diff --git a/Editor/editorfe/package-lock.json b/Editor/editorfe/package-lock.json index 30c192a9..5f5f0af6 100644 --- a/Editor/editorfe/package-lock.json +++ b/Editor/editorfe/package-lock.json @@ -22,7 +22,8 @@ }, "devDependencies": { "vite": "^7.0.0" - } + }, + "license": "Apache-2.0" }, "node_modules/@codemirror/autocomplete": { "version": "6.20.3", diff --git a/Editor/editorfe/package.json b/Editor/editorfe/package.json index be645548..7956005b 100644 --- a/Editor/editorfe/package.json +++ b/Editor/editorfe/package.json @@ -25,5 +25,6 @@ }, "devDependencies": { "vite": "^7.0.0" - } + }, + "license": "Apache-2.0" } diff --git a/Editor/editorfe/src/dataAPICatalog.d.ts b/Editor/editorfe/src/dataAPICatalog.d.ts index 343701a8..883a1546 100644 --- a/Editor/editorfe/src/dataAPICatalog.d.ts +++ b/Editor/editorfe/src/dataAPICatalog.d.ts @@ -1,11 +1,11 @@ export type DataAPIValue = null | boolean | number | string | DataAPIValue[] | { [key: string]: DataAPIValue }; export interface DataAPI { id: string; - group: "device" | "system" | "health" | "location" | "calendar" | "reminders" | "photos" | "services" | "music"; + group: "device" | "system" | "health" | "location" | "calendar" | "reminders" | "photos" | "services" | "music" | "notifications" | "maps" | "weather" | "alarms" | "documents" | "contacts" | "home"; value: DataAPIValue; legacy?: string[]; platforms: ("ios" | "macos")[]; - authorization: "none" | "healthRead" | "locationWhenInUse" | "calendarRead" | "remindersRead" | "remindersWrite" | "photosRead" | "serviceAccount" | "musicRead"; + authorization: "none" | "healthRead" | "locationWhenInUse" | "calendarRead" | "remindersRead" | "remindersWrite" | "photosRead" | "serviceAccount" | "musicRead" | "systemAccess"; notes: string; arguments: string[]; asynchronous: boolean; diff --git a/Editor/editorfe/src/dataAPICatalog.js b/Editor/editorfe/src/dataAPICatalog.js index 9ea86dca..79c5d104 100644 --- a/Editor/editorfe/src/dataAPICatalog.js +++ b/Editor/editorfe/src/dataAPICatalog.js @@ -1,3 +1,4 @@ +import { systemAPICatalog } from "./systemAPICatalog.js"; // Descriptive data API metadata, shared by Studio completion and Web mocks. // Native JSExport protocols remain authoritative. This catalog grants no access. const sampleStart = "2026-01-01T00:00:00Z"; @@ -67,7 +68,7 @@ const groupPolicy = { health: { platforms: ["ios"], authorization: "healthRead", notes: "Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain." }, location: { platforms: ["ios"], authorization: "locationWhenInUse", notes: "Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale." }, }; -export const dataAPICatalog = samples.map((sample) => { +export const dataAPICatalog = [...samples.map((sample) => { const method = sample.id.split(".")[1]; const asynchronous = (sample.group === "music" && method === "current") || sample.group === "services" || (["calendar", "reminders", "photos"].includes(sample.group) && !["isAvailable", "authorizationStatus"].includes(method)) || (sample.group === "health" && !["isAvailable", "authorizationStatus"].includes(method)) || (sample.group === "location" && ["current", "requestAuthorization"].includes(method)); @@ -83,4 +84,4 @@ export const dataAPICatalog = samples.map((sample) => { operation: sample.group === "reminders" && ["create", "update", "setCompleted"].includes(method) ? "write" : method === "requestAuthorization" ? "authorization" : ["isAvailable", "authorizationStatus", "isAuthorizedForWidgetUpdates"].includes(method) ? "availability" : "read", mock: "editable", }; -}); +}), ...systemAPICatalog]; diff --git a/Editor/editorfe/src/scriptWidgetAPI.js b/Editor/editorfe/src/scriptWidgetAPI.js index 492fa819..11e4708e 100644 --- a/Editor/editorfe/src/scriptWidgetAPI.js +++ b/Editor/editorfe/src/scriptWidgetAPI.js @@ -6,7 +6,7 @@ import { dataAPICatalog } from "./dataAPICatalog.js"; // authority; tests verify that this metadata stays aligned with it. export const scriptWidgetAPI = { "schemaVersion": 1, - "runtimeVersion": "1.5", + "runtimeVersion": "1.6", "documentation": "Public JSX surface shared by ScriptWidget Runtime and Studio.", "platforms": { "ios": "16.0", @@ -68,6 +68,7 @@ export const scriptWidgetAPI = { ...Object.fromEntries(storageAPICatalog.map((api) => [api.id, api])), ...Object.fromEntries(dataAPICatalog.map((api) => [api.id, { documentation: api.notes, + minimumRuntimeVersion: api.minimumRuntimeVersion, arguments: api.arguments, returns: api.asynchronous ? "Promise" : typeof api.value === "object" ? "json" : typeof api.value, }])), @@ -75,7 +76,7 @@ export const scriptWidgetAPI = { "$icloud.writeJSON": {"documentation": "Save a new immutable JSON revision locally from a user action. Requires the revision from readJSON. Background exchange is eventual.", "arguments": ["name", "value", "expectedRevision"], "returns": "Promise", "minimumRuntimeVersion": "1.5"}, "$icloud.resolveJSON": {"documentation": "Explicitly resolve all observed conflicting heads into a new revision. Stale tokens fail; originals remain.", "arguments": ["name", "value", "expectedRevision"], "returns": "Promise", "minimumRuntimeVersion": "1.5"}, "$icloud.sync": {"documentation": "Exchange materialized revisions with iCloud; requires a user action. Upload completion is unknown.", "arguments": [], "returns": "Promise", "minimumRuntimeVersion": "1.5"}, - "$icloud.status": {"documentation": "Read native connection state. Cloud store IDs are granted in the app, never by the script. Web uses preview mocks.", "arguments": [], "returns": "Promise", "minimumRuntimeVersion": "1.5"}, + "$icloud.status": {"documentation": "Read native connection state. In the app, explicitly connect packages to separate stores for isolation or the same store ID to share JSON documents. Scripts cannot choose store IDs. Sync is eventual; local $storage is not migrated. Web uses preview mocks.", "arguments": [], "returns": "Promise", "minimumRuntimeVersion": "1.5"}, "$file.exists": { "documentation": "Return whether a regular file is locally present inside this package, including binary assets. Missing files, directories, unsafe paths and links return false. Does not download iCloud files or read outside the package. Web preview uses workspace file presence.", "arguments": ["path"], "returns": "boolean", "minimumRuntimeVersion": "1.3" }, "$file.read": { "documentation": "Read package-relative UTF-8 text. Missing or unavailable files return an empty string.", "arguments": ["path"], "returns": "string" }, "$file.readJSON": { "documentation": "Read a package-relative JSON object.", "arguments": ["path"], "returns": "json" }, diff --git a/Editor/editorfe/src/systemAPICatalog.js b/Editor/editorfe/src/systemAPICatalog.js new file mode 100644 index 00000000..73a003e7 --- /dev/null +++ b/Editor/editorfe/src/systemAPICatalog.js @@ -0,0 +1,636 @@ +// Runtime 1.6 system capabilities; metadata never grants native access. +export const systemAPICatalog = [ + { + "id": "$notifications.status", + "group": "notifications", + "value": { + "authorization": "authorized" + }, + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$notifications.pending", + "group": "notifications", + "value": [], + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$notifications.schedule", + "group": "notifications", + "value": { + "key": "daily", + "status": "scheduled" + }, + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$notifications.cancel", + "group": "notifications", + "value": { + "key": "daily", + "status": "cancellationRequested" + }, + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "key" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$health.dailyStatistics", + "group": "health", + "value": { + "metric": "steps", + "unit": "count", + "aggregation": "sum", + "timeZone": "UTC", + "items": [ + { + "date": "2026-01-01", + "value": 6840, + "hasSamples": true + } + ] + }, + "platforms": [ + "ios" + ], + "authorization": "healthRead", + "notes": "Runtime 1.6. Read-only daily HealthKit statistics on installed iPhone/iPad widgets. Declare health and minimumRuntimeVersion 1.6, review Health access in native Settings. No separate System Access toggle. Missing readings are null/hasSamples false and cannot establish read denial. No raw samples, persistence or queries in future/Live Activity presentations. Preview fixtures never access real Health data.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$calendar.create", + "group": "calendar", + "value": { + "id": "sample.event", + "calendarID": "sample.calendar", + "status": "applied", + "replayed": false + }, + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$calendar.update", + "group": "calendar", + "value": { + "id": "sample.event", + "calendarID": "sample.calendar", + "status": "applied", + "replayed": false + }, + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$weather.forecast", + "group": "weather", + "value": { + "provider": "MET Norway", + "attribution": { + "text": "Weather data from MET Norway", + "url": "https://www.met.no/en/free-meteorological-data/Download-services" + }, + "latitude": 37.33, + "longitude": -122.01, + "fetchedAt": "2026-01-01T12:00:00Z", + "isStale": false, + "hours": [ + { + "time": "2026-01-01T12:00:00Z", + "temperatureC": 21, + "windMetersPerSecond": 2, + "precipitationMM": 0, + "condition": "partlycloudy_day" + } + ] + }, + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeWeather.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$alarms.status", + "group": "alarms", + "value": { + "authorization": "authorized" + }, + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$alarms.pending", + "group": "alarms", + "value": [], + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$alarms.schedule", + "group": "alarms", + "value": { + "key": "focus", + "status": "scheduled", + "replayed": false + }, + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$alarms.cancel", + "group": "alarms", + "value": { + "key": "focus", + "status": "requested" + }, + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "key" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$alarms.stop", + "group": "alarms", + "value": { + "key": "focus", + "status": "requested" + }, + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "key" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$alarms.pause", + "group": "alarms", + "value": { + "key": "focus", + "status": "requested" + }, + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "key" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$alarms.resume", + "group": "alarms", + "value": { + "key": "focus", + "status": "requested" + }, + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "key" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$documents.list", + "group": "documents", + "value": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "name": "Sample.json", + "type": "json", + "bytes": 17 + }, + { + "id": "550e8400-e29b-41d4-a716-446655440001", + "name": "Sample.csv", + "type": "csv", + "bytes": 24 + } + ], + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$documents.readJSON", + "group": "documents", + "value": { + "goal": 12, + "done": 7 + }, + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "id" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$documents.readCSV", + "group": "documents", + "value": { + "headers": [ + "day", + "value" + ], + "rows": [ + [ + "Monday", + "7" + ], + [ + "Tuesday", + "9" + ] + ], + "truncated": false + }, + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "id" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$contacts.selected", + "group": "contacts", + "value": [ + { + "id": "sample.contact", + "name": "Alex Example", + "organization": "Sample", + "phones": [ + "+1 202 555 0100" + ], + "emails": [ + "alex@example.com" + ] + } + ], + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeContacts.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$maps.search", + "group": "maps", + "value": [ + { + "name": "Example Park", + "address": "Sample address", + "latitude": 37.33, + "longitude": -122.01 + } + ], + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$maps.geocode", + "group": "maps", + "value": [ + { + "name": "Example Park", + "address": "Sample address", + "latitude": 37.33, + "longitude": -122.01 + } + ], + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "address" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$maps.reverseGeocode", + "group": "maps", + "value": [ + { + "name": "Example Park", + "address": "Sample address", + "latitude": 37.33, + "longitude": -122.01 + } + ], + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$maps.snapshot", + "group": "maps", + "value": { + "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4z8DwHwAFgAI/ScLbtAAAAABJRU5ErkJggg==", + "width": 256, + "height": 256, + "provider": "Apple Maps" + }, + "platforms": [ + "ios", + "macos" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$home.items", + "group": "home", + "value": [ + { + "id": "sample.light", + "name": "Living Room Lamp", + "kind": "power", + "value": true, + "isCached": true, + "metric": "power", + "unit": "boolean" + }, + { + "id": "scene-sample", + "name": "Evening", + "kind": "scene", + "value": null, + "isCached": true, + "metric": "scene", + "unit": "none" + } + ], + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift", + "operation": "read", + "mock": "editable" + }, + { + "id": "$home.setPower", + "group": "home", + "value": { + "id": "sample.light", + "value": true, + "status": "acknowledged" + }, + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift", + "operation": "write", + "mock": "editable" + }, + { + "id": "$home.runScene", + "group": "home", + "value": { + "id": "scene-sample", + "status": "acknowledged", + "replayed": false + }, + "platforms": [ + "ios" + ], + "authorization": "systemAccess", + "notes": "Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.", + "arguments": [ + "options" + ], + "asynchronous": true, + "minimumRuntimeVersion": "1.6", + "nativeSource": "Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift", + "operation": "write", + "mock": "editable" + } +]; diff --git a/Editor/editorfe/test/dataAPICatalog.test.js b/Editor/editorfe/test/dataAPICatalog.test.js index 7fa19f71..81ebf09c 100644 --- a/Editor/editorfe/test/dataAPICatalog.test.js +++ b/Editor/editorfe/test/dataAPICatalog.test.js @@ -7,7 +7,7 @@ import { scriptWidgetAPI } from "../src/scriptWidgetAPI.js"; test("editor metadata uses the native public API version rather than an app version", async () => { const source = await readFile(new URL("../../../Shared/ScriptWidgetRuntime/Common/ScriptWidgetPackage.swift", import.meta.url), "utf8"); assert.ok(source.includes(`static let nativeRuntimeAPIVersion = "${scriptWidgetAPI.runtimeVersion}"`)); - for (const api of dataAPICatalog) assert.ok(["1.0", "1.3", "1.4"].includes(api.minimumRuntimeVersion)); + for (const api of dataAPICatalog) assert.ok(["1.0", "1.3", "1.4", "1.6"].includes(api.minimumRuntimeVersion)); }); test("data catalog exactly covers native JSExport data methods and Promise semantics", async () => { @@ -26,7 +26,7 @@ test("data catalog exactly covers native JSExport data methods and Promise seman assert.ok(scriptWidgetAPI.functions[entry.id], `${entry.id} missing from completion metadata`); assert.ok(entry.notes.length > 20); assert.ok(entry.platforms.length); - assert.ok(["none", "healthRead", "locationWhenInUse", "calendarRead", "remindersRead", "remindersWrite", "photosRead", "serviceAccount", "musicRead"].includes(entry.authorization)); + assert.ok(["none", "healthRead", "locationWhenInUse", "calendarRead", "remindersRead", "remindersWrite", "photosRead", "serviceAccount", "musicRead", "systemAccess"].includes(entry.authorization)); assert.ok(["availability", "authorization", "read", "write"].includes(entry.operation)); assert.equal(entry.mock, "editable"); assert.notEqual(JSON.stringify(entry.value), undefined, entry.id); diff --git a/README.md b/README.md index 7f187550..f09f36d0 100644 --- a/README.md +++ b/README.md @@ -413,3 +413,6 @@ Inspired by: **Project Link:** [https://github.com/everettjf/ScriptWidget](https://github.com/everettjf/ScriptWidget) +## System capabilities under development + +Runtime 1.6 adds opt-in notifications, HealthKit daily history, owned calendar writes, normalized forecasts, AlarmKit timers, imported JSON/CSV, selected contacts, MapKit places/snapshots and selected HomeKit controls. Native user grants and OS permissions are separate from exported widgets; Web Studio offers isolated editable mocks. See the [contracts, nine examples and device acceptance checklist](docs/system-services-api.md). Physical-device verification is required before release. diff --git a/README_CN.md b/README_CN.md index f3f7f485..108a810f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -85,3 +85,7 @@ ScriptWidget 仓库中的源代码使用 [Apache 2.0 License](LICENSE) 发布。 ScriptWidget 名称、Logo、截图与 App Store 商店宣传素材不包含在 Apache 2.0 许可范围内;这些品牌及宣传资产的权利归各自权利人所有。 [Discord](https://discord.gg/eGzEaP6TzR) + +## 正在开发的系统能力 + +Runtime 1.6 新增通知提醒、健康历史、日历写入、天气、闹钟、文件导入、联系人、地图和 HomeKit。每个组件独立授权,Web Studio 提供隔离的模拟数据。[API 文档、九个示例及真机验收清单](docs/system-services-api.md)。当前仍需完成真机验收后再发布。 diff --git a/Scripts/release-readiness.sh b/Scripts/release-readiness.sh index ff0ae4a6..b44e07d1 100755 --- a/Scripts/release-readiness.sh +++ b/Scripts/release-readiness.sh @@ -37,6 +37,7 @@ if [ "${SCRIPTWIDGET_SKIP_XCODE:-0}" != "1" ]; then node Scripts/test-service-authorization.mjs node Scripts/test-storage-atomic.mjs node Scripts/test-icloud-json.mjs + node Scripts/test-system-services.mjs node Scripts/test-storage-files.mjs sh Scripts/macos-widget-link-tests.sh xcodebuild -quiet -project macOS/ScriptWidgetMac.xcodeproj -scheme ScriptWidgetRuntimeTests \ diff --git a/Scripts/test-icloud-json.mjs b/Scripts/test-icloud-json.mjs index 3a97a768..d34235c4 100644 --- a/Scripts/test-icloud-json.mjs +++ b/Scripts/test-icloud-json.mjs @@ -27,7 +27,7 @@ suite.run() guard let result = suite.testRun, result.executionCount >= 10, result.totalFailureCount == 0 else { exit(1) } `); const binary = join(temporary, "tests"); - await exec("xcrun", ["swiftc", "-F", frameworks, "-I", libraries, "-L", libraries, + await exec("xcrun", ["swiftc", "-D", "SCRIPTWIDGET_CLI", "-F", frameworks, "-I", libraries, "-L", libraries, ...[frameworks, libraries, join(platform, "Library/PrivateFrameworks"), resolve(developer, "../SharedFrameworks")] .flatMap(path => ["-Xlinker", "-rpath", "-Xlinker", path]), ...["Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetStorageLock.swift", diff --git a/Scripts/test-system-services.mjs b/Scripts/test-system-services.mjs new file mode 100644 index 00000000..2ecf755e --- /dev/null +++ b/Scripts/test-system-services.mjs @@ -0,0 +1,31 @@ +// Compile production pure validators/grants and their actual XCTest cases. +// No app host, account, HealthKit query, network or system write is invoked. +import {execFile} from "node:child_process"; +import {promisify} from "node:util"; +import {mkdtemp,readFile,writeFile,rm} from "node:fs/promises"; +import {tmpdir} from "node:os"; +import {join,resolve} from "node:path"; +import {fileURLToPath} from "node:url"; +const exec=promisify(execFile), repo=fileURLToPath(new URL("..",import.meta.url)); +const temporary=await mkdtemp(join(tmpdir(),"scriptwidget-system-tests-")); +const read=path=>readFile(resolve(repo,path),"utf8"); +function section(source,start,end){const a=source.indexOf(start),b=end?source.indexOf(end,a):source.length;if(a<0||b<=a)throw Error(`Source boundary changed: ${start}`);return source.slice(a,b);} +try{ + const developer=(await exec("xcode-select",["-p"])).stdout.trim(); + const platform=join(developer,"Platforms/MacOSX.platform/Developer"),frameworks=join(platform,"Library/Frameworks"),libraries=join(platform,"usr/lib"); + const services=await read("Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystemServices.swift"); + const packages=await read("Shared/ScriptWidgetRuntime/Common/ScriptWidgetPackage.swift"); + let helpers="import Foundation\nimport Darwin\nimport CryptoKit\n"+section(packages,"enum ScriptWidgetMetadataFile {","/// Keeps private execution resources") + +section(services,"enum ScriptWidgetSystemServiceError:","struct ScriptWidgetSystemServiceContext") + +section(services,"enum ScriptWidgetSystemOptions {","protocol ScriptWidgetSystemMutationRequest") + +section(services,"protocol ScriptWidgetSystemMutationRequest {","extension ScriptWidgetReminderMutation") + +section(services,"struct ScriptWidgetNativeMutation:",null); + for(const [file,start,end] of [["Notifications","struct ScriptWidgetNotificationOptions","@objc protocol"],["CalendarWrites","struct ScriptWidgetCalendarMutation","enum ScriptWidgetRuntimeCalendarWrites"],["HealthHistory","struct ScriptWidgetHealthHistoryOptions","enum ScriptWidgetRuntimeHealthHistory"],["Alarms","struct ScriptWidgetAlarmOptions","@objc protocol"],["Documents","enum ScriptWidgetDocumentData","@objc protocol"],["Weather","struct ScriptWidgetWeatherOptions","@objc protocol"]])helpers+=section(await read(`Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntime${file}.swift`),start,end); + await writeFile(join(temporary,"helpers.swift"),helpers); + const testSource=(await read("Tests/ScriptWidgetRuntimeTests/SystemServiceTests.swift")).replace("@testable import ScriptWidget",""); + await writeFile(join(temporary,"main.swift"),testSource+`\nlet suite=SystemServiceTests.defaultTestSuite\nsuite.run()\nguard let run=suite.testRun,run.executionCount>=8,run.totalFailureCount==0 else {exit(1)}\n`); + const binary=join(temporary,"tests"); + await exec("xcrun",["swiftc","-D","SCRIPTWIDGET_CLI","-F",frameworks,"-I",libraries,"-L",libraries,...[frameworks,libraries,join(platform,"Library/PrivateFrameworks"),resolve(developer,"../SharedFrameworks")].flatMap(p=>["-Xlinker","-rpath","-Xlinker",p]), + ...["Widget/API/ScriptWidgetStorageLock.swift","Widget/API/ScriptWidgetStorageNamespaces.swift","Widget/API/ScriptWidgetStorageFiles.swift","Common/ScriptWidgetCloudJSON.swift"].map(p=>resolve(repo,"Shared/ScriptWidgetRuntime",p)),join(temporary,"helpers.swift"),join(temporary,"main.swift"),"-o",binary],{timeout:60000}); + const result=await exec(binary,[],{timeout:30000});process.stdout.write(result.stdout+result.stderr); +}catch(error){process.stderr.write(error.stdout??"");process.stderr.write(error.stderr??"");throw error;}finally{await rm(temporary,{recursive:true,force:true});} diff --git a/Shared/ScriptWidgetRuntime/AI/PromptBuilder.swift b/Shared/ScriptWidgetRuntime/AI/PromptBuilder.swift index 32740135..0d7b71fe 100644 --- a/Shared/ScriptWidgetRuntime/AI/PromptBuilder.swift +++ b/Shared/ScriptWidgetRuntime/AI/PromptBuilder.swift @@ -219,6 +219,27 @@ enum PromptBuilder { query/prompt from future entries or Live Activity presentations. Health Overview supports overview/sleep/activity/workouts parameters; Web Studio supplies editable simulated aggregates, not native access. + Runtime 1.6 adds $notifications.status/pending/schedule/cancel, + $alarms.status/pending/schedule/cancel/stop/pause/resume, + $calendar.create/update, $health.dailyStatistics, + $documents.list/readJSON/readCSV, $contacts.selected, + $maps.search/geocode/reverseGeocode/snapshot, + $weather.forecast and $home.items/setPower/runScene. + These require Package 2.0 minimumRuntimeVersion 1.6. Declare the + matching permission; Calendar writes also require calendarWrite. + Weather requires weather, network and api.met.no; return and display + provider attribution. New capabilities need native per-widget System + Access except Health, which uses Health Settings review. Copies do + not inherit grants. All calls share eight queries and reject in future + entries/Live Activities; writes require explicit native user actions. + Persist a canonical requestID UUID before calendar/alarm/scene writes; + uncertain outcomes require inspection, never a blind new operation. + Native replay receipts are bounded and completed ones expire after + seven days. Documents use imported native UUIDs, never arbitrary paths. + Contacts/Home expose native selections only. Home values are cached, + and scene actions may require system authentication. AlarmKit needs + iOS/iPadOS 26; native macOS must show unavailable. Mocks do not prove + native authorization, system delivery or physical accessory state. 16. Location needs the location package permission and approval in the main app. Widget access is separate: use isAuthorizedForWidgetUpdates when explaining widget setup, never infer permission from cached data. diff --git a/Shared/ScriptWidgetRuntime/Common/ScriptManager.swift b/Shared/ScriptWidgetRuntime/Common/ScriptManager.swift index 9545df85..1da09ff2 100644 --- a/Shared/ScriptWidgetRuntime/Common/ScriptManager.swift +++ b/Shared/ScriptWidgetRuntime/Common/ScriptManager.swift @@ -1027,17 +1027,21 @@ final class ScriptManager: @unchecked Sendable { guard let scriptDirPath = self.getPackagePathFromPackageName(packageName: packageName) else { return false } let package = ScriptWidgetPackage(path: scriptDirPath) let deleteResult: Bool + var retiredOwner: String? if let storageContext { do { guard scriptDirectory.standardizedFileURL.resolvingSymlinksInPath() == storageContext.libraryRoot else { throw ScriptWidgetStorageNamespaceError.conflict } + retiredOwner = (try? storageContext.boundDirectory(name: packageName, role: .source))?.ownerID try storageContext.relocate(name: packageName) deleteResult = true } catch { return false } } else { deleteResult = package.delete() } if deleteResult { - NotificationCenter.default.post(name: Self.packageRemovedNotification, object: packageName) + var info: [String: Any] = [:] + if let retiredOwner, let storageContext { info = ["retiredOwner": retiredOwner, "storageContext": storageContext] } + NotificationCenter.default.post(name: Self.packageRemovedNotification, object: packageName, userInfo: info) } let deleteBuildResult = removeBuildScriptPackage(package: package) diff --git a/Shared/ScriptWidgetRuntime/Common/ScriptMetadata.swift b/Shared/ScriptWidgetRuntime/Common/ScriptMetadata.swift index a15c8f62..37a4fb37 100644 --- a/Shared/ScriptWidgetRuntime/Common/ScriptMetadata.swift +++ b/Shared/ScriptWidgetRuntime/Common/ScriptMetadata.swift @@ -60,6 +60,7 @@ enum WidgetPackagePermission: String, Codable, CaseIterable, Identifiable { case music case storage case icloud + case notifications, calendarWrite, maps, weather, alarms, documents, contacts, home case files var id: String { rawValue } @@ -306,6 +307,13 @@ enum WidgetPackageManifestValidator { error("unsupported_minimum_runtime", "This package requires a newer or incompatible ScriptWidget Runtime. Update the app before running it.") } } + let systemPermissions: Set = [.notifications, .calendarWrite, .maps, .weather, .alarms, .documents, .contacts, .home] + if manifest.permissions.contains(where: { systemPermissions.contains($0) }), !WidgetRuntimeRequirement.supports("1.6", current: manifest.minimumRuntimeVersion ?? "0.0") { + error("system_runtime", "System service capabilities require minimumRuntimeVersion 1.6 or later.") + } + if manifest.permissions.contains(.calendarWrite), !manifest.permissions.contains(.calendar) { + error("calendar_write_permission", "calendarWrite also requires calendar.") + } if manifest.permissions.contains(.icloud), !WidgetRuntimeRequirement.supports("1.5", current: manifest.minimumRuntimeVersion ?? "0.0") { error("icloud_runtime", "iCloud JSON requires minimumRuntimeVersion 1.5 or later.") } diff --git a/Shared/ScriptWidgetRuntime/Common/ScriptWidgetPackage.swift b/Shared/ScriptWidgetRuntime/Common/ScriptWidgetPackage.swift index 6fcfa8d5..99531954 100644 --- a/Shared/ScriptWidgetRuntime/Common/ScriptWidgetPackage.swift +++ b/Shared/ScriptWidgetRuntime/Common/ScriptWidgetPackage.swift @@ -433,7 +433,7 @@ struct ScriptWidgetBuildManifest: Codable, Equatable { enum ScriptWidgetBuildContract { static let runtimeAPIVersion = "1.0" - static let nativeRuntimeAPIVersion = "1.5" + static let nativeRuntimeAPIVersion = "1.6" static let compilerFingerprint = "scriptwidget-babel-v3" } @@ -852,8 +852,7 @@ enum ScriptWidgetPackageFiles { guard fstatat(sourceDirectory, sourceName, &info, AT_SYMLINK_NOFOLLOW) == 0, info.st_mode & S_IFMT == S_IFREG || info.st_mode & S_IFMT == S_IFDIR else { return false } if let expectedReceipt { - guard info.st_mode & S_IFMT == S_IFDIR, expectedReceipt.device == UInt64(UInt32(bitPattern: info.st_dev)), - expectedReceipt.inode == info.st_ino else { return false } + guard info.st_mode & S_IFMT == S_IFDIR, expectedReceipt.matches(parent: sourceDirectory, name: sourceName) else { return false } } return withParent(root: root, relative: destination) { destinationDirectory, destinationName in renameatx_np(sourceDirectory, sourceName, destinationDirectory, destinationName, UInt32(RENAME_EXCL)) == 0 @@ -881,7 +880,8 @@ enum ScriptWidgetPackageFiles { guard fstat(child, &opened) == 0, opened.st_dev == entry.st_dev, opened.st_ino == entry.st_ino else { return .failure(ScriptWidgetStorageNamespaceError.conflict) } - return .success(.init(device: UInt64(UInt32(bitPattern: opened.st_dev)), inode: opened.st_ino)) + do { return .success(try ScriptWidgetStoragePublicationReceipt.capture(directory: child)) } + catch { return .failure(error) } } guard let result else { throw ScriptWidgetStorageNamespaceError.unavailable } return try result.get() @@ -893,7 +893,7 @@ enum ScriptWidgetPackageFiles { var info = stat() guard fstatat(sourceParent, sourceName, &info, AT_SYMLINK_NOFOLLOW) == 0, info.st_mode & S_IFMT == S_IFDIR else { return false } if let expectedReceipt { - guard expectedReceipt.device == UInt64(UInt32(bitPattern: info.st_dev)), expectedReceipt.inode == info.st_ino else { return false } + guard expectedReceipt.matches(parent: sourceParent, name: sourceName) else { return false } } return withParent(root: root, relative: name) { parent, finalName in renameatx_np(sourceParent, sourceName, parent, finalName, UInt32(RENAME_EXCL)) == 0 @@ -908,8 +908,7 @@ enum ScriptWidgetPackageFiles { return withParent(root: source.deletingLastPathComponent(), relative: source.lastPathComponent) { sourceParent, sourceName in var prepared = stat() guard fstatat(sourceParent, sourceName, &prepared, AT_SYMLINK_NOFOLLOW) == 0, - prepared.st_mode & S_IFMT == S_IFDIR, expectedReceipt.device == UInt64(UInt32(bitPattern: prepared.st_dev)), - expectedReceipt.inode == prepared.st_ino else { return false } + prepared.st_mode & S_IFMT == S_IFDIR, expectedReceipt.matches(parent: sourceParent, name: sourceName) else { return false } return withParent(root: root, relative: name) { parent, finalName in var existing = stat() if fstatat(parent, finalName, &existing, AT_SYMLINK_NOFOLLOW) != 0 { @@ -932,8 +931,7 @@ enum ScriptWidgetPackageFiles { var info = stat() guard fstatat(parent, name, &info, AT_SYMLINK_NOFOLLOW) == 0 else { return false } if depth == 0, let expectedReceipt { - guard info.st_mode & S_IFMT == S_IFDIR, expectedReceipt.device == UInt64(UInt32(bitPattern: info.st_dev)), - expectedReceipt.inode == info.st_ino else { return false } + guard info.st_mode & S_IFMT == S_IFDIR, expectedReceipt.matches(parent: parent, name: name) else { return false } } if info.st_mode & S_IFMT == S_IFDIR { let child = openat(parent, name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC) @@ -974,7 +972,7 @@ enum ScriptWidgetPackageFiles { guard source >= 0 else { throw ScriptWidgetStorageNamespaceError.unavailable } defer { close(source) } var info = stat() - guard fstat(source, &info) == 0, UInt64(UInt32(bitPattern: info.st_dev)) == receipt.device, info.st_ino == receipt.inode else { + guard fstat(source, &info) == 0, try ScriptWidgetStoragePublicationReceipt.capture(directory: source) == receipt else { throw ScriptWidgetStorageNamespaceError.conflict } let target = open(destination.path, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC) diff --git a/Shared/ScriptWidgetRuntime/Common/ScriptWidgetSystemAccessView.swift b/Shared/ScriptWidgetRuntime/Common/ScriptWidgetSystemAccessView.swift new file mode 100644 index 00000000..8880b9ea --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Common/ScriptWidgetSystemAccessView.swift @@ -0,0 +1,149 @@ +import SwiftUI +import UniformTypeIdentifiers +import Contacts +import UserNotifications +#if os(iOS) && canImport(AlarmKit) +import AlarmKit +#endif + +struct ScriptWidgetSystemAccessView: View { + let package: ScriptWidgetPackage + @Environment(\.dismiss) private var dismiss + @State private var grant = ScriptWidgetSystemAccessGrant() + @State private var original = ScriptWidgetSystemAccessGrant() + @State private var message = "" + @State private var contacts: [ScriptWidgetContactChoice] = [] + @State private var home: [ScriptWidgetHomeChoice] = [] + @State private var importing = false + @State private var busy = false + static func supports(_ package: ScriptWidgetPackage) -> Bool { + package.readManifest()?.permissions.contains(where: { ScriptWidgetSystemAccessGrant.capabilities.contains($0.rawValue) }) == true + } + static func store(_ package: ScriptWidgetPackage) throws -> ScriptWidgetSystemAccessStore { + guard let scope = package.managedScope, let binding = scope.binding else { throw ScriptWidgetSystemServiceError.permissionDenied } + try scope.validate(name: package.name) + return .init(container: scope.context.container, owner: binding.ownerID, validate: { try scope.validate(name: package.name) }) + } + var body: some View { + NavigationStack { + Form { + Section("Access for This Widget") { + Text(package.name).font(.headline) + Text("Only enable capabilities you want this installed widget to use. Copies require their own access. System writes require a button or declared action.") + ForEach((package.readManifest()?.permissions ?? []).filter { ScriptWidgetSystemAccessGrant.capabilities.contains($0.rawValue) }, id: \.rawValue) { permission in + Toggle(Self.label(permission.rawValue), isOn: Binding(get: { grant.permissions.contains(permission.rawValue) }, set: { on in + grant.permissions.removeAll { $0 == permission.rawValue }; if on { grant.permissions.append(permission.rawValue) } + })) + } + Button("Save Access and Selections") { run { + let store = try Self.store(package); try store.save(grant, expected: original); reload(); ScriptWidgetSystemRefresh.request(); message = "Access saved. System authorization may also be required below." + } } + Text("Turning access off takes effect for subsequent system calls. It does not delete imported files or cancel previously scheduled notifications or alarms; cancel those before revoking access.").font(.footnote) + } + if declared("notifications") { + Section("Notifications") { + Button("Authorize Notifications") { + UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { granted, _ in DispatchQueue.main.async { message = granted ? "Notifications authorized." : "Notifications are not authorized." } } + } + } + } + if declared("alarms") { + Section("Alarms") { + #if os(iOS) && canImport(AlarmKit) + if #available(iOS 26.0, *) { + Button("Authorize Alarms") { Task { do { let status = try await AlarmManager.shared.requestAuthorization(); message = "Alarm authorization: \(String(describing: status))" } catch { message = "Alarm authorization could not complete." } } } + } else { Text("Alarms require iOS or iPadOS 26 or later.") } + #else + Text("AlarmKit is unavailable on this platform.") + #endif + } + } + if declared("documents") { + Section("Imported Data Files") { + Text("Import JSON or CSV as a private copy, up to 256 KiB per file and eight files per widget. The original file is never modified. Reimport to capture later edits.") + Button("Import JSON or CSV") { importing = true } + .disabled(!original.permissions.contains("documents")) + ForEach(grant.documents, id: \.id) { item in + VStack(alignment: .leading) { Text(item.name); Text("\(item.type) · \(item.bytes) bytes · \(item.id)").font(.caption).textSelection(.enabled) } + } + Text("File identifiers are available through $documents.list().") + } + } + if declared("contacts") { + Section("Selected Contacts") { + Text("The widget can read names, organization, up to three phone numbers and three email addresses for selected contacts only. The picker lists up to 200 contacts the system shares with this app; at most 20 can be selected.") + Button("Authorize and Load Contacts") { + CNContactStore().requestAccess(for: .contacts) { allowed, _ in + ScriptWidgetSystemServices.queue.async { + let values = allowed ? (try? ScriptWidgetContactProvider.choices()) ?? [] : [] + DispatchQueue.main.async { contacts = values; message = allowed ? "Choose contacts and save access." : "Contacts are not authorized." } + } + } + } + ForEach(contacts) { item in Toggle(item.name, isOn: selection(\.contacts, id: item.id)) } + } + } + if declared("home") { + Section("Selected Home Accessories and Scenes") { + Text("Selected power controls can be switched by explicit actions. Selected scenes may also operate locks, doors or other accessories according to your Home configuration; choose only scenes you trust this widget to run. Sensor readings are cached HomeKit values, not guaranteed live readings.") + #if os(iOS) + Button("Authorize and Load Home") { + ScriptWidgetHomeProvider.shared.load { result in + switch result { case .success(let values): home = values; message = "Choose items and save access."; case .failure: message = "Home could not be loaded. Check system authorization, then retry." } + } + } + ForEach(home) { item in Toggle("\(item.name) (\(item.kind))", isOn: selection(\.home, id: item.id)) } + #else + Text("Native HomeKit access is currently supported on iPhone and iPad.") + #endif + } + } + if declared("calendarWrite") { Section("Calendar Writes") { Text("Authorize Calendar and select calendars in app Settings. This API creates single events and updates only events this installation created. Recurring-event edits and deletion are not exposed.") } } + if declared("maps") || declared("weather") { Section("Network Services") { Text("Map requests send the supplied place or coordinate to Apple Maps. Weather sends rounded coordinates to MET Norway and also requires network permission for api.met.no. No current device location is read automatically.") } } + if !message.isEmpty { Section { Text(message).accessibilityIdentifier("system-access-message") } } + } + .disabled(busy) + .navigationTitle("System Access") + .toolbar { ToolbarItem(placement: .confirmationAction) { Button("Done") { dismiss() } } } + .task { reload() } + .fileImporter(isPresented: $importing, allowedContentTypes: [.json, .commaSeparatedText], allowsMultipleSelection: false) { result in + run { + let url = try result.get().first! + let opened = url.startAccessingSecurityScopedResource(); defer { if opened { url.stopAccessingSecurityScopedResource() } } + let keys = try url.resourceValues(forKeys: [.isRegularFileKey, .isSymbolicLinkKey, .fileSizeKey]) + guard keys.isRegularFile == true, keys.isSymbolicLink != true, let size = keys.fileSize, size <= 262144 else { throw ScriptWidgetSystemServiceError.invalidOptions } + let data = try ScriptWidgetDocumentData.importedFile(url) + guard data.count <= 262144 else { throw ScriptWidgetSystemServiceError.limitExceeded } + let type = url.pathExtension.lowercased() + if type == "json" { _ = try ScriptWidgetDocumentData.json(data) } + else if type == "csv" { _ = try ScriptWidgetDocumentData.csv(data) } + else { throw ScriptWidgetSystemServiceError.invalidOptions } + let store = try Self.store(package) + let before = try store.load(); var next = before + guard before.permissions.contains("documents"), before.documents.count < 8 else { throw ScriptWidgetSystemServiceError.permissionDenied } + let id = UUID().uuidString.lowercased() + next.documents.append(.init(id: id, name: String(url.lastPathComponent.prefix(80)), type: type, bytes: data.count)) + try store.validate() + guard ScriptWidgetPackageFiles.write(data, root: store.container, relative: store.directory + "/documents/" + id) else { throw ScriptWidgetSystemServiceError.unavailable } + try store.save(next, expected: before) + reload(); message = "Imported a private data copy. The original file is unchanged." + } + } + } + #if os(macOS) + .frame(minWidth: 560, minHeight: 600) + #endif + } + private static func label(_ name: String) -> String { + ["notifications":"Schedule local notifications", "calendarWrite":"Create and update this widget’s events", "maps":"Look up places and generate maps", "weather":"Fetch weather for supplied coordinates", "alarms":"Schedule alarms and timers", "documents":"Read imported JSON and CSV copies", "contacts":"Read selected contacts", "home":"Read and control selected Home items"][name] ?? name + } + private func declared(_ name: String) -> Bool { package.readManifest()?.permissions.contains(where: { $0.rawValue == name }) == true } + private func selection(_ path: WritableKeyPath, id: String) -> Binding { + Binding(get: { grant[keyPath: path].contains(id) }, set: { on in + grant[keyPath: path].removeAll { $0 == id } + if on && grant[keyPath: path].count < 20 { grant[keyPath: path].append(id) } + }) + } + private func reload() { do { let value = try Self.store(package).load(); grant = value; original = value } catch { message = ScriptWidgetSystemServices.safeError(error) } } + private func run(_ work: () throws -> Void) { do { try work() } catch { message = ScriptWidgetSystemServices.safeError(error) } } +} diff --git a/Shared/ScriptWidgetRuntime/Resource/widget.schema.json b/Shared/ScriptWidgetRuntime/Resource/widget.schema.json index afb4b19a..d9cdc1e2 100644 --- a/Shared/ScriptWidgetRuntime/Resource/widget.schema.json +++ b/Shared/ScriptWidgetRuntime/Resource/widget.schema.json @@ -27,7 +27,7 @@ }, "permissions": { "type": "array", "uniqueItems": true, - "items": { "enum": ["network", "location", "health", "calendar", "reminders", "remindersWrite", "photos", "services", "music", "storage", "icloud", "files"] } + "items": { "enum": ["network", "location", "health", "calendar", "reminders", "remindersWrite", "photos", "services", "music", "storage", "icloud", "notifications", "calendarWrite", "maps", "weather", "alarms", "documents", "contacts", "home", "files"] } }, "networkDomains": { "type": "array", "uniqueItems": true, diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift new file mode 100644 index 00000000..f6331dcb --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift @@ -0,0 +1,120 @@ +import Foundation +import JavaScriptCore +#if os(iOS) && canImport(AlarmKit) +import AlarmKit +import SwiftUI +#endif + +struct ScriptWidgetAlarmOptions { + let key: String + let title: String + let date: Date? + let seconds: Double? + init(_ options: [String: Any], now: Date = Date()) throws { + try ScriptWidgetSystemOptions.fields(options, ["requestID", "key", "title", "date", "seconds"]) + key = try ScriptWidgetSystemOptions.text(options["key"], maximum: 64) + guard ScriptWidgetSystemOptions.validKey(key), (options["date"] == nil) != (options["seconds"] == nil) else { throw ScriptWidgetSystemServiceError.invalidOptions } + title = try ScriptWidgetSystemOptions.text(options["title"], maximum: 128) + date = try options["date"].map(ScriptWidgetSystemOptions.date) + seconds = try options["seconds"].map { try ScriptWidgetSystemOptions.number($0, range: 60...86400) } + if let date { guard date > now, date.timeIntervalSince(now) <= 366 * 86400 else { throw ScriptWidgetSystemServiceError.invalidOptions } } + } + static func id(owner: String, key: String) throws -> UUID { + guard ScriptWidgetSystemOptions.validKey(key), UUID(uuidString: owner) != nil else { throw ScriptWidgetSystemServiceError.invalidOptions } + let hex = Array(ScriptWidgetCloudJSONStore.hash(Data((owner + ":alarm:" + key).utf8)).prefix(32)) + return UUID(uuidString: String(hex[0..<8]) + "-" + String(hex[8..<12]) + "-" + String(hex[12..<16]) + "-" + String(hex[16..<20]) + "-" + String(hex[20..<32]))! + } +} +@objc protocol ScriptWidgetRuntimeAlarmsExports: JSExport { + static func status() -> ScriptWidgetRuntimePromise + static func pending() -> ScriptWidgetRuntimePromise + static func schedule(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise + static func cancel(_ key: String) -> ScriptWidgetRuntimePromise + static func stop(_ key: String) -> ScriptWidgetRuntimePromise + static func pause(_ key: String) -> ScriptWidgetRuntimePromise + static func resume(_ key: String) -> ScriptWidgetRuntimePromise +} +@objc final class ScriptWidgetRuntimeAlarms: NSObject, ScriptWidgetRuntimeAlarmsExports { + static func status() -> ScriptWidgetRuntimePromise { run("status") } + static func pending() -> ScriptWidgetRuntimePromise { run("pending") } + static func schedule(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { run("schedule", options ?? [:]) } + static func cancel(_ key: String) -> ScriptWidgetRuntimePromise { run("cancel", ["key": key]) } + static func stop(_ key: String) -> ScriptWidgetRuntimePromise { run("stop", ["key": key]) } + static func pause(_ key: String) -> ScriptWidgetRuntimePromise { run("pause", ["key": key]) } + static func resume(_ key: String) -> ScriptWidgetRuntimePromise { run("resume", ["key": key]) } + static func retire(owner: String, backend: any ScriptWidgetStorageBackend) { + #if os(iOS) && canImport(AlarmKit) + if #available(iOS 26.0, *) { + guard let keys = try? ScriptWidgetSystemAccessStore.readNativeValue([String].self, key: "ScriptWidget.SystemServices.alarmKeys.v1." + owner, backend: backend), keys.count <= 32 else { return } + for key in keys where ScriptWidgetSystemOptions.validKey(key) { + if let id = try? ScriptWidgetAlarmOptions.id(owner: owner, key: key) { try? AlarmManager.shared.cancel(id: id) } + } + } + #endif + } + private static func run(_ method: String, _ options: [String: Any] = [:]) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.alarms, writing: !["status", "pending"].contains(method)) { context, finish in + #if os(iOS) && canImport(AlarmKit) + guard #available(iOS 26.0, *) else { throw ScriptWidgetSystemServiceError.unavailable } + let manager = AlarmManager.shared + if method == "status" { finish(.success(["authorization": String(describing: manager.authorizationState)])); return } + guard manager.authorizationState == .authorized else { throw ScriptWidgetSystemServiceError.permissionDenied } + let backend = context.state.executionSnapshot!.context.defaults + let indexKey = context.access.privateKey("alarmKeys") + guard let operationResult = ScriptWidgetStorageLock.withExclusiveAccess(container: context.access.container, namespace: indexKey, operation: { Result { + guard backend.synchronize() else { throw ScriptWidgetSystemServiceError.unavailable } + let keys = try ScriptWidgetSystemAccessStore.readNativeValue([String].self, key: indexKey, backend: backend) ?? [] + guard keys.count <= 32, keys.allSatisfy(ScriptWidgetSystemOptions.validKey), Set(keys).count == keys.count else { throw ScriptWidgetSystemServiceError.unavailable } + if method == "pending" { + let alarms = try manager.alarms + let rows = try keys.compactMap { key -> [String: Any]? in + let id = try ScriptWidgetAlarmOptions.id(owner: context.owner, key: key) + guard let alarm = alarms.first(where: { $0.id == id }) else { return nil } + return ["key": key, "state": String(describing: alarm.state)] + } + return rows + } + let key = try ScriptWidgetSystemOptions.text(options["key"], maximum: 64) + let id = try ScriptWidgetAlarmOptions.id(owner: context.owner, key: key) + if method != "schedule" { + try context.validate() + switch method { case "cancel": try manager.cancel(id: id); case "stop": try manager.stop(id: id); case "pause": try manager.pause(id: id); default: try manager.resume(id: id) } + return ["key": key, "status": "requested"] + } + let value = try ScriptWidgetAlarmOptions(options) + let request = try ScriptWidgetNativeMutation(options, scope: "alarms", operation: "schedule") + let ledgerKey = context.access.privateKey("alarmReceipts") + let result = try ScriptWidgetReminderMutationLedger.perform(request, container: context.access.container, backend: backend, key: ledgerKey, validate: context.validate) { beforeCommit in + guard keys.contains(key) || keys.count < 32 else { throw ScriptWidgetSystemServiceError.limitExceeded } + // Never silently replace a running alarm. Cancel explicitly first. + guard try !manager.alarms.contains(where: { $0.id == id }) else { throw ScriptWidgetSystemServiceError.staleRequest } + try ScriptWidgetSystemAccessStore.writeNativeValue(Array(Set(keys + [key])).sorted(), key: indexKey, backend: backend) + guard backend.synchronize() else { throw ScriptWidgetSystemServiceError.unavailable } + try beforeCommit() + let box = ScriptWidgetSystemCompletionBox() + Task { + do { + try context.validate() + let alert = AlarmPresentation.Alert(title: LocalizedStringResource(stringLiteral: value.title), stopButton: AlarmButton(text: "Stop", textColor: .white, systemImageName: "stop.fill")) + let presentation = AlarmPresentation(alert: alert, countdown: value.seconds.map { _ in .init(title: LocalizedStringResource(stringLiteral: value.title)) }) + let attributes = AlarmAttributes(presentation: presentation, metadata: ScriptWidgetAlarmMetadata(), tintColor: .teal) + let configuration: AlarmManager.AlarmConfiguration = value.seconds.map { .timer(duration: $0, attributes: attributes) } ?? .alarm(schedule: value.date.map { .fixed($0) }, attributes: attributes) + _ = try await manager.schedule(id: id, configuration: configuration) + box.finish(.success(id.uuidString.lowercased())) + } catch { box.finish(.failure(ScriptWidgetSystemServiceError.outcomeUnknown)) } + } + return try box.wait() + } + return ["key": key, "status": "scheduled", "replayed": result["replayed"] ?? false] + } }) else { throw ScriptWidgetSystemServiceError.unavailable } + finish(.success(try operationResult.get())) + #else + _ = context; throw ScriptWidgetSystemServiceError.unavailable + #endif + } + } +} +#if os(iOS) && canImport(AlarmKit) +@available(iOS 26.0, *) +struct ScriptWidgetAlarmMetadata: AlarmMetadata { } +#endif diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift index 8d2d7b77..8f5cc4d8 100644 --- a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift @@ -12,6 +12,8 @@ import EventKit static func authorizationStatus() -> String static func requestAuthorization() -> ScriptWidgetRuntimePromise static func calendars() -> ScriptWidgetRuntimePromise + static func create(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise + static func update(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise static func events(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise } @@ -409,6 +411,8 @@ struct ScriptWidgetCalendarProvider { static func calendars() -> ScriptWidgetRuntimePromise { read(query: nil, error: nil) } + static func create(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { ScriptWidgetRuntimeCalendarWrites.mutate(options ?? [:], updating: false) } + static func update(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { ScriptWidgetRuntimeCalendarWrites.mutate(options ?? [:], updating: true) } static func events(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { do { return read(query: try ScriptWidgetCalendarQuery(options), error: nil) } catch { return read(query: nil, error: error.localizedDescription) } @@ -646,8 +650,8 @@ struct CalendarAccessSettingsView: View { Label(connected ? "Calendar Connected" : "Connect Calendar", systemImage: connected ? "checkmark.circle" : "calendar.badge.clock") .font(.headline) Text(connected - ? "Calendar widgets can read events. Each package must also declare Calendar access. ScriptWidget does not expose event editing." - : "Allow access to display real events. Apple requires full Calendar permission to read events; ScriptWidget uses it only for reading.") + ? "Calendar widgets can read events from selected calendars. Creating or updating events also requires calendarWrite permission, access saved for that widget, and an explicit action. Only events created by that widget can be updated." + : "Apple requires full Calendar permission to read events. ScriptWidget reads selected calendars; widgets with separately granted Calendar write access can create events and update their own events through explicit actions.") .font(.footnote) .foregroundStyle(.secondary) .fixedSize(horizontal: false, vertical: true) diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendarWrites.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendarWrites.swift new file mode 100644 index 00000000..69cd9347 --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendarWrites.swift @@ -0,0 +1,75 @@ +import Foundation +import JavaScriptCore +import EventKit + +struct ScriptWidgetCalendarMutation: ScriptWidgetSystemMutationRequest { + let requestID: String + let listID: String + let fingerprint: String + let title: String + let start: Date + let end: Date + let allDay: Bool + let eventID: String? + init(_ options: [String: Any], updating: Bool) throws { + try ScriptWidgetSystemOptions.fields(options, updating ? ["requestID", "calendarID", "id", "title", "start", "end", "allDay"] : ["requestID", "calendarID", "title", "start", "end", "allDay"]) + requestID = try ScriptWidgetSystemOptions.text(options["requestID"], maximum: 36) + guard UUID(uuidString: requestID)?.uuidString.lowercased() == requestID else { throw ScriptWidgetSystemServiceError.invalidOptions } + listID = try ScriptWidgetSystemOptions.text(options["calendarID"], maximum: 256) + title = try ScriptWidgetSystemOptions.text(options["title"], maximum: 512) + start = try ScriptWidgetSystemOptions.date(options["start"]); end = try ScriptWidgetSystemOptions.date(options["end"]) + guard end > start, end.timeIntervalSince(start) <= 366 * 86400 else { throw ScriptWidgetSystemServiceError.invalidOptions } + allDay = try options["allDay"].map(ScriptWidgetSystemOptions.boolean) ?? false + eventID = updating ? try ScriptWidgetSystemOptions.text(options["id"], maximum: 2048) : nil + fingerprint = ScriptWidgetCloudJSONStore.hash(try JSONSerialization.data(withJSONObject: ["operation": updating ? "update" : "create", "options": options], options: [.sortedKeys, .withoutEscapingSlashes])) + } +} + +enum ScriptWidgetRuntimeCalendarWrites { + static func mutate(_ options: [String: Any], updating: Bool) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.calendarWrite, writing: true) { context, finish in + let request = try ScriptWidgetCalendarMutation(options, updating: updating) + guard context.state.package.readManifest()?.permissions.contains(.calendar) == true, + ScriptWidgetRuntimeCalendar.systemAuthorizationStatus() == "authorized" else { throw ScriptWidgetSystemServiceError.permissionDenied } + let snapshot = context.state.executionSnapshot! + let selected = try ScriptWidgetCalendarSelection.load(container: snapshot.context.container) + guard selected.allows(request.listID) else { throw ScriptWidgetSystemServiceError.permissionDenied } + let store = EKEventStore() + guard let calendar = store.calendar(withIdentifier: request.listID), calendar.allowedEntityTypes.contains(.event), calendar.allowsContentModifications else { throw ScriptWidgetSystemServiceError.permissionDenied } + let ownershipKey = context.access.privateKey("ownedEvents") + guard let response = ScriptWidgetStorageLock.withExclusiveAccess(container: snapshot.context.container, namespace: ownershipKey, operation: { Result { + guard snapshot.context.defaults.synchronize() else { throw ScriptWidgetSystemServiceError.unavailable } + var owned = try ScriptWidgetSystemAccessStore.readNativeValue([String: String].self, key: ownershipKey, backend: snapshot.context.defaults) ?? [:] + guard owned.count <= 128, owned.allSatisfy({ !$0.key.isEmpty && $0.key.utf8.count <= 2048 && $0.value.utf8.count <= 256 }) else { throw ScriptWidgetSystemServiceError.limitExceeded } + let event: EKEvent + if let id = request.eventID { + guard owned[id] == request.listID, let existing = store.event(withIdentifier: id), existing.calendar.calendarIdentifier == request.listID, + !existing.hasRecurrenceRules else { throw ScriptWidgetSystemServiceError.permissionDenied } + event = existing + } else { + guard owned.count < 128 else { throw ScriptWidgetSystemServiceError.limitExceeded } + event = EKEvent(eventStore: store); event.calendar = calendar + } + event.title = request.title; event.startDate = request.start; event.endDate = request.end; event.isAllDay = request.allDay + let result = try selected.withStableAccess(container: snapshot.context.container, kind: .calendar) { + try ScriptWidgetReminderMutationLedger.perform(request, container: snapshot.context.container, backend: snapshot.context.defaults, + key: context.access.privateKey("calendarReceipts"), validate: { + try context.validate() + guard ScriptWidgetRuntimeCalendar.systemAuthorizationStatus() == "authorized" else { throw ScriptWidgetSystemServiceError.permissionDenied } + }) { beforeCommit in + try beforeCommit() + try store.save(event, span: .thisEvent, commit: true) + guard let id = event.eventIdentifier else { throw ScriptWidgetSystemServiceError.outcomeUnknown } + return id + } + } + guard let id = result["id"] as? String else { throw ScriptWidgetSystemServiceError.outcomeUnknown } + owned[id] = request.listID + try ScriptWidgetSystemAccessStore.writeNativeValue(owned, key: ownershipKey, backend: snapshot.context.defaults) + guard snapshot.context.defaults.synchronize() else { throw ScriptWidgetSystemServiceError.outcomeUnknown } + return ["id": id, "calendarID": request.listID, "status": "applied", "replayed": result["replayed"] ?? false] + } }) else { throw ScriptWidgetSystemServiceError.unavailable } + finish(.success(try response.get())) + } + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCloudJSON.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCloudJSON.swift index 66062553..4db5d21a 100644 --- a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCloudJSON.swift +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCloudJSON.swift @@ -2,6 +2,13 @@ import Foundation import JavaScriptCore import WidgetKit +/// JSON documents belong to the store explicitly connected in the native app. +/// Each installed package has its own grant; users may connect several packages +/// to the same store to share documents, or separate stores to isolate them. +/// JavaScript supplies only a document name, never a store ID or arbitrary path. +/// Home Screen instances of one package share its connection. Cross-device +/// exchange is eventual and can retain conflicts; $storage stays local and is +/// never automatically migrated by connecting a cloud store. @objc protocol ScriptWidgetRuntimeCloudJSONExports: JSExport { static func readJSON(_ name: String) -> ScriptWidgetRuntimePromise static func writeJSON(_ name: String, _ value: [String: Any], _ expectedRevision: String) -> ScriptWidgetRuntimePromise diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeContacts.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeContacts.swift new file mode 100644 index 00000000..982e4fee --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeContacts.swift @@ -0,0 +1,51 @@ +import Foundation +import JavaScriptCore +import Contacts + +struct ScriptWidgetContactChoice: Identifiable { + let id: String + let name: String +} +enum ScriptWidgetContactProvider { + static var authorized: Bool { + let status = CNContactStore.authorizationStatus(for: .contacts) + #if os(iOS) + if #available(iOS 18.0, *), status == .limited { return true } + #endif + return status == .authorized + } + static let keys = [CNContactIdentifierKey, CNContactGivenNameKey, CNContactFamilyNameKey, CNContactOrganizationNameKey, CNContactPhoneNumbersKey, CNContactEmailAddressesKey] + static func choices() throws -> [ScriptWidgetContactChoice] { + guard authorized else { throw ScriptWidgetSystemServiceError.permissionDenied } + let request = CNContactFetchRequest(keysToFetch: [CNContactIdentifierKey as CNKeyDescriptor, CNContactGivenNameKey as CNKeyDescriptor, CNContactFamilyNameKey as CNKeyDescriptor]) + request.sortOrder = .userDefault + var result: [ScriptWidgetContactChoice] = [] + try CNContactStore().enumerateContacts(with: request) { contact, stop in + result.append(.init(id: contact.identifier, name: String((contact.givenName + " " + contact.familyName).prefix(256)))) + if result.count == 200 { stop.pointee = true } + } + return result + } + static func selected(_ ids: [String]) throws -> [[String: Any]] { + guard authorized, ids.count <= 20 else { throw ScriptWidgetSystemServiceError.permissionDenied } + if ids.isEmpty { return [] } + let contacts = try CNContactStore().unifiedContacts(matching: CNContact.predicateForContacts(withIdentifiers: ids), keysToFetch: keys.map { $0 as CNKeyDescriptor }) + return contacts.prefix(20).filter { ids.contains($0.identifier) }.map { contact in + ["id": contact.identifier, "name": String((contact.givenName + " " + contact.familyName).prefix(256)), "organization": String(contact.organizationName.prefix(256)), + "phones": contact.phoneNumbers.prefix(3).map { String($0.value.stringValue.prefix(128)) }, "emails": contact.emailAddresses.prefix(3).map { String(($0.value as String).prefix(256)) }] + } + } +} +@objc protocol ScriptWidgetRuntimeContactsExports: JSExport { + static func selected() -> ScriptWidgetRuntimePromise +} +@objc final class ScriptWidgetRuntimeContacts: NSObject, ScriptWidgetRuntimeContactsExports { + static func selected() -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.contacts) { context, finish in + let ids = try context.access.load().contacts + let result = try ScriptWidgetContactProvider.selected(ids) + guard ScriptWidgetContactProvider.authorized else { throw ScriptWidgetSystemServiceError.permissionDenied } + finish(.success(result)) + } + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift new file mode 100644 index 00000000..2f33c258 --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift @@ -0,0 +1,89 @@ +import Foundation +import Darwin +import JavaScriptCore + +/// Bounded RFC-4180-style CSV parser. JSON/CSV are imported as private copies; +/// no bookmark, user pathname or executable document is exposed to scripts. +enum ScriptWidgetDocumentData { + static func importedFile(_ url: URL) throws -> Data { + // The security-scoped picker authorizes this exact native URL. Opening + // the parent directory is unnecessary and can fail in the Mac sandbox. + let fd = open(url.path, O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC) + guard fd >= 0 else { throw ScriptWidgetSystemServiceError.unavailable } + defer { close(fd) } + var before = stat() + guard fstat(fd, &before) == 0, before.st_mode & S_IFMT == S_IFREG, before.st_nlink == 1, + before.st_size >= 0, before.st_size <= 262144 else { throw ScriptWidgetSystemServiceError.invalidOptions } + var result = Data(); var buffer = [UInt8](repeating: 0, count: 8192) + while true { + let count = Darwin.read(fd, &buffer, buffer.count) + if count < 0 && errno == EINTR { continue } + guard count >= 0, result.count + count <= 262144 else { throw ScriptWidgetSystemServiceError.limitExceeded } + if count == 0 { break }; result.append(contentsOf: buffer.prefix(count)) + } + var after = stat(), current = stat() + guard fstat(fd, &after) == 0, lstat(url.path, ¤t) == 0, + before.st_dev == after.st_dev, before.st_ino == after.st_ino, after.st_ino == current.st_ino, after.st_dev == current.st_dev, + before.st_size == after.st_size, before.st_size == result.count, after.st_nlink == 1, current.st_mode & S_IFMT == S_IFREG, + before.st_mtimespec.tv_sec == after.st_mtimespec.tv_sec, before.st_mtimespec.tv_nsec == after.st_mtimespec.tv_nsec, + before.st_ctimespec.tv_sec == after.st_ctimespec.tv_sec, before.st_ctimespec.tv_nsec == after.st_ctimespec.tv_nsec else { throw ScriptWidgetSystemServiceError.scopeChanged } + return result + } + static func csv(_ data: Data) throws -> [String: Any] { + guard data.count <= 262144, var text = String(data: data, encoding: .utf8) else { throw ScriptWidgetSystemServiceError.invalidOptions } + if text.hasPrefix("\u{feff}") { text.removeFirst() } + var rows: [[String]] = [], row: [String] = [], field = "" + var quoted = false, closed = false, cursor = text.startIndex + func finishField() throws { + guard field.utf8.count <= 8192, row.count < 32 else { throw ScriptWidgetSystemServiceError.limitExceeded } + row.append(field); field = ""; closed = false + } + func finishRow() throws { + try finishField() + guard rows.count < 501 else { throw ScriptWidgetSystemServiceError.limitExceeded } + rows.append(row); row = [] + } + while cursor < text.endIndex { + let c = text[cursor]; cursor = text.index(after: cursor) + if quoted { + if c == "\"" { + if cursor < text.endIndex && text[cursor] == "\"" { field.append("\""); cursor = text.index(after: cursor) } + else { quoted = false; closed = true } + } else { field.append(c) } + } else if c == "\"" { + guard field.isEmpty && !closed else { throw ScriptWidgetSystemServiceError.invalidOptions }; quoted = true + } else if c == "," { try finishField() } + else if c == "\r\n" || c == "\n" || c == "\r" { try finishRow() } + else { guard !closed else { throw ScriptWidgetSystemServiceError.invalidOptions }; field.append(c) } + guard field.utf8.count <= 8192 else { throw ScriptWidgetSystemServiceError.limitExceeded } + } + guard !quoted else { throw ScriptWidgetSystemServiceError.invalidOptions } + if !field.isEmpty || !row.isEmpty || closed { try finishRow() } + guard let headers = rows.first, !headers.isEmpty, headers.allSatisfy({ !$0.isEmpty }), Set(headers).count == headers.count, + rows.dropFirst().allSatisfy({ $0.count == headers.count }) else { throw ScriptWidgetSystemServiceError.invalidOptions } + return ["headers": headers, "rows": Array(rows.dropFirst()), "truncated": false] + } + static func json(_ data: Data) throws -> Any { + guard data.count <= 262144 else { throw ScriptWidgetSystemServiceError.limitExceeded } + let object = try JSONSerialization.jsonObject(with: data) + guard object is [String: Any] || object is [Any] else { throw ScriptWidgetSystemServiceError.invalidOptions }; return object + } +} +@objc protocol ScriptWidgetRuntimeDocumentsExports: JSExport { + static func list() -> ScriptWidgetRuntimePromise + static func readJSON(_ id: String) -> ScriptWidgetRuntimePromise + static func readCSV(_ id: String) -> ScriptWidgetRuntimePromise +} +@objc final class ScriptWidgetRuntimeDocuments: NSObject, ScriptWidgetRuntimeDocumentsExports { + static func list() -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.documents) { context, finish in + finish(.success(try context.access.load().documents.map { ["id": $0.id, "name": $0.name, "type": $0.type, "bytes": $0.bytes] as [String: Any] })) + } + } + static func readJSON(_ id: String) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.documents) { context, finish in finish(.success(try ScriptWidgetDocumentData.json(context.access.readDocument(id, type: "json")))) } + } + static func readCSV(_ id: String) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.documents) { context, finish in finish(.success(try ScriptWidgetDocumentData.csv(context.access.readDocument(id, type: "csv")))) } + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift index 9a1c23a1..8faee4cd 100644 --- a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift @@ -44,6 +44,7 @@ enum ScriptWidgetHealthAccessPolicy { static func sleepSummary(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise static func activitySummary(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise static func workouts(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise + static func dailyStatistics(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise } #if canImport(HealthKit) @@ -74,7 +75,7 @@ import HealthKit readTypes.insert(HKObjectType.categoryType(forIdentifier: .sleepAnalysis)!) readTypes.insert(HKObjectType.activitySummaryType()) readTypes.insert(HKObjectType.workoutType()) - for identifier in [HKQuantityTypeIdentifier.distanceWalkingRunning, .distanceCycling, .distanceSwimming] { + for identifier in [HKQuantityTypeIdentifier.distanceWalkingRunning, .distanceCycling, .distanceSwimming, .dietaryWater, .bodyMass] { if let type = HKObjectType.quantityType(forIdentifier: identifier) { readTypes.insert(type) } } return readTypes @@ -672,3 +673,5 @@ extension ScriptWidgetRuntimeHealth { } } } + +extension ScriptWidgetRuntimeHealth { @objc static func dailyStatistics(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { ScriptWidgetRuntimeHealthHistory.read(options ?? [:]) } } diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealthHistory.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealthHistory.swift new file mode 100644 index 00000000..888a3683 --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealthHistory.swift @@ -0,0 +1,63 @@ +import Foundation +import JavaScriptCore +#if canImport(HealthKit) +import HealthKit +#endif + +struct ScriptWidgetHealthHistoryOptions { + let metric: String + let days: Int + static let metrics: Set = ["steps", "activeEnergy", "walkingDistance", "water", "bodyMass", "heartRate"] + init(_ options: [String: Any]) throws { + try ScriptWidgetSystemOptions.fields(options, ["metric", "days"]) + metric = try ScriptWidgetSystemOptions.text(options["metric"], maximum: 32) + let n = try ScriptWidgetSystemOptions.number(options["days"] ?? 7, range: 1...31) + guard Self.metrics.contains(metric), n.rounded() == n else { throw ScriptWidgetSystemServiceError.invalidOptions }; days = Int(n) + } +} + +enum ScriptWidgetRuntimeHealthHistory { + static func read(_ options: [String: Any]) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.health, grant: false) { context, finish in + let value = try ScriptWidgetHealthHistoryOptions(options) + #if canImport(HealthKit) && !os(macOS) + guard HKHealthStore.isHealthDataAvailable() else { throw ScriptWidgetSystemServiceError.unavailable } + let identifier: HKQuantityTypeIdentifier + let unit: HKUnit + let aggregation: HKStatisticsOptions + switch value.metric { + case "steps": identifier = .stepCount; unit = .count(); aggregation = .cumulativeSum + case "activeEnergy": identifier = .activeEnergyBurned; unit = .kilocalorie(); aggregation = .cumulativeSum + case "walkingDistance": identifier = .distanceWalkingRunning; unit = .meter(); aggregation = .cumulativeSum + case "water": identifier = .dietaryWater; unit = .literUnit(with: .milli); aggregation = .cumulativeSum + case "bodyMass": identifier = .bodyMass; unit = .gramUnit(with: .kilo); aggregation = .discreteAverage + default: identifier = .heartRate; unit = HKUnit.count().unitDivided(by: .minute()); aggregation = .discreteAverage + } + let store = HKHealthStore() + var calendar = Calendar(identifier: .gregorian); calendar.timeZone = .current + let today = calendar.startOfDay(for: Date()) + let start = calendar.date(byAdding: .day, value: 1 - value.days, to: today)! + let end = Date() + let query = HKStatisticsCollectionQuery(quantityType: HKObjectType.quantityType(forIdentifier: identifier)!, quantitySamplePredicate: HKQuery.predicateForSamples(withStart: start, end: end), options: aggregation, anchorDate: start, intervalComponents: DateComponents(day: 1)) + let cancellation = ScriptWidgetQueryCancellation(session: context.state.executionSession) + query.initialResultsHandler = { _, collection, error in + cancellation.complete() + guard error == nil, let collection else { finish(.failure(ScriptWidgetSystemServiceError.unavailable)); return } + var rows: [[String: Any]] = [] + collection.enumerateStatistics(from: start, to: end) { stat, _ in + let quantity = aggregation == .cumulativeSum ? stat.sumQuantity() : stat.averageQuantity() + let n = quantity?.doubleValue(for: unit) + let parts = calendar.dateComponents([.year, .month, .day], from: stat.startDate) + rows.append(["date": String(format: "%04d-%02d-%02d", parts.year!, parts.month!, parts.day!), "value": n.flatMap { $0.isFinite && $0 >= 0 ? $0 : nil } as Any? ?? NSNull(), "hasSamples": n != nil]) + } + guard rows.count <= value.days else { finish(.failure(ScriptWidgetSystemServiceError.limitExceeded)); return } + finish(.success(["metric": value.metric, "unit": unit.unitString, "aggregation": aggregation == .cumulativeSum ? "sum" : "average", "timeZone": calendar.timeZone.identifier, "items": rows])) + } + guard cancellation.install({ store.stop(query) }) else { throw ScriptWidgetSystemServiceError.unavailable } + store.execute(query) + #else + _ = context; _ = value; throw ScriptWidgetSystemServiceError.unavailable + #endif + } + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift new file mode 100644 index 00000000..e85e066d --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift @@ -0,0 +1,136 @@ +import Foundation +import JavaScriptCore +#if os(iOS) +import HomeKit +#endif + +struct ScriptWidgetHomeChoice: Identifiable { + let id: String + let name: String + let kind: String +} +#if os(iOS) +final class ScriptWidgetHomeProvider: NSObject, HMHomeManagerDelegate { + static let shared = ScriptWidgetHomeProvider() + private var manager: HMHomeManager! + private var loaded = false + private var waiters: [(Result<[ScriptWidgetHomeChoice], Error>) -> Void] = [] + override init() { super.init(); manager = HMHomeManager(); manager.delegate = self } + func homeManagerDidUpdateHomes(_ manager: HMHomeManager) { loaded = true; let callbacks = waiters; waiters = []; callbacks.forEach { $0(.success(choices())) } } + func load(_ finish: @escaping (Result<[ScriptWidgetHomeChoice], Error>) -> Void) { + if loaded { finish(.success(choices())) } + else if waiters.count < 8 { + waiters.append(finish) + DispatchQueue.main.asyncAfter(deadline: .now() + 3) { [weak self] in + guard let self, !self.loaded else { return }; let pending = self.waiters; self.waiters = []; pending.forEach { $0(.failure(ScriptWidgetSystemServiceError.unavailable)) } + } + } + else { finish(.failure(ScriptWidgetSystemServiceError.limitExceeded)) } + } + private var characteristics: [(HMCharacteristic, String)] { + var result: [(HMCharacteristic, String)] = [] + let types = [HMCharacteristicTypePowerState, HMCharacteristicTypeCurrentTemperature, HMCharacteristicTypeCurrentRelativeHumidity, HMCharacteristicTypeMotionDetected, HMCharacteristicTypeContactState] + for home in manager.homes.prefix(8) { + for accessory in home.accessories.prefix(64) { + for service in accessory.services.prefix(32) { + for characteristic in service.characteristics.prefix(32) where types.contains(characteristic.characteristicType) { + result.append((characteristic, String((home.name + " · " + accessory.name + " · " + service.name).prefix(256)))) + if result.count == 200 { return result } + } + } + } + } + return result + } + func choices() -> [ScriptWidgetHomeChoice] { + let values = characteristics.prefix(200).map { ScriptWidgetHomeChoice(id: $0.0.uniqueIdentifier.uuidString.lowercased(), name: $0.1, kind: $0.0.characteristicType == HMCharacteristicTypePowerState ? "power" : "sensor") } + let scenes = manager.homes.prefix(8).flatMap { home in home.actionSets.prefix(32).map { ScriptWidgetHomeChoice(id: "scene-" + $0.uniqueIdentifier.uuidString.lowercased(), name: String((home.name + " · " + $0.name).prefix(256)), kind: "scene") } } + return Array((values + scenes).prefix(200)) + } + func values(_ ids: [String]) throws -> [[String: Any]] { + guard manager.authorizationStatus.contains(.authorized) else { throw ScriptWidgetSystemServiceError.permissionDenied } + return choices().filter { ids.contains($0.id) }.map { choice in + let characteristic = characteristics.first { $0.0.uniqueIdentifier.uuidString.lowercased() == choice.id }?.0 + let metric: String + let unit: String + switch characteristic?.characteristicType { + case HMCharacteristicTypePowerState: metric = "power"; unit = "boolean" + case HMCharacteristicTypeCurrentTemperature: metric = "temperature"; unit = "celsius" + case HMCharacteristicTypeCurrentRelativeHumidity: metric = "humidity"; unit = "percent" + case HMCharacteristicTypeMotionDetected: metric = "motion"; unit = "boolean" + case HMCharacteristicTypeContactState: metric = "contactState"; unit = "enum" + default: metric = "scene"; unit = "none" + } + return ["metric": metric, "unit": unit, "id": choice.id, "name": choice.name, "kind": choice.kind, "value": characteristic?.value as Any? ?? NSNull(), "isCached": true] + } + } + func setPower(_ id: String, on: Bool, validate: () throws -> Void, finish: @escaping (Result) -> Void) throws { + guard manager.authorizationStatus.contains(.authorized), let characteristic = characteristics.first(where: { $0.0.uniqueIdentifier.uuidString.lowercased() == id })?.0, + characteristic.characteristicType == HMCharacteristicTypePowerState, characteristic.properties.contains(HMCharacteristicPropertyWritable) else { throw ScriptWidgetSystemServiceError.permissionDenied } + try validate() + characteristic.writeValue(on) { error in finish(error == nil ? .success(["id": id, "status": "acknowledged", "value": on]) : .failure(ScriptWidgetSystemServiceError.outcomeUnknown)) } + } + func scene(_ id: String, validate: () throws -> Void, finish: @escaping (Result) -> Void) throws { + guard manager.authorizationStatus.contains(.authorized) else { throw ScriptWidgetSystemServiceError.permissionDenied } + for home in manager.homes { + if let scene = home.actionSets.first(where: { "scene-" + $0.uniqueIdentifier.uuidString.lowercased() == id }) { + try validate() + home.executeActionSet(scene) { error in finish(error == nil ? .success(id) : .failure(ScriptWidgetSystemServiceError.outcomeUnknown)) }; return + } + } + throw ScriptWidgetSystemServiceError.permissionDenied + } +} +#endif +@objc protocol ScriptWidgetRuntimeHomeExports: JSExport { + static func items() -> ScriptWidgetRuntimePromise + static func setPower(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise + static func runScene(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise +} +@objc final class ScriptWidgetRuntimeHome: NSObject, ScriptWidgetRuntimeHomeExports { + static func items() -> ScriptWidgetRuntimePromise { perform("items", [:]) } + static func setPower(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { perform("power", options ?? [:]) } + static func runScene(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { perform("scene", options ?? [:]) } + private static func perform(_ method: String, _ options: [String: Any]) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.home, writing: method != "items") { context, finish in + #if os(iOS) + let ids = try context.access.load().home + if method == "items" && ids.isEmpty { finish(.success([[String: Any]]())); return } + if method != "items" { + try ScriptWidgetSystemOptions.fields(options, method == "scene" ? ["id", "requestID"] : ["id", "on"]) + guard let id = options["id"] as? String, ids.contains(id) else { throw ScriptWidgetSystemServiceError.permissionDenied } + } + if method == "scene" { + let request = try ScriptWidgetNativeMutation(options, scope: "home", operation: "scene") + let result = try ScriptWidgetReminderMutationLedger.perform(request, container: context.access.container, backend: context.state.executionSnapshot!.context.defaults, + key: context.access.privateKey("homeReceipts"), validate: context.validate) { beforeCommit in + try beforeCommit() + let box = ScriptWidgetSystemCompletionBox() + DispatchQueue.main.async { + let provider = ScriptWidgetHomeProvider.shared + provider.load { result in + do { _ = try result.get(); try provider.scene(options["id"] as! String, validate: context.validate) { result in box.finish(result.flatMap { ($0 as? String).map(Result.success) ?? .failure(ScriptWidgetSystemServiceError.unavailable) }) } } + catch { box.finish(.failure(error)) } + } + } + return try box.wait() + } + finish(.success(["id": options["id"]!, "status": "acknowledged", "replayed": result["replayed"] ?? false])); return + } + let on = method == "power" ? try ScriptWidgetSystemOptions.boolean(options["on"]) : false + DispatchQueue.main.async { + let provider = ScriptWidgetHomeProvider.shared + provider.load { result in + do { + _ = try result.get(); try context.validate() + if method == "items" { finish(.success(try provider.values(ids))) } + else { try provider.setPower(options["id"] as! String, on: on, validate: context.validate, finish: finish) } + } catch { finish(.failure(error)) } + } + } + #else + _ = context; throw ScriptWidgetSystemServiceError.unavailable + #endif + } + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift new file mode 100644 index 00000000..665cee8d --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift @@ -0,0 +1,143 @@ +import Foundation +import JavaScriptCore +import MapKit +#if os(macOS) +import AppKit +#else +import UIKit +#endif + +struct ScriptWidgetMapOptions { + let coordinate: CLLocationCoordinate2D + let radius: Double + init(_ options: [String: Any], fields: Set) throws { + try ScriptWidgetSystemOptions.fields(options, fields.union(["latitude", "longitude", "radiusMeters"])) + coordinate = .init(latitude: try ScriptWidgetSystemOptions.number(options["latitude"], range: -90...90), longitude: try ScriptWidgetSystemOptions.number(options["longitude"], range: -180...180)) + radius = try ScriptWidgetSystemOptions.number(options["radiusMeters"] ?? 2000, range: 100...50000) + } + var region: MKCoordinateRegion { .init(center: coordinate, latitudinalMeters: radius * 2, longitudinalMeters: radius * 2) } +} +@objc protocol ScriptWidgetRuntimeMapsExports: JSExport { + static func search(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise + static func geocode(_ address: String) -> ScriptWidgetRuntimePromise + static func reverseGeocode(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise + static func snapshot(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise +} +@objc final class ScriptWidgetRuntimeMaps: NSObject, ScriptWidgetRuntimeMapsExports { + static func search(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { + lookup { request in + let value = try ScriptWidgetMapOptions(options ?? [:], fields: ["query"]) + request.naturalLanguageQuery = try ScriptWidgetSystemOptions.text(options?["query"], maximum: 256); request.region = value.region + } + } + static func geocode(_ address: String) -> ScriptWidgetRuntimePromise { + if #available(iOS 26.0, macOS 26.0, *) { return modernGeocode(address: address) } + return lookup { request in request.naturalLanguageQuery = try ScriptWidgetSystemOptions.text(address, maximum: 256); request.resultTypes = .address } + } + private static func lookup(_ configure: @escaping (MKLocalSearch.Request) throws -> Void) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.maps) { context, finish in + DispatchQueue.main.async { + do { + try context.validate() + let request = MKLocalSearch.Request(); try configure(request) + let search = MKLocalSearch(request: request) + let cancellation = ScriptWidgetQueryCancellation(session: context.state.executionSession) + guard cancellation.install({ search.cancel() }) else { throw ScriptWidgetSystemServiceError.unavailable } + search.start { response, error in + cancellation.complete() + guard error == nil, let response else { finish(.failure(ScriptWidgetSystemServiceError.unavailable)); return } + let rows = response.mapItems.prefix(5).map(mapItem) + finish(.success(rows)) + } + } catch { finish(.failure(error)) } + } + } + } + static func reverseGeocode(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.maps) { context, finish in + let value = try ScriptWidgetMapOptions(options ?? [:], fields: []) + if #available(iOS 26.0, macOS 26.0, *) { + DispatchQueue.main.async { + do { + try context.validate() + guard let request = MKReverseGeocodingRequest(location: CLLocation(latitude: value.coordinate.latitude, longitude: value.coordinate.longitude)) else { throw ScriptWidgetSystemServiceError.invalidOptions } + let cancellation = ScriptWidgetQueryCancellation(session: context.state.executionSession) + guard cancellation.install({ request.cancel() }) else { throw ScriptWidgetSystemServiceError.unavailable } + request.getMapItems { items, error in + cancellation.complete() + guard error == nil else { finish(.failure(ScriptWidgetSystemServiceError.unavailable)); return } + finish(.success((items ?? []).prefix(5).map(mapItem))) + } + } catch { finish(.failure(error)) } + } + return + } + let geocoder = CLGeocoder() + let cancellation = ScriptWidgetQueryCancellation(session: context.state.executionSession) + guard cancellation.install({ geocoder.cancelGeocode() }) else { throw ScriptWidgetSystemServiceError.unavailable } + geocoder.reverseGeocodeLocation(CLLocation(latitude: value.coordinate.latitude, longitude: value.coordinate.longitude)) { places, error in + cancellation.complete() + guard error == nil else { finish(.failure(ScriptWidgetSystemServiceError.unavailable)); return } + finish(.success((places ?? []).prefix(5).map { place in + ["name": String((place.name ?? "").prefix(256)), "address": String([place.name, place.locality, place.administrativeArea, place.country].compactMap { $0 }.joined(separator: ", ").prefix(512)), "latitude": place.location?.coordinate.latitude ?? value.coordinate.latitude, "longitude": place.location?.coordinate.longitude ?? value.coordinate.longitude] as [String: Any] + })) + } + } + } + private static func mapItem(_ item: MKMapItem) -> [String: Any] { + let coordinate: CLLocationCoordinate2D + let address: String + if #available(iOS 26.0, macOS 26.0, *) { coordinate = item.location.coordinate; address = item.address?.fullAddress ?? "" } + else { coordinate = item.placemark.coordinate; address = item.placemark.title ?? "" } + return ["name": String((item.name ?? "").prefix(256)), "address": String(address.prefix(512)), "latitude": coordinate.latitude, "longitude": coordinate.longitude] + } + @available(iOS 26.0, macOS 26.0, *) + private static func modernGeocode(address: String) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.maps) { context, finish in + let text = try ScriptWidgetSystemOptions.text(address, maximum: 256) + DispatchQueue.main.async { + do { + try context.validate() + guard let request = MKGeocodingRequest(addressString: text) else { throw ScriptWidgetSystemServiceError.invalidOptions } + let cancellation = ScriptWidgetQueryCancellation(session: context.state.executionSession) + guard cancellation.install({ request.cancel() }) else { throw ScriptWidgetSystemServiceError.unavailable } + request.getMapItems { items, error in + cancellation.complete() + guard error == nil else { finish(.failure(ScriptWidgetSystemServiceError.unavailable)); return } + finish(.success((items ?? []).prefix(5).map(mapItem))) + } + } catch { finish(.failure(error)) } + } + } + } + static func snapshot(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.maps) { context, finish in + let value = try ScriptWidgetMapOptions(options ?? [:], fields: ["size"]) + let size = try ScriptWidgetSystemOptions.number(options?["size"] ?? 256, range: 128...512) + guard size.rounded() == size else { throw ScriptWidgetSystemServiceError.invalidOptions } + DispatchQueue.main.async { + do { + try context.validate() + let config = MKMapSnapshotter.Options(); config.region = value.region; config.size = .init(width: size, height: size) + #if os(iOS) + config.scale = 1 + #endif + let snapshotter = MKMapSnapshotter(options: config) + let cancellation = ScriptWidgetQueryCancellation(session: context.state.executionSession) + guard cancellation.install({ snapshotter.cancel() }) else { throw ScriptWidgetSystemServiceError.unavailable } + snapshotter.start { result, error in + cancellation.complete() + guard error == nil, let result else { finish(.failure(ScriptWidgetSystemServiceError.unavailable)); return } + #if os(macOS) + let bytes = result.image.tiffRepresentation.flatMap(NSBitmapImageRep.init(data:))?.representation(using: .jpeg, properties: [.compressionFactor: 0.7]) + #else + let bytes = result.image.jpegData(compressionQuality: 0.7) + #endif + guard let bytes, bytes.count <= 262144 else { finish(.failure(ScriptWidgetSystemServiceError.limitExceeded)); return } + finish(.success(["image": "data:image/jpeg;base64," + bytes.base64EncodedString(), "width": size, "height": size, "provider": "Apple Maps"])) + } + } catch { finish(.failure(error)) } + } + } + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift new file mode 100644 index 00000000..a52f95aa --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift @@ -0,0 +1,135 @@ +import Foundation +import JavaScriptCore +import UserNotifications + +struct ScriptWidgetNotificationOptions { + let key: String + let title: String + let body: String + let date: Date? + let dailyHour: Int? + let dailyMinute: Int? + init(_ options: [String: Any], now: Date = Date()) throws { + try ScriptWidgetSystemOptions.fields(options, ["key", "title", "body", "date", "daily"]) + key = try ScriptWidgetSystemOptions.text(options["key"], maximum: 64) + guard ScriptWidgetSystemOptions.validKey(key) else { throw ScriptWidgetSystemServiceError.invalidOptions } + title = try ScriptWidgetSystemOptions.text(options["title"], maximum: 256) + body = try ScriptWidgetSystemOptions.text(options["body"], maximum: 1024) + guard (options["date"] == nil) != (options["daily"] == nil) else { throw ScriptWidgetSystemServiceError.invalidOptions } + date = try options["date"].map(ScriptWidgetSystemOptions.date) + if let date { guard date > now, date.timeIntervalSince(now) <= 366 * 86400 else { throw ScriptWidgetSystemServiceError.invalidOptions } } + if let raw = options["daily"] { + guard let daily = raw as? [String: Any] else { throw ScriptWidgetSystemServiceError.invalidOptions } + try ScriptWidgetSystemOptions.fields(daily, ["hour", "minute"]) + let hour = try ScriptWidgetSystemOptions.number(daily["hour"], range: 0...23), minute = try ScriptWidgetSystemOptions.number(daily["minute"], range: 0...59) + guard hour.rounded() == hour, minute.rounded() == minute else { throw ScriptWidgetSystemServiceError.invalidOptions } + dailyHour = Int(hour); dailyMinute = Int(minute) + } else { dailyHour = nil; dailyMinute = nil } + } +} +@objc protocol ScriptWidgetRuntimeNotificationsExports: JSExport { + static func status() -> ScriptWidgetRuntimePromise + static func pending() -> ScriptWidgetRuntimePromise + static func schedule(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise + static func cancel(_ key: String) -> ScriptWidgetRuntimePromise +} +@objc final class ScriptWidgetRuntimeNotifications: NSObject, ScriptWidgetRuntimeNotificationsExports { + static func status() -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.notifications) { _, finish in + UNUserNotificationCenter.current().getNotificationSettings { settings in + let status: String + switch settings.authorizationStatus { case .authorized: status = "authorized"; case .provisional: status = "provisional"; case .ephemeral: status = "ephemeral"; case .denied: status = "denied"; case .notDetermined: status = "notDetermined"; @unknown default: status = "unavailable" } + finish(.success(["authorization": status])) + } + } + } + static func pending() -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.notifications) { context, finish in + let prefix = "sw." + context.owner + ".notification." + UNUserNotificationCenter.current().getPendingNotificationRequests { items in + let rows = items.filter { $0.identifier.hasPrefix(prefix) }.prefix(32).map { item -> [String: Any] in + let nextDate = (item.trigger as? UNTimeIntervalNotificationTrigger)?.nextTriggerDate() ?? (item.trigger as? UNCalendarNotificationTrigger)?.nextTriggerDate() + return ["key": String(item.identifier.dropFirst(prefix.count)), "title": item.content.title, "body": item.content.body, + "repeats": item.trigger?.repeats ?? false, "date": nextDate.map { ISO8601DateFormatter().string(from: $0) } as Any? ?? NSNull()] + } + finish(.success(rows)) + } + } + } + static func schedule(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.notifications, writing: true) { context, finish in + let value = try ScriptWidgetNotificationOptions(options ?? [:]) + let id = try context.scopedID(value.key, group: "notification") + let center = UNUserNotificationCenter.current() + // Coordinate capacity checks across both app/extension processes. + guard let result = ScriptWidgetStorageLock.withExclusiveAccess(container: context.access.container, namespace: "ScriptWidget.Notifications.Queue.v1", operation: { () -> Result in + let box = ScriptWidgetSystemCompletionBox() + let deadline = Date().addingTimeInterval(2.4) + center.getNotificationSettings { settings in + guard settings.authorizationStatus == .authorized || settings.authorizationStatus == .provisional else { box.finish(.failure(ScriptWidgetSystemServiceError.permissionDenied)); return } + center.getPendingNotificationRequests { items in + do { + try context.validate() + guard Date() < deadline else { throw ScriptWidgetSystemServiceError.outcomeUnknown } + let replacing = items.contains(where: { $0.identifier == id }) + guard replacing || items.count < 60, + replacing || items.filter({ $0.identifier.hasPrefix("sw." + context.owner + ".notification.") }).count < 32 else { throw ScriptWidgetSystemServiceError.limitExceeded } + let content = UNMutableNotificationContent(); content.title = value.title; content.body = value.body + let trigger: UNNotificationTrigger + if let hour = value.dailyHour, let minute = value.dailyMinute { + trigger = UNCalendarNotificationTrigger(dateMatching: DateComponents(hour: hour, minute: minute), repeats: true) + } else { + trigger = UNTimeIntervalNotificationTrigger(timeInterval: max(1, value.date!.timeIntervalSinceNow), repeats: false) + } + try context.validate() + center.add(.init(identifier: id, content: content, trigger: trigger)) { error in + box.finish(error == nil ? .success(id) : .failure(ScriptWidgetSystemServiceError.outcomeUnknown)) + } + } catch { box.finish(.failure(error)) } + } + } + return Result { try box.wait() } + }) else { throw ScriptWidgetSystemServiceError.unavailable } + _ = try result.get() + finish(.success(["key": value.key, "status": "scheduled"])) + } + } + static func cancel(_ key: String) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.notifications, writing: true) { context, finish in + let id = try context.scopedID(key, group: "notification") + try context.validate() + UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [id]) + finish(.success(["key": key, "status": "cancellationRequested"])) + } + } +} + +extension ScriptWidgetSystemServices { + private static let deletionObserver = NotificationCenter.default.addObserver(forName: ScriptManager.packageRemovedNotification, object: nil, queue: nil) { event in + guard let owner = event.userInfo?["retiredOwner"] as? String, + let context = event.userInfo?["storageContext"] as? ScriptWidgetPackageStorageContext else { return } + retireSchedules(owner: owner, container: context.container, backend: context.defaults) + } + static func startLifecycle() { _ = deletionObserver } + /// Called only after native package deletion has retired its installation. + /// Calendar events, imported data and other user records are never deleted. + static func retireSchedules(owner: String, container: URL, backend: any ScriptWidgetStorageBackend) { + guard UUID(uuidString: owner)?.uuidString.lowercased() == owner, + ["com.everettjf.scriptwidget", "com.everettjf.scriptwidget.widget", "com.everettjf.scriptwidget.macwidget"].contains(Bundle.main.bundleIdentifier ?? ""), + NSClassFromString("XCTestCase") == nil, NSClassFromString("XCTest.XCTestCase") == nil, + ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] == nil else { return } + queue.async { + _ = ScriptWidgetStorageLock.withExclusiveAccess(container: container, namespace: "ScriptWidget.Notifications.Queue.v1") { + let box = ScriptWidgetSystemCompletionBox() + let prefix = "sw." + owner + ".notification." + UNUserNotificationCenter.current().getPendingNotificationRequests { requests in + let ids = requests.filter { $0.identifier.hasPrefix(prefix) }.map(\.identifier) + UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: ids) + box.finish(.success(owner)) + } + _ = try? box.wait() + } + ScriptWidgetRuntimeAlarms.retire(owner: owner, backend: backend) + } + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift index b6b590e4..6902f1aa 100644 --- a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift @@ -609,7 +609,7 @@ enum ScriptWidgetReminderMutationLedger { let formatVersion: Int var entries: [Entry] } - static func perform(_ request: ScriptWidgetReminderMutation, container: URL, + static func perform(_ request: Request, container: URL, backend: any ScriptWidgetStorageBackend, key: String, now: Date = Date(), validate: @escaping () throws -> Void, write: (_ beforeCommit: () throws -> Void) throws -> String) throws -> [String: Any] { diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystemServices.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystemServices.swift new file mode 100644 index 00000000..a5edcec3 --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystemServices.swift @@ -0,0 +1,213 @@ +import Foundation +import CoreFoundation +import JavaScriptCore +import CryptoKit + +// Public native system capability adapters share one execution/identity gate. +// Grants are installation-local metadata, never authored package contents. +enum ScriptWidgetSystemServiceError: String, Error, LocalizedError { + case invalidOptions = "invalid_options", permissionDenied = "permission_denied", unavailable, queryLimit = "query_limit", readOnly = "read_only", scopeChanged = "scope_changed", limitExceeded = "limit_exceeded", outcomeUnknown = "outcome_unknown", staleRequest = "request_conflict" + var errorDescription: String? { "[\(rawValue)] System operation could not complete. Existing user data is preserved." } +} + +struct ScriptWidgetSystemAccessGrant: Codable, Equatable { + var version = 1 + var generation = UUID().uuidString.lowercased() + var permissions: [String] = [] + var contacts: [String] = [] + var home: [String] = [] + var documents: [Document] = [] + struct Document: Codable, Equatable { + let id: String + let name: String + let type: String + let bytes: Int + } + static let capabilities: Set = ["notifications", "calendarWrite", "alarms", "documents", "contacts", "home", "maps", "weather"] + var isValid: Bool { + version == 1 && UUID(uuidString: generation)?.uuidString.lowercased() == generation && + Set(permissions).count == permissions.count && Set(permissions).isSubset(of: Self.capabilities) && + contacts.count <= 20 && home.count <= 20 && [contacts, home].allSatisfy { ids in Set(ids).count == ids.count && ids.allSatisfy { !$0.isEmpty && $0.utf8.count <= 1024 && !$0.unicodeScalars.contains(where: CharacterSet.controlCharacters.contains) } } && + documents.count <= 8 && Set(documents.map(\.id)).count == documents.count && documents.allSatisfy { + UUID(uuidString: $0.id)?.uuidString.lowercased() == $0.id && !$0.name.isEmpty && $0.name.utf8.count <= 255 && ["json", "csv"].contains($0.type) && (0...262144).contains($0.bytes) + } + } +} + +struct ScriptWidgetSystemAccessStore { + let container: URL + let owner: String + let validate: () throws -> Void + var directory: String { "SystemAccess.v1/" + owner } + var path: String { directory + "/grant.json" } + func privateKey(_ kind: String) -> String { "ScriptWidget.SystemServices." + kind + ".v1." + owner } + static func readNativeValue(_ type: T.Type, key: String, backend: any ScriptWidgetStorageBackend) throws -> T? { + guard let raw = try backend.readValue(forKey: key) else { return nil } + guard let bytes = raw as? Data, bytes.count <= 128 * 1024 else { throw ScriptWidgetSystemServiceError.unavailable } + return try JSONDecoder().decode(type, from: bytes) + } + static func writeNativeValue(_ value: T, key: String, backend: any ScriptWidgetStorageBackend) throws { + let bytes = try JSONEncoder().encode(value) + guard bytes.count <= 128 * 1024 else { throw ScriptWidgetSystemServiceError.limitExceeded } + try backend.writeValue(bytes, forKey: key) + } + func load() throws -> ScriptWidgetSystemAccessGrant { + try validate() + guard UUID(uuidString: owner)?.uuidString.lowercased() == owner else { throw ScriptWidgetSystemServiceError.permissionDenied } + guard let data = ScriptWidgetPackageFiles.read(root: container, relative: path, maximumBytes: 32768) else { + if ScriptWidgetPackageFiles.safeURL(root: container, relative: path) != nil, ScriptWidgetPackageFiles.kind(root: container, relative: path) == nil { return .init() } + throw ScriptWidgetSystemServiceError.unavailable + } + let value = try JSONDecoder().decode(ScriptWidgetSystemAccessGrant.self, from: data) + guard value.isValid, + try ScriptWidgetCloudJSONStore.hash(JSONSerialization.data(withJSONObject: JSONSerialization.jsonObject(with: data), options: .sortedKeys)) == ScriptWidgetCloudJSONStore.hash(JSONSerialization.data(withJSONObject: JSONSerialization.jsonObject(with: JSONEncoder().encode(value)), options: .sortedKeys)) else { throw ScriptWidgetSystemServiceError.unavailable } + return value + } + func save(_ grant: ScriptWidgetSystemAccessGrant, expected: ScriptWidgetSystemAccessGrant) throws { + guard grant.isValid else { throw ScriptWidgetSystemServiceError.invalidOptions } + guard let result = ScriptWidgetStorageLock.withExclusiveAccess(container: container, namespace: path, operation: { Result { + try validate() + let current = try load() + // Missing grants have no durable generation yet. + guard ScriptWidgetPackageFiles.kind(root: container, relative: path) == nil || current == expected else { throw ScriptWidgetSystemServiceError.scopeChanged } + var value = grant; value.generation = UUID().uuidString.lowercased() + guard ScriptWidgetPackageFiles.write(try JSONEncoder().encode(value), root: container, relative: path) else { throw ScriptWidgetSystemServiceError.unavailable } + } }) else { throw ScriptWidgetSystemServiceError.unavailable } + try result.get() + } + func readDocument(_ id: String, type: String) throws -> Data { + let grant = try load() + guard grant.permissions.contains("documents"), let item = grant.documents.first(where: { $0.id == id && $0.type == type }), + let data = ScriptWidgetPackageFiles.read(root: container, relative: directory + "/documents/" + item.id, maximumBytes: 262144), data.count == item.bytes else { throw ScriptWidgetSystemServiceError.permissionDenied } + return data + } +} + +struct ScriptWidgetSystemServiceContext { + let state: ScriptWidgetRunningState + let permission: WidgetPackagePermission + let writing: Bool + let grantRequired: Bool + let initialGrant: ScriptWidgetSystemAccessGrant? + var access: ScriptWidgetSystemAccessStore { + let snapshot = state.executionSnapshot! + return .init(container: snapshot.context.container, owner: snapshot.binding.ownerID, validate: { try snapshot.validateIdentity() }) + } + func validate() throws { + guard state.isCurrentExecution, state.previewStorage == nil, let snapshot = state.executionSnapshot, + let manifest = state.package.readManifest(), manifest.permissions.contains(permission), + WidgetPackageManifestValidator.validate(manifest, package: state.package, checkEntryExists: false).isValid, + WidgetRuntimeRequirement.supports("1.6", current: manifest.minimumRuntimeVersion ?? "0.0") else { throw ScriptWidgetSystemServiceError.permissionDenied } + try snapshot.validateIdentity() + guard !state.isTimelineProjection, !state.isLiveActivityPresentation, + !writing || state.isUserInitiatedAction else { throw ScriptWidgetSystemServiceError.readOnly } + if grantRequired { + let grant = try access.load() + guard grant.permissions.contains(permission.rawValue), initialGrant == nil || grant == initialGrant else { throw ScriptWidgetSystemServiceError.permissionDenied } + } + } + var owner: String { state.executionSnapshot!.binding.ownerID } + func scopedID(_ key: String, group: String) throws -> String { + guard ScriptWidgetSystemOptions.validKey(key) else { throw ScriptWidgetSystemServiceError.invalidOptions } + return "sw." + owner + "." + group + "." + key + } +} + +enum ScriptWidgetSystemServices { + static let queue = DispatchQueue(label: "ScriptWidget.SystemServices", qos: .userInitiated) + static func perform(_ permission: WidgetPackagePermission, writing: Bool = false, grant: Bool = true, + operation: @escaping (ScriptWidgetSystemServiceContext, @escaping (Result) -> Void) throws -> Void) -> ScriptWidgetRuntimePromise { + let state = JSContext.current()?.scriptWidgetRunningState + return ScriptWidgetRuntimePromise { resolve, reject in + guard let state, state.executionSnapshot != nil else { reject.call(withArguments: [ScriptWidgetSystemServiceError.permissionDenied.localizedDescription]); return } + var context = ScriptWidgetSystemServiceContext(state: state, permission: permission, writing: writing, grantRequired: grant, initialGrant: nil) + do { + try context.validate() + context = .init(state: state, permission: permission, writing: writing, grantRequired: grant, initialGrant: grant ? try context.access.load() : nil) + guard state.executionSession.registerDataQuery() else { throw ScriptWidgetSystemServiceError.queryLimit } + } catch { reject.call(withArguments: [safeError(error)]); return } + let captured = context + let finish: (Result) -> Void = { result in + state.executionSession.callbackQueue.async { + guard state.isCurrentExecution else { return } + do { try captured.validate(); resolve.call(withArguments: [try result.get()]) } + catch { reject.call(withArguments: [safeError(error)]) } + } + } + queue.async { + do { try captured.validate(); try operation(captured, finish) } + catch { finish(.failure(error)) } + } + } + } + static func safeError(_ error: Error) -> String { + if let failure = error as? ScriptWidgetReminderMutationLedger.Failure { + switch failure { + case .uncertain: return ScriptWidgetSystemServiceError.outcomeUnknown.localizedDescription + case .conflict: return ScriptWidgetSystemServiceError.staleRequest.localizedDescription + case .full: return ScriptWidgetSystemServiceError.limitExceeded.localizedDescription + case .busy, .corrupt: return ScriptWidgetSystemServiceError.unavailable.localizedDescription + } + } + return (error as? ScriptWidgetSystemServiceError)?.localizedDescription ?? "[system_failed] System operation failed; review the result before retrying a write." + } +} + +/// Strict bounded inputs used by the native adapters and deterministic tests. +enum ScriptWidgetSystemOptions { + static func validKey(_ key: String) -> Bool { key.range(of: "^[a-zA-Z0-9_-]{1,64}$", options: .regularExpression) != nil } + static func fields(_ options: [String: Any], _ allowed: Set) throws { + guard Set(options.keys).isSubset(of: allowed), JSONSerialization.isValidJSONObject(options), + try JSONSerialization.data(withJSONObject: options).count <= 16384 else { throw ScriptWidgetSystemServiceError.invalidOptions } + } + static func text(_ value: Any?, maximum: Int = 256) throws -> String { + guard let text = value as? String, !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty, + text.utf8.count <= maximum, !text.unicodeScalars.contains(where: CharacterSet.controlCharacters.contains) else { throw ScriptWidgetSystemServiceError.invalidOptions } + return text + } + static func number(_ value: Any?, range: ClosedRange) throws -> Double { + guard let n = value as? NSNumber, CFGetTypeID(n) != CFBooleanGetTypeID(), n.doubleValue.isFinite, range.contains(n.doubleValue) else { throw ScriptWidgetSystemServiceError.invalidOptions } + return n.doubleValue + } + static func date(_ value: Any?) throws -> Date { + let text = try text(value, maximum: 64) + let formatter = ISO8601DateFormatter(); formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds] + guard text.contains("T"), let date = ISO8601DateFormatter().date(from: text) ?? formatter.date(from: text), date.timeIntervalSince1970.isFinite else { throw ScriptWidgetSystemServiceError.invalidOptions } + return date + } + static func boolean(_ value: Any?) throws -> Bool { + guard let n = value as? NSNumber, CFGetTypeID(n) == CFBooleanGetTypeID() else { throw ScriptWidgetSystemServiceError.invalidOptions }; return n.boolValue + } +} + +protocol ScriptWidgetSystemMutationRequest { + var requestID: String { get } + var fingerprint: String { get } + var listID: String { get } +} +extension ScriptWidgetReminderMutation: ScriptWidgetSystemMutationRequest { } + +/// Worker-only bounded bridge for native asynchronous mutation acknowledgments. +/// A timeout leaves the durable prepared receipt in place; never auto-retry it. +final class ScriptWidgetSystemCompletionBox { + private let lock = NSLock() + private var result: Result? + private let semaphore = DispatchSemaphore(value: 0) + func finish(_ value: Result) { lock.lock(); if result == nil { result = value; semaphore.signal() }; lock.unlock() } + func wait() throws -> String { + guard semaphore.wait(timeout: .now() + 2.5) == .success else { throw ScriptWidgetSystemServiceError.outcomeUnknown } + lock.lock(); defer { lock.unlock() }; return try result!.get() + } +} + +struct ScriptWidgetNativeMutation: ScriptWidgetSystemMutationRequest { + let requestID: String + let fingerprint: String + let listID: String + init(_ options: [String: Any], scope: String, operation: String) throws { + requestID = try ScriptWidgetSystemOptions.text(options["requestID"], maximum: 36) + guard UUID(uuidString: requestID)?.uuidString.lowercased() == requestID else { throw ScriptWidgetSystemServiceError.invalidOptions } + listID = scope + fingerprint = ScriptWidgetCloudJSONStore.hash(try JSONSerialization.data(withJSONObject: ["operation": operation, "options": options], options: [.sortedKeys, .withoutEscapingSlashes])) + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeWeather.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeWeather.swift new file mode 100644 index 00000000..33f167d1 --- /dev/null +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeWeather.swift @@ -0,0 +1,76 @@ +import Foundation +import JavaScriptCore + +struct ScriptWidgetWeatherOptions { + let latitude: Double + let longitude: Double + let hours: Int + init(_ options: [String: Any]) throws { + try ScriptWidgetSystemOptions.fields(options, ["latitude", "longitude", "hours"]) + latitude = (try ScriptWidgetSystemOptions.number(options["latitude"], range: -90...90) * 100).rounded() / 100 + longitude = (try ScriptWidgetSystemOptions.number(options["longitude"], range: -180...180) * 100).rounded() / 100 + let count = try ScriptWidgetSystemOptions.number(options["hours"] ?? 24, range: 1...48) + guard count.rounded() == count else { throw ScriptWidgetSystemServiceError.invalidOptions }; hours = Int(count) + } + var url: URL { URL(string: "https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=\(latitude)&lon=\(longitude)")! } + static func normalize(_ data: Data, options: Self, now: Date = Date()) throws -> [String: Any] { + guard data.count <= 2 * 1024 * 1024, + let root = try JSONSerialization.jsonObject(with: data) as? [String: Any], let properties = root["properties"] as? [String: Any], let series = properties["timeseries"] as? [[String: Any]], series.count <= 300 else { throw ScriptWidgetSystemServiceError.unavailable } + var rows: [[String: Any]] = [] + for item in series { + guard let time = item["time"] as? String, let date = (try? ScriptWidgetSystemOptions.date(time)), date >= now.addingTimeInterval(-3600), + let values = item["data"] as? [String: Any], let instant = values["instant"] as? [String: Any], let details = instant["details"] as? [String: Any] else { continue } + let temperature = try ScriptWidgetSystemOptions.number(details["air_temperature"], range: -150...100) + let wind = try ScriptWidgetSystemOptions.number(details["wind_speed"], range: 0...200) + let next = values["next_1_hours"] as? [String: Any] + let precipitation = (next?["details"] as? [String: Any])?["precipitation_amount"] + let symbol = (next?["summary"] as? [String: Any])?["symbol_code"] as? String + rows.append(["time": time, "temperatureC": temperature, "windMetersPerSecond": wind, + "precipitationMM": try precipitation.map { try ScriptWidgetSystemOptions.number($0, range: 0...1000) } as Any? ?? NSNull(), "condition": symbol.map { String($0.prefix(64)) } as Any? ?? NSNull()]) + if rows.count == options.hours { break } + } + guard !rows.isEmpty else { throw ScriptWidgetSystemServiceError.unavailable } + return ["provider": "MET Norway", "attribution": ["text": "Weather data from MET Norway", "url": "https://www.met.no/en/free-meteorological-data/Download-services"], "latitude": options.latitude, "longitude": options.longitude, + "fetchedAt": ISO8601DateFormatter().string(from: now), "isStale": false, "hours": rows] + } +} +@objc protocol ScriptWidgetRuntimeWeatherExports: JSExport { + static func forecast(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise +} +@objc final class ScriptWidgetRuntimeWeather: NSObject, ScriptWidgetRuntimeWeatherExports { + static func forecast(_ options: [String: Any]?) -> ScriptWidgetRuntimePromise { + ScriptWidgetSystemServices.perform(.weather) { context, finish in + let value = try ScriptWidgetWeatherOptions(options ?? [:]) + guard ScriptWidgetNetworkPolicy.packageAllows(value.url, package: context.state.package) else { throw ScriptWidgetSystemServiceError.permissionDenied } + let key = context.access.privateKey("weatherCache") + let backend = context.state.executionSnapshot!.context.defaults + var cached: [String: Any]? + if let data = try backend.readValue(forKey: key) as? Data, data.count <= 128 * 1024, + let object = try JSONSerialization.jsonObject(with: data) as? [String: Any], + object["latitude"] as? Double == value.latitude, object["longitude"] as? Double == value.longitude, + let stamp = object["fetchedAt"] as? String, let date = (try? ScriptWidgetSystemOptions.date(stamp)), + Date().timeIntervalSince(date) >= 0, Date().timeIntervalSince(date) <= 6 * 3600, + let hours = object["hours"] as? [[String: Any]], hours.count >= value.hours { + var result = object; result["hours"] = Array(hours.prefix(value.hours)); result["isStale"] = Date().timeIntervalSince(date) >= 3600 + cached = result + if result["isStale"] as? Bool == false { finish(.success(result)); return } + } + var task: URLSessionDataTask! + task = context.state.fetchManager.makeTask(httpMethod: "GET", url: value.url, params: ["headers": ["User-Agent": "ScriptWidget/27.1 https://github.com/everettjf/scriptwidget"], "timeoutInterval": 3], redirectValidator: { ScriptWidgetNetworkPolicy.allowsRedirect($0, state: context.state) }) { data, response, error in + context.state.executionSession.complete(task) + do { + try context.validate() + guard ScriptWidgetNetworkPolicy.packageAllows(value.url, package: context.state.package), error == nil, + (response as? HTTPURLResponse)?.statusCode == 200, let data else { throw ScriptWidgetSystemServiceError.unavailable } + let normalized = try ScriptWidgetWeatherOptions.normalize(data, options: value) + let encoded = try JSONSerialization.data(withJSONObject: normalized) + guard encoded.count <= 128 * 1024 else { throw ScriptWidgetSystemServiceError.limitExceeded } + try backend.writeValue(encoded, forKey: key) + finish(.success(normalized)) + } catch { finish(cached.map(Result.success) ?? .failure(error)) } + } + guard context.state.executionSession.register(task) else { task.cancel(); throw ScriptWidgetSystemServiceError.queryLimit } + task.resume() + } + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetStorageFiles.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetStorageFiles.swift index 098541e1..7d3360b5 100644 --- a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetStorageFiles.swift +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetStorageFiles.swift @@ -34,6 +34,7 @@ final class ScriptWidgetStorageFiles { private let rootDevice: dev_t private let rootInode: ino_t private let storeReceipt: ScriptWidgetStoragePublicationReceipt + private let volumeIdentity: Data private static let anchorName = ".ScriptWidgetStorage.v2.anchor" var storageReceipt: ScriptWidgetStoragePublicationReceipt { storeReceipt } private static let maximumRecordFileBytes = 3 * 1024 * 1024 @@ -70,7 +71,8 @@ final class ScriptWidgetStorageFiles { return true } - init(container: URL, expectedStoreReceipt: ScriptWidgetStoragePublicationReceipt? = nil) throws { + init(container: URL, expectedStoreReceipt: ScriptWidgetStoragePublicationReceipt? = nil, + legacyRecoveryRoot: URL? = ScriptWidgetStorageVolume.nativeGroupRoot, inheritedDevice: UInt64? = nil) throws { let root = container.standardizedFileURL.resolvingSymlinksInPath() var original = stat() guard lstat(container.path, &original) == 0, original.st_mode & S_IFMT == S_IFDIR else { throw ScriptWidgetStorageFileError.unavailable } @@ -80,42 +82,63 @@ final class ScriptWidgetStorageFiles { var info = stat() guard fstat(fd, &info) == 0, info.st_dev == original.st_dev, info.st_ino == original.st_ino else { throw ScriptWidgetStorageFileError.unavailable } self.container = root; rootDevice = info.st_dev; rootInode = info.st_ino + let volume = try ScriptWidgetStorageVolume.identifier(fd) + volumeIdentity = volume guard let result = ScriptWidgetStorageLock.withExclusiveAccess(container: root, namespace: "ScriptWidgetStorage.FileInitialization.v1", operation: { () -> Result in Result { let directory = try Self.child(fd, name: Self.directoryName) defer { close(directory) } var storeInfo = stat() - guard fstat(directory, &storeInfo) == 0 else { throw ScriptWidgetStorageFileError.unavailable } - let receipt = Self.receipt(storeInfo) - guard expectedStoreReceipt == nil || expectedStoreReceipt == receipt else { throw ScriptWidgetStorageFileError.unavailable } - let anchor = Self.anchor(receipt) + guard fstat(directory, &storeInfo) == 0, storeInfo.st_dev == info.st_dev else { throw ScriptWidgetStorageFileError.unavailable } + let physicalDevice = UInt64(UInt32(bitPattern: storeInfo.st_dev)) + let marker = try Self.read(directory, name: ScriptWidgetStorageVolume.markerName, maximum: 24) + let receipt: ScriptWidgetStoragePublicationReceipt if let existing = try Self.read(fd, name: Self.anchorName, maximum: 24) { - guard existing == anchor else { throw ScriptWidgetStorageFileError.invalidData } + receipt = try ScriptWidgetStorageVolume.anchorReceipt(existing) + guard receipt.inode == storeInfo.st_ino else { throw ScriptWidgetStorageFileError.invalidData } + if let marker { + guard marker == ScriptWidgetStorageVolume.markerMagic + volume else { throw ScriptWidgetStorageFileError.invalidData } + } else { + guard existing.prefix(8) == Data("SWANCH01".utf8) else { throw ScriptWidgetStorageFileError.invalidData } + // Legacy anchors stored a boot-local mount number. Only + // native OS-group descendants may recover a changed one; + // never adopt a replaced directory or arbitrary volume. + guard receipt.device == physicalDevice || ScriptWidgetStorageVolume.permitsLegacyRecovery(container: root, groupRoot: legacyRecoveryRoot, volume: volume) else { + throw ScriptWidgetStorageFileError.invalidData + } + } } else { // Anchor publication precedes the version marker. A retry // may complete an empty store, but never adopts existing // data whose durable identity has gone missing. guard try Self.names(directory).isEmpty else { throw ScriptWidgetStorageFileError.invalidData } - try Self.write(anchor, directory: fd, name: Self.anchorName) + receipt = .init(device: inheritedDevice ?? physicalDevice, inode: storeInfo.st_ino) + try Self.write(Self.anchor(receipt, legacy: true), directory: fd, name: Self.anchorName) } + guard expectedStoreReceipt == nil || expectedStoreReceipt == receipt else { throw ScriptWidgetStorageFileError.unavailable } if let marker = try Self.read(directory, name: "version", maximum: 32) { guard marker == Self.rootMagic else { throw ScriptWidgetStorageFileError.invalidData } } else { guard try Self.names(directory).isEmpty else { throw ScriptWidgetStorageFileError.invalidData } try Self.write(Self.rootMagic, directory: directory, name: "version") } + if marker == nil { + try Self.write(ScriptWidgetStorageVolume.markerMagic + volume, directory: directory, name: ScriptWidgetStorageVolume.markerName) + } + // The upgraded anchor requires the volume marker. A removed + // marker can never be mistaken for a legacy store on reopen. + let upgraded = Self.anchor(receipt) + if try Self.read(fd, name: Self.anchorName, maximum: 24) != upgraded { + try Self.write(upgraded, directory: fd, name: Self.anchorName) + } return receipt } }) else { throw ScriptWidgetStorageFileError.unavailable } storeReceipt = try result.get() } - private static func receipt(_ info: stat) -> ScriptWidgetStoragePublicationReceipt { - .init(device: UInt64(UInt32(bitPattern: info.st_dev)), inode: UInt64(info.st_ino)) - } - - private static func anchor(_ receipt: ScriptWidgetStoragePublicationReceipt) -> Data { - var bytes = Data("SWANCH01".utf8) + private static func anchor(_ receipt: ScriptWidgetStoragePublicationReceipt, legacy: Bool = false) -> Data { + var bytes = Data((legacy ? "SWANCH01" : "SWANCH02").utf8) for value in [receipt.device, receipt.inode] { for index in (0..<8).reversed() { bytes.append(UInt8((value >> (index * 8)) & 255)) } } @@ -131,9 +154,11 @@ final class ScriptWidgetStorageFiles { let directory = try Self.child(root, name: Self.directoryName) defer { close(directory) } var storeInfo = stat() - guard fstat(directory, &storeInfo) == 0, Self.receipt(storeInfo) == storeReceipt, + guard fstat(directory, &storeInfo) == 0, storeInfo.st_dev == rootDevice, storeInfo.st_ino == storeReceipt.inode, try Self.read(root, name: Self.anchorName, maximum: 24) == Self.anchor(storeReceipt) else { throw ScriptWidgetStorageFileError.unavailable } guard try Self.read(directory, name: "version", maximum: 32) == Self.rootMagic else { throw ScriptWidgetStorageFileError.invalidData } + guard try Self.read(directory, name: ScriptWidgetStorageVolume.markerName, maximum: 24) == ScriptWidgetStorageVolume.markerMagic + volumeIdentity, + try ScriptWidgetStorageVolume.identifier(directory) == volumeIdentity else { throw ScriptWidgetStorageFileError.invalidData } let bucket = try Self.child(directory, name: name) defer { close(bucket) } return try operation(bucket) @@ -193,7 +218,7 @@ final class ScriptWidgetStorageFiles { var receipt = stat() guard fstat(descriptor, &receipt) == 0 else { throw ScriptWidgetStorageFileError.unavailable } let path = container.appendingPathComponent(Self.directoryName).appendingPathComponent("profiles").appendingPathComponent(id) - let files = try ScriptWidgetStorageFiles(container: path, expectedStoreReceipt: expectedStoreReceipt) + let files = try ScriptWidgetStorageFiles(container: path, expectedStoreReceipt: expectedStoreReceipt, inheritedDevice: storeReceipt.device) guard files.rootDevice == receipt.st_dev, files.rootInode == receipt.st_ino else { throw ScriptWidgetStorageFileError.unavailable } return files } @@ -477,6 +502,14 @@ final class ScriptWidgetFileStorageBackend: ScriptWidgetStorageBackend { private func metadata(_ key: String) -> Bool { if Self.metadataKeys.contains(key) { return true } + let servicePrefix = "ScriptWidget.SystemServices." + if key.hasPrefix(servicePrefix) { + let parts = key.dropFirst(servicePrefix.count).split(separator: ".", omittingEmptySubsequences: false) + let kinds: Set = ["alarmKeys", "alarmReceipts", "ownedEvents", "calendarReceipts", "homeReceipts", "weatherCache"] + guard parts.count == 3, kinds.contains(String(parts[0])), parts[1] == "v1" else { return false } + let owner = String(parts[2]) + return UUID(uuidString: owner)?.uuidString.lowercased() == owner + } return ["ScriptWidget.CalendarCache.v1.", "ScriptWidget.RemindersCache.v1.", "ScriptWidget.RemindersWrites.v1.", "ScriptWidget.PhotosCache.v1."].contains { prefix in let suffix = key.dropFirst(prefix.count) return key.hasPrefix(prefix) && suffix.count == 64 && suffix.utf8.allSatisfy { (48...57).contains($0) || (97...102).contains($0) } diff --git a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetStorageNamespaces.swift b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetStorageNamespaces.swift index f7848457..2ba8b852 100644 --- a/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetStorageNamespaces.swift +++ b/Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetStorageNamespaces.swift @@ -1,6 +1,7 @@ import Foundation import CoreFoundation import CryptoKit +import Darwin /// Native-owned identities. Package manifests and backup files cannot choose an /// identity. The prefix deliberately sits outside the old `script.` domain. @@ -61,6 +62,117 @@ struct ScriptWidgetLegacyStoragePreview { struct ScriptWidgetStoragePublicationReceipt: Codable, Equatable, Sendable { let device: UInt64 let inode: UInt64 + + static func capture(directory: Int32, groupRoot: URL? = ScriptWidgetStorageVolume.nativeGroupRoot) throws -> Self { + var info = stat() + guard fstat(directory, &info) == 0, info.st_mode & S_IFMT == S_IFDIR else { throw ScriptWidgetStorageNamespaceError.unavailable } + let physicalDevice = UInt64(UInt32(bitPattern: info.st_dev)) + guard let identity = try ScriptWidgetStorageVolume.groupIdentity(root: groupRoot) else { + return .init(device: physicalDevice, inode: info.st_ino) + } + let volume = try ScriptWidgetStorageVolume.identifier(directory) + // Keep the original logical domain so owner IDs, existing journals and + // location hashes survive a reboot. A mount number is not a volume ID. + if volume == identity.volume { return .init(device: identity.device, inode: info.st_ino) } + // Another filesystem cannot collide with this app's legacy domain. + let digest = SHA256.hash(data: volume).prefix(8).reduce(UInt64(0)) { ($0 << 8) | UInt64($1) } + return .init(device: digest | (1 << 63), inode: info.st_ino) + } + + func matches(parent: Int32, name: String) -> Bool { + let fd = openat(parent, name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC) + guard fd >= 0 else { return false } + defer { close(fd) } + return (try? Self.capture(directory: fd)) == self + } +} + +/// Volume UUIDs survive remounts; st_dev does not. The marker is native private +/// metadata and remains paired with the original directory inode and anchor. +enum ScriptWidgetStorageVolume { + static let markerName = "volume" + static let markerMagic = Data("SWVOL001".utf8) + // The OS group URL is stable for this process. Cache the lookup, not the + // volume/anchor proof, which is revalidated for every receipt. + static let nativeGroupRoot: URL? = { +#if SCRIPTWIDGET_CLI + return nil +#else + // Isolated test/preview libraries must not depend on, or inspect, the + // user's real App Group (which unsigned Mac test hosts cannot access). + guard ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] == nil, + ProcessInfo.processInfo.environment["XCTestBundlePath"] == nil, + ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != "1", + NSClassFromString("XCTestCase") == nil, NSClassFromString("XCTest.XCTestCase") == nil else { return nil } + return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.everettjf.scriptwidget") +#endif + }() + + static func identifier(_ fd: Int32) throws -> Data { + var attrs = attrlist() + attrs.bitmapcount = UInt16(ATTR_BIT_MAP_COUNT) + attrs.volattr = UInt32(ATTR_VOL_INFO) | UInt32(ATTR_VOL_UUID) + var data = Data(count: 20) + let status = data.withUnsafeMutableBytes { fgetattrlist(fd, &attrs, $0.baseAddress, $0.count, 0) } + guard status == 0, data.withUnsafeBytes({ $0.loadUnaligned(as: UInt32.self) }) == 20, + data.dropFirst(4).contains(where: { $0 != 0 }) else { throw ScriptWidgetStorageNamespaceError.unavailable } + return Data(data.dropFirst(4)) + } + + static func anchorReceipt(_ bytes: Data) throws -> ScriptWidgetStoragePublicationReceipt { + guard bytes.count == 24, [Data("SWANCH01".utf8), Data("SWANCH02".utf8)].contains(Data(bytes.prefix(8))) else { throw ScriptWidgetStorageNamespaceError.invalidRegistry } + return .init(device: bytes[8..<16].reduce(0) { ($0 << 8) | UInt64($1) }, + inode: bytes[16..<24].reduce(0) { ($0 << 8) | UInt64($1) }) + } + + static func permitsLegacyRecovery(container: URL, groupRoot: URL?, volume: Data) -> Bool { + guard let groupRoot else { return false } + let group = groupRoot.standardizedFileURL.resolvingSymlinksInPath() + let candidate = container.standardizedFileURL.resolvingSymlinksInPath() + guard candidate.pathComponents.starts(with: group.pathComponents) else { return false } + let fd = open(group.path, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC) + guard fd >= 0 else { return false } + defer { close(fd) } + return (try? identifier(fd)) == volume + } + + static func groupIdentity(root: URL?) throws -> (volume: Data, device: UInt64)? { + guard let root else { return nil } + let parent = open(root.standardizedFileURL.resolvingSymlinksInPath().path, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC) + guard parent >= 0 else { throw ScriptWidgetStorageNamespaceError.unavailable } + defer { close(parent) } + let directory = openat(parent, "__WidgetStorage.v2", O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC) + if directory < 0 { + if errno == ENOENT { return nil } + throw ScriptWidgetStorageNamespaceError.unavailable + } + defer { close(directory) } + guard let marker = try readMarker(directory, markerName) else { return nil } + guard let anchor = try readMarker(parent, ".ScriptWidgetStorage.v2.anchor") else { throw ScriptWidgetStorageNamespaceError.invalidRegistry } + let receipt = try anchorReceipt(anchor) + var info = stat() + let volume = try identifier(directory) + guard fstat(directory, &info) == 0, info.st_ino == receipt.inode, + marker == markerMagic + volume else { throw ScriptWidgetStorageNamespaceError.invalidRegistry } + return (volume, receipt.device) + } + + private static func readMarker(_ parent: Int32, _ name: String) throws -> Data? { + let fd = openat(parent, name, O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC) + if fd < 0 { + if errno == ENOENT { return nil } + throw ScriptWidgetStorageNamespaceError.unavailable + } + defer { close(fd) } + var info = stat() + guard fstat(fd, &info) == 0, info.st_mode & S_IFMT == S_IFREG, info.st_nlink == 1, info.st_size == 24 else { + throw ScriptWidgetStorageNamespaceError.invalidRegistry + } + var bytes = Data(count: 24) + let count = bytes.withUnsafeMutableBytes { Darwin.read(fd, $0.baseAddress, $0.count) } + guard count == 24 else { throw ScriptWidgetStorageNamespaceError.unavailable } + return bytes + } } enum ScriptWidgetStorageDirectoryRole: String, Codable, Sendable { diff --git a/Shared/ScriptWidgetRuntime/Widget/AppIntents/ButtonActionAppIntent.swift b/Shared/ScriptWidgetRuntime/Widget/AppIntents/ButtonActionAppIntent.swift index c070cfdc..5092f739 100644 --- a/Shared/ScriptWidgetRuntime/Widget/AppIntents/ButtonActionAppIntent.swift +++ b/Shared/ScriptWidgetRuntime/Widget/AppIntents/ButtonActionAppIntent.swift @@ -385,6 +385,10 @@ struct RunScriptWidgetActionIntent: AppIntent { init() {} + init(resolved: ResolvedScriptWidgetAction) { + action = ScriptWidgetActionEntity(resolved: resolved) + } + init(identifier: String) { if let resolved = ScriptWidgetActionCatalog.live.resolve(identifier: identifier) { action = ScriptWidgetActionEntity(resolved: resolved) @@ -432,6 +436,15 @@ struct SetScriptWidgetActionValueIntent: SetValueIntent { } } +#if os(iOS) +// System permissions such as AlarmKit belong to the app, not the widget +// extension. Match the direct-button intent on iOS 17–26 as well as iOS 27. +@available(iOS 17.0, *) +extension RunScriptWidgetActionIntent: LiveActivityIntent {} +@available(iOS 17.0, *) +extension SetScriptWidgetActionValueIntent: LiveActivityIntent {} +#endif + #if os(macOS) private typealias ScriptWidgetActionIntentProtocol = AppIntent #else diff --git a/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagButton.swift b/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagButton.swift index d6bbcdc9..25322f07 100644 --- a/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagButton.swift +++ b/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagButton.swift @@ -39,7 +39,7 @@ class ScriptWidgetElementTagButton { .modifier(ScriptWidgetAttributeGeneralModifier(element, context)) case .declared(let actionID): if let resolved = context.actionCatalog.resolve(package: context.package, actionID: actionID) { - Button(intent: RunScriptWidgetActionIntent(identifier: resolved.identifier)) { + Button(intent: RunScriptWidgetActionIntent(resolved: resolved)) { buttonLabel(element: element, context: context) } .modifier(ScriptWidgetAttributeGeneralModifier(element, context)) diff --git a/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagShape.swift b/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagShape.swift index 49f08f3a..a50aa20d 100644 --- a/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagShape.swift +++ b/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagShape.swift @@ -74,7 +74,52 @@ extension Shape { class ScriptWidgetElementTagRectangle { + struct CompactStyle { + let width: CGFloat + let height: CGFloat + let color: Color + let corner: CGFloat? + let clippingCorner: CGFloat? + + @ViewBuilder private var framedShape: some View { + if let corner { + RoundedRectangle(cornerRadius: corner).foregroundColor(color) + .frame(width: width, height: height) + } else { + Rectangle().foregroundColor(color).frame(width: width, height: height) + } + } + @ViewBuilder var view: some View { + // Preserve the existing shape + outer corner clip, including the + // distinction between string and numeric corner properties. + if let clippingCorner { framedShape.cornerRadius(clippingCorner).widgetAccentable(false) } + else { framedShape.widgetAccentable(false) } + } + } + + static func compactStyle(_ element: ScriptWidgetRuntimeElement, debugMode: Bool) -> CompactStyle? { + // Dense heatmaps otherwise build the full conditional modifier chain + // for every cell, exhausting WidgetKit's 30 MB process limit. + let allowed: Set = ["frame", "color", "corner"] + guard !debugMode, Set(element.getProps().keys).isSubset(of: allowed), + let value = element.getPropString("color"), + let color = ScriptWidgetAttributeColor(value).color else { return nil } + let frame = ScriptWidgetAttributeFrameModifier(element) + guard frame.frameMode == .width_height_alignment, + frame.width.isFinite, frame.height.isFinite, frame.width >= 0, frame.height >= 0 else { return nil } + let corner = element.getPropString("corner").flatMap { Double($0) }.map { CGFloat($0) } + if let corner, !corner.isFinite || corner < 0 { return nil } + let clippingCorner = element.getPropDouble("corner").map { CGFloat($0) } + if let clippingCorner, !clippingCorner.isFinite || clippingCorner < 0 { return nil } + return .init(width: frame.width, height: frame.height, color: color, corner: corner, clippingCorner: clippingCorner) + } + static func buildView(_ element: ScriptWidgetRuntimeElement, _ context: ScriptWidgetElementContext) -> AnyView { + if let style = compactStyle(element, debugMode: context.debugMode) { return AnyView(style.view) } + return buildGeneralView(element, context) + } + + static func buildGeneralView(_ element: ScriptWidgetRuntimeElement, _ context: ScriptWidgetElementContext) -> AnyView { var cornerRadius: CGFloat? if let cornerValue = element.getPropString("corner") { diff --git a/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagStack.swift b/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagStack.swift index 604792de..4b3fade0 100644 --- a/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagStack.swift +++ b/Shared/ScriptWidgetRuntime/Widget/Component/Elements/ScriptWidgetElementTagStack.swift @@ -12,6 +12,11 @@ class ScriptWidgetElementTagStack { ///-------------------------------------------------------------------------------------------------------- static func buildViewVStack(_ element: ScriptWidgetRuntimeElement, _ context: ScriptWidgetElementContext) -> AnyView { + if let column = ScriptWidgetRectangleColumn.make(element, context: context) { return AnyView(column) } + return buildGeneralViewVStack(element, context) + } + + static func buildGeneralViewVStack(_ element: ScriptWidgetRuntimeElement, _ context: ScriptWidgetElementContext) -> AnyView { return AnyView(Self.buildVStack( element: element, context: context @@ -71,3 +76,41 @@ class ScriptWidgetElementTagStack { return CGFloat(spacing) } } + +/// Flatten only noninteractive, fixed-size solid cells. Other stacks retain +/// their normal view hierarchy and all authored modifiers. +struct ScriptWidgetRectangleColumn: View { + let cells: [ScriptWidgetElementTagRectangle.CompactStyle] + let spacing: CGFloat + var height: CGFloat { cells.reduce(0) { $0 + $1.height } + CGFloat(cells.count - 1) * spacing } + + static func make(_ element: ScriptWidgetRuntimeElement, context: ScriptWidgetElementContext) -> Self? { + guard !context.debugMode, Set(element.getProps().keys).isSubset(of: [AnyHashable("spacing")]), + let spacing = element.getPropDouble("spacing"), spacing.isFinite, spacing >= 0 else { return nil } + let children = element.childrenAsElements() + guard (2...16).contains(children.count), children.allSatisfy({ $0.tagAsString() == "rect" }) else { return nil } + let cells = children.compactMap { ScriptWidgetElementTagRectangle.compactStyle($0, debugMode: false) } + guard cells.count == children.count, let first = cells.first, + first.width > 0, first.width <= 32, cells.allSatisfy({ $0.width == first.width && $0.height > 0 && $0.height <= 32 }) else { return nil } + let result = Self(cells: cells, spacing: CGFloat(spacing)) + return result.height <= 1024 ? result : nil + } + + var body: some View { + Canvas { context, _ in + var y: CGFloat = 0 + for cell in cells { + let rect = CGRect(x: 0, y: y, width: cell.width, height: cell.height) + var drawing = context + if let corner = cell.clippingCorner { + drawing.clip(to: RoundedRectangle(cornerRadius: corner).path(in: rect)) + } + let path = cell.corner.map { RoundedRectangle(cornerRadius: $0).path(in: rect) } ?? Path(rect) + drawing.fill(path, with: .color(cell.color)) + y += cell.height + spacing + } + } + .frame(width: cells[0].width, height: height) + .widgetAccentable(false) + } +} diff --git a/Shared/ScriptWidgetRuntime/Widget/Runtime/ScriptWidgetAppState.swift b/Shared/ScriptWidgetRuntime/Widget/Runtime/ScriptWidgetAppState.swift index dcbdc2d2..5c445131 100644 --- a/Shared/ScriptWidgetRuntime/Widget/Runtime/ScriptWidgetAppState.swift +++ b/Shared/ScriptWidgetRuntime/Widget/Runtime/ScriptWidgetAppState.swift @@ -15,15 +15,6 @@ import UIKit class ScriptWidgetAppState { -#if os(macOS) - let screenBounds = NSScreen.main!.frame - let screenScale = 0.5 -#else - let screenBounds = UIScreen.main.bounds - let screenScale = UIScreen.main.scale -#endif - - init() { #if os(macOS) #else diff --git a/Shared/ScriptWidgetRuntime/Widget/Runtime/ScriptWidgetRuntime.swift b/Shared/ScriptWidgetRuntime/Widget/Runtime/ScriptWidgetRuntime.swift index 8a539023..d87cddf8 100644 --- a/Shared/ScriptWidgetRuntime/Widget/Runtime/ScriptWidgetRuntime.swift +++ b/Shared/ScriptWidgetRuntime/Widget/Runtime/ScriptWidgetRuntime.swift @@ -80,7 +80,15 @@ enum ScriptWidgetRuntimeContract { static let maximumElementDepth = 64 static let maximumPropsPerElement = 128 - static let globalAPIs = ["$calendar","$component","$console","$device","$dynamic_island","$element","$error","$fetch","$file","$getenv","$health","$http","$icloud","$import","$location","$music","$photos","$reminders","$render","$runtime","$services","$storage","$system","$xml","console","fetch"] + static let globalAPIs = [ + "$alarms", "$calendar", "$component", "$console", "$contacts", + "$device", "$documents", "$dynamic_island", "$element", "$error", + "$fetch", "$file", "$getenv", "$health", "$home", + "$http", "$icloud", "$import", "$location", "$maps", + "$music", "$notifications", "$photos", "$reminders", "$render", + "$runtime", "$services", "$storage", "$system", "$weather", + "$xml", "console", "fetch" + ] static func validateSource(_ source: String) -> ScriptWidgetError? { validateByteCount(source.utf8.count, maximum: maximumSourceBytes, label: "Source") @@ -522,6 +530,13 @@ class ScriptWidgetRuntime { runtimeContext["$http"] = ScriptWidgetRuntimeHttp.self runtimeContext["$file"] = ScriptWidgetRuntimeFile.self runtimeContext["$icloud"] = ScriptWidgetRuntimeCloudJSON.self + runtimeContext["$notifications"] = ScriptWidgetRuntimeNotifications.self + runtimeContext["$maps"] = ScriptWidgetRuntimeMaps.self + runtimeContext["$weather"] = ScriptWidgetRuntimeWeather.self + runtimeContext["$alarms"] = ScriptWidgetRuntimeAlarms.self + runtimeContext["$documents"] = ScriptWidgetRuntimeDocuments.self + runtimeContext["$contacts"] = ScriptWidgetRuntimeContacts.self + runtimeContext["$home"] = ScriptWidgetRuntimeHome.self runtimeContext["$system"] = ScriptWidgetRuntimeSystem.self runtimeContext["$calendar"] = ScriptWidgetRuntimeCalendar.self runtimeContext["$photos"] = ScriptWidgetRuntimePhotos.self diff --git a/Skills/scriptwidget-creator/references/runtime-api.md b/Skills/scriptwidget-creator/references/runtime-api.md index cd8a13cb..7bc87d32 100644 --- a/Skills/scriptwidget-creator/references/runtime-api.md +++ b/Skills/scriptwidget-creator/references/runtime-api.md @@ -1,6 +1,6 @@ # ScriptWidget Runtime API -> Generated from Studio's static API metadata (schema v1, runtime 1.5). The native runtime switch is authoritative. Do not edit by hand. +> Generated from Studio's static API metadata (schema v1, runtime 1.6). The native runtime switch is authoritative. Do not edit by hand. ## Components @@ -885,6 +885,32 @@ Interactive widget toggle. A declared actionID requires a package-relative stora - `$location.isAuthorizedForWidgetUpdates`: Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale. - `$location.requestAuthorization`: Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale. - `$location.current`: Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale. +- `$notifications.status`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$notifications.pending`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$notifications.schedule`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$notifications.cancel`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$health.dailyStatistics`: Runtime 1.6. Read-only daily HealthKit statistics on installed iPhone/iPad widgets. Declare health and minimumRuntimeVersion 1.6, review Health access in native Settings. No separate System Access toggle. Missing readings are null/hasSamples false and cannot establish read denial. No raw samples, persistence or queries in future/Live Activity presentations. Preview fixtures never access real Health data. +- `$calendar.create`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created. +- `$calendar.update`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created. +- `$weather.forecast`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.status`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.pending`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.schedule`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.cancel`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.stop`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.pause`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.resume`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$documents.list`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$documents.readJSON`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$documents.readCSV`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$contacts.selected`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$maps.search`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$maps.geocode`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$maps.reverseGeocode`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$maps.snapshot`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$home.items`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$home.setPower`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$home.runScene`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. - `$icloud.readJSON`: Read cached JSON and revision; conflicts preserve all heads. Requires icloud permission and a native connection. Never certifies upload. - `$icloud.writeJSON`: Save a new immutable JSON revision locally from a user action. Requires the revision from readJSON. Background exchange is eventual. - `$icloud.resolveJSON`: Explicitly resolve all observed conflicting heads into a new revision. Stale tokens fail; originals remain. diff --git a/Tests/ScriptWidgetRuntimeTests/RuntimeExecutionTests.swift b/Tests/ScriptWidgetRuntimeTests/RuntimeExecutionTests.swift index 5dceb9db..18b31ba4 100644 --- a/Tests/ScriptWidgetRuntimeTests/RuntimeExecutionTests.swift +++ b/Tests/ScriptWidgetRuntimeTests/RuntimeExecutionTests.swift @@ -2622,8 +2622,8 @@ final class NativeAPIIdentityTests: XCTestCase { } override func tearDownWithError() throws { NativeIdentityURLProtocol.set(host, handler: nil) - defaults.removePersistentDomain(forName: suite) - if let build = ScriptManager.getSandboxBuildDirectoryURL() { _ = ScriptWidgetPackageFiles.removeTree(root: build, relative: packageName) } + if let defaults, let suite { defaults.removePersistentDomain(forName: suite) } + if let packageName, let build = ScriptManager.getSandboxBuildDirectoryURL() { _ = ScriptWidgetPackageFiles.removeTree(root: build, relative: packageName) } try FileManager.default.removeItem(at: root) } private func captured(_ source: String? = nil) throws -> ScriptWidgetExecutionSnapshot { @@ -5824,3 +5824,23 @@ extension RuntimeExecutionTests { } } } + + +extension RuntimeExecutionTests { + func testSystemCapabilitiesDenyUnmanagedAndPreviewPackages() throws { + let calls = ["$notifications.status()", "$calendar.create({})", "$health.dailyStatistics({metric:'steps'})", "$weather.forecast({latitude:0,longitude:0})", "$alarms.pending()", "$documents.list()", "$contacts.selected()", "$maps.geocode('park')", "$home.items()"] + for readonly in [false, true] { + for call in calls { + let temp = makeTempPackage() + defer { try? FileManager.default.removeItem(at:temp.path) } + let package = ScriptWidgetPackage(path:temp.path,readonly:readonly) + let runtime = ScriptWidgetRuntime(package:package,environments:["widget-size":"medium"]) + let result = runtime.executeJSXSyncForWidget("try { await \(call); $render(unexpected); } catch(e) { $render({String(e)}); }") + XCTAssertNil(result.1) + let tree = snapshot(try XCTUnwrap(result.0)) + XCTAssertTrue(tree.contains("permission_denied"),call) + XCTAssertFalse(tree.contains("unexpected"),call) + } + } + } +} diff --git a/Tests/ScriptWidgetRuntimeTests/RuntimeUnitTests.swift b/Tests/ScriptWidgetRuntimeTests/RuntimeUnitTests.swift index 68150bef..022db798 100644 --- a/Tests/ScriptWidgetRuntimeTests/RuntimeUnitTests.swift +++ b/Tests/ScriptWidgetRuntimeTests/RuntimeUnitTests.swift @@ -28,6 +28,7 @@ import Darwin import SwiftUI import UniformTypeIdentifiers #if os(iOS) +import AppIntents import UIKit #elseif os(macOS) import AppKit @@ -390,7 +391,7 @@ final class ScriptWidgetErrorTests: XCTestCase { final class RuntimeContractTests: XCTestCase { func testPublicAPIVersionAndGlobalsAreFixed() { - XCTAssertEqual(ScriptWidgetRuntimeContract.apiVersion, "1.5") + XCTAssertEqual(ScriptWidgetRuntimeContract.apiVersion, "1.6") XCTAssertEqual(ScriptWidgetRuntimeContract.globalAPIs, ScriptWidgetRuntimeContract.globalAPIs.sorted()) XCTAssertTrue(ScriptWidgetRuntimeContract.globalAPIs.contains("$render")) XCTAssertTrue(ScriptWidgetRuntimeContract.globalAPIs.contains("$runtime")) @@ -1325,6 +1326,14 @@ final class ScriptWidgetActionTests: XCTestCase { XCTAssertTrue(catalog.actions().isEmpty, "Malformed Package 2.0 manifests must fail closed on system surfaces") } + func testResolvedButtonIntentPreservesLocalActionWithoutGlobalDiscovery() throws { + let (package, _) = try makeActionPackage() + let resolved = try XCTUnwrap(ScriptWidgetActionCatalog(packages: [package]).actions().first) + let intent = RunScriptWidgetActionIntent(resolved: resolved) + XCTAssertEqual(intent.action.id, resolved.identifier) + XCTAssertEqual(intent.action.title, resolved.action.title) + } + func testExecutorProvidesSharedActionAndLegacyControlEnvironments() throws { let (package, manifest) = try makeActionPackage() let resolved = try XCTUnwrap(ScriptWidgetActionCatalog(packages: [package]).actions().first) @@ -1649,6 +1658,20 @@ final class PackageListRefreshTests: XCTestCase { #else let store = ScriptWidgetHomeViewDataObject(packages: listing) #endif + defer { listing.allowFirstToFinish.signal() } + let latestPublished = expectation(description: "The latest reload is published") + let stalePublished = expectation(description: "The stale reload is discarded") + stalePublished.isInverted = true +#if os(macOS) + let publisher = store.$scriptModels +#else + let publisher = store.$models +#endif + let subscription = publisher.sink { items in + if items.map(\.name) == ["Latest"] { latestPublished.fulfill() } + if items.map(\.name) == ["Stale"] { stalePublished.fulfill() } + } + defer { subscription.cancel() } XCTAssertEqual(listing.firstStarted.wait(timeout: .now() + 2), .success) #if os(macOS) store.reloadUserScripts() @@ -1656,7 +1679,7 @@ final class PackageListRefreshTests: XCTestCase { store.reload() #endif XCTAssertEqual(listing.secondFinished.wait(timeout: .now() + 2), .success) - RunLoop.main.run(until: Date().addingTimeInterval(0.1)) + wait(for: [latestPublished], timeout: 5) #if os(macOS) XCTAssertEqual(store.scriptModels.map(\.name), ["Latest"]) #else @@ -1664,7 +1687,7 @@ final class PackageListRefreshTests: XCTestCase { #endif listing.allowFirstToFinish.signal() - RunLoop.main.run(until: Date().addingTimeInterval(0.1)) + wait(for: [stalePublished], timeout: 0.5) #if os(macOS) XCTAssertEqual(store.scriptModels.map(\.name), ["Latest"]) #else @@ -2150,8 +2173,8 @@ final class CalendarSourceSelectionTests: XCTestCase { final class WidgetRuntimeRequirementTests: XCTestCase { func testOnlyCanonicalSameMajorRequirementsAreSupported() { - for value in ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5"] { XCTAssertTrue(WidgetRuntimeRequirement.supports(value), value) } - for value in ["1.6", "1.10", "2.0", "0.9", "01.3", "1.03", "1.3.0", "1", "1.9999", ">=1.3", " 1.3"] { + for value in ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6"] { XCTAssertTrue(WidgetRuntimeRequirement.supports(value), value) } + for value in ["1.7", "1.10", "2.0", "0.9", "01.3", "1.03", "1.3.0", "1", "1.9999", ">=1.3", " 1.3"] { XCTAssertFalse(WidgetRuntimeRequirement.supports(value), value) } XCTAssertTrue(WidgetRuntimeRequirement.supports("1.9", current: "1.10")) @@ -5059,6 +5082,10 @@ final class StorageCapacityStudyTests: XCTestCase { } final class NativeStorageFileTests: XCTestCase { + func testIsolatedTestHostDoesNotDiscoverTheUsersNativeAppGroup() { + XCTAssertNil(ScriptWidgetStorageVolume.nativeGroupRoot) + } + private var root: URL! private var owner: String! override func setUpWithError() throws { @@ -6543,3 +6570,240 @@ final class PublicAnimationTests: XCTestCase { XCTAssertEqual(quarter-zero,8,accuracy:0.5); XCTAssertEqual(reduced,quarter,accuracy:0.5) } } + +extension NativeStorageFileTests { + private func legacyVolumeFixture(changedMount: Bool, retainMarker: Bool = false) throws -> (Data, UInt64) { + let store = try ScriptWidgetStorageFiles(container: root) + var values = ScriptWidgetStorageFileMap(); values["kept"] = "original record" + try store.commitNamespace(ownerID: owner, values: values) + let bytes = try Data(contentsOf: recordURL) + let original = store.storageReceipt.device + let logical = changedMount ? original ^ 1 : original + var anchor = Data("SWANCH01".utf8) + for value in [logical, store.storageReceipt.inode] { + for shift in (0..<8).reversed() { anchor.append(UInt8((value >> (shift * 8)) & 255)) } + } + try anchor.write(to: root.appendingPathComponent(".ScriptWidgetStorage.v2.anchor")) + if !retainMarker { try FileManager.default.removeItem(at: root.appendingPathComponent(ScriptWidgetStorageFiles.directoryName).appendingPathComponent("volume")) } + return (bytes, logical) + } + + func testRemountedNativeVolumePreservesRecordsReceiptsAndLogicalDevice() throws { + let (bytes, logical) = try legacyVolumeFixture(changedMount: true) + let reopened = try ScriptWidgetStorageFiles(container: root, legacyRecoveryRoot: root) + XCTAssertEqual(reopened.storageReceipt.device, logical) + XCTAssertEqual(try reopened.readNamespace(ownerID: owner)["kept"] as? String, "original record") + XCTAssertEqual(try Data(contentsOf: recordURL), bytes) + let source = root.appendingPathComponent("Scripts") + try FileManager.default.createDirectory(at: source, withIntermediateDirectories: true) + let fd = open(source.path, O_RDONLY | O_DIRECTORY | O_NOFOLLOW) + guard fd >= 0 else { return XCTFail("Fixture directory could not open") } + defer { close(fd) } + let receipt = try ScriptWidgetStoragePublicationReceipt.capture(directory: fd, groupRoot: root) + XCTAssertEqual(receipt.device, logical) + let nested = try reopened.profileFiles(id: UUID().uuidString.lowercased()) + XCTAssertEqual(nested.storageReceipt.device, logical) + XCTAssertEqual(try ScriptWidgetStorageFiles(container: root, legacyRecoveryRoot: nil).storageReceipt, reopened.storageReceipt) + } + + func testChangedLegacyMountOutsideNativeGroupIsNotAutomaticallyAdopted() throws { + let (bytes, _) = try legacyVolumeFixture(changedMount: true) + let anchorURL = root.appendingPathComponent(".ScriptWidgetStorage.v2.anchor") + let anchor = try Data(contentsOf: anchorURL) + XCTAssertThrowsError(try ScriptWidgetStorageFiles(container: root, legacyRecoveryRoot: nil)) + XCTAssertEqual(try Data(contentsOf: anchorURL), anchor) + XCTAssertEqual(try Data(contentsOf: recordURL), bytes) + } + + func testLegacyVolumeUpgradeResumesAfterMarkerPublicationWithoutChangingRecords() throws { + let (bytes, _) = try legacyVolumeFixture(changedMount: true, retainMarker: true) + let reopened = try ScriptWidgetStorageFiles(container: root, legacyRecoveryRoot: nil) + XCTAssertEqual(try Data(contentsOf: root.appendingPathComponent(".ScriptWidgetStorage.v2.anchor")).prefix(8), Data("SWANCH02".utf8)) + XCTAssertEqual(try reopened.readNamespace(ownerID: owner)["kept"] as? String, "original record") + XCTAssertEqual(try Data(contentsOf: recordURL), bytes) + } + + func testModernVolumeProofCannotBeRemovedAndRecreatedAsLegacy() throws { + let store = try ScriptWidgetStorageFiles(container: root) + let marker = root.appendingPathComponent(ScriptWidgetStorageFiles.directoryName).appendingPathComponent("volume") + try FileManager.default.removeItem(at: marker) + XCTAssertThrowsError(try ScriptWidgetStorageFiles(container: root, legacyRecoveryRoot: root)) + XCTAssertThrowsError(try store.readNamespace(ownerID: owner)) + XCTAssertFalse(FileManager.default.fileExists(atPath: marker.path)) + } + + func testForeignVolumeProofIsRejectedEvenForTheNativeRecoveryRoot() throws { + let (bytes, _) = try legacyVolumeFixture(changedMount: true, retainMarker: true) + let marker = root.appendingPathComponent(ScriptWidgetStorageFiles.directoryName).appendingPathComponent("volume") + try (Data("SWVOL001".utf8) + Data(repeating: 0xff, count: 16)).write(to: marker) + XCTAssertThrowsError(try ScriptWidgetStorageFiles(container: root, legacyRecoveryRoot: root)) + XCTAssertEqual(try Data(contentsOf: recordURL), bytes) + } + + func testVolumeProofSymlinkAndHardlinkDoNotAuthorizeAStore() throws { + _ = try ScriptWidgetStorageFiles(container: root) + let marker = root.appendingPathComponent(ScriptWidgetStorageFiles.directoryName).appendingPathComponent("volume") + let kept = root.appendingPathComponent("kept-volume-proof") + try FileManager.default.moveItem(at: marker, to: kept) + try FileManager.default.createSymbolicLink(at: marker, withDestinationURL: kept) + XCTAssertThrowsError(try ScriptWidgetStorageFiles(container: root, legacyRecoveryRoot: root)) + try FileManager.default.removeItem(at: marker) + try FileManager.default.linkItem(at: kept, to: marker) + XCTAssertThrowsError(try ScriptWidgetStorageFiles(container: root, legacyRecoveryRoot: root)) + } +} + +#if os(iOS) +@available(iOS 17.0, *) +final class ScriptWidgetActionHostTests: XCTestCase { + func testDeclaredActionsUseTheApplicationHostBeforeIOS27() { + let actionType: Any.Type = RunScriptWidgetActionIntent.self + let toggleType: Any.Type = SetScriptWidgetActionValueIntent.self + XCTAssertTrue(actionType is any LiveActivityIntent.Type) + XCTAssertTrue(toggleType is any LiveActivityIntent.Type) + } +} +#endif + +final class CompactRectangleTests: XCTestCase { + func testOnlyFixedSolidCellsWithoutOtherModifiersUseTheCompactPath() { + let base: [AnyHashable: Any] = ["frame": "7,7", "color": "#239A3B", "corner": "1.75"] + func style(_ props: [AnyHashable: Any], debug: Bool = false) -> ScriptWidgetElementTagRectangle.CompactStyle? { + ScriptWidgetElementTagRectangle.compactStyle(.init(tagString: "rect", props: props, children: nil), debugMode: debug) + } + XCTAssertNotNil(style(base)) + XCTAssertNil(style(base, debug: true)) + for key in ["padding", "background", "opacity", "trim", "stroke", "shadow", "linkurl", "widgetAccentable", "animation", "unknown"] { + var props = base; props[key] = "1"; XCTAssertNil(style(props), key) + } + for value in ["max", "7,max", "-1,7", "nan,7"] { + var props = base; props["frame"] = value; XCTAssertNil(style(props), value) + } + } + + @MainActor func testCompactCellsMatchGeneralRendererPixelsInBothAppearances() throws { + let package = ScriptWidgetPackage(path: FileManager.default.temporaryDirectory, readonly: true) + let context = ScriptWidgetElementContext(runtime: nil, debugMode: false, scriptName: "Cell fixture", scriptParameter: "", package: package) + func pixels(_ view: AnyView, _ scheme: ColorScheme) throws -> [UInt8] { + let renderer = ImageRenderer(content: view.frame(width: 32, height: 128).background(Color.white).environment(\.colorScheme, scheme)) + renderer.scale = 2 + let image = try XCTUnwrap(renderer.cgImage) + var bytes = [UInt8](repeating: 0, count: image.width * image.height * 4) + let bitmap = try XCTUnwrap(CGContext(data: &bytes, width: image.width, height: image.height, bitsPerComponent: 8, bytesPerRow: image.width * 4, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)) + bitmap.draw(image, in: CGRect(x: 0, y: 0, width: image.width, height: image.height)) + return bytes + } + let children = (0..<7).map { index in ScriptWidgetRuntimeElement(tagString: "rect", props: ["frame": "7,7", "color": index % 3 == 0 ? "red,0.5" : index % 3 == 1 ? "clear" : "#239A3B", "corner": index % 2 == 0 ? "1.75" as Any : 1.75], children: nil) } + let column = ScriptWidgetRuntimeElement(tagString: "vstack", props: ["spacing": 3.0], children: children) + XCTAssertNotNil(ScriptWidgetRectangleColumn.make(column, context: context)) + for spacing in [-1.0, Double.nan, Double.infinity, 200.0] { + let invalid = ScriptWidgetRuntimeElement(tagString: "vstack", props: ["spacing": spacing], children: children) + XCTAssertNil(ScriptWidgetRectangleColumn.make(invalid, context: context)) + } + let decorated = ScriptWidgetRuntimeElement(tagString: "vstack", props: ["spacing": 3.0, "opacity": 0.5], children: children) + XCTAssertNil(ScriptWidgetRectangleColumn.make(decorated, context: context)) + let oversized = ScriptWidgetRuntimeElement(tagString: "rect", props: ["frame": "33,7", "color": "red"], children: nil) + let mixed = ScriptWidgetRuntimeElement(tagString: "vstack", props: ["spacing": 3.0], children: [children[0], oversized]) + XCTAssertNil(ScriptWidgetRectangleColumn.make(mixed, context: context)) + var linked = children[0].getProps(); linked["linkurl"] = "https://example.com"; children[0].props = linked + XCTAssertNil(ScriptWidgetRectangleColumn.make(column, context: context)) + linked.removeValue(forKey: "linkurl"); children[0].props = linked + for scheme in [ColorScheme.light, .dark] { + let flat = try pixels(ScriptWidgetElementTagStack.buildViewVStack(column, context), scheme) + let stacked = try pixels(ScriptWidgetElementTagStack.buildGeneralViewVStack(column, context), scheme) + let differences = zip(flat, stacked).filter { $0 != $1 }.count + let maximumDelta = zip(flat, stacked).map { abs(Int($0) - Int($1)) }.max() ?? 0 + XCTAssertEqual(differences, 0, "column \(scheme), maximum channel delta=\(maximumDelta)") + for color in ["#239A3B", "clear", "red", "red,0.5"] { + for corner in [nil, "1.75", 1.75] as [Any?] { + var props: [AnyHashable: Any] = ["frame": "7,11", "color": color] + props["corner"] = corner + let element = ScriptWidgetRuntimeElement(tagString: "rect", props: props, children: nil) + XCTAssertNotNil(ScriptWidgetElementTagRectangle.compactStyle(element, debugMode: false)) + let compact = try pixels(ScriptWidgetElementTagRectangle.buildView(element, context), scheme) + let general = try pixels(ScriptWidgetElementTagRectangle.buildGeneralView(element, context), scheme) + let differences = zip(compact, general).filter { $0 != $1 }.count + let maximumDelta = zip(compact, general).map { abs(Int($0) - Int($1)) }.max() ?? 0 + XCTAssertEqual(differences, 0, "\(scheme) \(color) corner=\(String(describing: corner)), maximum channel delta=\(maximumDelta)") + } + } + } + } +} + +#if os(iOS) +final class TemplateCardLayoutTests: XCTestCase { + @MainActor func testPhotoPickerControlsAndPreviewFitResizableScenes() throws { + let controller = try XCTUnwrap(UIStoryboard(name: "PhotoPicker", bundle: .main).instantiateViewController(identifier: "PhotoPickerViewController") as? PhotoPickerViewController) + controller.loadViewIfNeeded() + let view = try XCTUnwrap(controller.view) + let buttons = view.subviews.compactMap { $0 as? UIButton } + let save = try XCTUnwrap(buttons.first { $0.currentTitle == "Save" }) + let options = buttons.filter { ["Inline", "Circular", "Rectangular"].contains($0.currentTitle ?? "") } + XCTAssertEqual(options.count, 3) + for size in [CGSize(width: 375, height: 600), CGSize(width: 382, height: 626), CGSize(width: 653, height: 641)] { + view.frame = CGRect(origin: .zero, size: size) + view.setNeedsLayout() + view.layoutIfNeeded() + for option in options { + XCTAssertLessThanOrEqual(option.frame.maxY + 12, save.frame.minY + 0.5, "\(option.currentTitle ?? "Option") overlaps Save at \(size).") + } + let imageView = try XCTUnwrap(controller.imageView) + let container = try XCTUnwrap(imageView.superview) + XCTAssertGreaterThan(imageView.frame.width, 0) + XCTAssertGreaterThan(imageView.frame.height, 0) + XCTAssertGreaterThanOrEqual(imageView.frame.minX, -0.5, "\(size)") + XCTAssertGreaterThanOrEqual(imageView.frame.minY, -0.5, "\(size)") + XCTAssertLessThanOrEqual(imageView.frame.maxX, container.bounds.width + 0.5, "\(size)") + XCTAssertLessThanOrEqual(imageView.frame.maxY, container.bounds.height + 0.5, "\(size)") + } + } + + @MainActor func testWidePreviewStaysWithinTwoColumnCards() throws { + let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true) + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) + defer { try? FileManager.default.removeItem(at: directory) } + let format = UIGraphicsImageRendererFormat(); format.scale = 1 + let preview = UIGraphicsImageRenderer(size: CGSize(width: 600, height: 100), format: format).image { context in + UIColor.red.setFill() + context.fill(CGRect(x: 0, y: 0, width: 600, height: 100)) + } + try XCTUnwrap(preview.pngData()).write(to: directory.appendingPathComponent("preview.png")) + let model = ScriptModel(package: ScriptWidgetPackage(path: directory, readonly: true)) + XCTAssertNotNil(model.package.previewImageURL()) + let cards = HStack(alignment: .top, spacing: 12) { + TemplateCardView(model: model).frame(width: 160) + TemplateCardView(model: model).frame(width: 160) + } + .padding(16) + .background(Color.white) + .environment(\.colorScheme, .light) + let renderer = ImageRenderer(content: cards); renderer.scale = 1 + let image = try XCTUnwrap(renderer.cgImage) + XCTAssertEqual(image.width, 364) + var bytes = [UInt8](repeating: 0, count: image.width * image.height * 4) + let bitmap = try XCTUnwrap(CGContext(data: &bytes, width: image.width, height: image.height, bitsPerComponent: 8, bytesPerRow: image.width * 4, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)) + bitmap.draw(image, in: CGRect(x: 0, y: 0, width: image.width, height: image.height)) + var redPixels = 0 + for y in 0.. 240 && bytes[offset + 1] < 15 && bytes[offset + 2] < 15 { redPixels += 1 } + } + } + XCTAssertGreaterThan(redPixels, 100, "The actual package image must render, rather than only a placeholder.") + for (name, columns) in [("left margin", 0..<12), ("column gap", 179..<185), ("right margin", 352..<364)] { + var coveredPixels = 0 + for y in 0..= 250 && bytes[offset + 1] >= 250 && bytes[offset + 2] >= 250 + if !transparent && !white { coveredPixels += 1 } + } + } + XCTAssertEqual(coveredPixels, 0, "Preview content escaped into the \(name).") + } + } +} +#endif diff --git a/Tests/ScriptWidgetRuntimeTests/SystemServiceTests.swift b/Tests/ScriptWidgetRuntimeTests/SystemServiceTests.swift new file mode 100644 index 00000000..c6fc62f3 --- /dev/null +++ b/Tests/ScriptWidgetRuntimeTests/SystemServiceTests.swift @@ -0,0 +1,155 @@ +import XCTest +import Foundation +@testable import ScriptWidget + +final class SystemServiceTests: XCTestCase { + func testNotificationNamesDatesAndUnknownFieldsFailClosed() throws { + let valid: [String: Any] = ["key": "daily", "title": "Read", "body": "A chapter", "date": "2026-10-28T12:00:00Z"] + let now = ISO8601DateFormatter().date(from: "2026-10-27T12:00:00Z")! + XCTAssertEqual(try ScriptWidgetNotificationOptions(valid, now: now).key, "daily") + for patch: [String: Any] in [["key":"../other"],["key":""],["date":"2020-01-01T00:00:00Z"],["title":"a\nprivate"],["url":"https://example.com"]] { + XCTAssertThrowsError(try ScriptWidgetNotificationOptions(valid.merging(patch, uniquingKeysWith: { _, b in b }), now: now)) + } + } + func testCalendarMutationRequiresCanonicalIDAndBoundedDates() throws { + let input: [String: Any] = ["requestID":"11111111-1111-4111-8111-111111111111", "calendarID":"calendar", "title":"Focus", "start":"2026-10-28T12:00:00Z", "end":"2026-10-28T13:00:00Z"] + let first = try ScriptWidgetCalendarMutation(input, updating: false) + XCTAssertEqual(first.listID, "calendar") + XCTAssertThrowsError(try ScriptWidgetCalendarMutation(input, updating: true)) + for patch: [String: Any] in [["end":"2026-10-28T11:00:00Z"],["allDay":1],["requestID":"not-a-uuid"],["recurrence":"daily"]] { + XCTAssertThrowsError(try ScriptWidgetCalendarMutation(input.merging(patch, uniquingKeysWith: { _,b in b }), updating: false)) + } + } + func testHealthHistoryBoundsAndTypes() throws { + for metric in ScriptWidgetHealthHistoryOptions.metrics { XCTAssertEqual(try ScriptWidgetHealthHistoryOptions(["metric":metric]).days,7) } + for input: [String: Any] in [["metric":"all"],["metric":"steps","days":true],["metric":"steps","days":32],["metric":"steps","days":1.5],["metric":"steps","rawSamples":true]] { XCTAssertThrowsError(try ScriptWidgetHealthHistoryOptions(input)) } + } + func testAlarmIDsAreStableAndIsolatedByOwner() throws { + let a="11111111-1111-4111-8111-111111111111", b="22222222-2222-4222-8222-222222222222" + XCTAssertEqual(try ScriptWidgetAlarmOptions.id(owner:a,key:"focus"),try ScriptWidgetAlarmOptions.id(owner:a,key:"focus")) + XCTAssertNotEqual(try ScriptWidgetAlarmOptions.id(owner:a,key:"focus"),try ScriptWidgetAlarmOptions.id(owner:b,key:"focus")) + XCTAssertThrowsError(try ScriptWidgetAlarmOptions(["key":"focus","title":"Focus","seconds":0])) + XCTAssertThrowsError(try ScriptWidgetAlarmOptions(["key":"focus","title":"Focus","seconds":60,"date":"2026-11-01T12:00:00Z"])) + } + func testCSVQuotesRowsAndBinaryBounds() throws { + let parsed=try ScriptWidgetDocumentData.csv(Data("name,value\r\n\"A,B\",\"quote \"\"here\"\"\"\r\n".utf8)) + XCTAssertEqual(parsed["headers"] as? [String],["name","value"]) + XCTAssertEqual(parsed["rows"] as? [[String]],[["A,B","quote \"here\""]]) + for text in ["a,a\n1,2", "a,b\n1", "a\n\"unclosed", "a\n\"closed\"x"] { XCTAssertThrowsError(try ScriptWidgetDocumentData.csv(Data(text.utf8))) } + XCTAssertThrowsError(try ScriptWidgetDocumentData.csv(Data([0xff,0xfe]))) + XCTAssertThrowsError(try ScriptWidgetDocumentData.json(Data(repeating:32,count:262145))) + XCTAssertThrowsError(try ScriptWidgetDocumentData.csv(Data(("a\n"+Array(repeating:"1",count:501).joined(separator:"\n")).utf8))) + } + func testWeatherCoordinatePrecisionAndMalformedResponses() throws { + let options=try ScriptWidgetWeatherOptions(["latitude":37.33495,"longitude":-122.00902]) + XCTAssertEqual(options.latitude,37.33); XCTAssertEqual(options.longitude,-122.01) + XCTAssertThrowsError(try ScriptWidgetWeatherOptions(["latitude":91,"longitude":0])) + XCTAssertThrowsError(try ScriptWidgetWeatherOptions(["latitude":0,"longitude":0,"hours":true])) + XCTAssertThrowsError(try ScriptWidgetWeatherOptions.normalize(Data("{}".utf8),options:options)) + } + func testNativeGrantsCannotBeImportedOrInheritedByAnotherOwner() throws { + let root=FileManager.default.temporaryDirectory.appendingPathComponent("SystemGrantTests-"+UUID().uuidString) + try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) + defer { try? FileManager.default.removeItem(at:root) } + let a=ScriptWidgetSystemAccessStore(container:root,owner:UUID().uuidString.lowercased(),validate:{}) + let b=ScriptWidgetSystemAccessStore(container:root,owner:UUID().uuidString.lowercased(),validate:{}) + let before=try a.load();var grant=before;grant.permissions=["documents"] + let id=UUID().uuidString.lowercased();let bytes=Data("{\"keep\":true}".utf8) + grant.documents=[.init(id:id,name:"Data.json",type:"json",bytes:bytes.count)] + XCTAssertTrue(ScriptWidgetPackageFiles.write(bytes,root:root,relative:a.directory+"/documents/"+id)) + try a.save(grant,expected:before) + XCTAssertEqual(try a.readDocument(id,type:"json"),bytes) + XCTAssertThrowsError(try b.readDocument(id,type:"json")) + XCTAssertThrowsError(try a.readDocument("../private",type:"json")) + XCTAssertThrowsError(try a.readDocument(id,type:"csv")) + let current=try a.load();var revoked=current;revoked.permissions=[];try a.save(revoked,expected:current) + XCTAssertThrowsError(try a.readDocument(id,type:"json")) + XCTAssertEqual(ScriptWidgetPackageFiles.read(root:root,relative:a.directory+"/documents/"+id),bytes) + XCTAssertThrowsError(try a.save(grant,expected:current)) + } + func testNativeGrantUnknownFieldsAndLinksFailClosed() throws { + let root=FileManager.default.temporaryDirectory.appendingPathComponent("SystemGrantTests-"+UUID().uuidString) + try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) + defer { try? FileManager.default.removeItem(at:root) } + let store=ScriptWidgetSystemAccessStore(container:root,owner:UUID().uuidString.lowercased(),validate:{}) + let before=try store.load();var allowed=before;allowed.permissions=["contacts"];try store.save(allowed,expected:before) + let bytes=try JSONEncoder().encode(store.load());var json=try JSONSerialization.jsonObject(with:bytes) as! [String:Any];json["grantEverything"]=true + XCTAssertTrue(ScriptWidgetPackageFiles.write(try JSONSerialization.data(withJSONObject:json),root:root,relative:store.path)) + XCTAssertThrowsError(try store.load()) + try FileManager.default.removeItem(at:root.appendingPathComponent(store.path)) + let external=root.appendingPathComponent("outside.json");try bytes.write(to:external) + try FileManager.default.createSymbolicLink(at:root.appendingPathComponent(store.path),withDestinationURL:external) + XCTAssertThrowsError(try store.load()) + } + func testNativeFileImportRejectsLinksAndPreservesOriginal() throws { + let root=FileManager.default.temporaryDirectory.appendingPathComponent("SystemImportTests-"+UUID().uuidString) + try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) + defer { try? FileManager.default.removeItem(at:root) } + let source=root.appendingPathComponent("Data.json"), bytes=Data("{\"keep\":true}".utf8) + try bytes.write(to:source) + XCTAssertEqual(try ScriptWidgetDocumentData.importedFile(source),bytes) + let link=root.appendingPathComponent("link.json") + try FileManager.default.createSymbolicLink(at:link,withDestinationURL:source) + XCTAssertThrowsError(try ScriptWidgetDocumentData.importedFile(link)) + let hardlink=root.appendingPathComponent("hardlink.json") + try FileManager.default.linkItem(at:source,to:hardlink) + XCTAssertThrowsError(try ScriptWidgetDocumentData.importedFile(source)) + XCTAssertEqual(try Data(contentsOf:source),bytes) + } + + func testScriptStorageCannotForgeNativeReceiptsOrOwnedEventRegistry() throws { + let owner=UUID().uuidString.lowercased(), domain="SystemPrivateKeys-"+UUID().uuidString + let defaults=UserDefaults(suiteName:domain)! + defer { defaults.removePersistentDomain(forName:domain) } + let store=ScriptWidgetSystemAccessStore(container:FileManager.default.temporaryDirectory,owner:owner,validate:{}) + let prefix="ScriptWidgetStorage.v2:"+owner+":" + let forged=Data("{\"formatVersion\":1,\"entries\":[]}".utf8) + try defaults.writeValue(forged,forKey:prefix+"system.calendar.receipts.v1") + try defaults.writeValue(["victim":"calendar"],forKey:prefix+"system.calendar.owned.v1") + XCTAssertNil(try defaults.readValue(forKey:store.privateKey("calendarReceipts"))) + XCTAssertNil(try defaults.readValue(forKey:store.privateKey("ownedEvents"))) + XCTAssertFalse(store.privateKey("alarmKeys").hasPrefix(prefix)) + } + + func testServicePrivateStateUsesTheProductionFileBackend() throws { + let root = FileManager.default.temporaryDirectory.appendingPathComponent("SystemFileBackend-" + UUID().uuidString) + try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true) + defer { try? FileManager.default.removeItem(at: root) } + let domain = "SystemFileBackend-" + UUID().uuidString + let legacy = UserDefaults(suiteName: domain)! + defer { legacy.removePersistentDomain(forName: domain) } + let backend = try ScriptWidgetFileStorageBackend(container: root, legacy: legacy) + let owner = UUID().uuidString.lowercased() + let access = ScriptWidgetSystemAccessStore(container: root, owner: owner, validate: {}) + let kinds = ["alarmKeys", "alarmReceipts", "ownedEvents", "calendarReceipts", "homeReceipts", "weatherCache"] + for kind in kinds { + let key = access.privateKey(kind) + XCTAssertNil(try backend.readValue(forKey: key)) + try backend.writeValue(Data("{}".utf8), forKey: key) + XCTAssertEqual(try backend.readValue(forKey: key) as? Data, Data("{}".utf8)) + } + try ScriptWidgetSystemAccessStore.writeNativeValue(["focus"], key: access.privateKey("alarmKeys"), backend: backend) + try ScriptWidgetSystemAccessStore.writeNativeValue(["event": "calendar"], key: access.privateKey("ownedEvents"), backend: backend) + let reopened = try ScriptWidgetFileStorageBackend(container: root, legacy: legacy) + XCTAssertEqual(try ScriptWidgetSystemAccessStore.readNativeValue([String].self, key: access.privateKey("alarmKeys"), backend: reopened), ["focus"]) + XCTAssertEqual(try ScriptWidgetSystemAccessStore.readNativeValue([String: String].self, key: access.privateKey("ownedEvents"), backend: reopened), ["event": "calendar"]) + XCTAssertTrue(try backend.values(in: "ScriptWidgetStorage.v2:" + owner + ":").isEmpty) + for key in [access.privateKey("unknown"), "ScriptWidget.SystemServices.alarmKeys.v1.not-an-owner", "ScriptWidget.SystemServices.alarmKeys.v2." + owner] { + XCTAssertThrowsError(try backend.readValue(forKey: key)) + XCTAssertThrowsError(try backend.writeValue(Data(), forKey: key)) + } + XCTAssertThrowsError(try backend.writeValue(["focus"], forKey: access.privateKey("alarmKeys"))) + try backend.writeValue(Data("invalid".utf8), forKey: access.privateKey("alarmKeys")) + XCTAssertThrowsError(try ScriptWidgetSystemAccessStore.readNativeValue([String].self, key: access.privateKey("alarmKeys"), backend: reopened)) + XCTAssertEqual(try backend.readValue(forKey: access.privateKey("alarmKeys")) as? Data, Data("invalid".utf8)) + } + + func testDailyNotificationUsesOneRepeatingSlotAndStrictLocalClock() throws { + let input: [String:Any] = ["key":"daily", "title":"Read", "body":"A chapter", "daily":["hour":20,"minute":0]] + let parsed=try ScriptWidgetNotificationOptions(input) + XCTAssertNil(parsed.date); XCTAssertEqual(parsed.dailyHour,20); XCTAssertEqual(parsed.dailyMinute,0) + XCTAssertThrowsError(try ScriptWidgetNotificationOptions(input.merging(["date":"2026-11-01T00:00:00Z"],uniquingKeysWith:{_,b in b}))) + for daily: [String:Any] in [["hour":24,"minute":0],["hour":20,"minute":true],["hour":20,"minute":0,"weekday":1]] { XCTAssertThrowsError(try ScriptWidgetNotificationOptions(input.merging(["daily":daily],uniquingKeysWith:{_,b in b}))) } + } + +} diff --git a/Tests/ScriptWidgetRuntimeTests/WebStudioServerTests.swift b/Tests/ScriptWidgetRuntimeTests/WebStudioServerTests.swift index 99840cc9..79672ce5 100644 --- a/Tests/ScriptWidgetRuntimeTests/WebStudioServerTests.swift +++ b/Tests/ScriptWidgetRuntimeTests/WebStudioServerTests.swift @@ -2,6 +2,27 @@ import XCTest @testable import ScriptWidget final class WebStudioServerTests: XCTestCase { + private var root: URL! + private var manager: ScriptManager! + override func setUpWithError() throws { + root = FileManager.default.temporaryDirectory.appendingPathComponent("WebStudioServerTests-" + UUID().uuidString) + manager = ScriptManager(isBuild: false, scriptDirectoryOverride: root) + } + override func tearDownWithError() throws { + manager = nil + try? FileManager.default.removeItem(at: root) + root = nil + } + @MainActor func testUnavailableLibraryFailsClosedBeforeListening() { + let unavailable = ScriptManager(isBuild: false, unavailableReason: "Unavailable test library") + let server = WebStudioServer(manager: unavailable) + server.start() + defer { server.stop() } + XCTAssertFalse(server.isRunning) + XCTAssertEqual(server.port, 0) + XCTAssertNotNil(server.lastError) + } + func testParsesBoundedJSONRequest() throws { let payload = Data(#"{"code":"123456"}"#.utf8) var data = Data("POST /api/v1/pair HTTP/1.1\r\nHost: device\r\nContent-Type: application/json\r\nContent-Length: \(payload.count)\r\n\r\n".utf8) @@ -40,7 +61,7 @@ final class WebStudioServerTests: XCTestCase { } func testHTTPServerServesStudioAndAuthenticatedSession() async throws { - let server = WebStudioServer(sessionLease: 5) + let server = WebStudioServer(sessionLease: 5, manager: manager) await MainActor.run { server.start() } let port = try await waitForPort(server) defer { server.stop() } @@ -61,8 +82,8 @@ final class WebStudioServerTests: XCTestCase { let packageName = "WebStudio-P0-\(UUID().uuidString)" let initialSource = "const widget = ;" - XCTAssertTrue(sharedScriptManager.saveScript(packageName: packageName, content: initialSource, imageCopyPath: nil).0) - defer { _ = sharedScriptManager.deleteScript(packageName: packageName) } + XCTAssertTrue(manager.saveScript(packageName: packageName, content: initialSource, imageCopyPath: nil).0) + defer { _ = manager.deleteScript(packageName: packageName) } var packagesRequest = URLRequest(url: URL(string: "http://127.0.0.1:\(port)/api/v1/packages")!) packagesRequest.setValue(token, forHTTPHeaderField: "X-Studio-Token") @@ -87,7 +108,7 @@ final class WebStudioServerTests: XCTestCase { createRequest.httpBody = try JSONSerialization.data(withJSONObject: ["package": packageName, "path": "source/helper.js"]) let (_, createResponse) = try await URLSession.shared.data(for: createRequest) XCTAssertEqual((createResponse as? HTTPURLResponse)?.statusCode, 201) - XCTAssertEqual(sharedScriptManager.getScriptPackage(packageName: packageName).readFile(relativePath: "source/helper.js").0, "") + XCTAssertEqual(manager.getScriptPackage(packageName: packageName).readFile(relativePath: "source/helper.js").0, "") let updatedSource = "const widget = ;" var saveRequest = URLRequest(url: URL(string: "http://127.0.0.1:\(port)/api/v1/document")!) @@ -103,7 +124,7 @@ final class WebStudioServerTests: XCTestCase { let (saveData, saveResponse) = try await URLSession.shared.data(for: saveRequest) XCTAssertEqual((saveResponse as? HTTPURLResponse)?.statusCode, 200) let savedRevision = try XCTUnwrap((try JSONSerialization.jsonObject(with: saveData) as? [String: Any])?["revision"] as? String) - XCTAssertEqual(sharedScriptManager.getScriptPackage(packageName: packageName).readMainFile().0, updatedSource) + XCTAssertEqual(manager.getScriptPackage(packageName: packageName).readMainFile().0, updatedSource) var eventsRequest = URLRequest(url: URL(string: "http://127.0.0.1:\(port)/api/v1/events?after=0")!) eventsRequest.setValue(token, forHTTPHeaderField: "X-Studio-Token") @@ -119,7 +140,7 @@ final class WebStudioServerTests: XCTestCase { deleteRequest.setValue(token, forHTTPHeaderField: "X-Studio-Token") let (_, deleteFileResponse) = try await URLSession.shared.data(for: deleteRequest) XCTAssertEqual((deleteFileResponse as? HTTPURLResponse)?.statusCode, 200) - XCTAssertNil(sharedScriptManager.getScriptPackage(packageName: packageName).readFile(relativePath: "source/helper.js").0) + XCTAssertNil(manager.getScriptPackage(packageName: packageName).readFile(relativePath: "source/helper.js").0) let conflictingSource = "const widget = ;" saveRequest.httpBody = try JSONSerialization.data(withJSONObject: [ @@ -133,7 +154,7 @@ final class WebStudioServerTests: XCTestCase { let conflict = try XCTUnwrap(try JSONSerialization.jsonObject(with: conflictData) as? [String: Any]) XCTAssertEqual(conflict["currentContent"] as? String, updatedSource) XCTAssertEqual(conflict["currentRevision"] as? String, savedRevision) - XCTAssertEqual(sharedScriptManager.getScriptPackage(packageName: packageName).readMainFile().0, updatedSource) + XCTAssertEqual(manager.getScriptPackage(packageName: packageName).readMainFile().0, updatedSource) var sessionRequest = URLRequest(url: URL(string: "http://127.0.0.1:\(port)/api/v1/session")!) sessionRequest.setValue(token, forHTTPHeaderField: "X-Studio-Token") @@ -151,7 +172,7 @@ final class WebStudioServerTests: XCTestCase { } func testSessionLeaseReleasesClosedBrowser() async throws { - let server = WebStudioServer(sessionLease: 0.25) + let server = WebStudioServer(sessionLease: 0.25, manager: manager) await MainActor.run { server.start() } let port = try await waitForPort(server) defer { server.stop() } @@ -172,7 +193,7 @@ final class WebStudioServerTests: XCTestCase { } func testHTTPServerRejectsOversizedRequestAndStaysAvailable() async throws { - let server = WebStudioServer(sessionLease: 5) + let server = WebStudioServer(sessionLease: 5, manager: manager) await MainActor.run { server.start() } let port = try await waitForPort(server) defer { server.stop() } @@ -193,7 +214,8 @@ final class WebStudioServerTests: XCTestCase { if port != 0 { return port } try await Task.sleep(nanoseconds: 20_000_000) } - XCTFail("Web Studio listener did not become ready") + let diagnostics = await MainActor.run { server.diagnosticReport } + XCTFail("Web Studio listener did not become ready: \(diagnostics)") throw URLError(.cannotConnectToHost) } } diff --git a/Tools/ScriptWidgetCLI/Resources/api-catalog.json b/Tools/ScriptWidgetCLI/Resources/api-catalog.json index 7919f2b9..1d4169f9 100644 --- a/Tools/ScriptWidgetCLI/Resources/api-catalog.json +++ b/Tools/ScriptWidgetCLI/Resources/api-catalog.json @@ -1 +1 @@ -[{"id":"$music.isAvailable","group":"music","value":true,"platforms":["ios"],"authorization":"musicRead","notes":"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMusic.swift","operation":"availability","mock":"editable"},{"id":"$music.authorizationStatus","group":"music","value":"authorized","platforms":["ios"],"authorization":"musicRead","notes":"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMusic.swift","operation":"availability","mock":"editable"},{"id":"$music.current","group":"music","value":{"provider":"appleMusic","state":"playing","hasItem":true,"title":"Morning Light","artist":"ScriptWidget Sessions","album":"Focus","duration":224,"position":86,"capturedAt":"2026-01-01T12:00:00Z"},"platforms":["ios"],"authorization":"musicRead","notes":"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMusic.swift","operation":"read","mock":"editable"},{"id":"$services.status","group":"services","value":"connected","platforms":["ios","macos"],"authorization":"serviceAccount","notes":"Runtime 1.4: status(service) and profile(service) are asynchronous. Only provider: github. Unknown providers reject with service_operation. Requires an installed owner and services permission. profile additionally requires network and api.github.com in networkDomains, a native connected GitHub account and explicit owner grant. Native Settings handles credentials; scripts cannot log in or obtain tokens. profile returns service, subject, username, displayName, publicRepositories, privateRepositories, followers and following (missing values are null). No live queries in future entries or Live Activities. Eight shared data queries; native requests also share the eight concurrent/32 total network budget, while Web uses its existing preview network budget. Web uses editable best-state samples only; it never authenticates or sends these requests.","minimumRuntimeVersion":"1.4","arguments":["service"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeServices.swift","operation":"read","mock":"editable"},{"id":"$services.profile","group":"services","value":{"service":"github","subject":"42","username":"octocat","displayName":"Mona","publicRepositories":32,"privateRepositories":8,"followers":128,"following":24},"platforms":["ios","macos"],"authorization":"serviceAccount","notes":"Runtime 1.4: status(service) and profile(service) are asynchronous. Only provider: github. Unknown providers reject with service_operation. Requires an installed owner and services permission. profile additionally requires network and api.github.com in networkDomains, a native connected GitHub account and explicit owner grant. Native Settings handles credentials; scripts cannot log in or obtain tokens. profile returns service, subject, username, displayName, publicRepositories, privateRepositories, followers and following (missing values are null). No live queries in future entries or Live Activities. Eight shared data queries; native requests also share the eight concurrent/32 total network budget, while Web uses its existing preview network budget. Web uses editable best-state samples only; it never authenticates or sends these requests.","minimumRuntimeVersion":"1.4","arguments":["service"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeServices.swift","operation":"read","mock":"editable"},{"id":"$device.screen","group":"device","value":{"width":390,"height":844,"scale":3},"legacy":["device","screen"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.language","group":"device","value":"en","legacy":["device","language"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.model","group":"device","value":"iPhone","legacy":["device","model"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.name","group":"device","value":"My iPhone","legacy":["device","name"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.battery","group":"device","value":{"level":0.8,"state":"unplugged"},"legacy":["device","battery"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.systemVersion","group":"device","value":"26.0","legacy":["device","systemVersion"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.isdarkmode","group":"device","value":false,"legacy":["device","isdarkmode"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.totalDiskSpace","group":"device","value":128000000000,"legacy":["device","totalDiskSpace"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.freeDiskSpace","group":"device","value":64000000000,"legacy":["device","freeDiskSpace"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$system.appInfo","group":"system","value":{"name":"ScriptWidget","bundleId":"com.everettjf.scriptwidget","version":"27.1.2","build":"27012"},"legacy":["system","appInfo"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.locale","group":"system","value":"en_US","legacy":["system","locale"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.preferredLanguages","group":"system","value":["en-US"],"legacy":["system","preferredLanguages"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.timeZone","group":"system","value":{"identifier":"UTC","abbreviation":"GMT","offsetSeconds":0},"legacy":["system","timeZone"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.is24HourClock","group":"system","value":false,"legacy":["system","is24HourClock"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.calendarInfo","group":"system","value":{"identifier":"gregorian","firstWeekday":1,"minimumDaysInFirstWeek":1},"legacy":["system","calendarInfo"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.systemUptime","group":"system","value":3600,"legacy":["system","systemUptime"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.memory","group":"system","value":{"physical":8589934592},"legacy":["system","memory"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.thermalState","group":"system","value":"nominal","legacy":["system","thermalState"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.lowPowerMode","group":"system","value":false,"legacy":["system","lowPowerMode"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.brightness","group":"system","value":0.5,"legacy":["system","brightness"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.reduceMotionEnabled","group":"system","value":false,"legacy":["system","reduceMotionEnabled"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.platform","group":"system","value":"ios","legacy":["system","platform"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.hostName","group":"system","value":"My iPhone","legacy":["system","hostName"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.processName","group":"system","value":"ScriptWidgetWidget","legacy":["system","processName"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.osVersionString","group":"system","value":"Version 26.0","legacy":["system","osVersionString"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.processorCount","group":"system","value":6,"legacy":["system","processorCount"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.activeProcessorCount","group":"system","value":6,"legacy":["system","activeProcessorCount"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$photos.isAvailable","group":"photos","value":true,"platforms":["ios","macos"],"authorization":"photosRead","notes":"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimePhotos.swift","operation":"availability","mock":"editable"},{"id":"$photos.authorizationStatus","group":"photos","value":"authorized","platforms":["ios","macos"],"authorization":"photosRead","notes":"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimePhotos.swift","operation":"availability","mock":"editable"},{"id":"$photos.requestAuthorization","group":"photos","value":true,"platforms":["ios","macos"],"authorization":"photosRead","notes":"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimePhotos.swift","operation":"authorization","mock":"editable"},{"id":"$photos.items","group":"photos","value":{"status":"ready","items":[{"id":"sample.photo","image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fbPe3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQK/QnooooGFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK7TxwooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi++865Pl26H91CDwo9T6t6mhs5cTiVSXmX/ABx49v8Axdc+UmYbKM/u4vX/AGm9T+g/U6/w38fv4buRpOqMTYynr18pj3H+ye4/H1z5TRU3PHVean7S+p+gSOkiCSMhlYZBHIIPcU6vmn4YfEL+zXTw5rb/AOjscQyN/wAsyf4Sf7p7Ht9On0tVHuUKyqx5kFFFFBsFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABTXdIkMkhwo5JNOrjPEN8ZJfsUZ+VeW9z/8AWry84zOGXYd4iSu9ku7O7L8FLF1lSjt19Av/ABDLIxjsvkX+8ep/wrn5J5pjmVyx9zmoqK/HsdmuJxsnPETb8ui9EfoWFwNHDR5aUbefX7yWOeaE5icqfY4roLDxDLGwjvfnX+8Oo/xrmqKMDmuJwUlPDza8uj9UGKwNHEx5asb+fX7z1ZHSVBJGcqeQRTq4zw9fGOX7FIflblfY/wD167Ov2HJ8zhmOHWIirPZrsz89zDBSwlZ0pbdPQKKKK9Q4QooooAKKKKAP/9P9uKKKK7TxwooooAKKKKACiiigAooooAK5zxP4o0vwpp5vtRbJPEcY+87eg/qe1UvGHjPTfCFj51yfMncfuoQeWPqfRfU18ia7r2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1NUvE/ijVPFeoG+1FsAcRxj7qL6D+p71zldjZ8XisW6vux2CiiikcYUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFISAMngCvGvGPjQ3m7StIbEXSSQfxew9vfv9OrSuRUqKCuz0Pxn8e/Ec/ho+BdGnxEMpLdKf3jR9PLU+nYt1I46dfm6iitkrHn1a06rvNhRRRTMgooooAKKKKACiiigAooooAKKKKACiiigAr6a+B3x5uvA00fhjxS7TaO5wj8s1sT3Hcp6r26juD8y0UjahXnRkp03qfthaXdrfW0d7ZSLNDKodHQgqynkEEcEGrFfmf8EvjnffDy6XQtdLXGiytyOrW5J5ZPVe7L+I5zn9JNO1Gx1axi1PTJVnt51DxyIcqynoQazasfXYPGQxMbx36ouUUUUjsP/R+tKKKK6z8/CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigApGZVUsxwBySaR3SNDJIQqqMkngAV4h4w8ZPqjNpumMVthwzdC/8A9j/OnGNzOpUUFdkvjHxm2oFtL0psQdHcdX9h/s/z+leb0UVslY86c3N3YUUUUyAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvePgx8bNT+Gl8NN1Hdc6PM2ZIurRE9Xjz39V6H2PNeD0UjSlWlSkpwdmftNo+saZr+mQ6xo0y3FtcLvjkQ5BH9COhB5B4NaVflf8IPjJrHww1LyZN1zpU7Znt88g9N8eejDuOjDg9iP038P+INH8UaRDrmhTrcWs67kdf1BHUEdCDyDUNWPrsFjo4mPZ9Uf//S+tKKKK6z8/CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACmSSRwxtLKwVVGSTwABSTTRW8TTzsERBkseABXhHi3xfLrchsrIlLVT9C5Hc+3oPz9nGNzOpVUFdkvi/xjJrDmw08lbVTyehkI7n29B+ftwNFFbJWPNnNyd2FFFFMkKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvWvhP8W9b+F+r+bBm40+dh9otieG7bk/uuB379D2x5LRSLp1JU5KcHZo//0/rSiiius/PwooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtYWublgiIMsx6AU26ureyt3urpwkaDJY14H4q8V3GvzeTDmO1Q/Kvdvdv8O1OMbmVWqoIk8WeLZtdlNrbZS1Q8Du59T/AEFcXRRWyVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/9T60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKKKKACq15eW2n2z3d44SNBkk0y/v7XTbV7y9cJGg5J/kPU18/eJfE114hucnKW6H5I/6n1P8qqMbmVWqoLzJPFHim58QXGxcx2yH5E9fdvf+VcpRRWqVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9X60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKo6jqNppVo17etsRfzJ9B6mm6pqlnpFm17ettReg7k+gHrXz34h8Q3niC786c7Y1+5GOij+p9TVRjcxq1lBeY/xH4ku/EN1vk+SFD8kfYe59TXOUUVqedKTbuwooopiCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9b60oqRYZX+4pP0FWV03UX+5byH6Kf8K6z4CzKVFay6Drj/AHLKc/SNv8KsJ4V8Tv8Ac026P0hf/CgfJLsYNFdOngvxc/TTbn8Y2H8xVhPAHjN+mnTfiMfzoH7KfZnIUV3C/Dbxu/TT3/FkH82qyvws8dt/y44+skf/AMVQV7Cp/K/uPPqK9JT4S+OG62yL9ZE/oTVlfg94zbqkK/WQf0BosP6vU/lZ5bRXra/Bjxc3V7Zfq7f0U1YX4JeKD9+4tR/wJz/7JRYf1Wr/ACnjlZmravZaLZte3rYUcADqx9BXpXjnwZH8PNCfXPEeoQKv3Y4k3GSV/wC6gIH4noB1r4t1vXL3Xrw3V2cAcIg6KPQf1PeqjG5y4mTo+7Jaj9e1+91+8NzcnCDhEHRR/j6msOiitTy223dhRRRTEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/Z","width":384,"height":256},{"id":"sample.photo.2","image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/ayiiivVAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9D9rKKKK9UAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/0f2sooor1QCiiigAooooAKKKKACiiigAooooAKKKKACiq15eWun2r3t7IsUUY3MzHAApbW6tr62S8tHEkUqhlZeQQaduoFiiiikAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB/9L9rKKKK9UAooooAKKKKACiiigAooooAKKKKACs/VdVsNFsZNS1OQRQxjJJ/kB3J7Cquva/pnhvTn1PVJNiLwAPvMeyqO5P+eK+P/GPjTU/GF9510fLt0P7qEHhR6n1Y9zXRRoOo/Iyq1VD1L3jrx9f+MLrykzDZRn93F6/7T+p/QdvU7Pw1+IL+GbkaTqjFrCVuvXymP8AEP8AZPcfiO+fJqK9F0ouPJbQ4lUfNzH6FI6SoJIyGVhkEcgg9xTq+ZPhd8Rf7MdPDeuP/ozHEMjf8syf4Sf7p7en06fTdeXVpOm7M74TU1dBRRRWRYUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFNZlRS7nAHU06uc1a6LyfZkPyr1+tebm2ZRwFB15avZLuzmxeJVCm5sLrVpHJS2+VfXvWS8skhy7E/U0yivybG5niMZJyrzb8un3HylbE1KzvNj0lkjOUYj6Gta11aRCEufmX171jUUYLM8Rg5KVCbXl0+4KOJqUXeDO6VldQ6HIPQ06uc0m6KSfZnPyt0+tdHX6zlOZRx9BV46PZrsz6vCYlV6amgooor0jpCiiigAooooA//9P9rKKKK9UAooooAKKKKACiiigAooooAK5rxR4q0rwnpxvtRbLHIjjH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TgADuaSeeG2ha4uGCIgyzHgACvnbxp42m1+Q2NgSlmp+hkI7n29B+J9tKVJzdkTKViXxt44k1x203TSUtFPJ6GQjuf9n0H4n284oor0oxUVZGLdwoooqgCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAr2H4QfGLXvhTrPm2+bjTZ2H2m1J4btvT+64Hfv0PbHj1FROEZxcZrQcZOLuj//T+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKgubm3s7d7q6cRxxjLMegFNu7y2sLZ7y8cRxxjLMe1fN/jDxlc+JJ/IgzHaIflTux/vN7+g7VpSpObJlKxL4y8aXHiKY2lpmOzQ8L0Lkd2/oK4OiivSjFRVkYt3CiiiqAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//1PqCiiivszygooooAKKKKACiiigAooooAKKKKACiiigAooooAKqX19aabave3riOKMZJP+etN1HUbPSrN76/cRxoOSf5D1J9K+afFfiy88TXeTmO2Q/u4/6t6n+XataVJzfkTKViXxd4vu/EtzsTMdrGfkj9f9pvf+VcbRRXoxioqyMW7hRRRVAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//V+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACs/VNUstHsnv799kafmT2AHcmmavq9jolk1/qD7UXoO7HsAO5NfM3iXxNfeJb3z7j5Il/1cY6KP6k9zW1Ki5vyJlKxL4o8VXvia78yX5IEP7uMdB7n1PvXLUUV6EYpKyMW7hRRRVAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB//1vqCipFhlf7ik/QVZTTdRk+5byH6IT/SvsrnlWKVFay6Drr/AHLKc/SNv8Ksp4U8UP8Ac026P0hf/ClzLuOzMCiuoXwT4vfpplz+MbD+Yqynw/8AGj9NNm/EY/nS549x8j7HHUV3K/DXxy/TT3/FkH82qyvwq8ev/wAuGPrLEP8A2al7WHdByS7HntFelp8I/HLdbZF+sif0NWU+DnjRuqQr9ZB/QGl7aH8w/Zy7HldFeur8FfGDdXtl+rt/Rasr8D/FR+/c2o/4E5/9kpe3h3H7KXY8ZrJ1rWrDQbFr+/bCjhVHVj6AetemePvB0Xw20B9f8TajAq/diiTcZJX/ALqAgZ9z0A5NfCviDxBf+Ir43l6cAcIg+6g9B/U966sPBVfeWxlUvDRkniPxHf8AiS9N1dnai8Rxjoo/x9TXP0UV6aSSsjAKKKKYBRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//Z","width":384,"height":256},{"id":"sample.photo.3","image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDTt1AnooopAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9vKKKK7T0wooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi++865PlwIf3UIPCj1Pq3qa3o0XUfkXCHMX/HHjy/8AF115SZhsoz+7iz1/2m9T+g/U6/w38fv4buRpWqMTYSnr18pj3H+ye4/Ed8+U0V6DpR5eS2h0cqtY/QJHSVBJGQysMgjkEHuKdXzT8MPiF/Zjp4c1t/8ARmOIZGP+rJ/hP+ye3p9On0tXmVKbg7M5pR5XYKKKKzJCiiigAooooAKKKKACiiigAooooAKKKKACiiigApkkiRIZJDtUckmn1xXiK/aSb7DGflTlvc//AF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AUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//1vriipFilf7ik/QVZXTtQf7kEh+in/CvqD6ApUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf/AApcy7iuYNFdOngvxc/TTbn8Y2H8xVhfAPjJ+mnTfiMfzpc8e4XRyFFdwvw38bv009/xZB/NqsL8LfHbf8uOPrJH/wDFUvaR7hzLuef0V6Svwl8cN1tkX6yJ/Q1ZX4P+M26pCv1kH9AaXtYdxc67nltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AAJz/wCyUvbw7hzx7njlZesaxY6JZNe3zYUcADqx9APWvSvHfg6P4daE+u+JNQgVfuxxJuMkr/3UBAz7noB1r4j13Xr7xBem7vDgDhEHRR6D+p710UIqpqtjejT9pr0JPEHiC+8Q3hubo7UXhIx0Uf4+prBoorvStojvSS0QUUUUxhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//2Q==","width":384,"height":256},{"id":"sample.photo.4","image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQO3UnooooEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK5z1QooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi+9865PlwIf3UIPCj1Pq3qaaR0UKDqPyL3jjx5f+LrrykzDZRn93Fnr/tN6n9B+p2Phv4/fw3cjStUYmx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+TxeDnh5Wlt0ZdooooOM//9H60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigApGZUUu5wBySaR3SNDJIQqqMkngACvBvGnjZ9WZtM0titqDhm6GT/7H+dJuxrSpOo7Im8a+OG1ItpOkNi36O46v7D/Z/n9K8woorNu560IKC5YhRRRSLCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAK98+Cvxw1T4ZXw0zUd1zo07Zki6tET1ePPf1XofrzXgdFMyq0o1YuE1oftro2s6X4h0yHWdFnW5tbhd8ciHII/oR0IPIPBrTr8o/g58Z9Z+Fup+TJuudJnbM9vnkHp5keeA47jow4PYj9QvD3iHRvFWjw69oE63NrcLuR1/UEdQQeCDyDTTPlMbgpYeXddGf/9L60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACmSyxwxtNMwVFGSTwAB3NNnnhtoWuLhgiIMsx4AAr5+8Y+M5tekNlYkpaKfoXI7n29B+J9k3Y2o0XUdkS+MvGsmtO2nacSlop5PQyEdz7eg/E155RRWbdz1YQUFyxCiiikWFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABXrvwk+L2ufCzWPNt83GnTsPtNqTw3ben91wO/foe2PIqKDOpTjUi4TV0f/T+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtIHublwkaDLMegFNu7u2sbZ7u7cRxoMsx7V87+LfF9z4in8iHMdoh+VO7H+839B2pN2NqNF1H5EvjDxjP4gmNra5jtEPC93I7t/QVw1FFZtnqwgorliFFFFIsKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9T60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAqre3trp1q95euI40GST/nrTNQ1C00u0e9vnCRoOSf5D1Jr5y8U+KrvxJdZOY7dD+7j/qfU/wAqTdjejRdR+RL4r8WXXiO52LmO1Q/Inr/tN7/yrkKKKzPVjFRVkFFFFIoKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP//V+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAqhqep2ekWb318+yNPzJ9AO5NM1XVrLRbJr6/fai9B3Y9gB3NfN/iPxJe+I7zz7j5Yl/wBXGOij+p9TUt2OihQdR+RJ4m8T3niO78yT5IEP7uPsPc+prmaKKg9SMVFWQUUUUigooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/W+tKKkWKV/uKT9BVlNO1CT7kEjfRT/hWR9rcpUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf8AwoFzLuYNFdMvgvxc/TTbn8Y2H8xVlfAPjJ+mnTfiMfzoF7SPc5Ciu4X4b+N36ae/4sg/masL8LfHb/8ALjj6yR//ABVIXtYfzI8/or0lPhL44brbIv1kT+hqynwf8Zt1SFfrIP6A0C9tD+ZHltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AnP8A7JQL6xT/AJjxysrWNZsdDsmvr5sKOAB1Y+gHrXpXjvwfF8OdBfXfEmoQKv3Yok3GSV/7qAgZ9z0A618Q69r194gvTd3hwBwiDoo9B/U96TdjrwtNVveWw/xB4hvvEV6bm6O1F4SMdFH+PqawaKKg9dJJWQUUUUhhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH/9k=","width":384,"height":256}],"unavailableCount":0,"fetchedAt":"2026-01-01T12:00:00Z","source":"system","stale":false},"platforms":["ios","macos"],"authorization":"photosRead","notes":"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimePhotos.swift","operation":"read","mock":"editable"},{"id":"$calendar.isAvailable","group":"calendar","value":true,"platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"availability","mock":"editable"},{"id":"$calendar.authorizationStatus","group":"calendar","value":"authorized","platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"availability","mock":"editable"},{"id":"$calendar.requestAuthorization","group":"calendar","value":true,"platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"authorization","mock":"editable"},{"id":"$calendar.calendars","group":"calendar","value":[{"id":"sample.personal","title":"Personal"}],"platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"read","mock":"editable"},{"id":"$calendar.events","group":"calendar","value":{"status":"ready","items":[{"id":"sample.event","calendarID":"sample.personal","title":"Read and recharge","start":"2026-01-01T15:00:00Z","end":"2026-01-01T15:30:00Z","allDay":false}],"fetchedAt":"2026-01-01T12:00:00Z","source":"system","stale":false,"truncated":false},"platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"read","mock":"editable"},{"id":"$reminders.isAvailable","group":"reminders","value":true,"platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"availability","mock":"editable"},{"id":"$reminders.authorizationStatus","group":"reminders","value":"authorized","platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"availability","mock":"editable"},{"id":"$reminders.requestAuthorization","group":"reminders","value":true,"platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"authorization","mock":"editable"},{"id":"$reminders.lists","group":"reminders","value":[{"id":"sample.reminders","title":"Personal"}],"platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"read","mock":"editable"},{"id":"$reminders.items","group":"reminders","value":{"status":"ready","items":[{"id":"sample.reminder","listID":"sample.reminders","title":"Read a chapter","due":"2026-01-01T16:00:00Z","hasTime":true,"completed":false,"completedAt":null,"priority":0}],"fetchedAt":"2026-01-01T12:00:00Z","source":"system","stale":false,"truncated":false},"platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"read","mock":"editable"},{"id":"$reminders.create","group":"reminders","value":{"id":"sample.reminder","listID":"sample.reminders","status":"applied","replayed":false},"platforms":["ios","macos"],"authorization":"remindersWrite","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":["options"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"write","mock":"editable"},{"id":"$reminders.update","group":"reminders","value":{"id":"sample.reminder","listID":"sample.reminders","status":"applied","replayed":false},"platforms":["ios","macos"],"authorization":"remindersWrite","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":["options"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"write","mock":"editable"},{"id":"$reminders.setCompleted","group":"reminders","value":{"id":"sample.reminder","listID":"sample.reminders","status":"applied","replayed":false},"platforms":["ios","macos"],"authorization":"remindersWrite","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":["options"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"write","mock":"editable"},{"id":"$health.authorizationStatus","group":"health","value":"notDisclosed","platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"availability","mock":"editable"},{"id":"$health.sleepSummary","group":"health","value":{"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z","timeZone":"UTC","hasSamples":true,"totalSleepSeconds":27000,"inBedSeconds":30600,"awakeSeconds":1800,"stages":{"unspecified":0,"core":16200,"deep":5400,"rem":5400},"sourceCount":1,"truncated":false,"conflictSeconds":0,"aggregation":"union-awake-rem-deep-core-unspecified"},"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.activitySummary","group":"health","value":{"date":"2026-01-01","timeZone":"UTC","hasSamples":true,"moveMode":"activeEnergy","move":{"value":480,"goal":600,"unit":"kcal"},"exercise":{"value":26,"goal":30,"unit":"min"},"stand":{"value":9,"goal":12,"unit":"count"}},"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.workouts","group":"health","value":{"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z","timeZone":"UTC","hasSamples":true,"truncated":false,"items":[{"id":"550e8400-e29b-41d4-a716-446655440000","activity":"running","start":"2026-01-01T09:00:00.000Z","end":"2026-01-01T09:45:00.000Z","duration":2700,"energyKcal":285,"distanceMeters":5200}]},"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.isAvailable","group":"health","value":true,"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"availability","mock":"editable"},{"id":"$health.requestAuthorization","group":"health","value":true,"legacy":["health"],"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"authorization","mock":"editable"},{"id":"$health.stepCountToday","group":"health","value":{"value":6840,"unit":"count","hasSamples":true,"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z"},"legacy":["health.stepCountToday"],"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.activeEnergyToday","group":"health","value":{"value":420,"unit":"kcal","hasSamples":true,"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z"},"legacy":["health.activeEnergyToday"],"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.heartRateLatest","group":"health","value":{"value":72,"unit":"bpm","hasSamples":true,"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z"},"legacy":["health.heartRateLatest"],"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$location.isAvailable","group":"location","value":true,"platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"availability","mock":"editable"},{"id":"$location.authorizationStatus","group":"location","value":"authorizedWhenInUse","platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"availability","mock":"editable"},{"id":"$location.isAuthorizedForWidgetUpdates","group":"location","value":true,"platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"availability","mock":"editable"},{"id":"$location.requestAuthorization","group":"location","value":true,"legacy":["location.authorization"],"platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.0","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"authorization","mock":"editable"},{"id":"$location.current","group":"location","value":{"latitude":37.3349,"longitude":-122.009,"altitude":0,"accuracy":10,"verticalAccuracy":10,"speed":-1,"course":-1,"timestamp":"2026-01-01T12:00:00Z","accuracyAuthorization":"full","age":0,"isStale":false},"legacy":["location"],"platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.0","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"read","mock":"editable"}] \ No newline at end of file +[{"id":"$music.isAvailable","group":"music","value":true,"platforms":["ios"],"authorization":"musicRead","notes":"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMusic.swift","operation":"availability","mock":"editable"},{"id":"$music.authorizationStatus","group":"music","value":"authorized","platforms":["ios"],"authorization":"musicRead","notes":"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMusic.swift","operation":"availability","mock":"editable"},{"id":"$music.current","group":"music","value":{"provider":"appleMusic","state":"playing","hasItem":true,"title":"Morning Light","artist":"ScriptWidget Sessions","album":"Focus","duration":224,"position":86,"capturedAt":"2026-01-01T12:00:00Z"},"platforms":["ios"],"authorization":"musicRead","notes":"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMusic.swift","operation":"read","mock":"editable"},{"id":"$services.status","group":"services","value":"connected","platforms":["ios","macos"],"authorization":"serviceAccount","notes":"Runtime 1.4: status(service) and profile(service) are asynchronous. Only provider: github. Unknown providers reject with service_operation. Requires an installed owner and services permission. profile additionally requires network and api.github.com in networkDomains, a native connected GitHub account and explicit owner grant. Native Settings handles credentials; scripts cannot log in or obtain tokens. profile returns service, subject, username, displayName, publicRepositories, privateRepositories, followers and following (missing values are null). No live queries in future entries or Live Activities. Eight shared data queries; native requests also share the eight concurrent/32 total network budget, while Web uses its existing preview network budget. Web uses editable best-state samples only; it never authenticates or sends these requests.","minimumRuntimeVersion":"1.4","arguments":["service"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeServices.swift","operation":"read","mock":"editable"},{"id":"$services.profile","group":"services","value":{"service":"github","subject":"42","username":"octocat","displayName":"Mona","publicRepositories":32,"privateRepositories":8,"followers":128,"following":24},"platforms":["ios","macos"],"authorization":"serviceAccount","notes":"Runtime 1.4: status(service) and profile(service) are asynchronous. Only provider: github. Unknown providers reject with service_operation. Requires an installed owner and services permission. profile additionally requires network and api.github.com in networkDomains, a native connected GitHub account and explicit owner grant. Native Settings handles credentials; scripts cannot log in or obtain tokens. profile returns service, subject, username, displayName, publicRepositories, privateRepositories, followers and following (missing values are null). No live queries in future entries or Live Activities. Eight shared data queries; native requests also share the eight concurrent/32 total network budget, while Web uses its existing preview network budget. Web uses editable best-state samples only; it never authenticates or sends these requests.","minimumRuntimeVersion":"1.4","arguments":["service"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeServices.swift","operation":"read","mock":"editable"},{"id":"$device.screen","group":"device","value":{"width":390,"height":844,"scale":3},"legacy":["device","screen"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.language","group":"device","value":"en","legacy":["device","language"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.model","group":"device","value":"iPhone","legacy":["device","model"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.name","group":"device","value":"My iPhone","legacy":["device","name"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.battery","group":"device","value":{"level":0.8,"state":"unplugged"},"legacy":["device","battery"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.systemVersion","group":"device","value":"26.0","legacy":["device","systemVersion"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.isdarkmode","group":"device","value":false,"legacy":["device","isdarkmode"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.totalDiskSpace","group":"device","value":128000000000,"legacy":["device","totalDiskSpace"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$device.freeDiskSpace","group":"device","value":64000000000,"legacy":["device","freeDiskSpace"],"platforms":["ios","macos"],"authorization":"none","notes":"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDevice.swift","operation":"read","mock":"editable"},{"id":"$system.appInfo","group":"system","value":{"name":"ScriptWidget","bundleId":"com.everettjf.scriptwidget","version":"27.1.2","build":"27012"},"legacy":["system","appInfo"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.locale","group":"system","value":"en_US","legacy":["system","locale"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.preferredLanguages","group":"system","value":["en-US"],"legacy":["system","preferredLanguages"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.timeZone","group":"system","value":{"identifier":"UTC","abbreviation":"GMT","offsetSeconds":0},"legacy":["system","timeZone"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.is24HourClock","group":"system","value":false,"legacy":["system","is24HourClock"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.calendarInfo","group":"system","value":{"identifier":"gregorian","firstWeekday":1,"minimumDaysInFirstWeek":1},"legacy":["system","calendarInfo"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.systemUptime","group":"system","value":3600,"legacy":["system","systemUptime"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.memory","group":"system","value":{"physical":8589934592},"legacy":["system","memory"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.thermalState","group":"system","value":"nominal","legacy":["system","thermalState"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.lowPowerMode","group":"system","value":false,"legacy":["system","lowPowerMode"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.brightness","group":"system","value":0.5,"legacy":["system","brightness"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.reduceMotionEnabled","group":"system","value":false,"legacy":["system","reduceMotionEnabled"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.platform","group":"system","value":"ios","legacy":["system","platform"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.hostName","group":"system","value":"My iPhone","legacy":["system","hostName"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.processName","group":"system","value":"ScriptWidgetWidget","legacy":["system","processName"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.osVersionString","group":"system","value":"Version 26.0","legacy":["system","osVersionString"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.processorCount","group":"system","value":6,"legacy":["system","processorCount"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$system.activeProcessorCount","group":"system","value":6,"legacy":["system","activeProcessorCount"],"platforms":["ios","macos"],"authorization":"none","notes":"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeSystem.swift","operation":"read","mock":"editable"},{"id":"$photos.isAvailable","group":"photos","value":true,"platforms":["ios","macos"],"authorization":"photosRead","notes":"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimePhotos.swift","operation":"availability","mock":"editable"},{"id":"$photos.authorizationStatus","group":"photos","value":"authorized","platforms":["ios","macos"],"authorization":"photosRead","notes":"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimePhotos.swift","operation":"availability","mock":"editable"},{"id":"$photos.requestAuthorization","group":"photos","value":true,"platforms":["ios","macos"],"authorization":"photosRead","notes":"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimePhotos.swift","operation":"authorization","mock":"editable"},{"id":"$photos.items","group":"photos","value":{"status":"ready","items":[{"id":"sample.photo","image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAK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Hn1a06rvNhRRRTMgooooAKKKKACiiigAooooAKKKKACiiigAr6a+B3x5uvA00fhjxS7TaO5wj8s1sT3Hcp6r26juD8y0UjahXnRkp03qfthaXdrfW0d7ZSLNDKodHQgqynkEEcEGrFfmf8EvjnffDy6XQtdLXGiytyOrW5J5ZPVe7L+I5zn9JNO1Gx1axi1PTJVnt51DxyIcqynoQazasfXYPGQxMbx36ouUUUUjsP/R+tKKKK6z8/CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigApGZVUsxwBySaR3SNDJIQqqMkngAV4h4w8ZPqjNpumMVthwzdC/8A9j/OnGNzOpUUFdkvjHxm2oFtL0psQdHcdX9h/s/z+leb0UVslY86c3N3YUUUUyAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvePgx8bNT+Gl8NN1Hdc6PM2ZIurRE9Xjz39V6H2PNeD0UjSlWlSkpwdmftNo+saZr+mQ6xo0y3FtcLvjkQ5BH9COhB5B4NaVflf8IPjJrHww1LyZN1zpU7Znt88g9N8eejDuOjDg9iP038P+INH8UaRDrmhTrcWs67kdf1BHUEdCDyDUNWPrsFjo4mPZ9Uf//S+tKKKK6z8/CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACmSSRwxtLKwVVGSTwABSTTRW8TTzsERBkseABXhHi3xfLrchsrIlLVT9C5Hc+3oPz9nGNzOpVUFdkvi/xjJrDmw08lbVTyehkI7n29B+ftwNFFbJWPNnNyd2FFFFMkKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvWvhP8W9b+F+r+bBm40+dh9otieG7bk/uuB379D2x5LRSLp1JU5KcHZo//0/rSiiius/PwooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtYWublgiIMsx6AU26ureyt3urpwkaDJY14H4q8V3GvzeTDmO1Q/Kvdvdv8O1OMbmVWqoIk8WeLZtdlNrbZS1Q8Du59T/AEFcXRRWyVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/9T60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKKKKACq15eW2n2z3d44SNBkk0y/v7XTbV7y9cJGg5J/kPU18/eJfE114hucnKW6H5I/6n1P8qqMbmVWqoLzJPFHim58QXGxcx2yH5E9fdvf+VcpRRWqVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9X60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKo6jqNppVo17etsRfzJ9B6mm6pqlnpFm17ettReg7k+gHrXz34h8Q3niC786c7Y1+5GOij+p9TVRjcxq1lBeY/xH4ku/EN1vk+SFD8kfYe59TXOUUVqedKTbuwooopiCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9b60oqRYZX+4pP0FWV03UX+5byH6Kf8K6z4CzKVFay6Drj/AHLKc/SNv8KsJ4V8Tv8Ac026P0hf/CgfJLsYNFdOngvxc/TTbn8Y2H8xVhPAHjN+mnTfiMfzoH7KfZnIUV3C/Dbxu/TT3/FkH82qyvws8dt/y44+skf/AMVQV7Cp/K/uPPqK9JT4S+OG62yL9ZE/oTVlfg94zbqkK/WQf0BosP6vU/lZ5bRXra/Bjxc3V7Zfq7f0U1YX4JeKD9+4tR/wJz/7JRYf1Wr/ACnjlZmravZaLZte3rYUcADqx9BXpXjnwZH8PNCfXPEeoQKv3Y4k3GSV/wC6gIH4noB1r4t1vXL3Xrw3V2cAcIg6KPQf1PeqjG5y4mTo+7Jaj9e1+91+8NzcnCDhEHRR/j6msOiitTy223dhRRRTEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/Z","width":384,"height":256},{"id":"sample.photo.2","image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/ayiiivVAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9D9rKKKK9UAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAoooo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igAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAo6cmkJCjJ4Arwrxz48N7v0bRHxD0klH8fsv8As+p7/TrdOm5uyE3Y9G8d/tC+JLjwy3gDQp8RDMct2pPmNH08pT/d7FupHHTr8v0UV6FKjGmrQRlKbluFFFFakhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABX1N8Bf2g7rwDNH4V8WO02iucI/LPbE9x3MfqvbqO4PyzRWVWjGrHkmioTcHzRP3Us7y11C1jvrGRZoZlDo6EMrKRkEEcEEVYr8tvgV8fL/AOG10ugeIGe40OVuV6tbknl09V7sv4jnIP6eabqVhrFhDqmlTJcW86h45EOVZT0INfMYrCyoSs9u561Ksqiui7RRRXKan//R+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigApGZUUu5wBySe1NkkSJDJIQqqMkngADua+f8Axv46fWGbStJYrag4Zuhk/wDsf51dOm5uyJbsT+OPHbamX0jR2xbDh5B1k9h/s/z+leV0UV6UIKKsjJu4UUUVYgooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvoL4IfHTVfhdfjTNS3XWiztmSHq0RPWSPPf1Xo3sea+faKzq0o1IuE1oVGbi+aJ+5Gi61pXiLS4Na0SdLm1uF3xyIcgj+hHQg8g8HmtSvyU+DHxs1r4Vap5Em660i4bM9tnkHp5keeA47jow4PYj9UPDviPRfFmjQa/4fnW5tbhdyOv6gjqCDwQeQa+ZxeElQl5Hq0ayqLzP//S+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACo5ZYoI2mmYIiDLMTgADuaSeeG2ha4uGCIgyzHgACvnbxp42m1+Q2NgSlmp+hkI7n29B+J9tKVJzdkTKViXxt44k1x203TSUtFPJ6GQjuf9n0H4n284oor0oxUVZGLdwoooqgCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAr2H4QfGLXvhTrPm2+bjTZ2H2m1J4btvT+64Hfv0PbHj1FRO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Z9z0A5NfCviDxBf+Ir43l6cAcIg+6g9B/U966sPBVfeWxlUvDRkniPxHf8AiS9N1dnai8Rxjoo/x9TXP0UV6aSSsjAKKKKYBRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//Z","width":384,"height":256},{"id":"sample.photo.3","image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDTt1AnooopAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9vKKKK7T0wooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi++865PlwIf3UIPCj1Pq3qa3o0XUfkXCHMX/HHjy/8AF115SZhsoz+7iz1/2m9T+g/U6/w38fv4buRpWqMTYSnr18pj3H+ye4/Ed8+U0V6DpR5eS2h0cqtY/QJHSVBJGQysMgjkEHuKdXzT8MPiF/Zjp4c1t/8ARmOIZGP+rJ/hP+ye3p9On0tXmVKbg7M5pR5XYKKKKzJCiiigAooooAKKKKACiiigAooooAKKKKACiiigApkkiRIZJDtUckmn1xXiK/aSb7DGflTlvc//AFqmcuVXPJzrNYZbhpYiau9ku7C/8RTSMY7H5F/vHqf8K52SeaY5ldmPuc1FRXHKTe5+LY/NsVjpOeIm35dF6IljnmhOYnZT7HFdFYeIpo2Ed986/wB4dR/jXMUURk1sGAzbFYGSnh5teXR+qPWY5ElQSRncp5BFPrivDt+0c32GQ/K/K+x/+vXa12QlzK5+05LmsMyw0cRBWezX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L8LfHbf8uOPrJH/wDFUvaR7hzLuef0V6Svwl8cN1tkX6yJ/Q1ZX4P+M26pCv1kH9AaXtYdxc67nltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AAJz/wCyUvbw7hzx7njlZesaxY6JZNe3zYUcADqx9APWvSvHfg6P4daE+u+JNQgVfuxxJuMkr/3UBAz7noB1r4j13Xr7xBem7vDgDhEHRR6D+p710UIqpqtjejT9pr0JPEHiC+8Q3hubo7UXhIx0Uf4+prBoorvStojvSS0QUUUUxhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//2Q==","width":384,"height":256},{"id":"sample.photo.4","image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQO3UnooooEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK5z1QooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi+9865PlwIf3UIPCj1Pq3qaaR0UKDqPyL3jjx5f+LrrykzDZRn93Fnr/tN6n9B+p2Phv4/fw3cjStUYmxlbr18pj3H+ye4/Ed8+U0U7HqOlFx5LaH6BI6SoJIyGVhkEcgg9xTq+afhh8Q/7MdPDmtv/AKMxxDIx/wBWT/CT/dPb0+nT6WqTyKtJ05WYUUUUGQUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFRTzw20LXFwwREGWY9AKlrxX4i6+9xd/2HbtiOLBkx/E3UD6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ooAKKKKACiiigAooooAK98+Cvxw1T4ZXw0zUd1zo07Zki6tET1ePPf1XofrzXgdFMyq0o1YuE1oftro2s6X4h0yHWdFnW5tbhd8ciHII/oR0IPIPBrTr8o/g58Z9Z+Fup+TJuudJnbM9vnkHp5keeA47jow4PYj9QvD3iHRvFWjw69oE63NrcLuR1/UEdQQeCDyDTTPlMbgpYeXddGf/9L60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACmSyxwxtNMwVFGSTwAB3NNnnhtoWuLhgiIMsx4AAr5+8Y+M5tekNlYkpaKfoXI7n29B+J9k3Y2o0XUdkS+MvGsmtO2nacSlop5PQyEdz7eg/E155RRWbdz1YQUFyxCiiikWFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABXrvwk+L2ufCzWPNt83GnTsPtNqTw3ben91wO/foe2PIqKDOpTjUi4TV0f/T+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtIHublwkaDLMegFNu7u2sbZ7u7cRxoMsx7V87+LfF9z4in8iHMdoh+VO7H+839B2pN2NqNF1H5EvjDxjP4gmNra5jtEPC93I7t/QVw1FFZtnqwgorliFFFFIsKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9T60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAqre3trp1q95euI40GST/nrTNQ1C00u0e9vnCRoOSf5D1Jr5y8U+KrvxJdZOY7dD+7j/qfU/wAqTdjejRdR+RL4r8WXXiO52LmO1Q/Inr/tN7/yrkKKKzPVjFRVkFFFFIoKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP//V+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAqhqep2ekWb318+yNPzJ9AO5NM1XVrLRbJr6/fai9B3Y9gB3NfN/iPxJe+I7zz7j5Yl/wBXGOij+p9TUt2OihQdR+RJ4m8T3niO78yT5IEP7uPsPc+prmaKKg9SMVFWQUUUUigooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/W+tKKkWKV/uKT9BVlNO1CT7kEjfRT/hWR9rcpUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf8AwoFzLuYNFdMvgvxc/TTbn8Y2H8xVlfAPjJ+mnTfiMfzoF7SPc5Ciu4X4b+N36ae/4sg/masL8LfHb/8ALjj6yR//ABVIXtYfzI8/or0lPhL44brbIv1kT+hqynwf8Zt1SFfrIP6A0C9tD+ZHltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AnP8A7JQL6xT/AJjxysrWNZsdDsmvr5sKOAB1Y+gHrXpXjvwfF8OdBfXfEmoQKv3Yok3GSV/7qAgZ9z0A618Q69r194gvTd3hwBwiDoo9B/U96TdjrwtNVveWw/xB4hvvEV6bm6O1F4SMdFH+PqawaKKg9dJJWQUUUUhhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH/9k=","width":384,"height":256}],"unavailableCount":0,"fetchedAt":"2026-01-01T12:00:00Z","source":"system","stale":false},"platforms":["ios","macos"],"authorization":"photosRead","notes":"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimePhotos.swift","operation":"read","mock":"editable"},{"id":"$calendar.isAvailable","group":"calendar","value":true,"platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"availability","mock":"editable"},{"id":"$calendar.authorizationStatus","group":"calendar","value":"authorized","platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"availability","mock":"editable"},{"id":"$calendar.requestAuthorization","group":"calendar","value":true,"platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"authorization","mock":"editable"},{"id":"$calendar.calendars","group":"calendar","value":[{"id":"sample.personal","title":"Personal"}],"platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"read","mock":"editable"},{"id":"$calendar.events","group":"calendar","value":{"status":"ready","items":[{"id":"sample.event","calendarID":"sample.personal","title":"Read and recharge","start":"2026-01-01T15:00:00Z","end":"2026-01-01T15:30:00Z","allDay":false}],"fetchedAt":"2026-01-01T12:00:00Z","source":"system","stale":false,"truncated":false},"platforms":["ios","macos"],"authorization":"calendarRead","notes":"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission.","minimumRuntimeVersion":"1.3","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"read","mock":"editable"},{"id":"$reminders.isAvailable","group":"reminders","value":true,"platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"availability","mock":"editable"},{"id":"$reminders.authorizationStatus","group":"reminders","value":"authorized","platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"availability","mock":"editable"},{"id":"$reminders.requestAuthorization","group":"reminders","value":true,"platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"authorization","mock":"editable"},{"id":"$reminders.lists","group":"reminders","value":[{"id":"sample.reminders","title":"Personal"}],"platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"read","mock":"editable"},{"id":"$reminders.items","group":"reminders","value":{"status":"ready","items":[{"id":"sample.reminder","listID":"sample.reminders","title":"Read a chapter","due":"2026-01-01T16:00:00Z","hasTime":true,"completed":false,"completedAt":null,"priority":0}],"fetchedAt":"2026-01-01T12:00:00Z","source":"system","stale":false,"truncated":false},"platforms":["ios","macos"],"authorization":"remindersRead","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"read","mock":"editable"},{"id":"$reminders.create","group":"reminders","value":{"id":"sample.reminder","listID":"sample.reminders","status":"applied","replayed":false},"platforms":["ios","macos"],"authorization":"remindersWrite","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":["options"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"write","mock":"editable"},{"id":"$reminders.update","group":"reminders","value":{"id":"sample.reminder","listID":"sample.reminders","status":"applied","replayed":false},"platforms":["ios","macos"],"authorization":"remindersWrite","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":["options"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"write","mock":"editable"},{"id":"$reminders.setCompleted","group":"reminders","value":{"id":"sample.reminder","listID":"sample.reminders","status":"applied","replayed":false},"platforms":["ios","macos"],"authorization":"remindersWrite","notes":"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission.","minimumRuntimeVersion":"1.4","arguments":["options"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeReminders.swift","operation":"write","mock":"editable"},{"id":"$health.authorizationStatus","group":"health","value":"notDisclosed","platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"availability","mock":"editable"},{"id":"$health.sleepSummary","group":"health","value":{"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z","timeZone":"UTC","hasSamples":true,"totalSleepSeconds":27000,"inBedSeconds":30600,"awakeSeconds":1800,"stages":{"unspecified":0,"core":16200,"deep":5400,"rem":5400},"sourceCount":1,"truncated":false,"conflictSeconds":0,"aggregation":"union-awake-rem-deep-core-unspecified"},"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.activitySummary","group":"health","value":{"date":"2026-01-01","timeZone":"UTC","hasSamples":true,"moveMode":"activeEnergy","move":{"value":480,"goal":600,"unit":"kcal"},"exercise":{"value":26,"goal":30,"unit":"min"},"stand":{"value":9,"goal":12,"unit":"count"}},"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.workouts","group":"health","value":{"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z","timeZone":"UTC","hasSamples":true,"truncated":false,"items":[{"id":"550e8400-e29b-41d4-a716-446655440000","activity":"running","start":"2026-01-01T09:00:00.000Z","end":"2026-01-01T09:45:00.000Z","duration":2700,"energyKcal":285,"distanceMeters":5200}]},"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.4","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.isAvailable","group":"health","value":true,"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"availability","mock":"editable"},{"id":"$health.requestAuthorization","group":"health","value":true,"legacy":["health"],"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"authorization","mock":"editable"},{"id":"$health.stepCountToday","group":"health","value":{"value":6840,"unit":"count","hasSamples":true,"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z"},"legacy":["health.stepCountToday"],"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.activeEnergyToday","group":"health","value":{"value":420,"unit":"kcal","hasSamples":true,"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z"},"legacy":["health.activeEnergyToday"],"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$health.heartRateLatest","group":"health","value":{"value":72,"unit":"bpm","hasSamples":true,"start":"2026-01-01T00:00:00Z","end":"2026-01-01T12:00:00Z"},"legacy":["health.heartRateLatest"],"platforms":["ios"],"authorization":"healthRead","notes":"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$location.isAvailable","group":"location","value":true,"platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"availability","mock":"editable"},{"id":"$location.authorizationStatus","group":"location","value":"authorizedWhenInUse","platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.0","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"availability","mock":"editable"},{"id":"$location.isAuthorizedForWidgetUpdates","group":"location","value":true,"platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.3","arguments":[],"asynchronous":false,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"availability","mock":"editable"},{"id":"$location.requestAuthorization","group":"location","value":true,"legacy":["location.authorization"],"platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.0","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"authorization","mock":"editable"},{"id":"$location.current","group":"location","value":{"latitude":37.3349,"longitude":-122.009,"altitude":0,"accuracy":10,"verticalAccuracy":10,"speed":-1,"course":-1,"timestamp":"2026-01-01T12:00:00Z","accuracyAuthorization":"full","age":0,"isStale":false},"legacy":["location"],"platforms":["ios"],"authorization":"locationWhenInUse","notes":"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale.","minimumRuntimeVersion":"1.0","arguments":["options?"],"asynchronous":true,"nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeLocation.swift","operation":"read","mock":"editable"},{"id":"$notifications.status","group":"notifications","value":{"authorization":"authorized"},"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":[],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift","operation":"read","mock":"editable"},{"id":"$notifications.pending","group":"notifications","value":[],"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":[],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift","operation":"read","mock":"editable"},{"id":"$notifications.schedule","group":"notifications","value":{"key":"daily","status":"scheduled"},"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift","operation":"write","mock":"editable"},{"id":"$notifications.cancel","group":"notifications","value":{"key":"daily","status":"cancellationRequested"},"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["key"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift","operation":"write","mock":"editable"},{"id":"$health.dailyStatistics","group":"health","value":{"metric":"steps","unit":"count","aggregation":"sum","timeZone":"UTC","items":[{"date":"2026-01-01","value":6840,"hasSamples":true}]},"platforms":["ios"],"authorization":"healthRead","notes":"Runtime 1.6. Read-only daily HealthKit statistics on installed iPhone/iPad widgets. Declare health and minimumRuntimeVersion 1.6, review Health access in native Settings. No separate System Access toggle. Missing readings are null/hasSamples false and cannot establish read denial. No raw samples, persistence or queries in future/Live Activity presentations. Preview fixtures never access real Health data.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift","operation":"read","mock":"editable"},{"id":"$calendar.create","group":"calendar","value":{"id":"sample.event","calendarID":"sample.calendar","status":"applied","replayed":false},"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"write","mock":"editable"},{"id":"$calendar.update","group":"calendar","value":{"id":"sample.event","calendarID":"sample.calendar","status":"applied","replayed":false},"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift","operation":"write","mock":"editable"},{"id":"$weather.forecast","group":"weather","value":{"provider":"MET Norway","attribution":{"text":"Weather data from MET Norway","url":"https://www.met.no/en/free-meteorological-data/Download-services"},"latitude":37.33,"longitude":-122.01,"fetchedAt":"2026-01-01T12:00:00Z","isStale":false,"hours":[{"time":"2026-01-01T12:00:00Z","temperatureC":21,"windMetersPerSecond":2,"precipitationMM":0,"condition":"partlycloudy_day"}]},"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeWeather.swift","operation":"read","mock":"editable"},{"id":"$alarms.status","group":"alarms","value":{"authorization":"authorized"},"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":[],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift","operation":"read","mock":"editable"},{"id":"$alarms.pending","group":"alarms","value":[],"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":[],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift","operation":"read","mock":"editable"},{"id":"$alarms.schedule","group":"alarms","value":{"key":"focus","status":"scheduled","replayed":false},"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift","operation":"write","mock":"editable"},{"id":"$alarms.cancel","group":"alarms","value":{"key":"focus","status":"requested"},"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["key"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift","operation":"write","mock":"editable"},{"id":"$alarms.stop","group":"alarms","value":{"key":"focus","status":"requested"},"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["key"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift","operation":"write","mock":"editable"},{"id":"$alarms.pause","group":"alarms","value":{"key":"focus","status":"requested"},"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["key"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift","operation":"write","mock":"editable"},{"id":"$alarms.resume","group":"alarms","value":{"key":"focus","status":"requested"},"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["key"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift","operation":"write","mock":"editable"},{"id":"$documents.list","group":"documents","value":[{"id":"550e8400-e29b-41d4-a716-446655440000","name":"Sample.json","type":"json","bytes":17},{"id":"550e8400-e29b-41d4-a716-446655440001","name":"Sample.csv","type":"csv","bytes":24}],"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":[],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift","operation":"read","mock":"editable"},{"id":"$documents.readJSON","group":"documents","value":{"goal":12,"done":7},"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["id"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift","operation":"read","mock":"editable"},{"id":"$documents.readCSV","group":"documents","value":{"headers":["day","value"],"rows":[["Monday","7"],["Tuesday","9"]],"truncated":false},"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["id"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift","operation":"read","mock":"editable"},{"id":"$contacts.selected","group":"contacts","value":[{"id":"sample.contact","name":"Alex Example","organization":"Sample","phones":["+1 202 555 0100"],"emails":["alex@example.com"]}],"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":[],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeContacts.swift","operation":"read","mock":"editable"},{"id":"$maps.search","group":"maps","value":[{"name":"Example Park","address":"Sample address","latitude":37.33,"longitude":-122.01}],"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift","operation":"read","mock":"editable"},{"id":"$maps.geocode","group":"maps","value":[{"name":"Example Park","address":"Sample address","latitude":37.33,"longitude":-122.01}],"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["address"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift","operation":"read","mock":"editable"},{"id":"$maps.reverseGeocode","group":"maps","value":[{"name":"Example Park","address":"Sample address","latitude":37.33,"longitude":-122.01}],"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift","operation":"read","mock":"editable"},{"id":"$maps.snapshot","group":"maps","value":{"image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4z8DwHwAFgAI/ScLbtAAAAABJRU5ErkJggg==","width":256,"height":256,"provider":"Apple Maps"},"platforms":["ios","macos"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift","operation":"read","mock":"editable"},{"id":"$home.items","group":"home","value":[{"id":"sample.light","name":"Living Room Lamp","kind":"power","value":true,"isCached":true,"metric":"power","unit":"boolean"},{"id":"scene-sample","name":"Evening","kind":"scene","value":null,"isCached":true,"metric":"scene","unit":"none"}],"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":[],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift","operation":"read","mock":"editable"},{"id":"$home.setPower","group":"home","value":{"id":"sample.light","value":true,"status":"acknowledged"},"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift","operation":"write","mock":"editable"},{"id":"$home.runScene","group":"home","value":{"id":"scene-sample","status":"acknowledged","replayed":false},"platforms":["ios"],"authorization":"systemAccess","notes":"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.","arguments":["options"],"asynchronous":true,"minimumRuntimeVersion":"1.6","nativeSource":"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift","operation":"write","mock":"editable"}] \ No newline at end of file diff --git a/Tools/ScriptWidgetCLI/Resources/validation-host.js b/Tools/ScriptWidgetCLI/Resources/validation-host.js index 3e9043b9..e7868a2a 100644 --- a/Tools/ScriptWidgetCLI/Resources/validation-host.js +++ b/Tools/ScriptWidgetCLI/Resources/validation-host.js @@ -12,14 +12,16 @@ const asyncValue = call => ({then(resolve, reject) { try { return resolve(call()); } catch (e) { if (reject) return reject(String(e)); throw e; }}}); const includes = Function.prototype.call.bind(Array.prototype.includes); const groups = {}; - const caps = {health:'health',location:'location',calendar:'calendar',photos:'photos',reminders:'reminders',services:'services',music:'music'}; + const caps = {health:'health',location:'location',calendar:'calendar',photos:'photos',reminders:'reminders',services:'services',music:'music',notifications:'notifications',alarms:'alarms',maps:'maps',weather:'weather',documents:'documents',contacts:'contacts',home:'home'}; for (const item of catalog) { const [group, method] = item.id.split('.'); const object = groups[group] ?? (groups[group] = {}); object[method] = function () { const args = Array.from(arguments); const call = () => { - const capability = item.group === 'reminders' && includes(['create','update','setCompleted'],method) ? 'remindersWrite' : caps[item.group]; + if (item.minimumRuntimeVersion === '1.6' && !permit('runtime1.6','')) throw Error('[system_runtime] Declare minimumRuntimeVersion 1.6 or later'); + if (item.minimumRuntimeVersion === '1.6' && item.operation === 'write') throw Error('[read_only] Native CLI renders cannot run system actions'); + const capability = item.group === 'calendar' && includes(['create','update'],method) ? 'calendarWrite' : item.group === 'reminders' && includes(['create','update','setCompleted'],method) ? 'remindersWrite' : caps[item.group]; if (capability && !includes(['isAvailable','authorizationStatus','isAuthorizedForWidgetUpdates'],method) && !permit(capability,'')) throw Error('[permission_denied] Declare '+capability+' in widget.json'); if (args.length && !reported.has(item.id)) {reported.add(item.id); note('mock.arguments_not_validated','Offline reply for '+item.id+' does not certify real system query arguments.');} if (capability && item.operation === 'read' && !reserve()) throw Error('[resource_limit] System-data query budget exceeded'); @@ -35,7 +37,7 @@ return item.asynchronous ? asyncValue(call) : call(); }; } - for (const group of ['$device','$system','$calendar','$health','$location','$photos','$reminders','$services','$music']) globalThis[group] = Object.freeze(groups[group] || {}); + for (const group of Object.keys(groups)) globalThis[group] = Object.freeze(groups[group] || {}); function http(method, url, metadata) { return asyncValue(() => { if (++networkRequests > 32) throw Error('[resource_limit] Network fixture query budget exceeded'); diff --git a/Tools/ScriptWidgetCLI/ScriptWidgetCLI.xcodeproj/project.pbxproj b/Tools/ScriptWidgetCLI/ScriptWidgetCLI.xcodeproj/project.pbxproj index 3156bfce..c3c2573e 100644 --- a/Tools/ScriptWidgetCLI/ScriptWidgetCLI.xcodeproj/project.pbxproj +++ b/Tools/ScriptWidgetCLI/ScriptWidgetCLI.xcodeproj/project.pbxproj @@ -57,11 +57,22 @@ 72AA114107506BE3AE708C13 /* ScriptModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AC799313C3197689F1A906C /* ScriptModel.swift */; }; 72DC6D622A75391C9582ECB9 /* ScriptWidgetRecordsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B05AB13CF7EEB977AF0102 /* ScriptWidgetRecordsView.swift */; }; F0EF7680531C44E78A77ECAB /* ScriptWidgetCloudJSONView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C95F627B7AAA4A96AF8FD652 /* ScriptWidgetCloudJSONView.swift */; }; + FD759D35754342E38900037F /* ScriptWidgetSystemAccessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 419456A0002B4CC5A04B4C37 /* ScriptWidgetSystemAccessView.swift */; }; 768C0215C3BB8EF7DA908EC6 /* ScriptWidgetElementTagDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52F28D26C0C5131742555232 /* ScriptWidgetElementTagDate.swift */; }; 77CDFEBAA10BF9D8D2B34F84 /* ScriptWidgetAttributeRotation3DEffectModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16C9FD4B4DC6C668AF39EE39 /* ScriptWidgetAttributeRotation3DEffectModifier.swift */; }; 7BADA9DF2237397473BA33C3 /* ScriptWidgetStorageProfiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66C6D05A624D8D0DB750AF9E /* ScriptWidgetStorageProfiles.swift */; }; 7C15B0E6C184D7473773C48A /* ScriptWidgetRuntimeFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E4CA81CF5D27A626C845BA4 /* ScriptWidgetRuntimeFile.swift */; }; 4765703F555240FD8B843727 /* ScriptWidgetRuntimeCloudJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C16994AEAC4DC7B56EBBB3 /* ScriptWidgetRuntimeCloudJSON.swift */; }; + 827F0361D8CC43E1A5F25B5B /* ScriptWidgetRuntimeHome.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEFB05DBBBF84D6AB35E3895 /* ScriptWidgetRuntimeHome.swift */; }; + 4FF0658BE63747C6869F2161 /* ScriptWidgetRuntimeContacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681A4CD2C32B4FB08DBA434D /* ScriptWidgetRuntimeContacts.swift */; }; + 3B26B14F6D9C46B1B2ACBAD3 /* ScriptWidgetRuntimeDocuments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91729BD7818C44D9BCD830BD /* ScriptWidgetRuntimeDocuments.swift */; }; + 82F56DFE964A4EC9B1E93CD0 /* ScriptWidgetRuntimeAlarms.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC02EF3176C34D37BDB789ED /* ScriptWidgetRuntimeAlarms.swift */; }; + 6DFDEE2D172F48BBBE4389C7 /* ScriptWidgetRuntimeWeather.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28230F40942A49A3903F1D76 /* ScriptWidgetRuntimeWeather.swift */; }; + 095B6A7BD12C4EC585837C8A /* ScriptWidgetRuntimeMaps.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52547DBC00FA4A9E860D4E0B /* ScriptWidgetRuntimeMaps.swift */; }; + E0B314E8753645EEBE740D85 /* ScriptWidgetRuntimeHealthHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72614CF766604706A6D8922D /* ScriptWidgetRuntimeHealthHistory.swift */; }; + 05780F4B9BD84EFAB79EAA0C /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FCDFCDB1622429A8FA74862 /* ScriptWidgetRuntimeCalendarWrites.swift */; }; + 483051ECDB314908ABF77DA6 /* ScriptWidgetRuntimeNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EF46E70B36645D6B2570CDE /* ScriptWidgetRuntimeNotifications.swift */; }; + 78242FAAD90949A1A69A56C3 /* ScriptWidgetRuntimeSystemServices.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E44A71C5E74B0A90C28F2D /* ScriptWidgetRuntimeSystemServices.swift */; }; 7C1E07AEE5B4391EDE276A26 /* ScriptWidgetRuntimeConsole.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7718541A936C5B6158CEC828 /* ScriptWidgetRuntimeConsole.swift */; }; 7C26F00AB29E25F691A20494 /* ScriptWidgetAttributeGeneral.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28D158D6BC46CC44E9E461AE /* ScriptWidgetAttributeGeneral.swift */; }; 7DAEC073E680BD60C3FBABAB /* api-catalog.json in Resources */ = {isa = PBXBuildFile; fileRef = 5011ED35898ED75BA7F1A1F2 /* api-catalog.json */; }; @@ -171,6 +182,7 @@ 52F28D26C0C5131742555232 /* ScriptWidgetElementTagDate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetElementTagDate.swift; sourceTree = ""; }; 56B05AB13CF7EEB977AF0102 /* ScriptWidgetRecordsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRecordsView.swift; sourceTree = ""; }; C95F627B7AAA4A96AF8FD652 /* ScriptWidgetCloudJSONView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetCloudJSONView.swift; sourceTree = ""; }; + 419456A0002B4CC5A04B4C37 /* ScriptWidgetSystemAccessView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetSystemAccessView.swift; sourceTree = ""; }; 58A58E5429F7356FA9F5C203 /* ScriptManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptManager.swift; sourceTree = ""; }; 5BF63F313011E594BD60F288 /* ScriptWidgetCLI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ScriptWidgetCLI.app; sourceTree = BUILT_PRODUCTS_DIR; }; 66B36B4A85B7D7A8BCA1082B /* ScriptWidgetRuntimeFetch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeFetch.swift; sourceTree = ""; }; @@ -201,6 +213,16 @@ 9D60B046B70D59D4F539B7E7 /* ScriptWidgetRuntimeReminders.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeReminders.swift; sourceTree = ""; }; 9E4CA81CF5D27A626C845BA4 /* ScriptWidgetRuntimeFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeFile.swift; sourceTree = ""; }; 52C16994AEAC4DC7B56EBBB3 /* ScriptWidgetRuntimeCloudJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeCloudJSON.swift; sourceTree = ""; }; + EEFB05DBBBF84D6AB35E3895 /* ScriptWidgetRuntimeHome.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeHome.swift; sourceTree = ""; }; + 681A4CD2C32B4FB08DBA434D /* ScriptWidgetRuntimeContacts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeContacts.swift; sourceTree = ""; }; + 91729BD7818C44D9BCD830BD /* ScriptWidgetRuntimeDocuments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeDocuments.swift; sourceTree = ""; }; + AC02EF3176C34D37BDB789ED /* ScriptWidgetRuntimeAlarms.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeAlarms.swift; sourceTree = ""; }; + 28230F40942A49A3903F1D76 /* ScriptWidgetRuntimeWeather.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeWeather.swift; sourceTree = ""; }; + 52547DBC00FA4A9E860D4E0B /* ScriptWidgetRuntimeMaps.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeMaps.swift; sourceTree = ""; }; + 72614CF766604706A6D8922D /* ScriptWidgetRuntimeHealthHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeHealthHistory.swift; sourceTree = ""; }; + 4FCDFCDB1622429A8FA74862 /* ScriptWidgetRuntimeCalendarWrites.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeCalendarWrites.swift; sourceTree = ""; }; + 4EF46E70B36645D6B2570CDE /* ScriptWidgetRuntimeNotifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeNotifications.swift; sourceTree = ""; }; + 84E44A71C5E74B0A90C28F2D /* ScriptWidgetRuntimeSystemServices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeSystemServices.swift; sourceTree = ""; }; 9FCA745E5877B5491EF6AD86 /* WorkerMain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkerMain.swift; sourceTree = ""; }; A0BE8865811BC2E348AFB47A /* ScriptWidgetAttributeShadowModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetAttributeShadowModifier.swift; sourceTree = ""; }; A1F360ABE599E880EB4925ED /* ButtonActionAppIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonActionAppIntent.swift; sourceTree = ""; }; @@ -314,6 +336,7 @@ 81F85786A10341E097E9DE73 /* ScriptWidgetCloudJSON.swift */, 56B05AB13CF7EEB977AF0102 /* ScriptWidgetRecordsView.swift */, C95F627B7AAA4A96AF8FD652 /* ScriptWidgetCloudJSONView.swift */, + 419456A0002B4CC5A04B4C37 /* ScriptWidgetSystemAccessView.swift */, 66C6D05A624D8D0DB750AF9E /* ScriptWidgetStorageProfiles.swift */, 88FBB82C566EF24581DBB278 /* ScriptWidgetStorageUpgrade.swift */, 4898BF5AB25F5560504579BE /* ScriptWidgetStorageUpgradeView.swift */, @@ -568,6 +591,16 @@ 66B36B4A85B7D7A8BCA1082B /* ScriptWidgetRuntimeFetch.swift */, 9E4CA81CF5D27A626C845BA4 /* ScriptWidgetRuntimeFile.swift */, 52C16994AEAC4DC7B56EBBB3 /* ScriptWidgetRuntimeCloudJSON.swift */, + EEFB05DBBBF84D6AB35E3895 /* ScriptWidgetRuntimeHome.swift */, + 681A4CD2C32B4FB08DBA434D /* ScriptWidgetRuntimeContacts.swift */, + 91729BD7818C44D9BCD830BD /* ScriptWidgetRuntimeDocuments.swift */, + AC02EF3176C34D37BDB789ED /* ScriptWidgetRuntimeAlarms.swift */, + 28230F40942A49A3903F1D76 /* ScriptWidgetRuntimeWeather.swift */, + 52547DBC00FA4A9E860D4E0B /* ScriptWidgetRuntimeMaps.swift */, + 72614CF766604706A6D8922D /* ScriptWidgetRuntimeHealthHistory.swift */, + 4FCDFCDB1622429A8FA74862 /* ScriptWidgetRuntimeCalendarWrites.swift */, + 4EF46E70B36645D6B2570CDE /* ScriptWidgetRuntimeNotifications.swift */, + 84E44A71C5E74B0A90C28F2D /* ScriptWidgetRuntimeSystemServices.swift */, 72999E36BA973789D4B9833E /* ScriptWidgetRuntimeHealth.swift */, DD66F0D5D5A8268A8FBD3344 /* ScriptWidgetRuntimeLocation.swift */, 91E69BD0DC00230A3E1BF379 /* ScriptWidgetRuntimeMusic.swift */, @@ -771,6 +804,7 @@ 311E16A1025A41A991EB15DF /* ScriptWidgetCloudJSON.swift in Sources */, 72DC6D622A75391C9582ECB9 /* ScriptWidgetRecordsView.swift in Sources */, F0EF7680531C44E78A77ECAB /* ScriptWidgetCloudJSONView.swift in Sources */, + FD759D35754342E38900037F /* ScriptWidgetSystemAccessView.swift in Sources */, 96FF84D543C3926DD61FBDCF /* ScriptWidgetRunningState.swift in Sources */, 56B7B77DE398881D7CF732EC /* ScriptWidgetRuntime.swift in Sources */, 2619A4F58CFC814CEC1AD878 /* ScriptWidgetRuntimeCalendar.swift in Sources */, @@ -782,6 +816,16 @@ 727350AEDCC719A184D5995C /* ScriptWidgetRuntimeFetch.swift in Sources */, 7C15B0E6C184D7473773C48A /* ScriptWidgetRuntimeFile.swift in Sources */, 4765703F555240FD8B843727 /* ScriptWidgetRuntimeCloudJSON.swift in Sources */, + 827F0361D8CC43E1A5F25B5B /* ScriptWidgetRuntimeHome.swift in Sources */, + 4FF0658BE63747C6869F2161 /* ScriptWidgetRuntimeContacts.swift in Sources */, + 3B26B14F6D9C46B1B2ACBAD3 /* ScriptWidgetRuntimeDocuments.swift in Sources */, + 82F56DFE964A4EC9B1E93CD0 /* ScriptWidgetRuntimeAlarms.swift in Sources */, + 6DFDEE2D172F48BBBE4389C7 /* ScriptWidgetRuntimeWeather.swift in Sources */, + 095B6A7BD12C4EC585837C8A /* ScriptWidgetRuntimeMaps.swift in Sources */, + E0B314E8753645EEBE740D85 /* ScriptWidgetRuntimeHealthHistory.swift in Sources */, + 05780F4B9BD84EFAB79EAA0C /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */, + 483051ECDB314908ABF77DA6 /* ScriptWidgetRuntimeNotifications.swift in Sources */, + 78242FAAD90949A1A69A56C3 /* ScriptWidgetRuntimeSystemServices.swift in Sources */, B94F843A0032914002F41258 /* ScriptWidgetRuntimeHealth.swift in Sources */, 85E640C7E6A10F44B81BAE0C /* ScriptWidgetRuntimeLocation.swift in Sources */, AF7AD22F3F68DBF68AD9C1B0 /* ScriptWidgetRuntimeMusic.swift in Sources */, diff --git a/Tools/ScriptWidgetCLI/Tests/smoke.py b/Tools/ScriptWidgetCLI/Tests/smoke.py index e38b0fa8..81334539 100644 --- a/Tools/ScriptWidgetCLI/Tests/smoke.py +++ b/Tools/ScriptWidgetCLI/Tests/smoke.py @@ -136,6 +136,17 @@ def test_missing_render_and_unknown_native_tag_are_failures(self): self.run_cli('render','--output',self.root/'out',code=1) self.source('$render(Hello);') self.run_cli('render','--output',self.root/'out',code=1) + def test_runtime_16_system_fixtures_remain_offline_and_writes_are_denied(self): + self.manifest.update(minimumRuntimeVersion='1.6', permissions=['notifications']) + self.save_manifest() + self.source('const status=await $notifications.status(); if(status.authorization!=="authorized")throw new Error("mock status"); let denied=false; try{await $notifications.schedule({key:"test",title:"Test",body:"Body",daily:{hour:20,minute:0}});}catch(e){denied=String(e).includes("read_only");} if(!denied)throw new Error("write allowed"); $render(Offline only);') + self.run_cli('render','--output',self.root/'out') + self.manifest.pop('minimumRuntimeVersion'); self.save_manifest() + self.source('await $notifications.status(); $render(unexpected);') + self.run_cli('render','--output',self.root/'version-denied',code=1) + self.manifest.update(minimumRuntimeVersion='1.6',permissions=[]); self.save_manifest() + self.run_cli('render','--output',self.root/'permission-denied',code=1) + def test_execution_deadline_and_current_environment(self): self.run_cli('doctor') self.source('while(true) {}') diff --git a/Tools/ScriptWidgetCLI/Worker/WorkerMain.swift b/Tools/ScriptWidgetCLI/Worker/WorkerMain.swift index 72268a37..045864d5 100644 --- a/Tools/ScriptWidgetCLI/Worker/WorkerMain.swift +++ b/Tools/ScriptWidgetCLI/Worker/WorkerMain.swift @@ -118,6 +118,7 @@ struct ValidationWorkerMain { guard let target=URL(string:url), ScriptWidgetFetchPolicy.validationError(for:target) == nil else { return false } return ScriptWidgetNetworkPolicy.packageAllows(target,package:package) } + if capability == "runtime1.6" { return WidgetRuntimeRequirement.supports("1.6", current: manifest?.minimumRuntimeVersion ?? "0.0") } return manifest == nil || manifest!.permissions.contains(where:{$0.rawValue == capability}) } let note:@convention(block)(String,String)->Void={ code,message in if diagnostics.count < 128 {diagnostics.append(["severity":"warning","code":code,"message":String(message.prefix(2048))])} } diff --git a/Web/preview-engine/package.json b/Web/preview-engine/package.json index 2d678ce4..6e823244 100644 --- a/Web/preview-engine/package.json +++ b/Web/preview-engine/package.json @@ -1,6 +1,6 @@ { "name": "@scriptwidget/preview-engine", - "version": "0.19.0", + "version": "0.20.0", "private": true, "type": "module", "description": "Browser and Node execution of ScriptWidget JSX packages that mirrors the native JavaScriptCore runtime contract.", @@ -17,5 +17,6 @@ "build": "node scripts/build-browser.mjs", "coverage": "node scripts/coverage-report.mjs", "compare": "node scripts/compare-snapshots.mjs" - } + }, + "license": "Apache-2.0" } diff --git a/Web/preview-engine/src/contract.js b/Web/preview-engine/src/contract.js index bdaef00b..7177a169 100644 --- a/Web/preview-engine/src/contract.js +++ b/Web/preview-engine/src/contract.js @@ -5,7 +5,7 @@ export const runtimeContract = Object.freeze({ // Native 1.3 uses cooperative checks and disallows dynamic code. The web // host keeps its disposable Worker; both expose Calendar, with distinct caches. - nativeAPIVersion: "1.5", + nativeAPIVersion: "1.6", nativeCompilerFingerprint: "scriptwidget-babel-v3", apiVersion: "1.2", compilerFingerprint: "scriptwidget-babel-v2", @@ -17,7 +17,7 @@ export const runtimeContract = Object.freeze({ maximumElementDepth: 64, maximumPropsPerElement: 128, maximumDataQueries: 8, - globalAPIs: Object.freeze(["$calendar", "$component", "$console", "$device", "$dynamic_island", "$element", "$error", "$fetch", "$file", "$getenv", "$health", "$http", "$icloud", "$import", "$location", "$music", "$photos", "$reminders", "$render", "$runtime", "$services", "$storage", "$system", "$xml", "console", "fetch"]), + globalAPIs: Object.freeze(["$alarms", "$calendar", "$component", "$console", "$contacts", "$device", "$documents", "$dynamic_island", "$element", "$error", "$fetch", "$file", "$getenv", "$health", "$home", "$http", "$icloud", "$import", "$location", "$maps", "$music", "$notifications", "$photos", "$reminders", "$render", "$runtime", "$services", "$storage", "$system", "$weather", "$xml", "console", "fetch"]), }); /// Bumped whenever the web host changes observable execution semantics. diff --git a/Web/preview-engine/src/kernel.js b/Web/preview-engine/src/kernel.js index ddb2b015..0ebf49f6 100644 --- a/Web/preview-engine/src/kernel.js +++ b/Web/preview-engine/src/kernel.js @@ -1158,6 +1158,136 @@ export function scriptWidgetKernel(global, host, configJSON) { } catch (error) { reject(StringCtor(error.message ?? error)); } }); } + // Runtime 1.6: isolated system simulations. Manifest/action checks execute + // before editable fixtures; no fixture grants native access or real I/O. + const systemIncludes = Function.prototype.call.bind(Array.prototype.includes); + const systemFinite = Number.isFinite; + const systemState = JSON.parse(JSONStringify(fixtures.systemState ?? {version:1,notifications:[],alarms:[],events:[],home:{},receipts:[]})); + const systemMethods = { + notifications: ["status","pending","schedule","cancel"], alarms: ["status","pending","schedule","cancel","stop","pause","resume"], + maps: ["search","geocode","reverseGeocode","snapshot"], weather: ["forecast"], documents: ["list","readJSON","readCSV"], contacts: ["selected"], home: ["items","setPower","runScene"], health: ["dailyStatistics"], calendar: ["create","update"] + }; + const systemUUID = value => typeof value === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(value); + const systemKey = value => typeof value === "string" && /^[a-zA-Z0-9_-]{1,64}$/.test(value); + const systemText = (value, max=256) => typeof value === "string" && value.trim().length > 0 && utf8ByteLength(value) <= max && !/[\x00-\x1f\x7f]/.test(value); + const systemNumber = (value,min,max) => typeof value === "number" && systemFinite(value) && value >= min && value <= max; + const systemDate = value => typeof value === "string" && value.length<=64 && value.includes("T") && systemFinite(DateCtor.parse(value)); + function systemCall(group, method, args) { + return nativePromise((resolve,reject) => { + const fail = code => { throw new Error(`[${code}] Simulated system operation rejected; real device data is unchanged.`); }; + try { + const permissions = config.manifest?.permissions ?? []; + const permission = group === "calendar" ? "calendarWrite" : group; + if (!config.hasManifest || !systemIncludes(permissions,permission) || (group === "calendar" && !systemIncludes(permissions,"calendar"))) fail("permission_denied"); + if (!/^1\.(?:[6-9]|[1-9][0-9]+)$/.test(config.manifest.minimumRuntimeVersion ?? "")) fail("system_runtime"); + const writing = (group === "notifications" && systemIncludes(["schedule","cancel"],method)) || (group === "alarms" && !systemIncludes(["status","pending"],method)) || group === "calendar" || (group === "home" && method !== "items"); + if (timelineProjection || liveActivityPresentation || (writing && !actionMode)) fail("read_only"); + if (++dataQueries > contract.maximumDataQueries) fail("query_limit"); + const scope = fixtures.systemAccess; + if (group !== "health" && scope !== undefined && (!scope || !ArrayIsArray(scope.permissions) || !systemIncludes(scope.permissions,permission))) fail("permission_denied"); + if (!systemState || systemState.version !== 1 || ObjectKeys(systemState).some(key => !systemIncludes(["version","notifications","alarms","events","home","receipts"],key)) || !ArrayIsArray(systemState.notifications) || !ArrayIsArray(systemState.alarms) || !ArrayIsArray(systemState.events) || !ArrayIsArray(systemState.receipts) || !systemState.home || typeof systemState.home !== "object" || systemState.receipts.length > 128 || systemState.events.length > 128 || systemState.alarms.length > 32 || systemState.notifications.length > 32 || utf8ByteLength(JSONStringify(systemState)) > 262144) fail("mock_invalid"); + const rule = apiMocks[`$${group}.${method}`]; + if (rule && Object.prototype.hasOwnProperty.call(rule,"error")) throw new Error(nativeString(rule.error)); + const sample = rule && Object.prototype.hasOwnProperty.call(rule,"value") ? bridgeValue(rule.value,0) : undefined; + const raw = args[0]; + const input = raw && typeof raw === "object" && !ArrayIsArray(raw) ? bridgeDictionary(raw,0) : null; + const fields = allowed => { if (!input || ObjectKeys(input).some(k => !systemIncludes(allowed,k)) || utf8ByteLength(JSONStringify(input))>16384) fail("invalid_options"); }; + const coordinates = () => { if (!systemNumber(input?.latitude,-90,90) || !systemNumber(input?.longitude,-180,180) || (input.radiusMeters!==undefined && !systemNumber(input.radiusMeters,100,50000))) fail("invalid_options"); }; + const receipt = (operation) => { + if (!systemUUID(input?.requestID)) fail("invalid_options"); + const fingerprint=JSONStringify([group,method,ObjectKeys(input).sort().map(k=>[k,input[k]])]); + const prior=systemState.receipts.find(r=>r.requestID===input.requestID); + if (prior) { if(prior.fingerprint!==fingerprint) fail("request_conflict"); if(prior.state!=="completed") fail("outcome_unknown"); return {...prior.result,replayed:true}; } + if(systemState.receipts.length>=128)fail("limit_exceeded"); + const result=operation(); + systemState.receipts.push({requestID:input.requestID,fingerprint,state:fixtures.systemCommitUncertain===true?"prepared":"completed",result}); + if(fixtures.systemCommitUncertain===true)fail("outcome_unknown"); + return {...result,replayed:false}; + }; + let result; + if(group==="notifications") { + if(method==="status") result=sample??{authorization:"authorized"}; + else if(method==="pending") result=systemState.notifications.length?systemState.notifications.map(item=>{ + let date=item.date; + if(item.daily){const next=new DateCtor();next.setHours(item.daily.hour,item.daily.minute,0,0);if(next.getTime()<=DateCtor.now())next.setDate(next.getDate()+1);date=next.toISOString();} + return {key:item.key,title:item.title,body:item.body,repeats:!!item.daily,date}; + }):(sample??[]); + else if(method==="schedule") { + fields(["key","title","body","date","daily"]); + if(!systemKey(input.key)||!systemText(input.title)||!systemText(input.body,1024)||(input.date===undefined)===(input.daily===undefined))fail("invalid_options"); + if(input.date!==undefined&&(!systemDate(input.date)||DateCtor.parse(input.date)<=DateCtor.now()||DateCtor.parse(input.date)-DateCtor.now()>366*86400000))fail("invalid_options"); + if(input.daily!==undefined&&(!input.daily||typeof input.daily!=="object"||ArrayIsArray(input.daily)||ObjectKeys(input.daily).some(k=>!systemIncludes(["hour","minute"],k))||!systemNumber(input.daily.hour,0,23)||!systemNumber(input.daily.minute,0,59)||input.daily.hour%1!==0||input.daily.minute%1!==0))fail("invalid_options"); + if(apiMocks["$notifications.status"]?.value?.authorization!==undefined&&!systemIncludes(["authorized","provisional"],apiMocks["$notifications.status"].value.authorization))fail("permission_denied"); + const index=systemState.notifications.findIndex(n=>n.key===input.key); + if(index<0&&systemState.notifications.length>=32)fail("limit_exceeded"); + if(index>=0)systemState.notifications.splice(index,1); + systemState.notifications.push({...input}); result={key:input.key,status:"scheduled"}; + } else {if(!systemKey(raw))fail("invalid_options");systemState.notifications=systemState.notifications.filter(n=>n.key!==raw);result={key:raw,status:"cancellationRequested"};} + } else if(group==="calendar") { + fields(["requestID","calendarID","title","start","end","allDay",...(method==="update"?["id"]:[])]); + if(!systemText(input.calendarID)||!systemText(input.title,512)||!systemDate(input.start)||!systemDate(input.end)||DateCtor.parse(input.end)<=DateCtor.parse(input.start)||DateCtor.parse(input.end)-DateCtor.parse(input.start)>366*86400000||(input.allDay!==undefined&&typeof input.allDay!=="boolean"))fail("invalid_options"); + if(ArrayIsArray(fixtures.calendarSelection)&&!systemIncludes(fixtures.calendarSelection,input.calendarID))fail("permission_denied"); + result=receipt(()=>{ + if(method==="update"&&!systemState.events.some(e=>e.id===input.id&&e.calendarID===input.calendarID))fail("permission_denied"); + if(method==="create"&&systemState.events.length>=128)fail("limit_exceeded"); + const id=method==="update"?input.id:`event-${input.requestID}`; + systemState.events=systemState.events.filter(e=>e.id!==id);systemState.events.push({...input,id});return {id,calendarID:input.calendarID,status:"applied"}; + }); + } else if(group==="alarms") { + if(method==="status")result=sample??{authorization:"authorized"}; + else if(method==="pending")result=systemState.alarms.length?systemState.alarms.map(item=>({key:item.key,state:item.state})):(sample??[]); + else if(method==="schedule") { + fields(["requestID","key","title","date","seconds"]); + if(!systemKey(input.key)||!systemText(input.title,128)||(input.date===undefined)===(input.seconds===undefined)||(input.seconds!==undefined&&!systemNumber(input.seconds,60,86400))||(input.date!==undefined&&(!systemDate(input.date)||DateCtor.parse(input.date)<=DateCtor.now()||DateCtor.parse(input.date)-DateCtor.now()>366*86400000)))fail("invalid_options"); + if(apiMocks["$alarms.status"]?.value?.authorization!==undefined&&apiMocks["$alarms.status"].value.authorization!=="authorized")fail("permission_denied"); + result=receipt(()=>{if(systemState.alarms.some(a=>a.key===input.key))fail("request_conflict");if(systemState.alarms.length>=32)fail("limit_exceeded");systemState.alarms.push({...input,state:input.seconds===undefined?"scheduled":"countdown"});return {key:input.key,status:"scheduled"};}); + } else { + if(!systemKey(raw))fail("invalid_options");const alarm=systemState.alarms.find(a=>a.key===raw);if(!alarm)fail("unavailable"); + if(method==="cancel")systemState.alarms=systemState.alarms.filter(a=>a.key!==raw);else alarm.state=method==="pause"?"paused":method==="stop"?"stopped":"countdown"; + result={key:raw,status:"requested"}; + } + } else if(group==="health") { + fields(["metric","days"]);if(!systemIncludes(["steps","activeEnergy","walkingDistance","water","bodyMass","heartRate"],input.metric)||!systemNumber(input.days??7,1,31)||(input.days??7)%1!==0)fail("invalid_options"); + result=sample??{metric:input.metric,unit:"count",aggregation:"sum",timeZone:"UTC",items:[]}; + if(!result||!ArrayIsArray(result.items)||result.items.length>31)fail("mock_invalid"); + if(apiMocks["$health.isAvailable"]?.value===false)fail("unavailable"); + const units={steps:"count",activeEnergy:"kcal",walkingDistance:"m",water:"mL",bodyMass:"kg",heartRate:"count/min"}; + const averages=systemIncludes(["bodyMass","heartRate"],input.metric); + if(result.metric!==input.metric){const typical={steps:6840,activeEnergy:285,walkingDistance:4200,water:1800,bodyMass:68.2,heartRate:72};result={...result,unit:units[input.metric],aggregation:averages?"average":"sum",items:result.items.map((row,i)=>({...row,value:row.hasSamples?typical[input.metric]+(averages?i/10:i*10):null}))};} + result={...result,metric:input.metric,items:result.items.slice(-(input.days??7))}; + } else if(group==="weather") { + fields(["latitude","longitude","hours"]);coordinates();if(!systemNumber(input.hours??24,1,48)||(input.hours??24)%1!==0)fail("invalid_options"); + if(!systemIncludes(permissions,"network")||!hostMatches("api.met.no",config.manifest.networkDomains??[]))fail("permission_denied"); + if(!sample||!ArrayIsArray(sample.hours))fail("mock_missing");result={...sample,latitude:Math.round(input.latitude*100)/100,longitude:Math.round(input.longitude*100)/100,hours:sample.hours.slice(0,input.hours??24)}; + } else if(group==="maps") { + if(method==="geocode"){if(!systemText(raw))fail("invalid_options");} + else{fields(method==="search"?["latitude","longitude","radiusMeters","query"]:method==="snapshot"?["latitude","longitude","radiusMeters","size"]:["latitude","longitude","radiusMeters"]);coordinates();if(method==="search"&&!systemText(input.query))fail("invalid_options");if(method==="snapshot"&&(!systemNumber(input.size??256,128,512)||(input.size??256)%1!==0))fail("invalid_options");} + result=sample??(method==="snapshot"?null:[]);if(result===null)fail("mock_missing"); + } else if(group==="documents") { + const list=apiMocks["$documents.list"]?.value??[]; + if(method==="list")result=list; + else{if(!systemUUID(raw)||!ArrayIsArray(list)||!list.some(d=>d.id===raw&&d.type===(method==="readJSON"?"json":"csv")))fail("permission_denied");if(sample===undefined)fail("mock_missing");result=sample;} + } else if(group==="contacts") { + if(!ArrayIsArray(sample??[]))fail("mock_invalid");result=(sample??[]).filter(c=>!ArrayIsArray(scope?.contacts)||systemIncludes(scope.contacts,c.id)).slice(0,20); + } else if(group==="home") { + const items=apiMocks["$home.items"]?.value??[]; + if(!ArrayIsArray(items))fail("mock_invalid");const selected=items.filter(i=>!ArrayIsArray(scope?.home)||systemIncludes(scope.home,i.id)).slice(0,20); + if(method==="items")result=selected.map(i=>({...i,value:systemState.home[i.id]??i.value,isCached:true})); + else{ + fields(method==="runScene"?["id","requestID"]:["id","on"]);const item=selected.find(i=>i.id===input.id);if(!item)fail("permission_denied"); + if(method==="runScene"){if(item.kind!=="scene")fail("permission_denied");result=receipt(()=>({id:item.id,status:"acknowledged"}));} + else {if(item.kind!=="power"||typeof input.on!=="boolean")fail("invalid_options");systemState.home[item.id]=input.on;result={id:item.id,value:input.on,status:"acknowledged"};} + } + } + resolve(bridgeValue(result,0)); + } catch(error) {reject(StringCtor(error.message??error));} + }); + } + for(const group of ObjectKeys(systemMethods)){ + apis[`$${group}`]??={}; + for(const method of systemMethods[group])apis[`$${group}`][method]=(...args)=>systemCall(group,method,args); + } + apis.$fetch = apis.fetch; apis.console = apis.$console; apis.Promise = global.Promise; @@ -1189,7 +1319,7 @@ export function scriptWidgetKernel(global, host, configJSON) { if (validation) error = { kind: validation.kind, message: validation.message }; else tree = encodeElement(state.resultElement); } - return JSONStringify({ tree, error, logs, diagnostics, ...(actionMode ? { mockState: { storage: Object.fromEntries(storage), remindersState: { formatVersion: 1, items: reminderRows, receipts: reminderReceipts } } } : {}) }); + return JSONStringify({ tree, error, logs, diagnostics, ...(actionMode ? { mockState: { systemState, storage: Object.fromEntries(storage), remindersState: { formatVersion: 1, items: reminderRows, receipts: reminderReceipts } } } : {}) }); } return { diff --git a/Web/preview-engine/src/package/manifest.js b/Web/preview-engine/src/package/manifest.js index d226d35e..e8ac247e 100644 --- a/Web/preview-engine/src/package/manifest.js +++ b/Web/preview-engine/src/package/manifest.js @@ -6,7 +6,7 @@ import { normalizePackagePath } from "../packageFiles.js"; export const runtimeAPIVersion = "1.0"; export const families = ["systemSmall", "systemMedium", "systemLarge", "systemExtraLarge", "systemExtraLargePortrait", "accessoryCircular", "accessoryRectangular", "accessoryInline"]; -export const permissions = ["network", "location", "health", "calendar", "reminders", "remindersWrite", "photos", "services", "music", "storage", "icloud", "files"]; +export const permissions = ["network", "location", "health", "calendar", "reminders", "remindersWrite", "photos", "services", "music", "storage", "icloud", "notifications", "calendarWrite", "maps", "weather", "alarms", "documents", "contacts", "home", "files"]; const manifestKeys = new Set(["formatVersion", "id", "name", "version", "runtimeVersion", "minimumRuntimeVersion", "timeline", "entry", "supportedFamilies", "permissions", "networkDomains", "plugins", "actions", "controls", "pushUpdates", "description", "category", "tags", "icon", "preview", "author", "license"]); const actionKeys = new Set(["id", "title", "description", "systemImage", "function"]); const controlKeys = new Set(["id", "type", "title", "subtitle", "systemImage", "action", "actionID", "stateKey"]); @@ -142,6 +142,8 @@ export function validateManifest(manifest, paths, { checkEntryExists = true } = if (manifest.supportedFamilies.length === 0) error("missing_families", "At least one supported widget family is required."); if (new Set(manifest.supportedFamilies).size !== manifest.supportedFamilies.length) error("duplicate_families", "supportedFamilies must not contain duplicates."); if (new Set(manifest.permissions).size !== manifest.permissions.length) error("duplicate_permissions", "permissions must not contain duplicates."); + if (manifest.permissions.some(p => ["notifications","calendarWrite","maps","weather","alarms","documents","contacts","home"].includes(p)) && !supportsMinimumRuntime("1.6", manifest.minimumRuntimeVersion ?? "0.0")) error("system_runtime", "System capabilities require minimumRuntimeVersion 1.6 or later."); + if (manifest.permissions.includes("calendarWrite") && !manifest.permissions.includes("calendar")) error("calendar_write_permission", "calendarWrite also requires calendar."); if (manifest.permissions.includes("icloud") && (!/^1\.[0-9]+$/.test(manifest.minimumRuntimeVersion ?? "") || Number(manifest.minimumRuntimeVersion.split(".")[1]) < 5)) error("icloud_runtime", "iCloud JSON requires minimumRuntimeVersion 1.5 or later."); const network = manifest.permissions.includes("network"); if (manifest.networkDomains.length && !network) error("undeclared_network", "networkDomains requires the network permission."); diff --git a/Web/preview-engine/src/types.d.ts b/Web/preview-engine/src/types.d.ts index e4475c72..61556110 100644 --- a/Web/preview-engine/src/types.d.ts +++ b/Web/preview-engine/src/types.d.ts @@ -5,7 +5,7 @@ export type WidgetFamilyName = "systemSmall" | "systemMedium" | "systemLarge" | "systemExtraLarge" | "systemExtraLargePortrait" | "accessoryCircular" | "accessoryRectangular" | "accessoryInline"; export type WidgetSize = "small" | "medium" | "large" | "extraLarge" | "extraLargePortrait" | "accessoryCircular" | "accessoryRectangular" | "accessoryInline"; -export type Permission = "network" | "location" | "health" | "calendar" | "reminders" | "remindersWrite" | "photos" | "services" | "music" | "storage" | "icloud" | "files"; +export type Permission = "network" | "location" | "health" | "calendar" | "reminders" | "remindersWrite" | "photos" | "services" | "music" | "storage" | "icloud" | "notifications" | "calendarWrite" | "maps" | "weather" | "alarms" | "documents" | "contacts" | "home" | "files"; export type Severity = "error" | "warning" | "info"; export type Appearance = "light" | "dark"; export type RenderingMode = "fullColor" | "accented" | "vibrant"; @@ -61,6 +61,6 @@ export interface ExecutionResult { error: { kind: string; message: string } | null; logs: LogEntry[]; diagnostics: Issue[]; - mockState?: { storage: Record; remindersState: { formatVersion: number; items: Array>; receipts: Array> } }; + mockState?: { systemState?: Record; storage: Record; remindersState: { formatVersion: number; items: Array>; receipts: Array> } }; timing?: { compileMilliseconds: number; executeMilliseconds: number }; } diff --git a/Web/preview-engine/test/packagePreflight.test.js b/Web/preview-engine/test/packagePreflight.test.js index ef8983c0..b2049c7a 100644 --- a/Web/preview-engine/test/packagePreflight.test.js +++ b/Web/preview-engine/test/packagePreflight.test.js @@ -7,8 +7,8 @@ import { decodeManifest, newManifest, supportsMinimumRuntime, validateManifest } const files = (manifest, source = '$render(ok);') => ({ "widget.json": JSON.stringify(manifest), "main.jsx": source }); test("minimum API versions use canonical numeric same-major comparison", () => { - for (const version of ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5"]) assert.equal(supportsMinimumRuntime(version), true, version); - for (const version of ["1.6", "1.10", "2.0", "0.9", "01.3", "1.03", "1.3.0", "1", "1.9999", ">=1.3", " 1.3"]) assert.equal(supportsMinimumRuntime(version), false, version); + for (const version of ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6"]) assert.equal(supportsMinimumRuntime(version), true, version); + for (const version of ["1.7", "1.10", "2.0", "0.9", "01.3", "1.03", "1.3.0", "1", "1.9999", ">=1.3", " 1.3"]) assert.equal(supportsMinimumRuntime(version), false, version); assert.equal(supportsMinimumRuntime("1.9", "1.10"), true); assert.equal(supportsMinimumRuntime("1.10", "1.9"), false); for (const minimum of [undefined, null, "1.0", "1.3", "1.4", "2.0", "01.3"]) { @@ -22,7 +22,7 @@ test("minimum API versions use canonical numeric same-major comparison", () => { test("invalid packages are rejected before the compiler or script can run", () => { const compiler = new Proxy({}, { get() { throw new Error("Compiler must not run"); } }); - for (const patch of [{ minimumRuntimeVersion: "1.6" }, { minimumRuntimeVersion: "01.3" }, { formatVersion: 99 }, { extraCapability: true }]) { + for (const patch of [{ minimumRuntimeVersion: "1.7" }, { minimumRuntimeVersion: "01.3" }, { formatVersion: 99 }, { extraCapability: true }]) { const result = preparePackage(compiler, { files: files({ ...newManifest("Preflight"), ...patch }, "while(true) {}") }); assert.equal(result.ok, false); assert.equal(result.error.kind, "scriptError"); @@ -32,7 +32,7 @@ test("invalid packages are rejected before the compiler or script can run", () = test("file manifest is authoritative over a permissive host object", async () => { const host = { ...newManifest("Host grant"), permissions: ["calendar"] }; - for (const text of ["{bad", JSON.stringify({ ...host, formatVersion: 999 }), JSON.stringify({ ...host, minimumRuntimeVersion: "1.6" })]) { + for (const text of ["{bad", JSON.stringify({ ...host, formatVersion: 999 }), JSON.stringify({ ...host, minimumRuntimeVersion: "1.7" })]) { const result = await executePackageInNode({ files: { "widget.json": text, "main.jsx": 'throw new Error("executed");' }, manifest: host }); assert.equal(result.error.kind, "scriptError"); assert.match(result.error.message, /\[package:/); diff --git a/Web/preview-engine/test/systemServices.test.js b/Web/preview-engine/test/systemServices.test.js new file mode 100644 index 00000000..3d2c31df --- /dev/null +++ b/Web/preview-engine/test/systemServices.test.js @@ -0,0 +1,81 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { executePackageInNode } from "../src/node.js"; +import { systemAPICatalog } from "../../../Editor/editorfe/src/systemAPICatalog.js"; +const permissions=["notifications","calendar","calendarWrite","health","maps","weather","alarms","documents","contacts","home","network"]; +const manifest={formatVersion:2,id:"example.system-services",name:"System Services",version:"1.0.0",runtimeVersion:"1.0",minimumRuntimeVersion:"1.6",entry:"main.jsx",supportedFamilies:["systemMedium"],permissions,networkDomains:["api.met.no"],actions:[{id:"test",title:"Test",systemImage:"play",function:"testAction"}]}; +const fixtures=()=>({api:Object.fromEntries(systemAPICatalog.map(api=>[api.id,{value:api.value}]))}); +const run=(code,options={})=>executePackageInNode({files:{"widget.json":JSON.stringify(manifest),"main.jsx":code},fixtures:fixtures(),...options}); +const action=(code,options={})=>run(`async function testAction(){${code}}$render(Ready);`,{actionID:"test",...options}); +const log=result=>{assert.equal(result.error,null);return JSON.parse(result.logs.find(l=>l.level==="log").message);}; +const request="11111111-1111-4111-8111-111111111111"; + +test("every new capability denies missing manifest permission even with healthy mocks",async()=>{ + for(const source of ["await $notifications.status()","await $alarms.status()","await $contacts.selected()","await $documents.list()","await $home.items()","await $maps.geocode('park')","await $weather.forecast({latitude:0,longitude:0})","await $health.dailyStatistics({metric:'steps'})"]){ + const m={...manifest,permissions:[],networkDomains:[]}; + const result=await run(source+';$render(never);',{files:{"widget.json":JSON.stringify(m),"main.jsx":source+';$render(never);'}}); + assert.match(result.error.message,/permission_denied/); + } +}); +test("per-installation simulated grants deny access before fixture replies",async()=>{ + const f=fixtures();f.systemAccess={permissions:[]}; + assert.match((await run('await $contacts.selected();$render(never);',{fixtures:f})).error.message,/permission_denied/); +}); +test("normal render cannot schedule, change calendar, alarm or home",async()=>{ + for(const source of ["$notifications.schedule({})","$notifications.cancel('daily')","$calendar.create({})","$alarms.schedule({})","$home.setPower({})","$home.runScene({})"]){ + assert.match((await run(`await ${source};$render(never);`)).error.message,/read_only/); + } +}); +test("notification actions schedule, replace and cancel their named slot",async()=>{ + const date=new Date(Date.now()+3600000).toISOString(); + const result=await action(`await $notifications.schedule({key:'daily',title:'Read',body:'One chapter',date:'${date}'});await $notifications.schedule({key:'daily',title:'Read now',body:'One chapter',date:'${date}'});const pending=await $notifications.pending();await $notifications.cancel('daily');console.log(JSON.stringify({pending,after:await $notifications.pending()}));`); + const value=log(result);assert.equal(value.pending.length,1);assert.equal(value.pending[0].title,"Read now");assert.equal(value.after.length,0); +}); +test("calendar writes are scoped, owned and replay-safe",async()=>{ + const input={requestID:request,calendarID:"sample.calendar",title:"Focus",start:"2026-10-28T12:00:00Z",end:"2026-10-28T13:00:00Z"}; + const result=await action(`const a=await $calendar.create(${JSON.stringify(input)});const b=await $calendar.create(${JSON.stringify(input)});let denied=false;try{await $calendar.update({...${JSON.stringify(input)},id:'someone-elses-event'});}catch(e){denied=true;}console.log(JSON.stringify({a,b,denied}));`); + const value=log(result);assert.equal(value.a.id,value.b.id);assert.equal(value.b.replayed,true);assert.equal(value.denied,true); + const f=fixtures();f.calendarSelection=[]; + assert.match((await action(`await $calendar.create(${JSON.stringify(input)});`,{fixtures:f})).error.message,/permission_denied/); +}); +test("uncertain native-style mutation results cannot be blindly replayed",async()=>{ + const f=fixtures();f.systemCommitUncertain=true; + const result=await action(`try{await $alarms.schedule({requestID:'${request}',key:'focus',title:'Focus',seconds:1500});}catch(e){console.log(JSON.stringify({error:String(e)}));}`,{fixtures:f}); + assert.match(log(result).error,/outcome_unknown/); + const next=fixtures();next.systemState=result.mockState.systemState; + const replay=await action(`await $alarms.schedule({requestID:'${request}',key:'focus',title:'Focus',seconds:1500});`,{fixtures:next}); + assert.match(replay.error.message,/outcome_unknown/); +}); +test("alarm lifecycle preserves named identity and rejects replacing active alarms",async()=>{ + const result=await action(`const a=await $alarms.schedule({requestID:'${request}',key:'focus',title:'Focus',seconds:1500});await $alarms.pause('focus');const paused=await $alarms.pending();await $alarms.resume('focus');await $alarms.cancel('focus');console.log(JSON.stringify({a,paused,after:await $alarms.pending()}));`); + const value=log(result);assert.equal(value.paused[0].state,"paused");assert.equal(value.after.length,0); +}); +test("home selection filters sensors and actions set absolute power",async()=>{ + const f=fixtures();f.systemAccess={permissions:["home"],home:["sample.light"]}; + const result=await action(`await $home.setPower({id:'sample.light',on:false});console.log(JSON.stringify(await $home.items()));`,{fixtures:f}); + const value=log(result);assert.equal(value.length,1);assert.equal(value[0].value,false); + assert.match((await action(`await $home.setPower({id:'unselected',on:true});`,{fixtures:f})).error.message,/permission_denied/); +}); +test("documents use opaque imported IDs and contacts obey their selected scope",async()=>{ + assert.match((await run(`await $documents.readJSON('../private');$render(never);`)).error.message,/permission_denied/); + const result=await run(`const rows=await $contacts.selected();$render({rows.length});`,{fixtures:{...fixtures(),systemAccess:{permissions:["contacts"],contacts:[]}}}); + assert.equal(result.error,null);assert.match(result.tree,/0/); +}); +test("bounded query inputs and shared budgets cannot be bypassed by mocks",async()=>{ + for(const source of ["$health.dailyStatistics({metric:'unknown'})","$health.dailyStatistics({metric:'steps',days:32})","$maps.search({query:'park',latitude:91,longitude:0})","$maps.snapshot({latitude:0,longitude:0,size:10000})","$weather.forecast({latitude:0,longitude:0,hours:49})"]){assert.match((await run(`await ${source};$render(never);`)).error.message,/invalid_options/);} + assert.match((await run('for(let n=0;n<9;n++)await $notifications.status();$render(never);')).error.message,/query_limit/); +}); + +test("daily notifications are one named repeating slot with strict clock bounds",async()=>{ + const result=await action(`await $notifications.schedule({key:'daily',title:'Read',body:'One chapter',daily:{hour:20,minute:0}});console.log(JSON.stringify(await $notifications.pending()));`); + assert.equal(log(result)[0].repeats,true); assert.ok(Date.parse(log(result)[0].date)>Date.now()); + const invalid=await action(`await $notifications.schedule({key:'daily',title:'Read',body:'One chapter',daily:{hour:24,minute:0}});`); + assert.match(invalid.error.message,/invalid_options/); +}); + +test("health metric defaults preserve units and availability",async()=>{ + const result=await run(`$render({JSON.stringify(await $health.dailyStatistics({metric:'bodyMass',days:7}))});`); + assert.equal(result.error,null);const value=JSON.parse(JSON.parse(result.tree).children[0]);assert.equal(value.unit,'kg');assert.equal(value.aggregation,'average');assert.ok(value.items[0].value<200); + const f=fixtures();f.api['$health.isAvailable']={value:false}; + assert.match((await run(`await $health.dailyStatistics({metric:'steps'});$render(never);`,{fixtures:f})).error.message,/unavailable/); +}); diff --git a/Web/studio/package-lock.json b/Web/studio/package-lock.json index 8e66d64b..5571e36a 100644 --- a/Web/studio/package-lock.json +++ b/Web/studio/package-lock.json @@ -39,7 +39,8 @@ "tw-animate-css": "1.4.0", "typescript": "7.0.2", "vite": "7.3.6" - } + }, + "license": "Apache-2.0" }, "node_modules/@babel/code-frame": { "version": "7.29.7", diff --git a/Web/studio/package.json b/Web/studio/package.json index c3dd0020..1a1911df 100644 --- a/Web/studio/package.json +++ b/Web/studio/package.json @@ -43,5 +43,6 @@ "tw-animate-css": "1.4.0", "typescript": "7.0.2", "vite": "7.3.6" - } + }, + "license": "Apache-2.0" } diff --git a/Web/studio/scripts/onboarding-smoke.ts b/Web/studio/scripts/onboarding-smoke.ts index 9262cfb5..e352514b 100644 --- a/Web/studio/scripts/onboarding-smoke.ts +++ b/Web/studio/scripts/onboarding-smoke.ts @@ -35,6 +35,10 @@ try { assert.equal(await page.evaluate("document.documentElement.scrollWidth<=innerWidth"), true); if (output) fs.writeFileSync(path.join(output, "home-mobile.png"), await page.screenshot()); await page.goto(`${server.origin}/creator/`); + // Page.navigate returns before the new document and its stylesheet are ready. + // Wait for the destination, fonts and layout before measuring mobile overflow. + await page.waitFor("!!document.getElementById('install-command') && document.readyState==='complete'"); + await page.evaluate("(async()=>{await document.fonts.ready;await new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)))})()"); assert.equal(await page.evaluate("document.documentElement.scrollWidth<=innerWidth"), true); // Deterministic clipboard success/denial, including exact multiline payload. await page.evaluate("window.copied=[]; Object.defineProperty(navigator,'clipboard',{configurable:true,value:{writeText:async text=>window.copied.push(text)}})"); diff --git a/Web/studio/scripts/preview-handoff-smoke.ts b/Web/studio/scripts/preview-handoff-smoke.ts index 4606aedf..709c81e3 100644 --- a/Web/studio/scripts/preview-handoff-smoke.ts +++ b/Web/studio/scripts/preview-handoff-smoke.ts @@ -12,7 +12,9 @@ try { const page=await chrome.newPage(); const base=process.env.SCRIPTWIDGET_STUDIO_URL || server.origin+'/index.html'; await page.goto(base); - await page.waitFor("!!document.querySelector('.sw-widget')",20000); + // Measure the baseline only after the saved project UI is ready, and wait + // for the imported project's list update as well as its asynchronous preview. + await page.waitFor("!!document.querySelector('.sw-widget') && document.querySelectorAll('#project-list li').length>0 && document.getElementById('save-state')?.textContent==='Saved in this browser'",20000); const initial=await page.evaluate("document.querySelectorAll('#project-list li').length"); let fragment: string; if(process.env.SCRIPTWIDGET_CLI && process.env.SCRIPTWIDGET_PREVIEW_PACKAGE) { @@ -26,6 +28,7 @@ try { await page.goto(base+fragment); try { await page.waitFor("document.querySelector('.sw-widget')?.textContent.includes('Agent handoff loaded ✓')",25000); } catch(error) { console.error(await page.evaluate("document.body.innerText.slice(-4500)"), page.consoleMessages); throw error; } + await page.waitFor(`document.querySelectorAll('#project-list li').length===${initial+1} && document.getElementById('save-state')?.textContent==='Saved in this browser'`,20000); if(await page.evaluate("location.hash!==''"))throw Error('Payload remained in browser URL'); if(await page.evaluate("document.querySelectorAll('#project-list li').length")!==initial+1)throw Error('Existing project overwritten or handoff imported more than once'); await page.goto(base); diff --git a/Web/studio/src/components/ActionTestPanel.tsx b/Web/studio/src/components/ActionTestPanel.tsx index 182f19eb..dab0d77e 100644 --- a/Web/studio/src/components/ActionTestPanel.tsx +++ b/Web/studio/src/components/ActionTestPanel.tsx @@ -34,7 +34,7 @@ export function ActionTestPanel({ project, onFixtures }: { project: Project; onF const reset = () => { try { const fixtures = parseMocks(project.fixtures); - delete fixtures.remindersState; fixtures.storage = {}; + delete fixtures.remindersState; delete fixtures.systemState; fixtures.storage = {}; onFixtures(JSON.stringify(fixtures, null, 2)); setMessage("Simulated action state reset. System reminders were not changed."); } catch (error) { setMessage((error as Error).message); } diff --git a/Web/studio/src/components/MockDataPanel.tsx b/Web/studio/src/components/MockDataPanel.tsx index d6319c52..371735eb 100644 --- a/Web/studio/src/components/MockDataPanel.tsx +++ b/Web/studio/src/components/MockDataPanel.tsx @@ -5,8 +5,8 @@ import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { addSampleMocks, isObject, mockAPIs, musicScenario, parseMocks, permissionScenario, responseFor, sampleFixtures, serviceScenario, setResponse, type MockObject, type MockValue } from "@/mockData.ts"; -const groups = ["services", "music", "calendar", "reminders", "photos", "health", "location", "device", "system", "network", "storage", "icloud", "dataSource", "json"]; -const labels: Record = { services: "Connected services", music: "Music playback", calendar: "Calendar", reminders: "Reminders", photos: "Photos", health: "Health", location: "Location", device: "Device", system: "System", network: "Network responses", storage: "Storage", icloud: "iCloud JSON", dataSource: "Data Source Plugins", json: "Full JSON" }; +const groups = ["services", "music", "notifications", "alarms", "maps", "weather", "documents", "contacts", "home", "calendar", "reminders", "photos", "health", "location", "device", "system", "network", "storage", "icloud", "systemAccess", "dataSource", "json"]; +const labels: Record = { services: "Connected services", notifications: "Local notifications", alarms: "Alarms & timers", maps: "Maps & places", weather: "Weather forecast", documents: "Imported documents", contacts: "Selected contacts", home: "Home accessories", music: "Music playback", calendar: "Calendar", reminders: "Reminders", photos: "Photos", health: "Health", location: "Location", device: "Device", system: "System", network: "Network responses", storage: "Storage", icloud: "iCloud JSON", systemAccess: "System access grants", dataSource: "Data Source Plugins", json: "Full JSON" }; // Primitive leaves use normal form fields. Arrays and uncommon payloads can // always be edited in the return JSON without losing unknown properties. @@ -37,7 +37,7 @@ export function MockDataPanel({ fixtures, onChange }: { fixtures: string; onChan const response = responseFor(data, api); const writeResponse = api.operation === "write"; const special = group === "network" ? "fetch" : group; - const structured = ["network", "storage", "icloud", "dataSource"].includes(group); + const structured = ["network", "storage", "icloud", "systemAccess", "dataSource"].includes(group); const encoded = structured ? JSON.stringify(data[special] ?? (["storage", "icloud"].includes(group) ? {} : []), null, 2) : JSON.stringify("error" in response ? response.error : response.value, null, 2); useEffect(() => { diff --git a/Web/studio/src/mockData.ts b/Web/studio/src/mockData.ts index b8dcbf6b..402d5efd 100644 --- a/Web/studio/src/mockData.ts +++ b/Web/studio/src/mockData.ts @@ -16,13 +16,15 @@ export function sampleFixtures(): MockObject { const day=`${dayStart.getFullYear()}-${String(dayStart.getMonth()+1).padStart(2,"0")}-${String(dayStart.getDate()).padStart(2,"0")}`; const healthSample=(id:string,value:MockValue):MockValue=>{ if(!isObject(value))return value; + if(id==="$health.dailyStatistics") return {...value,timeZone:zone,items:Array.from({length:7},(_,i)=>{const d=new Date(dayStart);d.setDate(d.getDate()-6+i);return {date:`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`,value:[4200,7300,5100,8900,6400,9200,6840][i]!,hasSamples:true};})}; if(id==="$health.sleepSummary")return {...value,start:new Date(now-86400000).toISOString(),end:new Date(now).toISOString(),timeZone:zone}; if(id==="$health.activitySummary")return {...value,date:day,timeZone:zone}; if(id==="$health.workouts")return {...value,start:new Date(now-7*86400000).toISOString(),end:new Date(now).toISOString(),timeZone:zone,items:[{id:"550e8400-e29b-41d4-a716-446655440000",activity:"running",start:new Date(now-3600000).toISOString(),end:new Date(now-900000).toISOString(),duration:2700,energyKcal:285,distanceMeters:5200}]}; return {...value,start:dayStart.toISOString(),end:new Date(now).toISOString()}; }; return { - api: Object.fromEntries(mockAPIs.filter((api) => api.id !== "$device.isdarkmode").map((api) => [api.id, { value: api.group === "health" && isObject(api.value) ? healthSample(api.id,api.value) : api.group === "photos" && api.id.endsWith(".items") ? {...api.value as MockObject,fetchedAt:new Date(now).toISOString()} : api.group === "reminders" && api.id.endsWith(".items") ? {...api.value as MockObject, fetchedAt: new Date(now).toISOString(), items: [{id:"sample.reminder",listID:"sample.reminders",title:"Read a chapter",due:new Date(dayStart.getTime()+16*3600000).toISOString(),hasTime:true,completed:false,completedAt:null,priority:0}]} : api.value }])), + systemAccess: {permissions:["notifications","calendarWrite","maps","weather","alarms","documents","contacts","home"],contacts:["sample.contact"],home:["sample.light","scene-sample"]}, + api: Object.fromEntries(mockAPIs.filter((api) => api.id !== "$device.isdarkmode").map((api) => [api.id, { value: api.group === "health" && isObject(api.value) ? healthSample(api.id,api.value) : api.group === "weather" && isObject(api.value) ? {...api.value,fetchedAt:new Date(now).toISOString(),hours:Array.from({length:48},(_,i)=>({time:new Date(start+i*3600000).toISOString(),temperatureC:Math.round((21+Math.sin(i/5)*4)*10)/10,windMetersPerSecond:2,precipitationMM:0,condition:"partlycloudy_day"}))} : api.group === "photos" && api.id.endsWith(".items") ? {...api.value as MockObject,fetchedAt:new Date(now).toISOString()} : api.group === "reminders" && api.id.endsWith(".items") ? {...api.value as MockObject, fetchedAt: new Date(now).toISOString(), items: [{id:"sample.reminder",listID:"sample.reminders",title:"Read a chapter",due:new Date(dayStart.getTime()+16*3600000).toISOString(),hasTime:true,completed:false,completedAt:null,priority:0}]} : api.value }])), fetch: [{url:"https://api.github.com/repos/everettjf/scriptwidget",method:"GET",status:200,body:JSON.stringify({full_name:"everettjf/ScriptWidget",private:false,stargazers_count:1280,forks_count:96,open_issues_count:18}),headers:{"content-type":"application/json","cache-control":"public, max-age=3600"}}, { url: "https://api.example.com/data", method: "GET", body: '{"value":42}', status: 200, headers: {"content-type":"application/json"} }, {url:"https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=37.33&lon=-122.01",method:"GET",status:200,body:JSON.stringify(weather),headers:{"content-type":"application/json",expires:new Date(now+3600000).toUTCString(),"last-modified":new Date(start).toUTCString()}}], storage: {}, icloud: { connected: true, available: true, documents: {} }, storageAtomicAvailable: true, dataSource: [], calendarSelection: null, remindersSelection: null, photosSelection: ["sample.photo", "sample.photo.2", "sample.photo.3", "sample.photo.4"], photosSnapshotPrepared: true, @@ -35,6 +37,8 @@ export function parseMocks(text: string): MockObject { for (const key of ["api", "device", "system", "storage", "icloud"]) { if (value[key] !== undefined && !isObject(value[key])) throw new Error(`${key} must be a JSON object.`); } + if (value.systemAccess !== undefined && (!isObject(value.systemAccess) || !Array.isArray(value.systemAccess.permissions))) throw new Error("System access mock needs a permissions array."); + if (value.systemState !== undefined && (!isObject(value.systemState) || value.systemState.version !== 1)) throw new Error("System action state requires version 1."); if (value.remindersState !== undefined && (!isObject(value.remindersState) || value.remindersState.formatVersion !== 1 || Object.keys(value.remindersState).some(key => !["formatVersion", "items", "receipts"].includes(key)) || !Array.isArray(value.remindersState.items) || !Array.isArray(value.remindersState.receipts))) throw new Error("Reminder action state needs formatVersion 1, items and receipts."); if (value.photosSelection !== undefined && (!Array.isArray(value.photosSelection) || value.photosSelection.length > 64 || new Set(value.photosSelection).size !== value.photosSelection.length || value.photosSelection.some(id => typeof id !== "string" || !id || new TextEncoder().encode(id).length > 1024 || /[\x00-\x1f\x7f]/.test(id)))) throw new Error("Photo selection needs up to 64 unique IDs; [] selects none."); diff --git a/Web/studio/test/calendar.test.ts b/Web/studio/test/calendar.test.ts index afb5bf42..b53d1829 100644 --- a/Web/studio/test/calendar.test.ts +++ b/Web/studio/test/calendar.test.ts @@ -11,7 +11,7 @@ const output = (tree: string) => JSON.parse(JSON.parse(tree).children[0]); test("calendar declaration round-trips but unknown permissions still fail closed", () => { assert.equal(decodeManifest(JSON.stringify(manifest)).error, undefined); - assert.match(decodeManifest(JSON.stringify({ ...manifest, permissions: ["calendarWrite"] })).error!, /unknown permission/); + assert.match(decodeManifest(JSON.stringify({ ...manifest, permissions: ["calendarWriteUnknown"] })).error!, /unknown permission/); }); test("best-state calendar mocks cannot bypass package permission", async () => { diff --git a/Web/studio/test/mockData.test.ts b/Web/studio/test/mockData.test.ts index 85a60661..2e4ff4ee 100644 --- a/Web/studio/test/mockData.test.ts +++ b/Web/studio/test/mockData.test.ts @@ -8,7 +8,7 @@ import type { WidgetManifest } from "../../preview-engine/src/types.js"; import { createProject } from "../src/project.ts"; import { dataAPICatalog } from "../../../Editor/editorfe/src/dataAPICatalog.js"; const execute = (source: string, fixtures = parseMocks(defaultFixtures)) => { - const manifest: WidgetManifest = { ...newManifest("API Mocks"), permissions: ["calendar", "reminders", "photos", "location", "health", "services", "music", "network"], networkDomains: ["api.github.com"] }; + const manifest: WidgetManifest = { ...newManifest("API Mocks"), minimumRuntimeVersion: "1.6", permissions: ["calendar", "calendarWrite", "reminders", "photos", "location", "health", "services", "music", "network", "notifications", "maps", "weather", "alarms", "documents", "contacts", "home"], networkDomains: ["api.github.com", "api.met.no"] }; return executePackageInNode({ files: { "main.jsx": source, "widget.json": JSON.stringify(manifest) }, fixtures, manifest }); }; @@ -39,6 +39,13 @@ test("new projects can read healthy system samples and authorize without setup", function mockCall(api: {id:string}, fixtures: ReturnType): string { if(api.id.startsWith("$services."))return `${api.id}("github")`; const value=(fixtures.api as any)[api.id]?.value; + const inputs: Record = { + "$health.dailyStatistics":{metric:"steps",days:7}, "$weather.forecast":{latitude:37.33,longitude:-122.01,hours:24}, + "$maps.search":{query:"park",latitude:37.33,longitude:-122.01}, "$maps.geocode":"park", "$maps.reverseGeocode":{latitude:37.33,longitude:-122.01}, "$maps.snapshot":{latitude:37.33,longitude:-122.01,size:256}, + "$documents.readJSON":"550e8400-e29b-41d4-a716-446655440000", "$documents.readCSV":"550e8400-e29b-41d4-a716-446655440001" + }; + if(api.id in inputs)return `${api.id}(${JSON.stringify(inputs[api.id])})`; + const options=api.id==="$health.sleepSummary"||api.id==="$health.workouts"?{start:value.start,end:value.end}:api.id==="$health.activitySummary"?{date:value.date}:null; return `${api.id}(${options?JSON.stringify(options):""})`; } @@ -49,14 +56,16 @@ test("every read API returns its configured value with the right sync or async s const fixtures=parseMocks(defaultFixtures); const result=await execute(`$render({JSON.stringify(await ${mockCall(api,fixtures)})});`,fixtures); assert.equal(result.error,null,api.id); - assert.deepEqual(JSON.parse(JSON.parse(result.tree!).children[0]),(fixtures.api as any)[api.id].value,api.id); + const configured=(fixtures.api as any)[api.id].value; + const expected=api.id==="$weather.forecast"?{...configured,hours:configured.hours.slice(0,24)}:configured; + assert.deepEqual(JSON.parse(JSON.parse(result.tree!).children[0]),expected,api.id); } }); test("catalog Promise semantics hold before awaiting, including simulated failures", async () => { for(const api of dataAPICatalog) { const fixtures=parseMocks(defaultFixtures); - const code=`const response=${mockCall(api,fixtures)};const asynchronous=response!==null&&typeof response==='object'&&typeof response.then==='function';if(asynchronous!==${api.asynchronous})throw new Error('Promise shape mismatch');${api.operation==="write"?"try{await response;throw new Error('unexpected write');}catch(e){if(!String(e).includes('permission_denied'))throw e;}":"await response;"}$render(ok);`; + const code=`const response=${mockCall(api,fixtures)};const asynchronous=response!==null&&typeof response==='object'&&typeof response.then==='function';if(asynchronous!==${api.asynchronous})throw new Error('Promise shape mismatch');${api.operation==="write"?"try{await response;throw new Error('unexpected write');}catch(e){if(!/permission_denied|read_only/.test(String(e)))throw e;}":"await response;"}$render(ok);`; const result=await execute(code,fixtures);assert.equal(result.error,null,api.id); } for (const id of ["$health.stepCountToday", "$location.current", "$system.locale", "$device.battery", "$services.profile"]) { diff --git a/Web/studio/test/systemExamples.test.ts b/Web/studio/test/systemExamples.test.ts new file mode 100644 index 00000000..19b74f7a --- /dev/null +++ b/Web/studio/test/systemExamples.test.ts @@ -0,0 +1,31 @@ +import assert from "node:assert/strict"; +import fs from "node:fs"; +import test from "node:test"; +import { executePackageInNode } from "../../preview-engine/src/node.js"; +import { defaultFixtures, parseMocks } from "../src/mockData.ts"; + +const examples = ["notification-reminder", "health-history", "calendar-focus", "weather-forecast", "alarm-focus-timer", "document-data", "selected-contacts", "map-place", "home-light"]; +function filesFor(name: string) { + const root = new URL(`../../../docs/examples/${name}/`, import.meta.url); + return Object.fromEntries(["widget.json", "main.jsx"].map(file => [file, fs.readFileSync(new URL(file, root), "utf8")])); +} +for (const name of examples) test(`system example ${name} renders healthy data and rejects missing permissions`, async () => { + const files = filesFor(name); + const healthy = await executePackageInNode({ files, fixtures: parseMocks(defaultFixtures) }); + assert.equal(healthy.error, null, name); + assert.ok(healthy.tree, name); + assert.deepEqual(healthy.logs.filter(row => row.level === "error"), [], name); + const manifest = JSON.parse(files["widget.json"]!); + const denied = await executePackageInNode({ files: { ...files, "widget.json": JSON.stringify({ ...manifest, permissions: [], networkDomains: [] }) }, fixtures: parseMocks(defaultFixtures) }); + // Examples display setup guidance instead of an empty Home Screen widget. + assert.equal(denied.error, null, name); + assert.ok(denied.tree, name); + assert.ok(denied.logs.some(row => row.level === "error"), name); +}); +for (const [name, actionID] of [["notification-reminder", "schedule"], ["calendar-focus", "create"], ["alarm-focus-timer", "start"], ["home-light", "on"]] as const) { + test(`system example ${name} executes its declared action`, async () => { + const result = await executePackageInNode({ files: filesFor(name!), actionID, fixtures: parseMocks(defaultFixtures) }); + assert.equal(result.error, null, name); + assert.deepEqual(result.logs.filter(row => row.level === "error"), [], name); + }); +} diff --git a/docs/README.md b/docs/README.md index bf0836a4..d2be9e0d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -54,3 +54,5 @@ Build native widgets for iPhone, iPad, and Mac with JavaScript and JSX. The quic ScriptWidget focuses on iOS, iPadOS, and macOS. A single `main.jsx` can adapt its layout with `$getenv("widget-size")`. Native watchOS is unsupported and outside the current [A/B scope](widget-capabilities-plan.md). visionOS is outside this plan. - [Opt-in iCloud JSON API](icloud-json-api.md) — native grants, immutable revisions, conflicts and Web mocks. + +- [System services API (Runtime 1.6)](system-services-api.md): notifications, health history, calendar writes, weather, alarms, imported data, contacts, maps and HomeKit. diff --git a/docs/data-api-catalog.md b/docs/data-api-catalog.md index 9c5ecfbd..dcda7217 100644 --- a/docs/data-api-catalog.md +++ b/docs/data-api-catalog.md @@ -71,6 +71,32 @@ Existing data-method return formats are unchanged. Present manifests now undergo | `$location.isAuthorizedForWidgetUpdates()` | 1.3 | ios | Synchronous | locationWhenInUse | availability | | `$location.requestAuthorization(options?)` | 1.0 | ios | Promise | locationWhenInUse | authorization | | `$location.current(options?)` | 1.0 | ios | Promise | locationWhenInUse | read | +| `$notifications.status()` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$notifications.pending()` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$notifications.schedule(options)` | 1.6 | ios, macos | Promise | systemAccess | write | +| `$notifications.cancel(key)` | 1.6 | ios, macos | Promise | systemAccess | write | +| `$health.dailyStatistics(options)` | 1.6 | ios | Promise | healthRead | read | +| `$calendar.create(options)` | 1.6 | ios, macos | Promise | systemAccess | write | +| `$calendar.update(options)` | 1.6 | ios, macos | Promise | systemAccess | write | +| `$weather.forecast(options)` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$alarms.status()` | 1.6 | ios | Promise | systemAccess | read | +| `$alarms.pending()` | 1.6 | ios | Promise | systemAccess | read | +| `$alarms.schedule(options)` | 1.6 | ios | Promise | systemAccess | write | +| `$alarms.cancel(key)` | 1.6 | ios | Promise | systemAccess | write | +| `$alarms.stop(key)` | 1.6 | ios | Promise | systemAccess | write | +| `$alarms.pause(key)` | 1.6 | ios | Promise | systemAccess | write | +| `$alarms.resume(key)` | 1.6 | ios | Promise | systemAccess | write | +| `$documents.list()` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$documents.readJSON(id)` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$documents.readCSV(id)` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$contacts.selected()` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$maps.search(options)` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$maps.geocode(address)` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$maps.reverseGeocode(options)` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$maps.snapshot(options)` | 1.6 | ios, macos | Promise | systemAccess | read | +| `$home.items()` | 1.6 | ios | Promise | systemAccess | read | +| `$home.setPower(options)` | 1.6 | ios | Promise | systemAccess | write | +| `$home.runScene(options)` | 1.6 | ios | Promise | systemAccess | write | ## music @@ -520,6 +546,32 @@ Default editable preview sample: } ``` +### `$calendar.create` + +Default editable preview sample: + +```json +{ + "id": "sample.event", + "calendarID": "sample.calendar", + "status": "applied", + "replayed": false +} +``` + +### `$calendar.update` + +Default editable preview sample: + +```json +{ + "id": "sample.event", + "calendarID": "sample.calendar", + "status": "applied", + "replayed": false +} +``` + ## reminders Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission. @@ -775,6 +827,26 @@ Default editable preview sample: } ``` +### `$health.dailyStatistics` + +Default editable preview sample: + +```json +{ + "metric": "steps", + "unit": "count", + "aggregation": "sum", + "timeZone": "UTC", + "items": [ + { + "date": "2026-01-01", + "value": 6840, + "hasSamples": true + } + ] +} +``` + ## location Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale. @@ -830,3 +902,357 @@ Default editable preview sample: "isStale": false } ``` + +## notifications + +Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. + +### `$notifications.status` + +Default editable preview sample: + +```json +{ + "authorization": "authorized" +} +``` + +### `$notifications.pending` + +Default editable preview sample: + +```json +[] +``` + +### `$notifications.schedule` + +Default editable preview sample: + +```json +{ + "key": "daily", + "status": "scheduled" +} +``` + +### `$notifications.cancel` + +Default editable preview sample: + +```json +{ + "key": "daily", + "status": "cancellationRequested" +} +``` + +## weather + +Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. + +### `$weather.forecast` + +Default editable preview sample: + +```json +{ + "provider": "MET Norway", + "attribution": { + "text": "Weather data from MET Norway", + "url": "https://www.met.no/en/free-meteorological-data/Download-services" + }, + "latitude": 37.33, + "longitude": -122.01, + "fetchedAt": "2026-01-01T12:00:00Z", + "isStale": false, + "hours": [ + { + "time": "2026-01-01T12:00:00Z", + "temperatureC": 21, + "windMetersPerSecond": 2, + "precipitationMM": 0, + "condition": "partlycloudy_day" + } + ] +} +``` + +## alarms + +Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. + +### `$alarms.status` + +Default editable preview sample: + +```json +{ + "authorization": "authorized" +} +``` + +### `$alarms.pending` + +Default editable preview sample: + +```json +[] +``` + +### `$alarms.schedule` + +Default editable preview sample: + +```json +{ + "key": "focus", + "status": "scheduled", + "replayed": false +} +``` + +### `$alarms.cancel` + +Default editable preview sample: + +```json +{ + "key": "focus", + "status": "requested" +} +``` + +### `$alarms.stop` + +Default editable preview sample: + +```json +{ + "key": "focus", + "status": "requested" +} +``` + +### `$alarms.pause` + +Default editable preview sample: + +```json +{ + "key": "focus", + "status": "requested" +} +``` + +### `$alarms.resume` + +Default editable preview sample: + +```json +{ + "key": "focus", + "status": "requested" +} +``` + +## documents + +Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. + +### `$documents.list` + +Default editable preview sample: + +```json +[ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "name": "Sample.json", + "type": "json", + "bytes": 17 + }, + { + "id": "550e8400-e29b-41d4-a716-446655440001", + "name": "Sample.csv", + "type": "csv", + "bytes": 24 + } +] +``` + +### `$documents.readJSON` + +Default editable preview sample: + +```json +{ + "goal": 12, + "done": 7 +} +``` + +### `$documents.readCSV` + +Default editable preview sample: + +```json +{ + "headers": [ + "day", + "value" + ], + "rows": [ + [ + "Monday", + "7" + ], + [ + "Tuesday", + "9" + ] + ], + "truncated": false +} +``` + +## contacts + +Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. + +### `$contacts.selected` + +Default editable preview sample: + +```json +[ + { + "id": "sample.contact", + "name": "Alex Example", + "organization": "Sample", + "phones": [ + "+1 202 555 0100" + ], + "emails": [ + "alex@example.com" + ] + } +] +``` + +## maps + +Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. + +### `$maps.search` + +Default editable preview sample: + +```json +[ + { + "name": "Example Park", + "address": "Sample address", + "latitude": 37.33, + "longitude": -122.01 + } +] +``` + +### `$maps.geocode` + +Default editable preview sample: + +```json +[ + { + "name": "Example Park", + "address": "Sample address", + "latitude": 37.33, + "longitude": -122.01 + } +] +``` + +### `$maps.reverseGeocode` + +Default editable preview sample: + +```json +[ + { + "name": "Example Park", + "address": "Sample address", + "latitude": 37.33, + "longitude": -122.01 + } +] +``` + +### `$maps.snapshot` + +Default editable preview sample: + +```json +{ + "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4z8DwHwAFgAI/ScLbtAAAAABJRU5ErkJggg==", + "width": 256, + "height": 256, + "provider": "Apple Maps" +} +``` + +## home + +Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. + +### `$home.items` + +Default editable preview sample: + +```json +[ + { + "id": "sample.light", + "name": "Living Room Lamp", + "kind": "power", + "value": true, + "isCached": true, + "metric": "power", + "unit": "boolean" + }, + { + "id": "scene-sample", + "name": "Evening", + "kind": "scene", + "value": null, + "isCached": true, + "metric": "scene", + "unit": "none" + } +] +``` + +### `$home.setPower` + +Default editable preview sample: + +```json +{ + "id": "sample.light", + "value": true, + "status": "acknowledged" +} +``` + +### `$home.runScene` + +Default editable preview sample: + +```json +{ + "id": "scene-sample", + "status": "acknowledged", + "replayed": false +} +``` diff --git a/docs/examples/alarm-focus-timer/README.md b/docs/examples/alarm-focus-timer/README.md new file mode 100644 index 00000000..ba294572 --- /dev/null +++ b/docs/examples/alarm-focus-timer/README.md @@ -0,0 +1,5 @@ +# Focus Timer + +Requires Runtime 1.6. Import this folder as a Package 2.0 widget. Open this widget’s System Access in ScriptWidget, save access and authorize the system service. + +Web Studio uses simulated data only. Native CLI renders cannot run real system actions. See [system API contracts](../../system-services-api.md) for limits, replay rules and the pending physical-device acceptance checklist. diff --git a/docs/examples/alarm-focus-timer/main.jsx b/docs/examples/alarm-focus-timer/main.jsx new file mode 100644 index 00000000..da72c3db --- /dev/null +++ b/docs/examples/alarm-focus-timer/main.jsx @@ -0,0 +1,41 @@ +// Runtime 1.6; native grants are separate from this exported package. +function requestID() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => { const r = Math.floor(Math.random() * 16); return (c === "x" ? r : (r & 3) | 8).toString(16); }); } +function pending(key, value) { + const before = $storage.getString(key); + if (before) return JSON.parse(before); + $storage.compareAndSetString(key, "", JSON.stringify(value)); + const saved = $storage.getString(key); + if (!saved) throw new Error("Could not save the request before the system write"); + return JSON.parse(saved); +} +async function startTimer() { + const op = pending("timer.pending.v1",{requestID:requestID(),key:"focus",title:"Focus complete",seconds:1500}); + await $alarms.schedule(op); + if (!$storage.compareAndSetString("timer.pending.v1",JSON.stringify(op),"")) throw new Error("Timer scheduled; review local confirmation before retrying"); +} +async function cancelTimer() { await $alarms.cancel("focus"); } +async function pauseTimer() { await $alarms.pause("focus"); } +async function resumeTimer() { await $alarms.resume("focus"); } +if ($getenv("widget-size") !== "action") { + const lines = ["25 minutes, one thing at a time"]; + try { + const status = await $alarms.status(); + // AlarmKit authorization is process-scoped on some iOS versions. Widget + // actions run in the app; keep controls visible when extension reads differ. + if (status.authorization === "authorized") { + const timers = await $alarms.pending(); + lines.push(...timers.filter(item => item.key === "focus").slice(0,1).map(item => item.key + " · " + item.state)); + } else { + lines.push("Start checks app alarm access"); + } + } catch (error) { + console.error(String(error)); + lines.push("Review System Access in ScriptWidget"); + } + $render( + Focus Timer + {lines.map(line => {line})} + + + ); +} diff --git a/docs/examples/alarm-focus-timer/widget.json b/docs/examples/alarm-focus-timer/widget.json new file mode 100644 index 00000000..3f0a81d2 --- /dev/null +++ b/docs/examples/alarm-focus-timer/widget.json @@ -0,0 +1,45 @@ +{ + "formatVersion": 2, + "id": "app.scriptwidget.example.alarm-focus-timer", + "name": "Focus Timer", + "version": "1.0.0", + "runtimeVersion": "1.0", + "minimumRuntimeVersion": "1.6", + "entry": "main.jsx", + "supportedFamilies": [ + "systemMedium", + "systemLarge" + ], + "permissions": [ + "alarms", + "storage" + ], + "networkDomains": [], + "license": "Apache-2.0", + "actions": [ + { + "id": "start", + "title": "Start 25 min", + "systemImage": "play.circle", + "function": "startTimer" + }, + { + "id": "pause", + "title": "Pause", + "systemImage": "play.circle", + "function": "pauseTimer" + }, + { + "id": "resume", + "title": "Resume", + "systemImage": "play.circle", + "function": "resumeTimer" + }, + { + "id": "cancel", + "title": "Cancel", + "systemImage": "play.circle", + "function": "cancelTimer" + } + ] +} diff --git a/docs/examples/calendar-focus/README.md b/docs/examples/calendar-focus/README.md new file mode 100644 index 00000000..a11bfac3 --- /dev/null +++ b/docs/examples/calendar-focus/README.md @@ -0,0 +1,5 @@ +# Focus Session + +Requires Runtime 1.6. Import this folder as a Package 2.0 widget. Open this widget’s System Access in ScriptWidget, save access and authorize the system service. + +Web Studio uses simulated data only. Native CLI renders cannot run real system actions. See [system API contracts](../../system-services-api.md) for limits, replay rules and the pending physical-device acceptance checklist. diff --git a/docs/examples/calendar-focus/main.jsx b/docs/examples/calendar-focus/main.jsx new file mode 100644 index 00000000..9ab2996c --- /dev/null +++ b/docs/examples/calendar-focus/main.jsx @@ -0,0 +1,34 @@ +// Runtime 1.6; native grants are separate from this exported package. +function requestID() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => { const r = Math.floor(Math.random() * 16); return (c === "x" ? r : (r & 3) | 8).toString(16); }); } +function pending(key, value) { + const before = $storage.getString(key); + if (before) return JSON.parse(before); + $storage.compareAndSetString(key, "", JSON.stringify(value)); + const saved = $storage.getString(key); + if (!saved) throw new Error("Could not save the request before the system write"); + return JSON.parse(saved); +} +async function createFocus() { + const calendars = await $calendar.calendars(); + if (!calendars.length) throw new Error("Select a writable calendar in native Settings first"); + const start = new Date(Date.now() + 5 * 60000); + const op = pending("focus.pending.v1", {requestID:requestID(),calendarID:calendars[0].id,title:"Focus time",start:start.toISOString(),end:new Date(start.getTime() + 30 * 60000).toISOString()}); + if (Date.now() - Date.parse(op.start) > 6 * 86400000) throw new Error("Inspect Calendar before retrying this old pending request"); + const result = await $calendar.create(op); + if (!$storage.compareAndSetString("focus.pending.v1",JSON.stringify(op),"")) throw new Error("Saved to Calendar; local confirmation needs review"); +} +if ($getenv("widget-size") !== "action") { + try { + const calendars = await $calendar.calendars(); + const lines = ["Add a 30-minute focus session", calendars.length ? "Calendar: " + calendars[0].title : "Select a calendar in Settings", "A new session starts five minutes after tapping."]; + $render( + Focus Session + {lines.map(line => {line})} + + + ); + } catch (error) { + console.error(String(error)); + $render(Focus SessionOpen this widget’s System Access in ScriptWidget, save access and authorize the system service.); + } +} diff --git a/docs/examples/calendar-focus/widget.json b/docs/examples/calendar-focus/widget.json new file mode 100644 index 00000000..a94a5ddb --- /dev/null +++ b/docs/examples/calendar-focus/widget.json @@ -0,0 +1,28 @@ +{ + "formatVersion": 2, + "id": "app.scriptwidget.example.calendar-focus", + "name": "Focus Session", + "version": "1.0.0", + "runtimeVersion": "1.0", + "minimumRuntimeVersion": "1.6", + "entry": "main.jsx", + "supportedFamilies": [ + "systemMedium", + "systemLarge" + ], + "permissions": [ + "calendar", + "calendarWrite", + "storage" + ], + "networkDomains": [], + "license": "Apache-2.0", + "actions": [ + { + "id": "create", + "title": "Add focus session", + "systemImage": "play.circle", + "function": "createFocus" + } + ] +} diff --git a/docs/examples/document-data/README.md b/docs/examples/document-data/README.md new file mode 100644 index 00000000..30103e54 --- /dev/null +++ b/docs/examples/document-data/README.md @@ -0,0 +1,5 @@ +# My JSON Data + +Requires Runtime 1.6. Import this folder as a Package 2.0 widget. Open this widget’s System Access in ScriptWidget, save access and authorize the system service. + +Web Studio uses simulated data only. Native CLI renders cannot run real system actions. See [system API contracts](../../system-services-api.md) for limits, replay rules and the pending physical-device acceptance checklist. diff --git a/docs/examples/document-data/main.jsx b/docs/examples/document-data/main.jsx new file mode 100644 index 00000000..0686c5bf --- /dev/null +++ b/docs/examples/document-data/main.jsx @@ -0,0 +1,16 @@ +// Runtime 1.6; native grants are separate from this exported package. +if ($getenv("widget-size") !== "action") { + try { + const files = await $documents.list(); + const file = files.find(item => item.type === "json"); + const data = file ? await $documents.readJSON(file.id) : null; + const lines = file ? [file.name, JSON.stringify(data).slice(0,180)] : ["Import a JSON file in System Access", "The original file stays unchanged."]; + $render( + My JSON Data + {lines.map(line => {line})} + ); + } catch (error) { + console.error(String(error)); + $render(My JSON DataOpen this widget’s System Access in ScriptWidget, save access and authorize the system service.); + } +} diff --git a/docs/examples/document-data/widget.json b/docs/examples/document-data/widget.json new file mode 100644 index 00000000..61401790 --- /dev/null +++ b/docs/examples/document-data/widget.json @@ -0,0 +1,18 @@ +{ + "formatVersion": 2, + "id": "app.scriptwidget.example.document-data", + "name": "My JSON Data", + "version": "1.0.0", + "runtimeVersion": "1.0", + "minimumRuntimeVersion": "1.6", + "entry": "main.jsx", + "supportedFamilies": [ + "systemMedium", + "systemLarge" + ], + "permissions": [ + "documents" + ], + "networkDomains": [], + "license": "Apache-2.0" +} diff --git a/docs/examples/health-history/README.md b/docs/examples/health-history/README.md new file mode 100644 index 00000000..cd200403 --- /dev/null +++ b/docs/examples/health-history/README.md @@ -0,0 +1,5 @@ +# Seven Day Steps + +Requires Runtime 1.6. Import this folder as a Package 2.0 widget. Review Health access in native Settings. + +Web Studio uses simulated data only. Native CLI renders cannot run real system actions. See [system API contracts](../../system-services-api.md) for limits, replay rules and the pending physical-device acceptance checklist. diff --git a/docs/examples/health-history/main.jsx b/docs/examples/health-history/main.jsx new file mode 100644 index 00000000..f0d58a05 --- /dev/null +++ b/docs/examples/health-history/main.jsx @@ -0,0 +1,15 @@ +// Runtime 1.6; native grants are separate from this exported package. +if ($getenv("widget-size") !== "action") { + try { + const history = await $health.dailyStatistics({metric:"steps",days:7}); + const lines = history.items.slice(-2).map(item => item.date.slice(5) + " " + (item.hasSamples && item.value !== null ? Math.round(item.value).toLocaleString() + " steps" : "No shared samples")); + $render( + Seven Day Steps + {history.items.some(item => item.hasSamples && item.value !== null) && item.hasSamples && item.value !== null).map(item => ({label:item.date.slice(5),value:item.value})))}/>} + {lines.map(line => {line})} + ); + } catch (error) { + console.error(String(error)); + $render(Seven Day StepsReview Health access in native Settings.); + } +} diff --git a/docs/examples/health-history/widget.json b/docs/examples/health-history/widget.json new file mode 100644 index 00000000..0e6b3b9d --- /dev/null +++ b/docs/examples/health-history/widget.json @@ -0,0 +1,18 @@ +{ + "formatVersion": 2, + "id": "app.scriptwidget.example.health-history", + "name": "Seven Day Steps", + "version": "1.0.0", + "runtimeVersion": "1.0", + "minimumRuntimeVersion": "1.6", + "entry": "main.jsx", + "supportedFamilies": [ + "systemMedium", + "systemLarge" + ], + "permissions": [ + "health" + ], + "networkDomains": [], + "license": "Apache-2.0" +} diff --git a/docs/examples/home-light/README.md b/docs/examples/home-light/README.md new file mode 100644 index 00000000..03186ddc --- /dev/null +++ b/docs/examples/home-light/README.md @@ -0,0 +1,5 @@ +# A Calmer Home + +Requires Runtime 1.6. Import this folder as a Package 2.0 widget. Open this widget’s System Access in ScriptWidget, save access and authorize the system service. + +Web Studio uses simulated data only. Native CLI renders cannot run real system actions. See [system API contracts](../../system-services-api.md) for limits, replay rules and the pending physical-device acceptance checklist. diff --git a/docs/examples/home-light/main.jsx b/docs/examples/home-light/main.jsx new file mode 100644 index 00000000..a76f17ae --- /dev/null +++ b/docs/examples/home-light/main.jsx @@ -0,0 +1,19 @@ +// Runtime 1.6; native grants are separate from this exported package. +async function lightOn() { const items = await $home.items(); const item = items.find(x => x.kind === "power"); if (!item) throw new Error("Select a light in System Access"); await $home.setPower({id:item.id,on:true}); } +async function lightOff() { const items = await $home.items(); const item = items.find(x => x.kind === "power"); if (!item) throw new Error("Select a light in System Access"); await $home.setPower({id:item.id,on:false}); } +if ($getenv("widget-size") !== "action") { + try { + const items = await $home.items(); + const lines = items.length ? items.slice(0,2).map(item => item.name.slice(0,28) + " · " + (item.value === null ? "Unknown" : String(item.value))) : ["Select Home items in System Access"]; + lines.push("HomeKit cached readings"); + $render( + A Calmer Home + {lines.map(line => {line})} + + + ); + } catch (error) { + console.error(String(error)); + $render(A Calmer HomeOpen this widget’s System Access in ScriptWidget, save access and authorize the system service.); + } +} diff --git a/docs/examples/home-light/widget.json b/docs/examples/home-light/widget.json new file mode 100644 index 00000000..b305bc95 --- /dev/null +++ b/docs/examples/home-light/widget.json @@ -0,0 +1,32 @@ +{ + "formatVersion": 2, + "id": "app.scriptwidget.example.home-light", + "name": "A Calmer Home", + "version": "1.0.0", + "runtimeVersion": "1.0", + "minimumRuntimeVersion": "1.6", + "entry": "main.jsx", + "supportedFamilies": [ + "systemMedium", + "systemLarge" + ], + "permissions": [ + "home" + ], + "networkDomains": [], + "license": "Apache-2.0", + "actions": [ + { + "id": "on", + "title": "Light on", + "systemImage": "play.circle", + "function": "lightOn" + }, + { + "id": "off", + "title": "Light off", + "systemImage": "play.circle", + "function": "lightOff" + } + ] +} diff --git a/docs/examples/icloud-json-note/main.jsx b/docs/examples/icloud-json-note/main.jsx index bd48479b..1b2a3693 100644 --- a/docs/examples/icloud-json-note/main.jsx +++ b/docs/examples/icloud-json-note/main.jsx @@ -1,4 +1,8 @@ // Connect this installed package through the native "iCloud Data" menu first. +// Choose a new store for isolation, or explicitly connect another widget to +// the same store ID to share note.json. JS cannot select that ID or a path. +// Shared widgets must agree on the schema and handle eventual-sync conflicts. +// Connecting does not migrate existing local $storage records. // Writes are actions only; normal render never creates a cloud record. async function syncNote() { await $icloud.sync(); } async function saveNote() { diff --git a/docs/examples/map-place/README.md b/docs/examples/map-place/README.md new file mode 100644 index 00000000..8c583a8d --- /dev/null +++ b/docs/examples/map-place/README.md @@ -0,0 +1,5 @@ +# A Place to Go + +Requires Runtime 1.6. Import this folder as a Package 2.0 widget. Open this widget’s System Access in ScriptWidget, save access and authorize the system service. + +Web Studio uses simulated data only. Native CLI renders cannot run real system actions. See [system API contracts](../../system-services-api.md) for limits, replay rules and the pending physical-device acceptance checklist. diff --git a/docs/examples/map-place/main.jsx b/docs/examples/map-place/main.jsx new file mode 100644 index 00000000..21869ba6 --- /dev/null +++ b/docs/examples/map-place/main.jsx @@ -0,0 +1,14 @@ +// Runtime 1.6; native grants are separate from this exported package. +if ($getenv("widget-size") !== "action") { + try { + const places = await $maps.search({query:"park",latitude:37.33,longitude:-122.01,radiusMeters:3000}); + const lines = places.length ? places.slice(0,3).map(place => place.name.slice(0,36)) : ["No matching places"]; + $render( + A Place to Go + {lines.map(line => {line})} + ); + } catch (error) { + console.error(String(error)); + $render(A Place to GoOpen this widget’s System Access in ScriptWidget, save access and authorize the system service.); + } +} diff --git a/docs/examples/map-place/widget.json b/docs/examples/map-place/widget.json new file mode 100644 index 00000000..b40c4eaf --- /dev/null +++ b/docs/examples/map-place/widget.json @@ -0,0 +1,18 @@ +{ + "formatVersion": 2, + "id": "app.scriptwidget.example.map-place", + "name": "A Place to Go", + "version": "1.0.0", + "runtimeVersion": "1.0", + "minimumRuntimeVersion": "1.6", + "entry": "main.jsx", + "supportedFamilies": [ + "systemMedium", + "systemLarge" + ], + "permissions": [ + "maps" + ], + "networkDomains": [], + "license": "Apache-2.0" +} diff --git a/docs/examples/notification-reminder/README.md b/docs/examples/notification-reminder/README.md new file mode 100644 index 00000000..ceae66bd --- /dev/null +++ b/docs/examples/notification-reminder/README.md @@ -0,0 +1,5 @@ +# Reading Reminder + +Requires Runtime 1.6. Import this folder as a Package 2.0 widget. Open this widget’s System Access in ScriptWidget, save access and authorize the system service. + +Web Studio uses simulated data only. Native CLI renders cannot run real system actions. See [system API contracts](../../system-services-api.md) for limits, replay rules and the pending physical-device acceptance checklist. diff --git a/docs/examples/notification-reminder/main.jsx b/docs/examples/notification-reminder/main.jsx new file mode 100644 index 00000000..33d565bb --- /dev/null +++ b/docs/examples/notification-reminder/main.jsx @@ -0,0 +1,19 @@ +// Runtime 1.6; native grants are separate from this exported package. +async function scheduleReminder() { await $notifications.schedule({key:"reading",title:"Time to read",body:"One chapter is enough to keep going.",daily:{hour:20,minute:0}}); } +async function cancelReminder() { await $notifications.cancel("reading"); } +if ($getenv("widget-size") !== "action") { + try { + const status = await $notifications.status(); + const items = await $notifications.pending(); + const lines = ["Authorization: " + status.authorization, items.length ? "Reading reminder scheduled" : "No reminder scheduled"]; + $render( + Reading Reminder + {lines.map(line => {line})} + + + ); + } catch (error) { + console.error(String(error)); + $render(Reading ReminderOpen this widget’s System Access in ScriptWidget, save access and authorize the system service.); + } +} diff --git a/docs/examples/notification-reminder/widget.json b/docs/examples/notification-reminder/widget.json new file mode 100644 index 00000000..efc23161 --- /dev/null +++ b/docs/examples/notification-reminder/widget.json @@ -0,0 +1,32 @@ +{ + "formatVersion": 2, + "id": "app.scriptwidget.example.notification-reminder", + "name": "Reading Reminder", + "version": "1.0.0", + "runtimeVersion": "1.0", + "minimumRuntimeVersion": "1.6", + "entry": "main.jsx", + "supportedFamilies": [ + "systemMedium", + "systemLarge" + ], + "permissions": [ + "notifications" + ], + "networkDomains": [], + "license": "Apache-2.0", + "actions": [ + { + "id": "schedule", + "title": "Remind at 20:00", + "systemImage": "play.circle", + "function": "scheduleReminder" + }, + { + "id": "cancel", + "title": "Cancel", + "systemImage": "play.circle", + "function": "cancelReminder" + } + ] +} diff --git a/docs/examples/selected-contacts/README.md b/docs/examples/selected-contacts/README.md new file mode 100644 index 00000000..67e4b7e2 --- /dev/null +++ b/docs/examples/selected-contacts/README.md @@ -0,0 +1,5 @@ +# People Close By + +Requires Runtime 1.6. Import this folder as a Package 2.0 widget. Open this widget’s System Access in ScriptWidget, save access and authorize the system service. + +Web Studio uses simulated data only. Native CLI renders cannot run real system actions. See [system API contracts](../../system-services-api.md) for limits, replay rules and the pending physical-device acceptance checklist. diff --git a/docs/examples/selected-contacts/main.jsx b/docs/examples/selected-contacts/main.jsx new file mode 100644 index 00000000..3315efce --- /dev/null +++ b/docs/examples/selected-contacts/main.jsx @@ -0,0 +1,14 @@ +// Runtime 1.6; native grants are separate from this exported package. +if ($getenv("widget-size") !== "action") { + try { + const people = await $contacts.selected(); + const lines = people.length ? people.slice(0,2).map(person => person.name + (person.phones[0] ? " · " + person.phones[0] : "")) : ["Select contacts in System Access"]; + $render( + People Close By + {lines.map(line => {line})} + ); + } catch (error) { + console.error(String(error)); + $render(People Close ByOpen this widget’s System Access in ScriptWidget, save access and authorize the system service.); + } +} diff --git a/docs/examples/selected-contacts/widget.json b/docs/examples/selected-contacts/widget.json new file mode 100644 index 00000000..f2fdd0e6 --- /dev/null +++ b/docs/examples/selected-contacts/widget.json @@ -0,0 +1,18 @@ +{ + "formatVersion": 2, + "id": "app.scriptwidget.example.selected-contacts", + "name": "People Close By", + "version": "1.0.0", + "runtimeVersion": "1.0", + "minimumRuntimeVersion": "1.6", + "entry": "main.jsx", + "supportedFamilies": [ + "systemMedium", + "systemLarge" + ], + "permissions": [ + "contacts" + ], + "networkDomains": [], + "license": "Apache-2.0" +} diff --git a/docs/examples/weather-forecast/README.md b/docs/examples/weather-forecast/README.md new file mode 100644 index 00000000..5cfa636d --- /dev/null +++ b/docs/examples/weather-forecast/README.md @@ -0,0 +1,5 @@ +# Weather Ahead + +Requires Runtime 1.6. Import this folder as a Package 2.0 widget. Open this widget’s System Access in ScriptWidget, save access and authorize the system service. + +Web Studio uses simulated data only. Native CLI renders cannot run real system actions. See [system API contracts](../../system-services-api.md) for limits, replay rules and the pending physical-device acceptance checklist. diff --git a/docs/examples/weather-forecast/main.jsx b/docs/examples/weather-forecast/main.jsx new file mode 100644 index 00000000..91365c01 --- /dev/null +++ b/docs/examples/weather-forecast/main.jsx @@ -0,0 +1,17 @@ +// Runtime 1.6; native grants are separate from this exported package. +if ($getenv("widget-size") !== "action") { + try { + const weather = await $weather.forecast({latitude:37.33,longitude:-122.01,hours:6}); + const lines = weather.hours.slice(0,2).map(item => item.time.slice(11,16) + " " + Math.round(item.temperatureC) + "°C · " + item.windMetersPerSecond + " m/s"); + lines.push(weather.isStale ? "Cached forecast · may be out of date" : "Forecast fetched " + weather.fetchedAt.slice(11,16)); + $render( + Weather Ahead + {lines.map(line => {line})} + + {weather.attribution.text} + ); + } catch (error) { + console.error(String(error)); + $render(Weather AheadOpen this widget’s System Access in ScriptWidget, save access and authorize the system service.); + } +} diff --git a/docs/examples/weather-forecast/widget.json b/docs/examples/weather-forecast/widget.json new file mode 100644 index 00000000..66b4e4ea --- /dev/null +++ b/docs/examples/weather-forecast/widget.json @@ -0,0 +1,21 @@ +{ + "formatVersion": 2, + "id": "app.scriptwidget.example.weather-forecast", + "name": "Weather Ahead", + "version": "1.0.0", + "runtimeVersion": "1.0", + "minimumRuntimeVersion": "1.6", + "entry": "main.jsx", + "supportedFamilies": [ + "systemMedium", + "systemLarge" + ], + "permissions": [ + "weather", + "network" + ], + "networkDomains": [ + "api.met.no" + ], + "license": "Apache-2.0" +} diff --git a/docs/icloud-json-api.md b/docs/icloud-json-api.md index b1f3dec2..a6976070 100644 --- a/docs/icloud-json-api.md +++ b/docs/icloud-json-api.md @@ -10,6 +10,16 @@ In the native widget list, open the context menu → **iCloud Data**. Create a n Grants and caches are bound to a native installation UUID and current iCloud identity. Sign-out/account change denies old-account cached reads and writes. Reconnect explicitly for a new account. A system change to the identity token's archive can require reconnection rather than guessing authority. +## Separate and shared data spaces + +The `Scripts//` folder contains widget source and resources. It is separate from the JSON data stores under `WidgetData//`. A widget does not automatically receive a cloud data store just because its package is saved in iCloud. + +Each installed package has its own native read/write grant. In **iCloud Data**, the user can create a separate store for each package, or explicitly connect multiple packages to the **same store ID**. Connected packages share documents: a reading heatmap and reading statistics widget connected to the same store can both read and update `reading.json`. The same filename in different stores refers to independent data. Multiple Home Screen instances of the same installed package use that package's connection. + +JavaScript supplies only the document filename, such as `$icloud.readJSON("reading.json")`; it cannot choose a store ID, switch stores, access another unconnected store, or browse arbitrary iCloud files. Sharing grants read/write access to the connected store, so connect only widgets you trust with that data. Matching package names alone never establish sharing. On another device signed into the same iCloud account, explicitly connect the installed package to the same store ID. + +Shared data is eventually synchronized, not instantly shared memory. Widgets must agree on their JSON schema and handle retained conflicting revisions when devices edit offline or concurrently. `$storage` remains local and separate; connecting a store does not move existing habit records into iCloud. + ## Methods Every method returns a Promise. `name` is a flat lowercase ASCII filename matching `/^[a-z][a-z0-9_-]{0,58}\.json$/`. No directories, absolute paths, URLs or arbitrary iCloud access. diff --git a/docs/images/system-services/health-history-web.png b/docs/images/system-services/health-history-web.png new file mode 100644 index 00000000..886ff0d3 Binary files /dev/null and b/docs/images/system-services/health-history-web.png differ diff --git a/docs/images/system-services/notification-reminder-web.png b/docs/images/system-services/notification-reminder-web.png new file mode 100644 index 00000000..cad6cc67 Binary files /dev/null and b/docs/images/system-services/notification-reminder-web.png differ diff --git a/docs/scriptwidget-runtime-api.md b/docs/scriptwidget-runtime-api.md index cd8a13cb..8056457e 100644 --- a/docs/scriptwidget-runtime-api.md +++ b/docs/scriptwidget-runtime-api.md @@ -1,6 +1,6 @@ # ScriptWidget Runtime API -> Generated from Studio's static API metadata (schema v1, runtime 1.5). The native runtime switch is authoritative. Do not edit by hand. +> Generated from Studio's static API metadata (schema v1, runtime 1.6). The native runtime switch is authoritative. Do not edit by hand. ## Components @@ -885,11 +885,37 @@ Interactive widget toggle. A declared actionID requires a package-relative stora - `$location.isAuthorizedForWidgetUpdates`: Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale. - `$location.requestAuthorization`: Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale. - `$location.current`: Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale. +- `$notifications.status`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$notifications.pending`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$notifications.schedule`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$notifications.cancel`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$health.dailyStatistics`: Runtime 1.6. Read-only daily HealthKit statistics on installed iPhone/iPad widgets. Declare health and minimumRuntimeVersion 1.6, review Health access in native Settings. No separate System Access toggle. Missing readings are null/hasSamples false and cannot establish read denial. No raw samples, persistence or queries in future/Live Activity presentations. Preview fixtures never access real Health data. +- `$calendar.create`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created. +- `$calendar.update`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created. +- `$weather.forecast`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.status`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.pending`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.schedule`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.cancel`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.stop`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.pause`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$alarms.resume`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$documents.list`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$documents.readJSON`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$documents.readCSV`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$contacts.selected`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$maps.search`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$maps.geocode`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$maps.reverseGeocode`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$maps.snapshot`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$home.items`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$home.setPower`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. +- `$home.runScene`: Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. - `$icloud.readJSON`: Read cached JSON and revision; conflicts preserve all heads. Requires icloud permission and a native connection. Never certifies upload. - `$icloud.writeJSON`: Save a new immutable JSON revision locally from a user action. Requires the revision from readJSON. Background exchange is eventual. - `$icloud.resolveJSON`: Explicitly resolve all observed conflicting heads into a new revision. Stale tokens fail; originals remain. - `$icloud.sync`: Exchange materialized revisions with iCloud; requires a user action. Upload completion is unknown. -- `$icloud.status`: Read native connection state. Cloud store IDs are granted in the app, never by the script. Web uses preview mocks. +- `$icloud.status`: Read native connection state. In the app, explicitly connect packages to separate stores for isolation or the same store ID to share JSON documents. Scripts cannot choose store IDs. Sync is eventual; local $storage is not migrated. Web uses preview mocks. - `$file.exists`: Return whether a regular file is locally present inside this package, including binary assets. Missing files, directories, unsafe paths and links return false. Does not download iCloud files or read outside the package. Web preview uses workspace file presence. - `$file.read`: Read package-relative UTF-8 text. Missing or unavailable files return an empty string. - `$file.readJSON`: Read a package-relative JSON object. diff --git a/docs/storage-api.md b/docs/storage-api.md index e8504ac7..9f82f2cb 100644 --- a/docs/storage-api.md +++ b/docs/storage-api.md @@ -291,3 +291,9 @@ The `launcher` configuration-only kind saves title, accent and ordered link defi ## Optional iCloud JSON `$storage` remains local and is not migrated automatically. New packages can opt into the separate [iCloud JSON API](icloud-json-api.md) (Runtime 1.5), with explicit native user connection, cache-first reads and preserved conflicting revisions. + +## Filesystem identity across device restarts + +Native record storage now pairs its directory anchor with the filesystem's volume UUID. A POSIX mount device number (`st_dev`) can change after a device restart or system upgrade even when the directory inode and its contents are unchanged. The original logical record domain is retained, so package owner UUIDs, directory bindings, location hashes and saved records do not need to be recreated. + +On first opening an older store, a changed mount number can be recovered only inside the OS-provided ScriptWidget App Group, on the same current volume and with the original directory inode. The native service validates the existing anchor and version before publishing the volume proof, then marks the upgraded anchor. Interrupted proof publication can resume. Once upgraded, missing, malformed, symlinked or foreign-volume proofs fail closed instead of creating an empty store. A genuinely replaced directory still fails its inode check. Record payloads and original preferences are not rewritten by this compatibility upgrade. diff --git a/docs/system-services-api.md b/docs/system-services-api.md new file mode 100644 index 00000000..a31168e1 --- /dev/null +++ b/docs/system-services-api.md @@ -0,0 +1,179 @@ +# System services (Runtime 1.6) + +These APIs extend existing Calendar, HealthKit, network and App Intent capabilities. They use Apple's frameworks and the existing bounded HTTP transport; no third-party SDK, inference server or application server is added. Weather currently uses MET Norway rather than WeatherKit. + +## Install and authorize + +Use Package 2.0, `minimumRuntimeVersion: "1.6"`, and the relevant permissions below. Older runtimes reject unsupported permissions/versions. In the native widget list, open the widget's context menu → **System Access**, select capabilities and items, then **Save Access and Selections**. Separately authorize Notifications, Contacts, Home or Alarms there when needed. Calendar and Health authorization/source selection stay in app Settings. + +Native grants are local, bound to the installation UUID, and absent from exported packages. Rename retains access; a remix, import or new same-name installation does not inherit it. Revoking access stops subsequent calls without removing user records or imported copies. Cancel outstanding notifications/alarms before revocation. Native deletion requests cancellation of that installation's schedules; delivery/cancellation after process termination or OS denial still needs device acceptance. Calendar events are never deleted during widget deletion. + +All methods return Promises. All calls require a live installed execution, share the **8-query/execution** budget, and are denied during future timeline projections and scripted Live Activity presentations. Writes require a user-initiated native action. Native service callbacks recheck installation identity and the captured grant before delivery. No authorization sheets are presented automatically during widget rendering. + +| Capability | Manifest permissions | Native support | +| --- | --- | --- | +| Notifications | `notifications` | iOS/iPadOS, macOS; OS notification authorization | +| Health history | `health` | iPhone/iPad with available HealthKit; review types in Settings | +| Calendar writes | `calendar`, `calendarWrite` | iOS/iPadOS, macOS; full Calendar access and permitted calendar | +| Forecast | `weather`, `network`, `networkDomains:["api.met.no"]` | iOS/iPadOS, macOS; supplied coordinates, no automatic GPS | +| Alarms/timers | `alarms` | iOS/iPadOS 26+; AlarmKit authorization; unavailable on native macOS | +| Imported data | `documents` | iOS/iPadOS, macOS; explicit native file importer | +| Contacts | `contacts` | iOS/iPadOS, macOS; OS access plus native per-widget selection | +| Maps/places | `maps` | iOS/iPadOS, macOS; supplied query/coordinates sent to Apple Maps | +| Home accessories/scenes | `home` | iPhone/iPad; HomeKit authorization and selected items; unavailable on native macOS | + +Health history uses the existing Health review rather than the System Access toggle. Read authorization remains undisclosed by HealthKit: an empty result cannot establish denial. These APIs do not persist Health readings or log contacts, document contents, home values or system responses. + +## Local notifications + +```js +await $notifications.status(); // {authorization:"authorized"|...} +await $notifications.schedule({key:"reading",title:"Time to read",body:"One chapter",daily:{hour:20,minute:0}}); +await $notifications.schedule({key:"one-time",title:"A reminder",body:"Take a break",date:"2026-11-01T12:00:00Z"}); +await $notifications.pending(); // own keys, title, body, repeats, next date +await $notifications.cancel("reading"); // {key,status:"cancellationRequested"} +``` + +Supply exactly one of `date` (future ISO date-time, at most 366 days away) or `daily` (integer hour 0–23 and minute 0–59, system local clock). Daily reminders occupy one repeating slot; they do not require JavaScript to keep running. A key matches `[a-zA-Z0-9_-]{1,64}`. A repeated schedule with the same key replaces that installation's slot. Titles/body are nonempty, without control characters, at most 256/1024 UTF-8 bytes. Unknown fields reject. + +At most 32 slots per installation, with a conservative application-wide capacity check at 60 pending requests and a cross-process lock. Scheduling acknowledges OS acceptance, not delivery: Focus, notification settings and system behavior still apply. An acknowledgment timeout is an unknown outcome; inspect `pending()` before retrying. Cancellation targets only owned pending notifications, not notifications from other apps or already delivered history. + +[Runnable Reading Reminder](examples/notification-reminder). + +## Health history + +```js +const history = await $health.dailyStatistics({metric:"steps",days:7}); +// {metric,unit,aggregation,timeZone,items:[{date:"YYYY-MM-DD",value,hasSamples}]} +``` + +Metrics: `steps` (count), `activeEnergy` (kcal), `walkingDistance` (meters), `water` (milliliters), `bodyMass` (kilograms), `heartRate` (beats/minute). Body mass and heart rate use daily averages; the others use sums. `days` is an integer 1–31, default 7, including the current partial day. Bins use Gregorian local days and calendar boundaries, including DST. Missing readings return `value:null,hasSamples:false`; a measured zero remains valid. No raw samples, write access, routes or source identifiers are exposed. + +[Runnable Seven Day Steps](examples/health-history). + +## Calendar writes + +```js +const result = await $calendar.create({requestID:"11111111-1111-4111-8111-111111111111",calendarID:"",title:"Focus",start:"2026-11-01T12:00:00Z",end:"2026-11-01T12:30:00Z",allDay:false}); +await $calendar.update({requestID:"22222222-2222-4222-8222-222222222222",calendarID:"",id:result.id,title:"Updated focus",start:"2026-11-01T13:00:00Z",end:"2026-11-01T13:30:00Z",allDay:false}); +// {id,calendarID,status:"applied",replayed:boolean} +``` + +Create/update accept closed fields and a canonical lowercase request UUID. Start/end are explicit ISO date-times with positive duration up to 366 days. Update supplies the complete title/start/end, not a partial patch. Titles are at most 512 UTF-8 bytes. Calendar must be in the native selected source scope and writable. Updates are limited to single, nonrecurring events this installation created; importing an event ID cannot grant ownership. Recurrence, deletion and modification of other events are deliberately outside this contract. The native ownership registry is bounded to 128 events and stored outside script-accessible `$storage`. + +Create/update use private native replay receipts. A repeated requestID with the same operation returns its confirmed result; different arguments reject. Prepared/uncertain receipts cannot be retried blindly. Up to 128 receipts/64 KiB are retained; completed receipts expire after seven days, prepared receipts are not automatically discarded. Save the pending operation locally **before** calling the API. Retry an unchanged recent request only; inspect Calendar before resetting an old or uncertain operation. A system write can succeed even if the widget execution expires before receiving its result. + +[Runnable Focus Session with durable pending request](examples/calendar-focus). + +## Weather + +```js +const forecast = await $weather.forecast({latitude:37.33,longitude:-122.01,hours:24}); +// {provider,attribution:{text,url},latitude,longitude,fetchedAt,isStale, +// hours:[{time,temperatureC,windMetersPerSecond,precipitationMM,condition}]} +``` + +Coordinates are rounded to two decimals before transmission; latitude/longitude bounds are enforced. `hours` is an integer 1–48, default 24. MET Norway's compact forecast is normalized and bounded. Fresh matching private cache can be used for one hour; failures may return matching cache up to six hours old with `isStale:true`. `fetchedAt` is the fetch time, not an observation timestamp. Missing precipitation/condition remain null. Display the returned provider attribution and link. No WeatherKit entitlement, Apple weather quota or API key is involved. Network/domain restrictions, redirects, cancellation and request budgets still apply. + +[Runnable Weather Ahead with attribution](examples/weather-forecast). + +## Alarms and timers + +```js +await $alarms.status(); +await $alarms.schedule({requestID:"11111111-1111-4111-8111-111111111111",key:"focus",title:"Focus complete",seconds:1500}); +// Or supply date: instead of seconds. +await $alarms.pending(); // this installation's {key,state} items +await $alarms.pause("focus"); await $alarms.resume("focus"); +await $alarms.stop("focus"); await $alarms.cancel("focus"); +``` + +Use exactly one of `seconds` (60–86400) or `date` (future, at most 366 days). Titles are at most 128 UTF-8 bytes. Up to 32 named keys are tracked per installation. IDs are derived natively from installation + key; scripts cannot supply another alarm UUID. An active alarm is not silently replaced: cancel it explicitly first. Pause/resume depend on the system's current countdown state. Schedule uses the same bounded seven-day replay-receipt rules as calendar writes. Preserve pending requests when an outcome is unknown. + +On iOS 17–26, declared actions and control value actions use the application host via `LiveActivityIntent`, matching direct widget buttons; iOS 27 also declares the main execution target. AlarmKit authorization is process-scoped on iOS 26: a widget extension can report `notDetermined` even after the containing app is authorized, and pending reads can be denied there. Keep action controls visible when extension reads are unavailable; scheduling and control actions check the app’s live authorization. + +The extension includes native AlarmKit countdown Live Activity/Dynamic Island UI. It displays system dates without rerunning JavaScript. AlarmKit authorization, presentation, locked-device behavior, delivery and acknowledgments require physical-device acceptance. This API does not enumerate or edit alarms owned by Apple's Clock app. + +[Runnable Focus Timer](examples/alarm-focus-timer). + +## Imported JSON and CSV + +```js +const files = await $documents.list(); // [{id,name,type,bytes}] +const object = await $documents.readJSON(files.find(f => f.type === "json").id); +const table = await $documents.readCSV(files.find(f => f.type === "csv").id); +// {headers:[...],rows:[[...]],truncated:false} +``` + +Enable documents and import through System Access. The native picker authorizes a source file; a bounded descriptor read rejects links, nonregular files and concurrent source changes. The original is never modified. Copies and handles are installation-local and not exported with the script. Up to eight files, 256 KiB each; JSON root must be an object or array. CSV supports UTF-8/BOM, quoted delimiters/newlines and escaped quotes, up to 500 data rows, 32 unique nonempty headers and 8 KiB per cell. Ragged rows, invalid UTF-8, unclosed quotes and excess data reject rather than silently truncate. IDs are native UUIDs, never paths or bookmarks. Reimport captures an updated source; automatic live-file synchronization is not provided. + +[Runnable My JSON Data](examples/document-data). + +## Selected contacts + +```js +const people = await $contacts.selected(); +// [{id,name,organization,phones:[...],emails:[...]}] +``` + +Authorize Contacts and select up to 20 contacts in System Access, then save. The selection UI lists at most 200 system-accessible contacts. On iOS, limited authorization is respected. Each returned contact includes up to three phone numbers and three email addresses. Notes, photos, birthdays, arbitrary search and contact mutation are not exposed. No native contacts cache is retained; revocation is checked on reads. Data sent to Web Studio is always an editable sample, never this native selection. + +[Runnable People Close By](examples/selected-contacts). + +## Maps and places + +```js +await $maps.search({query:"park",latitude:37.33,longitude:-122.01,radiusMeters:3000}); +await $maps.geocode("Cupertino, California"); +await $maps.reverseGeocode({latitude:37.33,longitude:-122.01}); +const map = await $maps.snapshot({latitude:37.33,longitude:-122.01,radiusMeters:2000,size:256}); +// map: {image:,width,height,provider:"Apple Maps"} +``` + +Search/geocoding return up to five results. Queries/address text are bounded to 256 UTF-8 bytes; supplied coordinates are validated. Region radius is 100–50000 meters. Snapshots are square, integer 128–512 points, bounded JPEGs of at most 256 KiB; iOS uses scale 1 to bound decoded pixels. Preserve map attribution when displaying the image. New systems use MapKit geocoding requests; older iOS uses the supported fallback. Place results expose name/address/coordinates, not arbitrary provider objects. Older iOS returns the same bounded name/address/coordinate shape through its fallback. No device location is read implicitly. Requests are cancellable and system service availability/extension resource limits still apply. + +[Runnable A Place to Go](examples/map-place). + +## Home accessories and scenes + +```js +const items = await $home.items(); // selected {id,name,kind,metric,unit,value,isCached:true} +await $home.setPower({id:"",on:true}); +await $home.runScene({id:"",requestID:"11111111-1111-4111-8111-111111111111"}); +``` + +Authorize Home, select up to 20 exposed items and save. Discovery is bounded and exposes power, temperature, humidity, motion/contact sensors and scenes. Only power-state characteristics are directly writable; `setPower` is an absolute Boolean, never a blind toggle. Sensor values are HomeKit's cached readings and can be null; no claim of live accessory connectivity is made. Native macOS returns unavailable. + +Scenes can contain security-sensitive actions according to the user's Home configuration; native selection describes this before granting access. Only explicitly selected scenes execute, and platform authentication/lock restrictions remain in force. Scene execution uses private bounded replay receipts, with the same uncertainty and retention rules as calendar writes. An acknowledgment is not proof that every physical accessory reached its target. No arbitrary characteristic writes, lock/door API, discovery pairing, camera streaming or Home configuration changes are exposed. + +[Runnable A Calmer Home](examples/home-light). + +## Web Studio, CLI and validation + +Web Studio has editable per-method samples plus a **System access grants** section. `systemAccess.permissions` and selected `contacts`/`home` IDs model native scope. Manifest permission, Runtime 1.6, action-only writes, argument bounds and query budgets run before mock replies. Simulated notification/alarm/calendar/home mutations return `systemState` into the browser draft; Reset simulated state clears it. `systemCommitUncertain:true` models prepared mutation receipts. None of this touches Apple's services or changes package exports. Simulated receipts operate on the saved preview state; they do not certify real seven-day retention or OS side effects. + +Native CLI check/pack validate manifests and syntax. CLI renders use isolated read fixtures, with diagnostics that offline replies do not certify native query arguments; new system writes are rejected. An offline fixture cannot authorize a real system operation. Native record/receipt/grant files are separate from package-relative `$file` and public `$storage` keys. + +Run `node Scripts/test-system-services.mjs` for deterministic native validators, grants, file imports and private-key isolation. Application-host tests also verify real JSExport calls deny unmanaged/preview packages. Preview tests cover scopes, writes, replay/uncertainty, lifecycle simulation and budgets. Native builds/fixtures are not proof of real permissions, delivery or hardware behavior. + +## Preview examples + +These captures show Web Studio simulated data; they do not represent real-device system authorization or delivery. + +![Daily steps with editable simulated data](images/system-services/health-history-web.png) + +![Daily notification example in Web Studio](images/system-services/notification-reminder-web.png) + +## Physical-device acceptance before release + +- Fresh install, deny/grant/revoke each OS permission; verify missing native grant, copied widget and retired owner stay denied. +- One-time/daily notifications: replace/cancel, local-time/DST behavior, Focus suppression, capacity and concurrent app/extension requests. +- Health: readable data, no shared samples, actual zeros, new metric review, day boundaries and widget memory. +- Calendar: selected/writable source, create/update, denied foreign/recurring event, same request replay, changed arguments, interruption and unchanged existing events. +- Weather/Maps: offline/cache expiry, native attribution, geocoding, snapshot pixels, cancellation and extension memory. +- AlarmKit: authorize/deny, countdown Live Activity/Dynamic Island, pause/resume/stop/cancel, locked device, acknowledgment timeout and no Clock-app access. +- File picker: iCloud Drive and local files, UTF-8/quoted CSV, source unchanged, copies surviving relaunch, cross-widget denial and stale grant writes. +- Contacts/Home: limited selection, revocation, missing items, no automatic prompts in widgets, selected lights/scenes only, system authentication and stale sensor labels. +- Delete/rename/remix: native schedule cleanup requests, grant isolation, original package records retained and no same-name inheritance. + +Sources: [local notifications](https://developer.apple.com/documentation/usernotifications/scheduling-a-notification-locally-from-your-app), [HealthKit statistics](https://developer.apple.com/documentation/healthkit/hkstatisticscollectionquery), [EventKit access](https://developer.apple.com/documentation/eventkit/accessing-the-event-store), [AlarmKit](https://developer.apple.com/documentation/alarmkit), [Contacts access](https://developer.apple.com/documentation/contacts/accessing-the-contact-store), [HomeKit](https://developer.apple.com/documentation/homekit). diff --git a/iOS/ScriptWidget.xcodeproj/project.pbxproj b/iOS/ScriptWidget.xcodeproj/project.pbxproj index f209d037..0eeab8f0 100644 --- a/iOS/ScriptWidget.xcodeproj/project.pbxproj +++ b/iOS/ScriptWidget.xcodeproj/project.pbxproj @@ -36,6 +36,7 @@ 774D548855AA4BF0BF1E9DBA /* ScriptWidgetRuntimeLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC40ED375515427089251479 /* ScriptWidgetRuntimeLocation.swift */; }; 7D960C5FE159D8D1CB823654 /* ScriptWidgetRuntimeSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AE63BF6B17D4C800EFF80E9 /* ScriptWidgetRuntimeSystem.swift */; }; 84C1353FBC065F971E23478C /* PackageCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99DD0AE0F4C799D5DFEE8E76 /* PackageCacheTests.swift */; }; + 0A3A531AF5AC4D499D95C0F1 /* SystemServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85BD0B733DF8415FBF9D22F9 /* SystemServiceTests.swift */; }; 8B3078FA29098AA7314D1B74 /* ScriptWidgetRuntimeHealth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 654916CAF3464C1D5149BB77 /* ScriptWidgetRuntimeHealth.swift */; }; 08A34358AD98E4A7706B116B /* ScriptWidgetRuntimeCalendar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28960B338B1C363177987F8C /* ScriptWidgetRuntimeCalendar.swift */; }; 10CCA333072F422691BA7C60 /* ScriptWidgetRuntimeReminders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46E343599D0D41D29692292B /* ScriptWidgetRuntimeReminders.swift */; }; @@ -131,6 +132,7 @@ D1CBAED228D5B13400DE4E65 /* ScriptLiveActivityAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1CBAED128D5B13400DE4E65 /* ScriptLiveActivityAttributes.swift */; }; D1CBAED328D5B13400DE4E65 /* ScriptLiveActivityAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1CBAED128D5B13400DE4E65 /* ScriptLiveActivityAttributes.swift */; }; D1CBAED628D5B1DE00DE4E65 /* ScriptLiveActivityWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1CBAED528D5B1DE00DE4E65 /* ScriptLiveActivityWidget.swift */; }; + 909A08CF7F984EA5BBE67AE6 /* ScriptWidgetAlarmLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68A769B2F4CF48C693A359C8 /* ScriptWidgetAlarmLiveActivity.swift */; }; D1CBAEDA28D5DA9700DE4E65 /* ScriptWidgetDataObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1CBAED928D5DA9700DE4E65 /* ScriptWidgetDataObject.swift */; }; D1F9883228CCE7BF00C56B06 /* ScriptCodePreviewConsoleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1F9883128CCE7BF00C56B06 /* ScriptCodePreviewConsoleView.swift */; }; D58FF19E4AF865ACBDAF306A /* ScriptWidgetElementTagExtras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5116262BE362901C3EAD93A5 /* ScriptWidgetElementTagExtras.swift */; }; @@ -407,8 +409,28 @@ F2D738C925D0CA8900021E08 /* SettingTemplatesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2D738C825D0CA8900021E08 /* SettingTemplatesView.swift */; }; F2F0A7AE27F6841700D7911B /* ScriptWidgetRuntimeFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2F0A7AD27F6841700D7911B /* ScriptWidgetRuntimeFile.swift */; }; FBABB490DFDA409D8D266385 /* ScriptWidgetRuntimeCloudJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EC92A21DC4745FB8B1F582E /* ScriptWidgetRuntimeCloudJSON.swift */; }; + 493C018FD30D4FC1A2D33CAE /* ScriptWidgetRuntimeHome.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279E48E9059E44EEBCA5BE1E /* ScriptWidgetRuntimeHome.swift */; }; + 6CE6807AB92D473B90430578 /* ScriptWidgetRuntimeContacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 122CF699B12040C89F141B81 /* ScriptWidgetRuntimeContacts.swift */; }; + 14B364BBCA2C463B895ED69D /* ScriptWidgetRuntimeDocuments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4615A24A08384031A6652F21 /* ScriptWidgetRuntimeDocuments.swift */; }; + 6E3C7EE934474FD4AC1E6AE6 /* ScriptWidgetRuntimeAlarms.swift in Sources */ = {isa = PBXBuildFile; fileRef = 978C2231EB584BD39A45C9DE /* ScriptWidgetRuntimeAlarms.swift */; }; + 4C8326FBA7B64D51AAE7097E /* ScriptWidgetRuntimeWeather.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5AB6B70AB594C658947233F /* ScriptWidgetRuntimeWeather.swift */; }; + 82FBA0AE8CE34B4DAD0C4897 /* ScriptWidgetRuntimeMaps.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C957ED353A04BC4B282DCC8 /* ScriptWidgetRuntimeMaps.swift */; }; + 89C39D3BB1E643AEA85EA2B5 /* ScriptWidgetRuntimeHealthHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = E85C982B018243269DEDC303 /* ScriptWidgetRuntimeHealthHistory.swift */; }; + 5CCE97E07B3D455185E8946E /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E0E44B4112D435998BB2C2E /* ScriptWidgetRuntimeCalendarWrites.swift */; }; + 3B1F005818494B1596C2F2D6 /* ScriptWidgetRuntimeNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82031D1FFF65497BAE2FD92D /* ScriptWidgetRuntimeNotifications.swift */; }; + DC35F11FA99C4BB197FCAF63 /* ScriptWidgetRuntimeSystemServices.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB010D58873044FCADF6EF73 /* ScriptWidgetRuntimeSystemServices.swift */; }; F2F0A7AF27F6841700D7911B /* ScriptWidgetRuntimeFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2F0A7AD27F6841700D7911B /* ScriptWidgetRuntimeFile.swift */; }; 0F853DA1A57C46DCB7F10E8E /* ScriptWidgetRuntimeCloudJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EC92A21DC4745FB8B1F582E /* ScriptWidgetRuntimeCloudJSON.swift */; }; + AAE5AEE8B6164B898A7A19D0 /* ScriptWidgetRuntimeHome.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279E48E9059E44EEBCA5BE1E /* ScriptWidgetRuntimeHome.swift */; }; + 2287776114FE4116B6AA410F /* ScriptWidgetRuntimeContacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 122CF699B12040C89F141B81 /* ScriptWidgetRuntimeContacts.swift */; }; + 7D78B97645E64E2EA0396697 /* ScriptWidgetRuntimeDocuments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4615A24A08384031A6652F21 /* ScriptWidgetRuntimeDocuments.swift */; }; + A9953FF2D7CA4FB0B9D3F665 /* ScriptWidgetRuntimeAlarms.swift in Sources */ = {isa = PBXBuildFile; fileRef = 978C2231EB584BD39A45C9DE /* ScriptWidgetRuntimeAlarms.swift */; }; + 4AE33603CDAC471783071C79 /* ScriptWidgetRuntimeWeather.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5AB6B70AB594C658947233F /* ScriptWidgetRuntimeWeather.swift */; }; + BAFA4CE9BB80400EA07E1C66 /* ScriptWidgetRuntimeMaps.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C957ED353A04BC4B282DCC8 /* ScriptWidgetRuntimeMaps.swift */; }; + 51E80A0B83904F0CA3862B66 /* ScriptWidgetRuntimeHealthHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = E85C982B018243269DEDC303 /* ScriptWidgetRuntimeHealthHistory.swift */; }; + 4087BA20E7C54529BCA5E8CF /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E0E44B4112D435998BB2C2E /* ScriptWidgetRuntimeCalendarWrites.swift */; }; + 20BFB3F656E44E0CAF48598F /* ScriptWidgetRuntimeNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82031D1FFF65497BAE2FD92D /* ScriptWidgetRuntimeNotifications.swift */; }; + 815D58697D5C47EEBE5A4E1F /* ScriptWidgetRuntimeSystemServices.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB010D58873044FCADF6EF73 /* ScriptWidgetRuntimeSystemServices.swift */; }; F2F8398E27CBBC8800D74288 /* HomeHelloView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2F8398D27CBBC8800D74288 /* HomeHelloView.swift */; }; F2FC062327DC5D9000A6A99D /* MirrorEditorScriptView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2FC062227DC5D9000A6A99D /* MirrorEditorScriptView.swift */; }; F2FC062827DC5DB300A6A99D /* WKWebViewJavascriptBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2FC062527DC5DB300A6A99D /* WKWebViewJavascriptBridge.swift */; }; @@ -423,6 +445,7 @@ A815305D31B24EFE9AE72321 /* ScriptWidgetCloudJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 113B591460C0428199E1B2D3 /* ScriptWidgetCloudJSON.swift */; }; 4635FD7C47944227987DB767 /* ScriptWidgetRecordsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B96A79828AD84572AB1D6170 /* ScriptWidgetRecordsView.swift */; }; 6E5ACA07639849578EAF9019 /* ScriptWidgetCloudJSONView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5802CF1E2FEF4FFCAAC3BEC9 /* ScriptWidgetCloudJSONView.swift */; }; + 8AFAEADE37DE4A0589FB69CB /* ScriptWidgetSystemAccessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3870C1E2FAC54FA2B5CC888A /* ScriptWidgetSystemAccessView.swift */; }; A666715063344E9EBBE6E4E9 /* ScriptWidgetStorageUpgradeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE3501C2E4244E879AD942D7 /* ScriptWidgetStorageUpgradeView.swift */; }; D96A3CEA7A35471B83EE7BD1 /* ScriptWidgetRecordStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C847E9CCBC140F6B53AC772 /* ScriptWidgetRecordStore.swift */; }; 65E61B2E0949425591993A22 /* ScriptWidgetCloudJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 113B591460C0428199E1B2D3 /* ScriptWidgetCloudJSON.swift */; }; @@ -511,6 +534,7 @@ 750919EB639B4EB3B07D27FC /* ReloadWidgetAppIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReloadWidgetAppIntent.swift; sourceTree = ""; }; 95D38A9C0960C28615553017 /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; }; 99DD0AE0F4C799D5DFEE8E76 /* PackageCacheTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PackageCacheTests.swift; path = ../Tests/ScriptWidgetRuntimeTests/PackageCacheTests.swift; sourceTree = ""; }; + 85BD0B733DF8415FBF9D22F9 /* SystemServiceTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SystemServiceTests.swift; path = ../Tests/ScriptWidgetRuntimeTests/SystemServiceTests.swift; sourceTree = ""; }; 9CAE338C670B4A70B52A6CFD /* ScriptWidgetRuntimeStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeStorage.swift; sourceTree = ""; }; 99619D8E19192386E982EC46 /* ScriptWidgetStorageLock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetStorageLock.swift; sourceTree = ""; }; A101000100000000000000B0 /* AISettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AISettings.swift; sourceTree = ""; }; @@ -599,6 +623,7 @@ D1BD329B28E0713D00F217ED /* ScriptLiveActivityDataObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptLiveActivityDataObject.swift; sourceTree = ""; }; D1CBAED128D5B13400DE4E65 /* ScriptLiveActivityAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptLiveActivityAttributes.swift; sourceTree = ""; }; D1CBAED528D5B1DE00DE4E65 /* ScriptLiveActivityWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptLiveActivityWidget.swift; sourceTree = ""; }; + 68A769B2F4CF48C693A359C8 /* ScriptWidgetAlarmLiveActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetAlarmLiveActivity.swift; sourceTree = ""; }; D1CBAED928D5DA9700DE4E65 /* ScriptWidgetDataObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetDataObject.swift; sourceTree = ""; }; D1F9883128CCE7BF00C56B06 /* ScriptCodePreviewConsoleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptCodePreviewConsoleView.swift; sourceTree = ""; }; DC40ED375515427089251479 /* ScriptWidgetRuntimeLocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeLocation.swift; sourceTree = ""; }; @@ -797,6 +822,16 @@ F2D738C825D0CA8900021E08 /* SettingTemplatesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingTemplatesView.swift; sourceTree = ""; }; F2F0A7AD27F6841700D7911B /* ScriptWidgetRuntimeFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeFile.swift; sourceTree = ""; }; 8EC92A21DC4745FB8B1F582E /* ScriptWidgetRuntimeCloudJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeCloudJSON.swift; sourceTree = ""; }; + 279E48E9059E44EEBCA5BE1E /* ScriptWidgetRuntimeHome.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeHome.swift; sourceTree = ""; }; + 122CF699B12040C89F141B81 /* ScriptWidgetRuntimeContacts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeContacts.swift; sourceTree = ""; }; + 4615A24A08384031A6652F21 /* ScriptWidgetRuntimeDocuments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeDocuments.swift; sourceTree = ""; }; + 978C2231EB584BD39A45C9DE /* ScriptWidgetRuntimeAlarms.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeAlarms.swift; sourceTree = ""; }; + D5AB6B70AB594C658947233F /* ScriptWidgetRuntimeWeather.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeWeather.swift; sourceTree = ""; }; + 9C957ED353A04BC4B282DCC8 /* ScriptWidgetRuntimeMaps.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeMaps.swift; sourceTree = ""; }; + E85C982B018243269DEDC303 /* ScriptWidgetRuntimeHealthHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeHealthHistory.swift; sourceTree = ""; }; + 9E0E44B4112D435998BB2C2E /* ScriptWidgetRuntimeCalendarWrites.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeCalendarWrites.swift; sourceTree = ""; }; + 82031D1FFF65497BAE2FD92D /* ScriptWidgetRuntimeNotifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeNotifications.swift; sourceTree = ""; }; + DB010D58873044FCADF6EF73 /* ScriptWidgetRuntimeSystemServices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeSystemServices.swift; sourceTree = ""; }; F2F8398D27CBBC8800D74288 /* HomeHelloView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeHelloView.swift; sourceTree = ""; }; F2FC062227DC5D9000A6A99D /* MirrorEditorScriptView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MirrorEditorScriptView.swift; sourceTree = ""; }; F2FC062527DC5DB300A6A99D /* WKWebViewJavascriptBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WKWebViewJavascriptBridge.swift; sourceTree = ""; }; @@ -811,6 +846,7 @@ 113B591460C0428199E1B2D3 /* ScriptWidgetCloudJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetCloudJSON.swift; sourceTree = ""; }; B96A79828AD84572AB1D6170 /* ScriptWidgetRecordsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRecordsView.swift; sourceTree = ""; }; 5802CF1E2FEF4FFCAAC3BEC9 /* ScriptWidgetCloudJSONView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetCloudJSONView.swift; sourceTree = ""; }; + 3870C1E2FAC54FA2B5CC888A /* ScriptWidgetSystemAccessView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetSystemAccessView.swift; sourceTree = ""; }; BE3501C2E4244E879AD942D7 /* ScriptWidgetStorageUpgradeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetStorageUpgradeView.swift; sourceTree = ""; }; A804AC8F6C5F4242BBA72345 /* ScriptWidgetStorageNamespaces.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetStorageNamespaces.swift; sourceTree = ""; }; 903FF2D5FB884143B154AA20 /* ScriptWidgetStorageFiles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetStorageFiles.swift; sourceTree = ""; }; @@ -890,6 +926,7 @@ E9ABF8F095487FE21DB73700 /* RuntimeExecutionTests.swift */, 4504B2C47E011F6AE74734CD /* BrowserPreviewParityTests.swift */, 99DD0AE0F4C799D5DFEE8E76 /* PackageCacheTests.swift */, + 85BD0B733DF8415FBF9D22F9 /* SystemServiceTests.swift */, ); name = Tests; sourceTree = SOURCE_ROOT; @@ -1192,6 +1229,7 @@ isa = PBXGroup; children = ( D1CBAED528D5B1DE00DE4E65 /* ScriptLiveActivityWidget.swift */, + 68A769B2F4CF48C693A359C8 /* ScriptWidgetAlarmLiveActivity.swift */, D1BD329B28E0713D00F217ED /* ScriptLiveActivityDataObject.swift */, D132336628E09630002C26A2 /* ScriptDynamicIslandCreator.swift */, ); @@ -1303,6 +1341,7 @@ 113B591460C0428199E1B2D3 /* ScriptWidgetCloudJSON.swift */, B96A79828AD84572AB1D6170 /* ScriptWidgetRecordsView.swift */, 5802CF1E2FEF4FFCAAC3BEC9 /* ScriptWidgetCloudJSONView.swift */, + 3870C1E2FAC54FA2B5CC888A /* ScriptWidgetSystemAccessView.swift */, BE3501C2E4244E879AD942D7 /* ScriptWidgetStorageUpgradeView.swift */, F29118EC2793034D00B860B0 /* ScriptModel.swift */, D1A0000000E0000000000001 /* ScriptMetadata.swift */, @@ -1461,6 +1500,16 @@ F29119302793035E00B860B0 /* ScriptWidgetRuntimeDevice.swift */, F2F0A7AD27F6841700D7911B /* ScriptWidgetRuntimeFile.swift */, 8EC92A21DC4745FB8B1F582E /* ScriptWidgetRuntimeCloudJSON.swift */, + 279E48E9059E44EEBCA5BE1E /* ScriptWidgetRuntimeHome.swift */, + 122CF699B12040C89F141B81 /* ScriptWidgetRuntimeContacts.swift */, + 4615A24A08384031A6652F21 /* ScriptWidgetRuntimeDocuments.swift */, + 978C2231EB584BD39A45C9DE /* ScriptWidgetRuntimeAlarms.swift */, + D5AB6B70AB594C658947233F /* ScriptWidgetRuntimeWeather.swift */, + 9C957ED353A04BC4B282DCC8 /* ScriptWidgetRuntimeMaps.swift */, + E85C982B018243269DEDC303 /* ScriptWidgetRuntimeHealthHistory.swift */, + 9E0E44B4112D435998BB2C2E /* ScriptWidgetRuntimeCalendarWrites.swift */, + 82031D1FFF65497BAE2FD92D /* ScriptWidgetRuntimeNotifications.swift */, + DB010D58873044FCADF6EF73 /* ScriptWidgetRuntimeSystemServices.swift */, 1AE63BF6B17D4C800EFF80E9 /* ScriptWidgetRuntimeSystem.swift */, 654916CAF3464C1D5149BB77 /* ScriptWidgetRuntimeHealth.swift */, 28960B338B1C363177987F8C /* ScriptWidgetRuntimeCalendar.swift */, @@ -1971,6 +2020,7 @@ A120000600000000000000B0 /* WebStudioServerTests.swift in Sources */, B165542F120D2E511D4012B9 /* AIGenerationTests.swift in Sources */, 84C1353FBC065F971E23478C /* PackageCacheTests.swift in Sources */, + 0A3A531AF5AC4D499D95C0F1 /* SystemServiceTests.swift in Sources */, CE64AF58A011259D931CFF8F /* RuntimeExecutionTests.swift in Sources */, 264B37FB1BB1BFADE1A20B70 /* BrowserPreviewParityTests.swift in Sources */, 74884F234581499E712CA059 /* RuntimeUnitTests.swift in Sources */, @@ -2031,6 +2081,16 @@ F29119582793035E00B860B0 /* ScriptWidgetAttributeShadowModifier.swift in Sources */, F2F0A7AE27F6841700D7911B /* ScriptWidgetRuntimeFile.swift in Sources */, FBABB490DFDA409D8D266385 /* ScriptWidgetRuntimeCloudJSON.swift in Sources */, + 493C018FD30D4FC1A2D33CAE /* ScriptWidgetRuntimeHome.swift in Sources */, + 6CE6807AB92D473B90430578 /* ScriptWidgetRuntimeContacts.swift in Sources */, + 14B364BBCA2C463B895ED69D /* ScriptWidgetRuntimeDocuments.swift in Sources */, + 6E3C7EE934474FD4AC1E6AE6 /* ScriptWidgetRuntimeAlarms.swift in Sources */, + 4C8326FBA7B64D51AAE7097E /* ScriptWidgetRuntimeWeather.swift in Sources */, + 82FBA0AE8CE34B4DAD0C4897 /* ScriptWidgetRuntimeMaps.swift in Sources */, + 89C39D3BB1E643AEA85EA2B5 /* ScriptWidgetRuntimeHealthHistory.swift in Sources */, + 5CCE97E07B3D455185E8946E /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */, + 3B1F005818494B1596C2F2D6 /* ScriptWidgetRuntimeNotifications.swift in Sources */, + DC35F11FA99C4BB197FCAF63 /* ScriptWidgetRuntimeSystemServices.swift in Sources */, 7D960C5FE159D8D1CB823654 /* ScriptWidgetRuntimeSystem.swift in Sources */, 8B3078FA29098AA7314D1B74 /* ScriptWidgetRuntimeHealth.swift in Sources */, 08A34358AD98E4A7706B116B /* ScriptWidgetRuntimeCalendar.swift in Sources */, @@ -2053,6 +2113,7 @@ A815305D31B24EFE9AE72321 /* ScriptWidgetCloudJSON.swift in Sources */, 4635FD7C47944227987DB767 /* ScriptWidgetRecordsView.swift in Sources */, 6E5ACA07639849578EAF9019 /* ScriptWidgetCloudJSONView.swift in Sources */, + 8AFAEADE37DE4A0589FB69CB /* ScriptWidgetSystemAccessView.swift in Sources */, A666715063344E9EBBE6E4E9 /* ScriptWidgetStorageUpgradeView.swift in Sources */, D58FF19E4AF865ACBDAF306A /* ScriptWidgetElementTagExtras.swift in Sources */, F2BA1DA725D500B400363EEA /* EditAttributesView.swift in Sources */, @@ -2176,6 +2237,7 @@ F28D681F27CE8874000C2D03 /* ScriptWidgetElementTagGrid.swift in Sources */, D1CBAEDA28D5DA9700DE4E65 /* ScriptWidgetDataObject.swift in Sources */, D1CBAED628D5B1DE00DE4E65 /* ScriptLiveActivityWidget.swift in Sources */, + 909A08CF7F984EA5BBE67AE6 /* ScriptWidgetAlarmLiveActivity.swift in Sources */, F29119472793035E00B860B0 /* ScriptWidgetRuntime.swift in Sources */, 3DDAB85E7A78E9FAA8078100 /* ScriptWidgetRuntimeDelivery.swift in Sources */, A130000300000000000000B0 /* ScriptWidgetRuntimeDiagnostics.swift in Sources */, @@ -2206,6 +2268,16 @@ F28D681327CE764B000C2D03 /* ScriptWidgetAttributeClippedModifier.swift in Sources */, F2F0A7AF27F6841700D7911B /* ScriptWidgetRuntimeFile.swift in Sources */, 0F853DA1A57C46DCB7F10E8E /* ScriptWidgetRuntimeCloudJSON.swift in Sources */, + AAE5AEE8B6164B898A7A19D0 /* ScriptWidgetRuntimeHome.swift in Sources */, + 2287776114FE4116B6AA410F /* ScriptWidgetRuntimeContacts.swift in Sources */, + 7D78B97645E64E2EA0396697 /* ScriptWidgetRuntimeDocuments.swift in Sources */, + A9953FF2D7CA4FB0B9D3F665 /* ScriptWidgetRuntimeAlarms.swift in Sources */, + 4AE33603CDAC471783071C79 /* ScriptWidgetRuntimeWeather.swift in Sources */, + BAFA4CE9BB80400EA07E1C66 /* ScriptWidgetRuntimeMaps.swift in Sources */, + 51E80A0B83904F0CA3862B66 /* ScriptWidgetRuntimeHealthHistory.swift in Sources */, + 4087BA20E7C54529BCA5E8CF /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */, + 20BFB3F656E44E0CAF48598F /* ScriptWidgetRuntimeNotifications.swift in Sources */, + 815D58697D5C47EEBE5A4E1F /* ScriptWidgetRuntimeSystemServices.swift in Sources */, 219AD8869A85F18C81A30804 /* ScriptWidgetRuntimeSystem.swift in Sources */, D84E5F5BA6A8C145C140773A /* ScriptWidgetRuntimeHealth.swift in Sources */, 379480111C85C446898E519E /* ScriptWidgetRuntimeCalendar.swift in Sources */, @@ -2488,7 +2560,7 @@ CODE_SIGN_ENTITLEMENTS = ScriptWidget/ScriptWidget.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEVELOPMENT_ASSET_PATHS = "\"ScriptWidget/Preview Content\""; DEVELOPMENT_TEAM = YPV49M8592; ENABLE_PREVIEWS = YES; @@ -2500,7 +2572,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2521,7 +2593,7 @@ CODE_SIGN_ENTITLEMENTS = ScriptWidget/ScriptWidget.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEVELOPMENT_ASSET_PATHS = "\"ScriptWidget/Preview Content\""; DEVELOPMENT_TEAM = YPV49M8592; ENABLE_PREVIEWS = YES; @@ -2532,7 +2604,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2549,7 +2621,7 @@ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CODE_SIGN_ENTITLEMENTS = ScriptWidgetWidget/ScriptWidgetWidget.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEVELOPMENT_TEAM = YPV49M8592; INFOPLIST_FILE = ScriptWidgetWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 18.0; @@ -2558,7 +2630,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; OTHER_SWIFT_FLAGS = "-D IsWidgetTarget"; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget.widget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2575,7 +2647,7 @@ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CODE_SIGN_ENTITLEMENTS = ScriptWidgetWidget/ScriptWidgetWidget.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEVELOPMENT_TEAM = YPV49M8592; INFOPLIST_FILE = ScriptWidgetWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 18.0; @@ -2584,7 +2656,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; OTHER_SWIFT_FLAGS = "-D IsWidgetTarget"; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget.widget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2600,7 +2672,7 @@ CODE_SIGN_ENTITLEMENTS = ScriptWidgetShare/ScriptWidgetShare.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEVELOPMENT_TEAM = YPV49M8592; INFOPLIST_FILE = ScriptWidgetShare/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.0; @@ -2609,7 +2681,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget.share; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -2624,7 +2696,7 @@ CODE_SIGN_ENTITLEMENTS = ScriptWidgetShare/ScriptWidgetShare.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEVELOPMENT_TEAM = YPV49M8592; INFOPLIST_FILE = ScriptWidgetShare/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.0; @@ -2633,7 +2705,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget.share; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; diff --git a/iOS/ScriptWidget/App/APIs/APIsHomeView.swift b/iOS/ScriptWidget/App/APIs/APIsHomeView.swift index 526bdd66..d594f945 100644 --- a/iOS/ScriptWidget/App/APIs/APIsHomeView.swift +++ b/iOS/ScriptWidget/App/APIs/APIsHomeView.swift @@ -8,8 +8,8 @@ import SwiftUI struct APIsHomeView: View { - @State private var tabBar: UITabBar! = nil - private var idiom : UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } + @Environment(\.horizontalSizeClass) private var horizontalSizeClass + @State private var isTabBarVisible = true var body: some View { NavigationStack { @@ -19,23 +19,11 @@ struct APIsHomeView: View { showTabBar(true) } } - .background(TabBarAccessor { tabbar in // << here !! - if idiom != .pad { - self.tabBar = tabbar - } - }) + .toolbar(horizontalSizeClass == .regular || isTabBarVisible ? .visible : .hidden, for: .tabBar) } func showTabBar(_ visible: Bool) { - guard let tabBar = tabBar else { - return - } - - if visible { - tabBar.isHidden = false - } else { - tabBar.isHidden = true - } + isTabBarVisible = visible } } diff --git a/iOS/ScriptWidget/App/AppDelegate.swift b/iOS/ScriptWidget/App/AppDelegate.swift index 8aff7569..d9fd05df 100644 --- a/iOS/ScriptWidget/App/AppDelegate.swift +++ b/iOS/ScriptWidget/App/AppDelegate.swift @@ -12,7 +12,7 @@ class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { - let _ = sharedAppState.screenBounds + let _ = sharedAppState #if !DEBUG DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { diff --git a/iOS/ScriptWidget/App/Components/ComponentsHomeView.swift b/iOS/ScriptWidget/App/Components/ComponentsHomeView.swift index dad73d03..6d1314df 100644 --- a/iOS/ScriptWidget/App/Components/ComponentsHomeView.swift +++ b/iOS/ScriptWidget/App/Components/ComponentsHomeView.swift @@ -8,8 +8,8 @@ import SwiftUI struct ComponentsHomeView: View { - @State private var tabBar: UITabBar! = nil - private var idiom : UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } + @Environment(\.horizontalSizeClass) private var horizontalSizeClass + @State private var isTabBarVisible = true var body: some View { NavigationStack { @@ -22,23 +22,11 @@ struct ComponentsHomeView: View { showTabBar(true) } } - .background(TabBarAccessor { tabbar in // << here !! - if idiom != .pad { - self.tabBar = tabbar - } - }) + .toolbar(horizontalSizeClass == .regular || isTabBarVisible ? .visible : .hidden, for: .tabBar) } func showTabBar(_ visible: Bool) { - guard let tabBar = tabBar else { - return - } - - if visible { - tabBar.isHidden = false - } else { - tabBar.isHidden = true - } + isTabBarVisible = visible } } diff --git a/iOS/ScriptWidget/App/ScriptWidgetApp.swift b/iOS/ScriptWidget/App/ScriptWidgetApp.swift index 6ba3eb7b..17fc48a6 100644 --- a/iOS/ScriptWidget/App/ScriptWidgetApp.swift +++ b/iOS/ScriptWidget/App/ScriptWidgetApp.swift @@ -130,6 +130,7 @@ struct ScriptWidgetApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate; init() { + ScriptWidgetSystemServices.startLifecycle() if #available(iOS 16.2,*) { _ = sharedLiveActivityManager } ScriptWidgetPrecompiler.install() } diff --git a/iOS/ScriptWidget/App/Scripts/CreateGuideView.swift b/iOS/ScriptWidget/App/Scripts/CreateGuideView.swift index e1d217b2..674226d3 100644 --- a/iOS/ScriptWidget/App/Scripts/CreateGuideView.swift +++ b/iOS/ScriptWidget/App/Scripts/CreateGuideView.swift @@ -327,10 +327,13 @@ struct TemplateCardView: View { if let url = model.package.previewImageURL(), let uiImage = UIImage(contentsOfFile: url.path) { - Image(uiImage: uiImage) - .resizable() - .scaledToFill() - .clipShape(RoundedRectangle(cornerRadius: 10)) + GeometryReader { proxy in + Image(uiImage: uiImage) + .resizable() + .scaledToFit() + .frame(width: proxy.size.width, height: proxy.size.height) + .clipShape(RoundedRectangle(cornerRadius: 10)) + } } else { Image(systemName: model.iconSystemName) .font(.system(size: 34, weight: .regular)) diff --git a/iOS/ScriptWidget/App/Scripts/ImageListView.swift b/iOS/ScriptWidget/App/Scripts/ImageListView.swift index 38620301..6e76f901 100644 --- a/iOS/ScriptWidget/App/Scripts/ImageListView.swift +++ b/iOS/ScriptWidget/App/Scripts/ImageListView.swift @@ -51,66 +51,66 @@ struct ImageListView: View { @State private var isAddingImage: Bool = false @StateObject private var dataObject: ImageDataObject - let size: CGFloat - let columns: [GridItem] let title: String init(model: ScriptModel) { - // Cap thumbnail size so the grid stays well-proportioned on iPad / wide - // multitasking windows instead of rendering a few oversized images. - self.size = min(screenShortLength / 3 - 10, 110) - self.columns = [ - GridItem(.adaptive(minimum: size), spacing: 5), - ] _dataObject = StateObject(wrappedValue: ImageDataObject(model: model)) self.title = "Images" } var body: some View { - ScrollView { - LazyVGrid(columns: columns, spacing: 16) { - if dataObject.images.isEmpty { - VStack(spacing: 10) { - Image(systemName: "photo.on.rectangle.angled") - .font(.largeTitle) - Text("No images yet") - .font(.headline) - Text("Add an image to use it from your widget script.") - .font(.caption) - .multilineTextAlignment(.center) + GeometryReader { proxy in + // Use this view's available width so thumbnails follow scene resizing. + let size = min(max((proxy.size.width - 32) / 3 - 10, 1), 110) + let columns = [GridItem(.adaptive(minimum: size), spacing: 5)] + ScrollView { + LazyVGrid(columns: columns, spacing: 16) { + if dataObject.images.isEmpty { + VStack(spacing: 10) { + Image(systemName: "photo.on.rectangle.angled") + .font(.largeTitle) + Text("No images yet") + .font(.headline) + Text("Add an image to use it from your widget script.") + .font(.caption) + .multilineTextAlignment(.center) + } + .foregroundStyle(.secondary) + .frame(maxWidth: .infinity) + .padding(.vertical, 60) } - .foregroundStyle(.secondary) - .frame(maxWidth: .infinity) - .padding(.vertical, 60) - } - ForEach(dataObject.images) { item in - Button(action: { - self.previewingImage = item - }) { + ForEach(dataObject.images) { item in + Button(action: { + self.previewingImage = item + }) { - VStack(alignment: .leading, spacing: 8) { - WebImage(url: item.path) - .placeholder { - RoundedRectangle(cornerRadius: 12) - .fill(.quaternary) + VStack(alignment: .leading, spacing: 8) { + GeometryReader { thumbnail in + WebImage(url: item.path) + .placeholder { + RoundedRectangle(cornerRadius: 12) + .fill(.quaternary) + } + .resizable() + .aspectRatio(contentMode: .fill) + .frame(width: thumbnail.size.width, height: size) + .clipped() } - .resizable() - .aspectRatio(contentMode: .fill) .frame(height: size) - .frame(maxWidth: .infinity) .clipShape(.rect(cornerRadius: 12)) - Text(item.name) - .font(.caption.weight(.medium)) - .foregroundStyle(.primary) - .lineLimit(1) + Text(item.name) + .font(.caption.weight(.medium)) + .foregroundStyle(.primary) + .lineLimit(1) + } + .padding(10) + .background(Color(.secondarySystemGroupedBackground), in: .rect(cornerRadius: 16)) } - .padding(10) - .background(Color(.secondarySystemGroupedBackground), in: .rect(cornerRadius: 16)) + .buttonStyle(.plain) } - .buttonStyle(.plain) } + .padding() } - .padding() } .background(Color(.systemGroupedBackground)) .navigationTitle(title) diff --git a/iOS/ScriptWidget/App/Scripts/ScriptWidgetHomeView.swift b/iOS/ScriptWidget/App/Scripts/ScriptWidgetHomeView.swift index 5154564b..ca32b2e2 100644 --- a/iOS/ScriptWidget/App/Scripts/ScriptWidgetHomeView.swift +++ b/iOS/ScriptWidget/App/Scripts/ScriptWidgetHomeView.swift @@ -69,6 +69,7 @@ struct ScriptWidgetHomeView: View { @State private var selectedShareItem: ScriptModel? @State private var selectedRecordItem: ScriptModel? @State private var selectedCloudItem: ScriptModel? + @State private var selectedSystemItem: ScriptModel? @State private var selectedDeleteItem: ScriptModel? @State private var isShowingDeleteAlert = false @@ -96,7 +97,8 @@ struct ScriptWidgetHomeView: View { } message: { item in Text("“\(item.name)” and its project files will be removed. This can’t be undone.") } - .sheet(item: $selectedCloudItem) { item in ScriptWidgetCloudJSONView(package: item.package) } + .sheet(item: $selectedSystemItem) { item in ScriptWidgetSystemAccessView(package: item.package) } + .sheet(item: $selectedCloudItem) { item in ScriptWidgetCloudJSONView(package: item.package) } .sheet(item: $selectedRecordItem) { item in ScriptWidgetRecordsView(package: item.package) } @@ -228,6 +230,9 @@ struct ScriptWidgetHomeView: View { WidgetRowView(model: item) } .contextMenu { + if ScriptWidgetSystemAccessView.supports(item.package) { + Button("System Access", systemImage: "hand.raised") { selectedSystemItem = item } + } if item.package.readManifest()?.permissions.contains(.icloud) == true { Button("iCloud Data", systemImage: "icloud") { selectedCloudItem = item } } diff --git a/iOS/ScriptWidget/Data/ScreenData.swift b/iOS/ScriptWidget/Data/ScreenData.swift index e6b6ef72..783af5b3 100644 --- a/iOS/ScriptWidget/Data/ScreenData.swift +++ b/iOS/ScriptWidget/Data/ScreenData.swift @@ -5,8 +5,4 @@ // Created by everettjf on 2021/2/14. // -import SwiftUI - -let screenWidth = UIScreen.main.bounds.width -let screenHeight = UIScreen.main.bounds.height -let screenShortLength = screenWidth > screenHeight ? screenHeight : screenWidth +// Layout reads local GeometryReader sizes instead of process-wide screen constants. diff --git a/iOS/ScriptWidget/Info.plist b/iOS/ScriptWidget/Info.plist index fdd42801..bc246071 100644 --- a/iOS/ScriptWidget/Info.plist +++ b/iOS/ScriptWidget/Info.plist @@ -29,9 +29,9 @@ NSRemindersUsageDescription Allow ScriptWidget to read reminders from lists you choose and apply reminder actions you trigger. NSCalendarsFullAccessUsageDescription - Allow ScriptWidget to read events for calendar widgets you choose. + Allow ScriptWidget to read events from calendars you choose and create or update widget-owned events through actions you trigger. NSCalendarsUsageDescription - Allow ScriptWidget to read events for calendar widgets you choose. + Allow ScriptWidget to read events from calendars you choose and create or update widget-owned events through actions you trigger. CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -461,5 +461,11 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSContactsUsageDescription + Select contacts to share with your chosen widgets. + NSHomeKitUsageDescription + Read selected home accessories and run selected controls or scenes from widgets. + NSAlarmKitUsageDescription + Schedule alarms and timers you explicitly request from a widget. diff --git a/iOS/ScriptWidget/Manager/WebStudioServer.swift b/iOS/ScriptWidget/Manager/WebStudioServer.swift index 3fe7ba43..7dcf4b1c 100644 --- a/iOS/ScriptWidget/Manager/WebStudioServer.swift +++ b/iOS/ScriptWidget/Manager/WebStudioServer.swift @@ -46,13 +46,15 @@ final class WebStudioServer: ObservableObject { private var leaseWorkItem: DispatchWorkItem? private let maximumRequestBytes = 2 * 1024 * 1024 private let sessionLease: TimeInterval + private let managerOverride: ScriptManager? private var eventSequence = 0 private var events = [WebStudioEvent]() private var previewSnapshot: Data? private let eventLock = NSLock() - init(sessionLease: TimeInterval = 15) { + init(sessionLease: TimeInterval = 15, manager: ScriptManager? = nil) { self.sessionLease = sessionLease + self.managerOverride = manager } var displayURLs: [String] { @@ -74,7 +76,7 @@ final class WebStudioServer: ObservableObject { let lease = ScriptWidgetEditorPresence.register() libraryEditorLease = lease do { - let library = try ScriptWidgetEditingLibrary(manager: sharedScriptManager) + let library = try ScriptWidgetEditingLibrary(manager: managerOverride ?? sharedScriptManager) let listener = try NWListener(using: .tcp, on: .any) listener.service = NWListener.Service(name: "ScriptWidget", type: "_scriptwidget._tcp") listener.stateUpdateHandler = { [weak self] state in diff --git a/iOS/ScriptWidget/ScriptWidget.entitlements b/iOS/ScriptWidget/ScriptWidget.entitlements index 34562fdd..0038c4fd 100644 --- a/iOS/ScriptWidget/ScriptWidget.entitlements +++ b/iOS/ScriptWidget/ScriptWidget.entitlements @@ -29,5 +29,7 @@ group.everettjf.scriptwidget + com.apple.developer.homekit + diff --git a/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/assets/index-BaJfekQk.js b/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/assets/index-BaJfekQk.js deleted file mode 100644 index 0f976695..00000000 --- a/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/assets/index-BaJfekQk.js +++ /dev/null @@ -1,59 +0,0 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();const Yd="modulepreload",Nd=function(n,e){return new URL(n,e).href},la={},Cs=function(e,t,i){let r=Promise.resolve();if(t&&t.length>0){let c=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),a=l?.nonce||l?.getAttribute("nonce");r=c(t.map(h=>{if(h=Nd(h,i),h in la)return;la[h]=!0;const u=h.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(i)for(let p=o.length-1;p>=0;p--){const m=o[p];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${f}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Yd,u||(d.as="script"),d.crossOrigin="",d.href=h,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((p,m)=>{d.addEventListener("load",p),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return r.then(o=>{for(const l of o||[])l.status==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2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=mh[i])e=i+1;else return!0;if(e==t)return!1}}function aa(n){return n>=127462&&n<=127487}const ca=8205;function Hd(n,e,t=!0,i=!0){return(t?Oh:_d)(n,e,i)}function Oh(n,e,t){if(e==n.length)return e;e&&gh(n.charCodeAt(e))&&yh(n.charCodeAt(e-1))&&e--;let i=Ts(n,e);for(e+=ha(i);e=0&&aa(Ts(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function _d(n,e,t){for(;e>1;){let i=Oh(n,e-2,t);if(i=56320&&n<57344}function yh(n){return n>=55296&&n<56320}function ha(n){return n<65536?1:2}class re{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Bi(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),kt.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Bi(this,e,t);let i=[];return this.decompose(e,t,i,0),kt.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new pn(this),s=new pn(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new pn(this,e)}iterRange(e,t=this.length){return new Ah(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new bh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?re.empty:e.length<=32?new ve(e):kt.from(ve.split(e,[]))}}class ve extends re{constructor(e,t=Jd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new ep(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new ve(ua(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Or(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new ve(l,o.length+s.length));else{let a=l.length>>1;i.push(new ve(l.slice(0,a)),new ve(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof ve))return super.replace(e,t,i);[e,t]=Bi(this,e,t);let r=Or(this.text,Or(i.text,ua(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new ve(r,s):kt.from(ve.split(r,[]),s)}sliceString(e,t=this.length,i=` -`){[e,t]=Bi(this,e,t);let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=i),es&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new ve(i,r)),i=[],r=-1);return r>-1&&t.push(new ve(i,r)),t}}class kt extends re{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s=o){let c=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!c?i.push(l):l.decompose(e-o,t-o,i,c)}o=a+1}}replace(e,t,i){if([e,t]=Bi(this,e,t),i.lines=s&&t<=l){let a=o.replace(e-s,t-s,i),c=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>c>>6){let h=this.children.slice();return h[r]=a,new kt(h,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` -`){[e,t]=Bi(this,e,t);let r="";for(let s=0,o=0;se&&s&&(r+=i),eo&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof kt))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],c=e.children[s];if(a!=c)return i+a.scanIdentical(c,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new ve(d,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,c=-1,h=[];function u(d){let p;if(d.lines>s&&d instanceof kt)for(let m of d.children)u(m);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof ve&&a&&(p=h[h.length-1])instanceof ve&&d.lines+p.lines<=32?(a+=d.lines,c+=d.length+1,h[h.length-1]=new ve(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&f(),a+=d.lines,c+=d.length+1,h.push(d))}function f(){a!=0&&(l.push(h.length==1?h[0]:kt.from(h,c)),c=-1,a=h.length=0)}for(let d of e)u(d);return f(),l.length==1?l[0]:new kt(l,t)}}re.empty=new ve([""],0);function Jd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Or(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s=t&&(a>i&&(l=l.slice(0,i-r)),r0?1:(e instanceof ve?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof ve?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(r instanceof ve){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ve?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Ah{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new pn(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class bh{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(re.prototype[Symbol.iterator]=function(){return this.iter()},pn.prototype[Symbol.iterator]=Ah.prototype[Symbol.iterator]=bh.prototype[Symbol.iterator]=function(){return this});class ep{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}}function Bi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Ze(n,e,t=!0,i=!0){return Hd(n,e,t,i)}function tp(n){return n>=56320&&n<57344}function ip(n){return n>=55296&&n<56320}function Ne(n,e){let t=n.charCodeAt(e);if(!ip(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return tp(i)?(t-55296<<10)+(i-56320)+65536:t}function fl(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Qt(n){return n<65536?1:2}const mo=/\r\n?|\n/;var De=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(De||(De={}));class Zt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-r);s+=l}else{if(i!=De.Simple&&c>=e&&(i==De.TrackDel&&re||i==De.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i=0&&r<=t&&l>=e)return rt?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Zt(e)}static create(e){return new Zt(e)}}class $e extends Zt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Oo(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return go(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length0&&Gt(i,t,s.text),s.forward(h),l+=h}let c=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(h=!1){if(!h&&!r.length)return;of||u<0||f>t)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?re.of(d.split(i||mo)):d:re.empty,m=p.length;if(u==f&&m==0)return;uo&&Le(r,u-o,-1),Le(r,f-u,m),Gt(s,r,p),o=f}}return c(e),a(!l),l}static empty(e){return new $e(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;rl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Gt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,c,s,h,u),r=c,s=h}}}function go(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Sn(n),l=new Sn(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let c=Math.min(o.len,l.len);Le(r,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let c=0,h=o.len;for(;h;)if(l.ins==-1){let u=Math.min(h,l.len);c+=u,h-=u,l.forward(u)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||i.length>c),s.forward2(a),o.forward(a)}}}}class Sn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?re.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?re.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Yt{constructor(e,t,i,r){this.from=e,this.to=t,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Yt(i,r,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return A.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return A.range(this.anchor,r,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return A.range(e.anchor,e.head)}static create(e,t,i,r){return new Yt(e,t,i,r)}}class A{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:A.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new A(e.ranges.map(t=>Yt.fromJSON(t)),e.main)}static single(e,t=e){return new A([A.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;rr.from-s.from),t=e.indexOf(i);for(let r=1;rs.head?A.range(a,l):A.range(l,a))}}return new A(e,t)}}function xh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let dl=0;class K{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=dl++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new K(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:pl),!!e.static,e.enables)}of(e){return new gr([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new gr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new gr(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function pl(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class gr{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=dl++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,c=!1,h=[];for(let u of this.dependencies)u=="doc"?a=!0:u=="selection"?c=!0:(((t=e[u.id])!==null&&t!==void 0?t:1)&1)==0&&h.push(e[u.id]);return{create(u){return u.values[o]=i(u),1},update(u,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||yo(u,h)){let d=i(u);if(l?!fa(d,u.values[o],r):!r(d,u.values[o]))return u.values[o]=d,1}return 0},reconfigure:(u,f)=>{let d,p=f.config.address[s];if(p!=null){let m=Cr(f,p);if(this.dependencies.every(O=>O instanceof K?f.facet(O)===u.facet(O):O instanceof Te?f.field(O,!1)==u.field(O,!1):!0)||(l?fa(d=i(u),m,r):r(d=i(u),m)))return u.values[o]=m,0}else d=i(u);return u.values[o]=d,1}}}get extension(){return this}}function fa(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let c=[];for(let h=0;hi===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(jn).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(jn),o=r.facet(jn),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,jn.of({field:this,create:e})]}get extension(){return this}}const fi={lowest:4,low:3,default:2,high:1,highest:0};function rn(n){return e=>new wh(e,n)}const si={highest:rn(fi.highest),high:rn(fi.high),default:rn(fi.default),low:rn(fi.low),lowest:rn(fi.lowest)};class wh{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Hi{of(e){return new Ao(this,e)}reconfigure(e){return Hi.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ao{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class Pr{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let f of rp(e,t,o))f instanceof Te?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of r)l[f.id]=c.length<<1,c.push(d=>f.slot(d));let h=i?.config.facets;for(let f in s){let d=s[f],p=d[0].facet,m=h&&h[f]||[];if(d.every(O=>O.type==0))if(l[p.id]=a.length<<1|1,pl(m,d))a.push(i.facet(p));else{let O=p.combine(d.map(y=>y.value));a.push(i&&p.compare(O,i.facet(p))?i.facet(p):O)}else{for(let O of d)O.type==0?(l[O.id]=a.length<<1|1,a.push(O.value)):(l[O.id]=c.length<<1,c.push(y=>O.dynamicSlot(y)));l[p.id]=c.length<<1,c.push(O=>np(O,p,d))}}let u=c.map(f=>f(l));return new Pr(e,o,u,l,a,s)}}function rp(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let c=i[a].indexOf(o);c>-1&&i[a].splice(c,1),o instanceof Ao&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let c of o)s(c,l);else if(o instanceof Ao){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),s(c,l)}else if(o instanceof wh)s(o.inner,o.prec);else if(o instanceof Te)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof gr)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,fi.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(c==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,l)}}return s(n,fi.default),i.reduce((o,l)=>o.concat(l))}function mn(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Cr(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const vh=K.define(),bo=K.define({combine:n=>n.some(e=>e),static:!0}),kh=K.define({combine:n=>n.length?n[0]:void 0,static:!0}),Qh=K.define(),Ph=K.define(),Ch=K.define(),Th=K.define({combine:n=>n.length?n[0]:!1});class zt{constructor(e,t){this.type=e,this.value=t}static define(){return new sp}}class sp{of(e){return new zt(this,e)}}class op{constructor(e){this.map=e}of(e){return new W(this,e)}}class W{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new W(this.type,t)}is(e){return this.type==e}static define(e={}){return new op(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}}W.reconfigure=W.define();W.appendConfig=W.define();class Pe{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&xh(i,t.newLength),s.some(l=>l.type==Pe.time)||(this.annotations=s.concat(Pe.time.of(Date.now())))}static create(e,t,i,r,s,o){return new Pe(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Pe.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Pe.time=zt.define();Pe.userEvent=zt.define();Pe.addToHistory=zt.define();Pe.remote=zt.define();function lp(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i=n[i]))s=n[i++],o=n[i++];else if(r=0;r--){let s=i[r](n);s instanceof Pe?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Pe?n=s[0]:n=Rh(e,Zi(s),!1)}return n}function cp(n){let e=n.startState,t=e.facet(Ch),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=$h(i,So(e,s,n.changes.newLength),!0))}return i==n?n:Pe.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const hp=[];function Zi(n){return n==null?hp:Array.isArray(n)?n:[n]}var ye=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(ye||(ye={}));const up=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let xo;try{xo=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function fp(n){if(xo)return xo.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||up.test(t)))return!0}return!1}function dp(n){return e=>{if(!/\S/.test(e))return ye.Space;if(fp(e))return ye.Word;for(let t=0;t-1)return ye.Word;return ye.Other}}class _{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;lr.set(c,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(W.reconfigure)?(t=null,i=l.value):l.is(W.appendConfig)&&(t=null,i=Zi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Pr.resolve(i,r,this),s=new _(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=e.startState.facet(bo)?e.newSelection:e.newSelection.asSingle();new _(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:A.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=Zi(i.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return _.create({doc:e.doc,selection:A.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Pr.resolve(e.extensions||[],new Map),i=e.doc instanceof re?e.doc:re.of((e.doc||"").split(t.staticFacet(_.lineSeparator)||mo)),r=e.selection?e.selection instanceof A?e.selection:A.single(e.selection.anchor,e.selection.head):A.single(0);return xh(r,i.length),t.staticFacet(bo)||(r=r.asSingle()),new _(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(_.tabSize)}get lineBreak(){return this.facet(_.lineSeparator)||` -`}get readOnly(){return this.facet(Th)}phrase(e,...t){for(let i of this.facet(_.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(vh))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return dp(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=Ze(t,o,!1);if(s(t.slice(a,o))!=ye.Word)break;o=a}for(;ln.length?n[0]:4});_.lineSeparator=kh;_.readOnly=Th;_.phrases=K.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});_.languageData=vh;_.changeFilter=Qh;_.transactionFilter=Ph;_.transactionExtender=Ch;Hi.reconfigure=W.define();function yt(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}class Jt{eq(e){return this==e}range(e,t=e){return wo.create(e,t,this)}}Jt.prototype.startSide=Jt.prototype.endSide=0;Jt.prototype.point=!1;Jt.prototype.mapMode=De.TrackDel;function ml(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let wo=class Kh{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Kh(e,t,i)}};function vo(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Ol{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,c=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return c>=0?o:l;c>=0?l=a:o=a+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);sd||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(o<0&&(o=f),c.point&&(l=Math.max(l,d-f)),i.push(c),r.push(f-o),s.push(d-o))}return{mapped:i.length?new Ol(r,s,i,l):null,pos:o}}}class N{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new N(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(vo)),this.isEmpty)return t.length?N.of(t):this;let l=new Zh(this,null,-1).goto(0),a=0,c=[],h=new Bt;for(;l.value||a=0){let u=t[a++];h.addInner(u.from,u.to,u.value)||c.push(u)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return xn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return xn.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),l=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),a=da(o,l,i),c=new sn(o,a,s),h=new sn(l,a,s);i.iterGaps((u,f,d)=>pa(c,u,h,f,d,r)),i.empty&&i.length==0&&pa(c,0,h,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=da(s,o),a=new sn(s,l,0).goto(i),c=new sn(o,l,0).goto(i);for(;;){if(a.to!=c.to||!ko(a.active,c.active)||a.point&&(!c.point||!ml(a.point,c.point)))return!1;if(a.to>r)return!0;a.next(),c.next()}}static spans(e,t,i,r,s=-1){let o=new sn(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let c=Math.min(o.to,i);if(o.point){let h=o.activeForPoint(o.to),u=o.pointFroml&&(r.span(l,c,o.active,a),a=o.openEnd(c));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Bt;for(let r of e instanceof wo?[e]:t?pp(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return N.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=N.empty;r=r.nextLayer)t=new N(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}N.empty=new N([],[],null,-1);function pp(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(vo);e=i}return n}N.empty.nextLayer=N.empty;class Bt{finishChunk(e){this.chunks.push(new Ol(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Bt)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(N.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=N.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function da(n,e,t){let i=new Map;for(let s of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&r.push(new Zh(o,t,i,s));return r.length==1?r[0]:new xn(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)$s(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)$s(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),$s(this.heap,0)}}}function $s(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}class sn{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=xn.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Vn(this.active,e),Vn(this.activeTo,e),Vn(this.activeRank,e),this.minActive=ma(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t0;)t++;Yn(this.active,t,i),Yn(this.activeTo,t,r),Yn(this.activeRank,t,s),e&&Yn(e,t,this.cursor.from),this.minActive=ma(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Vn(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[r]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function pa(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,a=i-e,c=!!s.boundChange;for(let h=!1;;){let u=n.to+a-t.to,f=u||n.endSide-t.endSide,d=f<0?n.to+a:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&ml(n.point,t.point)&&ko(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,p,n.point,t.point),h=!1):(h&&s.boundChange(l),p>l&&!ko(n.active,t.active)&&s.compareRange(l,p,n.active,t.active),c&&po)break;l=d,f<=0&&n.next(),f>=0&&t.next()}}function ko(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function ma(n,e){let t=-1,i=1e9;for(let r=0;r=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=Ze(n,r)}return i===!0?-1:n.length}const Po="ͼ",Oa=typeof Symbol>"u"?"__"+Po:Symbol.for(Po),Co=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ga=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ei{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,c){let h=[],u=/^@(\w+)\b/.exec(o[0]),f=u&&u[1]=="keyframes";if(u&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(m=>o.map(O=>m.replace(/&/,O))).reduce((m,O)=>m.concat(O)),p,a);else if(p&&typeof p=="object"){if(!u)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,h,f)}else p!=null&&h.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(h.length||f)&&a.push((i&&!u&&!c?o.map(i):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=ga[Oa]||1;return ga[Oa]=e+1,Po+e.toString(36)}static mount(e,t,i){let r=e[Co],s=i&&i.nonce;r?s&&r.setNonce(s):r=new mp(e,s),r.mount(Array.isArray(t)?t:[t],e)}}let ya=new Map;class mp{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=ya.get(i);if(s)return e[Co]=s;this.sheet=new r.CSSStyleSheet,ya.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Co]=this}mount(e,t){let i=this.sheet,r=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),i)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},Aa=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Op=typeof navigator<"u"&&/Apple Computer/.test(navigator.vendor),gp=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),ba=typeof navigator<"u"&&/Mac/.test(navigator.platform),yp=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ap=Aa&&(ba||+Aa[1]<57)||gp&&ba;for(var Fe=0;Fe<10;Fe++)ti[48+Fe]=ti[96+Fe]=String(Fe);for(var Fe=1;Fe<=24;Fe++)ti[Fe+111]="F"+Fe;for(var Fe=65;Fe<=90;Fe++)ti[Fe]=String.fromCharCode(Fe+32),wn[Fe]=String.fromCharCode(Fe);for(var Rs in ti)wn.hasOwnProperty(Rs)||(wn[Rs]=ti[Rs]);function bp(n){var e=Ap&&(n.ctrlKey||n.altKey||n.metaKey)||(Op||yp)&&n.shiftKey&&n.key&&n.key.length==1,t=!e&&n.key||(n.shiftKey?wn:ti)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function he(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e2);var $={mac:wa||/Mac/.test(ze.platform),windows:/Win/.test(ze.platform),linux:/Linux|X11/.test(ze.platform),ie:hs,ie_version:Eh?To.documentMode||6:Ro?+Ro[1]:$o?+$o[1]:0,gecko:Sa,gecko_version:Sa?+(/Firefox\/(\d+)/.exec(ze.userAgent)||[0,0])[1]:0,chrome:!!Ks,chrome_version:Ks?+Ks[1]:0,ios:wa,android:/Android\b/.test(ze.userAgent),webkit:xa,webkit_version:xa?+(/\bAppleWebKit\/(\d+)/.exec(ze.userAgent)||[0,0])[1]:0,safari:Ko,safari_version:Ko?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ze.userAgent)||[0,0])[1]:0,tabSize:To.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function gl(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const Tr=Object.create(null);function yl(n,e,t){if(n==e)return!0;n||(n=Tr),e||(e=Tr);let i=Object.keys(n),r=Object.keys(e);if(i.length-0!=r.length-0)return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function Sp(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function va(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function xp(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Ai(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Uh(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Ai(e,i,r,t,e.widget||null,!0)}static line(e){return new Fn(e)}static set(e,t=!1){return N.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}B.none=N.empty;class Un extends B{constructor(e){let{start:t,end:i}=Uh(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?gl(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Tr}eq(e){return this==e||e instanceof Un&&this.tagName==e.tagName&&yl(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Un.prototype.point=!1;class Fn extends B{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Fn&&this.spec.class==e.spec.class&&yl(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Fn.prototype.mapMode=De.TrackBefore;Fn.prototype.point=!0;class Ai extends B{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?De.TrackBefore:De.TrackAfter:De.TrackDel}get type(){return this.startSide!=this.endSide?Xe.WidgetRange:this.startSide<=0?Xe.WidgetBefore:Xe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ai&&wp(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Ai.prototype.point=!0;function Uh(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function wp(n,e){return n==e||!!(n&&e&&n.compare(e))}function Mi(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}class vn extends Jt{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof vn&&this.tagName==e.tagName&&yl(this.attributes,e.attributes)}static create(e){return new vn(e.tagName,e.attributes||Tr,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return N.of(e,t)}}vn.prototype.startSide=vn.prototype.endSide=-1;function kn(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Zo(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function On(n,e){if(!e.anchorNode)return!1;try{return Zo(n,e.anchorNode)}catch{return!1}}function yr(n){return n.nodeType==3?Qn(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function gn(n,e,t,i){return t?ka(n,e,t,i,-1)||ka(n,e,t,i,1):!1}function ii(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function $r(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function ka(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:qt(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=ii(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?qt(n):0}else return!1}}function qt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Rr(n,e){let{left:t,right:i}=n;if(t==i)return n;let r=e?t:i;return{left:r,right:r,top:n.top,bottom:n.bottom}}function vp(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Fh(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function kp(n,e,t,i,r,s,o,l){let a=n.ownerDocument,c=a.defaultView||window;for(let h=n,u=!1;h&&!u;)if(h.nodeType==1){let f,d=h==a.body,p=1,m=1;if(d)f=vp(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let b=h.getBoundingClientRect();({scaleX:p,scaleY:m}=Fh(h,b)),f={left:b.left,right:b.left+h.clientWidth*p,top:b.top,bottom:b.top+h.clientHeight*m}}let O=0,y=0;if(r=="nearest")e.top0&&e.bottom>f.bottom+y&&(y=e.bottom-f.bottom+o)):e.bottom>f.bottom-o&&(y=e.bottom-f.bottom+o,t<0&&e.top-y0&&e.right>f.right+O&&(O=e.right-f.right+s)):e.right>f.right-s&&(O=e.right-f.right+s,t<0&&e.leftf.bottom||e.leftf.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function Dh(n,e=!0){let t=n.ownerDocument,i=null,r=null;for(let s=n.parentNode;s&&!(s==t.body||(!e||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}class Qp{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?qt(t):0),i,Math.min(e.focusOffset,i?qt(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}}function Xh(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function Lh(n,e=!0){for(let{node:t,left:i,top:r}of n)e&&t.scrollTop!=r&&(t.scrollTop=r),t.scrollLeft!=i&&(t.scrollLeft=i)}let ui=null;$.safari&&$.safari_version>=26&&(ui=!1);function Bh(n){if(n.setActive)return n.setActive();if(ui)return n.focus(ui);let e=Xh(n);n.focus(ui==null?{get preventScroll(){return ui={preventScroll:!0},!0}}:void 0),ui||(ui=!1,Lh(e))}let Qa;function Qn(n,e,t=e){let i=Qa||(Qa=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Ei(n,e,t,i){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,n.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,n.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Pp(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Cp(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,qt(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=qt(t))}else{if(t==n)return!0;i=ii(t),t=t.parentNode}}function qh(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function Ih(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=qt(t)}else if(t.parentNode&&!$r(t))i=ii(t),t=t.parentNode;else return null}}function zh(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.fromt:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Vh(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(St[m+1]==-d){let O=St[m+2],y=O&2?r:O&4?O&1?s:r:0;y&&(ue[u]=ue[St[m]]=y),l=m;break}}else{if(St.length==189)break;St[l++]=u,St[l++]=f,St[l++]=a}else if((p=ue[u])==2||p==1){let m=p==r;a=m?0:1;for(let O=l-3;O>=0;O-=3){let y=St[O+2];if(y&2)break;if(m)St[O+2]|=2;else{if(y&4)break;St[O+2]|=4}}}}}function Mp(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=ra;)p==O&&(p=t[--m].from,O=m?t[m-1].to:n),ue[--p]=d;a=h}else s=c,a++}}}function Eo(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,c=0;aa&&o.push(new Ct(a,m.from,d));let O=m.direction==bi!=!(d%2);Uo(n,O?i+1:i,r,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(h?ue[p]!=l:ue[p]==l))break;p++}f?Eo(n,a,p,i+1,r,f,o):ae;){let h=!0,u=!1;if(!c||a>s[c-1].to){let m=ue[a-1];m!=l&&(h=!1,u=m==16)}let f=!h&&l==1?[]:null,d=h?i:i+1,p=a;e:for(;;)if(c&&p==s[c-1].to){if(u)break e;let m=s[--c];if(!h)for(let O=m.from,y=c;;){if(O==e)break e;if(y&&s[y-1].to==O)O=s[--y].from;else{if(ue[O-1]==l)break e;break}}if(f)f.push(m);else{m.toue.length;)ue[ue.length]=256;let i=[],r=e==bi?0:1;return Uo(n,r,r,t,0,n.length,i),i}function Yh(n){return[new Ct(0,n,0)]}let Nh="";function Up(n,e,t,i,r){var s;let o=i.head-n.from,l=Ct.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],c=a.side(r,t);if(o==c){let f=l+=r?1:-1;if(f<0||f>=e.length)return null;a=e[l=f],o=a.side(!r,t),c=a.side(r,t)}let h=Ze(n.text,o,a.forward(r,t));(ha.to)&&(h=c),Nh=n.text.slice(Math.min(o,h),Math.max(o,h));let u=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return u&&h==c&&u.level+(r?0:1)n.some(e=>e)}),nu=K.define({combine:n=>n.some(e=>e)}),ru=K.define();class Ui{constructor(e,t,i,r,s,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Ui(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ui(A.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Nn=W.define({map:(n,e)=>n.map(e)}),su=W.define();function We(n,e,t){let i=n.facet(Jh);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Dt=K.define({combine:n=>n.length?n[0]:!0});let Dp=0;const Ti=K.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let a=[];return o&&a.push(us.of(c=>{let h=c.plugin(l);return h?o(h):B.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return xe.define((i,r)=>new e(i,r),t)}}class Zs{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(We(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){We(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){We(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ou=K.define(),xl=K.define(),us=K.define(),lu=K.define(),wl=K.define(),Dn=K.define(),au=K.define();function Pa(n,e){let t=n.state.facet(au);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return N.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let c=s-e.from,h=o-e.from,u=r;for(let f=l.length-1;f>=0;f--,a--){let d=l[f].spec.bidiIsolate,p;if(d==null&&(d=Fp(e.text,c,h)),a>0&&u.length&&(p=u[u.length-1]).to==c&&p.direction==d)p.to=h,u=p.inner;else{let m={from:c,to:h,direction:d,inner:[]};u.push(m),u=m.inner}}}}),r}const cu=K.define();function vl(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(cu)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}const hn=K.define();class ct{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new ct(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toAr.push(new ct(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new Kr(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Xp=[];class Se{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Xp}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Sp(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=ii(this.dom),r=this.length?e>0:t>0;return new pt(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof ds)return e;return null}static get(e){return e.cmTile}}class fs extends Se{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,r,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:t.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;r&&r!=l.dom;)r=Ca(r);else t.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=Ca(r);this.length=o}}function Ca(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ds extends fs{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Se.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&s++,r=t.pop()}else{let o=i.children[r++];if(o instanceof Xt)t.push(r),i=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,t){let i,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let c=a+l.length;if(e>=a&&e<=c){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(ae||e==a&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&t<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}}class Xt extends fs{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new Xt(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class qi extends fs{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let r=new qi(t||document.createElement("div"),e);return(!t||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,i){let r=null,s=-1,o=null,l=-1;function a(h,u){for(let f=0,d=0;f=u&&(p.isComposite()?a(p,u-d):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&Bp(o,p)))&&(m>u||p.flags&32&&t<=1)?(o=p,l=u-d):(d=-1)&&(r=p,s=u-d)),d=m}}a(this,e);let c=(t<0?r:o)||r||o;return c?{tile:c,offset:c==r?s:l}:null}coordsIn(e,t,i){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,i):Lp(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new pt(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new pt(a.dom,0);a==i.tile&&(l=!0)}}return new pt(this.dom,0)}}function Lp(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=yr(e);return t[t.length-1]||null}function Bp(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.topr&&(e=r);let s=e,o=e,l=0;e==0&&t<0||e==r&&t>=0?$.chrome||$.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return $.safari&&!l&&c.width==0&&(c=Array.prototype.find.call(a,h=>h.width)||c),i==null?c:Rr(c,(l?l>0:t<0)==i)}static of(e,t){let i=new pi(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Si extends Se{constructor(e,t,i,r){super(e,t,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(i)return Rr(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==i)}}class qp{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],c=a.breakAfter;(t>0?a.length<=e:a.length=0;l--){let a=t.marks[l],c=r.lastChild;if(c instanceof He&&c.mark.eq(a.mark))c.dom!=a.dom&&c.setDOM(Ms(a.dom)),r=c;else{if(this.cache.reused.get(a)){let u=Se.get(a.dom);u&&u.setDOM(Ms(a.dom))}let h=He.of(a.mark,a.dom);r.append(h),r=h}this.cache.reused.set(a,2)}let s=Se.get(e.text);s&&this.cache.reused.set(s,2);let o=new pi(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=hu);let r=qi.start(e,t||((i=this.cache.find(qi))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=r.lastChild)&&l instanceof He&&l.mark.eq(o))r=l,t--;else{let a=He.of(o,(i=this.cache.find(He,c=>c.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Ta(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!($.ios&&Ta(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Es,0,32)||new Si(Es.toDOM(),0,Es,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=e.rank*102+e.value.rank,i=new Ip(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.fromo.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Zr,void 0,1);return i&&(i.flags=t),i||new Zr(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Wp{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const Mr=[Si,qi,pi,He,Zr,Xt,ds];for(let n=0;n[]),this.index=Mr.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,s=0,o=0;;){let l=or){let c=a-r;this.preserve(c,!o,!l),r=a,s+=c}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let c=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof He&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof He&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,s=-1,o=N.spans(this.decorations,e,t,{point:(l,a,c,h,u,f)=>{if(c instanceof Ai){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=h.length,u>h.length)r.continueWidget(a-l);else{let d=c.widget||(c.block?Ii.block:Ii.inline),p=Yp(c),m=this.cache.findWidget(d,a-l,p)||Si.of(d,this.view,a-l,p);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(m)):(r.ensureLine(i),r.addInlineWidget(m,h,u))}i=null}else i=Np(i,c);a>l&&this.text.skip(a-l)},span:(l,a,c,h)=>{for(let u=l;u-1&&(this.openWidget=o>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=Se.get(r);if(r==this.view.contentDOM)break;s instanceof He?t.push(s):s?.isLine()?i=s:s instanceof Xt||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new qi(r,hu):i||t.push(He.of(new Un({tagName:r.nodeName.toLowerCase(),attributes:xp(r)}),r)))}return{line:i,marks:t}}}function Ta(n,e){let t=i=>{for(let r of i.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(n)}function Yp(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const hu={class:"cm-line"};function Np(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&gl(t,n),i&&(n.class+=" "+i)),n}function Gp(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof He&&e.push(i.mark)}return e}function Ms(n){let e=Se.get(n);return e&&e.setDOM(n.cloneNode()),n}class Ii extends Ut{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ii.inline=new Ii("span");Ii.block=new Ii("div");const Es=new class extends Ut{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class $a{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=B.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new ds(e,e.contentDOM),this.updateInner([new ct(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!sm(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?_p(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:u}=this.hasComposition;i=new ct(h,u,e.changes.mapPos(h,-1),e.changes.mapPos(u,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,($.ie||$.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=tm(o,this.decorations,e.changes);a.length&&(i=ct.extendWithRanges(i,a));let c=nm(l,this.blockWrappers,e.changes);return c.length&&(i=ct.extendWithRanges(i,c)),s&&!i.some(h=>h.fromA<=s.range.fromA&&h.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new Vp(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Se.get(t.text)&&l.cache.reused.set(Se.get(t.text),2),this.tile=l.run(e,t),Do(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=$.chrome||$.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&On(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,c,h;if(a.empty?h=c=this.inlineDOMNearPos(a.anchor,a.assoc||1):(h=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),c=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),$.gecko&&a.empty&&!this.hasComposition&&Hp(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=h=new pt(f,0),l=!0}let u=this.view.observer.selectionRange;(l||!u.focusNode||(!gn(c.node,c.offset,u.anchorNode,u.anchorOffset)||!gn(h.node,h.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{$.android&&$.chrome&&i.contains(u.focusNode)&&rm(u.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let f=kn(this.view.root);if(f)if(a.empty){if($.gecko){let d=Jp(c.node,c.offset);if(d&&d!=3){let p=(d==1?Ih:zh)(c.node,c.offset);p&&(c=new pt(p.node,p.offset))}}f.collapse(c.node,c.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(h.node,h.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([c,h]=[h,c]),d.setEnd(h.node,h.offset),d.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new pt(u.anchorNode,u.anchorOffset),this.impreciseHead=h.precise?null:new pt(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&gn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=kn(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!a||!c||a.bottom>c.top)return;let h=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(h.node,h.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&i.collapse(r,s)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[t];else{let o=qt(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!Se.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let a=i.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?r+t:r+(t?i.length:0):r}domAtPos(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(r,t):i.domIn(r,t)}inlineDOMNearPos(e,t){let i,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((c,h)=>{if(c.isWidget()){if(c.flags&32&&h>=e)return!0;c.flags&16&&(s=!0)}else{let u=h+c.length;if(h<=e&&(i=c,r=e-h,s=u=e&&!o&&(o=c,l=e-h,a=h>e),h>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(s&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(r,t):o.domIn(l,t))}coordsAt(e,t,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Us?null:r.coordsInWidget(s,t,!0):r.coordsIn(s,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==fe.LTR,c=0,h=(u,f,d)=>{for(let p=0;pr);p++){let m=u.children[p],O=f+m.length,y=m.dom.getBoundingClientRect(),{height:b}=y;if(d&&!p&&(c+=y.top-d.top),m instanceof Xt)O>i&&h(m,f,y);else if(f>=i&&(c>0&&t.push(-c),t.push(b+c),c=0,o)){let x=m.dom.lastChild,C=x?yr(x):[];if(C.length){let k=C[C.length-1],S=a?k.right-y.left:y.right-k.left;S>l&&(l=S,this.minWidth=s,this.minWidthFrom=f,this.minWidthTo=O)}}d&&p==u.children.length-1&&(c+=d.bottom-y.bottom),f=O+m.breakAfter}};return h(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?fe.RTL:fe.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let h=yr(c.dom);if(h.length!=1)return;l+=h[0].width,a=h[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=yr(t.firstChild)[0];i=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(B.replace({widget:new Us(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return B.set(e)}updateDeco(){let e=1,t=this.view.state.facet(us).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(wl).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(N.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(ru))try{if(c(this.view,e.range,e))return!0}catch(h){We(this.view.state,h,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=vl(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(kp(this.view.scrollDOM,o,t.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Do(this.tile)}}function Do(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Do(i,e)}}function Hp(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function uu(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=Ih(t.focusNode,t.focusOffset),r=zh(t.focusNode,t.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=Se.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(n.docView.lastCompositionAfterCursor){let a=Se.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(s=r)}}if(n.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function _p(n,e,t){let i=uu(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new ct(a.mapPos(s),a.mapPos(o),s,o),text:r}}function Jp(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}class Us extends Ut{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function om(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return A.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=Ze(r.text,s,!1):l=Ze(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let c=Ze(r.text,o,!1);if(i(r.text.slice(c,o))!=a)break;o=c}for(;ln.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Qo(o,s,n.state.tabSize)}function Xo(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.toe)return s;(!r||s.type==Xe.Text&&(r.type!=s.type||(t<0?s.frome)))&&(r=s)}}return r||i}return i}function am(n,e,t,i){let r=Xo(n,e.head,e.assoc||-1),s=!i||r.type!=Xe.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),a=n.posAtCoords({x:t==(l==fe.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return A.cursor(a,t?-1:1)}return A.cursor(t?r.to:r.from,t?-1:1)}function Ra(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let c=Up(r,s,o,l,t),h=Nh;if(!c){if(r.number==(t?n.state.doc.lines:1))return l;h=` -`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),c=n.visualLineSide(r,!t)}if(a){if(!a(h))return l}else{if(!i)return c;a=i(h)}l=c}}function cm(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==ye.Space&&(r=o),r==o}}function hm(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return A.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(r,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),h=n.documentTop;if(c)o==null&&(o=c.left-a.left),l=s<0?c.top:c.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+h}let u=a.left+o,f=n.viewState.heightOracle.textHeight>>1,d=i??f;for(let p=0;;p+=f){let m=l+(d+p)*s,O=Lo(n,{x:u,y:m},!1,s);if(t?m>a.bottom:ml:b{if(e>s&&er(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:A.cursor(i,in.viewState.docHeight)return new Pt(n.state.doc.length,-1);if(c=n.elementAtHeight(a),i==null)break;if(c.type==Xe.Text){if(i<0?c.ton.viewport.to)break;let f=n.docView.coordsAt(i<0?c.from:c.to,i>0?-1:1);if(f&&(i<0?f.top<=a+s:f.bottom>=a+s))break}let u=n.viewState.heightOracle.textHeight/2;a=i>0?c.bottom+u:c.top-u}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==Xe.Text){let u=lm(n,r,c,o,l);return new Pt(u,u==c.from?1:-1)}}if(c.type!=Xe.Text)return a<(c.top+c.bottom)/2?new Pt(c.from,1):new Pt(c.to,-1);let h=n.docView.lineAt(c.from,2);return(!h||h.length!=c.length)&&(h=n.docView.lineAt(c.from,-2)),new um(n,o,l,n.textDirectionAt(c.from)).scanTile(h,c.from)}class um{constructor(e,t,i,r){this.view=e,this.x=t,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from>1;t:if(o.has(m)){for(let b=1;b=s&&(x-=p),!o.has(x)){m=x;break t}}break e}o.add(m);let O=t(m),y=0;if(O)for(let b=0;b1))if(x.bottomthis.y)(!c||c.top>x.top)&&(c=x),y=-1;else{let C=x.left>this.x?this.x-x.left:x.right(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(c&&c.top<(p+m+m)/3)return this.y=c.top+1,this.scan(e,t,!0)}let d=(l?this.dirAt(e[h],1):this.baseDir)==fe.LTR;return{i:h,after:this.x>(f.left+f.right)/2==d}}scanText(e,t){let i=[];for(let s=0;s{let o=i[s]-t,l=i[s+1]-t;return Qn(e.dom,o,l).getClientRects()});return r.after?new Pt(i[r.i+1],-1):new Pt(i[r.i],1)}scanTile(e,t){if(!e.length)return new Pt(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Qn(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Pt(i[r.i+1],-1):new Pt(o,1)}}const ki="￿";class fm{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(_.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ki}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=Se.get(r),l=r.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=Se.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:$r(r))||$r(l)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!pm(l,t)&&this.lineBreak(),r=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){let t=Se.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(dm(e,i.node,i.offset)?t:0))}}function dm(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=du(e.docView.tile,t,i,0))){let a=s||o?[]:gm(e),c=new fm(a,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=ym(a,this.bounds.from)}else{let a=e.observer.selectionRange,c=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!Zo(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),h=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Zo(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if(($.ios||$.chrome)&&c!=h&&Math.min(c,h)<=l.main.from&&Math.max(c,h)>=l.main.to&&(u.from>0||u.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(A.range(h,c));else if(e.lineWrapping&&h==c&&!(l.main.empty&&l.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(c,-1),d=0;f&&(d=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=A.create([A.cursor(c,d)])}else this.newSel=A.single(h,c)}}}function du(n,e,t,i){if(n.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,c=i,h=i;at)return du(u,e,t,c);if(f>=e&&r==-1&&(r=a,s=c),c>t&&u.dom.parentNode==n.dom){o=a,l=h;break}h=f,c=f+u.breakAfter}return{from:s,to:l<0?i+n.length:l,startDOM:(r?n.children[r-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function pu(n,e){let t,{newSel:i}=e,{state:r}=n,s=r.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,c=s.from,h=null;(o===8||$.android&&e.text.length=l&&s.to<=a&&(e.typeOver||u!=e.text)&&u.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&u.slice(s.to-l)==e.text.slice(f=e.text.length-(u.length-(s.to-l)))?t={from:s.from,to:s.to,insert:re.of(e.text.slice(s.from-l,f).split(ki))}:(d=mu(u,e.text,c-l,h))&&($.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==ki+ki&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:re.of(e.text.slice(d.from,d.toB).split(ki))})}else i&&(!n.hasFocus&&r.facet(Dt)||Er(i,s))&&(i=null);if(!t&&!i)return!1;if(($.mac||$.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=A.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:re.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).toDate.now()-50?t={from:s.from,to:s.to,insert:r.toText(n.inputState.insertingText)}:$.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==` - `&&n.lineWrapping&&(i&&(i=A.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:re.of([" "])}),t)return kl(n,t,i,o);if(i&&!Er(i,s)){let l=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(l=!0),a=n.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=fu(r.facet(Dn).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function kl(n,e,t,i=-1){if($.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if($.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&n.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ei(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.lengthr.head)&&Ei(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Ei(n.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=Om(n,e,t));return n.state.facet(eu).some(a=>a(n,e.from,e.to,s,l))||n.dispatch(l()),!0}function Om(n,e,t){let i,r=n.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromu(n)),c,a);e.from==h&&(o=h)}if(o>-1)i={changes:e,selection:A.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=s.frome.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let a=r.changes(e),c=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let h=n.state.sliceDoc(e.from,e.to),u,f=t&&uu(n,t.main.head);if(f){let p=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-p}}else u=n.state.doc.lineAt(s.head);let d=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:c||p.map(a)};let m=p.to-d,O=m-h.length;if(n.state.sliceDoc(O,m)!=h||m>=u.from&&O<=u.to)return{range:p};let y=r.changes({from:O,to:m,insert:e.insert}),b=p.to-s.to;return{changes:y,range:c?A.range(Math.max(0,c.anchor+b),Math.max(0,c.head+b)):p.map(y)}})}else i={changes:a,selection:c&&r.selection.replaceRange(c)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function mu(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function gm(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Ka(t,i)),(r!=t||s!=i)&&e.push(new Ka(r,s))),e}function ym(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?A.single(t+e,i+e):null}function Er(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class Am{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,$.safari&&e.contentDOM.addEventListener("input",()=>null),$.gecko&&Em(e.contentDOM.ownerDocument)}handleEvent(e){!Cm(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Sm(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&gu.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),$.android&&$.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if($.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Ou.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||xm.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&$.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&bm(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:$.safari&&!$.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function bm(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function Za(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){We(t.state,r)}}}function Sm(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&t(l).handlers.push(Za(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(Za(i.value,a))}}for(let i in gt)t(i).handlers.push(gt[i]);for(let i in Ve)t(i).observers.push(Ve[i]);return e}const Ou=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],xm="dthko",gu=[16,17,18,20,91,92,224,225],Gn=6;function Hn(n){return Math.max(0,n)*.7+8}function wm(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class vm{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Dh(e.contentDOM),this.atoms=e.state.facet(Dn).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(_.allowMultipleSelections)&&km(e,t),this.dragging=Pm(e,t)&&bu(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&wm(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=vl(this.view);e.clientX-a.left<=r+Gn?t=-Hn(r-e.clientX):e.clientX+a.right>=o-Gn&&(t=Hn(e.clientX-o)),e.clientY-a.top<=s+Gn?i=-Hn(s-e.clientY):e.clientY+a.bottom>=l-Gn&&(i=Hn(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=fu(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function km(n,e){let t=n.state.facet(Gh);return t.length?t[0](e):$.mac?e.metaKey:e.ctrlKey}function Qm(n,e){let t=n.state.facet(Hh);return t.length?t[0](e):$.mac?!e.altKey:!e.ctrlKey}function Pm(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=kn(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Cm(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Se.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const gt=Object.create(null),Ve=Object.create(null),yu=$.ie&&$.ie_version<15||$.ios&&$.webkit_version<604;function Tm(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),Au(n,t.value)},50)}function ps(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function Au(n,e){e=ps(n.state,bl,e);let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Bo!=null&&t.selection.ranges.every(a=>a.empty)&&Bo==s.toString()){let a=-1;i=t.changeByRange(c=>{let h=t.doc.lineAt(c.from);if(h.from==a)return{range:c};a=h.from;let u=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:u},range:A.cursor(c.from+u.length)}})}else o?i=t.changeByRange(a=>{let c=s.line(r++);return{changes:{from:a.from,to:a.to,insert:c.text},range:A.cursor(a.from+c.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Ve.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,$.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};Ve.wheel=Ve.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};gt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);Ve.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};Ve.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Ve.touchend=(n,e)=>{n.inputState.touchActive=!1};gt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(_h))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Rm(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new vm(n,e,t,i)),i&&n.observer.ignore(()=>{Bh(n.contentDOM);let s=n.root.activeElement;s&&!s.contains(n.contentDOM)&&s.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function Ma(n,e,t,i){if(i==1)return A.cursor(e,t);if(i==2)return om(n.state,e,t);{let r=n.docView.lineAt(e,t),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(Ua+1)%3:1}function Rm(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=bu(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,h=Ma(n,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let u=Ma(n,t.pos,t.assoc,i),f=Math.min(u.from,h.from),d=Math.max(u.to,h.to);h=f1&&(c=Km(r,a.pos))?c:l?r.addRange(h):A.create([h])}}}function Km(n,e){for(let t=0;t=e)return A.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}gt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=A.undirectionalRange(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",ps(n.state,Sl,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};gt.dragend=n=>(n.inputState.draggedContent=null,!1);function Da(n,e,t,i){if(t=ps(n.state,bl,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&Qm(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}gt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&Da(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Da(n,e,i,!0),!0}return!1};gt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=yu?null:e.clipboardData;return t?(Au(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Tm(n),!1)};function Zm(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Mm(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:ps(n,Sl,e.join(n.lineBreak)),ranges:t,linewise:i}}let Bo=null;gt.copy=gt.cut=(n,e)=>{if(!On(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=Mm(n.state);if(!t&&!r)return!1;Bo=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=yu?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Zm(n,t),!1)};const Su=zt.define();function xu(n,e){let t=[];for(let i of n.facet(tu)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:Su.of(!0)}):null}function wu(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=xu(n.state,e);t?n.dispatch(t):n.update([])}},10)}Ve.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),wu(n)};Ve.blur=n=>{n.observer.clearSelectionRange(),wu(n)};Ve.compositionstart=Ve.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};Ve.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,$.chrome&&$.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};Ve.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};gt.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=n.posAtDOM(l.startContainer,l.startOffset),c=n.posAtDOM(l.endContainer,l.endOffset);return kl(n,{from:a,to:c,insert:n.state.toText(s)},null),!0}}let r;if($.chrome&&$.android&&(r=Ou.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return $.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),$.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>Ve.compositionend(n,e),20),!1};const Xa=new Set;function Em(n){Xa.has(n)||(Xa.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const La=["pre-wrap","normal","pre-line","break-spaces"];let zi=!1;function Ba(){zi=!1}class Um{constructor(e){this.lineWrapping=e,this.doc=re.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return La.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Ar&&(zi=!0),this.height=e)}replace(e,t,i){return je.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:h,toB:u}=r[l],f=s.lineAt(a,pe.ByPosNoHeight,i.setDoc(t),0,0),d=f.to>=c?f:s.lineAt(c,pe.ByPosNoHeight,i,0,0);for(u+=d.to-c,c=d.to;l>0&&f.from<=r[l-1].toA;)a=r[l-1].fromA,h=r[l-1].fromB,l--,as*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r=s&&o(this.lineAt(0,pe.ByPos,i,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ot extends vu{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new dt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof ot||r instanceof Ee&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Ee?r=new ot(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):je.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ee extends je{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e0){let s=i[i.length-1];s instanceof Ee?i[i.length-1]=new Ee(s.length+r):i.push(null,new Ee(r-1))}if(e>0){let s=i[0];s instanceof Ee?i[0]=new Ee(e+s.length):i.unshift(new Ee(e-1),null)}return je.of(i)}decomposeLeft(e,t){t.push(new Ee(e-1),null)}decomposeRight(e,t){t.push(null,new Ee(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new Ee(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let h=e.doc.lineAt(l).length;o.length&&o.push(null);let u=r.heights[r.index++],f=0;u<0&&(f=-u,u=r.heights[r.index++]),a==-1?a=u:Math.abs(u-a)>=Ar&&(a=-2);let d=new ot(h,u,f);d.outdated=!1,o.push(d),l+=h+1}l<=s&&o.push(null,new Ee(s-l).updateHeight(e,l));let c=je.of(o);return(a<0||Math.abs(c.height-this.height)>=Ar||Math.abs(a-this.heightMetrics(e,t).perLine)>=Ar)&&(zi=!0),Ur(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Xm extends je{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return el))return c;let h=t==pe.ByPosNoHeight?pe.ByPosNoHeight:pe.ByPos;return a?c.join(this.right.lineAt(l,h,i,o,l)):this.left.lineAt(l,h,i,r,s).join(c)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,l,a,o);else{let c=this.lineAt(a,pe.ByPos,i,r,s);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,l,a,o)}}replace(e,t,i){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&qa(s,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?je.of(this.break?[e,null,t]:[e,t]):(this.left=Ur(this.left,e),this.right=Ur(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function qa(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Ee&&(i=n[e+1])instanceof Ee&&n.splice(e-1,3,new Ee(t.length+1+i.length))}const Lm=5;class Ql{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof ot?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ot(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=Lm)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new ot(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new Ee(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ot)return e;let t=new ot(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ot)&&!this.isCovered?this.nodes.push(new ot(0,-1,0)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&u.overflow!="visible"){let f=h.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(c==n.parentNode?r.innerHeight:a,f.bottom)}c=u.position=="absolute"||u.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function zm(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function Wm(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Ds{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Um(i),this.stateDeco=Wa(t),this.heightMap=je.empty().applyChanges(this.stateDeco,re.empty,this.heightOracle.setDoc(t.doc),[new ct(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=B.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new _n(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?za:new Pl(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(un(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Wa(this.state);let r=e.changedRanges,s=ct.extendWithRanges(r,Bm(i,this.stateDeco,e?e.changes:$e.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ba(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||zi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let c=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(nu)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?fe.RTL:fe.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,h=0;if(l.width&&l.height){let{scaleX:k,scaleY:S}=Fh(t,l);(k>.005&&Math.abs(this.scaleX-k)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=k,this.scaleY=S,c|=16,o=a=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let d=Dh(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=qh(this.scrollParent||e.win);let m=(this.printing?Wm:Im)(t,this.paddingTop),O=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView&&!this.scrollTarget&&!zm(e.dom))return 0;let x=l.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),a){let k=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(k)&&(o=!0),o||r.lineWrapping&&Math.abs(x-this.contentDOMWidth)>r.charWidth){let{lineHeight:S,charWidth:v,textHeight:U}=e.docView.measureTextSize();o=S>0&&r.refresh(s,S,v,U,Math.max(5,x/v),k),o&&(e.docView.minWidth=0,c|=16)}O>0&&y>0?h=Math.max(O,y):O<0&&y<0&&(h=Math.min(O,y)),Ba();for(let S of this.viewports){let v=S.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?je.empty().applyChanges(this.stateDeco,re.empty,this.heightOracle,[new ct(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Fm(S.from,v))}zi&&(c|=2)}let C=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return C&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||C)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new _n(r.lineAt(o-i*1e3,pe.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,pe.ByHeight,s,0,0).to);if(t){let{head:c}=t.range;if(ca.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(c,pe.ByPos,s,0,0),f;t.y=="center"?f=(u.top+u.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&c=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=fe.LTR&&!i)return[];let l=[],a=(h,u,f,d)=>{if(u-hh&&yy.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)y.fromb));if(!O){if(ux.from<=u&&x.to>=u)){let x=t.moveToLineBoundary(A.cursor(u),!1,!0).head;x>h&&(u=x)}let y=this.gapSize(f,h,u,d),b=i||y<2e6?y:2e6;O=new Ds(h,u,y,b)}l.push(O)},c=h=>{if(h.length2e6)for(let S of e)S.from>=h.from&&S.fromh.from&&a(h.from,d,h,u),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];N.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||un(this.heightMap.lineAt(e,pe.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||un(this.heightMap.lineAt(this.scaler.fromDOM(e),pe.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return un(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class _n{constructor(e,t){this.from=e,this.to=t}}function Vm(n,e,t){let i=[],r=n,s=0;return N.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function er(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Ym(n,e){for(let t of n)if(e(t))return t}const za={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Wa(n){let e=n.facet(us).filter(i=>typeof i!="function"),t=n.facet(wl).filter(i=>typeof i!="function");return t.length&&e.push(N.join(t)),e}class Pl{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let c=t.lineAt(l,pe.ByPos,e,0,0).top,h=t.lineAt(a,pe.ByPos,e,0,0).bottom;return r+=h-c,{from:l,to:a,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function un(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new dt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>un(r,e)):n._content)}const tr=K.define({combine:n=>n.join(" ")}),qo=K.define({combine:n=>n.indexOf(!0)>-1}),Io=ei.newName(),ku=ei.newName(),Qu=ei.newName(),Pu={"&light":"."+ku,"&dark":"."+Qu};function zo(n,e,t){return new ei(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}const Nm=zo("."+Io,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Pu),Gm={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Xs=$.ie&&$.ie_version<=11;class Hm{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Qp,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);($.ie&&$.ie_version<=11||$.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&$.android&&e.constructor.EDIT_CONTEXT!==!1&&!($.chrome&&$.chrome_version<126)&&(this.editContext=new Jm(e),e.state.facet(Dt)&&(e.contentDOM.editContext=this.editContext.editContext)),Xs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Dt)?i.root.activeElement!=this.dom:!On(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}($.ie&&$.ie_version<=11||$.android&&$.chrome)&&!i.state.selection.main.empty&&r.focusNode&&gn(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=kn(e.root);if(!t)return!1;let i=$.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&_m(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=On(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ei(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&On(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new mm(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=pu(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Er(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=ja(t,e.previousSibling||e.target.previousSibling,-1),r=ja(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Dt)!=e.state.facet(Dt)&&(e.view.contentDOM.editContext=e.state.facet(Dt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function ja(n,e,t){for(;e;){let i=Se.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Va(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return gn(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function _m(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Va(n,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Va(n,t):null}class Jm{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let c=a-l>i.text.length;l==this.from&&sthis.to&&(a=s);let h=mu(e.state.sliceDoc(l,a),i.text,(c?r.from:r.to)-l,c?"end":null);if(!h){let f=A.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Er(f,r)||e.dispatch({selection:f,userEvent:"select"});return}let u={from:h.from+l,to:h.toA+l,insert:re.of(i.text.slice(h.from,h.toB).split(` -`))};if(($.mac||$.android)&&u.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:l,to:a,insert:re.of([i.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let f=this.to-this.from+(u.to-u.from+u.insert.length);kl(e,u,A.single(this.toEditorPos(i.selectionStart,f),this.toEditorPos(i.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=kn(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,c)=>{if(i)return;let h=c.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=h,this.to+=h;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=h,this.to+=h;else if(sthis.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=h}t+=h}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class R{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Pp(e.parent)||document,this.viewState=new Ia(this,e.state||_.create(e)),e.scrollTo&&e.scrollTo.is(Nn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ti).map(r=>new Zs(r));for(let r of this.plugins)r.update(this);this.observer=new Hm(this),this.inputState=new Am(this),this.inputState.ensureHandlers(this.plugins),this.docView=new $a(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Pe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let f of e){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(Su))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=xu(s,o),a||(l=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(_.phrases)!=this.state.facet(_.phrases))return this.setState(s);r=Kr.create(this,s,e),r.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:p,y:m}=this.state.facet(R.cursorScrollMargin);u=new Ui(d.empty?d:A.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of f.effects)d.is(Nn)&&(u=d.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Fr.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(hn)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(tr)!=r.state.facet(tr)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Fo))try{f(r)}catch(d){We(this.state,d,"update listener")}(a||h)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!pu(this,h)&&c.force&&Ei(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Ia(this,e),this.plugins=e.facet(Ti).map(i=>new Zs(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new $a(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ti),i=e.state.facet(Ti);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new Zs(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(qh(i||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(d=>{try{return d.read(this)}catch(p){return We(this.state,p),Ya}}),u=Kr.create(this,this.state,[]),f=!1;u.flags|=a,t?t.flags|=a:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u),f&&this.docViewUpdate());for(let d=0;d1||p<-1)&&!($.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Fo))l(t)}get themeClasses(){return Io+" "+(this.state.facet(qo)?Qu:ku)+" "+this.state.facet(tr)}updateAttrs(){let e=Na(this,ou,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Dt)?"true":"false",class:"cm-content",style:`${$.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Na(this,xl,t);let i=this.observer.ignore(()=>{let r=va(this.contentDOM,this.contentAttrs,t),s=va(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(R.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(hn);let e=this.state.facet(R.cspNonce);ei.mount(this.root,this.styleModules.concat(Nm).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Fs(this,e,Ra(this,e,t,i))}moveByGroup(e,t){return Fs(this,e,Ra(this,e,t,i=>cm(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return A.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return am(this,e,t,i)}moveVertically(e,t,i){return Fs(this,e,hm(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Lo(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Lo(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),r=this.bidiSpans(i),s=r[Ct.find(r,e-i.from,-1,t)];return this.docView.coordsAt(e,t,s.dir==fe.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(iu)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>eO)return Yh(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Vh(s.isolates,i=Pa(this,e))))return s.order;i||(i=Pa(this,e));let r=Ep(e.text,t,i);return this.bidiCache.push(new Fr(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||$.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Bh(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,r,s,o;return Nn.of(new Ui(typeof e=="number"?A.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Nn.of(new Ui(A.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return xe.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return xe.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ei.newName(),r=[tr.of(i),hn.of(zo(`.${i}`,e))];return t&&t.dark&&r.push(qo.of(!0)),r}static baseTheme(e){return si.lowest(hn.of(zo("."+Io,e,Pu)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&Se.get(i)||Se.get(e);return((t=r?.root)===null||t===void 0?void 0:t.view)||null}}R.styleModule=hn;R.inputHandler=eu;R.clipboardInputFilter=bl;R.clipboardOutputFilter=Sl;R.scrollHandler=ru;R.focusChangeEffect=tu;R.perLineTextDirection=iu;R.exceptionSink=Jh;R.updateListener=Fo;R.editable=Dt;R.mouseSelectionStyle=_h;R.dragMovesSelection=Hh;R.clickAddsSelectionRange=Gh;R.decorations=us;R.blockWrappers=lu;R.outerDecorations=wl;R.atomicRanges=Dn;R.bidiIsolatedRanges=au;R.cursorScrollMargin=K.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});R.scrollMargins=cu;R.darkTheme=qo;R.cspNonce=K.define({combine:n=>n.length?n[0]:""});R.contentAttributes=xl;R.editorAttributes=ou;R.lineWrapping=R.contentAttributes.of({class:"cm-lineWrapping"});R.announce=W.define();const eO=4096,Ya={};class Fr{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:fe.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&gl(o,t)}return t}const tO=$.mac?"mac":$.windows?"win":$.linux?"linux":"key";function iO(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;ai.concat(r),[]))),t}function rO(n,e,t){return Tu(Cu(n.state),e,n,t)}let Nt=null;const sO=4e3;function oO(n,e=tO){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,c,h)=>{var u,f;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>iO(y,e));for(let y=1;y{let C=Nt={view:x,prefix:b,scope:o};return setTimeout(()=>{Nt==C&&(Nt=null)},sO),!0}]})}let m=p.join(" ");r(m,!1);let O=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((f=(u=d._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});a&&O.run.push(a),c&&(O.preventDefault=!0),h&&(O.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let h=t[c]||(t[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let f in h)h[f].run.push(d=>u(d,Wo))}let a=o[e]||o.key;if(a)for(let c of l)s(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let Wo=null;function Tu(n,e,t,i){Wo=e;let r=bp(e),s=Ne(r,0),o=Qt(s)==r.length&&r!=" ",l="",a=!1,c=!1,h=!1;Nt&&Nt.view==t&&Nt.scope==i&&(l=Nt.prefix+" ",gu.indexOf(e.keyCode)<0&&(c=!0,Nt=null));let u=new Set,f=O=>{if(O){for(let y of O.run)if(!u.has(y)&&(u.add(y),y(t)))return O.stopPropagation&&(h=!0),!0;O.preventDefault&&(O.stopPropagation&&(h=!0),c=!0)}return!1},d=n[i],p,m;return d&&(f(d[l+ir(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!($.windows&&e.ctrlKey&&e.altKey)&&!($.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=ti[e.keyCode])&&p!=r?(f(d[l+ir(p,e,!0)])||e.shiftKey&&(m=wn[e.keyCode])!=r&&m!=p&&f(d[l+ir(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(d[l+ir(r,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),c&&(a=!0),a&&h&&e.stopPropagation(),Wo=null,a}class Oi{constructor(e,t,i,r,s){this.className=e,this.left=t,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=$u(e);return[new Oi(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return lO(e,t,i)}}function $u(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==fe.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Ha(n,e,t,i){let r=n.coordsAtPos(e,t*2);if(!r)return i;let s=n.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=n.posAtCoords({x:s.left+1,y:o}),a=n.posAtCoords({x:s.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function lO(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),r=Math.min(t.to,n.viewport.to),s=n.textDirection==fe.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=$u(n),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=l.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),f=l.right-(h?parseInt(h.paddingRight):0),d=Xo(n,i,1),p=Xo(n,r,-1),m=d.type==Xe.Text?d:null,O=p.type==Xe.Text?p:null;if(m&&(n.lineWrapping||d.widgetLineBreaks)&&(m=Ha(n,i,1,m)),O&&(n.lineWrapping||p.widgetLineBreaks)&&(O=Ha(n,r,-1,O)),m&&O&&m.from==O.from&&m.to==O.to)return b(x(t.from,t.to,m));{let k=m?x(t.from,null,m):C(d,!1),S=O?x(null,t.to,O):C(p,!0),v=[];return(m||d).to<(O||p).from-(m&&O?1:0)||d.widgetLineBreaks>1&&k.bottom+n.defaultLineHeight/2M&&Q.from=P)break;ee>D&&E(Math.max(J,D),k==null&&J<=M,Math.min(ee,P),S==null&&ee>=Y,le.dir)}if(D=V.to+1,D>=P)break}return j.length==0&&E(M,k==null,Y,S==null,n.textDirection),{top:U,bottom:F,horizontal:j}}function C(k,S){let v=l.top+(S?k.top:k.bottom);return{top:v,bottom:v,horizontal:[]}}}function aO(n,e){return n.constructor==e.constructor&&n.eq(e)}class cO{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(br)!=e.state.facet(br)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(br);for(;t!aO(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[i].constructor&&r.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,$.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const br=K.define();function Ru(n){return[xe.define(e=>new cO(e,n)),br.of(n)]}const Wi=K.define({combine(n){return yt(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function hO(n={}){return[Wi.of(n),uO,fO,pO,nu.of(!0)]}function Ku(n){return n.startState.facet(Wi)!=n.state.facet(Wi)}const uO=Ru({above:!0,markers(n){let{state:e}=n,t=e.facet(Wi),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||t.drawRangeCursor&&!(s&&$.ios&&t.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:A.cursor(r.head,r.assoc);for(let a of Oi.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Ku(n);return t&&_a(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){_a(e.state,n)},class:"cm-cursorLayer"});function _a(n,e){e.style.animationDuration=n.facet(Wi).cursorBlinkRate+"ms"}const fO=Ru({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let r of i)if(!r.empty)for(let s of Oi.forRange(n,"cm-selectionBackground",r))e.push(s);if($.ios&&!t.empty&&n.state.facet(Wi).iosSelectionHandles){for(let r of Oi.forRange(n,"cm-selectionHandle cm-selectionHandle-start",A.cursor(t.from,1)))e.push(r);for(let r of Oi.forRange(n,"cm-selectionHandle cm-selectionHandle-end",A.cursor(t.to,1)))e.push(r)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Ku(n)},class:"cm-selectionLayer"}),dO=$.gecko&&$.gecko_version==153?"#ffffff01":"transparent",pO=si.highest(R.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${dO} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Zu=W.define({map(n,e){return n==null?null:e.mapPos(n)}}),fn=Te.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Zu)?i.value:t,n)}}),mO=xe.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(fn);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(fn)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(fn),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(fn)!=n&&this.view.dispatch({effects:Zu.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function OO(){return[fn,mO]}function Ja(n,e,t,i,r){e.lastIndex=0;for(let s=n.iterRange(t,i),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function gO(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:r,to:s}of t)r=Math.max(n.state.doc.lineAt(r).from,r-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}class yO{constructor(e){const{regexp:t,decoration:i,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,a,c,h)=>r(h,c,c+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,c,h)=>{let u=i(l,a,c);u&&h(c,c+l[0].length,u)};else if(i)this.addMatch=(l,a,c,h)=>h(c,c+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new Bt,i=t.add.bind(t);for(let{from:r,to:s}of gO(e,this.maxLength))Ja(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(i=Math.min(l,i),r=Math.max(a,r))}),e.viewportMoved||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),l=Math.min(s.to,r);if(l>=o){let a=e.state.doc.lineAt(o),c=a.toa.from;o--)if(this.boundary.test(a.text[o-1-a.from])){h=o;break}for(;lf.push(y.range(m,O));if(a==c)for(this.regexp.lastIndex=h-a.from;(d=this.regexp.exec(a.text))&&d.indexthis.addMatch(O,e,m,p));t=t.update({filterFrom:h,filterTo:u,filter:(m,O)=>mu,add:f})}}return t}}const jo=/x/.unicode!=null?"gu":"g",AO=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,jo),bO={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Ls=null;function SO(){var n;if(Ls==null&&typeof document<"u"&&document.body){let e=document.body.style;Ls=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Ls||!1}const Sr=K.define({combine(n){let e=yt(n,{render:null,specialChars:AO,addSpecialChars:null});return(e.replaceTabs=!SO())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,jo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,jo)),e}});function xO(n={}){return[Sr.of(n),wO()]}let ec=null;function wO(){return ec||(ec=xe.fromClass(class{constructor(n){this.view=n,this.decorations=B.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Sr)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new yO({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=Ne(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,a=_i(o.text,l,i-o.from);return B.replace({widget:new PO((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=B.replace({widget:new QO(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Sr);n.startState.facet(Sr)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const vO="•";function kO(n){return n>=32?vO:n==10?"␤":String.fromCharCode(9216+n)}class QO extends Ut{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=kO(this.code),i=e.state.phrase("Control character")+" "+(bO[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class PO extends Ut{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function CO(){return $O}const TO=B.line({class:"cm-activeLine"}),$O=xe.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(TO.range(r.from)),e=r.from)}return B.set(t)}},{decorations:n=>n.decorations}),Vo=2e3;function RO(n,e,t){let i=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>Vo||t.off>Vo||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=r;a++){let c=n.doc.line(a);c.length<=l&&s.push(A.range(c.from+o,c.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=r;a++){let c=n.doc.line(a),h=Qo(c.text,o,n.tabSize,!0);if(h<0)s.push(A.cursor(c.to));else{let u=Qo(c.text,l,n.tabSize);s.push(A.range(c.from+h,c.from+u))}}}return s}function KO(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function tc(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),r=t-i.from,s=r>Vo?-1:r==i.length?KO(n,e.clientX):_i(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:s,off:r}}function ZO(n,e){let t=tc(n,e),i=n.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(r.changes)}},get(r,s,o){let l=tc(n,r);if(!l)return i;let a=RO(n.state,t,l);return a.length?o?A.create(a.concat(i.ranges)):A.create(a):i}}:null}function MO(n){let e=(t=>t.altKey&&t.button==0);return R.mouseSelectionStyle.of((t,i)=>e(i)?ZO(t,i):null)}const EO={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},UO={style:"cursor: crosshair"};function FO(n={}){let[e,t]=EO[n.key||"Alt"],i=xe.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==e||t(r))},keyup(r){(r.keyCode==e||!t(r))&&this.set(!1)},mousemove(r){this.set(t(r))}}});return[i,R.contentAttributes.of(r=>{var s;return!((s=r.plugin(i))===null||s===void 0)&&s.isDown?UO:null})]}const nr="-10000px";class Mu{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;at[c]=a),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function DO(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Bs=K.define({combine:n=>{var e,t,i;return{position:$.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||DO}}}),ic=new WeakMap,Cl=xe.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Bs);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Mu(n,Os,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Bs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=nr,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if($.safari){let o=s.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(n=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=vl(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Bs).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:i,scaleX:r,scaleY:s}=n,o=[];for(let l=0;l=Math.min(t.bottom,i.bottom)||u.rightMath.min(t.right,i.right)+.1)){h.style.top=nr;continue}let d=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=f.right-f.left,O=(e=ic.get(c))!==null&&e!==void 0?e:f.bottom-f.top,y=c.offset||LO,b=this.view.textDirection==fe.LTR,x=f.width>i.right-i.left?b?i.left:i.right-f.width:b?Math.max(i.left,Math.min(u.left-(d?14:0)+y.x,i.right-m)):Math.min(Math.max(i.left,u.left-m+(d?14:0)-y.x),i.right-m),C=this.above[l];!a.strictSide&&(C?u.top-O-p-y.yi.bottom)&&C==i.bottom-u.bottom>u.top-i.top&&(C=this.above[l]=!C);let k=(C?u.top-i.top:i.bottom-u.bottom)-p;if(kx&&U.topS&&(S=C?U.top-O-2-p:U.bottom+p+2);if(this.position=="absolute"?(h.style.top=(S-n.parent.top)/s+"px",nc(h,(x-n.parent.left)/r)):(h.style.top=S/s+"px",nc(h,x/r)),d){let U=u.left+(b?y.x:-y.x)-(x+14-7);d.style.left=U/r+"px"}c.overlap!==!0&&o.push({left:x,top:S,right:v,bottom:S+O}),h.classList.toggle("cm-tooltip-above",C),h.classList.toggle("cm-tooltip-below",!C),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=nr}},{eventObservers:{scroll(){this.maybeMeasure()}}});function nc(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const XO=R.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),LO={x:0,y:0},Os=K.define({enables:[Cl,XO]}),Dr=K.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class gs{static create(e){return new gs(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Mu(e,Dr,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const BO=Os.compute([Dr],n=>{let e=n.facet(Dr);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:gs.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),qO=K.define();class IO{constructor(e,t,i,r,s,o){this.view=e,this.source=t,this.field=i,this.locked=r,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||t.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),a=l&&l.dir==fe.RTL?-1:1;s=t.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];r&&this.locked.set(a,r),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:t};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>We(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(Cl),t=e?e.manager.tooltips.findIndex(i=>i.create==gs.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&!this.locked.has(r)&&s&&!zO(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,l=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!WO(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const rr=4;function zO(n,e){let{left:t,right:i,top:r,bottom:s}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();r=Math.min(l.top,r),s=Math.max(l.bottom,s)}return e.clientX>=t-rr&&e.clientX<=i+rr&&e.clientY>=r-rr&&e.clientY<=s+rr}function WO(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.rightr||Math.min(o.bottom,l)=e&&a<=t}function Eu(n,e={}){let t=W.define(),i=new WeakMap,r=Te.define({create(){return[]},update(o,l){let a=i.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(c=>!e.hideOn(l,c)))),l.docChanged&&o.length){let c=[];for(let h of o){let u=l.changes.mapPos(h.pos,-1,De.TrackDel);if(u!=null){let f=Object.assign(Object.create(null),h);f.pos=u,f.end!=null&&(f.end=l.changes.mapPos(f.end)),c.push(f)}}o=c}for(let c of l.effects)c.is(t)&&(o=c.value,a=void 0),(c.is(jO)&&!c.value||c.value==r)&&(o=[]);return o.length&&a&&i.set(o,a),o},provide:o=>Dr.from(o)});const s=xe.define(o=>new IO(o,n,r,i,t,e.hoverTime||300));return{active:r,extension:[r,s,qO.of(s),BO]}}function Uu(n,e){let t=n.plugin(Cl);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const jO=W.define(),rc=K.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Fu(n,e){let t=n.plugin(Du),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Du=xe.fromClass(class{constructor(n){this.input=n.state.facet(ji),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(rc);this.top=new sr(n,!0,e.topContainer),this.bottom=new sr(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(rc);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new sr(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new sr(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(ji);if(t!=this.input){let i=t.filter(a=>a),r=[],s=[],o=[],l=[];for(let a of i){let c=this.specs.indexOf(a),h;c<0?(h=a(n.view),l.push(h)):(h=this.panels[c],h.update&&h.update(n)),r.push(h),(h.top?s:o).push(h)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>R.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class sr{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=sc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=sc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function sc(n){let e=n.nextSibling;return n.remove(),e}const ji=K.define({enables:Du});function VO(n,e){let t,i=new Promise(o=>t=o),r=o=>YO(o,e,t);n.state.field(qs,!1)?n.dispatch({effects:Xu.of(r)}):n.dispatch({effects:W.appendConfig.of(qs.init(()=>[r]))});let s=Lu.of(r);return{close:s,result:i.then(o=>((n.win.queueMicrotask||(a=>n.win.setTimeout(a,10)))(()=>{n.state.field(qs).indexOf(r)>-1&&n.dispatch({effects:s})}),o))}}const qs=Te.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(Xu)?n=[t.value].concat(n):t.is(Lu)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>ji.computeN([n],e=>e.field(n))}),Xu=W.define(),Lu=W.define();function YO(n,e,t){let i=e.content?e.content(n,()=>o(null)):null;if(!i){if(i=he("form"),e.input){let l=he("input",e.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),i.appendChild(he("label",(e.label||"")+": ",l))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(he("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let r=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let l=0;l{c.keyCode==27?(c.preventDefault(),o(null)):c.keyCode==13&&(c.preventDefault(),o(a))}),a.addEventListener("submit",c=>{c.preventDefault(),o(a)})}let s=he("div",i,he("button",{onclick:()=>o(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(s.className=e.class),s.classList.add("cm-dialog");function o(l){s.contains(s.ownerDocument.activeElement)&&n.focus(),t(l)}return{dom:s,top:e.top,mount:()=>{if(e.focus){let l;typeof e.focus=="string"?l=i.querySelector(e.focus):l=i.querySelector("input")||i.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}class Mt extends Jt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Mt.prototype.elementClass="";Mt.prototype.toDOM=void 0;Mt.prototype.mapMode=De.TrackBefore;Mt.prototype.startSide=Mt.prototype.endSide=-1;Mt.prototype.point=!0;const xr=K.define(),NO=K.define(),GO={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>N.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},An=K.define();function Bu(n){return[qu(),An.of({...GO,...n})]}const oc=K.define({combine:n=>n.some(e=>e)});function qu(n){return[HO]}const HO=xe.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(An).map(e=>new ac(n,e)),this.fixed=!n.state.facet(oc);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(oc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=N.iter(this.view.state.facet(xr),this.view.viewport.from),i=[],r=this.gutters.map(s=>new _O(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Xe.Text&&o){Yo(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Xe.Text){Yo(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(An),t=n.state.facet(An),i=n.docChanged||n.heightChanged||n.viewportChanged||!N.eq(n.startState.facet(xr),n.state.facet(xr),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new ac(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>R.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==fe.LTR?{left:i,right:r}:{right:i,left:r}})});function lc(n){return Array.isArray(n)?n:[n]}function Yo(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class _O{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=N.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Iu(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Yo(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),r=i?[i]:null;for(let s of e.state.facet(NO)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class ac{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=lc(t.markers(e)),t.initialSpacer&&(this.spacer=new Iu(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=lc(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!N.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Iu{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),JO(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=ss(l,a,c)||o(l,a,c):o}return i}})}});class Is extends Mt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function zs(n,e){return n.state.facet($i).formatNumber(e,n.state)}const ig=An.compute([$i],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(eg)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new Is(zs(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let r of e.state.facet(tg)){let s=r(e,t,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet($i)!=e.state.facet($i),initialSpacer(e){return new Is(zs(e,cc(e.state.doc.lines)))},updateSpacer(e,t){let i=zs(t.view,cc(t.view.state.doc.lines));return i==e.number?e:new Is(i)},domEventHandlers:n.facet($i).domEventHandlers,side:"before"}));function ng(n={}){return[$i.of(n),qu(),ig]}function cc(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.head).from;r>t&&(t=r,e.push(rg.range(r)))}return N.of(e)});function og(){return sg}const zu=1024;let lg=0;class Ws{constructor(e,t){this.from=e,this.to=t}}class H{constructor(e={}){this.id=lg++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=et.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}H.closedBy=new H({deserialize:n=>n.split(" ")});H.openedBy=new H({deserialize:n=>n.split(" ")});H.group=new H({deserialize:n=>n.split(" ")});H.isolate=new H({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});H.contextHash=new H({perNode:!0});H.lookAhead=new H({perNode:!0});H.mounted=new H({perNode:!0});class bn{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[H.mounted.id]}}const ag=Object.create(null);class et{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):ag,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new et(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(H.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(H.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}}et.none=new et("",Object.create(null),0,8);class Tl{constructor(e){this.types=e;for(let t=0;t0;for(let a=this.cursor(o|be.IncludeAnonymous);;){let c=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Kl(et.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new ke(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new ke(et.none,t,i,r)))}static build(e){return fg(e)}}ke.empty=new ke(et.none,[],[],0);class $l{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new $l(this.buffer,this.index)}}class ni{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return et.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Pn(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?l.length:-1;e!=c;e+=t){let h=l[e],u=a[e]+o.from,f;if(!(!(s&be.EnterBracketed&&h instanceof ke&&(f=bn.get(h))&&!f.overlay&&f.bracketed&&i>=u&&i<=u+h.length)&&!Wu(r,i,u,u+h.length))){if(h instanceof ni){if(s&be.ExcludeBuffers)continue;let d=h.findChild(0,h.buffer.length,t,i-u,r);if(d>-1)return new Tt(new cg(o,h,e,u),null,d)}else if(s&be.IncludeAnonymous||!h.type.isAnonymous||Rl(h)){let d;if(!(s&be.IgnoreMounts)&&(d=bn.get(h))&&!d.overlay)return new Je(d.tree,u,e,o);let p=new Je(h,u,e,o);return s&be.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?h.children.length-1:0,t,i,r,s)}}}if(s&be.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&be.IgnoreOverlays)&&(r=bn.get(this._tree))&&r.overlay){let s=e-this.from,o=i&be.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l=s:a>s))return new Je(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function uc(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function No(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class cg{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}}class Tt extends ju{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new Tt(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&be.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new Tt(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Tt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Tt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new ke(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Vu(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;st.from||o.to=e){let l=new Je(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Pn(l,e,t,!1))}}return r?Vu(r):i}class Go{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~be.EnterBracketed,e instanceof Je)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof Je?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&be.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&be.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&be.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&be.IncludeAnonymous||l instanceof ni||!l.type.isAnonymous||Rl(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r=0;s--){if(s<0)return No(this._tree,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Rl(n){return n.children.some(e=>e instanceof ni||!e.type.isAnonymous||Rl(e))}function fg(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=zu,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new $l(t,t.length):t,a=i.types,c=0,h=0;function u(k,S,v,U,F,j){let{id:E,start:M,end:Y,size:Q}=l,D=h,P=c;if(Q<0)if(l.next(),Q==-1){let q=s[E];v.push(q),U.push(M-k);return}else if(Q==-3){c=E;return}else if(Q==-4){h=E;return}else throw new RangeError(`Unrecognized record size: ${Q}`);let V=a[E],le,J,ee=M-k;if(Y-M<=r&&(J=O(l.pos-S,F))){let q=new Uint16Array(J.size-J.skip),G=l.pos-J.size,ce=q.length;for(;l.pos>G;)ce=y(J.start,q,ce);le=new ni(q,Y-J.start,i),ee=J.start-k}else{let q=l.pos-Q;l.next();let G=[],ce=[],I=E>=o?E:-1,te=0,se=Y;for(;l.pos>q;)I>=0&&l.id==I&&l.size>=0?(l.end<=se-r&&(p(G,ce,M,te,l.end,se,I,D,P),te=G.length,se=l.end),l.next()):j>2500?f(M,q,G,ce):u(M,q,G,ce,I,j+1);if(I>=0&&te>0&&te-1&&te>0){let Me=d(V,P);le=Kl(V,G,ce,0,G.length,0,Y-M,Me,Me)}else le=m(V,G,ce,Y-M,D-Y,P)}v.push(le),U.push(ee)}function f(k,S,v,U){let F=[],j=0,E=-1;for(;l.pos>S;){let{id:M,start:Y,end:Q,size:D}=l;if(D>4)l.next();else{if(E>-1&&Y=0;Q-=3)M[D++]=F[Q],M[D++]=F[Q+1]-Y,M[D++]=F[Q+2]-Y,M[D++]=D;v.push(new ni(M,F[2]-Y,i)),U.push(Y-k)}}function d(k,S){return(v,U,F)=>{let j=0,E=v.length-1,M,Y;if(E>=0&&(M=v[E])instanceof ke){if(!E&&M.type==k&&M.length==F)return M;(Y=M.prop(H.lookAhead))&&(j=U[E]+M.length+Y)}return m(k,v,U,F,j,S)}}function p(k,S,v,U,F,j,E,M,Y){let Q=[],D=[];for(;k.length>U;)Q.push(k.pop()),D.push(S.pop()+v-F);k.push(m(i.types[E],Q,D,j-F,M-j,Y)),S.push(F-v)}function m(k,S,v,U,F,j,E){if(j){let M=[H.contextHash,j];E=E?[M].concat(E):[M]}if(F>25){let M=[H.lookAhead,F];E=E?[M].concat(E):[M]}return new ke(k,S,v,U,E)}function O(k,S){let v=l.fork(),U=0,F=0,j=0,E=v.end-r,M={size:0,start:0,skip:0};e:for(let Y=v.pos-k;v.pos>Y;){let Q=v.size;if(v.id==S&&Q>=0){M.size=U,M.start=F,M.skip=j,j+=4,U+=4,v.next();continue}let D=v.pos-Q;if(Q<0||D=o?4:0,V=v.start;for(v.next();v.pos>D;){if(v.size<0)if(v.size==-3||v.size==-4)P+=4;else break e;else v.id>=o&&(P+=4);v.next()}F=V,U+=Q,j+=P}return(S<0||U==k)&&(M.size=U,M.start=F,M.skip=j),M.size>4?M:void 0}function y(k,S,v){let{id:U,start:F,end:j,size:E}=l;if(l.next(),E>=0&&U4){let Y=l.pos-(E-4);for(;l.pos>Y;)v=y(k,S,v)}S[--v]=M,S[--v]=j-k,S[--v]=F-k,S[--v]=U}else E==-3?c=U:E==-4&&(h=U);return v}let b=[],x=[];for(;l.pos>0;)u(n.start||0,n.bufferStart||0,b,x,-1,0);let C=(e=n.length)!==null&&e!==void 0?e:b.length?x[0]+b[0].length:0;return new ke(a[n.topID],b.reverse(),x.reverse(),C)}const fc=new WeakMap;function wr(n,e){if(!n.isAnonymous||e instanceof ni||e.type!=n)return 1;let t=fc.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof ke)){t=1;break}t+=wr(n,i)}fc.set(e,t)}return t}function Kl(n,e,t,i,r,s,o,l,a){let c=0;for(let p=i;p=h)break;S+=v}if(x==C+1){if(S>h){let v=p[C];d(v.children,v.positions,0,v.children.length,m[C]+b);continue}u.push(p[C])}else{let v=m[x-1]+p[x-1].length-k;u.push(Kl(n,p,m,C,x,k,v,null,a))}f.push(k+b-s)}}return d(e,t,i,r,0),(l||a)(u,f,o)}class dg{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Tt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Je&&this.map.set(e.tree,t)}get(e){return e instanceof Tt?this.getBuffer(e.context.buffer,e.index):e instanceof Je?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class gi{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new gi(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let h=l=i)for(;o&&o.from=f.from||u<=f.to||c){let d=Math.max(f.from,a)-c,p=Math.min(f.to,u)-c;f=d>=p?null:new gi(d,p,f.tree,f.offset+c,l>0,!!h)}if(f&&r.push(f),o.to>u)break;o=snew Ws(r.from,r.to)):[new Ws(0,0)]:[new Ws(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}}class pg{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new H({perNode:!0});let mg=0;class at{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=mg++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof at&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new at(i,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Xr(e);return i=>i.modified.indexOf(t)>-1?i:Xr.get(i.base||i,i.modified.concat(t).sort((r,s)=>r.id-s.id))}}let Og=0;class Xr{constructor(e){this.name=e,this.instances=[],this.id=Og++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&gg(t,l.modified));if(i)return i;let r=[],s=new at(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=yg(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(Xr.get(l,a));return s}}function gg(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function yg(n){let e=[[]];for(let t=0;ti.length-t.length)}function Nu(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let u=0;;){if(l=="..."&&u>0&&u+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==r.length)break;let d=r[u++];if(u==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(u)}let a=s.length-1,c=s[a];if(!c)throw new RangeError("Invalid path: "+r);let h=new Cn(i,o,a>0?s.slice(0,a):null);e[c]=h.sort(e[c])}}return Gu.add(e)}const Gu=new H({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new Cn(r.tags,r.mode,r.context);t?t.next=s:i=s,t=s}return i}});class Cn{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let l of s)for(let a of l.set){let c=t[a.id];if(c){o=o?o+" "+c:c;break}}return o},scope:i}}function Ag(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function bg(n,e,t,i=0,r=n.length){let s=new Sg(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}class Sg{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=r,h=xg(e)||Cn.empty,u=Ag(s,h.tags);if(u&&(c&&(c+=" "),c+=u,h.mode==1&&(r+=(r?" ":"")+u)),this.startSpan(Math.max(t,l),c),h.opaque)return;let f=e.tree&&e.tree.prop(H.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+l,1),p=this.highlighters.filter(O=>!O.scope||O.scope(f.tree.type)),m=e.firstChild();for(let O=0,y=l;;O++){let b=O=x||!e.nextSibling())););if(!b||x>i)break;y=b.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,b.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),c))}m&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}}function xg(n){let e=n.type.prop(Gu);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const T=at.define,lr=T(),jt=T(),dc=T(jt),pc=T(jt),Vt=T(),ar=T(Vt),js=T(Vt),vt=T(),ai=T(vt),xt=T(),wt=T(),Ho=T(),on=T(Ho),cr=T(),g={comment:lr,lineComment:T(lr),blockComment:T(lr),docComment:T(lr),name:jt,variableName:T(jt),typeName:dc,tagName:T(dc),propertyName:pc,attributeName:T(pc),className:T(jt),labelName:T(jt),namespace:T(jt),macroName:T(jt),literal:Vt,string:ar,docString:T(ar),character:T(ar),attributeValue:T(ar),number:js,integer:T(js),float:T(js),bool:T(Vt),regexp:T(Vt),escape:T(Vt),color:T(Vt),url:T(Vt),keyword:xt,self:T(xt),null:T(xt),atom:T(xt),unit:T(xt),modifier:T(xt),operatorKeyword:T(xt),controlKeyword:T(xt),definitionKeyword:T(xt),moduleKeyword:T(xt),operator:wt,derefOperator:T(wt),arithmeticOperator:T(wt),logicOperator:T(wt),bitwiseOperator:T(wt),compareOperator:T(wt),updateOperator:T(wt),definitionOperator:T(wt),typeOperator:T(wt),controlOperator:T(wt),punctuation:Ho,separator:T(Ho),bracket:on,angleBracket:T(on),squareBracket:T(on),paren:T(on),brace:T(on),content:vt,heading:ai,heading1:T(ai),heading2:T(ai),heading3:T(ai),heading4:T(ai),heading5:T(ai),heading6:T(ai),contentSeparator:T(vt),list:T(vt),quote:T(vt),emphasis:T(vt),strong:T(vt),link:T(vt),monospace:T(vt),strikethrough:T(vt),inserted:T(),deleted:T(),changed:T(),invalid:T(),meta:cr,documentMeta:T(cr),annotation:T(cr),processingInstruction:T(cr),definition:at.defineModifier("definition"),constant:at.defineModifier("constant"),function:at.defineModifier("function"),standard:at.defineModifier("standard"),local:at.defineModifier("local"),special:at.defineModifier("special")};for(let n in g){let e=g[n];e instanceof at&&(e.name=n)}Hu([{tag:g.link,class:"tok-link"},{tag:g.heading,class:"tok-heading"},{tag:g.emphasis,class:"tok-emphasis"},{tag:g.strong,class:"tok-strong"},{tag:g.keyword,class:"tok-keyword"},{tag:g.atom,class:"tok-atom"},{tag:g.bool,class:"tok-bool"},{tag:g.url,class:"tok-url"},{tag:g.labelName,class:"tok-labelName"},{tag:g.inserted,class:"tok-inserted"},{tag:g.deleted,class:"tok-deleted"},{tag:g.literal,class:"tok-literal"},{tag:g.string,class:"tok-string"},{tag:g.number,class:"tok-number"},{tag:[g.regexp,g.escape,g.special(g.string)],class:"tok-string2"},{tag:g.variableName,class:"tok-variableName"},{tag:g.local(g.variableName),class:"tok-variableName tok-local"},{tag:g.definition(g.variableName),class:"tok-variableName tok-definition"},{tag:g.special(g.variableName),class:"tok-variableName2"},{tag:g.definition(g.propertyName),class:"tok-propertyName tok-definition"},{tag:g.typeName,class:"tok-typeName"},{tag:g.namespace,class:"tok-namespace"},{tag:g.className,class:"tok-className"},{tag:g.macroName,class:"tok-macroName"},{tag:g.propertyName,class:"tok-propertyName"},{tag:g.operator,class:"tok-operator"},{tag:g.comment,class:"tok-comment"},{tag:g.meta,class:"tok-meta"},{tag:g.invalid,class:"tok-invalid"},{tag:g.punctuation,class:"tok-punctuation"}]);var Vs;const Ri=new H;function _u(n){return K.define({combine:n?e=>e.concat(n):void 0})}const Zl=new H;class mt{constructor(e,t,i=[],r=""){this.data=e,this.name=r,_.prototype.hasOwnProperty("tree")||Object.defineProperty(_.prototype,"tree",{get(){return Ce(this)}}),this.parser=t,this.extension=[ri.of(this),_.languageData.of((s,o,l)=>{let a=mc(s,o,l),c=a.type.prop(Ri);if(!c)return[];let h=s.facet(c),u=a.type.prop(Zl);if(u){let f=a.resolve(o-a.from,l);for(let d of u)if(d.test(f,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(h)}}return h})].concat(i)}isActiveAt(e,t,i=-1){return mc(e,t,i).type.prop(Ri)==this.data}findRegions(e){let t=e.facet(ri);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Ri)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(H.mounted);if(l){if(l.tree.prop(Ri)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;ai.isTop?t:void 0)]}),e.name)}configure(e,t){return new Lr(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ce(n){let e=n.field(mt.state,!1);return e?e.tree:ke.empty}class wg{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let ln=null;class Br{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Br(e,t,[],ke.empty,0,i,[],null)}startParse(){return this.parser.startParse(new wg(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ke.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(gi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ln;ln=this;try{return e()}finally{ln=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Oc(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,h,u,f)=>a.push({fromA:c,toA:h,fromB:u,toB:f})),i=gi.applyChanges(i,a),r=ke.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);he.from&&(this.fragments=Oc(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Yu{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=ln;if(a){for(let c of r)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new ke(et.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return ln}}function Oc(n,e,t){return gi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class Vi{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new Vi(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Br.create(e.facet(ri).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new Vi(i)}}mt.state=Te.define({create:Vi.init,update(n,e){for(let t of e.effects)if(t.is(mt.setState))return t.value;return e.startState.facet(ri)!=e.state.facet(ri)?Vi.init(e.state):n.apply(e)}});let Ju=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Ju=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Ys=typeof navigator<"u"&&(!((Vs=navigator.scheduling)===null||Vs===void 0)&&Vs.isInputPending)?()=>navigator.scheduling.isInputPending():null,vg=xe.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(mt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(mt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Ju(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,a=s.context.work(()=>Ys&&Ys()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:mt.setState.of(new Vi(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>We(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ri=K.define({combine(n){return n.length?n[0]:null},enables:n=>[mt.state,vg,R.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class kg{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Qg=K.define(),ys=K.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function qr(n){let e=n.facet(ys);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Tn(n,e){let t="",i=n.tabSize,r=n.facet(ys)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s=e?Pg(n,t,e):null}class As{constructor(e,t={}){this.state=e,this.options=t,this.unit=qr(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return _i(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ef=new H;function Pg(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o&&!(o.fromi.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return tf(i,n,t)}function tf(n,e,t){for(let i=n;i;i=i.next){let r=Tg(i.node);if(r)return r(El.create(e,t,i))}return 0}function Cg(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Tg(n){let e=n.type.prop(ef);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(H.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>nf(o,!0,1,void 0,s&&!Cg(o)?r.from:void 0)}return n.parent==null?$g:null}function $g(){return 0}class El extends As{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new El(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Rg(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return tf(this.context.next,this.base,this.pos)}}function Rg(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Kg(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+c}}l=a.to}}function Zg({closing:n,align:e=!0,units:t=1}){return i=>nf(i,e,t,n)}function nf(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?Kg(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const Mg=n=>n.baseIndent;function Ns({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const Eg=200;function Ug(){return _.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+Eg)return n;let s=t.sliceString(r.from,i);if(!e.some(c=>c.test(s)))return n;let{state:o}=n,l=-1,a=[];for(let{head:c}of o.selection.ranges){let h=o.doc.lineAt(c);if(h.from==l)continue;l=h.from;let u=Ml(o,h.from);if(u==null)continue;let f=/^\s*/.exec(h.text)[0],d=Tn(o,u);f!=d&&a.push({from:h.from,to:h.from+f.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const Fg=K.define(),rf=new H;function Dg(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(s&&l.from=e&&c.to>t&&(s=c)}}return s}function Lg(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Ir(n,e,t){for(let i of n.facet(Fg)){let r=i(n,e,t);if(r)return r}return Xg(n,e,t)}function sf(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const bs=W.define({map:sf}),Xn=W.define({map:sf});function of(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const xi=Te.define({create(){return B.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,r)=>n=gc(n,i,r)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(bs)&&!Bg(n,i.value.from,i.value.to)?t.push(i.value):i.is(Xn)&&(n=n.update({filter:(r,s)=>i.value.from!=r||i.value.to!=s,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(cf),r=t.map(s=>(i?B.replace({widget:new Yg(i(e.state,s))}):yc).range(s.from,s.to));n=n.update({add:r})}return e.selection&&(n=gc(n,e.selection.main.head)),n},provide:n=>R.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,r)=>{t.push(i,r)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{re&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(r,s)=>r>=t||s<=e}):n}function zr(n,e,t){var i;let r=null;return(i=n.field(xi,!1))===null||i===void 0||i.between(e,t,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function Bg(n,e,t){let i=!1;return n.between(e,e,(r,s)=>{r==e&&s==t&&(i=!0)}),i}function lf(n,e){return n.field(xi,!1)?e:e.concat(W.appendConfig.of(hf()))}const qg=n=>{for(let e of of(n)){let t=Ir(n.state,e.from,e.to);if(t)return n.dispatch({effects:lf(n.state,[bs.of(t),af(n,t)])}),!0}return!1},Ig=n=>{if(!n.state.field(xi,!1))return!1;let e=[];for(let t of of(n)){let i=zr(n.state,t.from,t.to);i&&e.push(Xn.of(i),af(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function af(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,r=n.state.doc.lineAt(e.to).number;return R.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${r}.`)}const zg=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(xi,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,r)=>{t.push(Xn.of({from:i,to:r}))}),n.dispatch({effects:t}),!0},jg=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:qg},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ig},{key:"Ctrl-Alt-[",run:zg},{key:"Ctrl-Alt-]",run:Wg}],Vg={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},cf=K.define({combine(n){return yt(n,Vg)}});function hf(n){return[xi,Hg]}function uf(n,e){let{state:t}=n,i=t.facet(cf),r=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=zr(n.state,l.from,l.to);a&&n.dispatch({effects:Xn.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const yc=B.replace({widget:new class extends Ut{toDOM(n){return uf(n,null)}}});class Yg extends Ut{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return uf(e,this.value)}}const Ng={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Gs extends Mt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Gg(n={}){let e={...Ng,...n},t=new Gs(e,!0),i=new Gs(e,!1),r=xe.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(ri)!=o.state.facet(ri)||o.startState.field(xi,!1)!=o.state.field(xi,!1)||Ce(o.startState)!=Ce(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Bt;for(let a of o.viewportLineBlocks){let c=zr(o.state,a.from,a.to)?i:Ir(o.state,a.from,a.to)?t:null;c&&l.add(a.from,a.from,c)}return l.finish()}}),{domEventHandlers:s}=e;return[r,Bu({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(r))===null||l===void 0?void 0:l.markers)||N.empty},initialSpacer(){return new Gs(e,!1)},domEventHandlers:{...s,click:(o,l,a)=>{if(s.click&&s.click(o,l,a))return!0;let c=zr(o.state,l.from,l.to);if(c)return o.dispatch({effects:Xn.of(c)}),!0;let h=Ir(o.state,l.from,l.to);return h?(o.dispatch({effects:bs.of(h)}),!0):!1}}}),hf()]}const Hg=R.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Ln{constructor(e,t){this.specs=e;let i;function r(l){let a=ei.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof mt?l=>l.prop(Ri)==o.data:o?l=>l==o:void 0,this.style=Hu(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new ei(i):null,this.themeType=t.themeType}static define(e,t){return new Ln(e,t||{})}}const _o=K.define(),_g=K.define({combine(n){return n.length?[n[0]]:null}});function Hs(n){let e=n.facet(_o);return e.length?e:n.facet(_g)}function Jg(n,e){let t=[t0],i;return n instanceof Ln&&(n.module&&t.push(R.styleModule.of(n.module)),i=n.themeType),i?t.push(_o.computeN([R.darkTheme],r=>r.facet(R.darkTheme)==(i=="dark")?[n]:[])):t.push(_o.of(n)),t}class e0{constructor(e){this.markCache=Object.create(null),this.tree=Ce(e.state),this.decorations=this.buildDeco(e,Hs(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ce(e.state),i=Hs(e.state),r=i!=Hs(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return B.none;let i=new Bt;for(let{from:r,to:s}of e.visibleRanges)bg(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=B.mark({class:a})))},r,s);return i.finish()}}const t0=si.high(xe.fromClass(e0,{decorations:n=>n.decorations})),i0=Ln.define([{tag:g.meta,color:"#404740"},{tag:g.link,textDecoration:"underline"},{tag:g.heading,textDecoration:"underline",fontWeight:"bold"},{tag:g.emphasis,fontStyle:"italic"},{tag:g.strong,fontWeight:"bold"},{tag:g.strikethrough,textDecoration:"line-through"},{tag:g.keyword,color:"#708"},{tag:[g.atom,g.bool,g.url,g.contentSeparator,g.labelName],color:"#219"},{tag:[g.literal,g.inserted],color:"#164"},{tag:[g.string,g.deleted],color:"#a11"},{tag:[g.regexp,g.escape,g.special(g.string)],color:"#e40"},{tag:g.definition(g.variableName),color:"#00f"},{tag:g.local(g.variableName),color:"#30a"},{tag:[g.typeName,g.namespace],color:"#085"},{tag:g.className,color:"#167"},{tag:[g.special(g.variableName),g.macroName],color:"#256"},{tag:g.definition(g.propertyName),color:"#00c"},{tag:g.comment,color:"#940"},{tag:g.invalid,color:"#f00"}]),n0=R.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ff=1e4,df="()[]{}",pf=K.define({combine(n){return yt(n,{afterCursor:!0,brackets:df,maxScanDistance:ff,renderMatch:o0})}}),r0=B.mark({class:"cm-matchingBracket"}),s0=B.mark({class:"cm-nonmatchingBracket"});function o0(n){let e=[],t=n.matched?r0:s0;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function Ac(n){let e=[],t=n.facet(pf);for(let i of n.selection.ranges){if(!i.empty)continue;let r=$t(n,i.head,-1,t)||i.head>0&&$t(n,i.head-1,1,t)||t.afterCursor&&($t(n,i.head,1,t)||i.headn.decorations}),a0=[l0,n0];function c0(n={}){return[pf.of(n),a0]}const h0=new H;function Jo(n,e,t){let i=n.prop(e<0?H.openedBy:H.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function el(n){let e=n.type.prop(h0);return e?e(n.node):n}function $t(n,e,t,i={}){let r=i.maxScanDistance||ff,s=i.brackets||df,o=Ce(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=Jo(a.type,t,s);if(c&&a.from0?e>=h.from&&eh.from&&e<=h.to))return u0(n,e,t,a,h,c,s)}}return f0(n,e,t,o,l.type,r,s)}function u0(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},c=0,h=l?.cursor();if(h&&(t<0?h.childBefore(i.from):h.childAfter(i.to)))do if(t<0?h.to<=i.from:h.from>=i.to){if(c==0&&s.indexOf(h.type.name)>-1&&h.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},h=n.doc.iterRange(e,t>0?n.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=s;){let d=h.value;t<0&&(f+=d.length);let p=e+f*t;for(let m=t>0?0:d.length-1,O=t>0?d.length:-1;m!=O;m+=t){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=r))if(y%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};u--}}t>0&&(f+=d.length)}return h.done?{start:c,matched:!1}:null}const d0=Object.create(null),bc=[et.none],Sc=[],xc=Object.create(null),p0=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])p0[n]=m0(d0,e);function _s(n,e){Sc.indexOf(n)>-1||(Sc.push(n),console.warn(e))}function m0(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let c of l.split(".")){let h=n[c]||g[c];h?typeof h=="function"?a.length?a=a.map(h):_s(c,`Modifier ${c} used at start of tag`):a.length?_s(c,`Tag ${c} used as modifier`):a=Array.isArray(h)?h:[h]:_s(c,`Unknown highlighting tag ${c}`)}for(let c of a)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=xc[r];if(s)return s.id;let o=xc[r]=et.define({id:bc.length,name:i,props:[Nu({[i]:t})]});return bc.push(o),o.id}fe.RTL,fe.LTR;const O0=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Fl(n.state,t.from);return i.line?g0(n):i.block?A0(n):!1};function Ul(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}const g0=Ul(x0,0),y0=Ul(mf,0),A0=Ul((n,e)=>mf(n,e,S0(e)),0);function Fl(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const an=50;function b0(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-an,i),o=n.sliceDoc(r,r+an),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,c=s.length-l;if(s.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let h,u;r-i<=2*an?h=u=n.sliceDoc(i,r):(h=n.sliceDoc(i,i+an),u=n.sliceDoc(r-an,r));let f=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(u)[0].length,p=u.length-d-t.length;return h.slice(f,f+e.length)==e&&u.slice(p,p+t.length)==t?{open:{pos:i+f+e.length,margin:/\s/.test(h.charAt(f+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function S0(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function mf(n,e,t=e.selection.ranges){let i=t.map(s=>Fl(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>b0(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;or&&(s==o||o>u.from)){r=u.from;let f=/^\s*/.exec(u.text)[0].length,d=f==u.length,p=u.text.slice(f,f+c.length)==c?f:-1;fs.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:c,empty:h,single:u}of i)(u||!h)&&s.push({from:l.from+c,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let c=o.from+l,h=c+a.length;o.text[h-o.from]==" "&&h++,s.push({from:c,to:h})}return{changes:s}}return null}const tl=zt.define(),vr=zt.define(),w0=K.define(),Of=K.define({combine(n){return yt(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),Dl=Te.define({create(){return Rt.empty},update(n,e){let t=e.state.facet(Of),i=e.annotation(tl);if(i){let a=_e.fromTransaction(e,i.selection),c=i.side,h=c==0?n.undone:n.done;return a?h=jr(h,h.length,t.minDepth,a):h=Af(h,e.startState.selection),new Rt(c==0?i.rest:h,c==0?h:i.rest)}let r=e.annotation(vr);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(Pe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=_e.fromTransaction(e),o=e.annotation(Pe.time),l=e.annotation(Pe.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Rt(n.done.map(_e.fromJSON),n.undone.map(_e.fromJSON))}});function v0(n={}){return[Dl,Of.of(n),R.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Xl:e.inputType=="historyRedo"?Wr:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ss(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(Dl,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}const Xl=Ss(0,!1),Wr=Ss(1,!1),k0=Ss(0,!0),Q0=Ss(1,!0);function gf(n){return function(e){let t=e.field(Dl,!1);if(!t)return 0;let i=n==0?t.done:t.undone;return i.length-(i.length&&!i[0].changes?1:0)}}const wc=gf(0),vc=gf(1);class _e{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new _e(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new _e(e.changes&&$e.fromJSON(e.changes),[],e.mapped&&Zt.fromJSON(e.mapped),e.startSelection&&A.fromJSON(e.startSelection),e.selectionsAfter.map(A.fromJSON))}static fromTransaction(e,t){let i=ht;for(let r of e.startState.facet(w0)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new _e(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ht)}static selection(e){return new _e(void 0,ht,void 0,void 0,e)}}function jr(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function P0(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a=c&&o<=h&&(i=!0)}}),i}function C0(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function yf(n,e){return n.length?e.length?n.concat(e):n:e}const ht=[],T0=200;function Af(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-T0));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),jr(n,n.length-1,1e9,t.setSelAfter(i)))}else return[_e.selection([e])]}function $0(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Js(n,e){if(!n.length)return n;let t=n.length,i=ht;for(;t;){let r=R0(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[_e.selection(i)]:ht}function R0(n,e,t){let i=yf(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):ht,t);if(!n.changes)return _e.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new _e(r,W.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}const K0=/^(input\.type|delete)($|\.)/;class Rt{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new Rt(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||K0.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):xs(t,e))}function Be(n){return n.textDirectionAt(n.state.selection.main.head)==fe.LTR}const Sf=n=>bf(n,!Be(n)),xf=n=>bf(n,Be(n));function wf(n,e){return bt(n,t=>t.empty?n.moveByGroup(t,e):xs(t,e))}const M0=n=>wf(n,!Be(n)),E0=n=>wf(n,Be(n));function U0(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function ws(n,e,t){let i=Ce(n).resolveInner(e.head),r=t?H.closedBy:H.openedBy;for(let a=e.head;;){let c=t?i.childAfter(a):i.childBefore(a);if(!c)break;U0(n,c,r)?i=c:a=t?c.to:c.from}let s=i.type.prop(r),o,l;return s&&(o=t?$t(n,i.from,1):$t(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,A.cursor(l,t?-1:1)}const F0=n=>bt(n,e=>ws(n.state,e,!Be(n))),D0=n=>bt(n,e=>ws(n.state,e,Be(n)));function vf(n,e){return bt(n,t=>{if(!t.empty)return xs(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const kf=n=>vf(n,!1),Qf=n=>vf(n,!0);function Pf(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):xs(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottomCf(n,!1),il=n=>Cf(n,!0);function oi(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=A.cursor(i.from+s))}return r}const X0=n=>bt(n,e=>oi(n,e,!0)),L0=n=>bt(n,e=>oi(n,e,!1)),B0=n=>bt(n,e=>oi(n,e,!Be(n))),q0=n=>bt(n,e=>oi(n,e,Be(n))),I0=n=>bt(n,e=>A.cursor(n.lineBlockAt(e.head).from,1)),z0=n=>bt(n,e=>A.cursor(n.lineBlockAt(e.head).to,-1));function W0(n,e,t){let i=!1,r=Ji(n.selection,s=>{let o=$t(n,s.head,-1)||$t(n,s.head,1)||s.head>0&&$t(n,s.head-1,1)||s.headW0(n,e);function ft(n,e,t){let i=Ji(n.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=A.range(r.head,r.anchor));let s=t(r);return A.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(At(n.state,i)),!0)}function Tf(n,e){return ft(n,e,t=>n.moveByChar(t,e))}const $f=n=>Tf(n,!Be(n)),Rf=n=>Tf(n,Be(n));function Kf(n,e){return ft(n,e,t=>n.moveByGroup(t,e))}const V0=n=>Kf(n,!Be(n)),Y0=n=>Kf(n,Be(n)),N0=n=>{let e=!Be(n);return ft(n,e,t=>ws(n.state,t,e))},G0=n=>{let e=Be(n);return ft(n,e,t=>ws(n.state,t,e))};function Zf(n,e){return ft(n,e,t=>n.moveVertically(t,e))}const Mf=n=>Zf(n,!1),Ef=n=>Zf(n,!0);function Uf(n,e){return ft(n,e,t=>n.moveVertically(t,e,Pf(n).height))}const Qc=n=>Uf(n,!1),Pc=n=>Uf(n,!0),H0=n=>ft(n,!0,e=>oi(n,e,!0)),_0=n=>ft(n,!1,e=>oi(n,e,!1)),J0=n=>{let e=!Be(n);return ft(n,e,t=>oi(n,t,e))},ey=n=>{let e=Be(n);return ft(n,e,t=>oi(n,t,e))},ty=n=>ft(n,!1,e=>A.cursor(n.lineBlockAt(e.head).from)),iy=n=>ft(n,!0,e=>A.cursor(n.lineBlockAt(e.head).to)),Cc=({state:n,dispatch:e})=>(e(At(n,{anchor:0})),!0),Tc=({state:n,dispatch:e})=>(e(At(n,{anchor:n.doc.length})),!0),$c=({state:n,dispatch:e})=>(e(At(n,{anchor:n.selection.main.anchor,head:0})),!0),Rc=({state:n,dispatch:e})=>(e(At(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),ny=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),ry=({state:n,dispatch:e})=>{let t=vs(n).map(({from:i,to:r})=>A.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:A.create(t),userEvent:"select"})),!0},sy=({state:n,dispatch:e})=>{let t=Ji(n.selection,i=>{let r=Ce(n),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return A.range(l.to,l.from)}return i});return t.eq(n.selection)?!1:(e(At(n,t)),!0)};function Ff(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=n.moveVertically(l,e);if(a.heado.to){r.some(c=>c.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==i.ranges.length?!1:(n.dispatch(At(t,A.create(r,r.length-1))),!0)}const oy=n=>Ff(n,!1),ly=n=>Ff(n,!0),ay=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=A.create([t.main]):t.main.empty||(i=A.create([A.cursor(t.main.head)])),i?(e(At(n,i)),!0):!1};function Bn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(t="delete.forward",a=hr(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=hr(n,o,!1),l=hr(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:A.cursor(o,or(n)))i.between(e,e,(r,s)=>{re&&(e=t?s:r)});return e}const Df=(n,e,t)=>Bn(n,i=>{let r=i.from,{state:s}=n,o=s.doc.lineAt(r),l,a;if(t&&!e&&r>o.from&&rDf(n,!1,!0),Xf=n=>Df(n,!0,!1),Lf=(n,e)=>Bn(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=Ze(s.text,i-s.from,e)+s.from,c=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),h=o(c);if(l!=null&&h!=l)break;(c!=" "||i!=t.head)&&(l=h),i=a}return i}),Bf=n=>Lf(n,!1),cy=n=>Lf(n,!0),hy=n=>Bn(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headBn(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),fy=n=>Bn(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:re.of(["",""])},range:A.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},py=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:Ze(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:Ze(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:A.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function vs(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function qf(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of vs(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(A.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(A.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:A.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const my=({state:n,dispatch:e})=>qf(n,e,!1),Oy=({state:n,dispatch:e})=>qf(n,e,!0);function If(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of vs(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const gy=({state:n,dispatch:e})=>If(n,e,!1),yy=({state:n,dispatch:e})=>If(n,e,!0),Ay=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(vs(e).map(({from:r,to:s})=>(r>0?r--:s{let s;if(n.lineWrapping){let o=n.lineBlockAt(r.head),l=n.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,s)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function by(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Ce(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(H.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const Kc=zf(!1),Sy=zf(!0);function zf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&by(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new As(e,{simulateBreak:s,simulateDoubleBreak:!!a}),h=Ml(c,s);for(h==null&&(h=_i(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:A.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const xy=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new As(n,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=Ll(n,(s,o,l)=>{let a=Ml(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let c=/^\s*/.exec(s.text)[0],h=Tn(n,a);(c!=h||l.fromn.readOnly?!1:(e(n.update(Ll(n,(t,i)=>{i.push({from:t.from,insert:n.facet(ys)})}),{userEvent:"input.indent"})),!0),jf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ll(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=_i(r,n.tabSize),o=0,l=Tn(n,Math.max(0,s-qr(n)));for(;o(n.setTabFocusMode(),!0),vy=[{key:"Ctrl-b",run:Sf,shift:$f,preventDefault:!0},{key:"Ctrl-f",run:xf,shift:Rf},{key:"Ctrl-p",run:kf,shift:Mf},{key:"Ctrl-n",run:Qf,shift:Ef},{key:"Ctrl-a",run:I0,shift:ty},{key:"Ctrl-e",run:z0,shift:iy},{key:"Ctrl-d",run:Xf},{key:"Ctrl-h",run:nl},{key:"Ctrl-k",run:hy},{key:"Ctrl-Alt-h",run:Bf},{key:"Ctrl-o",run:dy},{key:"Ctrl-t",run:py},{key:"Ctrl-v",run:il}],ky=[{key:"ArrowLeft",run:Sf,shift:$f,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:M0,shift:V0,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:B0,shift:J0,preventDefault:!0},{key:"ArrowRight",run:xf,shift:Rf,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:E0,shift:Y0,preventDefault:!0},{mac:"Cmd-ArrowRight",run:q0,shift:ey,preventDefault:!0},{key:"ArrowUp",run:kf,shift:Mf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Cc,shift:$c},{mac:"Ctrl-ArrowUp",run:kc,shift:Qc},{key:"ArrowDown",run:Qf,shift:Ef,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Tc,shift:Rc},{mac:"Ctrl-ArrowDown",run:il,shift:Pc},{key:"PageUp",run:kc,shift:Qc},{key:"PageDown",run:il,shift:Pc},{key:"Home",run:L0,shift:_0,preventDefault:!0},{key:"Mod-Home",run:Cc,shift:$c},{key:"End",run:X0,shift:H0,preventDefault:!0},{key:"Mod-End",run:Tc,shift:Rc},{key:"Enter",run:Kc,shift:Kc},{key:"Mod-a",run:ny},{key:"Backspace",run:nl,shift:nl,preventDefault:!0},{key:"Delete",run:Xf,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Bf,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:cy,preventDefault:!0},{mac:"Mod-Backspace",run:uy,preventDefault:!0},{mac:"Mod-Delete",run:fy,preventDefault:!0}].concat(vy.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Qy=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:F0,shift:N0},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:D0,shift:G0},{key:"Alt-ArrowUp",run:my},{key:"Shift-Alt-ArrowUp",run:gy},{key:"Alt-ArrowDown",run:Oy},{key:"Shift-Alt-ArrowDown",run:yy},{key:"Mod-Alt-ArrowUp",run:oy},{key:"Mod-Alt-ArrowDown",run:ly},{key:"Escape",run:ay},{key:"Mod-Enter",run:Sy},{key:"Alt-l",mac:"Ctrl-l",run:ry},{key:"Mod-i",run:sy,preventDefault:!0},{key:"Mod-[",run:jf},{key:"Mod-]",run:Wf},{key:"Mod-Alt-\\",run:xy},{key:"Shift-Mod-k",run:Ay},{key:"Shift-Mod-\\",run:j0},{key:"Mod-/",run:O0},{key:"Alt-A",run:y0},{key:"Ctrl-m",mac:"Shift-Alt-m",run:wy}].concat(ky),Py={key:"Tab",run:Wf,shift:jf};class Vf{constructor(e,t,i,r){this.state=e,this.pos=t,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Ce(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),s=r.search(Nf(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Zc(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Cy(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Cy(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}function Ty(n,e){return t=>{for(let i=Ce(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}let Mc=class{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}};function yi(n){return n.selection.main.from}function Nf(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?n:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Bl=zt.define();function $y(n,e,t,i){let{main:r}=n.selection,s=t-r.from,o=i-r.from;return{...n.changeByRange(l=>{if(l!=r&&t!=i&&n.sliceDoc(l.from+s,l.from+o)!=n.sliceDoc(t,i))return{range:l};let a=n.toText(e);return{changes:{from:l.from+s,to:i==r.from?l.to:l.from+o,insert:a},range:A.cursor(l.from+s+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Ec=new WeakMap;function Ry(n){if(!Array.isArray(n))return n;let e=Ec.get(n);return e||Ec.set(n,e=Yf(n)),e}const Vr=W.define(),$n=W.define();class Ky{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(S=fl(k))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||v==1&&O||C==0&&v!=0)&&(t[u]==k||i[u]==k&&(f=!0)?o[u++]=b:o.length&&(y=!1)),C=v,b+=Qt(k)}return u==a&&o[0]==0&&y?this.result(-100+(f?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):u==a?this.result(-100+(f?-200:0)+-700+(y?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],s=0;for(let o of t){let l=o+(this.astral?Qt(Ne(i,o)):1);s&&r[s-1]==o?r[s-1]=l:(r[s++]=o,r[s++]=l)}return this.ret(e-i.length,r)}}class Zy{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:My,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Uc(e(i),t(i)),optionClass:(e,t)=>i=>Uc(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Uc(n,e){return n?e?n+" "+e:n:e}function My(n,e,t,i,r,s){let o=n.textDirection==fe.RTL,l=o,a=!1,c="top",h,u,f=e.left-r.left,d=r.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&f=m||b>e.top?h=t.bottom-e.top:(c="bottom",h=e.bottom-t.top)}let O=(e.bottom-e.top)/s.offsetHeight,y=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${h/O}px; max-width: ${u/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const ql=W.define();function Ey(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let c=0;ca&&o.appendChild(document.createTextNode(l.slice(a,h)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(l.slice(h,u))),f.className="cm-completionMatchedText",a=u}return at.position-i.position).map(t=>t.render)}function eo(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class Uy{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,l=e.state.facet(Ke);this.optionContent=Ey(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=eo(s.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:c}=e.state.field(t).open;for(let h=a.target,u;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(u=/-(\d+)$/.exec(h.id))&&+u[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;h!=null&&(e.dispatch({effects:ql.of(h)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Ke).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:$n.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:l}=i.open;(!r.open||r.open.options!=s)&&(this.range=eo(s.length,o,e.state.facet(Ke).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),l!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=eo(t.options.length,t.selected,this.view.state.facet(Ke).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,r)}).catch(l=>We(this.view.state,l,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&Dy(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottom{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;oi.from||i.from==0))if(s=f,typeof c!="string"&&c.header)r.appendChild(c.header(c));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=f}}const h=r.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");let u=this.optionClass(l);u&&(h.className=u);for(let f of this.optionContent){let d=f(l,this.view.state,this.view,a);d&&h.appendChild(d)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.tonew Uy(t,n,e)}function Dy(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function Fc(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Xy(n,e){let t=[],i=null,r=null,s=h=>{t.push(h);let{section:u}=h.completion;if(u){i||(i=[]);let f=typeof u=="string"?u:u.name;i.some(d=>d.name==f)||i.push(typeof u=="string"?{name:f}:u)}},o=e.facet(Ke);for(let h of n)if(h.hasResult()){let u=h.result.getMatch;if(h.result.filter===!1)for(let f of h.result.options)s(new Mc(f,h.source,u?u(f):[],1e9-t.length));else{let f=e.sliceDoc(h.from,h.to),d,p=o.filterStrict?new Zy(f):new Ky(f);for(let m of h.result.options)if(d=p.match(m.label)){let O=m.displayLabel?u?u(m,d.matched):[]:d.matched,y=d.score+(m.boost||0);if(s(new Mc(m,h.source,O,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:b}=m.section;r||(r=Object.create(null)),r[b]=Math.max(y,r[b]||-1e9)}}}}if(i){let h=Object.create(null),u=0,f=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.namef.score-u.score||c(u.completion,f.completion))){let u=h.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?l.push(h):Fc(h.completion)>Fc(a)&&(l[l.length-1]=h),a=h.completion}return l}class Ki{constructor(e,t,i,r,s,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ki(this.options,Dc(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,s,o){if(r&&!o&&e.some(c=>c.isPending))return r.setDisabled();let l=Xy(e,t);if(!l.length)return r&&e.some(c=>c.isPending)?r.setDisabled():null;let a=t.facet(Ke).selectOnOpen?0:-1;if(r&&r.selected!=a&&r.selected!=-1){let c=r.options[r.selected].completion;for(let h=0;hh.hasResult()?Math.min(c,h.from):c,1e8),create:Wy,above:s.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new Ki(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ki(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Yr{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Yr(Iy,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Ke),s=(i.override||t.languageDataAt("autocomplete",yi(t)).map(Ry)).map(a=>(this.active.find(h=>h.source==a)||new ut(a,this.active.some(h=>h.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((a,c)=>a==this.active[c])&&(s=this.active);let o=this.open,l=e.effects.some(a=>a.is(Il));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!Ly(s,this.active)||l?o=Ki.build(s,t,this.id,o,i,l):o&&o.disabled&&!s.some(a=>a.isPending)&&(o=null),!o&&s.every(a=>!a.isPending)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new ut(a.source,0):a));for(let a of e.effects)a.is(ql)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new Yr(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?By:qy}}function Ly(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const Iy=[];function Gf(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Bl);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class ut{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=Gf(e,t),r=this;(i&8||i&16&&this.touches(e))&&(r=new ut(r.source,0)),i&4&&r.state==0&&(r=new ut(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(Vr))r=new ut(r.source,1,s.value);else if(s.is($n))r=new ut(r.source,0);else if(s.is(Il))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(yi(e.state))}}class Fi extends ut{constructor(e,t,i,r,s,o){super(e,3,t),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=yi(e.state);if(l>o||!r||t&2&&(yi(e.startState)==this.from||lt.map(e))}}),Ge=Te.define({create(){return Yr.start()},update(n,e){return n.update(e)},provide:n=>[Os.from(n,e=>e.tooltip),R.contentAttributes.from(n,e=>e.attrs)]});function zl(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(Ge).active.find(r=>r.source==e.source);return i instanceof Fi?(typeof t=="string"?n.dispatch({...$y(n.state,t,i.from,i.to),annotations:Bl.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const Wy=Fy(Ge,zl);function ur(n,e="option"){return t=>{let i=t.state.field(Ge,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+r*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:ql.of(l)}),!0}}const jy=n=>{let e=n.state.field(Ge,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(Ge,!1)?(n.dispatch({effects:Vr.of(!0)}),!0):!1,Vy=n=>{let e=n.state.field(Ge,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:$n.of(null)}),!0)};class Yy{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ny=50,Gy=1e3,Hy=xe.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(Ge).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(Ge),t=n.state.facet(Ke);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Ge)==e)return;let i=n.transactions.some(s=>{let o=Gf(s,t);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;sNy&&Date.now()-o.time>Gy){for(let l of o.context.abortListeners)try{l()}catch(a){We(this.view.state,a)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(s=>s.effects.some(o=>o.is(Vr)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of n.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(Ge);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ke).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=yi(e),i=new Vf(e,t,n.explicit,this.view),r=new Yy(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:$n.of(null)}),We(this.view.state,s)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ke).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Ke),i=this.view.state.field(Ge);for(let r=0;rl.source==s.active.source);if(o&&o.isPending)if(s.done==null){let l=new ut(s.active.source,0);for(let a of s.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Il.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Ge,!1);if(e&&e.tooltip&&this.view.state.facet(Ke).closeOnBlur){let t=e.open&&Uu(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:$n.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Vr.of(!1)}),20),this.composing=0}}}),_y=typeof navigator=="object"&&/Win/.test(navigator.platform),Jy=si.highest(R.domEventHandlers({keydown(n,e){let t=e.state.field(Ge,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(_y&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],r=t.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(n.key)>-1&&zl(e,i),!1}})),Hf=R.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class eA{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}}class Wl{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,De.TrackDel),i=e.mapPos(this.to,1,De.TrackDel);return t==null||i==null?null:new Wl(this.field,t,i)}}class jl{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],r=[t],s=e.doc.lineAt(t),o=/^\s*/.exec(s.text)[0];for(let a of this.lines){if(i.length){let c=o,h=/^\t*/.exec(a)[0].length;for(let u=0;unew Wl(a.field,r[a.line]+a.from,r[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],r=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=s[1]?+s[1]:null,a=s[2]||s[3]||"",c=-1;l===0&&(l=1e9);let h=a.replace(/\\[{}]/g,u=>u[1]);for(let u=0;u=c&&f.field++}for(let u of r)if(u.line==i.length&&u.from>s.index){let f=s[2]?3+(s[1]||"").length:2;u.from-=f,u.to-=f}r.push(new eA(c,i.length,s.index,s.index+h.length)),o=o.slice(0,s.index)+a+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(l,a,c)=>{for(let h of r)h.line==i.length&&h.from>c&&(h.from--,h.to--);return a}),i.push(o)}return new jl(i,r)}}let tA=B.widget({widget:new class extends Ut{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),iA=B.mark({class:"cm-snippetField"});class en{constructor(e,t){this.ranges=e,this.active=t,this.deco=B.set(e.map(i=>(i.from==i.to?tA:iA).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;t.push(r)}return new en(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const qn=W.define({map(n,e){return n&&n.map(e)}}),nA=W.define(),Rn=Te.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(qn))return t.value;if(t.is(nA)&&n)return new en(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>R.decorations.from(n,e=>e?e.deco:B.none)});function Vl(n,e){return A.create(n.filter(t=>t.field==e).map(t=>A.range(t.from,t.to)))}function rA(n){let e=jl.parse(n);return(t,i,r,s)=>{let{text:o,ranges:l}=e.instantiate(t.state,r),{main:a}=t.state.selection,c={changes:{from:r,to:s==a.from?a.to:s,insert:re.of(o)},scrollIntoView:!0,annotations:i?[Bl.of(i),Pe.userEvent.of("input.complete")]:void 0};if(l.length&&(c.selection=Vl(l,0)),l.some(h=>h.field>0)){let h=new en(l,0),u=c.effects=[qn.of(h)];t.state.field(Rn,!1)===void 0&&u.push(W.appendConfig.of([Rn,cA,hA,Hf]))}t.dispatch(t.state.update(c))}}function _f(n){return({state:e,dispatch:t})=>{let i=e.field(Rn,!1);if(!i||n<0&&i.active==0)return!1;let r=i.active+n,s=n>0&&!i.ranges.some(o=>o.field==r+n);return t(e.update({selection:Vl(i.ranges,r),effects:qn.of(s?null:new en(i.ranges,r)),scrollIntoView:!0})),!0}}const sA=({state:n,dispatch:e})=>n.field(Rn,!1)?(e(n.update({effects:qn.of(null)})),!0):!1,oA=_f(1),lA=_f(-1),aA=[{key:"Tab",run:oA,shift:lA},{key:"Escape",run:sA}],Xc=K.define({combine(n){return n.length?n[0]:aA}}),cA=si.highest(ms.compute([Xc],n=>n.facet(Xc)));function Ye(n,e){return{...e,apply:rA(n)}}const hA=R.domEventHandlers({mousedown(n,e){let t=e.state.field(Rn,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let r=t.ranges.find(s=>s.from<=i&&s.to>=i);return!r||r.field==t.active?!1:(e.dispatch({selection:Vl(t.ranges,r.field),effects:qn.of(t.ranges.some(s=>s.field>r.field)?new en(t.ranges,r.field):null),scrollIntoView:!0}),!0)}}),Kn={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},mi=W.define({map(n,e){let t=e.mapPos(n,-1,De.TrackAfter);return t??void 0}}),Yl=new class extends Jt{};Yl.startSide=1;Yl.endSide=-1;const Jf=Te.define({create(){return N.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(mi)&&(n=n.update({add:[Yl.range(t.value,t.value+1)]}));return n}});function uA(){return[dA,Jf]}const io="()[]{}<>«»»«[]{}";function ed(n){for(let e=0;e{if((fA?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&Qt(Ne(i,0))==1||e!=r.from||t!=r.to)return!1;let s=OA(n.state,i);return s?(n.dispatch(s),!0):!1}),pA=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=td(n,n.selection.main.head).brackets||Kn.brackets,r=null,s=n.changeByRange(o=>{if(o.empty){let l=gA(n.doc,o.head);for(let a of i)if(a==l&&ks(n.doc,o.head)==ed(Ne(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:A.cursor(o.head-a.length)}}return{range:r=o}});return r||e(n.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},mA=[{key:"Backspace",run:pA}];function OA(n,e){let t=td(n,n.selection.main.head),i=t.brackets||Kn.brackets;for(let r of i){let s=ed(Ne(r,0));if(e==r)return s==r?bA(n,r,i.indexOf(r+r+r)>-1,t):yA(n,r,s,t.before||Kn.before);if(e==s&&id(n,n.selection.main.from))return AA(n,r,s)}return null}function id(n,e){let t=!1;return n.field(Jf).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function ks(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Qt(Ne(t,0)))}function gA(n,e){let t=n.sliceString(e-2,e);return Qt(Ne(t,0))==t.length?t:t.slice(1)}function yA(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:mi.of(o.to+e.length),range:A.range(o.anchor+e.length,o.head+e.length)};let l=ks(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:mi.of(o.head+e.length),range:A.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function AA(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&ks(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:A.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function bA(n,e,t,i){let r=i.stringPrefixes||Kn.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:mi.of(l.to+e.length),range:A.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=ks(n.doc,a),h;if(c==e){if(Lc(n,a))return{changes:{insert:e+e,from:a},effects:mi.of(a+e.length),range:A.cursor(a+e.length)};if(id(n,a)){let f=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+f.length,insert:f},range:A.cursor(a+f.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(h=Bc(n,a-2*e.length,r))>-1&&Lc(n,h))return{changes:{insert:e+e+e+e,from:a},effects:mi.of(a+e.length),range:A.cursor(a+e.length)};if(n.charCategorizer(a)(c)!=ye.Word&&Bc(n,a,r)>-1&&!SA(n,a,e,r))return{changes:{insert:e+e,from:a},effects:mi.of(a+e.length),range:A.cursor(a+e.length)}}return{range:s=l}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Lc(n,e){let t=Ce(n).resolveInner(e+1);return t.parent&&t.from==e}function SA(n,e,t,i){let r=Ce(n).resolveInner(e,-1),s=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let h=r.firstChild;for(;h&&h.from==r.from&&h.to-h.from>t.length+a;){if(n.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function Bc(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ye.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=ye.Word)return s}return-1}function xA(n={}){return[Jy,Ge,Ke.of(n),Hy,wA,Hf]}const nd=[{key:"Ctrl-Space",run:to},{mac:"Alt-`",run:to},{mac:"Alt-i",run:to},{key:"Escape",run:Vy},{key:"ArrowDown",run:ur(!0)},{key:"ArrowUp",run:ur(!1)},{key:"PageDown",run:ur(!0,"page")},{key:"PageUp",run:ur(!1,"page")},{key:"Enter",run:jy}],wA=si.highest(ms.computeN([Ke],n=>n.facet(Ke).defaultKeymap?[nd]:[]));var qc={};class Nr{constructor(e,t,i,r,s,o,l,a,c,h=0,u){this.p=e,this.stack=t,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=h,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new Nr(e,[],t,i,i,0,[],0,r?new Ic(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,t,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,t,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,t,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let l=o.stateFlag(s,1);!l&&(r>i||t<=o.maxNode)&&(this.reducePos=r),this.pushState(s,l?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,r,4)}else this.pos=r,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,r,4)}apply(e,t,i,r){e&65536?this.reduce(e):this.shift(e,t,i,r)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new Nr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new vA(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;sa&1&&l==o)||r.push(t[s],o)}t=r}let i=[];for(let r=0;r>19,r=t&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,s+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}}class Ic{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class vA{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class Gr{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Gr(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Gr(this.stack,this.pos,this.index)}}function dn(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}t?t[r++]=s:t=new e(s)}return t}class kr{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const zc=new kr;class kA{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=zc,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;si.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t=this.chunk2Pos&&il.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=zc,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}}class Di{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;rd(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}Di.prototype.contextual=Di.prototype.fallback=Di.prototype.extend=!1;class rl{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?dn(e):e}token(e,t){let i=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(rd(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}}rl.prototype.contextual=Di.prototype.fallback=Di.prototype.extend=!1;class In{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function rd(n,e,t,i,r,s){let o=0,l=1<0){let p=n[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||QA(p,e.token.value,r,s))){e.acceptToken(p);break}}let h=e.next,u=0,f=n[o+2];if(e.next<0&&f>u&&n[c+f*3-3]==65535){o=n[c+f*3-1];continue e}for(;u>1,p=c+d+(d<<1),m=n[p],O=n[p+1]||65536;if(h=O)u=d+1;else{o=n[p+2],e.advance();continue e}}break}}function Wc(n,e,t){for(let i=e,r;(r=n[i])!=65535;i++)if(r==t)return i-e;return-1}function QA(n,e,t,i){let r=Wc(t,i,e);return r<0||Wc(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class PA{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?jc(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?jc(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof ke){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class CA{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new kr)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;cu.end+25&&(a=Math.max(u.lookAhead,a)),u.value!=0)){let f=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!h.extend&&(i=u,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new kr,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new kr,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let s=0;se.bufferLength*4?new PA(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)i.push(l);else{if(this.advanceStack(l,i,e))continue;{r||(r=[],s=[]),r.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!i.length){let o=r&&KA(r);if(o)return nt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw nt&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return nt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,h=c?e.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let f=this.parser.nodeSet.types[u.type.id]==u.type?s.getGoto(e.state,u.type.id):-1;if(f>-1&&u.length&&(!c||(u.prop(H.contextHash)||0)==h))return e.useNode(u,f),nt&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(u.type.id)})`),!0;if(!(u instanceof ke)||u.children.length==0||u.positions[0]>0)break;let d=u.children[0];if(d instanceof ke&&u.positions[0]==0)u=d;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),nt&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let c=0;cr?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Vc(e,t),!0}}runRecovery(e,t,i){let r=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),nt&&console.log(h+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let u=l.split(),f=h;for(let d=0;d<10&&u.forceReduce()&&(nt&&console.log(f+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));d++)nt&&(f=this.stackID(u)+" -> ");for(let d of l.recoverByInsert(a))nt&&console.log(h+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),nt&&console.log(h+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Vc(l,i)):(!r||r.scoren;class RA{constructor(e){this.start=e.start,this.shift=e.shift||ro,this.reduce=e.reduce||ro,this.reuse=e.reuse||ro,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Hr extends Yu{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;le.topRules[l][1]),r=[];for(let l=0;l=0)s(h,a,l[c++]);else{let u=l[c+-h];for(let f=-h;f>0;f--)s(l[c++],a,u);c++}}}this.nodeSet=new Tl(t.map((l,a)=>et.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:r[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=zu;let o=dn(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Di(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let r=new TA(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],l=o&1,a=r[s++];if(l&&i)return a;for(let c=s+(o>>1);s0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),r=i?t(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Ft(this.data,s+2);else break;r=t(Ft(this.data,s+1))}return r}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Ft(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[i],r)}}return t}configure(e){let t=Object.assign(Object.create(Hr.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(l=>l.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[r]=Yc(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;si)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const ZA=316,MA=317,Nc=1,EA=2,UA=3,FA=4,DA=318,XA=320,LA=321,BA=5,qA=6,IA=0,sl=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],sd=125,zA=59,ol=47,WA=42,jA=43,VA=45,YA=60,NA=44,GA=63,HA=46,_A=91,JA=new RA({start:!1,shift(n,e){return e==BA||e==qA||e==XA?n:e==LA},strict:!1}),eb=new In((n,e)=>{let{next:t}=n;(t==sd||t==-1||e.context)&&n.acceptToken(DA)},{contextual:!0,fallback:!0}),tb=new In((n,e)=>{let{next:t}=n,i;sl.indexOf(t)>-1||t==ol&&((i=n.peek(1))==ol||i==WA)||t!=sd&&t!=zA&&t!=-1&&!e.context&&n.acceptToken(ZA)},{contextual:!0}),ib=new In((n,e)=>{n.next==_A&&!e.context&&n.acceptToken(MA)},{contextual:!0}),nb=new In((n,e)=>{let{next:t}=n;if(t==jA||t==VA){if(n.advance(),t==n.next){n.advance();let i=!e.context&&e.canShift(Nc);n.acceptToken(i?Nc:EA)}}else t==GA&&n.peek(1)==HA&&(n.advance(),n.advance(),(n.next<48||n.next>57)&&n.acceptToken(UA))},{contextual:!0});function so(n,e){return n>=65&&n<=90||n>=97&&n<=122||n==95||n>=192||!e&&n>=48&&n<=57}const rb=new In((n,e)=>{if(n.next!=YA||!e.dialectEnabled(IA)||(n.advance(),n.next==ol))return;let t=0;for(;sl.indexOf(n.next)>-1;)n.advance(),t++;if(so(n.next,!0)){for(n.advance(),t++;so(n.next,!1);)n.advance(),t++;for(;sl.indexOf(n.next)>-1;)n.advance(),t++;if(n.next==NA)return;for(let i=0;;i++){if(i==7){if(!so(n.next,!0))return;break}if(n.next!="extends".charCodeAt(i))break;n.advance(),t++}}n.acceptToken(FA,-t)}),sb=Nu({"get set async static":g.modifier,"for while do if else switch try catch finally return throw break continue default case defer":g.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":g.operatorKeyword,"let var const using function class extends":g.definitionKeyword,"import export from":g.moduleKeyword,"with debugger new":g.keyword,TemplateString:g.special(g.string),super:g.atom,BooleanLiteral:g.bool,this:g.self,null:g.null,Star:g.modifier,VariableName:g.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":g.function(g.variableName),VariableDefinition:g.definition(g.variableName),Label:g.labelName,PropertyName:g.propertyName,PrivatePropertyName:g.special(g.propertyName),"CallExpression/MemberExpression/PropertyName":g.function(g.propertyName),"FunctionDeclaration/VariableDefinition":g.function(g.definition(g.variableName)),"ClassDeclaration/VariableDefinition":g.definition(g.className),"NewExpression/VariableName":g.className,PropertyDefinition:g.definition(g.propertyName),PrivatePropertyDefinition:g.definition(g.special(g.propertyName)),UpdateOp:g.updateOperator,"LineComment Hashbang":g.lineComment,BlockComment:g.blockComment,Number:g.number,String:g.string,Escape:g.escape,ArithOp:g.arithmeticOperator,LogicOp:g.logicOperator,BitOp:g.bitwiseOperator,CompareOp:g.compareOperator,RegExp:g.regexp,Equals:g.definitionOperator,Arrow:g.function(g.punctuation),": Spread":g.punctuation,"( )":g.paren,"[ ]":g.squareBracket,"{ }":g.brace,"InterpolationStart InterpolationEnd":g.special(g.brace),".":g.derefOperator,", ;":g.separator,"@":g.meta,TypeName:g.typeName,TypeDefinition:g.definition(g.typeName),"type enum interface implements namespace module declare":g.definitionKeyword,"abstract global Privacy readonly override":g.modifier,"is keyof unique infer asserts":g.operatorKeyword,JSXAttributeValue:g.attributeValue,JSXText:g.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":g.angleBracket,"JSXIdentifier JSXNameSpacedName":g.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":g.attributeName,"JSXBuiltin/JSXIdentifier":g.standard(g.tagName)}),ob={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},lb={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},ab={__proto__:null,"<":193},cb=Hr.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#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emplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:JA,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[sb],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!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O(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:n=>ob[n]||-1},{term:343,get:n=>lb[n]||-1},{term:95,get:n=>ab[n]||-1}],tokenPrec:15201}),od=[Ye("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Ye("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Ye("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Ye("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Ye("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Ye(`try { - \${} -} catch (\${error}) { - \${} -}`,{label:"try",detail:"/ catch block",type:"keyword"}),Ye("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Ye(`if (\${}) { - \${} -} else { - \${} -}`,{label:"if",detail:"/ else block",type:"keyword"}),Ye(`class \${name} { - constructor(\${params}) { - \${} - } -}`,{label:"class",detail:"definition",type:"keyword"}),Ye('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Ye('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],hb=od.concat([Ye("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Ye("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Ye("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Gc=new dg,ld=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function cn(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const ub=["FunctionDeclaration"],fb={FunctionDeclaration:cn("function"),ClassDeclaration:cn("class"),ClassExpression:()=>!0,EnumDeclaration:cn("constant"),TypeAliasDeclaration:cn("type"),NamespaceDeclaration:cn("namespace"),VariableDefinition(n,e){n.matchContext(ub)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function ad(n,e){let t=Gc.get(e);if(t)return t;let i=[],r=!0;function s(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(be.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=fb[o.name];if(l&&l(o,s)||ld.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of ad(n,o.node))i.push(l);return!1}}),Gc.set(e,i),i}const Hc=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,cd=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function db(n){let e=Ce(n.state).resolveInner(n.pos,-1);if(cd.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Hc.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let r=e;r;r=r.parent)ld.has(r.name)&&(i=i.concat(ad(n.state.doc,r)));return{options:i,from:t?e.from:n.pos,validFor:Hc}}const Lt=Lr.define({name:"javascript",parser:cb.configure({props:[ef.add({IfStatement:Ns({except:/^\s*({|else\b)/}),TryStatement:Ns({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Mg,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:Zg({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Ns({except:/^\s*{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),rf.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Dg,BlockComment(n){return{from:n.from+2,to:n.to-2}},JSXElement(n){let e=n.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let t=n.lastChild;return{from:e.to,to:t.type.isError?n.to:t.from}},"JSXSelfClosingTag JSXOpenTag"(n){var e;let t=(e=n.firstChild)===null||e===void 0?void 0:e.nextSibling,i=n.lastChild;return!t||t.type.isError?null:{from:t.to,to:i.type.isError?n.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),hd={test:n=>/^JSX/.test(n.name),facet:_u({commentTokens:{block:{open:"{/*",close:"*/}"}}})},pb=Lt.configure({dialect:"ts"},"typescript"),mb=Lt.configure({dialect:"jsx",props:[Zl.add(n=>n.isTop?[hd]:void 0)]}),Ob=Lt.configure({dialect:"jsx ts",props:[Zl.add(n=>n.isTop?[hd]:void 0)]},"typescript");let ud=n=>({label:n,type:"keyword"});const fd="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(ud),gb=fd.concat(["declare","implements","private","protected","public"].map(ud));function yb(n={}){let e=n.jsx?n.typescript?Ob:mb:n.typescript?pb:Lt,t=n.typescript?hb.concat(gb):od.concat(fd);return new kg(e,[Lt.data.of({autocomplete:Ty(cd,Yf(t))}),Lt.data.of({autocomplete:db}),n.jsx?Sb:[]])}function Ab(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function _c(n,e,t=n.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const bb=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Sb=R.inputHandler.of((n,e,t,i,r)=>{if((bb?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!Lt.isActiveAt(n.state,e,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(a=>{var c;let{head:h}=a,u=Ce(o).resolveInner(h-1,-1),f;if(u.name=="JSXStartTag"&&(u=u.parent),!(o.doc.sliceString(h-1,h)!=i||u.name=="JSXAttributeValue"&&u.to>h)){if(i==">"&&u.name=="JSXFragmentTag")return{range:a,changes:{from:h,insert:""}};if(i=="/"&&u.name=="JSXStartCloseTag"){let d=u.parent,p=d.parent;if(p&&d.from==h-2&&((f=_c(o.doc,p.firstChild,h))||((c=p.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let m=`${f}>`;return{range:A.cursor(h+m.length,-1),changes:{from:h,insert:m}}}}else if(i==">"){let d=Ab(u);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(f=_c(o.doc,d,h)))return{range:a,changes:{from:h,insert:``}}}}return{range:a}});return l.changes.empty?!1:(n.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Jc=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Yi{constructor(e,t,i=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=s?l=>s(Jc(l)):Jc,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Ne(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=fl(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Qt(e);let r=this.normalize(t);if(r.length)for(let s=0,o=i,l=!0;;s++){let a=r.charCodeAt(s),c=this.match(a,o,l,this.bufferPos+this.bufferStart,s==r.length-1);if(c)return this.value=c,this;if(s==r.length-1)break;l&&sthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=_r(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||r.to<=t){let l=new Xi(t,e.sliceString(t,i));return oo.set(e,l),l}if(r.from==t&&r.to==i)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,precise:!0,match:t},this.matchPos=_r(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Xi.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(pd.prototype[Symbol.iterator]=md.prototype[Symbol.iterator]=function(){return this});function xb(n){try{return new RegExp(n,Nl),!0}catch{return!1}}function _r(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}const wb=n=>{let{state:e}=n,t=String(e.doc.lineAt(n.state.selection.main.head).number),{close:i,result:r}=VO(n,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return r.then(s=>{let o=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!o){n.dispatch({effects:i});return}let l=e.doc.lineAt(e.selection.main.head),[,a,c,h,u]=o,f=h?+h.slice(1):0,d=c?+c:l.number;if(c&&u){let O=d/100;a&&(O=O*(a=="-"?-1:1)+l.number/e.doc.lines),d=Math.round(e.doc.lines*O)}else c&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=e.doc.line(Math.max(1,Math.min(e.doc.lines,d))),m=A.cursor(p.from+Math.max(0,Math.min(f,p.length)));n.dispatch({effects:[i,R.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0},vb={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},kb=K.define({combine(n){return yt(n,vb,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Qb(n){return[Rb,$b]}const Pb=B.mark({class:"cm-selectionMatch"}),Cb=B.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function eh(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=ye.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=ye.Word)}function Tb(n,e,t,i){return n(e.sliceDoc(t,t+1))==ye.Word&&n(e.sliceDoc(i-1,i))==ye.Word}const $b=xe.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(kb),{state:t}=n,i=t.selection;if(i.ranges.length>1)return B.none;let r=i.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return B.none;let a=t.wordAt(r.head);if(!a)return B.none;o=t.charCategorizer(r.head),s=t.sliceDoc(a.from,a.to)}else{let a=r.to-r.from;if(a200)return B.none;if(e.wholeWords){if(s=t.sliceDoc(r.from,r.to),o=t.charCategorizer(r.head),!(eh(o,t,r.from,r.to)&&Tb(o,t,r.from,r.to)))return B.none}else if(s=t.sliceDoc(r.from,r.to),!s)return B.none}let l=[];for(let a of n.visibleRanges){let c=new Yi(t.doc,s,a.from,a.to);for(;!c.next().done;){let{from:h,to:u}=c.value;if((!o||eh(o,t,h,u))&&(r.empty&&h<=r.from&&u>=r.to?l.push(Cb.range(h,u)):(h>=r.to||u<=r.from)&&l.push(Pb.range(h,u)),l.length>e.maxMatches))return B.none}}return B.set(l)}},{decorations:n=>n.decorations}),Rb=R.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Kb=({state:n,dispatch:e})=>{let{selection:t}=n,i=A.create(t.ranges.map(r=>n.wordAt(r.head)||A.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function Zb(n,e){let{main:t,ranges:i}=n.selection,r=n.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,l=new Yi(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Yi(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(s){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const Mb=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return Kb({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=i))return!1;let r=Zb(n,i);return r?(e(n.update({selection:n.selection.addRange(A.range(r.from,r.to),!1),effects:R.scrollIntoView(r.to)})),!0):!1},tn=K.define({combine(n){return yt(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Yb(e),scrollToMatch:e=>R.scrollIntoView(e)})}});class Od{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||xb(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` -`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Lb(this):new Fb(this)}getCursor(e,t=0,i){let r=e.doc?e:_.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Pi(this,r,t,i):Qi(this,r,t,i)}}class gd{constructor(e){this.spec=e}}function Eb(n,e,t){return(i,r,s,o)=>{if(t&&!t(i,r,s,o))return!1;let l=i>=o&&r<=o+s.length?s.slice(i-o,r-o):e.doc.sliceString(i,r);return n(l,e,i,r)}}function Qi(n,e,t,i){let r;return n.wholeWord&&(r=Ub(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(r=Eb(n.test,e,r)),new Yi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase(),r)}function Ub(n,e){return(t,i,r,s)=>((s>t||s+r.length=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Qi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function Db(n,e,t){return(i,r,s)=>(!t||t(i,r,s))&&n(s[0],e,i,r)}function Pi(n,e,t,i){let r;return n.wholeWord&&(r=Xb(e.charCategorizer(e.selection.main.head))),n.test&&(r=Db(n.test,e,r)),new pd(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:r},t,i)}function Jr(n,e){return n.slice(Ze(n,e,!1),e)}function es(n,e){return n.slice(e,Ze(n,e))}function Xb(n){return(e,t,i)=>!i[0].length||(n(Jr(i.input,i.index))!=ye.Word||n(es(i.input,i.index))!=ye.Word)&&(n(es(i.input,i.index+i[0].length))!=ye.Word||n(Jr(i.input,i.index+i[0].length))!=ye.Word)}class Lb extends gd{nextMatch(e,t,i){let r=Pi(this.spec,e,i,e.doc.length).next();return r.done&&(r=Pi(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let s=Math.max(t,i-r*1e4),o=Pi(this.spec,e,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let s=+i.slice(0,r);if(s>0&&s=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Pi(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const Zn=W.define(),Gl=W.define(),Ht=Te.define({create(n){return new lo(ll(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Zn)?n=new lo(t.value.create(),n.panel):t.is(Gl)&&(n=new lo(n.query,t.value?Hl:null));return n},provide:n=>ji.from(n,e=>e.panel)});class lo{constructor(e,t){this.query=e,this.panel=t}}const Bb=B.mark({class:"cm-searchMatch"}),qb=B.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Ib=xe.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Ht))}update(n){let e=n.state.field(Ht);(e!=n.startState.field(Ht)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return B.none;let{view:t}=this,i=new Bt;for(let r=0,s=t.visibleRanges,o=s.length;rs[r+1].from-500;)a=s[++r].to;n.highlight(t.state,l,a,(c,h)=>{let u=t.state.selection.ranges.some(f=>f.from==c&&f.to==h);i.add(c,h,u?qb:Bb)})}return i.finish()}},{decorations:n=>n.decorations});function zn(n){return e=>{let t=e.state.field(Ht,!1);return t&&t.query.spec.valid?n(e,t):bd(e)}}const ts=zn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let r=A.single(i.from,i.to),s=n.state.facet(tn);return n.dispatch({selection:r,effects:[_l(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),Ad(n),!0}),is=zn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let s=A.single(r.from,r.to),o=n.state.facet(tn);return n.dispatch({selection:s,effects:[_l(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),Ad(n),!0}),zb=zn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:A.create(t.map(i=>A.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Wb=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,s=[],o=0;for(let l=new Yi(n.doc,n.sliceDoc(i,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(A.range(l.value.from,l.value.to))}return e(n.update({selection:A.create(s,o),userEvent:"select.search.matches"})),!0},th=zn((n,{query:e})=>{let{state:t}=n,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,i,i);if(!s)return!1;let o=s,l=[],a,c,h=[];o.precise?o.from==i&&o.to==r&&(c=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),h.push(R.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let u=n.state.changes(l);return o&&(a=A.single(o.from,o.to).map(u),h.push(_l(n,o)),h.push(t.facet(tn).scrollToMatch(a.main,n))),n.dispatch({changes:u,selection:a,effects:h,userEvent:"input.replace"}),!0}),jb=zn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let r of e.matchAll(n.state,1e9)){let{from:s,to:o,precise:l}=r;l&&t.push({from:s,to:o,insert:e.getReplacement(r)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:R.announce.of(i),userEvent:"input.replace.all"}),!0});function Hl(n){return n.state.facet(tn).createPanel(n)}function ll(n,e){var t,i,r,s,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let c=n.facet(tn);return new Od({search:((t=e?.literal)!==null&&t!==void 0?t:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:c.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function yd(n){let e=Fu(n,Hl);return e&&e.dom.querySelector("[main-field]")}function Ad(n){let e=yd(n);e&&e==n.root.activeElement&&e.select()}const bd=n=>{let e=n.state.field(Ht,!1);if(e&&e.panel){let t=yd(n);if(t&&t!=n.root.activeElement){let i=ll(n.state,e.query.spec);i.valid&&n.dispatch({effects:Zn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Gl.of(!0),e?Zn.of(ll(n.state,e.query.spec)):W.appendConfig.of(Gb)]});return!0},Sd=n=>{let e=n.state.field(Ht,!1);if(!e||!e.panel)return!1;let t=Fu(n,Hl);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Gl.of(!1)}),!0},Vb=[{key:"Mod-f",run:bd,scope:"editor search-panel"},{key:"F3",run:ts,shift:is,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ts,shift:is,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Sd,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Wb},{key:"Mod-Alt-g",run:wb},{key:"Mod-d",run:Mb,preventDefault:!0}];class Yb{constructor(e){this.view=e;let t=this.query=e.state.field(Ht).query.spec;this.commit=this.commit.bind(this),this.searchField=he("input",{value:t.search,placeholder:rt(e,"Find"),"aria-label":rt(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=he("input",{value:t.replace,placeholder:rt(e,"Replace"),"aria-label":rt(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=he("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=he("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=he("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return he("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=he("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>ts(e),[rt(e,"next")]),i("prev",()=>is(e),[rt(e,"previous")]),i("select",()=>zb(e),[rt(e,"all")]),he("label",null,[this.caseField,rt(e,"match case")]),he("label",null,[this.reField,rt(e,"regexp")]),he("label",null,[this.wordField,rt(e,"by word")]),...e.state.readOnly?[]:[he("br"),this.replaceField,i("replace",()=>th(e),[rt(e,"replace")]),i("replaceAll",()=>jb(e),[rt(e,"replace all")])],he("button",{name:"close",onclick:()=>Sd(e),"aria-label":rt(e,"close"),type:"button"},["×"])])}commit(){let e=new Od({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Zn.of(e)}))}keydown(e){rO(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?is:ts)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),th(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Zn)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(tn).top}}function rt(n,e){return n.state.phrase(e)}const fr=30,dr=/[\s\.,:;?!]/;function _l(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),r=n.state.doc.lineAt(t).to,s=Math.max(i.from,e-fr),o=Math.min(r,t+fr),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;al.length-fr;a--)if(!dr.test(l[a-1])&&dr.test(l[a])){l=l.slice(0,a);break}}return R.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const Nb=R.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Gb=[Ht,si.low(Ib),Nb];class ih{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class di{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(Kt).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Bt,l=[],a=0,c=i.doc.iter(),h=0,u=i.doc.length;for(let d=0;;){let p=d==s.length?null:s[d];if(!p&&!l.length)break;let m,O;if(l.length)m=a,O=l.reduce((x,C)=>Math.min(x,C.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>u)break;O=p.to,l.push(p),d++}for(;dx.from||x.to==m))l.push(x),d++,O=Math.min(x.to,O);else{O=Math.min(x.from,O);break}}O=Math.min(O,u);let y=!1;if(l.some(x=>x.from==m&&(x.to==O||O==u))&&(y=m==O,!y&&O-m<10)){let x=m-(h+c.value.length);x>0&&(c.next(x),h=m);for(let C=m;;){if(C>=O){y=!0;break}if(!c.lineBreak&&h+c.value.length>C)break;C=h+c.value.length,h+=c.value.length,c.next()}}let b=Td(l);if(y)o.add(m,m,B.widget({widget:new n1(b),diagnostics:l.slice()}));else{let x=l.reduce((C,k)=>k.markClass?C+" "+k.markClass:C,"");o.add(m,O,B.mark({class:"cm-lintRange cm-lintRange-"+b+x,diagnostics:l.slice(),inclusiveEnd:l.some(C=>C.to>O)}))}if(a=O,a==u)break;for(let x=0;x{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new ih(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ih(i.from,s,i.diagnostic)}}),i}function xd(n,e){let t=e.pos,i=e.end||t,r=n.state.facet(Kt).hideOn(n,t,i);if(r!=null)return r;let s=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(Qs))||n.changes.touchesRange(s.from,Math.max(s.to,i)))}function Hb(n,e){return n.field(Ot,!1)?e:e.concat(W.appendConfig.of(Kd))}function wd(n,e){return{effects:Hb(n,[Qs.of(e)])}}const Qs=W.define(),vd=W.define(),kd=W.define(),Ot=Te.define({create(){return new di(B.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,r=n.panel;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);i=Ni(t,n.selected.diagnostic,s)||Ni(t,null,s)}!t.size&&r&&e.state.facet(Kt).autoPanel&&(r=null),n=new di(t,r,i)}for(let t of e.effects)if(t.is(Qs)){let i=e.state.facet(Kt).autoPanel?t.value.length?ns.open:null:n.panel;n=di.init(t.value,i,e.state)}else t.is(vd)?n=new di(n.diagnostics,t.value?ns.open:null,n.selected):t.is(kd)&&(n=new di(n.diagnostics,n.panel,t.value));return n},provide:n=>[ji.from(n,e=>e.panel),R.decorations.from(n,e=>e.diagnostics)]}),_b=B.mark({class:"cm-lintRange cm-lintRange-active"});function Jb(n,e,t){let{diagnostics:i}=n.state.field(Ot),r,s=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,c,{spec:h})=>{if(e>=a&&e<=c&&(a==c||(e>a||t>0)&&(eCd(n,t,!1)))}const nh=n=>{let e=n.state.field(Ot,!1);return!e||!e.panel?!1:(n.dispatch({effects:vd.of(!1)}),!0)},e1=xe.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(Kt);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(nPromise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(wd(this.view.state,i.reduce((r,s)=>r.concat(s))))},i=>{We(this.view.state,i)})}}update(n){let e=n.state.facet(Kt);(n.docChanged||e!=n.startState.facet(Kt)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function t1(n,e,t){let i=[],r=-1;for(let s of n)s.then(o=>{i.push(o),clearTimeout(r),i.length==n.length?e(i):r=setTimeout(()=>e(i),200)},t)}const Kt=K.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...yt(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:rh,tooltipFilter:rh,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,r,s)=>e(i,r,s)||t(i,r,s):e:t,autoPanel:(e,t)=>e||t})}}});function rh(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function i1(n,e={}){return[Kt.of({source:n,config:e}),e1,Kd]}function Pd(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;is.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Cd(n,e,t){var i;let r=t?Pd(e.actions):[];return he("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},he("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Ni(n.state.field(Ot).diagnostics,e);p&&s.apply(n,p.from,p.to)},{name:c}=s,h=r[o]?c.indexOf(r[o]):-1,u=h<0?c:[c.slice(0,h),he("u",c.slice(h,h+1)),c.slice(h+1)],f=s.markClass?" "+s.markClass:"";return he("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:a,onmousedown:a,"aria-label":` Action: ${c}${h<0?"":` (access key "${r[o]})"`}.`},u)}),e.source&&he("div",{class:"cm-diagnosticSource"},e.source))}class n1 extends Ut{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return he("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class sh{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Cd(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ns{constructor(e){this.view=e,this.items=[];let t=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)nh(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=Pd(s.actions);for(let l=0;l{for(let s=0;snh(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ot).selected;if(!e)return-1;for(let t=0;t{for(let h of c.diagnostics){if(o.has(h))continue;o.add(h);let u=-1,f;for(let d=i;di&&(this.items.splice(i,u-i),r=!0)),t&&f.diagnostic==t.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),s=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),i++}});i({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let c=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Ot),i=Ni(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:kd.of(i)})}static open(e){return new ns(e)}}function Qr(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function pr(n){return Qr(``,'width="6" height="3"')}const r1=R.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:pr("#f11")},".cm-lintRange-warning":{backgroundImage:pr("orange")},".cm-lintRange-info":{backgroundImage:pr("#999")},".cm-lintRange-hint":{backgroundImage:pr("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function s1(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function Td(n){let e="hint",t=1;for(let i of n){let r=s1(i.severity);r>t&&(t=r,e=i.severity)}return e}class $d extends Mt{constructor(e){super(),this.diagnostics=e,this.severity=Td(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=e.state.facet(Ps).tooltipFilter;return r&&(i=r(i,e.state)),i.length&&(t.onmouseover=()=>l1(e,t,i)),t}}function o1(n,e){let t=i=>{let r=e.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientXr.top-10&&i.clientYe.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,o1(n,e)}let{hoverTime:r}=n.state.facet(Ps),s=setTimeout(i,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,r)}}function a1(n,e){let t=Object.create(null);for(let r of e){let s=n.lineAt(r.from);(t[s.from]||(t[s.from]=[])).push(r)}let i=[];for(let r in t)i.push(new $d(t[r]).range(+r));return N.of(i,!0)}const c1=Bu({class:"cm-gutter-lint",markers:n=>n.state.field(al),widgetMarker:(n,e,t)=>{let i=[];return n.state.field(al).between(t.from,t.to,(r,s,o)=>{r>t.from&&ri.is(Jl)?i.value:t,n)},provide:n=>Os.from(n)}),h1=R.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Qr('')},".cm-lint-marker-warning":{content:Qr('')},".cm-lint-marker-error":{content:Qr('')}}),u1=Eu(Jb,{hideOn:xd}),Kd=[Ot,R.decorations.compute([Ot],n=>{let{selected:e,panel:t}=n.field(Ot);return!e||!t||e.from==e.to?B.none:B.set([_b.range(e.from,e.to)])}),u1,r1],Ps=K.define({combine(n){return yt(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function f1(n={}){return[Ps.of(n),al,c1,h1,Rd]}const Zd=1,Ue=Object.freeze({ready:"studio.ready",documentOpen:"document.open",documentReplace:"document.replace",documentChanged:"document.changed",documentSave:"document.save",documentSetReadOnly:"document.setReadOnly",documentResources:"document.resources",editorInsert:"editor.insert",editorFormat:"editor.format",editorSetTheme:"editor.setTheme",editorGetState:"editor.getState",diagnosticsPublish:"diagnostics.publish"});function d1(n,e={},t=null,i=null){return{protocolVersion:Zd,type:n,documentID:t,...i===null?{}:{sessionID:i},payload:e}}function p1(n){if(window.WKWebViewJavascriptBridge){n(window.WKWebViewJavascriptBridge);return}if(window.WKWVJBCallbacks){window.WKWVJBCallbacks.push(n);return}window.webkit?.messageHandlers?.iOS_Native_InjectJavascript&&(window.WKWVJBCallbacks=[n],window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage(null))}function nn(n,e,t={},i=null,r=()=>{},s=null){if(!n){r({result:"unavailable"});return}n.callHandler(e,d1(e,t,i,s),r)}function m1(n){const e={capabilities:["jsx","format","search","completion","diagnostics"]};nn(n,Ue.ready,e)}const O1=[{id:"$storage.getString",arguments:["key"],returns:"string",documentation:"Read a package-scoped string. Missing keys return an empty string."},{id:"$storage.setString",arguments:["key","value"],returns:"boolean",documentation:"Set a package-scoped string, limited to 256 KiB of UTF-8. Check the success result."},{id:"$storage.getJSON",arguments:["key"],returns:"json",documentation:"Read a package-scoped JSON object. Missing or invalid values return an empty object."},{id:"$storage.setJSON",arguments:["key","value"],returns:"boolean",documentation:"Store a valid JSON object, limited to 256 KiB encoded. Check the success result."},{id:"$storage.compareAndSetString",arguments:["key","expected","value"],returns:"boolean",minimumRuntimeVersion:"1.3",documentation:"Atomically replace a string only when it still matches expected. A missing key matches an empty string. Conflicts return false; reread and retry a bounded number of times. Requires the shared storage container."},{id:"$storage.compareAndSetJSON",arguments:["key","expected","value"],returns:"boolean",minimumRuntimeVersion:"1.3",documentation:"Atomically replace a JSON object if its current value equals expected, independent of property order. A missing key matches an empty object. Wrong types and conflicts return false. Requires the shared storage container."},{id:"$storage.remove",arguments:["key"],returns:"boolean",documentation:"Remove a key from this package only."},{id:"$storage.keys",arguments:[],returns:"string[]",documentation:"List keys in this package's namespace."},{id:"$storage.clear",arguments:[],returns:"boolean",documentation:"Clear this package's storage. Other packages are unaffected."}].map(n=>({minimumRuntimeVersion:"1.0",...n,preview:"initialState"})),cl="2026-01-01T00:00:00Z",Wt="2026-01-01T12:00:00Z",ao=(n,e)=>({value:n,unit:e,hasSamples:!0,start:cl,end:Wt}),oh=(n,e,t)=>Object.entries(e).map(([i,r])=>({id:`$${n}.${i}`,group:n,value:r,legacy:[t,i]})),g1=[{id:"$music.isAvailable",group:"music",value:!0},{id:"$music.authorizationStatus",group:"music",value:"authorized"},{id:"$music.current",group:"music",value:{provider:"appleMusic",state:"playing",hasItem:!0,title:"Morning Light",artist:"ScriptWidget Sessions",album:"Focus",duration:224,position:86,capturedAt:Wt}},{id:"$services.status",group:"services",value:"connected"},{id:"$services.profile",group:"services",value:{service:"github",subject:"42",username:"octocat",displayName:"Mona",publicRepositories:32,privateRepositories:8,followers:128,following:24}},...oh("device",{screen:{width:390,height:844,scale:3},language:"en",model:"iPhone",name:"My iPhone",battery:{level:.8,state:"unplugged"},systemVersion:"26.0",isdarkmode:!1,totalDiskSpace:128e9,freeDiskSpace:64e9},"device"),...oh("system",{appInfo:{name:"ScriptWidget",bundleId:"com.everettjf.scriptwidget",version:"27.1.2",build:"27012"},locale:"en_US",preferredLanguages:["en-US"],timeZone:{identifier:"UTC",abbreviation:"GMT",offsetSeconds:0},is24HourClock:!1,calendarInfo:{identifier:"gregorian",firstWeekday:1,minimumDaysInFirstWeek:1},systemUptime:3600,memory:{physical:8589934592},thermalState:"nominal",lowPowerMode:!1,brightness:.5,reduceMotionEnabled:!1,platform:"ios",hostName:"My iPhone",processName:"ScriptWidgetWidget",osVersionString:"Version 26.0",processorCount:6,activeProcessorCount:6},"system"),{id:"$photos.isAvailable",group:"photos",value:!0},{id:"$photos.authorizationStatus",group:"photos",value:"authorized"},{id:"$photos.requestAuthorization",group:"photos",value:!0},{id:"$photos.items",group:"photos",value:{status:"ready",items:[{id:"sample.photo",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fbPe3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQK/QnooooGFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK7TxwooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi++865Pl26H91CDwo9T6t6mhs5cTiVSXmX/ABx49v8Axdc+UmYbKM/u4vX/AGm9T+g/U6/w38fv4buRpOqMTYynr18pj3H+ye4/H1z5TRU3PHVean7S+p+gSOkiCSMhlYZBHIIPcU6vmn4YfEL+zXTw5rb/AOjscQyN/wAsyf4Sf7p7Ht9On0tVHuUKyqx5kFFFFBsFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABTXdIkMkhwo5JNOrjPEN8ZJfsUZ+VeW9z/8AWry84zOGXYd4iSu9ku7O7L8FLF1lSjt19Av/ABDLIxjsvkX+8ep/wrn5J5pjmVyx9zmoqK/HsdmuJxsnPETb8ui9EfoWFwNHDR5aUbefX7yWOeaE5icqfY4roLDxDLGwjvfnX+8Oo/xrmqKMDmuJwUlPDza8uj9UGKwNHEx5asb+fX7z1ZHSVBJGcqeQRTq4zw9fGOX7FIflblfY/wD167Ov2HJ8zhmOHWIirPZrsz89zDBSwlZ0pbdPQKKKK9Q4QooooAKKKKAP/9P9uKKKK7TxwooooAKKKKACiiigAooooAK5zxP4o0vwpp5vtRb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KKACiiigAooooAKKKKACvWvhP8W9b+F+r+bBm40+dh9otieG7bk/uuB379D2x5LRSLp1JU5KcHZo//0/rSiiius/PwooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtYWublgiIMsx6AU26ureyt3urpwkaDJY14H4q8V3GvzeTDmO1Q/Kvdvdv8O1OMbmVWqoIk8WeLZtdlNrbZS1Q8Du59T/AEFcXRRWyVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/9T60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKKKKACq15eW2n2z3d44SNBkk0y/v7XTbV7y9cJGg5J/kPU18/eJfE114hucnKW6H5I/6n1P8qqMbmVWqoLzJPFHim58QXGxcx2yH5E9fdvf+VcpRRWqVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9X60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKo6jqNppVo17etsRfzJ9B6mm6pqlnpFm17ettReg7k+gHrXz34h8Q3niC786c7Y1+5GOij+p9TVRjcxq1lBeY/xH4ku/EN1vk+SFD8kfYe59TXOUUVqedKTbuwooopiCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9b60oqRYZX+4pP0FWV03UX+5byH6Kf8K6z4CzKVFay6Drj/AHLKc/SNv8KsJ4V8Tv8Ac026P0hf/CgfJLsYNFdOngvxc/TTbn8Y2H8xVhPAHjN+mnTfiMfzoH7KfZnIUV3C/Dbxu/TT3/FkH82qyvws8dt/y44+skf/AMVQV7Cp/K/uPPqK9JT4S+OG62yL9ZE/oTVlfg94zbqkK/WQf0BosP6vU/lZ5bRXra/Bjxc3V7Zfq7f0U1YX4JeKD9+4tR/wJz/7JRYf1Wr/ACnjlZmravZaLZte3rYUcADqx9BXpXjnwZH8PNCfXPEeoQKv3Y4k3GSV/wC6gIH4noB1r4t1vXL3Xrw3V2cAcIg6KPQf1PeqjG5y4mTo+7Jaj9e1+91+8NzcnCDhEHRR/j6msOiitTy223dhRRRTEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/Z",width:384,height:256},{id:"sample.photo.2",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/ayiiivVAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9D9rKKKK9UAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/0f2sooor1QCiiigAooooAKKKKACiiigAooooAKKKKACiq15eWun2r3t7IsUUY3MzHAApbW6tr62S8tHEkUqhlZeQQaduoFiiiikAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB/9L9rKKKK9UAooooAKKKKACiiigAooooAKKKKACs/VdVsNFsZNS1OQRQxjJJ/kB3J7Cquva/pnhvTn1PVJNiLwAPvMeyqO5P+eK+P/GPjTU/GF9510fLt0P7qEHhR6n1Y9zXRRoOo/Iyq1VD1L3jrx9f+MLrykzDZRn93F6/7T+p/QdvU7Pw1+IL+GbkaTqjFrCVuvXymP8AEP8AZPcfiO+fJqK9F0ouPJbQ4lUfNzH6FI6SoJIyGVhkEcgg9xTq+ZPhd8Rf7MdPDeuP/ozHEMjf8syf4Sf7p7en06fTdeXVpOm7M74TU1dBRRRWRYUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFNZlRS7nAHU06uc1a6LyfZkPyr1+tebm2ZRwFB15avZLuzmxeJVCm5sLrVpHJS2+VfXvWS8skhy7E/U0yivybG5niMZJyrzb8un3HylbE1KzvNj0lkjOUYj6Gta11aRCEufmX171jUUYLM8Rg5KVCbXl0+4KOJqUXeDO6VldQ6HIPQ06uc0m6KSfZnPyt0+tdHX6zlOZRx9BV46PZrsz6vCYlV6amgooor0jpCiiigAooooA//9P9r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KKKKACiiigAooooAKKKKACiiigAooooAKKKKACo5ZYoI2mmYIiDLMTgADuaSeeG2ha4uGCIgyzHgACvnbxp42m1+Q2NgSlmp+hkI7n29B+J9tKVJzdkTKViXxt44k1x203TSUtFPJ6GQjuf9n0H4n284oor0oxUVZGLdwoooqgCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAr2H4QfGLXvhTrPm2+bjTZ2H2m1J4btvT+64Hfv0PbHj1FROEZxcZrQcZOLuj//T+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKgubm3s7d7q6cRxxjLMegFNu7y2sLZ7y8cRxxjLMe1fN/jDxlc+JJ/IgzHaIflTux/vN7+g7VpSpObJlKxL4y8aXHiKY2lpmOzQ8L0Lkd2/oK4OiivSjFRVkYt3CiiiqAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//1PqCiiivszygooooAKKKKACiiigAooooAKKKKACiiigAooooAKqX19aabave3riOKMZJP+etN1HUbPSrN76/cRxoOSf5D1J9K+afFfiy88TXeTmO2Q/u4/6t6n+XataVJzfkTKViXxd4vu/EtzsTMdrGfkj9f9pvf+VcbRRXoxioqyMW7hRRRVAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//V+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACs/VNUstHsnv799kafmT2AHcmmavq9jolk1/qD7UXoO7HsAO5NfM3iXxNfeJb3z7j5Il/1cY6KP6k9zW1Ki5vyJlKxL4o8VXvia78yX5IEP7uMdB7n1PvXLUUV6EYpKyMW7hRRRVAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB//1vqCipFhlf7ik/QVZTTdRk+5byH6IT/SvsrnlWKVFay6Drr/AHLKc/SNv8Ksp4U8UP8Ac026P0hf/ClzLuOzMCiuoXwT4v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LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDTt1AnooopAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9vKKKK7T0wooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi++865PlwIf3UIPCj1Pq3qa3o0XUfkXCHMX/HHjy/8AF115SZhsoz+7iz1/2m9T+g/U6/w38fv4buRpWqMTYSnr18pj3H+ye4/Ed8+U0V6DpR5eS2h0cqtY/QJHSVBJGQysMgjkEHuKdXzT8MPiF/Zjp4c1t/8ARmOIZGP+rJ/hP+ye3p9On0tXmVKbg7M5pR5XYKKKKzJCiiigAooooAKKKKACiiigAoooo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H93H2HufU1zNFFdqSSsjvSSVkFFFFMYUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//1vriipFilf7ik/QVZXTtQf7kEh+in/CvqD6ApUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf/AApcy7iuYNFdOngvxc/TTbn8Y2H8xVhfAPjJ+mnTfiMfzpc8e4XRyFFdwvw38bv009/xZB/NqsL8LfHbf8uOPrJH/wDFUvaR7hzLuef0V6Svwl8cN1tkX6yJ/Q1ZX4P+M26pCv1kH9AaXtYdxc67nltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AAJz/wCyUvbw7hzx7njlZesaxY6JZNe3zYUcADqx9APWvSvHfg6P4daE+u+JNQgVfuxxJuMkr/3UBAz7noB1r4j13Xr7xBem7vDgDhEHRR6D+p710UIqpqtjejT9pr0JPEHiC+8Q3hubo7UXhIx0Uf4+prBoorvStojvSS0QUUUUxhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//2Q==",width:384,height:256},{id:"sample.photo.4",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQO3UnooooEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK5z1QooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi+9865PlwIf3UIPCj1Pq3qaaR0UKDqPyL3jjx5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erW5J5dPVe7L+I5yD+l2najYavYxanpcyz286h45EOVZT0INVc+TxeDnh5Wlt0ZdooooOM//9H60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigApGZUUu5wBySaR3SNDJIQqqMkngACvBvGnjZ9WZtM0titqDhm6GT/7H+dJuxrSpOo7Im8a+OG1ItpOkNi36O46v7D/Z/n9K8woorNu560IKC5YhRRRSLCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAK98+Cvxw1T4ZXw0zUd1zo07Zki6tET1ePPf1XofrzXgdFMyq0o1YuE1oftro2s6X4h0yHWdFnW5tbhd8ciHII/oR0IPIPBrTr8o/g58Z9Z+Fup+TJuudJnbM9vnkHp5keeA47jow4PYj9QvD3iHRvFWjw69oE63NrcLuR1/UEdQQeCDyDTTPlMbgpYeXddGf/9L60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACmSyxwxtNMwVFGSTwAB3NNnnhtoWuLhgiIMsx4AAr5+8Y+M5tekNlYkpaKfoXI7n29B+J9k3Y2o0XUdkS+MvGsmtO2nacSlop5PQyEdz7eg/E155RRWbdz1YQUFyxCiiikWFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABXrvwk+L2ufCzWPNt83GnTsPtNqTw3ben91wO/foe2PIqKDOpTjUi4TV0f/T+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtIHublwkaDLMegFNu7u2sbZ7u7cRxoMsx7V87+LfF9z4in8iHMdoh+VO7H+839B2pN2NqNF1H5EvjDxjP4gmNra5jtEPC93I7t/QVw1FFZtnqwgorliFFFFIsKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9T60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAqre3trp1q95euI40GST/nrTNQ1C00u0e9vnCRoOSf5D1Jr5y8U+KrvxJdZOY7dD+7j/qfU/wAqTdjejRdR+RL4r8WXXiO52LmO1Q/Inr/tN7/yrkKKKzPVjFRVkFFFFIoKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP//V+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAqhqep2ekWb318+yNPzJ9AO5NM1XVrLRbJr6/fai9B3Y9gB3NfN/iPxJe+I7zz7j5Yl/wBXGOij+p9TUt2OihQdR+RJ4m8T3niO78yT5IEP7uPsPc+prmaKKg9SMVFWQUUUUigooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/W+tKKkWKV/uKT9BVlNO1CT7kEjfRT/hWR9rcpUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf8AwoFzLuYNFdMvgvxc/TTbn8Y2H8xVlfAPjJ+mnTfiMfzoF7SPc5Ciu4X4b+N36ae/4sg/masL8LfHb/8ALjj6yR//ABVIXtYfzI8/or0lPhL44brbIv1kT+hqynwf8Zt1SFfrIP6A0C9tD+ZHltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AnP8A7JQL6xT/AJjxysrWNZsdDsmvr5sKOAB1Y+gHrXpXjvwfF8OdBfXfEmoQKv3Yok3GSV/7qAgZ9z0A618Q69r194gvTd3hwBwiDoo9B/U96TdjrwtNVveWw/xB4hvvEV6bm6O1F4SMdFH+PqawaKKg9dJJWQUUUUhhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH/9k=",width:384,height:256}],unavailableCount:0,fetchedAt:Wt,source:"system",stale:!1}},{id:"$calendar.isAvailable",group:"calendar",value:!0},{id:"$calendar.authorizationStatus",group:"calendar",value:"authorized"},{id:"$calendar.requestAuthorization",group:"calendar",value:!0},{id:"$calendar.calendars",group:"calendar",value:[{id:"sample.personal",title:"Personal"}]},{id:"$calendar.events",group:"calendar",value:{status:"ready",items:[{id:"sample.event",calendarID:"sample.personal",title:"Read and recharge",start:"2026-01-01T15:00:00Z",end:"2026-01-01T15:30:00Z",allDay:!1}],fetchedAt:Wt,source:"system",stale:!1,truncated:!1}},{id:"$reminders.isAvailable",group:"reminders",value:!0},{id:"$reminders.authorizationStatus",group:"reminders",value:"authorized"},{id:"$reminders.requestAuthorization",group:"reminders",value:!0},{id:"$reminders.lists",group:"reminders",value:[{id:"sample.reminders",title:"Personal"}]},{id:"$reminders.items",group:"reminders",value:{status:"ready",items:[{id:"sample.reminder",listID:"sample.reminders",title:"Read a chapter",due:"2026-01-01T16:00:00Z",hasTime:!0,completed:!1,completedAt:null,priority:0}],fetchedAt:Wt,source:"system",stale:!1,truncated:!1}},{id:"$reminders.create",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$reminders.update",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$reminders.setCompleted",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$health.authorizationStatus",group:"health",value:"notDisclosed"},{id:"$health.sleepSummary",group:"health",value:{start:cl,end:Wt,timeZone:"UTC",hasSamples:!0,totalSleepSeconds:27e3,inBedSeconds:30600,awakeSeconds:1800,stages:{unspecified:0,core:16200,deep:5400,rem:5400},sourceCount:1,truncated:!1,conflictSeconds:0,aggregation:"union-awake-rem-deep-core-unspecified"}},{id:"$health.activitySummary",group:"health",value:{date:"2026-01-01",timeZone:"UTC",hasSamples:!0,moveMode:"activeEnergy",move:{value:480,goal:600,unit:"kcal"},exercise:{value:26,goal:30,unit:"min"},stand:{value:9,goal:12,unit:"count"}}},{id:"$health.workouts",group:"health",value:{start:cl,end:Wt,timeZone:"UTC",hasSamples:!0,truncated:!1,items:[{id:"550e8400-e29b-41d4-a716-446655440000",activity:"running",start:"2026-01-01T09:00:00.000Z",end:"2026-01-01T09:45:00.000Z",duration:2700,energyKcal:285,distanceMeters:5200}]}},{id:"$health.isAvailable",group:"health",value:!0},{id:"$health.requestAuthorization",group:"health",value:!0,legacy:["health"]},{id:"$health.stepCountToday",group:"health",value:ao(6840,"count"),legacy:["health.stepCountToday"]},{id:"$health.activeEnergyToday",group:"health",value:ao(420,"kcal"),legacy:["health.activeEnergyToday"]},{id:"$health.heartRateLatest",group:"health",value:ao(72,"bpm"),legacy:["health.heartRateLatest"]},{id:"$location.isAvailable",group:"location",value:!0},{id:"$location.authorizationStatus",group:"location",value:"authorizedWhenInUse"},{id:"$location.isAuthorizedForWidgetUpdates",group:"location",value:!0},{id:"$location.requestAuthorization",group:"location",value:!0,legacy:["location.authorization"]},{id:"$location.current",group:"location",value:{latitude:37.3349,longitude:-122.009,altitude:0,accuracy:10,verticalAccuracy:10,speed:-1,course:-1,timestamp:Wt,accuracyAuthorization:"full",age:0,isStale:!1},legacy:["location"]}],y1={music:{platforms:["ios"],authorization:"musicRead",notes:"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access."},services:{platforms:["ios","macos"],authorization:"serviceAccount",notes:"Runtime 1.4: status(service) and profile(service) are asynchronous. Only provider: github. Unknown providers reject with service_operation. Requires an installed owner and services permission. profile additionally requires network and api.github.com in networkDomains, a native connected GitHub account and explicit owner grant. Native Settings handles credentials; scripts cannot log in or obtain tokens. profile returns service, subject, username, displayName, publicRepositories, privateRepositories, followers and following (missing values are null). No live queries in future entries or Live Activities. Eight shared data queries; native requests also share the eight concurrent/32 total network budget, while Web uses its existing preview network budget. Web uses editable best-state samples only; it never authenticates or sends these requests."},photos:{platforms:["ios","macos"],authorization:"photosRead",notes:"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access."},reminders:{platforms:["ios","macos"],authorization:"remindersRead",notes:"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission."},calendar:{platforms:["ios","macos"],authorization:"calendarRead",notes:"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission."},device:{platforms:["ios","macos"],authorization:"none",notes:"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements."},system:{platforms:["ios","macos"],authorization:"none",notes:"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable."},health:{platforms:["ios"],authorization:"healthRead",notes:"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain."},location:{platforms:["ios"],authorization:"locationWhenInUse",notes:"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale."}},A1=g1.map(n=>{const e=n.id.split(".")[1],t=n.group==="music"&&e==="current"||n.group==="services"||["calendar","reminders","photos"].includes(n.group)&&!["isAvailable","authorizationStatus"].includes(e)||n.group==="health"&&!["isAvailable","authorizationStatus"].includes(e)||n.group==="location"&&["current","requestAuthorization"].includes(e),i=n.group==="health"&&["sleepSummary","activitySummary","workouts"].includes(e)||n.group==="location"&&["current","requestAuthorization"].includes(e)||["calendar","reminders","photos"].includes(n.group)&&["events","items"].includes(e);return{...n,...y1[n.group],minimumRuntimeVersion:["music","services","reminders","photos"].includes(n.group)||n.group==="health"&&["sleepSummary","activitySummary","workouts"].includes(e)?"1.4":["calendar"].includes(n.group)||["$health.authorizationStatus","$location.isAuthorizedForWidgetUpdates"].includes(n.id)?"1.3":"1.0",arguments:n.group==="services"?["service"]:n.group==="reminders"&&["create","update","setCompleted"].includes(e)?["options"]:i?["options?"]:[],...n.group==="reminders"&&["create","update","setCompleted"].includes(e)?{authorization:"remindersWrite"}:{},asynchronous:t,nativeSource:`Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntime${n.group[0].toUpperCase()}${n.group.slice(1)}.swift`,operation:n.group==="reminders"&&["create","update","setCompleted"].includes(e)?"write":e==="requestAuthorization"?"authorization":["isAvailable","authorizationStatus","isAuthorizedForWidgetUpdates"].includes(e)?"availability":"read",mock:"editable"}}),Re={globalProperties:{background:{type:"color",documentation:"Background color, hex value, or named color."},backgroundMaterial:{type:"enum",values:["none","ultraThin","thin","regular","thick","ultraThick"],documentation:"Runtime API 1.4. Public SwiftUI frosted material inside the widget, not Home Screen wallpaper blur or system Liquid Glass. At most four material backgrounds per tree. background supplies an opaque-composited Reduce Transparency fallback. In accented/vibrant mode local material is omitted for system rendering; none keeps the ordinary background."},color:{type:"color",documentation:"Foreground color, hex value, or named color."},font:{type:"enum",values:["largeTitle","title","title2","title3","headline","subheadline","body","callout","footnote","caption","caption2"],documentation:"Semantic text style."},fontWeight:{type:"enum",values:["ultraLight","thin","light","regular","medium","semibold","bold","heavy","black"],documentation:"Font weight."},fontDesign:{type:"enum",values:["default","rounded","serif","monospaced"],documentation:"Font design."},frame:{type:"number|string",documentation:'Square size (64 or "64"), width,height ("64,48"), or flexible frame ("max", "max,48").'},padding:{type:"number|string",documentation:"Padding amount or edge description."},corner:{type:"number",documentation:"Corner radius."},opacity:{type:"number",documentation:"Opacity from 0 through 1."},alignment:{type:"enum",values:["center","leading","trailing","top","bottom","topLeading","topTrailing","bottomLeading","bottomTrailing","firstTextBaseline","lastTextBaseline"],documentation:"Layout alignment."},clip:{type:"enum",values:["circle","rect","capsule","ellipse"],documentation:"Clip the view to a shape."},rotation:{type:"number",documentation:"Rotation in degrees."},rotation3d:{type:"string",documentation:"Static degree,x,y,z rotation with four finite numbers and a nonzero axis. Invalid values are ignored; axis magnitude is normalized. Reduce Motion removes the tilt. This does not read device motion or provide parallax."},shadow:{type:"string",documentation:"Shadow color, radius, and offset description."},animation:{type:"string",documentation:"iOS public SwiftUI scheduled clock/swing effect. Mac renders static standard-clock poses; other effects remain at rest. Signed clockCustom intervals specify a half-turn (full cycle = 2 * abs(interval)), minimum magnitude 0.25 seconds. App previews can animate; WidgetKit decides cadence and may freeze. Reduced motion/luminance freezes standard clock poses and keeps custom/swing effects at rest. Dynamic scripts are not rerun on animation ticks."},widgetAccentable:{type:"boolean",documentation:"Group this view into the accent layer in tinted and vibrant widget appearances."},linkurl:{type:"url",documentation:"Widget deep link URL."}},components:{VStack:{documentation:"Arrange children vertically.",children:!0,properties:{spacing:{type:"number"}}},HStack:{documentation:"Arrange children horizontally.",children:!0,properties:{spacing:{type:"number"}}},ZStack:{documentation:"Overlay children.",children:!0,properties:{}},VGrid:{documentation:"Vertical lazy grid.",children:!0,properties:{columns:{type:"string",required:!0},spacing:{type:"number"},alignment:{type:"enum",values:["leading","center","trailing"]}}},HGrid:{documentation:"Horizontal lazy grid.",children:!0,properties:{columns:{type:"string",required:!0},spacing:{type:"number"},alignment:{type:"enum",values:["top","center","bottom","firstTextBaseline","lastTextBaseline"]}}},Text:{documentation:"Display text content.",children:!1,properties:{text:{type:"string"}}},Date:{documentation:"Display a formatted date.",children:!1,properties:{date:{type:"date|number",required:!0},style:{type:"enum",values:["time","date","relative","offset","timer"]}}},Image:{documentation:"Display a bundled, remote, or SF Symbol image.",children:!1,properties:{systemName:{type:"string"},name:{type:"string"},id:{type:"string",deprecated:"Use name."},url:{type:"url"},src:{type:"url",deprecated:"Use url."},ratio:{type:"number"},mode:{type:"enum",values:["fit","fill"]},accentedRenderingMode:{type:"enum",values:["accented","desaturated","accentedDesaturated","fullColor"],documentation:"Control how the image is rendered in tinted and clear widget appearances."}}},Gif:{documentation:"Display a bounded package GIF using system decoding: up to 8 MiB input and 1,048,576 canvas pixels. iOS retains at most 60 downsampled frames / 4 MiB decoded pixels; more frames fall back to the first frame. Mac, Reduce Motion and reduced luminance use a static first frame. Active iOS previews use public SwiftUI timing with variable frame delays. Snapshots, inactive scenes, Mac and accessibility fallbacks use the first frame. No private clock bridge or continuous WidgetKit guarantee.",children:!1,properties:{file:{type:"string",required:!0}}},Spacer:{documentation:"Flexible layout space.",children:!1,properties:{minLength:{type:"number"}}},Rect:{documentation:"Rectangle shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},RoundedRect:{documentation:"Filled rounded rectangle.",children:!1,properties:{radius:{type:"number"}}},Capsule:{documentation:"Capsule shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Ellipse:{documentation:"Ellipse shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Circle:{documentation:"Circle shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Gauge:{documentation:"Display a gauge or instrument.",children:!1,properties:{type:{type:"string"},value:{type:"number"},style:{type:"enum",values:["circular","linear"]},text:{type:"string"},current:{type:"string"},min:{type:"string"},max:{type:"string"},angle:{type:"number"},thickness:{type:"number"},needleColor:{type:"color"},label:{type:"string"},title:{type:"string"},sections:{type:"string"}}},Chart:{documentation:"Render chart data.",children:!1,availability:{ios:"16.0",macos:"26.0"},properties:{type:{type:"enum",values:["bar","bar-x","bar-y","bar-gantt","line","point","line-point","area","rect","rule-x"]},data:{type:"json",required:!0},category:{type:"boolean"},hideLegend:{type:"boolean"},hideXAxis:{type:"boolean"},hideYAxis:{type:"boolean"}}},Link:{documentation:"Open a URL when selected.",children:!0,properties:{url:{type:"url",required:!0}}},Divider:{documentation:"Horizontal or vertical separator.",children:!1,properties:{thickness:{type:"number"},axis:{type:"enum",values:["horizontal","vertical"]}}},Line:{documentation:"Fixed-length line.",children:!1,properties:{thickness:{type:"number"},length:{type:"number"},axis:{type:"enum",values:["horizontal","vertical"]}}},Icon:{documentation:"SF Symbol icon.",children:!1,properties:{systemName:{type:"string",required:!0},size:{type:"number"}}},Label:{documentation:"Text paired with an SF Symbol.",children:!1,properties:{title:{type:"string"},systemName:{type:"string",required:!0}}},Progress:{documentation:"Linear or circular progress.",children:!1,properties:{value:{type:"number",required:!0},total:{type:"number"},label:{type:"string"},style:{type:"enum",values:["linear","circular"]},trackColor:{type:"color"},thickness:{type:"number"}}},Ring:{documentation:"Circular progress ring.",children:!1,properties:{value:{type:"number",required:!0},thickness:{type:"number"},trackColor:{type:"color"}}},Badge:{documentation:"Compact status badge.",children:!1,properties:{text:{type:"string"},radius:{type:"number"}}},Chip:{documentation:"Outlined metadata chip.",children:!1,properties:{text:{type:"string"},radius:{type:"number"},borderColor:{type:"color"}}},Stat:{documentation:"Title, value, and subtitle statistic.",children:!1,properties:{title:{type:"string"},value:{type:"string",required:!0},subtitle:{type:"string"},mutedColor:{type:"color"}}},Button:{documentation:"Interactive widget button. Use actionID to share a declared Package 2.0 action with Siri, Shortcuts, and Control Widgets.",children:!0,availability:{interactiveIos:"17.0"},requiredAny:["action","onClick","actionID"],properties:{action:{type:"enum",values:["reload"],conflicts:["actionID"]},onClick:{type:"function",conflicts:["actionID"]},actionID:{type:"action-id",conflicts:["action","onClick"]}}},Toggle:{documentation:"Interactive widget toggle. A declared actionID requires a package-relative storage stateKey.",children:!0,availability:{interactiveIos:"17.0"},requiredAny:["onClick","actionID"],properties:{on:{type:"boolean",required:!0},onClick:{type:"function",conflicts:["actionID"]},actionID:{type:"action-id",requires:["stateKey"],conflicts:["onClick"]},stateKey:{type:"storage-key",requires:["actionID"]}}}},functions:{...Object.fromEntries(O1.map(n=>[n.id,n])),...Object.fromEntries(A1.map(n=>[n.id,{documentation:n.notes,arguments:n.arguments,returns:n.asynchronous?"Promise":typeof n.value=="object"?"json":typeof n.value}])),"$icloud.readJSON":{documentation:"Read cached JSON and revision; conflicts preserve all heads. Requires icloud permission and a native connection. Never certifies upload.",arguments:["name"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.writeJSON":{documentation:"Save a new immutable JSON revision locally from a user action. Requires the revision from readJSON. Background exchange is eventual.",arguments:["name","value","expectedRevision"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.resolveJSON":{documentation:"Explicitly resolve all observed conflicting heads into a new revision. Stale tokens fail; originals remain.",arguments:["name","value","expectedRevision"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.sync":{documentation:"Exchange materialized revisions with iCloud; requires a user action. Upload completion is unknown.",arguments:[],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.status":{documentation:"Read native connection state. Cloud store IDs are granted in the app, never by the script. Web uses preview mocks.",arguments:[],returns:"Promise",minimumRuntimeVersion:"1.5"},"$file.exists":{documentation:"Return whether a regular file is locally present inside this package, including binary assets. Missing files, directories, unsafe paths and links return false. Does not download iCloud files or read outside the package. Web preview uses workspace file presence.",arguments:["path"],returns:"boolean",minimumRuntimeVersion:"1.3"},"$file.read":{documentation:"Read package-relative UTF-8 text. Missing or unavailable files return an empty string.",arguments:["path"],returns:"string"},"$file.readJSON":{documentation:"Read a package-relative JSON object.",arguments:["path"],returns:"json"},fetch:{documentation:"Perform a network request and return its response text. Existing HTTP methods keep this string result."},"$http.getResponse":{documentation:"GET response metadata: {status, body, headers}. Headers are limited to content-type, cache-control, expires, last-modified, date and retry-after (lowercase; each at most 2048 UTF-8 bytes). Network permissions, public-host policy, redirects, body limits and timeline restrictions still apply. HTTP error statuses resolve; transport errors reject.",arguments:["url","options?"],returns:"Promise",minimumRuntimeVersion:"1.3"},importJS:{documentation:"Import a package-relative JavaScript file."},"$dataSource.request":{documentation:"Call a declared Data Source Plugin operation. Requires Package 2.0 plugins, network permission, and networkDomains declarations.",arguments:["pluginID","operationID","parameters"],returns:"Promise"},"$xml.parse":{documentation:"Parse up to 256 KiB of XML into {name, attributes, text, children}. DTDs and external entities are rejected; depth and node limits apply.",arguments:["source"],returns:"XMLNode"}}};function b1(n,e){const t=Object.entries(e.properties??{}).filter(([,r])=>r.required).map(([r,s])=>`${r}=${s.type.includes("number")||s.type==="boolean"?"{${}}":'"${}"'}`).join(" "),i=t?` ${t}`:"";return e.children?`<${n}${i}> - \${} -`:`<${n}${i} />`}const lh=Object.entries(Re.components).map(([n,e])=>({label:n,type:"class",detail:`ScriptWidget · ${Object.keys(e.properties??{}).length} properties`,info:e.documentation,apply:b1(n,e)}));function S1(n){const e=n.match(/<([A-Za-z][\w]*)\b([^<>]*)$/);return!e||e[2].includes(">")?null:{name:e[1],attributes:e[2]}}function x1(n,e){const t=Re.components[n];return t?Object.entries({...Re.globalProperties,...t.properties??{}}).filter(([i])=>!e.has(i)).map(([i,r])=>({label:i,type:"property",detail:r.required?`${r.type} · required`:r.type,info:r.deprecated?`Deprecated: ${r.deprecated}`:r.documentation,apply:`${i}=${r.type.includes("number")||r.type==="boolean"?"{${}}":'"${}"'}`})):[]}function w1(n){const e=n.match(/<([A-Za-z][\w]*)\b[^<>]*\b([A-Za-z][\w]*)\s*=\s*["']([^"']*)$/);if(!e)return null;const t=Re.components[e[1]]?.properties?.[e[2]]??Re.globalProperties[e[2]];return t?.values?{typed:e[3],values:t.values}:null}function v1(n){const e=n.state.doc.sliceString(Math.max(0,n.pos-1200),n.pos),t=w1(e);if(t)return{from:n.pos-t.typed.length,options:t.values.map(o=>({label:o,type:"enum"})),validFor:/^[\w-]*$/};const i=n.matchBefore(/<[A-Za-z]*$/);if(i)return{from:i.from+1,options:lh,validFor:/^[A-Za-z]*$/};const r=S1(e);if(r&&/(?:\s|^)\w*$/.test(r.attributes)){const o=n.matchBefore(/[A-Za-z][\w]*$/),l=new Set([...r.attributes.matchAll(/\b([A-Za-z][\w]*)\s*=/g)].map(a=>a[1]));return{from:o?.from??n.pos,options:x1(r.name,l),validFor:/^[A-Za-z][\w]*$/}}const s=n.matchBefore(/\$[A-Za-z]+\.[A-Za-z]*$/);if(s){const o=s.text.slice(0,s.text.indexOf(".")+1),l=Object.entries(Re.functions).filter(([a])=>a.startsWith(o));return l.length?{from:s.from+o.length,options:l.map(([a,c])=>({label:a.slice(o.length),type:"function",detail:c.returns,info:c.documentation})),validFor:/^[A-Za-z]*$/}:null}return n.explicit?{from:n.pos,options:lh,validFor:/^[A-Za-z]*$/}:null}function ah(n,e){const t=[];for(let i=n.node.firstChild;i;i=i.nextSibling)i.name===e&&t.push(i);return t}function Md(n){const e=[];return Ce(n).iterate({enter(t){if(t.name!=="JSXOpenTag"&&t.name!=="JSXSelfClosingTag")return;const r=ah(t,"JSXIdentifier")[0];r&&e.push({name:n.doc.sliceString(r.from,r.to),from:r.from,to:r.to,attributes:ah(t,"JSXAttribute").map(s=>{const o=s.firstChild;return o?{name:n.doc.sliceString(o.from,o.to),from:o.from,to:o.to}:null}).filter(Boolean)})}}),e}function Ed(n){const e=[];for(const t of Md(n.state)){const i=Re.components[t.name];if(!i)continue;const r=new Set([...Object.keys(Re.globalProperties),...Object.keys(i.properties??{})]),s=new Set(t.attributes.map(o=>o.name));for(const o of t.attributes){r.has(o.name)||e.push({from:o.from,to:o.to,severity:"warning",message:`“${o.name}” is not supported by <${t.name}>.`});const l=i.properties?.[o.name]??Re.globalProperties[o.name];l?.deprecated&&e.push({from:o.from,to:o.to,severity:"warning",message:`${o.name} is deprecated. ${l.deprecated}`})}for(const[o,l]of Object.entries(i.properties??{}))if(l.required&&!s.has(o)&&e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> requires the “${o}” property.`}),s.has(o)){for(const a of l.requires??[])s.has(a)||e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> “${o}” requires the “${a}” property.`});for(const a of l.conflicts??[])s.has(a)&&o cannot combine “${o}” with “${a}”.`})}i.requiredAny?.length&&!i.requiredAny.some(o=>s.has(o))&&e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> requires one of: ${i.requiredAny.map(o=>`“${o}”`).join(", ")}.`})}return e}function k1(n,e){const t=Md(n.state).find(r=>e>=r.from&&e<=r.to);if(!t)return null;const i=Re.components[t.name];return i?{pos:t.from,end:t.to,above:!0,create(){const r=document.createElement("div");r.className="studio-hover";const s=document.createElement("strong");s.textContent=`<${t.name}>`;const o=document.createElement("p");return o.textContent=i.documentation,r.append(s,o),{dom:r}}}:null}const ch={light:{background:"#FAFAFC",foreground:"#202124",gutter:"#F3F3F6",gutterText:"#8A8A93",activeLine:"#EDEEF3",selection:"#B9D7FF",caret:"#0067C0"},dark:{background:"#1E1F22",foreground:"#E8E8ED",gutter:"#191A1D",gutterText:"#777982",activeLine:"#292A2F",selection:"#315A85",caret:"#65B7FF"}};function Q1(n,e){return R.theme({"&":{height:"100%",color:n.foreground,backgroundColor:n.background,fontSize:"13px"},".cm-scroller":{fontFamily:'ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace',lineHeight:"1.58",overscrollBehavior:"contain"},".cm-content":{caretColor:n.caret,padding:"12px 0 32px"},".cm-line":{padding:"0 8px"},".cm-cursor, .cm-dropCursor":{borderLeftColor:n.caret},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:n.selection},".cm-activeLine":{backgroundColor:n.activeLine},".cm-gutters":{backgroundColor:n.gutter,color:n.gutterText,border:"none",paddingLeft:"env(safe-area-inset-left)"},".cm-activeLineGutter":{backgroundColor:n.activeLine,color:n.foreground},".cm-foldPlaceholder":{backgroundColor:"transparent",border:`1px solid ${n.gutterText}`,color:n.gutterText},".cm-tooltip":{border:e?"1px solid #41434A":"1px solid #D2D3D8",backgroundColor:e?"#292A2F":"#FFFFFF",borderRadius:"8px",overflow:"hidden",boxShadow:"0 8px 28px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete ul li[aria-selected]":{backgroundColor:e?"#315A85":"#DCEBFA",color:n.foreground},".cm-panels":{backgroundColor:n.gutter,color:n.foreground},".cm-searchMatch":{backgroundColor:e?"#725C1D":"#FFE69A"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e?"#8D6D20":"#FFD45C"}},{dark:e})}const P1=Ln.define([{tag:[g.keyword,g.controlKeyword,g.moduleKeyword,g.operatorKeyword,g.bool,g.null],color:"#FF7AB2"},{tag:[g.string,g.special(g.string)],color:"#FF8170"},{tag:[g.number,g.regexp],color:"#D9C97C"},{tag:[g.comment,g.lineComment,g.blockComment],color:"#7F8C98",fontStyle:"italic"},{tag:[g.tagName,g.typeName,g.className],color:"#5DD8FF"},{tag:g.attributeName,color:"#B281EB"},{tag:[g.propertyName,g.function(g.variableName),g.function(g.propertyName)],color:"#67B7A4"},{tag:g.definition(g.variableName),color:"#4EB0CC"},{tag:[g.variableName,g.operator,g.punctuation,g.bracket],color:"#E8E8ED"},{tag:g.invalid,color:"#FF453A"}]);function Ud(n){const e=n==="dark";return[Q1(e?ch.dark:ch.light,e),Jg(e?P1:i0)]}const C1=Lt.parser.configure({dialect:"jsx"}),T1=new Map(Object.keys(Re.components).map(n=>[n.toLowerCase(),n])),$1=new Set(["VStack","HStack","ZStack","VGrid","HGrid"]),R1=512*1024,K1=512,Z1=32,ci=n=>{const e=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t);return e},hi=(n,e)=>n.slice(e.from,e.to),de=n=>{throw new Error(n)},Fd=n=>{let e=!0;const t=n.replace(/&([^;\s]+);/g,(i,r)=>{const s={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};if(Object.hasOwn(s,r))return s[r];if(/^#(?:[0-9]+|x[0-9a-f]+)$/i.test(r)){const o=r[1].toLowerCase()==="x"?parseInt(r.slice(2),16):Number(r.slice(1));if(o>0&&o<=1114111&&!(o>=55296&&o<=57343))return String.fromCodePoint(o)}return e=!1,i});return e?t:void 0};function co(n,e=!1){if(e)return Fd(n.slice(1,-1));const t=n.trim();if(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(t)){const i=Number(t);return Number.isFinite(i)?i:void 0}if(t==="true"||t==="false")return t==="true";if(t.startsWith('"'))try{const i=JSON.parse(t);return typeof i=="string"?i:void 0}catch{}}function wi(n){const e={formatVersion:1,source:n,nodes:[],roots:[],issue:""};if(typeof n!="string"||new TextEncoder().encode(n).length>R1)return{...e,issue:"Layout editing supports source files up to 512 KiB."};const t=C1.parse(n);let i=!1;if(t.iterate({enter:s=>{s.type.isError&&(i=!0)}}),i)return{...e,issue:"Fix the JavaScript/JSX syntax before using Layout. Your source is preserved."};function r(s,o,l){(l>Z1||e.nodes.length>=K1)&&de("Layout editing supports up to 512 layers and 32 nesting levels.");const a=ci(s),c=a[0],h=a.at(-1),u=ci(c).find(S=>["JSXBuiltin","JSXIdentifier","JSXNamespacedName","JSXMemberExpression"].includes(S.name)),f=u?hi(n,u):"Fragment",d=T1.get(f.toLowerCase()),p=Re.components[d],m={...Re.globalProperties,...p?.properties??{}},O=c.name==="JSXOpenTag"&&h?.name==="JSXCloseTag",y=O?ci(h).find(S=>["JSXBuiltin","JSXIdentifier","JSXNamespacedName","JSXMemberExpression"].includes(S.name)):null;u&&O&&(!y||hi(n,y)!==f)&&de("Opening and closing JSX tags must match before using Layout.");const b={id:String(s.from),parentID:o,tag:f,component:d??null,from:s.from,to:s.to,openingEnd:c.to,insertAt:c.to-(O?1:2),contentFrom:c.to,contentTo:O?h.from:c.to,children:[],properties:[],locked:!p,structure:!1,text:null,textEditable:!1,depth:l};let x=!1;for(const S of ci(c)){if(S.name==="JSXSpreadAttribute"&&(x=!0),S.name!=="JSXAttribute")continue;const v=ci(S),U=hi(n,v[0]),F=v[2],j=F?co(hi(n,F),F.name==="JSXAttributeValue"):!0,E=F?.name==="JSXEscape"?co(n.slice(F.from+1,F.to-1)):j,M=Object.hasOwn(m,U)?m[U]:null;b.properties.push({name:U,value:E??null,from:S.from,to:S.to,editable:!!(p&&M&&M.type!=="function"&&E!==void 0),definition:M??null})}const C=new Set(b.properties.map(S=>S.name)).size!==b.properties.length;b.locked||=x||C,b.reason=x?"Spread properties are preserved; edit this element in Code.":C?"Duplicate properties are preserved; resolve them in Code.":p?"":"Custom components and fragments are preserved; edit them in Code.",b.locked&&b.properties.forEach(S=>{S.editable=!1}),e.nodes.push(b);const k=O?a.slice(1,-1):[];for(const S of k)S.name==="JSXElement"&&b.children.push(r(S,b.id,l+1).id);if(b.structure=!b.locked&&O&&$1.has(d)&&k.every(S=>S.name==="JSXElement"||S.name==="JSXText"&&!hi(n,S).trim())&&b.children.every(S=>!e.nodes.find(v=>v.id===S).locked),!b.locked&&d==="Text"&&O&&k.length===1){const S=k[0],v=hi(n,S),U=S.name==="JSXText"&&!/[\r\n]/.test(v)?Fd(v):S.name==="JSXEscape"?co(v.slice(1,-1)):void 0;typeof U=="string"&&(b.text=U,b.textEditable=!0)}return b}try{t.iterate({enter(s){if(s.name!=="CallExpression")return;const o=ci(s.node);if(o[0]?.name!=="VariableName"||hi(n,o[0])!=="$render"||o[1]?.name!=="ArgList")return;const l=ci(o[1]).filter(a=>!["(",")"].includes(a.name));if(l.length===1&&l[0].name==="JSXElement")return e.roots.push(r(l[0],null,0).id),!1}})}catch(s){return{...e,nodes:[],roots:[],issue:s.message}}return e.roots.length||(e.issue="Layout needs a direct $render(…) or another native JSX element. Variables, loops and functions stay editable in Code."),e}function hl(n){return!n?.component||n.locked?{}:{...Re.globalProperties,...Re.components[n.component]?.properties??{}}}function M1(n,e,t){(n.source!==e||n.issue)&&de("Layout changed. Select the layer again before editing.");const i=n.nodes.find(a=>a.id===t.id);(!i||i.locked)&&de("This layer is locked. Edit its source in Code.");let r=[],s=i.from;if(t.type==="property"){const a=hl(i),c=Object.hasOwn(a,t.name)?a[t.name]:null,h=i.properties.find(d=>d.name===t.name);(!c||c.type==="function"||h&&!h.editable)&&de("Dynamic or unsupported properties must be edited in Code.");const u=new Set(i.properties.map(d=>d.name)),f=Re.components[i.component];if(t.remove?(f.requiredAny?.includes(t.name)&&!f.requiredAny.some(d=>d!==t.name&&u.has(d))&&de("Keep at least one required component property."),Object.entries(f.properties??{}).some(([d,p])=>u.has(d)&&p.requires?.includes(t.name))&&de("Another property requires this value. Edit the dependent properties together in Code.")):(c.requires?.some(d=>!u.has(d))&&de("Add the required related properties together in Code."),(c.conflicts?.some(d=>u.has(d))||Object.entries(f.properties??{}).some(([d,p])=>d!==t.name&&u.has(d)&&p.conflicts?.includes(t.name)))&&de("This property conflicts with another component property.")),t.remove)(!h||c.required)&&de("This property cannot be removed."),r=[{from:h.from,to:h.to,insert:""}];else{const d=t.value;(!["string","number","boolean"].includes(typeof d)||typeof d=="number"&&!Number.isFinite(d)||typeof d=="string"&&d.length>8192)&&de("Use a bounded string, finite number or Boolean."),c.values&&!c.values.includes(d)&&de("Choose one of the supported property values."),c.type==="boolean"&&typeof d!="boolean"&&de("This property needs true or false."),c.type==="number"&&!(typeof d=="number"||typeof d=="string"&&d.trim()&&Number.isFinite(Number(d)))&&de("This property needs a number."),typeof d=="boolean"&&c.type!=="boolean"&&de("This property does not accept a Boolean."),typeof d=="number"&&!c.type.includes("number")&&de("This property needs a string value."),t.name==="opacity"&&!(Number(d)>=0&&Number(d)<=1)&&de("Opacity must be between zero and one.");const p=`${t.name}={${JSON.stringify(d)}}`;r=h?[{from:h.from,to:h.to,insert:p}]:[{from:i.insertAt,to:i.insertAt,insert:` ${p}`}]}}else if(t.type==="text")(!i.textEditable||typeof t.value!="string"||t.value.length>8192)&&de("Dynamic text is preserved. Edit it in Code."),r=[{from:i.contentFrom,to:i.contentTo,insert:`{${JSON.stringify(t.value)}}`}];else if(t.type==="move"||t.type==="remove")if(n.nodes.find(c=>c.id===i.parentID)?.structure||de("Only literal children of a supported stack/grid can be moved or removed."),t.type==="remove")r=[{from:i.from,to:i.to,insert:""}];else{const c=n.nodes.find(p=>p.id===t.parentID);(!c?.structure||c.from>=i.from&&c.to<=i.to)&&de("Choose a supported container outside this layer.");const h=p=>{for(;p.parentID!==null;)p=n.nodes.find(m=>m.id===p.parentID);return p.id};h(i)!==h(c)&&de("Layers cannot move between render branches or JavaScript scopes.");const u=c.children.filter(p=>p!==i.id),f=t.index;(!Number.isInteger(f)||f<0||f>u.length)&&de("Invalid layer position.");const d=f===u.length?c.contentTo:n.nodes.find(p=>p.id===u[f]).from;if(d===i.from||d===i.to)return{changes:[],selectedFrom:s};r=[{from:i.from,to:i.to,insert:""},{from:d,to:d,insert:e.slice(i.from,i.to)}],s=d-(d>i.to?i.to-i.from:0)}else if(t.type==="add"){i.structure||de("Choose a supported container with literal JSX children.");const a={text:'New text',spacer:"",stack:'',icon:''};Object.hasOwn(a,t.kind)||de("Unsupported new layer."),r=[{from:i.contentTo,to:i.contentTo,insert:a[t.kind]}],s=i.contentTo}else de("Unsupported layout operation.");r.sort((a,c)=>a.from-c.from);let o=e;for(const a of[...r].reverse())o=o.slice(0,a.from)+a.insert+o.slice(a.to);return wi(o).issue&&de("This edit would leave the supported layout. Your source was not changed."),{changes:r,selectedFrom:s}}const Dd=Lt.parser.configure({dialect:"jsx"}),Ci=n=>{const e=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t);return e},Qe=n=>{throw new Error(n)},Gi=Object.freeze({background:{type:"color"},surface:{type:"color"},foreground:{type:"color"},muted:{type:"color"},accent:{type:"color"},titleFont:{values:Re.globalProperties.font.values},bodyFont:{values:Re.globalProperties.font.values},fontDesign:{values:Re.globalProperties.fontDesign.values},corner:{type:"number",maximum:48},padding:{type:"number",maximum:48},spacing:{type:"number",maximum:32}}),mr={titleFont:"headline",bodyFont:"caption",fontDesign:"rounded",corner:20,padding:16,spacing:10},rs=Object.freeze({Meadow:Object.freeze({...mr,background:"#F2FAF5",surface:"#FFFFFF",foreground:"#193F31",muted:"#607C70",accent:"#328963"}),Paper:Object.freeze({...mr,background:"#F4F7FD",surface:"#FFFFFF",foreground:"#243454",muted:"#687795",accent:"#4777D6"}),Peach:Object.freeze({...mr,background:"#FFF5EE",surface:"#FFFFFF",foreground:"#56392C",muted:"#967461",accent:"#C86B43"}),Midnight:Object.freeze({...mr,background:"#192332",surface:"#283548",foreground:"#F1F5FC",muted:"#AABAD0",accent:"#8EB7FF"})});function Xd(n,e){Object.hasOwn(Gi,n)||Qe("Unknown theme token.");const t=Gi[n];t.type==="color"&&!(typeof e=="string"&&/^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/i.test(e))&&Qe(`${n} needs a six or eight digit hex color.`),t.values&&!t.values.includes(e)&&Qe(`${n} needs a supported font value.`),t.type==="number"&&!(typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=t.maximum)&&Qe(`${n} needs a number from zero to ${t.maximum}.`)}function ea(n){(!n||typeof n!="object"||Array.isArray(n)||Object.keys(n).length!==Object.keys(Gi).length)&&Qe("A theme needs exactly the documented tokens.");for(const e of Object.keys(n))Xd(e,n[e]);return n}function Ld(n){(typeof n!="string"||new TextEncoder().encode(n).length>4096)&&Qe("Theme JSON is limited to 4 KiB.");const e=JSON.parse(n);return(!e||Array.isArray(e)||Object.keys(e).sort().join()!=="formatVersion,name,tokens"||e.formatVersion!==1||typeof e.name!="string"||!e.name.trim()||/[\u0000-\u001f]/.test(e.name)||new TextEncoder().encode(e.name).length>64)&&Qe("Use a version 1 theme with a name of at most 64 bytes."),ea(e.tokens),e}function E1(n,e="My theme"){const t=JSON.stringify({formatVersion:1,name:e,tokens:n},null,2);return Ld(t),t}function ss(n){const e={source:n,tokens:null,ranges:{},issue:"",canInitialize:!1};try{(typeof n!="string"||new TextEncoder().encode(n).length>512*1024)&&Qe("Theme editing supports files up to 512 KiB.");const t=Dd.parse(n),i=[],r=[];if(t.iterate({enter(a){a.type.isError&&Qe("Fix JavaScript syntax before editing the theme."),["VariableDefinition","VariableName"].includes(a.name)&&n.slice(a.from,a.to).includes("\\")&&Qe("Escaped identifiers stay in Code."),n.slice(a.from,a.to)==="widgetTheme"&&["VariableDefinition","VariableName"].includes(a.name)&&(a.name==="VariableDefinition"?i:r).push(a.node)}}),!i.length&&!r.length){const a=wi(n);e.canInitialize=!a.issue&&a.roots.length===1&&!a.nodes[0].locked;let c=!1;for(const h of Ci(t.topNode)){const u=h.firstChild;a.nodes[0]&&h.name==="ExpressionStatement"&&u?.name==="CallExpression"&&n.slice(u.firstChild.from,u.firstChild.to)==="$render"&&u.froma.nodes[0].to&&(c=!0)}return e.canInitialize&&=c,e}i.length!==1&&Qe("Keep one top-level const widgetTheme object. Other bindings stay in Code.");const s=i[0].parent,o=Ci(s);(s.name!=="VariableDeclaration"||s.parent?.name!=="Script"||o[0]?.name!=="const"||o[1]?.from!==i[0].from||o[2]?.name!=="Equals"||o[3]?.name!=="ObjectExpression"||o.slice(4).some(a=>a.name!==";"))&&Qe("Theme editing needs a single top-level const widgetTheme = { … } declaration.");const l={};for(const a of Ci(o[3])){if(["{","}",","].includes(a.name))continue;const c=Ci(a),h=c[0]?n.slice(c[0].from,c[0].to):"",u=c[0]?.name==="String"&&h.startsWith('"')?JSON.parse(h):h;(a.name!=="Property"||c.length!==3||!["PropertyDefinition","String"].includes(c[0].name)||c[1].name!==":"||!["String","Number"].includes(c[2].name)||Object.hasOwn(l,u))&&Qe("Theme tokens must be unique literal properties. Computed or dynamic values stay in Code.");let f;try{f=JSON.parse(n.slice(c[2].from,c[2].to))}catch{Qe("Theme values use JSON strings or numbers. Edit this declaration in Code.")}Xd(u,f),l[u]=f,e.ranges[u]={from:c[2].from,to:c[2].to}}ea(l);for(const a of r){const c=a.parent,h=Ci(c),u=h[2]?n.slice(h[2].from,h[2].to):"";(c.name!=="MemberExpression"||h[0].from!==a.from||h[1]?.name!=="."||h[2]?.name!=="PropertyName"||!Object.hasOwn(Gi,u))&&Qe("Theme references must read widgetTheme.token. Other uses stay in Code."),c.parent?.name==="MemberExpression"&&Qe("Mutable theme references stay in Code.");for(let f=c.parent;f;f=f.parent)(["UpdateExpression","PostfixExpression"].includes(f.name)||f.name==="UnaryExpression"&&/^(?:delete|\+\+|--)/.test(n.slice(f.from,c.from).trim())||f.name==="AssignmentExpression"&&f.firstChild.from<=c.from&&f.firstChild.to>=c.to||f.name==="ForOfSpec"||f.name==="ForInSpec")&&Qe("Mutable theme references stay in Code.")}e.tokens=l}catch(t){e.issue=t.message}return e}function ho(n,e,t){return(n.source!==e||n.issue||!n.tokens)&&Qe("Theme changed or is unsupported. Reopen Theme before editing."),ea(t),{changes:Object.keys(Gi).filter(r=>t[r]!==n.tokens[r]).map(r=>({...n.ranges[r],insert:JSON.stringify(t[r])})).sort((r,s)=>r.from-s.from)}}function U1(n,e="Meadow"){(!ss(n).canInitialize||!Object.hasOwn(rs,e))&&Qe("Start with a literal top-level layout without an existing widgetTheme binding.");const i=wi(n),r=i.nodes[0],s=[];function o(c,h,u,f=!1){const d=c.properties.find(m=>m.name===h);if(c.locked||d&&!d.editable||!d&&!f)return;const p=`${h}={widgetTheme.${u}}`;s.push(d?{from:d.from,to:d.to,insert:p}:{from:c.insertAt,to:c.insertAt,insert:` ${p}`})}for(const c of["background","corner","padding"])o(r,c,c,!0);r.structure&&o(r,"spacing","spacing",!0);for(const c of i.nodes)if(c.component==="Text"){const h=c.properties.find(f=>f.name==="font")?.value,u=["headline","largeTitle","title","title2","title3"].includes(h);o(c,"font",u?"titleFont":"bodyFont",!0),o(c,"color",u?"foreground":"muted",!0),o(c,"fontDesign","fontDesign",!0)}else c.component==="Icon"&&o(c,"color","accent",!0);let l=0;for(const c of Ci(Dd.parse(n).topNode))if(!(c.name==="LineComment"||c.name==="BlockComment"))if(c.name==="ExpressionStatement"&&c.firstChild?.name==="String")l=c.to;else break;s.push({from:l,to:l,insert:` -const widgetTheme = ${JSON.stringify(rs[e],null,2)}; -`}),s.sort((c,h)=>c.from-h.from);let a=n;for(const c of[...s].reverse())a=a.slice(0,c.from)+c.insert+a.slice(c.to);return(!ss(a).tokens||wi(a).issue)&&Qe("This layout cannot be themed automatically. Your source was preserved."),{changes:s}}function Bd(n){if(!Array.isArray(n)||n.length>4096)return[];const e=new Map,t=new Set;for(const i of n){if(typeof i!="string"||new TextEncoder().encode(i).length>1024||/[\\\u0000-\u001f\u007f-\u009f]/.test(i))continue;const r=i.split("/");if(r.length!==2||r[0]!=="image"||!r[1]||new TextEncoder().encode(r[1]).length>255||r[1]!==r[1].trim()||r[1].includes("..")||!/\.(png|jpe?g|webp)$/i.test(r[1]))continue;const s=i.normalize("NFC").toLowerCase();e.has(s)&&e.get(s)!==i&&t.add(s),e.set(s,i)}return[...e].filter(([i])=>!t.has(i)).map(([,i])=>i).sort().slice(0,256)}const ta=W.define(),os=Te.define({create:()=>[],update(n,e){for(const t of e.effects)t.is(ta)&&(n=Bd(t.value));return n}});function ia(n,e){n.state.field(os,!1)!==void 0&&n.dispatch({effects:ta.of(e)})}const qd=Object.freeze({bloom:Object.freeze({name:"Bloom mark",description:"A small four-petal flower",kind:"icon"}),leaf:Object.freeze({name:"Leaf mark",description:"A tilted leaf and stem",kind:"icon"}),pebble:Object.freeze({name:"Pebble friend",description:"A quiet, round-eared companion",kind:"pet"})}),uo=`/* -ScriptWidget original geometric assets 1: Bloom mark, Leaf mark, Pebble friend. -Source: https://github.com/everettjf/scriptwidget (Editor/editorfe/src/visualAssets.js) -SPDX-License-Identifier: MIT -Copyright (c) 2021-2022 everettjf - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ -`;function F1(n,e){const t=i=>e?`{widgetTheme.${i}}`:JSON.stringify(rs.Meadow[i]);if(n==="bloom")return``;if(n==="leaf")return``;if(n==="pebble")return``;throw new Error("Choose an original asset from the catalog.")}function D1(n,e,{id:t,kind:i,path:r},s=[]){if(n.source!==e||n.issue)throw new Error("Layout changed. Select the container again.");const o=n.nodes.find(f=>f.id===t);if(!o?.structure)throw new Error("Select a stack/grid with literal JSX children in Layout or Assets.");let l;if(i==="photo"){if(!Bd(s).includes(r))throw new Error("This image is no longer in the package resource list. Refresh images.");l=``}else{if(!Object.hasOwn(qd,i))throw new Error("Choose an original asset from the catalog.");l=F1(i,!!ss(e).tokens)}const a=[{from:o.contentTo,to:o.contentTo,insert:l}];let c=o.contentTo;if(i!=="photo"&&!e.includes(uo)){const f=e.startsWith("#!")?e.indexOf(` -`)+1:0;a.push({from:f,to:f,insert:uo}),c+=uo.length}a.sort((f,d)=>f.from-d.from);let h=e;for(const f of[...a].reverse())h=h.slice(0,f.from)+f.insert+h.slice(f.to);if(wi(h).issue)throw new Error("This asset would exceed the supported layout limits. Your source was preserved.");return{changes:a,selectedFrom:c}}const X1=n=>["string","number","number|string","date|number","boolean","enum","color","url","action-id","storage-key"].includes(n.type);function L(n,e,t){const i=document.createElement(n);return e&&(i.className=e),t!==void 0&&(i.textContent=t),i}function L1(n,e){const t=L("section","sw-layout"),i=L("div","sw-layout-header"),r=L("div","sw-layout-body");t.setAttribute("aria-label","Visual layout editor");let s=!1,o="layout",l=null,a=null,c="",h=null,u=!1,f=0;const d=String(Math.random()),p=(Q,D)=>P=>{if(u||!t.contains(Q)){P.preventDefault();return}return D(P)},m=(Q,D,P)=>Q.addEventListener(D,p(Q,P)),O=(Q,D,P=!1)=>{const V=L("button","sw-layout-button",Q);return V.type="button",V.disabled=P,m(V,"click",D),V},y=O("Layout",()=>{s=o==="layout"?!s:!0,o="layout",Y(),n.requestMeasure()});y.classList.add("sw-layout-toggle"),y.setAttribute("aria-expanded","false");const b=L("span","sw-layout-hint","Select layers and edit literal JSX"),x=O("Undo",()=>Xl(n)),C=O("Redo",()=>Wr(n)),k=O("Theme",()=>{s=o==="theme"?!s:!0,o="theme",Y(),n.requestMeasure()});k.setAttribute("aria-expanded","false");const S=O("Assets",()=>{s=o==="assets"?!s:!0,o="assets",Y(),n.requestMeasure()});S.setAttribute("aria-expanded","false"),i.append(y,k,S,b,x,C),t.append(i,r),r.hidden=x.hidden=C.hidden=!0;const v=L("p","sw-layout-error");v.setAttribute("role","alert"),v.hidden=!0,t.append(v);function U(){l=wi(n.state.doc.toString());const Q=L("div","sw-layout-inspector sw-theme-inspector");if(r.replaceChildren(Q),Q.append(L("div","sw-layout-title","Widget assets")),Q.append(L("p","sw-layout-notice","Insert editable original JSX or a package image. Originals follow connected theme colors; pet artwork is static. Import photos with the app's existing image tools or Web Studio's Add image.")),l.issue){Q.append(L("p","sw-layout-notice",l.issue));return}const D=l.nodes.filter(q=>q.structure),P=L("select");P.setAttribute("aria-label","Asset destination");for(const q of D){const G=L("option","",`${q.tag} · line ${n.state.doc.lineAt(q.from).number}`);G.value=q.id,P.append(G)}D.some(q=>q.id===a)?P.value=a:a=P.value,m(P,"change",()=>{a=P.value}),Q.append(P);const V=n.state.readOnly||!D.length;D.length||Q.append(L("p","sw-layout-notice","Add a stack/grid with literal JSX children in Code to insert assets."));function le(q,G){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");const ce=D1(l,n.state.doc.toString(),{id:P.value,kind:q,path:G},n.state.field(os));a=P.value,v.hidden=!0,n.dispatch({changes:ce.changes,selection:{anchor:ce.selectedFrom},annotations:vr.of("full"),userEvent:"input.asset",scrollIntoView:!0})}catch(ce){v.textContent=ce.message,v.hidden=!1}}for(const[q,G]of Object.entries(qd)){const ce=L("div","sw-layout-actions");ce.append(O(`Insert ${G.name}`,()=>le(q),V),L("span","",G.description)),Q.append(ce)}Q.append(L("div","sw-layout-title","Package images"));const J=n.state.field(os),ee=L("select");ee.setAttribute("aria-label","Package image");for(const q of J){const G=L("option","",q);G.value=q,ee.append(G)}ee.disabled=!J.length,Q.append(ee,O("Insert package image",()=>le("photo",ee.value),V||!J.length)),J.length||Q.append(L("p","sw-layout-notice","No supported images in image/. Add a PNG, JPEG or WebP to the package, then refresh or reopen the editor.")),e.refreshResources&&Q.append(O("Refresh images",async()=>{const q=++f,G=n.state.doc,ce=()=>!u&&q===f&&n.state.doc===G;try{const I=await e.refreshResources();ce()&&(v.hidden=!0,ia(n,I))}catch{ce()&&(v.textContent="Images could not be refreshed. Reopen this document and try again.",v.hidden=!1)}})),Q.append(L("p","sw-layout-notice","Bloom mark, Leaf mark and Pebble friend: original ScriptWidget geometry, MIT licensed. Package photos retain their own rights. See the Studio assets documentation."))}function F(Q,D){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");const P=n.state.doc.toString();if(P!==D)throw new Error("Source changed. Reopen Theme before editing.");const V=Q(P);v.hidden=!0,V.changes.length&&n.dispatch({changes:V.changes,annotations:vr.of("full"),userEvent:"input.theme"})}catch(P){v.textContent=P.message,v.hidden=!1}}function j(){const Q=n.state.doc.toString(),D=ss(Q),P=n.state.readOnly,V=L("div","sw-layout-inspector sw-theme-inspector");if(r.replaceChildren(V),V.append(L("div","sw-layout-title","Widget theme")),V.append(L("p","sw-layout-notice","Saved as ordinary JavaScript with your widget. Dynamic values stay in Code. Applying a theme changes the connected colors, fonts and spacing.")),D.issue){V.append(L("p","sw-layout-notice",D.issue));return}if(!D.tokens){V.append(O("Connect layout to Meadow theme",()=>F(ee=>U1(ee),Q),P||!D.canInitialize)),D.canInitialize||V.append(L("p","sw-layout-notice","Use a literal top-level $render layout, or define the documented widgetTheme object in Code."));return}const le=L("div","sw-layout-actions");for(const[ee,q]of Object.entries(rs))le.append(O(ee,()=>F(G=>ho(D,G,q),Q),P));V.append(le);for(const[ee,q]of Object.entries(Gi)){const G=L("form","sw-layout-form"),ce=L("label","",ee),I=L(q.values?"select":"input");if(q.values)for(const se of q.values){const Me=L("option","",se);Me.value=se,I.append(Me)}q.type==="number"&&(I.type="number",I.min="0",I.max=String(q.maximum),I.step="any"),I.value=String(D.tokens[ee]),I.setAttribute("aria-label",`Theme ${ee}`),I.disabled=P;const te=O(`Apply ${ee}`,()=>{},P);te.type="submit",G.append(ce,I,te),m(G,"submit",se=>{se.preventDefault();const Me=q.type==="number"?I.value.trim()?Number(I.value):NaN:I.value;F(ge=>ho(D,ge,{...D.tokens,[ee]:Me}),Q)}),V.append(G)}const J=L("textarea");J.rows=5,J.setAttribute("aria-label","Reusable theme JSON"),J.value=E1(D.tokens),V.append(L("label","","Copy this JSON to reuse a theme, or paste a version 1 theme and import it."),J,O("Import theme JSON",()=>F(ee=>ho(D,ee,Ld(J.value).tokens),Q),P))}function E(Q,D=l?.source){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");if(D!==n.state.doc.toString())throw new Error("Source changed during this operation. Select the layer again.");const P=M1(l,n.state.doc.toString(),Q);if(v.hidden=!0,!P.changes.length)return;n.dispatch({changes:P.changes,selection:{anchor:P.selectedFrom},annotations:vr.of("full"),userEvent:"input.layout",scrollIntoView:!0})}catch(P){v.textContent=P.message,v.hidden=!1}}function M(Q){u||(a=Q.id,c="",n.dispatch({selection:{anchor:Q.from,head:Q.to},scrollIntoView:!0,userEvent:"select.layout"}),Y())}function Y(){if(y.setAttribute("aria-expanded",String(s&&o==="layout")),k.setAttribute("aria-expanded",String(s&&o==="theme")),S.setAttribute("aria-expanded",String(s&&o==="assets")),r.hidden=!s,x.hidden=C.hidden=!s,b.hidden=s,x.disabled=n.state.readOnly||wc(n.state)===0,C.disabled=n.state.readOnly||vc(n.state)===0,!s)return;if(o==="assets"){U();return}if(o==="theme"){j();return}if(l=wi(n.state.doc.toString()),r.replaceChildren(),l.issue){r.append(L("p","sw-layout-notice",l.issue));return}const Q=n.state.selection.main.from,D=l.nodes.filter(I=>I.from<=Q&&QI.id===a&&I.from<=Q&&Q<=I.to)??D??l.nodes[0];a=P.id;const V=L("div","sw-layout-layers");V.setAttribute("role","tree"),V.setAttribute("aria-label","Layout layers");const le=n.state.readOnly,J=I=>{const te=I.text??I.properties.find(se=>se.name==="text"&&se.editable&&typeof se.value=="string")?.value;return`<${I.tag}>${te?` · ${te.slice(0,32)}`:""}${I.locked?" · locked":""}`};for(const[I,te]of l.nodes.entries()){const se=l.nodes.find(ie=>ie.id===te.parentID),Me=!le&&!te.locked&&se?.structure,ge=O(J(te),()=>M(te));ge.classList.add("sw-layout-layer"),ge.dataset.layerId=te.id,ge.style.paddingInlineStart=`${8+te.depth*14}px`,ge.setAttribute("role","treeitem"),ge.setAttribute("aria-level",String(te.depth+1)),ge.setAttribute("aria-selected",String(te.id===P.id)),ge.tabIndex=te.id===P.id?0:-1,ge.draggable=!!Me,m(ge,"keydown",ie=>{let we;ie.key==="ArrowUp"&&(we=l.nodes[Math.max(0,I-1)]),ie.key==="ArrowDown"&&(we=l.nodes[Math.min(l.nodes.length-1,I+1)]),ie.key==="ArrowLeft"&&(we=se),ie.key==="ArrowRight"&&(we=l.nodes.find(qe=>qe.id===te.children[0])),ie.key==="Home"&&(we=l.nodes[0]),ie.key==="End"&&(we=l.nodes.at(-1)),we&&(ie.preventDefault(),ie.stopPropagation(),M(we),ee().find(qe=>qe.dataset.layerId===we.id)?.focus())}),m(ge,"dragstart",ie=>{if(!Me){ie.preventDefault();return}h={id:te.id,source:l.source},ie.dataTransfer.setData("application/x-scriptwidget-layer",d),ie.dataTransfer.effectAllowed="move"}),m(ge,"dragover",ie=>{h&&se?.structure&&te.id!==h.id&&(ie.preventDefault(),ie.dataTransfer.dropEffect="move")}),m(ge,"drop",ie=>{if(!h||ie.dataTransfer.getData("application/x-scriptwidget-layer")!==d||!se?.structure)return;ie.preventDefault();const we=h;h=null,E({type:"move",id:we.id,parentID:se.id,index:se.children.filter(qe=>qe!==we.id).indexOf(te.id)},we.source)}),m(ge,"dragend",()=>{h=null}),V.append(ge)}function ee(){return[...t.querySelectorAll(".sw-layout-layer")]}const q=L("div","sw-layout-inspector"),G=L("div","sw-layout-title",`<${P.tag}>`);if(q.append(G),(le||P.locked)&&q.append(L("p","sw-layout-notice",le?"This document is read only.":P.reason)),!le&&!P.locked){let ge=function(){c=se.value;const oe=hl(P)[c],Ae=P.properties.find(tt=>tt.name===c);if(Me.replaceChildren(),te.onsubmit=tt=>tt.preventDefault(),Ae&&!Ae.editable){Me.append(L("span","sw-layout-notice","Dynamic value: edit it in Code. Connected widgetTheme tokens can be changed in Theme."));return}const ae=L(oe.values||oe.type==="boolean"?"select":"input");ae.setAttribute("aria-label","Layout property value");for(const tt of oe.values??(oe.type==="boolean"?[!0,!1]:[])){const li=L("option","",String(tt));li.value=String(tt),ae.append(li)}ae.value=Ae?String(Ae.value):oe.values?.[0]??(oe.type==="boolean"?"true":"");const Ie=O("Apply",()=>{});Ie.type="submit",Me.append(ae,Ie,O("Remove",()=>E({type:"property",id:P.id,name:c,remove:!0}),!Ae||oe.required)),te.onsubmit=p(te,tt=>{tt.preventDefault();const li=oe.type==="boolean"?ae.value==="true":oe.type==="number"?ae.value.trim()?Number(ae.value):NaN:ae.value;E({type:"property",id:P.id,name:c,value:li})})};if(P.textEditable){const oe=L("form","sw-layout-form"),Ae=L("label","","Text"),ae=L("input");ae.value=P.text,ae.setAttribute("aria-label","Layer text");const Ie=O("Apply text",()=>{});Ie.type="submit",oe.append(Ae,ae,Ie),m(oe,"submit",tt=>{tt.preventDefault(),E({type:"text",id:P.id,value:ae.value})}),q.append(oe)}const I=Object.entries(hl(P)).filter(([,oe])=>X1(oe)),te=L("form","sw-layout-form"),se=L("select");se.setAttribute("aria-label","Layout property");for(const[oe]of I){const Ae=L("option","",oe);Ae.value=oe,se.append(Ae)}I.some(([oe])=>oe===c)||(c=P.structure?"alignment":"color"),se.value=c,se.value||(se.selectedIndex=0,c=se.value);const Me=L("div","sw-layout-property");te.append(se,Me),m(se,"change",ge),ge(),q.append(te);const ie=l.nodes.find(oe=>oe.id===P.parentID),we=ie?.children.indexOf(P.id)??-1,qe=L("div","sw-layout-actions");if(qe.append(O("Move up",()=>E({type:"move",id:P.id,parentID:ie.id,index:we-1}),!ie?.structure||we<=0),O("Move down",()=>E({type:"move",id:P.id,parentID:ie.id,index:we+1}),!ie?.structure||we>=ie.children.length-1),O("Delete layer",()=>E({type:"remove",id:P.id}),!ie?.structure)),q.append(qe),ie?.structure){const oe=l.nodes.filter(ae=>ae.structure&&!(ae.from>=P.from&&ae.to<=P.to)),Ae=L("select");Ae.setAttribute("aria-label","Move layer into container");for(const ae of oe){const Ie=L("option","",`${ae.tag} · line ${n.state.doc.lineAt(ae.from).number}`);Ie.value=ae.id,Ae.append(Ie)}q.append(Ae,O("Move inside",()=>{const ae=l.nodes.find(Ie=>Ie.id===Ae.value);E({type:"move",id:P.id,parentID:ae.id,index:ae.children.filter(Ie=>Ie!==P.id).length})},!oe.length))}if(P.structure){const oe=L("div","sw-layout-actions");for(const[Ae,ae]of[["text","Add text"],["stack","Add stack"],["spacer","Add spacer"],["icon","Add icon"]])oe.append(O(ae,()=>E({type:"add",id:P.id,kind:Ae})));q.append(oe)}}const ce=P.properties.filter(I=>!I.editable).map(I=>I.name);ce.length&&q.append(L("p","sw-layout-notice",`Preserved in Code: ${ce.join(", ")}`)),!P.structure&&P.children.length&&q.append(L("p","sw-layout-notice","This child structure stays in Code. Reordering is available on literal stack/grid children.")),r.append(V,q)}return{dom:t,top:!0,update(Q){if(!s)return;const D=n.state.selection.main.from,P=l?.nodes.filter(le=>le.from<=D&&Dle.effects.some(J=>J.is(ta)));(Q.docChanged||V||Q.startState.readOnly!==n.state.readOnly||Q.selectionSet&&P!==a)&&(Q.docChanged&&o!=="assets"&&(a=null),Y()),x.disabled=n.state.readOnly||wc(n.state)===0,C.disabled=n.state.readOnly||vc(n.state)===0},destroy(){u=!0}}}const B1=R.baseTheme({".sw-layout":{fontFamily:"system-ui, sans-serif",fontSize:"12px",backgroundColor:"#f6f7fa",color:"#272a34",borderBottom:"1px solid #dce0e9"},"&dark .sw-layout":{backgroundColor:"#252830",color:"#eceef5",borderColor:"#414552"},".sw-layout-header":{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"8px",padding:"6px 10px"},".sw-layout-toggle":{fontWeight:"600"},".sw-layout-hint":{opacity:"0.65",fontSize:"11px"},".sw-layout-button":{fontFamily:"inherit",fontSize:"11px",color:"inherit",backgroundColor:"transparent",border:"1px solid #a0a5b655",borderRadius:"6px",padding:"4px 8px",cursor:"pointer",whiteSpace:"nowrap"},".sw-layout-button:disabled":{opacity:"0.4",cursor:"default"},".sw-layout-body":{display:"grid",gridTemplateColumns:"minmax(120px, 1fr) minmax(180px, 1.6fr)",maxHeight:"280px",overflow:"auto",borderTop:"1px solid #a0a5b633"},".sw-layout-body[hidden]":{display:"none"},".sw-layout-layers":{padding:"6px 2px",overflow:"auto",borderRight:"1px solid #a0a5b633"},".sw-layout-layer":{display:"block",border:0,borderRadius:"4px",width:"100%",textAlign:"left",overflow:"hidden",textOverflow:"ellipsis",margin:"1px 0",paddingBlock:"6px"},'.sw-layout-layer[aria-selected="true"]':{backgroundColor:"#4085f52b",color:"inherit"},".sw-layout-inspector":{padding:"8px 10px",display:"flex",alignItems:"start",flexDirection:"column",gap:"8px",minWidth:0},".sw-theme-inspector":{gridColumn:"1 / -1"},".sw-theme-inspector textarea":{boxSizing:"border-box",width:"100%",fontFamily:"monospace",backgroundColor:"transparent",color:"inherit",border:"1px solid #a0a5b666",borderRadius:"5px"},".sw-layout-title":{fontWeight:"600"},".sw-layout-form":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"5px",width:"100%"},".sw-layout-property,.sw-layout-actions":{display:"flex",flexWrap:"wrap",gap:"5px",alignItems:"center"},".sw-layout input,.sw-layout select":{fontFamily:"inherit",fontSize:"12px",minWidth:0,maxWidth:"100%",padding:"4px 6px",border:"1px solid #a0a5b666",borderRadius:"5px",backgroundColor:"transparent",color:"inherit"},".sw-layout-notice":{margin:"8px",lineHeight:"1.5",fontSize:"11px",opacity:"0.7"},".sw-layout-body > .sw-layout-notice":{gridColumn:"1 / -1"},".sw-layout-error":{margin:"0 10px 6px",color:"#b32636",fontSize:"12px"},"&dark .sw-layout-error":{color:"#ff99a4"},".sw-layout button:focus-visible,.sw-layout input:focus-visible,.sw-layout select:focus-visible":{outline:"2px solid #4085f5",outlineOffset:"1px"},"@media (max-width: 480px)":{".sw-layout-body":{gridTemplateColumns:"minmax(90px, 1fr) minmax(150px, 1.6fr)"},".sw-layout-hint":{display:"none"}}});function q1(n={}){return[B1,os,ji.of(e=>L1(e,n))]}const Id="scriptwidget.studio.document-state.v1.";function zd(n,e,t){if(!n||!e)return!1;try{return n.setItem(`${Id}${e}`,JSON.stringify({anchor:Number(t.anchor)||0,head:Number(t.head)||0,scrollTop:Number(t.scrollTop)||0})),!0}catch{return!1}}function I1(n,e,t){if(!n||!e)return null;try{const i=JSON.parse(n.getItem(`${Id}${e}`));if(!i||typeof i!="object")return null;const r=s=>Math.max(0,Math.min(Number(s)||0,t));return{anchor:r(i.anchor),head:r(i.head),scrollTop:Math.max(0,Number(i.scrollTop)||0)}}catch{return null}}const z1="scriptwidget.web-studio.draft.v1:";function na(n){return`${z1}${n}`}function W1(n,e){if(!e)return null;try{const t=JSON.parse(n.getItem(na(e))||"null");return t&&typeof t.content=="string"&&typeof t.baseRevision=="string"?t:null}catch{return null}}function hh(n,e,t,i,r=Date.now()){if(!e||typeof i!="string")return null;const s={documentID:e,content:t,baseRevision:i,updatedAt:r};return n.setItem(na(e),JSON.stringify(s)),s}function fo(n,e){e&&n.removeItem(na(e))}function j1(n,e,t,i){const r=W1(n,e);return!r||r.content===t?null:{...r,serverContent:t,serverRevision:i,isStale:r.baseRevision!==i}}function V1(){return{connection:"connecting",save:"idle",preview:"idle",conflict:null}}function Y1(n,e){switch(e.type){case"CONNECTED":return{...n,connection:"connected"};case"OFFLINE":return{...n,connection:"offline",save:n.save==="saving"?"draft":n.save};case"DISCONNECTED":return{...n,connection:"disconnected"};case"EDITED":return{...n,save:"draft",conflict:null};case"SAVING":return{...n,save:"saving"};case"SAVED":return{...n,save:"saved",preview:e.preview||"requested",conflict:null};case"SAVE_FAILED":return{...n,save:"error"};case"CONFLICT":return{...n,save:"conflict",conflict:e.conflict};default:return n}}class N1{constructor(e){this.send=e,this.epoch=0,this.context=null,this.inFlight=null,this.needsFlush=!1}open({documentID:e,packageID:t,path:i,revision:r,content:s}){return this.epoch+=1,this.context={documentID:e,packageID:t,path:i,revision:r,content:s,generation:0,savedGeneration:0},this.needsFlush=!1,this.snapshot()}edit(e){return this.context?(this.context.content=e,this.context.generation+=1,this.snapshot()):null}rebase(e){return this.context&&(this.context.revision=e),this.snapshot()}get isDirty(){return!!(this.context&&this.context.generation!==this.context.savedGeneration)}snapshot(){return this.context?{...this.context,dirty:this.isDirty}:null}async flush(){if(!this.context||!this.isDirty)return{skipped:!0,snapshot:this.snapshot()};if(this.inFlight)return this.needsFlush=!0,this.inFlight.then(()=>this.isDirty?this.flush():{skipped:!0,snapshot:this.snapshot()});const e=this.epoch,t={...this.context};this.needsFlush=!1,this.inFlight=this.send({documentID:t.documentID,packageID:t.packageID,path:t.path,content:t.content,baseRevision:t.revision}).then(r=>this.epoch!==e||this.context?.documentID!==t.documentID?{ignored:!0,result:r,snapshot:this.snapshot()}:(this.context.revision=r.revision,this.context.savedGeneration=t.generation,{result:r,snapshot:this.snapshot()})).finally(()=>{this.inFlight=null});const i=await this.inFlight;return this.needsFlush&&this.isDirty?this.flush():i}}function uh(n){return["draft","saving","error","conflict"].includes(n)}class G1 extends Error{constructor(e,t,i={}){super(e),this.name="StudioAPIError",this.status=t,this.body=i}}class H1{constructor({fetchImpl:e=globalThis.fetch,token:t=()=>"",onUnauthorized:i=()=>{}}={}){if(typeof e!="function")throw new TypeError("A fetch implementation is required");this.fetchImpl=e,this.token=t,this.onUnauthorized=i}async request(e,t={}){const i=await this.fetchImpl(e,this.authorizedOptions(t)),r=await i.json().catch(()=>({}));return this.validate(i,e,r),r}async requestBlob(e,t={}){const i=await this.fetchImpl(e,this.authorizedOptions(t));if(!i.ok){const r=await i.json().catch(()=>({}));this.validate(i,e,r)}return i.blob()}authorizedOptions(e){return{...e,headers:{"Content-Type":"application/json","X-Studio-Token":this.token(),...e.headers||{}}}}validate(e,t,i){if(!e.ok){const r=new G1(i.message||`Request failed (${e.status})`,e.status,i);throw e.status===401&&t!=="/api/v1/pair"&&this.onUnauthorized(r),r}}}const ra=/^https?:$/.test(window.location.protocol),_1=document.querySelector(ra?"#editor":"#native-editor"),sa=new Hi,ls=new Hi;let It=null,me=null,Et=null,lt=0,vi=0,ul=!1,Mn=null,fh=null;const dh=document.querySelector("#save-status");let Wd=null;function En(n,e="idle"){dh.textContent=n,dh.dataset.state=e}function J1(){window.clearTimeout(fh),fh=window.setTimeout(()=>{const n=z.state.selection.main;zd(window.localStorage,me,{anchor:n.anchor,head:n.head,scrollTop:z.scrollDOM.scrollTop})},180)}function jd(){return window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"}function oa(){window.clearTimeout(Mn),En("Saving…","saving"),Mn=window.setTimeout(()=>{const n=z.state.doc.toString(),e=lt,t=me,i=Et,r=vi;nn(It,Ue.documentSave,{content:n,version:e},t,(s={})=>{ra||t!==me||i!==Et||r!==vi||e!==lt||En(s.result==="ok"||s.result==="unavailable"?"Saved":"Save failed",s.result==="failed"?"error":"saved")},i)},700)}function eS(n){if((n.selectionSet||n.viewportChanged||n.docChanged)&&J1(),!n.docChanged||ul)return;lt+=1,Wd?.documentChanged();const e=[];n.changes.iterChanges((t,i,r,s,o)=>{e.push({from:t,to:i,insert:o.toString(),newFrom:r,newTo:s})}),nn(It,Ue.documentChanged,{changes:e,version:lt},me,void 0,Et),oa()}const Vd=[ng(),og(),xO(),v0(),q1({refreshResources:()=>new Promise((n,e)=>{const t=me,i=vi,r=Et,s=window.setTimeout(()=>e(new Error("Resource refresh timed out")),5e3);nn(It,Ue.documentResources,{},t,(o={})=>{window.clearTimeout(s),t!==me||i!==vi||o.result!=="ok"||o.documentID!==t||!Array.isArray(o.resources)?e(new Error("Document resources are unavailable")):n(o.resources)},r)})}),Gg(),hO(),OO(),_.allowMultipleSelections.of(!0),Ug(),c0(),uA(),xA({override:[v1],activateOnTyping:!0}),MO(),FO(),CO(),Qb(),f1(),i1(Ed,{delay:350}),Eu(k1),yb({jsx:!0}),ms.of([Py,...mA,...Qy,...Vb,...Z0,...jg,...nd]),sa.of(_.readOnly.of(!1)),ls.of(Ud(jd())),R.updateListener.of(eS),R.contentAttributes.of({autocapitalize:"off",autocomplete:"off",spellcheck:"false"})],z=new R({state:_.create({doc:"",extensions:Vd}),parent:_1});function _t(n,e=me,t=0,i=!1){window.clearTimeout(Mn),vi+=1;const r=z.state.selection.main;zd(window.localStorage,me,{anchor:r.anchor,head:r.head,scrollTop:z.scrollDOM.scrollTop}),ul=!0;const s=e!==me;me=e,lt=t;const o=I1(window.localStorage,me,(n??"").length),l=o?{anchor:o.anchor,head:o.head}:{anchor:0};if(s){const a=ls.get(z.state),c=z.state.readOnly;let h=_.create({doc:n??"",extensions:Vd,selection:l});h=h.update({effects:[ls.reconfigure(a),sa.reconfigure(_.readOnly.of(c))]}).state,z.setState(h)}else z.dispatch({changes:{from:0,to:z.state.doc.length,insert:n??""},selection:l,scrollIntoView:!0});o&&window.requestAnimationFrame(()=>{z.scrollDOM.scrollTop=o.scrollTop}),ul=!1,i&&nn(It,Ue.documentChanged,{content:z.state.doc.toString(),version:lt},me,void 0,Et),En("Saved","saved")}function ph(n){if(z.state.readOnly)return!1;const e=z.state.selection.main;return z.dispatch({changes:{from:e.from,to:e.to,insert:n},selection:{anchor:e.from+n.length},userEvent:"input"}),z.focus(),!0}async function as(){if(z.state.readOnly)return!1;const n=z.state.doc.toString(),e=vi,t=lt,i=()=>!z.state.readOnly&&e===vi&&t===lt&&n===z.state.doc.toString();try{const[{format:r},{default:s},{default:o}]=await Promise.all([Cs(()=>import("./standalone-Cayz_KD-.js"),[],import.meta.url),Cs(()=>import("./babel-BktJt1uC.js"),[],import.meta.url),Cs(()=>import("./estree-DFfjoHvx.js"),[],import.meta.url)]),l=await r(n,{parser:"babel",plugins:[s,o],semi:!0,singleQuote:!0,trailingComma:"es5"});return i()?(_t(l,me,lt+1,!0),oa(),!0):!1}catch(r){return i()&&nn(It,"diagnostics.publish",{message:String(r),severity:"error"},me,void 0,Et),!1}}function Li(n){z.dispatch({effects:sa.reconfigure(_.readOnly.of(!!n))})}function cs(n){const e=n==="dark"||n==="light"?n:jd();document.documentElement.dataset.theme=e,z.dispatch({effects:ls.reconfigure(Ud(e))})}function tS(n=[]){const e=n.map(t=>({from:Math.max(0,Math.min(t.from??0,z.state.doc.length)),to:Math.max(0,Math.min(t.to??t.from??0,z.state.doc.length)),severity:t.severity??"error",message:t.message??"Unknown error"}));z.dispatch(wd(z.state,e))}function st(n,e){It.registerHandler(n,async(t={},i=()=>{})=>{try{if(Et!==null&&n!==Ue.documentOpen&&n!==Ue.editorSetTheme&&(t.documentID!==me||t.sessionID!==Et))throw new Error("The editor session changed.");i({result:"ok",...await e(t)})}catch(r){i({result:"failed",message:String(r)})}})}p1(n=>{It=n,st(Ue.documentOpen,({payload:e={},documentID:t,sessionID:i=null})=>(Et=i,_t(e.content,t,e.version??0),ia(z,e.resources??[]),Li(e.readOnly),e.dirty&&(En("Restored unsaved edits","editing"),e.readOnly||oa()),{protocolVersion:Zd})),st(Ue.documentReplace,({payload:e={},documentID:t})=>{if(z.state.readOnly||e.expectedContent!==void 0&&e.expectedContent!==z.state.doc.toString())throw new Error("The file changed or is read only.");return _t(e.content,t,e.version??lt,!0),{}}),st(Ue.documentSetReadOnly,({payload:e={}})=>(Li(e.readOnly),{readOnly:!!e.readOnly})),st(Ue.editorInsert,({payload:e={}})=>({inserted:ph(e.content??"")})),st(Ue.editorFormat,async()=>({formatted:await as()})),st(Ue.editorSetTheme,({payload:e={}})=>(cs(e.theme),{})),st(Ue.editorGetState,()=>({content:z.state.doc.toString(),version:lt,documentID:me,sessionID:Et,selection:{from:z.state.selection.main.from,to:z.state.selection.main.to}})),st(Ue.diagnosticsPublish,({payload:e={}})=>(tS(e.items),{})),st("editor_setValue",({value:e})=>(_t(e),{})),st("editor_insertValue",({value:e})=>({inserted:ph(e??"")})),st("editor_getValue",()=>({value:z.state.doc.toString()})),st("editor_setReadonly",({readonly:e})=>(Li(e),{readonly:!!e})),st("editor_formatCode",async()=>({formatted:await as()})),m1(It)});ra&&(document.querySelector("#native-editor").hidden=!0,document.querySelector("#web-studio").hidden=!1,iS());async function iS(){const n=document.querySelector("#pair-dialog"),e=document.querySelector("#pair-form"),t=document.querySelector("#pair-error"),i=document.querySelector("#package-select"),r=document.querySelector("#file-select"),s=document.querySelector("#connection-status"),o=document.querySelector("#disconnect-button"),l=document.querySelector("#studio-grid"),a=document.querySelector(".editor-column"),c=document.querySelector("#recovery-banner"),h=document.querySelector("#conflict-banner"),u=document.querySelector("#command-dialog"),f=document.querySelector("#command-search"),d=document.querySelector("#command-list"),p=document.querySelector("#compare-dialog");let m=window.sessionStorage.getItem("scriptwidget.web-studio.token")||"",O=[],y=null,b=null,x=null,C=0,k=null,S="",v="",U=null,F=V1(),j="",E="",M=null;function Y(w="Session ended. Enter the new code shown on your device."){m="",window.sessionStorage.removeItem("scriptwidget.web-studio.token"),o.hidden=!0,Q({type:"DISCONNECTED"}),s.textContent=w,Li(!0),n.open||n.showModal()}function Q(w){F=Y1(F,w);const Z={connecting:"Connecting",connected:"Connected",offline:"Offline",disconnected:"Disconnected"},X={idle:"Ready",draft:"Draft saved locally",saving:"Saving…",saved:"Saved",error:"Save failed",conflict:"Conflict"};s.dataset.state=F.connection,document.querySelector("#status-connection").textContent=Z[F.connection]||F.connection,En(X[F.save]||F.save,F.save),document.querySelector("#dirty-indicator").hidden=!["draft","saving","error","conflict"].includes(F.save),document.querySelector("#status-preview").textContent=F.preview==="requested"?"Preview requested":"Preview idle",document.querySelector("#preview-detail").textContent=F.preview==="requested"?"Requested on device":"Not requested"}const D=new H1({token:()=>m,onUnauthorized:()=>Y()}),P=(w,Z)=>D.request(w,Z);M=new N1(({packageID:w,path:Z,content:X,baseRevision:ne})=>P("/api/v1/document",{method:"PUT",body:JSON.stringify({package:w,path:Z,content:X,baseRevision:ne})}));async function V(w){m=(await P("/api/v1/pair",{method:"POST",body:JSON.stringify({code:w})})).token,window.sessionStorage.setItem("scriptwidget.web-studio.token",m),o.hidden=!1,Q({type:"CONNECTED"}),le()}function le(){window.clearInterval(y),y=window.setInterval(async()=>{if(m)try{const w=await P("/api/v1/session");if(!navigator.onLine)return;I(w),Q({type:"CONNECTED"})}catch(w){w.status!==401&&(s.textContent=`Interrupted · ${w.message}`,Q({type:"OFFLINE"}))}},5e3)}async function J(){if(O=(await P("/api/v1/packages")).packages||[],i.replaceChildren(...O.map(Z=>new Option(Z.name,Z.id))),!O.length){s.textContent="No editable widgets",Li(!0);return}await ee()}async function ee(){const w=O.find(ne=>ne.id===i.value),Z=w?.files||[];r.replaceChildren(...Z.map(ne=>new Option(ne,ne)));const X=Z.includes(w?.entry)?w.entry:Z[0];X&&(r.value=X),await G()}async function q(w=""){O=(await P("/api/v1/packages")).packages||[],i.replaceChildren(...O.map(Oe=>new Option(Oe.name,Oe.id))),j&&(i.value=j);const X=O.find(Oe=>Oe.id===i.value),ne=X?.files||[];r.replaceChildren(...ne.map(Oe=>new Option(Oe,Oe))),r.value=ne.includes(w)?w:ne.includes(E)?E:X?.entry||ne[0]}async function G(){if(!i.value||!r.value)return;const w=new URLSearchParams({package:i.value,path:r.value}),Z=await P(`/api/v1/document?${w}`),X=`${i.value}/${r.value}`;j=i.value,E=r.value,S=Z.revision,v=Z.content,U=null,h.hidden=!0,_t(Z.content,X,0),ia(z,O.find(Oe=>Oe.id===j)?.files??[]),M.open({documentID:X,packageID:j,path:E,revision:Z.revision,content:Z.content}),Li(!!Z.readOnly),ce(Z);const ne=j1(window.localStorage,X,Z.content,Z.revision);c.hidden=!ne,c._draft=ne,document.querySelector("#recovery-message").textContent=ne?.isStale?"The device version also changed. Review before saving.":"Restore it or keep the device version.",s.textContent="Connected",Q({type:"CONNECTED"}),o.hidden=!1,ge(),le(),Me()}function ce(w){document.querySelector("#breadcrumb-package").textContent=w.packageName||i.value,document.querySelector("#breadcrumb-file").textContent=r.value,document.querySelector("#editor-tab-name").textContent=r.value,document.querySelector("#revision-detail").textContent=S?S.slice(0,8):"—",document.querySelector("#access-detail").textContent=w.readOnly?"Read only":"Editable"}function I(w){w.device&&(document.querySelector("#device-name").textContent=w.device.name||w.device.model,document.querySelector("#device-system").textContent=`${w.device.model} · ${w.device.system}`),w.preview?.package&&(document.querySelector("#preview-target").textContent=w.preview.package),w.preview?.snapshotSequence&&te()}async function te(){try{const w=await D.requestBlob("/api/v1/preview"),Z=URL.createObjectURL(w),X=document.querySelector("#device-preview"),ne=k;k=Z,X.onload=()=>{ne&&URL.revokeObjectURL(ne)},X.src=Z,X.hidden=!1,document.querySelector("#preview-detail").textContent="Rendered on device"}catch{}}function se(w){const Z=document.querySelector("#console-list"),X=document.createElement("li");for(X.className=w.level||"info",X.textContent=w.message||"",Z.append(X);Z.children.length>200;)Z.firstChild.remove();Z.scrollTop=Z.scrollHeight}function Me(){window.clearTimeout(x);const w=async()=>{if(m)try{const Z=await P(`/api/v1/events?after=${C}`);C=Z.nextSequence??C;for(const X of Z.events||[])X.type==="console"&&se(X.payload||{}),X.type==="preview.snapshot"&&te(),X.type==="preview.requested"&&(document.querySelector("#status-preview").textContent="Preview requested",document.querySelector("#preview-detail").textContent="Requested on device"),X.type==="files.changed"&&X.payload?.package===j&&q(E).catch(qe);Q({type:"CONNECTED"})}catch(Z){Z.status!==401&&Q({type:"OFFLINE"})}finally{m&&(x=window.setTimeout(w,1e3))}};w()}function ge(){const w=Ed(z);document.querySelector("#problems-list").replaceChildren(...w.map(X=>{const ne=z.state.doc.lineAt(X.from),Oe=document.createElement("li");Oe.className=`problem-item ${X.severity}`;const it=document.createElement("button");return it.type="button",it.innerHTML=`${X.severity==="error"?"●":"▲"}Ln ${ne.number}`,it.children[1].textContent=X.message,it.addEventListener("click",()=>{z.dispatch({selection:{anchor:X.from},scrollIntoView:!0}),z.focus()}),Oe.append(it),Oe})),document.querySelector("#problems-count").textContent=String(w.length),document.querySelector("#status-problem-count").textContent=String(w.length),document.querySelector("#problems-summary").textContent=w.length?`${w.filter(X=>X.severity==="error").length} errors, ${w.filter(X=>X.severity!=="error").length} warnings`:"No problems detected"}async function ie(w,Z,X=null){M.snapshot()?.content!==w&&M.edit(w),X&&M.rebase(X),Q({type:"SAVING"});try{const ne=await M.flush();if(ne.ignored){Z({result:"ok",ignored:!0});return}if(ne.skipped){Q({type:"SAVED"}),Z({result:"ok",skipped:!0});return}const Oe=ne.result||{},it=M.snapshot();S=it?.revision||S,v=it?.content||w,fo(window.localStorage,me),U=null,h.hidden=!0,document.querySelector("#revision-detail").textContent=S?.slice(0,8)||"—",Q({type:"SAVED",preview:Oe.preview?.state}),Z({result:"ok",...Oe})}catch(ne){ne.status===409?(U=ne.body,h.hidden=!1,Q({type:"CONFLICT",conflict:U})):Q({type:"SAVE_FAILED"}),Z({result:"failed",message:ne.message})}}It={registerHandler(){},callHandler(w,Z,X=()=>{}){if(w===Ue.documentSave)ie(Z.payload.content,X);else if(w===Ue.documentResources){const ne=me,Oe=j;P("/api/v1/packages").then(it=>{if(ne!==me||Z.documentID!==me||Oe!==j){X({result:"failed"});return}X({result:"ok",documentID:ne,resources:(it.packages??[]).find(Wn=>Wn.id===Oe)?.files??[]})}).catch(()=>X({result:"failed"}))}else X({result:"ok"})}},Wd={documentChanged(){const w=z.state.doc.toString();M.edit(w),hh(window.localStorage,me,w,M.snapshot()?.revision||S),Q({type:"EDITED"}),window.clearTimeout(b),b=window.setTimeout(ge,380)}};async function we(w,Z){if(!uh(F.save)){await w();return}try{if(window.clearTimeout(Mn),await ie(z.state.doc.toString(),()=>{}),!M.isDirty&&F.save!=="conflict"){await w();return}}catch{}window.confirm("This document has changes that are not saved on the device. A browser draft is available. Switch anyway?")?await w():Z()}i.addEventListener("change",()=>{const w=i.value;i.value=j,we(async()=>{i.value=w,await ee()},()=>{i.value=j}).catch(qe)}),r.addEventListener("change",()=>{const w=r.value;r.value=E,we(async()=>{r.value=w,await G()},()=>{r.value=E}).catch(qe)});function qe(w){s.textContent=w.message||String(w),Q({type:"SAVE_FAILED"})}e.addEventListener("submit",async w=>{w.preventDefault(),t.textContent="";try{await V(document.querySelector("#pair-code").value),n.close(),await J()}catch(Z){t.textContent=Z.message}}),o.addEventListener("click",async()=>{try{await P("/api/v1/session",{method:"DELETE"})}catch{}Y("Disconnected. Start a new session with the code on your device.")}),document.querySelector("#new-file").addEventListener("click",async()=>{const w=window.prompt("New package-relative text file","source/helper.js")?.trim();if(w)try{await P("/api/v1/document",{method:"POST",body:JSON.stringify({package:j,path:w})}),await q(w),await G()}catch(Z){qe(Z)}}),document.querySelector("#delete-file").addEventListener("click",async()=>{const w=O.find(Z=>Z.id===j);if(!E||E===w?.entry){window.alert("The widget entry file cannot be deleted.");return}if(window.confirm(`Delete ${E}? This cannot be undone.`))try{const Z=new URLSearchParams({package:j,path:E});await P(`/api/v1/document?${Z}`,{method:"DELETE"}),E="",await q(),await G()}catch(Z){qe(Z)}}),document.querySelector("#clear-console").addEventListener("click",()=>document.querySelector("#console-list").replaceChildren()),document.querySelector("#restore-draft").addEventListener("click",()=>{const w=c._draft;w&&(_t(w.content,w.documentID,lt+1),c.hidden=!0,hh(window.localStorage,me,w.content,S),Q({type:"EDITED"}),ge())}),document.querySelector("#discard-draft").addEventListener("click",()=>{fo(window.localStorage,me),c.hidden=!0}),document.querySelector("#reload-server").addEventListener("click",()=>{U&&(fo(window.localStorage,me),S=U.currentRevision,v=U.currentContent,_t(v,me,lt+1),M.open({documentID:me,packageID:j,path:E,revision:S,content:v}),U=null,h.hidden=!0,Q({type:"SAVED"}),ge())}),document.querySelector("#keep-local").addEventListener("click",()=>{U&&ie(z.state.doc.toString(),()=>{},U.currentRevision)}),document.querySelector("#compare-conflict").addEventListener("click",()=>{document.querySelector("#compare-local").textContent=z.state.doc.toString(),document.querySelector("#compare-server").textContent=U?.currentContent||v,p.showModal()}),p.querySelector("button").addEventListener("click",()=>p.close());function oe(){const w=a.classList.toggle("problems-collapsed");document.querySelector("#problems-toggle").setAttribute("aria-expanded",String(!w))}function Ae(w){l.classList.toggle(`show-${w}`)}document.querySelector("#problems-toggle").addEventListener("click",oe),document.querySelector("#status-problems").addEventListener("click",()=>{a.classList.remove("problems-collapsed")}),document.querySelector("#explorer-button").addEventListener("click",()=>Ae("explorer")),document.querySelector("#inspector-button").addEventListener("click",()=>Ae("inspector")),document.querySelectorAll("[data-close-panel]").forEach(w=>w.addEventListener("click",()=>l.classList.remove(`show-${w.dataset.closePanel}`)));const ae=[{name:"Save Document",keys:"⌘S",run:()=>{window.clearTimeout(Mn),ie(z.state.doc.toString(),()=>{})}},{name:"Format Document",keys:"⇧⌥F",run:as},{name:"Toggle Problems",keys:"⌘J",run:oe},{name:"Toggle Explorer",keys:"⌘⇧E",run:()=>Ae("explorer")},{name:"Toggle Inspector",keys:"",run:()=>Ae("inspector")},{name:"Use Light Theme",keys:"",run:()=>cs("light")},{name:"Use Dark Theme",keys:"",run:()=>cs("dark")}];function Ie(w=""){const Z=ae.filter(X=>X.name.toLowerCase().includes(w.toLowerCase()));d.replaceChildren(...Z.map(X=>{const ne=document.createElement("li"),Oe=document.createElement("button");Oe.type="button",Oe.className="command";const it=document.createElement("span");it.textContent=X.name;const Wn=document.createElement("kbd");return Wn.textContent=X.keys,Oe.append(it,Wn),Oe.addEventListener("click",()=>{u.close(),X.run()}),ne.append(Oe),ne}))}function tt(){Ie(),u.showModal(),f.value="",f.focus()}document.querySelector("#command-button").addEventListener("click",tt),f.addEventListener("input",()=>Ie(f.value)),document.addEventListener("keydown",w=>{const Z=w.metaKey||w.ctrlKey;Z&&w.shiftKey&&w.key.toLowerCase()==="p"?(w.preventDefault(),tt()):Z&&w.key.toLowerCase()==="s"?(w.preventDefault(),ae[0].run()):Z&&w.key.toLowerCase()==="j"?(w.preventDefault(),oe()):Z&&w.shiftKey&&w.key.toLowerCase()==="e"?(w.preventDefault(),Ae("explorer")):w.shiftKey&&w.altKey&&w.key.toLowerCase()==="f"&&(w.preventDefault(),as())}),z.dom.addEventListener("keyup",li),z.dom.addEventListener("mouseup",li);function li(){const w=z.state.selection.main.head,Z=z.state.doc.lineAt(w);document.querySelector("#cursor-position").textContent=`Ln ${Z.number}, Col ${w-Z.from+1}`}window.addEventListener("offline",()=>{s.textContent="Computer is offline",Q({type:"OFFLINE"})}),window.addEventListener("online",()=>{m&&P("/api/v1/session").then(w=>(I(w),Q({type:"CONNECTED"}),J())).catch(qe)}),window.addEventListener("beforeunload",w=>{uh(F.save)&&(w.preventDefault(),w.returnValue="")});try{await J()}catch{Y("Pair with the code shown on your device.")}}window.matchMedia?.("(prefers-color-scheme: dark)").addEventListener("change",()=>cs("system"));window.webkit||_t(`// ScriptWidget Studio -const widget = ( - - - -); -`); diff --git a/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/assets/index-ijvFWH5h.js b/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/assets/index-ijvFWH5h.js new file mode 100644 index 00000000..339e39fc --- /dev/null +++ b/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/assets/index-ijvFWH5h.js @@ -0,0 +1,59 @@ +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();const Yd="modulepreload",Nd=function(n,e){return new URL(n,e).href},al={},Cr=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){let c=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");s=c(t.map(h=>{if(h=Nd(h,i),h in al)return;al[h]=!0;const u=h.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(i)for(let p=o.length-1;p>=0;p--){const m=o[p];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${f}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Yd,u||(d.as="script"),d.crossOrigin="",d.href=h,l&&d.setAttribute("nonce",l),document.head.appendChild(d),u)return new Promise((p,m)=>{d.addEventListener("load",p),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})};let po=[],mh=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=mh[i])e=i+1;else return!0;if(e==t)return!1}}function ll(n){return n>=127462&&n<=127487}const cl=8205;function Gd(n,e,t=!0,i=!0){return(t?gh:_d)(n,e,i)}function gh(n,e,t){if(e==n.length)return e;e&&Oh(n.charCodeAt(e))&&yh(n.charCodeAt(e-1))&&e--;let i=Tr(n,e);for(e+=hl(i);e=0&&ll(Tr(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function _d(n,e,t){for(;e>1;){let i=gh(n,e-2,t);if(i=56320&&n<57344}function yh(n){return n>=55296&&n<56320}function hl(n){return n<65536?1:2}class se{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Bi(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),kt.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Bi(this,e,t);let i=[];return this.decompose(e,t,i,0),kt.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new pn(this),r=new pn(e);for(let o=t,a=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(a+=s.value.length,s.done||a>=i)return!0}}iter(e=1){return new pn(this,e)}iterRange(e,t=this.length){return new Ah(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new bh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?se.empty:e.length<=32?new we(e):kt.from(we.split(e,[]))}}class we extends se{constructor(e,t=Jd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],a=s+o.length;if((t?i:a)>=e)return new ep(s,a,i,o);s=a+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new we(ul(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),a=gs(r.text,o.text.slice(),0,r.length);if(a.length<=32)i.push(new we(a,o.length+r.length));else{let l=a.length>>1;i.push(new we(a.slice(0,l)),new we(a.slice(l)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof we))return super.replace(e,t,i);[e,t]=Bi(this,e,t);let s=gs(this.text,gs(i.text,ul(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new we(s,r):kt.from(we.split(s,[]),r)}sliceString(e,t=this.length,i=` +`){[e,t]=Bi(this,e,t);let s="";for(let r=0,o=0;r<=t&&oe&&o&&(s+=i),er&&(s+=a.slice(Math.max(0,e-r),t-r)),r=l+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new we(i,s)),i=[],s=-1);return s>-1&&t.push(new we(i,s)),t}}class kt extends se{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],a=s+o.length,l=i+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,i,s);s=a+1,i=l+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r=o){let c=s&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?i.push(a):a.decompose(e-o,t-o,i,c)}o=l+1}}replace(e,t,i){if([e,t]=Bi(this,e,t),i.lines=r&&t<=a){let l=o.replace(e-r,t-r,i),c=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>c>>6){let h=this.children.slice();return h[s]=l,new kt(h,this.length-(t-e)+i.length)}return super.replace(r,a,l)}r=a+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` +`){[e,t]=Bi(this,e,t);let s="";for(let r=0,o=0;re&&r&&(s+=i),eo&&(s+=a.sliceString(e-o,t-o,i)),o=l+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof kt))return 0;let i=0,[s,r,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==a)return i;let l=this.children[s],c=e.children[r];if(l!=c)return i+l.scanIdentical(c,t);i+=l.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new we(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,a=[],l=0,c=-1,h=[];function u(d){let p;if(d.lines>r&&d instanceof kt)for(let m of d.children)u(m);else d.lines>o&&(l>o||!l)?(f(),a.push(d)):d instanceof we&&l&&(p=h[h.length-1])instanceof we&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,h[h.length-1]=new we(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>s&&f(),l+=d.lines,c+=d.length+1,h.push(d))}function f(){l!=0&&(a.push(h.length==1?h[0]:kt.from(h,c)),c=-1,l=h.length=0)}for(let d of e)u(d);return f(),a.length==1?a[0]:new kt(a,t)}}se.empty=new we([""],0);function Jd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function gs(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r=t&&(l>i&&(a=a.slice(0,i-s)),s0?1:(e instanceof we?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,a=s instanceof we?s.text.length:s.children.length;if(o==(t>0?a:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof we){let l=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=s.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof we?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Ah{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new pn(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class bh{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(se.prototype[Symbol.iterator]=function(){return this.iter()},pn.prototype[Symbol.iterator]=Ah.prototype[Symbol.iterator]=bh.prototype[Symbol.iterator]=function(){return this});class ep{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function Bi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Ze(n,e,t=!0,i=!0){return Gd(n,e,t,i)}function tp(n){return n>=56320&&n<57344}function ip(n){return n>=55296&&n<56320}function Ne(n,e){let t=n.charCodeAt(e);if(!ip(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return tp(i)?(t-55296<<10)+(i-56320)+65536:t}function fa(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Qt(n){return n<65536?1:2}const mo=/\r\n?|\n/;var De=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(De||(De={}));class Zt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-s);r+=a}else{if(i!=De.Simple&&c>=e&&(i==De.TrackDel&&se||i==De.TrackBefore&&se))return null;if(c>e||c==e&&t<0&&!a)return e==s||t<0?r:r+l;r+=l}s=c}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i=0&&s<=t&&a>=e)return st?"cover":!0;s=a}return!1}toString(){let e="";for(let t=0;t=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Zt(e)}static create(e){return new Zt(e)}}class Re extends Zt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return go(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return Oo(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s=0){t[s]=a,t[s+1]=o;let l=s>>1;for(;i.length0&&Ht(i,t,r.text),r.forward(h),a+=h}let c=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,a=null;function l(h=!1){if(!h&&!s.length)return;of||u<0||f>t)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?se.of(d.split(i||mo)):d:se.empty,m=p.length;if(u==f&&m==0)return;uo&&Xe(s,u-o,-1),Xe(s,f-u,m),Ht(r,s,p),o=f}}return c(e),l(!a),a}static empty(e){return new Re(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;sa&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length=0&&t<=0&&t==n[s+1]?n[s]+=e:s>=0&&e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function Ht(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)a=n.sections[o++],l=n.sections[o++];e(s,c,r,h,u),s=c,r=h}}}function Oo(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Sn(n),a=new Sn(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);Xe(s,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let c=0,h=o.len;for(;h;)if(a.ins==-1){let u=Math.min(h,a.len);c+=u,h-=u,a.forward(u)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||i.length>c),r.forward2(l),o.forward(l)}}}}class Sn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?se.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?se.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Yt{constructor(e,t,i,s){this.from=e,this.to=t,this.flags=i,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Yt(i,s,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return A.range(e,t,void 0,void 0,i);let s=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return A.range(this.anchor,s,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return A.range(e.anchor,e.head)}static create(e,t,i,s){return new Yt(e,t,i,s)}}class A{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:A.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new A(e.ranges.map(t=>Yt.fromJSON(t)),e.main)}static single(e,t=e){return new A([A.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;ss.from-r.from),t=e.indexOf(i);for(let s=1;sr.head?A.range(l,a):A.range(a,l))}}return new A(e,t)}}function xh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let da=0;class K{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=da++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new K(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:pa),!!e.static,e.enables)}of(e){return new Os([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Os(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Os(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function pa(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Os{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=da++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,a=this.type==2,l=!1,c=!1,h=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?c=!0:(((t=e[u.id])!==null&&t!==void 0?t:1)&1)==0&&h.push(e[u.id]);return{create(u){return u.values[o]=i(u),1},update(u,f){if(l&&f.docChanged||c&&(f.docChanged||f.selection)||yo(u,h)){let d=i(u);if(a?!fl(d,u.values[o],s):!s(d,u.values[o]))return u.values[o]=d,1}return 0},reconfigure:(u,f)=>{let d,p=f.config.address[r];if(p!=null){let m=Cs(f,p);if(this.dependencies.every(g=>g instanceof K?f.facet(g)===u.facet(g):g instanceof Te?f.field(g,!1)==u.field(g,!1):!0)||(a?fl(d=i(u),m,s):s(d=i(u),m)))return u.values[o]=m,0}else d=i(u);return u.values[o]=d,1}}}get extension(){return this}}function fl(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[l.id]),s=t.map(l=>l.type),r=i.filter(l=>!(l&1)),o=n[e.id]>>1;function a(l){let c=[];for(let h=0;hi===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Vn).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>{let r=i.facet(Vn),o=s.facet(Vn),a;return(a=r.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(i.values[t]=a.create(i),1):s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Vn.of({field:this,create:e})]}get extension(){return this}}const fi={lowest:4,low:3,default:2,high:1,highest:0};function sn(n){return e=>new vh(e,n)}const ri={highest:sn(fi.highest),high:sn(fi.high),default:sn(fi.default),low:sn(fi.low),lowest:sn(fi.lowest)};class vh{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Gi{of(e){return new Ao(this,e)}reconfigure(e){return Gi.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ao{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class Ps{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let f of sp(e,t,o))f instanceof Te?s.push(f):(r[f.facet.id]||(r[f.facet.id]=[])).push(f);let a=Object.create(null),l=[],c=[];for(let f of s)a[f.id]=c.length<<1,c.push(d=>f.slot(d));let h=i?.config.facets;for(let f in r){let d=r[f],p=d[0].facet,m=h&&h[f]||[];if(d.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,pa(m,d))l.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));l.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=c.length<<1,c.push(y=>g.dynamicSlot(y)));a[p.id]=c.length<<1,c.push(g=>np(g,p,d))}}let u=c.map(f=>f(a));return new Ps(e,o,u,a,l,r)}}function sp(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,a){let l=s.get(o);if(l!=null){if(l<=a)return;let c=i[l].indexOf(o);c>-1&&i[l].splice(c,1),o instanceof Ao&&t.delete(o.compartment)}if(s.set(o,a),Array.isArray(o))for(let c of o)r(c,a);else if(o instanceof Ao){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),r(c,a)}else if(o instanceof vh)r(o.inner,o.prec);else if(o instanceof Te)i[a].push(o),o.provides&&r(o.provides,a);else if(o instanceof Os)i[a].push(o),o.facet.extensions&&r(o.facet.extensions,fi.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(c==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(c,a)}}return r(n,fi.default),i.reduce((o,a)=>o.concat(a))}function mn(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function Cs(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const wh=K.define(),bo=K.define({combine:n=>n.some(e=>e),static:!0}),kh=K.define({combine:n=>n.length?n[0]:void 0,static:!0}),Qh=K.define(),Ph=K.define(),Ch=K.define(),Th=K.define({combine:n=>n.length?n[0]:!1});class Wt{constructor(e,t){this.type=e,this.value=t}static define(){return new rp}}class rp{of(e){return new Wt(this,e)}}class op{constructor(e){this.map=e}of(e){return new z(this,e)}}class z{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new z(this.type,t)}is(e){return this.type==e}static define(e={}){return new op(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}z.reconfigure=z.define();z.appendConfig=z.define();class Pe{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&xh(i,t.newLength),r.some(a=>a.type==Pe.time)||(this.annotations=r.concat(Pe.time.of(Date.now())))}static create(e,t,i,s,r,o){return new Pe(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Pe.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Pe.time=Wt.define();Pe.userEvent=Wt.define();Pe.addToHistory=Wt.define();Pe.remote=Wt.define();function ap(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i=n[i]))r=n[i++],o=n[i++];else if(s=0;s--){let r=i[s](n);r instanceof Pe?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Pe?n=r[0]:n=$h(e,Zi(r),!1)}return n}function cp(n){let e=n.startState,t=e.facet(Ch),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=Rh(i,So(e,r,n.changes.newLength),!0))}return i==n?n:Pe.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const hp=[];function Zi(n){return n==null?hp:Array.isArray(n)?n:[n]}var ye=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(ye||(ye={}));const up=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let xo;try{xo=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function fp(n){if(xo)return xo.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||up.test(t)))return!0}return!1}function dp(n){return e=>{if(!/\S/.test(e))return ye.Space;if(fp(e))return ye.Word;for(let t=0;t-1)return ye.Word;return ye.Other}}class _{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let a=0;as.set(c,l)),t=null),s.set(a.value.compartment,a.value.extension)):a.is(z.reconfigure)?(t=null,i=a.value):a.is(z.appendConfig)&&(t=null,i=Zi(i).concat(a.value));let r;t?r=e.startState.values.slice():(t=Ps.resolve(i,s,this),r=new _(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(bo)?e.newSelection:e.newSelection.asSingle();new _(t,e.newDoc,o,r,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:A.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=Zi(i.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return _.create({doc:e.doc,selection:A.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Ps.resolve(e.extensions||[],new Map),i=e.doc instanceof se?e.doc:se.of((e.doc||"").split(t.staticFacet(_.lineSeparator)||mo)),s=e.selection?e.selection instanceof A?e.selection:A.single(e.selection.anchor,e.selection.head):A.single(0);return xh(s,i.length),t.staticFacet(bo)||(s=s.asSingle()),new _(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(_.tabSize)}get lineBreak(){return this.facet(_.lineSeparator)||` +`}get readOnly(){return this.facet(Th)}phrase(e,...t){for(let i of this.facet(_.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(wh))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return dp(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,a=e-i;for(;o>0;){let l=Ze(t,o,!1);if(r(t.slice(l,o))!=ye.Word)break;o=l}for(;an.length?n[0]:4});_.lineSeparator=kh;_.readOnly=Th;_.phrases=K.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(s=>n[s]==e[s])}});_.languageData=wh;_.changeFilter=Qh;_.transactionFilter=Ph;_.transactionExtender=Ch;Gi.reconfigure=z.define();function yt(n,e,t={}){let i={};for(let s of n)for(let r of Object.keys(s)){let o=s[r],a=i[r];if(a===void 0)i[r]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](a,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)i[s]===void 0&&(i[s]=e[s]);return i}class Jt{eq(e){return this==e}range(e,t=e){return vo.create(e,t,this)}}Jt.prototype.startSide=Jt.prototype.endSide=0;Jt.prototype.point=!1;Jt.prototype.mapMode=De.TrackDel;function ma(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let vo=class Kh{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Kh(e,t,i)}};function wo(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class ga{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,s=0){let r=i?this.to:this.from;for(let o=s,a=r.length;;){if(o==a)return o;let l=o+a>>1,c=r[l]-e||(i?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return c>=0?o:a;c>=0?a=l:o=l+1}}between(e,t,i,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);rd||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(o<0&&(o=f),c.point&&(a=Math.max(a,d-f)),i.push(c),s.push(f-o),r.push(d-o))}return{mapped:i.length?new ga(s,r,i,a):null,pos:o}}}class N{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new N(e,t,i,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(wo)),this.isEmpty)return t.length?N.of(t):this;let a=new Zh(this,null,-1).goto(0),l=0,c=[],h=new Bt;for(;a.value||l=0){let u=t[l++];h.addInner(u.from,u.to,u.value)||c.push(u)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||ra.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return xn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return xn.from(e).goto(t)}static compare(e,t,i,s,r=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=r),a=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=r),l=dl(o,a,i),c=new rn(o,l,r),h=new rn(a,l,r);i.iterGaps((u,f,d)=>pl(c,u,h,f,d,s)),i.empty&&i.length==0&&pl(c,0,h,0,0,s)}static eq(e,t,i=0,s){s==null&&(s=999999999);let r=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let a=dl(r,o),l=new rn(r,a,0).goto(i),c=new rn(o,a,0).goto(i);for(;;){if(l.to!=c.to||!ko(l.active,c.active)||l.point&&(!c.point||!ma(l.point,c.point)))return!1;if(l.to>s)return!0;l.next(),c.next()}}static spans(e,t,i,s,r=-1){let o=new rn(e,null,r).goto(t),a=t,l=o.openStart;for(;;){let c=Math.min(o.to,i);if(o.point){let h=o.activeForPoint(o.to),u=o.pointFroma&&(s.span(a,c,o.active,l),l=o.openEnd(c));if(o.to>i)return l+(o.point&&o.to>i?1:0);a=o.to,o.next()}}static of(e,t=!1){let i=new Bt;for(let s of e instanceof vo?[e]:t?pp(e):e)i.add(s.from,s.to,s.value);return i.finish()}static join(e){if(!e.length)return N.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let s=e[i];s!=N.empty;s=s.nextLayer)t=new N(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}N.empty=new N([],[],null,-1);function pp(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(wo);e=i}return n}N.empty.nextLayer=N.empty;class Bt{finishChunk(e){this.chunks.push(new ga(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Bt)).add(e,t,i)}addInner(e,t,i){let s=e-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(N.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=N.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function dl(n,e,t){let i=new Map;for(let r of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&s.push(new Zh(o,t,i,r));return s.length==1?s[0]:new xn(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Rr(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Rr(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Rr(this.heap,0)}}}function Rr(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let s=n[i];if(i+1=0&&(s=n[i+1],i++),t.compare(s)<0)break;n[i]=t,n[e]=s,e=i}}class rn{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=xn.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){jn(this.active,e),jn(this.activeTo,e),jn(this.activeRank,e),this.minActive=ml(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:r}=this.cursor;for(;t0;)t++;Yn(this.active,t,i),Yn(this.activeTo,t,s),Yn(this.activeRank,t,r),e&&Yn(e,t,this.cursor.from),this.minActive=ml(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&jn(i,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[s]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function pl(n,e,t,i,s,r){n.goto(e),t.goto(i);let o=i+s,a=i,l=i-e,c=!!r.boundChange;for(let h=!1;;){let u=n.to+l-t.to,f=u||n.endSide-t.endSide,d=f<0?n.to+l:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&ma(n.point,t.point)&&ko(n.activeForPoint(n.to),t.activeForPoint(t.to))||r.comparePoint(a,p,n.point,t.point),h=!1):(h&&r.boundChange(a),p>a&&!ko(n.active,t.active)&&r.compareRange(a,p,n.active,t.active),c&&po)break;a=d,f<=0&&n.next(),f>=0&&t.next()}}function ko(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function ml(n,e){let t=-1,i=1e9;for(let s=0;s=e)return s;if(s==n.length)break;r+=n.charCodeAt(s)==9?t-r%t:1,s=Ze(n,s)}return i===!0?-1:n.length}const Po="ͼ",gl=typeof Symbol>"u"?"__"+Po:Symbol.for(Po),Co=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ol=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ei{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,a,l,c){let h=[],u=/^@(\w+)\b/.exec(o[0]),f=u&&u[1]=="keyframes";if(u&&a==null)return l.push(o[0]+";");for(let d in a){let p=a[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,l);else if(p&&typeof p=="object"){if(!u)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,h,f)}else p!=null&&h.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(h.length||f)&&l.push((i&&!u&&!c?o.map(i):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Ol[gl]||1;return Ol[gl]=e+1,Po+e.toString(36)}static mount(e,t,i){let s=e[Co],r=i&&i.nonce;s?r&&s.setNonce(r):s=new mp(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let yl=new Map;class mp{constructor(e,t){let i=e.ownerDocument||e,s=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=yl.get(i);if(r)return e[Co]=r;this.sheet=new s.CSSStyleSheet,yl.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Co]=this}mount(e,t){let i=this.sheet,s=0,r=0;for(let o=0;o-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,a),i)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},Al=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),gp=typeof navigator<"u"&&/Apple Computer/.test(navigator.vendor),Op=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),bl=typeof navigator<"u"&&/Mac/.test(navigator.platform),yp=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ap=Al&&(bl||+Al[1]<57)||Op&&bl;for(var Fe=0;Fe<10;Fe++)ti[48+Fe]=ti[96+Fe]=String(Fe);for(var Fe=1;Fe<=24;Fe++)ti[Fe+111]="F"+Fe;for(var Fe=65;Fe<=90;Fe++)ti[Fe]=String.fromCharCode(Fe+32),vn[Fe]=String.fromCharCode(Fe);for(var $r in ti)vn.hasOwnProperty($r)||(vn[$r]=ti[$r]);function bp(n){var e=Ap&&(n.ctrlKey||n.altKey||n.metaKey)||(gp||yp)&&n.shiftKey&&n.key&&n.key.length==1,t=!e&&n.key||(n.shiftKey?vn:ti)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function he(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;e2);var R={mac:vl||/Mac/.test(We.platform),windows:/Win/.test(We.platform),linux:/Linux|X11/.test(We.platform),ie:hr,ie_version:Eh?To.documentMode||6:$o?+$o[1]:Ro?+Ro[1]:0,gecko:Sl,gecko_version:Sl?+(/Firefox\/(\d+)/.exec(We.userAgent)||[0,0])[1]:0,chrome:!!Kr,chrome_version:Kr?+Kr[1]:0,ios:vl,android:/Android\b/.test(We.userAgent),webkit:xl,webkit_version:xl?+(/\bAppleWebKit\/(\d+)/.exec(We.userAgent)||[0,0])[1]:0,safari:Ko,safari_version:Ko?+(/\bVersion\/(\d+(\.\d+)?)/.exec(We.userAgent)||[0,0])[1]:0,tabSize:To.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Oa(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const Ts=Object.create(null);function ya(n,e,t){if(n==e)return!0;n||(n=Ts),e||(e=Ts);let i=Object.keys(n),s=Object.keys(e);if(i.length-0!=s.length-0)return!1;for(let r of i)if(r!=t&&(s.indexOf(r)==-1||n[r]!==e[r]))return!1;return!0}function Sp(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function wl(n,e,t){let i=!1;if(e)for(let s in e)t&&s in t||(i=!0,s=="style"?n.style.cssText="":n.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(i=!0,s=="style"?n.style.cssText=t[s]:n.setAttribute(s,t[s]));return i}function xp(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Ai(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=Uh(e,t);i=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Ai(e,i,s,t,e.widget||null,!0)}static line(e){return new Fn(e)}static set(e,t=!1){return N.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}B.none=N.empty;class Un extends B{constructor(e){let{start:t,end:i}=Uh(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Oa(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ts}eq(e){return this==e||e instanceof Un&&this.tagName==e.tagName&&ya(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Un.prototype.point=!1;class Fn extends B{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Fn&&this.spec.class==e.spec.class&&ya(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Fn.prototype.mapMode=De.TrackBefore;Fn.prototype.point=!0;class Ai extends B{constructor(e,t,i,s,r,o){super(t,i,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?De.TrackBefore:De.TrackAfter:De.TrackDel}get type(){return this.startSide!=this.endSide?Le.WidgetRange:this.startSide<=0?Le.WidgetBefore:Le.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ai&&vp(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Ai.prototype.point=!0;function Uh(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function vp(n,e){return n==e||!!(n&&e&&n.compare(e))}function Mi(n,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=n?t[s]=Math.max(t[s],e):t.push(n,e)}class wn extends Jt{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof wn&&this.tagName==e.tagName&&ya(this.attributes,e.attributes)}static create(e){return new wn(e.tagName,e.attributes||Ts,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return N.of(e,t)}}wn.prototype.startSide=wn.prototype.endSide=-1;function kn(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Zo(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function gn(n,e){if(!e.anchorNode)return!1;try{return Zo(n,e.anchorNode)}catch{return!1}}function ys(n){return n.nodeType==3?Qn(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function On(n,e,t,i){return t?kl(n,e,t,i,-1)||kl(n,e,t,i,1):!1}function ii(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Rs(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function kl(n,e,t,i,s){for(;;){if(n==t&&e==i)return!0;if(e==(s<0?0:It(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=ii(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=s<0?It(n):0}else return!1}}function It(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function $s(n,e){let{left:t,right:i}=n;if(t==i)return n;let s=e?t:i;return{left:s,right:s,top:n.top,bottom:n.bottom}}function wp(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Fh(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function kp(n,e,t,i,s,r,o,a){let l=n.ownerDocument,c=l.defaultView||window;for(let h=n,u=!1;h&&!u;)if(h.nodeType==1){let f,d=h==l.body,p=1,m=1;if(d)f=wp(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let b=h.getBoundingClientRect();({scaleX:p,scaleY:m}=Fh(h,b)),f={left:b.left,right:b.left+h.clientWidth*p,top:b.top,bottom:b.top+h.clientHeight*m}}let g=0,y=0;if(s=="nearest")e.top0&&e.bottom>f.bottom+y&&(y=e.bottom-f.bottom+o)):e.bottom>f.bottom-o&&(y=e.bottom-f.bottom+o,t<0&&e.top-y0&&e.right>f.right+g&&(g=e.right-f.right+r)):e.right>f.right-r&&(g=e.right-f.right+r,t<0&&e.leftf.bottom||e.leftf.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function Dh(n,e=!0){let t=n.ownerDocument,i=null,s=null;for(let r=n.parentNode;r&&!(r==t.body||(!e||i)&&s);)if(r.nodeType==1)!s&&r.scrollHeight>r.clientHeight&&(s=r),e&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:s}}class Qp{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?It(t):0),i,Math.min(e.focusOffset,i?It(i):0))}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}}function Lh(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function Xh(n,e=!0){for(let{node:t,left:i,top:s}of n)e&&t.scrollTop!=s&&(t.scrollTop=s),t.scrollLeft!=i&&(t.scrollLeft=i)}let ui=null;R.safari&&R.safari_version>=26&&(ui=!1);function Bh(n){if(n.setActive)return n.setActive();if(ui)return n.focus(ui);let e=Lh(n);n.focus(ui==null?{get preventScroll(){return ui={preventScroll:!0},!0}}:void 0),ui||(ui=!1,Xh(e))}let Ql;function Qn(n,e,t=e){let i=Ql||(Ql=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Ei(n,e,t,i){let s={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=i);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,n.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,n.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function Pp(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Cp(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,It(t));;)if(i){if(t.nodeType!=1)return!1;let s=t.childNodes[i-1];s.contentEditable=="false"?i--:(t=s,i=It(t))}else{if(t==n)return!0;i=ii(t),t=t.parentNode}}function Ih(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function qh(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=It(t)}else if(t.parentNode&&!Rs(t))i=ii(t),t=t.parentNode;else return null}}function Wh(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i=t){if(a.level==i)return o;(r<0||(s!=0?s<0?a.fromt:e[r].level>a.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function jh(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(St[m+1]==-d){let g=St[m+2],y=g&2?s:g&4?g&1?r:s:0;y&&(ue[u]=ue[St[m]]=y),a=m;break}}else{if(St.length==189)break;St[a++]=u,St[a++]=f,St[a++]=l}else if((p=ue[u])==2||p==1){let m=p==s;l=m?0:1;for(let g=a-3;g>=0;g-=3){let y=St[g+2];if(y&2)break;if(m)St[g+2]|=2;else{if(y&4)break;St[g+2]|=4}}}}}function Mp(n,e,t,i){for(let s=0,r=i;s<=t.length;s++){let o=s?t[s-1].to:n,a=sl;)p==g&&(p=t[--m].from,g=m?t[m-1].to:n),ue[--p]=d;l=h}else r=c,l++}}}function Eo(n,e,t,i,s,r,o){let a=i%2?2:1;if(i%2==s%2)for(let l=e,c=0;ll&&o.push(new Ct(l,m.from,d));let g=m.direction==bi!=!(d%2);Uo(n,g?i+1:i,s,m.inner,m.from,m.to,o),l=m.to}p=m.to}else{if(p==t||(h?ue[p]!=a:ue[p]==a))break;p++}f?Eo(n,l,p,i+1,s,f,o):le;){let h=!0,u=!1;if(!c||l>r[c-1].to){let m=ue[l-1];m!=a&&(h=!1,u=m==16)}let f=!h&&a==1?[]:null,d=h?i:i+1,p=l;e:for(;;)if(c&&p==r[c-1].to){if(u)break e;let m=r[--c];if(!h)for(let g=m.from,y=c;;){if(g==e)break e;if(y&&r[y-1].to==g)g=r[--y].from;else{if(ue[g-1]==a)break e;break}}if(f)f.push(m);else{m.toue.length;)ue[ue.length]=256;let i=[],s=e==bi?0:1;return Uo(n,s,s,t,0,n.length,i),i}function Yh(n){return[new Ct(0,n,0)]}let Nh="";function Up(n,e,t,i,s){var r;let o=i.head-n.from,a=Ct.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),l=e[a],c=l.side(s,t);if(o==c){let f=a+=s?1:-1;if(f<0||f>=e.length)return null;l=e[a=f],o=l.side(!s,t),c=l.side(s,t)}let h=Ze(n.text,o,l.forward(s,t));(hl.to)&&(h=c),Nh=n.text.slice(Math.min(o,h),Math.max(o,h));let u=a==(s?e.length-1:0)?null:e[a+(s?1:-1)];return u&&h==c&&u.level+(s?0:1)n.some(e=>e)}),nu=K.define({combine:n=>n.some(e=>e)}),su=K.define();class Ui{constructor(e,t,i,s,r,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new Ui(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ui(A.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Nn=z.define({map:(n,e)=>n.map(e)}),ru=z.define();function ze(n,e,t){let i=n.facet(Jh);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Dt=K.define({combine:n=>n.length?n[0]:!0});let Dp=0;const Ti=K.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let l=[];return o&&l.push(ur.of(c=>{let h=c.plugin(a);return h?o(h):B.none})),r&&l.push(r(a)),l})}static fromClass(e,t){return xe.define((i,s)=>new e(i,s),t)}}class Zr{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(ze(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){ze(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){ze(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ou=K.define(),xa=K.define(),ur=K.define(),au=K.define(),va=K.define(),Dn=K.define(),lu=K.define();function Pl(n,e){let t=n.state.facet(lu);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(n):r),s=[];return N.spans(i,e.from,e.to,{point(){},span(r,o,a,l){let c=r-e.from,h=o-e.from,u=s;for(let f=a.length-1;f>=0;f--,l--){let d=a[f].spec.bidiIsolate,p;if(d==null&&(d=Fp(e.text,c,h)),l>0&&u.length&&(p=u[u.length-1]).to==c&&p.direction==d)p.to=h,u=p.inner;else{let m={from:c,to:h,direction:d,inner:[]};u.push(m),u=m.inner}}}}),s}const cu=K.define();function wa(n){let e=0,t=0,i=0,s=0;for(let r of n.state.facet(cu)){let o=r(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:i,bottom:s}}const hn=K.define();class ct{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new ct(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>i.toA)){if(s.toAs.push(new ct(r,o,a,l))),this.changedRanges=s}static create(e,t,i){return new Ks(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Lp=[];class Se{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Lp}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Sp(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let s of this.children){if(s==e)return i;i+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=ii(this.dom),s=this.length?e>0:t>0;return new pt(this.parent.dom,i+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof dr)return e;return null}static get(e){return e.cmTile}}class fr extends Se{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,s,r=e?.node==t?e:null,o=0;for(let a of this.children){if(a.sync(e),o+=a.length+a.breakAfter,s=i?i.nextSibling:t.firstChild,r&&s!=a.dom&&(r.written=!0),a.dom.parentNode==t)for(;s&&s!=a.dom;)s=Cl(s);else t.insertBefore(a.dom,s);i=a.dom}for(s=i?i.nextSibling:t.firstChild,r&&s&&(r.written=!0);s;)s=Cl(s);this.length=o}}function Cl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class dr extends fr{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Se.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,s=0,r=0;;)if(s==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&r++,s=t.pop()}else{let o=i.children[s++];if(o instanceof Lt)t.push(s),i=o,s=0;else{let a=r+o.length,l=e(o,r);if(l!==void 0)return l;r=a+o.breakAfter}}}resolveBlock(e,t){let i,s=-1,r,o=-1;if(this.blockTiles((a,l)=>{let c=l+a.length;if(e>=l&&e<=c){if(a.isWidget()&&t>=-1&&t<=1){if(a.flags&32)return!0;a.flags&16&&(i=void 0)}(le||e==l&&(t>1?a.length:a.covers(-1)))&&(!r||!a.isWidget()&&r.isWidget())&&(r=a,o=e-l)}}),!i&&!r)throw new Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:s}:{tile:r,offset:o}}}class Lt extends fr{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new Lt(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Ii extends fr{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let s=new Ii(t||document.createElement("div"),e);return(!t||!i)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,t,i){let s=null,r=-1,o=null,a=-1;function l(h,u){for(let f=0,d=0;f=u&&(p.isComposite()?l(p,u-d):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&Bp(o,p)))&&(m>u||p.flags&32&&t<=1)?(o=p,a=u-d):(d=-1)&&(s=p,r=u-d)),d=m}}l(this,e);let c=(t<0?s:o)||s||o;return c?{tile:c,offset:c==s?r:a}:null}coordsIn(e,t,i){let s=this.resolveInline(e,t,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),t,i):Xp(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:s,offset:r}=i;if(this.dom.contains(s.dom))return s.isText()?new pt(s.dom,Math.min(s.dom.nodeValue.length,r)):s.domPosFor(r,s.flags&16?1:s.flags&32?-1:t);let o=i.tile.parent,a=!1;for(let l of o.children){if(a)return new pt(l.dom,0);l==i.tile&&(a=!0)}}return new pt(this.dom,0)}}function Xp(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=ys(e);return t[t.length-1]||null}function Bp(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.tops&&(e=s);let r=e,o=e,a=0;e==0&&t<0||e==s&&t>=0?R.chrome||R.gecko||(e?(r--,a=1):o=0)?0:l.length-1];return R.safari&&!a&&c.width==0&&(c=Array.prototype.find.call(l,h=>h.width)||c),i==null?c:$s(c,(a?a>0:t<0)==i)}static of(e,t){let i=new pi(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Si extends Se{constructor(e,t,i,s){super(e,t,s),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let s=this.widget.coordsAt(this.dom,e,t);if(s)return s;if(i)return $s(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?r.length-1:0;o=r[l],!(e>0?l==0:l==r.length-1||o.top0==i)}}class Ip{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:s,index:r,beforeBreak:o,parents:a}=this;for(;e||t>0;)if(s.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(r==s.children.length){if(!e&&!a.length)break;i&&i.leave(s),o=!!s.breakAfter,{tile:s,index:r}=a.pop(),r++}else{let l=s.children[r],c=l.breakAfter;(t>0?l.length<=e:l.length=0;a--){let l=t.marks[a],c=s.lastChild;if(c instanceof Ge&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(Mr(l.dom)),s=c;else{if(this.cache.reused.get(l)){let u=Se.get(l.dom);u&&u.setDOM(Mr(l.dom))}let h=Ge.of(l.mark,l.dom);s.append(h),s=h}this.cache.reused.set(l,2)}let r=Se.get(e.text);r&&this.cache.reused.set(r,2);let o=new pi(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,s.append(o)}addInlineWidget(e,t,i){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let r=this.ensureMarks(t,i);!s&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=hu);let s=Ii.start(e,t||((i=this.cache.find(Ii))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let s=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],a;if(t>0&&(a=s.lastChild)&&a instanceof Ge&&a.mark.eq(o))s=a,t--;else{let l=Ge.of(o,(i=this.cache.find(Ge,c=>c.mark.eq(o)))===null||i===void 0?void 0:i.dom);s.append(l),s=l,t=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Tl(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(R.ios&&Tl(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Er,0,32)||new Si(Er.toDOM(),0,Er,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=e.rank*102+e.value.rank,i=new qp(e.from,e.to,e.value,t),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-i.rank||this.wrappers[s-1].to-i.to)<0;)s--;this.wrappers.splice(s,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let s=t.lastChild;if(i.fromo.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Zs,void 0,1);return i&&(i.flags=t),i||new Zs(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class zp{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let a=this.textOff=Math.min(e,s.length);return r?null:s.slice(0,a)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const Ms=[Si,Ii,pi,Ge,Zs,Lt,dr];for(let n=0;n[]),this.index=Ms.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let s=e.bucket,r=this.buckets[s],o=this.index[s];for(let a=0;a{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let s=0,r=0,o=0;;){let a=os){let c=l-s;this.preserve(c,!o,!a),s=l,r+=c}if(!a)break;t&&a.fromA<=t.range.fromA&&a.toA>=t.range.toA?(this.forward(a.fromA,t.range.fromA,t.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Ge&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=r=0):o instanceof Ge&&(s.shift(),r=Math.min(r,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,s=this.builder,r=-1,o=N.spans(this.decorations,e,t,{point:(a,l,c,h,u,f)=>{if(c instanceof Ai){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=h.length,u>h.length)s.continueWidget(l-a);else{let d=c.widget||(c.block?qi.block:qi.inline),p=Yp(c),m=this.cache.findWidget(d,l-a,p)||Si.of(d,this.view,l-a,p);c.block?(c.startSide>0&&s.addLineStartIfNotCovered(i),s.addBlockWidget(m)):(s.ensureLine(i),s.addInlineWidget(m,h,u))}i=null}else i=Np(i,c);l>a&&this.text.skip(l-a)},span:(a,l,c,h)=>{for(let u=a;u-1&&(this.openWidget=o>r),this.openWidget||s.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let s=e.parentNode;;s=s.parentNode){let r=Se.get(s);if(s==this.view.contentDOM)break;r instanceof Ge?t.push(r):r?.isLine()?i=r:r instanceof Lt||(s.nodeName=="DIV"&&!i&&s!=this.view.contentDOM?i=new Ii(s,hu):i||t.push(Ge.of(new Un({tagName:s.nodeName.toLowerCase(),attributes:xp(s)}),s)))}return{line:i,marks:t}}}function Tl(n,e){let t=i=>{for(let s of i.children)if((e?s.isText():s.length)||t(s))return!0;return!1};return t(n)}function Yp(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const hu={class:"cm-line"};function Np(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Oa(t,n),i&&(n.class+=" "+i)),n}function Hp(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof Ge&&e.push(i.mark)}return e}function Mr(n){let e=Se.get(n);return e&&e.setDOM(n.cloneNode()),n}class qi extends Ut{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}qi.inline=new qi("span");qi.block=new qi("div");const Er=new class extends Ut{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Rl{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=B.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new dr(e,e.contentDOM),this.updateInner([new ct(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!rm(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?_p(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:u}=this.hasComposition;i=new ct(h,u,e.changes.mapPos(h,-1),e.changes.mapPos(u,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(R.ie||R.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.blockWrappers;this.updateDeco();let l=tm(o,this.decorations,e.changes);l.length&&(i=ct.extendWithRanges(i,l));let c=nm(a,this.blockWrappers,e.changes);return c.length&&(i=ct.extendWithRanges(i,c)),r&&!i.some(h=>h.fromA<=r.range.fromA&&h.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,a=new jp(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Se.get(t.text)&&a.cache.reused.set(Se.get(t.text),2),this.tile=a.run(e,t),Do(o,a.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=R.chrome||R.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&gn(i,this.view.observer.selectionRange)&&!(s&&i.contains(s));if(!(r||t||o))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,h;if(l.empty?h=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(h=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),R.gecko&&l.empty&&!this.hasComposition&&Gp(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=h=new pt(f,0),a=!0}let u=this.view.observer.selectionRange;(a||!u.focusNode||(!On(c.node,c.offset,u.anchorNode,u.anchorOffset)||!On(h.node,h.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,l))&&(this.view.observer.ignore(()=>{R.android&&R.chrome&&i.contains(u.focusNode)&&sm(u.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let f=kn(this.view.root);if(f)if(l.empty){if(R.gecko){let d=Jp(c.node,c.offset);if(d&&d!=3){let p=(d==1?qh:Wh)(c.node,c.offset);p&&(c=new pt(p.node,p.offset))}}f.collapse(c.node,c.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(h.node,h.offset)}catch{}}else{let d=document.createRange();l.anchor>l.head&&([c,h]=[h,c]),d.setEnd(h.node,h.offset),d.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new pt(u.anchorNode,u.anchorOffset),this.impreciseHead=h.precise?null:new pt(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&On(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=kn(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!l||!c||l.bottom>c.top)return;let h=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(h.node,h.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&i.collapse(s,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let o=It(e)==0?0:t==0?-1:1;for(;;){let a=e.parentNode;if(a==i.dom)break;o==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?o=-1:o=1),e=a}o<0?r=e:r=e.nextSibling}if(r==i.dom.firstChild)return s;for(;r&&!Se.get(r);)r=r.nextSibling;if(!r)return s+i.length;for(let o=0,a=s;;o++){let l=i.children[o];if(l.dom==r)return a;a+=l.length+l.breakAfter}}else return i.isText()?e==i.dom?s+t:s+(t?i.length:0):s}domAtPos(e,t){let{tile:i,offset:s}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(s,t):i.domIn(s,t)}inlineDOMNearPos(e,t){let i,s=-1,r=!1,o,a=-1,l=!1;return this.tile.blockTiles((c,h)=>{if(c.isWidget()){if(c.flags&32&&h>=e)return!0;c.flags&16&&(r=!0)}else{let u=h+c.length;if(h<=e&&(i=c,s=e-h,r=u=e&&!o&&(o=c,a=e-h,l=h>e),h>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(r&&o?i=null:l&&i&&(o=null),i&&t<0||!o?i.domIn(s,t):o.domIn(a,t))}coordsAt(e,t,i){let{tile:s,offset:r}=this.tile.resolveBlock(e,t);return s.isWidget()?s.widget instanceof Ur?null:s.coordsInWidget(r,t,!0):s.coordsIn(r,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function s(r,o){if(r.isComposite())for(let a of r.children){if(a.length>=o){let l=s(a,o);if(l)return l}if(o-=a.length,o<0)break}else if(r.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==fe.LTR,c=0,h=(u,f,d)=>{for(let p=0;ps);p++){let m=u.children[p],g=f+m.length,y=m.dom.getBoundingClientRect(),{height:b}=y;if(d&&!p&&(c+=y.top-d.top),m instanceof Lt)g>i&&h(m,f,y);else if(f>=i&&(c>0&&t.push(-c),t.push(b+c),c=0,o)){let x=m.dom.lastChild,C=x?ys(x):[];if(C.length){let k=C[C.length-1],S=l?k.right-y.left:y.right-k.left;S>a&&(a=S,this.minWidth=r,this.minWidthFrom=f,this.minWidthTo=g)}}d&&p==u.children.length-1&&(c+=d.bottom-y.bottom),f=g+m.breakAfter}};return h(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?fe.RTL:fe.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let a=0,l;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let h=ys(c.dom);if(h.length!=1)return;a+=h[0].width,l=h[0].height}if(a)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:a/o.length,textHeight:l}}});if(e)return e;let t=document.createElement("div"),i,s,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=ys(t.firstChild)[0];i=t.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:s,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.view.state.doc.length;if(o>i){let a=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(B.replace({widget:new Ur(a),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return B.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ur).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,s=this.view.state.facet(va).map((r,o)=>{let a=typeof r=="function";return a&&(i=!0),a?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=i,t.push(N.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof r=="function"?r(this.view):r)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(su))try{if(c(this.view,e.range,e))return!0}catch(h){ze(this.view.state,h,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),s;if(!i)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let r=wa(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(kp(this.view.scrollDOM,o,t.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Do(this.tile)}}function Do(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Do(i,e)}}function Gp(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function uu(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=qh(t.focusNode,t.focusOffset),s=Wh(t.focusNode,t.focusOffset),r=i||s;if(s&&i&&s.node!=i.node){let a=Se.get(s.node);if(!a||a.isText()&&a.text!=s.node.nodeValue)r=s;else if(n.docView.lastCompositionAfterCursor){let l=Se.get(i.node);!l||l.isText()&&l.text!=i.node.nodeValue||(r=s)}}if(n.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function _p(n,e,t){let i=uu(n,t);if(!i)return null;let{node:s,from:r,to:o}=i,a=s.nodeValue;if(/[\n\r]/.test(a)||n.state.doc.sliceString(i.from,i.to)!=a)return null;let l=e.invertedDesc;return{range:new ct(l.mapPos(r),l.mapPos(o),r,o),text:s}}function Jp(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}class Ur extends Ut{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function om(n,e,t=1){let i=n.charCategorizer(e),s=n.doc.lineAt(e),r=e-s.from;if(s.length==0)return A.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,a=r;t<0?o=Ze(s.text,r,!1):a=Ze(s.text,r);let l=i(s.text.slice(o,a));for(;o>0;){let c=Ze(s.text,o,!1);if(i(s.text.slice(c,o))!=l)break;o=c}for(;an.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight,l=Math.floor((s-t.top-(n.defaultLineHeight-a)*.5)/a);r+=l*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Qo(o,r,n.state.tabSize)}function Lo(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let s;for(let r of i.type){if(r.from>e)break;if(!(r.toe)return r;(!s||r.type==Le.Text&&(s.type!=r.type||(t<0?r.frome)))&&(s=r)}}return s||i}return i}function lm(n,e,t,i){let s=Lo(n,e.head,e.assoc||-1),r=!i||s.type!=Le.Text||!(n.lineWrapping||s.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=n.dom.getBoundingClientRect(),a=n.textDirectionAt(s.from),l=n.posAtCoords({x:t==(a==fe.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(l!=null)return A.cursor(l,t?-1:1)}return A.cursor(t?s.to:s.from,t?-1:1)}function $l(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let a=e,l=null;;){let c=Up(s,r,o,a,t),h=Nh;if(!c){if(s.number==(t?n.state.doc.lines:1))return a;h=` +`,s=n.state.doc.line(s.number+(t?1:-1)),r=n.bidiSpans(s),c=n.visualLineSide(s,!t)}if(l){if(!l(h))return a}else{if(!i)return c;l=i(h)}a=c}}function cm(n,e,t){let i=n.state.charCategorizer(e),s=i(t);return r=>{let o=i(r);return s==ye.Space&&(s=o),s==o}}function hm(n,e,t,i){let s=e.head,r=t?1:-1;if(s==(t?n.state.doc.length:0))return A.cursor(s,e.assoc);let o=e.goalColumn,a,l=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(s,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),h=n.documentTop;if(c)o==null&&(o=c.left-l.left),a=r<0?c.top:c.bottom;else{let p=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(l.right-l.left,n.defaultCharacterWidth*(s-p.from))),a=(r<0?p.top:p.bottom)+h}let u=l.left+o,f=n.viewState.heightOracle.textHeight>>1,d=i??f;for(let p=0;;p+=f){let m=a+(d+p)*r,g=Xo(n,{x:u,y:m},!1,r);if(t?m>l.bottom:ma:b{if(e>r&&es(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:A.cursor(i,in.viewState.docHeight)return new Pt(n.state.doc.length,-1);if(c=n.elementAtHeight(l),i==null)break;if(c.type==Le.Text){if(i<0?c.ton.viewport.to)break;let f=n.docView.coordsAt(i<0?c.from:c.to,i>0?-1:1);if(f&&(i<0?f.top<=l+r:f.bottom>=l+r))break}let u=n.viewState.heightOracle.textHeight/2;l=i>0?c.bottom+u:c.top-u}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==Le.Text){let u=am(n,s,c,o,a);return new Pt(u,u==c.from?1:-1)}}if(c.type!=Le.Text)return l<(c.top+c.bottom)/2?new Pt(c.from,1):new Pt(c.to,-1);let h=n.docView.lineAt(c.from,2);return(!h||h.length!=c.length)&&(h=n.docView.lineAt(c.from,-2)),new um(n,o,a,n.textDirectionAt(c.from)).scanTile(h,c.from)}class um{constructor(e,t,i,s){this.view=e,this.x=t,this.y=i,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+s.from>1;t:if(o.has(m)){for(let b=1;b=r&&(x-=p),!o.has(x)){m=x;break t}}break e}o.add(m);let g=t(m),y=0;if(g)for(let b=0;b1))if(x.bottomthis.y)(!c||c.top>x.top)&&(c=x),y=-1;else{let C=x.left>this.x?this.x-x.left:x.right(p+p+m)/3)return this.y=l.bottom-1,this.scan(e,t,!0);if(c&&c.top<(p+m+m)/3)return this.y=c.top+1,this.scan(e,t,!0)}let d=(a?this.dirAt(e[h],1):this.baseDir)==fe.LTR;return{i:h,after:this.x>(f.left+f.right)/2==d}}scanText(e,t){let i=[];for(let r=0;r{let o=i[r]-t,a=i[r+1]-t;return Qn(e.dom,o,a).getClientRects()});return s.after?new Pt(i[s.i+1],-1):new Pt(i[s.i],1)}scanTile(e,t){if(!e.length)return new Pt(t,1);if(e.children.length==1){let a=e.children[0];if(a.isText())return this.scanText(a,t);if(a.isComposite())return this.scanTile(a,t)}let i=[t];for(let a=0,l=t;a{let l=e.children[a];return l.flags&48?null:(l.dom.nodeType==1?l.dom:Qn(l.dom,0,l.length)).getClientRects()}),r=e.children[s.i],o=i[s.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):s.after?new Pt(i[s.i+1],-1):new Pt(o,1)}}const ki="￿";class fm{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(_.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ki}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let s=e;;){this.findPointBefore(i,s);let r=this.text.length;this.readNode(s);let o=Se.get(s),a=s.nextSibling;if(a==t){o?.breakAfter&&!a&&i!=this.view.contentDOM&&this.lineBreak();break}let l=Se.get(a);(o&&l?o.breakAfter:(o?o.breakAfter:Rs(s))||Rs(a)&&(s.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!pm(a,t)&&this.lineBreak(),s=a}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,a;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(a=s.exec(t))&&(r=a.index,o=a[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);i=r+o}}readNode(e){let t=Se.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(dm(e,i.node,i.offset)?t:0))}}function dm(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,a=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=du(e.docView.tile,t,i,0))){let l=r||o?[]:Om(e),c=new fm(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=ym(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Zo(e.contentDOM,l.focusNode)?a.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Zo(e.contentDOM,l.anchorNode)?a.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),u=e.viewport;if((R.ios||R.chrome)&&c!=h&&Math.min(c,h)<=a.main.from&&Math.max(c,h)>=a.main.to&&(u.from>0||u.to-1&&a.ranges.length>1)this.newSel=a.replaceRange(A.range(h,c));else if(e.lineWrapping&&h==c&&!(a.main.empty&&a.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(c,-1),d=0;f&&(d=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=A.create([A.cursor(c,d)])}else this.newSel=A.single(h,c)}}}function du(n,e,t,i){if(n.isComposite()){let s=-1,r=-1,o=-1,a=-1;for(let l=0,c=i,h=i;lt)return du(u,e,t,c);if(f>=e&&s==-1&&(s=l,r=c),c>t&&u.dom.parentNode==n.dom){o=l,a=h;break}h=f,c=f+u.breakAfter}return{from:r,to:a<0?i+n.length:a,startDOM:(s?n.children[s-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function pu(n,e){let t,{newSel:i}=e,{state:s}=n,r=s.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:l}=e.bounds,c=r.from,h=null;(o===8||R.android&&e.text.length=a&&r.to<=l&&(e.typeOver||u!=e.text)&&u.slice(0,r.from-a)==e.text.slice(0,r.from-a)&&u.slice(r.to-a)==e.text.slice(f=e.text.length-(u.length-(r.to-a)))?t={from:r.from,to:r.to,insert:se.of(e.text.slice(r.from-a,f).split(ki))}:(d=mu(u,e.text,c-a,h))&&(R.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==ki+ki&&d.toB--,t={from:a+d.from,to:a+d.toA,insert:se.of(e.text.slice(d.from,d.toB).split(ki))})}else i&&(!n.hasFocus&&s.facet(Dt)||Es(i,r))&&(i=null);if(!t&&!i)return!1;if((R.mac||R.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=A.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:se.of([t.insert.toString().replace("."," ")])}):s.doc.lineAt(r.from).toDate.now()-50?t={from:r.from,to:r.to,insert:s.toText(n.inputState.insertingText)}:R.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` + `&&n.lineWrapping&&(i&&(i=A.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:se.of([" "])}),t)return ka(n,t,i,o);if(i&&!Es(i,r)){let a=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(a=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(i=fu(s.facet(Dn).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:a,userEvent:l}),!0}else return!1}function ka(n,e,t,i=-1){if(R.ios&&n.inputState.flushIOSKey(e))return!0;let s=n.state.selection.main;if(R.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&n.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ei(n.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||i==8&&e.insert.lengths.head)&&Ei(n.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Ei(n.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,a=()=>o||(o=gm(n,e,t));return n.state.facet(eu).some(l=>l(n,e.from,e.to,r,a))||n.dispatch(a()),!0}function gm(n,e,t){let i,s=n.state,r=s.selection.main,o=-1;if(e.from==e.to&&e.fromr.to){let l=e.fromu(n)),c,l);e.from==h&&(o=h)}if(o>-1)i={changes:e,selection:A.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=r.frome.to?s.sliceDoc(e.to,r.to):"";i=s.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let l=s.changes(e),c=t&&t.main.to<=l.newLength?t.main:void 0;if(s.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let h=n.state.sliceDoc(e.from,e.to),u,f=t&&uu(n,t.main.head);if(f){let p=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-p}}else u=n.state.doc.lineAt(r.head);let d=r.to-e.to;i=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:l,range:c||p.map(l)};let m=p.to-d,g=m-h.length;if(n.state.sliceDoc(g,m)!=h||m>=u.from&&g<=u.to)return{range:p};let y=s.changes({from:g,to:m,insert:e.insert}),b=p.to-r.to;return{changes:y,range:c?A.range(Math.max(0,c.anchor+b),Math.max(0,c.head+b)):p.map(y)}})}else i={changes:l,selection:c&&s.selection.replaceRange(c)}}let a="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,a+=".compose",n.inputState.compositionFirstChange&&(a+=".start",n.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:a,scrollIntoView:!0})}function mu(n,e,t,i){let s=Math.min(n.length,e.length),r=0;for(;r0&&a>0&&n.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(i=="end"){let l=Math.max(0,r-Math.min(o,a));t-=o+l-r}if(o=o?r-t:0;r-=l,a=r+(a-o),o=r}else if(a=a?r-t:0;r-=l,o=r+(o-a),a=r}return{from:r,toA:o,toB:a}}function Om(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new Kl(t,i)),(s!=t||r!=i)&&e.push(new Kl(s,r))),e}function ym(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?A.single(t+e,i+e):null}function Es(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class Am{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,R.safari&&e.contentDOM.addEventListener("input",()=>null),R.gecko&&Em(e.contentDOM.ownerDocument)}handleEvent(e){!Cm(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let s of i.observers)s(this.view,t);for(let s of i.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Sm(e),i=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,a=i[r];a&&o!=!a.handlers.length&&(s.removeEventListener(r,this.handleEvent),a=null),a||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Ou.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),R.android&&R.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(R.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(gu.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||xm.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&R.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&bm(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:R.safari&&!R.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function bm(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function Zl(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(s){ze(t.state,s)}}}function Sm(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let s=i.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let a in r){let l=r[a];l&&t(a).handlers.push(Zl(i.value,l))}if(o)for(let a in o){let l=o[a];l&&t(a).observers.push(Zl(i.value,l))}}for(let i in Ot)t(i).handlers.push(Ot[i]);for(let i in je)t(i).observers.push(je[i]);return e}const gu=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],xm="dthko",Ou=[16,17,18,20,91,92,224,225],Hn=6;function Gn(n){return Math.max(0,n)*.7+8}function vm(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class wm{constructor(e,t,i,s){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Dh(e.contentDOM),this.atoms=e.state.facet(Dn).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(_.allowMultipleSelections)&&km(e,t),this.dragging=Pm(e,t)&&bu(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&vm(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,s=0,r=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=wa(this.view);e.clientX-l.left<=s+Hn?t=-Gn(s-e.clientX):e.clientX+l.right>=o-Hn&&(t=Gn(e.clientX-o)),e.clientY-l.top<=r+Hn?i=-Gn(r-e.clientY):e.clientY+l.bottom>=a-Hn&&(i=Gn(e.clientY-a)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=fu(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function km(n,e){let t=n.state.facet(Hh);return t.length?t[0](e):R.mac?e.metaKey:e.ctrlKey}function Qm(n,e){let t=n.state.facet(Gh);return t.length?t[0](e):R.mac?!e.altKey:!e.ctrlKey}function Pm(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=kn(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Cm(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Se.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const Ot=Object.create(null),je=Object.create(null),yu=R.ie&&R.ie_version<15||R.ios&&R.webkit_version<604;function Tm(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),Au(n,t.value)},50)}function pr(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function Au(n,e){e=pr(n.state,ba,e);let{state:t}=n,i,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Bo!=null&&t.selection.ranges.every(l=>l.empty)&&Bo==r.toString()){let l=-1;i=t.changeByRange(c=>{let h=t.doc.lineAt(c.from);if(h.from==l)return{range:c};l=h.from;let u=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:u},range:A.cursor(c.from+u.length)}})}else o?i=t.changeByRange(l=>{let c=r.line(s++);return{changes:{from:l.from,to:l.to,insert:c.text},range:A.cursor(l.from+c.length)}}):i=t.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}je.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,R.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};je.wheel=je.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};Ot.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);je.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};je.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};je.touchend=(n,e)=>{n.inputState.touchActive=!1};Ot.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(_h))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=$m(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new wm(n,e,t,i)),i&&n.observer.ignore(()=>{Bh(n.contentDOM);let r=n.root.activeElement;r&&!r.contains(n.contentDOM)&&r.blur()});let s=n.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function Ml(n,e,t,i){if(i==1)return A.cursor(e,t);if(i==2)return om(n.state,e,t);{let s=n.docView.lineAt(e,t),r=n.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,a=s?s.posAtEnd:r.to;return aDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(Ul+1)%3:1}function $m(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=bu(e),s=n.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,a){let l=n.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),c,h=Ml(n,l.pos,l.assoc,i);if(t.pos!=l.pos&&!o){let u=Ml(n,t.pos,t.assoc,i),f=Math.min(u.from,h.from),d=Math.max(u.to,h.to);h=f1&&(c=Km(s,l.pos))?c:a?s.addRange(h):A.create([h])}}}function Km(n,e){for(let t=0;t=e)return A.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Ot.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let s=n.docView.tile.nearest(e.target);if(s&&s.isWidget()){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=A.undirectionalRange(r,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",pr(n.state,Sa,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ot.dragend=n=>(n.inputState.draggedContent=null,!1);function Dl(n,e,t,i){if(t=pr(n.state,ba,t),!t)return;let s=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=n.inputState,o=i&&r&&Qm(n,e)?{from:r.from,to:r.to}:null,a={from:s,insert:t},l=n.state.changes(o?[o,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Ot.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),s=0,r=()=>{++s==t.length&&Dl(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(i[o]=a.result),r()},a.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Dl(n,e,i,!0),!0}return!1};Ot.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=yu?null:e.clipboardData;return t?(Au(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Tm(n),!1)};function Zm(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Mm(n){let e=[],t=[],i=!1;for(let s of n.selection.ranges)s.empty||(e.push(n.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:pr(n,Sa,e.join(n.lineBreak)),ranges:t,linewise:i}}let Bo=null;Ot.copy=Ot.cut=(n,e)=>{if(!gn(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:s}=Mm(n.state);if(!t&&!s)return!1;Bo=s?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=yu?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(Zm(n,t),!1)};const Su=Wt.define();function xu(n,e){let t=[];for(let i of n.facet(tu)){let s=i(n,e);s&&t.push(s)}return t.length?n.update({effects:t,annotations:Su.of(!0)}):null}function vu(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=xu(n.state,e);t?n.dispatch(t):n.update([])}},10)}je.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),vu(n)};je.blur=n=>{n.observer.clearSelectionRange(),vu(n)};je.compositionstart=je.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};je.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,R.chrome&&R.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};je.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Ot.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let a=o[0],l=n.posAtDOM(a.startContainer,a.startOffset),c=n.posAtDOM(a.endContainer,a.endOffset);return ka(n,{from:l,to:c,insert:n.state.toText(r)},null),!0}}let s;if(R.chrome&&R.android&&(s=gu.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return R.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),R.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>je.compositionend(n,e),20),!1};const Ll=new Set;function Em(n){Ll.has(n)||(Ll.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const Xl=["pre-wrap","normal","pre-line","break-spaces"];let Wi=!1;function Bl(){Wi=!1}class Um{constructor(e){this.lineWrapping=e,this.doc=se.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Xl.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=i,this.textHeight=s,this.lineLength=r,l){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>As&&(Wi=!0),this.height=e)}replace(e,t,i){return Ve.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this,o=i.doc;for(let a=s.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:h,toB:u}=s[a],f=r.lineAt(l,pe.ByPosNoHeight,i.setDoc(t),0,0),d=f.to>=c?f:r.lineAt(c,pe.ByPosNoHeight,i,0,0);for(u+=d.to-c,c=d.to;a>0&&f.from<=s[a-1].toA;)l=s[a-1].fromA,h=s[a-1].fromB,a--,lr*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),i+=1+a.break,s-=a.size}else if(r>s*2){let a=e[i];a.break?e.splice(i,1,a.left,null,a.right):e.splice(i,1,a.left,a.right),i+=2+a.break,r-=a.size}else break;else if(s=r&&o(this.lineAt(0,pe.ByPos,i,s,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ot extends wu{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new dt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof ot||s instanceof Ee&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Ee?s=new ot(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ve.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setMeasuredHeight(s):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ee extends Ve{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-i+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*r);o=l/r,this.length>r+1&&(a=(this.height-l)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:s,perLine:o,perChar:a}}blockAt(e,t,i,s){let{firstLine:r,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,s);if(t.lineWrapping){let c=s+(e0){let r=i[i.length-1];r instanceof Ee?i[i.length-1]=new Ee(r.length+s):i.push(null,new Ee(s-1))}if(e>0){let r=i[0];r instanceof Ee?i[0]=new Ee(e+r.length):i.unshift(new Ee(e-1),null)}return Ve.of(i)}decomposeLeft(e,t){t.push(new Ee(e-1),null)}decomposeRight(e,t){t.push(null,new Ee(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],a=Math.max(t,s.from),l=-1;for(s.from>t&&o.push(new Ee(s.from-t-1).updateHeight(e,t));a<=r&&s.more;){let h=e.doc.lineAt(a).length;o.length&&o.push(null);let u=s.heights[s.index++],f=0;u<0&&(f=-u,u=s.heights[s.index++]),l==-1?l=u:Math.abs(u-l)>=As&&(l=-2);let d=new ot(h,u,f);d.outdated=!1,o.push(d),a+=h+1}a<=r&&o.push(null,new Ee(r-a).updateHeight(e,a));let c=Ve.of(o);return(l<0||Math.abs(c.height-this.height)>=As||Math.abs(l-this.heightMetrics(e,t).perLine)>=As)&&(Wi=!0),Us(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Lm extends Ve{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,s){let r=i+this.left.height;return ea))return c;let h=t==pe.ByPosNoHeight?pe.ByPosNoHeight:pe.ByPos;return l?c.join(this.right.lineAt(a,h,i,o,a)):this.left.lineAt(a,h,i,s,r).join(c)}forEachLine(e,t,i,s,r,o){let a=s+this.left.height,l=r+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,i,a,l,o);else{let c=this.lineAt(l,pe.ByPos,i,s,r);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,a,l,o)}}replace(e,t,i){let s=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let a of i)r.push(a);if(e>0&&Il(r,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e2*t.size||t.size>2*e.size?Ve.of(this.break?[e,null,t]:[e,t]):(this.left=Us(this.left,e),this.right=Us(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,s){let{left:r,right:o}=this,a=t+r.length+this.break,l=null;return s&&s.from<=t+r.length&&s.more?l=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=a+o.length&&s.more?l=o=o.updateHeight(e,a,i,s):o.updateHeight(e,a,i),l?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Il(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Ee&&(i=n[e+1])instanceof Ee&&n.splice(e-1,3,new Ee(t.length+1+i.length))}const Xm=5;class Qa{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof ot?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ot(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=Xm)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new ot(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new Ee(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ot)return e;let t=new ot(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ot)&&!this.isCovered?this.nodes.push(new ot(0,-1,0)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&u.overflow!="visible"){let f=h.getBoundingClientRect();r=Math.max(r,f.left),o=Math.min(o,f.right),a=Math.max(a,f.top),l=Math.min(c==n.parentNode?s.innerHeight:l,f.bottom)}c=u.position=="absolute"||u.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function Wm(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function zm(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Dr{constructor(e,t,i,s){this.from=e,this.to=t,this.size=i,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new Um(i),this.stateDeco=zl(t),this.heightMap=Ve.empty().applyChanges(this.stateDeco,se.empty,this.heightOracle.setDoc(t.doc),[new ct(0,0,0,t.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=B.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new _n(r,o))}}return this.viewports=e.sort((i,s)=>i.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Wl:new Pa(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(un(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=zl(this.state);let s=e.changedRanges,r=ct.extendWithRanges(s,Bm(i,this.stateDeco,e?e.changes:Re.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Bl(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Wi)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(nu)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?fe.RTL:fe.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,h=0;if(a.width&&a.height){let{scaleX:k,scaleY:S}=Fh(t,a);(k>.005&&Math.abs(this.scaleX-k)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=k,this.scaleY=S,c|=16,o=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let d=Dh(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Ih(this.scrollParent||e.win);let m=(this.printing?zm:qm)(t,this.paddingTop),g=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(l=!0)),!this.inView&&!this.scrollTarget&&!Wm(e.dom))return 0;let x=a.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let k=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(k)&&(o=!0),o||s.lineWrapping&&Math.abs(x-this.contentDOMWidth)>s.charWidth){let{lineHeight:S,charWidth:w,textHeight:U}=e.docView.measureTextSize();o=S>0&&s.refresh(r,S,w,U,Math.max(5,x/w),k),o&&(e.docView.minWidth=0,c|=16)}g>0&&y>0?h=Math.max(g,y):g<0&&y<0&&(h=Math.min(g,y)),Bl();for(let S of this.viewports){let w=S.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?Ve.empty().applyChanges(this.stateDeco,se.empty,this.heightOracle,[new ct(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Fm(S.from,w))}Wi&&(c|=2)}let C=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return C&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||C)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new _n(s.lineAt(o-i*1e3,pe.ByHeight,r,0,0).from,s.lineAt(a+(1-i)*1e3,pe.ByHeight,r,0,0).to);if(t){let{head:c}=t.range;if(cl.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=s.lineAt(c,pe.ByPos,r,0,0),f;t.y=="center"?f=(u.top+u.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&c=a+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r>1,o=s<<1;if(this.defaultTextDirection!=fe.LTR&&!i)return[];let a=[],l=(h,u,f,d)=>{if(u-hh&&yy.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)y.fromb));if(!g){if(ux.from<=u&&x.to>=u)){let x=t.moveToLineBoundary(A.cursor(u),!1,!0).head;x>h&&(u=x)}let y=this.gapSize(f,h,u,d),b=i||y<2e6?y:2e6;g=new Dr(h,u,y,b)}a.push(g)},c=h=>{if(h.length2e6)for(let S of e)S.from>=h.from&&S.fromh.from&&l(h.from,d,h,u),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];N.spans(t,this.viewport.from,this.viewport.to,{span(r,o){i.push({from:r,to:o})},point(){}},20);let s=0;if(i.length!=this.visibleRanges.length)s=12;else for(let r=0;r=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||un(this.heightMap.lineAt(e,pe.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||un(this.heightMap.lineAt(this.scaler.fromDOM(e),pe.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return un(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class _n{constructor(e,t){this.from=e,this.to=t}}function jm(n,e,t){let i=[],s=n,r=0;return N.spans(t,n,e,{span(){},point(o,a){o>s&&(i.push({from:s,to:o}),r+=o-s),s=a}},20),s=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let s=0;;s++){let{from:r,to:o}=e[s],a=o-r;if(i<=a)return r+i;i-=a}}function es(n,e){let t=0;for(let{from:i,to:s}of n.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/n.total}function Ym(n,e){for(let t of n)if(e(t))return t}const Wl={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function zl(n){let e=n.facet(ur).filter(i=>typeof i!="function"),t=n.facet(va).filter(i=>typeof i!="function");return t.length&&e.push(N.join(t)),e}class Pa{constructor(e,t,i){let s=0,r=0,o=0;this.viewports=i.map(({from:a,to:l})=>{let c=t.lineAt(a,pe.ByPos,e,0,0).top,h=t.lineAt(l,pe.ByPos,e,0,0).bottom;return s+=h-c,{from:a,to:l,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let a of this.viewports)a.domTop=o+(a.top-r)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),r=a.bottom}toDOM(e){for(let t=0,i=0,s=0;;t++){let r=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function un(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new dt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(s=>un(s,e)):n._content)}const ts=K.define({combine:n=>n.join(" ")}),Io=K.define({combine:n=>n.indexOf(!0)>-1}),qo=ei.newName(),ku=ei.newName(),Qu=ei.newName(),Pu={"&light":"."+ku,"&dark":"."+Qu};function Wo(n,e,t){return new ei(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):n+" "+i}})}const Nm=Wo("."+qo,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Pu),Hm={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Lr=R.ie&&R.ie_version<=11;class Gm{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Qp,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(R.ie&&R.ie_version<=11||R.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&R.android&&e.constructor.EDIT_CONTEXT!==!1&&!(R.chrome&&R.chrome_version<126)&&(this.editContext=new Jm(e),e.state.facet(Dt)&&(e.contentDOM.editContext=this.editContext.editContext)),Lr&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(Dt)?i.root.activeElement!=this.dom:!gn(this.dom,s))return;let r=s.anchorNode&&i.docView.tile.nearest(s.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(R.ie&&R.ie_version<=11||R.android&&R.chrome)&&!i.state.selection.main.empty&&s.focusNode&&On(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=kn(e.root);if(!t)return!1;let i=R.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&_m(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let s=gn(this.dom,i);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Ei(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&gn(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new mm(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,s=pu(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Es(this.view.state.selection,t.newSel.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Vl(t,e.previousSibling||e.target.previousSibling,-1),s=Vl(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Dt)!=e.state.facet(Dt)&&(e.view.contentDOM.editContext=e.state.facet(Dt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Vl(n,e,t){for(;e;){let i=Se.get(e);if(i&&i.parent==n)return i;let s=e.parentNode;e=s!=n.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function jl(n,e){let t=e.startContainer,i=e.startOffset,s=e.endContainer,r=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return On(o.node,o.offset,s,r)&&([t,i,s,r]=[s,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}}function _m(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return jl(n,s)}let t=null;function i(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?jl(n,t):null}class Jm{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let s=e.state.selection.main,{anchor:r,head:o}=s,a=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>i.text.length;a==this.from&&rthis.to&&(l=r);let h=mu(e.state.sliceDoc(a,l),i.text,(c?s.from:s.to)-a,c?"end":null);if(!h){let f=A.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Es(f,s)||e.dispatch({selection:f,userEvent:"select"});return}let u={from:h.from+a,to:h.toA+a,insert:se.of(i.text.slice(h.from,h.toB).split(` +`))};if((R.mac||R.android)&&u.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:a,to:l,insert:se.of([i.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let f=this.to-this.from+(u.to-u.from+u.insert.length);ka(e,u,A.single(this.toEditorPos(i.selectionStart,f),this.toEditorPos(i.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],r=null;for(let o=this.toEditorPos(i.rangeStart),a=this.toEditorPos(i.rangeEnd);o{let s=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,a=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let l=this.toEditorPos(r.rangeStart),c=this.toEditorPos(r.rangeEnd);if(l{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let s=kn(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,a,l,c)=>{if(i)return;let h=c.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(c)){s=this.pendingContextChange=null,t+=h,this.to+=h;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=h,this.to+=h;else if(rthis.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),c.toString()),this.to+=h}t+=h}),s&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class ${get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(s=>s.forEach(r=>i(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Pp(e.parent)||document,this.viewState=new ql(this,e.state||_.create(e)),e.scrollTo&&e.scrollTo.is(Nn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ti).map(s=>new Zr(s));for(let s of this.plugins)s.update(this);this.observer=new Gm(this),this.inputState=new Am(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Rl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Pe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,s,r=this.state;for(let f of e){if(f.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=f.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,a=0,l=null;e.some(f=>f.annotation(Su))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=xu(r,o),l||(a=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(_.phrases)!=this.state.facet(_.phrases))return this.setState(r);s=Ks.create(this,r,e),s.flags|=a;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:p,y:m}=this.state.facet($.cursorScrollMargin);u=new Ui(d.empty?d:A.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of f.effects)d.is(Nn)&&(u=d.value.clip(this.state))}this.viewState.update(s,u),this.bidiCache=Fs.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(hn)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(ts)!=s.state.facet(ts)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let f of this.state.facet(Fo))try{f(s)}catch(d){ze(this.state,d,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!pu(this,h)&&c.force&&Ei(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new ql(this,e),this.plugins=e.facet(Ti).map(i=>new Zr(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Rl(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ti),i=e.state.facet(Ti);if(t!=i){let s=[];for(let r of i){let o=t.indexOf(r);if(o<0)s.push(new Zr(r));else{let a=this.plugins[o];a.mustUpdate=e,s.push(a)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(Ih(i||this.win))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(d=>{try{return d.read(this)}catch(p){return ze(this.state,p),Yl}}),u=Ks.create(this,this.state,[]),f=!1;u.flags|=l,t?t.flags|=l:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u),f&&this.docViewUpdate());for(let d=0;d1||p<-1)&&!(R.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Fo))a(t)}get themeClasses(){return qo+" "+(this.state.facet(Io)?Qu:ku)+" "+this.state.facet(ts)}updateAttrs(){let e=Nl(this,ou,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Dt)?"true":"false",class:"cm-content",style:`${R.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Nl(this,xa,t);let i=this.observer.ignore(()=>{let s=wl(this.contentDOM,this.contentAttrs,t),r=wl(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is($.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(hn);let e=this.state.facet($.cspNonce);ei.mount(this.root,this.styleModules.concat(Nm).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Fr(this,e,$l(this,e,t,i))}moveByGroup(e,t){return Fr(this,e,$l(this,e,t,i=>cm(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return A.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,i=!0){return lm(this,e,t,i)}moveVertically(e,t,i){return Fr(this,e,hm(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Xo(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Xo(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),s=this.bidiSpans(i),r=s[Ct.find(s,e-i.from,-1,t)];return this.docView.coordsAt(e,t,r.dir==fe.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(iu)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>eg)return Yh(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||jh(r.isolates,i=Pl(this,e))))return r.order;i||(i=Pl(this,e));let s=Ep(e.text,t,i);return this.bidiCache.push(new Fs(e.from,e.to,t,i,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||R.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Bh(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,s,r,o;return Nn.of(new Ui(typeof e=="number"?A.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(s=t.x)!==null&&s!==void 0?s:"nearest",(r=t.yMargin)!==null&&r!==void 0?r:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Nn.of(new Ui(A.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return xe.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return xe.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ei.newName(),s=[ts.of(i),hn.of(Wo(`.${i}`,e))];return t&&t.dark&&s.push(Io.of(!0)),s}static baseTheme(e){return ri.lowest(hn.of(Wo("."+qo,e,Pu)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&Se.get(i)||Se.get(e);return((t=s?.root)===null||t===void 0?void 0:t.view)||null}}$.styleModule=hn;$.inputHandler=eu;$.clipboardInputFilter=ba;$.clipboardOutputFilter=Sa;$.scrollHandler=su;$.focusChangeEffect=tu;$.perLineTextDirection=iu;$.exceptionSink=Jh;$.updateListener=Fo;$.editable=Dt;$.mouseSelectionStyle=_h;$.dragMovesSelection=Gh;$.clickAddsSelectionRange=Hh;$.decorations=ur;$.blockWrappers=au;$.outerDecorations=va;$.atomicRanges=Dn;$.bidiIsolatedRanges=lu;$.cursorScrollMargin=K.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});$.scrollMargins=cu;$.darkTheme=Io;$.cspNonce=K.define({combine:n=>n.length?n[0]:""});$.contentAttributes=xa;$.editorAttributes=ou;$.lineWrapping=$.contentAttributes.of({class:"cm-lineWrapping"});$.announce=z.define();const eg=4096,Yl={};class Fs{constructor(e,t,i,s,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],s=e.length?e[e.length-1].dir:fe.LTR;for(let r=Math.max(0,e.length-10);r=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&Oa(o,t)}return t}const tg=R.mac?"mac":R.windows?"win":R.linux?"linux":"key";function ig(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let s,r,o,a;for(let l=0;li.concat(s),[]))),t}function sg(n,e,t){return Tu(Cu(n.state),e,n,t)}let Nt=null;const rg=4e3;function og(n,e=tg){let t=Object.create(null),i=Object.create(null),s=(o,a)=>{let l=i[o];if(l==null)i[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,a,l,c,h)=>{var u,f;let d=t[o]||(t[o]=Object.create(null)),p=a.split(/ (?!$)/).map(y=>ig(y,e));for(let y=1;y{let C=Nt={view:x,prefix:b,scope:o};return setTimeout(()=>{Nt==C&&(Nt=null)},rg),!0}]})}let m=p.join(" ");s(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((f=(u=d._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),h&&(g.stopPropagation=!0)};for(let o of n){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let h=t[c]||(t[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let f in h)h[f].run.push(d=>u(d,zo))}let l=o[e]||o.key;if(l)for(let c of a)r(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}let zo=null;function Tu(n,e,t,i){zo=e;let s=bp(e),r=Ne(s,0),o=Qt(r)==s.length&&s!=" ",a="",l=!1,c=!1,h=!1;Nt&&Nt.view==t&&Nt.scope==i&&(a=Nt.prefix+" ",Ou.indexOf(e.keyCode)<0&&(c=!0,Nt=null));let u=new Set,f=g=>{if(g){for(let y of g.run)if(!u.has(y)&&(u.add(y),y(t)))return g.stopPropagation&&(h=!0),!0;g.preventDefault&&(g.stopPropagation&&(h=!0),c=!0)}return!1},d=n[i],p,m;return d&&(f(d[a+is(s,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(R.windows&&e.ctrlKey&&e.altKey)&&!(R.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=ti[e.keyCode])&&p!=s?(f(d[a+is(p,e,!0)])||e.shiftKey&&(m=vn[e.keyCode])!=s&&m!=p&&f(d[a+is(m,e,!1)]))&&(l=!0):o&&e.shiftKey&&f(d[a+is(s,e,!0)])&&(l=!0),!l&&f(d._any)&&(l=!0)),c&&(l=!0),l&&h&&e.stopPropagation(),zo=null,l}class gi{constructor(e,t,i,s,r){this.className=e,this.left=t,this.top=i,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let s=e.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let r=Ru(e);return[new gi(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return ag(e,t,i)}}function Ru(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==fe.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Gl(n,e,t,i){let s=n.coordsAtPos(e,t*2);if(!s)return i;let r=n.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,a=n.posAtCoords({x:r.left+1,y:o}),l=n.posAtCoords({x:r.right-1,y:o});return a==null||l==null?i:{from:Math.max(i.from,Math.min(a,l)),to:Math.min(i.to,Math.max(a,l))}}function ag(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),s=Math.min(t.to,n.viewport.to),r=n.textDirection==fe.LTR,o=n.contentDOM,a=o.getBoundingClientRect(),l=Ru(n),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),f=a.right-(h?parseInt(h.paddingRight):0),d=Lo(n,i,1),p=Lo(n,s,-1),m=d.type==Le.Text?d:null,g=p.type==Le.Text?p:null;if(m&&(n.lineWrapping||d.widgetLineBreaks)&&(m=Gl(n,i,1,m)),g&&(n.lineWrapping||p.widgetLineBreaks)&&(g=Gl(n,s,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return b(x(t.from,t.to,m));{let k=m?x(t.from,null,m):C(d,!1),S=g?x(null,t.to,g):C(p,!0),w=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&k.bottom+n.defaultLineHeight/2M&&Q.from=P)break;ee>D&&E(Math.max(J,D),k==null&&J<=M,Math.min(ee,P),S==null&&ee>=Y,ae.dir)}if(D=j.to+1,D>=P)break}return V.length==0&&E(M,k==null,Y,S==null,n.textDirection),{top:U,bottom:F,horizontal:V}}function C(k,S){let w=a.top+(S?k.top:k.bottom);return{top:w,bottom:w,horizontal:[]}}}function lg(n,e){return n.constructor==e.constructor&&n.eq(e)}class cg{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(bs)!=e.state.facet(bs)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(bs);for(;t!lg(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[i].constructor&&s.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e,R.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const bs=K.define();function $u(n){return[xe.define(e=>new cg(e,n)),bs.of(n)]}const zi=K.define({combine(n){return yt(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function hg(n={}){return[zi.of(n),ug,fg,pg,nu.of(!0)]}function Ku(n){return n.startState.facet(zi)!=n.state.facet(zi)}const ug=$u({above:!0,markers(n){let{state:e}=n,t=e.facet(zi),i=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty||t.drawRangeCursor&&!(r&&R.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=s.empty?s:A.cursor(s.head,s.assoc);for(let l of gi.forRange(n,o,a))i.push(l)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Ku(n);return t&&_l(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){_l(e.state,n)},class:"cm-cursorLayer"});function _l(n,e){e.style.animationDuration=n.facet(zi).cursorBlinkRate+"ms"}const fg=$u({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let s of i)if(!s.empty)for(let r of gi.forRange(n,"cm-selectionBackground",s))e.push(r);if(R.ios&&!t.empty&&n.state.facet(zi).iosSelectionHandles){for(let s of gi.forRange(n,"cm-selectionHandle cm-selectionHandle-start",A.cursor(t.from,1)))e.push(s);for(let s of gi.forRange(n,"cm-selectionHandle cm-selectionHandle-end",A.cursor(t.to,1)))e.push(s)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Ku(n)},class:"cm-selectionLayer"}),dg=R.gecko&&R.gecko_version==153?"#ffffff01":"transparent",pg=ri.highest($.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${dg} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Zu=z.define({map(n,e){return n==null?null:e.mapPos(n)}}),fn=Te.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Zu)?i.value:t,n)}}),mg=xe.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(fn);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(fn)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(fn),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(fn)!=n&&this.view.dispatch({effects:Zu.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function gg(){return[fn,mg]}function Jl(n,e,t,i,s){e.lastIndex=0;for(let r=n.iterRange(t,i),o=t,a;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;a=e.exec(r.value);)s(o+a.index,a)}function Og(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:s,to:r}of t)s=Math.max(n.state.doc.lineAt(s).from,s-e),r=Math.min(n.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}class yg{constructor(e){const{regexp:t,decoration:i,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(a,l,c,h)=>s(h,c,c+a[0].length,a,l);else if(typeof i=="function")this.addMatch=(a,l,c,h)=>{let u=i(a,l,c);u&&h(c,c+a[0].length,u)};else if(i)this.addMatch=(a,l,c,h)=>h(c,c+a[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Bt,i=t.add.bind(t);for(let{from:s,to:r}of Og(e,this.maxLength))Jl(e.state.doc,this.regexp,s,r,(o,a)=>this.addMatch(a,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,a,l)=>{l>=e.view.viewport.from&&a<=e.view.viewport.to&&(i=Math.min(a,i),s=Math.max(l,s))}),e.viewportMoved||s-i>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let o=Math.max(r.from,i),a=Math.min(r.to,s);if(a>=o){let l=e.state.doc.lineAt(o),c=l.tol.from;o--)if(this.boundary.test(l.text[o-1-l.from])){h=o;break}for(;af.push(y.range(m,g));if(l==c)for(this.regexp.lastIndex=h-l.from;(d=this.regexp.exec(l.text))&&d.indexthis.addMatch(g,e,m,p));t=t.update({filterFrom:h,filterTo:u,filter:(m,g)=>mu,add:f})}}return t}}const Vo=/x/.unicode!=null?"gu":"g",Ag=new RegExp(`[\0-\b +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Vo),bg={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Xr=null;function Sg(){var n;if(Xr==null&&typeof document<"u"&&document.body){let e=document.body.style;Xr=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Xr||!1}const Ss=K.define({combine(n){let e=yt(n,{render:null,specialChars:Ag,addSpecialChars:null});return(e.replaceTabs=!Sg())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Vo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Vo)),e}});function xg(n={}){return[Ss.of(n),vg()]}let ec=null;function vg(){return ec||(ec=xe.fromClass(class{constructor(n){this.view=n,this.decorations=B.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Ss)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new yg({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=Ne(e[0],0);if(r==9){let o=s.lineAt(i),a=t.state.tabSize,l=_i(o.text,a,i-o.from);return B.replace({widget:new Pg((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=B.replace({widget:new Qg(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Ss);n.startState.facet(Ss)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const wg="•";function kg(n){return n>=32?wg:n==10?"␤":String.fromCharCode(9216+n)}class Qg extends Ut{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=kg(this.code),i=e.state.phrase("Control character")+" "+(bg[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class Pg extends Ut{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function Cg(){return Rg}const Tg=B.line({class:"cm-activeLine"}),Rg=xe.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let s=n.lineBlockAt(i.head);s.from>e&&(t.push(Tg.range(s.from)),e=s.from)}return B.set(t)}},{decorations:n=>n.decorations}),jo=2e3;function $g(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>jo||t.off>jo||e.col<0||t.col<0){let o=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let l=i;l<=s;l++){let c=n.doc.line(l);c.length<=a&&r.push(A.range(c.from+o,c.to+a))}}else{let o=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let l=i;l<=s;l++){let c=n.doc.line(l),h=Qo(c.text,o,n.tabSize,!0);if(h<0)r.push(A.cursor(c.to));else{let u=Qo(c.text,a,n.tabSize);r.push(A.range(c.from+h,c.from+u))}}}return r}function Kg(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function tc(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>jo?-1:s==i.length?Kg(n,e.clientX):_i(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function Zg(n,e){let t=tc(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let a=tc(n,s);if(!a)return i;let l=$g(n.state,t,a);return l.length?o?A.create(l.concat(i.ranges)):A.create(l):i}}:null}function Mg(n){let e=(t=>t.altKey&&t.button==0);return $.mouseSelectionStyle.of((t,i)=>e(i)?Zg(t,i):null)}const Eg={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},Ug={style:"cursor: crosshair"};function Fg(n={}){let[e,t]=Eg[n.key||"Alt"],i=xe.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,$.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?Ug:null})]}const ns="-10000px";class Mu{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let s=e.state.facet(this.facet),r=s.filter(l=>l);if(s===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=t?[]:null;for(let l=0;lt[c]=l),t.length=a.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function Dg(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Br=K.define({combine:n=>{var e,t,i;return{position:R.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Dg}}}),ic=new WeakMap,Ca=xe.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Br);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Mu(n,gr,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Br);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=ns,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(R.safari){let o=r.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(n=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=wa(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Br).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:i,scaleX:s,scaleY:r}=n,o=[];for(let a=0;a=Math.min(t.bottom,i.bottom)||u.rightMath.min(t.right,i.right)+.1)){h.style.top=ns;continue}let d=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=f.right-f.left,g=(e=ic.get(c))!==null&&e!==void 0?e:f.bottom-f.top,y=c.offset||Xg,b=this.view.textDirection==fe.LTR,x=f.width>i.right-i.left?b?i.left:i.right-f.width:b?Math.max(i.left,Math.min(u.left-(d?14:0)+y.x,i.right-m)):Math.min(Math.max(i.left,u.left-m+(d?14:0)-y.x),i.right-m),C=this.above[a];!l.strictSide&&(C?u.top-g-p-y.yi.bottom)&&C==i.bottom-u.bottom>u.top-i.top&&(C=this.above[a]=!C);let k=(C?u.top-i.top:i.bottom-u.bottom)-p;if(kx&&U.topS&&(S=C?U.top-g-2-p:U.bottom+p+2);if(this.position=="absolute"?(h.style.top=(S-n.parent.top)/r+"px",nc(h,(x-n.parent.left)/s)):(h.style.top=S/r+"px",nc(h,x/s)),d){let U=u.left+(b?y.x:-y.x)-(x+14-7);d.style.left=U/s+"px"}c.overlap!==!0&&o.push({left:x,top:S,right:w,bottom:S+g}),h.classList.toggle("cm-tooltip-above",C),h.classList.toggle("cm-tooltip-below",!C),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=ns}},{eventObservers:{scroll(){this.maybeMeasure()}}});function nc(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const Lg=$.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Xg={x:0,y:0},gr=K.define({enables:[Ca,Lg]}),Ds=K.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class Or{static create(e){return new Or(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Mu(e,Ds,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let s=i[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Bg=gr.compute([Ds],n=>{let e=n.facet(Ds);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Or.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Ig=K.define();class qg{constructor(e,t,i,s,r,o){this.view=e,this.source=t,this.field=i,this.locked=s,this.setHover=r,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||t.xo.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(s)).find(c=>c.from<=s&&c.to>=s),l=a&&a.dir==fe.RTL?-1:1;r=t.x{if(a&&!(Array.isArray(a)&&!a.length)){let l=Array.isArray(a)?a:[a];s&&this.locked.set(l,s),e.dispatch({effects:this.setHover.of(l)})}};if(r&&"then"in r){let a=this.pending={pos:t};r.then(l=>{this.pending==a&&(this.pending=null,o(l))},l=>ze(e.state,l,"hover tooltip"))}else o(r)}get tooltip(){let e=this.view.plugin(Ca),t=e?e.manager.tooltips.findIndex(i=>i.create==Or.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&!this.locked.has(s)&&r&&!Wg(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,a=(i=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!zg(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:s}=this;s.length&&!this.locked.has(s)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ss=4;function Wg(n,e){let{left:t,right:i,top:s,bottom:r}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();s=Math.min(a.top,s),r=Math.max(a.bottom,r)}return e.clientX>=t-ss&&e.clientX<=i+ss&&e.clientY>=s-ss&&e.clientY<=r+ss}function zg(n,e,t,i,s,r){let o=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.rights||Math.min(o.bottom,a)=e&&l<=t}function Eu(n,e={}){let t=z.define(),i=new WeakMap,s=Te.define({create(){return[]},update(o,a){let l=i.get(o);if(o.length&&(e.hideOnChange&&(a.docChanged||a.selection)?o=[]:l&&l(a)?o=[]:e.hideOn&&(o=o.filter(c=>!e.hideOn(a,c)))),a.docChanged&&o.length){let c=[];for(let h of o){let u=a.changes.mapPos(h.pos,-1,De.TrackDel);if(u!=null){let f=Object.assign(Object.create(null),h);f.pos=u,f.end!=null&&(f.end=a.changes.mapPos(f.end)),c.push(f)}}o=c}for(let c of a.effects)c.is(t)&&(o=c.value,l=void 0),(c.is(Vg)&&!c.value||c.value==s)&&(o=[]);return o.length&&l&&i.set(o,l),o},provide:o=>Ds.from(o)});const r=xe.define(o=>new qg(o,n,s,i,t,e.hoverTime||300));return{active:s,extension:[s,r,Ig.of(r),Bg]}}function Uu(n,e){let t=n.plugin(Ca);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const Vg=z.define(),sc=K.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Fu(n,e){let t=n.plugin(Du),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Du=xe.fromClass(class{constructor(n){this.input=n.state.facet(Vi),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(sc);this.top=new rs(n,!0,e.topContainer),this.bottom=new rs(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(sc);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new rs(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new rs(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Vi);if(t!=this.input){let i=t.filter(l=>l),s=[],r=[],o=[],a=[];for(let l of i){let c=this.specs.indexOf(l),h;c<0?(h=l(n.view),a.push(h)):(h=this.panels[c],h.update&&h.update(n)),s.push(h),(h.top?r:o).push(h)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>$.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class rs{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=rc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=rc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function rc(n){let e=n.nextSibling;return n.remove(),e}const Vi=K.define({enables:Du});function jg(n,e){let t,i=new Promise(o=>t=o),s=o=>Yg(o,e,t);n.state.field(Ir,!1)?n.dispatch({effects:Lu.of(s)}):n.dispatch({effects:z.appendConfig.of(Ir.init(()=>[s]))});let r=Xu.of(s);return{close:r,result:i.then(o=>((n.win.queueMicrotask||(l=>n.win.setTimeout(l,10)))(()=>{n.state.field(Ir).indexOf(s)>-1&&n.dispatch({effects:r})}),o))}}const Ir=Te.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(Lu)?n=[t.value].concat(n):t.is(Xu)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>Vi.computeN([n],e=>e.field(n))}),Lu=z.define(),Xu=z.define();function Yg(n,e,t){let i=e.content?e.content(n,()=>o(null)):null;if(!i){if(i=he("form"),e.input){let a=he("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),i.appendChild(he("label",(e.label||"")+": ",a))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(he("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let s=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let a=0;a{c.keyCode==27?(c.preventDefault(),o(null)):c.keyCode==13&&(c.preventDefault(),o(l))}),l.addEventListener("submit",c=>{c.preventDefault(),o(l)})}let r=he("div",i,he("button",{onclick:()=>o(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function o(a){r.contains(r.ownerDocument.activeElement)&&n.focus(),t(a)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let a;typeof e.focus=="string"?a=i.querySelector(e.focus):a=i.querySelector("input")||i.querySelector("button"),a&&"select"in a?a.select():a&&"focus"in a&&a.focus()}}}}class Mt extends Jt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Mt.prototype.elementClass="";Mt.prototype.toDOM=void 0;Mt.prototype.mapMode=De.TrackBefore;Mt.prototype.startSide=Mt.prototype.endSide=-1;Mt.prototype.point=!0;const xs=K.define(),Ng=K.define(),Hg={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>N.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},An=K.define();function Bu(n){return[Iu(),An.of({...Hg,...n})]}const oc=K.define({combine:n=>n.some(e=>e)});function Iu(n){return[Gg]}const Gg=xe.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(An).map(e=>new lc(n,e)),this.fixed=!n.state.facet(oc);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(oc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=N.iter(this.view.state.facet(xs),this.view.viewport.from),i=[],s=this.gutters.map(r=>new _g(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let a of r.type)if(a.type==Le.Text&&o){Yo(t,i,a.from);for(let l of s)l.line(this.view,a,i);o=!1}else if(a.widget)for(let l of s)l.widget(this.view,a)}else if(r.type==Le.Text){Yo(t,i,r.from);for(let o of s)o.line(this.view,r,i)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(An),t=n.state.facet(An),i=n.docChanged||n.heightChanged||n.viewportChanged||!N.eq(n.startState.facet(xs),n.state.facet(xs),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new lc(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>$.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==fe.LTR?{left:i,right:s}:{right:i,left:s}})});function ac(n){return Array.isArray(n)?n:[n]}function Yo(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class _g{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=N.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let a=new qu(e,o,r,i);s.elements.push(a),s.dom.appendChild(a.dom)}else s.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];Yo(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),s=i?[i]:null;for(let r of e.state.facet(Ng)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class lc{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let l=r.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=s.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,a,s)&&s.preventDefault()});this.markers=ac(t.markers(e)),t.initialSpacer&&(this.spacer=new qu(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=ac(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!N.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class qu{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Jg(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let a=o,l=rr(a,l,c)||o(a,l,c):o}return i}})}});class qr extends Mt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Wr(n,e){return n.state.facet(Ri).formatNumber(e,n.state)}const iO=An.compute([Ri],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(eO)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new qr(Wr(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let s of e.state.facet(tO)){let r=s(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Ri)!=e.state.facet(Ri),initialSpacer(e){return new qr(Wr(e,cc(e.state.doc.lines)))},updateSpacer(e,t){let i=Wr(t.view,cc(t.view.state.doc.lines));return i==e.number?e:new qr(i)},domEventHandlers:n.facet(Ri).domEventHandlers,side:"before"}));function nO(n={}){return[Ri.of(n),Iu(),iO]}function cc(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head).from;s>t&&(t=s,e.push(sO.range(s)))}return N.of(e)});function oO(){return rO}const Wu=1024;let aO=0;class zr{constructor(e,t){this.from=e,this.to=t}}class G{constructor(e={}){this.id=aO++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=et.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}G.closedBy=new G({deserialize:n=>n.split(" ")});G.openedBy=new G({deserialize:n=>n.split(" ")});G.group=new G({deserialize:n=>n.split(" ")});G.isolate=new G({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});G.contextHash=new G({perNode:!0});G.lookAhead=new G({perNode:!0});G.mounted=new G({perNode:!0});class bn{constructor(e,t,i,s=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=s}static get(e){return e&&e.props&&e.props[G.mounted.id]}}const lO=Object.create(null);class et{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):lO,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new et(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(G.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(G.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?i.name:s[r]];if(o)return o}}}}et.none=new et("",Object.create(null),0,8);class Ta{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|be.IncludeAnonymous);;){let c=!1;if(l.from<=r&&l.to>=s&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&i&&(a||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ka(et.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new ke(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new ke(et.none,t,i,s)))}static build(e){return fO(e)}}ke.empty=new ke(et.none,[],[],0);class Ra{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Ra(this.buffer,this.index)}}class ni{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return et.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,i){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Pn(n,e,t,i){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?a.length:-1;e!=c;e+=t){let h=a[e],u=l[e]+o.from,f;if(!(!(r&be.EnterBracketed&&h instanceof ke&&(f=bn.get(h))&&!f.overlay&&f.bracketed&&i>=u&&i<=u+h.length)&&!zu(s,i,u,u+h.length))){if(h instanceof ni){if(r&be.ExcludeBuffers)continue;let d=h.findChild(0,h.buffer.length,t,i-u,s);if(d>-1)return new Tt(new cO(o,h,e,u),null,d)}else if(r&be.IncludeAnonymous||!h.type.isAnonymous||$a(h)){let d;if(!(r&be.IgnoreMounts)&&(d=bn.get(h))&&!d.overlay)return new Je(d.tree,u,e,o);let p=new Je(h,u,e,o);return r&be.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?h.children.length-1:0,t,i,s,r)}}}if(r&be.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let s;if(!(i&be.IgnoreOverlays)&&(s=bn.get(this._tree))&&s.overlay){let r=e-this.from,o=i&be.EnterBracketed&&s.bracketed;for(let{from:a,to:l}of s.overlay)if((t>0||o?a<=r:a=r:l>r))return new Je(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function uc(n,e,t,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function No(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class cO{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class Tt extends Vu{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new Tt(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&be.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Tt(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Tt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Tt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];e.push(i.slice(s,r,o)),t.push(0)}return new ke(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function ju(n){if(!n.length)return null;let e=0,t=n[0];for(let r=1;rt.from||o.to=e){let a=new Je(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[i])).push(Pn(a,e,t,!1))}}return s?ju(s):i}class Ho{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~be.EnterBracketed,e instanceof Je)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof Je?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&be.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&be.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&be.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let a=i._tree.children[r];if(this.mode&be.IncludeAnonymous||a instanceof ni||!a.type.isAnonymous||$a(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,i=r+1;break e}s=this.stack[--r]}for(let s=i;s=0;r--){if(r<0)return No(this._tree,e,s);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function $a(n){return n.children.some(e=>e instanceof ni||!e.type.isAnonymous||$a(e))}function fO(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=Wu,reused:r=[],minRepeatType:o=i.types.length}=n,a=Array.isArray(t)?new Ra(t,t.length):t,l=i.types,c=0,h=0;function u(k,S,w,U,F,V){let{id:E,start:M,end:Y,size:Q}=a,D=h,P=c;if(Q<0)if(a.next(),Q==-1){let I=r[E];w.push(I),U.push(M-k);return}else if(Q==-3){c=E;return}else if(Q==-4){h=E;return}else throw new RangeError(`Unrecognized record size: ${Q}`);let j=l[E],ae,J,ee=M-k;if(Y-M<=s&&(J=g(a.pos-S,F))){let I=new Uint16Array(J.size-J.skip),H=a.pos-J.size,ce=I.length;for(;a.pos>H;)ce=y(J.start,I,ce);ae=new ni(I,Y-J.start,i),ee=J.start-k}else{let I=a.pos-Q;a.next();let H=[],ce=[],q=E>=o?E:-1,te=0,re=Y;for(;a.pos>I;)q>=0&&a.id==q&&a.size>=0?(a.end<=re-s&&(p(H,ce,M,te,a.end,re,q,D,P),te=H.length,re=a.end),a.next()):V>2500?f(M,I,H,ce):u(M,I,H,ce,q,V+1);if(q>=0&&te>0&&te-1&&te>0){let Me=d(j,P);ae=Ka(j,H,ce,0,H.length,0,Y-M,Me,Me)}else ae=m(j,H,ce,Y-M,D-Y,P)}w.push(ae),U.push(ee)}function f(k,S,w,U){let F=[],V=0,E=-1;for(;a.pos>S;){let{id:M,start:Y,end:Q,size:D}=a;if(D>4)a.next();else{if(E>-1&&Y=0;Q-=3)M[D++]=F[Q],M[D++]=F[Q+1]-Y,M[D++]=F[Q+2]-Y,M[D++]=D;w.push(new ni(M,F[2]-Y,i)),U.push(Y-k)}}function d(k,S){return(w,U,F)=>{let V=0,E=w.length-1,M,Y;if(E>=0&&(M=w[E])instanceof ke){if(!E&&M.type==k&&M.length==F)return M;(Y=M.prop(G.lookAhead))&&(V=U[E]+M.length+Y)}return m(k,w,U,F,V,S)}}function p(k,S,w,U,F,V,E,M,Y){let Q=[],D=[];for(;k.length>U;)Q.push(k.pop()),D.push(S.pop()+w-F);k.push(m(i.types[E],Q,D,V-F,M-V,Y)),S.push(F-w)}function m(k,S,w,U,F,V,E){if(V){let M=[G.contextHash,V];E=E?[M].concat(E):[M]}if(F>25){let M=[G.lookAhead,F];E=E?[M].concat(E):[M]}return new ke(k,S,w,U,E)}function g(k,S){let w=a.fork(),U=0,F=0,V=0,E=w.end-s,M={size:0,start:0,skip:0};e:for(let Y=w.pos-k;w.pos>Y;){let Q=w.size;if(w.id==S&&Q>=0){M.size=U,M.start=F,M.skip=V,V+=4,U+=4,w.next();continue}let D=w.pos-Q;if(Q<0||D=o?4:0,j=w.start;for(w.next();w.pos>D;){if(w.size<0)if(w.size==-3||w.size==-4)P+=4;else break e;else w.id>=o&&(P+=4);w.next()}F=j,U+=Q,V+=P}return(S<0||U==k)&&(M.size=U,M.start=F,M.skip=V),M.size>4?M:void 0}function y(k,S,w){let{id:U,start:F,end:V,size:E}=a;if(a.next(),E>=0&&U4){let Y=a.pos-(E-4);for(;a.pos>Y;)w=y(k,S,w)}S[--w]=M,S[--w]=V-k,S[--w]=F-k,S[--w]=U}else E==-3?c=U:E==-4&&(h=U);return w}let b=[],x=[];for(;a.pos>0;)u(n.start||0,n.bufferStart||0,b,x,-1,0);let C=(e=n.length)!==null&&e!==void 0?e:b.length?x[0]+b[0].length:0;return new ke(l[n.topID],b.reverse(),x.reverse(),C)}const fc=new WeakMap;function vs(n,e){if(!n.isAnonymous||e instanceof ni||e.type!=n)return 1;let t=fc.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof ke)){t=1;break}t+=vs(n,i)}fc.set(e,t)}return t}function Ka(n,e,t,i,s,r,o,a,l){let c=0;for(let p=i;p=h)break;S+=w}if(x==C+1){if(S>h){let w=p[C];d(w.children,w.positions,0,w.children.length,m[C]+b);continue}u.push(p[C])}else{let w=m[x-1]+p[x-1].length-k;u.push(Ka(n,p,m,C,x,k,w,null,l))}f.push(k+b-r)}}return d(e,t,i,s,0),(a||l)(u,f,o)}class dO{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Tt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Je&&this.map.set(e.tree,t)}get(e){return e instanceof Tt?this.getBuffer(e.context.buffer,e.index):e instanceof Je?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Oi{constructor(e,t,i,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let s=[new Oi(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let h=a=i)for(;o&&o.from=f.from||u<=f.to||c){let d=Math.max(f.from,l)-c,p=Math.min(f.to,u)-c;f=d>=p?null:new Oi(d,p,f.tree,f.offset+c,a>0,!!h)}if(f&&s.push(f),o.to>u)break;o=rnew zr(s.from,s.to)):[new zr(0,0)]:[new zr(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let r=s.advance();if(r)return r}}}class pO{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new G({perNode:!0});let mO=0;class lt{constructor(e,t,i,s){this.name=e,this.set=t,this.base=i,this.modified=s,this.id=mO++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof lt&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let s=new lt(i,[],null,[]);if(s.set.push(s),t)for(let r of t.set)s.set.push(r);return s}static defineModifier(e){let t=new Ls(e);return i=>i.modified.indexOf(t)>-1?i:Ls.get(i.base||i,i.modified.concat(t).sort((s,r)=>s.id-r.id))}}let gO=0;class Ls{constructor(e){this.name=e,this.instances=[],this.id=gO++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&OO(t,a.modified));if(i)return i;let s=[],r=new lt(e.name,s,e,t);for(let a of t)a.instances.push(r);let o=yO(t);for(let a of e.set)if(!a.modified.length)for(let l of o)s.push(Ls.get(a,l));return r}}function OO(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function yO(n){let e=[[]];for(let t=0;ti.length-t.length)}function Nu(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let r=[],o=2,a=s;for(let u=0;;){if(a=="..."&&u>0&&u+3==s.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+s);if(r.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==s.length)break;let d=s[u++];if(u==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);a=s.slice(u)}let l=r.length-1,c=r[l];if(!c)throw new RangeError("Invalid path: "+s);let h=new Cn(i,o,l>0?r.slice(0,l):null);e[c]=h.sort(e[c])}}return Hu.add(e)}const Hu=new G({combine(n,e){let t,i,s;for(;n||e;){if(!n||e&&n.depth>=e.depth?(s=e,e=e.next):(s=n,n=n.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let r=new Cn(s.tags,s.mode,s.context);t?t.next=r:i=r,t=r}return i}});class Cn{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=s;for(let a of r)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:i}}function AO(n,e){let t=null;for(let i of n){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function bO(n,e,t,i=0,s=n.length){let r=new SO(i,Array.isArray(e)?e:[e],t);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class SO{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,s,r){let{type:o,from:a,to:l}=e;if(a>=i||l<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=s,h=xO(e)||Cn.empty,u=AO(r,h.tags);if(u&&(c&&(c+=" "),c+=u,h.mode==1&&(s+=(s?" ":"")+u)),this.startSpan(Math.max(t,a),c),h.opaque)return;let f=e.tree&&e.tree.prop(G.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+a,1),p=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),m=e.firstChild();for(let g=0,y=a;;g++){let b=g=x||!e.nextSibling())););if(!b||x>i)break;y=b.to+a,y>t&&(this.highlightRange(d.cursor(),Math.max(t,b.from+a),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),c))}m&&e.parent()}else if(e.firstChild()){f&&(s="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}}function xO(n){let e=n.type.prop(Hu);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const T=lt.define,as=T(),Vt=T(),dc=T(Vt),pc=T(Vt),jt=T(),ls=T(jt),Vr=T(jt),wt=T(),li=T(wt),xt=T(),vt=T(),Go=T(),on=T(Go),cs=T(),O={comment:as,lineComment:T(as),blockComment:T(as),docComment:T(as),name:Vt,variableName:T(Vt),typeName:dc,tagName:T(dc),propertyName:pc,attributeName:T(pc),className:T(Vt),labelName:T(Vt),namespace:T(Vt),macroName:T(Vt),literal:jt,string:ls,docString:T(ls),character:T(ls),attributeValue:T(ls),number:Vr,integer:T(Vr),float:T(Vr),bool:T(jt),regexp:T(jt),escape:T(jt),color:T(jt),url:T(jt),keyword:xt,self:T(xt),null:T(xt),atom:T(xt),unit:T(xt),modifier:T(xt),operatorKeyword:T(xt),controlKeyword:T(xt),definitionKeyword:T(xt),moduleKeyword:T(xt),operator:vt,derefOperator:T(vt),arithmeticOperator:T(vt),logicOperator:T(vt),bitwiseOperator:T(vt),compareOperator:T(vt),updateOperator:T(vt),definitionOperator:T(vt),typeOperator:T(vt),controlOperator:T(vt),punctuation:Go,separator:T(Go),bracket:on,angleBracket:T(on),squareBracket:T(on),paren:T(on),brace:T(on),content:wt,heading:li,heading1:T(li),heading2:T(li),heading3:T(li),heading4:T(li),heading5:T(li),heading6:T(li),contentSeparator:T(wt),list:T(wt),quote:T(wt),emphasis:T(wt),strong:T(wt),link:T(wt),monospace:T(wt),strikethrough:T(wt),inserted:T(),deleted:T(),changed:T(),invalid:T(),meta:cs,documentMeta:T(cs),annotation:T(cs),processingInstruction:T(cs),definition:lt.defineModifier("definition"),constant:lt.defineModifier("constant"),function:lt.defineModifier("function"),standard:lt.defineModifier("standard"),local:lt.defineModifier("local"),special:lt.defineModifier("special")};for(let n in O){let e=O[n];e instanceof lt&&(e.name=n)}Gu([{tag:O.link,class:"tok-link"},{tag:O.heading,class:"tok-heading"},{tag:O.emphasis,class:"tok-emphasis"},{tag:O.strong,class:"tok-strong"},{tag:O.keyword,class:"tok-keyword"},{tag:O.atom,class:"tok-atom"},{tag:O.bool,class:"tok-bool"},{tag:O.url,class:"tok-url"},{tag:O.labelName,class:"tok-labelName"},{tag:O.inserted,class:"tok-inserted"},{tag:O.deleted,class:"tok-deleted"},{tag:O.literal,class:"tok-literal"},{tag:O.string,class:"tok-string"},{tag:O.number,class:"tok-number"},{tag:[O.regexp,O.escape,O.special(O.string)],class:"tok-string2"},{tag:O.variableName,class:"tok-variableName"},{tag:O.local(O.variableName),class:"tok-variableName tok-local"},{tag:O.definition(O.variableName),class:"tok-variableName tok-definition"},{tag:O.special(O.variableName),class:"tok-variableName2"},{tag:O.definition(O.propertyName),class:"tok-propertyName tok-definition"},{tag:O.typeName,class:"tok-typeName"},{tag:O.namespace,class:"tok-namespace"},{tag:O.className,class:"tok-className"},{tag:O.macroName,class:"tok-macroName"},{tag:O.propertyName,class:"tok-propertyName"},{tag:O.operator,class:"tok-operator"},{tag:O.comment,class:"tok-comment"},{tag:O.meta,class:"tok-meta"},{tag:O.invalid,class:"tok-invalid"},{tag:O.punctuation,class:"tok-punctuation"}]);var jr;const $i=new G;function _u(n){return K.define({combine:n?e=>e.concat(n):void 0})}const Za=new G;class mt{constructor(e,t,i=[],s=""){this.data=e,this.name=s,_.prototype.hasOwnProperty("tree")||Object.defineProperty(_.prototype,"tree",{get(){return Ce(this)}}),this.parser=t,this.extension=[si.of(this),_.languageData.of((r,o,a)=>{let l=mc(r,o,a),c=l.type.prop($i);if(!c)return[];let h=r.facet(c),u=l.type.prop(Za);if(u){let f=l.resolve(o-l.from,a);for(let d of u)if(d.test(f,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(h)}}return h})].concat(i)}isActiveAt(e,t,i=-1){return mc(e,t,i).type.prop($i)==this.data}findRegions(e){let t=e.facet(si);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop($i)==this.data){i.push({from:o,to:o+r.length});return}let a=r.prop(G.mounted);if(a){if(a.tree.prop($i)==this.data){if(a.overlay)for(let l of a.overlay)i.push({from:l.from+o,to:l.to+o});else i.push({from:o,to:o+r.length});return}else if(a.overlay){let l=i.length;if(s(a.tree,a.overlay[0].from+o),i.length>l)return}}for(let l=0;li.isTop?t:void 0)]}),e.name)}configure(e,t){return new Xs(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ce(n){let e=n.field(mt.state,!1);return e?e.tree:ke.empty}class vO{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let an=null;class Bs{constructor(e,t,i=[],s,r,o,a,l){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Bs(e,t,[],ke.empty,0,i,[],null)}startParse(){return this.parser.startParse(new vO(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ke.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Oi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=an;an=this;try{return e()}finally{an=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=gc(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,h,u,f)=>l.push({fromA:c,toA:h,fromB:u,toB:f})),i=Oi.applyChanges(i,l),s=ke.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);he.from&&(this.fragments=gc(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Yu{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let l=an;if(l){for(let c of s)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new ke(et.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return an}}function gc(n,e,t){return Oi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class ji{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new ji(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Bs.create(e.facet(si).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ji(i)}}mt.state=Te.define({create:ji.init,update(n,e){for(let t of e.effects)if(t.is(mt.setState))return t.value;return e.startState.facet(si)!=e.state.facet(si)?ji.init(e.state):n.apply(e)}});let Ju=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Ju=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Yr=typeof navigator<"u"&&(!((jr=navigator.scheduling)===null||jr===void 0)&&jr.isInputPending)?()=>navigator.scheduling.isInputPending():null,wO=xe.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(mt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(mt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Ju(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnds+1e3,l=r.context.work(()=>Yr&&Yr()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:mt.setState.of(new ji(r.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ze(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),si=K.define({combine(n){return n.length?n[0]:null},enables:n=>[mt.state,wO,$.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class kO{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const QO=K.define(),yr=K.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Is(n){let e=n.facet(yr);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Tn(n,e){let t="",i=n.tabSize,s=n.facet(yr)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r=e?PO(n,t,e):null}class Ar{constructor(e,t={}){this.state=e,this.options=t,this.unit=Is(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return _i(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ef=new G;function PO(n,e,t){let i=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=i.node){let r=[];for(let o=s;o&&!(o.fromi.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return tf(i,n,t)}function tf(n,e,t){for(let i=n;i;i=i.next){let s=TO(i.node);if(s)return s(Ea.create(e,t,i))}return 0}function CO(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function TO(n){let e=n.type.prop(ef);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(G.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>nf(o,!0,1,void 0,r&&!CO(o)?s.from:void 0)}return n.parent==null?RO:null}function RO(){return 0}class Ea extends Ar{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Ea(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if($O(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return tf(this.context.next,this.base,this.pos)}}function $O(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function KO(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==i)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function ZO({closing:n,align:e=!0,units:t=1}){return i=>nf(i,e,t,n)}function nf(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,a=i&&r.slice(o,o+i.length)==i||s==n.pos+o,l=e?KO(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}const MO=n=>n.baseIndent;function Nr({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const EO=200;function UO(){return _.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+EO)return n;let r=t.sliceString(s.from,i);if(!e.some(c=>c.test(r)))return n;let{state:o}=n,a=-1,l=[];for(let{head:c}of o.selection.ranges){let h=o.doc.lineAt(c);if(h.from==a)continue;a=h.from;let u=Ma(o,h.from);if(u==null)continue;let f=/^\s*/.exec(h.text)[0],d=Tn(o,u);f!=d&&l.push({from:h.from,to:h.from+f.length,insert:d})}return l.length?[n,{changes:l,sequential:!0}]:n})}const FO=K.define(),sf=new G;function DO(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(r&&a.from=e&&c.to>t&&(r=c)}}return r}function XO(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function qs(n,e,t){for(let i of n.facet(FO)){let s=i(n,e,t);if(s)return s}return LO(n,e,t)}function rf(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const br=z.define({map:rf}),Ln=z.define({map:rf});function of(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const xi=Te.define({create(){return B.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,s)=>n=Oc(n,i,s)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(br)&&!BO(n,i.value.from,i.value.to)?t.push(i.value):i.is(Ln)&&(n=n.update({filter:(s,r)=>i.value.from!=s||i.value.to!=r,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(cf),s=t.map(r=>(i?B.replace({widget:new YO(i(e.state,r))}):yc).range(r.from,r.to));n=n.update({add:s})}return e.selection&&(n=Oc(n,e.selection.main.head)),n},provide:n=>$.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{se&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(s,r)=>s>=t||r<=e}):n}function Ws(n,e,t){var i;let s=null;return(i=n.field(xi,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function BO(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function af(n,e){return n.field(xi,!1)?e:e.concat(z.appendConfig.of(hf()))}const IO=n=>{for(let e of of(n)){let t=qs(n.state,e.from,e.to);if(t)return n.dispatch({effects:af(n.state,[br.of(t),lf(n,t)])}),!0}return!1},qO=n=>{if(!n.state.field(xi,!1))return!1;let e=[];for(let t of of(n)){let i=Ws(n.state,t.from,t.to);i&&e.push(Ln.of(i),lf(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function lf(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return $.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const WO=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(xi,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(Ln.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},VO=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:IO},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:qO},{key:"Ctrl-Alt-[",run:WO},{key:"Ctrl-Alt-]",run:zO}],jO={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},cf=K.define({combine(n){return yt(n,jO)}});function hf(n){return[xi,GO]}function uf(n,e){let{state:t}=n,i=t.facet(cf),s=o=>{let a=n.lineBlockAt(n.posAtDOM(o.target)),l=Ws(n.state,a.from,a.to);l&&n.dispatch({effects:Ln.of(l)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,s,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const yc=B.replace({widget:new class extends Ut{toDOM(n){return uf(n,null)}}});class YO extends Ut{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return uf(e,this.value)}}const NO={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Hr extends Mt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function HO(n={}){let e={...NO,...n},t=new Hr(e,!0),i=new Hr(e,!1),s=xe.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(si)!=o.state.facet(si)||o.startState.field(xi,!1)!=o.state.field(xi,!1)||Ce(o.startState)!=Ce(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new Bt;for(let l of o.viewportLineBlocks){let c=Ws(o.state,l.from,l.to)?i:qs(o.state,l.from,l.to)?t:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:r}=e;return[s,Bu({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(s))===null||a===void 0?void 0:a.markers)||N.empty},initialSpacer(){return new Hr(e,!1)},domEventHandlers:{...r,click:(o,a,l)=>{if(r.click&&r.click(o,a,l))return!0;let c=Ws(o.state,a.from,a.to);if(c)return o.dispatch({effects:Ln.of(c)}),!0;let h=qs(o.state,a.from,a.to);return h?(o.dispatch({effects:br.of(h)}),!0):!1}}}),hf()]}const GO=$.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Xn{constructor(e,t){this.specs=e;let i;function s(a){let l=ei.newName();return(i||(i=Object.create(null)))["."+l]=a,l}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof mt?a=>a.prop($i)==o.data:o?a=>a==o:void 0,this.style=Gu(e.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:r}).style,this.module=i?new ei(i):null,this.themeType=t.themeType}static define(e,t){return new Xn(e,t||{})}}const _o=K.define(),_O=K.define({combine(n){return n.length?[n[0]]:null}});function Gr(n){let e=n.facet(_o);return e.length?e:n.facet(_O)}function JO(n,e){let t=[t0],i;return n instanceof Xn&&(n.module&&t.push($.styleModule.of(n.module)),i=n.themeType),i?t.push(_o.computeN([$.darkTheme],s=>s.facet($.darkTheme)==(i=="dark")?[n]:[])):t.push(_o.of(n)),t}class e0{constructor(e){this.markCache=Object.create(null),this.tree=Ce(e.state),this.decorations=this.buildDeco(e,Gr(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ce(e.state),i=Gr(e.state),s=i!=Gr(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return B.none;let i=new Bt;for(let{from:s,to:r}of e.visibleRanges)bO(this.tree,t,(o,a,l)=>{i.add(o,a,this.markCache[l]||(this.markCache[l]=B.mark({class:l})))},s,r);return i.finish()}}const t0=ri.high(xe.fromClass(e0,{decorations:n=>n.decorations})),i0=Xn.define([{tag:O.meta,color:"#404740"},{tag:O.link,textDecoration:"underline"},{tag:O.heading,textDecoration:"underline",fontWeight:"bold"},{tag:O.emphasis,fontStyle:"italic"},{tag:O.strong,fontWeight:"bold"},{tag:O.strikethrough,textDecoration:"line-through"},{tag:O.keyword,color:"#708"},{tag:[O.atom,O.bool,O.url,O.contentSeparator,O.labelName],color:"#219"},{tag:[O.literal,O.inserted],color:"#164"},{tag:[O.string,O.deleted],color:"#a11"},{tag:[O.regexp,O.escape,O.special(O.string)],color:"#e40"},{tag:O.definition(O.variableName),color:"#00f"},{tag:O.local(O.variableName),color:"#30a"},{tag:[O.typeName,O.namespace],color:"#085"},{tag:O.className,color:"#167"},{tag:[O.special(O.variableName),O.macroName],color:"#256"},{tag:O.definition(O.propertyName),color:"#00c"},{tag:O.comment,color:"#940"},{tag:O.invalid,color:"#f00"}]),n0=$.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ff=1e4,df="()[]{}",pf=K.define({combine(n){return yt(n,{afterCursor:!0,brackets:df,maxScanDistance:ff,renderMatch:o0})}}),s0=B.mark({class:"cm-matchingBracket"}),r0=B.mark({class:"cm-nonmatchingBracket"});function o0(n){let e=[],t=n.matched?s0:r0;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function Ac(n){let e=[],t=n.facet(pf);for(let i of n.selection.ranges){if(!i.empty)continue;let s=Rt(n,i.head,-1,t)||i.head>0&&Rt(n,i.head-1,1,t)||t.afterCursor&&(Rt(n,i.head,1,t)||i.headn.decorations}),l0=[a0,n0];function c0(n={}){return[pf.of(n),l0]}const h0=new G;function Jo(n,e,t){let i=n.prop(e<0?G.openedBy:G.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function ea(n){let e=n.type.prop(h0);return e?e(n.node):n}function Rt(n,e,t,i={}){let s=i.maxScanDistance||ff,r=i.brackets||df,o=Ce(n),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=Jo(l.type,t,r);if(c&&l.from0?e>=h.from&&eh.from&&e<=h.to))return u0(n,e,t,l,h,c,r)}}return f0(n,e,t,o,a.type,s,r)}function u0(n,e,t,i,s,r,o){let a=i.parent,l={from:s.from,to:s.to},c=0,h=a?.cursor();if(h&&(t<0?h.childBefore(i.from):h.childAfter(i.to)))do if(t<0?h.to<=i.from:h.from>=i.to){if(c==0&&r.indexOf(h.type.name)>-1&&h.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},h=n.doc.iterRange(e,t>0?n.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=r;){let d=h.value;t<0&&(f+=d.length);let p=e+f*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=s))if(y%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==l>>1};u--}}t>0&&(f+=d.length)}return h.done?{start:c,matched:!1}:null}const d0=Object.create(null),bc=[et.none],Sc=[],xc=Object.create(null),p0=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])p0[n]=m0(d0,e);function _r(n,e){Sc.indexOf(n)>-1||(Sc.push(n),console.warn(e))}function m0(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let h=n[c]||O[c];h?typeof h=="function"?l.length?l=l.map(h):_r(c,`Modifier ${c} used at start of tag`):l.length?_r(c,`Tag ${c} used as modifier`):l=Array.isArray(h)?h:[h]:_r(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+t.map(a=>a.id),r=xc[s];if(r)return r.id;let o=xc[s]=et.define({id:bc.length,name:i,props:[Nu({[i]:t})]});return bc.push(o),o.id}fe.RTL,fe.LTR;const g0=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Fa(n.state,t.from);return i.line?O0(n):i.block?A0(n):!1};function Ua(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const O0=Ua(x0,0),y0=Ua(mf,0),A0=Ua((n,e)=>mf(n,e,S0(e)),0);function Fa(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const ln=50;function b0(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-ln,i),o=n.sliceDoc(s,s+ln),a=/\s*$/.exec(r)[0].length,l=/^\s*/.exec(o)[0].length,c=r.length-a;if(r.slice(c-e.length,c)==e&&o.slice(l,l+t.length)==t)return{open:{pos:i-a,margin:a&&1},close:{pos:s+l,margin:l&&1}};let h,u;s-i<=2*ln?h=u=n.sliceDoc(i,s):(h=n.sliceDoc(i,i+ln),u=n.sliceDoc(s-ln,s));let f=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(u)[0].length,p=u.length-d-t.length;return h.slice(f,f+e.length)==e&&u.slice(p,p+t.length)==t?{open:{pos:i+f+e.length,margin:/\s/.test(h.charAt(f+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function S0(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to);s.from>i.from&&s.from==t.to&&(s=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function mf(n,e,t=e.selection.ranges){let i=t.map(r=>Fa(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>b0(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,a;os&&(r==o||o>u.from)){s=u.from;let f=/^\s*/.exec(u.text)[0].length,d=f==u.length,p=u.text.slice(f,f+c.length)==c?f:-1;fr.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:a,token:l,indent:c,empty:h,single:u}of i)(u||!h)&&r.push({from:a.from+c,insert:l+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:a,token:l}of i)if(a>=0){let c=o.from+a,h=c+l.length;o.text[h-o.from]==" "&&h++,r.push({from:c,to:h})}return{changes:r}}return null}const ta=Wt.define(),ws=Wt.define(),v0=K.define(),gf=K.define({combine(n){return yt(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),Da=Te.define({create(){return $t.empty},update(n,e){let t=e.state.facet(gf),i=e.annotation(ta);if(i){let l=_e.fromTransaction(e,i.selection),c=i.side,h=c==0?n.undone:n.done;return l?h=Vs(h,h.length,t.minDepth,l):h=Af(h,e.startState.selection),new $t(c==0?i.rest:h,c==0?h:i.rest)}let s=e.annotation(ws);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(Pe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=_e.fromTransaction(e),o=e.annotation(Pe.time),a=e.annotation(Pe.userEvent);return r?n=n.addChanges(r,o,a,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,a,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new $t(n.done.map(_e.fromJSON),n.undone.map(_e.fromJSON))}});function w0(n={}){return[Da,gf.of(n),$.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?La:e.inputType=="historyRedo"?zs:null;return i?(e.preventDefault(),i(t)):!1}})]}function Sr(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(Da,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const La=Sr(0,!1),zs=Sr(1,!1),k0=Sr(0,!0),Q0=Sr(1,!0);function Of(n){return function(e){let t=e.field(Da,!1);if(!t)return 0;let i=n==0?t.done:t.undone;return i.length-(i.length&&!i[0].changes?1:0)}}const vc=Of(0),wc=Of(1);class _e{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new _e(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new _e(e.changes&&Re.fromJSON(e.changes),[],e.mapped&&Zt.fromJSON(e.mapped),e.startSelection&&A.fromJSON(e.startSelection),e.selectionsAfter.map(A.fromJSON))}static fromTransaction(e,t){let i=ht;for(let s of e.startState.facet(v0)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new _e(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ht)}static selection(e){return new _e(void 0,ht,void 0,void 0,e)}}function Vs(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function P0(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,a)=>{for(let l=0;l=c&&o<=h&&(i=!0)}}),i}function C0(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function yf(n,e){return n.length?e.length?n.concat(e):n:e}const ht=[],T0=200;function Af(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-T0));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Vs(n,n.length-1,1e9,t.setSelAfter(i)))}else return[_e.selection([e])]}function R0(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Jr(n,e){if(!n.length)return n;let t=n.length,i=ht;for(;t;){let s=$0(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[_e.selection(i)]:ht}function $0(n,e,t){let i=yf(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):ht,t);if(!n.changes)return _e.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new _e(s,z.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const K0=/^(input\.type|delete)($|\.)/;class $t{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new $t(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!i||K0.test(i))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):xr(t,e))}function Be(n){return n.textDirectionAt(n.state.selection.main.head)==fe.LTR}const Sf=n=>bf(n,!Be(n)),xf=n=>bf(n,Be(n));function vf(n,e){return bt(n,t=>t.empty?n.moveByGroup(t,e):xr(t,e))}const M0=n=>vf(n,!Be(n)),E0=n=>vf(n,Be(n));function U0(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function vr(n,e,t){let i=Ce(n).resolveInner(e.head),s=t?G.closedBy:G.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;U0(n,c,s)?i=c:l=t?c.to:c.from}let r=i.type.prop(s),o,a;return r&&(o=t?Rt(n,i.from,1):Rt(n,i.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?i.to:i.from,A.cursor(a,t?-1:1)}const F0=n=>bt(n,e=>vr(n.state,e,!Be(n))),D0=n=>bt(n,e=>vr(n.state,e,Be(n)));function wf(n,e){return bt(n,t=>{if(!t.empty)return xr(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const kf=n=>wf(n,!1),Qf=n=>wf(n,!0);function Pf(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):xr(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;o&&o.top>l&&o.bottomCf(n,!1),ia=n=>Cf(n,!0);function oi(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=A.cursor(i.from+r))}return s}const L0=n=>bt(n,e=>oi(n,e,!0)),X0=n=>bt(n,e=>oi(n,e,!1)),B0=n=>bt(n,e=>oi(n,e,!Be(n))),I0=n=>bt(n,e=>oi(n,e,Be(n))),q0=n=>bt(n,e=>A.cursor(n.lineBlockAt(e.head).from,1)),W0=n=>bt(n,e=>A.cursor(n.lineBlockAt(e.head).to,-1));function z0(n,e,t){let i=!1,s=Ji(n.selection,r=>{let o=Rt(n,r.head,-1)||Rt(n,r.head,1)||r.head>0&&Rt(n,r.head-1,1)||r.headz0(n,e);function ft(n,e,t){let i=Ji(n.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=A.range(s.head,s.anchor));let r=t(s);return A.range(s.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(At(n.state,i)),!0)}function Tf(n,e){return ft(n,e,t=>n.moveByChar(t,e))}const Rf=n=>Tf(n,!Be(n)),$f=n=>Tf(n,Be(n));function Kf(n,e){return ft(n,e,t=>n.moveByGroup(t,e))}const j0=n=>Kf(n,!Be(n)),Y0=n=>Kf(n,Be(n)),N0=n=>{let e=!Be(n);return ft(n,e,t=>vr(n.state,t,e))},H0=n=>{let e=Be(n);return ft(n,e,t=>vr(n.state,t,e))};function Zf(n,e){return ft(n,e,t=>n.moveVertically(t,e))}const Mf=n=>Zf(n,!1),Ef=n=>Zf(n,!0);function Uf(n,e){return ft(n,e,t=>n.moveVertically(t,e,Pf(n).height))}const Qc=n=>Uf(n,!1),Pc=n=>Uf(n,!0),G0=n=>ft(n,!0,e=>oi(n,e,!0)),_0=n=>ft(n,!1,e=>oi(n,e,!1)),J0=n=>{let e=!Be(n);return ft(n,e,t=>oi(n,t,e))},ey=n=>{let e=Be(n);return ft(n,e,t=>oi(n,t,e))},ty=n=>ft(n,!1,e=>A.cursor(n.lineBlockAt(e.head).from)),iy=n=>ft(n,!0,e=>A.cursor(n.lineBlockAt(e.head).to)),Cc=({state:n,dispatch:e})=>(e(At(n,{anchor:0})),!0),Tc=({state:n,dispatch:e})=>(e(At(n,{anchor:n.doc.length})),!0),Rc=({state:n,dispatch:e})=>(e(At(n,{anchor:n.selection.main.anchor,head:0})),!0),$c=({state:n,dispatch:e})=>(e(At(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),ny=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),sy=({state:n,dispatch:e})=>{let t=wr(n).map(({from:i,to:s})=>A.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:A.create(t),userEvent:"select"})),!0},ry=({state:n,dispatch:e})=>{let t=Ji(n.selection,i=>{let s=Ce(n),r=s.resolveStack(i.from,1);if(i.empty){let o=s.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:a}=o;if((a.from=i.to||a.to>i.to&&a.from<=i.from)&&o.next)return A.range(a.to,a.from)}return i});return t.eq(n.selection)?!1:(e(At(n,t)),!0)};function Ff(n,e){let{state:t}=n,i=t.selection,s=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to0)for(let a=r;;){let l=n.moveVertically(a,e);if(l.heado.to){s.some(c=>c.head==l.head)||s.push(l);break}else{if(l.head==a.head)break;a=l}}}return s.length==i.ranges.length?!1:(n.dispatch(At(t,A.create(s,s.length-1))),!0)}const oy=n=>Ff(n,!1),ay=n=>Ff(n,!0),ly=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=A.create([t.main]):t.main.empty||(i=A.create([A.cursor(t.main.head)])),i?(e(At(n,i)),!0):!1};function Bn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:a}=r;if(o==a){let l=e(r);lo&&(t="delete.forward",l=hs(n,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=hs(n,o,!1),a=hs(n,a,!0);return o==a?{range:r}:{changes:{from:o,to:a},range:A.cursor(o,os(n)))i.between(e,e,(s,r)=>{se&&(e=t?r:s)});return e}const Df=(n,e,t)=>Bn(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),a,l;if(t&&!e&&s>o.from&&sDf(n,!1,!0),Lf=n=>Df(n,!0,!1),Xf=(n,e)=>Bn(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let a=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let l=Ze(r.text,i-r.from,e)+r.from,c=r.text.slice(Math.min(i,l)-r.from,Math.max(i,l)-r.from),h=o(c);if(a!=null&&h!=a)break;(c!=" "||i!=t.head)&&(a=h),i=l}return i}),Bf=n=>Xf(n,!1),cy=n=>Xf(n,!0),hy=n=>Bn(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headBn(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),fy=n=>Bn(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:se.of(["",""])},range:A.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},py=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:Ze(r.text,s-r.from,!1)+r.from,a=s==r.to?s+1:Ze(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:a,insert:n.doc.slice(s,a).append(n.doc.slice(o,s))},range:A.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function wr(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function If(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of wr(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),a=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let l of r.ranges)s.push(A.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let l of r.ranges)s.push(A.range(l.anchor-a,l.head-a))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:A.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const my=({state:n,dispatch:e})=>If(n,e,!1),gy=({state:n,dispatch:e})=>If(n,e,!0);function qf(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of wr(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});let s=n.changes(i);return e(n.update({changes:s,selection:n.selection.map(s,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Oy=({state:n,dispatch:e})=>qf(n,e,!1),yy=({state:n,dispatch:e})=>qf(n,e,!0),Ay=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(wr(e).map(({from:s,to:r})=>(s>0?s--:r{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),a=n.coordsAtPos(s.head,s.assoc||1);a&&(r=o.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function by(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Ce(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(G.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const Kc=Wf(!1),Sy=Wf(!0);function Wf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,a=e.doc.lineAt(r),l=!n&&r==o&&by(e,r);n&&(r=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new Ar(e,{simulateBreak:r,simulateDoubleBreak:!!l}),h=Ma(c,r);for(h==null&&(h=_i(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));oa.from&&r{let s=[];for(let o=i.from;o<=i.to;){let a=n.doc.lineAt(o);a.number>t&&(i.empty||i.to>a.from)&&(e(a,s,i),t=a.number),o=a.to+1}let r=n.changes(s);return{changes:s,range:A.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const xy=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Ar(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Xa(n,(r,o,a)=>{let l=Ma(i,r.from);if(l==null)return;/\S/.test(r.text)||(l=0);let c=/^\s*/.exec(r.text)[0],h=Tn(n,l);(c!=h||a.fromn.readOnly?!1:(e(n.update(Xa(n,(t,i)=>{i.push({from:t.from,insert:n.facet(yr)})}),{userEvent:"input.indent"})),!0),Vf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Xa(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=_i(s,n.tabSize),o=0,a=Tn(n,Math.max(0,r-Is(n)));for(;o(n.setTabFocusMode(),!0),wy=[{key:"Ctrl-b",run:Sf,shift:Rf,preventDefault:!0},{key:"Ctrl-f",run:xf,shift:$f},{key:"Ctrl-p",run:kf,shift:Mf},{key:"Ctrl-n",run:Qf,shift:Ef},{key:"Ctrl-a",run:q0,shift:ty},{key:"Ctrl-e",run:W0,shift:iy},{key:"Ctrl-d",run:Lf},{key:"Ctrl-h",run:na},{key:"Ctrl-k",run:hy},{key:"Ctrl-Alt-h",run:Bf},{key:"Ctrl-o",run:dy},{key:"Ctrl-t",run:py},{key:"Ctrl-v",run:ia}],ky=[{key:"ArrowLeft",run:Sf,shift:Rf,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:M0,shift:j0,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:B0,shift:J0,preventDefault:!0},{key:"ArrowRight",run:xf,shift:$f,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:E0,shift:Y0,preventDefault:!0},{mac:"Cmd-ArrowRight",run:I0,shift:ey,preventDefault:!0},{key:"ArrowUp",run:kf,shift:Mf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Cc,shift:Rc},{mac:"Ctrl-ArrowUp",run:kc,shift:Qc},{key:"ArrowDown",run:Qf,shift:Ef,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Tc,shift:$c},{mac:"Ctrl-ArrowDown",run:ia,shift:Pc},{key:"PageUp",run:kc,shift:Qc},{key:"PageDown",run:ia,shift:Pc},{key:"Home",run:X0,shift:_0,preventDefault:!0},{key:"Mod-Home",run:Cc,shift:Rc},{key:"End",run:L0,shift:G0,preventDefault:!0},{key:"Mod-End",run:Tc,shift:$c},{key:"Enter",run:Kc,shift:Kc},{key:"Mod-a",run:ny},{key:"Backspace",run:na,shift:na,preventDefault:!0},{key:"Delete",run:Lf,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Bf,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:cy,preventDefault:!0},{mac:"Mod-Backspace",run:uy,preventDefault:!0},{mac:"Mod-Delete",run:fy,preventDefault:!0}].concat(wy.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Qy=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:F0,shift:N0},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:D0,shift:H0},{key:"Alt-ArrowUp",run:my},{key:"Shift-Alt-ArrowUp",run:Oy},{key:"Alt-ArrowDown",run:gy},{key:"Shift-Alt-ArrowDown",run:yy},{key:"Mod-Alt-ArrowUp",run:oy},{key:"Mod-Alt-ArrowDown",run:ay},{key:"Escape",run:ly},{key:"Mod-Enter",run:Sy},{key:"Alt-l",mac:"Ctrl-l",run:sy},{key:"Mod-i",run:ry,preventDefault:!0},{key:"Mod-[",run:Vf},{key:"Mod-]",run:zf},{key:"Mod-Alt-\\",run:xy},{key:"Shift-Mod-k",run:Ay},{key:"Shift-Mod-\\",run:V0},{key:"Mod-/",run:g0},{key:"Alt-A",run:y0},{key:"Ctrl-m",mac:"Shift-Alt-m",run:vy}].concat(ky),Py={key:"Tab",run:zf,shift:Vf};class jf{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Ce(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(Nf(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Zc(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Cy(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;rtypeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:Cy(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Ty(n,e){return t=>{for(let i=Ce(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}let Mc=class{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}};function yi(n){return n.selection.main.from}function Nf(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Ba=Wt.define();function Ry(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return{...n.changeByRange(a=>{if(a!=s&&t!=i&&n.sliceDoc(a.from+r,a.from+o)!=n.sliceDoc(t,i))return{range:a};let l=n.toText(e);return{changes:{from:a.from+r,to:i==s.from?a.to:a.from+o,insert:l},range:A.cursor(a.from+r+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Ec=new WeakMap;function $y(n){if(!Array.isArray(n))return n;let e=Ec.get(n);return e||Ec.set(n,e=Yf(n)),e}const js=z.define(),Rn=z.define();class Ky{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(S=fa(k))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||w==1&&g||C==0&&w!=0)&&(t[u]==k||i[u]==k&&(f=!0)?o[u++]=b:o.length&&(y=!1)),C=w,b+=Qt(k)}return u==l&&o[0]==0&&y?this.result(-100+(f?-200:0),o,e):d==l&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):d==l?this.ret(-900-e.length,[p,m]):u==l?this.result(-100+(f?-200:0)+-700+(y?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let a=o+(this.astral?Qt(Ne(i,o)):1);r&&s[r-1]==o?s[r-1]=a:(s[r++]=o,s[r++]=a)}return this.ret(e-i.length,s)}}class Zy{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:My,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Uc(e(i),t(i)),optionClass:(e,t)=>i=>Uc(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Uc(n,e){return n?e?n+" "+e:n:e}function My(n,e,t,i,s,r){let o=n.textDirection==fe.RTL,a=o,l=!1,c="top",h,u,f=e.left-s.left,d=s.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(a&&f=m||b>e.top?h=t.bottom-e.top:(c="bottom",h=e.bottom-t.top)}let g=(e.bottom-e.top)/r.offsetHeight,y=(e.right-e.left)/r.offsetWidth;return{style:`${c}: ${h/g}px; max-width: ${u/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}const Ia=z.define();function Ey(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;cl&&o.appendChild(document.createTextNode(a.slice(l,h)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(a.slice(h,u))),f.className="cm-completionMatchedText",l=u}return lt.position-i.position).map(t=>t.render)}function eo(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class Uy{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,a=e.state.facet(Ke);this.optionContent=Ey(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=eo(r.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let h=l.target,u;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(u=/-(\d+)$/.exec(h.id))&&+u[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;h!=null&&(e.dispatch({effects:Ia.of(h)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Ke).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Rn.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:a}=i.open;(!s.open||s.open.options!=r)&&(this.range=eo(r.length,o,e.state.facet(Ke).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),a!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=eo(t.options.length,t.selected,this.view.state.facet(Ke).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,s)}).catch(a=>ze(this.view.state,a,"completion info")):(this.addInfoPane(o,s),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&Dy(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;oi.from||i.from==0))if(r=f,typeof c!="string"&&c.header)s.appendChild(c.header(c));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=f}}const h=s.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");let u=this.optionClass(a);u&&(h.className=u);for(let f of this.optionContent){let d=f(a,this.view.state,this.view,l);d&&h.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.tonew Uy(t,n,e)}function Dy(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function Fc(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Ly(n,e){let t=[],i=null,s=null,r=h=>{t.push(h);let{section:u}=h.completion;if(u){i||(i=[]);let f=typeof u=="string"?u:u.name;i.some(d=>d.name==f)||i.push(typeof u=="string"?{name:f}:u)}},o=e.facet(Ke);for(let h of n)if(h.hasResult()){let u=h.result.getMatch;if(h.result.filter===!1)for(let f of h.result.options)r(new Mc(f,h.source,u?u(f):[],1e9-t.length));else{let f=e.sliceDoc(h.from,h.to),d,p=o.filterStrict?new Zy(f):new Ky(f);for(let m of h.result.options)if(d=p.match(m.label)){let g=m.displayLabel?u?u(m,d.matched):[]:d.matched,y=d.score+(m.boost||0);if(r(new Mc(m,h.source,g,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:b}=m.section;s||(s=Object.create(null)),s[b]=Math.max(y,s[b]||-1e9)}}}}if(i){let h=Object.create(null),u=0,f=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?s[p.name]-s[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.namef.score-u.score||c(u.completion,f.completion))){let u=h.completion;!l||l.label!=u.label||l.detail!=u.detail||l.type!=null&&u.type!=null&&l.type!=u.type||l.apply!=u.apply||l.boost!=u.boost?a.push(h):Fc(h.completion)>Fc(l)&&(a[a.length-1]=h),l=h.completion}return a}class Ki{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ki(this.options,Dc(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r,o){if(s&&!o&&e.some(c=>c.isPending))return s.setDisabled();let a=Ly(e,t);if(!a.length)return s&&e.some(c=>c.isPending)?s.setDisabled():null;let l=t.facet(Ke).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let c=s.options[s.selected].completion;for(let h=0;hh.hasResult()?Math.min(c,h.from):c,1e8),create:zy,above:r.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new Ki(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ki(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Ys{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Ys(qy,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Ke),r=(i.override||t.languageDataAt("autocomplete",yi(t)).map($y)).map(l=>(this.active.find(h=>h.source==l)||new ut(l,this.active.some(h=>h.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((l,c)=>l==this.active[c])&&(r=this.active);let o=this.open,a=e.effects.some(l=>l.is(qa));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!Xy(r,this.active)||a?o=Ki.build(r,t,this.id,o,i,a):o&&o.disabled&&!r.some(l=>l.isPending)&&(o=null),!o&&r.every(l=>!l.isPending)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new ut(l.source,0):l));for(let l of e.effects)l.is(Ia)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new Ys(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?By:Iy}}function Xy(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const qy=[];function Hf(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Ba);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class ut{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=Hf(e,t),s=this;(i&8||i&16&&this.touches(e))&&(s=new ut(s.source,0)),i&4&&s.state==0&&(s=new ut(this.source,1)),s=s.updateFor(e,i);for(let r of e.effects)if(r.is(js))s=new ut(s.source,1,r.value);else if(r.is(Rn))s=new ut(s.source,0);else if(r.is(qa))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(yi(e.state))}}class Fi extends ut{constructor(e,t,i,s,r,o){super(e,3,t),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=yi(e.state);if(a>o||!s||t&2&&(yi(e.startState)==this.from||at.map(e))}}),He=Te.define({create(){return Ys.start()},update(n,e){return n.update(e)},provide:n=>[gr.from(n,e=>e.tooltip),$.contentAttributes.from(n,e=>e.attrs)]});function Wa(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(He).active.find(s=>s.source==e.source);return i instanceof Fi?(typeof t=="string"?n.dispatch({...Ry(n.state,t,i.from,i.to),annotations:Ba.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const zy=Fy(He,Wa);function us(n,e="option"){return t=>{let i=t.state.field(He,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+s*(n?1:-1):n?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:Ia.of(a)}),!0}}const Vy=n=>{let e=n.state.field(He,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(He,!1)?(n.dispatch({effects:js.of(!0)}),!0):!1,jy=n=>{let e=n.state.field(He,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Rn.of(null)}),!0)};class Yy{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ny=50,Hy=1e3,Gy=xe.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(He).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(He),t=n.state.facet(Ke);if(!n.selectionSet&&!n.docChanged&&n.startState.field(He)==e)return;let i=n.transactions.some(r=>{let o=Hf(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;rNy&&Date.now()-o.time>Hy){for(let a of o.context.abortListeners)try{a()}catch(l){ze(this.view.state,l)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(js)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(He);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ke).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=yi(e),i=new jf(e,t,n.explicit,this.view),s=new Yy(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Rn.of(null)}),ze(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ke).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Ke),i=this.view.state.field(He);for(let s=0;sa.source==r.active.source);if(o&&o.isPending)if(r.done==null){let a=new ut(r.active.source,0);for(let l of r.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:qa.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(He,!1);if(e&&e.tooltip&&this.view.state.facet(Ke).closeOnBlur){let t=e.open&&Uu(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Rn.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:js.of(!1)}),20),this.composing=0}}}),_y=typeof navigator=="object"&&/Win/.test(navigator.platform),Jy=ri.highest($.domEventHandlers({keydown(n,e){let t=e.state.field(He,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(_y&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&Wa(e,i),!1}})),Gf=$.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class eA{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class za{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,De.TrackDel),i=e.mapPos(this.to,1,De.TrackDel);return t==null||i==null?null:new za(this.field,t,i)}}class Va{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let l of this.lines){if(i.length){let c=o,h=/^\t*/.exec(l)[0].length;for(let u=0;unew za(l.field,s[l.line]+l.from,s[l.line]+l.to));return{text:i,ranges:a}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let a=r[1]?+r[1]:null,l=r[2]||r[3]||"",c=-1;a===0&&(a=1e9);let h=l.replace(/\\[{}]/g,u=>u[1]);for(let u=0;u=c&&f.field++}for(let u of s)if(u.line==i.length&&u.from>r.index){let f=r[2]?3+(r[1]||"").length:2;u.from-=f,u.to-=f}s.push(new eA(c,i.length,r.index,r.index+h.length)),o=o.slice(0,r.index)+l+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(a,l,c)=>{for(let h of s)h.line==i.length&&h.from>c&&(h.from--,h.to--);return l}),i.push(o)}return new Va(i,s)}}let tA=B.widget({widget:new class extends Ut{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),iA=B.mark({class:"cm-snippetField"});class en{constructor(e,t){this.ranges=e,this.active=t,this.deco=B.set(e.map(i=>(i.from==i.to?tA:iA).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new en(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const In=z.define({map(n,e){return n&&n.map(e)}}),nA=z.define(),$n=Te.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(In))return t.value;if(t.is(nA)&&n)return new en(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>$.decorations.from(n,e=>e?e.deco:B.none)});function ja(n,e){return A.create(n.filter(t=>t.field==e).map(t=>A.range(t.from,t.to)))}function sA(n){let e=Va.parse(n);return(t,i,s,r)=>{let{text:o,ranges:a}=e.instantiate(t.state,s),{main:l}=t.state.selection,c={changes:{from:s,to:r==l.from?l.to:r,insert:se.of(o)},scrollIntoView:!0,annotations:i?[Ba.of(i),Pe.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=ja(a,0)),a.some(h=>h.field>0)){let h=new en(a,0),u=c.effects=[In.of(h)];t.state.field($n,!1)===void 0&&u.push(z.appendConfig.of([$n,cA,hA,Gf]))}t.dispatch(t.state.update(c))}}function _f(n){return({state:e,dispatch:t})=>{let i=e.field($n,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:ja(i.ranges,s),effects:In.of(r?null:new en(i.ranges,s)),scrollIntoView:!0})),!0}}const rA=({state:n,dispatch:e})=>n.field($n,!1)?(e(n.update({effects:In.of(null)})),!0):!1,oA=_f(1),aA=_f(-1),lA=[{key:"Tab",run:oA,shift:aA},{key:"Escape",run:rA}],Lc=K.define({combine(n){return n.length?n[0]:lA}}),cA=ri.highest(mr.compute([Lc],n=>n.facet(Lc)));function Ye(n,e){return{...e,apply:sA(n)}}const hA=$.domEventHandlers({mousedown(n,e){let t=e.state.field($n,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:ja(t.ranges,s.field),effects:In.of(t.ranges.some(r=>r.field>s.field)?new en(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),Kn={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},mi=z.define({map(n,e){let t=e.mapPos(n,-1,De.TrackAfter);return t??void 0}}),Ya=new class extends Jt{};Ya.startSide=1;Ya.endSide=-1;const Jf=Te.define({create(){return N.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(mi)&&(n=n.update({add:[Ya.range(t.value,t.value+1)]}));return n}});function uA(){return[dA,Jf]}const io="()[]{}<>«»»«[]{}";function ed(n){for(let e=0;e{if((fA?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&Qt(Ne(i,0))==1||e!=s.from||t!=s.to)return!1;let r=gA(n.state,i);return r?(n.dispatch(r),!0):!1}),pA=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=td(n,n.selection.main.head).brackets||Kn.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let a=OA(n.doc,o.head);for(let l of i)if(l==a&&kr(n.doc,o.head)==ed(Ne(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:A.cursor(o.head-l.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},mA=[{key:"Backspace",run:pA}];function gA(n,e){let t=td(n,n.selection.main.head),i=t.brackets||Kn.brackets;for(let s of i){let r=ed(Ne(s,0));if(e==s)return r==s?bA(n,s,i.indexOf(s+s+s)>-1,t):yA(n,s,r,t.before||Kn.before);if(e==r&&id(n,n.selection.main.from))return AA(n,s,r)}return null}function id(n,e){let t=!1;return n.field(Jf).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function kr(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Qt(Ne(t,0)))}function OA(n,e){let t=n.sliceString(e-2,e);return Qt(Ne(t,0))==t.length?t:t.slice(1)}function yA(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:mi.of(o.to+e.length),range:A.range(o.anchor+e.length,o.head+e.length)};let a=kr(n.doc,o.head);return!a||/\s/.test(a)||i.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:mi.of(o.head+e.length),range:A.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function AA(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&kr(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:A.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function bA(n,e,t,i){let s=i.stringPrefixes||Kn.stringPrefixes,r=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:mi.of(a.to+e.length),range:A.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=kr(n.doc,l),h;if(c==e){if(Xc(n,l))return{changes:{insert:e+e,from:l},effects:mi.of(l+e.length),range:A.cursor(l+e.length)};if(id(n,l)){let f=t&&n.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+f.length,insert:f},range:A.cursor(l+f.length)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(h=Bc(n,l-2*e.length,s))>-1&&Xc(n,h))return{changes:{insert:e+e+e+e,from:l},effects:mi.of(l+e.length),range:A.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=ye.Word&&Bc(n,l,s)>-1&&!SA(n,l,e,s))return{changes:{insert:e+e,from:l},effects:mi.of(l+e.length),range:A.cursor(l+e.length)}}return{range:r=a}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Xc(n,e){let t=Ce(n).resolveInner(e+1);return t.parent&&t.from==e}function SA(n,e,t,i){let s=Ce(n).resolveInner(e,-1),r=i.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),l=a.indexOf(t);if(!l||l>-1&&i.indexOf(a.slice(0,l))>-1){let h=s.firstChild;for(;h&&h.from==s.from&&h.to-h.from>t.length+l;){if(n.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let c=s.to==e&&s.parent;if(!c)break;s=c}return!1}function Bc(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ye.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=ye.Word)return r}return-1}function xA(n={}){return[Jy,He,Ke.of(n),Gy,vA,Gf]}const nd=[{key:"Ctrl-Space",run:to},{mac:"Alt-`",run:to},{mac:"Alt-i",run:to},{key:"Escape",run:jy},{key:"ArrowDown",run:us(!0)},{key:"ArrowUp",run:us(!1)},{key:"PageDown",run:us(!0,"page")},{key:"PageUp",run:us(!1,"page")},{key:"Enter",run:Vy}],vA=ri.highest(mr.computeN([Ke],n=>n.facet(Ke).defaultKeymap?[nd]:[]));var Ic={};class Ns{constructor(e,t,i,s,r,o,a,l,c,h=0,u){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=h,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let s=e.parser.context;return new Ns(e,[],t,i,i,0,[],0,s?new qc(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,s=e&65535,{parser:r}=this.p,o=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizel;)this.stack.pop();this.reduceContext(s,c)}storeNode(e,t,i,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(e,t,i,s){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;this.pos=s;let a=o.stateFlag(r,1);!a&&(s>i||t<=o.maxNode)&&(this.reducePos=s),this.pushState(r,a?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,s,4)}else this.pos=s,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,s,4)}apply(e,t,i,s){e&65536?this.reduce(e):this.shift(e,t,i,s)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new Ns(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new wA(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let s=[];for(let r=0,o;rl&1&&a==o)||s.push(t[r],o)}t=s}let i=[];for(let s=0;s>19,s=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-r;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=i(o,r+1);if(a!=null)return a}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}}class qc{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class wA{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class Hs{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Hs(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Hs(this.stack,this.pos,this.index)}}function dn(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,s=0;i=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),r+=l,a)break;r*=46}t?t[s++]=r:t=new e(r)}return t}class ks{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Wc=new ks;class kA{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Wc,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,s=this.rangeIndex,r=this.pos+e;for(;ri.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,s;if(t>=0&&t=this.chunk2Pos&&ia.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Wc,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class Di{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;sd(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}Di.prototype.contextual=Di.prototype.fallback=Di.prototype.extend=!1;class sa{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?dn(e):e}token(e,t){let i=e.pos,s=0;for(;;){let r=e.next<0,o=e.resolveOffset(1,1);if(sd(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(r||s++,o==null)break;e.reset(o,e.token)}s&&(e.reset(i,e.token),e.acceptToken(this.elseToken,s))}}sa.prototype.contextual=Di.prototype.fallback=Di.prototype.extend=!1;class qn{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function sd(n,e,t,i,s,r){let o=0,a=1<0){let p=n[d];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||QA(p,e.token.value,s,r))){e.acceptToken(p);break}}let h=e.next,u=0,f=n[o+2];if(e.next<0&&f>u&&n[c+f*3-3]==65535){o=n[c+f*3-1];continue e}for(;u>1,p=c+d+(d<<1),m=n[p],g=n[p+1]||65536;if(h=g)u=d+1;else{o=n[p+2],e.advance();continue e}}break}}function zc(n,e,t){for(let i=e,s;(s=n[i])!=65535;i++)if(s==t)return i-e;return-1}function QA(n,e,t,i){let s=zc(t,i,e);return s<0||zc(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class PA{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Vc(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Vc(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(r instanceof ke){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class CA{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new ks)}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;cu.end+25&&(l=Math.max(u.lookAhead,l)),u.value!=0)){let f=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!h.extend&&(i=u,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!i&&e.pos==this.stream.end&&(i=new ks,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new ks,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){let s=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(s,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,i,s){for(let r=0;re.bufferLength*4?new PA(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],s,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)i.push(a);else{if(this.advanceStack(a,i,e))continue;{s||(s=[],r=[]),s.push(a);let l=this.tokens.getMainToken(a);r.push(l.value,l.end)}}break}}if(!i.length){let o=s&&KA(s);if(o)return nt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw nt&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return nt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((a,l)=>l.score-a.score);i.length>o;)i.pop();i.some(a=>a.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)i.splice(l--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,a)=>a.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,h=c?e.curContext.hash:0;for(let u=this.fragments.nodeAt(s);u;){let f=this.parser.nodeSet.types[u.type.id]==u.type?r.getGoto(e.state,u.type.id):-1;if(f>-1&&u.length&&(!c||(u.prop(G.contextHash)||0)==h))return e.useNode(u,f),nt&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(u.type.id)})`),!0;if(!(u instanceof ke)||u.children.length==0||u.positions[0]>0)break;let d=u.children[0];if(d instanceof ke&&u.positions[0]==0)u=d;else break}}let a=r.stateSlot(e.state,4);if(a>0)return e.reduce(a),nt&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;cs?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return jc(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let o=0;o ":"";if(a.deadEnd&&(r||(r=!0,a.restart(),nt&&console.log(h+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let u=a.split(),f=h;for(let d=0;d<10&&u.forceReduce()&&(nt&&console.log(f+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));d++)nt&&(f=this.stackID(u)+" -> ");for(let d of a.recoverByInsert(l))nt&&console.log(h+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),nt&&console.log(h+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),jc(a,i)):(!s||s.scoren;class $A{constructor(e){this.start=e.start,this.shift=e.shift||so,this.reduce=e.reduce||so,this.reuse=e.reuse||so,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Gs extends Yu{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;ae.topRules[a][1]),s=[];for(let a=0;a=0)r(h,l,a[c++]);else{let u=a[c+-h];for(let f=-h;f>0;f--)r(a[c++],l,u);c++}}}this.nodeSet=new Ta(t.map((a,l)=>et.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:s[l],top:i.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Wu;let o=dn(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;atypeof a=="number"?new Di(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let s=new TA(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],a=o&1,l=s[r++];if(a&&i)return l;for(let c=r+(o>>1);r0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),s=i?t(i):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Ft(this.data,r+2);else break;s=t(Ft(this.data,r+1))}return s}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Ft(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[i],s)}}return t}configure(e){let t=Object.assign(Object.create(Gs.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let s=e.tokenizers.find(r=>r.from==i);return s?s.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=e.specializers.find(a=>a.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[s]=Yc(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;ri)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const ZA=316,MA=317,Nc=1,EA=2,UA=3,FA=4,DA=318,LA=320,XA=321,BA=5,IA=6,qA=0,ra=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],rd=125,WA=59,oa=47,zA=42,VA=43,jA=45,YA=60,NA=44,HA=63,GA=46,_A=91,JA=new $A({start:!1,shift(n,e){return e==BA||e==IA||e==LA?n:e==XA},strict:!1}),eb=new qn((n,e)=>{let{next:t}=n;(t==rd||t==-1||e.context)&&n.acceptToken(DA)},{contextual:!0,fallback:!0}),tb=new qn((n,e)=>{let{next:t}=n,i;ra.indexOf(t)>-1||t==oa&&((i=n.peek(1))==oa||i==zA)||t!=rd&&t!=WA&&t!=-1&&!e.context&&n.acceptToken(ZA)},{contextual:!0}),ib=new qn((n,e)=>{n.next==_A&&!e.context&&n.acceptToken(MA)},{contextual:!0}),nb=new qn((n,e)=>{let{next:t}=n;if(t==VA||t==jA){if(n.advance(),t==n.next){n.advance();let i=!e.context&&e.canShift(Nc);n.acceptToken(i?Nc:EA)}}else t==HA&&n.peek(1)==GA&&(n.advance(),n.advance(),(n.next<48||n.next>57)&&n.acceptToken(UA))},{contextual:!0});function ro(n,e){return n>=65&&n<=90||n>=97&&n<=122||n==95||n>=192||!e&&n>=48&&n<=57}const sb=new qn((n,e)=>{if(n.next!=YA||!e.dialectEnabled(qA)||(n.advance(),n.next==oa))return;let t=0;for(;ra.indexOf(n.next)>-1;)n.advance(),t++;if(ro(n.next,!0)){for(n.advance(),t++;ro(n.next,!1);)n.advance(),t++;for(;ra.indexOf(n.next)>-1;)n.advance(),t++;if(n.next==NA)return;for(let i=0;;i++){if(i==7){if(!ro(n.next,!0))return;break}if(n.next!="extends".charCodeAt(i))break;n.advance(),t++}}n.acceptToken(FA,-t)}),rb=Nu({"get set async static":O.modifier,"for while do if else switch try catch finally return throw break continue default case defer":O.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":O.operatorKeyword,"let var const using function class extends":O.definitionKeyword,"import export from":O.moduleKeyword,"with debugger new":O.keyword,TemplateString:O.special(O.string),super:O.atom,BooleanLiteral:O.bool,this:O.self,null:O.null,Star:O.modifier,VariableName:O.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":O.function(O.variableName),VariableDefinition:O.definition(O.variableName),Label:O.labelName,PropertyName:O.propertyName,PrivatePropertyName:O.special(O.propertyName),"CallExpression/MemberExpression/PropertyName":O.function(O.propertyName),"FunctionDeclaration/VariableDefinition":O.function(O.definition(O.variableName)),"ClassDeclaration/VariableDefinition":O.definition(O.className),"NewExpression/VariableName":O.className,PropertyDefinition:O.definition(O.propertyName),PrivatePropertyDefinition:O.definition(O.special(O.propertyName)),UpdateOp:O.updateOperator,"LineComment Hashbang":O.lineComment,BlockComment:O.blockComment,Number:O.number,String:O.string,Escape:O.escape,ArithOp:O.arithmeticOperator,LogicOp:O.logicOperator,BitOp:O.bitwiseOperator,CompareOp:O.compareOperator,RegExp:O.regexp,Equals:O.definitionOperator,Arrow:O.function(O.punctuation),": Spread":O.punctuation,"( )":O.paren,"[ ]":O.squareBracket,"{ }":O.brace,"InterpolationStart InterpolationEnd":O.special(O.brace),".":O.derefOperator,", ;":O.separator,"@":O.meta,TypeName:O.typeName,TypeDefinition:O.definition(O.typeName),"type enum interface implements namespace module declare":O.definitionKeyword,"abstract global Privacy readonly override":O.modifier,"is keyof unique infer asserts":O.operatorKeyword,JSXAttributeValue:O.attributeValue,JSXText:O.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":O.angleBracket,"JSXIdentifier JSXNameSpacedName":O.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":O.attributeName,"JSXBuiltin/JSXIdentifier":O.standard(O.tagName)}),ob={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},ab={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},lb={__proto__:null,"<":193},cb=Gs.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ES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ypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:JA,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[rb],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%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340),new sa("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:n=>ob[n]||-1},{term:343,get:n=>ab[n]||-1},{term:95,get:n=>lb[n]||-1}],tokenPrec:15201}),od=[Ye("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Ye("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Ye("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Ye("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Ye("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Ye(`try { + \${} +} catch (\${error}) { + \${} +}`,{label:"try",detail:"/ catch block",type:"keyword"}),Ye("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Ye(`if (\${}) { + \${} +} else { + \${} +}`,{label:"if",detail:"/ else block",type:"keyword"}),Ye(`class \${name} { + constructor(\${params}) { + \${} + } +}`,{label:"class",detail:"definition",type:"keyword"}),Ye('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Ye('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],hb=od.concat([Ye("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Ye("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Ye("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Hc=new dO,ad=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function cn(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const ub=["FunctionDeclaration"],fb={FunctionDeclaration:cn("function"),ClassDeclaration:cn("class"),ClassExpression:()=>!0,EnumDeclaration:cn("constant"),TypeAliasDeclaration:cn("type"),NamespaceDeclaration:cn("namespace"),VariableDefinition(n,e){n.matchContext(ub)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function ld(n,e){let t=Hc.get(e);if(t)return t;let i=[],s=!0;function r(o,a){let l=n.sliceString(o.from,o.to);i.push({label:l,type:a})}return e.cursor(be.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let a=fb[o.name];if(a&&a(o,r)||ad.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of ld(n,o.node))i.push(a);return!1}}),Hc.set(e,i),i}const Gc=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,cd=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function db(n){let e=Ce(n.state).resolveInner(n.pos,-1);if(cd.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Gc.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)ad.has(s.name)&&(i=i.concat(ld(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:Gc}}const Xt=Xs.define({name:"javascript",parser:cb.configure({props:[ef.add({IfStatement:Nr({except:/^\s*({|else\b)/}),TryStatement:Nr({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:MO,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:ZO({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Nr({except:/^\s*{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),sf.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":DO,BlockComment(n){return{from:n.from+2,to:n.to-2}},JSXElement(n){let e=n.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let t=n.lastChild;return{from:e.to,to:t.type.isError?n.to:t.from}},"JSXSelfClosingTag JSXOpenTag"(n){var e;let t=(e=n.firstChild)===null||e===void 0?void 0:e.nextSibling,i=n.lastChild;return!t||t.type.isError?null:{from:t.to,to:i.type.isError?n.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),hd={test:n=>/^JSX/.test(n.name),facet:_u({commentTokens:{block:{open:"{/*",close:"*/}"}}})},pb=Xt.configure({dialect:"ts"},"typescript"),mb=Xt.configure({dialect:"jsx",props:[Za.add(n=>n.isTop?[hd]:void 0)]}),gb=Xt.configure({dialect:"jsx ts",props:[Za.add(n=>n.isTop?[hd]:void 0)]},"typescript");let ud=n=>({label:n,type:"keyword"});const fd="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(ud),Ob=fd.concat(["declare","implements","private","protected","public"].map(ud));function yb(n={}){let e=n.jsx?n.typescript?gb:mb:n.typescript?pb:Xt,t=n.typescript?hb.concat(Ob):od.concat(fd);return new kO(e,[Xt.data.of({autocomplete:Ty(cd,Yf(t))}),Xt.data.of({autocomplete:db}),n.jsx?Sb:[]])}function Ab(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function _c(n,e,t=n.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const bb=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Sb=$.inputHandler.of((n,e,t,i,s)=>{if((bb?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!Xt.isActiveAt(n.state,e,-1))return!1;let r=s(),{state:o}=r,a=o.changeByRange(l=>{var c;let{head:h}=l,u=Ce(o).resolveInner(h-1,-1),f;if(u.name=="JSXStartTag"&&(u=u.parent),!(o.doc.sliceString(h-1,h)!=i||u.name=="JSXAttributeValue"&&u.to>h)){if(i==">"&&u.name=="JSXFragmentTag")return{range:l,changes:{from:h,insert:""}};if(i=="/"&&u.name=="JSXStartCloseTag"){let d=u.parent,p=d.parent;if(p&&d.from==h-2&&((f=_c(o.doc,p.firstChild,h))||((c=p.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let m=`${f}>`;return{range:A.cursor(h+m.length,-1),changes:{from:h,insert:m}}}}else if(i==">"){let d=Ab(u);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(f=_c(o.doc,d,h)))return{range:l,changes:{from:h,insert:``}}}}return{range:l}});return a.changes.empty?!1:(n.dispatch([r,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Jc=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Yi{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?a=>r(Jc(a)):Jc,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Ne(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=fa(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Qt(e);let s=this.normalize(t);if(s.length)for(let r=0,o=i,a=!0;;r++){let l=s.charCodeAt(r),c=this.match(l,o,a,this.bufferPos+this.bufferStart,r==s.length-1);if(c)return this.value=c,this;if(r==s.length-1)break;a&&rthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=_s(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||s.to<=t){let a=new Li(t,e.sliceString(t,i));return oo.set(e,a),a}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,s=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,precise:!0,match:t},this.matchPos=_s(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Li.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(pd.prototype[Symbol.iterator]=md.prototype[Symbol.iterator]=function(){return this});function xb(n){try{return new RegExp(n,Na),!0}catch{return!1}}function _s(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}const vb=n=>{let{state:e}=n,t=String(e.doc.lineAt(n.state.selection.main.head).number),{close:i,result:s}=jg(n,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return s.then(r=>{let o=r&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.elements.line.value);if(!o){n.dispatch({effects:i});return}let a=e.doc.lineAt(e.selection.main.head),[,l,c,h,u]=o,f=h?+h.slice(1):0,d=c?+c:a.number;if(c&&u){let g=d/100;l&&(g=g*(l=="-"?-1:1)+a.number/e.doc.lines),d=Math.round(e.doc.lines*g)}else c&&l&&(d=d*(l=="-"?-1:1)+a.number);let p=e.doc.line(Math.max(1,Math.min(e.doc.lines,d))),m=A.cursor(p.from+Math.max(0,Math.min(f,p.length)));n.dispatch({effects:[i,$.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0},wb={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},kb=K.define({combine(n){return yt(n,wb,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Qb(n){return[$b,Rb]}const Pb=B.mark({class:"cm-selectionMatch"}),Cb=B.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function eh(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=ye.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=ye.Word)}function Tb(n,e,t,i){return n(e.sliceDoc(t,t+1))==ye.Word&&n(e.sliceDoc(i-1,i))==ye.Word}const Rb=xe.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(kb),{state:t}=n,i=t.selection;if(i.ranges.length>1)return B.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return B.none;let l=t.wordAt(s.head);if(!l)return B.none;o=t.charCategorizer(s.head),r=t.sliceDoc(l.from,l.to)}else{let l=s.to-s.from;if(l200)return B.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(eh(o,t,s.from,s.to)&&Tb(o,t,s.from,s.to)))return B.none}else if(r=t.sliceDoc(s.from,s.to),!r)return B.none}let a=[];for(let l of n.visibleRanges){let c=new Yi(t.doc,r,l.from,l.to);for(;!c.next().done;){let{from:h,to:u}=c.value;if((!o||eh(o,t,h,u))&&(s.empty&&h<=s.from&&u>=s.to?a.push(Cb.range(h,u)):(h>=s.to||u<=s.from)&&a.push(Pb.range(h,u)),a.length>e.maxMatches))return B.none}}return B.set(a)}},{decorations:n=>n.decorations}),$b=$.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Kb=({state:n,dispatch:e})=>{let{selection:t}=n,i=A.create(t.ranges.map(s=>n.wordAt(s.head)||A.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function Zb(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,a=new Yi(n.doc,e,i[i.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new Yi(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(l=>l.from==a.value.from))continue;if(r){let l=n.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const Mb=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return Kb({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=Zb(n,i);return s?(e(n.update({selection:n.selection.addRange(A.range(s.from,s.to),!1),effects:$.scrollIntoView(s.to)})),!0):!1},tn=K.define({combine(n){return yt(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Yb(e),scrollToMatch:e=>$.scrollIntoView(e)})}});class gd{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||xb(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` +`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Xb(this):new Fb(this)}getCursor(e,t=0,i){let s=e.doc?e:_.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?Pi(this,s,t,i):Qi(this,s,t,i)}}class Od{constructor(e){this.spec=e}}function Eb(n,e,t){return(i,s,r,o)=>{if(t&&!t(i,s,r,o))return!1;let a=i>=o&&s<=o+r.length?r.slice(i-o,s-o):e.doc.sliceString(i,s);return n(a,e,i,s)}}function Qi(n,e,t,i){let s;return n.wholeWord&&(s=Ub(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(s=Eb(n.test,e,s)),new Yi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),s)}function Ub(n,e){return(t,i,s,r)=>((r>t||r+s.length=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Qi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Db(n,e,t){return(i,s,r)=>(!t||t(i,s,r))&&n(r[0],e,i,s)}function Pi(n,e,t,i){let s;return n.wholeWord&&(s=Lb(e.charCategorizer(e.selection.main.head))),n.test&&(s=Db(n.test,e,s)),new pd(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:s},t,i)}function Js(n,e){return n.slice(Ze(n,e,!1),e)}function er(n,e){return n.slice(e,Ze(n,e))}function Lb(n){return(e,t,i)=>!i[0].length||(n(Js(i.input,i.index))!=ye.Word||n(er(i.input,i.index))!=ye.Word)&&(n(er(i.input,i.index+i[0].length))!=ye.Word||n(Js(i.input,i.index+i[0].length))!=ye.Word)}class Xb extends Od{nextMatch(e,t,i){let s=Pi(this.spec,e,i,e.doc.length).next();return s.done&&(s=Pi(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=Pi(this.spec,e,r,i),a=null;for(;!o.next().done;)a=o.value;if(a&&(r==t||a.from>r+10))return a;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let s=i.length;s>0;s--){let r=+i.slice(0,s);if(r>0&&r=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Pi(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Zn=z.define(),Ha=z.define(),Gt=Te.define({create(n){return new ao(aa(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Zn)?n=new ao(t.value.create(),n.panel):t.is(Ha)&&(n=new ao(n.query,t.value?Ga:null));return n},provide:n=>Vi.from(n,e=>e.panel)});class ao{constructor(e,t){this.query=e,this.panel=t}}const Bb=B.mark({class:"cm-searchMatch"}),Ib=B.mark({class:"cm-searchMatch cm-searchMatch-selected"}),qb=xe.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Gt))}update(n){let e=n.state.field(Gt);(e!=n.startState.field(Gt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return B.none;let{view:t}=this,i=new Bt;for(let s=0,r=t.visibleRanges,o=r.length;sr[s+1].from-500;)l=r[++s].to;n.highlight(t.state,a,l,(c,h)=>{let u=t.state.selection.ranges.some(f=>f.from==c&&f.to==h);i.add(c,h,u?Ib:Bb)})}return i.finish()}},{decorations:n=>n.decorations});function Wn(n){return e=>{let t=e.state.field(Gt,!1);return t&&t.query.spec.valid?n(e,t):bd(e)}}const tr=Wn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=A.single(i.from,i.to),r=n.state.facet(tn);return n.dispatch({selection:s,effects:[_a(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Ad(n),!0}),ir=Wn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=A.single(s.from,s.to),o=n.state.facet(tn);return n.dispatch({selection:r,effects:[_a(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Ad(n),!0}),Wb=Wn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:A.create(t.map(i=>A.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),zb=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let a=new Yi(n.doc,n.sliceDoc(i,s));!a.next().done;){if(r.length>1e3)return!1;a.value.from==i&&(o=r.length),r.push(A.range(a.value.from,a.value.to))}return e(n.update({selection:A.create(r,o),userEvent:"select.search.matches"})),!0},th=Wn((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,a=[],l,c,h=[];o.precise?o.from==i&&o.to==s&&(c=t.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),h.push($.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let u=n.state.changes(a);return o&&(l=A.single(o.from,o.to).map(u),h.push(_a(n,o)),h.push(t.facet(tn).scrollToMatch(l.main,n))),n.dispatch({changes:u,selection:l,effects:h,userEvent:"input.replace"}),!0}),Vb=Wn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let s of e.matchAll(n.state,1e9)){let{from:r,to:o,precise:a}=s;a&&t.push({from:r,to:o,insert:e.getReplacement(s)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:$.announce.of(i),userEvent:"input.replace.all"}),!0});function Ga(n){return n.state.facet(tn).createPanel(n)}function aa(n,e){var t,i,s,r,o;let a=n.selection.main,l=a.empty||a.to>a.from+100?"":n.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=n.facet(tn);return new gd({search:((t=e?.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(s=e?.literal)!==null&&s!==void 0?s:c.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function yd(n){let e=Fu(n,Ga);return e&&e.dom.querySelector("[main-field]")}function Ad(n){let e=yd(n);e&&e==n.root.activeElement&&e.select()}const bd=n=>{let e=n.state.field(Gt,!1);if(e&&e.panel){let t=yd(n);if(t&&t!=n.root.activeElement){let i=aa(n.state,e.query.spec);i.valid&&n.dispatch({effects:Zn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Ha.of(!0),e?Zn.of(aa(n.state,e.query.spec)):z.appendConfig.of(Hb)]});return!0},Sd=n=>{let e=n.state.field(Gt,!1);if(!e||!e.panel)return!1;let t=Fu(n,Ga);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Ha.of(!1)}),!0},jb=[{key:"Mod-f",run:bd,scope:"editor search-panel"},{key:"F3",run:tr,shift:ir,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:tr,shift:ir,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Sd,scope:"editor search-panel"},{key:"Mod-Shift-l",run:zb},{key:"Mod-Alt-g",run:vb},{key:"Mod-d",run:Mb,preventDefault:!0}];class Yb{constructor(e){this.view=e;let t=this.query=e.state.field(Gt).query.spec;this.commit=this.commit.bind(this),this.searchField=he("input",{value:t.search,placeholder:st(e,"Find"),"aria-label":st(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=he("input",{value:t.replace,placeholder:st(e,"Replace"),"aria-label":st(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=he("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=he("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=he("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return he("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=he("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>tr(e),[st(e,"next")]),i("prev",()=>ir(e),[st(e,"previous")]),i("select",()=>Wb(e),[st(e,"all")]),he("label",null,[this.caseField,st(e,"match case")]),he("label",null,[this.reField,st(e,"regexp")]),he("label",null,[this.wordField,st(e,"by word")]),...e.state.readOnly?[]:[he("br"),this.replaceField,i("replace",()=>th(e),[st(e,"replace")]),i("replaceAll",()=>Vb(e),[st(e,"replace all")])],he("button",{name:"close",onclick:()=>Sd(e),"aria-label":st(e,"close"),type:"button"},["×"])])}commit(){let e=new gd({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Zn.of(e)}))}keydown(e){sg(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ir:tr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),th(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Zn)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(tn).top}}function st(n,e){return n.state.phrase(e)}const fs=30,ds=/[\s\.,:;?!]/;function _a(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-fs),o=Math.min(s,t+fs),a=n.state.sliceDoc(r,o);if(r!=i.from){for(let l=0;la.length-fs;l--)if(!ds.test(a[l-1])&&ds.test(a[l])){a=a.slice(0,l);break}}return $.announce.of(`${n.state.phrase("current match")}. ${a} ${n.state.phrase("on line")} ${i.number}.`)}const Nb=$.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Hb=[Gt,ri.low(qb),Nb];class ih{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class di{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=i.facet(Kt).markerFilter;s&&(e=s(e,i));let r=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Bt,a=[],l=0,c=i.doc.iter(),h=0,u=i.doc.length;for(let d=0;;){let p=d==r.length?null:r[d];if(!p&&!a.length)break;let m,g;if(a.length)m=l,g=a.reduce((x,C)=>Math.min(x,C.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>u)break;g=p.to,a.push(p),d++}for(;dx.from||x.to==m))a.push(x),d++,g=Math.min(x.to,g);else{g=Math.min(x.from,g);break}}g=Math.min(g,u);let y=!1;if(a.some(x=>x.from==m&&(x.to==g||g==u))&&(y=m==g,!y&&g-m<10)){let x=m-(h+c.value.length);x>0&&(c.next(x),h=m);for(let C=m;;){if(C>=g){y=!0;break}if(!c.lineBreak&&h+c.value.length>C)break;C=h+c.value.length,h+=c.value.length,c.next()}}let b=Td(a);if(y)o.add(m,m,B.widget({widget:new nS(b),diagnostics:a.slice()}));else{let x=a.reduce((C,k)=>k.markClass?C+" "+k.markClass:C,"");o.add(m,g,B.mark({class:"cm-lintRange cm-lintRange-"+b+x,diagnostics:a.slice(),inclusiveEnd:a.some(C=>C.to>g)}))}if(l=g,l==u)break;for(let x=0;x{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new ih(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ih(i.from,r,i.diagnostic)}}),i}function xd(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(Kt).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(Qr))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function Gb(n,e){return n.field(gt,!1)?e:e.concat(z.appendConfig.of(Kd))}function vd(n,e){return{effects:Gb(n,[Qr.of(e)])}}const Qr=z.define(),wd=z.define(),kd=z.define(),gt=Te.define({create(){return new di(B.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Ni(t,n.selected.diagnostic,r)||Ni(t,null,r)}!t.size&&s&&e.state.facet(Kt).autoPanel&&(s=null),n=new di(t,s,i)}for(let t of e.effects)if(t.is(Qr)){let i=e.state.facet(Kt).autoPanel?t.value.length?nr.open:null:n.panel;n=di.init(t.value,i,e.state)}else t.is(wd)?n=new di(n.diagnostics,t.value?nr.open:null,n.selected):t.is(kd)&&(n=new di(n.diagnostics,n.panel,t.value));return n},provide:n=>[Vi.from(n,e=>e.panel),$.decorations.from(n,e=>e.diagnostics)]}),_b=B.mark({class:"cm-lintRange cm-lintRange-active"});function Jb(n,e,t){let{diagnostics:i}=n.state.field(gt),s,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:h})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(eCd(n,t,!1)))}const nh=n=>{let e=n.state.field(gt,!1);return!e||!e.panel?!1:(n.dispatch({effects:wd.of(!1)}),!0)},eS=xe.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(Kt);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(nPromise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(vd(this.view.state,i.reduce((s,r)=>s.concat(r))))},i=>{ze(this.view.state,i)})}}update(n){let e=n.state.facet(Kt);(n.docChanged||e!=n.startState.facet(Kt)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function tS(n,e,t){let i=[],s=-1;for(let r of n)r.then(o=>{i.push(o),clearTimeout(s),i.length==n.length?e(i):s=setTimeout(()=>e(i),200)},t)}const Kt=K.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...yt(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:sh,tooltipFilter:sh,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,s,r)=>e(i,s,r)||t(i,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function sh(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function iS(n,e={}){return[Kt.of({source:n,config:e}),eS,Kd]}function Pd(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;ir.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Cd(n,e,t){var i;let s=t?Pd(e.actions):[];return he("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},he("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=Ni(n.state.field(gt).diagnostics,e);p&&r.apply(n,p.from,p.to)},{name:c}=r,h=s[o]?c.indexOf(s[o]):-1,u=h<0?c:[c.slice(0,h),he("u",c.slice(h,h+1)),c.slice(h+1)],f=r.markClass?" "+r.markClass:"";return he("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${h<0?"":` (access key "${s[o]})"`}.`},u)}),e.source&&he("div",{class:"cm-diagnosticSource"},e.source))}class nS extends Ut{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return he("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class rh{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Cd(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class nr{constructor(e){this.view=e,this.items=[];let t=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)nh(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Pd(r.actions);for(let a=0;a{for(let r=0;rnh(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(gt).selected;if(!e)return-1;for(let t=0;t{for(let h of c.diagnostics){if(o.has(h))continue;o.add(h);let u=-1,f;for(let d=i;di&&(this.items.splice(i,u-i),s=!0)),t&&f.diagnostic==t.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),r=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),i++}});i({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.topl.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(gt),i=Ni(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:kd.of(i)})}static open(e){return new nr(e)}}function Qs(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function ps(n){return Qs(``,'width="6" height="3"')}const sS=$.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ps("#f11")},".cm-lintRange-warning":{backgroundImage:ps("orange")},".cm-lintRange-info":{backgroundImage:ps("#999")},".cm-lintRange-hint":{backgroundImage:ps("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function rS(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function Td(n){let e="hint",t=1;for(let i of n){let s=rS(i.severity);s>t&&(t=s,e=i.severity)}return e}class Rd extends Mt{constructor(e){super(),this.diagnostics=e,this.severity=Td(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,s=e.state.facet(Pr).tooltipFilter;return s&&(i=s(i,e.state)),i.length&&(t.onmouseover=()=>aS(e,t,i)),t}}function oS(n,e){let t=i=>{let s=e.getBoundingClientRect();if(!(i.clientX>s.left-10&&i.clientXs.top-10&&i.clientYe.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,oS(n,e)}let{hoverTime:s}=n.state.facet(Pr),r=setTimeout(i,s);e.onmouseout=()=>{clearTimeout(r),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,s)}}function lS(n,e){let t=Object.create(null);for(let s of e){let r=n.lineAt(s.from);(t[r.from]||(t[r.from]=[])).push(s)}let i=[];for(let s in t)i.push(new Rd(t[s]).range(+s));return N.of(i,!0)}const cS=Bu({class:"cm-gutter-lint",markers:n=>n.state.field(la),widgetMarker:(n,e,t)=>{let i=[];return n.state.field(la).between(t.from,t.to,(s,r,o)=>{s>t.from&&si.is(Ja)?i.value:t,n)},provide:n=>gr.from(n)}),hS=$.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Qs('')},".cm-lint-marker-warning":{content:Qs('')},".cm-lint-marker-error":{content:Qs('')}}),uS=Eu(Jb,{hideOn:xd}),Kd=[gt,$.decorations.compute([gt],n=>{let{selected:e,panel:t}=n.field(gt);return!e||!t||e.from==e.to?B.none:B.set([_b.range(e.from,e.to)])}),uS,sS],Pr=K.define({combine(n){return yt(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function fS(n={}){return[Pr.of(n),la,cS,hS,$d]}const Zd=1,Ue=Object.freeze({ready:"studio.ready",documentOpen:"document.open",documentReplace:"document.replace",documentChanged:"document.changed",documentSave:"document.save",documentSetReadOnly:"document.setReadOnly",documentResources:"document.resources",editorInsert:"editor.insert",editorFormat:"editor.format",editorSetTheme:"editor.setTheme",editorGetState:"editor.getState",diagnosticsPublish:"diagnostics.publish"});function dS(n,e={},t=null,i=null){return{protocolVersion:Zd,type:n,documentID:t,...i===null?{}:{sessionID:i},payload:e}}function pS(n){if(window.WKWebViewJavascriptBridge){n(window.WKWebViewJavascriptBridge);return}if(window.WKWVJBCallbacks){window.WKWVJBCallbacks.push(n);return}window.webkit?.messageHandlers?.iOS_Native_InjectJavascript&&(window.WKWVJBCallbacks=[n],window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage(null))}function nn(n,e,t={},i=null,s=()=>{},r=null){if(!n){s({result:"unavailable"});return}n.callHandler(e,dS(e,t,i,r),s)}function mS(n){const e={capabilities:["jsx","format","search","completion","diagnostics"]};nn(n,Ue.ready,e)}const gS=[{id:"$storage.getString",arguments:["key"],returns:"string",documentation:"Read a package-scoped string. Missing keys return an empty string."},{id:"$storage.setString",arguments:["key","value"],returns:"boolean",documentation:"Set a package-scoped string, limited to 256 KiB of UTF-8. Check the success result."},{id:"$storage.getJSON",arguments:["key"],returns:"json",documentation:"Read a package-scoped JSON object. Missing or invalid values return an empty object."},{id:"$storage.setJSON",arguments:["key","value"],returns:"boolean",documentation:"Store a valid JSON object, limited to 256 KiB encoded. Check the success result."},{id:"$storage.compareAndSetString",arguments:["key","expected","value"],returns:"boolean",minimumRuntimeVersion:"1.3",documentation:"Atomically replace a string only when it still matches expected. A missing key matches an empty string. Conflicts return false; reread and retry a bounded number of times. Requires the shared storage container."},{id:"$storage.compareAndSetJSON",arguments:["key","expected","value"],returns:"boolean",minimumRuntimeVersion:"1.3",documentation:"Atomically replace a JSON object if its current value equals expected, independent of property order. A missing key matches an empty object. Wrong types and conflicts return false. Requires the shared storage container."},{id:"$storage.remove",arguments:["key"],returns:"boolean",documentation:"Remove a key from this package only."},{id:"$storage.keys",arguments:[],returns:"string[]",documentation:"List keys in this package's namespace."},{id:"$storage.clear",arguments:[],returns:"boolean",documentation:"Clear this package's storage. Other packages are unaffected."}].map(n=>({minimumRuntimeVersion:"1.0",...n,preview:"initialState"})),OS=[{id:"$notifications.status",group:"notifications",value:{authorization:"authorized"},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift",operation:"read",mock:"editable"},{id:"$notifications.pending",group:"notifications",value:[],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift",operation:"read",mock:"editable"},{id:"$notifications.schedule",group:"notifications",value:{key:"daily",status:"scheduled"},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift",operation:"write",mock:"editable"},{id:"$notifications.cancel",group:"notifications",value:{key:"daily",status:"cancellationRequested"},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift",operation:"write",mock:"editable"},{id:"$health.dailyStatistics",group:"health",value:{metric:"steps",unit:"count",aggregation:"sum",timeZone:"UTC",items:[{date:"2026-01-01",value:6840,hasSamples:!0}]},platforms:["ios"],authorization:"healthRead",notes:"Runtime 1.6. Read-only daily HealthKit statistics on installed iPhone/iPad widgets. Declare health and minimumRuntimeVersion 1.6, review Health access in native Settings. No separate System Access toggle. Missing readings are null/hasSamples false and cannot establish read denial. No raw samples, persistence or queries in future/Live Activity presentations. Preview fixtures never access real Health data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift",operation:"read",mock:"editable"},{id:"$calendar.create",group:"calendar",value:{id:"sample.event",calendarID:"sample.calendar",status:"applied",replayed:!1},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift",operation:"write",mock:"editable"},{id:"$calendar.update",group:"calendar",value:{id:"sample.event",calendarID:"sample.calendar",status:"applied",replayed:!1},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift",operation:"write",mock:"editable"},{id:"$weather.forecast",group:"weather",value:{provider:"MET Norway",attribution:{text:"Weather data from MET Norway",url:"https://www.met.no/en/free-meteorological-data/Download-services"},latitude:37.33,longitude:-122.01,fetchedAt:"2026-01-01T12:00:00Z",isStale:!1,hours:[{time:"2026-01-01T12:00:00Z",temperatureC:21,windMetersPerSecond:2,precipitationMM:0,condition:"partlycloudy_day"}]},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeWeather.swift",operation:"read",mock:"editable"},{id:"$alarms.status",group:"alarms",value:{authorization:"authorized"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"read",mock:"editable"},{id:"$alarms.pending",group:"alarms",value:[],platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"read",mock:"editable"},{id:"$alarms.schedule",group:"alarms",value:{key:"focus",status:"scheduled",replayed:!1},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$alarms.cancel",group:"alarms",value:{key:"focus",status:"requested"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$alarms.stop",group:"alarms",value:{key:"focus",status:"requested"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$alarms.pause",group:"alarms",value:{key:"focus",status:"requested"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$alarms.resume",group:"alarms",value:{key:"focus",status:"requested"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$documents.list",group:"documents",value:[{id:"550e8400-e29b-41d4-a716-446655440000",name:"Sample.json",type:"json",bytes:17},{id:"550e8400-e29b-41d4-a716-446655440001",name:"Sample.csv",type:"csv",bytes:24}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift",operation:"read",mock:"editable"},{id:"$documents.readJSON",group:"documents",value:{goal:12,done:7},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["id"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift",operation:"read",mock:"editable"},{id:"$documents.readCSV",group:"documents",value:{headers:["day","value"],rows:[["Monday","7"],["Tuesday","9"]],truncated:!1},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["id"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift",operation:"read",mock:"editable"},{id:"$contacts.selected",group:"contacts",value:[{id:"sample.contact",name:"Alex Example",organization:"Sample",phones:["+1 202 555 0100"],emails:["alex@example.com"]}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeContacts.swift",operation:"read",mock:"editable"},{id:"$maps.search",group:"maps",value:[{name:"Example Park",address:"Sample address",latitude:37.33,longitude:-122.01}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift",operation:"read",mock:"editable"},{id:"$maps.geocode",group:"maps",value:[{name:"Example Park",address:"Sample address",latitude:37.33,longitude:-122.01}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["address"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift",operation:"read",mock:"editable"},{id:"$maps.reverseGeocode",group:"maps",value:[{name:"Example Park",address:"Sample address",latitude:37.33,longitude:-122.01}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift",operation:"read",mock:"editable"},{id:"$maps.snapshot",group:"maps",value:{image:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4z8DwHwAFgAI/ScLbtAAAAABJRU5ErkJggg==",width:256,height:256,provider:"Apple Maps"},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift",operation:"read",mock:"editable"},{id:"$home.items",group:"home",value:[{id:"sample.light",name:"Living Room Lamp",kind:"power",value:!0,isCached:!0,metric:"power",unit:"boolean"},{id:"scene-sample",name:"Evening",kind:"scene",value:null,isCached:!0,metric:"scene",unit:"none"}],platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift",operation:"read",mock:"editable"},{id:"$home.setPower",group:"home",value:{id:"sample.light",value:!0,status:"acknowledged"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift",operation:"write",mock:"editable"},{id:"$home.runScene",group:"home",value:{id:"scene-sample",status:"acknowledged",replayed:!1},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift",operation:"write",mock:"editable"}],ca="2026-01-01T00:00:00Z",zt="2026-01-01T12:00:00Z",lo=(n,e)=>({value:n,unit:e,hasSamples:!0,start:ca,end:zt}),oh=(n,e,t)=>Object.entries(e).map(([i,s])=>({id:`$${n}.${i}`,group:n,value:s,legacy:[t,i]})),yS=[{id:"$music.isAvailable",group:"music",value:!0},{id:"$music.authorizationStatus",group:"music",value:"authorized"},{id:"$music.current",group:"music",value:{provider:"appleMusic",state:"playing",hasItem:!0,title:"Morning Light",artist:"ScriptWidget Sessions",album:"Focus",duration:224,position:86,capturedAt:zt}},{id:"$services.status",group:"services",value:"connected"},{id:"$services.profile",group:"services",value:{service:"github",subject:"42",username:"octocat",displayName:"Mona",publicRepositories:32,privateRepositories:8,followers:128,following:24}},...oh("device",{screen:{width:390,height:844,scale:3},language:"en",model:"iPhone",name:"My iPhone",battery:{level:.8,state:"unplugged"},systemVersion:"26.0",isdarkmode:!1,totalDiskSpace:128e9,freeDiskSpace:64e9},"device"),...oh("system",{appInfo:{name:"ScriptWidget",bundleId:"com.everettjf.scriptwidget",version:"27.1.2",build:"27012"},locale:"en_US",preferredLanguages:["en-US"],timeZone:{identifier:"UTC",abbreviation:"GMT",offsetSeconds:0},is24HourClock:!1,calendarInfo:{identifier:"gregorian",firstWeekday:1,minimumDaysInFirstWeek:1},systemUptime:3600,memory:{physical:8589934592},thermalState:"nominal",lowPowerMode:!1,brightness:.5,reduceMotionEnabled:!1,platform:"ios",hostName:"My iPhone",processName:"ScriptWidgetWidget",osVersionString:"Version 26.0",processorCount:6,activeProcessorCount:6},"system"),{id:"$photos.isAvailable",group:"photos",value:!0},{id:"$photos.authorizationStatus",group:"photos",value:"authorized"},{id:"$photos.requestAuthorization",group:"photos",value:!0},{id:"$photos.items",group:"photos",value:{status:"ready",items:[{id:"sample.photo",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fbPe3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQK/QnooooGFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK7TxwooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi++865Pl26H91CDwo9T6t6mhs5cTiVSXmX/ABx49v8Axdc+UmYbKM/u4vX/AGm9T+g/U6/w38fv4buRpOqMTYynr18pj3H+ye4/H1z5TRU3PHVean7S+p+gSOkiCSMhlYZBHIIPcU6vmn4YfEL+zXTw5rb/AOjscQyN/wAsyf4Sf7p7Ht9On0tVHuUKyqx5kFFFFBsFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABTXdIkMkhwo5JNOrjPEN8ZJfsUZ+VeW9z/8AWry84zOGXYd4iSu9ku7O7L8FLF1lSjt19Av/ABDLIxjsvkX+8ep/wrn5J5pjmVyx9zmoqK/HsdmuJxsnPETb8ui9EfoWFwNHDR5aUbefX7yWOeaE5icqfY4roLDxDLGwjvfnX+8Oo/xrmqKMDmuJwUlPDza8uj9UGKwNHEx5asb+fX7z1ZH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TwABSTTRW8TTzsERBkseABXhHi3xfLrchsrIlLVT9C5Hc+3oPz9nGNzOpVUFdkvi/xjJrDmw08lbVTyehkI7n29B+ftwNFFbJWPNnNyd2FFFFMkKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvWvhP8W9b+F+r+bBm40+dh9otieG7bk/uuB379D2x5LRSLp1JU5KcHZo//0/rSiiius/PwooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtYWublgiIMsx6AU26ureyt3urpwkaDJY14H4q8V3GvzeTDmO1Q/Kvdvdv8O1OMbmVWqoIk8WeLZtdlNrbZS1Q8Du59T/AEFcXRRWyVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/9T60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKKKKACq15eW2n2z3d44SNBkk0y/v7XTbV7y9cJGg5J/kPU18/eJfE114hucnKW6H5I/6n1P8qqMbmVWqoLzJPFHim58QXGxcx2yH5E9fdvf+VcpRRWqVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9X60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKo6jqNppVo17etsRfzJ9B6mm6pqlnpFm17ettReg7k+gHrXz34h8Q3niC786c7Y1+5GOij+p9TVRjcxq1lBeY/xH4ku/EN1vk+SFD8kfYe59TXOUUVqedKTbuwooopiCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9b60oqRYZX+4pP0FWV03UX+5byH6Kf8K6z4CzKVFay6Drj/AHLKc/SNv8KsJ4V8Tv8Ac026P0hf/CgfJLsYNFdOngvxc/TTbn8Y2H8xVhPAHjN+mnTfiMfzoH7KfZnIUV3C/Dbxu/TT3/FkH82qyvws8dt/y44+skf/AMVQV7Cp/K/uPPqK9JT4S+OG62yL9ZE/oTVlfg94zbqkK/WQf0B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JytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/ayiiivVAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9D9rKKKK9UAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/0f2sooor1QCiiigAooooAKKKKACiiigAooooAKKKKACiq15eWun2r3t7IsUUY3MzHAApbW6tr62S8tHEkUqhlZeQQaduoFiiiikAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB/9L9rKKKK9UAooooAKKKKACiiigAooooAKKKKACs/VdVsNFsZNS1OQRQxjJJ/kB3J7Cquva/pnhvTn1PVJNiLwAPvMeyqO5P+eK+P/GPjTU/GF9510fLt0P7qEHhR6n1Y9zXRRoOo/Iyq1VD1L3jrx9f+MLrykzDZRn93F6/7T+p/QdvU7Pw1+IL+GbkaTqjFrCVuvXymP8AEP8AZPcfiO+fJqK9F0ouPJbQ4lUfNzH6FI6SoJIyGVhkEcgg9xTq+ZPhd8Rf7MdPDeuP/ozHEMjf8syf4Sf7p7en06fTdeXVpOm7M74TU1dBRRRWRYUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFNZlRS7nAHU06uc1a6LyfZkPyr1+tebm2ZRwFB15avZLuzmxeJVCm5sLrVpHJS2+VfXvWS8skhy7E/U0yivybG5niMZJyrzb8un3HylbE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cgj+hHQg8g8HmtSvyU+DHxs1r4Vap5Em660i4bM9tnkHp5keeA47jow4PYj9UPDviPRfFmjQa/4fnW5tbhdyOv6gjqCDwQeQa+ZxeElQl5Hq0ayqLzP//S+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACo5ZYoI2mmYIiDLMTgADuaSeeG2ha4uGCIgyzHgACvnbxp42m1+Q2NgSlmp+hkI7n29B+J9tKVJzdkTKViXxt44k1x203TSUtFPJ6GQjuf9n0H4n284oor0oxUVZGLdwoooqgCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAr2H4QfGLXvhTrPm2+bjTZ2H2m1J4btvT+64Hfv0PbHj1FROEZxcZrQcZOLuj//T+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKgubm3s7d7q6cRxxjLMegFNu7y2sLZ7y8cRxxjLMe1fN/jDxlc+JJ/IgzHaIflTux/vN7+g7VpSpObJlKxL4y8aXHiKY2lpmOzQ8L0Lkd2/oK4OiivSjFRVkYt3CiiiqAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//1PqCiiivszygooooAKKKKACiiigAooooAKKKKACiiigAooooAKqX19aabave3riOKMZJP+etN1HUbPSrN76/cRxoOSf5D1J9K+afFfiy88TXeTmO2Q/u4/6t6n+XataVJzfkTKViXxd4vu/EtzsTMdrGfkj9f9pvf+VcbRRXoxioqyMW7hRRRVAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//V+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACs/VNUstHsnv799kafmT2AHcmmavq9jolk1/qD7UXoO7HsAO5NfM3iXxNfeJb3z7j5Il/1cY6KP6k9zW1Ki5vyJlKxL4o8VXvia78yX5IEP7uMdB7n1PvXLUUV6EYpKyMW7hRRRVAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFF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4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDTt1AnooopAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9vKKKK7T0wooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi++865PlwIf3UIPCj1Pq3qa3o0XUfkXCHMX/HHjy/8AF115SZhsoz+7iz1/2m9T+g/U6/w38fv4buRpWqMTYSnr18pj3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CiiigAooooAKKKKACiiigAooooAKKKKACqGpalZ6TZtfXz7I1/Mn0A7k03VdVstGs2vr59qL0Hcn0A7mvnLxH4jvfEV558/yxL/AKuMdFH9T6mtadPm9DWlSc/Qk8S+JrzxHd+ZJ8kKH93H2HufU1zNFFdqSSsjvSSVkFFFFMYUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//1vriipFilf7ik/QVZXTtQf7kEh+in/CvqD6ApUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf/AApcy7iuYNFdOngvxc/TTbn8Y2H8xVhfAPjJ+mnTfiMfzpc8e4XRyFFdwvw38bv009/xZB/NqsL8LfHbf8uOPrJH/wDFUvaR7hzLuef0V6Svwl8cN1tkX6yJ/Q1ZX4P+M26pCv1kH9AaXtYdxc67nltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AAJz/wCyUvbw7hzx7njlZesaxY6JZNe3zYUcADqx9APWvSvHfg6P4daE+u+JNQgVfuxxJuMkr/3UBAz7noB1r4j13Xr7xBem7vDgDhEHRR6D+p710UIqpqtjejT9pr0JPEHiC+8Q3hubo7UXhIx0Uf4+prBoorvStojvSS0QUUUUxhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//2Q==",width:384,height:256},{id:"sample.photo.4",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQO3UnooooEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf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RRRQAUUUUAFFFFABX0/8Cvj7deBJo/C/ip2m0ZzhH5ZrYnuO5T1Xt1HcH5gopmNajGtFwmtD9wLS7tb+1jvrGRZoZlDo6EMrKRkEEcEEVYr8xPgf8d7/wCHN0ug68WuNFlblerW5J5dPVe7L+I5yD+l2najYavYxanpcyz286h45EOVZT0INVc+TxeDnh5Wlt0ZdooooOM//9H60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigApGZUUu5wBySaR3SNDJIQqqMkngACvBvGnjZ9WZtM0titqDhm6GT/7H+dJuxrSpOo7Im8a+OG1ItpOkNi36O46v7D/Z/n9K8woorNu560IKC5YhRRRSLCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAK98+Cvxw1T4ZXw0zUd1zo07Zki6tET1ePPf1XofrzXgdFMyq0o1YuE1oftro2s6X4h0yHWdFnW5tbhd8ciHII/oR0IPIPBrTr8o/g58Z9Z+Fup+TJuudJnbM9vnkHp5keeA47jow4PYj9QvD3iHRvFWjw69oE63NrcLuR1/UEdQQeCDyDTTPlMbgpYeXddGf/9L60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACmSyxwxtNMwVFGSTwAB3NNnnhtoWuLhgiIMsx4AAr5+8Y+M5tekNlYkpaKfoXI7n29B+J9k3Y2o0XUdkS+MvGsmtO2nacSlop5PQyEdz7eg/E155RRWbdz1YQUFyxCiiikWFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABXrvwk+L2ufCzWPNt83GnTsPtNqTw3ben91wO/foe2PIqKDOpTjUi4TV0f/T+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtIHublwkaDLMegFNu7u2sbZ7u7cRxoMsx7V87+LfF9z4in8iHMdoh+VO7H+839B2pN2NqNF1H5EvjDxjP4gmNra5jtEPC93I7t/QVw1FFZtnqwgorliFFFFIsKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9T60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAqre3trp1q95euI40GST/nrTNQ1C00u0e9vnCRoOSf5D1Jr5y8U+KrvxJdZOY7dD+7j/qfU/wAqTdjejRdR+RL4r8WXXiO52LmO1Q/Inr/tN7/yrkKKKzPVjFRVkFFFFIoKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP//V+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAqhqep2ekWb318+yNPzJ9AO5NM1XVrLRbJr6/fai9B3Y9gB3NfN/iPxJe+I7zz7j5Yl/wBXGOij+p9TUt2OihQdR+RJ4m8T3niO78yT5IEP7uPsPc+prmaKKg9SMVFWQUUUUigooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/W+tKKkWKV/uKT9BVlNO1CT7kEjfRT/hWR9rcpUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf8AwoFzLuYNFdMvgvxc/TTbn8Y2H8xVlfAPjJ+mnTfiMfzoF7SPc5Ciu4X4b+N36ae/4sg/masL8LfHb/8ALjj6yR//ABVIXtYfzI8/or0lPhL44brbIv1kT+hqynwf8Zt1SFfrIP6A0C9tD+ZHltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AnP8A7JQL6xT/AJjxysrWNZsdDsmvr5sKOAB1Y+gHrXpXjvwfF8OdBfXfEmoQKv3Yok3GSV/7qAgZ9z0A618Q69r194gvTd3hwBwiDoo9B/U96TdjrwtNVveWw/xB4hvvEV6bm6O1F4SMdFH+PqawaKKg9dJJWQUUUUhhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH/9k=",width:384,height:256}],unavailableCount:0,fetchedAt:zt,source:"system",stale:!1}},{id:"$calendar.isAvailable",group:"calendar",value:!0},{id:"$calendar.authorizationStatus",group:"calendar",value:"authorized"},{id:"$calendar.requestAuthorization",group:"calendar",value:!0},{id:"$calendar.calendars",group:"calendar",value:[{id:"sample.personal",title:"Personal"}]},{id:"$calendar.events",group:"calendar",value:{status:"ready",items:[{id:"sample.event",calendarID:"sample.personal",title:"Read and recharge",start:"2026-01-01T15:00:00Z",end:"2026-01-01T15:30:00Z",allDay:!1}],fetchedAt:zt,source:"system",stale:!1,truncated:!1}},{id:"$reminders.isAvailable",group:"reminders",value:!0},{id:"$reminders.authorizationStatus",group:"reminders",value:"authorized"},{id:"$reminders.requestAuthorization",group:"reminders",value:!0},{id:"$reminders.lists",group:"reminders",value:[{id:"sample.reminders",title:"Personal"}]},{id:"$reminders.items",group:"reminders",value:{status:"ready",items:[{id:"sample.reminder",listID:"sample.reminders",title:"Read a chapter",due:"2026-01-01T16:00:00Z",hasTime:!0,completed:!1,completedAt:null,priority:0}],fetchedAt:zt,source:"system",stale:!1,truncated:!1}},{id:"$reminders.create",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$reminders.update",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$reminders.setCompleted",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$health.authorizationStatus",group:"health",value:"notDisclosed"},{id:"$health.sleepSummary",group:"health",value:{start:ca,end:zt,timeZone:"UTC",hasSamples:!0,totalSleepSeconds:27e3,inBedSeconds:30600,awakeSeconds:1800,stages:{unspecified:0,core:16200,deep:5400,rem:5400},sourceCount:1,truncated:!1,conflictSeconds:0,aggregation:"union-awake-rem-deep-core-unspecified"}},{id:"$health.activitySummary",group:"health",value:{date:"2026-01-01",timeZone:"UTC",hasSamples:!0,moveMode:"activeEnergy",move:{value:480,goal:600,unit:"kcal"},exercise:{value:26,goal:30,unit:"min"},stand:{value:9,goal:12,unit:"count"}}},{id:"$health.workouts",group:"health",value:{start:ca,end:zt,timeZone:"UTC",hasSamples:!0,truncated:!1,items:[{id:"550e8400-e29b-41d4-a716-446655440000",activity:"running",start:"2026-01-01T09:00:00.000Z",end:"2026-01-01T09:45:00.000Z",duration:2700,energyKcal:285,distanceMeters:5200}]}},{id:"$health.isAvailable",group:"health",value:!0},{id:"$health.requestAuthorization",group:"health",value:!0,legacy:["health"]},{id:"$health.stepCountToday",group:"health",value:lo(6840,"count"),legacy:["health.stepCountToday"]},{id:"$health.activeEnergyToday",group:"health",value:lo(420,"kcal"),legacy:["health.activeEnergyToday"]},{id:"$health.heartRateLatest",group:"health",value:lo(72,"bpm"),legacy:["health.heartRateLatest"]},{id:"$location.isAvailable",group:"location",value:!0},{id:"$location.authorizationStatus",group:"location",value:"authorizedWhenInUse"},{id:"$location.isAuthorizedForWidgetUpdates",group:"location",value:!0},{id:"$location.requestAuthorization",group:"location",value:!0,legacy:["location.authorization"]},{id:"$location.current",group:"location",value:{latitude:37.3349,longitude:-122.009,altitude:0,accuracy:10,verticalAccuracy:10,speed:-1,course:-1,timestamp:zt,accuracyAuthorization:"full",age:0,isStale:!1},legacy:["location"]}],AS={music:{platforms:["ios"],authorization:"musicRead",notes:"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access."},services:{platforms:["ios","macos"],authorization:"serviceAccount",notes:"Runtime 1.4: status(service) and profile(service) are asynchronous. Only provider: github. Unknown providers reject with service_operation. Requires an installed owner and services permission. profile additionally requires network and api.github.com in networkDomains, a native connected GitHub account and explicit owner grant. Native Settings handles credentials; scripts cannot log in or obtain tokens. profile returns service, subject, username, displayName, publicRepositories, privateRepositories, followers and following (missing values are null). No live queries in future entries or Live Activities. Eight shared data queries; native requests also share the eight concurrent/32 total network budget, while Web uses its existing preview network budget. Web uses editable best-state samples only; it never authenticates or sends these requests."},photos:{platforms:["ios","macos"],authorization:"photosRead",notes:"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access."},reminders:{platforms:["ios","macos"],authorization:"remindersRead",notes:"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission."},calendar:{platforms:["ios","macos"],authorization:"calendarRead",notes:"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission."},device:{platforms:["ios","macos"],authorization:"none",notes:"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements."},system:{platforms:["ios","macos"],authorization:"none",notes:"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable."},health:{platforms:["ios"],authorization:"healthRead",notes:"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain."},location:{platforms:["ios"],authorization:"locationWhenInUse",notes:"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale."}},bS=[...yS.map(n=>{const e=n.id.split(".")[1],t=n.group==="music"&&e==="current"||n.group==="services"||["calendar","reminders","photos"].includes(n.group)&&!["isAvailable","authorizationStatus"].includes(e)||n.group==="health"&&!["isAvailable","authorizationStatus"].includes(e)||n.group==="location"&&["current","requestAuthorization"].includes(e),i=n.group==="health"&&["sleepSummary","activitySummary","workouts"].includes(e)||n.group==="location"&&["current","requestAuthorization"].includes(e)||["calendar","reminders","photos"].includes(n.group)&&["events","items"].includes(e);return{...n,...AS[n.group],minimumRuntimeVersion:["music","services","reminders","photos"].includes(n.group)||n.group==="health"&&["sleepSummary","activitySummary","workouts"].includes(e)?"1.4":["calendar"].includes(n.group)||["$health.authorizationStatus","$location.isAuthorizedForWidgetUpdates"].includes(n.id)?"1.3":"1.0",arguments:n.group==="services"?["service"]:n.group==="reminders"&&["create","update","setCompleted"].includes(e)?["options"]:i?["options?"]:[],...n.group==="reminders"&&["create","update","setCompleted"].includes(e)?{authorization:"remindersWrite"}:{},asynchronous:t,nativeSource:`Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntime${n.group[0].toUpperCase()}${n.group.slice(1)}.swift`,operation:n.group==="reminders"&&["create","update","setCompleted"].includes(e)?"write":e==="requestAuthorization"?"authorization":["isAvailable","authorizationStatus","isAuthorizedForWidgetUpdates"].includes(e)?"availability":"read",mock:"editable"}}),...OS],$e={globalProperties:{background:{type:"color",documentation:"Background color, hex value, or named color."},backgroundMaterial:{type:"enum",values:["none","ultraThin","thin","regular","thick","ultraThick"],documentation:"Runtime API 1.4. Public SwiftUI frosted material inside the widget, not Home Screen wallpaper blur or system Liquid Glass. At most four material backgrounds per tree. background supplies an opaque-composited Reduce Transparency fallback. In accented/vibrant mode local material is omitted for system rendering; none keeps the ordinary background."},color:{type:"color",documentation:"Foreground color, hex value, or named color."},font:{type:"enum",values:["largeTitle","title","title2","title3","headline","subheadline","body","callout","footnote","caption","caption2"],documentation:"Semantic text style."},fontWeight:{type:"enum",values:["ultraLight","thin","light","regular","medium","semibold","bold","heavy","black"],documentation:"Font weight."},fontDesign:{type:"enum",values:["default","rounded","serif","monospaced"],documentation:"Font design."},frame:{type:"number|string",documentation:'Square size (64 or "64"), width,height ("64,48"), or flexible frame ("max", "max,48").'},padding:{type:"number|string",documentation:"Padding amount or edge description."},corner:{type:"number",documentation:"Corner radius."},opacity:{type:"number",documentation:"Opacity from 0 through 1."},alignment:{type:"enum",values:["center","leading","trailing","top","bottom","topLeading","topTrailing","bottomLeading","bottomTrailing","firstTextBaseline","lastTextBaseline"],documentation:"Layout alignment."},clip:{type:"enum",values:["circle","rect","capsule","ellipse"],documentation:"Clip the view to a shape."},rotation:{type:"number",documentation:"Rotation in degrees."},rotation3d:{type:"string",documentation:"Static degree,x,y,z rotation with four finite numbers and a nonzero axis. Invalid values are ignored; axis magnitude is normalized. Reduce Motion removes the tilt. This does not read device motion or provide parallax."},shadow:{type:"string",documentation:"Shadow color, radius, and offset description."},animation:{type:"string",documentation:"iOS public SwiftUI scheduled clock/swing effect. Mac renders static standard-clock poses; other effects remain at rest. Signed clockCustom intervals specify a half-turn (full cycle = 2 * abs(interval)), minimum magnitude 0.25 seconds. App previews can animate; WidgetKit decides cadence and may freeze. Reduced motion/luminance freezes standard clock poses and keeps custom/swing effects at rest. Dynamic scripts are not rerun on animation ticks."},widgetAccentable:{type:"boolean",documentation:"Group this view into the accent layer in tinted and vibrant widget appearances."},linkurl:{type:"url",documentation:"Widget deep link URL."}},components:{VStack:{documentation:"Arrange children vertically.",children:!0,properties:{spacing:{type:"number"}}},HStack:{documentation:"Arrange children horizontally.",children:!0,properties:{spacing:{type:"number"}}},ZStack:{documentation:"Overlay children.",children:!0,properties:{}},VGrid:{documentation:"Vertical lazy grid.",children:!0,properties:{columns:{type:"string",required:!0},spacing:{type:"number"},alignment:{type:"enum",values:["leading","center","trailing"]}}},HGrid:{documentation:"Horizontal lazy grid.",children:!0,properties:{columns:{type:"string",required:!0},spacing:{type:"number"},alignment:{type:"enum",values:["top","center","bottom","firstTextBaseline","lastTextBaseline"]}}},Text:{documentation:"Display text content.",children:!1,properties:{text:{type:"string"}}},Date:{documentation:"Display a formatted date.",children:!1,properties:{date:{type:"date|number",required:!0},style:{type:"enum",values:["time","date","relative","offset","timer"]}}},Image:{documentation:"Display a bundled, remote, or SF Symbol image.",children:!1,properties:{systemName:{type:"string"},name:{type:"string"},id:{type:"string",deprecated:"Use name."},url:{type:"url"},src:{type:"url",deprecated:"Use url."},ratio:{type:"number"},mode:{type:"enum",values:["fit","fill"]},accentedRenderingMode:{type:"enum",values:["accented","desaturated","accentedDesaturated","fullColor"],documentation:"Control how the image is rendered in tinted and clear widget appearances."}}},Gif:{documentation:"Display a bounded package GIF using system decoding: up to 8 MiB input and 1,048,576 canvas pixels. iOS retains at most 60 downsampled frames / 4 MiB decoded pixels; more frames fall back to the first frame. Mac, Reduce Motion and reduced luminance use a static first frame. Active iOS previews use public SwiftUI timing with variable frame delays. Snapshots, inactive scenes, Mac and accessibility fallbacks use the first frame. No private clock bridge or continuous WidgetKit guarantee.",children:!1,properties:{file:{type:"string",required:!0}}},Spacer:{documentation:"Flexible layout space.",children:!1,properties:{minLength:{type:"number"}}},Rect:{documentation:"Rectangle shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},RoundedRect:{documentation:"Filled rounded rectangle.",children:!1,properties:{radius:{type:"number"}}},Capsule:{documentation:"Capsule shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Ellipse:{documentation:"Ellipse shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Circle:{documentation:"Circle shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Gauge:{documentation:"Display a gauge or instrument.",children:!1,properties:{type:{type:"string"},value:{type:"number"},style:{type:"enum",values:["circular","linear"]},text:{type:"string"},current:{type:"string"},min:{type:"string"},max:{type:"string"},angle:{type:"number"},thickness:{type:"number"},needleColor:{type:"color"},label:{type:"string"},title:{type:"string"},sections:{type:"string"}}},Chart:{documentation:"Render chart data.",children:!1,availability:{ios:"16.0",macos:"26.0"},properties:{type:{type:"enum",values:["bar","bar-x","bar-y","bar-gantt","line","point","line-point","area","rect","rule-x"]},data:{type:"json",required:!0},category:{type:"boolean"},hideLegend:{type:"boolean"},hideXAxis:{type:"boolean"},hideYAxis:{type:"boolean"}}},Link:{documentation:"Open a URL when selected.",children:!0,properties:{url:{type:"url",required:!0}}},Divider:{documentation:"Horizontal or vertical separator.",children:!1,properties:{thickness:{type:"number"},axis:{type:"enum",values:["horizontal","vertical"]}}},Line:{documentation:"Fixed-length line.",children:!1,properties:{thickness:{type:"number"},length:{type:"number"},axis:{type:"enum",values:["horizontal","vertical"]}}},Icon:{documentation:"SF Symbol icon.",children:!1,properties:{systemName:{type:"string",required:!0},size:{type:"number"}}},Label:{documentation:"Text paired with an SF Symbol.",children:!1,properties:{title:{type:"string"},systemName:{type:"string",required:!0}}},Progress:{documentation:"Linear or circular progress.",children:!1,properties:{value:{type:"number",required:!0},total:{type:"number"},label:{type:"string"},style:{type:"enum",values:["linear","circular"]},trackColor:{type:"color"},thickness:{type:"number"}}},Ring:{documentation:"Circular progress ring.",children:!1,properties:{value:{type:"number",required:!0},thickness:{type:"number"},trackColor:{type:"color"}}},Badge:{documentation:"Compact status badge.",children:!1,properties:{text:{type:"string"},radius:{type:"number"}}},Chip:{documentation:"Outlined metadata chip.",children:!1,properties:{text:{type:"string"},radius:{type:"number"},borderColor:{type:"color"}}},Stat:{documentation:"Title, value, and subtitle statistic.",children:!1,properties:{title:{type:"string"},value:{type:"string",required:!0},subtitle:{type:"string"},mutedColor:{type:"color"}}},Button:{documentation:"Interactive widget button. Use actionID to share a declared Package 2.0 action with Siri, Shortcuts, and Control Widgets.",children:!0,availability:{interactiveIos:"17.0"},requiredAny:["action","onClick","actionID"],properties:{action:{type:"enum",values:["reload"],conflicts:["actionID"]},onClick:{type:"function",conflicts:["actionID"]},actionID:{type:"action-id",conflicts:["action","onClick"]}}},Toggle:{documentation:"Interactive widget toggle. A declared actionID requires a package-relative storage stateKey.",children:!0,availability:{interactiveIos:"17.0"},requiredAny:["onClick","actionID"],properties:{on:{type:"boolean",required:!0},onClick:{type:"function",conflicts:["actionID"]},actionID:{type:"action-id",requires:["stateKey"],conflicts:["onClick"]},stateKey:{type:"storage-key",requires:["actionID"]}}}},functions:{...Object.fromEntries(gS.map(n=>[n.id,n])),...Object.fromEntries(bS.map(n=>[n.id,{documentation:n.notes,minimumRuntimeVersion:n.minimumRuntimeVersion,arguments:n.arguments,returns:n.asynchronous?"Promise":typeof n.value=="object"?"json":typeof n.value}])),"$icloud.readJSON":{documentation:"Read cached JSON and revision; conflicts preserve all heads. Requires icloud permission and a native connection. Never certifies upload.",arguments:["name"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.writeJSON":{documentation:"Save a new immutable JSON revision locally from a user action. Requires the revision from readJSON. Background exchange is eventual.",arguments:["name","value","expectedRevision"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.resolveJSON":{documentation:"Explicitly resolve all observed conflicting heads into a new revision. Stale tokens fail; originals remain.",arguments:["name","value","expectedRevision"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.sync":{documentation:"Exchange materialized revisions with iCloud; requires a user action. Upload completion is unknown.",arguments:[],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.status":{documentation:"Read native connection state. In the app, explicitly connect packages to separate stores for isolation or the same store ID to share JSON documents. Scripts cannot choose store IDs. Sync is eventual; local $storage is not migrated. Web uses preview mocks.",arguments:[],returns:"Promise",minimumRuntimeVersion:"1.5"},"$file.exists":{documentation:"Return whether a regular file is locally present inside this package, including binary assets. Missing files, directories, unsafe paths and links return false. Does not download iCloud files or read outside the package. Web preview uses workspace file presence.",arguments:["path"],returns:"boolean",minimumRuntimeVersion:"1.3"},"$file.read":{documentation:"Read package-relative UTF-8 text. Missing or unavailable files return an empty string.",arguments:["path"],returns:"string"},"$file.readJSON":{documentation:"Read a package-relative JSON object.",arguments:["path"],returns:"json"},fetch:{documentation:"Perform a network request and return its response text. Existing HTTP methods keep this string result."},"$http.getResponse":{documentation:"GET response metadata: {status, body, headers}. Headers are limited to content-type, cache-control, expires, last-modified, date and retry-after (lowercase; each at most 2048 UTF-8 bytes). Network permissions, public-host policy, redirects, body limits and timeline restrictions still apply. HTTP error statuses resolve; transport errors reject.",arguments:["url","options?"],returns:"Promise",minimumRuntimeVersion:"1.3"},importJS:{documentation:"Import a package-relative JavaScript file."},"$dataSource.request":{documentation:"Call a declared Data Source Plugin operation. Requires Package 2.0 plugins, network permission, and networkDomains declarations.",arguments:["pluginID","operationID","parameters"],returns:"Promise"},"$xml.parse":{documentation:"Parse up to 256 KiB of XML into {name, attributes, text, children}. DTDs and external entities are rejected; depth and node limits apply.",arguments:["source"],returns:"XMLNode"}}};function SS(n,e){const t=Object.entries(e.properties??{}).filter(([,s])=>s.required).map(([s,r])=>`${s}=${r.type.includes("number")||r.type==="boolean"?"{${}}":'"${}"'}`).join(" "),i=t?` ${t}`:"";return e.children?`<${n}${i}> + \${} +`:`<${n}${i} />`}const ah=Object.entries($e.components).map(([n,e])=>({label:n,type:"class",detail:`ScriptWidget · ${Object.keys(e.properties??{}).length} properties`,info:e.documentation,apply:SS(n,e)}));function xS(n){const e=n.match(/<([A-Za-z][\w]*)\b([^<>]*)$/);return!e||e[2].includes(">")?null:{name:e[1],attributes:e[2]}}function vS(n,e){const t=$e.components[n];return t?Object.entries({...$e.globalProperties,...t.properties??{}}).filter(([i])=>!e.has(i)).map(([i,s])=>({label:i,type:"property",detail:s.required?`${s.type} · required`:s.type,info:s.deprecated?`Deprecated: ${s.deprecated}`:s.documentation,apply:`${i}=${s.type.includes("number")||s.type==="boolean"?"{${}}":'"${}"'}`})):[]}function wS(n){const e=n.match(/<([A-Za-z][\w]*)\b[^<>]*\b([A-Za-z][\w]*)\s*=\s*["']([^"']*)$/);if(!e)return null;const t=$e.components[e[1]]?.properties?.[e[2]]??$e.globalProperties[e[2]];return t?.values?{typed:e[3],values:t.values}:null}function kS(n){const e=n.state.doc.sliceString(Math.max(0,n.pos-1200),n.pos),t=wS(e);if(t)return{from:n.pos-t.typed.length,options:t.values.map(o=>({label:o,type:"enum"})),validFor:/^[\w-]*$/};const i=n.matchBefore(/<[A-Za-z]*$/);if(i)return{from:i.from+1,options:ah,validFor:/^[A-Za-z]*$/};const s=xS(e);if(s&&/(?:\s|^)\w*$/.test(s.attributes)){const o=n.matchBefore(/[A-Za-z][\w]*$/),a=new Set([...s.attributes.matchAll(/\b([A-Za-z][\w]*)\s*=/g)].map(l=>l[1]));return{from:o?.from??n.pos,options:vS(s.name,a),validFor:/^[A-Za-z][\w]*$/}}const r=n.matchBefore(/\$[A-Za-z]+\.[A-Za-z]*$/);if(r){const o=r.text.slice(0,r.text.indexOf(".")+1),a=Object.entries($e.functions).filter(([l])=>l.startsWith(o));return a.length?{from:r.from+o.length,options:a.map(([l,c])=>({label:l.slice(o.length),type:"function",detail:c.returns,info:c.documentation})),validFor:/^[A-Za-z]*$/}:null}return n.explicit?{from:n.pos,options:ah,validFor:/^[A-Za-z]*$/}:null}function lh(n,e){const t=[];for(let i=n.node.firstChild;i;i=i.nextSibling)i.name===e&&t.push(i);return t}function Md(n){const e=[];return Ce(n).iterate({enter(t){if(t.name!=="JSXOpenTag"&&t.name!=="JSXSelfClosingTag")return;const s=lh(t,"JSXIdentifier")[0];s&&e.push({name:n.doc.sliceString(s.from,s.to),from:s.from,to:s.to,attributes:lh(t,"JSXAttribute").map(r=>{const o=r.firstChild;return o?{name:n.doc.sliceString(o.from,o.to),from:o.from,to:o.to}:null}).filter(Boolean)})}}),e}function Ed(n){const e=[];for(const t of Md(n.state)){const i=$e.components[t.name];if(!i)continue;const s=new Set([...Object.keys($e.globalProperties),...Object.keys(i.properties??{})]),r=new Set(t.attributes.map(o=>o.name));for(const o of t.attributes){s.has(o.name)||e.push({from:o.from,to:o.to,severity:"warning",message:`“${o.name}” is not supported by <${t.name}>.`});const a=i.properties?.[o.name]??$e.globalProperties[o.name];a?.deprecated&&e.push({from:o.from,to:o.to,severity:"warning",message:`${o.name} is deprecated. ${a.deprecated}`})}for(const[o,a]of Object.entries(i.properties??{}))if(a.required&&!r.has(o)&&e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> requires the “${o}” property.`}),r.has(o)){for(const l of a.requires??[])r.has(l)||e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> “${o}” requires the “${l}” property.`});for(const l of a.conflicts??[])r.has(l)&&o cannot combine “${o}” with “${l}”.`})}i.requiredAny?.length&&!i.requiredAny.some(o=>r.has(o))&&e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> requires one of: ${i.requiredAny.map(o=>`“${o}”`).join(", ")}.`})}return e}function QS(n,e){const t=Md(n.state).find(s=>e>=s.from&&e<=s.to);if(!t)return null;const i=$e.components[t.name];return i?{pos:t.from,end:t.to,above:!0,create(){const s=document.createElement("div");s.className="studio-hover";const r=document.createElement("strong");r.textContent=`<${t.name}>`;const o=document.createElement("p");return o.textContent=i.documentation,s.append(r,o),{dom:s}}}:null}const ch={light:{background:"#FAFAFC",foreground:"#202124",gutter:"#F3F3F6",gutterText:"#8A8A93",activeLine:"#EDEEF3",selection:"#B9D7FF",caret:"#0067C0"},dark:{background:"#1E1F22",foreground:"#E8E8ED",gutter:"#191A1D",gutterText:"#777982",activeLine:"#292A2F",selection:"#315A85",caret:"#65B7FF"}};function PS(n,e){return $.theme({"&":{height:"100%",color:n.foreground,backgroundColor:n.background,fontSize:"13px"},".cm-scroller":{fontFamily:'ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace',lineHeight:"1.58",overscrollBehavior:"contain"},".cm-content":{caretColor:n.caret,padding:"12px 0 32px"},".cm-line":{padding:"0 8px"},".cm-cursor, .cm-dropCursor":{borderLeftColor:n.caret},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:n.selection},".cm-activeLine":{backgroundColor:n.activeLine},".cm-gutters":{backgroundColor:n.gutter,color:n.gutterText,border:"none",paddingLeft:"env(safe-area-inset-left)"},".cm-activeLineGutter":{backgroundColor:n.activeLine,color:n.foreground},".cm-foldPlaceholder":{backgroundColor:"transparent",border:`1px solid ${n.gutterText}`,color:n.gutterText},".cm-tooltip":{border:e?"1px solid #41434A":"1px solid #D2D3D8",backgroundColor:e?"#292A2F":"#FFFFFF",borderRadius:"8px",overflow:"hidden",boxShadow:"0 8px 28px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete ul li[aria-selected]":{backgroundColor:e?"#315A85":"#DCEBFA",color:n.foreground},".cm-panels":{backgroundColor:n.gutter,color:n.foreground},".cm-searchMatch":{backgroundColor:e?"#725C1D":"#FFE69A"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e?"#8D6D20":"#FFD45C"}},{dark:e})}const CS=Xn.define([{tag:[O.keyword,O.controlKeyword,O.moduleKeyword,O.operatorKeyword,O.bool,O.null],color:"#FF7AB2"},{tag:[O.string,O.special(O.string)],color:"#FF8170"},{tag:[O.number,O.regexp],color:"#D9C97C"},{tag:[O.comment,O.lineComment,O.blockComment],color:"#7F8C98",fontStyle:"italic"},{tag:[O.tagName,O.typeName,O.className],color:"#5DD8FF"},{tag:O.attributeName,color:"#B281EB"},{tag:[O.propertyName,O.function(O.variableName),O.function(O.propertyName)],color:"#67B7A4"},{tag:O.definition(O.variableName),color:"#4EB0CC"},{tag:[O.variableName,O.operator,O.punctuation,O.bracket],color:"#E8E8ED"},{tag:O.invalid,color:"#FF453A"}]);function Ud(n){const e=n==="dark";return[PS(e?ch.dark:ch.light,e),JO(e?CS:i0)]}const TS=Xt.parser.configure({dialect:"jsx"}),RS=new Map(Object.keys($e.components).map(n=>[n.toLowerCase(),n])),$S=new Set(["VStack","HStack","ZStack","VGrid","HGrid"]),KS=512*1024,ZS=512,MS=32,ci=n=>{const e=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t);return e},hi=(n,e)=>n.slice(e.from,e.to),de=n=>{throw new Error(n)},Fd=n=>{let e=!0;const t=n.replace(/&([^;\s]+);/g,(i,s)=>{const r={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};if(Object.hasOwn(r,s))return r[s];if(/^#(?:[0-9]+|x[0-9a-f]+)$/i.test(s)){const o=s[1].toLowerCase()==="x"?parseInt(s.slice(2),16):Number(s.slice(1));if(o>0&&o<=1114111&&!(o>=55296&&o<=57343))return String.fromCodePoint(o)}return e=!1,i});return e?t:void 0};function co(n,e=!1){if(e)return Fd(n.slice(1,-1));const t=n.trim();if(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(t)){const i=Number(t);return Number.isFinite(i)?i:void 0}if(t==="true"||t==="false")return t==="true";if(t.startsWith('"'))try{const i=JSON.parse(t);return typeof i=="string"?i:void 0}catch{}}function vi(n){const e={formatVersion:1,source:n,nodes:[],roots:[],issue:""};if(typeof n!="string"||new TextEncoder().encode(n).length>KS)return{...e,issue:"Layout editing supports source files up to 512 KiB."};const t=TS.parse(n);let i=!1;if(t.iterate({enter:r=>{r.type.isError&&(i=!0)}}),i)return{...e,issue:"Fix the JavaScript/JSX syntax before using Layout. Your source is preserved."};function s(r,o,a){(a>MS||e.nodes.length>=ZS)&&de("Layout editing supports up to 512 layers and 32 nesting levels.");const l=ci(r),c=l[0],h=l.at(-1),u=ci(c).find(S=>["JSXBuiltin","JSXIdentifier","JSXNamespacedName","JSXMemberExpression"].includes(S.name)),f=u?hi(n,u):"Fragment",d=RS.get(f.toLowerCase()),p=$e.components[d],m={...$e.globalProperties,...p?.properties??{}},g=c.name==="JSXOpenTag"&&h?.name==="JSXCloseTag",y=g?ci(h).find(S=>["JSXBuiltin","JSXIdentifier","JSXNamespacedName","JSXMemberExpression"].includes(S.name)):null;u&&g&&(!y||hi(n,y)!==f)&&de("Opening and closing JSX tags must match before using Layout.");const b={id:String(r.from),parentID:o,tag:f,component:d??null,from:r.from,to:r.to,openingEnd:c.to,insertAt:c.to-(g?1:2),contentFrom:c.to,contentTo:g?h.from:c.to,children:[],properties:[],locked:!p,structure:!1,text:null,textEditable:!1,depth:a};let x=!1;for(const S of ci(c)){if(S.name==="JSXSpreadAttribute"&&(x=!0),S.name!=="JSXAttribute")continue;const w=ci(S),U=hi(n,w[0]),F=w[2],V=F?co(hi(n,F),F.name==="JSXAttributeValue"):!0,E=F?.name==="JSXEscape"?co(n.slice(F.from+1,F.to-1)):V,M=Object.hasOwn(m,U)?m[U]:null;b.properties.push({name:U,value:E??null,from:S.from,to:S.to,editable:!!(p&&M&&M.type!=="function"&&E!==void 0),definition:M??null})}const C=new Set(b.properties.map(S=>S.name)).size!==b.properties.length;b.locked||=x||C,b.reason=x?"Spread properties are preserved; edit this element in Code.":C?"Duplicate properties are preserved; resolve them in Code.":p?"":"Custom components and fragments are preserved; edit them in Code.",b.locked&&b.properties.forEach(S=>{S.editable=!1}),e.nodes.push(b);const k=g?l.slice(1,-1):[];for(const S of k)S.name==="JSXElement"&&b.children.push(s(S,b.id,a+1).id);if(b.structure=!b.locked&&g&&$S.has(d)&&k.every(S=>S.name==="JSXElement"||S.name==="JSXText"&&!hi(n,S).trim())&&b.children.every(S=>!e.nodes.find(w=>w.id===S).locked),!b.locked&&d==="Text"&&g&&k.length===1){const S=k[0],w=hi(n,S),U=S.name==="JSXText"&&!/[\r\n]/.test(w)?Fd(w):S.name==="JSXEscape"?co(w.slice(1,-1)):void 0;typeof U=="string"&&(b.text=U,b.textEditable=!0)}return b}try{t.iterate({enter(r){if(r.name!=="CallExpression")return;const o=ci(r.node);if(o[0]?.name!=="VariableName"||hi(n,o[0])!=="$render"||o[1]?.name!=="ArgList")return;const a=ci(o[1]).filter(l=>!["(",")"].includes(l.name));if(a.length===1&&a[0].name==="JSXElement")return e.roots.push(s(a[0],null,0).id),!1}})}catch(r){return{...e,nodes:[],roots:[],issue:r.message}}return e.roots.length||(e.issue="Layout needs a direct $render(…) or another native JSX element. Variables, loops and functions stay editable in Code."),e}function ha(n){return!n?.component||n.locked?{}:{...$e.globalProperties,...$e.components[n.component]?.properties??{}}}function ES(n,e,t){(n.source!==e||n.issue)&&de("Layout changed. Select the layer again before editing.");const i=n.nodes.find(l=>l.id===t.id);(!i||i.locked)&&de("This layer is locked. Edit its source in Code.");let s=[],r=i.from;if(t.type==="property"){const l=ha(i),c=Object.hasOwn(l,t.name)?l[t.name]:null,h=i.properties.find(d=>d.name===t.name);(!c||c.type==="function"||h&&!h.editable)&&de("Dynamic or unsupported properties must be edited in Code.");const u=new Set(i.properties.map(d=>d.name)),f=$e.components[i.component];if(t.remove?(f.requiredAny?.includes(t.name)&&!f.requiredAny.some(d=>d!==t.name&&u.has(d))&&de("Keep at least one required component property."),Object.entries(f.properties??{}).some(([d,p])=>u.has(d)&&p.requires?.includes(t.name))&&de("Another property requires this value. Edit the dependent properties together in Code.")):(c.requires?.some(d=>!u.has(d))&&de("Add the required related properties together in Code."),(c.conflicts?.some(d=>u.has(d))||Object.entries(f.properties??{}).some(([d,p])=>d!==t.name&&u.has(d)&&p.conflicts?.includes(t.name)))&&de("This property conflicts with another component property.")),t.remove)(!h||c.required)&&de("This property cannot be removed."),s=[{from:h.from,to:h.to,insert:""}];else{const d=t.value;(!["string","number","boolean"].includes(typeof d)||typeof d=="number"&&!Number.isFinite(d)||typeof d=="string"&&d.length>8192)&&de("Use a bounded string, finite number or Boolean."),c.values&&!c.values.includes(d)&&de("Choose one of the supported property values."),c.type==="boolean"&&typeof d!="boolean"&&de("This property needs true or false."),c.type==="number"&&!(typeof d=="number"||typeof d=="string"&&d.trim()&&Number.isFinite(Number(d)))&&de("This property needs a number."),typeof d=="boolean"&&c.type!=="boolean"&&de("This property does not accept a Boolean."),typeof d=="number"&&!c.type.includes("number")&&de("This property needs a string value."),t.name==="opacity"&&!(Number(d)>=0&&Number(d)<=1)&&de("Opacity must be between zero and one.");const p=`${t.name}={${JSON.stringify(d)}}`;s=h?[{from:h.from,to:h.to,insert:p}]:[{from:i.insertAt,to:i.insertAt,insert:` ${p}`}]}}else if(t.type==="text")(!i.textEditable||typeof t.value!="string"||t.value.length>8192)&&de("Dynamic text is preserved. Edit it in Code."),s=[{from:i.contentFrom,to:i.contentTo,insert:`{${JSON.stringify(t.value)}}`}];else if(t.type==="move"||t.type==="remove")if(n.nodes.find(c=>c.id===i.parentID)?.structure||de("Only literal children of a supported stack/grid can be moved or removed."),t.type==="remove")s=[{from:i.from,to:i.to,insert:""}];else{const c=n.nodes.find(p=>p.id===t.parentID);(!c?.structure||c.from>=i.from&&c.to<=i.to)&&de("Choose a supported container outside this layer.");const h=p=>{for(;p.parentID!==null;)p=n.nodes.find(m=>m.id===p.parentID);return p.id};h(i)!==h(c)&&de("Layers cannot move between render branches or JavaScript scopes.");const u=c.children.filter(p=>p!==i.id),f=t.index;(!Number.isInteger(f)||f<0||f>u.length)&&de("Invalid layer position.");const d=f===u.length?c.contentTo:n.nodes.find(p=>p.id===u[f]).from;if(d===i.from||d===i.to)return{changes:[],selectedFrom:r};s=[{from:i.from,to:i.to,insert:""},{from:d,to:d,insert:e.slice(i.from,i.to)}],r=d-(d>i.to?i.to-i.from:0)}else if(t.type==="add"){i.structure||de("Choose a supported container with literal JSX children.");const l={text:'New text',spacer:"",stack:'',icon:''};Object.hasOwn(l,t.kind)||de("Unsupported new layer."),s=[{from:i.contentTo,to:i.contentTo,insert:l[t.kind]}],r=i.contentTo}else de("Unsupported layout operation.");s.sort((l,c)=>l.from-c.from);let o=e;for(const l of[...s].reverse())o=o.slice(0,l.from)+l.insert+o.slice(l.to);return vi(o).issue&&de("This edit would leave the supported layout. Your source was not changed."),{changes:s,selectedFrom:r}}const Dd=Xt.parser.configure({dialect:"jsx"}),Ci=n=>{const e=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t);return e},Qe=n=>{throw new Error(n)},Hi=Object.freeze({background:{type:"color"},surface:{type:"color"},foreground:{type:"color"},muted:{type:"color"},accent:{type:"color"},titleFont:{values:$e.globalProperties.font.values},bodyFont:{values:$e.globalProperties.font.values},fontDesign:{values:$e.globalProperties.fontDesign.values},corner:{type:"number",maximum:48},padding:{type:"number",maximum:48},spacing:{type:"number",maximum:32}}),ms={titleFont:"headline",bodyFont:"caption",fontDesign:"rounded",corner:20,padding:16,spacing:10},sr=Object.freeze({Meadow:Object.freeze({...ms,background:"#F2FAF5",surface:"#FFFFFF",foreground:"#193F31",muted:"#607C70",accent:"#328963"}),Paper:Object.freeze({...ms,background:"#F4F7FD",surface:"#FFFFFF",foreground:"#243454",muted:"#687795",accent:"#4777D6"}),Peach:Object.freeze({...ms,background:"#FFF5EE",surface:"#FFFFFF",foreground:"#56392C",muted:"#967461",accent:"#C86B43"}),Midnight:Object.freeze({...ms,background:"#192332",surface:"#283548",foreground:"#F1F5FC",muted:"#AABAD0",accent:"#8EB7FF"})});function Ld(n,e){Object.hasOwn(Hi,n)||Qe("Unknown theme token.");const t=Hi[n];t.type==="color"&&!(typeof e=="string"&&/^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/i.test(e))&&Qe(`${n} needs a six or eight digit hex color.`),t.values&&!t.values.includes(e)&&Qe(`${n} needs a supported font value.`),t.type==="number"&&!(typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=t.maximum)&&Qe(`${n} needs a number from zero to ${t.maximum}.`)}function el(n){(!n||typeof n!="object"||Array.isArray(n)||Object.keys(n).length!==Object.keys(Hi).length)&&Qe("A theme needs exactly the documented tokens.");for(const e of Object.keys(n))Ld(e,n[e]);return n}function Xd(n){(typeof n!="string"||new TextEncoder().encode(n).length>4096)&&Qe("Theme JSON is limited to 4 KiB.");const e=JSON.parse(n);return(!e||Array.isArray(e)||Object.keys(e).sort().join()!=="formatVersion,name,tokens"||e.formatVersion!==1||typeof e.name!="string"||!e.name.trim()||/[\u0000-\u001f]/.test(e.name)||new TextEncoder().encode(e.name).length>64)&&Qe("Use a version 1 theme with a name of at most 64 bytes."),el(e.tokens),e}function US(n,e="My theme"){const t=JSON.stringify({formatVersion:1,name:e,tokens:n},null,2);return Xd(t),t}function rr(n){const e={source:n,tokens:null,ranges:{},issue:"",canInitialize:!1};try{(typeof n!="string"||new TextEncoder().encode(n).length>512*1024)&&Qe("Theme editing supports files up to 512 KiB.");const t=Dd.parse(n),i=[],s=[];if(t.iterate({enter(l){l.type.isError&&Qe("Fix JavaScript syntax before editing the theme."),["VariableDefinition","VariableName"].includes(l.name)&&n.slice(l.from,l.to).includes("\\")&&Qe("Escaped identifiers stay in Code."),n.slice(l.from,l.to)==="widgetTheme"&&["VariableDefinition","VariableName"].includes(l.name)&&(l.name==="VariableDefinition"?i:s).push(l.node)}}),!i.length&&!s.length){const l=vi(n);e.canInitialize=!l.issue&&l.roots.length===1&&!l.nodes[0].locked;let c=!1;for(const h of Ci(t.topNode)){const u=h.firstChild;l.nodes[0]&&h.name==="ExpressionStatement"&&u?.name==="CallExpression"&&n.slice(u.firstChild.from,u.firstChild.to)==="$render"&&u.froml.nodes[0].to&&(c=!0)}return e.canInitialize&&=c,e}i.length!==1&&Qe("Keep one top-level const widgetTheme object. Other bindings stay in Code.");const r=i[0].parent,o=Ci(r);(r.name!=="VariableDeclaration"||r.parent?.name!=="Script"||o[0]?.name!=="const"||o[1]?.from!==i[0].from||o[2]?.name!=="Equals"||o[3]?.name!=="ObjectExpression"||o.slice(4).some(l=>l.name!==";"))&&Qe("Theme editing needs a single top-level const widgetTheme = { … } declaration.");const a={};for(const l of Ci(o[3])){if(["{","}",","].includes(l.name))continue;const c=Ci(l),h=c[0]?n.slice(c[0].from,c[0].to):"",u=c[0]?.name==="String"&&h.startsWith('"')?JSON.parse(h):h;(l.name!=="Property"||c.length!==3||!["PropertyDefinition","String"].includes(c[0].name)||c[1].name!==":"||!["String","Number"].includes(c[2].name)||Object.hasOwn(a,u))&&Qe("Theme tokens must be unique literal properties. Computed or dynamic values stay in Code.");let f;try{f=JSON.parse(n.slice(c[2].from,c[2].to))}catch{Qe("Theme values use JSON strings or numbers. Edit this declaration in Code.")}Ld(u,f),a[u]=f,e.ranges[u]={from:c[2].from,to:c[2].to}}el(a);for(const l of s){const c=l.parent,h=Ci(c),u=h[2]?n.slice(h[2].from,h[2].to):"";(c.name!=="MemberExpression"||h[0].from!==l.from||h[1]?.name!=="."||h[2]?.name!=="PropertyName"||!Object.hasOwn(Hi,u))&&Qe("Theme references must read widgetTheme.token. Other uses stay in Code."),c.parent?.name==="MemberExpression"&&Qe("Mutable theme references stay in Code.");for(let f=c.parent;f;f=f.parent)(["UpdateExpression","PostfixExpression"].includes(f.name)||f.name==="UnaryExpression"&&/^(?:delete|\+\+|--)/.test(n.slice(f.from,c.from).trim())||f.name==="AssignmentExpression"&&f.firstChild.from<=c.from&&f.firstChild.to>=c.to||f.name==="ForOfSpec"||f.name==="ForInSpec")&&Qe("Mutable theme references stay in Code.")}e.tokens=a}catch(t){e.issue=t.message}return e}function ho(n,e,t){return(n.source!==e||n.issue||!n.tokens)&&Qe("Theme changed or is unsupported. Reopen Theme before editing."),el(t),{changes:Object.keys(Hi).filter(s=>t[s]!==n.tokens[s]).map(s=>({...n.ranges[s],insert:JSON.stringify(t[s])})).sort((s,r)=>s.from-r.from)}}function FS(n,e="Meadow"){(!rr(n).canInitialize||!Object.hasOwn(sr,e))&&Qe("Start with a literal top-level layout without an existing widgetTheme binding.");const i=vi(n),s=i.nodes[0],r=[];function o(c,h,u,f=!1){const d=c.properties.find(m=>m.name===h);if(c.locked||d&&!d.editable||!d&&!f)return;const p=`${h}={widgetTheme.${u}}`;r.push(d?{from:d.from,to:d.to,insert:p}:{from:c.insertAt,to:c.insertAt,insert:` ${p}`})}for(const c of["background","corner","padding"])o(s,c,c,!0);s.structure&&o(s,"spacing","spacing",!0);for(const c of i.nodes)if(c.component==="Text"){const h=c.properties.find(f=>f.name==="font")?.value,u=["headline","largeTitle","title","title2","title3"].includes(h);o(c,"font",u?"titleFont":"bodyFont",!0),o(c,"color",u?"foreground":"muted",!0),o(c,"fontDesign","fontDesign",!0)}else c.component==="Icon"&&o(c,"color","accent",!0);let a=0;for(const c of Ci(Dd.parse(n).topNode))if(!(c.name==="LineComment"||c.name==="BlockComment"))if(c.name==="ExpressionStatement"&&c.firstChild?.name==="String")a=c.to;else break;r.push({from:a,to:a,insert:` +const widgetTheme = ${JSON.stringify(sr[e],null,2)}; +`}),r.sort((c,h)=>c.from-h.from);let l=n;for(const c of[...r].reverse())l=l.slice(0,c.from)+c.insert+l.slice(c.to);return(!rr(l).tokens||vi(l).issue)&&Qe("This layout cannot be themed automatically. Your source was preserved."),{changes:r}}function Bd(n){if(!Array.isArray(n)||n.length>4096)return[];const e=new Map,t=new Set;for(const i of n){if(typeof i!="string"||new TextEncoder().encode(i).length>1024||/[\\\u0000-\u001f\u007f-\u009f]/.test(i))continue;const s=i.split("/");if(s.length!==2||s[0]!=="image"||!s[1]||new TextEncoder().encode(s[1]).length>255||s[1]!==s[1].trim()||s[1].includes("..")||!/\.(png|jpe?g|webp)$/i.test(s[1]))continue;const r=i.normalize("NFC").toLowerCase();e.has(r)&&e.get(r)!==i&&t.add(r),e.set(r,i)}return[...e].filter(([i])=>!t.has(i)).map(([,i])=>i).sort().slice(0,256)}const tl=z.define(),or=Te.define({create:()=>[],update(n,e){for(const t of e.effects)t.is(tl)&&(n=Bd(t.value));return n}});function il(n,e){n.state.field(or,!1)!==void 0&&n.dispatch({effects:tl.of(e)})}const Id=Object.freeze({bloom:Object.freeze({name:"Bloom mark",description:"A small four-petal flower",kind:"icon"}),leaf:Object.freeze({name:"Leaf mark",description:"A tilted leaf and stem",kind:"icon"}),pebble:Object.freeze({name:"Pebble friend",description:"A quiet, round-eared companion",kind:"pet"})}),uo=`/* +ScriptWidget original geometric assets 1: Bloom mark, Leaf mark, Pebble friend. +Source: https://github.com/everettjf/scriptwidget (Editor/editorfe/src/visualAssets.js) +SPDX-License-Identifier: MIT +Copyright (c) 2021-2022 everettjf + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +`;function DS(n,e){const t=i=>e?`{widgetTheme.${i}}`:JSON.stringify(sr.Meadow[i]);if(n==="bloom")return``;if(n==="leaf")return``;if(n==="pebble")return``;throw new Error("Choose an original asset from the catalog.")}function LS(n,e,{id:t,kind:i,path:s},r=[]){if(n.source!==e||n.issue)throw new Error("Layout changed. Select the container again.");const o=n.nodes.find(f=>f.id===t);if(!o?.structure)throw new Error("Select a stack/grid with literal JSX children in Layout or Assets.");let a;if(i==="photo"){if(!Bd(r).includes(s))throw new Error("This image is no longer in the package resource list. Refresh images.");a=``}else{if(!Object.hasOwn(Id,i))throw new Error("Choose an original asset from the catalog.");a=DS(i,!!rr(e).tokens)}const l=[{from:o.contentTo,to:o.contentTo,insert:a}];let c=o.contentTo;if(i!=="photo"&&!e.includes(uo)){const f=e.startsWith("#!")?e.indexOf(` +`)+1:0;l.push({from:f,to:f,insert:uo}),c+=uo.length}l.sort((f,d)=>f.from-d.from);let h=e;for(const f of[...l].reverse())h=h.slice(0,f.from)+f.insert+h.slice(f.to);if(vi(h).issue)throw new Error("This asset would exceed the supported layout limits. Your source was preserved.");return{changes:l,selectedFrom:c}}const XS=n=>["string","number","number|string","date|number","boolean","enum","color","url","action-id","storage-key"].includes(n.type);function X(n,e,t){const i=document.createElement(n);return e&&(i.className=e),t!==void 0&&(i.textContent=t),i}function BS(n,e){const t=X("section","sw-layout"),i=X("div","sw-layout-header"),s=X("div","sw-layout-body");t.setAttribute("aria-label","Visual layout editor");let r=!1,o="layout",a=null,l=null,c="",h=null,u=!1,f=0;const d=String(Math.random()),p=(Q,D)=>P=>{if(u||!t.contains(Q)){P.preventDefault();return}return D(P)},m=(Q,D,P)=>Q.addEventListener(D,p(Q,P)),g=(Q,D,P=!1)=>{const j=X("button","sw-layout-button",Q);return j.type="button",j.disabled=P,m(j,"click",D),j},y=g("Layout",()=>{r=o==="layout"?!r:!0,o="layout",Y(),n.requestMeasure()});y.classList.add("sw-layout-toggle"),y.setAttribute("aria-expanded","false");const b=X("span","sw-layout-hint","Select layers and edit literal JSX"),x=g("Undo",()=>La(n)),C=g("Redo",()=>zs(n)),k=g("Theme",()=>{r=o==="theme"?!r:!0,o="theme",Y(),n.requestMeasure()});k.setAttribute("aria-expanded","false");const S=g("Assets",()=>{r=o==="assets"?!r:!0,o="assets",Y(),n.requestMeasure()});S.setAttribute("aria-expanded","false"),i.append(y,k,S,b,x,C),t.append(i,s),s.hidden=x.hidden=C.hidden=!0;const w=X("p","sw-layout-error");w.setAttribute("role","alert"),w.hidden=!0,t.append(w);function U(){a=vi(n.state.doc.toString());const Q=X("div","sw-layout-inspector sw-theme-inspector");if(s.replaceChildren(Q),Q.append(X("div","sw-layout-title","Widget assets")),Q.append(X("p","sw-layout-notice","Insert editable original JSX or a package image. Originals follow connected theme colors; pet artwork is static. Import photos with the app's existing image tools or Web Studio's Add image.")),a.issue){Q.append(X("p","sw-layout-notice",a.issue));return}const D=a.nodes.filter(I=>I.structure),P=X("select");P.setAttribute("aria-label","Asset destination");for(const I of D){const H=X("option","",`${I.tag} · line ${n.state.doc.lineAt(I.from).number}`);H.value=I.id,P.append(H)}D.some(I=>I.id===l)?P.value=l:l=P.value,m(P,"change",()=>{l=P.value}),Q.append(P);const j=n.state.readOnly||!D.length;D.length||Q.append(X("p","sw-layout-notice","Add a stack/grid with literal JSX children in Code to insert assets."));function ae(I,H){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");const ce=LS(a,n.state.doc.toString(),{id:P.value,kind:I,path:H},n.state.field(or));l=P.value,w.hidden=!0,n.dispatch({changes:ce.changes,selection:{anchor:ce.selectedFrom},annotations:ws.of("full"),userEvent:"input.asset",scrollIntoView:!0})}catch(ce){w.textContent=ce.message,w.hidden=!1}}for(const[I,H]of Object.entries(Id)){const ce=X("div","sw-layout-actions");ce.append(g(`Insert ${H.name}`,()=>ae(I),j),X("span","",H.description)),Q.append(ce)}Q.append(X("div","sw-layout-title","Package images"));const J=n.state.field(or),ee=X("select");ee.setAttribute("aria-label","Package image");for(const I of J){const H=X("option","",I);H.value=I,ee.append(H)}ee.disabled=!J.length,Q.append(ee,g("Insert package image",()=>ae("photo",ee.value),j||!J.length)),J.length||Q.append(X("p","sw-layout-notice","No supported images in image/. Add a PNG, JPEG or WebP to the package, then refresh or reopen the editor.")),e.refreshResources&&Q.append(g("Refresh images",async()=>{const I=++f,H=n.state.doc,ce=()=>!u&&I===f&&n.state.doc===H;try{const q=await e.refreshResources();ce()&&(w.hidden=!0,il(n,q))}catch{ce()&&(w.textContent="Images could not be refreshed. Reopen this document and try again.",w.hidden=!1)}})),Q.append(X("p","sw-layout-notice","Bloom mark, Leaf mark and Pebble friend: original ScriptWidget geometry, MIT licensed. Package photos retain their own rights. See the Studio assets documentation."))}function F(Q,D){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");const P=n.state.doc.toString();if(P!==D)throw new Error("Source changed. Reopen Theme before editing.");const j=Q(P);w.hidden=!0,j.changes.length&&n.dispatch({changes:j.changes,annotations:ws.of("full"),userEvent:"input.theme"})}catch(P){w.textContent=P.message,w.hidden=!1}}function V(){const Q=n.state.doc.toString(),D=rr(Q),P=n.state.readOnly,j=X("div","sw-layout-inspector sw-theme-inspector");if(s.replaceChildren(j),j.append(X("div","sw-layout-title","Widget theme")),j.append(X("p","sw-layout-notice","Saved as ordinary JavaScript with your widget. Dynamic values stay in Code. Applying a theme changes the connected colors, fonts and spacing.")),D.issue){j.append(X("p","sw-layout-notice",D.issue));return}if(!D.tokens){j.append(g("Connect layout to Meadow theme",()=>F(ee=>FS(ee),Q),P||!D.canInitialize)),D.canInitialize||j.append(X("p","sw-layout-notice","Use a literal top-level $render layout, or define the documented widgetTheme object in Code."));return}const ae=X("div","sw-layout-actions");for(const[ee,I]of Object.entries(sr))ae.append(g(ee,()=>F(H=>ho(D,H,I),Q),P));j.append(ae);for(const[ee,I]of Object.entries(Hi)){const H=X("form","sw-layout-form"),ce=X("label","",ee),q=X(I.values?"select":"input");if(I.values)for(const re of I.values){const Me=X("option","",re);Me.value=re,q.append(Me)}I.type==="number"&&(q.type="number",q.min="0",q.max=String(I.maximum),q.step="any"),q.value=String(D.tokens[ee]),q.setAttribute("aria-label",`Theme ${ee}`),q.disabled=P;const te=g(`Apply ${ee}`,()=>{},P);te.type="submit",H.append(ce,q,te),m(H,"submit",re=>{re.preventDefault();const Me=I.type==="number"?q.value.trim()?Number(q.value):NaN:q.value;F(Oe=>ho(D,Oe,{...D.tokens,[ee]:Me}),Q)}),j.append(H)}const J=X("textarea");J.rows=5,J.setAttribute("aria-label","Reusable theme JSON"),J.value=US(D.tokens),j.append(X("label","","Copy this JSON to reuse a theme, or paste a version 1 theme and import it."),J,g("Import theme JSON",()=>F(ee=>ho(D,ee,Xd(J.value).tokens),Q),P))}function E(Q,D=a?.source){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");if(D!==n.state.doc.toString())throw new Error("Source changed during this operation. Select the layer again.");const P=ES(a,n.state.doc.toString(),Q);if(w.hidden=!0,!P.changes.length)return;n.dispatch({changes:P.changes,selection:{anchor:P.selectedFrom},annotations:ws.of("full"),userEvent:"input.layout",scrollIntoView:!0})}catch(P){w.textContent=P.message,w.hidden=!1}}function M(Q){u||(l=Q.id,c="",n.dispatch({selection:{anchor:Q.from,head:Q.to},scrollIntoView:!0,userEvent:"select.layout"}),Y())}function Y(){if(y.setAttribute("aria-expanded",String(r&&o==="layout")),k.setAttribute("aria-expanded",String(r&&o==="theme")),S.setAttribute("aria-expanded",String(r&&o==="assets")),s.hidden=!r,x.hidden=C.hidden=!r,b.hidden=r,x.disabled=n.state.readOnly||vc(n.state)===0,C.disabled=n.state.readOnly||wc(n.state)===0,!r)return;if(o==="assets"){U();return}if(o==="theme"){V();return}if(a=vi(n.state.doc.toString()),s.replaceChildren(),a.issue){s.append(X("p","sw-layout-notice",a.issue));return}const Q=n.state.selection.main.from,D=a.nodes.filter(q=>q.from<=Q&&Qq.id===l&&q.from<=Q&&Q<=q.to)??D??a.nodes[0];l=P.id;const j=X("div","sw-layout-layers");j.setAttribute("role","tree"),j.setAttribute("aria-label","Layout layers");const ae=n.state.readOnly,J=q=>{const te=q.text??q.properties.find(re=>re.name==="text"&&re.editable&&typeof re.value=="string")?.value;return`<${q.tag}>${te?` · ${te.slice(0,32)}`:""}${q.locked?" · locked":""}`};for(const[q,te]of a.nodes.entries()){const re=a.nodes.find(ie=>ie.id===te.parentID),Me=!ae&&!te.locked&&re?.structure,Oe=g(J(te),()=>M(te));Oe.classList.add("sw-layout-layer"),Oe.dataset.layerId=te.id,Oe.style.paddingInlineStart=`${8+te.depth*14}px`,Oe.setAttribute("role","treeitem"),Oe.setAttribute("aria-level",String(te.depth+1)),Oe.setAttribute("aria-selected",String(te.id===P.id)),Oe.tabIndex=te.id===P.id?0:-1,Oe.draggable=!!Me,m(Oe,"keydown",ie=>{let ve;ie.key==="ArrowUp"&&(ve=a.nodes[Math.max(0,q-1)]),ie.key==="ArrowDown"&&(ve=a.nodes[Math.min(a.nodes.length-1,q+1)]),ie.key==="ArrowLeft"&&(ve=re),ie.key==="ArrowRight"&&(ve=a.nodes.find(Ie=>Ie.id===te.children[0])),ie.key==="Home"&&(ve=a.nodes[0]),ie.key==="End"&&(ve=a.nodes.at(-1)),ve&&(ie.preventDefault(),ie.stopPropagation(),M(ve),ee().find(Ie=>Ie.dataset.layerId===ve.id)?.focus())}),m(Oe,"dragstart",ie=>{if(!Me){ie.preventDefault();return}h={id:te.id,source:a.source},ie.dataTransfer.setData("application/x-scriptwidget-layer",d),ie.dataTransfer.effectAllowed="move"}),m(Oe,"dragover",ie=>{h&&re?.structure&&te.id!==h.id&&(ie.preventDefault(),ie.dataTransfer.dropEffect="move")}),m(Oe,"drop",ie=>{if(!h||ie.dataTransfer.getData("application/x-scriptwidget-layer")!==d||!re?.structure)return;ie.preventDefault();const ve=h;h=null,E({type:"move",id:ve.id,parentID:re.id,index:re.children.filter(Ie=>Ie!==ve.id).indexOf(te.id)},ve.source)}),m(Oe,"dragend",()=>{h=null}),j.append(Oe)}function ee(){return[...t.querySelectorAll(".sw-layout-layer")]}const I=X("div","sw-layout-inspector"),H=X("div","sw-layout-title",`<${P.tag}>`);if(I.append(H),(ae||P.locked)&&I.append(X("p","sw-layout-notice",ae?"This document is read only.":P.reason)),!ae&&!P.locked){let Oe=function(){c=re.value;const oe=ha(P)[c],Ae=P.properties.find(tt=>tt.name===c);if(Me.replaceChildren(),te.onsubmit=tt=>tt.preventDefault(),Ae&&!Ae.editable){Me.append(X("span","sw-layout-notice","Dynamic value: edit it in Code. Connected widgetTheme tokens can be changed in Theme."));return}const le=X(oe.values||oe.type==="boolean"?"select":"input");le.setAttribute("aria-label","Layout property value");for(const tt of oe.values??(oe.type==="boolean"?[!0,!1]:[])){const ai=X("option","",String(tt));ai.value=String(tt),le.append(ai)}le.value=Ae?String(Ae.value):oe.values?.[0]??(oe.type==="boolean"?"true":"");const qe=g("Apply",()=>{});qe.type="submit",Me.append(le,qe,g("Remove",()=>E({type:"property",id:P.id,name:c,remove:!0}),!Ae||oe.required)),te.onsubmit=p(te,tt=>{tt.preventDefault();const ai=oe.type==="boolean"?le.value==="true":oe.type==="number"?le.value.trim()?Number(le.value):NaN:le.value;E({type:"property",id:P.id,name:c,value:ai})})};if(P.textEditable){const oe=X("form","sw-layout-form"),Ae=X("label","","Text"),le=X("input");le.value=P.text,le.setAttribute("aria-label","Layer text");const qe=g("Apply text",()=>{});qe.type="submit",oe.append(Ae,le,qe),m(oe,"submit",tt=>{tt.preventDefault(),E({type:"text",id:P.id,value:le.value})}),I.append(oe)}const q=Object.entries(ha(P)).filter(([,oe])=>XS(oe)),te=X("form","sw-layout-form"),re=X("select");re.setAttribute("aria-label","Layout property");for(const[oe]of q){const Ae=X("option","",oe);Ae.value=oe,re.append(Ae)}q.some(([oe])=>oe===c)||(c=P.structure?"alignment":"color"),re.value=c,re.value||(re.selectedIndex=0,c=re.value);const Me=X("div","sw-layout-property");te.append(re,Me),m(re,"change",Oe),Oe(),I.append(te);const ie=a.nodes.find(oe=>oe.id===P.parentID),ve=ie?.children.indexOf(P.id)??-1,Ie=X("div","sw-layout-actions");if(Ie.append(g("Move up",()=>E({type:"move",id:P.id,parentID:ie.id,index:ve-1}),!ie?.structure||ve<=0),g("Move down",()=>E({type:"move",id:P.id,parentID:ie.id,index:ve+1}),!ie?.structure||ve>=ie.children.length-1),g("Delete layer",()=>E({type:"remove",id:P.id}),!ie?.structure)),I.append(Ie),ie?.structure){const oe=a.nodes.filter(le=>le.structure&&!(le.from>=P.from&&le.to<=P.to)),Ae=X("select");Ae.setAttribute("aria-label","Move layer into container");for(const le of oe){const qe=X("option","",`${le.tag} · line ${n.state.doc.lineAt(le.from).number}`);qe.value=le.id,Ae.append(qe)}I.append(Ae,g("Move inside",()=>{const le=a.nodes.find(qe=>qe.id===Ae.value);E({type:"move",id:P.id,parentID:le.id,index:le.children.filter(qe=>qe!==P.id).length})},!oe.length))}if(P.structure){const oe=X("div","sw-layout-actions");for(const[Ae,le]of[["text","Add text"],["stack","Add stack"],["spacer","Add spacer"],["icon","Add icon"]])oe.append(g(le,()=>E({type:"add",id:P.id,kind:Ae})));I.append(oe)}}const ce=P.properties.filter(q=>!q.editable).map(q=>q.name);ce.length&&I.append(X("p","sw-layout-notice",`Preserved in Code: ${ce.join(", ")}`)),!P.structure&&P.children.length&&I.append(X("p","sw-layout-notice","This child structure stays in Code. Reordering is available on literal stack/grid children.")),s.append(j,I)}return{dom:t,top:!0,update(Q){if(!r)return;const D=n.state.selection.main.from,P=a?.nodes.filter(ae=>ae.from<=D&&Dae.effects.some(J=>J.is(tl)));(Q.docChanged||j||Q.startState.readOnly!==n.state.readOnly||Q.selectionSet&&P!==l)&&(Q.docChanged&&o!=="assets"&&(l=null),Y()),x.disabled=n.state.readOnly||vc(n.state)===0,C.disabled=n.state.readOnly||wc(n.state)===0},destroy(){u=!0}}}const IS=$.baseTheme({".sw-layout":{fontFamily:"system-ui, sans-serif",fontSize:"12px",backgroundColor:"#f6f7fa",color:"#272a34",borderBottom:"1px solid #dce0e9"},"&dark .sw-layout":{backgroundColor:"#252830",color:"#eceef5",borderColor:"#414552"},".sw-layout-header":{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"8px",padding:"6px 10px"},".sw-layout-toggle":{fontWeight:"600"},".sw-layout-hint":{opacity:"0.65",fontSize:"11px"},".sw-layout-button":{fontFamily:"inherit",fontSize:"11px",color:"inherit",backgroundColor:"transparent",border:"1px solid #a0a5b655",borderRadius:"6px",padding:"4px 8px",cursor:"pointer",whiteSpace:"nowrap"},".sw-layout-button:disabled":{opacity:"0.4",cursor:"default"},".sw-layout-body":{display:"grid",gridTemplateColumns:"minmax(120px, 1fr) minmax(180px, 1.6fr)",maxHeight:"280px",overflow:"auto",borderTop:"1px solid #a0a5b633"},".sw-layout-body[hidden]":{display:"none"},".sw-layout-layers":{padding:"6px 2px",overflow:"auto",borderRight:"1px solid #a0a5b633"},".sw-layout-layer":{display:"block",border:0,borderRadius:"4px",width:"100%",textAlign:"left",overflow:"hidden",textOverflow:"ellipsis",margin:"1px 0",paddingBlock:"6px"},'.sw-layout-layer[aria-selected="true"]':{backgroundColor:"#4085f52b",color:"inherit"},".sw-layout-inspector":{padding:"8px 10px",display:"flex",alignItems:"start",flexDirection:"column",gap:"8px",minWidth:0},".sw-theme-inspector":{gridColumn:"1 / -1"},".sw-theme-inspector textarea":{boxSizing:"border-box",width:"100%",fontFamily:"monospace",backgroundColor:"transparent",color:"inherit",border:"1px solid #a0a5b666",borderRadius:"5px"},".sw-layout-title":{fontWeight:"600"},".sw-layout-form":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"5px",width:"100%"},".sw-layout-property,.sw-layout-actions":{display:"flex",flexWrap:"wrap",gap:"5px",alignItems:"center"},".sw-layout input,.sw-layout select":{fontFamily:"inherit",fontSize:"12px",minWidth:0,maxWidth:"100%",padding:"4px 6px",border:"1px solid #a0a5b666",borderRadius:"5px",backgroundColor:"transparent",color:"inherit"},".sw-layout-notice":{margin:"8px",lineHeight:"1.5",fontSize:"11px",opacity:"0.7"},".sw-layout-body > .sw-layout-notice":{gridColumn:"1 / -1"},".sw-layout-error":{margin:"0 10px 6px",color:"#b32636",fontSize:"12px"},"&dark .sw-layout-error":{color:"#ff99a4"},".sw-layout button:focus-visible,.sw-layout input:focus-visible,.sw-layout select:focus-visible":{outline:"2px solid #4085f5",outlineOffset:"1px"},"@media (max-width: 480px)":{".sw-layout-body":{gridTemplateColumns:"minmax(90px, 1fr) minmax(150px, 1.6fr)"},".sw-layout-hint":{display:"none"}}});function qS(n={}){return[IS,or,Vi.of(e=>BS(e,n))]}const qd="scriptwidget.studio.document-state.v1.";function Wd(n,e,t){if(!n||!e)return!1;try{return n.setItem(`${qd}${e}`,JSON.stringify({anchor:Number(t.anchor)||0,head:Number(t.head)||0,scrollTop:Number(t.scrollTop)||0})),!0}catch{return!1}}function WS(n,e,t){if(!n||!e)return null;try{const i=JSON.parse(n.getItem(`${qd}${e}`));if(!i||typeof i!="object")return null;const s=r=>Math.max(0,Math.min(Number(r)||0,t));return{anchor:s(i.anchor),head:s(i.head),scrollTop:Math.max(0,Number(i.scrollTop)||0)}}catch{return null}}const zS="scriptwidget.web-studio.draft.v1:";function nl(n){return`${zS}${n}`}function VS(n,e){if(!e)return null;try{const t=JSON.parse(n.getItem(nl(e))||"null");return t&&typeof t.content=="string"&&typeof t.baseRevision=="string"?t:null}catch{return null}}function hh(n,e,t,i,s=Date.now()){if(!e||typeof i!="string")return null;const r={documentID:e,content:t,baseRevision:i,updatedAt:s};return n.setItem(nl(e),JSON.stringify(r)),r}function fo(n,e){e&&n.removeItem(nl(e))}function jS(n,e,t,i){const s=VS(n,e);return!s||s.content===t?null:{...s,serverContent:t,serverRevision:i,isStale:s.baseRevision!==i}}function YS(){return{connection:"connecting",save:"idle",preview:"idle",conflict:null}}function NS(n,e){switch(e.type){case"CONNECTED":return{...n,connection:"connected"};case"OFFLINE":return{...n,connection:"offline",save:n.save==="saving"?"draft":n.save};case"DISCONNECTED":return{...n,connection:"disconnected"};case"EDITED":return{...n,save:"draft",conflict:null};case"SAVING":return{...n,save:"saving"};case"SAVED":return{...n,save:"saved",preview:e.preview||"requested",conflict:null};case"SAVE_FAILED":return{...n,save:"error"};case"CONFLICT":return{...n,save:"conflict",conflict:e.conflict};default:return n}}class HS{constructor(e){this.send=e,this.epoch=0,this.context=null,this.inFlight=null,this.needsFlush=!1}open({documentID:e,packageID:t,path:i,revision:s,content:r}){return this.epoch+=1,this.context={documentID:e,packageID:t,path:i,revision:s,content:r,generation:0,savedGeneration:0},this.needsFlush=!1,this.snapshot()}edit(e){return this.context?(this.context.content=e,this.context.generation+=1,this.snapshot()):null}rebase(e){return this.context&&(this.context.revision=e),this.snapshot()}get isDirty(){return!!(this.context&&this.context.generation!==this.context.savedGeneration)}snapshot(){return this.context?{...this.context,dirty:this.isDirty}:null}async flush(){if(!this.context||!this.isDirty)return{skipped:!0,snapshot:this.snapshot()};if(this.inFlight)return this.needsFlush=!0,this.inFlight.then(()=>this.isDirty?this.flush():{skipped:!0,snapshot:this.snapshot()});const e=this.epoch,t={...this.context};this.needsFlush=!1,this.inFlight=this.send({documentID:t.documentID,packageID:t.packageID,path:t.path,content:t.content,baseRevision:t.revision}).then(s=>this.epoch!==e||this.context?.documentID!==t.documentID?{ignored:!0,result:s,snapshot:this.snapshot()}:(this.context.revision=s.revision,this.context.savedGeneration=t.generation,{result:s,snapshot:this.snapshot()})).finally(()=>{this.inFlight=null});const i=await this.inFlight;return this.needsFlush&&this.isDirty?this.flush():i}}function uh(n){return["draft","saving","error","conflict"].includes(n)}class GS extends Error{constructor(e,t,i={}){super(e),this.name="StudioAPIError",this.status=t,this.body=i}}class _S{constructor({fetchImpl:e=globalThis.fetch,token:t=()=>"",onUnauthorized:i=()=>{}}={}){if(typeof e!="function")throw new TypeError("A fetch implementation is required");this.fetchImpl=e,this.token=t,this.onUnauthorized=i}async request(e,t={}){const i=await this.fetchImpl(e,this.authorizedOptions(t)),s=await i.json().catch(()=>({}));return this.validate(i,e,s),s}async requestBlob(e,t={}){const i=await this.fetchImpl(e,this.authorizedOptions(t));if(!i.ok){const s=await i.json().catch(()=>({}));this.validate(i,e,s)}return i.blob()}authorizedOptions(e){return{...e,headers:{"Content-Type":"application/json","X-Studio-Token":this.token(),...e.headers||{}}}}validate(e,t,i){if(!e.ok){const s=new GS(i.message||`Request failed (${e.status})`,e.status,i);throw e.status===401&&t!=="/api/v1/pair"&&this.onUnauthorized(s),s}}}const sl=/^https?:$/.test(window.location.protocol),JS=document.querySelector(sl?"#editor":"#native-editor"),rl=new Gi,ar=new Gi;let qt=null,me=null,Et=null,at=0,wi=0,ua=!1,Mn=null,fh=null;const dh=document.querySelector("#save-status");let zd=null;function En(n,e="idle"){dh.textContent=n,dh.dataset.state=e}function e1(){window.clearTimeout(fh),fh=window.setTimeout(()=>{const n=W.state.selection.main;Wd(window.localStorage,me,{anchor:n.anchor,head:n.head,scrollTop:W.scrollDOM.scrollTop})},180)}function Vd(){return window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"}function ol(){window.clearTimeout(Mn),En("Saving…","saving"),Mn=window.setTimeout(()=>{const n=W.state.doc.toString(),e=at,t=me,i=Et,s=wi;nn(qt,Ue.documentSave,{content:n,version:e},t,(r={})=>{sl||t!==me||i!==Et||s!==wi||e!==at||En(r.result==="ok"||r.result==="unavailable"?"Saved":"Save failed",r.result==="failed"?"error":"saved")},i)},700)}function t1(n){if((n.selectionSet||n.viewportChanged||n.docChanged)&&e1(),!n.docChanged||ua)return;at+=1,zd?.documentChanged();const e=[];n.changes.iterChanges((t,i,s,r,o)=>{e.push({from:t,to:i,insert:o.toString(),newFrom:s,newTo:r})}),nn(qt,Ue.documentChanged,{changes:e,version:at},me,void 0,Et),ol()}const jd=[nO(),oO(),xg(),w0(),qS({refreshResources:()=>new Promise((n,e)=>{const t=me,i=wi,s=Et,r=window.setTimeout(()=>e(new Error("Resource refresh timed out")),5e3);nn(qt,Ue.documentResources,{},t,(o={})=>{window.clearTimeout(r),t!==me||i!==wi||o.result!=="ok"||o.documentID!==t||!Array.isArray(o.resources)?e(new Error("Document resources are unavailable")):n(o.resources)},s)})}),HO(),hg(),gg(),_.allowMultipleSelections.of(!0),UO(),c0(),uA(),xA({override:[kS],activateOnTyping:!0}),Mg(),Fg(),Cg(),Qb(),fS(),iS(Ed,{delay:350}),Eu(QS),yb({jsx:!0}),mr.of([Py,...mA,...Qy,...jb,...Z0,...VO,...nd]),rl.of(_.readOnly.of(!1)),ar.of(Ud(Vd())),$.updateListener.of(t1),$.contentAttributes.of({autocapitalize:"off",autocomplete:"off",spellcheck:"false"})],W=new $({state:_.create({doc:"",extensions:jd}),parent:JS});function _t(n,e=me,t=0,i=!1){window.clearTimeout(Mn),wi+=1;const s=W.state.selection.main;Wd(window.localStorage,me,{anchor:s.anchor,head:s.head,scrollTop:W.scrollDOM.scrollTop}),ua=!0;const r=e!==me;me=e,at=t;const o=WS(window.localStorage,me,(n??"").length),a=o?{anchor:o.anchor,head:o.head}:{anchor:0};if(r){const l=ar.get(W.state),c=W.state.readOnly;let h=_.create({doc:n??"",extensions:jd,selection:a});h=h.update({effects:[ar.reconfigure(l),rl.reconfigure(_.readOnly.of(c))]}).state,W.setState(h)}else W.dispatch({changes:{from:0,to:W.state.doc.length,insert:n??""},selection:a,scrollIntoView:!0});o&&window.requestAnimationFrame(()=>{W.scrollDOM.scrollTop=o.scrollTop}),ua=!1,i&&nn(qt,Ue.documentChanged,{content:W.state.doc.toString(),version:at},me,void 0,Et),En("Saved","saved")}function ph(n){if(W.state.readOnly)return!1;const e=W.state.selection.main;return W.dispatch({changes:{from:e.from,to:e.to,insert:n},selection:{anchor:e.from+n.length},userEvent:"input"}),W.focus(),!0}async function lr(){if(W.state.readOnly)return!1;const n=W.state.doc.toString(),e=wi,t=at,i=()=>!W.state.readOnly&&e===wi&&t===at&&n===W.state.doc.toString();try{const[{format:s},{default:r},{default:o}]=await Promise.all([Cr(()=>import("./standalone-Cayz_KD-.js"),[],import.meta.url),Cr(()=>import("./babel-BktJt1uC.js"),[],import.meta.url),Cr(()=>import("./estree-DFfjoHvx.js"),[],import.meta.url)]),a=await s(n,{parser:"babel",plugins:[r,o],semi:!0,singleQuote:!0,trailingComma:"es5"});return i()?(_t(a,me,at+1,!0),ol(),!0):!1}catch(s){return i()&&nn(qt,"diagnostics.publish",{message:String(s),severity:"error"},me,void 0,Et),!1}}function Xi(n){W.dispatch({effects:rl.reconfigure(_.readOnly.of(!!n))})}function cr(n){const e=n==="dark"||n==="light"?n:Vd();document.documentElement.dataset.theme=e,W.dispatch({effects:ar.reconfigure(Ud(e))})}function i1(n=[]){const e=n.map(t=>({from:Math.max(0,Math.min(t.from??0,W.state.doc.length)),to:Math.max(0,Math.min(t.to??t.from??0,W.state.doc.length)),severity:t.severity??"error",message:t.message??"Unknown error"}));W.dispatch(vd(W.state,e))}function rt(n,e){qt.registerHandler(n,async(t={},i=()=>{})=>{try{if(Et!==null&&n!==Ue.documentOpen&&n!==Ue.editorSetTheme&&(t.documentID!==me||t.sessionID!==Et))throw new Error("The editor session changed.");i({result:"ok",...await e(t)})}catch(s){i({result:"failed",message:String(s)})}})}pS(n=>{qt=n,rt(Ue.documentOpen,({payload:e={},documentID:t,sessionID:i=null})=>(Et=i,_t(e.content,t,e.version??0),il(W,e.resources??[]),Xi(e.readOnly),e.dirty&&(En("Restored unsaved edits","editing"),e.readOnly||ol()),{protocolVersion:Zd})),rt(Ue.documentReplace,({payload:e={},documentID:t})=>{if(W.state.readOnly||e.expectedContent!==void 0&&e.expectedContent!==W.state.doc.toString())throw new Error("The file changed or is read only.");return _t(e.content,t,e.version??at,!0),{}}),rt(Ue.documentSetReadOnly,({payload:e={}})=>(Xi(e.readOnly),{readOnly:!!e.readOnly})),rt(Ue.editorInsert,({payload:e={}})=>({inserted:ph(e.content??"")})),rt(Ue.editorFormat,async()=>({formatted:await lr()})),rt(Ue.editorSetTheme,({payload:e={}})=>(cr(e.theme),{})),rt(Ue.editorGetState,()=>({content:W.state.doc.toString(),version:at,documentID:me,sessionID:Et,selection:{from:W.state.selection.main.from,to:W.state.selection.main.to}})),rt(Ue.diagnosticsPublish,({payload:e={}})=>(i1(e.items),{})),rt("editor_setValue",({value:e})=>(_t(e),{})),rt("editor_insertValue",({value:e})=>({inserted:ph(e??"")})),rt("editor_getValue",()=>({value:W.state.doc.toString()})),rt("editor_setReadonly",({readonly:e})=>(Xi(e),{readonly:!!e})),rt("editor_formatCode",async()=>({formatted:await lr()})),mS(qt)});sl&&(document.querySelector("#native-editor").hidden=!0,document.querySelector("#web-studio").hidden=!1,n1());async function n1(){const n=document.querySelector("#pair-dialog"),e=document.querySelector("#pair-form"),t=document.querySelector("#pair-error"),i=document.querySelector("#package-select"),s=document.querySelector("#file-select"),r=document.querySelector("#connection-status"),o=document.querySelector("#disconnect-button"),a=document.querySelector("#studio-grid"),l=document.querySelector(".editor-column"),c=document.querySelector("#recovery-banner"),h=document.querySelector("#conflict-banner"),u=document.querySelector("#command-dialog"),f=document.querySelector("#command-search"),d=document.querySelector("#command-list"),p=document.querySelector("#compare-dialog");let m=window.sessionStorage.getItem("scriptwidget.web-studio.token")||"",g=[],y=null,b=null,x=null,C=0,k=null,S="",w="",U=null,F=YS(),V="",E="",M=null;function Y(v="Session ended. Enter the new code shown on your device."){m="",window.sessionStorage.removeItem("scriptwidget.web-studio.token"),o.hidden=!0,Q({type:"DISCONNECTED"}),r.textContent=v,Xi(!0),n.open||n.showModal()}function Q(v){F=NS(F,v);const Z={connecting:"Connecting",connected:"Connected",offline:"Offline",disconnected:"Disconnected"},L={idle:"Ready",draft:"Draft saved locally",saving:"Saving…",saved:"Saved",error:"Save failed",conflict:"Conflict"};r.dataset.state=F.connection,document.querySelector("#status-connection").textContent=Z[F.connection]||F.connection,En(L[F.save]||F.save,F.save),document.querySelector("#dirty-indicator").hidden=!["draft","saving","error","conflict"].includes(F.save),document.querySelector("#status-preview").textContent=F.preview==="requested"?"Preview requested":"Preview idle",document.querySelector("#preview-detail").textContent=F.preview==="requested"?"Requested on device":"Not requested"}const D=new _S({token:()=>m,onUnauthorized:()=>Y()}),P=(v,Z)=>D.request(v,Z);M=new HS(({packageID:v,path:Z,content:L,baseRevision:ne})=>P("/api/v1/document",{method:"PUT",body:JSON.stringify({package:v,path:Z,content:L,baseRevision:ne})}));async function j(v){m=(await P("/api/v1/pair",{method:"POST",body:JSON.stringify({code:v})})).token,window.sessionStorage.setItem("scriptwidget.web-studio.token",m),o.hidden=!1,Q({type:"CONNECTED"}),ae()}function ae(){window.clearInterval(y),y=window.setInterval(async()=>{if(m)try{const v=await P("/api/v1/session");if(!navigator.onLine)return;q(v),Q({type:"CONNECTED"})}catch(v){v.status!==401&&(r.textContent=`Interrupted · ${v.message}`,Q({type:"OFFLINE"}))}},5e3)}async function J(){if(g=(await P("/api/v1/packages")).packages||[],i.replaceChildren(...g.map(Z=>new Option(Z.name,Z.id))),!g.length){r.textContent="No editable widgets",Xi(!0);return}await ee()}async function ee(){const v=g.find(ne=>ne.id===i.value),Z=v?.files||[];s.replaceChildren(...Z.map(ne=>new Option(ne,ne)));const L=Z.includes(v?.entry)?v.entry:Z[0];L&&(s.value=L),await H()}async function I(v=""){g=(await P("/api/v1/packages")).packages||[],i.replaceChildren(...g.map(ge=>new Option(ge.name,ge.id))),V&&(i.value=V);const L=g.find(ge=>ge.id===i.value),ne=L?.files||[];s.replaceChildren(...ne.map(ge=>new Option(ge,ge))),s.value=ne.includes(v)?v:ne.includes(E)?E:L?.entry||ne[0]}async function H(){if(!i.value||!s.value)return;const v=new URLSearchParams({package:i.value,path:s.value}),Z=await P(`/api/v1/document?${v}`),L=`${i.value}/${s.value}`;V=i.value,E=s.value,S=Z.revision,w=Z.content,U=null,h.hidden=!0,_t(Z.content,L,0),il(W,g.find(ge=>ge.id===V)?.files??[]),M.open({documentID:L,packageID:V,path:E,revision:Z.revision,content:Z.content}),Xi(!!Z.readOnly),ce(Z);const ne=jS(window.localStorage,L,Z.content,Z.revision);c.hidden=!ne,c._draft=ne,document.querySelector("#recovery-message").textContent=ne?.isStale?"The device version also changed. Review before saving.":"Restore it or keep the device version.",r.textContent="Connected",Q({type:"CONNECTED"}),o.hidden=!1,Oe(),ae(),Me()}function ce(v){document.querySelector("#breadcrumb-package").textContent=v.packageName||i.value,document.querySelector("#breadcrumb-file").textContent=s.value,document.querySelector("#editor-tab-name").textContent=s.value,document.querySelector("#revision-detail").textContent=S?S.slice(0,8):"—",document.querySelector("#access-detail").textContent=v.readOnly?"Read only":"Editable"}function q(v){v.device&&(document.querySelector("#device-name").textContent=v.device.name||v.device.model,document.querySelector("#device-system").textContent=`${v.device.model} · ${v.device.system}`),v.preview?.package&&(document.querySelector("#preview-target").textContent=v.preview.package),v.preview?.snapshotSequence&&te()}async function te(){try{const v=await D.requestBlob("/api/v1/preview"),Z=URL.createObjectURL(v),L=document.querySelector("#device-preview"),ne=k;k=Z,L.onload=()=>{ne&&URL.revokeObjectURL(ne)},L.src=Z,L.hidden=!1,document.querySelector("#preview-detail").textContent="Rendered on device"}catch{}}function re(v){const Z=document.querySelector("#console-list"),L=document.createElement("li");for(L.className=v.level||"info",L.textContent=v.message||"",Z.append(L);Z.children.length>200;)Z.firstChild.remove();Z.scrollTop=Z.scrollHeight}function Me(){window.clearTimeout(x);const v=async()=>{if(m)try{const Z=await P(`/api/v1/events?after=${C}`);C=Z.nextSequence??C;for(const L of Z.events||[])L.type==="console"&&re(L.payload||{}),L.type==="preview.snapshot"&&te(),L.type==="preview.requested"&&(document.querySelector("#status-preview").textContent="Preview requested",document.querySelector("#preview-detail").textContent="Requested on device"),L.type==="files.changed"&&L.payload?.package===V&&I(E).catch(Ie);Q({type:"CONNECTED"})}catch(Z){Z.status!==401&&Q({type:"OFFLINE"})}finally{m&&(x=window.setTimeout(v,1e3))}};v()}function Oe(){const v=Ed(W);document.querySelector("#problems-list").replaceChildren(...v.map(L=>{const ne=W.state.doc.lineAt(L.from),ge=document.createElement("li");ge.className=`problem-item ${L.severity}`;const it=document.createElement("button");return it.type="button",it.innerHTML=`${L.severity==="error"?"●":"▲"}Ln ${ne.number}`,it.children[1].textContent=L.message,it.addEventListener("click",()=>{W.dispatch({selection:{anchor:L.from},scrollIntoView:!0}),W.focus()}),ge.append(it),ge})),document.querySelector("#problems-count").textContent=String(v.length),document.querySelector("#status-problem-count").textContent=String(v.length),document.querySelector("#problems-summary").textContent=v.length?`${v.filter(L=>L.severity==="error").length} errors, ${v.filter(L=>L.severity!=="error").length} warnings`:"No problems detected"}async function ie(v,Z,L=null){M.snapshot()?.content!==v&&M.edit(v),L&&M.rebase(L),Q({type:"SAVING"});try{const ne=await M.flush();if(ne.ignored){Z({result:"ok",ignored:!0});return}if(ne.skipped){Q({type:"SAVED"}),Z({result:"ok",skipped:!0});return}const ge=ne.result||{},it=M.snapshot();S=it?.revision||S,w=it?.content||v,fo(window.localStorage,me),U=null,h.hidden=!0,document.querySelector("#revision-detail").textContent=S?.slice(0,8)||"—",Q({type:"SAVED",preview:ge.preview?.state}),Z({result:"ok",...ge})}catch(ne){ne.status===409?(U=ne.body,h.hidden=!1,Q({type:"CONFLICT",conflict:U})):Q({type:"SAVE_FAILED"}),Z({result:"failed",message:ne.message})}}qt={registerHandler(){},callHandler(v,Z,L=()=>{}){if(v===Ue.documentSave)ie(Z.payload.content,L);else if(v===Ue.documentResources){const ne=me,ge=V;P("/api/v1/packages").then(it=>{if(ne!==me||Z.documentID!==me||ge!==V){L({result:"failed"});return}L({result:"ok",documentID:ne,resources:(it.packages??[]).find(zn=>zn.id===ge)?.files??[]})}).catch(()=>L({result:"failed"}))}else L({result:"ok"})}},zd={documentChanged(){const v=W.state.doc.toString();M.edit(v),hh(window.localStorage,me,v,M.snapshot()?.revision||S),Q({type:"EDITED"}),window.clearTimeout(b),b=window.setTimeout(Oe,380)}};async function ve(v,Z){if(!uh(F.save)){await v();return}try{if(window.clearTimeout(Mn),await ie(W.state.doc.toString(),()=>{}),!M.isDirty&&F.save!=="conflict"){await v();return}}catch{}window.confirm("This document has changes that are not saved on the device. A browser draft is available. Switch anyway?")?await v():Z()}i.addEventListener("change",()=>{const v=i.value;i.value=V,ve(async()=>{i.value=v,await ee()},()=>{i.value=V}).catch(Ie)}),s.addEventListener("change",()=>{const v=s.value;s.value=E,ve(async()=>{s.value=v,await H()},()=>{s.value=E}).catch(Ie)});function Ie(v){r.textContent=v.message||String(v),Q({type:"SAVE_FAILED"})}e.addEventListener("submit",async v=>{v.preventDefault(),t.textContent="";try{await j(document.querySelector("#pair-code").value),n.close(),await J()}catch(Z){t.textContent=Z.message}}),o.addEventListener("click",async()=>{try{await P("/api/v1/session",{method:"DELETE"})}catch{}Y("Disconnected. Start a new session with the code on your device.")}),document.querySelector("#new-file").addEventListener("click",async()=>{const v=window.prompt("New package-relative text file","source/helper.js")?.trim();if(v)try{await P("/api/v1/document",{method:"POST",body:JSON.stringify({package:V,path:v})}),await I(v),await H()}catch(Z){Ie(Z)}}),document.querySelector("#delete-file").addEventListener("click",async()=>{const v=g.find(Z=>Z.id===V);if(!E||E===v?.entry){window.alert("The widget entry file cannot be deleted.");return}if(window.confirm(`Delete ${E}? This cannot be undone.`))try{const Z=new URLSearchParams({package:V,path:E});await P(`/api/v1/document?${Z}`,{method:"DELETE"}),E="",await I(),await H()}catch(Z){Ie(Z)}}),document.querySelector("#clear-console").addEventListener("click",()=>document.querySelector("#console-list").replaceChildren()),document.querySelector("#restore-draft").addEventListener("click",()=>{const v=c._draft;v&&(_t(v.content,v.documentID,at+1),c.hidden=!0,hh(window.localStorage,me,v.content,S),Q({type:"EDITED"}),Oe())}),document.querySelector("#discard-draft").addEventListener("click",()=>{fo(window.localStorage,me),c.hidden=!0}),document.querySelector("#reload-server").addEventListener("click",()=>{U&&(fo(window.localStorage,me),S=U.currentRevision,w=U.currentContent,_t(w,me,at+1),M.open({documentID:me,packageID:V,path:E,revision:S,content:w}),U=null,h.hidden=!0,Q({type:"SAVED"}),Oe())}),document.querySelector("#keep-local").addEventListener("click",()=>{U&&ie(W.state.doc.toString(),()=>{},U.currentRevision)}),document.querySelector("#compare-conflict").addEventListener("click",()=>{document.querySelector("#compare-local").textContent=W.state.doc.toString(),document.querySelector("#compare-server").textContent=U?.currentContent||w,p.showModal()}),p.querySelector("button").addEventListener("click",()=>p.close());function oe(){const v=l.classList.toggle("problems-collapsed");document.querySelector("#problems-toggle").setAttribute("aria-expanded",String(!v))}function Ae(v){a.classList.toggle(`show-${v}`)}document.querySelector("#problems-toggle").addEventListener("click",oe),document.querySelector("#status-problems").addEventListener("click",()=>{l.classList.remove("problems-collapsed")}),document.querySelector("#explorer-button").addEventListener("click",()=>Ae("explorer")),document.querySelector("#inspector-button").addEventListener("click",()=>Ae("inspector")),document.querySelectorAll("[data-close-panel]").forEach(v=>v.addEventListener("click",()=>a.classList.remove(`show-${v.dataset.closePanel}`)));const le=[{name:"Save Document",keys:"⌘S",run:()=>{window.clearTimeout(Mn),ie(W.state.doc.toString(),()=>{})}},{name:"Format Document",keys:"⇧⌥F",run:lr},{name:"Toggle Problems",keys:"⌘J",run:oe},{name:"Toggle Explorer",keys:"⌘⇧E",run:()=>Ae("explorer")},{name:"Toggle Inspector",keys:"",run:()=>Ae("inspector")},{name:"Use Light Theme",keys:"",run:()=>cr("light")},{name:"Use Dark Theme",keys:"",run:()=>cr("dark")}];function qe(v=""){const Z=le.filter(L=>L.name.toLowerCase().includes(v.toLowerCase()));d.replaceChildren(...Z.map(L=>{const ne=document.createElement("li"),ge=document.createElement("button");ge.type="button",ge.className="command";const it=document.createElement("span");it.textContent=L.name;const zn=document.createElement("kbd");return zn.textContent=L.keys,ge.append(it,zn),ge.addEventListener("click",()=>{u.close(),L.run()}),ne.append(ge),ne}))}function tt(){qe(),u.showModal(),f.value="",f.focus()}document.querySelector("#command-button").addEventListener("click",tt),f.addEventListener("input",()=>qe(f.value)),document.addEventListener("keydown",v=>{const Z=v.metaKey||v.ctrlKey;Z&&v.shiftKey&&v.key.toLowerCase()==="p"?(v.preventDefault(),tt()):Z&&v.key.toLowerCase()==="s"?(v.preventDefault(),le[0].run()):Z&&v.key.toLowerCase()==="j"?(v.preventDefault(),oe()):Z&&v.shiftKey&&v.key.toLowerCase()==="e"?(v.preventDefault(),Ae("explorer")):v.shiftKey&&v.altKey&&v.key.toLowerCase()==="f"&&(v.preventDefault(),lr())}),W.dom.addEventListener("keyup",ai),W.dom.addEventListener("mouseup",ai);function ai(){const v=W.state.selection.main.head,Z=W.state.doc.lineAt(v);document.querySelector("#cursor-position").textContent=`Ln ${Z.number}, Col ${v-Z.from+1}`}window.addEventListener("offline",()=>{r.textContent="Computer is offline",Q({type:"OFFLINE"})}),window.addEventListener("online",()=>{m&&P("/api/v1/session").then(v=>(q(v),Q({type:"CONNECTED"}),J())).catch(Ie)}),window.addEventListener("beforeunload",v=>{uh(F.save)&&(v.preventDefault(),v.returnValue="")});try{await J()}catch{Y("Pair with the code shown on your device.")}}window.matchMedia?.("(prefers-color-scheme: dark)").addEventListener("change",()=>cr("system"));window.webkit||_t(`// ScriptWidget Studio +const widget = ( + + + +); +`); diff --git a/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/index.html b/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/index.html index f08a8fe2..55c4909d 100644 --- a/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/index.html +++ b/iOS/ScriptWidget/View/CodeEditor/MirrorEditor/StudioEditor.bundle/index.html @@ -5,7 +5,7 @@ ScriptWidget Web Studio - + diff --git a/iOS/ScriptWidget/View/PhotoPicker/en.lproj/PhotoPicker.storyboard b/iOS/ScriptWidget/View/PhotoPicker/en.lproj/PhotoPicker.storyboard index c6522d46..5e4dfc77 100644 --- a/iOS/ScriptWidget/View/PhotoPicker/en.lproj/PhotoPicker.storyboard +++ b/iOS/ScriptWidget/View/PhotoPicker/en.lproj/PhotoPicker.storyboard @@ -133,15 +133,17 @@ - - + + - + + + @@ -237,6 +239,7 @@ + diff --git a/iOS/ScriptWidgetWidget/Info.plist b/iOS/ScriptWidgetWidget/Info.plist index 8d493edb..75ec5a51 100644 --- a/iOS/ScriptWidgetWidget/Info.plist +++ b/iOS/ScriptWidgetWidget/Info.plist @@ -56,5 +56,11 @@ Larabiefont Free.ttf Apple ][.ttf + NSContactsUsageDescription + Select contacts to share with your chosen widgets. + NSHomeKitUsageDescription + Read selected home accessories and run selected controls or scenes from widgets. + NSAlarmKitUsageDescription + Schedule alarms and timers you explicitly request from a widget. diff --git a/iOS/ScriptWidgetWidget/LiveActivity/ScriptWidgetAlarmLiveActivity.swift b/iOS/ScriptWidgetWidget/LiveActivity/ScriptWidgetAlarmLiveActivity.swift new file mode 100644 index 00000000..a70db60e --- /dev/null +++ b/iOS/ScriptWidgetWidget/LiveActivity/ScriptWidgetAlarmLiveActivity.swift @@ -0,0 +1,42 @@ +import SwiftUI +import WidgetKit +import AlarmKit + +/// AlarmKit countdown UI uses native dates; it never evaluates widget scripts +/// or queries external data while rendering a Live Activity. +@available(iOSApplicationExtension 26.0, *) +struct ScriptWidgetAlarmLiveActivity: Widget { + var body: some WidgetConfiguration { + ActivityConfiguration(for: AlarmAttributes.self) { context in + VStack(alignment: .leading, spacing: 8) { + Label("ScriptWidget Timer", systemImage: "timer").font(.caption).foregroundStyle(.secondary) + Text(context.attributes.presentation.alert.title).font(.headline) + time(context.state.mode).font(.largeTitle.monospacedDigit()) + } + .padding() + .activityBackgroundTint(.black) + .activitySystemActionForegroundColor(.white) + } dynamicIsland: { context in + DynamicIsland { + DynamicIslandExpandedRegion(.leading) { Image(systemName: "timer").foregroundStyle(.teal) } + DynamicIslandExpandedRegion(.center) { Text(context.attributes.presentation.alert.title).lineLimit(1) } + DynamicIslandExpandedRegion(.bottom) { time(context.state.mode).font(.title.monospacedDigit()) } + } compactLeading: { + Image(systemName: "timer").foregroundStyle(.teal) + } compactTrailing: { + time(context.state.mode).monospacedDigit().frame(maxWidth: 64) + } minimal: { + Image(systemName: "timer") + } + } + } + @ViewBuilder + private func time(_ mode: AlarmPresentationState.Mode) -> some View { + switch mode { + case .countdown(let value): Text(timerInterval: value.startDate...max(value.startDate, value.fireDate), countsDown: true) + case .paused: Text("Paused") + case .alert: Text("Time’s up") + @unknown default: Text("Timer") + } + } +} diff --git a/iOS/ScriptWidgetWidget/ScriptWidgetMain.swift b/iOS/ScriptWidgetWidget/ScriptWidgetMain.swift index 36241a3c..3c91c056 100644 --- a/iOS/ScriptWidgetWidget/ScriptWidgetMain.swift +++ b/iOS/ScriptWidgetWidget/ScriptWidgetMain.swift @@ -46,6 +46,7 @@ struct ScriptWidgets: WidgetBundle { var body: some Widget { ScriptWidgetMainWidget() ScriptLiveActivityWidget() + if #available(iOSApplicationExtension 26.0, *) { ScriptWidgetAlarmLiveActivity() } ScriptWidgetButtonControlWidget() ScriptWidgetControlWidget() } diff --git a/iOS/ScriptWidgetWidget/ScriptWidgetWidget.entitlements b/iOS/ScriptWidgetWidget/ScriptWidgetWidget.entitlements index b5675d24..2950fa1e 100644 --- a/iOS/ScriptWidgetWidget/ScriptWidgetWidget.entitlements +++ b/iOS/ScriptWidgetWidget/ScriptWidgetWidget.entitlements @@ -27,5 +27,7 @@ group.everettjf.scriptwidget + com.apple.developer.homekit + diff --git a/macOS/ScriptWidgetMac.xcodeproj/project.pbxproj b/macOS/ScriptWidgetMac.xcodeproj/project.pbxproj index 05bc0971..316036ac 100644 --- a/macOS/ScriptWidgetMac.xcodeproj/project.pbxproj +++ b/macOS/ScriptWidgetMac.xcodeproj/project.pbxproj @@ -91,6 +91,7 @@ A621B963FD9840DB82F74813 /* ScriptWidgetRuntimeLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124FAA64786342F5A3432631 /* ScriptWidgetRuntimeLocation.swift */; }; A990D65181507F3AA8EB7951 /* ScriptWidgetElementTagExtras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DAACB8F5182390731F6DFE7 /* ScriptWidgetElementTagExtras.swift */; }; C43EFB088718FE26BF9B393F /* PackageCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CF0C59766F5837DEC033FB9 /* PackageCacheTests.swift */; }; + DD4971B1EBB047D7A8B6AA34 /* SystemServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F8E682016AD45E7A899E9A6 /* SystemServiceTests.swift */; }; D1995C9429536BB800D1BD94 /* MineGaugeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1995C5729536BB800D1BD94 /* MineGaugeView.swift */; }; D1995C9529536BB800D1BD94 /* MineGaugeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1995C5729536BB800D1BD94 /* MineGaugeView.swift */; }; D1995C9629536BB800D1BD94 /* ScriptWidgetElementColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1995C5829536BB800D1BD94 /* ScriptWidgetElementColor.swift */; }; @@ -175,8 +176,28 @@ D1995CE529536BB800D1BD94 /* ScriptWidgetRuntimeFetch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1995C8A29536BB800D1BD94 /* ScriptWidgetRuntimeFetch.swift */; }; D1995CE629536BB800D1BD94 /* ScriptWidgetRuntimeFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1995C8B29536BB800D1BD94 /* ScriptWidgetRuntimeFile.swift */; }; 2848A73946D449769C0CD55F /* ScriptWidgetRuntimeCloudJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F6759273EF4F709A101EA6 /* ScriptWidgetRuntimeCloudJSON.swift */; }; + 0B66058AFF5D468293210F09 /* ScriptWidgetRuntimeHome.swift in Sources */ = {isa = PBXBuildFile; fileRef = A06580CB379D48EDA122214A /* ScriptWidgetRuntimeHome.swift */; }; + 475BF3577F8043A78DC4A0A6 /* ScriptWidgetRuntimeContacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DCF2DB7D61A41DAAFAF0573 /* ScriptWidgetRuntimeContacts.swift */; }; + 85E36B7D4A444AD5BAD89EBA /* ScriptWidgetRuntimeDocuments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B4FB15F3744FEE88CAE788 /* ScriptWidgetRuntimeDocuments.swift */; }; + 198AB87CFA224B3DB68AEAC9 /* ScriptWidgetRuntimeAlarms.swift in Sources */ = {isa = PBXBuildFile; fileRef = A127D754AED148F0BA45B9D6 /* ScriptWidgetRuntimeAlarms.swift */; }; + 9383F4BEDE8E4022959F8A45 /* ScriptWidgetRuntimeWeather.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C4C812353D3490BB2D30429 /* ScriptWidgetRuntimeWeather.swift */; }; + F184017F8DA4436797FC2F41 /* ScriptWidgetRuntimeMaps.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC36F2C183B41BE91E03EBC /* ScriptWidgetRuntimeMaps.swift */; }; + B12F091859EC436DABC8C8C7 /* ScriptWidgetRuntimeHealthHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0BA60773C8A46EAB7B90001 /* ScriptWidgetRuntimeHealthHistory.swift */; }; + 14BE2B9A71254A699CCA7AB5 /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6598107944B540E9ACD548E6 /* ScriptWidgetRuntimeCalendarWrites.swift */; }; + 7A9A3DF0BF3E4CBEACFB7C2E /* ScriptWidgetRuntimeNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = A28FC797570D4EF18F352DC8 /* ScriptWidgetRuntimeNotifications.swift */; }; + 06FFA3E8D5B04EFEB162B378 /* ScriptWidgetRuntimeSystemServices.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85434CD26E2745F3ABAAF731 /* ScriptWidgetRuntimeSystemServices.swift */; }; D1995CE729536BB800D1BD94 /* ScriptWidgetRuntimeFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1995C8B29536BB800D1BD94 /* ScriptWidgetRuntimeFile.swift */; }; 005E0FFB61C747FB9D148955 /* ScriptWidgetRuntimeCloudJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F6759273EF4F709A101EA6 /* ScriptWidgetRuntimeCloudJSON.swift */; }; + ED10B15491EE4CDFBB175205 /* ScriptWidgetRuntimeHome.swift in Sources */ = {isa = PBXBuildFile; fileRef = A06580CB379D48EDA122214A /* ScriptWidgetRuntimeHome.swift */; }; + 9645A5F773C74E478719C366 /* ScriptWidgetRuntimeContacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DCF2DB7D61A41DAAFAF0573 /* ScriptWidgetRuntimeContacts.swift */; }; + F4415D7C41D74F548A88D81F /* ScriptWidgetRuntimeDocuments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B4FB15F3744FEE88CAE788 /* ScriptWidgetRuntimeDocuments.swift */; }; + C575AE472D4E4356A5143350 /* ScriptWidgetRuntimeAlarms.swift in Sources */ = {isa = PBXBuildFile; fileRef = A127D754AED148F0BA45B9D6 /* ScriptWidgetRuntimeAlarms.swift */; }; + A0A86A24C5C949C0AF743608 /* ScriptWidgetRuntimeWeather.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C4C812353D3490BB2D30429 /* ScriptWidgetRuntimeWeather.swift */; }; + FF4F63F4478C419D9A9D1DF9 /* ScriptWidgetRuntimeMaps.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC36F2C183B41BE91E03EBC /* ScriptWidgetRuntimeMaps.swift */; }; + E0F2CE2AF2064CD5B66369CD /* ScriptWidgetRuntimeHealthHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0BA60773C8A46EAB7B90001 /* ScriptWidgetRuntimeHealthHistory.swift */; }; + 9B207930D97748EBB593C33D /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6598107944B540E9ACD548E6 /* ScriptWidgetRuntimeCalendarWrites.swift */; }; + 0B0C94EBB37E4764A51AD7DF /* ScriptWidgetRuntimeNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = A28FC797570D4EF18F352DC8 /* ScriptWidgetRuntimeNotifications.swift */; }; + 770D1ED6C3444D8AB975BB1D /* ScriptWidgetRuntimeSystemServices.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85434CD26E2745F3ABAAF731 /* ScriptWidgetRuntimeSystemServices.swift */; }; D1995CE829536BB800D1BD94 /* ScriptWidgetRuntimePromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1995C8C29536BB800D1BD94 /* ScriptWidgetRuntimePromise.swift */; }; D1995CE929536BB800D1BD94 /* ScriptWidgetRuntimePromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1995C8C29536BB800D1BD94 /* ScriptWidgetRuntimePromise.swift */; }; D1995CEA29536BB800D1BD94 /* ScriptWidgetRuntimeConsole.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1995C8D29536BB800D1BD94 /* ScriptWidgetRuntimeConsole.swift */; }; @@ -267,6 +288,7 @@ F7F9A50928F64529981556FE /* ScriptWidgetCloudJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A9469B308A04CF7BC84E549 /* ScriptWidgetCloudJSON.swift */; }; 1A12140C0C8248BDB21EF14F /* ScriptWidgetRecordsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10538215ECFD4FADA216F872 /* ScriptWidgetRecordsView.swift */; }; 466E709555B74AAD834094B4 /* ScriptWidgetCloudJSONView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF5C35C0CEF344629F7D4B6B /* ScriptWidgetCloudJSONView.swift */; }; + 2BD5540F422248D1872E98DD /* ScriptWidgetSystemAccessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB7CA52FDC44FCCB4833C76 /* ScriptWidgetSystemAccessView.swift */; }; 2F12113B8920446580D6B39E /* ScriptWidgetStorageUpgradeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF563C68CB1F4834876CF479 /* ScriptWidgetStorageUpgradeView.swift */; }; 36FDE008D662491489635EA7 /* ScriptWidgetRecordStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = D98FE968018D484D8FBCDC17 /* ScriptWidgetRecordStore.swift */; }; 3D87692664A44C799D7182CA /* ScriptWidgetCloudJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A9469B308A04CF7BC84E549 /* ScriptWidgetCloudJSON.swift */; }; @@ -319,6 +341,7 @@ 5CBD28F52391D2A6FD860DE8 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; 77AA76CA4DC3B9BF781E4FD2 /* ScriptWidgetRuntimeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ScriptWidgetRuntimeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 7CF0C59766F5837DEC033FB9 /* PackageCacheTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PackageCacheTests.swift; path = ../Tests/ScriptWidgetRuntimeTests/PackageCacheTests.swift; sourceTree = ""; }; + 8F8E682016AD45E7A899E9A6 /* SystemServiceTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SystemServiceTests.swift; path = ../Tests/ScriptWidgetRuntimeTests/SystemServiceTests.swift; sourceTree = ""; }; 8445DB90E4A34EB19697BAEB /* ReloadWidgetAppIntent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReloadWidgetAppIntent.swift; sourceTree = ""; }; 8A078A98942A275CF9F25103 /* RuntimeUnitTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RuntimeUnitTests.swift; path = ../Tests/ScriptWidgetRuntimeTests/RuntimeUnitTests.swift; sourceTree = ""; }; A268224FAE0BE130C6D0BAC0 /* ServiceAccessPolicyTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ServiceAccessPolicyTests.swift; path = ../Tests/ScriptWidgetRuntimeTests/ServiceAccessPolicyTests.swift; sourceTree = ""; }; @@ -414,6 +437,16 @@ D1995C8A29536BB800D1BD94 /* ScriptWidgetRuntimeFetch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeFetch.swift; sourceTree = ""; }; D1995C8B29536BB800D1BD94 /* ScriptWidgetRuntimeFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeFile.swift; sourceTree = ""; }; 06F6759273EF4F709A101EA6 /* ScriptWidgetRuntimeCloudJSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeCloudJSON.swift; sourceTree = ""; }; + A06580CB379D48EDA122214A /* ScriptWidgetRuntimeHome.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeHome.swift; sourceTree = ""; }; + 0DCF2DB7D61A41DAAFAF0573 /* ScriptWidgetRuntimeContacts.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeContacts.swift; sourceTree = ""; }; + 74B4FB15F3744FEE88CAE788 /* ScriptWidgetRuntimeDocuments.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeDocuments.swift; sourceTree = ""; }; + A127D754AED148F0BA45B9D6 /* ScriptWidgetRuntimeAlarms.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeAlarms.swift; sourceTree = ""; }; + 5C4C812353D3490BB2D30429 /* ScriptWidgetRuntimeWeather.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeWeather.swift; sourceTree = ""; }; + DBC36F2C183B41BE91E03EBC /* ScriptWidgetRuntimeMaps.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeMaps.swift; sourceTree = ""; }; + E0BA60773C8A46EAB7B90001 /* ScriptWidgetRuntimeHealthHistory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeHealthHistory.swift; sourceTree = ""; }; + 6598107944B540E9ACD548E6 /* ScriptWidgetRuntimeCalendarWrites.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeCalendarWrites.swift; sourceTree = ""; }; + A28FC797570D4EF18F352DC8 /* ScriptWidgetRuntimeNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeNotifications.swift; sourceTree = ""; }; + 85434CD26E2745F3ABAAF731 /* ScriptWidgetRuntimeSystemServices.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeSystemServices.swift; sourceTree = ""; }; D1995C8C29536BB800D1BD94 /* ScriptWidgetRuntimePromise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimePromise.swift; sourceTree = ""; }; D1995C8D29536BB800D1BD94 /* ScriptWidgetRuntimeConsole.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeConsole.swift; sourceTree = ""; }; D1995C8E29536BB800D1BD94 /* ScriptWidgetRuntimeDevice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRuntimeDevice.swift; sourceTree = ""; }; @@ -484,6 +517,7 @@ 8A9469B308A04CF7BC84E549 /* ScriptWidgetCloudJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetCloudJSON.swift; sourceTree = ""; }; 10538215ECFD4FADA216F872 /* ScriptWidgetRecordsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetRecordsView.swift; sourceTree = ""; }; FF5C35C0CEF344629F7D4B6B /* ScriptWidgetCloudJSONView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetCloudJSONView.swift; sourceTree = ""; }; + 2FB7CA52FDC44FCCB4833C76 /* ScriptWidgetSystemAccessView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetSystemAccessView.swift; sourceTree = ""; }; FF563C68CB1F4834876CF479 /* ScriptWidgetStorageUpgradeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetStorageUpgradeView.swift; sourceTree = ""; }; B9D4AE7B65A246F08085C382 /* ScriptWidgetStorageNamespaces.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetStorageNamespaces.swift; sourceTree = ""; }; 64423A310BE1421199E81550 /* ScriptWidgetStorageFiles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptWidgetStorageFiles.swift; sourceTree = ""; }; @@ -635,6 +669,7 @@ 1492D936BBC23E9D0195DE26 /* RuntimeExecutionTests.swift */, A43E23B1BB04A5AC18DEC1B1 /* BrowserPreviewParityTests.swift */, 7CF0C59766F5837DEC033FB9 /* PackageCacheTests.swift */, + 8F8E682016AD45E7A899E9A6 /* SystemServiceTests.swift */, ); name = Tests; sourceTree = SOURCE_ROOT; @@ -804,6 +839,16 @@ D1995C8A29536BB800D1BD94 /* ScriptWidgetRuntimeFetch.swift */, D1995C8B29536BB800D1BD94 /* ScriptWidgetRuntimeFile.swift */, 06F6759273EF4F709A101EA6 /* ScriptWidgetRuntimeCloudJSON.swift */, + A06580CB379D48EDA122214A /* ScriptWidgetRuntimeHome.swift */, + 0DCF2DB7D61A41DAAFAF0573 /* ScriptWidgetRuntimeContacts.swift */, + 74B4FB15F3744FEE88CAE788 /* ScriptWidgetRuntimeDocuments.swift */, + A127D754AED148F0BA45B9D6 /* ScriptWidgetRuntimeAlarms.swift */, + 5C4C812353D3490BB2D30429 /* ScriptWidgetRuntimeWeather.swift */, + DBC36F2C183B41BE91E03EBC /* ScriptWidgetRuntimeMaps.swift */, + E0BA60773C8A46EAB7B90001 /* ScriptWidgetRuntimeHealthHistory.swift */, + 6598107944B540E9ACD548E6 /* ScriptWidgetRuntimeCalendarWrites.swift */, + A28FC797570D4EF18F352DC8 /* ScriptWidgetRuntimeNotifications.swift */, + 85434CD26E2745F3ABAAF731 /* ScriptWidgetRuntimeSystemServices.swift */, 8E3B593386F820DCF99C631E /* ScriptWidgetRuntimeSystem.swift */, CD9F1F298DF5C4FAED8AAD43 /* ScriptWidgetRuntimeHealth.swift */, 1F219B313B36BE844638FBC2 /* ScriptWidgetRuntimeCalendar.swift */, @@ -859,6 +904,7 @@ 8A9469B308A04CF7BC84E549 /* ScriptWidgetCloudJSON.swift */, 10538215ECFD4FADA216F872 /* ScriptWidgetRecordsView.swift */, FF5C35C0CEF344629F7D4B6B /* ScriptWidgetCloudJSONView.swift */, + 2FB7CA52FDC44FCCB4833C76 /* ScriptWidgetSystemAccessView.swift */, FF563C68CB1F4834876CF479 /* ScriptWidgetStorageUpgradeView.swift */, D1995CF629536BC700D1BD94 /* ScriptModel.swift */, D1A0000000E0000000001000 /* ScriptMetadata.swift */, @@ -1264,6 +1310,7 @@ files = ( A10633E3A2F1C708E2078A33 /* AIGenerationTests.swift in Sources */, C43EFB088718FE26BF9B393F /* PackageCacheTests.swift in Sources */, + DD4971B1EBB047D7A8B6AA34 /* SystemServiceTests.swift in Sources */, EBAE7DF1351F9A6ECE2E2AE2 /* RuntimeExecutionTests.swift in Sources */, CD29AE3DAA240E9D6FF92EA4 /* BrowserPreviewParityTests.swift in Sources */, 7B77915046C30834D191319E /* RuntimeUnitTests.swift in Sources */, @@ -1391,6 +1438,16 @@ D1995CB829536BB800D1BD94 /* ScriptWidgetAttributeText.swift in Sources */, D1995CE629536BB800D1BD94 /* ScriptWidgetRuntimeFile.swift in Sources */, 2848A73946D449769C0CD55F /* ScriptWidgetRuntimeCloudJSON.swift in Sources */, + 0B66058AFF5D468293210F09 /* ScriptWidgetRuntimeHome.swift in Sources */, + 475BF3577F8043A78DC4A0A6 /* ScriptWidgetRuntimeContacts.swift in Sources */, + 85E36B7D4A444AD5BAD89EBA /* ScriptWidgetRuntimeDocuments.swift in Sources */, + 198AB87CFA224B3DB68AEAC9 /* ScriptWidgetRuntimeAlarms.swift in Sources */, + 9383F4BEDE8E4022959F8A45 /* ScriptWidgetRuntimeWeather.swift in Sources */, + F184017F8DA4436797FC2F41 /* ScriptWidgetRuntimeMaps.swift in Sources */, + B12F091859EC436DABC8C8C7 /* ScriptWidgetRuntimeHealthHistory.swift in Sources */, + 14BE2B9A71254A699CCA7AB5 /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */, + 7A9A3DF0BF3E4CBEACFB7C2E /* ScriptWidgetRuntimeNotifications.swift in Sources */, + 06FFA3E8D5B04EFEB162B378 /* ScriptWidgetRuntimeSystemServices.swift in Sources */, 2748BECB1506585B128418DC /* ScriptWidgetRuntimeSystem.swift in Sources */, 75F45276F84EA01B91EC0CEC /* ScriptWidgetRuntimeHealth.swift in Sources */, 404165AC81E77E3021CBD919 /* ScriptWidgetRuntimeCalendar.swift in Sources */, @@ -1414,6 +1471,7 @@ F7F9A50928F64529981556FE /* ScriptWidgetCloudJSON.swift in Sources */, 1A12140C0C8248BDB21EF14F /* ScriptWidgetRecordsView.swift in Sources */, 466E709555B74AAD834094B4 /* ScriptWidgetCloudJSONView.swift in Sources */, + 2BD5540F422248D1872E98DD /* ScriptWidgetSystemAccessView.swift in Sources */, 2F12113B8920446580D6B39E /* ScriptWidgetStorageUpgradeView.swift in Sources */, 65BB9B8C3E605B9CDA324E9C /* ScriptWidgetElementTagExtras.swift in Sources */, F29118C02791DC5300B860B0 /* WidgetRowView.swift in Sources */, @@ -1464,6 +1522,16 @@ D1995CB929536BB800D1BD94 /* ScriptWidgetAttributeText.swift in Sources */, D1995CE729536BB800D1BD94 /* ScriptWidgetRuntimeFile.swift in Sources */, 005E0FFB61C747FB9D148955 /* ScriptWidgetRuntimeCloudJSON.swift in Sources */, + ED10B15491EE4CDFBB175205 /* ScriptWidgetRuntimeHome.swift in Sources */, + 9645A5F773C74E478719C366 /* ScriptWidgetRuntimeContacts.swift in Sources */, + F4415D7C41D74F548A88D81F /* ScriptWidgetRuntimeDocuments.swift in Sources */, + C575AE472D4E4356A5143350 /* ScriptWidgetRuntimeAlarms.swift in Sources */, + A0A86A24C5C949C0AF743608 /* ScriptWidgetRuntimeWeather.swift in Sources */, + FF4F63F4478C419D9A9D1DF9 /* ScriptWidgetRuntimeMaps.swift in Sources */, + E0F2CE2AF2064CD5B66369CD /* ScriptWidgetRuntimeHealthHistory.swift in Sources */, + 9B207930D97748EBB593C33D /* ScriptWidgetRuntimeCalendarWrites.swift in Sources */, + 0B0C94EBB37E4764A51AD7DF /* ScriptWidgetRuntimeNotifications.swift in Sources */, + 770D1ED6C3444D8AB975BB1D /* ScriptWidgetRuntimeSystemServices.swift in Sources */, 855878C6168D59CE4C6CB13C /* ScriptWidgetRuntimeSystem.swift in Sources */, 1C24B164B4EBE88815490627 /* ScriptWidgetRuntimeHealth.swift in Sources */, 2E70438FD53BEA7361410166 /* ScriptWidgetRuntimeCalendar.swift in Sources */, @@ -1698,7 +1766,7 @@ CODE_SIGN_ENTITLEMENTS = ScriptWidgetMac/macOS.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEAD_CODE_STRIPPING = YES; ENABLE_APP_SANDBOX = YES; ENABLE_FILE_ACCESS_DOWNLOADS_FOLDER = readonly; @@ -1718,7 +1786,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 26.0; - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget; PRODUCT_NAME = ScriptWidget; REGISTER_APP_GROUPS = YES; @@ -1736,7 +1804,7 @@ CODE_SIGN_ENTITLEMENTS = ScriptWidgetMac/macOS.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEAD_CODE_STRIPPING = YES; ENABLE_APP_SANDBOX = YES; ENABLE_FILE_ACCESS_DOWNLOADS_FOLDER = readonly; @@ -1755,7 +1823,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 26.0; - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget; PRODUCT_NAME = ScriptWidget; REGISTER_APP_GROUPS = YES; @@ -1772,7 +1840,7 @@ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CODE_SIGN_ENTITLEMENTS = ScriptWidgetMacWidget/ScriptWidgetMacWidget.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEAD_CODE_STRIPPING = YES; ENABLE_APP_SANDBOX = YES; ENABLE_FILE_ACCESS_DOWNLOADS_FOLDER = readonly; @@ -1788,7 +1856,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 26.0; - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget.macwidget; PRODUCT_NAME = "$(TARGET_NAME)"; REGISTER_APP_GROUPS = YES; @@ -1806,7 +1874,7 @@ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CODE_SIGN_ENTITLEMENTS = ScriptWidgetMacWidget/ScriptWidgetMacWidget.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 27016; + CURRENT_PROJECT_VERSION = 27019; DEAD_CODE_STRIPPING = YES; ENABLE_APP_SANDBOX = YES; ENABLE_FILE_ACCESS_DOWNLOADS_FOLDER = readonly; @@ -1822,7 +1890,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 26.0; - MARKETING_VERSION = 27.1.5; + MARKETING_VERSION = 27.2; PRODUCT_BUNDLE_IDENTIFIER = com.everettjf.scriptwidget.macwidget; PRODUCT_NAME = "$(TARGET_NAME)"; REGISTER_APP_GROUPS = YES; diff --git a/macOS/ScriptWidgetMac/App/ScriptWidgetMacApp.swift b/macOS/ScriptWidgetMac/App/ScriptWidgetMacApp.swift index e241b80b..0f9b3e9f 100644 --- a/macOS/ScriptWidgetMac/App/ScriptWidgetMacApp.swift +++ b/macOS/ScriptWidgetMac/App/ScriptWidgetMacApp.swift @@ -32,6 +32,7 @@ struct ScriptWidgetMacApp: App { @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate; init() { + ScriptWidgetSystemServices.startLifecycle() #if DEBUG ScriptWidgetCutoverProcessProbe.runIfRequested() #endif diff --git a/macOS/ScriptWidgetMac/Info.plist b/macOS/ScriptWidgetMac/Info.plist index 3090b9d2..49ca6811 100644 --- a/macOS/ScriptWidgetMac/Info.plist +++ b/macOS/ScriptWidgetMac/Info.plist @@ -35,9 +35,9 @@ NSCalendarsFullAccessUsageDescription - Allow ScriptWidget to read events for calendar widgets you choose. + Allow ScriptWidget to read events from calendars you choose and create or update widget-owned events through actions you trigger. NSCalendarsUsageDescription - Allow ScriptWidget to read events for calendar widgets you choose. + Allow ScriptWidget to read events from calendars you choose and create or update widget-owned events through actions you trigger. CFBundleDisplayName ScriptWidget Studio CFBundleName @@ -68,5 +68,11 @@ ATSApplicationFontsPath . + NSContactsUsageDescription + Select contacts to share with your chosen widgets. + NSHomeKitUsageDescription + Read selected home accessories and run selected controls or scenes from widgets. + NSAlarmKitUsageDescription + Schedule alarms and timers you explicitly request from a widget. diff --git a/macOS/ScriptWidgetMac/Sidebar/SidebarView.swift b/macOS/ScriptWidgetMac/Sidebar/SidebarView.swift index be78dd68..2cf627b4 100644 --- a/macOS/ScriptWidgetMac/Sidebar/SidebarView.swift +++ b/macOS/ScriptWidgetMac/Sidebar/SidebarView.swift @@ -24,6 +24,7 @@ struct SidebarView: View { @State private var searchText = "" @State private var selectedRecordItem: ScriptModel? @State private var selectedCloudItem: ScriptModel? + @State private var selectedSystemItem: ScriptModel? // rename @State private var renameCurrentName = "" @@ -38,6 +39,7 @@ struct SidebarView: View { var body: some View { content .frame(minWidth: 230, idealWidth: 260, maxWidth: 320) + .sheet(item: $selectedSystemItem) { item in ScriptWidgetSystemAccessView(package: item.package) } .sheet(item: $selectedCloudItem) { item in ScriptWidgetCloudJSONView(package: item.package) } .sheet(item: $selectedRecordItem) { item in ScriptWidgetRecordsView(package: item.package) } .sheet(isPresented: $renameShowingSheet) { @@ -143,6 +145,9 @@ struct SidebarView: View { .padding(.vertical, 2) } .contextMenu(menuItems: { + if ScriptWidgetSystemAccessView.supports(item.package) { + Button("System Access", systemImage: "hand.raised") { selectedSystemItem = item } + } if item.package.readManifest()?.permissions.contains(.icloud) == true { Button("iCloud Data", systemImage: "icloud") { selectedCloudItem = item } } diff --git a/macOS/ScriptWidgetMac/StudioEditor.bundle/assets/index-BaJfekQk.js b/macOS/ScriptWidgetMac/StudioEditor.bundle/assets/index-BaJfekQk.js deleted file mode 100644 index 0f976695..00000000 --- a/macOS/ScriptWidgetMac/StudioEditor.bundle/assets/index-BaJfekQk.js +++ /dev/null @@ -1,59 +0,0 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();const Yd="modulepreload",Nd=function(n,e){return new URL(n,e).href},la={},Cs=function(e,t,i){let r=Promise.resolve();if(t&&t.length>0){let c=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),a=l?.nonce||l?.getAttribute("nonce");r=c(t.map(h=>{if(h=Nd(h,i),h in la)return;la[h]=!0;const u=h.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(i)for(let p=o.length-1;p>=0;p--){const m=o[p];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${f}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Yd,u||(d.as="script"),d.crossOrigin="",d.href=h,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((p,m)=>{d.addEventListener("load",p),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return r.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};let po=[],mh=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=mh[i])e=i+1;else return!0;if(e==t)return!1}}function aa(n){return n>=127462&&n<=127487}const ca=8205;function Hd(n,e,t=!0,i=!0){return(t?Oh:_d)(n,e,i)}function Oh(n,e,t){if(e==n.length)return e;e&&gh(n.charCodeAt(e))&&yh(n.charCodeAt(e-1))&&e--;let i=Ts(n,e);for(e+=ha(i);e=0&&aa(Ts(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function _d(n,e,t){for(;e>1;){let i=Oh(n,e-2,t);if(i=56320&&n<57344}function yh(n){return n>=55296&&n<56320}function ha(n){return n<65536?1:2}class re{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Bi(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),kt.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Bi(this,e,t);let i=[];return this.decompose(e,t,i,0),kt.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new pn(this),s=new pn(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new pn(this,e)}iterRange(e,t=this.length){return new Ah(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new bh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?re.empty:e.length<=32?new ve(e):kt.from(ve.split(e,[]))}}class ve extends re{constructor(e,t=Jd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new ep(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new ve(ua(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Or(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new ve(l,o.length+s.length));else{let a=l.length>>1;i.push(new ve(l.slice(0,a)),new ve(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof ve))return super.replace(e,t,i);[e,t]=Bi(this,e,t);let r=Or(this.text,Or(i.text,ua(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new ve(r,s):kt.from(ve.split(r,[]),s)}sliceString(e,t=this.length,i=` -`){[e,t]=Bi(this,e,t);let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=i),es&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new ve(i,r)),i=[],r=-1);return r>-1&&t.push(new ve(i,r)),t}}class kt extends re{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s=o){let c=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!c?i.push(l):l.decompose(e-o,t-o,i,c)}o=a+1}}replace(e,t,i){if([e,t]=Bi(this,e,t),i.lines=s&&t<=l){let a=o.replace(e-s,t-s,i),c=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>c>>6){let h=this.children.slice();return h[r]=a,new kt(h,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` -`){[e,t]=Bi(this,e,t);let r="";for(let s=0,o=0;se&&s&&(r+=i),eo&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof kt))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],c=e.children[s];if(a!=c)return i+a.scanIdentical(c,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new ve(d,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,c=-1,h=[];function u(d){let p;if(d.lines>s&&d instanceof kt)for(let m of d.children)u(m);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof ve&&a&&(p=h[h.length-1])instanceof ve&&d.lines+p.lines<=32?(a+=d.lines,c+=d.length+1,h[h.length-1]=new ve(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&f(),a+=d.lines,c+=d.length+1,h.push(d))}function f(){a!=0&&(l.push(h.length==1?h[0]:kt.from(h,c)),c=-1,a=h.length=0)}for(let d of e)u(d);return f(),l.length==1?l[0]:new kt(l,t)}}re.empty=new ve([""],0);function Jd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Or(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s=t&&(a>i&&(l=l.slice(0,i-r)),r0?1:(e instanceof ve?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof ve?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(r instanceof ve){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ve?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Ah{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new pn(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class bh{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(re.prototype[Symbol.iterator]=function(){return this.iter()},pn.prototype[Symbol.iterator]=Ah.prototype[Symbol.iterator]=bh.prototype[Symbol.iterator]=function(){return this});class ep{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}}function Bi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Ze(n,e,t=!0,i=!0){return Hd(n,e,t,i)}function tp(n){return n>=56320&&n<57344}function ip(n){return n>=55296&&n<56320}function Ne(n,e){let t=n.charCodeAt(e);if(!ip(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return tp(i)?(t-55296<<10)+(i-56320)+65536:t}function fl(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Qt(n){return n<65536?1:2}const mo=/\r\n?|\n/;var De=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(De||(De={}));class Zt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-r);s+=l}else{if(i!=De.Simple&&c>=e&&(i==De.TrackDel&&re||i==De.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i=0&&r<=t&&l>=e)return rt?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Zt(e)}static create(e){return new Zt(e)}}class $e extends Zt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Oo(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return go(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length0&&Gt(i,t,s.text),s.forward(h),l+=h}let c=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(h=!1){if(!h&&!r.length)return;of||u<0||f>t)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?re.of(d.split(i||mo)):d:re.empty,m=p.length;if(u==f&&m==0)return;uo&&Le(r,u-o,-1),Le(r,f-u,m),Gt(s,r,p),o=f}}return c(e),a(!l),l}static empty(e){return new $e(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;rl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Gt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,c,s,h,u),r=c,s=h}}}function go(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Sn(n),l=new Sn(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let c=Math.min(o.len,l.len);Le(r,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let c=0,h=o.len;for(;h;)if(l.ins==-1){let u=Math.min(h,l.len);c+=u,h-=u,l.forward(u)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||i.length>c),s.forward2(a),o.forward(a)}}}}class Sn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?re.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?re.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Yt{constructor(e,t,i,r){this.from=e,this.to=t,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Yt(i,r,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return A.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return A.range(this.anchor,r,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return A.range(e.anchor,e.head)}static create(e,t,i,r){return new Yt(e,t,i,r)}}class A{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:A.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new A(e.ranges.map(t=>Yt.fromJSON(t)),e.main)}static single(e,t=e){return new A([A.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;rr.from-s.from),t=e.indexOf(i);for(let r=1;rs.head?A.range(a,l):A.range(l,a))}}return new A(e,t)}}function xh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let dl=0;class K{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=dl++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new K(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:pl),!!e.static,e.enables)}of(e){return new gr([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new gr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new gr(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function pl(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class gr{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=dl++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,c=!1,h=[];for(let u of this.dependencies)u=="doc"?a=!0:u=="selection"?c=!0:(((t=e[u.id])!==null&&t!==void 0?t:1)&1)==0&&h.push(e[u.id]);return{create(u){return u.values[o]=i(u),1},update(u,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||yo(u,h)){let d=i(u);if(l?!fa(d,u.values[o],r):!r(d,u.values[o]))return u.values[o]=d,1}return 0},reconfigure:(u,f)=>{let d,p=f.config.address[s];if(p!=null){let m=Cr(f,p);if(this.dependencies.every(O=>O instanceof K?f.facet(O)===u.facet(O):O instanceof Te?f.field(O,!1)==u.field(O,!1):!0)||(l?fa(d=i(u),m,r):r(d=i(u),m)))return u.values[o]=m,0}else d=i(u);return u.values[o]=d,1}}}get extension(){return this}}function fa(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let c=[];for(let h=0;hi===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(jn).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(jn),o=r.facet(jn),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,jn.of({field:this,create:e})]}get extension(){return this}}const fi={lowest:4,low:3,default:2,high:1,highest:0};function rn(n){return e=>new wh(e,n)}const si={highest:rn(fi.highest),high:rn(fi.high),default:rn(fi.default),low:rn(fi.low),lowest:rn(fi.lowest)};class wh{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Hi{of(e){return new Ao(this,e)}reconfigure(e){return Hi.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ao{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class Pr{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let f of rp(e,t,o))f instanceof Te?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of r)l[f.id]=c.length<<1,c.push(d=>f.slot(d));let h=i?.config.facets;for(let f in s){let d=s[f],p=d[0].facet,m=h&&h[f]||[];if(d.every(O=>O.type==0))if(l[p.id]=a.length<<1|1,pl(m,d))a.push(i.facet(p));else{let O=p.combine(d.map(y=>y.value));a.push(i&&p.compare(O,i.facet(p))?i.facet(p):O)}else{for(let O of d)O.type==0?(l[O.id]=a.length<<1|1,a.push(O.value)):(l[O.id]=c.length<<1,c.push(y=>O.dynamicSlot(y)));l[p.id]=c.length<<1,c.push(O=>np(O,p,d))}}let u=c.map(f=>f(l));return new Pr(e,o,u,l,a,s)}}function rp(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let c=i[a].indexOf(o);c>-1&&i[a].splice(c,1),o instanceof Ao&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let c of o)s(c,l);else if(o instanceof Ao){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),s(c,l)}else if(o instanceof wh)s(o.inner,o.prec);else if(o instanceof Te)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof gr)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,fi.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(c==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,l)}}return s(n,fi.default),i.reduce((o,l)=>o.concat(l))}function mn(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Cr(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const vh=K.define(),bo=K.define({combine:n=>n.some(e=>e),static:!0}),kh=K.define({combine:n=>n.length?n[0]:void 0,static:!0}),Qh=K.define(),Ph=K.define(),Ch=K.define(),Th=K.define({combine:n=>n.length?n[0]:!1});class zt{constructor(e,t){this.type=e,this.value=t}static define(){return new sp}}class sp{of(e){return new zt(this,e)}}class op{constructor(e){this.map=e}of(e){return new W(this,e)}}class W{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new W(this.type,t)}is(e){return this.type==e}static define(e={}){return new op(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}}W.reconfigure=W.define();W.appendConfig=W.define();class Pe{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&xh(i,t.newLength),s.some(l=>l.type==Pe.time)||(this.annotations=s.concat(Pe.time.of(Date.now())))}static create(e,t,i,r,s,o){return new Pe(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Pe.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Pe.time=zt.define();Pe.userEvent=zt.define();Pe.addToHistory=zt.define();Pe.remote=zt.define();function lp(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i=n[i]))s=n[i++],o=n[i++];else if(r=0;r--){let s=i[r](n);s instanceof Pe?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Pe?n=s[0]:n=Rh(e,Zi(s),!1)}return n}function cp(n){let e=n.startState,t=e.facet(Ch),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=$h(i,So(e,s,n.changes.newLength),!0))}return i==n?n:Pe.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const hp=[];function Zi(n){return n==null?hp:Array.isArray(n)?n:[n]}var ye=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(ye||(ye={}));const up=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let xo;try{xo=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function fp(n){if(xo)return xo.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||up.test(t)))return!0}return!1}function dp(n){return e=>{if(!/\S/.test(e))return ye.Space;if(fp(e))return ye.Word;for(let t=0;t-1)return ye.Word;return ye.Other}}class _{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;lr.set(c,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(W.reconfigure)?(t=null,i=l.value):l.is(W.appendConfig)&&(t=null,i=Zi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Pr.resolve(i,r,this),s=new _(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=e.startState.facet(bo)?e.newSelection:e.newSelection.asSingle();new _(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:A.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=Zi(i.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return _.create({doc:e.doc,selection:A.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Pr.resolve(e.extensions||[],new Map),i=e.doc instanceof re?e.doc:re.of((e.doc||"").split(t.staticFacet(_.lineSeparator)||mo)),r=e.selection?e.selection instanceof A?e.selection:A.single(e.selection.anchor,e.selection.head):A.single(0);return xh(r,i.length),t.staticFacet(bo)||(r=r.asSingle()),new _(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(_.tabSize)}get lineBreak(){return this.facet(_.lineSeparator)||` -`}get readOnly(){return this.facet(Th)}phrase(e,...t){for(let i of this.facet(_.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(vh))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return dp(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=Ze(t,o,!1);if(s(t.slice(a,o))!=ye.Word)break;o=a}for(;ln.length?n[0]:4});_.lineSeparator=kh;_.readOnly=Th;_.phrases=K.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});_.languageData=vh;_.changeFilter=Qh;_.transactionFilter=Ph;_.transactionExtender=Ch;Hi.reconfigure=W.define();function yt(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}class Jt{eq(e){return this==e}range(e,t=e){return wo.create(e,t,this)}}Jt.prototype.startSide=Jt.prototype.endSide=0;Jt.prototype.point=!1;Jt.prototype.mapMode=De.TrackDel;function ml(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let wo=class Kh{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Kh(e,t,i)}};function vo(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Ol{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,c=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return c>=0?o:l;c>=0?l=a:o=a+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);sd||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(o<0&&(o=f),c.point&&(l=Math.max(l,d-f)),i.push(c),r.push(f-o),s.push(d-o))}return{mapped:i.length?new Ol(r,s,i,l):null,pos:o}}}class N{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new N(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(vo)),this.isEmpty)return t.length?N.of(t):this;let l=new Zh(this,null,-1).goto(0),a=0,c=[],h=new Bt;for(;l.value||a=0){let u=t[a++];h.addInner(u.from,u.to,u.value)||c.push(u)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return xn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return xn.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),l=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),a=da(o,l,i),c=new sn(o,a,s),h=new sn(l,a,s);i.iterGaps((u,f,d)=>pa(c,u,h,f,d,r)),i.empty&&i.length==0&&pa(c,0,h,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=da(s,o),a=new sn(s,l,0).goto(i),c=new sn(o,l,0).goto(i);for(;;){if(a.to!=c.to||!ko(a.active,c.active)||a.point&&(!c.point||!ml(a.point,c.point)))return!1;if(a.to>r)return!0;a.next(),c.next()}}static spans(e,t,i,r,s=-1){let o=new sn(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let c=Math.min(o.to,i);if(o.point){let h=o.activeForPoint(o.to),u=o.pointFroml&&(r.span(l,c,o.active,a),a=o.openEnd(c));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Bt;for(let r of e instanceof wo?[e]:t?pp(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return N.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=N.empty;r=r.nextLayer)t=new N(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}N.empty=new N([],[],null,-1);function pp(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(vo);e=i}return n}N.empty.nextLayer=N.empty;class Bt{finishChunk(e){this.chunks.push(new Ol(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Bt)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(N.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=N.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function da(n,e,t){let i=new Map;for(let s of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&r.push(new Zh(o,t,i,s));return r.length==1?r[0]:new xn(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)$s(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)$s(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),$s(this.heap,0)}}}function $s(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}class sn{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=xn.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Vn(this.active,e),Vn(this.activeTo,e),Vn(this.activeRank,e),this.minActive=ma(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t0;)t++;Yn(this.active,t,i),Yn(this.activeTo,t,r),Yn(this.activeRank,t,s),e&&Yn(e,t,this.cursor.from),this.minActive=ma(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Vn(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[r]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function pa(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,a=i-e,c=!!s.boundChange;for(let h=!1;;){let u=n.to+a-t.to,f=u||n.endSide-t.endSide,d=f<0?n.to+a:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&ml(n.point,t.point)&&ko(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,p,n.point,t.point),h=!1):(h&&s.boundChange(l),p>l&&!ko(n.active,t.active)&&s.compareRange(l,p,n.active,t.active),c&&po)break;l=d,f<=0&&n.next(),f>=0&&t.next()}}function ko(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function ma(n,e){let t=-1,i=1e9;for(let r=0;r=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=Ze(n,r)}return i===!0?-1:n.length}const Po="ͼ",Oa=typeof Symbol>"u"?"__"+Po:Symbol.for(Po),Co=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ga=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ei{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,c){let h=[],u=/^@(\w+)\b/.exec(o[0]),f=u&&u[1]=="keyframes";if(u&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(m=>o.map(O=>m.replace(/&/,O))).reduce((m,O)=>m.concat(O)),p,a);else if(p&&typeof p=="object"){if(!u)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,h,f)}else p!=null&&h.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(h.length||f)&&a.push((i&&!u&&!c?o.map(i):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=ga[Oa]||1;return ga[Oa]=e+1,Po+e.toString(36)}static mount(e,t,i){let r=e[Co],s=i&&i.nonce;r?s&&r.setNonce(s):r=new mp(e,s),r.mount(Array.isArray(t)?t:[t],e)}}let ya=new Map;class mp{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=ya.get(i);if(s)return e[Co]=s;this.sheet=new r.CSSStyleSheet,ya.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Co]=this}mount(e,t){let i=this.sheet,r=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),i)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},Aa=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Op=typeof navigator<"u"&&/Apple Computer/.test(navigator.vendor),gp=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),ba=typeof navigator<"u"&&/Mac/.test(navigator.platform),yp=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ap=Aa&&(ba||+Aa[1]<57)||gp&&ba;for(var Fe=0;Fe<10;Fe++)ti[48+Fe]=ti[96+Fe]=String(Fe);for(var Fe=1;Fe<=24;Fe++)ti[Fe+111]="F"+Fe;for(var Fe=65;Fe<=90;Fe++)ti[Fe]=String.fromCharCode(Fe+32),wn[Fe]=String.fromCharCode(Fe);for(var Rs in ti)wn.hasOwnProperty(Rs)||(wn[Rs]=ti[Rs]);function bp(n){var e=Ap&&(n.ctrlKey||n.altKey||n.metaKey)||(Op||yp)&&n.shiftKey&&n.key&&n.key.length==1,t=!e&&n.key||(n.shiftKey?wn:ti)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function he(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e2);var $={mac:wa||/Mac/.test(ze.platform),windows:/Win/.test(ze.platform),linux:/Linux|X11/.test(ze.platform),ie:hs,ie_version:Eh?To.documentMode||6:Ro?+Ro[1]:$o?+$o[1]:0,gecko:Sa,gecko_version:Sa?+(/Firefox\/(\d+)/.exec(ze.userAgent)||[0,0])[1]:0,chrome:!!Ks,chrome_version:Ks?+Ks[1]:0,ios:wa,android:/Android\b/.test(ze.userAgent),webkit:xa,webkit_version:xa?+(/\bAppleWebKit\/(\d+)/.exec(ze.userAgent)||[0,0])[1]:0,safari:Ko,safari_version:Ko?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ze.userAgent)||[0,0])[1]:0,tabSize:To.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function gl(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const Tr=Object.create(null);function yl(n,e,t){if(n==e)return!0;n||(n=Tr),e||(e=Tr);let i=Object.keys(n),r=Object.keys(e);if(i.length-0!=r.length-0)return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function Sp(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function va(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function xp(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Ai(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Uh(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Ai(e,i,r,t,e.widget||null,!0)}static line(e){return new Fn(e)}static set(e,t=!1){return N.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}B.none=N.empty;class Un extends B{constructor(e){let{start:t,end:i}=Uh(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?gl(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Tr}eq(e){return this==e||e instanceof Un&&this.tagName==e.tagName&&yl(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Un.prototype.point=!1;class Fn extends B{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Fn&&this.spec.class==e.spec.class&&yl(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Fn.prototype.mapMode=De.TrackBefore;Fn.prototype.point=!0;class Ai extends B{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?De.TrackBefore:De.TrackAfter:De.TrackDel}get type(){return this.startSide!=this.endSide?Xe.WidgetRange:this.startSide<=0?Xe.WidgetBefore:Xe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ai&&wp(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Ai.prototype.point=!0;function Uh(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function wp(n,e){return n==e||!!(n&&e&&n.compare(e))}function Mi(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}class vn extends Jt{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof vn&&this.tagName==e.tagName&&yl(this.attributes,e.attributes)}static create(e){return new vn(e.tagName,e.attributes||Tr,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return N.of(e,t)}}vn.prototype.startSide=vn.prototype.endSide=-1;function kn(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Zo(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function On(n,e){if(!e.anchorNode)return!1;try{return Zo(n,e.anchorNode)}catch{return!1}}function yr(n){return n.nodeType==3?Qn(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function gn(n,e,t,i){return t?ka(n,e,t,i,-1)||ka(n,e,t,i,1):!1}function ii(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function $r(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function ka(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:qt(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=ii(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?qt(n):0}else return!1}}function qt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Rr(n,e){let{left:t,right:i}=n;if(t==i)return n;let r=e?t:i;return{left:r,right:r,top:n.top,bottom:n.bottom}}function vp(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Fh(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function kp(n,e,t,i,r,s,o,l){let a=n.ownerDocument,c=a.defaultView||window;for(let h=n,u=!1;h&&!u;)if(h.nodeType==1){let f,d=h==a.body,p=1,m=1;if(d)f=vp(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let b=h.getBoundingClientRect();({scaleX:p,scaleY:m}=Fh(h,b)),f={left:b.left,right:b.left+h.clientWidth*p,top:b.top,bottom:b.top+h.clientHeight*m}}let O=0,y=0;if(r=="nearest")e.top0&&e.bottom>f.bottom+y&&(y=e.bottom-f.bottom+o)):e.bottom>f.bottom-o&&(y=e.bottom-f.bottom+o,t<0&&e.top-y0&&e.right>f.right+O&&(O=e.right-f.right+s)):e.right>f.right-s&&(O=e.right-f.right+s,t<0&&e.leftf.bottom||e.leftf.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function Dh(n,e=!0){let t=n.ownerDocument,i=null,r=null;for(let s=n.parentNode;s&&!(s==t.body||(!e||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}class Qp{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?qt(t):0),i,Math.min(e.focusOffset,i?qt(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}}function Xh(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function Lh(n,e=!0){for(let{node:t,left:i,top:r}of n)e&&t.scrollTop!=r&&(t.scrollTop=r),t.scrollLeft!=i&&(t.scrollLeft=i)}let ui=null;$.safari&&$.safari_version>=26&&(ui=!1);function Bh(n){if(n.setActive)return n.setActive();if(ui)return n.focus(ui);let e=Xh(n);n.focus(ui==null?{get preventScroll(){return ui={preventScroll:!0},!0}}:void 0),ui||(ui=!1,Lh(e))}let Qa;function Qn(n,e,t=e){let i=Qa||(Qa=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Ei(n,e,t,i){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,n.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,n.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Pp(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Cp(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,qt(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=qt(t))}else{if(t==n)return!0;i=ii(t),t=t.parentNode}}function qh(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function Ih(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=qt(t)}else if(t.parentNode&&!$r(t))i=ii(t),t=t.parentNode;else return null}}function zh(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.fromt:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Vh(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(St[m+1]==-d){let O=St[m+2],y=O&2?r:O&4?O&1?s:r:0;y&&(ue[u]=ue[St[m]]=y),l=m;break}}else{if(St.length==189)break;St[l++]=u,St[l++]=f,St[l++]=a}else if((p=ue[u])==2||p==1){let m=p==r;a=m?0:1;for(let O=l-3;O>=0;O-=3){let y=St[O+2];if(y&2)break;if(m)St[O+2]|=2;else{if(y&4)break;St[O+2]|=4}}}}}function Mp(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=ra;)p==O&&(p=t[--m].from,O=m?t[m-1].to:n),ue[--p]=d;a=h}else s=c,a++}}}function Eo(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,c=0;aa&&o.push(new Ct(a,m.from,d));let O=m.direction==bi!=!(d%2);Uo(n,O?i+1:i,r,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(h?ue[p]!=l:ue[p]==l))break;p++}f?Eo(n,a,p,i+1,r,f,o):ae;){let h=!0,u=!1;if(!c||a>s[c-1].to){let m=ue[a-1];m!=l&&(h=!1,u=m==16)}let f=!h&&l==1?[]:null,d=h?i:i+1,p=a;e:for(;;)if(c&&p==s[c-1].to){if(u)break e;let m=s[--c];if(!h)for(let O=m.from,y=c;;){if(O==e)break e;if(y&&s[y-1].to==O)O=s[--y].from;else{if(ue[O-1]==l)break e;break}}if(f)f.push(m);else{m.toue.length;)ue[ue.length]=256;let i=[],r=e==bi?0:1;return Uo(n,r,r,t,0,n.length,i),i}function Yh(n){return[new Ct(0,n,0)]}let Nh="";function Up(n,e,t,i,r){var s;let o=i.head-n.from,l=Ct.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],c=a.side(r,t);if(o==c){let f=l+=r?1:-1;if(f<0||f>=e.length)return null;a=e[l=f],o=a.side(!r,t),c=a.side(r,t)}let h=Ze(n.text,o,a.forward(r,t));(ha.to)&&(h=c),Nh=n.text.slice(Math.min(o,h),Math.max(o,h));let u=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return u&&h==c&&u.level+(r?0:1)n.some(e=>e)}),nu=K.define({combine:n=>n.some(e=>e)}),ru=K.define();class Ui{constructor(e,t,i,r,s,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Ui(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ui(A.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Nn=W.define({map:(n,e)=>n.map(e)}),su=W.define();function We(n,e,t){let i=n.facet(Jh);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Dt=K.define({combine:n=>n.length?n[0]:!0});let Dp=0;const Ti=K.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let a=[];return o&&a.push(us.of(c=>{let h=c.plugin(l);return h?o(h):B.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return xe.define((i,r)=>new e(i,r),t)}}class Zs{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(We(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){We(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){We(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ou=K.define(),xl=K.define(),us=K.define(),lu=K.define(),wl=K.define(),Dn=K.define(),au=K.define();function Pa(n,e){let t=n.state.facet(au);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return N.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let c=s-e.from,h=o-e.from,u=r;for(let f=l.length-1;f>=0;f--,a--){let d=l[f].spec.bidiIsolate,p;if(d==null&&(d=Fp(e.text,c,h)),a>0&&u.length&&(p=u[u.length-1]).to==c&&p.direction==d)p.to=h,u=p.inner;else{let m={from:c,to:h,direction:d,inner:[]};u.push(m),u=m.inner}}}}),r}const cu=K.define();function vl(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(cu)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}const hn=K.define();class ct{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new ct(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toAr.push(new ct(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new Kr(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Xp=[];class Se{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Xp}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Sp(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=ii(this.dom),r=this.length?e>0:t>0;return new pt(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof ds)return e;return null}static get(e){return e.cmTile}}class fs extends Se{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,r,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:t.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;r&&r!=l.dom;)r=Ca(r);else t.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=Ca(r);this.length=o}}function Ca(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ds extends fs{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Se.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&s++,r=t.pop()}else{let o=i.children[r++];if(o instanceof Xt)t.push(r),i=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,t){let i,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let c=a+l.length;if(e>=a&&e<=c){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(ae||e==a&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&t<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}}class Xt extends fs{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new Xt(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class qi extends fs{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let r=new qi(t||document.createElement("div"),e);return(!t||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,i){let r=null,s=-1,o=null,l=-1;function a(h,u){for(let f=0,d=0;f=u&&(p.isComposite()?a(p,u-d):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&Bp(o,p)))&&(m>u||p.flags&32&&t<=1)?(o=p,l=u-d):(d=-1)&&(r=p,s=u-d)),d=m}}a(this,e);let c=(t<0?r:o)||r||o;return c?{tile:c,offset:c==r?s:l}:null}coordsIn(e,t,i){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,i):Lp(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new pt(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new pt(a.dom,0);a==i.tile&&(l=!0)}}return new pt(this.dom,0)}}function Lp(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=yr(e);return t[t.length-1]||null}function Bp(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.topr&&(e=r);let s=e,o=e,l=0;e==0&&t<0||e==r&&t>=0?$.chrome||$.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return $.safari&&!l&&c.width==0&&(c=Array.prototype.find.call(a,h=>h.width)||c),i==null?c:Rr(c,(l?l>0:t<0)==i)}static of(e,t){let i=new pi(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Si extends Se{constructor(e,t,i,r){super(e,t,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(i)return Rr(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==i)}}class qp{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],c=a.breakAfter;(t>0?a.length<=e:a.length=0;l--){let a=t.marks[l],c=r.lastChild;if(c instanceof He&&c.mark.eq(a.mark))c.dom!=a.dom&&c.setDOM(Ms(a.dom)),r=c;else{if(this.cache.reused.get(a)){let u=Se.get(a.dom);u&&u.setDOM(Ms(a.dom))}let h=He.of(a.mark,a.dom);r.append(h),r=h}this.cache.reused.set(a,2)}let s=Se.get(e.text);s&&this.cache.reused.set(s,2);let o=new pi(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=hu);let r=qi.start(e,t||((i=this.cache.find(qi))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=r.lastChild)&&l instanceof He&&l.mark.eq(o))r=l,t--;else{let a=He.of(o,(i=this.cache.find(He,c=>c.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Ta(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!($.ios&&Ta(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Es,0,32)||new Si(Es.toDOM(),0,Es,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=e.rank*102+e.value.rank,i=new Ip(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.fromo.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Zr,void 0,1);return i&&(i.flags=t),i||new Zr(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Wp{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const Mr=[Si,qi,pi,He,Zr,Xt,ds];for(let n=0;n[]),this.index=Mr.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,s=0,o=0;;){let l=or){let c=a-r;this.preserve(c,!o,!l),r=a,s+=c}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let c=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof He&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof He&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,s=-1,o=N.spans(this.decorations,e,t,{point:(l,a,c,h,u,f)=>{if(c instanceof Ai){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=h.length,u>h.length)r.continueWidget(a-l);else{let d=c.widget||(c.block?Ii.block:Ii.inline),p=Yp(c),m=this.cache.findWidget(d,a-l,p)||Si.of(d,this.view,a-l,p);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(m)):(r.ensureLine(i),r.addInlineWidget(m,h,u))}i=null}else i=Np(i,c);a>l&&this.text.skip(a-l)},span:(l,a,c,h)=>{for(let u=l;u-1&&(this.openWidget=o>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=Se.get(r);if(r==this.view.contentDOM)break;s instanceof He?t.push(s):s?.isLine()?i=s:s instanceof Xt||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new qi(r,hu):i||t.push(He.of(new Un({tagName:r.nodeName.toLowerCase(),attributes:xp(r)}),r)))}return{line:i,marks:t}}}function Ta(n,e){let t=i=>{for(let r of i.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(n)}function Yp(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const hu={class:"cm-line"};function Np(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&gl(t,n),i&&(n.class+=" "+i)),n}function Gp(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof He&&e.push(i.mark)}return e}function Ms(n){let e=Se.get(n);return e&&e.setDOM(n.cloneNode()),n}class Ii extends Ut{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ii.inline=new Ii("span");Ii.block=new Ii("div");const Es=new class extends Ut{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class $a{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=B.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new ds(e,e.contentDOM),this.updateInner([new ct(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!sm(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?_p(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:u}=this.hasComposition;i=new ct(h,u,e.changes.mapPos(h,-1),e.changes.mapPos(u,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,($.ie||$.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=tm(o,this.decorations,e.changes);a.length&&(i=ct.extendWithRanges(i,a));let c=nm(l,this.blockWrappers,e.changes);return c.length&&(i=ct.extendWithRanges(i,c)),s&&!i.some(h=>h.fromA<=s.range.fromA&&h.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new Vp(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Se.get(t.text)&&l.cache.reused.set(Se.get(t.text),2),this.tile=l.run(e,t),Do(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=$.chrome||$.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&On(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,c,h;if(a.empty?h=c=this.inlineDOMNearPos(a.anchor,a.assoc||1):(h=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),c=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),$.gecko&&a.empty&&!this.hasComposition&&Hp(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=h=new pt(f,0),l=!0}let u=this.view.observer.selectionRange;(l||!u.focusNode||(!gn(c.node,c.offset,u.anchorNode,u.anchorOffset)||!gn(h.node,h.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{$.android&&$.chrome&&i.contains(u.focusNode)&&rm(u.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let f=kn(this.view.root);if(f)if(a.empty){if($.gecko){let d=Jp(c.node,c.offset);if(d&&d!=3){let p=(d==1?Ih:zh)(c.node,c.offset);p&&(c=new pt(p.node,p.offset))}}f.collapse(c.node,c.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(h.node,h.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([c,h]=[h,c]),d.setEnd(h.node,h.offset),d.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new pt(u.anchorNode,u.anchorOffset),this.impreciseHead=h.precise?null:new pt(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&gn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=kn(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!a||!c||a.bottom>c.top)return;let h=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(h.node,h.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&i.collapse(r,s)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[t];else{let o=qt(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!Se.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let a=i.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?r+t:r+(t?i.length:0):r}domAtPos(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(r,t):i.domIn(r,t)}inlineDOMNearPos(e,t){let i,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((c,h)=>{if(c.isWidget()){if(c.flags&32&&h>=e)return!0;c.flags&16&&(s=!0)}else{let u=h+c.length;if(h<=e&&(i=c,r=e-h,s=u=e&&!o&&(o=c,l=e-h,a=h>e),h>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(s&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(r,t):o.domIn(l,t))}coordsAt(e,t,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Us?null:r.coordsInWidget(s,t,!0):r.coordsIn(s,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==fe.LTR,c=0,h=(u,f,d)=>{for(let p=0;pr);p++){let m=u.children[p],O=f+m.length,y=m.dom.getBoundingClientRect(),{height:b}=y;if(d&&!p&&(c+=y.top-d.top),m instanceof Xt)O>i&&h(m,f,y);else if(f>=i&&(c>0&&t.push(-c),t.push(b+c),c=0,o)){let x=m.dom.lastChild,C=x?yr(x):[];if(C.length){let k=C[C.length-1],S=a?k.right-y.left:y.right-k.left;S>l&&(l=S,this.minWidth=s,this.minWidthFrom=f,this.minWidthTo=O)}}d&&p==u.children.length-1&&(c+=d.bottom-y.bottom),f=O+m.breakAfter}};return h(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?fe.RTL:fe.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let h=yr(c.dom);if(h.length!=1)return;l+=h[0].width,a=h[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=yr(t.firstChild)[0];i=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(B.replace({widget:new Us(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return B.set(e)}updateDeco(){let e=1,t=this.view.state.facet(us).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(wl).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(N.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(ru))try{if(c(this.view,e.range,e))return!0}catch(h){We(this.view.state,h,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=vl(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(kp(this.view.scrollDOM,o,t.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Do(this.tile)}}function Do(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Do(i,e)}}function Hp(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function uu(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=Ih(t.focusNode,t.focusOffset),r=zh(t.focusNode,t.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=Se.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(n.docView.lastCompositionAfterCursor){let a=Se.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(s=r)}}if(n.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function _p(n,e,t){let i=uu(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new ct(a.mapPos(s),a.mapPos(o),s,o),text:r}}function Jp(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}class Us extends Ut{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function om(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return A.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=Ze(r.text,s,!1):l=Ze(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let c=Ze(r.text,o,!1);if(i(r.text.slice(c,o))!=a)break;o=c}for(;ln.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Qo(o,s,n.state.tabSize)}function Xo(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.toe)return s;(!r||s.type==Xe.Text&&(r.type!=s.type||(t<0?s.frome)))&&(r=s)}}return r||i}return i}function am(n,e,t,i){let r=Xo(n,e.head,e.assoc||-1),s=!i||r.type!=Xe.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),a=n.posAtCoords({x:t==(l==fe.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return A.cursor(a,t?-1:1)}return A.cursor(t?r.to:r.from,t?-1:1)}function Ra(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let c=Up(r,s,o,l,t),h=Nh;if(!c){if(r.number==(t?n.state.doc.lines:1))return l;h=` -`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),c=n.visualLineSide(r,!t)}if(a){if(!a(h))return l}else{if(!i)return c;a=i(h)}l=c}}function cm(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==ye.Space&&(r=o),r==o}}function hm(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return A.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(r,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),h=n.documentTop;if(c)o==null&&(o=c.left-a.left),l=s<0?c.top:c.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+h}let u=a.left+o,f=n.viewState.heightOracle.textHeight>>1,d=i??f;for(let p=0;;p+=f){let m=l+(d+p)*s,O=Lo(n,{x:u,y:m},!1,s);if(t?m>a.bottom:ml:b{if(e>s&&er(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:A.cursor(i,in.viewState.docHeight)return new Pt(n.state.doc.length,-1);if(c=n.elementAtHeight(a),i==null)break;if(c.type==Xe.Text){if(i<0?c.ton.viewport.to)break;let f=n.docView.coordsAt(i<0?c.from:c.to,i>0?-1:1);if(f&&(i<0?f.top<=a+s:f.bottom>=a+s))break}let u=n.viewState.heightOracle.textHeight/2;a=i>0?c.bottom+u:c.top-u}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==Xe.Text){let u=lm(n,r,c,o,l);return new Pt(u,u==c.from?1:-1)}}if(c.type!=Xe.Text)return a<(c.top+c.bottom)/2?new Pt(c.from,1):new Pt(c.to,-1);let h=n.docView.lineAt(c.from,2);return(!h||h.length!=c.length)&&(h=n.docView.lineAt(c.from,-2)),new um(n,o,l,n.textDirectionAt(c.from)).scanTile(h,c.from)}class um{constructor(e,t,i,r){this.view=e,this.x=t,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from>1;t:if(o.has(m)){for(let b=1;b=s&&(x-=p),!o.has(x)){m=x;break t}}break e}o.add(m);let O=t(m),y=0;if(O)for(let b=0;b1))if(x.bottomthis.y)(!c||c.top>x.top)&&(c=x),y=-1;else{let C=x.left>this.x?this.x-x.left:x.right(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(c&&c.top<(p+m+m)/3)return this.y=c.top+1,this.scan(e,t,!0)}let d=(l?this.dirAt(e[h],1):this.baseDir)==fe.LTR;return{i:h,after:this.x>(f.left+f.right)/2==d}}scanText(e,t){let i=[];for(let s=0;s{let o=i[s]-t,l=i[s+1]-t;return Qn(e.dom,o,l).getClientRects()});return r.after?new Pt(i[r.i+1],-1):new Pt(i[r.i],1)}scanTile(e,t){if(!e.length)return new Pt(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Qn(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Pt(i[r.i+1],-1):new Pt(o,1)}}const ki="￿";class fm{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(_.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ki}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=Se.get(r),l=r.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=Se.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:$r(r))||$r(l)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!pm(l,t)&&this.lineBreak(),r=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){let t=Se.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(dm(e,i.node,i.offset)?t:0))}}function dm(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=du(e.docView.tile,t,i,0))){let a=s||o?[]:gm(e),c=new fm(a,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=ym(a,this.bounds.from)}else{let a=e.observer.selectionRange,c=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!Zo(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),h=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Zo(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if(($.ios||$.chrome)&&c!=h&&Math.min(c,h)<=l.main.from&&Math.max(c,h)>=l.main.to&&(u.from>0||u.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(A.range(h,c));else if(e.lineWrapping&&h==c&&!(l.main.empty&&l.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(c,-1),d=0;f&&(d=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=A.create([A.cursor(c,d)])}else this.newSel=A.single(h,c)}}}function du(n,e,t,i){if(n.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,c=i,h=i;at)return du(u,e,t,c);if(f>=e&&r==-1&&(r=a,s=c),c>t&&u.dom.parentNode==n.dom){o=a,l=h;break}h=f,c=f+u.breakAfter}return{from:s,to:l<0?i+n.length:l,startDOM:(r?n.children[r-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function pu(n,e){let t,{newSel:i}=e,{state:r}=n,s=r.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,c=s.from,h=null;(o===8||$.android&&e.text.length=l&&s.to<=a&&(e.typeOver||u!=e.text)&&u.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&u.slice(s.to-l)==e.text.slice(f=e.text.length-(u.length-(s.to-l)))?t={from:s.from,to:s.to,insert:re.of(e.text.slice(s.from-l,f).split(ki))}:(d=mu(u,e.text,c-l,h))&&($.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==ki+ki&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:re.of(e.text.slice(d.from,d.toB).split(ki))})}else i&&(!n.hasFocus&&r.facet(Dt)||Er(i,s))&&(i=null);if(!t&&!i)return!1;if(($.mac||$.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=A.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:re.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).toDate.now()-50?t={from:s.from,to:s.to,insert:r.toText(n.inputState.insertingText)}:$.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==` - `&&n.lineWrapping&&(i&&(i=A.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:re.of([" "])}),t)return kl(n,t,i,o);if(i&&!Er(i,s)){let l=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(l=!0),a=n.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=fu(r.facet(Dn).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function kl(n,e,t,i=-1){if($.ios&&n.inputState.flushIOSKey(e))return!0;let r=n.state.selection.main;if($.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&n.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ei(n.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.lengthr.head)&&Ei(n.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Ei(n.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=Om(n,e,t));return n.state.facet(eu).some(a=>a(n,e.from,e.to,s,l))||n.dispatch(l()),!0}function Om(n,e,t){let i,r=n.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromu(n)),c,a);e.from==h&&(o=h)}if(o>-1)i={changes:e,selection:A.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=s.frome.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let a=r.changes(e),c=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let h=n.state.sliceDoc(e.from,e.to),u,f=t&&uu(n,t.main.head);if(f){let p=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-p}}else u=n.state.doc.lineAt(s.head);let d=s.to-e.to;i=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:c||p.map(a)};let m=p.to-d,O=m-h.length;if(n.state.sliceDoc(O,m)!=h||m>=u.from&&O<=u.to)return{range:p};let y=r.changes({from:O,to:m,insert:e.insert}),b=p.to-s.to;return{changes:y,range:c?A.range(Math.max(0,c.anchor+b),Math.max(0,c.head+b)):p.map(y)}})}else i={changes:a,selection:c&&r.selection.replaceRange(c)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function mu(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function gm(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Ka(t,i)),(r!=t||s!=i)&&e.push(new Ka(r,s))),e}function ym(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?A.single(t+e,i+e):null}function Er(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class Am{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,$.safari&&e.contentDOM.addEventListener("input",()=>null),$.gecko&&Em(e.contentDOM.ownerDocument)}handleEvent(e){!Cm(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Sm(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&gu.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),$.android&&$.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if($.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Ou.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||xm.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&$.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&bm(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:$.safari&&!$.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function bm(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function Za(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){We(t.state,r)}}}function Sm(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&t(l).handlers.push(Za(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(Za(i.value,a))}}for(let i in gt)t(i).handlers.push(gt[i]);for(let i in Ve)t(i).observers.push(Ve[i]);return e}const Ou=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],xm="dthko",gu=[16,17,18,20,91,92,224,225],Gn=6;function Hn(n){return Math.max(0,n)*.7+8}function wm(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class vm{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Dh(e.contentDOM),this.atoms=e.state.facet(Dn).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(_.allowMultipleSelections)&&km(e,t),this.dragging=Pm(e,t)&&bu(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&wm(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=vl(this.view);e.clientX-a.left<=r+Gn?t=-Hn(r-e.clientX):e.clientX+a.right>=o-Gn&&(t=Hn(e.clientX-o)),e.clientY-a.top<=s+Gn?i=-Hn(s-e.clientY):e.clientY+a.bottom>=l-Gn&&(i=Hn(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=fu(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function km(n,e){let t=n.state.facet(Gh);return t.length?t[0](e):$.mac?e.metaKey:e.ctrlKey}function Qm(n,e){let t=n.state.facet(Hh);return t.length?t[0](e):$.mac?!e.altKey:!e.ctrlKey}function Pm(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=kn(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Cm(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Se.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const gt=Object.create(null),Ve=Object.create(null),yu=$.ie&&$.ie_version<15||$.ios&&$.webkit_version<604;function Tm(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),Au(n,t.value)},50)}function ps(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function Au(n,e){e=ps(n.state,bl,e);let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Bo!=null&&t.selection.ranges.every(a=>a.empty)&&Bo==s.toString()){let a=-1;i=t.changeByRange(c=>{let h=t.doc.lineAt(c.from);if(h.from==a)return{range:c};a=h.from;let u=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:u},range:A.cursor(c.from+u.length)}})}else o?i=t.changeByRange(a=>{let c=s.line(r++);return{changes:{from:a.from,to:a.to,insert:c.text},range:A.cursor(a.from+c.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Ve.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,$.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};Ve.wheel=Ve.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};gt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);Ve.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};Ve.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Ve.touchend=(n,e)=>{n.inputState.touchActive=!1};gt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(_h))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Rm(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new vm(n,e,t,i)),i&&n.observer.ignore(()=>{Bh(n.contentDOM);let s=n.root.activeElement;s&&!s.contains(n.contentDOM)&&s.blur()});let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function Ma(n,e,t,i){if(i==1)return A.cursor(e,t);if(i==2)return om(n.state,e,t);{let r=n.docView.lineAt(e,t),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(Ua+1)%3:1}function Rm(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=bu(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=n.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,h=Ma(n,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let u=Ma(n,t.pos,t.assoc,i),f=Math.min(u.from,h.from),d=Math.max(u.to,h.to);h=f1&&(c=Km(r,a.pos))?c:l?r.addRange(h):A.create([h])}}}function Km(n,e){for(let t=0;t=e)return A.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}gt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=A.undirectionalRange(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",ps(n.state,Sl,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};gt.dragend=n=>(n.inputState.draggedContent=null,!1);function Da(n,e,t,i){if(t=ps(n.state,bl,t),!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&Qm(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}gt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&Da(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Da(n,e,i,!0),!0}return!1};gt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=yu?null:e.clipboardData;return t?(Au(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Tm(n),!1)};function Zm(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Mm(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:ps(n,Sl,e.join(n.lineBreak)),ranges:t,linewise:i}}let Bo=null;gt.copy=gt.cut=(n,e)=>{if(!On(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=Mm(n.state);if(!t&&!r)return!1;Bo=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=yu?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Zm(n,t),!1)};const Su=zt.define();function xu(n,e){let t=[];for(let i of n.facet(tu)){let r=i(n,e);r&&t.push(r)}return t.length?n.update({effects:t,annotations:Su.of(!0)}):null}function wu(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=xu(n.state,e);t?n.dispatch(t):n.update([])}},10)}Ve.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),wu(n)};Ve.blur=n=>{n.observer.clearSelectionRange(),wu(n)};Ve.compositionstart=Ve.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};Ve.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,$.chrome&&$.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};Ve.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};gt.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=n.posAtDOM(l.startContainer,l.startOffset),c=n.posAtDOM(l.endContainer,l.endOffset);return kl(n,{from:a,to:c,insert:n.state.toText(s)},null),!0}}let r;if($.chrome&&$.android&&(r=Ou.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return $.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),$.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>Ve.compositionend(n,e),20),!1};const Xa=new Set;function Em(n){Xa.has(n)||(Xa.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const La=["pre-wrap","normal","pre-line","break-spaces"];let zi=!1;function Ba(){zi=!1}class Um{constructor(e){this.lineWrapping=e,this.doc=re.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return La.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Ar&&(zi=!0),this.height=e)}replace(e,t,i){return je.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:h,toB:u}=r[l],f=s.lineAt(a,pe.ByPosNoHeight,i.setDoc(t),0,0),d=f.to>=c?f:s.lineAt(c,pe.ByPosNoHeight,i,0,0);for(u+=d.to-c,c=d.to;l>0&&f.from<=r[l-1].toA;)a=r[l-1].fromA,h=r[l-1].fromB,l--,as*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r=s&&o(this.lineAt(0,pe.ByPos,i,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ot extends vu{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new dt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof ot||r instanceof Ee&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Ee?r=new ot(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):je.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ee extends je{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e0){let s=i[i.length-1];s instanceof Ee?i[i.length-1]=new Ee(s.length+r):i.push(null,new Ee(r-1))}if(e>0){let s=i[0];s instanceof Ee?i[0]=new Ee(e+s.length):i.unshift(new Ee(e-1),null)}return je.of(i)}decomposeLeft(e,t){t.push(new Ee(e-1),null)}decomposeRight(e,t){t.push(null,new Ee(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new Ee(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let h=e.doc.lineAt(l).length;o.length&&o.push(null);let u=r.heights[r.index++],f=0;u<0&&(f=-u,u=r.heights[r.index++]),a==-1?a=u:Math.abs(u-a)>=Ar&&(a=-2);let d=new ot(h,u,f);d.outdated=!1,o.push(d),l+=h+1}l<=s&&o.push(null,new Ee(s-l).updateHeight(e,l));let c=je.of(o);return(a<0||Math.abs(c.height-this.height)>=Ar||Math.abs(a-this.heightMetrics(e,t).perLine)>=Ar)&&(zi=!0),Ur(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Xm extends je{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return el))return c;let h=t==pe.ByPosNoHeight?pe.ByPosNoHeight:pe.ByPos;return a?c.join(this.right.lineAt(l,h,i,o,l)):this.left.lineAt(l,h,i,r,s).join(c)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,l,a,o);else{let c=this.lineAt(a,pe.ByPos,i,r,s);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,l,a,o)}}replace(e,t,i){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&qa(s,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?je.of(this.break?[e,null,t]:[e,t]):(this.left=Ur(this.left,e),this.right=Ur(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function qa(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Ee&&(i=n[e+1])instanceof Ee&&n.splice(e-1,3,new Ee(t.length+1+i.length))}const Lm=5;class Ql{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof ot?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ot(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=Lm)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new ot(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new Ee(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ot)return e;let t=new ot(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ot)&&!this.isCovered?this.nodes.push(new ot(0,-1,0)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&u.overflow!="visible"){let f=h.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(c==n.parentNode?r.innerHeight:a,f.bottom)}c=u.position=="absolute"||u.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function zm(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function Wm(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Ds{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Um(i),this.stateDeco=Wa(t),this.heightMap=je.empty().applyChanges(this.stateDeco,re.empty,this.heightOracle.setDoc(t.doc),[new ct(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=B.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new _n(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?za:new Pl(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(un(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Wa(this.state);let r=e.changedRanges,s=ct.extendWithRanges(r,Bm(i,this.stateDeco,e?e.changes:$e.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ba(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||zi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let c=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(nu)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?fe.RTL:fe.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,h=0;if(l.width&&l.height){let{scaleX:k,scaleY:S}=Fh(t,l);(k>.005&&Math.abs(this.scaleX-k)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=k,this.scaleY=S,c|=16,o=a=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let d=Dh(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=qh(this.scrollParent||e.win);let m=(this.printing?Wm:Im)(t,this.paddingTop),O=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView&&!this.scrollTarget&&!zm(e.dom))return 0;let x=l.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),a){let k=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(k)&&(o=!0),o||r.lineWrapping&&Math.abs(x-this.contentDOMWidth)>r.charWidth){let{lineHeight:S,charWidth:v,textHeight:U}=e.docView.measureTextSize();o=S>0&&r.refresh(s,S,v,U,Math.max(5,x/v),k),o&&(e.docView.minWidth=0,c|=16)}O>0&&y>0?h=Math.max(O,y):O<0&&y<0&&(h=Math.min(O,y)),Ba();for(let S of this.viewports){let v=S.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?je.empty().applyChanges(this.stateDeco,re.empty,this.heightOracle,[new ct(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Fm(S.from,v))}zi&&(c|=2)}let C=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return C&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||C)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new _n(r.lineAt(o-i*1e3,pe.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,pe.ByHeight,s,0,0).to);if(t){let{head:c}=t.range;if(ca.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(c,pe.ByPos,s,0,0),f;t.y=="center"?f=(u.top+u.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&c=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=fe.LTR&&!i)return[];let l=[],a=(h,u,f,d)=>{if(u-hh&&yy.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)y.fromb));if(!O){if(ux.from<=u&&x.to>=u)){let x=t.moveToLineBoundary(A.cursor(u),!1,!0).head;x>h&&(u=x)}let y=this.gapSize(f,h,u,d),b=i||y<2e6?y:2e6;O=new Ds(h,u,y,b)}l.push(O)},c=h=>{if(h.length2e6)for(let S of e)S.from>=h.from&&S.fromh.from&&a(h.from,d,h,u),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];N.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||un(this.heightMap.lineAt(e,pe.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||un(this.heightMap.lineAt(this.scaler.fromDOM(e),pe.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return un(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class _n{constructor(e,t){this.from=e,this.to=t}}function Vm(n,e,t){let i=[],r=n,s=0;return N.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function er(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Ym(n,e){for(let t of n)if(e(t))return t}const za={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Wa(n){let e=n.facet(us).filter(i=>typeof i!="function"),t=n.facet(wl).filter(i=>typeof i!="function");return t.length&&e.push(N.join(t)),e}class Pl{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let c=t.lineAt(l,pe.ByPos,e,0,0).top,h=t.lineAt(a,pe.ByPos,e,0,0).bottom;return r+=h-c,{from:l,to:a,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function un(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new dt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>un(r,e)):n._content)}const tr=K.define({combine:n=>n.join(" ")}),qo=K.define({combine:n=>n.indexOf(!0)>-1}),Io=ei.newName(),ku=ei.newName(),Qu=ei.newName(),Pu={"&light":"."+ku,"&dark":"."+Qu};function zo(n,e,t){return new ei(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}const Nm=zo("."+Io,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Pu),Gm={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Xs=$.ie&&$.ie_version<=11;class Hm{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Qp,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);($.ie&&$.ie_version<=11||$.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&$.android&&e.constructor.EDIT_CONTEXT!==!1&&!($.chrome&&$.chrome_version<126)&&(this.editContext=new Jm(e),e.state.facet(Dt)&&(e.contentDOM.editContext=this.editContext.editContext)),Xs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Dt)?i.root.activeElement!=this.dom:!On(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}($.ie&&$.ie_version<=11||$.android&&$.chrome)&&!i.state.selection.main.empty&&r.focusNode&&gn(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=kn(e.root);if(!t)return!1;let i=$.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&_m(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=On(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ei(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&On(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new mm(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=pu(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Er(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=ja(t,e.previousSibling||e.target.previousSibling,-1),r=ja(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Dt)!=e.state.facet(Dt)&&(e.view.contentDOM.editContext=e.state.facet(Dt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function ja(n,e,t){for(;e;){let i=Se.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Va(n,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return gn(o.node,o.offset,r,s)&&([t,i,r,s]=[r,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}}function _m(n,e){if(e.getComposedRanges){let r=e.getComposedRanges(n.root)[0];if(r)return Va(n,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Va(n,t):null}class Jm{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let c=a-l>i.text.length;l==this.from&&sthis.to&&(a=s);let h=mu(e.state.sliceDoc(l,a),i.text,(c?r.from:r.to)-l,c?"end":null);if(!h){let f=A.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Er(f,r)||e.dispatch({selection:f,userEvent:"select"});return}let u={from:h.from+l,to:h.toA+l,insert:re.of(i.text.slice(h.from,h.toB).split(` -`))};if(($.mac||$.android)&&u.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:l,to:a,insert:re.of([i.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let f=this.to-this.from+(u.to-u.from+u.insert.length);kl(e,u,A.single(this.toEditorPos(i.selectionStart,f),this.toEditorPos(i.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=kn(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,c)=>{if(i)return;let h=c.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=h,this.to+=h;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=h,this.to+=h;else if(sthis.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=h}t+=h}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class R{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Pp(e.parent)||document,this.viewState=new Ia(this,e.state||_.create(e)),e.scrollTo&&e.scrollTo.is(Nn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ti).map(r=>new Zs(r));for(let r of this.plugins)r.update(this);this.observer=new Hm(this),this.inputState=new Am(this),this.inputState.ensureHandlers(this.plugins),this.docView=new $a(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Pe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let f of e){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(Su))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=xu(s,o),a||(l=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(_.phrases)!=this.state.facet(_.phrases))return this.setState(s);r=Kr.create(this,s,e),r.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:p,y:m}=this.state.facet(R.cursorScrollMargin);u=new Ui(d.empty?d:A.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of f.effects)d.is(Nn)&&(u=d.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Fr.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(hn)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(tr)!=r.state.facet(tr)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Fo))try{f(r)}catch(d){We(this.state,d,"update listener")}(a||h)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!pu(this,h)&&c.force&&Ei(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Ia(this,e),this.plugins=e.facet(Ti).map(i=>new Zs(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new $a(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ti),i=e.state.facet(Ti);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new Zs(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(qh(i||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(d=>{try{return d.read(this)}catch(p){return We(this.state,p),Ya}}),u=Kr.create(this,this.state,[]),f=!1;u.flags|=a,t?t.flags|=a:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u),f&&this.docViewUpdate());for(let d=0;d1||p<-1)&&!($.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Fo))l(t)}get themeClasses(){return Io+" "+(this.state.facet(qo)?Qu:ku)+" "+this.state.facet(tr)}updateAttrs(){let e=Na(this,ou,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Dt)?"true":"false",class:"cm-content",style:`${$.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Na(this,xl,t);let i=this.observer.ignore(()=>{let r=va(this.contentDOM,this.contentAttrs,t),s=va(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(R.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(hn);let e=this.state.facet(R.cspNonce);ei.mount(this.root,this.styleModules.concat(Nm).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Fs(this,e,Ra(this,e,t,i))}moveByGroup(e,t){return Fs(this,e,Ra(this,e,t,i=>cm(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return A.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return am(this,e,t,i)}moveVertically(e,t,i){return Fs(this,e,hm(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Lo(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Lo(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),r=this.bidiSpans(i),s=r[Ct.find(r,e-i.from,-1,t)];return this.docView.coordsAt(e,t,s.dir==fe.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(iu)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>eO)return Yh(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Vh(s.isolates,i=Pa(this,e))))return s.order;i||(i=Pa(this,e));let r=Ep(e.text,t,i);return this.bidiCache.push(new Fr(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||$.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Bh(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,r,s,o;return Nn.of(new Ui(typeof e=="number"?A.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Nn.of(new Ui(A.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return xe.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return xe.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ei.newName(),r=[tr.of(i),hn.of(zo(`.${i}`,e))];return t&&t.dark&&r.push(qo.of(!0)),r}static baseTheme(e){return si.lowest(hn.of(zo("."+Io,e,Pu)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&Se.get(i)||Se.get(e);return((t=r?.root)===null||t===void 0?void 0:t.view)||null}}R.styleModule=hn;R.inputHandler=eu;R.clipboardInputFilter=bl;R.clipboardOutputFilter=Sl;R.scrollHandler=ru;R.focusChangeEffect=tu;R.perLineTextDirection=iu;R.exceptionSink=Jh;R.updateListener=Fo;R.editable=Dt;R.mouseSelectionStyle=_h;R.dragMovesSelection=Hh;R.clickAddsSelectionRange=Gh;R.decorations=us;R.blockWrappers=lu;R.outerDecorations=wl;R.atomicRanges=Dn;R.bidiIsolatedRanges=au;R.cursorScrollMargin=K.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});R.scrollMargins=cu;R.darkTheme=qo;R.cspNonce=K.define({combine:n=>n.length?n[0]:""});R.contentAttributes=xl;R.editorAttributes=ou;R.lineWrapping=R.contentAttributes.of({class:"cm-lineWrapping"});R.announce=W.define();const eO=4096,Ya={};class Fr{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:fe.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&gl(o,t)}return t}const tO=$.mac?"mac":$.windows?"win":$.linux?"linux":"key";function iO(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;ai.concat(r),[]))),t}function rO(n,e,t){return Tu(Cu(n.state),e,n,t)}let Nt=null;const sO=4e3;function oO(n,e=tO){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,c,h)=>{var u,f;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>iO(y,e));for(let y=1;y{let C=Nt={view:x,prefix:b,scope:o};return setTimeout(()=>{Nt==C&&(Nt=null)},sO),!0}]})}let m=p.join(" ");r(m,!1);let O=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((f=(u=d._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});a&&O.run.push(a),c&&(O.preventDefault=!0),h&&(O.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let h=t[c]||(t[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let f in h)h[f].run.push(d=>u(d,Wo))}let a=o[e]||o.key;if(a)for(let c of l)s(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let Wo=null;function Tu(n,e,t,i){Wo=e;let r=bp(e),s=Ne(r,0),o=Qt(s)==r.length&&r!=" ",l="",a=!1,c=!1,h=!1;Nt&&Nt.view==t&&Nt.scope==i&&(l=Nt.prefix+" ",gu.indexOf(e.keyCode)<0&&(c=!0,Nt=null));let u=new Set,f=O=>{if(O){for(let y of O.run)if(!u.has(y)&&(u.add(y),y(t)))return O.stopPropagation&&(h=!0),!0;O.preventDefault&&(O.stopPropagation&&(h=!0),c=!0)}return!1},d=n[i],p,m;return d&&(f(d[l+ir(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!($.windows&&e.ctrlKey&&e.altKey)&&!($.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=ti[e.keyCode])&&p!=r?(f(d[l+ir(p,e,!0)])||e.shiftKey&&(m=wn[e.keyCode])!=r&&m!=p&&f(d[l+ir(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(d[l+ir(r,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),c&&(a=!0),a&&h&&e.stopPropagation(),Wo=null,a}class Oi{constructor(e,t,i,r,s){this.className=e,this.left=t,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=$u(e);return[new Oi(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return lO(e,t,i)}}function $u(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==fe.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Ha(n,e,t,i){let r=n.coordsAtPos(e,t*2);if(!r)return i;let s=n.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=n.posAtCoords({x:s.left+1,y:o}),a=n.posAtCoords({x:s.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function lO(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),r=Math.min(t.to,n.viewport.to),s=n.textDirection==fe.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=$u(n),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=l.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),f=l.right-(h?parseInt(h.paddingRight):0),d=Xo(n,i,1),p=Xo(n,r,-1),m=d.type==Xe.Text?d:null,O=p.type==Xe.Text?p:null;if(m&&(n.lineWrapping||d.widgetLineBreaks)&&(m=Ha(n,i,1,m)),O&&(n.lineWrapping||p.widgetLineBreaks)&&(O=Ha(n,r,-1,O)),m&&O&&m.from==O.from&&m.to==O.to)return b(x(t.from,t.to,m));{let k=m?x(t.from,null,m):C(d,!1),S=O?x(null,t.to,O):C(p,!0),v=[];return(m||d).to<(O||p).from-(m&&O?1:0)||d.widgetLineBreaks>1&&k.bottom+n.defaultLineHeight/2M&&Q.from=P)break;ee>D&&E(Math.max(J,D),k==null&&J<=M,Math.min(ee,P),S==null&&ee>=Y,le.dir)}if(D=V.to+1,D>=P)break}return j.length==0&&E(M,k==null,Y,S==null,n.textDirection),{top:U,bottom:F,horizontal:j}}function C(k,S){let v=l.top+(S?k.top:k.bottom);return{top:v,bottom:v,horizontal:[]}}}function aO(n,e){return n.constructor==e.constructor&&n.eq(e)}class cO{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(br)!=e.state.facet(br)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(br);for(;t!aO(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[i].constructor&&r.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,$.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const br=K.define();function Ru(n){return[xe.define(e=>new cO(e,n)),br.of(n)]}const Wi=K.define({combine(n){return yt(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function hO(n={}){return[Wi.of(n),uO,fO,pO,nu.of(!0)]}function Ku(n){return n.startState.facet(Wi)!=n.state.facet(Wi)}const uO=Ru({above:!0,markers(n){let{state:e}=n,t=e.facet(Wi),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||t.drawRangeCursor&&!(s&&$.ios&&t.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:A.cursor(r.head,r.assoc);for(let a of Oi.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Ku(n);return t&&_a(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){_a(e.state,n)},class:"cm-cursorLayer"});function _a(n,e){e.style.animationDuration=n.facet(Wi).cursorBlinkRate+"ms"}const fO=Ru({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let r of i)if(!r.empty)for(let s of Oi.forRange(n,"cm-selectionBackground",r))e.push(s);if($.ios&&!t.empty&&n.state.facet(Wi).iosSelectionHandles){for(let r of Oi.forRange(n,"cm-selectionHandle cm-selectionHandle-start",A.cursor(t.from,1)))e.push(r);for(let r of Oi.forRange(n,"cm-selectionHandle cm-selectionHandle-end",A.cursor(t.to,1)))e.push(r)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Ku(n)},class:"cm-selectionLayer"}),dO=$.gecko&&$.gecko_version==153?"#ffffff01":"transparent",pO=si.highest(R.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${dO} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Zu=W.define({map(n,e){return n==null?null:e.mapPos(n)}}),fn=Te.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Zu)?i.value:t,n)}}),mO=xe.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(fn);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(fn)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(fn),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(fn)!=n&&this.view.dispatch({effects:Zu.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function OO(){return[fn,mO]}function Ja(n,e,t,i,r){e.lastIndex=0;for(let s=n.iterRange(t,i),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function gO(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:r,to:s}of t)r=Math.max(n.state.doc.lineAt(r).from,r-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}class yO{constructor(e){const{regexp:t,decoration:i,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,a,c,h)=>r(h,c,c+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,c,h)=>{let u=i(l,a,c);u&&h(c,c+l[0].length,u)};else if(i)this.addMatch=(l,a,c,h)=>h(c,c+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new Bt,i=t.add.bind(t);for(let{from:r,to:s}of gO(e,this.maxLength))Ja(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(i=Math.min(l,i),r=Math.max(a,r))}),e.viewportMoved||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),l=Math.min(s.to,r);if(l>=o){let a=e.state.doc.lineAt(o),c=a.toa.from;o--)if(this.boundary.test(a.text[o-1-a.from])){h=o;break}for(;lf.push(y.range(m,O));if(a==c)for(this.regexp.lastIndex=h-a.from;(d=this.regexp.exec(a.text))&&d.indexthis.addMatch(O,e,m,p));t=t.update({filterFrom:h,filterTo:u,filter:(m,O)=>mu,add:f})}}return t}}const jo=/x/.unicode!=null?"gu":"g",AO=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,jo),bO={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Ls=null;function SO(){var n;if(Ls==null&&typeof document<"u"&&document.body){let e=document.body.style;Ls=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Ls||!1}const Sr=K.define({combine(n){let e=yt(n,{render:null,specialChars:AO,addSpecialChars:null});return(e.replaceTabs=!SO())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,jo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,jo)),e}});function xO(n={}){return[Sr.of(n),wO()]}let ec=null;function wO(){return ec||(ec=xe.fromClass(class{constructor(n){this.view=n,this.decorations=B.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Sr)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new yO({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=Ne(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,a=_i(o.text,l,i-o.from);return B.replace({widget:new PO((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=B.replace({widget:new QO(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Sr);n.startState.facet(Sr)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const vO="•";function kO(n){return n>=32?vO:n==10?"␤":String.fromCharCode(9216+n)}class QO extends Ut{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=kO(this.code),i=e.state.phrase("Control character")+" "+(bO[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class PO extends Ut{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function CO(){return $O}const TO=B.line({class:"cm-activeLine"}),$O=xe.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(TO.range(r.from)),e=r.from)}return B.set(t)}},{decorations:n=>n.decorations}),Vo=2e3;function RO(n,e,t){let i=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>Vo||t.off>Vo||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=r;a++){let c=n.doc.line(a);c.length<=l&&s.push(A.range(c.from+o,c.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=r;a++){let c=n.doc.line(a),h=Qo(c.text,o,n.tabSize,!0);if(h<0)s.push(A.cursor(c.to));else{let u=Qo(c.text,l,n.tabSize);s.push(A.range(c.from+h,c.from+u))}}}return s}function KO(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function tc(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),r=t-i.from,s=r>Vo?-1:r==i.length?KO(n,e.clientX):_i(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:s,off:r}}function ZO(n,e){let t=tc(n,e),i=n.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(r.changes)}},get(r,s,o){let l=tc(n,r);if(!l)return i;let a=RO(n.state,t,l);return a.length?o?A.create(a.concat(i.ranges)):A.create(a):i}}:null}function MO(n){let e=(t=>t.altKey&&t.button==0);return R.mouseSelectionStyle.of((t,i)=>e(i)?ZO(t,i):null)}const EO={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},UO={style:"cursor: crosshair"};function FO(n={}){let[e,t]=EO[n.key||"Alt"],i=xe.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==e||t(r))},keyup(r){(r.keyCode==e||!t(r))&&this.set(!1)},mousemove(r){this.set(t(r))}}});return[i,R.contentAttributes.of(r=>{var s;return!((s=r.plugin(i))===null||s===void 0)&&s.isDown?UO:null})]}const nr="-10000px";class Mu{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;at[c]=a),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function DO(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Bs=K.define({combine:n=>{var e,t,i;return{position:$.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||DO}}}),ic=new WeakMap,Cl=xe.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Bs);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Mu(n,Os,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Bs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=nr,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if($.safari){let o=s.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(n=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=vl(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Bs).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:i,scaleX:r,scaleY:s}=n,o=[];for(let l=0;l=Math.min(t.bottom,i.bottom)||u.rightMath.min(t.right,i.right)+.1)){h.style.top=nr;continue}let d=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=f.right-f.left,O=(e=ic.get(c))!==null&&e!==void 0?e:f.bottom-f.top,y=c.offset||LO,b=this.view.textDirection==fe.LTR,x=f.width>i.right-i.left?b?i.left:i.right-f.width:b?Math.max(i.left,Math.min(u.left-(d?14:0)+y.x,i.right-m)):Math.min(Math.max(i.left,u.left-m+(d?14:0)-y.x),i.right-m),C=this.above[l];!a.strictSide&&(C?u.top-O-p-y.yi.bottom)&&C==i.bottom-u.bottom>u.top-i.top&&(C=this.above[l]=!C);let k=(C?u.top-i.top:i.bottom-u.bottom)-p;if(kx&&U.topS&&(S=C?U.top-O-2-p:U.bottom+p+2);if(this.position=="absolute"?(h.style.top=(S-n.parent.top)/s+"px",nc(h,(x-n.parent.left)/r)):(h.style.top=S/s+"px",nc(h,x/r)),d){let U=u.left+(b?y.x:-y.x)-(x+14-7);d.style.left=U/r+"px"}c.overlap!==!0&&o.push({left:x,top:S,right:v,bottom:S+O}),h.classList.toggle("cm-tooltip-above",C),h.classList.toggle("cm-tooltip-below",!C),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=nr}},{eventObservers:{scroll(){this.maybeMeasure()}}});function nc(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const XO=R.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),LO={x:0,y:0},Os=K.define({enables:[Cl,XO]}),Dr=K.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class gs{static create(e){return new gs(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Mu(e,Dr,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const BO=Os.compute([Dr],n=>{let e=n.facet(Dr);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:gs.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),qO=K.define();class IO{constructor(e,t,i,r,s,o){this.view=e,this.source=t,this.field=i,this.locked=r,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||t.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),a=l&&l.dir==fe.RTL?-1:1;s=t.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];r&&this.locked.set(a,r),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:t};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>We(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(Cl),t=e?e.manager.tooltips.findIndex(i=>i.create==gs.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&!this.locked.has(r)&&s&&!zO(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,l=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!WO(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const rr=4;function zO(n,e){let{left:t,right:i,top:r,bottom:s}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();r=Math.min(l.top,r),s=Math.max(l.bottom,s)}return e.clientX>=t-rr&&e.clientX<=i+rr&&e.clientY>=r-rr&&e.clientY<=s+rr}function WO(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.rightr||Math.min(o.bottom,l)=e&&a<=t}function Eu(n,e={}){let t=W.define(),i=new WeakMap,r=Te.define({create(){return[]},update(o,l){let a=i.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(c=>!e.hideOn(l,c)))),l.docChanged&&o.length){let c=[];for(let h of o){let u=l.changes.mapPos(h.pos,-1,De.TrackDel);if(u!=null){let f=Object.assign(Object.create(null),h);f.pos=u,f.end!=null&&(f.end=l.changes.mapPos(f.end)),c.push(f)}}o=c}for(let c of l.effects)c.is(t)&&(o=c.value,a=void 0),(c.is(jO)&&!c.value||c.value==r)&&(o=[]);return o.length&&a&&i.set(o,a),o},provide:o=>Dr.from(o)});const s=xe.define(o=>new IO(o,n,r,i,t,e.hoverTime||300));return{active:r,extension:[r,s,qO.of(s),BO]}}function Uu(n,e){let t=n.plugin(Cl);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const jO=W.define(),rc=K.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Fu(n,e){let t=n.plugin(Du),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Du=xe.fromClass(class{constructor(n){this.input=n.state.facet(ji),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(rc);this.top=new sr(n,!0,e.topContainer),this.bottom=new sr(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(rc);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new sr(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new sr(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(ji);if(t!=this.input){let i=t.filter(a=>a),r=[],s=[],o=[],l=[];for(let a of i){let c=this.specs.indexOf(a),h;c<0?(h=a(n.view),l.push(h)):(h=this.panels[c],h.update&&h.update(n)),r.push(h),(h.top?s:o).push(h)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>R.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class sr{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=sc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=sc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function sc(n){let e=n.nextSibling;return n.remove(),e}const ji=K.define({enables:Du});function VO(n,e){let t,i=new Promise(o=>t=o),r=o=>YO(o,e,t);n.state.field(qs,!1)?n.dispatch({effects:Xu.of(r)}):n.dispatch({effects:W.appendConfig.of(qs.init(()=>[r]))});let s=Lu.of(r);return{close:s,result:i.then(o=>((n.win.queueMicrotask||(a=>n.win.setTimeout(a,10)))(()=>{n.state.field(qs).indexOf(r)>-1&&n.dispatch({effects:s})}),o))}}const qs=Te.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(Xu)?n=[t.value].concat(n):t.is(Lu)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>ji.computeN([n],e=>e.field(n))}),Xu=W.define(),Lu=W.define();function YO(n,e,t){let i=e.content?e.content(n,()=>o(null)):null;if(!i){if(i=he("form"),e.input){let l=he("input",e.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),i.appendChild(he("label",(e.label||"")+": ",l))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(he("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let r=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let l=0;l{c.keyCode==27?(c.preventDefault(),o(null)):c.keyCode==13&&(c.preventDefault(),o(a))}),a.addEventListener("submit",c=>{c.preventDefault(),o(a)})}let s=he("div",i,he("button",{onclick:()=>o(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(s.className=e.class),s.classList.add("cm-dialog");function o(l){s.contains(s.ownerDocument.activeElement)&&n.focus(),t(l)}return{dom:s,top:e.top,mount:()=>{if(e.focus){let l;typeof e.focus=="string"?l=i.querySelector(e.focus):l=i.querySelector("input")||i.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}class Mt extends Jt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Mt.prototype.elementClass="";Mt.prototype.toDOM=void 0;Mt.prototype.mapMode=De.TrackBefore;Mt.prototype.startSide=Mt.prototype.endSide=-1;Mt.prototype.point=!0;const xr=K.define(),NO=K.define(),GO={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>N.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},An=K.define();function Bu(n){return[qu(),An.of({...GO,...n})]}const oc=K.define({combine:n=>n.some(e=>e)});function qu(n){return[HO]}const HO=xe.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(An).map(e=>new ac(n,e)),this.fixed=!n.state.facet(oc);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(oc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=N.iter(this.view.state.facet(xr),this.view.viewport.from),i=[],r=this.gutters.map(s=>new _O(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Xe.Text&&o){Yo(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Xe.Text){Yo(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(An),t=n.state.facet(An),i=n.docChanged||n.heightChanged||n.viewportChanged||!N.eq(n.startState.facet(xr),n.state.facet(xr),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new ac(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>R.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==fe.LTR?{left:i,right:r}:{right:i,left:r}})});function lc(n){return Array.isArray(n)?n:[n]}function Yo(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class _O{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=N.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Iu(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Yo(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),r=i?[i]:null;for(let s of e.state.facet(NO)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class ac{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=lc(t.markers(e)),t.initialSpacer&&(this.spacer=new Iu(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=lc(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!N.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Iu{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),JO(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=ss(l,a,c)||o(l,a,c):o}return i}})}});class Is extends Mt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function zs(n,e){return n.state.facet($i).formatNumber(e,n.state)}const ig=An.compute([$i],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(eg)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new Is(zs(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let r of e.state.facet(tg)){let s=r(e,t,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet($i)!=e.state.facet($i),initialSpacer(e){return new Is(zs(e,cc(e.state.doc.lines)))},updateSpacer(e,t){let i=zs(t.view,cc(t.view.state.doc.lines));return i==e.number?e:new Is(i)},domEventHandlers:n.facet($i).domEventHandlers,side:"before"}));function ng(n={}){return[$i.of(n),qu(),ig]}function cc(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.head).from;r>t&&(t=r,e.push(rg.range(r)))}return N.of(e)});function og(){return sg}const zu=1024;let lg=0;class Ws{constructor(e,t){this.from=e,this.to=t}}class H{constructor(e={}){this.id=lg++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=et.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}H.closedBy=new H({deserialize:n=>n.split(" ")});H.openedBy=new H({deserialize:n=>n.split(" ")});H.group=new H({deserialize:n=>n.split(" ")});H.isolate=new H({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});H.contextHash=new H({perNode:!0});H.lookAhead=new H({perNode:!0});H.mounted=new H({perNode:!0});class bn{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[H.mounted.id]}}const ag=Object.create(null);class et{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):ag,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new et(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(H.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(H.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}}et.none=new et("",Object.create(null),0,8);class Tl{constructor(e){this.types=e;for(let t=0;t0;for(let a=this.cursor(o|be.IncludeAnonymous);;){let c=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Kl(et.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new ke(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new ke(et.none,t,i,r)))}static build(e){return fg(e)}}ke.empty=new ke(et.none,[],[],0);class $l{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new $l(this.buffer,this.index)}}class ni{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return et.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Pn(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?l.length:-1;e!=c;e+=t){let h=l[e],u=a[e]+o.from,f;if(!(!(s&be.EnterBracketed&&h instanceof ke&&(f=bn.get(h))&&!f.overlay&&f.bracketed&&i>=u&&i<=u+h.length)&&!Wu(r,i,u,u+h.length))){if(h instanceof ni){if(s&be.ExcludeBuffers)continue;let d=h.findChild(0,h.buffer.length,t,i-u,r);if(d>-1)return new Tt(new cg(o,h,e,u),null,d)}else if(s&be.IncludeAnonymous||!h.type.isAnonymous||Rl(h)){let d;if(!(s&be.IgnoreMounts)&&(d=bn.get(h))&&!d.overlay)return new Je(d.tree,u,e,o);let p=new Je(h,u,e,o);return s&be.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?h.children.length-1:0,t,i,r,s)}}}if(s&be.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&be.IgnoreOverlays)&&(r=bn.get(this._tree))&&r.overlay){let s=e-this.from,o=i&be.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l=s:a>s))return new Je(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function uc(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function No(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class cg{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}}class Tt extends ju{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new Tt(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&be.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new Tt(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Tt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Tt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new ke(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Vu(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;st.from||o.to=e){let l=new Je(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Pn(l,e,t,!1))}}return r?Vu(r):i}class Go{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~be.EnterBracketed,e instanceof Je)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof Je?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&be.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&be.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&be.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&be.IncludeAnonymous||l instanceof ni||!l.type.isAnonymous||Rl(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r=0;s--){if(s<0)return No(this._tree,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Rl(n){return n.children.some(e=>e instanceof ni||!e.type.isAnonymous||Rl(e))}function fg(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=zu,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new $l(t,t.length):t,a=i.types,c=0,h=0;function u(k,S,v,U,F,j){let{id:E,start:M,end:Y,size:Q}=l,D=h,P=c;if(Q<0)if(l.next(),Q==-1){let q=s[E];v.push(q),U.push(M-k);return}else if(Q==-3){c=E;return}else if(Q==-4){h=E;return}else throw new RangeError(`Unrecognized record size: ${Q}`);let V=a[E],le,J,ee=M-k;if(Y-M<=r&&(J=O(l.pos-S,F))){let q=new Uint16Array(J.size-J.skip),G=l.pos-J.size,ce=q.length;for(;l.pos>G;)ce=y(J.start,q,ce);le=new ni(q,Y-J.start,i),ee=J.start-k}else{let q=l.pos-Q;l.next();let G=[],ce=[],I=E>=o?E:-1,te=0,se=Y;for(;l.pos>q;)I>=0&&l.id==I&&l.size>=0?(l.end<=se-r&&(p(G,ce,M,te,l.end,se,I,D,P),te=G.length,se=l.end),l.next()):j>2500?f(M,q,G,ce):u(M,q,G,ce,I,j+1);if(I>=0&&te>0&&te-1&&te>0){let Me=d(V,P);le=Kl(V,G,ce,0,G.length,0,Y-M,Me,Me)}else le=m(V,G,ce,Y-M,D-Y,P)}v.push(le),U.push(ee)}function f(k,S,v,U){let F=[],j=0,E=-1;for(;l.pos>S;){let{id:M,start:Y,end:Q,size:D}=l;if(D>4)l.next();else{if(E>-1&&Y=0;Q-=3)M[D++]=F[Q],M[D++]=F[Q+1]-Y,M[D++]=F[Q+2]-Y,M[D++]=D;v.push(new ni(M,F[2]-Y,i)),U.push(Y-k)}}function d(k,S){return(v,U,F)=>{let j=0,E=v.length-1,M,Y;if(E>=0&&(M=v[E])instanceof ke){if(!E&&M.type==k&&M.length==F)return M;(Y=M.prop(H.lookAhead))&&(j=U[E]+M.length+Y)}return m(k,v,U,F,j,S)}}function p(k,S,v,U,F,j,E,M,Y){let Q=[],D=[];for(;k.length>U;)Q.push(k.pop()),D.push(S.pop()+v-F);k.push(m(i.types[E],Q,D,j-F,M-j,Y)),S.push(F-v)}function m(k,S,v,U,F,j,E){if(j){let M=[H.contextHash,j];E=E?[M].concat(E):[M]}if(F>25){let M=[H.lookAhead,F];E=E?[M].concat(E):[M]}return new ke(k,S,v,U,E)}function O(k,S){let v=l.fork(),U=0,F=0,j=0,E=v.end-r,M={size:0,start:0,skip:0};e:for(let Y=v.pos-k;v.pos>Y;){let Q=v.size;if(v.id==S&&Q>=0){M.size=U,M.start=F,M.skip=j,j+=4,U+=4,v.next();continue}let D=v.pos-Q;if(Q<0||D=o?4:0,V=v.start;for(v.next();v.pos>D;){if(v.size<0)if(v.size==-3||v.size==-4)P+=4;else break e;else v.id>=o&&(P+=4);v.next()}F=V,U+=Q,j+=P}return(S<0||U==k)&&(M.size=U,M.start=F,M.skip=j),M.size>4?M:void 0}function y(k,S,v){let{id:U,start:F,end:j,size:E}=l;if(l.next(),E>=0&&U4){let Y=l.pos-(E-4);for(;l.pos>Y;)v=y(k,S,v)}S[--v]=M,S[--v]=j-k,S[--v]=F-k,S[--v]=U}else E==-3?c=U:E==-4&&(h=U);return v}let b=[],x=[];for(;l.pos>0;)u(n.start||0,n.bufferStart||0,b,x,-1,0);let C=(e=n.length)!==null&&e!==void 0?e:b.length?x[0]+b[0].length:0;return new ke(a[n.topID],b.reverse(),x.reverse(),C)}const fc=new WeakMap;function wr(n,e){if(!n.isAnonymous||e instanceof ni||e.type!=n)return 1;let t=fc.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof ke)){t=1;break}t+=wr(n,i)}fc.set(e,t)}return t}function Kl(n,e,t,i,r,s,o,l,a){let c=0;for(let p=i;p=h)break;S+=v}if(x==C+1){if(S>h){let v=p[C];d(v.children,v.positions,0,v.children.length,m[C]+b);continue}u.push(p[C])}else{let v=m[x-1]+p[x-1].length-k;u.push(Kl(n,p,m,C,x,k,v,null,a))}f.push(k+b-s)}}return d(e,t,i,r,0),(l||a)(u,f,o)}class dg{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Tt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Je&&this.map.set(e.tree,t)}get(e){return e instanceof Tt?this.getBuffer(e.context.buffer,e.index):e instanceof Je?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class gi{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new gi(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let h=l=i)for(;o&&o.from=f.from||u<=f.to||c){let d=Math.max(f.from,a)-c,p=Math.min(f.to,u)-c;f=d>=p?null:new gi(d,p,f.tree,f.offset+c,l>0,!!h)}if(f&&r.push(f),o.to>u)break;o=snew Ws(r.from,r.to)):[new Ws(0,0)]:[new Ws(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}}class pg{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new H({perNode:!0});let mg=0;class at{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=mg++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof at&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new at(i,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Xr(e);return i=>i.modified.indexOf(t)>-1?i:Xr.get(i.base||i,i.modified.concat(t).sort((r,s)=>r.id-s.id))}}let Og=0;class Xr{constructor(e){this.name=e,this.instances=[],this.id=Og++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&gg(t,l.modified));if(i)return i;let r=[],s=new at(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=yg(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(Xr.get(l,a));return s}}function gg(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function yg(n){let e=[[]];for(let t=0;ti.length-t.length)}function Nu(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let u=0;;){if(l=="..."&&u>0&&u+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==r.length)break;let d=r[u++];if(u==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(u)}let a=s.length-1,c=s[a];if(!c)throw new RangeError("Invalid path: "+r);let h=new Cn(i,o,a>0?s.slice(0,a):null);e[c]=h.sort(e[c])}}return Gu.add(e)}const Gu=new H({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new Cn(r.tags,r.mode,r.context);t?t.next=s:i=s,t=s}return i}});class Cn{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let l of s)for(let a of l.set){let c=t[a.id];if(c){o=o?o+" "+c:c;break}}return o},scope:i}}function Ag(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function bg(n,e,t,i=0,r=n.length){let s=new Sg(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}class Sg{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=r,h=xg(e)||Cn.empty,u=Ag(s,h.tags);if(u&&(c&&(c+=" "),c+=u,h.mode==1&&(r+=(r?" ":"")+u)),this.startSpan(Math.max(t,l),c),h.opaque)return;let f=e.tree&&e.tree.prop(H.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+l,1),p=this.highlighters.filter(O=>!O.scope||O.scope(f.tree.type)),m=e.firstChild();for(let O=0,y=l;;O++){let b=O=x||!e.nextSibling())););if(!b||x>i)break;y=b.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,b.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),c))}m&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}}function xg(n){let e=n.type.prop(Gu);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const T=at.define,lr=T(),jt=T(),dc=T(jt),pc=T(jt),Vt=T(),ar=T(Vt),js=T(Vt),vt=T(),ai=T(vt),xt=T(),wt=T(),Ho=T(),on=T(Ho),cr=T(),g={comment:lr,lineComment:T(lr),blockComment:T(lr),docComment:T(lr),name:jt,variableName:T(jt),typeName:dc,tagName:T(dc),propertyName:pc,attributeName:T(pc),className:T(jt),labelName:T(jt),namespace:T(jt),macroName:T(jt),literal:Vt,string:ar,docString:T(ar),character:T(ar),attributeValue:T(ar),number:js,integer:T(js),float:T(js),bool:T(Vt),regexp:T(Vt),escape:T(Vt),color:T(Vt),url:T(Vt),keyword:xt,self:T(xt),null:T(xt),atom:T(xt),unit:T(xt),modifier:T(xt),operatorKeyword:T(xt),controlKeyword:T(xt),definitionKeyword:T(xt),moduleKeyword:T(xt),operator:wt,derefOperator:T(wt),arithmeticOperator:T(wt),logicOperator:T(wt),bitwiseOperator:T(wt),compareOperator:T(wt),updateOperator:T(wt),definitionOperator:T(wt),typeOperator:T(wt),controlOperator:T(wt),punctuation:Ho,separator:T(Ho),bracket:on,angleBracket:T(on),squareBracket:T(on),paren:T(on),brace:T(on),content:vt,heading:ai,heading1:T(ai),heading2:T(ai),heading3:T(ai),heading4:T(ai),heading5:T(ai),heading6:T(ai),contentSeparator:T(vt),list:T(vt),quote:T(vt),emphasis:T(vt),strong:T(vt),link:T(vt),monospace:T(vt),strikethrough:T(vt),inserted:T(),deleted:T(),changed:T(),invalid:T(),meta:cr,documentMeta:T(cr),annotation:T(cr),processingInstruction:T(cr),definition:at.defineModifier("definition"),constant:at.defineModifier("constant"),function:at.defineModifier("function"),standard:at.defineModifier("standard"),local:at.defineModifier("local"),special:at.defineModifier("special")};for(let n in g){let e=g[n];e instanceof at&&(e.name=n)}Hu([{tag:g.link,class:"tok-link"},{tag:g.heading,class:"tok-heading"},{tag:g.emphasis,class:"tok-emphasis"},{tag:g.strong,class:"tok-strong"},{tag:g.keyword,class:"tok-keyword"},{tag:g.atom,class:"tok-atom"},{tag:g.bool,class:"tok-bool"},{tag:g.url,class:"tok-url"},{tag:g.labelName,class:"tok-labelName"},{tag:g.inserted,class:"tok-inserted"},{tag:g.deleted,class:"tok-deleted"},{tag:g.literal,class:"tok-literal"},{tag:g.string,class:"tok-string"},{tag:g.number,class:"tok-number"},{tag:[g.regexp,g.escape,g.special(g.string)],class:"tok-string2"},{tag:g.variableName,class:"tok-variableName"},{tag:g.local(g.variableName),class:"tok-variableName tok-local"},{tag:g.definition(g.variableName),class:"tok-variableName tok-definition"},{tag:g.special(g.variableName),class:"tok-variableName2"},{tag:g.definition(g.propertyName),class:"tok-propertyName tok-definition"},{tag:g.typeName,class:"tok-typeName"},{tag:g.namespace,class:"tok-namespace"},{tag:g.className,class:"tok-className"},{tag:g.macroName,class:"tok-macroName"},{tag:g.propertyName,class:"tok-propertyName"},{tag:g.operator,class:"tok-operator"},{tag:g.comment,class:"tok-comment"},{tag:g.meta,class:"tok-meta"},{tag:g.invalid,class:"tok-invalid"},{tag:g.punctuation,class:"tok-punctuation"}]);var Vs;const Ri=new H;function _u(n){return K.define({combine:n?e=>e.concat(n):void 0})}const Zl=new H;class mt{constructor(e,t,i=[],r=""){this.data=e,this.name=r,_.prototype.hasOwnProperty("tree")||Object.defineProperty(_.prototype,"tree",{get(){return Ce(this)}}),this.parser=t,this.extension=[ri.of(this),_.languageData.of((s,o,l)=>{let a=mc(s,o,l),c=a.type.prop(Ri);if(!c)return[];let h=s.facet(c),u=a.type.prop(Zl);if(u){let f=a.resolve(o-a.from,l);for(let d of u)if(d.test(f,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(h)}}return h})].concat(i)}isActiveAt(e,t,i=-1){return mc(e,t,i).type.prop(Ri)==this.data}findRegions(e){let t=e.facet(ri);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Ri)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(H.mounted);if(l){if(l.tree.prop(Ri)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;ai.isTop?t:void 0)]}),e.name)}configure(e,t){return new Lr(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ce(n){let e=n.field(mt.state,!1);return e?e.tree:ke.empty}class wg{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let ln=null;class Br{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Br(e,t,[],ke.empty,0,i,[],null)}startParse(){return this.parser.startParse(new wg(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ke.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(gi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ln;ln=this;try{return e()}finally{ln=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Oc(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,h,u,f)=>a.push({fromA:c,toA:h,fromB:u,toB:f})),i=gi.applyChanges(i,a),r=ke.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);he.from&&(this.fragments=Oc(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Yu{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=ln;if(a){for(let c of r)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new ke(et.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return ln}}function Oc(n,e,t){return gi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class Vi{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new Vi(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Br.create(e.facet(ri).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new Vi(i)}}mt.state=Te.define({create:Vi.init,update(n,e){for(let t of e.effects)if(t.is(mt.setState))return t.value;return e.startState.facet(ri)!=e.state.facet(ri)?Vi.init(e.state):n.apply(e)}});let Ju=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Ju=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Ys=typeof navigator<"u"&&(!((Vs=navigator.scheduling)===null||Vs===void 0)&&Vs.isInputPending)?()=>navigator.scheduling.isInputPending():null,vg=xe.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(mt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(mt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Ju(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,a=s.context.work(()=>Ys&&Ys()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:mt.setState.of(new Vi(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>We(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ri=K.define({combine(n){return n.length?n[0]:null},enables:n=>[mt.state,vg,R.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class kg{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Qg=K.define(),ys=K.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function qr(n){let e=n.facet(ys);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Tn(n,e){let t="",i=n.tabSize,r=n.facet(ys)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s=e?Pg(n,t,e):null}class As{constructor(e,t={}){this.state=e,this.options=t,this.unit=qr(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return _i(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ef=new H;function Pg(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o&&!(o.fromi.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return tf(i,n,t)}function tf(n,e,t){for(let i=n;i;i=i.next){let r=Tg(i.node);if(r)return r(El.create(e,t,i))}return 0}function Cg(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Tg(n){let e=n.type.prop(ef);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(H.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>nf(o,!0,1,void 0,s&&!Cg(o)?r.from:void 0)}return n.parent==null?$g:null}function $g(){return 0}class El extends As{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new El(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Rg(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return tf(this.context.next,this.base,this.pos)}}function Rg(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Kg(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+c}}l=a.to}}function Zg({closing:n,align:e=!0,units:t=1}){return i=>nf(i,e,t,n)}function nf(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?Kg(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const Mg=n=>n.baseIndent;function Ns({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const Eg=200;function Ug(){return _.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+Eg)return n;let s=t.sliceString(r.from,i);if(!e.some(c=>c.test(s)))return n;let{state:o}=n,l=-1,a=[];for(let{head:c}of o.selection.ranges){let h=o.doc.lineAt(c);if(h.from==l)continue;l=h.from;let u=Ml(o,h.from);if(u==null)continue;let f=/^\s*/.exec(h.text)[0],d=Tn(o,u);f!=d&&a.push({from:h.from,to:h.from+f.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const Fg=K.define(),rf=new H;function Dg(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(s&&l.from=e&&c.to>t&&(s=c)}}return s}function Lg(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Ir(n,e,t){for(let i of n.facet(Fg)){let r=i(n,e,t);if(r)return r}return Xg(n,e,t)}function sf(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const bs=W.define({map:sf}),Xn=W.define({map:sf});function of(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const xi=Te.define({create(){return B.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,r)=>n=gc(n,i,r)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(bs)&&!Bg(n,i.value.from,i.value.to)?t.push(i.value):i.is(Xn)&&(n=n.update({filter:(r,s)=>i.value.from!=r||i.value.to!=s,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(cf),r=t.map(s=>(i?B.replace({widget:new Yg(i(e.state,s))}):yc).range(s.from,s.to));n=n.update({add:r})}return e.selection&&(n=gc(n,e.selection.main.head)),n},provide:n=>R.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,r)=>{t.push(i,r)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{re&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(r,s)=>r>=t||s<=e}):n}function zr(n,e,t){var i;let r=null;return(i=n.field(xi,!1))===null||i===void 0||i.between(e,t,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function Bg(n,e,t){let i=!1;return n.between(e,e,(r,s)=>{r==e&&s==t&&(i=!0)}),i}function lf(n,e){return n.field(xi,!1)?e:e.concat(W.appendConfig.of(hf()))}const qg=n=>{for(let e of of(n)){let t=Ir(n.state,e.from,e.to);if(t)return n.dispatch({effects:lf(n.state,[bs.of(t),af(n,t)])}),!0}return!1},Ig=n=>{if(!n.state.field(xi,!1))return!1;let e=[];for(let t of of(n)){let i=zr(n.state,t.from,t.to);i&&e.push(Xn.of(i),af(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function af(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,r=n.state.doc.lineAt(e.to).number;return R.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${r}.`)}const zg=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(xi,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,r)=>{t.push(Xn.of({from:i,to:r}))}),n.dispatch({effects:t}),!0},jg=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:qg},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ig},{key:"Ctrl-Alt-[",run:zg},{key:"Ctrl-Alt-]",run:Wg}],Vg={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},cf=K.define({combine(n){return yt(n,Vg)}});function hf(n){return[xi,Hg]}function uf(n,e){let{state:t}=n,i=t.facet(cf),r=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=zr(n.state,l.from,l.to);a&&n.dispatch({effects:Xn.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const yc=B.replace({widget:new class extends Ut{toDOM(n){return uf(n,null)}}});class Yg extends Ut{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return uf(e,this.value)}}const Ng={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Gs extends Mt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Gg(n={}){let e={...Ng,...n},t=new Gs(e,!0),i=new Gs(e,!1),r=xe.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(ri)!=o.state.facet(ri)||o.startState.field(xi,!1)!=o.state.field(xi,!1)||Ce(o.startState)!=Ce(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Bt;for(let a of o.viewportLineBlocks){let c=zr(o.state,a.from,a.to)?i:Ir(o.state,a.from,a.to)?t:null;c&&l.add(a.from,a.from,c)}return l.finish()}}),{domEventHandlers:s}=e;return[r,Bu({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(r))===null||l===void 0?void 0:l.markers)||N.empty},initialSpacer(){return new Gs(e,!1)},domEventHandlers:{...s,click:(o,l,a)=>{if(s.click&&s.click(o,l,a))return!0;let c=zr(o.state,l.from,l.to);if(c)return o.dispatch({effects:Xn.of(c)}),!0;let h=Ir(o.state,l.from,l.to);return h?(o.dispatch({effects:bs.of(h)}),!0):!1}}}),hf()]}const Hg=R.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Ln{constructor(e,t){this.specs=e;let i;function r(l){let a=ei.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof mt?l=>l.prop(Ri)==o.data:o?l=>l==o:void 0,this.style=Hu(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new ei(i):null,this.themeType=t.themeType}static define(e,t){return new Ln(e,t||{})}}const _o=K.define(),_g=K.define({combine(n){return n.length?[n[0]]:null}});function Hs(n){let e=n.facet(_o);return e.length?e:n.facet(_g)}function Jg(n,e){let t=[t0],i;return n instanceof Ln&&(n.module&&t.push(R.styleModule.of(n.module)),i=n.themeType),i?t.push(_o.computeN([R.darkTheme],r=>r.facet(R.darkTheme)==(i=="dark")?[n]:[])):t.push(_o.of(n)),t}class e0{constructor(e){this.markCache=Object.create(null),this.tree=Ce(e.state),this.decorations=this.buildDeco(e,Hs(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ce(e.state),i=Hs(e.state),r=i!=Hs(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return B.none;let i=new Bt;for(let{from:r,to:s}of e.visibleRanges)bg(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=B.mark({class:a})))},r,s);return i.finish()}}const t0=si.high(xe.fromClass(e0,{decorations:n=>n.decorations})),i0=Ln.define([{tag:g.meta,color:"#404740"},{tag:g.link,textDecoration:"underline"},{tag:g.heading,textDecoration:"underline",fontWeight:"bold"},{tag:g.emphasis,fontStyle:"italic"},{tag:g.strong,fontWeight:"bold"},{tag:g.strikethrough,textDecoration:"line-through"},{tag:g.keyword,color:"#708"},{tag:[g.atom,g.bool,g.url,g.contentSeparator,g.labelName],color:"#219"},{tag:[g.literal,g.inserted],color:"#164"},{tag:[g.string,g.deleted],color:"#a11"},{tag:[g.regexp,g.escape,g.special(g.string)],color:"#e40"},{tag:g.definition(g.variableName),color:"#00f"},{tag:g.local(g.variableName),color:"#30a"},{tag:[g.typeName,g.namespace],color:"#085"},{tag:g.className,color:"#167"},{tag:[g.special(g.variableName),g.macroName],color:"#256"},{tag:g.definition(g.propertyName),color:"#00c"},{tag:g.comment,color:"#940"},{tag:g.invalid,color:"#f00"}]),n0=R.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ff=1e4,df="()[]{}",pf=K.define({combine(n){return yt(n,{afterCursor:!0,brackets:df,maxScanDistance:ff,renderMatch:o0})}}),r0=B.mark({class:"cm-matchingBracket"}),s0=B.mark({class:"cm-nonmatchingBracket"});function o0(n){let e=[],t=n.matched?r0:s0;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function Ac(n){let e=[],t=n.facet(pf);for(let i of n.selection.ranges){if(!i.empty)continue;let r=$t(n,i.head,-1,t)||i.head>0&&$t(n,i.head-1,1,t)||t.afterCursor&&($t(n,i.head,1,t)||i.headn.decorations}),a0=[l0,n0];function c0(n={}){return[pf.of(n),a0]}const h0=new H;function Jo(n,e,t){let i=n.prop(e<0?H.openedBy:H.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function el(n){let e=n.type.prop(h0);return e?e(n.node):n}function $t(n,e,t,i={}){let r=i.maxScanDistance||ff,s=i.brackets||df,o=Ce(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=Jo(a.type,t,s);if(c&&a.from0?e>=h.from&&eh.from&&e<=h.to))return u0(n,e,t,a,h,c,s)}}return f0(n,e,t,o,l.type,r,s)}function u0(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},c=0,h=l?.cursor();if(h&&(t<0?h.childBefore(i.from):h.childAfter(i.to)))do if(t<0?h.to<=i.from:h.from>=i.to){if(c==0&&s.indexOf(h.type.name)>-1&&h.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},h=n.doc.iterRange(e,t>0?n.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=s;){let d=h.value;t<0&&(f+=d.length);let p=e+f*t;for(let m=t>0?0:d.length-1,O=t>0?d.length:-1;m!=O;m+=t){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=r))if(y%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};u--}}t>0&&(f+=d.length)}return h.done?{start:c,matched:!1}:null}const d0=Object.create(null),bc=[et.none],Sc=[],xc=Object.create(null),p0=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])p0[n]=m0(d0,e);function _s(n,e){Sc.indexOf(n)>-1||(Sc.push(n),console.warn(e))}function m0(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let c of l.split(".")){let h=n[c]||g[c];h?typeof h=="function"?a.length?a=a.map(h):_s(c,`Modifier ${c} used at start of tag`):a.length?_s(c,`Tag ${c} used as modifier`):a=Array.isArray(h)?h:[h]:_s(c,`Unknown highlighting tag ${c}`)}for(let c of a)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=xc[r];if(s)return s.id;let o=xc[r]=et.define({id:bc.length,name:i,props:[Nu({[i]:t})]});return bc.push(o),o.id}fe.RTL,fe.LTR;const O0=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Fl(n.state,t.from);return i.line?g0(n):i.block?A0(n):!1};function Ul(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}const g0=Ul(x0,0),y0=Ul(mf,0),A0=Ul((n,e)=>mf(n,e,S0(e)),0);function Fl(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const an=50;function b0(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-an,i),o=n.sliceDoc(r,r+an),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,c=s.length-l;if(s.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let h,u;r-i<=2*an?h=u=n.sliceDoc(i,r):(h=n.sliceDoc(i,i+an),u=n.sliceDoc(r-an,r));let f=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(u)[0].length,p=u.length-d-t.length;return h.slice(f,f+e.length)==e&&u.slice(p,p+t.length)==t?{open:{pos:i+f+e.length,margin:/\s/.test(h.charAt(f+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function S0(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function mf(n,e,t=e.selection.ranges){let i=t.map(s=>Fl(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>b0(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;or&&(s==o||o>u.from)){r=u.from;let f=/^\s*/.exec(u.text)[0].length,d=f==u.length,p=u.text.slice(f,f+c.length)==c?f:-1;fs.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:c,empty:h,single:u}of i)(u||!h)&&s.push({from:l.from+c,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let c=o.from+l,h=c+a.length;o.text[h-o.from]==" "&&h++,s.push({from:c,to:h})}return{changes:s}}return null}const tl=zt.define(),vr=zt.define(),w0=K.define(),Of=K.define({combine(n){return yt(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),Dl=Te.define({create(){return Rt.empty},update(n,e){let t=e.state.facet(Of),i=e.annotation(tl);if(i){let a=_e.fromTransaction(e,i.selection),c=i.side,h=c==0?n.undone:n.done;return a?h=jr(h,h.length,t.minDepth,a):h=Af(h,e.startState.selection),new Rt(c==0?i.rest:h,c==0?h:i.rest)}let r=e.annotation(vr);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(Pe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=_e.fromTransaction(e),o=e.annotation(Pe.time),l=e.annotation(Pe.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Rt(n.done.map(_e.fromJSON),n.undone.map(_e.fromJSON))}});function v0(n={}){return[Dl,Of.of(n),R.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Xl:e.inputType=="historyRedo"?Wr:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ss(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(Dl,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}const Xl=Ss(0,!1),Wr=Ss(1,!1),k0=Ss(0,!0),Q0=Ss(1,!0);function gf(n){return function(e){let t=e.field(Dl,!1);if(!t)return 0;let i=n==0?t.done:t.undone;return i.length-(i.length&&!i[0].changes?1:0)}}const wc=gf(0),vc=gf(1);class _e{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new _e(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new _e(e.changes&&$e.fromJSON(e.changes),[],e.mapped&&Zt.fromJSON(e.mapped),e.startSelection&&A.fromJSON(e.startSelection),e.selectionsAfter.map(A.fromJSON))}static fromTransaction(e,t){let i=ht;for(let r of e.startState.facet(w0)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new _e(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ht)}static selection(e){return new _e(void 0,ht,void 0,void 0,e)}}function jr(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function P0(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a=c&&o<=h&&(i=!0)}}),i}function C0(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function yf(n,e){return n.length?e.length?n.concat(e):n:e}const ht=[],T0=200;function Af(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-T0));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),jr(n,n.length-1,1e9,t.setSelAfter(i)))}else return[_e.selection([e])]}function $0(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Js(n,e){if(!n.length)return n;let t=n.length,i=ht;for(;t;){let r=R0(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[_e.selection(i)]:ht}function R0(n,e,t){let i=yf(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):ht,t);if(!n.changes)return _e.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new _e(r,W.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}const K0=/^(input\.type|delete)($|\.)/;class Rt{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new Rt(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||K0.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):xs(t,e))}function Be(n){return n.textDirectionAt(n.state.selection.main.head)==fe.LTR}const Sf=n=>bf(n,!Be(n)),xf=n=>bf(n,Be(n));function wf(n,e){return bt(n,t=>t.empty?n.moveByGroup(t,e):xs(t,e))}const M0=n=>wf(n,!Be(n)),E0=n=>wf(n,Be(n));function U0(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function ws(n,e,t){let i=Ce(n).resolveInner(e.head),r=t?H.closedBy:H.openedBy;for(let a=e.head;;){let c=t?i.childAfter(a):i.childBefore(a);if(!c)break;U0(n,c,r)?i=c:a=t?c.to:c.from}let s=i.type.prop(r),o,l;return s&&(o=t?$t(n,i.from,1):$t(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,A.cursor(l,t?-1:1)}const F0=n=>bt(n,e=>ws(n.state,e,!Be(n))),D0=n=>bt(n,e=>ws(n.state,e,Be(n)));function vf(n,e){return bt(n,t=>{if(!t.empty)return xs(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const kf=n=>vf(n,!1),Qf=n=>vf(n,!0);function Pf(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):xs(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottomCf(n,!1),il=n=>Cf(n,!0);function oi(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=A.cursor(i.from+s))}return r}const X0=n=>bt(n,e=>oi(n,e,!0)),L0=n=>bt(n,e=>oi(n,e,!1)),B0=n=>bt(n,e=>oi(n,e,!Be(n))),q0=n=>bt(n,e=>oi(n,e,Be(n))),I0=n=>bt(n,e=>A.cursor(n.lineBlockAt(e.head).from,1)),z0=n=>bt(n,e=>A.cursor(n.lineBlockAt(e.head).to,-1));function W0(n,e,t){let i=!1,r=Ji(n.selection,s=>{let o=$t(n,s.head,-1)||$t(n,s.head,1)||s.head>0&&$t(n,s.head-1,1)||s.headW0(n,e);function ft(n,e,t){let i=Ji(n.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=A.range(r.head,r.anchor));let s=t(r);return A.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(At(n.state,i)),!0)}function Tf(n,e){return ft(n,e,t=>n.moveByChar(t,e))}const $f=n=>Tf(n,!Be(n)),Rf=n=>Tf(n,Be(n));function Kf(n,e){return ft(n,e,t=>n.moveByGroup(t,e))}const V0=n=>Kf(n,!Be(n)),Y0=n=>Kf(n,Be(n)),N0=n=>{let e=!Be(n);return ft(n,e,t=>ws(n.state,t,e))},G0=n=>{let e=Be(n);return ft(n,e,t=>ws(n.state,t,e))};function Zf(n,e){return ft(n,e,t=>n.moveVertically(t,e))}const Mf=n=>Zf(n,!1),Ef=n=>Zf(n,!0);function Uf(n,e){return ft(n,e,t=>n.moveVertically(t,e,Pf(n).height))}const Qc=n=>Uf(n,!1),Pc=n=>Uf(n,!0),H0=n=>ft(n,!0,e=>oi(n,e,!0)),_0=n=>ft(n,!1,e=>oi(n,e,!1)),J0=n=>{let e=!Be(n);return ft(n,e,t=>oi(n,t,e))},ey=n=>{let e=Be(n);return ft(n,e,t=>oi(n,t,e))},ty=n=>ft(n,!1,e=>A.cursor(n.lineBlockAt(e.head).from)),iy=n=>ft(n,!0,e=>A.cursor(n.lineBlockAt(e.head).to)),Cc=({state:n,dispatch:e})=>(e(At(n,{anchor:0})),!0),Tc=({state:n,dispatch:e})=>(e(At(n,{anchor:n.doc.length})),!0),$c=({state:n,dispatch:e})=>(e(At(n,{anchor:n.selection.main.anchor,head:0})),!0),Rc=({state:n,dispatch:e})=>(e(At(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),ny=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),ry=({state:n,dispatch:e})=>{let t=vs(n).map(({from:i,to:r})=>A.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:A.create(t),userEvent:"select"})),!0},sy=({state:n,dispatch:e})=>{let t=Ji(n.selection,i=>{let r=Ce(n),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return A.range(l.to,l.from)}return i});return t.eq(n.selection)?!1:(e(At(n,t)),!0)};function Ff(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=n.moveVertically(l,e);if(a.heado.to){r.some(c=>c.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==i.ranges.length?!1:(n.dispatch(At(t,A.create(r,r.length-1))),!0)}const oy=n=>Ff(n,!1),ly=n=>Ff(n,!0),ay=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=A.create([t.main]):t.main.empty||(i=A.create([A.cursor(t.main.head)])),i?(e(At(n,i)),!0):!1};function Bn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(t="delete.forward",a=hr(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=hr(n,o,!1),l=hr(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:A.cursor(o,or(n)))i.between(e,e,(r,s)=>{re&&(e=t?s:r)});return e}const Df=(n,e,t)=>Bn(n,i=>{let r=i.from,{state:s}=n,o=s.doc.lineAt(r),l,a;if(t&&!e&&r>o.from&&rDf(n,!1,!0),Xf=n=>Df(n,!0,!1),Lf=(n,e)=>Bn(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=Ze(s.text,i-s.from,e)+s.from,c=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),h=o(c);if(l!=null&&h!=l)break;(c!=" "||i!=t.head)&&(l=h),i=a}return i}),Bf=n=>Lf(n,!1),cy=n=>Lf(n,!0),hy=n=>Bn(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headBn(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),fy=n=>Bn(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:re.of(["",""])},range:A.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},py=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:Ze(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:Ze(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:A.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function vs(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function qf(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of vs(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(A.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(A.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:A.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const my=({state:n,dispatch:e})=>qf(n,e,!1),Oy=({state:n,dispatch:e})=>qf(n,e,!0);function If(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of vs(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const gy=({state:n,dispatch:e})=>If(n,e,!1),yy=({state:n,dispatch:e})=>If(n,e,!0),Ay=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(vs(e).map(({from:r,to:s})=>(r>0?r--:s{let s;if(n.lineWrapping){let o=n.lineBlockAt(r.head),l=n.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,s)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function by(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Ce(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(H.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const Kc=zf(!1),Sy=zf(!0);function zf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&by(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new As(e,{simulateBreak:s,simulateDoubleBreak:!!a}),h=Ml(c,s);for(h==null&&(h=_i(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:A.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const xy=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new As(n,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=Ll(n,(s,o,l)=>{let a=Ml(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let c=/^\s*/.exec(s.text)[0],h=Tn(n,a);(c!=h||l.fromn.readOnly?!1:(e(n.update(Ll(n,(t,i)=>{i.push({from:t.from,insert:n.facet(ys)})}),{userEvent:"input.indent"})),!0),jf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ll(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=_i(r,n.tabSize),o=0,l=Tn(n,Math.max(0,s-qr(n)));for(;o(n.setTabFocusMode(),!0),vy=[{key:"Ctrl-b",run:Sf,shift:$f,preventDefault:!0},{key:"Ctrl-f",run:xf,shift:Rf},{key:"Ctrl-p",run:kf,shift:Mf},{key:"Ctrl-n",run:Qf,shift:Ef},{key:"Ctrl-a",run:I0,shift:ty},{key:"Ctrl-e",run:z0,shift:iy},{key:"Ctrl-d",run:Xf},{key:"Ctrl-h",run:nl},{key:"Ctrl-k",run:hy},{key:"Ctrl-Alt-h",run:Bf},{key:"Ctrl-o",run:dy},{key:"Ctrl-t",run:py},{key:"Ctrl-v",run:il}],ky=[{key:"ArrowLeft",run:Sf,shift:$f,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:M0,shift:V0,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:B0,shift:J0,preventDefault:!0},{key:"ArrowRight",run:xf,shift:Rf,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:E0,shift:Y0,preventDefault:!0},{mac:"Cmd-ArrowRight",run:q0,shift:ey,preventDefault:!0},{key:"ArrowUp",run:kf,shift:Mf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Cc,shift:$c},{mac:"Ctrl-ArrowUp",run:kc,shift:Qc},{key:"ArrowDown",run:Qf,shift:Ef,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Tc,shift:Rc},{mac:"Ctrl-ArrowDown",run:il,shift:Pc},{key:"PageUp",run:kc,shift:Qc},{key:"PageDown",run:il,shift:Pc},{key:"Home",run:L0,shift:_0,preventDefault:!0},{key:"Mod-Home",run:Cc,shift:$c},{key:"End",run:X0,shift:H0,preventDefault:!0},{key:"Mod-End",run:Tc,shift:Rc},{key:"Enter",run:Kc,shift:Kc},{key:"Mod-a",run:ny},{key:"Backspace",run:nl,shift:nl,preventDefault:!0},{key:"Delete",run:Xf,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Bf,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:cy,preventDefault:!0},{mac:"Mod-Backspace",run:uy,preventDefault:!0},{mac:"Mod-Delete",run:fy,preventDefault:!0}].concat(vy.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Qy=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:F0,shift:N0},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:D0,shift:G0},{key:"Alt-ArrowUp",run:my},{key:"Shift-Alt-ArrowUp",run:gy},{key:"Alt-ArrowDown",run:Oy},{key:"Shift-Alt-ArrowDown",run:yy},{key:"Mod-Alt-ArrowUp",run:oy},{key:"Mod-Alt-ArrowDown",run:ly},{key:"Escape",run:ay},{key:"Mod-Enter",run:Sy},{key:"Alt-l",mac:"Ctrl-l",run:ry},{key:"Mod-i",run:sy,preventDefault:!0},{key:"Mod-[",run:jf},{key:"Mod-]",run:Wf},{key:"Mod-Alt-\\",run:xy},{key:"Shift-Mod-k",run:Ay},{key:"Shift-Mod-\\",run:j0},{key:"Mod-/",run:O0},{key:"Alt-A",run:y0},{key:"Ctrl-m",mac:"Shift-Alt-m",run:wy}].concat(ky),Py={key:"Tab",run:Wf,shift:jf};class Vf{constructor(e,t,i,r){this.state=e,this.pos=t,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Ce(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),s=r.search(Nf(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Zc(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Cy(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Cy(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}function Ty(n,e){return t=>{for(let i=Ce(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}let Mc=class{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}};function yi(n){return n.selection.main.from}function Nf(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?n:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Bl=zt.define();function $y(n,e,t,i){let{main:r}=n.selection,s=t-r.from,o=i-r.from;return{...n.changeByRange(l=>{if(l!=r&&t!=i&&n.sliceDoc(l.from+s,l.from+o)!=n.sliceDoc(t,i))return{range:l};let a=n.toText(e);return{changes:{from:l.from+s,to:i==r.from?l.to:l.from+o,insert:a},range:A.cursor(l.from+s+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Ec=new WeakMap;function Ry(n){if(!Array.isArray(n))return n;let e=Ec.get(n);return e||Ec.set(n,e=Yf(n)),e}const Vr=W.define(),$n=W.define();class Ky{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(S=fl(k))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||v==1&&O||C==0&&v!=0)&&(t[u]==k||i[u]==k&&(f=!0)?o[u++]=b:o.length&&(y=!1)),C=v,b+=Qt(k)}return u==a&&o[0]==0&&y?this.result(-100+(f?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):u==a?this.result(-100+(f?-200:0)+-700+(y?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],s=0;for(let o of t){let l=o+(this.astral?Qt(Ne(i,o)):1);s&&r[s-1]==o?r[s-1]=l:(r[s++]=o,r[s++]=l)}return this.ret(e-i.length,r)}}class Zy{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:My,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Uc(e(i),t(i)),optionClass:(e,t)=>i=>Uc(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Uc(n,e){return n?e?n+" "+e:n:e}function My(n,e,t,i,r,s){let o=n.textDirection==fe.RTL,l=o,a=!1,c="top",h,u,f=e.left-r.left,d=r.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&f=m||b>e.top?h=t.bottom-e.top:(c="bottom",h=e.bottom-t.top)}let O=(e.bottom-e.top)/s.offsetHeight,y=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${h/O}px; max-width: ${u/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const ql=W.define();function Ey(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let c=0;ca&&o.appendChild(document.createTextNode(l.slice(a,h)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(l.slice(h,u))),f.className="cm-completionMatchedText",a=u}return at.position-i.position).map(t=>t.render)}function eo(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class Uy{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,l=e.state.facet(Ke);this.optionContent=Ey(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=eo(s.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:c}=e.state.field(t).open;for(let h=a.target,u;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(u=/-(\d+)$/.exec(h.id))&&+u[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;h!=null&&(e.dispatch({effects:ql.of(h)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Ke).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:$n.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:l}=i.open;(!r.open||r.open.options!=s)&&(this.range=eo(s.length,o,e.state.facet(Ke).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),l!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=eo(t.options.length,t.selected,this.view.state.facet(Ke).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,r)}).catch(l=>We(this.view.state,l,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&Dy(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottom{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;oi.from||i.from==0))if(s=f,typeof c!="string"&&c.header)r.appendChild(c.header(c));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=f}}const h=r.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");let u=this.optionClass(l);u&&(h.className=u);for(let f of this.optionContent){let d=f(l,this.view.state,this.view,a);d&&h.appendChild(d)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.tonew Uy(t,n,e)}function Dy(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function Fc(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Xy(n,e){let t=[],i=null,r=null,s=h=>{t.push(h);let{section:u}=h.completion;if(u){i||(i=[]);let f=typeof u=="string"?u:u.name;i.some(d=>d.name==f)||i.push(typeof u=="string"?{name:f}:u)}},o=e.facet(Ke);for(let h of n)if(h.hasResult()){let u=h.result.getMatch;if(h.result.filter===!1)for(let f of h.result.options)s(new Mc(f,h.source,u?u(f):[],1e9-t.length));else{let f=e.sliceDoc(h.from,h.to),d,p=o.filterStrict?new Zy(f):new Ky(f);for(let m of h.result.options)if(d=p.match(m.label)){let O=m.displayLabel?u?u(m,d.matched):[]:d.matched,y=d.score+(m.boost||0);if(s(new Mc(m,h.source,O,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:b}=m.section;r||(r=Object.create(null)),r[b]=Math.max(y,r[b]||-1e9)}}}}if(i){let h=Object.create(null),u=0,f=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.namef.score-u.score||c(u.completion,f.completion))){let u=h.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?l.push(h):Fc(h.completion)>Fc(a)&&(l[l.length-1]=h),a=h.completion}return l}class Ki{constructor(e,t,i,r,s,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ki(this.options,Dc(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,s,o){if(r&&!o&&e.some(c=>c.isPending))return r.setDisabled();let l=Xy(e,t);if(!l.length)return r&&e.some(c=>c.isPending)?r.setDisabled():null;let a=t.facet(Ke).selectOnOpen?0:-1;if(r&&r.selected!=a&&r.selected!=-1){let c=r.options[r.selected].completion;for(let h=0;hh.hasResult()?Math.min(c,h.from):c,1e8),create:Wy,above:s.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new Ki(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ki(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Yr{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Yr(Iy,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Ke),s=(i.override||t.languageDataAt("autocomplete",yi(t)).map(Ry)).map(a=>(this.active.find(h=>h.source==a)||new ut(a,this.active.some(h=>h.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((a,c)=>a==this.active[c])&&(s=this.active);let o=this.open,l=e.effects.some(a=>a.is(Il));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!Ly(s,this.active)||l?o=Ki.build(s,t,this.id,o,i,l):o&&o.disabled&&!s.some(a=>a.isPending)&&(o=null),!o&&s.every(a=>!a.isPending)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new ut(a.source,0):a));for(let a of e.effects)a.is(ql)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new Yr(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?By:qy}}function Ly(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const Iy=[];function Gf(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Bl);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class ut{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=Gf(e,t),r=this;(i&8||i&16&&this.touches(e))&&(r=new ut(r.source,0)),i&4&&r.state==0&&(r=new ut(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(Vr))r=new ut(r.source,1,s.value);else if(s.is($n))r=new ut(r.source,0);else if(s.is(Il))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(yi(e.state))}}class Fi extends ut{constructor(e,t,i,r,s,o){super(e,3,t),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=yi(e.state);if(l>o||!r||t&2&&(yi(e.startState)==this.from||lt.map(e))}}),Ge=Te.define({create(){return Yr.start()},update(n,e){return n.update(e)},provide:n=>[Os.from(n,e=>e.tooltip),R.contentAttributes.from(n,e=>e.attrs)]});function zl(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(Ge).active.find(r=>r.source==e.source);return i instanceof Fi?(typeof t=="string"?n.dispatch({...$y(n.state,t,i.from,i.to),annotations:Bl.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const Wy=Fy(Ge,zl);function ur(n,e="option"){return t=>{let i=t.state.field(Ge,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+r*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:ql.of(l)}),!0}}const jy=n=>{let e=n.state.field(Ge,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(Ge,!1)?(n.dispatch({effects:Vr.of(!0)}),!0):!1,Vy=n=>{let e=n.state.field(Ge,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:$n.of(null)}),!0)};class Yy{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ny=50,Gy=1e3,Hy=xe.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(Ge).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(Ge),t=n.state.facet(Ke);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Ge)==e)return;let i=n.transactions.some(s=>{let o=Gf(s,t);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;sNy&&Date.now()-o.time>Gy){for(let l of o.context.abortListeners)try{l()}catch(a){We(this.view.state,a)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(s=>s.effects.some(o=>o.is(Vr)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of n.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(Ge);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ke).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=yi(e),i=new Vf(e,t,n.explicit,this.view),r=new Yy(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:$n.of(null)}),We(this.view.state,s)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ke).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Ke),i=this.view.state.field(Ge);for(let r=0;rl.source==s.active.source);if(o&&o.isPending)if(s.done==null){let l=new ut(s.active.source,0);for(let a of s.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Il.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Ge,!1);if(e&&e.tooltip&&this.view.state.facet(Ke).closeOnBlur){let t=e.open&&Uu(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:$n.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Vr.of(!1)}),20),this.composing=0}}}),_y=typeof navigator=="object"&&/Win/.test(navigator.platform),Jy=si.highest(R.domEventHandlers({keydown(n,e){let t=e.state.field(Ge,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(_y&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],r=t.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(n.key)>-1&&zl(e,i),!1}})),Hf=R.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class eA{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}}class Wl{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,De.TrackDel),i=e.mapPos(this.to,1,De.TrackDel);return t==null||i==null?null:new Wl(this.field,t,i)}}class jl{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],r=[t],s=e.doc.lineAt(t),o=/^\s*/.exec(s.text)[0];for(let a of this.lines){if(i.length){let c=o,h=/^\t*/.exec(a)[0].length;for(let u=0;unew Wl(a.field,r[a.line]+a.from,r[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],r=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=s[1]?+s[1]:null,a=s[2]||s[3]||"",c=-1;l===0&&(l=1e9);let h=a.replace(/\\[{}]/g,u=>u[1]);for(let u=0;u=c&&f.field++}for(let u of r)if(u.line==i.length&&u.from>s.index){let f=s[2]?3+(s[1]||"").length:2;u.from-=f,u.to-=f}r.push(new eA(c,i.length,s.index,s.index+h.length)),o=o.slice(0,s.index)+a+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(l,a,c)=>{for(let h of r)h.line==i.length&&h.from>c&&(h.from--,h.to--);return a}),i.push(o)}return new jl(i,r)}}let tA=B.widget({widget:new class extends Ut{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),iA=B.mark({class:"cm-snippetField"});class en{constructor(e,t){this.ranges=e,this.active=t,this.deco=B.set(e.map(i=>(i.from==i.to?tA:iA).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;t.push(r)}return new en(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const qn=W.define({map(n,e){return n&&n.map(e)}}),nA=W.define(),Rn=Te.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(qn))return t.value;if(t.is(nA)&&n)return new en(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>R.decorations.from(n,e=>e?e.deco:B.none)});function Vl(n,e){return A.create(n.filter(t=>t.field==e).map(t=>A.range(t.from,t.to)))}function rA(n){let e=jl.parse(n);return(t,i,r,s)=>{let{text:o,ranges:l}=e.instantiate(t.state,r),{main:a}=t.state.selection,c={changes:{from:r,to:s==a.from?a.to:s,insert:re.of(o)},scrollIntoView:!0,annotations:i?[Bl.of(i),Pe.userEvent.of("input.complete")]:void 0};if(l.length&&(c.selection=Vl(l,0)),l.some(h=>h.field>0)){let h=new en(l,0),u=c.effects=[qn.of(h)];t.state.field(Rn,!1)===void 0&&u.push(W.appendConfig.of([Rn,cA,hA,Hf]))}t.dispatch(t.state.update(c))}}function _f(n){return({state:e,dispatch:t})=>{let i=e.field(Rn,!1);if(!i||n<0&&i.active==0)return!1;let r=i.active+n,s=n>0&&!i.ranges.some(o=>o.field==r+n);return t(e.update({selection:Vl(i.ranges,r),effects:qn.of(s?null:new en(i.ranges,r)),scrollIntoView:!0})),!0}}const sA=({state:n,dispatch:e})=>n.field(Rn,!1)?(e(n.update({effects:qn.of(null)})),!0):!1,oA=_f(1),lA=_f(-1),aA=[{key:"Tab",run:oA,shift:lA},{key:"Escape",run:sA}],Xc=K.define({combine(n){return n.length?n[0]:aA}}),cA=si.highest(ms.compute([Xc],n=>n.facet(Xc)));function Ye(n,e){return{...e,apply:rA(n)}}const hA=R.domEventHandlers({mousedown(n,e){let t=e.state.field(Rn,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let r=t.ranges.find(s=>s.from<=i&&s.to>=i);return!r||r.field==t.active?!1:(e.dispatch({selection:Vl(t.ranges,r.field),effects:qn.of(t.ranges.some(s=>s.field>r.field)?new en(t.ranges,r.field):null),scrollIntoView:!0}),!0)}}),Kn={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},mi=W.define({map(n,e){let t=e.mapPos(n,-1,De.TrackAfter);return t??void 0}}),Yl=new class extends Jt{};Yl.startSide=1;Yl.endSide=-1;const Jf=Te.define({create(){return N.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(mi)&&(n=n.update({add:[Yl.range(t.value,t.value+1)]}));return n}});function uA(){return[dA,Jf]}const io="()[]{}<>«»»«[]{}";function ed(n){for(let e=0;e{if((fA?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&Qt(Ne(i,0))==1||e!=r.from||t!=r.to)return!1;let s=OA(n.state,i);return s?(n.dispatch(s),!0):!1}),pA=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=td(n,n.selection.main.head).brackets||Kn.brackets,r=null,s=n.changeByRange(o=>{if(o.empty){let l=gA(n.doc,o.head);for(let a of i)if(a==l&&ks(n.doc,o.head)==ed(Ne(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:A.cursor(o.head-a.length)}}return{range:r=o}});return r||e(n.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},mA=[{key:"Backspace",run:pA}];function OA(n,e){let t=td(n,n.selection.main.head),i=t.brackets||Kn.brackets;for(let r of i){let s=ed(Ne(r,0));if(e==r)return s==r?bA(n,r,i.indexOf(r+r+r)>-1,t):yA(n,r,s,t.before||Kn.before);if(e==s&&id(n,n.selection.main.from))return AA(n,r,s)}return null}function id(n,e){let t=!1;return n.field(Jf).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function ks(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Qt(Ne(t,0)))}function gA(n,e){let t=n.sliceString(e-2,e);return Qt(Ne(t,0))==t.length?t:t.slice(1)}function yA(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:mi.of(o.to+e.length),range:A.range(o.anchor+e.length,o.head+e.length)};let l=ks(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:mi.of(o.head+e.length),range:A.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function AA(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&ks(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:A.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function bA(n,e,t,i){let r=i.stringPrefixes||Kn.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:mi.of(l.to+e.length),range:A.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=ks(n.doc,a),h;if(c==e){if(Lc(n,a))return{changes:{insert:e+e,from:a},effects:mi.of(a+e.length),range:A.cursor(a+e.length)};if(id(n,a)){let f=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+f.length,insert:f},range:A.cursor(a+f.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(h=Bc(n,a-2*e.length,r))>-1&&Lc(n,h))return{changes:{insert:e+e+e+e,from:a},effects:mi.of(a+e.length),range:A.cursor(a+e.length)};if(n.charCategorizer(a)(c)!=ye.Word&&Bc(n,a,r)>-1&&!SA(n,a,e,r))return{changes:{insert:e+e,from:a},effects:mi.of(a+e.length),range:A.cursor(a+e.length)}}return{range:s=l}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Lc(n,e){let t=Ce(n).resolveInner(e+1);return t.parent&&t.from==e}function SA(n,e,t,i){let r=Ce(n).resolveInner(e,-1),s=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let h=r.firstChild;for(;h&&h.from==r.from&&h.to-h.from>t.length+a;){if(n.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function Bc(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ye.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=ye.Word)return s}return-1}function xA(n={}){return[Jy,Ge,Ke.of(n),Hy,wA,Hf]}const nd=[{key:"Ctrl-Space",run:to},{mac:"Alt-`",run:to},{mac:"Alt-i",run:to},{key:"Escape",run:Vy},{key:"ArrowDown",run:ur(!0)},{key:"ArrowUp",run:ur(!1)},{key:"PageDown",run:ur(!0,"page")},{key:"PageUp",run:ur(!1,"page")},{key:"Enter",run:jy}],wA=si.highest(ms.computeN([Ke],n=>n.facet(Ke).defaultKeymap?[nd]:[]));var qc={};class Nr{constructor(e,t,i,r,s,o,l,a,c,h=0,u){this.p=e,this.stack=t,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=h,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new Nr(e,[],t,i,i,0,[],0,r?new Ic(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,t,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,t,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,t,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let l=o.stateFlag(s,1);!l&&(r>i||t<=o.maxNode)&&(this.reducePos=r),this.pushState(s,l?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,r,4)}else this.pos=r,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,r,4)}apply(e,t,i,r){e&65536?this.reduce(e):this.shift(e,t,i,r)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new Nr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new vA(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;sa&1&&l==o)||r.push(t[s],o)}t=r}let i=[];for(let r=0;r>19,r=t&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,s+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}}class Ic{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class vA{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class Gr{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Gr(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Gr(this.stack,this.pos,this.index)}}function dn(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}t?t[r++]=s:t=new e(s)}return t}class kr{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const zc=new kr;class kA{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=zc,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;si.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t=this.chunk2Pos&&il.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=zc,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}}class Di{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;rd(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}Di.prototype.contextual=Di.prototype.fallback=Di.prototype.extend=!1;class rl{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?dn(e):e}token(e,t){let i=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(rd(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}}rl.prototype.contextual=Di.prototype.fallback=Di.prototype.extend=!1;class In{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function rd(n,e,t,i,r,s){let o=0,l=1<0){let p=n[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||QA(p,e.token.value,r,s))){e.acceptToken(p);break}}let h=e.next,u=0,f=n[o+2];if(e.next<0&&f>u&&n[c+f*3-3]==65535){o=n[c+f*3-1];continue e}for(;u>1,p=c+d+(d<<1),m=n[p],O=n[p+1]||65536;if(h=O)u=d+1;else{o=n[p+2],e.advance();continue e}}break}}function Wc(n,e,t){for(let i=e,r;(r=n[i])!=65535;i++)if(r==t)return i-e;return-1}function QA(n,e,t,i){let r=Wc(t,i,e);return r<0||Wc(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class PA{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?jc(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?jc(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof ke){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class CA{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new kr)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;cu.end+25&&(a=Math.max(u.lookAhead,a)),u.value!=0)){let f=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!h.extend&&(i=u,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new kr,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new kr,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let s=0;se.bufferLength*4?new PA(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)i.push(l);else{if(this.advanceStack(l,i,e))continue;{r||(r=[],s=[]),r.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!i.length){let o=r&&KA(r);if(o)return nt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw nt&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return nt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,h=c?e.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let f=this.parser.nodeSet.types[u.type.id]==u.type?s.getGoto(e.state,u.type.id):-1;if(f>-1&&u.length&&(!c||(u.prop(H.contextHash)||0)==h))return e.useNode(u,f),nt&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(u.type.id)})`),!0;if(!(u instanceof ke)||u.children.length==0||u.positions[0]>0)break;let d=u.children[0];if(d instanceof ke&&u.positions[0]==0)u=d;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),nt&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let c=0;cr?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Vc(e,t),!0}}runRecovery(e,t,i){let r=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),nt&&console.log(h+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let u=l.split(),f=h;for(let d=0;d<10&&u.forceReduce()&&(nt&&console.log(f+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));d++)nt&&(f=this.stackID(u)+" -> ");for(let d of l.recoverByInsert(a))nt&&console.log(h+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),nt&&console.log(h+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Vc(l,i)):(!r||r.scoren;class RA{constructor(e){this.start=e.start,this.shift=e.shift||ro,this.reduce=e.reduce||ro,this.reuse=e.reuse||ro,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Hr extends Yu{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;le.topRules[l][1]),r=[];for(let l=0;l=0)s(h,a,l[c++]);else{let u=l[c+-h];for(let f=-h;f>0;f--)s(l[c++],a,u);c++}}}this.nodeSet=new Tl(t.map((l,a)=>et.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:r[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=zu;let o=dn(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Di(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let r=new TA(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],l=o&1,a=r[s++];if(l&&i)return a;for(let c=s+(o>>1);s0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),r=i?t(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Ft(this.data,s+2);else break;r=t(Ft(this.data,s+1))}return r}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Ft(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[i],r)}}return t}configure(e){let t=Object.assign(Object.create(Hr.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(l=>l.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[r]=Yc(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;si)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const ZA=316,MA=317,Nc=1,EA=2,UA=3,FA=4,DA=318,XA=320,LA=321,BA=5,qA=6,IA=0,sl=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],sd=125,zA=59,ol=47,WA=42,jA=43,VA=45,YA=60,NA=44,GA=63,HA=46,_A=91,JA=new RA({start:!1,shift(n,e){return e==BA||e==qA||e==XA?n:e==LA},strict:!1}),eb=new In((n,e)=>{let{next:t}=n;(t==sd||t==-1||e.context)&&n.acceptToken(DA)},{contextual:!0,fallback:!0}),tb=new In((n,e)=>{let{next:t}=n,i;sl.indexOf(t)>-1||t==ol&&((i=n.peek(1))==ol||i==WA)||t!=sd&&t!=zA&&t!=-1&&!e.context&&n.acceptToken(ZA)},{contextual:!0}),ib=new In((n,e)=>{n.next==_A&&!e.context&&n.acceptToken(MA)},{contextual:!0}),nb=new In((n,e)=>{let{next:t}=n;if(t==jA||t==VA){if(n.advance(),t==n.next){n.advance();let i=!e.context&&e.canShift(Nc);n.acceptToken(i?Nc:EA)}}else t==GA&&n.peek(1)==HA&&(n.advance(),n.advance(),(n.next<48||n.next>57)&&n.acceptToken(UA))},{contextual:!0});function so(n,e){return n>=65&&n<=90||n>=97&&n<=122||n==95||n>=192||!e&&n>=48&&n<=57}const rb=new In((n,e)=>{if(n.next!=YA||!e.dialectEnabled(IA)||(n.advance(),n.next==ol))return;let t=0;for(;sl.indexOf(n.next)>-1;)n.advance(),t++;if(so(n.next,!0)){for(n.advance(),t++;so(n.next,!1);)n.advance(),t++;for(;sl.indexOf(n.next)>-1;)n.advance(),t++;if(n.next==NA)return;for(let i=0;;i++){if(i==7){if(!so(n.next,!0))return;break}if(n.next!="extends".charCodeAt(i))break;n.advance(),t++}}n.acceptToken(FA,-t)}),sb=Nu({"get set async static":g.modifier,"for while do if else switch try catch finally return throw break continue default case defer":g.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":g.operatorKeyword,"let var const using function class extends":g.definitionKeyword,"import export from":g.moduleKeyword,"with debugger new":g.keyword,TemplateString:g.special(g.string),super:g.atom,BooleanLiteral:g.bool,this:g.self,null:g.null,Star:g.modifier,VariableName:g.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":g.function(g.variableName),VariableDefinition:g.definition(g.variableName),Label:g.labelName,PropertyName:g.propertyName,PrivatePropertyName:g.special(g.propertyName),"CallExpression/MemberExpression/PropertyName":g.function(g.propertyName),"FunctionDeclaration/VariableDefinition":g.function(g.definition(g.variableName)),"ClassDeclaration/VariableDefinition":g.definition(g.className),"NewExpression/VariableName":g.className,PropertyDefinition:g.definition(g.propertyName),PrivatePropertyDefinition:g.definition(g.special(g.propertyName)),UpdateOp:g.updateOperator,"LineComment Hashbang":g.lineComment,BlockComment:g.blockComment,Number:g.number,String:g.string,Escape:g.escape,ArithOp:g.arithmeticOperator,LogicOp:g.logicOperator,BitOp:g.bitwiseOperator,CompareOp:g.compareOperator,RegExp:g.regexp,Equals:g.definitionOperator,Arrow:g.function(g.punctuation),": Spread":g.punctuation,"( )":g.paren,"[ ]":g.squareBracket,"{ }":g.brace,"InterpolationStart InterpolationEnd":g.special(g.brace),".":g.derefOperator,", ;":g.separator,"@":g.meta,TypeName:g.typeName,TypeDefinition:g.definition(g.typeName),"type enum interface implements namespace module declare":g.definitionKeyword,"abstract global Privacy readonly override":g.modifier,"is keyof unique infer asserts":g.operatorKeyword,JSXAttributeValue:g.attributeValue,JSXText:g.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":g.angleBracket,"JSXIdentifier JSXNameSpacedName":g.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":g.attributeName,"JSXBuiltin/JSXIdentifier":g.standard(g.tagName)}),ob={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},lb={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},ab={__proto__:null,"<":193},cb=Hr.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0Mx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U-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:JA,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[sb],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEru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#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[tb,ib,nb,rb,2,3,4,5,6,7,8,9,10,11,12,13,14,eb,new rl("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new rl("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:n=>ob[n]||-1},{term:343,get:n=>lb[n]||-1},{term:95,get:n=>ab[n]||-1}],tokenPrec:15201}),od=[Ye("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Ye("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Ye("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Ye("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Ye("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Ye(`try { - \${} -} catch (\${error}) { - \${} -}`,{label:"try",detail:"/ catch block",type:"keyword"}),Ye("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Ye(`if (\${}) { - \${} -} else { - \${} -}`,{label:"if",detail:"/ else block",type:"keyword"}),Ye(`class \${name} { - constructor(\${params}) { - \${} - } -}`,{label:"class",detail:"definition",type:"keyword"}),Ye('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Ye('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],hb=od.concat([Ye("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Ye("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Ye("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Gc=new dg,ld=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function cn(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const ub=["FunctionDeclaration"],fb={FunctionDeclaration:cn("function"),ClassDeclaration:cn("class"),ClassExpression:()=>!0,EnumDeclaration:cn("constant"),TypeAliasDeclaration:cn("type"),NamespaceDeclaration:cn("namespace"),VariableDefinition(n,e){n.matchContext(ub)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function ad(n,e){let t=Gc.get(e);if(t)return t;let i=[],r=!0;function s(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(be.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=fb[o.name];if(l&&l(o,s)||ld.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of ad(n,o.node))i.push(l);return!1}}),Gc.set(e,i),i}const Hc=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,cd=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function db(n){let e=Ce(n.state).resolveInner(n.pos,-1);if(cd.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Hc.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let r=e;r;r=r.parent)ld.has(r.name)&&(i=i.concat(ad(n.state.doc,r)));return{options:i,from:t?e.from:n.pos,validFor:Hc}}const Lt=Lr.define({name:"javascript",parser:cb.configure({props:[ef.add({IfStatement:Ns({except:/^\s*({|else\b)/}),TryStatement:Ns({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Mg,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:Zg({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Ns({except:/^\s*{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),rf.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Dg,BlockComment(n){return{from:n.from+2,to:n.to-2}},JSXElement(n){let e=n.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let t=n.lastChild;return{from:e.to,to:t.type.isError?n.to:t.from}},"JSXSelfClosingTag JSXOpenTag"(n){var e;let t=(e=n.firstChild)===null||e===void 0?void 0:e.nextSibling,i=n.lastChild;return!t||t.type.isError?null:{from:t.to,to:i.type.isError?n.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),hd={test:n=>/^JSX/.test(n.name),facet:_u({commentTokens:{block:{open:"{/*",close:"*/}"}}})},pb=Lt.configure({dialect:"ts"},"typescript"),mb=Lt.configure({dialect:"jsx",props:[Zl.add(n=>n.isTop?[hd]:void 0)]}),Ob=Lt.configure({dialect:"jsx ts",props:[Zl.add(n=>n.isTop?[hd]:void 0)]},"typescript");let ud=n=>({label:n,type:"keyword"});const fd="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(ud),gb=fd.concat(["declare","implements","private","protected","public"].map(ud));function yb(n={}){let e=n.jsx?n.typescript?Ob:mb:n.typescript?pb:Lt,t=n.typescript?hb.concat(gb):od.concat(fd);return new kg(e,[Lt.data.of({autocomplete:Ty(cd,Yf(t))}),Lt.data.of({autocomplete:db}),n.jsx?Sb:[]])}function Ab(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function _c(n,e,t=n.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const bb=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Sb=R.inputHandler.of((n,e,t,i,r)=>{if((bb?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!Lt.isActiveAt(n.state,e,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(a=>{var c;let{head:h}=a,u=Ce(o).resolveInner(h-1,-1),f;if(u.name=="JSXStartTag"&&(u=u.parent),!(o.doc.sliceString(h-1,h)!=i||u.name=="JSXAttributeValue"&&u.to>h)){if(i==">"&&u.name=="JSXFragmentTag")return{range:a,changes:{from:h,insert:""}};if(i=="/"&&u.name=="JSXStartCloseTag"){let d=u.parent,p=d.parent;if(p&&d.from==h-2&&((f=_c(o.doc,p.firstChild,h))||((c=p.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let m=`${f}>`;return{range:A.cursor(h+m.length,-1),changes:{from:h,insert:m}}}}else if(i==">"){let d=Ab(u);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(f=_c(o.doc,d,h)))return{range:a,changes:{from:h,insert:``}}}}return{range:a}});return l.changes.empty?!1:(n.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Jc=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Yi{constructor(e,t,i=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=s?l=>s(Jc(l)):Jc,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Ne(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=fl(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Qt(e);let r=this.normalize(t);if(r.length)for(let s=0,o=i,l=!0;;s++){let a=r.charCodeAt(s),c=this.match(a,o,l,this.bufferPos+this.bufferStart,s==r.length-1);if(c)return this.value=c,this;if(s==r.length-1)break;l&&sthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=_r(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||r.to<=t){let l=new Xi(t,e.sliceString(t,i));return oo.set(e,l),l}if(r.from==t&&r.to==i)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,precise:!0,match:t},this.matchPos=_r(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Xi.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(pd.prototype[Symbol.iterator]=md.prototype[Symbol.iterator]=function(){return this});function xb(n){try{return new RegExp(n,Nl),!0}catch{return!1}}function _r(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}const wb=n=>{let{state:e}=n,t=String(e.doc.lineAt(n.state.selection.main.head).number),{close:i,result:r}=VO(n,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return r.then(s=>{let o=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!o){n.dispatch({effects:i});return}let l=e.doc.lineAt(e.selection.main.head),[,a,c,h,u]=o,f=h?+h.slice(1):0,d=c?+c:l.number;if(c&&u){let O=d/100;a&&(O=O*(a=="-"?-1:1)+l.number/e.doc.lines),d=Math.round(e.doc.lines*O)}else c&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=e.doc.line(Math.max(1,Math.min(e.doc.lines,d))),m=A.cursor(p.from+Math.max(0,Math.min(f,p.length)));n.dispatch({effects:[i,R.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0},vb={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},kb=K.define({combine(n){return yt(n,vb,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Qb(n){return[Rb,$b]}const Pb=B.mark({class:"cm-selectionMatch"}),Cb=B.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function eh(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=ye.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=ye.Word)}function Tb(n,e,t,i){return n(e.sliceDoc(t,t+1))==ye.Word&&n(e.sliceDoc(i-1,i))==ye.Word}const $b=xe.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(kb),{state:t}=n,i=t.selection;if(i.ranges.length>1)return B.none;let r=i.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return B.none;let a=t.wordAt(r.head);if(!a)return B.none;o=t.charCategorizer(r.head),s=t.sliceDoc(a.from,a.to)}else{let a=r.to-r.from;if(a200)return B.none;if(e.wholeWords){if(s=t.sliceDoc(r.from,r.to),o=t.charCategorizer(r.head),!(eh(o,t,r.from,r.to)&&Tb(o,t,r.from,r.to)))return B.none}else if(s=t.sliceDoc(r.from,r.to),!s)return B.none}let l=[];for(let a of n.visibleRanges){let c=new Yi(t.doc,s,a.from,a.to);for(;!c.next().done;){let{from:h,to:u}=c.value;if((!o||eh(o,t,h,u))&&(r.empty&&h<=r.from&&u>=r.to?l.push(Cb.range(h,u)):(h>=r.to||u<=r.from)&&l.push(Pb.range(h,u)),l.length>e.maxMatches))return B.none}}return B.set(l)}},{decorations:n=>n.decorations}),Rb=R.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Kb=({state:n,dispatch:e})=>{let{selection:t}=n,i=A.create(t.ranges.map(r=>n.wordAt(r.head)||A.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function Zb(n,e){let{main:t,ranges:i}=n.selection,r=n.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,l=new Yi(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Yi(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(s){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const Mb=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return Kb({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=i))return!1;let r=Zb(n,i);return r?(e(n.update({selection:n.selection.addRange(A.range(r.from,r.to),!1),effects:R.scrollIntoView(r.to)})),!0):!1},tn=K.define({combine(n){return yt(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Yb(e),scrollToMatch:e=>R.scrollIntoView(e)})}});class Od{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||xb(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` -`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Lb(this):new Fb(this)}getCursor(e,t=0,i){let r=e.doc?e:_.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Pi(this,r,t,i):Qi(this,r,t,i)}}class gd{constructor(e){this.spec=e}}function Eb(n,e,t){return(i,r,s,o)=>{if(t&&!t(i,r,s,o))return!1;let l=i>=o&&r<=o+s.length?s.slice(i-o,r-o):e.doc.sliceString(i,r);return n(l,e,i,r)}}function Qi(n,e,t,i){let r;return n.wholeWord&&(r=Ub(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(r=Eb(n.test,e,r)),new Yi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase(),r)}function Ub(n,e){return(t,i,r,s)=>((s>t||s+r.length=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Qi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function Db(n,e,t){return(i,r,s)=>(!t||t(i,r,s))&&n(s[0],e,i,r)}function Pi(n,e,t,i){let r;return n.wholeWord&&(r=Xb(e.charCategorizer(e.selection.main.head))),n.test&&(r=Db(n.test,e,r)),new pd(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:r},t,i)}function Jr(n,e){return n.slice(Ze(n,e,!1),e)}function es(n,e){return n.slice(e,Ze(n,e))}function Xb(n){return(e,t,i)=>!i[0].length||(n(Jr(i.input,i.index))!=ye.Word||n(es(i.input,i.index))!=ye.Word)&&(n(es(i.input,i.index+i[0].length))!=ye.Word||n(Jr(i.input,i.index+i[0].length))!=ye.Word)}class Lb extends gd{nextMatch(e,t,i){let r=Pi(this.spec,e,i,e.doc.length).next();return r.done&&(r=Pi(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let s=Math.max(t,i-r*1e4),o=Pi(this.spec,e,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let s=+i.slice(0,r);if(s>0&&s=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Pi(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const Zn=W.define(),Gl=W.define(),Ht=Te.define({create(n){return new lo(ll(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Zn)?n=new lo(t.value.create(),n.panel):t.is(Gl)&&(n=new lo(n.query,t.value?Hl:null));return n},provide:n=>ji.from(n,e=>e.panel)});class lo{constructor(e,t){this.query=e,this.panel=t}}const Bb=B.mark({class:"cm-searchMatch"}),qb=B.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Ib=xe.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Ht))}update(n){let e=n.state.field(Ht);(e!=n.startState.field(Ht)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return B.none;let{view:t}=this,i=new Bt;for(let r=0,s=t.visibleRanges,o=s.length;rs[r+1].from-500;)a=s[++r].to;n.highlight(t.state,l,a,(c,h)=>{let u=t.state.selection.ranges.some(f=>f.from==c&&f.to==h);i.add(c,h,u?qb:Bb)})}return i.finish()}},{decorations:n=>n.decorations});function zn(n){return e=>{let t=e.state.field(Ht,!1);return t&&t.query.spec.valid?n(e,t):bd(e)}}const ts=zn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let r=A.single(i.from,i.to),s=n.state.facet(tn);return n.dispatch({selection:r,effects:[_l(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),Ad(n),!0}),is=zn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let s=A.single(r.from,r.to),o=n.state.facet(tn);return n.dispatch({selection:s,effects:[_l(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),Ad(n),!0}),zb=zn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:A.create(t.map(i=>A.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Wb=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,s=[],o=0;for(let l=new Yi(n.doc,n.sliceDoc(i,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(A.range(l.value.from,l.value.to))}return e(n.update({selection:A.create(s,o),userEvent:"select.search.matches"})),!0},th=zn((n,{query:e})=>{let{state:t}=n,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,i,i);if(!s)return!1;let o=s,l=[],a,c,h=[];o.precise?o.from==i&&o.to==r&&(c=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),h.push(R.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let u=n.state.changes(l);return o&&(a=A.single(o.from,o.to).map(u),h.push(_l(n,o)),h.push(t.facet(tn).scrollToMatch(a.main,n))),n.dispatch({changes:u,selection:a,effects:h,userEvent:"input.replace"}),!0}),jb=zn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let r of e.matchAll(n.state,1e9)){let{from:s,to:o,precise:l}=r;l&&t.push({from:s,to:o,insert:e.getReplacement(r)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:R.announce.of(i),userEvent:"input.replace.all"}),!0});function Hl(n){return n.state.facet(tn).createPanel(n)}function ll(n,e){var t,i,r,s,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let c=n.facet(tn);return new Od({search:((t=e?.literal)!==null&&t!==void 0?t:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:c.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function yd(n){let e=Fu(n,Hl);return e&&e.dom.querySelector("[main-field]")}function Ad(n){let e=yd(n);e&&e==n.root.activeElement&&e.select()}const bd=n=>{let e=n.state.field(Ht,!1);if(e&&e.panel){let t=yd(n);if(t&&t!=n.root.activeElement){let i=ll(n.state,e.query.spec);i.valid&&n.dispatch({effects:Zn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Gl.of(!0),e?Zn.of(ll(n.state,e.query.spec)):W.appendConfig.of(Gb)]});return!0},Sd=n=>{let e=n.state.field(Ht,!1);if(!e||!e.panel)return!1;let t=Fu(n,Hl);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Gl.of(!1)}),!0},Vb=[{key:"Mod-f",run:bd,scope:"editor search-panel"},{key:"F3",run:ts,shift:is,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ts,shift:is,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Sd,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Wb},{key:"Mod-Alt-g",run:wb},{key:"Mod-d",run:Mb,preventDefault:!0}];class Yb{constructor(e){this.view=e;let t=this.query=e.state.field(Ht).query.spec;this.commit=this.commit.bind(this),this.searchField=he("input",{value:t.search,placeholder:rt(e,"Find"),"aria-label":rt(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=he("input",{value:t.replace,placeholder:rt(e,"Replace"),"aria-label":rt(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=he("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=he("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=he("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return he("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=he("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>ts(e),[rt(e,"next")]),i("prev",()=>is(e),[rt(e,"previous")]),i("select",()=>zb(e),[rt(e,"all")]),he("label",null,[this.caseField,rt(e,"match case")]),he("label",null,[this.reField,rt(e,"regexp")]),he("label",null,[this.wordField,rt(e,"by word")]),...e.state.readOnly?[]:[he("br"),this.replaceField,i("replace",()=>th(e),[rt(e,"replace")]),i("replaceAll",()=>jb(e),[rt(e,"replace all")])],he("button",{name:"close",onclick:()=>Sd(e),"aria-label":rt(e,"close"),type:"button"},["×"])])}commit(){let e=new Od({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Zn.of(e)}))}keydown(e){rO(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?is:ts)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),th(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Zn)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(tn).top}}function rt(n,e){return n.state.phrase(e)}const fr=30,dr=/[\s\.,:;?!]/;function _l(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),r=n.state.doc.lineAt(t).to,s=Math.max(i.from,e-fr),o=Math.min(r,t+fr),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;al.length-fr;a--)if(!dr.test(l[a-1])&&dr.test(l[a])){l=l.slice(0,a);break}}return R.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const Nb=R.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Gb=[Ht,si.low(Ib),Nb];class ih{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class di{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(Kt).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Bt,l=[],a=0,c=i.doc.iter(),h=0,u=i.doc.length;for(let d=0;;){let p=d==s.length?null:s[d];if(!p&&!l.length)break;let m,O;if(l.length)m=a,O=l.reduce((x,C)=>Math.min(x,C.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>u)break;O=p.to,l.push(p),d++}for(;dx.from||x.to==m))l.push(x),d++,O=Math.min(x.to,O);else{O=Math.min(x.from,O);break}}O=Math.min(O,u);let y=!1;if(l.some(x=>x.from==m&&(x.to==O||O==u))&&(y=m==O,!y&&O-m<10)){let x=m-(h+c.value.length);x>0&&(c.next(x),h=m);for(let C=m;;){if(C>=O){y=!0;break}if(!c.lineBreak&&h+c.value.length>C)break;C=h+c.value.length,h+=c.value.length,c.next()}}let b=Td(l);if(y)o.add(m,m,B.widget({widget:new n1(b),diagnostics:l.slice()}));else{let x=l.reduce((C,k)=>k.markClass?C+" "+k.markClass:C,"");o.add(m,O,B.mark({class:"cm-lintRange cm-lintRange-"+b+x,diagnostics:l.slice(),inclusiveEnd:l.some(C=>C.to>O)}))}if(a=O,a==u)break;for(let x=0;x{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new ih(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ih(i.from,s,i.diagnostic)}}),i}function xd(n,e){let t=e.pos,i=e.end||t,r=n.state.facet(Kt).hideOn(n,t,i);if(r!=null)return r;let s=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(Qs))||n.changes.touchesRange(s.from,Math.max(s.to,i)))}function Hb(n,e){return n.field(Ot,!1)?e:e.concat(W.appendConfig.of(Kd))}function wd(n,e){return{effects:Hb(n,[Qs.of(e)])}}const Qs=W.define(),vd=W.define(),kd=W.define(),Ot=Te.define({create(){return new di(B.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,r=n.panel;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);i=Ni(t,n.selected.diagnostic,s)||Ni(t,null,s)}!t.size&&r&&e.state.facet(Kt).autoPanel&&(r=null),n=new di(t,r,i)}for(let t of e.effects)if(t.is(Qs)){let i=e.state.facet(Kt).autoPanel?t.value.length?ns.open:null:n.panel;n=di.init(t.value,i,e.state)}else t.is(vd)?n=new di(n.diagnostics,t.value?ns.open:null,n.selected):t.is(kd)&&(n=new di(n.diagnostics,n.panel,t.value));return n},provide:n=>[ji.from(n,e=>e.panel),R.decorations.from(n,e=>e.diagnostics)]}),_b=B.mark({class:"cm-lintRange cm-lintRange-active"});function Jb(n,e,t){let{diagnostics:i}=n.state.field(Ot),r,s=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,c,{spec:h})=>{if(e>=a&&e<=c&&(a==c||(e>a||t>0)&&(eCd(n,t,!1)))}const nh=n=>{let e=n.state.field(Ot,!1);return!e||!e.panel?!1:(n.dispatch({effects:vd.of(!1)}),!0)},e1=xe.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(Kt);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(nPromise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(wd(this.view.state,i.reduce((r,s)=>r.concat(s))))},i=>{We(this.view.state,i)})}}update(n){let e=n.state.facet(Kt);(n.docChanged||e!=n.startState.facet(Kt)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function t1(n,e,t){let i=[],r=-1;for(let s of n)s.then(o=>{i.push(o),clearTimeout(r),i.length==n.length?e(i):r=setTimeout(()=>e(i),200)},t)}const Kt=K.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...yt(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:rh,tooltipFilter:rh,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,r,s)=>e(i,r,s)||t(i,r,s):e:t,autoPanel:(e,t)=>e||t})}}});function rh(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function i1(n,e={}){return[Kt.of({source:n,config:e}),e1,Kd]}function Pd(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;is.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Cd(n,e,t){var i;let r=t?Pd(e.actions):[];return he("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},he("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Ni(n.state.field(Ot).diagnostics,e);p&&s.apply(n,p.from,p.to)},{name:c}=s,h=r[o]?c.indexOf(r[o]):-1,u=h<0?c:[c.slice(0,h),he("u",c.slice(h,h+1)),c.slice(h+1)],f=s.markClass?" "+s.markClass:"";return he("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:a,onmousedown:a,"aria-label":` Action: ${c}${h<0?"":` (access key "${r[o]})"`}.`},u)}),e.source&&he("div",{class:"cm-diagnosticSource"},e.source))}class n1 extends Ut{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return he("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class sh{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Cd(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ns{constructor(e){this.view=e,this.items=[];let t=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)nh(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=Pd(s.actions);for(let l=0;l{for(let s=0;snh(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ot).selected;if(!e)return-1;for(let t=0;t{for(let h of c.diagnostics){if(o.has(h))continue;o.add(h);let u=-1,f;for(let d=i;di&&(this.items.splice(i,u-i),r=!0)),t&&f.diagnostic==t.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),s=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),i++}});i({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let c=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Ot),i=Ni(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:kd.of(i)})}static open(e){return new ns(e)}}function Qr(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function pr(n){return Qr(``,'width="6" height="3"')}const r1=R.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:pr("#f11")},".cm-lintRange-warning":{backgroundImage:pr("orange")},".cm-lintRange-info":{backgroundImage:pr("#999")},".cm-lintRange-hint":{backgroundImage:pr("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function s1(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function Td(n){let e="hint",t=1;for(let i of n){let r=s1(i.severity);r>t&&(t=r,e=i.severity)}return e}class $d extends Mt{constructor(e){super(),this.diagnostics=e,this.severity=Td(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=e.state.facet(Ps).tooltipFilter;return r&&(i=r(i,e.state)),i.length&&(t.onmouseover=()=>l1(e,t,i)),t}}function o1(n,e){let t=i=>{let r=e.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientXr.top-10&&i.clientYe.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,o1(n,e)}let{hoverTime:r}=n.state.facet(Ps),s=setTimeout(i,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,r)}}function a1(n,e){let t=Object.create(null);for(let r of e){let s=n.lineAt(r.from);(t[s.from]||(t[s.from]=[])).push(r)}let i=[];for(let r in t)i.push(new $d(t[r]).range(+r));return N.of(i,!0)}const c1=Bu({class:"cm-gutter-lint",markers:n=>n.state.field(al),widgetMarker:(n,e,t)=>{let i=[];return n.state.field(al).between(t.from,t.to,(r,s,o)=>{r>t.from&&ri.is(Jl)?i.value:t,n)},provide:n=>Os.from(n)}),h1=R.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Qr('')},".cm-lint-marker-warning":{content:Qr('')},".cm-lint-marker-error":{content:Qr('')}}),u1=Eu(Jb,{hideOn:xd}),Kd=[Ot,R.decorations.compute([Ot],n=>{let{selected:e,panel:t}=n.field(Ot);return!e||!t||e.from==e.to?B.none:B.set([_b.range(e.from,e.to)])}),u1,r1],Ps=K.define({combine(n){return yt(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function f1(n={}){return[Ps.of(n),al,c1,h1,Rd]}const Zd=1,Ue=Object.freeze({ready:"studio.ready",documentOpen:"document.open",documentReplace:"document.replace",documentChanged:"document.changed",documentSave:"document.save",documentSetReadOnly:"document.setReadOnly",documentResources:"document.resources",editorInsert:"editor.insert",editorFormat:"editor.format",editorSetTheme:"editor.setTheme",editorGetState:"editor.getState",diagnosticsPublish:"diagnostics.publish"});function d1(n,e={},t=null,i=null){return{protocolVersion:Zd,type:n,documentID:t,...i===null?{}:{sessionID:i},payload:e}}function p1(n){if(window.WKWebViewJavascriptBridge){n(window.WKWebViewJavascriptBridge);return}if(window.WKWVJBCallbacks){window.WKWVJBCallbacks.push(n);return}window.webkit?.messageHandlers?.iOS_Native_InjectJavascript&&(window.WKWVJBCallbacks=[n],window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage(null))}function nn(n,e,t={},i=null,r=()=>{},s=null){if(!n){r({result:"unavailable"});return}n.callHandler(e,d1(e,t,i,s),r)}function m1(n){const e={capabilities:["jsx","format","search","completion","diagnostics"]};nn(n,Ue.ready,e)}const O1=[{id:"$storage.getString",arguments:["key"],returns:"string",documentation:"Read a package-scoped string. Missing keys return an empty string."},{id:"$storage.setString",arguments:["key","value"],returns:"boolean",documentation:"Set a package-scoped string, limited to 256 KiB of UTF-8. Check the success result."},{id:"$storage.getJSON",arguments:["key"],returns:"json",documentation:"Read a package-scoped JSON object. Missing or invalid values return an empty object."},{id:"$storage.setJSON",arguments:["key","value"],returns:"boolean",documentation:"Store a valid JSON object, limited to 256 KiB encoded. Check the success result."},{id:"$storage.compareAndSetString",arguments:["key","expected","value"],returns:"boolean",minimumRuntimeVersion:"1.3",documentation:"Atomically replace a string only when it still matches expected. A missing key matches an empty string. Conflicts return false; reread and retry a bounded number of times. Requires the shared storage container."},{id:"$storage.compareAndSetJSON",arguments:["key","expected","value"],returns:"boolean",minimumRuntimeVersion:"1.3",documentation:"Atomically replace a JSON object if its current value equals expected, independent of property order. A missing key matches an empty object. Wrong types and conflicts return false. Requires the shared storage container."},{id:"$storage.remove",arguments:["key"],returns:"boolean",documentation:"Remove a key from this package only."},{id:"$storage.keys",arguments:[],returns:"string[]",documentation:"List keys in this package's namespace."},{id:"$storage.clear",arguments:[],returns:"boolean",documentation:"Clear this package's storage. Other packages are unaffected."}].map(n=>({minimumRuntimeVersion:"1.0",...n,preview:"initialState"})),cl="2026-01-01T00:00:00Z",Wt="2026-01-01T12:00:00Z",ao=(n,e)=>({value:n,unit:e,hasSamples:!0,start:cl,end:Wt}),oh=(n,e,t)=>Object.entries(e).map(([i,r])=>({id:`$${n}.${i}`,group:n,value:r,legacy:[t,i]})),g1=[{id:"$music.isAvailable",group:"music",value:!0},{id:"$music.authorizationStatus",group:"music",value:"authorized"},{id:"$music.current",group:"music",value:{provider:"appleMusic",state:"playing",hasItem:!0,title:"Morning Light",artist:"ScriptWidget Sessions",album:"Focus",duration:224,position:86,capturedAt:Wt}},{id:"$services.status",group:"services",value:"connected"},{id:"$services.profile",group:"services",value:{service:"github",subject:"42",username:"octocat",displayName:"Mona",publicRepositories:32,privateRepositories:8,followers:128,following:24}},...oh("device",{screen:{width:390,height:844,scale:3},language:"en",model:"iPhone",name:"My iPhone",battery:{level:.8,state:"unplugged"},systemVersion:"26.0",isdarkmode:!1,totalDiskSpace:128e9,freeDiskSpace:64e9},"device"),...oh("system",{appInfo:{name:"ScriptWidget",bundleId:"com.everettjf.scriptwidget",version:"27.1.2",build:"27012"},locale:"en_US",preferredLanguages:["en-US"],timeZone:{identifier:"UTC",abbreviation:"GMT",offsetSeconds:0},is24HourClock:!1,calendarInfo:{identifier:"gregorian",firstWeekday:1,minimumDaysInFirstWeek:1},systemUptime:3600,memory:{physical:8589934592},thermalState:"nominal",lowPowerMode:!1,brightness:.5,reduceMotionEnabled:!1,platform:"ios",hostName:"My iPhone",processName:"ScriptWidgetWidget",osVersionString:"Version 26.0",processorCount:6,activeProcessorCount:6},"system"),{id:"$photos.isAvailable",group:"photos",value:!0},{id:"$photos.authorizationStatus",group:"photos",value:"authorized"},{id:"$photos.requestAuthorization",group:"photos",value:!0},{id:"$photos.items",group:"photos",value:{status:"ready",items:[{id:"sample.photo",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fbPe3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQK/QnooooGFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK7TxwooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi++865Pl26H91CDwo9T6t6mhs5cTiVSXmX/ABx49v8Axdc+UmYbKM/u4vX/AGm9T+g/U6/w38fv4buRpOqMTYynr18pj3H+ye4/H1z5TRU3PHVean7S+p+gSOkiCSMhlYZBHIIPcU6vmn4YfEL+zXTw5rb/AOjscQ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yAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvePgx8bNT+Gl8NN1Hdc6PM2ZIurRE9Xjz39V6H2PNeD0UjSlWlSkpwdmftNo+saZr+mQ6xo0y3FtcLvjkQ5BH9COhB5B4NaVflf8IPjJrHww1LyZN1zpU7Znt88g9N8eejDuOjDg9iP038P+INH8UaRDrmhTrcWs67kdf1BHUEdCDyDUNWPrsFjo4mPZ9Uf//S+tKKKK6z8/CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACmSSRwxtLKwVVGSTwABSTTRW8TTzsERBkseABXhHi3xfLrchsrIlLVT9C5Hc+3oPz9nGNzOpVUFdkvi/xjJrDmw08lbVTyehkI7n29B+ftwNFFbJWPNnNyd2FFFFMkKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvWvhP8W9b+F+r+bBm40+dh9otieG7bk/uuB379D2x5LRSLp1JU5KcHZo//0/rSiiius/PwooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtYWublgiIMsx6AU26ureyt3urpwkaDJY14H4q8V3GvzeTDmO1Q/Kvdvdv8O1OMbmVWqoIk8WeLZtdlNrbZS1Q8Du59T/AEFcXRRWyVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/9T60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKKKKACq15eW2n2z3d44SNBkk0y/v7XTbV7y9cJGg5J/kPU18/eJfE114hucnKW6H5I/6n1P8qqMbmVWqoLzJPFHim58QXGxcx2yH5E9fdvf+VcpRRWqVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9X60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKo6jqNppVo17etsRfzJ9B6mm6pqlnpFm17ettReg7k+gHrXz34h8Q3niC786c7Y1+5GOij+p9TVRjcxq1lBeY/xH4ku/EN1vk+SFD8kfYe59TXOUUVqedKTbuwooopiCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9b60oqRYZX+4pP0FWV03UX+5byH6Kf8K6z4CzKVFay6Drj/AHLKc/SNv8KsJ4V8Tv8Ac026P0hf/CgfJLsYNFdOngvxc/TTbn8Y2H8xVhPAHjN+mnTfiMfzoH7KfZnIUV3C/Dbxu/TT3/FkH82qyvws8dt/y44+skf/AMVQV7Cp/K/uPPqK9JT4S+OG62yL9ZE/oTVlfg94zbqkK/WQf0BosP6vU/lZ5bRXra/Bjxc3V7Zfq7f0U1YX4JeKD9+4tR/wJz/7JRYf1Wr/ACnjlZmravZaLZte3rYUcADqx9BXpXjnwZH8PNCfXPEeoQKv3Y4k3GSV/wC6gIH4noB1r4t1vXL3Xrw3V2cAcIg6KPQf1PeqjG5y4mTo+7Jaj9e1+91+8NzcnCDhEHRR/j6msOiitTy223dhRRRTEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/Z",width:384,height:256},{id:"sample.photo.2",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/ayiiivVAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9D9rKKKK9UAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/0f2sooor1QCiiigAooooAKKKKACiiigAooooAKKKKACiq15eWun2r3t7IsUUY3MzHAApbW6tr62S8tHEkUqhlZeQQaduoFiiiikAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB/9L9rKKKK9UAooooAKKKKACiiigAooooAKKKKACs/VdVsNFsZNS1OQRQxjJJ/kB3J7Cquva/pnhvTn1PVJNiLwAPvMeyqO5P+eK+P/GPjTU/GF9510fLt0P7qEHhR6n1Y9zXRRoOo/Iyq1VD1L3jrx9f+MLrykzDZRn93F6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oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigApGZUUu5wBySe1NkkSJDJIQqqMkngADua+f8Axv46fWGbStJYrag4Zuhk/wDsf51dOm5uyJbsT+OPHbamX0jR2xbDh5B1k9h/s/z+leV0UV6UIKKsjJu4UUUVYgooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvoL4IfHTVfhdfjTNS3XWiztmSHq0RPWSPPf1Xo3sea+faKzq0o1IuE1oVGbi+aJ+5Gi61pXiLS4Na0SdLm1uF3xyIcgj+hHQg8g8HmtSvyU+DHxs1r4Vap5Em660i4bM9tnkHp5keeA47jow4PYj9UPDviPRfFmjQa/4fnW5tbhdyOv6gjqCDwQeQa+ZxeElQl5Hq0ayqLzP//S+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACo5ZYoI2mmYIiDLMTgADuaSeeG2ha4uGCIgyzHgACvnbxp42m1+Q2NgSlmp+hkI7n29B+J9tKVJzdkTKViXxt44k1x203TSUtFPJ6GQjuf9n0H4n284oor0oxUVZGLdwoooqgCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAr2H4QfGLXvhTrPm2+bjTZ2H2m1J4btvT+64Hfv0PbHj1FROEZxcZrQcZOLuj//T+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKgubm3s7d7q6cRxxjLMegFNu7y2sLZ7y8cRxxjLMe1fN/jDxlc+JJ/IgzHaIflTux/vN7+g7VpSpObJlKxL4y8aXHiKY2lpmOzQ8L0Lkd2/oK4OiivSjFRVkYt3CiiiqAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//1PqCiiivszygooooAKKKKACiiigAooooAKKKKACiiigAooooAKqX19aabave3riOKMZJP+etN1HUbPSrN76/cRxoOSf5D1J9K+afFfiy88TXeTmO2Q/u4/6t6n+XataVJzfkTKViXxd4vu/EtzsTMdrGfkj9f9pvf+VcbRRXoxioqyMW7hRRRVAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//V+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACs/VNUstHsnv799kafmT2AHcmmavq9jolk1/qD7UXoO7HsAO5NfM3iXxNfeJb3z7j5Il/1cY6KP6k9zW1Ki5vyJlKxL4o8VXvia78yX5IEP7uMdB7n1PvXLUUV6EYpKyMW7hRRRVAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB//1vqCipFhlf7ik/QVZTTdRk+5byH6IT/SvsrnlWKVFay6Drr/AHLKc/SNv8Ksp4U8UP8Ac026P0hf/ClzLuOzMCiuoXwT4vfpplz+MbD+Yqynw/8AGj9NNm/EY/nS549x8j7HHUV3K/DXxy/TT3/FkH82qyvwq8ev/wAuGPrLEP8A2al7WHdByS7HntFelp8I/HLdbZF+sif0NWU+DnjRuqQr9ZB/QGl7aH8w/Zy7HldFeur8FfGDdXtl+rt/Rasr8D/FR+/c2o/4E5/9kpe3h3H7KXY8ZrJ1rWrDQbFr+/bCjhVHVj6AetemePvB0Xw20B9f8TajAq/diiTcZJX/ALqAgZ9z0A5NfCviDxBf+Ir43l6cAcIg+6g9B/U966sPBVfeWxlUvDRkniPxHf8AiS9N1dnai8Rxjoo/x9TXP0UV6aSSsjAKKKKYBRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//Z",width:384,height:256},{id:"sample.photo.3",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOt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UAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//U+uKKKK+oPoAooooAKKKKACiiigAooooAKKKKACiiigAooooAKq3t7a6daveXjhI0GST/AJ602/v7TTLR729cJGg5J/kPUmvnXxR4pu/EdzzmO3Q/u4/6n1P8q0p03M1pUnN+RJ4q8V3XiK42LmO2Q/Inr/tN7/yrkaKK7UklZHfGKirIKKKKoYUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9X64ooor6g+gCiiigAooooAKKKKACiiigAooooAKKKKACqGpalZ6TZtfXz7I1/Mn0A7k03VdVstGs2vr59qL0Hcn0A7mvnLxH4jvfEV558/yxL/AKuMdFH9T6mtadPm9DWlSc/Qk8S+JrzxHd+ZJ8kKH93H2HufU1zNFFdqSSsjvSSVkFFFFMYUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//1vriipFilf7ik/QVZXTtQf7kEh+in/CvqD6ApUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf/AApcy7iuYNFdOngvxc/TTbn8Y2H8xVhfAPjJ+mnTfiMfzpc8e4XRyFFdwvw38bv009/xZB/NqsL8LfHbf8uOPrJH/wDFUvaR7hzLuef0V6Svwl8cN1tkX6yJ/Q1ZX4P+M26pCv1kH9AaXtYdxc67nltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AAJz/wCyUvbw7hzx7njlZesaxY6JZNe3zYUcADqx9APWvSvHfg6P4daE+u+JNQgVfuxxJuMkr/3UBAz7noB1r4j13Xr7xBem7vDgDhEHRR6D+p710UIqpqtjejT9pr0JPEHiC+8Q3hubo7UXhIx0Uf4+prBoorvStojvSS0QUUUUxhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//2Q==",width:384,height:256},{id:"sample.photo.4",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQO3UnooooEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK5z1QooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi+9865PlwIf3UIPCj1Pq3qaaR0UKDqPyL3jjx5f+LrrykzDZRn93Fnr/tN6n9B+p2Phv4/fw3cjStUYmxlbr18pj3H+ye4/Ed8+U0U7HqOlFx5LaH6BI6SoJIyGVhkEcgg9xTq+afhh8Q/7MdPDmtv/AKMxxDIx/wBWT/CT/dPb0+nT6WqTyKtJ05WYUUUUGQUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFRTzw20LXFwwREGWY9AKlrxX4i6+9xd/2HbtiOLBkx/E3UD6Afr9K78twEsbWVGO3V9kcOY46ODoutLfou7DX/iLeXDtb6H+5jHHmEZZvoDwB+v0rzu5vr28YvdzPKT3Zif51Vor9KwmAoYWPLRjbz6/efnOKx9bEy5q0r+XT7i1bX17ZsHtJniI7qxH8q9E0D4i3lu62+ufvozx5gGGX6gcEfr9a8xooxeAoYqPLWjfz6/eGFx9bDS5qMreXT7j6zgnhuYVuLdg6OMqw6EVLXivw6197e7/sO4bMcuTHn+FupH0I/X617VX5rmWAlgqzoy26Puj9Gy7HRxlFVo79V2YUUUVwHcFFFFABRRRQB//T/biiiiuc9UKKKKACiiigAooooAKKKKACub8T+KdL8Kaeb7UWyx4jjH3nPoP6ntVPxh4z03whY+dc/vLhx+6hB5Y+p9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UUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABXrvwk+L2ufCzWPNt83GnTsPtNqTw3ben91wO/foe2PIqKDOpTjUi4TV0f/T+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtIHublwkaDLMegFNu7u2sbZ7u7cRxoMsx7V87+LfF9z4in8iHMdoh+VO7H+839B2pN2NqNF1H5EvjDxjP4gmNra5jtEPC93I7t/QVw1FFZtnqwgorliFFFFIsKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9T60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAqre3trp1q95euI40GST/nrTNQ1C00u0e9vnCRoOSf5D1Jr5y8U+KrvxJdZOY7dD+7j/qfU/wAqTdjejRdR+RL4r8WXXiO52LmO1Q/Inr/tN7/yrkKKKzPVjFRVkFFFFIoKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP//V+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAqhqep2ekWb318+yNPzJ9AO5NM1XVrLRbJr6/fai9B3Y9gB3NfN/iPxJe+I7zz7j5Yl/wBXGOij+p9TUt2OihQdR+RJ4m8T3niO78yT5IEP7uPsPc+prmaKKg9SMVFWQUUUUigooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/W+tKKkWKV/uKT9BVlNO1CT7kEjfRT/hWR9rcpUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf8AwoFzLuYNFdMvgvxc/TTbn8Y2H8xVlfAPjJ+mnTfiMfzoF7SPc5Ciu4X4b+N36ae/4sg/masL8LfHb/8ALjj6yR//ABVIXtYfzI8/or0lPhL44brbIv1kT+hqynwf8Zt1SFfrIP6A0C9tD+ZHltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AnP8A7JQL6xT/AJjxysrWNZsdDsmvr5sKOAB1Y+gHrXpXjvwfF8OdBfXfEmoQKv3Yok3GSV/7qAgZ9z0A618Q69r194gvTd3hwBwiDoo9B/U96TdjrwtNVveWw/xB4hvvEV6bm6O1F4SMdFH+PqawaKKg9dJJWQUUUUhhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH/9k=",width:384,height:256}],unavailableCount:0,fetchedAt:Wt,source:"system",stale:!1}},{id:"$calendar.isAvailable",group:"calendar",value:!0},{id:"$calendar.authorizationStatus",group:"calendar",value:"authorized"},{id:"$calendar.requestAuthorization",group:"calendar",value:!0},{id:"$calendar.calendars",group:"calendar",value:[{id:"sample.personal",title:"Personal"}]},{id:"$calendar.events",group:"calendar",value:{status:"ready",items:[{id:"sample.event",calendarID:"sample.personal",title:"Read and recharge",start:"2026-01-01T15:00:00Z",end:"2026-01-01T15:30:00Z",allDay:!1}],fetchedAt:Wt,source:"system",stale:!1,truncated:!1}},{id:"$reminders.isAvailable",group:"reminders",value:!0},{id:"$reminders.authorizationStatus",group:"reminders",value:"authorized"},{id:"$reminders.requestAuthorization",group:"reminders",value:!0},{id:"$reminders.lists",group:"reminders",value:[{id:"sample.reminders",title:"Personal"}]},{id:"$reminders.items",group:"reminders",value:{status:"ready",items:[{id:"sample.reminder",listID:"sample.reminders",title:"Read a chapter",due:"2026-01-01T16:00:00Z",hasTime:!0,completed:!1,completedAt:null,priority:0}],fetchedAt:Wt,source:"system",stale:!1,truncated:!1}},{id:"$reminders.create",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$reminders.update",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$reminders.setCompleted",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$health.authorizationStatus",group:"health",value:"notDisclosed"},{id:"$health.sleepSummary",group:"health",value:{start:cl,end:Wt,timeZone:"UTC",hasSamples:!0,totalSleepSeconds:27e3,inBedSeconds:30600,awakeSeconds:1800,stages:{unspecified:0,core:16200,deep:5400,rem:5400},sourceCount:1,truncated:!1,conflictSeconds:0,aggregation:"union-awake-rem-deep-core-unspecified"}},{id:"$health.activitySummary",group:"health",value:{date:"2026-01-01",timeZone:"UTC",hasSamples:!0,moveMode:"activeEnergy",move:{value:480,goal:600,unit:"kcal"},exercise:{value:26,goal:30,unit:"min"},stand:{value:9,goal:12,unit:"count"}}},{id:"$health.workouts",group:"health",value:{start:cl,end:Wt,timeZone:"UTC",hasSamples:!0,truncated:!1,items:[{id:"550e8400-e29b-41d4-a716-446655440000",activity:"running",start:"2026-01-01T09:00:00.000Z",end:"2026-01-01T09:45:00.000Z",duration:2700,energyKcal:285,distanceMeters:5200}]}},{id:"$health.isAvailable",group:"health",value:!0},{id:"$health.requestAuthorization",group:"health",value:!0,legacy:["health"]},{id:"$health.stepCountToday",group:"health",value:ao(6840,"count"),legacy:["health.stepCountToday"]},{id:"$health.activeEnergyToday",group:"health",value:ao(420,"kcal"),legacy:["health.activeEnergyToday"]},{id:"$health.heartRateLatest",group:"health",value:ao(72,"bpm"),legacy:["health.heartRateLatest"]},{id:"$location.isAvailable",group:"location",value:!0},{id:"$location.authorizationStatus",group:"location",value:"authorizedWhenInUse"},{id:"$location.isAuthorizedForWidgetUpdates",group:"location",value:!0},{id:"$location.requestAuthorization",group:"location",value:!0,legacy:["location.authorization"]},{id:"$location.current",group:"location",value:{latitude:37.3349,longitude:-122.009,altitude:0,accuracy:10,verticalAccuracy:10,speed:-1,course:-1,timestamp:Wt,accuracyAuthorization:"full",age:0,isStale:!1},legacy:["location"]}],y1={music:{platforms:["ios"],authorization:"musicRead",notes:"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access."},services:{platforms:["ios","macos"],authorization:"serviceAccount",notes:"Runtime 1.4: status(service) and profile(service) are asynchronous. Only provider: github. Unknown providers reject with service_operation. Requires an installed owner and services permission. profile additionally requires network and api.github.com in networkDomains, a native connected GitHub account and explicit owner grant. Native Settings handles credentials; scripts cannot log in or obtain tokens. profile returns service, subject, username, displayName, publicRepositories, privateRepositories, followers and following (missing values are null). No live queries in future entries or Live Activities. Eight shared data queries; native requests also share the eight concurrent/32 total network budget, while Web uses its existing preview network budget. Web uses editable best-state samples only; it never authenticates or sends these requests."},photos:{platforms:["ios","macos"],authorization:"photosRead",notes:"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access."},reminders:{platforms:["ios","macos"],authorization:"remindersRead",notes:"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission."},calendar:{platforms:["ios","macos"],authorization:"calendarRead",notes:"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission."},device:{platforms:["ios","macos"],authorization:"none",notes:"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements."},system:{platforms:["ios","macos"],authorization:"none",notes:"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable."},health:{platforms:["ios"],authorization:"healthRead",notes:"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain."},location:{platforms:["ios"],authorization:"locationWhenInUse",notes:"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale."}},A1=g1.map(n=>{const e=n.id.split(".")[1],t=n.group==="music"&&e==="current"||n.group==="services"||["calendar","reminders","photos"].includes(n.group)&&!["isAvailable","authorizationStatus"].includes(e)||n.group==="health"&&!["isAvailable","authorizationStatus"].includes(e)||n.group==="location"&&["current","requestAuthorization"].includes(e),i=n.group==="health"&&["sleepSummary","activitySummary","workouts"].includes(e)||n.group==="location"&&["current","requestAuthorization"].includes(e)||["calendar","reminders","photos"].includes(n.group)&&["events","items"].includes(e);return{...n,...y1[n.group],minimumRuntimeVersion:["music","services","reminders","photos"].includes(n.group)||n.group==="health"&&["sleepSummary","activitySummary","workouts"].includes(e)?"1.4":["calendar"].includes(n.group)||["$health.authorizationStatus","$location.isAuthorizedForWidgetUpdates"].includes(n.id)?"1.3":"1.0",arguments:n.group==="services"?["service"]:n.group==="reminders"&&["create","update","setCompleted"].includes(e)?["options"]:i?["options?"]:[],...n.group==="reminders"&&["create","update","setCompleted"].includes(e)?{authorization:"remindersWrite"}:{},asynchronous:t,nativeSource:`Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntime${n.group[0].toUpperCase()}${n.group.slice(1)}.swift`,operation:n.group==="reminders"&&["create","update","setCompleted"].includes(e)?"write":e==="requestAuthorization"?"authorization":["isAvailable","authorizationStatus","isAuthorizedForWidgetUpdates"].includes(e)?"availability":"read",mock:"editable"}}),Re={globalProperties:{background:{type:"color",documentation:"Background color, hex value, or named color."},backgroundMaterial:{type:"enum",values:["none","ultraThin","thin","regular","thick","ultraThick"],documentation:"Runtime API 1.4. Public SwiftUI frosted material inside the widget, not Home Screen wallpaper blur or system Liquid Glass. At most four material backgrounds per tree. background supplies an opaque-composited Reduce Transparency fallback. In accented/vibrant mode local material is omitted for system rendering; none keeps the ordinary background."},color:{type:"color",documentation:"Foreground color, hex value, or named color."},font:{type:"enum",values:["largeTitle","title","title2","title3","headline","subheadline","body","callout","footnote","caption","caption2"],documentation:"Semantic text style."},fontWeight:{type:"enum",values:["ultraLight","thin","light","regular","medium","semibold","bold","heavy","black"],documentation:"Font weight."},fontDesign:{type:"enum",values:["default","rounded","serif","monospaced"],documentation:"Font design."},frame:{type:"number|string",documentation:'Square size (64 or "64"), width,height ("64,48"), or flexible frame ("max", "max,48").'},padding:{type:"number|string",documentation:"Padding amount or edge description."},corner:{type:"number",documentation:"Corner radius."},opacity:{type:"number",documentation:"Opacity from 0 through 1."},alignment:{type:"enum",values:["center","leading","trailing","top","bottom","topLeading","topTrailing","bottomLeading","bottomTrailing","firstTextBaseline","lastTextBaseline"],documentation:"Layout alignment."},clip:{type:"enum",values:["circle","rect","capsule","ellipse"],documentation:"Clip the view to a shape."},rotation:{type:"number",documentation:"Rotation in degrees."},rotation3d:{type:"string",documentation:"Static degree,x,y,z rotation with four finite numbers and a nonzero axis. Invalid values are ignored; axis magnitude is normalized. Reduce Motion removes the tilt. This does not read device motion or provide parallax."},shadow:{type:"string",documentation:"Shadow color, radius, and offset description."},animation:{type:"string",documentation:"iOS public SwiftUI scheduled clock/swing effect. Mac renders static standard-clock poses; other effects remain at rest. Signed clockCustom intervals specify a half-turn (full cycle = 2 * abs(interval)), minimum magnitude 0.25 seconds. App previews can animate; WidgetKit decides cadence and may freeze. Reduced motion/luminance freezes standard clock poses and keeps custom/swing effects at rest. Dynamic scripts are not rerun on animation ticks."},widgetAccentable:{type:"boolean",documentation:"Group this view into the accent layer in tinted and vibrant widget appearances."},linkurl:{type:"url",documentation:"Widget deep link URL."}},components:{VStack:{documentation:"Arrange children vertically.",children:!0,properties:{spacing:{type:"number"}}},HStack:{documentation:"Arrange children horizontally.",children:!0,properties:{spacing:{type:"number"}}},ZStack:{documentation:"Overlay children.",children:!0,properties:{}},VGrid:{documentation:"Vertical lazy grid.",children:!0,properties:{columns:{type:"string",required:!0},spacing:{type:"number"},alignment:{type:"enum",values:["leading","center","trailing"]}}},HGrid:{documentation:"Horizontal lazy grid.",children:!0,properties:{columns:{type:"string",required:!0},spacing:{type:"number"},alignment:{type:"enum",values:["top","center","bottom","firstTextBaseline","lastTextBaseline"]}}},Text:{documentation:"Display text content.",children:!1,properties:{text:{type:"string"}}},Date:{documentation:"Display a formatted date.",children:!1,properties:{date:{type:"date|number",required:!0},style:{type:"enum",values:["time","date","relative","offset","timer"]}}},Image:{documentation:"Display a bundled, remote, or SF Symbol image.",children:!1,properties:{systemName:{type:"string"},name:{type:"string"},id:{type:"string",deprecated:"Use name."},url:{type:"url"},src:{type:"url",deprecated:"Use url."},ratio:{type:"number"},mode:{type:"enum",values:["fit","fill"]},accentedRenderingMode:{type:"enum",values:["accented","desaturated","accentedDesaturated","fullColor"],documentation:"Control how the image is rendered in tinted and clear widget appearances."}}},Gif:{documentation:"Display a bounded package GIF using system decoding: up to 8 MiB input and 1,048,576 canvas pixels. iOS retains at most 60 downsampled frames / 4 MiB decoded pixels; more frames fall back to the first frame. Mac, Reduce Motion and reduced luminance use a static first frame. Active iOS previews use public SwiftUI timing with variable frame delays. Snapshots, inactive scenes, Mac and accessibility fallbacks use the first frame. No private clock bridge or continuous WidgetKit guarantee.",children:!1,properties:{file:{type:"string",required:!0}}},Spacer:{documentation:"Flexible layout space.",children:!1,properties:{minLength:{type:"number"}}},Rect:{documentation:"Rectangle shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},RoundedRect:{documentation:"Filled rounded rectangle.",children:!1,properties:{radius:{type:"number"}}},Capsule:{documentation:"Capsule shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Ellipse:{documentation:"Ellipse shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Circle:{documentation:"Circle shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Gauge:{documentation:"Display a gauge or instrument.",children:!1,properties:{type:{type:"string"},value:{type:"number"},style:{type:"enum",values:["circular","linear"]},text:{type:"string"},current:{type:"string"},min:{type:"string"},max:{type:"string"},angle:{type:"number"},thickness:{type:"number"},needleColor:{type:"color"},label:{type:"string"},title:{type:"string"},sections:{type:"string"}}},Chart:{documentation:"Render chart data.",children:!1,availability:{ios:"16.0",macos:"26.0"},properties:{type:{type:"enum",values:["bar","bar-x","bar-y","bar-gantt","line","point","line-point","area","rect","rule-x"]},data:{type:"json",required:!0},category:{type:"boolean"},hideLegend:{type:"boolean"},hideXAxis:{type:"boolean"},hideYAxis:{type:"boolean"}}},Link:{documentation:"Open a URL when selected.",children:!0,properties:{url:{type:"url",required:!0}}},Divider:{documentation:"Horizontal or vertical separator.",children:!1,properties:{thickness:{type:"number"},axis:{type:"enum",values:["horizontal","vertical"]}}},Line:{documentation:"Fixed-length line.",children:!1,properties:{thickness:{type:"number"},length:{type:"number"},axis:{type:"enum",values:["horizontal","vertical"]}}},Icon:{documentation:"SF Symbol icon.",children:!1,properties:{systemName:{type:"string",required:!0},size:{type:"number"}}},Label:{documentation:"Text paired with an SF Symbol.",children:!1,properties:{title:{type:"string"},systemName:{type:"string",required:!0}}},Progress:{documentation:"Linear or circular progress.",children:!1,properties:{value:{type:"number",required:!0},total:{type:"number"},label:{type:"string"},style:{type:"enum",values:["linear","circular"]},trackColor:{type:"color"},thickness:{type:"number"}}},Ring:{documentation:"Circular progress ring.",children:!1,properties:{value:{type:"number",required:!0},thickness:{type:"number"},trackColor:{type:"color"}}},Badge:{documentation:"Compact status badge.",children:!1,properties:{text:{type:"string"},radius:{type:"number"}}},Chip:{documentation:"Outlined metadata chip.",children:!1,properties:{text:{type:"string"},radius:{type:"number"},borderColor:{type:"color"}}},Stat:{documentation:"Title, value, and subtitle statistic.",children:!1,properties:{title:{type:"string"},value:{type:"string",required:!0},subtitle:{type:"string"},mutedColor:{type:"color"}}},Button:{documentation:"Interactive widget button. Use actionID to share a declared Package 2.0 action with Siri, Shortcuts, and Control Widgets.",children:!0,availability:{interactiveIos:"17.0"},requiredAny:["action","onClick","actionID"],properties:{action:{type:"enum",values:["reload"],conflicts:["actionID"]},onClick:{type:"function",conflicts:["actionID"]},actionID:{type:"action-id",conflicts:["action","onClick"]}}},Toggle:{documentation:"Interactive widget toggle. A declared actionID requires a package-relative storage stateKey.",children:!0,availability:{interactiveIos:"17.0"},requiredAny:["onClick","actionID"],properties:{on:{type:"boolean",required:!0},onClick:{type:"function",conflicts:["actionID"]},actionID:{type:"action-id",requires:["stateKey"],conflicts:["onClick"]},stateKey:{type:"storage-key",requires:["actionID"]}}}},functions:{...Object.fromEntries(O1.map(n=>[n.id,n])),...Object.fromEntries(A1.map(n=>[n.id,{documentation:n.notes,arguments:n.arguments,returns:n.asynchronous?"Promise":typeof n.value=="object"?"json":typeof n.value}])),"$icloud.readJSON":{documentation:"Read cached JSON and revision; conflicts preserve all heads. Requires icloud permission and a native connection. Never certifies upload.",arguments:["name"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.writeJSON":{documentation:"Save a new immutable JSON revision locally from a user action. Requires the revision from readJSON. Background exchange is eventual.",arguments:["name","value","expectedRevision"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.resolveJSON":{documentation:"Explicitly resolve all observed conflicting heads into a new revision. Stale tokens fail; originals remain.",arguments:["name","value","expectedRevision"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.sync":{documentation:"Exchange materialized revisions with iCloud; requires a user action. Upload completion is unknown.",arguments:[],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.status":{documentation:"Read native connection state. Cloud store IDs are granted in the app, never by the script. Web uses preview mocks.",arguments:[],returns:"Promise",minimumRuntimeVersion:"1.5"},"$file.exists":{documentation:"Return whether a regular file is locally present inside this package, including binary assets. Missing files, directories, unsafe paths and links return false. Does not download iCloud files or read outside the package. Web preview uses workspace file presence.",arguments:["path"],returns:"boolean",minimumRuntimeVersion:"1.3"},"$file.read":{documentation:"Read package-relative UTF-8 text. Missing or unavailable files return an empty string.",arguments:["path"],returns:"string"},"$file.readJSON":{documentation:"Read a package-relative JSON object.",arguments:["path"],returns:"json"},fetch:{documentation:"Perform a network request and return its response text. Existing HTTP methods keep this string result."},"$http.getResponse":{documentation:"GET response metadata: {status, body, headers}. Headers are limited to content-type, cache-control, expires, last-modified, date and retry-after (lowercase; each at most 2048 UTF-8 bytes). Network permissions, public-host policy, redirects, body limits and timeline restrictions still apply. HTTP error statuses resolve; transport errors reject.",arguments:["url","options?"],returns:"Promise",minimumRuntimeVersion:"1.3"},importJS:{documentation:"Import a package-relative JavaScript file."},"$dataSource.request":{documentation:"Call a declared Data Source Plugin operation. Requires Package 2.0 plugins, network permission, and networkDomains declarations.",arguments:["pluginID","operationID","parameters"],returns:"Promise"},"$xml.parse":{documentation:"Parse up to 256 KiB of XML into {name, attributes, text, children}. DTDs and external entities are rejected; depth and node limits apply.",arguments:["source"],returns:"XMLNode"}}};function b1(n,e){const t=Object.entries(e.properties??{}).filter(([,r])=>r.required).map(([r,s])=>`${r}=${s.type.includes("number")||s.type==="boolean"?"{${}}":'"${}"'}`).join(" "),i=t?` ${t}`:"";return e.children?`<${n}${i}> - \${} -`:`<${n}${i} />`}const lh=Object.entries(Re.components).map(([n,e])=>({label:n,type:"class",detail:`ScriptWidget · ${Object.keys(e.properties??{}).length} properties`,info:e.documentation,apply:b1(n,e)}));function S1(n){const e=n.match(/<([A-Za-z][\w]*)\b([^<>]*)$/);return!e||e[2].includes(">")?null:{name:e[1],attributes:e[2]}}function x1(n,e){const t=Re.components[n];return t?Object.entries({...Re.globalProperties,...t.properties??{}}).filter(([i])=>!e.has(i)).map(([i,r])=>({label:i,type:"property",detail:r.required?`${r.type} · required`:r.type,info:r.deprecated?`Deprecated: ${r.deprecated}`:r.documentation,apply:`${i}=${r.type.includes("number")||r.type==="boolean"?"{${}}":'"${}"'}`})):[]}function w1(n){const e=n.match(/<([A-Za-z][\w]*)\b[^<>]*\b([A-Za-z][\w]*)\s*=\s*["']([^"']*)$/);if(!e)return null;const t=Re.components[e[1]]?.properties?.[e[2]]??Re.globalProperties[e[2]];return t?.values?{typed:e[3],values:t.values}:null}function v1(n){const e=n.state.doc.sliceString(Math.max(0,n.pos-1200),n.pos),t=w1(e);if(t)return{from:n.pos-t.typed.length,options:t.values.map(o=>({label:o,type:"enum"})),validFor:/^[\w-]*$/};const i=n.matchBefore(/<[A-Za-z]*$/);if(i)return{from:i.from+1,options:lh,validFor:/^[A-Za-z]*$/};const r=S1(e);if(r&&/(?:\s|^)\w*$/.test(r.attributes)){const o=n.matchBefore(/[A-Za-z][\w]*$/),l=new Set([...r.attributes.matchAll(/\b([A-Za-z][\w]*)\s*=/g)].map(a=>a[1]));return{from:o?.from??n.pos,options:x1(r.name,l),validFor:/^[A-Za-z][\w]*$/}}const s=n.matchBefore(/\$[A-Za-z]+\.[A-Za-z]*$/);if(s){const o=s.text.slice(0,s.text.indexOf(".")+1),l=Object.entries(Re.functions).filter(([a])=>a.startsWith(o));return l.length?{from:s.from+o.length,options:l.map(([a,c])=>({label:a.slice(o.length),type:"function",detail:c.returns,info:c.documentation})),validFor:/^[A-Za-z]*$/}:null}return n.explicit?{from:n.pos,options:lh,validFor:/^[A-Za-z]*$/}:null}function ah(n,e){const t=[];for(let i=n.node.firstChild;i;i=i.nextSibling)i.name===e&&t.push(i);return t}function Md(n){const e=[];return Ce(n).iterate({enter(t){if(t.name!=="JSXOpenTag"&&t.name!=="JSXSelfClosingTag")return;const r=ah(t,"JSXIdentifier")[0];r&&e.push({name:n.doc.sliceString(r.from,r.to),from:r.from,to:r.to,attributes:ah(t,"JSXAttribute").map(s=>{const o=s.firstChild;return o?{name:n.doc.sliceString(o.from,o.to),from:o.from,to:o.to}:null}).filter(Boolean)})}}),e}function Ed(n){const e=[];for(const t of Md(n.state)){const i=Re.components[t.name];if(!i)continue;const r=new Set([...Object.keys(Re.globalProperties),...Object.keys(i.properties??{})]),s=new Set(t.attributes.map(o=>o.name));for(const o of t.attributes){r.has(o.name)||e.push({from:o.from,to:o.to,severity:"warning",message:`“${o.name}” is not supported by <${t.name}>.`});const l=i.properties?.[o.name]??Re.globalProperties[o.name];l?.deprecated&&e.push({from:o.from,to:o.to,severity:"warning",message:`${o.name} is deprecated. ${l.deprecated}`})}for(const[o,l]of Object.entries(i.properties??{}))if(l.required&&!s.has(o)&&e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> requires the “${o}” property.`}),s.has(o)){for(const a of l.requires??[])s.has(a)||e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> “${o}” requires the “${a}” property.`});for(const a of l.conflicts??[])s.has(a)&&o cannot combine “${o}” with “${a}”.`})}i.requiredAny?.length&&!i.requiredAny.some(o=>s.has(o))&&e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> requires one of: ${i.requiredAny.map(o=>`“${o}”`).join(", ")}.`})}return e}function k1(n,e){const t=Md(n.state).find(r=>e>=r.from&&e<=r.to);if(!t)return null;const i=Re.components[t.name];return i?{pos:t.from,end:t.to,above:!0,create(){const r=document.createElement("div");r.className="studio-hover";const s=document.createElement("strong");s.textContent=`<${t.name}>`;const o=document.createElement("p");return o.textContent=i.documentation,r.append(s,o),{dom:r}}}:null}const ch={light:{background:"#FAFAFC",foreground:"#202124",gutter:"#F3F3F6",gutterText:"#8A8A93",activeLine:"#EDEEF3",selection:"#B9D7FF",caret:"#0067C0"},dark:{background:"#1E1F22",foreground:"#E8E8ED",gutter:"#191A1D",gutterText:"#777982",activeLine:"#292A2F",selection:"#315A85",caret:"#65B7FF"}};function Q1(n,e){return R.theme({"&":{height:"100%",color:n.foreground,backgroundColor:n.background,fontSize:"13px"},".cm-scroller":{fontFamily:'ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace',lineHeight:"1.58",overscrollBehavior:"contain"},".cm-content":{caretColor:n.caret,padding:"12px 0 32px"},".cm-line":{padding:"0 8px"},".cm-cursor, .cm-dropCursor":{borderLeftColor:n.caret},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:n.selection},".cm-activeLine":{backgroundColor:n.activeLine},".cm-gutters":{backgroundColor:n.gutter,color:n.gutterText,border:"none",paddingLeft:"env(safe-area-inset-left)"},".cm-activeLineGutter":{backgroundColor:n.activeLine,color:n.foreground},".cm-foldPlaceholder":{backgroundColor:"transparent",border:`1px solid ${n.gutterText}`,color:n.gutterText},".cm-tooltip":{border:e?"1px solid #41434A":"1px solid #D2D3D8",backgroundColor:e?"#292A2F":"#FFFFFF",borderRadius:"8px",overflow:"hidden",boxShadow:"0 8px 28px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete ul li[aria-selected]":{backgroundColor:e?"#315A85":"#DCEBFA",color:n.foreground},".cm-panels":{backgroundColor:n.gutter,color:n.foreground},".cm-searchMatch":{backgroundColor:e?"#725C1D":"#FFE69A"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e?"#8D6D20":"#FFD45C"}},{dark:e})}const P1=Ln.define([{tag:[g.keyword,g.controlKeyword,g.moduleKeyword,g.operatorKeyword,g.bool,g.null],color:"#FF7AB2"},{tag:[g.string,g.special(g.string)],color:"#FF8170"},{tag:[g.number,g.regexp],color:"#D9C97C"},{tag:[g.comment,g.lineComment,g.blockComment],color:"#7F8C98",fontStyle:"italic"},{tag:[g.tagName,g.typeName,g.className],color:"#5DD8FF"},{tag:g.attributeName,color:"#B281EB"},{tag:[g.propertyName,g.function(g.variableName),g.function(g.propertyName)],color:"#67B7A4"},{tag:g.definition(g.variableName),color:"#4EB0CC"},{tag:[g.variableName,g.operator,g.punctuation,g.bracket],color:"#E8E8ED"},{tag:g.invalid,color:"#FF453A"}]);function Ud(n){const e=n==="dark";return[Q1(e?ch.dark:ch.light,e),Jg(e?P1:i0)]}const C1=Lt.parser.configure({dialect:"jsx"}),T1=new Map(Object.keys(Re.components).map(n=>[n.toLowerCase(),n])),$1=new Set(["VStack","HStack","ZStack","VGrid","HGrid"]),R1=512*1024,K1=512,Z1=32,ci=n=>{const e=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t);return e},hi=(n,e)=>n.slice(e.from,e.to),de=n=>{throw new Error(n)},Fd=n=>{let e=!0;const t=n.replace(/&([^;\s]+);/g,(i,r)=>{const s={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};if(Object.hasOwn(s,r))return s[r];if(/^#(?:[0-9]+|x[0-9a-f]+)$/i.test(r)){const o=r[1].toLowerCase()==="x"?parseInt(r.slice(2),16):Number(r.slice(1));if(o>0&&o<=1114111&&!(o>=55296&&o<=57343))return String.fromCodePoint(o)}return e=!1,i});return e?t:void 0};function co(n,e=!1){if(e)return Fd(n.slice(1,-1));const t=n.trim();if(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(t)){const i=Number(t);return Number.isFinite(i)?i:void 0}if(t==="true"||t==="false")return t==="true";if(t.startsWith('"'))try{const i=JSON.parse(t);return typeof i=="string"?i:void 0}catch{}}function wi(n){const e={formatVersion:1,source:n,nodes:[],roots:[],issue:""};if(typeof n!="string"||new TextEncoder().encode(n).length>R1)return{...e,issue:"Layout editing supports source files up to 512 KiB."};const t=C1.parse(n);let i=!1;if(t.iterate({enter:s=>{s.type.isError&&(i=!0)}}),i)return{...e,issue:"Fix the JavaScript/JSX syntax before using Layout. Your source is preserved."};function r(s,o,l){(l>Z1||e.nodes.length>=K1)&&de("Layout editing supports up to 512 layers and 32 nesting levels.");const a=ci(s),c=a[0],h=a.at(-1),u=ci(c).find(S=>["JSXBuiltin","JSXIdentifier","JSXNamespacedName","JSXMemberExpression"].includes(S.name)),f=u?hi(n,u):"Fragment",d=T1.get(f.toLowerCase()),p=Re.components[d],m={...Re.globalProperties,...p?.properties??{}},O=c.name==="JSXOpenTag"&&h?.name==="JSXCloseTag",y=O?ci(h).find(S=>["JSXBuiltin","JSXIdentifier","JSXNamespacedName","JSXMemberExpression"].includes(S.name)):null;u&&O&&(!y||hi(n,y)!==f)&&de("Opening and closing JSX tags must match before using Layout.");const b={id:String(s.from),parentID:o,tag:f,component:d??null,from:s.from,to:s.to,openingEnd:c.to,insertAt:c.to-(O?1:2),contentFrom:c.to,contentTo:O?h.from:c.to,children:[],properties:[],locked:!p,structure:!1,text:null,textEditable:!1,depth:l};let x=!1;for(const S of ci(c)){if(S.name==="JSXSpreadAttribute"&&(x=!0),S.name!=="JSXAttribute")continue;const v=ci(S),U=hi(n,v[0]),F=v[2],j=F?co(hi(n,F),F.name==="JSXAttributeValue"):!0,E=F?.name==="JSXEscape"?co(n.slice(F.from+1,F.to-1)):j,M=Object.hasOwn(m,U)?m[U]:null;b.properties.push({name:U,value:E??null,from:S.from,to:S.to,editable:!!(p&&M&&M.type!=="function"&&E!==void 0),definition:M??null})}const C=new Set(b.properties.map(S=>S.name)).size!==b.properties.length;b.locked||=x||C,b.reason=x?"Spread properties are preserved; edit this element in Code.":C?"Duplicate properties are preserved; resolve them in Code.":p?"":"Custom components and fragments are preserved; edit them in Code.",b.locked&&b.properties.forEach(S=>{S.editable=!1}),e.nodes.push(b);const k=O?a.slice(1,-1):[];for(const S of k)S.name==="JSXElement"&&b.children.push(r(S,b.id,l+1).id);if(b.structure=!b.locked&&O&&$1.has(d)&&k.every(S=>S.name==="JSXElement"||S.name==="JSXText"&&!hi(n,S).trim())&&b.children.every(S=>!e.nodes.find(v=>v.id===S).locked),!b.locked&&d==="Text"&&O&&k.length===1){const S=k[0],v=hi(n,S),U=S.name==="JSXText"&&!/[\r\n]/.test(v)?Fd(v):S.name==="JSXEscape"?co(v.slice(1,-1)):void 0;typeof U=="string"&&(b.text=U,b.textEditable=!0)}return b}try{t.iterate({enter(s){if(s.name!=="CallExpression")return;const o=ci(s.node);if(o[0]?.name!=="VariableName"||hi(n,o[0])!=="$render"||o[1]?.name!=="ArgList")return;const l=ci(o[1]).filter(a=>!["(",")"].includes(a.name));if(l.length===1&&l[0].name==="JSXElement")return e.roots.push(r(l[0],null,0).id),!1}})}catch(s){return{...e,nodes:[],roots:[],issue:s.message}}return e.roots.length||(e.issue="Layout needs a direct $render(…) or another native JSX element. Variables, loops and functions stay editable in Code."),e}function hl(n){return!n?.component||n.locked?{}:{...Re.globalProperties,...Re.components[n.component]?.properties??{}}}function M1(n,e,t){(n.source!==e||n.issue)&&de("Layout changed. Select the layer again before editing.");const i=n.nodes.find(a=>a.id===t.id);(!i||i.locked)&&de("This layer is locked. Edit its source in Code.");let r=[],s=i.from;if(t.type==="property"){const a=hl(i),c=Object.hasOwn(a,t.name)?a[t.name]:null,h=i.properties.find(d=>d.name===t.name);(!c||c.type==="function"||h&&!h.editable)&&de("Dynamic or unsupported properties must be edited in Code.");const u=new Set(i.properties.map(d=>d.name)),f=Re.components[i.component];if(t.remove?(f.requiredAny?.includes(t.name)&&!f.requiredAny.some(d=>d!==t.name&&u.has(d))&&de("Keep at least one required component property."),Object.entries(f.properties??{}).some(([d,p])=>u.has(d)&&p.requires?.includes(t.name))&&de("Another property requires this value. Edit the dependent properties together in Code.")):(c.requires?.some(d=>!u.has(d))&&de("Add the required related properties together in Code."),(c.conflicts?.some(d=>u.has(d))||Object.entries(f.properties??{}).some(([d,p])=>d!==t.name&&u.has(d)&&p.conflicts?.includes(t.name)))&&de("This property conflicts with another component property.")),t.remove)(!h||c.required)&&de("This property cannot be removed."),r=[{from:h.from,to:h.to,insert:""}];else{const d=t.value;(!["string","number","boolean"].includes(typeof d)||typeof d=="number"&&!Number.isFinite(d)||typeof d=="string"&&d.length>8192)&&de("Use a bounded string, finite number or Boolean."),c.values&&!c.values.includes(d)&&de("Choose one of the supported property values."),c.type==="boolean"&&typeof d!="boolean"&&de("This property needs true or false."),c.type==="number"&&!(typeof d=="number"||typeof d=="string"&&d.trim()&&Number.isFinite(Number(d)))&&de("This property needs a number."),typeof d=="boolean"&&c.type!=="boolean"&&de("This property does not accept a Boolean."),typeof d=="number"&&!c.type.includes("number")&&de("This property needs a string value."),t.name==="opacity"&&!(Number(d)>=0&&Number(d)<=1)&&de("Opacity must be between zero and one.");const p=`${t.name}={${JSON.stringify(d)}}`;r=h?[{from:h.from,to:h.to,insert:p}]:[{from:i.insertAt,to:i.insertAt,insert:` ${p}`}]}}else if(t.type==="text")(!i.textEditable||typeof t.value!="string"||t.value.length>8192)&&de("Dynamic text is preserved. Edit it in Code."),r=[{from:i.contentFrom,to:i.contentTo,insert:`{${JSON.stringify(t.value)}}`}];else if(t.type==="move"||t.type==="remove")if(n.nodes.find(c=>c.id===i.parentID)?.structure||de("Only literal children of a supported stack/grid can be moved or removed."),t.type==="remove")r=[{from:i.from,to:i.to,insert:""}];else{const c=n.nodes.find(p=>p.id===t.parentID);(!c?.structure||c.from>=i.from&&c.to<=i.to)&&de("Choose a supported container outside this layer.");const h=p=>{for(;p.parentID!==null;)p=n.nodes.find(m=>m.id===p.parentID);return p.id};h(i)!==h(c)&&de("Layers cannot move between render branches or JavaScript scopes.");const u=c.children.filter(p=>p!==i.id),f=t.index;(!Number.isInteger(f)||f<0||f>u.length)&&de("Invalid layer position.");const d=f===u.length?c.contentTo:n.nodes.find(p=>p.id===u[f]).from;if(d===i.from||d===i.to)return{changes:[],selectedFrom:s};r=[{from:i.from,to:i.to,insert:""},{from:d,to:d,insert:e.slice(i.from,i.to)}],s=d-(d>i.to?i.to-i.from:0)}else if(t.type==="add"){i.structure||de("Choose a supported container with literal JSX children.");const a={text:'New text',spacer:"",stack:'',icon:''};Object.hasOwn(a,t.kind)||de("Unsupported new layer."),r=[{from:i.contentTo,to:i.contentTo,insert:a[t.kind]}],s=i.contentTo}else de("Unsupported layout operation.");r.sort((a,c)=>a.from-c.from);let o=e;for(const a of[...r].reverse())o=o.slice(0,a.from)+a.insert+o.slice(a.to);return wi(o).issue&&de("This edit would leave the supported layout. Your source was not changed."),{changes:r,selectedFrom:s}}const Dd=Lt.parser.configure({dialect:"jsx"}),Ci=n=>{const e=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t);return e},Qe=n=>{throw new Error(n)},Gi=Object.freeze({background:{type:"color"},surface:{type:"color"},foreground:{type:"color"},muted:{type:"color"},accent:{type:"color"},titleFont:{values:Re.globalProperties.font.values},bodyFont:{values:Re.globalProperties.font.values},fontDesign:{values:Re.globalProperties.fontDesign.values},corner:{type:"number",maximum:48},padding:{type:"number",maximum:48},spacing:{type:"number",maximum:32}}),mr={titleFont:"headline",bodyFont:"caption",fontDesign:"rounded",corner:20,padding:16,spacing:10},rs=Object.freeze({Meadow:Object.freeze({...mr,background:"#F2FAF5",surface:"#FFFFFF",foreground:"#193F31",muted:"#607C70",accent:"#328963"}),Paper:Object.freeze({...mr,background:"#F4F7FD",surface:"#FFFFFF",foreground:"#243454",muted:"#687795",accent:"#4777D6"}),Peach:Object.freeze({...mr,background:"#FFF5EE",surface:"#FFFFFF",foreground:"#56392C",muted:"#967461",accent:"#C86B43"}),Midnight:Object.freeze({...mr,background:"#192332",surface:"#283548",foreground:"#F1F5FC",muted:"#AABAD0",accent:"#8EB7FF"})});function Xd(n,e){Object.hasOwn(Gi,n)||Qe("Unknown theme token.");const t=Gi[n];t.type==="color"&&!(typeof e=="string"&&/^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/i.test(e))&&Qe(`${n} needs a six or eight digit hex color.`),t.values&&!t.values.includes(e)&&Qe(`${n} needs a supported font value.`),t.type==="number"&&!(typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=t.maximum)&&Qe(`${n} needs a number from zero to ${t.maximum}.`)}function ea(n){(!n||typeof n!="object"||Array.isArray(n)||Object.keys(n).length!==Object.keys(Gi).length)&&Qe("A theme needs exactly the documented tokens.");for(const e of Object.keys(n))Xd(e,n[e]);return n}function Ld(n){(typeof n!="string"||new TextEncoder().encode(n).length>4096)&&Qe("Theme JSON is limited to 4 KiB.");const e=JSON.parse(n);return(!e||Array.isArray(e)||Object.keys(e).sort().join()!=="formatVersion,name,tokens"||e.formatVersion!==1||typeof e.name!="string"||!e.name.trim()||/[\u0000-\u001f]/.test(e.name)||new TextEncoder().encode(e.name).length>64)&&Qe("Use a version 1 theme with a name of at most 64 bytes."),ea(e.tokens),e}function E1(n,e="My theme"){const t=JSON.stringify({formatVersion:1,name:e,tokens:n},null,2);return Ld(t),t}function ss(n){const e={source:n,tokens:null,ranges:{},issue:"",canInitialize:!1};try{(typeof n!="string"||new TextEncoder().encode(n).length>512*1024)&&Qe("Theme editing supports files up to 512 KiB.");const t=Dd.parse(n),i=[],r=[];if(t.iterate({enter(a){a.type.isError&&Qe("Fix JavaScript syntax before editing the theme."),["VariableDefinition","VariableName"].includes(a.name)&&n.slice(a.from,a.to).includes("\\")&&Qe("Escaped identifiers stay in Code."),n.slice(a.from,a.to)==="widgetTheme"&&["VariableDefinition","VariableName"].includes(a.name)&&(a.name==="VariableDefinition"?i:r).push(a.node)}}),!i.length&&!r.length){const a=wi(n);e.canInitialize=!a.issue&&a.roots.length===1&&!a.nodes[0].locked;let c=!1;for(const h of Ci(t.topNode)){const u=h.firstChild;a.nodes[0]&&h.name==="ExpressionStatement"&&u?.name==="CallExpression"&&n.slice(u.firstChild.from,u.firstChild.to)==="$render"&&u.froma.nodes[0].to&&(c=!0)}return e.canInitialize&&=c,e}i.length!==1&&Qe("Keep one top-level const widgetTheme object. Other bindings stay in Code.");const s=i[0].parent,o=Ci(s);(s.name!=="VariableDeclaration"||s.parent?.name!=="Script"||o[0]?.name!=="const"||o[1]?.from!==i[0].from||o[2]?.name!=="Equals"||o[3]?.name!=="ObjectExpression"||o.slice(4).some(a=>a.name!==";"))&&Qe("Theme editing needs a single top-level const widgetTheme = { … } declaration.");const l={};for(const a of Ci(o[3])){if(["{","}",","].includes(a.name))continue;const c=Ci(a),h=c[0]?n.slice(c[0].from,c[0].to):"",u=c[0]?.name==="String"&&h.startsWith('"')?JSON.parse(h):h;(a.name!=="Property"||c.length!==3||!["PropertyDefinition","String"].includes(c[0].name)||c[1].name!==":"||!["String","Number"].includes(c[2].name)||Object.hasOwn(l,u))&&Qe("Theme tokens must be unique literal properties. Computed or dynamic values stay in Code.");let f;try{f=JSON.parse(n.slice(c[2].from,c[2].to))}catch{Qe("Theme values use JSON strings or numbers. Edit this declaration in Code.")}Xd(u,f),l[u]=f,e.ranges[u]={from:c[2].from,to:c[2].to}}ea(l);for(const a of r){const c=a.parent,h=Ci(c),u=h[2]?n.slice(h[2].from,h[2].to):"";(c.name!=="MemberExpression"||h[0].from!==a.from||h[1]?.name!=="."||h[2]?.name!=="PropertyName"||!Object.hasOwn(Gi,u))&&Qe("Theme references must read widgetTheme.token. Other uses stay in Code."),c.parent?.name==="MemberExpression"&&Qe("Mutable theme references stay in Code.");for(let f=c.parent;f;f=f.parent)(["UpdateExpression","PostfixExpression"].includes(f.name)||f.name==="UnaryExpression"&&/^(?:delete|\+\+|--)/.test(n.slice(f.from,c.from).trim())||f.name==="AssignmentExpression"&&f.firstChild.from<=c.from&&f.firstChild.to>=c.to||f.name==="ForOfSpec"||f.name==="ForInSpec")&&Qe("Mutable theme references stay in Code.")}e.tokens=l}catch(t){e.issue=t.message}return e}function ho(n,e,t){return(n.source!==e||n.issue||!n.tokens)&&Qe("Theme changed or is unsupported. Reopen Theme before editing."),ea(t),{changes:Object.keys(Gi).filter(r=>t[r]!==n.tokens[r]).map(r=>({...n.ranges[r],insert:JSON.stringify(t[r])})).sort((r,s)=>r.from-s.from)}}function U1(n,e="Meadow"){(!ss(n).canInitialize||!Object.hasOwn(rs,e))&&Qe("Start with a literal top-level layout without an existing widgetTheme binding.");const i=wi(n),r=i.nodes[0],s=[];function o(c,h,u,f=!1){const d=c.properties.find(m=>m.name===h);if(c.locked||d&&!d.editable||!d&&!f)return;const p=`${h}={widgetTheme.${u}}`;s.push(d?{from:d.from,to:d.to,insert:p}:{from:c.insertAt,to:c.insertAt,insert:` ${p}`})}for(const c of["background","corner","padding"])o(r,c,c,!0);r.structure&&o(r,"spacing","spacing",!0);for(const c of i.nodes)if(c.component==="Text"){const h=c.properties.find(f=>f.name==="font")?.value,u=["headline","largeTitle","title","title2","title3"].includes(h);o(c,"font",u?"titleFont":"bodyFont",!0),o(c,"color",u?"foreground":"muted",!0),o(c,"fontDesign","fontDesign",!0)}else c.component==="Icon"&&o(c,"color","accent",!0);let l=0;for(const c of Ci(Dd.parse(n).topNode))if(!(c.name==="LineComment"||c.name==="BlockComment"))if(c.name==="ExpressionStatement"&&c.firstChild?.name==="String")l=c.to;else break;s.push({from:l,to:l,insert:` -const widgetTheme = ${JSON.stringify(rs[e],null,2)}; -`}),s.sort((c,h)=>c.from-h.from);let a=n;for(const c of[...s].reverse())a=a.slice(0,c.from)+c.insert+a.slice(c.to);return(!ss(a).tokens||wi(a).issue)&&Qe("This layout cannot be themed automatically. Your source was preserved."),{changes:s}}function Bd(n){if(!Array.isArray(n)||n.length>4096)return[];const e=new Map,t=new Set;for(const i of n){if(typeof i!="string"||new TextEncoder().encode(i).length>1024||/[\\\u0000-\u001f\u007f-\u009f]/.test(i))continue;const r=i.split("/");if(r.length!==2||r[0]!=="image"||!r[1]||new TextEncoder().encode(r[1]).length>255||r[1]!==r[1].trim()||r[1].includes("..")||!/\.(png|jpe?g|webp)$/i.test(r[1]))continue;const s=i.normalize("NFC").toLowerCase();e.has(s)&&e.get(s)!==i&&t.add(s),e.set(s,i)}return[...e].filter(([i])=>!t.has(i)).map(([,i])=>i).sort().slice(0,256)}const ta=W.define(),os=Te.define({create:()=>[],update(n,e){for(const t of e.effects)t.is(ta)&&(n=Bd(t.value));return n}});function ia(n,e){n.state.field(os,!1)!==void 0&&n.dispatch({effects:ta.of(e)})}const qd=Object.freeze({bloom:Object.freeze({name:"Bloom mark",description:"A small four-petal flower",kind:"icon"}),leaf:Object.freeze({name:"Leaf mark",description:"A tilted leaf and stem",kind:"icon"}),pebble:Object.freeze({name:"Pebble friend",description:"A quiet, round-eared companion",kind:"pet"})}),uo=`/* -ScriptWidget original geometric assets 1: Bloom mark, Leaf mark, Pebble friend. -Source: https://github.com/everettjf/scriptwidget (Editor/editorfe/src/visualAssets.js) -SPDX-License-Identifier: MIT -Copyright (c) 2021-2022 everettjf - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ -`;function F1(n,e){const t=i=>e?`{widgetTheme.${i}}`:JSON.stringify(rs.Meadow[i]);if(n==="bloom")return``;if(n==="leaf")return``;if(n==="pebble")return``;throw new Error("Choose an original asset from the catalog.")}function D1(n,e,{id:t,kind:i,path:r},s=[]){if(n.source!==e||n.issue)throw new Error("Layout changed. Select the container again.");const o=n.nodes.find(f=>f.id===t);if(!o?.structure)throw new Error("Select a stack/grid with literal JSX children in Layout or Assets.");let l;if(i==="photo"){if(!Bd(s).includes(r))throw new Error("This image is no longer in the package resource list. Refresh images.");l=``}else{if(!Object.hasOwn(qd,i))throw new Error("Choose an original asset from the catalog.");l=F1(i,!!ss(e).tokens)}const a=[{from:o.contentTo,to:o.contentTo,insert:l}];let c=o.contentTo;if(i!=="photo"&&!e.includes(uo)){const f=e.startsWith("#!")?e.indexOf(` -`)+1:0;a.push({from:f,to:f,insert:uo}),c+=uo.length}a.sort((f,d)=>f.from-d.from);let h=e;for(const f of[...a].reverse())h=h.slice(0,f.from)+f.insert+h.slice(f.to);if(wi(h).issue)throw new Error("This asset would exceed the supported layout limits. Your source was preserved.");return{changes:a,selectedFrom:c}}const X1=n=>["string","number","number|string","date|number","boolean","enum","color","url","action-id","storage-key"].includes(n.type);function L(n,e,t){const i=document.createElement(n);return e&&(i.className=e),t!==void 0&&(i.textContent=t),i}function L1(n,e){const t=L("section","sw-layout"),i=L("div","sw-layout-header"),r=L("div","sw-layout-body");t.setAttribute("aria-label","Visual layout editor");let s=!1,o="layout",l=null,a=null,c="",h=null,u=!1,f=0;const d=String(Math.random()),p=(Q,D)=>P=>{if(u||!t.contains(Q)){P.preventDefault();return}return D(P)},m=(Q,D,P)=>Q.addEventListener(D,p(Q,P)),O=(Q,D,P=!1)=>{const V=L("button","sw-layout-button",Q);return V.type="button",V.disabled=P,m(V,"click",D),V},y=O("Layout",()=>{s=o==="layout"?!s:!0,o="layout",Y(),n.requestMeasure()});y.classList.add("sw-layout-toggle"),y.setAttribute("aria-expanded","false");const b=L("span","sw-layout-hint","Select layers and edit literal JSX"),x=O("Undo",()=>Xl(n)),C=O("Redo",()=>Wr(n)),k=O("Theme",()=>{s=o==="theme"?!s:!0,o="theme",Y(),n.requestMeasure()});k.setAttribute("aria-expanded","false");const S=O("Assets",()=>{s=o==="assets"?!s:!0,o="assets",Y(),n.requestMeasure()});S.setAttribute("aria-expanded","false"),i.append(y,k,S,b,x,C),t.append(i,r),r.hidden=x.hidden=C.hidden=!0;const v=L("p","sw-layout-error");v.setAttribute("role","alert"),v.hidden=!0,t.append(v);function U(){l=wi(n.state.doc.toString());const Q=L("div","sw-layout-inspector sw-theme-inspector");if(r.replaceChildren(Q),Q.append(L("div","sw-layout-title","Widget assets")),Q.append(L("p","sw-layout-notice","Insert editable original JSX or a package image. Originals follow connected theme colors; pet artwork is static. Import photos with the app's existing image tools or Web Studio's Add image.")),l.issue){Q.append(L("p","sw-layout-notice",l.issue));return}const D=l.nodes.filter(q=>q.structure),P=L("select");P.setAttribute("aria-label","Asset destination");for(const q of D){const G=L("option","",`${q.tag} · line ${n.state.doc.lineAt(q.from).number}`);G.value=q.id,P.append(G)}D.some(q=>q.id===a)?P.value=a:a=P.value,m(P,"change",()=>{a=P.value}),Q.append(P);const V=n.state.readOnly||!D.length;D.length||Q.append(L("p","sw-layout-notice","Add a stack/grid with literal JSX children in Code to insert assets."));function le(q,G){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");const ce=D1(l,n.state.doc.toString(),{id:P.value,kind:q,path:G},n.state.field(os));a=P.value,v.hidden=!0,n.dispatch({changes:ce.changes,selection:{anchor:ce.selectedFrom},annotations:vr.of("full"),userEvent:"input.asset",scrollIntoView:!0})}catch(ce){v.textContent=ce.message,v.hidden=!1}}for(const[q,G]of Object.entries(qd)){const ce=L("div","sw-layout-actions");ce.append(O(`Insert ${G.name}`,()=>le(q),V),L("span","",G.description)),Q.append(ce)}Q.append(L("div","sw-layout-title","Package images"));const J=n.state.field(os),ee=L("select");ee.setAttribute("aria-label","Package image");for(const q of J){const G=L("option","",q);G.value=q,ee.append(G)}ee.disabled=!J.length,Q.append(ee,O("Insert package image",()=>le("photo",ee.value),V||!J.length)),J.length||Q.append(L("p","sw-layout-notice","No supported images in image/. Add a PNG, JPEG or WebP to the package, then refresh or reopen the editor.")),e.refreshResources&&Q.append(O("Refresh images",async()=>{const q=++f,G=n.state.doc,ce=()=>!u&&q===f&&n.state.doc===G;try{const I=await e.refreshResources();ce()&&(v.hidden=!0,ia(n,I))}catch{ce()&&(v.textContent="Images could not be refreshed. Reopen this document and try again.",v.hidden=!1)}})),Q.append(L("p","sw-layout-notice","Bloom mark, Leaf mark and Pebble friend: original ScriptWidget geometry, MIT licensed. Package photos retain their own rights. See the Studio assets documentation."))}function F(Q,D){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");const P=n.state.doc.toString();if(P!==D)throw new Error("Source changed. Reopen Theme before editing.");const V=Q(P);v.hidden=!0,V.changes.length&&n.dispatch({changes:V.changes,annotations:vr.of("full"),userEvent:"input.theme"})}catch(P){v.textContent=P.message,v.hidden=!1}}function j(){const Q=n.state.doc.toString(),D=ss(Q),P=n.state.readOnly,V=L("div","sw-layout-inspector sw-theme-inspector");if(r.replaceChildren(V),V.append(L("div","sw-layout-title","Widget theme")),V.append(L("p","sw-layout-notice","Saved as ordinary JavaScript with your widget. Dynamic values stay in Code. Applying a theme changes the connected colors, fonts and spacing.")),D.issue){V.append(L("p","sw-layout-notice",D.issue));return}if(!D.tokens){V.append(O("Connect layout to Meadow theme",()=>F(ee=>U1(ee),Q),P||!D.canInitialize)),D.canInitialize||V.append(L("p","sw-layout-notice","Use a literal top-level $render layout, or define the documented widgetTheme object in Code."));return}const le=L("div","sw-layout-actions");for(const[ee,q]of Object.entries(rs))le.append(O(ee,()=>F(G=>ho(D,G,q),Q),P));V.append(le);for(const[ee,q]of Object.entries(Gi)){const G=L("form","sw-layout-form"),ce=L("label","",ee),I=L(q.values?"select":"input");if(q.values)for(const se of q.values){const Me=L("option","",se);Me.value=se,I.append(Me)}q.type==="number"&&(I.type="number",I.min="0",I.max=String(q.maximum),I.step="any"),I.value=String(D.tokens[ee]),I.setAttribute("aria-label",`Theme ${ee}`),I.disabled=P;const te=O(`Apply ${ee}`,()=>{},P);te.type="submit",G.append(ce,I,te),m(G,"submit",se=>{se.preventDefault();const Me=q.type==="number"?I.value.trim()?Number(I.value):NaN:I.value;F(ge=>ho(D,ge,{...D.tokens,[ee]:Me}),Q)}),V.append(G)}const J=L("textarea");J.rows=5,J.setAttribute("aria-label","Reusable theme JSON"),J.value=E1(D.tokens),V.append(L("label","","Copy this JSON to reuse a theme, or paste a version 1 theme and import it."),J,O("Import theme JSON",()=>F(ee=>ho(D,ee,Ld(J.value).tokens),Q),P))}function E(Q,D=l?.source){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");if(D!==n.state.doc.toString())throw new Error("Source changed during this operation. Select the layer again.");const P=M1(l,n.state.doc.toString(),Q);if(v.hidden=!0,!P.changes.length)return;n.dispatch({changes:P.changes,selection:{anchor:P.selectedFrom},annotations:vr.of("full"),userEvent:"input.layout",scrollIntoView:!0})}catch(P){v.textContent=P.message,v.hidden=!1}}function M(Q){u||(a=Q.id,c="",n.dispatch({selection:{anchor:Q.from,head:Q.to},scrollIntoView:!0,userEvent:"select.layout"}),Y())}function Y(){if(y.setAttribute("aria-expanded",String(s&&o==="layout")),k.setAttribute("aria-expanded",String(s&&o==="theme")),S.setAttribute("aria-expanded",String(s&&o==="assets")),r.hidden=!s,x.hidden=C.hidden=!s,b.hidden=s,x.disabled=n.state.readOnly||wc(n.state)===0,C.disabled=n.state.readOnly||vc(n.state)===0,!s)return;if(o==="assets"){U();return}if(o==="theme"){j();return}if(l=wi(n.state.doc.toString()),r.replaceChildren(),l.issue){r.append(L("p","sw-layout-notice",l.issue));return}const Q=n.state.selection.main.from,D=l.nodes.filter(I=>I.from<=Q&&QI.id===a&&I.from<=Q&&Q<=I.to)??D??l.nodes[0];a=P.id;const V=L("div","sw-layout-layers");V.setAttribute("role","tree"),V.setAttribute("aria-label","Layout layers");const le=n.state.readOnly,J=I=>{const te=I.text??I.properties.find(se=>se.name==="text"&&se.editable&&typeof se.value=="string")?.value;return`<${I.tag}>${te?` · ${te.slice(0,32)}`:""}${I.locked?" · locked":""}`};for(const[I,te]of l.nodes.entries()){const se=l.nodes.find(ie=>ie.id===te.parentID),Me=!le&&!te.locked&&se?.structure,ge=O(J(te),()=>M(te));ge.classList.add("sw-layout-layer"),ge.dataset.layerId=te.id,ge.style.paddingInlineStart=`${8+te.depth*14}px`,ge.setAttribute("role","treeitem"),ge.setAttribute("aria-level",String(te.depth+1)),ge.setAttribute("aria-selected",String(te.id===P.id)),ge.tabIndex=te.id===P.id?0:-1,ge.draggable=!!Me,m(ge,"keydown",ie=>{let we;ie.key==="ArrowUp"&&(we=l.nodes[Math.max(0,I-1)]),ie.key==="ArrowDown"&&(we=l.nodes[Math.min(l.nodes.length-1,I+1)]),ie.key==="ArrowLeft"&&(we=se),ie.key==="ArrowRight"&&(we=l.nodes.find(qe=>qe.id===te.children[0])),ie.key==="Home"&&(we=l.nodes[0]),ie.key==="End"&&(we=l.nodes.at(-1)),we&&(ie.preventDefault(),ie.stopPropagation(),M(we),ee().find(qe=>qe.dataset.layerId===we.id)?.focus())}),m(ge,"dragstart",ie=>{if(!Me){ie.preventDefault();return}h={id:te.id,source:l.source},ie.dataTransfer.setData("application/x-scriptwidget-layer",d),ie.dataTransfer.effectAllowed="move"}),m(ge,"dragover",ie=>{h&&se?.structure&&te.id!==h.id&&(ie.preventDefault(),ie.dataTransfer.dropEffect="move")}),m(ge,"drop",ie=>{if(!h||ie.dataTransfer.getData("application/x-scriptwidget-layer")!==d||!se?.structure)return;ie.preventDefault();const we=h;h=null,E({type:"move",id:we.id,parentID:se.id,index:se.children.filter(qe=>qe!==we.id).indexOf(te.id)},we.source)}),m(ge,"dragend",()=>{h=null}),V.append(ge)}function ee(){return[...t.querySelectorAll(".sw-layout-layer")]}const q=L("div","sw-layout-inspector"),G=L("div","sw-layout-title",`<${P.tag}>`);if(q.append(G),(le||P.locked)&&q.append(L("p","sw-layout-notice",le?"This document is read only.":P.reason)),!le&&!P.locked){let ge=function(){c=se.value;const oe=hl(P)[c],Ae=P.properties.find(tt=>tt.name===c);if(Me.replaceChildren(),te.onsubmit=tt=>tt.preventDefault(),Ae&&!Ae.editable){Me.append(L("span","sw-layout-notice","Dynamic value: edit it in Code. Connected widgetTheme tokens can be changed in Theme."));return}const ae=L(oe.values||oe.type==="boolean"?"select":"input");ae.setAttribute("aria-label","Layout property value");for(const tt of oe.values??(oe.type==="boolean"?[!0,!1]:[])){const li=L("option","",String(tt));li.value=String(tt),ae.append(li)}ae.value=Ae?String(Ae.value):oe.values?.[0]??(oe.type==="boolean"?"true":"");const Ie=O("Apply",()=>{});Ie.type="submit",Me.append(ae,Ie,O("Remove",()=>E({type:"property",id:P.id,name:c,remove:!0}),!Ae||oe.required)),te.onsubmit=p(te,tt=>{tt.preventDefault();const li=oe.type==="boolean"?ae.value==="true":oe.type==="number"?ae.value.trim()?Number(ae.value):NaN:ae.value;E({type:"property",id:P.id,name:c,value:li})})};if(P.textEditable){const oe=L("form","sw-layout-form"),Ae=L("label","","Text"),ae=L("input");ae.value=P.text,ae.setAttribute("aria-label","Layer text");const Ie=O("Apply text",()=>{});Ie.type="submit",oe.append(Ae,ae,Ie),m(oe,"submit",tt=>{tt.preventDefault(),E({type:"text",id:P.id,value:ae.value})}),q.append(oe)}const I=Object.entries(hl(P)).filter(([,oe])=>X1(oe)),te=L("form","sw-layout-form"),se=L("select");se.setAttribute("aria-label","Layout property");for(const[oe]of I){const Ae=L("option","",oe);Ae.value=oe,se.append(Ae)}I.some(([oe])=>oe===c)||(c=P.structure?"alignment":"color"),se.value=c,se.value||(se.selectedIndex=0,c=se.value);const Me=L("div","sw-layout-property");te.append(se,Me),m(se,"change",ge),ge(),q.append(te);const ie=l.nodes.find(oe=>oe.id===P.parentID),we=ie?.children.indexOf(P.id)??-1,qe=L("div","sw-layout-actions");if(qe.append(O("Move up",()=>E({type:"move",id:P.id,parentID:ie.id,index:we-1}),!ie?.structure||we<=0),O("Move down",()=>E({type:"move",id:P.id,parentID:ie.id,index:we+1}),!ie?.structure||we>=ie.children.length-1),O("Delete layer",()=>E({type:"remove",id:P.id}),!ie?.structure)),q.append(qe),ie?.structure){const oe=l.nodes.filter(ae=>ae.structure&&!(ae.from>=P.from&&ae.to<=P.to)),Ae=L("select");Ae.setAttribute("aria-label","Move layer into container");for(const ae of oe){const Ie=L("option","",`${ae.tag} · line ${n.state.doc.lineAt(ae.from).number}`);Ie.value=ae.id,Ae.append(Ie)}q.append(Ae,O("Move inside",()=>{const ae=l.nodes.find(Ie=>Ie.id===Ae.value);E({type:"move",id:P.id,parentID:ae.id,index:ae.children.filter(Ie=>Ie!==P.id).length})},!oe.length))}if(P.structure){const oe=L("div","sw-layout-actions");for(const[Ae,ae]of[["text","Add text"],["stack","Add stack"],["spacer","Add spacer"],["icon","Add icon"]])oe.append(O(ae,()=>E({type:"add",id:P.id,kind:Ae})));q.append(oe)}}const ce=P.properties.filter(I=>!I.editable).map(I=>I.name);ce.length&&q.append(L("p","sw-layout-notice",`Preserved in Code: ${ce.join(", ")}`)),!P.structure&&P.children.length&&q.append(L("p","sw-layout-notice","This child structure stays in Code. Reordering is available on literal stack/grid children.")),r.append(V,q)}return{dom:t,top:!0,update(Q){if(!s)return;const D=n.state.selection.main.from,P=l?.nodes.filter(le=>le.from<=D&&Dle.effects.some(J=>J.is(ta)));(Q.docChanged||V||Q.startState.readOnly!==n.state.readOnly||Q.selectionSet&&P!==a)&&(Q.docChanged&&o!=="assets"&&(a=null),Y()),x.disabled=n.state.readOnly||wc(n.state)===0,C.disabled=n.state.readOnly||vc(n.state)===0},destroy(){u=!0}}}const B1=R.baseTheme({".sw-layout":{fontFamily:"system-ui, sans-serif",fontSize:"12px",backgroundColor:"#f6f7fa",color:"#272a34",borderBottom:"1px solid #dce0e9"},"&dark .sw-layout":{backgroundColor:"#252830",color:"#eceef5",borderColor:"#414552"},".sw-layout-header":{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"8px",padding:"6px 10px"},".sw-layout-toggle":{fontWeight:"600"},".sw-layout-hint":{opacity:"0.65",fontSize:"11px"},".sw-layout-button":{fontFamily:"inherit",fontSize:"11px",color:"inherit",backgroundColor:"transparent",border:"1px solid #a0a5b655",borderRadius:"6px",padding:"4px 8px",cursor:"pointer",whiteSpace:"nowrap"},".sw-layout-button:disabled":{opacity:"0.4",cursor:"default"},".sw-layout-body":{display:"grid",gridTemplateColumns:"minmax(120px, 1fr) minmax(180px, 1.6fr)",maxHeight:"280px",overflow:"auto",borderTop:"1px solid #a0a5b633"},".sw-layout-body[hidden]":{display:"none"},".sw-layout-layers":{padding:"6px 2px",overflow:"auto",borderRight:"1px solid #a0a5b633"},".sw-layout-layer":{display:"block",border:0,borderRadius:"4px",width:"100%",textAlign:"left",overflow:"hidden",textOverflow:"ellipsis",margin:"1px 0",paddingBlock:"6px"},'.sw-layout-layer[aria-selected="true"]':{backgroundColor:"#4085f52b",color:"inherit"},".sw-layout-inspector":{padding:"8px 10px",display:"flex",alignItems:"start",flexDirection:"column",gap:"8px",minWidth:0},".sw-theme-inspector":{gridColumn:"1 / -1"},".sw-theme-inspector textarea":{boxSizing:"border-box",width:"100%",fontFamily:"monospace",backgroundColor:"transparent",color:"inherit",border:"1px solid #a0a5b666",borderRadius:"5px"},".sw-layout-title":{fontWeight:"600"},".sw-layout-form":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"5px",width:"100%"},".sw-layout-property,.sw-layout-actions":{display:"flex",flexWrap:"wrap",gap:"5px",alignItems:"center"},".sw-layout input,.sw-layout select":{fontFamily:"inherit",fontSize:"12px",minWidth:0,maxWidth:"100%",padding:"4px 6px",border:"1px solid #a0a5b666",borderRadius:"5px",backgroundColor:"transparent",color:"inherit"},".sw-layout-notice":{margin:"8px",lineHeight:"1.5",fontSize:"11px",opacity:"0.7"},".sw-layout-body > .sw-layout-notice":{gridColumn:"1 / -1"},".sw-layout-error":{margin:"0 10px 6px",color:"#b32636",fontSize:"12px"},"&dark .sw-layout-error":{color:"#ff99a4"},".sw-layout button:focus-visible,.sw-layout input:focus-visible,.sw-layout select:focus-visible":{outline:"2px solid #4085f5",outlineOffset:"1px"},"@media (max-width: 480px)":{".sw-layout-body":{gridTemplateColumns:"minmax(90px, 1fr) minmax(150px, 1.6fr)"},".sw-layout-hint":{display:"none"}}});function q1(n={}){return[B1,os,ji.of(e=>L1(e,n))]}const Id="scriptwidget.studio.document-state.v1.";function zd(n,e,t){if(!n||!e)return!1;try{return n.setItem(`${Id}${e}`,JSON.stringify({anchor:Number(t.anchor)||0,head:Number(t.head)||0,scrollTop:Number(t.scrollTop)||0})),!0}catch{return!1}}function I1(n,e,t){if(!n||!e)return null;try{const i=JSON.parse(n.getItem(`${Id}${e}`));if(!i||typeof i!="object")return null;const r=s=>Math.max(0,Math.min(Number(s)||0,t));return{anchor:r(i.anchor),head:r(i.head),scrollTop:Math.max(0,Number(i.scrollTop)||0)}}catch{return null}}const z1="scriptwidget.web-studio.draft.v1:";function na(n){return`${z1}${n}`}function W1(n,e){if(!e)return null;try{const t=JSON.parse(n.getItem(na(e))||"null");return t&&typeof t.content=="string"&&typeof t.baseRevision=="string"?t:null}catch{return null}}function hh(n,e,t,i,r=Date.now()){if(!e||typeof i!="string")return null;const s={documentID:e,content:t,baseRevision:i,updatedAt:r};return n.setItem(na(e),JSON.stringify(s)),s}function fo(n,e){e&&n.removeItem(na(e))}function j1(n,e,t,i){const r=W1(n,e);return!r||r.content===t?null:{...r,serverContent:t,serverRevision:i,isStale:r.baseRevision!==i}}function V1(){return{connection:"connecting",save:"idle",preview:"idle",conflict:null}}function Y1(n,e){switch(e.type){case"CONNECTED":return{...n,connection:"connected"};case"OFFLINE":return{...n,connection:"offline",save:n.save==="saving"?"draft":n.save};case"DISCONNECTED":return{...n,connection:"disconnected"};case"EDITED":return{...n,save:"draft",conflict:null};case"SAVING":return{...n,save:"saving"};case"SAVED":return{...n,save:"saved",preview:e.preview||"requested",conflict:null};case"SAVE_FAILED":return{...n,save:"error"};case"CONFLICT":return{...n,save:"conflict",conflict:e.conflict};default:return n}}class N1{constructor(e){this.send=e,this.epoch=0,this.context=null,this.inFlight=null,this.needsFlush=!1}open({documentID:e,packageID:t,path:i,revision:r,content:s}){return this.epoch+=1,this.context={documentID:e,packageID:t,path:i,revision:r,content:s,generation:0,savedGeneration:0},this.needsFlush=!1,this.snapshot()}edit(e){return this.context?(this.context.content=e,this.context.generation+=1,this.snapshot()):null}rebase(e){return this.context&&(this.context.revision=e),this.snapshot()}get isDirty(){return!!(this.context&&this.context.generation!==this.context.savedGeneration)}snapshot(){return this.context?{...this.context,dirty:this.isDirty}:null}async flush(){if(!this.context||!this.isDirty)return{skipped:!0,snapshot:this.snapshot()};if(this.inFlight)return this.needsFlush=!0,this.inFlight.then(()=>this.isDirty?this.flush():{skipped:!0,snapshot:this.snapshot()});const e=this.epoch,t={...this.context};this.needsFlush=!1,this.inFlight=this.send({documentID:t.documentID,packageID:t.packageID,path:t.path,content:t.content,baseRevision:t.revision}).then(r=>this.epoch!==e||this.context?.documentID!==t.documentID?{ignored:!0,result:r,snapshot:this.snapshot()}:(this.context.revision=r.revision,this.context.savedGeneration=t.generation,{result:r,snapshot:this.snapshot()})).finally(()=>{this.inFlight=null});const i=await this.inFlight;return this.needsFlush&&this.isDirty?this.flush():i}}function uh(n){return["draft","saving","error","conflict"].includes(n)}class G1 extends Error{constructor(e,t,i={}){super(e),this.name="StudioAPIError",this.status=t,this.body=i}}class H1{constructor({fetchImpl:e=globalThis.fetch,token:t=()=>"",onUnauthorized:i=()=>{}}={}){if(typeof e!="function")throw new TypeError("A fetch implementation is required");this.fetchImpl=e,this.token=t,this.onUnauthorized=i}async request(e,t={}){const i=await this.fetchImpl(e,this.authorizedOptions(t)),r=await i.json().catch(()=>({}));return this.validate(i,e,r),r}async requestBlob(e,t={}){const i=await this.fetchImpl(e,this.authorizedOptions(t));if(!i.ok){const r=await i.json().catch(()=>({}));this.validate(i,e,r)}return i.blob()}authorizedOptions(e){return{...e,headers:{"Content-Type":"application/json","X-Studio-Token":this.token(),...e.headers||{}}}}validate(e,t,i){if(!e.ok){const r=new G1(i.message||`Request failed (${e.status})`,e.status,i);throw e.status===401&&t!=="/api/v1/pair"&&this.onUnauthorized(r),r}}}const ra=/^https?:$/.test(window.location.protocol),_1=document.querySelector(ra?"#editor":"#native-editor"),sa=new Hi,ls=new Hi;let It=null,me=null,Et=null,lt=0,vi=0,ul=!1,Mn=null,fh=null;const dh=document.querySelector("#save-status");let Wd=null;function En(n,e="idle"){dh.textContent=n,dh.dataset.state=e}function J1(){window.clearTimeout(fh),fh=window.setTimeout(()=>{const n=z.state.selection.main;zd(window.localStorage,me,{anchor:n.anchor,head:n.head,scrollTop:z.scrollDOM.scrollTop})},180)}function jd(){return window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"}function oa(){window.clearTimeout(Mn),En("Saving…","saving"),Mn=window.setTimeout(()=>{const n=z.state.doc.toString(),e=lt,t=me,i=Et,r=vi;nn(It,Ue.documentSave,{content:n,version:e},t,(s={})=>{ra||t!==me||i!==Et||r!==vi||e!==lt||En(s.result==="ok"||s.result==="unavailable"?"Saved":"Save failed",s.result==="failed"?"error":"saved")},i)},700)}function eS(n){if((n.selectionSet||n.viewportChanged||n.docChanged)&&J1(),!n.docChanged||ul)return;lt+=1,Wd?.documentChanged();const e=[];n.changes.iterChanges((t,i,r,s,o)=>{e.push({from:t,to:i,insert:o.toString(),newFrom:r,newTo:s})}),nn(It,Ue.documentChanged,{changes:e,version:lt},me,void 0,Et),oa()}const Vd=[ng(),og(),xO(),v0(),q1({refreshResources:()=>new Promise((n,e)=>{const t=me,i=vi,r=Et,s=window.setTimeout(()=>e(new Error("Resource refresh timed out")),5e3);nn(It,Ue.documentResources,{},t,(o={})=>{window.clearTimeout(s),t!==me||i!==vi||o.result!=="ok"||o.documentID!==t||!Array.isArray(o.resources)?e(new Error("Document resources are unavailable")):n(o.resources)},r)})}),Gg(),hO(),OO(),_.allowMultipleSelections.of(!0),Ug(),c0(),uA(),xA({override:[v1],activateOnTyping:!0}),MO(),FO(),CO(),Qb(),f1(),i1(Ed,{delay:350}),Eu(k1),yb({jsx:!0}),ms.of([Py,...mA,...Qy,...Vb,...Z0,...jg,...nd]),sa.of(_.readOnly.of(!1)),ls.of(Ud(jd())),R.updateListener.of(eS),R.contentAttributes.of({autocapitalize:"off",autocomplete:"off",spellcheck:"false"})],z=new R({state:_.create({doc:"",extensions:Vd}),parent:_1});function _t(n,e=me,t=0,i=!1){window.clearTimeout(Mn),vi+=1;const r=z.state.selection.main;zd(window.localStorage,me,{anchor:r.anchor,head:r.head,scrollTop:z.scrollDOM.scrollTop}),ul=!0;const s=e!==me;me=e,lt=t;const o=I1(window.localStorage,me,(n??"").length),l=o?{anchor:o.anchor,head:o.head}:{anchor:0};if(s){const a=ls.get(z.state),c=z.state.readOnly;let h=_.create({doc:n??"",extensions:Vd,selection:l});h=h.update({effects:[ls.reconfigure(a),sa.reconfigure(_.readOnly.of(c))]}).state,z.setState(h)}else z.dispatch({changes:{from:0,to:z.state.doc.length,insert:n??""},selection:l,scrollIntoView:!0});o&&window.requestAnimationFrame(()=>{z.scrollDOM.scrollTop=o.scrollTop}),ul=!1,i&&nn(It,Ue.documentChanged,{content:z.state.doc.toString(),version:lt},me,void 0,Et),En("Saved","saved")}function ph(n){if(z.state.readOnly)return!1;const e=z.state.selection.main;return z.dispatch({changes:{from:e.from,to:e.to,insert:n},selection:{anchor:e.from+n.length},userEvent:"input"}),z.focus(),!0}async function as(){if(z.state.readOnly)return!1;const n=z.state.doc.toString(),e=vi,t=lt,i=()=>!z.state.readOnly&&e===vi&&t===lt&&n===z.state.doc.toString();try{const[{format:r},{default:s},{default:o}]=await Promise.all([Cs(()=>import("./standalone-Cayz_KD-.js"),[],import.meta.url),Cs(()=>import("./babel-BktJt1uC.js"),[],import.meta.url),Cs(()=>import("./estree-DFfjoHvx.js"),[],import.meta.url)]),l=await r(n,{parser:"babel",plugins:[s,o],semi:!0,singleQuote:!0,trailingComma:"es5"});return i()?(_t(l,me,lt+1,!0),oa(),!0):!1}catch(r){return i()&&nn(It,"diagnostics.publish",{message:String(r),severity:"error"},me,void 0,Et),!1}}function Li(n){z.dispatch({effects:sa.reconfigure(_.readOnly.of(!!n))})}function cs(n){const e=n==="dark"||n==="light"?n:jd();document.documentElement.dataset.theme=e,z.dispatch({effects:ls.reconfigure(Ud(e))})}function tS(n=[]){const e=n.map(t=>({from:Math.max(0,Math.min(t.from??0,z.state.doc.length)),to:Math.max(0,Math.min(t.to??t.from??0,z.state.doc.length)),severity:t.severity??"error",message:t.message??"Unknown error"}));z.dispatch(wd(z.state,e))}function st(n,e){It.registerHandler(n,async(t={},i=()=>{})=>{try{if(Et!==null&&n!==Ue.documentOpen&&n!==Ue.editorSetTheme&&(t.documentID!==me||t.sessionID!==Et))throw new Error("The editor session changed.");i({result:"ok",...await e(t)})}catch(r){i({result:"failed",message:String(r)})}})}p1(n=>{It=n,st(Ue.documentOpen,({payload:e={},documentID:t,sessionID:i=null})=>(Et=i,_t(e.content,t,e.version??0),ia(z,e.resources??[]),Li(e.readOnly),e.dirty&&(En("Restored unsaved edits","editing"),e.readOnly||oa()),{protocolVersion:Zd})),st(Ue.documentReplace,({payload:e={},documentID:t})=>{if(z.state.readOnly||e.expectedContent!==void 0&&e.expectedContent!==z.state.doc.toString())throw new Error("The file changed or is read only.");return _t(e.content,t,e.version??lt,!0),{}}),st(Ue.documentSetReadOnly,({payload:e={}})=>(Li(e.readOnly),{readOnly:!!e.readOnly})),st(Ue.editorInsert,({payload:e={}})=>({inserted:ph(e.content??"")})),st(Ue.editorFormat,async()=>({formatted:await as()})),st(Ue.editorSetTheme,({payload:e={}})=>(cs(e.theme),{})),st(Ue.editorGetState,()=>({content:z.state.doc.toString(),version:lt,documentID:me,sessionID:Et,selection:{from:z.state.selection.main.from,to:z.state.selection.main.to}})),st(Ue.diagnosticsPublish,({payload:e={}})=>(tS(e.items),{})),st("editor_setValue",({value:e})=>(_t(e),{})),st("editor_insertValue",({value:e})=>({inserted:ph(e??"")})),st("editor_getValue",()=>({value:z.state.doc.toString()})),st("editor_setReadonly",({readonly:e})=>(Li(e),{readonly:!!e})),st("editor_formatCode",async()=>({formatted:await as()})),m1(It)});ra&&(document.querySelector("#native-editor").hidden=!0,document.querySelector("#web-studio").hidden=!1,iS());async function iS(){const n=document.querySelector("#pair-dialog"),e=document.querySelector("#pair-form"),t=document.querySelector("#pair-error"),i=document.querySelector("#package-select"),r=document.querySelector("#file-select"),s=document.querySelector("#connection-status"),o=document.querySelector("#disconnect-button"),l=document.querySelector("#studio-grid"),a=document.querySelector(".editor-column"),c=document.querySelector("#recovery-banner"),h=document.querySelector("#conflict-banner"),u=document.querySelector("#command-dialog"),f=document.querySelector("#command-search"),d=document.querySelector("#command-list"),p=document.querySelector("#compare-dialog");let m=window.sessionStorage.getItem("scriptwidget.web-studio.token")||"",O=[],y=null,b=null,x=null,C=0,k=null,S="",v="",U=null,F=V1(),j="",E="",M=null;function Y(w="Session ended. Enter the new code shown on your device."){m="",window.sessionStorage.removeItem("scriptwidget.web-studio.token"),o.hidden=!0,Q({type:"DISCONNECTED"}),s.textContent=w,Li(!0),n.open||n.showModal()}function Q(w){F=Y1(F,w);const Z={connecting:"Connecting",connected:"Connected",offline:"Offline",disconnected:"Disconnected"},X={idle:"Ready",draft:"Draft saved locally",saving:"Saving…",saved:"Saved",error:"Save failed",conflict:"Conflict"};s.dataset.state=F.connection,document.querySelector("#status-connection").textContent=Z[F.connection]||F.connection,En(X[F.save]||F.save,F.save),document.querySelector("#dirty-indicator").hidden=!["draft","saving","error","conflict"].includes(F.save),document.querySelector("#status-preview").textContent=F.preview==="requested"?"Preview requested":"Preview idle",document.querySelector("#preview-detail").textContent=F.preview==="requested"?"Requested on device":"Not requested"}const D=new H1({token:()=>m,onUnauthorized:()=>Y()}),P=(w,Z)=>D.request(w,Z);M=new N1(({packageID:w,path:Z,content:X,baseRevision:ne})=>P("/api/v1/document",{method:"PUT",body:JSON.stringify({package:w,path:Z,content:X,baseRevision:ne})}));async function V(w){m=(await P("/api/v1/pair",{method:"POST",body:JSON.stringify({code:w})})).token,window.sessionStorage.setItem("scriptwidget.web-studio.token",m),o.hidden=!1,Q({type:"CONNECTED"}),le()}function le(){window.clearInterval(y),y=window.setInterval(async()=>{if(m)try{const w=await P("/api/v1/session");if(!navigator.onLine)return;I(w),Q({type:"CONNECTED"})}catch(w){w.status!==401&&(s.textContent=`Interrupted · ${w.message}`,Q({type:"OFFLINE"}))}},5e3)}async function J(){if(O=(await P("/api/v1/packages")).packages||[],i.replaceChildren(...O.map(Z=>new Option(Z.name,Z.id))),!O.length){s.textContent="No editable widgets",Li(!0);return}await ee()}async function ee(){const w=O.find(ne=>ne.id===i.value),Z=w?.files||[];r.replaceChildren(...Z.map(ne=>new Option(ne,ne)));const X=Z.includes(w?.entry)?w.entry:Z[0];X&&(r.value=X),await G()}async function q(w=""){O=(await P("/api/v1/packages")).packages||[],i.replaceChildren(...O.map(Oe=>new Option(Oe.name,Oe.id))),j&&(i.value=j);const X=O.find(Oe=>Oe.id===i.value),ne=X?.files||[];r.replaceChildren(...ne.map(Oe=>new Option(Oe,Oe))),r.value=ne.includes(w)?w:ne.includes(E)?E:X?.entry||ne[0]}async function G(){if(!i.value||!r.value)return;const w=new URLSearchParams({package:i.value,path:r.value}),Z=await P(`/api/v1/document?${w}`),X=`${i.value}/${r.value}`;j=i.value,E=r.value,S=Z.revision,v=Z.content,U=null,h.hidden=!0,_t(Z.content,X,0),ia(z,O.find(Oe=>Oe.id===j)?.files??[]),M.open({documentID:X,packageID:j,path:E,revision:Z.revision,content:Z.content}),Li(!!Z.readOnly),ce(Z);const ne=j1(window.localStorage,X,Z.content,Z.revision);c.hidden=!ne,c._draft=ne,document.querySelector("#recovery-message").textContent=ne?.isStale?"The device version also changed. Review before saving.":"Restore it or keep the device version.",s.textContent="Connected",Q({type:"CONNECTED"}),o.hidden=!1,ge(),le(),Me()}function ce(w){document.querySelector("#breadcrumb-package").textContent=w.packageName||i.value,document.querySelector("#breadcrumb-file").textContent=r.value,document.querySelector("#editor-tab-name").textContent=r.value,document.querySelector("#revision-detail").textContent=S?S.slice(0,8):"—",document.querySelector("#access-detail").textContent=w.readOnly?"Read only":"Editable"}function I(w){w.device&&(document.querySelector("#device-name").textContent=w.device.name||w.device.model,document.querySelector("#device-system").textContent=`${w.device.model} · ${w.device.system}`),w.preview?.package&&(document.querySelector("#preview-target").textContent=w.preview.package),w.preview?.snapshotSequence&&te()}async function te(){try{const w=await D.requestBlob("/api/v1/preview"),Z=URL.createObjectURL(w),X=document.querySelector("#device-preview"),ne=k;k=Z,X.onload=()=>{ne&&URL.revokeObjectURL(ne)},X.src=Z,X.hidden=!1,document.querySelector("#preview-detail").textContent="Rendered on device"}catch{}}function se(w){const Z=document.querySelector("#console-list"),X=document.createElement("li");for(X.className=w.level||"info",X.textContent=w.message||"",Z.append(X);Z.children.length>200;)Z.firstChild.remove();Z.scrollTop=Z.scrollHeight}function Me(){window.clearTimeout(x);const w=async()=>{if(m)try{const Z=await P(`/api/v1/events?after=${C}`);C=Z.nextSequence??C;for(const X of Z.events||[])X.type==="console"&&se(X.payload||{}),X.type==="preview.snapshot"&&te(),X.type==="preview.requested"&&(document.querySelector("#status-preview").textContent="Preview requested",document.querySelector("#preview-detail").textContent="Requested on device"),X.type==="files.changed"&&X.payload?.package===j&&q(E).catch(qe);Q({type:"CONNECTED"})}catch(Z){Z.status!==401&&Q({type:"OFFLINE"})}finally{m&&(x=window.setTimeout(w,1e3))}};w()}function ge(){const w=Ed(z);document.querySelector("#problems-list").replaceChildren(...w.map(X=>{const ne=z.state.doc.lineAt(X.from),Oe=document.createElement("li");Oe.className=`problem-item ${X.severity}`;const it=document.createElement("button");return it.type="button",it.innerHTML=`${X.severity==="error"?"●":"▲"}Ln ${ne.number}`,it.children[1].textContent=X.message,it.addEventListener("click",()=>{z.dispatch({selection:{anchor:X.from},scrollIntoView:!0}),z.focus()}),Oe.append(it),Oe})),document.querySelector("#problems-count").textContent=String(w.length),document.querySelector("#status-problem-count").textContent=String(w.length),document.querySelector("#problems-summary").textContent=w.length?`${w.filter(X=>X.severity==="error").length} errors, ${w.filter(X=>X.severity!=="error").length} warnings`:"No problems detected"}async function ie(w,Z,X=null){M.snapshot()?.content!==w&&M.edit(w),X&&M.rebase(X),Q({type:"SAVING"});try{const ne=await M.flush();if(ne.ignored){Z({result:"ok",ignored:!0});return}if(ne.skipped){Q({type:"SAVED"}),Z({result:"ok",skipped:!0});return}const Oe=ne.result||{},it=M.snapshot();S=it?.revision||S,v=it?.content||w,fo(window.localStorage,me),U=null,h.hidden=!0,document.querySelector("#revision-detail").textContent=S?.slice(0,8)||"—",Q({type:"SAVED",preview:Oe.preview?.state}),Z({result:"ok",...Oe})}catch(ne){ne.status===409?(U=ne.body,h.hidden=!1,Q({type:"CONFLICT",conflict:U})):Q({type:"SAVE_FAILED"}),Z({result:"failed",message:ne.message})}}It={registerHandler(){},callHandler(w,Z,X=()=>{}){if(w===Ue.documentSave)ie(Z.payload.content,X);else if(w===Ue.documentResources){const ne=me,Oe=j;P("/api/v1/packages").then(it=>{if(ne!==me||Z.documentID!==me||Oe!==j){X({result:"failed"});return}X({result:"ok",documentID:ne,resources:(it.packages??[]).find(Wn=>Wn.id===Oe)?.files??[]})}).catch(()=>X({result:"failed"}))}else X({result:"ok"})}},Wd={documentChanged(){const w=z.state.doc.toString();M.edit(w),hh(window.localStorage,me,w,M.snapshot()?.revision||S),Q({type:"EDITED"}),window.clearTimeout(b),b=window.setTimeout(ge,380)}};async function we(w,Z){if(!uh(F.save)){await w();return}try{if(window.clearTimeout(Mn),await ie(z.state.doc.toString(),()=>{}),!M.isDirty&&F.save!=="conflict"){await w();return}}catch{}window.confirm("This document has changes that are not saved on the device. A browser draft is available. Switch anyway?")?await w():Z()}i.addEventListener("change",()=>{const w=i.value;i.value=j,we(async()=>{i.value=w,await ee()},()=>{i.value=j}).catch(qe)}),r.addEventListener("change",()=>{const w=r.value;r.value=E,we(async()=>{r.value=w,await G()},()=>{r.value=E}).catch(qe)});function qe(w){s.textContent=w.message||String(w),Q({type:"SAVE_FAILED"})}e.addEventListener("submit",async w=>{w.preventDefault(),t.textContent="";try{await V(document.querySelector("#pair-code").value),n.close(),await J()}catch(Z){t.textContent=Z.message}}),o.addEventListener("click",async()=>{try{await P("/api/v1/session",{method:"DELETE"})}catch{}Y("Disconnected. Start a new session with the code on your device.")}),document.querySelector("#new-file").addEventListener("click",async()=>{const w=window.prompt("New package-relative text file","source/helper.js")?.trim();if(w)try{await P("/api/v1/document",{method:"POST",body:JSON.stringify({package:j,path:w})}),await q(w),await G()}catch(Z){qe(Z)}}),document.querySelector("#delete-file").addEventListener("click",async()=>{const w=O.find(Z=>Z.id===j);if(!E||E===w?.entry){window.alert("The widget entry file cannot be deleted.");return}if(window.confirm(`Delete ${E}? This cannot be undone.`))try{const Z=new URLSearchParams({package:j,path:E});await P(`/api/v1/document?${Z}`,{method:"DELETE"}),E="",await q(),await G()}catch(Z){qe(Z)}}),document.querySelector("#clear-console").addEventListener("click",()=>document.querySelector("#console-list").replaceChildren()),document.querySelector("#restore-draft").addEventListener("click",()=>{const w=c._draft;w&&(_t(w.content,w.documentID,lt+1),c.hidden=!0,hh(window.localStorage,me,w.content,S),Q({type:"EDITED"}),ge())}),document.querySelector("#discard-draft").addEventListener("click",()=>{fo(window.localStorage,me),c.hidden=!0}),document.querySelector("#reload-server").addEventListener("click",()=>{U&&(fo(window.localStorage,me),S=U.currentRevision,v=U.currentContent,_t(v,me,lt+1),M.open({documentID:me,packageID:j,path:E,revision:S,content:v}),U=null,h.hidden=!0,Q({type:"SAVED"}),ge())}),document.querySelector("#keep-local").addEventListener("click",()=>{U&&ie(z.state.doc.toString(),()=>{},U.currentRevision)}),document.querySelector("#compare-conflict").addEventListener("click",()=>{document.querySelector("#compare-local").textContent=z.state.doc.toString(),document.querySelector("#compare-server").textContent=U?.currentContent||v,p.showModal()}),p.querySelector("button").addEventListener("click",()=>p.close());function oe(){const w=a.classList.toggle("problems-collapsed");document.querySelector("#problems-toggle").setAttribute("aria-expanded",String(!w))}function Ae(w){l.classList.toggle(`show-${w}`)}document.querySelector("#problems-toggle").addEventListener("click",oe),document.querySelector("#status-problems").addEventListener("click",()=>{a.classList.remove("problems-collapsed")}),document.querySelector("#explorer-button").addEventListener("click",()=>Ae("explorer")),document.querySelector("#inspector-button").addEventListener("click",()=>Ae("inspector")),document.querySelectorAll("[data-close-panel]").forEach(w=>w.addEventListener("click",()=>l.classList.remove(`show-${w.dataset.closePanel}`)));const ae=[{name:"Save Document",keys:"⌘S",run:()=>{window.clearTimeout(Mn),ie(z.state.doc.toString(),()=>{})}},{name:"Format Document",keys:"⇧⌥F",run:as},{name:"Toggle Problems",keys:"⌘J",run:oe},{name:"Toggle Explorer",keys:"⌘⇧E",run:()=>Ae("explorer")},{name:"Toggle Inspector",keys:"",run:()=>Ae("inspector")},{name:"Use Light Theme",keys:"",run:()=>cs("light")},{name:"Use Dark Theme",keys:"",run:()=>cs("dark")}];function Ie(w=""){const Z=ae.filter(X=>X.name.toLowerCase().includes(w.toLowerCase()));d.replaceChildren(...Z.map(X=>{const ne=document.createElement("li"),Oe=document.createElement("button");Oe.type="button",Oe.className="command";const it=document.createElement("span");it.textContent=X.name;const Wn=document.createElement("kbd");return Wn.textContent=X.keys,Oe.append(it,Wn),Oe.addEventListener("click",()=>{u.close(),X.run()}),ne.append(Oe),ne}))}function tt(){Ie(),u.showModal(),f.value="",f.focus()}document.querySelector("#command-button").addEventListener("click",tt),f.addEventListener("input",()=>Ie(f.value)),document.addEventListener("keydown",w=>{const Z=w.metaKey||w.ctrlKey;Z&&w.shiftKey&&w.key.toLowerCase()==="p"?(w.preventDefault(),tt()):Z&&w.key.toLowerCase()==="s"?(w.preventDefault(),ae[0].run()):Z&&w.key.toLowerCase()==="j"?(w.preventDefault(),oe()):Z&&w.shiftKey&&w.key.toLowerCase()==="e"?(w.preventDefault(),Ae("explorer")):w.shiftKey&&w.altKey&&w.key.toLowerCase()==="f"&&(w.preventDefault(),as())}),z.dom.addEventListener("keyup",li),z.dom.addEventListener("mouseup",li);function li(){const w=z.state.selection.main.head,Z=z.state.doc.lineAt(w);document.querySelector("#cursor-position").textContent=`Ln ${Z.number}, Col ${w-Z.from+1}`}window.addEventListener("offline",()=>{s.textContent="Computer is offline",Q({type:"OFFLINE"})}),window.addEventListener("online",()=>{m&&P("/api/v1/session").then(w=>(I(w),Q({type:"CONNECTED"}),J())).catch(qe)}),window.addEventListener("beforeunload",w=>{uh(F.save)&&(w.preventDefault(),w.returnValue="")});try{await J()}catch{Y("Pair with the code shown on your device.")}}window.matchMedia?.("(prefers-color-scheme: dark)").addEventListener("change",()=>cs("system"));window.webkit||_t(`// ScriptWidget Studio -const widget = ( - - - -); -`); diff --git a/macOS/ScriptWidgetMac/StudioEditor.bundle/assets/index-ijvFWH5h.js b/macOS/ScriptWidgetMac/StudioEditor.bundle/assets/index-ijvFWH5h.js new file mode 100644 index 00000000..339e39fc --- /dev/null +++ b/macOS/ScriptWidgetMac/StudioEditor.bundle/assets/index-ijvFWH5h.js @@ -0,0 +1,59 @@ +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();const Yd="modulepreload",Nd=function(n,e){return new URL(n,e).href},al={},Cr=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){let c=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const o=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");s=c(t.map(h=>{if(h=Nd(h,i),h in al)return;al[h]=!0;const u=h.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(i)for(let p=o.length-1;p>=0;p--){const m=o[p];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${f}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Yd,u||(d.as="script"),d.crossOrigin="",d.href=h,l&&d.setAttribute("nonce",l),document.head.appendChild(d),u)return new Promise((p,m)=>{d.addEventListener("load",p),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})};let po=[],mh=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=mh[i])e=i+1;else return!0;if(e==t)return!1}}function ll(n){return n>=127462&&n<=127487}const cl=8205;function Gd(n,e,t=!0,i=!0){return(t?gh:_d)(n,e,i)}function gh(n,e,t){if(e==n.length)return e;e&&Oh(n.charCodeAt(e))&&yh(n.charCodeAt(e-1))&&e--;let i=Tr(n,e);for(e+=hl(i);e=0&&ll(Tr(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function _d(n,e,t){for(;e>1;){let i=gh(n,e-2,t);if(i=56320&&n<57344}function yh(n){return n>=55296&&n<56320}function hl(n){return n<65536?1:2}class se{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Bi(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),kt.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Bi(this,e,t);let i=[];return this.decompose(e,t,i,0),kt.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new pn(this),r=new pn(e);for(let o=t,a=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(a+=s.value.length,s.done||a>=i)return!0}}iter(e=1){return new pn(this,e)}iterRange(e,t=this.length){return new Ah(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new bh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?se.empty:e.length<=32?new we(e):kt.from(we.split(e,[]))}}class we extends se{constructor(e,t=Jd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],a=s+o.length;if((t?i:a)>=e)return new ep(s,a,i,o);s=a+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new we(ul(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),a=gs(r.text,o.text.slice(),0,r.length);if(a.length<=32)i.push(new we(a,o.length+r.length));else{let l=a.length>>1;i.push(new we(a.slice(0,l)),new we(a.slice(l)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof we))return super.replace(e,t,i);[e,t]=Bi(this,e,t);let s=gs(this.text,gs(i.text,ul(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new we(s,r):kt.from(we.split(s,[]),r)}sliceString(e,t=this.length,i=` +`){[e,t]=Bi(this,e,t);let s="";for(let r=0,o=0;r<=t&&oe&&o&&(s+=i),er&&(s+=a.slice(Math.max(0,e-r),t-r)),r=l+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new we(i,s)),i=[],s=-1);return s>-1&&t.push(new we(i,s)),t}}class kt extends se{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],a=s+o.length,l=i+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,i,s);s=a+1,i=l+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r=o){let c=s&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?i.push(a):a.decompose(e-o,t-o,i,c)}o=l+1}}replace(e,t,i){if([e,t]=Bi(this,e,t),i.lines=r&&t<=a){let l=o.replace(e-r,t-r,i),c=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>c>>6){let h=this.children.slice();return h[s]=l,new kt(h,this.length-(t-e)+i.length)}return super.replace(r,a,l)}r=a+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` +`){[e,t]=Bi(this,e,t);let s="";for(let r=0,o=0;re&&r&&(s+=i),eo&&(s+=a.sliceString(e-o,t-o,i)),o=l+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof kt))return 0;let i=0,[s,r,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==a)return i;let l=this.children[s],c=e.children[r];if(l!=c)return i+l.scanIdentical(c,t);i+=l.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new we(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,a=[],l=0,c=-1,h=[];function u(d){let p;if(d.lines>r&&d instanceof kt)for(let m of d.children)u(m);else d.lines>o&&(l>o||!l)?(f(),a.push(d)):d instanceof we&&l&&(p=h[h.length-1])instanceof we&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,h[h.length-1]=new we(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>s&&f(),l+=d.lines,c+=d.length+1,h.push(d))}function f(){l!=0&&(a.push(h.length==1?h[0]:kt.from(h,c)),c=-1,l=h.length=0)}for(let d of e)u(d);return f(),a.length==1?a[0]:new kt(a,t)}}se.empty=new we([""],0);function Jd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function gs(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r=t&&(l>i&&(a=a.slice(0,i-s)),s0?1:(e instanceof we?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,a=s instanceof we?s.text.length:s.children.length;if(o==(t>0?a:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof we){let l=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=s.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof we?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Ah{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new pn(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class bh{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(se.prototype[Symbol.iterator]=function(){return this.iter()},pn.prototype[Symbol.iterator]=Ah.prototype[Symbol.iterator]=bh.prototype[Symbol.iterator]=function(){return this});class ep{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function Bi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Ze(n,e,t=!0,i=!0){return Gd(n,e,t,i)}function tp(n){return n>=56320&&n<57344}function ip(n){return n>=55296&&n<56320}function Ne(n,e){let t=n.charCodeAt(e);if(!ip(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return tp(i)?(t-55296<<10)+(i-56320)+65536:t}function fa(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Qt(n){return n<65536?1:2}const mo=/\r\n?|\n/;var De=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(De||(De={}));class Zt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-s);r+=a}else{if(i!=De.Simple&&c>=e&&(i==De.TrackDel&&se||i==De.TrackBefore&&se))return null;if(c>e||c==e&&t<0&&!a)return e==s||t<0?r:r+l;r+=l}s=c}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i=0&&s<=t&&a>=e)return st?"cover":!0;s=a}return!1}toString(){let e="";for(let t=0;t=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Zt(e)}static create(e){return new Zt(e)}}class Re extends Zt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return go(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return Oo(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s=0){t[s]=a,t[s+1]=o;let l=s>>1;for(;i.length0&&Ht(i,t,r.text),r.forward(h),a+=h}let c=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,a=null;function l(h=!1){if(!h&&!s.length)return;of||u<0||f>t)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?se.of(d.split(i||mo)):d:se.empty,m=p.length;if(u==f&&m==0)return;uo&&Xe(s,u-o,-1),Xe(s,f-u,m),Ht(r,s,p),o=f}}return c(e),l(!a),a}static empty(e){return new Re(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;sa&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length=0&&t<=0&&t==n[s+1]?n[s]+=e:s>=0&&e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function Ht(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)a=n.sections[o++],l=n.sections[o++];e(s,c,r,h,u),s=c,r=h}}}function Oo(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Sn(n),a=new Sn(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);Xe(s,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let c=0,h=o.len;for(;h;)if(a.ins==-1){let u=Math.min(h,a.len);c+=u,h-=u,a.forward(u)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||i.length>c),r.forward2(l),o.forward(l)}}}}class Sn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?se.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?se.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Yt{constructor(e,t,i,s){this.from=e,this.to=t,this.flags=i,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Yt(i,s,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return A.range(e,t,void 0,void 0,i);let s=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return A.range(this.anchor,s,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return A.range(e.anchor,e.head)}static create(e,t,i,s){return new Yt(e,t,i,s)}}class A{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:A.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new A(e.ranges.map(t=>Yt.fromJSON(t)),e.main)}static single(e,t=e){return new A([A.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;ss.from-r.from),t=e.indexOf(i);for(let s=1;sr.head?A.range(l,a):A.range(a,l))}}return new A(e,t)}}function xh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let da=0;class K{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=da++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new K(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:pa),!!e.static,e.enables)}of(e){return new Os([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Os(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Os(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function pa(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Os{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=da++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,a=this.type==2,l=!1,c=!1,h=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?c=!0:(((t=e[u.id])!==null&&t!==void 0?t:1)&1)==0&&h.push(e[u.id]);return{create(u){return u.values[o]=i(u),1},update(u,f){if(l&&f.docChanged||c&&(f.docChanged||f.selection)||yo(u,h)){let d=i(u);if(a?!fl(d,u.values[o],s):!s(d,u.values[o]))return u.values[o]=d,1}return 0},reconfigure:(u,f)=>{let d,p=f.config.address[r];if(p!=null){let m=Cs(f,p);if(this.dependencies.every(g=>g instanceof K?f.facet(g)===u.facet(g):g instanceof Te?f.field(g,!1)==u.field(g,!1):!0)||(a?fl(d=i(u),m,s):s(d=i(u),m)))return u.values[o]=m,0}else d=i(u);return u.values[o]=d,1}}}get extension(){return this}}function fl(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[l.id]),s=t.map(l=>l.type),r=i.filter(l=>!(l&1)),o=n[e.id]>>1;function a(l){let c=[];for(let h=0;hi===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Vn).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>{let r=i.facet(Vn),o=s.facet(Vn),a;return(a=r.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(i.values[t]=a.create(i),1):s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Vn.of({field:this,create:e})]}get extension(){return this}}const fi={lowest:4,low:3,default:2,high:1,highest:0};function sn(n){return e=>new vh(e,n)}const ri={highest:sn(fi.highest),high:sn(fi.high),default:sn(fi.default),low:sn(fi.low),lowest:sn(fi.lowest)};class vh{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Gi{of(e){return new Ao(this,e)}reconfigure(e){return Gi.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ao{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class Ps{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let f of sp(e,t,o))f instanceof Te?s.push(f):(r[f.facet.id]||(r[f.facet.id]=[])).push(f);let a=Object.create(null),l=[],c=[];for(let f of s)a[f.id]=c.length<<1,c.push(d=>f.slot(d));let h=i?.config.facets;for(let f in r){let d=r[f],p=d[0].facet,m=h&&h[f]||[];if(d.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,pa(m,d))l.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));l.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=c.length<<1,c.push(y=>g.dynamicSlot(y)));a[p.id]=c.length<<1,c.push(g=>np(g,p,d))}}let u=c.map(f=>f(a));return new Ps(e,o,u,a,l,r)}}function sp(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,a){let l=s.get(o);if(l!=null){if(l<=a)return;let c=i[l].indexOf(o);c>-1&&i[l].splice(c,1),o instanceof Ao&&t.delete(o.compartment)}if(s.set(o,a),Array.isArray(o))for(let c of o)r(c,a);else if(o instanceof Ao){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),r(c,a)}else if(o instanceof vh)r(o.inner,o.prec);else if(o instanceof Te)i[a].push(o),o.provides&&r(o.provides,a);else if(o instanceof Os)i[a].push(o),o.facet.extensions&&r(o.facet.extensions,fi.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(c==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(c,a)}}return r(n,fi.default),i.reduce((o,a)=>o.concat(a))}function mn(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function Cs(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const wh=K.define(),bo=K.define({combine:n=>n.some(e=>e),static:!0}),kh=K.define({combine:n=>n.length?n[0]:void 0,static:!0}),Qh=K.define(),Ph=K.define(),Ch=K.define(),Th=K.define({combine:n=>n.length?n[0]:!1});class Wt{constructor(e,t){this.type=e,this.value=t}static define(){return new rp}}class rp{of(e){return new Wt(this,e)}}class op{constructor(e){this.map=e}of(e){return new z(this,e)}}class z{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new z(this.type,t)}is(e){return this.type==e}static define(e={}){return new op(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}z.reconfigure=z.define();z.appendConfig=z.define();class Pe{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&xh(i,t.newLength),r.some(a=>a.type==Pe.time)||(this.annotations=r.concat(Pe.time.of(Date.now())))}static create(e,t,i,s,r,o){return new Pe(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Pe.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Pe.time=Wt.define();Pe.userEvent=Wt.define();Pe.addToHistory=Wt.define();Pe.remote=Wt.define();function ap(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i=n[i]))r=n[i++],o=n[i++];else if(s=0;s--){let r=i[s](n);r instanceof Pe?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Pe?n=r[0]:n=$h(e,Zi(r),!1)}return n}function cp(n){let e=n.startState,t=e.facet(Ch),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=Rh(i,So(e,r,n.changes.newLength),!0))}return i==n?n:Pe.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const hp=[];function Zi(n){return n==null?hp:Array.isArray(n)?n:[n]}var ye=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(ye||(ye={}));const up=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let xo;try{xo=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function fp(n){if(xo)return xo.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||up.test(t)))return!0}return!1}function dp(n){return e=>{if(!/\S/.test(e))return ye.Space;if(fp(e))return ye.Word;for(let t=0;t-1)return ye.Word;return ye.Other}}class _{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let a=0;as.set(c,l)),t=null),s.set(a.value.compartment,a.value.extension)):a.is(z.reconfigure)?(t=null,i=a.value):a.is(z.appendConfig)&&(t=null,i=Zi(i).concat(a.value));let r;t?r=e.startState.values.slice():(t=Ps.resolve(i,s,this),r=new _(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(bo)?e.newSelection:e.newSelection.asSingle();new _(t,e.newDoc,o,r,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:A.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=Zi(i.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return _.create({doc:e.doc,selection:A.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Ps.resolve(e.extensions||[],new Map),i=e.doc instanceof se?e.doc:se.of((e.doc||"").split(t.staticFacet(_.lineSeparator)||mo)),s=e.selection?e.selection instanceof A?e.selection:A.single(e.selection.anchor,e.selection.head):A.single(0);return xh(s,i.length),t.staticFacet(bo)||(s=s.asSingle()),new _(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(_.tabSize)}get lineBreak(){return this.facet(_.lineSeparator)||` +`}get readOnly(){return this.facet(Th)}phrase(e,...t){for(let i of this.facet(_.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(wh))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return dp(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,a=e-i;for(;o>0;){let l=Ze(t,o,!1);if(r(t.slice(l,o))!=ye.Word)break;o=l}for(;an.length?n[0]:4});_.lineSeparator=kh;_.readOnly=Th;_.phrases=K.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(s=>n[s]==e[s])}});_.languageData=wh;_.changeFilter=Qh;_.transactionFilter=Ph;_.transactionExtender=Ch;Gi.reconfigure=z.define();function yt(n,e,t={}){let i={};for(let s of n)for(let r of Object.keys(s)){let o=s[r],a=i[r];if(a===void 0)i[r]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](a,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)i[s]===void 0&&(i[s]=e[s]);return i}class Jt{eq(e){return this==e}range(e,t=e){return vo.create(e,t,this)}}Jt.prototype.startSide=Jt.prototype.endSide=0;Jt.prototype.point=!1;Jt.prototype.mapMode=De.TrackDel;function ma(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let vo=class Kh{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Kh(e,t,i)}};function wo(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class ga{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,s=0){let r=i?this.to:this.from;for(let o=s,a=r.length;;){if(o==a)return o;let l=o+a>>1,c=r[l]-e||(i?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return c>=0?o:a;c>=0?a=l:o=l+1}}between(e,t,i,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);rd||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(o<0&&(o=f),c.point&&(a=Math.max(a,d-f)),i.push(c),s.push(f-o),r.push(d-o))}return{mapped:i.length?new ga(s,r,i,a):null,pos:o}}}class N{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new N(e,t,i,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(wo)),this.isEmpty)return t.length?N.of(t):this;let a=new Zh(this,null,-1).goto(0),l=0,c=[],h=new Bt;for(;a.value||l=0){let u=t[l++];h.addInner(u.from,u.to,u.value)||c.push(u)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||ra.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return xn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return xn.from(e).goto(t)}static compare(e,t,i,s,r=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=r),a=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=r),l=dl(o,a,i),c=new rn(o,l,r),h=new rn(a,l,r);i.iterGaps((u,f,d)=>pl(c,u,h,f,d,s)),i.empty&&i.length==0&&pl(c,0,h,0,0,s)}static eq(e,t,i=0,s){s==null&&(s=999999999);let r=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let a=dl(r,o),l=new rn(r,a,0).goto(i),c=new rn(o,a,0).goto(i);for(;;){if(l.to!=c.to||!ko(l.active,c.active)||l.point&&(!c.point||!ma(l.point,c.point)))return!1;if(l.to>s)return!0;l.next(),c.next()}}static spans(e,t,i,s,r=-1){let o=new rn(e,null,r).goto(t),a=t,l=o.openStart;for(;;){let c=Math.min(o.to,i);if(o.point){let h=o.activeForPoint(o.to),u=o.pointFroma&&(s.span(a,c,o.active,l),l=o.openEnd(c));if(o.to>i)return l+(o.point&&o.to>i?1:0);a=o.to,o.next()}}static of(e,t=!1){let i=new Bt;for(let s of e instanceof vo?[e]:t?pp(e):e)i.add(s.from,s.to,s.value);return i.finish()}static join(e){if(!e.length)return N.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let s=e[i];s!=N.empty;s=s.nextLayer)t=new N(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}N.empty=new N([],[],null,-1);function pp(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(wo);e=i}return n}N.empty.nextLayer=N.empty;class Bt{finishChunk(e){this.chunks.push(new ga(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Bt)).add(e,t,i)}addInner(e,t,i){let s=e-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(N.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=N.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function dl(n,e,t){let i=new Map;for(let r of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&s.push(new Zh(o,t,i,r));return s.length==1?s[0]:new xn(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Rr(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Rr(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Rr(this.heap,0)}}}function Rr(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let s=n[i];if(i+1=0&&(s=n[i+1],i++),t.compare(s)<0)break;n[i]=t,n[e]=s,e=i}}class rn{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=xn.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){jn(this.active,e),jn(this.activeTo,e),jn(this.activeRank,e),this.minActive=ml(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:r}=this.cursor;for(;t0;)t++;Yn(this.active,t,i),Yn(this.activeTo,t,s),Yn(this.activeRank,t,r),e&&Yn(e,t,this.cursor.from),this.minActive=ml(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&jn(i,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[s]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function pl(n,e,t,i,s,r){n.goto(e),t.goto(i);let o=i+s,a=i,l=i-e,c=!!r.boundChange;for(let h=!1;;){let u=n.to+l-t.to,f=u||n.endSide-t.endSide,d=f<0?n.to+l:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&ma(n.point,t.point)&&ko(n.activeForPoint(n.to),t.activeForPoint(t.to))||r.comparePoint(a,p,n.point,t.point),h=!1):(h&&r.boundChange(a),p>a&&!ko(n.active,t.active)&&r.compareRange(a,p,n.active,t.active),c&&po)break;a=d,f<=0&&n.next(),f>=0&&t.next()}}function ko(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function ml(n,e){let t=-1,i=1e9;for(let s=0;s=e)return s;if(s==n.length)break;r+=n.charCodeAt(s)==9?t-r%t:1,s=Ze(n,s)}return i===!0?-1:n.length}const Po="ͼ",gl=typeof Symbol>"u"?"__"+Po:Symbol.for(Po),Co=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ol=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ei{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,a,l,c){let h=[],u=/^@(\w+)\b/.exec(o[0]),f=u&&u[1]=="keyframes";if(u&&a==null)return l.push(o[0]+";");for(let d in a){let p=a[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,l);else if(p&&typeof p=="object"){if(!u)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,h,f)}else p!=null&&h.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(h.length||f)&&l.push((i&&!u&&!c?o.map(i):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Ol[gl]||1;return Ol[gl]=e+1,Po+e.toString(36)}static mount(e,t,i){let s=e[Co],r=i&&i.nonce;s?r&&s.setNonce(r):s=new mp(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let yl=new Map;class mp{constructor(e,t){let i=e.ownerDocument||e,s=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=yl.get(i);if(r)return e[Co]=r;this.sheet=new s.CSSStyleSheet,yl.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Co]=this}mount(e,t){let i=this.sheet,s=0,r=0;for(let o=0;o-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,a),i)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},Al=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),gp=typeof navigator<"u"&&/Apple Computer/.test(navigator.vendor),Op=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),bl=typeof navigator<"u"&&/Mac/.test(navigator.platform),yp=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ap=Al&&(bl||+Al[1]<57)||Op&&bl;for(var Fe=0;Fe<10;Fe++)ti[48+Fe]=ti[96+Fe]=String(Fe);for(var Fe=1;Fe<=24;Fe++)ti[Fe+111]="F"+Fe;for(var Fe=65;Fe<=90;Fe++)ti[Fe]=String.fromCharCode(Fe+32),vn[Fe]=String.fromCharCode(Fe);for(var $r in ti)vn.hasOwnProperty($r)||(vn[$r]=ti[$r]);function bp(n){var e=Ap&&(n.ctrlKey||n.altKey||n.metaKey)||(gp||yp)&&n.shiftKey&&n.key&&n.key.length==1,t=!e&&n.key||(n.shiftKey?vn:ti)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function he(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;e2);var R={mac:vl||/Mac/.test(We.platform),windows:/Win/.test(We.platform),linux:/Linux|X11/.test(We.platform),ie:hr,ie_version:Eh?To.documentMode||6:$o?+$o[1]:Ro?+Ro[1]:0,gecko:Sl,gecko_version:Sl?+(/Firefox\/(\d+)/.exec(We.userAgent)||[0,0])[1]:0,chrome:!!Kr,chrome_version:Kr?+Kr[1]:0,ios:vl,android:/Android\b/.test(We.userAgent),webkit:xl,webkit_version:xl?+(/\bAppleWebKit\/(\d+)/.exec(We.userAgent)||[0,0])[1]:0,safari:Ko,safari_version:Ko?+(/\bVersion\/(\d+(\.\d+)?)/.exec(We.userAgent)||[0,0])[1]:0,tabSize:To.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Oa(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const Ts=Object.create(null);function ya(n,e,t){if(n==e)return!0;n||(n=Ts),e||(e=Ts);let i=Object.keys(n),s=Object.keys(e);if(i.length-0!=s.length-0)return!1;for(let r of i)if(r!=t&&(s.indexOf(r)==-1||n[r]!==e[r]))return!1;return!0}function Sp(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function wl(n,e,t){let i=!1;if(e)for(let s in e)t&&s in t||(i=!0,s=="style"?n.style.cssText="":n.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(i=!0,s=="style"?n.style.cssText=t[s]:n.setAttribute(s,t[s]));return i}function xp(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Ai(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=Uh(e,t);i=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Ai(e,i,s,t,e.widget||null,!0)}static line(e){return new Fn(e)}static set(e,t=!1){return N.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}B.none=N.empty;class Un extends B{constructor(e){let{start:t,end:i}=Uh(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Oa(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ts}eq(e){return this==e||e instanceof Un&&this.tagName==e.tagName&&ya(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Un.prototype.point=!1;class Fn extends B{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Fn&&this.spec.class==e.spec.class&&ya(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Fn.prototype.mapMode=De.TrackBefore;Fn.prototype.point=!0;class Ai extends B{constructor(e,t,i,s,r,o){super(t,i,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?De.TrackBefore:De.TrackAfter:De.TrackDel}get type(){return this.startSide!=this.endSide?Le.WidgetRange:this.startSide<=0?Le.WidgetBefore:Le.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ai&&vp(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Ai.prototype.point=!0;function Uh(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function vp(n,e){return n==e||!!(n&&e&&n.compare(e))}function Mi(n,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=n?t[s]=Math.max(t[s],e):t.push(n,e)}class wn extends Jt{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof wn&&this.tagName==e.tagName&&ya(this.attributes,e.attributes)}static create(e){return new wn(e.tagName,e.attributes||Ts,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return N.of(e,t)}}wn.prototype.startSide=wn.prototype.endSide=-1;function kn(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Zo(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function gn(n,e){if(!e.anchorNode)return!1;try{return Zo(n,e.anchorNode)}catch{return!1}}function ys(n){return n.nodeType==3?Qn(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function On(n,e,t,i){return t?kl(n,e,t,i,-1)||kl(n,e,t,i,1):!1}function ii(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Rs(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function kl(n,e,t,i,s){for(;;){if(n==t&&e==i)return!0;if(e==(s<0?0:It(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=ii(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=s<0?It(n):0}else return!1}}function It(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function $s(n,e){let{left:t,right:i}=n;if(t==i)return n;let s=e?t:i;return{left:s,right:s,top:n.top,bottom:n.bottom}}function wp(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Fh(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function kp(n,e,t,i,s,r,o,a){let l=n.ownerDocument,c=l.defaultView||window;for(let h=n,u=!1;h&&!u;)if(h.nodeType==1){let f,d=h==l.body,p=1,m=1;if(d)f=wp(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let b=h.getBoundingClientRect();({scaleX:p,scaleY:m}=Fh(h,b)),f={left:b.left,right:b.left+h.clientWidth*p,top:b.top,bottom:b.top+h.clientHeight*m}}let g=0,y=0;if(s=="nearest")e.top0&&e.bottom>f.bottom+y&&(y=e.bottom-f.bottom+o)):e.bottom>f.bottom-o&&(y=e.bottom-f.bottom+o,t<0&&e.top-y0&&e.right>f.right+g&&(g=e.right-f.right+r)):e.right>f.right-r&&(g=e.right-f.right+r,t<0&&e.leftf.bottom||e.leftf.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function Dh(n,e=!0){let t=n.ownerDocument,i=null,s=null;for(let r=n.parentNode;r&&!(r==t.body||(!e||i)&&s);)if(r.nodeType==1)!s&&r.scrollHeight>r.clientHeight&&(s=r),e&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:s}}class Qp{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?It(t):0),i,Math.min(e.focusOffset,i?It(i):0))}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}}function Lh(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function Xh(n,e=!0){for(let{node:t,left:i,top:s}of n)e&&t.scrollTop!=s&&(t.scrollTop=s),t.scrollLeft!=i&&(t.scrollLeft=i)}let ui=null;R.safari&&R.safari_version>=26&&(ui=!1);function Bh(n){if(n.setActive)return n.setActive();if(ui)return n.focus(ui);let e=Lh(n);n.focus(ui==null?{get preventScroll(){return ui={preventScroll:!0},!0}}:void 0),ui||(ui=!1,Xh(e))}let Ql;function Qn(n,e,t=e){let i=Ql||(Ql=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Ei(n,e,t,i){let s={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=i);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,n.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,n.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function Pp(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Cp(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,It(t));;)if(i){if(t.nodeType!=1)return!1;let s=t.childNodes[i-1];s.contentEditable=="false"?i--:(t=s,i=It(t))}else{if(t==n)return!0;i=ii(t),t=t.parentNode}}function Ih(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function qh(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=It(t)}else if(t.parentNode&&!Rs(t))i=ii(t),t=t.parentNode;else return null}}function Wh(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i=t){if(a.level==i)return o;(r<0||(s!=0?s<0?a.fromt:e[r].level>a.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function jh(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(St[m+1]==-d){let g=St[m+2],y=g&2?s:g&4?g&1?r:s:0;y&&(ue[u]=ue[St[m]]=y),a=m;break}}else{if(St.length==189)break;St[a++]=u,St[a++]=f,St[a++]=l}else if((p=ue[u])==2||p==1){let m=p==s;l=m?0:1;for(let g=a-3;g>=0;g-=3){let y=St[g+2];if(y&2)break;if(m)St[g+2]|=2;else{if(y&4)break;St[g+2]|=4}}}}}function Mp(n,e,t,i){for(let s=0,r=i;s<=t.length;s++){let o=s?t[s-1].to:n,a=sl;)p==g&&(p=t[--m].from,g=m?t[m-1].to:n),ue[--p]=d;l=h}else r=c,l++}}}function Eo(n,e,t,i,s,r,o){let a=i%2?2:1;if(i%2==s%2)for(let l=e,c=0;ll&&o.push(new Ct(l,m.from,d));let g=m.direction==bi!=!(d%2);Uo(n,g?i+1:i,s,m.inner,m.from,m.to,o),l=m.to}p=m.to}else{if(p==t||(h?ue[p]!=a:ue[p]==a))break;p++}f?Eo(n,l,p,i+1,s,f,o):le;){let h=!0,u=!1;if(!c||l>r[c-1].to){let m=ue[l-1];m!=a&&(h=!1,u=m==16)}let f=!h&&a==1?[]:null,d=h?i:i+1,p=l;e:for(;;)if(c&&p==r[c-1].to){if(u)break e;let m=r[--c];if(!h)for(let g=m.from,y=c;;){if(g==e)break e;if(y&&r[y-1].to==g)g=r[--y].from;else{if(ue[g-1]==a)break e;break}}if(f)f.push(m);else{m.toue.length;)ue[ue.length]=256;let i=[],s=e==bi?0:1;return Uo(n,s,s,t,0,n.length,i),i}function Yh(n){return[new Ct(0,n,0)]}let Nh="";function Up(n,e,t,i,s){var r;let o=i.head-n.from,a=Ct.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),l=e[a],c=l.side(s,t);if(o==c){let f=a+=s?1:-1;if(f<0||f>=e.length)return null;l=e[a=f],o=l.side(!s,t),c=l.side(s,t)}let h=Ze(n.text,o,l.forward(s,t));(hl.to)&&(h=c),Nh=n.text.slice(Math.min(o,h),Math.max(o,h));let u=a==(s?e.length-1:0)?null:e[a+(s?1:-1)];return u&&h==c&&u.level+(s?0:1)n.some(e=>e)}),nu=K.define({combine:n=>n.some(e=>e)}),su=K.define();class Ui{constructor(e,t,i,s,r,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new Ui(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ui(A.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Nn=z.define({map:(n,e)=>n.map(e)}),ru=z.define();function ze(n,e,t){let i=n.facet(Jh);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Dt=K.define({combine:n=>n.length?n[0]:!0});let Dp=0;const Ti=K.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let l=[];return o&&l.push(ur.of(c=>{let h=c.plugin(a);return h?o(h):B.none})),r&&l.push(r(a)),l})}static fromClass(e,t){return xe.define((i,s)=>new e(i,s),t)}}class Zr{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(ze(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){ze(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){ze(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ou=K.define(),xa=K.define(),ur=K.define(),au=K.define(),va=K.define(),Dn=K.define(),lu=K.define();function Pl(n,e){let t=n.state.facet(lu);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(n):r),s=[];return N.spans(i,e.from,e.to,{point(){},span(r,o,a,l){let c=r-e.from,h=o-e.from,u=s;for(let f=a.length-1;f>=0;f--,l--){let d=a[f].spec.bidiIsolate,p;if(d==null&&(d=Fp(e.text,c,h)),l>0&&u.length&&(p=u[u.length-1]).to==c&&p.direction==d)p.to=h,u=p.inner;else{let m={from:c,to:h,direction:d,inner:[]};u.push(m),u=m.inner}}}}),s}const cu=K.define();function wa(n){let e=0,t=0,i=0,s=0;for(let r of n.state.facet(cu)){let o=r(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:i,bottom:s}}const hn=K.define();class ct{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new ct(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>i.toA)){if(s.toAs.push(new ct(r,o,a,l))),this.changedRanges=s}static create(e,t,i){return new Ks(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Lp=[];class Se{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Lp}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Sp(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let s of this.children){if(s==e)return i;i+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=ii(this.dom),s=this.length?e>0:t>0;return new pt(this.parent.dom,i+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof dr)return e;return null}static get(e){return e.cmTile}}class fr extends Se{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,s,r=e?.node==t?e:null,o=0;for(let a of this.children){if(a.sync(e),o+=a.length+a.breakAfter,s=i?i.nextSibling:t.firstChild,r&&s!=a.dom&&(r.written=!0),a.dom.parentNode==t)for(;s&&s!=a.dom;)s=Cl(s);else t.insertBefore(a.dom,s);i=a.dom}for(s=i?i.nextSibling:t.firstChild,r&&s&&(r.written=!0);s;)s=Cl(s);this.length=o}}function Cl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class dr extends fr{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Se.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,s=0,r=0;;)if(s==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&r++,s=t.pop()}else{let o=i.children[s++];if(o instanceof Lt)t.push(s),i=o,s=0;else{let a=r+o.length,l=e(o,r);if(l!==void 0)return l;r=a+o.breakAfter}}}resolveBlock(e,t){let i,s=-1,r,o=-1;if(this.blockTiles((a,l)=>{let c=l+a.length;if(e>=l&&e<=c){if(a.isWidget()&&t>=-1&&t<=1){if(a.flags&32)return!0;a.flags&16&&(i=void 0)}(le||e==l&&(t>1?a.length:a.covers(-1)))&&(!r||!a.isWidget()&&r.isWidget())&&(r=a,o=e-l)}}),!i&&!r)throw new Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:s}:{tile:r,offset:o}}}class Lt extends fr{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new Lt(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Ii extends fr{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let s=new Ii(t||document.createElement("div"),e);return(!t||!i)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,t,i){let s=null,r=-1,o=null,a=-1;function l(h,u){for(let f=0,d=0;f=u&&(p.isComposite()?l(p,u-d):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&Bp(o,p)))&&(m>u||p.flags&32&&t<=1)?(o=p,a=u-d):(d=-1)&&(s=p,r=u-d)),d=m}}l(this,e);let c=(t<0?s:o)||s||o;return c?{tile:c,offset:c==s?r:a}:null}coordsIn(e,t,i){let s=this.resolveInline(e,t,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),t,i):Xp(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:s,offset:r}=i;if(this.dom.contains(s.dom))return s.isText()?new pt(s.dom,Math.min(s.dom.nodeValue.length,r)):s.domPosFor(r,s.flags&16?1:s.flags&32?-1:t);let o=i.tile.parent,a=!1;for(let l of o.children){if(a)return new pt(l.dom,0);l==i.tile&&(a=!0)}}return new pt(this.dom,0)}}function Xp(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=ys(e);return t[t.length-1]||null}function Bp(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.tops&&(e=s);let r=e,o=e,a=0;e==0&&t<0||e==s&&t>=0?R.chrome||R.gecko||(e?(r--,a=1):o=0)?0:l.length-1];return R.safari&&!a&&c.width==0&&(c=Array.prototype.find.call(l,h=>h.width)||c),i==null?c:$s(c,(a?a>0:t<0)==i)}static of(e,t){let i=new pi(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Si extends Se{constructor(e,t,i,s){super(e,t,s),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let s=this.widget.coordsAt(this.dom,e,t);if(s)return s;if(i)return $s(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let a=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=a?r.length-1:0;o=r[l],!(e>0?l==0:l==r.length-1||o.top0==i)}}class Ip{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:s,index:r,beforeBreak:o,parents:a}=this;for(;e||t>0;)if(s.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(r==s.children.length){if(!e&&!a.length)break;i&&i.leave(s),o=!!s.breakAfter,{tile:s,index:r}=a.pop(),r++}else{let l=s.children[r],c=l.breakAfter;(t>0?l.length<=e:l.length=0;a--){let l=t.marks[a],c=s.lastChild;if(c instanceof Ge&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(Mr(l.dom)),s=c;else{if(this.cache.reused.get(l)){let u=Se.get(l.dom);u&&u.setDOM(Mr(l.dom))}let h=Ge.of(l.mark,l.dom);s.append(h),s=h}this.cache.reused.set(l,2)}let r=Se.get(e.text);r&&this.cache.reused.set(r,2);let o=new pi(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,s.append(o)}addInlineWidget(e,t,i){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let r=this.ensureMarks(t,i);!s&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=hu);let s=Ii.start(e,t||((i=this.cache.find(Ii))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let s=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],a;if(t>0&&(a=s.lastChild)&&a instanceof Ge&&a.mark.eq(o))s=a,t--;else{let l=Ge.of(o,(i=this.cache.find(Ge,c=>c.mark.eq(o)))===null||i===void 0?void 0:i.dom);s.append(l),s=l,t=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Tl(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(R.ios&&Tl(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Er,0,32)||new Si(Er.toDOM(),0,Er,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=e.rank*102+e.value.rank,i=new qp(e.from,e.to,e.value,t),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-i.rank||this.wrappers[s-1].to-i.to)<0;)s--;this.wrappers.splice(s,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let s=t.lastChild;if(i.fromo.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Zs,void 0,1);return i&&(i.flags=t),i||new Zs(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class zp{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let a=this.textOff=Math.min(e,s.length);return r?null:s.slice(0,a)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const Ms=[Si,Ii,pi,Ge,Zs,Lt,dr];for(let n=0;n[]),this.index=Ms.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let s=e.bucket,r=this.buckets[s],o=this.index[s];for(let a=0;a{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let s=0,r=0,o=0;;){let a=os){let c=l-s;this.preserve(c,!o,!a),s=l,r+=c}if(!a)break;t&&a.fromA<=t.range.fromA&&a.toA>=t.range.toA?(this.forward(a.fromA,t.range.fromA,t.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(l-a);else{let c=l>0||a{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Ge&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=r=0):o instanceof Ge&&(s.shift(),r=Math.min(r,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,s=this.builder,r=-1,o=N.spans(this.decorations,e,t,{point:(a,l,c,h,u,f)=>{if(c instanceof Ai){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(a).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=h.length,u>h.length)s.continueWidget(l-a);else{let d=c.widget||(c.block?qi.block:qi.inline),p=Yp(c),m=this.cache.findWidget(d,l-a,p)||Si.of(d,this.view,l-a,p);c.block?(c.startSide>0&&s.addLineStartIfNotCovered(i),s.addBlockWidget(m)):(s.ensureLine(i),s.addInlineWidget(m,h,u))}i=null}else i=Np(i,c);l>a&&this.text.skip(l-a)},span:(a,l,c,h)=>{for(let u=a;u-1&&(this.openWidget=o>r),this.openWidget||s.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let s=e.parentNode;;s=s.parentNode){let r=Se.get(s);if(s==this.view.contentDOM)break;r instanceof Ge?t.push(r):r?.isLine()?i=r:r instanceof Lt||(s.nodeName=="DIV"&&!i&&s!=this.view.contentDOM?i=new Ii(s,hu):i||t.push(Ge.of(new Un({tagName:s.nodeName.toLowerCase(),attributes:xp(s)}),s)))}return{line:i,marks:t}}}function Tl(n,e){let t=i=>{for(let s of i.children)if((e?s.isText():s.length)||t(s))return!0;return!1};return t(n)}function Yp(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const hu={class:"cm-line"};function Np(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Oa(t,n),i&&(n.class+=" "+i)),n}function Hp(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof Ge&&e.push(i.mark)}return e}function Mr(n){let e=Se.get(n);return e&&e.setDOM(n.cloneNode()),n}class qi extends Ut{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}qi.inline=new qi("span");qi.block=new qi("div");const Er=new class extends Ut{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Rl{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=B.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new dr(e,e.contentDOM),this.updateInner([new ct(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!rm(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?_p(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:u}=this.hasComposition;i=new ct(h,u,e.changes.mapPos(h,-1),e.changes.mapPos(u,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(R.ie||R.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.blockWrappers;this.updateDeco();let l=tm(o,this.decorations,e.changes);l.length&&(i=ct.extendWithRanges(i,l));let c=nm(a,this.blockWrappers,e.changes);return c.length&&(i=ct.extendWithRanges(i,c)),r&&!i.some(h=>h.fromA<=r.range.fromA&&h.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,a=new jp(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Se.get(t.text)&&a.cache.reused.set(Se.get(t.text),2),this.tile=a.run(e,t),Do(o,a.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=R.chrome||R.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&gn(i,this.view.observer.selectionRange)&&!(s&&i.contains(s));if(!(r||t||o))return;let a=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,h;if(l.empty?h=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(h=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),R.gecko&&l.empty&&!this.hasComposition&&Gp(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=h=new pt(f,0),a=!0}let u=this.view.observer.selectionRange;(a||!u.focusNode||(!On(c.node,c.offset,u.anchorNode,u.anchorOffset)||!On(h.node,h.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,l))&&(this.view.observer.ignore(()=>{R.android&&R.chrome&&i.contains(u.focusNode)&&sm(u.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let f=kn(this.view.root);if(f)if(l.empty){if(R.gecko){let d=Jp(c.node,c.offset);if(d&&d!=3){let p=(d==1?qh:Wh)(c.node,c.offset);p&&(c=new pt(p.node,p.offset))}}f.collapse(c.node,c.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(h.node,h.offset)}catch{}}else{let d=document.createRange();l.anchor>l.head&&([c,h]=[h,c]),d.setEnd(h.node,h.offset),d.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new pt(u.anchorNode,u.anchorOffset),this.impreciseHead=h.precise?null:new pt(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&On(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=kn(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!l||!c||l.bottom>c.top)return;let h=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(h.node,h.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&i.collapse(s,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let o=It(e)==0?0:t==0?-1:1;for(;;){let a=e.parentNode;if(a==i.dom)break;o==0&&a.firstChild!=a.lastChild&&(e==a.firstChild?o=-1:o=1),e=a}o<0?r=e:r=e.nextSibling}if(r==i.dom.firstChild)return s;for(;r&&!Se.get(r);)r=r.nextSibling;if(!r)return s+i.length;for(let o=0,a=s;;o++){let l=i.children[o];if(l.dom==r)return a;a+=l.length+l.breakAfter}}else return i.isText()?e==i.dom?s+t:s+(t?i.length:0):s}domAtPos(e,t){let{tile:i,offset:s}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(s,t):i.domIn(s,t)}inlineDOMNearPos(e,t){let i,s=-1,r=!1,o,a=-1,l=!1;return this.tile.blockTiles((c,h)=>{if(c.isWidget()){if(c.flags&32&&h>=e)return!0;c.flags&16&&(r=!0)}else{let u=h+c.length;if(h<=e&&(i=c,s=e-h,r=u=e&&!o&&(o=c,a=e-h,l=h>e),h>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(r&&o?i=null:l&&i&&(o=null),i&&t<0||!o?i.domIn(s,t):o.domIn(a,t))}coordsAt(e,t,i){let{tile:s,offset:r}=this.tile.resolveBlock(e,t);return s.isWidget()?s.widget instanceof Ur?null:s.coordsInWidget(r,t,!0):s.coordsIn(r,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function s(r,o){if(r.isComposite())for(let a of r.children){if(a.length>=o){let l=s(a,o);if(l)return l}if(o-=a.length,o<0)break}else if(r.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==fe.LTR,c=0,h=(u,f,d)=>{for(let p=0;ps);p++){let m=u.children[p],g=f+m.length,y=m.dom.getBoundingClientRect(),{height:b}=y;if(d&&!p&&(c+=y.top-d.top),m instanceof Lt)g>i&&h(m,f,y);else if(f>=i&&(c>0&&t.push(-c),t.push(b+c),c=0,o)){let x=m.dom.lastChild,C=x?ys(x):[];if(C.length){let k=C[C.length-1],S=l?k.right-y.left:y.right-k.left;S>a&&(a=S,this.minWidth=r,this.minWidthFrom=f,this.minWidthTo=g)}}d&&p==u.children.length-1&&(c+=d.bottom-y.bottom),f=g+m.breakAfter}};return h(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?fe.RTL:fe.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let a=0,l;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let h=ys(c.dom);if(h.length!=1)return;a+=h[0].width,l=h[0].height}if(a)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:a/o.length,textHeight:l}}});if(e)return e;let t=document.createElement("div"),i,s,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=ys(t.firstChild)[0];i=t.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:s,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.view.state.doc.length;if(o>i){let a=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(B.replace({widget:new Ur(a),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return B.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ur).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,s=this.view.state.facet(va).map((r,o)=>{let a=typeof r=="function";return a&&(i=!0),a?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=i,t.push(N.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof r=="function"?r(this.view):r)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(su))try{if(c(this.view,e.range,e))return!0}catch(h){ze(this.view.state,h,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),s;if(!i)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let r=wa(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;if(kp(this.view.scrollDOM,o,t.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Do(this.tile)}}function Do(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Do(i,e)}}function Gp(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function uu(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=qh(t.focusNode,t.focusOffset),s=Wh(t.focusNode,t.focusOffset),r=i||s;if(s&&i&&s.node!=i.node){let a=Se.get(s.node);if(!a||a.isText()&&a.text!=s.node.nodeValue)r=s;else if(n.docView.lastCompositionAfterCursor){let l=Se.get(i.node);!l||l.isText()&&l.text!=i.node.nodeValue||(r=s)}}if(n.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function _p(n,e,t){let i=uu(n,t);if(!i)return null;let{node:s,from:r,to:o}=i,a=s.nodeValue;if(/[\n\r]/.test(a)||n.state.doc.sliceString(i.from,i.to)!=a)return null;let l=e.invertedDesc;return{range:new ct(l.mapPos(r),l.mapPos(o),r,o),text:s}}function Jp(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}class Ur extends Ut{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function om(n,e,t=1){let i=n.charCategorizer(e),s=n.doc.lineAt(e),r=e-s.from;if(s.length==0)return A.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,a=r;t<0?o=Ze(s.text,r,!1):a=Ze(s.text,r);let l=i(s.text.slice(o,a));for(;o>0;){let c=Ze(s.text,o,!1);if(i(s.text.slice(c,o))!=l)break;o=c}for(;an.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight,l=Math.floor((s-t.top-(n.defaultLineHeight-a)*.5)/a);r+=l*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Qo(o,r,n.state.tabSize)}function Lo(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let s;for(let r of i.type){if(r.from>e)break;if(!(r.toe)return r;(!s||r.type==Le.Text&&(s.type!=r.type||(t<0?r.frome)))&&(s=r)}}return s||i}return i}function lm(n,e,t,i){let s=Lo(n,e.head,e.assoc||-1),r=!i||s.type!=Le.Text||!(n.lineWrapping||s.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=n.dom.getBoundingClientRect(),a=n.textDirectionAt(s.from),l=n.posAtCoords({x:t==(a==fe.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(l!=null)return A.cursor(l,t?-1:1)}return A.cursor(t?s.to:s.from,t?-1:1)}function $l(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let a=e,l=null;;){let c=Up(s,r,o,a,t),h=Nh;if(!c){if(s.number==(t?n.state.doc.lines:1))return a;h=` +`,s=n.state.doc.line(s.number+(t?1:-1)),r=n.bidiSpans(s),c=n.visualLineSide(s,!t)}if(l){if(!l(h))return a}else{if(!i)return c;l=i(h)}a=c}}function cm(n,e,t){let i=n.state.charCategorizer(e),s=i(t);return r=>{let o=i(r);return s==ye.Space&&(s=o),s==o}}function hm(n,e,t,i){let s=e.head,r=t?1:-1;if(s==(t?n.state.doc.length:0))return A.cursor(s,e.assoc);let o=e.goalColumn,a,l=n.contentDOM.getBoundingClientRect(),c=n.coordsAtPos(s,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),h=n.documentTop;if(c)o==null&&(o=c.left-l.left),a=r<0?c.top:c.bottom;else{let p=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(l.right-l.left,n.defaultCharacterWidth*(s-p.from))),a=(r<0?p.top:p.bottom)+h}let u=l.left+o,f=n.viewState.heightOracle.textHeight>>1,d=i??f;for(let p=0;;p+=f){let m=a+(d+p)*r,g=Xo(n,{x:u,y:m},!1,r);if(t?m>l.bottom:ma:b{if(e>r&&es(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:A.cursor(i,in.viewState.docHeight)return new Pt(n.state.doc.length,-1);if(c=n.elementAtHeight(l),i==null)break;if(c.type==Le.Text){if(i<0?c.ton.viewport.to)break;let f=n.docView.coordsAt(i<0?c.from:c.to,i>0?-1:1);if(f&&(i<0?f.top<=l+r:f.bottom>=l+r))break}let u=n.viewState.heightOracle.textHeight/2;l=i>0?c.bottom+u:c.top-u}if(n.viewport.from>=c.to||n.viewport.to<=c.from){if(t)return null;if(c.type==Le.Text){let u=am(n,s,c,o,a);return new Pt(u,u==c.from?1:-1)}}if(c.type!=Le.Text)return l<(c.top+c.bottom)/2?new Pt(c.from,1):new Pt(c.to,-1);let h=n.docView.lineAt(c.from,2);return(!h||h.length!=c.length)&&(h=n.docView.lineAt(c.from,-2)),new um(n,o,a,n.textDirectionAt(c.from)).scanTile(h,c.from)}class um{constructor(e,t,i,s){this.view=e,this.x=t,this.y=i,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+s.from>1;t:if(o.has(m)){for(let b=1;b=r&&(x-=p),!o.has(x)){m=x;break t}}break e}o.add(m);let g=t(m),y=0;if(g)for(let b=0;b1))if(x.bottomthis.y)(!c||c.top>x.top)&&(c=x),y=-1;else{let C=x.left>this.x?this.x-x.left:x.right(p+p+m)/3)return this.y=l.bottom-1,this.scan(e,t,!0);if(c&&c.top<(p+m+m)/3)return this.y=c.top+1,this.scan(e,t,!0)}let d=(a?this.dirAt(e[h],1):this.baseDir)==fe.LTR;return{i:h,after:this.x>(f.left+f.right)/2==d}}scanText(e,t){let i=[];for(let r=0;r{let o=i[r]-t,a=i[r+1]-t;return Qn(e.dom,o,a).getClientRects()});return s.after?new Pt(i[s.i+1],-1):new Pt(i[s.i],1)}scanTile(e,t){if(!e.length)return new Pt(t,1);if(e.children.length==1){let a=e.children[0];if(a.isText())return this.scanText(a,t);if(a.isComposite())return this.scanTile(a,t)}let i=[t];for(let a=0,l=t;a{let l=e.children[a];return l.flags&48?null:(l.dom.nodeType==1?l.dom:Qn(l.dom,0,l.length)).getClientRects()}),r=e.children[s.i],o=i[s.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):s.after?new Pt(i[s.i+1],-1):new Pt(o,1)}}const ki="￿";class fm{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(_.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ki}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let s=e;;){this.findPointBefore(i,s);let r=this.text.length;this.readNode(s);let o=Se.get(s),a=s.nextSibling;if(a==t){o?.breakAfter&&!a&&i!=this.view.contentDOM&&this.lineBreak();break}let l=Se.get(a);(o&&l?o.breakAfter:(o?o.breakAfter:Rs(s))||Rs(a)&&(s.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!pm(a,t)&&this.lineBreak(),s=a}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,a;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(a=s.exec(t))&&(r=a.index,o=a[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);i=r+o}}readNode(e){let t=Se.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(dm(e,i.node,i.offset)?t:0))}}function dm(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,a=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=du(e.docView.tile,t,i,0))){let l=r||o?[]:Om(e),c=new fm(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=ym(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Zo(e.contentDOM,l.focusNode)?a.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Zo(e.contentDOM,l.anchorNode)?a.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),u=e.viewport;if((R.ios||R.chrome)&&c!=h&&Math.min(c,h)<=a.main.from&&Math.max(c,h)>=a.main.to&&(u.from>0||u.to-1&&a.ranges.length>1)this.newSel=a.replaceRange(A.range(h,c));else if(e.lineWrapping&&h==c&&!(a.main.empty&&a.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(c,-1),d=0;f&&(d=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=A.create([A.cursor(c,d)])}else this.newSel=A.single(h,c)}}}function du(n,e,t,i){if(n.isComposite()){let s=-1,r=-1,o=-1,a=-1;for(let l=0,c=i,h=i;lt)return du(u,e,t,c);if(f>=e&&s==-1&&(s=l,r=c),c>t&&u.dom.parentNode==n.dom){o=l,a=h;break}h=f,c=f+u.breakAfter}return{from:r,to:a<0?i+n.length:a,startDOM:(s?n.children[s-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function pu(n,e){let t,{newSel:i}=e,{state:s}=n,r=s.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:l}=e.bounds,c=r.from,h=null;(o===8||R.android&&e.text.length=a&&r.to<=l&&(e.typeOver||u!=e.text)&&u.slice(0,r.from-a)==e.text.slice(0,r.from-a)&&u.slice(r.to-a)==e.text.slice(f=e.text.length-(u.length-(r.to-a)))?t={from:r.from,to:r.to,insert:se.of(e.text.slice(r.from-a,f).split(ki))}:(d=mu(u,e.text,c-a,h))&&(R.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==ki+ki&&d.toB--,t={from:a+d.from,to:a+d.toA,insert:se.of(e.text.slice(d.from,d.toB).split(ki))})}else i&&(!n.hasFocus&&s.facet(Dt)||Es(i,r))&&(i=null);if(!t&&!i)return!1;if((R.mac||R.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=A.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:se.of([t.insert.toString().replace("."," ")])}):s.doc.lineAt(r.from).toDate.now()-50?t={from:r.from,to:r.to,insert:s.toText(n.inputState.insertingText)}:R.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` + `&&n.lineWrapping&&(i&&(i=A.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:se.of([" "])}),t)return ka(n,t,i,o);if(i&&!Es(i,r)){let a=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(a=!0),l=n.inputState.lastSelectionOrigin,l=="select.pointer"&&(i=fu(s.facet(Dn).map(c=>c(n)),i))),n.dispatch({selection:i,scrollIntoView:a,userEvent:l}),!0}else return!1}function ka(n,e,t,i=-1){if(R.ios&&n.inputState.flushIOSKey(e))return!0;let s=n.state.selection.main;if(R.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&n.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ei(n.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||i==8&&e.insert.lengths.head)&&Ei(n.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Ei(n.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,a=()=>o||(o=gm(n,e,t));return n.state.facet(eu).some(l=>l(n,e.from,e.to,r,a))||n.dispatch(a()),!0}function gm(n,e,t){let i,s=n.state,r=s.selection.main,o=-1;if(e.from==e.to&&e.fromr.to){let l=e.fromu(n)),c,l);e.from==h&&(o=h)}if(o>-1)i={changes:e,selection:A.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=r.frome.to?s.sliceDoc(e.to,r.to):"";i=s.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+c))}else{let l=s.changes(e),c=t&&t.main.to<=l.newLength?t.main:void 0;if(s.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let h=n.state.sliceDoc(e.from,e.to),u,f=t&&uu(n,t.main.head);if(f){let p=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-p}}else u=n.state.doc.lineAt(r.head);let d=r.to-e.to;i=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:l,range:c||p.map(l)};let m=p.to-d,g=m-h.length;if(n.state.sliceDoc(g,m)!=h||m>=u.from&&g<=u.to)return{range:p};let y=s.changes({from:g,to:m,insert:e.insert}),b=p.to-r.to;return{changes:y,range:c?A.range(Math.max(0,c.anchor+b),Math.max(0,c.head+b)):p.map(y)}})}else i={changes:l,selection:c&&s.selection.replaceRange(c)}}let a="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,a+=".compose",n.inputState.compositionFirstChange&&(a+=".start",n.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:a,scrollIntoView:!0})}function mu(n,e,t,i){let s=Math.min(n.length,e.length),r=0;for(;r0&&a>0&&n.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(i=="end"){let l=Math.max(0,r-Math.min(o,a));t-=o+l-r}if(o=o?r-t:0;r-=l,a=r+(a-o),o=r}else if(a=a?r-t:0;r-=l,o=r+(o-a),a=r}return{from:r,toA:o,toB:a}}function Om(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new Kl(t,i)),(s!=t||r!=i)&&e.push(new Kl(s,r))),e}function ym(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?A.single(t+e,i+e):null}function Es(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class Am{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,R.safari&&e.contentDOM.addEventListener("input",()=>null),R.gecko&&Em(e.contentDOM.ownerDocument)}handleEvent(e){!Cm(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let s of i.observers)s(this.view,t);for(let s of i.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Sm(e),i=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,a=i[r];a&&o!=!a.handlers.length&&(s.removeEventListener(r,this.handleEvent),a=null),a||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Ou.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),R.android&&R.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(R.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(gu.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||xm.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&R.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&bm(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:R.safari&&!R.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function bm(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function Zl(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(s){ze(t.state,s)}}}function Sm(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let s=i.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let a in r){let l=r[a];l&&t(a).handlers.push(Zl(i.value,l))}if(o)for(let a in o){let l=o[a];l&&t(a).observers.push(Zl(i.value,l))}}for(let i in Ot)t(i).handlers.push(Ot[i]);for(let i in je)t(i).observers.push(je[i]);return e}const gu=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],xm="dthko",Ou=[16,17,18,20,91,92,224,225],Hn=6;function Gn(n){return Math.max(0,n)*.7+8}function vm(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class wm{constructor(e,t,i,s){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Dh(e.contentDOM),this.atoms=e.state.facet(Dn).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(_.allowMultipleSelections)&&km(e,t),this.dragging=Pm(e,t)&&bu(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&vm(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,s=0,r=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=wa(this.view);e.clientX-l.left<=s+Hn?t=-Gn(s-e.clientX):e.clientX+l.right>=o-Hn&&(t=Gn(e.clientX-o)),e.clientY-l.top<=r+Hn?i=-Gn(r-e.clientY):e.clientY+l.bottom>=a-Hn&&(i=Gn(e.clientY-a)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=fu(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function km(n,e){let t=n.state.facet(Hh);return t.length?t[0](e):R.mac?e.metaKey:e.ctrlKey}function Qm(n,e){let t=n.state.facet(Gh);return t.length?t[0](e):R.mac?!e.altKey:!e.ctrlKey}function Pm(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=kn(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Cm(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Se.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const Ot=Object.create(null),je=Object.create(null),yu=R.ie&&R.ie_version<15||R.ios&&R.webkit_version<604;function Tm(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),Au(n,t.value)},50)}function pr(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function Au(n,e){e=pr(n.state,ba,e);let{state:t}=n,i,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Bo!=null&&t.selection.ranges.every(l=>l.empty)&&Bo==r.toString()){let l=-1;i=t.changeByRange(c=>{let h=t.doc.lineAt(c.from);if(h.from==l)return{range:c};l=h.from;let u=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:u},range:A.cursor(c.from+u.length)}})}else o?i=t.changeByRange(l=>{let c=r.line(s++);return{changes:{from:l.from,to:l.to,insert:c.text},range:A.cursor(l.from+c.length)}}):i=t.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}je.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,R.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};je.wheel=je.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};Ot.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);je.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};je.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};je.touchend=(n,e)=>{n.inputState.touchActive=!1};Ot.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(_h))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=$m(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new wm(n,e,t,i)),i&&n.observer.ignore(()=>{Bh(n.contentDOM);let r=n.root.activeElement;r&&!r.contains(n.contentDOM)&&r.blur()});let s=n.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function Ml(n,e,t,i){if(i==1)return A.cursor(e,t);if(i==2)return om(n.state,e,t);{let s=n.docView.lineAt(e,t),r=n.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,a=s?s.posAtEnd:r.to;return aDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(Ul+1)%3:1}function $m(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=bu(e),s=n.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,a){let l=n.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),c,h=Ml(n,l.pos,l.assoc,i);if(t.pos!=l.pos&&!o){let u=Ml(n,t.pos,t.assoc,i),f=Math.min(u.from,h.from),d=Math.max(u.to,h.to);h=f1&&(c=Km(s,l.pos))?c:a?s.addRange(h):A.create([h])}}}function Km(n,e){for(let t=0;t=e)return A.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Ot.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let s=n.docView.tile.nearest(e.target);if(s&&s.isWidget()){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=A.undirectionalRange(r,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",pr(n.state,Sa,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ot.dragend=n=>(n.inputState.draggedContent=null,!1);function Dl(n,e,t,i){if(t=pr(n.state,ba,t),!t)return;let s=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=n.inputState,o=i&&r&&Qm(n,e)?{from:r.from,to:r.to}:null,a={from:s,insert:t},l=n.state.changes(o?[o,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Ot.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),s=0,r=()=>{++s==t.length&&Dl(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(i[o]=a.result),r()},a.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Dl(n,e,i,!0),!0}return!1};Ot.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=yu?null:e.clipboardData;return t?(Au(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Tm(n),!1)};function Zm(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Mm(n){let e=[],t=[],i=!1;for(let s of n.selection.ranges)s.empty||(e.push(n.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:pr(n,Sa,e.join(n.lineBreak)),ranges:t,linewise:i}}let Bo=null;Ot.copy=Ot.cut=(n,e)=>{if(!gn(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:s}=Mm(n.state);if(!t&&!s)return!1;Bo=s?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=yu?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(Zm(n,t),!1)};const Su=Wt.define();function xu(n,e){let t=[];for(let i of n.facet(tu)){let s=i(n,e);s&&t.push(s)}return t.length?n.update({effects:t,annotations:Su.of(!0)}):null}function vu(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=xu(n.state,e);t?n.dispatch(t):n.update([])}},10)}je.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),vu(n)};je.blur=n=>{n.observer.clearSelectionRange(),vu(n)};je.compositionstart=je.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};je.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,R.chrome&&R.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};je.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Ot.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let a=o[0],l=n.posAtDOM(a.startContainer,a.startOffset),c=n.posAtDOM(a.endContainer,a.endOffset);return ka(n,{from:l,to:c,insert:n.state.toText(r)},null),!0}}let s;if(R.chrome&&R.android&&(s=gu.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return R.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),R.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>je.compositionend(n,e),20),!1};const Ll=new Set;function Em(n){Ll.has(n)||(Ll.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const Xl=["pre-wrap","normal","pre-line","break-spaces"];let Wi=!1;function Bl(){Wi=!1}class Um{constructor(e){this.lineWrapping=e,this.doc=se.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Xl.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=i,this.textHeight=s,this.lineLength=r,l){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>As&&(Wi=!0),this.height=e)}replace(e,t,i){return Ve.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this,o=i.doc;for(let a=s.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:h,toB:u}=s[a],f=r.lineAt(l,pe.ByPosNoHeight,i.setDoc(t),0,0),d=f.to>=c?f:r.lineAt(c,pe.ByPosNoHeight,i,0,0);for(u+=d.to-c,c=d.to;a>0&&f.from<=s[a-1].toA;)l=s[a-1].fromA,h=s[a-1].fromB,a--,lr*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),i+=1+a.break,s-=a.size}else if(r>s*2){let a=e[i];a.break?e.splice(i,1,a.left,null,a.right):e.splice(i,1,a.left,a.right),i+=2+a.break,r-=a.size}else break;else if(s=r&&o(this.lineAt(0,pe.ByPos,i,s,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ot extends wu{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new dt(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof ot||s instanceof Ee&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Ee?s=new ot(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ve.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setMeasuredHeight(s):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ee extends Ve{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-i+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*r);o=l/r,this.length>r+1&&(a=(this.height-l)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:s,perLine:o,perChar:a}}blockAt(e,t,i,s){let{firstLine:r,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,s);if(t.lineWrapping){let c=s+(e0){let r=i[i.length-1];r instanceof Ee?i[i.length-1]=new Ee(r.length+s):i.push(null,new Ee(s-1))}if(e>0){let r=i[0];r instanceof Ee?i[0]=new Ee(e+r.length):i.unshift(new Ee(e-1),null)}return Ve.of(i)}decomposeLeft(e,t){t.push(new Ee(e-1),null)}decomposeRight(e,t){t.push(null,new Ee(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],a=Math.max(t,s.from),l=-1;for(s.from>t&&o.push(new Ee(s.from-t-1).updateHeight(e,t));a<=r&&s.more;){let h=e.doc.lineAt(a).length;o.length&&o.push(null);let u=s.heights[s.index++],f=0;u<0&&(f=-u,u=s.heights[s.index++]),l==-1?l=u:Math.abs(u-l)>=As&&(l=-2);let d=new ot(h,u,f);d.outdated=!1,o.push(d),a+=h+1}a<=r&&o.push(null,new Ee(r-a).updateHeight(e,a));let c=Ve.of(o);return(l<0||Math.abs(c.height-this.height)>=As||Math.abs(l-this.heightMetrics(e,t).perLine)>=As)&&(Wi=!0),Us(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Lm extends Ve{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,s){let r=i+this.left.height;return ea))return c;let h=t==pe.ByPosNoHeight?pe.ByPosNoHeight:pe.ByPos;return l?c.join(this.right.lineAt(a,h,i,o,a)):this.left.lineAt(a,h,i,s,r).join(c)}forEachLine(e,t,i,s,r,o){let a=s+this.left.height,l=r+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,i,a,l,o);else{let c=this.lineAt(l,pe.ByPos,i,s,r);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,a,l,o)}}replace(e,t,i){let s=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let a of i)r.push(a);if(e>0&&Il(r,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e2*t.size||t.size>2*e.size?Ve.of(this.break?[e,null,t]:[e,t]):(this.left=Us(this.left,e),this.right=Us(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,s){let{left:r,right:o}=this,a=t+r.length+this.break,l=null;return s&&s.from<=t+r.length&&s.more?l=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=a+o.length&&s.more?l=o=o.updateHeight(e,a,i,s):o.updateHeight(e,a,i),l?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Il(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Ee&&(i=n[e+1])instanceof Ee&&n.splice(e-1,3,new Ee(t.length+1+i.length))}const Xm=5;class Qa{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof ot?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ot(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=Xm)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new ot(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new Ee(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ot)return e;let t=new ot(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ot)&&!this.isCovered?this.nodes.push(new ot(0,-1,0)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&u.overflow!="visible"){let f=h.getBoundingClientRect();r=Math.max(r,f.left),o=Math.min(o,f.right),a=Math.max(a,f.top),l=Math.min(c==n.parentNode?s.innerHeight:l,f.bottom)}c=u.position=="absolute"||u.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function Wm(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function zm(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Dr{constructor(e,t,i,s){this.from=e,this.to=t,this.size=i,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new Um(i),this.stateDeco=zl(t),this.heightMap=Ve.empty().applyChanges(this.stateDeco,se.empty,this.heightOracle.setDoc(t.doc),[new ct(0,0,0,t.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=B.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new _n(r,o))}}return this.viewports=e.sort((i,s)=>i.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Wl:new Pa(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(un(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=zl(this.state);let s=e.changedRanges,r=ct.extendWithRanges(s,Bm(i,this.stateDeco,e?e.changes:Re.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Bl(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Wi)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(nu)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?fe.RTL:fe.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,h=0;if(a.width&&a.height){let{scaleX:k,scaleY:S}=Fh(t,a);(k>.005&&Math.abs(this.scaleX-k)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=k,this.scaleY=S,c|=16,o=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let d=Dh(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Ih(this.scrollParent||e.win);let m=(this.printing?zm:qm)(t,this.paddingTop),g=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(l=!0)),!this.inView&&!this.scrollTarget&&!Wm(e.dom))return 0;let x=a.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let k=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(k)&&(o=!0),o||s.lineWrapping&&Math.abs(x-this.contentDOMWidth)>s.charWidth){let{lineHeight:S,charWidth:w,textHeight:U}=e.docView.measureTextSize();o=S>0&&s.refresh(r,S,w,U,Math.max(5,x/w),k),o&&(e.docView.minWidth=0,c|=16)}g>0&&y>0?h=Math.max(g,y):g<0&&y<0&&(h=Math.min(g,y)),Bl();for(let S of this.viewports){let w=S.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?Ve.empty().applyChanges(this.stateDeco,se.empty,this.heightOracle,[new ct(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Fm(S.from,w))}Wi&&(c|=2)}let C=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return C&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||C)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new _n(s.lineAt(o-i*1e3,pe.ByHeight,r,0,0).from,s.lineAt(a+(1-i)*1e3,pe.ByHeight,r,0,0).to);if(t){let{head:c}=t.range;if(cl.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=s.lineAt(c,pe.ByPos,r,0,0),f;t.y=="center"?f=(u.top+u.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&c=a+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r>1,o=s<<1;if(this.defaultTextDirection!=fe.LTR&&!i)return[];let a=[],l=(h,u,f,d)=>{if(u-hh&&yy.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)y.fromb));if(!g){if(ux.from<=u&&x.to>=u)){let x=t.moveToLineBoundary(A.cursor(u),!1,!0).head;x>h&&(u=x)}let y=this.gapSize(f,h,u,d),b=i||y<2e6?y:2e6;g=new Dr(h,u,y,b)}a.push(g)},c=h=>{if(h.length2e6)for(let S of e)S.from>=h.from&&S.fromh.from&&l(h.from,d,h,u),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];N.spans(t,this.viewport.from,this.viewport.to,{span(r,o){i.push({from:r,to:o})},point(){}},20);let s=0;if(i.length!=this.visibleRanges.length)s=12;else for(let r=0;r=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||un(this.heightMap.lineAt(e,pe.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||un(this.heightMap.lineAt(this.scaler.fromDOM(e),pe.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return un(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class _n{constructor(e,t){this.from=e,this.to=t}}function jm(n,e,t){let i=[],s=n,r=0;return N.spans(t,n,e,{span(){},point(o,a){o>s&&(i.push({from:s,to:o}),r+=o-s),s=a}},20),s=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let s=0;;s++){let{from:r,to:o}=e[s],a=o-r;if(i<=a)return r+i;i-=a}}function es(n,e){let t=0;for(let{from:i,to:s}of n.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/n.total}function Ym(n,e){for(let t of n)if(e(t))return t}const Wl={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function zl(n){let e=n.facet(ur).filter(i=>typeof i!="function"),t=n.facet(va).filter(i=>typeof i!="function");return t.length&&e.push(N.join(t)),e}class Pa{constructor(e,t,i){let s=0,r=0,o=0;this.viewports=i.map(({from:a,to:l})=>{let c=t.lineAt(a,pe.ByPos,e,0,0).top,h=t.lineAt(l,pe.ByPos,e,0,0).bottom;return s+=h-c,{from:a,to:l,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let a of this.viewports)a.domTop=o+(a.top-r)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),r=a.bottom}toDOM(e){for(let t=0,i=0,s=0;;t++){let r=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function un(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new dt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(s=>un(s,e)):n._content)}const ts=K.define({combine:n=>n.join(" ")}),Io=K.define({combine:n=>n.indexOf(!0)>-1}),qo=ei.newName(),ku=ei.newName(),Qu=ei.newName(),Pu={"&light":"."+ku,"&dark":"."+Qu};function Wo(n,e,t){return new ei(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):n+" "+i}})}const Nm=Wo("."+qo,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Pu),Hm={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Lr=R.ie&&R.ie_version<=11;class Gm{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Qp,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(R.ie&&R.ie_version<=11||R.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&R.android&&e.constructor.EDIT_CONTEXT!==!1&&!(R.chrome&&R.chrome_version<126)&&(this.editContext=new Jm(e),e.state.facet(Dt)&&(e.contentDOM.editContext=this.editContext.editContext)),Lr&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(Dt)?i.root.activeElement!=this.dom:!gn(this.dom,s))return;let r=s.anchorNode&&i.docView.tile.nearest(s.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(R.ie&&R.ie_version<=11||R.android&&R.chrome)&&!i.state.selection.main.empty&&s.focusNode&&On(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=kn(e.root);if(!t)return!1;let i=R.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&_m(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let s=gn(this.dom,i);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Ei(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&gn(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new mm(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,s=pu(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Es(this.view.state.selection,t.newSel.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Vl(t,e.previousSibling||e.target.previousSibling,-1),s=Vl(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Dt)!=e.state.facet(Dt)&&(e.view.contentDOM.editContext=e.state.facet(Dt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Vl(n,e,t){for(;e;){let i=Se.get(e);if(i&&i.parent==n)return i;let s=e.parentNode;e=s!=n.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function jl(n,e){let t=e.startContainer,i=e.startOffset,s=e.endContainer,r=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return On(o.node,o.offset,s,r)&&([t,i,s,r]=[s,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}}function _m(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return jl(n,s)}let t=null;function i(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?jl(n,t):null}class Jm{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let s=e.state.selection.main,{anchor:r,head:o}=s,a=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>i.text.length;a==this.from&&rthis.to&&(l=r);let h=mu(e.state.sliceDoc(a,l),i.text,(c?s.from:s.to)-a,c?"end":null);if(!h){let f=A.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Es(f,s)||e.dispatch({selection:f,userEvent:"select"});return}let u={from:h.from+a,to:h.toA+a,insert:se.of(i.text.slice(h.from,h.toB).split(` +`))};if((R.mac||R.android)&&u.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:a,to:l,insert:se.of([i.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let f=this.to-this.from+(u.to-u.from+u.insert.length);ka(e,u,A.single(this.toEditorPos(i.selectionStart,f),this.toEditorPos(i.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],r=null;for(let o=this.toEditorPos(i.rangeStart),a=this.toEditorPos(i.rangeEnd);o{let s=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,a=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let l=this.toEditorPos(r.rangeStart),c=this.toEditorPos(r.rangeEnd);if(l{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let s=kn(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,a,l,c)=>{if(i)return;let h=c.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(c)){s=this.pendingContextChange=null,t+=h,this.to+=h;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=h,this.to+=h;else if(rthis.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),c.toString()),this.to+=h}t+=h}),s&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class ${get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(s=>s.forEach(r=>i(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Pp(e.parent)||document,this.viewState=new ql(this,e.state||_.create(e)),e.scrollTo&&e.scrollTo.is(Nn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ti).map(s=>new Zr(s));for(let s of this.plugins)s.update(this);this.observer=new Gm(this),this.inputState=new Am(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Rl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Pe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,s,r=this.state;for(let f of e){if(f.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=f.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,a=0,l=null;e.some(f=>f.annotation(Su))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=xu(r,o),l||(a=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(_.phrases)!=this.state.facet(_.phrases))return this.setState(r);s=Ks.create(this,r,e),s.flags|=a;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:p,y:m}=this.state.facet($.cursorScrollMargin);u=new Ui(d.empty?d:A.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of f.effects)d.is(Nn)&&(u=d.value.clip(this.state))}this.viewState.update(s,u),this.bidiCache=Fs.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(hn)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(ts)!=s.state.facet(ts)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let f of this.state.facet(Fo))try{f(s)}catch(d){ze(this.state,d,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!pu(this,h)&&c.force&&Ei(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new ql(this,e),this.plugins=e.facet(Ti).map(i=>new Zr(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Rl(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ti),i=e.state.facet(Ti);if(t!=i){let s=[];for(let r of i){let o=t.indexOf(r);if(o<0)s.push(new Zr(r));else{let a=this.plugins[o];a.mustUpdate=e,s.push(a)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(Ih(i||this.win))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(d=>{try{return d.read(this)}catch(p){return ze(this.state,p),Yl}}),u=Ks.create(this,this.state,[]),f=!1;u.flags|=l,t?t.flags|=l:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u),f&&this.docViewUpdate());for(let d=0;d1||p<-1)&&!(R.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Fo))a(t)}get themeClasses(){return qo+" "+(this.state.facet(Io)?Qu:ku)+" "+this.state.facet(ts)}updateAttrs(){let e=Nl(this,ou,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Dt)?"true":"false",class:"cm-content",style:`${R.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Nl(this,xa,t);let i=this.observer.ignore(()=>{let s=wl(this.contentDOM,this.contentAttrs,t),r=wl(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is($.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(hn);let e=this.state.facet($.cspNonce);ei.mount(this.root,this.styleModules.concat(Nm).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Fr(this,e,$l(this,e,t,i))}moveByGroup(e,t){return Fr(this,e,$l(this,e,t,i=>cm(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return A.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,i=!0){return lm(this,e,t,i)}moveVertically(e,t,i){return Fr(this,e,hm(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Xo(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Xo(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),s=this.bidiSpans(i),r=s[Ct.find(s,e-i.from,-1,t)];return this.docView.coordsAt(e,t,r.dir==fe.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(iu)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>eg)return Yh(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||jh(r.isolates,i=Pl(this,e))))return r.order;i||(i=Pl(this,e));let s=Ep(e.text,t,i);return this.bidiCache.push(new Fs(e.from,e.to,t,i,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||R.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Bh(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,s,r,o;return Nn.of(new Ui(typeof e=="number"?A.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(s=t.x)!==null&&s!==void 0?s:"nearest",(r=t.yMargin)!==null&&r!==void 0?r:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Nn.of(new Ui(A.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return xe.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return xe.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ei.newName(),s=[ts.of(i),hn.of(Wo(`.${i}`,e))];return t&&t.dark&&s.push(Io.of(!0)),s}static baseTheme(e){return ri.lowest(hn.of(Wo("."+qo,e,Pu)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&Se.get(i)||Se.get(e);return((t=s?.root)===null||t===void 0?void 0:t.view)||null}}$.styleModule=hn;$.inputHandler=eu;$.clipboardInputFilter=ba;$.clipboardOutputFilter=Sa;$.scrollHandler=su;$.focusChangeEffect=tu;$.perLineTextDirection=iu;$.exceptionSink=Jh;$.updateListener=Fo;$.editable=Dt;$.mouseSelectionStyle=_h;$.dragMovesSelection=Gh;$.clickAddsSelectionRange=Hh;$.decorations=ur;$.blockWrappers=au;$.outerDecorations=va;$.atomicRanges=Dn;$.bidiIsolatedRanges=lu;$.cursorScrollMargin=K.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});$.scrollMargins=cu;$.darkTheme=Io;$.cspNonce=K.define({combine:n=>n.length?n[0]:""});$.contentAttributes=xa;$.editorAttributes=ou;$.lineWrapping=$.contentAttributes.of({class:"cm-lineWrapping"});$.announce=z.define();const eg=4096,Yl={};class Fs{constructor(e,t,i,s,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],s=e.length?e[e.length-1].dir:fe.LTR;for(let r=Math.max(0,e.length-10);r=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&Oa(o,t)}return t}const tg=R.mac?"mac":R.windows?"win":R.linux?"linux":"key";function ig(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let s,r,o,a;for(let l=0;li.concat(s),[]))),t}function sg(n,e,t){return Tu(Cu(n.state),e,n,t)}let Nt=null;const rg=4e3;function og(n,e=tg){let t=Object.create(null),i=Object.create(null),s=(o,a)=>{let l=i[o];if(l==null)i[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,a,l,c,h)=>{var u,f;let d=t[o]||(t[o]=Object.create(null)),p=a.split(/ (?!$)/).map(y=>ig(y,e));for(let y=1;y{let C=Nt={view:x,prefix:b,scope:o};return setTimeout(()=>{Nt==C&&(Nt=null)},rg),!0}]})}let m=p.join(" ");s(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((f=(u=d._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),h&&(g.stopPropagation=!0)};for(let o of n){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let h=t[c]||(t[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let f in h)h[f].run.push(d=>u(d,zo))}let l=o[e]||o.key;if(l)for(let c of a)r(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}let zo=null;function Tu(n,e,t,i){zo=e;let s=bp(e),r=Ne(s,0),o=Qt(r)==s.length&&s!=" ",a="",l=!1,c=!1,h=!1;Nt&&Nt.view==t&&Nt.scope==i&&(a=Nt.prefix+" ",Ou.indexOf(e.keyCode)<0&&(c=!0,Nt=null));let u=new Set,f=g=>{if(g){for(let y of g.run)if(!u.has(y)&&(u.add(y),y(t)))return g.stopPropagation&&(h=!0),!0;g.preventDefault&&(g.stopPropagation&&(h=!0),c=!0)}return!1},d=n[i],p,m;return d&&(f(d[a+is(s,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(R.windows&&e.ctrlKey&&e.altKey)&&!(R.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=ti[e.keyCode])&&p!=s?(f(d[a+is(p,e,!0)])||e.shiftKey&&(m=vn[e.keyCode])!=s&&m!=p&&f(d[a+is(m,e,!1)]))&&(l=!0):o&&e.shiftKey&&f(d[a+is(s,e,!0)])&&(l=!0),!l&&f(d._any)&&(l=!0)),c&&(l=!0),l&&h&&e.stopPropagation(),zo=null,l}class gi{constructor(e,t,i,s,r){this.className=e,this.left=t,this.top=i,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let s=e.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let r=Ru(e);return[new gi(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return ag(e,t,i)}}function Ru(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==fe.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Gl(n,e,t,i){let s=n.coordsAtPos(e,t*2);if(!s)return i;let r=n.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,a=n.posAtCoords({x:r.left+1,y:o}),l=n.posAtCoords({x:r.right-1,y:o});return a==null||l==null?i:{from:Math.max(i.from,Math.min(a,l)),to:Math.min(i.to,Math.max(a,l))}}function ag(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),s=Math.min(t.to,n.viewport.to),r=n.textDirection==fe.LTR,o=n.contentDOM,a=o.getBoundingClientRect(),l=Ru(n),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),f=a.right-(h?parseInt(h.paddingRight):0),d=Lo(n,i,1),p=Lo(n,s,-1),m=d.type==Le.Text?d:null,g=p.type==Le.Text?p:null;if(m&&(n.lineWrapping||d.widgetLineBreaks)&&(m=Gl(n,i,1,m)),g&&(n.lineWrapping||p.widgetLineBreaks)&&(g=Gl(n,s,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return b(x(t.from,t.to,m));{let k=m?x(t.from,null,m):C(d,!1),S=g?x(null,t.to,g):C(p,!0),w=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&k.bottom+n.defaultLineHeight/2M&&Q.from=P)break;ee>D&&E(Math.max(J,D),k==null&&J<=M,Math.min(ee,P),S==null&&ee>=Y,ae.dir)}if(D=j.to+1,D>=P)break}return V.length==0&&E(M,k==null,Y,S==null,n.textDirection),{top:U,bottom:F,horizontal:V}}function C(k,S){let w=a.top+(S?k.top:k.bottom);return{top:w,bottom:w,horizontal:[]}}}function lg(n,e){return n.constructor==e.constructor&&n.eq(e)}class cg{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(bs)!=e.state.facet(bs)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(bs);for(;t!lg(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[i].constructor&&s.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e,R.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const bs=K.define();function $u(n){return[xe.define(e=>new cg(e,n)),bs.of(n)]}const zi=K.define({combine(n){return yt(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function hg(n={}){return[zi.of(n),ug,fg,pg,nu.of(!0)]}function Ku(n){return n.startState.facet(zi)!=n.state.facet(zi)}const ug=$u({above:!0,markers(n){let{state:e}=n,t=e.facet(zi),i=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty||t.drawRangeCursor&&!(r&&R.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=s.empty?s:A.cursor(s.head,s.assoc);for(let l of gi.forRange(n,o,a))i.push(l)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Ku(n);return t&&_l(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){_l(e.state,n)},class:"cm-cursorLayer"});function _l(n,e){e.style.animationDuration=n.facet(zi).cursorBlinkRate+"ms"}const fg=$u({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let s of i)if(!s.empty)for(let r of gi.forRange(n,"cm-selectionBackground",s))e.push(r);if(R.ios&&!t.empty&&n.state.facet(zi).iosSelectionHandles){for(let s of gi.forRange(n,"cm-selectionHandle cm-selectionHandle-start",A.cursor(t.from,1)))e.push(s);for(let s of gi.forRange(n,"cm-selectionHandle cm-selectionHandle-end",A.cursor(t.to,1)))e.push(s)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Ku(n)},class:"cm-selectionLayer"}),dg=R.gecko&&R.gecko_version==153?"#ffffff01":"transparent",pg=ri.highest($.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${dg} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Zu=z.define({map(n,e){return n==null?null:e.mapPos(n)}}),fn=Te.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Zu)?i.value:t,n)}}),mg=xe.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(fn);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(fn)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(fn),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(fn)!=n&&this.view.dispatch({effects:Zu.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function gg(){return[fn,mg]}function Jl(n,e,t,i,s){e.lastIndex=0;for(let r=n.iterRange(t,i),o=t,a;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;a=e.exec(r.value);)s(o+a.index,a)}function Og(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:s,to:r}of t)s=Math.max(n.state.doc.lineAt(s).from,s-e),r=Math.min(n.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}class yg{constructor(e){const{regexp:t,decoration:i,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(a,l,c,h)=>s(h,c,c+a[0].length,a,l);else if(typeof i=="function")this.addMatch=(a,l,c,h)=>{let u=i(a,l,c);u&&h(c,c+a[0].length,u)};else if(i)this.addMatch=(a,l,c,h)=>h(c,c+a[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Bt,i=t.add.bind(t);for(let{from:s,to:r}of Og(e,this.maxLength))Jl(e.state.doc,this.regexp,s,r,(o,a)=>this.addMatch(a,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,a,l)=>{l>=e.view.viewport.from&&a<=e.view.viewport.to&&(i=Math.min(a,i),s=Math.max(l,s))}),e.viewportMoved||s-i>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let o=Math.max(r.from,i),a=Math.min(r.to,s);if(a>=o){let l=e.state.doc.lineAt(o),c=l.tol.from;o--)if(this.boundary.test(l.text[o-1-l.from])){h=o;break}for(;af.push(y.range(m,g));if(l==c)for(this.regexp.lastIndex=h-l.from;(d=this.regexp.exec(l.text))&&d.indexthis.addMatch(g,e,m,p));t=t.update({filterFrom:h,filterTo:u,filter:(m,g)=>mu,add:f})}}return t}}const Vo=/x/.unicode!=null?"gu":"g",Ag=new RegExp(`[\0-\b +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Vo),bg={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Xr=null;function Sg(){var n;if(Xr==null&&typeof document<"u"&&document.body){let e=document.body.style;Xr=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Xr||!1}const Ss=K.define({combine(n){let e=yt(n,{render:null,specialChars:Ag,addSpecialChars:null});return(e.replaceTabs=!Sg())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Vo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Vo)),e}});function xg(n={}){return[Ss.of(n),vg()]}let ec=null;function vg(){return ec||(ec=xe.fromClass(class{constructor(n){this.view=n,this.decorations=B.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Ss)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new yg({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=Ne(e[0],0);if(r==9){let o=s.lineAt(i),a=t.state.tabSize,l=_i(o.text,a,i-o.from);return B.replace({widget:new Pg((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=B.replace({widget:new Qg(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Ss);n.startState.facet(Ss)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const wg="•";function kg(n){return n>=32?wg:n==10?"␤":String.fromCharCode(9216+n)}class Qg extends Ut{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=kg(this.code),i=e.state.phrase("Control character")+" "+(bg[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class Pg extends Ut{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function Cg(){return Rg}const Tg=B.line({class:"cm-activeLine"}),Rg=xe.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let s=n.lineBlockAt(i.head);s.from>e&&(t.push(Tg.range(s.from)),e=s.from)}return B.set(t)}},{decorations:n=>n.decorations}),jo=2e3;function $g(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>jo||t.off>jo||e.col<0||t.col<0){let o=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let l=i;l<=s;l++){let c=n.doc.line(l);c.length<=a&&r.push(A.range(c.from+o,c.to+a))}}else{let o=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let l=i;l<=s;l++){let c=n.doc.line(l),h=Qo(c.text,o,n.tabSize,!0);if(h<0)r.push(A.cursor(c.to));else{let u=Qo(c.text,a,n.tabSize);r.push(A.range(c.from+h,c.from+u))}}}return r}function Kg(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function tc(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>jo?-1:s==i.length?Kg(n,e.clientX):_i(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function Zg(n,e){let t=tc(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let a=tc(n,s);if(!a)return i;let l=$g(n.state,t,a);return l.length?o?A.create(l.concat(i.ranges)):A.create(l):i}}:null}function Mg(n){let e=(t=>t.altKey&&t.button==0);return $.mouseSelectionStyle.of((t,i)=>e(i)?Zg(t,i):null)}const Eg={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},Ug={style:"cursor: crosshair"};function Fg(n={}){let[e,t]=Eg[n.key||"Alt"],i=xe.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,$.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?Ug:null})]}const ns="-10000px";class Mu{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let s=e.state.facet(this.facet),r=s.filter(l=>l);if(s===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=t?[]:null;for(let l=0;lt[c]=l),t.length=a.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function Dg(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Br=K.define({combine:n=>{var e,t,i;return{position:R.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Dg}}}),ic=new WeakMap,Ca=xe.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Br);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Mu(n,gr,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Br);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=ns,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(R.safari){let o=r.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(n=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=wa(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Br).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:i,scaleX:s,scaleY:r}=n,o=[];for(let a=0;a=Math.min(t.bottom,i.bottom)||u.rightMath.min(t.right,i.right)+.1)){h.style.top=ns;continue}let d=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=f.right-f.left,g=(e=ic.get(c))!==null&&e!==void 0?e:f.bottom-f.top,y=c.offset||Xg,b=this.view.textDirection==fe.LTR,x=f.width>i.right-i.left?b?i.left:i.right-f.width:b?Math.max(i.left,Math.min(u.left-(d?14:0)+y.x,i.right-m)):Math.min(Math.max(i.left,u.left-m+(d?14:0)-y.x),i.right-m),C=this.above[a];!l.strictSide&&(C?u.top-g-p-y.yi.bottom)&&C==i.bottom-u.bottom>u.top-i.top&&(C=this.above[a]=!C);let k=(C?u.top-i.top:i.bottom-u.bottom)-p;if(kx&&U.topS&&(S=C?U.top-g-2-p:U.bottom+p+2);if(this.position=="absolute"?(h.style.top=(S-n.parent.top)/r+"px",nc(h,(x-n.parent.left)/s)):(h.style.top=S/r+"px",nc(h,x/s)),d){let U=u.left+(b?y.x:-y.x)-(x+14-7);d.style.left=U/s+"px"}c.overlap!==!0&&o.push({left:x,top:S,right:w,bottom:S+g}),h.classList.toggle("cm-tooltip-above",C),h.classList.toggle("cm-tooltip-below",!C),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=ns}},{eventObservers:{scroll(){this.maybeMeasure()}}});function nc(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const Lg=$.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Xg={x:0,y:0},gr=K.define({enables:[Ca,Lg]}),Ds=K.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class Or{static create(e){return new Or(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Mu(e,Ds,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let s=i[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Bg=gr.compute([Ds],n=>{let e=n.facet(Ds);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Or.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Ig=K.define();class qg{constructor(e,t,i,s,r,o){this.view=e,this.source=t,this.field=i,this.locked=s,this.setHover=r,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||t.xo.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(s)).find(c=>c.from<=s&&c.to>=s),l=a&&a.dir==fe.RTL?-1:1;r=t.x{if(a&&!(Array.isArray(a)&&!a.length)){let l=Array.isArray(a)?a:[a];s&&this.locked.set(l,s),e.dispatch({effects:this.setHover.of(l)})}};if(r&&"then"in r){let a=this.pending={pos:t};r.then(l=>{this.pending==a&&(this.pending=null,o(l))},l=>ze(e.state,l,"hover tooltip"))}else o(r)}get tooltip(){let e=this.view.plugin(Ca),t=e?e.manager.tooltips.findIndex(i=>i.create==Or.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&!this.locked.has(s)&&r&&!Wg(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,a=(i=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!zg(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:s}=this;s.length&&!this.locked.has(s)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ss=4;function Wg(n,e){let{left:t,right:i,top:s,bottom:r}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();s=Math.min(a.top,s),r=Math.max(a.bottom,r)}return e.clientX>=t-ss&&e.clientX<=i+ss&&e.clientY>=s-ss&&e.clientY<=r+ss}function zg(n,e,t,i,s,r){let o=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.rights||Math.min(o.bottom,a)=e&&l<=t}function Eu(n,e={}){let t=z.define(),i=new WeakMap,s=Te.define({create(){return[]},update(o,a){let l=i.get(o);if(o.length&&(e.hideOnChange&&(a.docChanged||a.selection)?o=[]:l&&l(a)?o=[]:e.hideOn&&(o=o.filter(c=>!e.hideOn(a,c)))),a.docChanged&&o.length){let c=[];for(let h of o){let u=a.changes.mapPos(h.pos,-1,De.TrackDel);if(u!=null){let f=Object.assign(Object.create(null),h);f.pos=u,f.end!=null&&(f.end=a.changes.mapPos(f.end)),c.push(f)}}o=c}for(let c of a.effects)c.is(t)&&(o=c.value,l=void 0),(c.is(Vg)&&!c.value||c.value==s)&&(o=[]);return o.length&&l&&i.set(o,l),o},provide:o=>Ds.from(o)});const r=xe.define(o=>new qg(o,n,s,i,t,e.hoverTime||300));return{active:s,extension:[s,r,Ig.of(r),Bg]}}function Uu(n,e){let t=n.plugin(Ca);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const Vg=z.define(),sc=K.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Fu(n,e){let t=n.plugin(Du),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Du=xe.fromClass(class{constructor(n){this.input=n.state.facet(Vi),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(sc);this.top=new rs(n,!0,e.topContainer),this.bottom=new rs(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(sc);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new rs(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new rs(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Vi);if(t!=this.input){let i=t.filter(l=>l),s=[],r=[],o=[],a=[];for(let l of i){let c=this.specs.indexOf(l),h;c<0?(h=l(n.view),a.push(h)):(h=this.panels[c],h.update&&h.update(n)),s.push(h),(h.top?r:o).push(h)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>$.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class rs{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=rc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=rc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function rc(n){let e=n.nextSibling;return n.remove(),e}const Vi=K.define({enables:Du});function jg(n,e){let t,i=new Promise(o=>t=o),s=o=>Yg(o,e,t);n.state.field(Ir,!1)?n.dispatch({effects:Lu.of(s)}):n.dispatch({effects:z.appendConfig.of(Ir.init(()=>[s]))});let r=Xu.of(s);return{close:r,result:i.then(o=>((n.win.queueMicrotask||(l=>n.win.setTimeout(l,10)))(()=>{n.state.field(Ir).indexOf(s)>-1&&n.dispatch({effects:r})}),o))}}const Ir=Te.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(Lu)?n=[t.value].concat(n):t.is(Xu)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>Vi.computeN([n],e=>e.field(n))}),Lu=z.define(),Xu=z.define();function Yg(n,e,t){let i=e.content?e.content(n,()=>o(null)):null;if(!i){if(i=he("form"),e.input){let a=he("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),i.appendChild(he("label",(e.label||"")+": ",a))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(he("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let s=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let a=0;a{c.keyCode==27?(c.preventDefault(),o(null)):c.keyCode==13&&(c.preventDefault(),o(l))}),l.addEventListener("submit",c=>{c.preventDefault(),o(l)})}let r=he("div",i,he("button",{onclick:()=>o(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function o(a){r.contains(r.ownerDocument.activeElement)&&n.focus(),t(a)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let a;typeof e.focus=="string"?a=i.querySelector(e.focus):a=i.querySelector("input")||i.querySelector("button"),a&&"select"in a?a.select():a&&"focus"in a&&a.focus()}}}}class Mt extends Jt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Mt.prototype.elementClass="";Mt.prototype.toDOM=void 0;Mt.prototype.mapMode=De.TrackBefore;Mt.prototype.startSide=Mt.prototype.endSide=-1;Mt.prototype.point=!0;const xs=K.define(),Ng=K.define(),Hg={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>N.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},An=K.define();function Bu(n){return[Iu(),An.of({...Hg,...n})]}const oc=K.define({combine:n=>n.some(e=>e)});function Iu(n){return[Gg]}const Gg=xe.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(An).map(e=>new lc(n,e)),this.fixed=!n.state.facet(oc);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(oc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=N.iter(this.view.state.facet(xs),this.view.viewport.from),i=[],s=this.gutters.map(r=>new _g(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let a of r.type)if(a.type==Le.Text&&o){Yo(t,i,a.from);for(let l of s)l.line(this.view,a,i);o=!1}else if(a.widget)for(let l of s)l.widget(this.view,a)}else if(r.type==Le.Text){Yo(t,i,r.from);for(let o of s)o.line(this.view,r,i)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(An),t=n.state.facet(An),i=n.docChanged||n.heightChanged||n.viewportChanged||!N.eq(n.startState.facet(xs),n.state.facet(xs),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new lc(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>$.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==fe.LTR?{left:i,right:s}:{right:i,left:s}})});function ac(n){return Array.isArray(n)?n:[n]}function Yo(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class _g{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=N.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let a=new qu(e,o,r,i);s.elements.push(a),s.dom.appendChild(a.dom)}else s.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];Yo(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),s=i?[i]:null;for(let r of e.state.facet(Ng)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class lc{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let l=r.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=s.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,a,s)&&s.preventDefault()});this.markers=ac(t.markers(e)),t.initialSpacer&&(this.spacer=new qu(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=ac(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!N.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class qu{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Jg(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let a=o,l=rr(a,l,c)||o(a,l,c):o}return i}})}});class qr extends Mt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Wr(n,e){return n.state.facet(Ri).formatNumber(e,n.state)}const iO=An.compute([Ri],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(eO)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new qr(Wr(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let s of e.state.facet(tO)){let r=s(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Ri)!=e.state.facet(Ri),initialSpacer(e){return new qr(Wr(e,cc(e.state.doc.lines)))},updateSpacer(e,t){let i=Wr(t.view,cc(t.view.state.doc.lines));return i==e.number?e:new qr(i)},domEventHandlers:n.facet(Ri).domEventHandlers,side:"before"}));function nO(n={}){return[Ri.of(n),Iu(),iO]}function cc(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head).from;s>t&&(t=s,e.push(sO.range(s)))}return N.of(e)});function oO(){return rO}const Wu=1024;let aO=0;class zr{constructor(e,t){this.from=e,this.to=t}}class G{constructor(e={}){this.id=aO++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=et.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}G.closedBy=new G({deserialize:n=>n.split(" ")});G.openedBy=new G({deserialize:n=>n.split(" ")});G.group=new G({deserialize:n=>n.split(" ")});G.isolate=new G({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});G.contextHash=new G({perNode:!0});G.lookAhead=new G({perNode:!0});G.mounted=new G({perNode:!0});class bn{constructor(e,t,i,s=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=s}static get(e){return e&&e.props&&e.props[G.mounted.id]}}const lO=Object.create(null);class et{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):lO,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new et(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(G.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(G.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?i.name:s[r]];if(o)return o}}}}et.none=new et("",Object.create(null),0,8);class Ta{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|be.IncludeAnonymous);;){let c=!1;if(l.from<=r&&l.to>=s&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&i&&(a||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ka(et.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new ke(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new ke(et.none,t,i,s)))}static build(e){return fO(e)}}ke.empty=new ke(et.none,[],[],0);class Ra{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Ra(this.buffer,this.index)}}class ni{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return et.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,i){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Pn(n,e,t,i){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?a.length:-1;e!=c;e+=t){let h=a[e],u=l[e]+o.from,f;if(!(!(r&be.EnterBracketed&&h instanceof ke&&(f=bn.get(h))&&!f.overlay&&f.bracketed&&i>=u&&i<=u+h.length)&&!zu(s,i,u,u+h.length))){if(h instanceof ni){if(r&be.ExcludeBuffers)continue;let d=h.findChild(0,h.buffer.length,t,i-u,s);if(d>-1)return new Tt(new cO(o,h,e,u),null,d)}else if(r&be.IncludeAnonymous||!h.type.isAnonymous||$a(h)){let d;if(!(r&be.IgnoreMounts)&&(d=bn.get(h))&&!d.overlay)return new Je(d.tree,u,e,o);let p=new Je(h,u,e,o);return r&be.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?h.children.length-1:0,t,i,s,r)}}}if(r&be.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let s;if(!(i&be.IgnoreOverlays)&&(s=bn.get(this._tree))&&s.overlay){let r=e-this.from,o=i&be.EnterBracketed&&s.bracketed;for(let{from:a,to:l}of s.overlay)if((t>0||o?a<=r:a=r:l>r))return new Je(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function uc(n,e,t,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function No(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class cO{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class Tt extends Vu{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new Tt(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&be.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Tt(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Tt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Tt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];e.push(i.slice(s,r,o)),t.push(0)}return new ke(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function ju(n){if(!n.length)return null;let e=0,t=n[0];for(let r=1;rt.from||o.to=e){let a=new Je(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[i])).push(Pn(a,e,t,!1))}}return s?ju(s):i}class Ho{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~be.EnterBracketed,e instanceof Je)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof Je?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&be.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&be.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&be.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let a=i._tree.children[r];if(this.mode&be.IncludeAnonymous||a instanceof ni||!a.type.isAnonymous||$a(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,i=r+1;break e}s=this.stack[--r]}for(let s=i;s=0;r--){if(r<0)return No(this._tree,e,s);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function $a(n){return n.children.some(e=>e instanceof ni||!e.type.isAnonymous||$a(e))}function fO(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=Wu,reused:r=[],minRepeatType:o=i.types.length}=n,a=Array.isArray(t)?new Ra(t,t.length):t,l=i.types,c=0,h=0;function u(k,S,w,U,F,V){let{id:E,start:M,end:Y,size:Q}=a,D=h,P=c;if(Q<0)if(a.next(),Q==-1){let I=r[E];w.push(I),U.push(M-k);return}else if(Q==-3){c=E;return}else if(Q==-4){h=E;return}else throw new RangeError(`Unrecognized record size: ${Q}`);let j=l[E],ae,J,ee=M-k;if(Y-M<=s&&(J=g(a.pos-S,F))){let I=new Uint16Array(J.size-J.skip),H=a.pos-J.size,ce=I.length;for(;a.pos>H;)ce=y(J.start,I,ce);ae=new ni(I,Y-J.start,i),ee=J.start-k}else{let I=a.pos-Q;a.next();let H=[],ce=[],q=E>=o?E:-1,te=0,re=Y;for(;a.pos>I;)q>=0&&a.id==q&&a.size>=0?(a.end<=re-s&&(p(H,ce,M,te,a.end,re,q,D,P),te=H.length,re=a.end),a.next()):V>2500?f(M,I,H,ce):u(M,I,H,ce,q,V+1);if(q>=0&&te>0&&te-1&&te>0){let Me=d(j,P);ae=Ka(j,H,ce,0,H.length,0,Y-M,Me,Me)}else ae=m(j,H,ce,Y-M,D-Y,P)}w.push(ae),U.push(ee)}function f(k,S,w,U){let F=[],V=0,E=-1;for(;a.pos>S;){let{id:M,start:Y,end:Q,size:D}=a;if(D>4)a.next();else{if(E>-1&&Y=0;Q-=3)M[D++]=F[Q],M[D++]=F[Q+1]-Y,M[D++]=F[Q+2]-Y,M[D++]=D;w.push(new ni(M,F[2]-Y,i)),U.push(Y-k)}}function d(k,S){return(w,U,F)=>{let V=0,E=w.length-1,M,Y;if(E>=0&&(M=w[E])instanceof ke){if(!E&&M.type==k&&M.length==F)return M;(Y=M.prop(G.lookAhead))&&(V=U[E]+M.length+Y)}return m(k,w,U,F,V,S)}}function p(k,S,w,U,F,V,E,M,Y){let Q=[],D=[];for(;k.length>U;)Q.push(k.pop()),D.push(S.pop()+w-F);k.push(m(i.types[E],Q,D,V-F,M-V,Y)),S.push(F-w)}function m(k,S,w,U,F,V,E){if(V){let M=[G.contextHash,V];E=E?[M].concat(E):[M]}if(F>25){let M=[G.lookAhead,F];E=E?[M].concat(E):[M]}return new ke(k,S,w,U,E)}function g(k,S){let w=a.fork(),U=0,F=0,V=0,E=w.end-s,M={size:0,start:0,skip:0};e:for(let Y=w.pos-k;w.pos>Y;){let Q=w.size;if(w.id==S&&Q>=0){M.size=U,M.start=F,M.skip=V,V+=4,U+=4,w.next();continue}let D=w.pos-Q;if(Q<0||D=o?4:0,j=w.start;for(w.next();w.pos>D;){if(w.size<0)if(w.size==-3||w.size==-4)P+=4;else break e;else w.id>=o&&(P+=4);w.next()}F=j,U+=Q,V+=P}return(S<0||U==k)&&(M.size=U,M.start=F,M.skip=V),M.size>4?M:void 0}function y(k,S,w){let{id:U,start:F,end:V,size:E}=a;if(a.next(),E>=0&&U4){let Y=a.pos-(E-4);for(;a.pos>Y;)w=y(k,S,w)}S[--w]=M,S[--w]=V-k,S[--w]=F-k,S[--w]=U}else E==-3?c=U:E==-4&&(h=U);return w}let b=[],x=[];for(;a.pos>0;)u(n.start||0,n.bufferStart||0,b,x,-1,0);let C=(e=n.length)!==null&&e!==void 0?e:b.length?x[0]+b[0].length:0;return new ke(l[n.topID],b.reverse(),x.reverse(),C)}const fc=new WeakMap;function vs(n,e){if(!n.isAnonymous||e instanceof ni||e.type!=n)return 1;let t=fc.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof ke)){t=1;break}t+=vs(n,i)}fc.set(e,t)}return t}function Ka(n,e,t,i,s,r,o,a,l){let c=0;for(let p=i;p=h)break;S+=w}if(x==C+1){if(S>h){let w=p[C];d(w.children,w.positions,0,w.children.length,m[C]+b);continue}u.push(p[C])}else{let w=m[x-1]+p[x-1].length-k;u.push(Ka(n,p,m,C,x,k,w,null,l))}f.push(k+b-r)}}return d(e,t,i,s,0),(a||l)(u,f,o)}class dO{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Tt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Je&&this.map.set(e.tree,t)}get(e){return e instanceof Tt?this.getBuffer(e.context.buffer,e.index):e instanceof Je?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Oi{constructor(e,t,i,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let s=[new Oi(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let h=a=i)for(;o&&o.from=f.from||u<=f.to||c){let d=Math.max(f.from,l)-c,p=Math.min(f.to,u)-c;f=d>=p?null:new Oi(d,p,f.tree,f.offset+c,a>0,!!h)}if(f&&s.push(f),o.to>u)break;o=rnew zr(s.from,s.to)):[new zr(0,0)]:[new zr(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let r=s.advance();if(r)return r}}}class pO{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new G({perNode:!0});let mO=0;class lt{constructor(e,t,i,s){this.name=e,this.set=t,this.base=i,this.modified=s,this.id=mO++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof lt&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let s=new lt(i,[],null,[]);if(s.set.push(s),t)for(let r of t.set)s.set.push(r);return s}static defineModifier(e){let t=new Ls(e);return i=>i.modified.indexOf(t)>-1?i:Ls.get(i.base||i,i.modified.concat(t).sort((s,r)=>s.id-r.id))}}let gO=0;class Ls{constructor(e){this.name=e,this.instances=[],this.id=gO++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&OO(t,a.modified));if(i)return i;let s=[],r=new lt(e.name,s,e,t);for(let a of t)a.instances.push(r);let o=yO(t);for(let a of e.set)if(!a.modified.length)for(let l of o)s.push(Ls.get(a,l));return r}}function OO(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function yO(n){let e=[[]];for(let t=0;ti.length-t.length)}function Nu(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let r=[],o=2,a=s;for(let u=0;;){if(a=="..."&&u>0&&u+3==s.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+s);if(r.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==s.length)break;let d=s[u++];if(u==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);a=s.slice(u)}let l=r.length-1,c=r[l];if(!c)throw new RangeError("Invalid path: "+s);let h=new Cn(i,o,l>0?r.slice(0,l):null);e[c]=h.sort(e[c])}}return Hu.add(e)}const Hu=new G({combine(n,e){let t,i,s;for(;n||e;){if(!n||e&&n.depth>=e.depth?(s=e,e=e.next):(s=n,n=n.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let r=new Cn(s.tags,s.mode,s.context);t?t.next=r:i=r,t=r}return i}});class Cn{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=s;for(let a of r)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:i}}function AO(n,e){let t=null;for(let i of n){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function bO(n,e,t,i=0,s=n.length){let r=new SO(i,Array.isArray(e)?e:[e],t);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class SO{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,s,r){let{type:o,from:a,to:l}=e;if(a>=i||l<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=s,h=xO(e)||Cn.empty,u=AO(r,h.tags);if(u&&(c&&(c+=" "),c+=u,h.mode==1&&(s+=(s?" ":"")+u)),this.startSpan(Math.max(t,a),c),h.opaque)return;let f=e.tree&&e.tree.prop(G.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+a,1),p=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),m=e.firstChild();for(let g=0,y=a;;g++){let b=g=x||!e.nextSibling())););if(!b||x>i)break;y=b.to+a,y>t&&(this.highlightRange(d.cursor(),Math.max(t,b.from+a),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),c))}m&&e.parent()}else if(e.firstChild()){f&&(s="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}}function xO(n){let e=n.type.prop(Hu);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const T=lt.define,as=T(),Vt=T(),dc=T(Vt),pc=T(Vt),jt=T(),ls=T(jt),Vr=T(jt),wt=T(),li=T(wt),xt=T(),vt=T(),Go=T(),on=T(Go),cs=T(),O={comment:as,lineComment:T(as),blockComment:T(as),docComment:T(as),name:Vt,variableName:T(Vt),typeName:dc,tagName:T(dc),propertyName:pc,attributeName:T(pc),className:T(Vt),labelName:T(Vt),namespace:T(Vt),macroName:T(Vt),literal:jt,string:ls,docString:T(ls),character:T(ls),attributeValue:T(ls),number:Vr,integer:T(Vr),float:T(Vr),bool:T(jt),regexp:T(jt),escape:T(jt),color:T(jt),url:T(jt),keyword:xt,self:T(xt),null:T(xt),atom:T(xt),unit:T(xt),modifier:T(xt),operatorKeyword:T(xt),controlKeyword:T(xt),definitionKeyword:T(xt),moduleKeyword:T(xt),operator:vt,derefOperator:T(vt),arithmeticOperator:T(vt),logicOperator:T(vt),bitwiseOperator:T(vt),compareOperator:T(vt),updateOperator:T(vt),definitionOperator:T(vt),typeOperator:T(vt),controlOperator:T(vt),punctuation:Go,separator:T(Go),bracket:on,angleBracket:T(on),squareBracket:T(on),paren:T(on),brace:T(on),content:wt,heading:li,heading1:T(li),heading2:T(li),heading3:T(li),heading4:T(li),heading5:T(li),heading6:T(li),contentSeparator:T(wt),list:T(wt),quote:T(wt),emphasis:T(wt),strong:T(wt),link:T(wt),monospace:T(wt),strikethrough:T(wt),inserted:T(),deleted:T(),changed:T(),invalid:T(),meta:cs,documentMeta:T(cs),annotation:T(cs),processingInstruction:T(cs),definition:lt.defineModifier("definition"),constant:lt.defineModifier("constant"),function:lt.defineModifier("function"),standard:lt.defineModifier("standard"),local:lt.defineModifier("local"),special:lt.defineModifier("special")};for(let n in O){let e=O[n];e instanceof lt&&(e.name=n)}Gu([{tag:O.link,class:"tok-link"},{tag:O.heading,class:"tok-heading"},{tag:O.emphasis,class:"tok-emphasis"},{tag:O.strong,class:"tok-strong"},{tag:O.keyword,class:"tok-keyword"},{tag:O.atom,class:"tok-atom"},{tag:O.bool,class:"tok-bool"},{tag:O.url,class:"tok-url"},{tag:O.labelName,class:"tok-labelName"},{tag:O.inserted,class:"tok-inserted"},{tag:O.deleted,class:"tok-deleted"},{tag:O.literal,class:"tok-literal"},{tag:O.string,class:"tok-string"},{tag:O.number,class:"tok-number"},{tag:[O.regexp,O.escape,O.special(O.string)],class:"tok-string2"},{tag:O.variableName,class:"tok-variableName"},{tag:O.local(O.variableName),class:"tok-variableName tok-local"},{tag:O.definition(O.variableName),class:"tok-variableName tok-definition"},{tag:O.special(O.variableName),class:"tok-variableName2"},{tag:O.definition(O.propertyName),class:"tok-propertyName tok-definition"},{tag:O.typeName,class:"tok-typeName"},{tag:O.namespace,class:"tok-namespace"},{tag:O.className,class:"tok-className"},{tag:O.macroName,class:"tok-macroName"},{tag:O.propertyName,class:"tok-propertyName"},{tag:O.operator,class:"tok-operator"},{tag:O.comment,class:"tok-comment"},{tag:O.meta,class:"tok-meta"},{tag:O.invalid,class:"tok-invalid"},{tag:O.punctuation,class:"tok-punctuation"}]);var jr;const $i=new G;function _u(n){return K.define({combine:n?e=>e.concat(n):void 0})}const Za=new G;class mt{constructor(e,t,i=[],s=""){this.data=e,this.name=s,_.prototype.hasOwnProperty("tree")||Object.defineProperty(_.prototype,"tree",{get(){return Ce(this)}}),this.parser=t,this.extension=[si.of(this),_.languageData.of((r,o,a)=>{let l=mc(r,o,a),c=l.type.prop($i);if(!c)return[];let h=r.facet(c),u=l.type.prop(Za);if(u){let f=l.resolve(o-l.from,a);for(let d of u)if(d.test(f,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(h)}}return h})].concat(i)}isActiveAt(e,t,i=-1){return mc(e,t,i).type.prop($i)==this.data}findRegions(e){let t=e.facet(si);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop($i)==this.data){i.push({from:o,to:o+r.length});return}let a=r.prop(G.mounted);if(a){if(a.tree.prop($i)==this.data){if(a.overlay)for(let l of a.overlay)i.push({from:l.from+o,to:l.to+o});else i.push({from:o,to:o+r.length});return}else if(a.overlay){let l=i.length;if(s(a.tree,a.overlay[0].from+o),i.length>l)return}}for(let l=0;li.isTop?t:void 0)]}),e.name)}configure(e,t){return new Xs(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ce(n){let e=n.field(mt.state,!1);return e?e.tree:ke.empty}class vO{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let an=null;class Bs{constructor(e,t,i=[],s,r,o,a,l){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Bs(e,t,[],ke.empty,0,i,[],null)}startParse(){return this.parser.startParse(new vO(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ke.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Oi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=an;an=this;try{return e()}finally{an=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=gc(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,h,u,f)=>l.push({fromA:c,toA:h,fromB:u,toB:f})),i=Oi.applyChanges(i,l),s=ke.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let h=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);he.from&&(this.fragments=gc(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Yu{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let l=an;if(l){for(let c of s)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new ke(et.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return an}}function gc(n,e,t){return Oi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class ji{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new ji(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Bs.create(e.facet(si).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ji(i)}}mt.state=Te.define({create:ji.init,update(n,e){for(let t of e.effects)if(t.is(mt.setState))return t.value;return e.startState.facet(si)!=e.state.facet(si)?ji.init(e.state):n.apply(e)}});let Ju=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Ju=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Yr=typeof navigator<"u"&&(!((jr=navigator.scheduling)===null||jr===void 0)&&jr.isInputPending)?()=>navigator.scheduling.isInputPending():null,wO=xe.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(mt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(mt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Ju(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnds+1e3,l=r.context.work(()=>Yr&&Yr()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:mt.setState.of(new ji(r.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ze(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),si=K.define({combine(n){return n.length?n[0]:null},enables:n=>[mt.state,wO,$.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class kO{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const QO=K.define(),yr=K.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Is(n){let e=n.facet(yr);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Tn(n,e){let t="",i=n.tabSize,s=n.facet(yr)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r=e?PO(n,t,e):null}class Ar{constructor(e,t={}){this.state=e,this.options=t,this.unit=Is(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return _i(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ef=new G;function PO(n,e,t){let i=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=i.node){let r=[];for(let o=s;o&&!(o.fromi.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return tf(i,n,t)}function tf(n,e,t){for(let i=n;i;i=i.next){let s=TO(i.node);if(s)return s(Ea.create(e,t,i))}return 0}function CO(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function TO(n){let e=n.type.prop(ef);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(G.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>nf(o,!0,1,void 0,r&&!CO(o)?s.from:void 0)}return n.parent==null?RO:null}function RO(){return 0}class Ea extends Ar{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Ea(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if($O(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return tf(this.context.next,this.base,this.pos)}}function $O(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function KO(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==i)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function ZO({closing:n,align:e=!0,units:t=1}){return i=>nf(i,e,t,n)}function nf(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,a=i&&r.slice(o,o+i.length)==i||s==n.pos+o,l=e?KO(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}const MO=n=>n.baseIndent;function Nr({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const EO=200;function UO(){return _.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+EO)return n;let r=t.sliceString(s.from,i);if(!e.some(c=>c.test(r)))return n;let{state:o}=n,a=-1,l=[];for(let{head:c}of o.selection.ranges){let h=o.doc.lineAt(c);if(h.from==a)continue;a=h.from;let u=Ma(o,h.from);if(u==null)continue;let f=/^\s*/.exec(h.text)[0],d=Tn(o,u);f!=d&&l.push({from:h.from,to:h.from+f.length,insert:d})}return l.length?[n,{changes:l,sequential:!0}]:n})}const FO=K.define(),sf=new G;function DO(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(r&&a.from=e&&c.to>t&&(r=c)}}return r}function XO(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function qs(n,e,t){for(let i of n.facet(FO)){let s=i(n,e,t);if(s)return s}return LO(n,e,t)}function rf(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const br=z.define({map:rf}),Ln=z.define({map:rf});function of(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const xi=Te.define({create(){return B.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,s)=>n=Oc(n,i,s)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(br)&&!BO(n,i.value.from,i.value.to)?t.push(i.value):i.is(Ln)&&(n=n.update({filter:(s,r)=>i.value.from!=s||i.value.to!=r,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(cf),s=t.map(r=>(i?B.replace({widget:new YO(i(e.state,r))}):yc).range(r.from,r.to));n=n.update({add:s})}return e.selection&&(n=Oc(n,e.selection.main.head)),n},provide:n=>$.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{se&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(s,r)=>s>=t||r<=e}):n}function Ws(n,e,t){var i;let s=null;return(i=n.field(xi,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function BO(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function af(n,e){return n.field(xi,!1)?e:e.concat(z.appendConfig.of(hf()))}const IO=n=>{for(let e of of(n)){let t=qs(n.state,e.from,e.to);if(t)return n.dispatch({effects:af(n.state,[br.of(t),lf(n,t)])}),!0}return!1},qO=n=>{if(!n.state.field(xi,!1))return!1;let e=[];for(let t of of(n)){let i=Ws(n.state,t.from,t.to);i&&e.push(Ln.of(i),lf(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function lf(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return $.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const WO=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(xi,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(Ln.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},VO=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:IO},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:qO},{key:"Ctrl-Alt-[",run:WO},{key:"Ctrl-Alt-]",run:zO}],jO={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},cf=K.define({combine(n){return yt(n,jO)}});function hf(n){return[xi,GO]}function uf(n,e){let{state:t}=n,i=t.facet(cf),s=o=>{let a=n.lineBlockAt(n.posAtDOM(o.target)),l=Ws(n.state,a.from,a.to);l&&n.dispatch({effects:Ln.of(l)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,s,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const yc=B.replace({widget:new class extends Ut{toDOM(n){return uf(n,null)}}});class YO extends Ut{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return uf(e,this.value)}}const NO={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Hr extends Mt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function HO(n={}){let e={...NO,...n},t=new Hr(e,!0),i=new Hr(e,!1),s=xe.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(si)!=o.state.facet(si)||o.startState.field(xi,!1)!=o.state.field(xi,!1)||Ce(o.startState)!=Ce(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new Bt;for(let l of o.viewportLineBlocks){let c=Ws(o.state,l.from,l.to)?i:qs(o.state,l.from,l.to)?t:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:r}=e;return[s,Bu({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(s))===null||a===void 0?void 0:a.markers)||N.empty},initialSpacer(){return new Hr(e,!1)},domEventHandlers:{...r,click:(o,a,l)=>{if(r.click&&r.click(o,a,l))return!0;let c=Ws(o.state,a.from,a.to);if(c)return o.dispatch({effects:Ln.of(c)}),!0;let h=qs(o.state,a.from,a.to);return h?(o.dispatch({effects:br.of(h)}),!0):!1}}}),hf()]}const GO=$.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Xn{constructor(e,t){this.specs=e;let i;function s(a){let l=ei.newName();return(i||(i=Object.create(null)))["."+l]=a,l}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof mt?a=>a.prop($i)==o.data:o?a=>a==o:void 0,this.style=Gu(e.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:r}).style,this.module=i?new ei(i):null,this.themeType=t.themeType}static define(e,t){return new Xn(e,t||{})}}const _o=K.define(),_O=K.define({combine(n){return n.length?[n[0]]:null}});function Gr(n){let e=n.facet(_o);return e.length?e:n.facet(_O)}function JO(n,e){let t=[t0],i;return n instanceof Xn&&(n.module&&t.push($.styleModule.of(n.module)),i=n.themeType),i?t.push(_o.computeN([$.darkTheme],s=>s.facet($.darkTheme)==(i=="dark")?[n]:[])):t.push(_o.of(n)),t}class e0{constructor(e){this.markCache=Object.create(null),this.tree=Ce(e.state),this.decorations=this.buildDeco(e,Gr(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ce(e.state),i=Gr(e.state),s=i!=Gr(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return B.none;let i=new Bt;for(let{from:s,to:r}of e.visibleRanges)bO(this.tree,t,(o,a,l)=>{i.add(o,a,this.markCache[l]||(this.markCache[l]=B.mark({class:l})))},s,r);return i.finish()}}const t0=ri.high(xe.fromClass(e0,{decorations:n=>n.decorations})),i0=Xn.define([{tag:O.meta,color:"#404740"},{tag:O.link,textDecoration:"underline"},{tag:O.heading,textDecoration:"underline",fontWeight:"bold"},{tag:O.emphasis,fontStyle:"italic"},{tag:O.strong,fontWeight:"bold"},{tag:O.strikethrough,textDecoration:"line-through"},{tag:O.keyword,color:"#708"},{tag:[O.atom,O.bool,O.url,O.contentSeparator,O.labelName],color:"#219"},{tag:[O.literal,O.inserted],color:"#164"},{tag:[O.string,O.deleted],color:"#a11"},{tag:[O.regexp,O.escape,O.special(O.string)],color:"#e40"},{tag:O.definition(O.variableName),color:"#00f"},{tag:O.local(O.variableName),color:"#30a"},{tag:[O.typeName,O.namespace],color:"#085"},{tag:O.className,color:"#167"},{tag:[O.special(O.variableName),O.macroName],color:"#256"},{tag:O.definition(O.propertyName),color:"#00c"},{tag:O.comment,color:"#940"},{tag:O.invalid,color:"#f00"}]),n0=$.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ff=1e4,df="()[]{}",pf=K.define({combine(n){return yt(n,{afterCursor:!0,brackets:df,maxScanDistance:ff,renderMatch:o0})}}),s0=B.mark({class:"cm-matchingBracket"}),r0=B.mark({class:"cm-nonmatchingBracket"});function o0(n){let e=[],t=n.matched?s0:r0;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function Ac(n){let e=[],t=n.facet(pf);for(let i of n.selection.ranges){if(!i.empty)continue;let s=Rt(n,i.head,-1,t)||i.head>0&&Rt(n,i.head-1,1,t)||t.afterCursor&&(Rt(n,i.head,1,t)||i.headn.decorations}),l0=[a0,n0];function c0(n={}){return[pf.of(n),l0]}const h0=new G;function Jo(n,e,t){let i=n.prop(e<0?G.openedBy:G.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function ea(n){let e=n.type.prop(h0);return e?e(n.node):n}function Rt(n,e,t,i={}){let s=i.maxScanDistance||ff,r=i.brackets||df,o=Ce(n),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=Jo(l.type,t,r);if(c&&l.from0?e>=h.from&&eh.from&&e<=h.to))return u0(n,e,t,l,h,c,r)}}return f0(n,e,t,o,a.type,s,r)}function u0(n,e,t,i,s,r,o){let a=i.parent,l={from:s.from,to:s.to},c=0,h=a?.cursor();if(h&&(t<0?h.childBefore(i.from):h.childAfter(i.to)))do if(t<0?h.to<=i.from:h.from>=i.to){if(c==0&&r.indexOf(h.type.name)>-1&&h.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},h=n.doc.iterRange(e,t>0?n.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=r;){let d=h.value;t<0&&(f+=d.length);let p=e+f*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=s))if(y%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==l>>1};u--}}t>0&&(f+=d.length)}return h.done?{start:c,matched:!1}:null}const d0=Object.create(null),bc=[et.none],Sc=[],xc=Object.create(null),p0=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])p0[n]=m0(d0,e);function _r(n,e){Sc.indexOf(n)>-1||(Sc.push(n),console.warn(e))}function m0(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let h=n[c]||O[c];h?typeof h=="function"?l.length?l=l.map(h):_r(c,`Modifier ${c} used at start of tag`):l.length?_r(c,`Tag ${c} used as modifier`):l=Array.isArray(h)?h:[h]:_r(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+t.map(a=>a.id),r=xc[s];if(r)return r.id;let o=xc[s]=et.define({id:bc.length,name:i,props:[Nu({[i]:t})]});return bc.push(o),o.id}fe.RTL,fe.LTR;const g0=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Fa(n.state,t.from);return i.line?O0(n):i.block?A0(n):!1};function Ua(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const O0=Ua(x0,0),y0=Ua(mf,0),A0=Ua((n,e)=>mf(n,e,S0(e)),0);function Fa(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const ln=50;function b0(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-ln,i),o=n.sliceDoc(s,s+ln),a=/\s*$/.exec(r)[0].length,l=/^\s*/.exec(o)[0].length,c=r.length-a;if(r.slice(c-e.length,c)==e&&o.slice(l,l+t.length)==t)return{open:{pos:i-a,margin:a&&1},close:{pos:s+l,margin:l&&1}};let h,u;s-i<=2*ln?h=u=n.sliceDoc(i,s):(h=n.sliceDoc(i,i+ln),u=n.sliceDoc(s-ln,s));let f=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(u)[0].length,p=u.length-d-t.length;return h.slice(f,f+e.length)==e&&u.slice(p,p+t.length)==t?{open:{pos:i+f+e.length,margin:/\s/.test(h.charAt(f+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function S0(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to);s.from>i.from&&s.from==t.to&&(s=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function mf(n,e,t=e.selection.ranges){let i=t.map(r=>Fa(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>b0(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,a;os&&(r==o||o>u.from)){s=u.from;let f=/^\s*/.exec(u.text)[0].length,d=f==u.length,p=u.text.slice(f,f+c.length)==c?f:-1;fr.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:a,token:l,indent:c,empty:h,single:u}of i)(u||!h)&&r.push({from:a.from+c,insert:l+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:a,token:l}of i)if(a>=0){let c=o.from+a,h=c+l.length;o.text[h-o.from]==" "&&h++,r.push({from:c,to:h})}return{changes:r}}return null}const ta=Wt.define(),ws=Wt.define(),v0=K.define(),gf=K.define({combine(n){return yt(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),Da=Te.define({create(){return $t.empty},update(n,e){let t=e.state.facet(gf),i=e.annotation(ta);if(i){let l=_e.fromTransaction(e,i.selection),c=i.side,h=c==0?n.undone:n.done;return l?h=Vs(h,h.length,t.minDepth,l):h=Af(h,e.startState.selection),new $t(c==0?i.rest:h,c==0?h:i.rest)}let s=e.annotation(ws);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(Pe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=_e.fromTransaction(e),o=e.annotation(Pe.time),a=e.annotation(Pe.userEvent);return r?n=n.addChanges(r,o,a,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,a,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new $t(n.done.map(_e.fromJSON),n.undone.map(_e.fromJSON))}});function w0(n={}){return[Da,gf.of(n),$.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?La:e.inputType=="historyRedo"?zs:null;return i?(e.preventDefault(),i(t)):!1}})]}function Sr(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(Da,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const La=Sr(0,!1),zs=Sr(1,!1),k0=Sr(0,!0),Q0=Sr(1,!0);function Of(n){return function(e){let t=e.field(Da,!1);if(!t)return 0;let i=n==0?t.done:t.undone;return i.length-(i.length&&!i[0].changes?1:0)}}const vc=Of(0),wc=Of(1);class _e{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new _e(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new _e(e.changes&&Re.fromJSON(e.changes),[],e.mapped&&Zt.fromJSON(e.mapped),e.startSelection&&A.fromJSON(e.startSelection),e.selectionsAfter.map(A.fromJSON))}static fromTransaction(e,t){let i=ht;for(let s of e.startState.facet(v0)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new _e(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ht)}static selection(e){return new _e(void 0,ht,void 0,void 0,e)}}function Vs(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function P0(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,a)=>{for(let l=0;l=c&&o<=h&&(i=!0)}}),i}function C0(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function yf(n,e){return n.length?e.length?n.concat(e):n:e}const ht=[],T0=200;function Af(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-T0));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Vs(n,n.length-1,1e9,t.setSelAfter(i)))}else return[_e.selection([e])]}function R0(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Jr(n,e){if(!n.length)return n;let t=n.length,i=ht;for(;t;){let s=$0(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[_e.selection(i)]:ht}function $0(n,e,t){let i=yf(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):ht,t);if(!n.changes)return _e.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new _e(s,z.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const K0=/^(input\.type|delete)($|\.)/;class $t{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new $t(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!i||K0.test(i))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):xr(t,e))}function Be(n){return n.textDirectionAt(n.state.selection.main.head)==fe.LTR}const Sf=n=>bf(n,!Be(n)),xf=n=>bf(n,Be(n));function vf(n,e){return bt(n,t=>t.empty?n.moveByGroup(t,e):xr(t,e))}const M0=n=>vf(n,!Be(n)),E0=n=>vf(n,Be(n));function U0(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function vr(n,e,t){let i=Ce(n).resolveInner(e.head),s=t?G.closedBy:G.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;U0(n,c,s)?i=c:l=t?c.to:c.from}let r=i.type.prop(s),o,a;return r&&(o=t?Rt(n,i.from,1):Rt(n,i.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?i.to:i.from,A.cursor(a,t?-1:1)}const F0=n=>bt(n,e=>vr(n.state,e,!Be(n))),D0=n=>bt(n,e=>vr(n.state,e,Be(n)));function wf(n,e){return bt(n,t=>{if(!t.empty)return xr(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const kf=n=>wf(n,!1),Qf=n=>wf(n,!0);function Pf(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):xr(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;o&&o.top>l&&o.bottomCf(n,!1),ia=n=>Cf(n,!0);function oi(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=A.cursor(i.from+r))}return s}const L0=n=>bt(n,e=>oi(n,e,!0)),X0=n=>bt(n,e=>oi(n,e,!1)),B0=n=>bt(n,e=>oi(n,e,!Be(n))),I0=n=>bt(n,e=>oi(n,e,Be(n))),q0=n=>bt(n,e=>A.cursor(n.lineBlockAt(e.head).from,1)),W0=n=>bt(n,e=>A.cursor(n.lineBlockAt(e.head).to,-1));function z0(n,e,t){let i=!1,s=Ji(n.selection,r=>{let o=Rt(n,r.head,-1)||Rt(n,r.head,1)||r.head>0&&Rt(n,r.head-1,1)||r.headz0(n,e);function ft(n,e,t){let i=Ji(n.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=A.range(s.head,s.anchor));let r=t(s);return A.range(s.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(At(n.state,i)),!0)}function Tf(n,e){return ft(n,e,t=>n.moveByChar(t,e))}const Rf=n=>Tf(n,!Be(n)),$f=n=>Tf(n,Be(n));function Kf(n,e){return ft(n,e,t=>n.moveByGroup(t,e))}const j0=n=>Kf(n,!Be(n)),Y0=n=>Kf(n,Be(n)),N0=n=>{let e=!Be(n);return ft(n,e,t=>vr(n.state,t,e))},H0=n=>{let e=Be(n);return ft(n,e,t=>vr(n.state,t,e))};function Zf(n,e){return ft(n,e,t=>n.moveVertically(t,e))}const Mf=n=>Zf(n,!1),Ef=n=>Zf(n,!0);function Uf(n,e){return ft(n,e,t=>n.moveVertically(t,e,Pf(n).height))}const Qc=n=>Uf(n,!1),Pc=n=>Uf(n,!0),G0=n=>ft(n,!0,e=>oi(n,e,!0)),_0=n=>ft(n,!1,e=>oi(n,e,!1)),J0=n=>{let e=!Be(n);return ft(n,e,t=>oi(n,t,e))},ey=n=>{let e=Be(n);return ft(n,e,t=>oi(n,t,e))},ty=n=>ft(n,!1,e=>A.cursor(n.lineBlockAt(e.head).from)),iy=n=>ft(n,!0,e=>A.cursor(n.lineBlockAt(e.head).to)),Cc=({state:n,dispatch:e})=>(e(At(n,{anchor:0})),!0),Tc=({state:n,dispatch:e})=>(e(At(n,{anchor:n.doc.length})),!0),Rc=({state:n,dispatch:e})=>(e(At(n,{anchor:n.selection.main.anchor,head:0})),!0),$c=({state:n,dispatch:e})=>(e(At(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),ny=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),sy=({state:n,dispatch:e})=>{let t=wr(n).map(({from:i,to:s})=>A.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:A.create(t),userEvent:"select"})),!0},ry=({state:n,dispatch:e})=>{let t=Ji(n.selection,i=>{let s=Ce(n),r=s.resolveStack(i.from,1);if(i.empty){let o=s.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:a}=o;if((a.from=i.to||a.to>i.to&&a.from<=i.from)&&o.next)return A.range(a.to,a.from)}return i});return t.eq(n.selection)?!1:(e(At(n,t)),!0)};function Ff(n,e){let{state:t}=n,i=t.selection,s=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to0)for(let a=r;;){let l=n.moveVertically(a,e);if(l.heado.to){s.some(c=>c.head==l.head)||s.push(l);break}else{if(l.head==a.head)break;a=l}}}return s.length==i.ranges.length?!1:(n.dispatch(At(t,A.create(s,s.length-1))),!0)}const oy=n=>Ff(n,!1),ay=n=>Ff(n,!0),ly=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=A.create([t.main]):t.main.empty||(i=A.create([A.cursor(t.main.head)])),i?(e(At(n,i)),!0):!1};function Bn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:a}=r;if(o==a){let l=e(r);lo&&(t="delete.forward",l=hs(n,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=hs(n,o,!1),a=hs(n,a,!0);return o==a?{range:r}:{changes:{from:o,to:a},range:A.cursor(o,os(n)))i.between(e,e,(s,r)=>{se&&(e=t?r:s)});return e}const Df=(n,e,t)=>Bn(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),a,l;if(t&&!e&&s>o.from&&sDf(n,!1,!0),Lf=n=>Df(n,!0,!1),Xf=(n,e)=>Bn(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let a=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let l=Ze(r.text,i-r.from,e)+r.from,c=r.text.slice(Math.min(i,l)-r.from,Math.max(i,l)-r.from),h=o(c);if(a!=null&&h!=a)break;(c!=" "||i!=t.head)&&(a=h),i=l}return i}),Bf=n=>Xf(n,!1),cy=n=>Xf(n,!0),hy=n=>Bn(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headBn(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),fy=n=>Bn(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:se.of(["",""])},range:A.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},py=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:Ze(r.text,s-r.from,!1)+r.from,a=s==r.to?s+1:Ze(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:a,insert:n.doc.slice(s,a).append(n.doc.slice(o,s))},range:A.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function wr(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function If(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of wr(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),a=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let l of r.ranges)s.push(A.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let l of r.ranges)s.push(A.range(l.anchor-a,l.head-a))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:A.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const my=({state:n,dispatch:e})=>If(n,e,!1),gy=({state:n,dispatch:e})=>If(n,e,!0);function qf(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of wr(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});let s=n.changes(i);return e(n.update({changes:s,selection:n.selection.map(s,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Oy=({state:n,dispatch:e})=>qf(n,e,!1),yy=({state:n,dispatch:e})=>qf(n,e,!0),Ay=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(wr(e).map(({from:s,to:r})=>(s>0?s--:r{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),a=n.coordsAtPos(s.head,s.assoc||1);a&&(r=o.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function by(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Ce(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(G.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const Kc=Wf(!1),Sy=Wf(!0);function Wf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,a=e.doc.lineAt(r),l=!n&&r==o&&by(e,r);n&&(r=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new Ar(e,{simulateBreak:r,simulateDoubleBreak:!!l}),h=Ma(c,r);for(h==null&&(h=_i(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));oa.from&&r{let s=[];for(let o=i.from;o<=i.to;){let a=n.doc.lineAt(o);a.number>t&&(i.empty||i.to>a.from)&&(e(a,s,i),t=a.number),o=a.to+1}let r=n.changes(s);return{changes:s,range:A.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const xy=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Ar(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Xa(n,(r,o,a)=>{let l=Ma(i,r.from);if(l==null)return;/\S/.test(r.text)||(l=0);let c=/^\s*/.exec(r.text)[0],h=Tn(n,l);(c!=h||a.fromn.readOnly?!1:(e(n.update(Xa(n,(t,i)=>{i.push({from:t.from,insert:n.facet(yr)})}),{userEvent:"input.indent"})),!0),Vf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Xa(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=_i(s,n.tabSize),o=0,a=Tn(n,Math.max(0,r-Is(n)));for(;o(n.setTabFocusMode(),!0),wy=[{key:"Ctrl-b",run:Sf,shift:Rf,preventDefault:!0},{key:"Ctrl-f",run:xf,shift:$f},{key:"Ctrl-p",run:kf,shift:Mf},{key:"Ctrl-n",run:Qf,shift:Ef},{key:"Ctrl-a",run:q0,shift:ty},{key:"Ctrl-e",run:W0,shift:iy},{key:"Ctrl-d",run:Lf},{key:"Ctrl-h",run:na},{key:"Ctrl-k",run:hy},{key:"Ctrl-Alt-h",run:Bf},{key:"Ctrl-o",run:dy},{key:"Ctrl-t",run:py},{key:"Ctrl-v",run:ia}],ky=[{key:"ArrowLeft",run:Sf,shift:Rf,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:M0,shift:j0,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:B0,shift:J0,preventDefault:!0},{key:"ArrowRight",run:xf,shift:$f,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:E0,shift:Y0,preventDefault:!0},{mac:"Cmd-ArrowRight",run:I0,shift:ey,preventDefault:!0},{key:"ArrowUp",run:kf,shift:Mf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Cc,shift:Rc},{mac:"Ctrl-ArrowUp",run:kc,shift:Qc},{key:"ArrowDown",run:Qf,shift:Ef,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Tc,shift:$c},{mac:"Ctrl-ArrowDown",run:ia,shift:Pc},{key:"PageUp",run:kc,shift:Qc},{key:"PageDown",run:ia,shift:Pc},{key:"Home",run:X0,shift:_0,preventDefault:!0},{key:"Mod-Home",run:Cc,shift:Rc},{key:"End",run:L0,shift:G0,preventDefault:!0},{key:"Mod-End",run:Tc,shift:$c},{key:"Enter",run:Kc,shift:Kc},{key:"Mod-a",run:ny},{key:"Backspace",run:na,shift:na,preventDefault:!0},{key:"Delete",run:Lf,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Bf,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:cy,preventDefault:!0},{mac:"Mod-Backspace",run:uy,preventDefault:!0},{mac:"Mod-Delete",run:fy,preventDefault:!0}].concat(wy.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Qy=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:F0,shift:N0},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:D0,shift:H0},{key:"Alt-ArrowUp",run:my},{key:"Shift-Alt-ArrowUp",run:Oy},{key:"Alt-ArrowDown",run:gy},{key:"Shift-Alt-ArrowDown",run:yy},{key:"Mod-Alt-ArrowUp",run:oy},{key:"Mod-Alt-ArrowDown",run:ay},{key:"Escape",run:ly},{key:"Mod-Enter",run:Sy},{key:"Alt-l",mac:"Ctrl-l",run:sy},{key:"Mod-i",run:ry,preventDefault:!0},{key:"Mod-[",run:Vf},{key:"Mod-]",run:zf},{key:"Mod-Alt-\\",run:xy},{key:"Shift-Mod-k",run:Ay},{key:"Shift-Mod-\\",run:V0},{key:"Mod-/",run:g0},{key:"Alt-A",run:y0},{key:"Ctrl-m",mac:"Shift-Alt-m",run:vy}].concat(ky),Py={key:"Tab",run:zf,shift:Vf};class jf{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Ce(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(Nf(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Zc(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Cy(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;rtypeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:Cy(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Ty(n,e){return t=>{for(let i=Ce(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}let Mc=class{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}};function yi(n){return n.selection.main.from}function Nf(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Ba=Wt.define();function Ry(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return{...n.changeByRange(a=>{if(a!=s&&t!=i&&n.sliceDoc(a.from+r,a.from+o)!=n.sliceDoc(t,i))return{range:a};let l=n.toText(e);return{changes:{from:a.from+r,to:i==s.from?a.to:a.from+o,insert:l},range:A.cursor(a.from+r+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Ec=new WeakMap;function $y(n){if(!Array.isArray(n))return n;let e=Ec.get(n);return e||Ec.set(n,e=Yf(n)),e}const js=z.define(),Rn=z.define();class Ky{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(S=fa(k))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||w==1&&g||C==0&&w!=0)&&(t[u]==k||i[u]==k&&(f=!0)?o[u++]=b:o.length&&(y=!1)),C=w,b+=Qt(k)}return u==l&&o[0]==0&&y?this.result(-100+(f?-200:0),o,e):d==l&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):d==l?this.ret(-900-e.length,[p,m]):u==l?this.result(-100+(f?-200:0)+-700+(y?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let a=o+(this.astral?Qt(Ne(i,o)):1);r&&s[r-1]==o?s[r-1]=a:(s[r++]=o,s[r++]=a)}return this.ret(e-i.length,s)}}class Zy{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:My,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Uc(e(i),t(i)),optionClass:(e,t)=>i=>Uc(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Uc(n,e){return n?e?n+" "+e:n:e}function My(n,e,t,i,s,r){let o=n.textDirection==fe.RTL,a=o,l=!1,c="top",h,u,f=e.left-s.left,d=s.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(a&&f=m||b>e.top?h=t.bottom-e.top:(c="bottom",h=e.bottom-t.top)}let g=(e.bottom-e.top)/r.offsetHeight,y=(e.right-e.left)/r.offsetWidth;return{style:`${c}: ${h/g}px; max-width: ${u/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}const Ia=z.define();function Ey(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;cl&&o.appendChild(document.createTextNode(a.slice(l,h)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(a.slice(h,u))),f.className="cm-completionMatchedText",l=u}return lt.position-i.position).map(t=>t.render)}function eo(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class Uy{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,a=e.state.facet(Ke);this.optionContent=Ey(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=eo(r.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let h=l.target,u;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(u=/-(\d+)$/.exec(h.id))&&+u[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;h!=null&&(e.dispatch({effects:Ia.of(h)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Ke).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Rn.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:a}=i.open;(!s.open||s.open.options!=r)&&(this.range=eo(r.length,o,e.state.facet(Ke).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),a!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=eo(t.options.length,t.selected,this.view.state.facet(Ke).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,s)}).catch(a=>ze(this.view.state,a,"completion info")):(this.addInfoPane(o,s),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&Dy(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;oi.from||i.from==0))if(r=f,typeof c!="string"&&c.header)s.appendChild(c.header(c));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=f}}const h=s.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");let u=this.optionClass(a);u&&(h.className=u);for(let f of this.optionContent){let d=f(a,this.view.state,this.view,l);d&&h.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.tonew Uy(t,n,e)}function Dy(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function Fc(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Ly(n,e){let t=[],i=null,s=null,r=h=>{t.push(h);let{section:u}=h.completion;if(u){i||(i=[]);let f=typeof u=="string"?u:u.name;i.some(d=>d.name==f)||i.push(typeof u=="string"?{name:f}:u)}},o=e.facet(Ke);for(let h of n)if(h.hasResult()){let u=h.result.getMatch;if(h.result.filter===!1)for(let f of h.result.options)r(new Mc(f,h.source,u?u(f):[],1e9-t.length));else{let f=e.sliceDoc(h.from,h.to),d,p=o.filterStrict?new Zy(f):new Ky(f);for(let m of h.result.options)if(d=p.match(m.label)){let g=m.displayLabel?u?u(m,d.matched):[]:d.matched,y=d.score+(m.boost||0);if(r(new Mc(m,h.source,g,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:b}=m.section;s||(s=Object.create(null)),s[b]=Math.max(y,s[b]||-1e9)}}}}if(i){let h=Object.create(null),u=0,f=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?s[p.name]-s[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.namef.score-u.score||c(u.completion,f.completion))){let u=h.completion;!l||l.label!=u.label||l.detail!=u.detail||l.type!=null&&u.type!=null&&l.type!=u.type||l.apply!=u.apply||l.boost!=u.boost?a.push(h):Fc(h.completion)>Fc(l)&&(a[a.length-1]=h),l=h.completion}return a}class Ki{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ki(this.options,Dc(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r,o){if(s&&!o&&e.some(c=>c.isPending))return s.setDisabled();let a=Ly(e,t);if(!a.length)return s&&e.some(c=>c.isPending)?s.setDisabled():null;let l=t.facet(Ke).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let c=s.options[s.selected].completion;for(let h=0;hh.hasResult()?Math.min(c,h.from):c,1e8),create:zy,above:r.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new Ki(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ki(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Ys{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Ys(qy,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Ke),r=(i.override||t.languageDataAt("autocomplete",yi(t)).map($y)).map(l=>(this.active.find(h=>h.source==l)||new ut(l,this.active.some(h=>h.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((l,c)=>l==this.active[c])&&(r=this.active);let o=this.open,a=e.effects.some(l=>l.is(qa));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!Xy(r,this.active)||a?o=Ki.build(r,t,this.id,o,i,a):o&&o.disabled&&!r.some(l=>l.isPending)&&(o=null),!o&&r.every(l=>!l.isPending)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new ut(l.source,0):l));for(let l of e.effects)l.is(Ia)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new Ys(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?By:Iy}}function Xy(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const qy=[];function Hf(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Ba);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class ut{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=Hf(e,t),s=this;(i&8||i&16&&this.touches(e))&&(s=new ut(s.source,0)),i&4&&s.state==0&&(s=new ut(this.source,1)),s=s.updateFor(e,i);for(let r of e.effects)if(r.is(js))s=new ut(s.source,1,r.value);else if(r.is(Rn))s=new ut(s.source,0);else if(r.is(qa))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(yi(e.state))}}class Fi extends ut{constructor(e,t,i,s,r,o){super(e,3,t),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=yi(e.state);if(a>o||!s||t&2&&(yi(e.startState)==this.from||at.map(e))}}),He=Te.define({create(){return Ys.start()},update(n,e){return n.update(e)},provide:n=>[gr.from(n,e=>e.tooltip),$.contentAttributes.from(n,e=>e.attrs)]});function Wa(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(He).active.find(s=>s.source==e.source);return i instanceof Fi?(typeof t=="string"?n.dispatch({...Ry(n.state,t,i.from,i.to),annotations:Ba.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const zy=Fy(He,Wa);function us(n,e="option"){return t=>{let i=t.state.field(He,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+s*(n?1:-1):n?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:Ia.of(a)}),!0}}const Vy=n=>{let e=n.state.field(He,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(He,!1)?(n.dispatch({effects:js.of(!0)}),!0):!1,jy=n=>{let e=n.state.field(He,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Rn.of(null)}),!0)};class Yy{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ny=50,Hy=1e3,Gy=xe.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(He).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(He),t=n.state.facet(Ke);if(!n.selectionSet&&!n.docChanged&&n.startState.field(He)==e)return;let i=n.transactions.some(r=>{let o=Hf(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;rNy&&Date.now()-o.time>Hy){for(let a of o.context.abortListeners)try{a()}catch(l){ze(this.view.state,l)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(js)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(He);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ke).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=yi(e),i=new jf(e,t,n.explicit,this.view),s=new Yy(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Rn.of(null)}),ze(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ke).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Ke),i=this.view.state.field(He);for(let s=0;sa.source==r.active.source);if(o&&o.isPending)if(r.done==null){let a=new ut(r.active.source,0);for(let l of r.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:qa.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(He,!1);if(e&&e.tooltip&&this.view.state.facet(Ke).closeOnBlur){let t=e.open&&Uu(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Rn.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:js.of(!1)}),20),this.composing=0}}}),_y=typeof navigator=="object"&&/Win/.test(navigator.platform),Jy=ri.highest($.domEventHandlers({keydown(n,e){let t=e.state.field(He,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(_y&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&Wa(e,i),!1}})),Gf=$.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class eA{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class za{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,De.TrackDel),i=e.mapPos(this.to,1,De.TrackDel);return t==null||i==null?null:new za(this.field,t,i)}}class Va{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let l of this.lines){if(i.length){let c=o,h=/^\t*/.exec(l)[0].length;for(let u=0;unew za(l.field,s[l.line]+l.from,s[l.line]+l.to));return{text:i,ranges:a}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let a=r[1]?+r[1]:null,l=r[2]||r[3]||"",c=-1;a===0&&(a=1e9);let h=l.replace(/\\[{}]/g,u=>u[1]);for(let u=0;u=c&&f.field++}for(let u of s)if(u.line==i.length&&u.from>r.index){let f=r[2]?3+(r[1]||"").length:2;u.from-=f,u.to-=f}s.push(new eA(c,i.length,r.index,r.index+h.length)),o=o.slice(0,r.index)+l+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(a,l,c)=>{for(let h of s)h.line==i.length&&h.from>c&&(h.from--,h.to--);return l}),i.push(o)}return new Va(i,s)}}let tA=B.widget({widget:new class extends Ut{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),iA=B.mark({class:"cm-snippetField"});class en{constructor(e,t){this.ranges=e,this.active=t,this.deco=B.set(e.map(i=>(i.from==i.to?tA:iA).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new en(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const In=z.define({map(n,e){return n&&n.map(e)}}),nA=z.define(),$n=Te.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(In))return t.value;if(t.is(nA)&&n)return new en(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>$.decorations.from(n,e=>e?e.deco:B.none)});function ja(n,e){return A.create(n.filter(t=>t.field==e).map(t=>A.range(t.from,t.to)))}function sA(n){let e=Va.parse(n);return(t,i,s,r)=>{let{text:o,ranges:a}=e.instantiate(t.state,s),{main:l}=t.state.selection,c={changes:{from:s,to:r==l.from?l.to:r,insert:se.of(o)},scrollIntoView:!0,annotations:i?[Ba.of(i),Pe.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=ja(a,0)),a.some(h=>h.field>0)){let h=new en(a,0),u=c.effects=[In.of(h)];t.state.field($n,!1)===void 0&&u.push(z.appendConfig.of([$n,cA,hA,Gf]))}t.dispatch(t.state.update(c))}}function _f(n){return({state:e,dispatch:t})=>{let i=e.field($n,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:ja(i.ranges,s),effects:In.of(r?null:new en(i.ranges,s)),scrollIntoView:!0})),!0}}const rA=({state:n,dispatch:e})=>n.field($n,!1)?(e(n.update({effects:In.of(null)})),!0):!1,oA=_f(1),aA=_f(-1),lA=[{key:"Tab",run:oA,shift:aA},{key:"Escape",run:rA}],Lc=K.define({combine(n){return n.length?n[0]:lA}}),cA=ri.highest(mr.compute([Lc],n=>n.facet(Lc)));function Ye(n,e){return{...e,apply:sA(n)}}const hA=$.domEventHandlers({mousedown(n,e){let t=e.state.field($n,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:ja(t.ranges,s.field),effects:In.of(t.ranges.some(r=>r.field>s.field)?new en(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),Kn={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},mi=z.define({map(n,e){let t=e.mapPos(n,-1,De.TrackAfter);return t??void 0}}),Ya=new class extends Jt{};Ya.startSide=1;Ya.endSide=-1;const Jf=Te.define({create(){return N.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(mi)&&(n=n.update({add:[Ya.range(t.value,t.value+1)]}));return n}});function uA(){return[dA,Jf]}const io="()[]{}<>«»»«[]{}";function ed(n){for(let e=0;e{if((fA?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&Qt(Ne(i,0))==1||e!=s.from||t!=s.to)return!1;let r=gA(n.state,i);return r?(n.dispatch(r),!0):!1}),pA=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=td(n,n.selection.main.head).brackets||Kn.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let a=OA(n.doc,o.head);for(let l of i)if(l==a&&kr(n.doc,o.head)==ed(Ne(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:A.cursor(o.head-l.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},mA=[{key:"Backspace",run:pA}];function gA(n,e){let t=td(n,n.selection.main.head),i=t.brackets||Kn.brackets;for(let s of i){let r=ed(Ne(s,0));if(e==s)return r==s?bA(n,s,i.indexOf(s+s+s)>-1,t):yA(n,s,r,t.before||Kn.before);if(e==r&&id(n,n.selection.main.from))return AA(n,s,r)}return null}function id(n,e){let t=!1;return n.field(Jf).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function kr(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Qt(Ne(t,0)))}function OA(n,e){let t=n.sliceString(e-2,e);return Qt(Ne(t,0))==t.length?t:t.slice(1)}function yA(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:mi.of(o.to+e.length),range:A.range(o.anchor+e.length,o.head+e.length)};let a=kr(n.doc,o.head);return!a||/\s/.test(a)||i.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:mi.of(o.head+e.length),range:A.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function AA(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&kr(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:A.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function bA(n,e,t,i){let s=i.stringPrefixes||Kn.stringPrefixes,r=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:mi.of(a.to+e.length),range:A.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=kr(n.doc,l),h;if(c==e){if(Xc(n,l))return{changes:{insert:e+e,from:l},effects:mi.of(l+e.length),range:A.cursor(l+e.length)};if(id(n,l)){let f=t&&n.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+f.length,insert:f},range:A.cursor(l+f.length)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(h=Bc(n,l-2*e.length,s))>-1&&Xc(n,h))return{changes:{insert:e+e+e+e,from:l},effects:mi.of(l+e.length),range:A.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=ye.Word&&Bc(n,l,s)>-1&&!SA(n,l,e,s))return{changes:{insert:e+e,from:l},effects:mi.of(l+e.length),range:A.cursor(l+e.length)}}return{range:r=a}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Xc(n,e){let t=Ce(n).resolveInner(e+1);return t.parent&&t.from==e}function SA(n,e,t,i){let s=Ce(n).resolveInner(e,-1),r=i.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),l=a.indexOf(t);if(!l||l>-1&&i.indexOf(a.slice(0,l))>-1){let h=s.firstChild;for(;h&&h.from==s.from&&h.to-h.from>t.length+l;){if(n.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let c=s.to==e&&s.parent;if(!c)break;s=c}return!1}function Bc(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ye.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=ye.Word)return r}return-1}function xA(n={}){return[Jy,He,Ke.of(n),Gy,vA,Gf]}const nd=[{key:"Ctrl-Space",run:to},{mac:"Alt-`",run:to},{mac:"Alt-i",run:to},{key:"Escape",run:jy},{key:"ArrowDown",run:us(!0)},{key:"ArrowUp",run:us(!1)},{key:"PageDown",run:us(!0,"page")},{key:"PageUp",run:us(!1,"page")},{key:"Enter",run:Vy}],vA=ri.highest(mr.computeN([Ke],n=>n.facet(Ke).defaultKeymap?[nd]:[]));var Ic={};class Ns{constructor(e,t,i,s,r,o,a,l,c,h=0,u){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=h,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let s=e.parser.context;return new Ns(e,[],t,i,i,0,[],0,s?new qc(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,s=e&65535,{parser:r}=this.p,o=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizel;)this.stack.pop();this.reduceContext(s,c)}storeNode(e,t,i,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(e,t,i,s){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;this.pos=s;let a=o.stateFlag(r,1);!a&&(s>i||t<=o.maxNode)&&(this.reducePos=s),this.pushState(r,a?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,s,4)}else this.pos=s,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,s,4)}apply(e,t,i,s){e&65536?this.reduce(e):this.shift(e,t,i,s)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new Ns(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new wA(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let s=[];for(let r=0,o;rl&1&&a==o)||s.push(t[r],o)}t=s}let i=[];for(let s=0;s>19,s=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-r;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=i(o,r+1);if(a!=null)return a}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}}class qc{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class wA{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class Hs{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Hs(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Hs(this.stack,this.pos,this.index)}}function dn(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,s=0;i=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),r+=l,a)break;r*=46}t?t[s++]=r:t=new e(r)}return t}class ks{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Wc=new ks;class kA{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Wc,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,s=this.rangeIndex,r=this.pos+e;for(;ri.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,s;if(t>=0&&t=this.chunk2Pos&&ia.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Wc,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class Di{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;sd(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}Di.prototype.contextual=Di.prototype.fallback=Di.prototype.extend=!1;class sa{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?dn(e):e}token(e,t){let i=e.pos,s=0;for(;;){let r=e.next<0,o=e.resolveOffset(1,1);if(sd(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(r||s++,o==null)break;e.reset(o,e.token)}s&&(e.reset(i,e.token),e.acceptToken(this.elseToken,s))}}sa.prototype.contextual=Di.prototype.fallback=Di.prototype.extend=!1;class qn{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function sd(n,e,t,i,s,r){let o=0,a=1<0){let p=n[d];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||QA(p,e.token.value,s,r))){e.acceptToken(p);break}}let h=e.next,u=0,f=n[o+2];if(e.next<0&&f>u&&n[c+f*3-3]==65535){o=n[c+f*3-1];continue e}for(;u>1,p=c+d+(d<<1),m=n[p],g=n[p+1]||65536;if(h=g)u=d+1;else{o=n[p+2],e.advance();continue e}}break}}function zc(n,e,t){for(let i=e,s;(s=n[i])!=65535;i++)if(s==t)return i-e;return-1}function QA(n,e,t,i){let s=zc(t,i,e);return s<0||zc(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class PA{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Vc(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Vc(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(r instanceof ke){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class CA{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new ks)}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;cu.end+25&&(l=Math.max(u.lookAhead,l)),u.value!=0)){let f=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!h.extend&&(i=u,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!i&&e.pos==this.stream.end&&(i=new ks,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new ks,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){let s=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(s,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,i,s){for(let r=0;re.bufferLength*4?new PA(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],s,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)i.push(a);else{if(this.advanceStack(a,i,e))continue;{s||(s=[],r=[]),s.push(a);let l=this.tokens.getMainToken(a);r.push(l.value,l.end)}}break}}if(!i.length){let o=s&&KA(s);if(o)return nt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw nt&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return nt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((a,l)=>l.score-a.score);i.length>o;)i.pop();i.some(a=>a.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)i.splice(l--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,a)=>a.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,h=c?e.curContext.hash:0;for(let u=this.fragments.nodeAt(s);u;){let f=this.parser.nodeSet.types[u.type.id]==u.type?r.getGoto(e.state,u.type.id):-1;if(f>-1&&u.length&&(!c||(u.prop(G.contextHash)||0)==h))return e.useNode(u,f),nt&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(u.type.id)})`),!0;if(!(u instanceof ke)||u.children.length==0||u.positions[0]>0)break;let d=u.children[0];if(d instanceof ke&&u.positions[0]==0)u=d;else break}}let a=r.stateSlot(e.state,4);if(a>0)return e.reduce(a),nt&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;cs?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return jc(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let o=0;o ":"";if(a.deadEnd&&(r||(r=!0,a.restart(),nt&&console.log(h+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let u=a.split(),f=h;for(let d=0;d<10&&u.forceReduce()&&(nt&&console.log(f+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));d++)nt&&(f=this.stackID(u)+" -> ");for(let d of a.recoverByInsert(l))nt&&console.log(h+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),nt&&console.log(h+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),jc(a,i)):(!s||s.scoren;class $A{constructor(e){this.start=e.start,this.shift=e.shift||so,this.reduce=e.reduce||so,this.reuse=e.reuse||so,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Gs extends Yu{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;ae.topRules[a][1]),s=[];for(let a=0;a=0)r(h,l,a[c++]);else{let u=a[c+-h];for(let f=-h;f>0;f--)r(a[c++],l,u);c++}}}this.nodeSet=new Ta(t.map((a,l)=>et.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:s[l],top:i.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Wu;let o=dn(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;atypeof a=="number"?new Di(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let s=new TA(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],a=o&1,l=s[r++];if(a&&i)return l;for(let c=r+(o>>1);r0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),s=i?t(i):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Ft(this.data,r+2);else break;s=t(Ft(this.data,r+1))}return s}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Ft(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[i],s)}}return t}configure(e){let t=Object.assign(Object.create(Gs.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let s=e.tokenizers.find(r=>r.from==i);return s?s.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=e.specializers.find(a=>a.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[s]=Yc(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;ri)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const ZA=316,MA=317,Nc=1,EA=2,UA=3,FA=4,DA=318,LA=320,XA=321,BA=5,IA=6,qA=0,ra=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],rd=125,WA=59,oa=47,zA=42,VA=43,jA=45,YA=60,NA=44,HA=63,GA=46,_A=91,JA=new $A({start:!1,shift(n,e){return e==BA||e==IA||e==LA?n:e==XA},strict:!1}),eb=new qn((n,e)=>{let{next:t}=n;(t==rd||t==-1||e.context)&&n.acceptToken(DA)},{contextual:!0,fallback:!0}),tb=new qn((n,e)=>{let{next:t}=n,i;ra.indexOf(t)>-1||t==oa&&((i=n.peek(1))==oa||i==zA)||t!=rd&&t!=WA&&t!=-1&&!e.context&&n.acceptToken(ZA)},{contextual:!0}),ib=new qn((n,e)=>{n.next==_A&&!e.context&&n.acceptToken(MA)},{contextual:!0}),nb=new qn((n,e)=>{let{next:t}=n;if(t==VA||t==jA){if(n.advance(),t==n.next){n.advance();let i=!e.context&&e.canShift(Nc);n.acceptToken(i?Nc:EA)}}else t==HA&&n.peek(1)==GA&&(n.advance(),n.advance(),(n.next<48||n.next>57)&&n.acceptToken(UA))},{contextual:!0});function ro(n,e){return n>=65&&n<=90||n>=97&&n<=122||n==95||n>=192||!e&&n>=48&&n<=57}const sb=new qn((n,e)=>{if(n.next!=YA||!e.dialectEnabled(qA)||(n.advance(),n.next==oa))return;let t=0;for(;ra.indexOf(n.next)>-1;)n.advance(),t++;if(ro(n.next,!0)){for(n.advance(),t++;ro(n.next,!1);)n.advance(),t++;for(;ra.indexOf(n.next)>-1;)n.advance(),t++;if(n.next==NA)return;for(let i=0;;i++){if(i==7){if(!ro(n.next,!0))return;break}if(n.next!="extends".charCodeAt(i))break;n.advance(),t++}}n.acceptToken(FA,-t)}),rb=Nu({"get set async static":O.modifier,"for while do if else switch try catch finally return throw break continue default case defer":O.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":O.operatorKeyword,"let var const using function class extends":O.definitionKeyword,"import export from":O.moduleKeyword,"with debugger new":O.keyword,TemplateString:O.special(O.string),super:O.atom,BooleanLiteral:O.bool,this:O.self,null:O.null,Star:O.modifier,VariableName:O.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":O.function(O.variableName),VariableDefinition:O.definition(O.variableName),Label:O.labelName,PropertyName:O.propertyName,PrivatePropertyName:O.special(O.propertyName),"CallExpression/MemberExpression/PropertyName":O.function(O.propertyName),"FunctionDeclaration/VariableDefinition":O.function(O.definition(O.variableName)),"ClassDeclaration/VariableDefinition":O.definition(O.className),"NewExpression/VariableName":O.className,PropertyDefinition:O.definition(O.propertyName),PrivatePropertyDefinition:O.definition(O.special(O.propertyName)),UpdateOp:O.updateOperator,"LineComment Hashbang":O.lineComment,BlockComment:O.blockComment,Number:O.number,String:O.string,Escape:O.escape,ArithOp:O.arithmeticOperator,LogicOp:O.logicOperator,BitOp:O.bitwiseOperator,CompareOp:O.compareOperator,RegExp:O.regexp,Equals:O.definitionOperator,Arrow:O.function(O.punctuation),": Spread":O.punctuation,"( )":O.paren,"[ ]":O.squareBracket,"{ }":O.brace,"InterpolationStart InterpolationEnd":O.special(O.brace),".":O.derefOperator,", ;":O.separator,"@":O.meta,TypeName:O.typeName,TypeDefinition:O.definition(O.typeName),"type enum interface implements namespace module declare":O.definitionKeyword,"abstract global Privacy readonly override":O.modifier,"is keyof unique infer asserts":O.operatorKeyword,JSXAttributeValue:O.attributeValue,JSXText:O.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":O.angleBracket,"JSXIdentifier JSXNameSpacedName":O.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":O.attributeName,"JSXBuiltin/JSXIdentifier":O.standard(O.tagName)}),ob={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},ab={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},lb={__proto__:null,"<":193},cb=Gs.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQ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gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:JA,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[rb],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkw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%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[tb,ib,nb,sb,2,3,4,5,6,7,8,9,10,11,12,13,14,eb,new sa("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new sa("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:n=>ob[n]||-1},{term:343,get:n=>ab[n]||-1},{term:95,get:n=>lb[n]||-1}],tokenPrec:15201}),od=[Ye("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Ye("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Ye("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Ye("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Ye("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Ye(`try { + \${} +} catch (\${error}) { + \${} +}`,{label:"try",detail:"/ catch block",type:"keyword"}),Ye("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Ye(`if (\${}) { + \${} +} else { + \${} +}`,{label:"if",detail:"/ else block",type:"keyword"}),Ye(`class \${name} { + constructor(\${params}) { + \${} + } +}`,{label:"class",detail:"definition",type:"keyword"}),Ye('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Ye('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],hb=od.concat([Ye("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Ye("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Ye("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Hc=new dO,ad=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function cn(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const ub=["FunctionDeclaration"],fb={FunctionDeclaration:cn("function"),ClassDeclaration:cn("class"),ClassExpression:()=>!0,EnumDeclaration:cn("constant"),TypeAliasDeclaration:cn("type"),NamespaceDeclaration:cn("namespace"),VariableDefinition(n,e){n.matchContext(ub)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function ld(n,e){let t=Hc.get(e);if(t)return t;let i=[],s=!0;function r(o,a){let l=n.sliceString(o.from,o.to);i.push({label:l,type:a})}return e.cursor(be.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let a=fb[o.name];if(a&&a(o,r)||ad.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of ld(n,o.node))i.push(a);return!1}}),Hc.set(e,i),i}const Gc=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,cd=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function db(n){let e=Ce(n.state).resolveInner(n.pos,-1);if(cd.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Gc.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)ad.has(s.name)&&(i=i.concat(ld(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:Gc}}const Xt=Xs.define({name:"javascript",parser:cb.configure({props:[ef.add({IfStatement:Nr({except:/^\s*({|else\b)/}),TryStatement:Nr({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:MO,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:ZO({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Nr({except:/^\s*{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),sf.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":DO,BlockComment(n){return{from:n.from+2,to:n.to-2}},JSXElement(n){let e=n.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let t=n.lastChild;return{from:e.to,to:t.type.isError?n.to:t.from}},"JSXSelfClosingTag JSXOpenTag"(n){var e;let t=(e=n.firstChild)===null||e===void 0?void 0:e.nextSibling,i=n.lastChild;return!t||t.type.isError?null:{from:t.to,to:i.type.isError?n.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),hd={test:n=>/^JSX/.test(n.name),facet:_u({commentTokens:{block:{open:"{/*",close:"*/}"}}})},pb=Xt.configure({dialect:"ts"},"typescript"),mb=Xt.configure({dialect:"jsx",props:[Za.add(n=>n.isTop?[hd]:void 0)]}),gb=Xt.configure({dialect:"jsx ts",props:[Za.add(n=>n.isTop?[hd]:void 0)]},"typescript");let ud=n=>({label:n,type:"keyword"});const fd="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(ud),Ob=fd.concat(["declare","implements","private","protected","public"].map(ud));function yb(n={}){let e=n.jsx?n.typescript?gb:mb:n.typescript?pb:Xt,t=n.typescript?hb.concat(Ob):od.concat(fd);return new kO(e,[Xt.data.of({autocomplete:Ty(cd,Yf(t))}),Xt.data.of({autocomplete:db}),n.jsx?Sb:[]])}function Ab(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function _c(n,e,t=n.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const bb=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Sb=$.inputHandler.of((n,e,t,i,s)=>{if((bb?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!Xt.isActiveAt(n.state,e,-1))return!1;let r=s(),{state:o}=r,a=o.changeByRange(l=>{var c;let{head:h}=l,u=Ce(o).resolveInner(h-1,-1),f;if(u.name=="JSXStartTag"&&(u=u.parent),!(o.doc.sliceString(h-1,h)!=i||u.name=="JSXAttributeValue"&&u.to>h)){if(i==">"&&u.name=="JSXFragmentTag")return{range:l,changes:{from:h,insert:""}};if(i=="/"&&u.name=="JSXStartCloseTag"){let d=u.parent,p=d.parent;if(p&&d.from==h-2&&((f=_c(o.doc,p.firstChild,h))||((c=p.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let m=`${f}>`;return{range:A.cursor(h+m.length,-1),changes:{from:h,insert:m}}}}else if(i==">"){let d=Ab(u);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(f=_c(o.doc,d,h)))return{range:l,changes:{from:h,insert:``}}}}return{range:l}});return a.changes.empty?!1:(n.dispatch([r,o.update(a,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Jc=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Yi{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?a=>r(Jc(a)):Jc,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Ne(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=fa(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Qt(e);let s=this.normalize(t);if(s.length)for(let r=0,o=i,a=!0;;r++){let l=s.charCodeAt(r),c=this.match(l,o,a,this.bufferPos+this.bufferStart,r==s.length-1);if(c)return this.value=c,this;if(r==s.length-1)break;a&&rthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=_s(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||s.to<=t){let a=new Li(t,e.sliceString(t,i));return oo.set(e,a),a}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,s=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,precise:!0,match:t},this.matchPos=_s(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Li.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(pd.prototype[Symbol.iterator]=md.prototype[Symbol.iterator]=function(){return this});function xb(n){try{return new RegExp(n,Na),!0}catch{return!1}}function _s(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}const vb=n=>{let{state:e}=n,t=String(e.doc.lineAt(n.state.selection.main.head).number),{close:i,result:s}=jg(n,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return s.then(r=>{let o=r&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.elements.line.value);if(!o){n.dispatch({effects:i});return}let a=e.doc.lineAt(e.selection.main.head),[,l,c,h,u]=o,f=h?+h.slice(1):0,d=c?+c:a.number;if(c&&u){let g=d/100;l&&(g=g*(l=="-"?-1:1)+a.number/e.doc.lines),d=Math.round(e.doc.lines*g)}else c&&l&&(d=d*(l=="-"?-1:1)+a.number);let p=e.doc.line(Math.max(1,Math.min(e.doc.lines,d))),m=A.cursor(p.from+Math.max(0,Math.min(f,p.length)));n.dispatch({effects:[i,$.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0},wb={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},kb=K.define({combine(n){return yt(n,wb,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Qb(n){return[$b,Rb]}const Pb=B.mark({class:"cm-selectionMatch"}),Cb=B.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function eh(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=ye.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=ye.Word)}function Tb(n,e,t,i){return n(e.sliceDoc(t,t+1))==ye.Word&&n(e.sliceDoc(i-1,i))==ye.Word}const Rb=xe.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(kb),{state:t}=n,i=t.selection;if(i.ranges.length>1)return B.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return B.none;let l=t.wordAt(s.head);if(!l)return B.none;o=t.charCategorizer(s.head),r=t.sliceDoc(l.from,l.to)}else{let l=s.to-s.from;if(l200)return B.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(eh(o,t,s.from,s.to)&&Tb(o,t,s.from,s.to)))return B.none}else if(r=t.sliceDoc(s.from,s.to),!r)return B.none}let a=[];for(let l of n.visibleRanges){let c=new Yi(t.doc,r,l.from,l.to);for(;!c.next().done;){let{from:h,to:u}=c.value;if((!o||eh(o,t,h,u))&&(s.empty&&h<=s.from&&u>=s.to?a.push(Cb.range(h,u)):(h>=s.to||u<=s.from)&&a.push(Pb.range(h,u)),a.length>e.maxMatches))return B.none}}return B.set(a)}},{decorations:n=>n.decorations}),$b=$.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Kb=({state:n,dispatch:e})=>{let{selection:t}=n,i=A.create(t.ranges.map(s=>n.wordAt(s.head)||A.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function Zb(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,a=new Yi(n.doc,e,i[i.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new Yi(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(l=>l.from==a.value.from))continue;if(r){let l=n.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const Mb=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return Kb({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=Zb(n,i);return s?(e(n.update({selection:n.selection.addRange(A.range(s.from,s.to),!1),effects:$.scrollIntoView(s.to)})),!0):!1},tn=K.define({combine(n){return yt(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Yb(e),scrollToMatch:e=>$.scrollIntoView(e)})}});class gd{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||xb(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` +`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Xb(this):new Fb(this)}getCursor(e,t=0,i){let s=e.doc?e:_.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?Pi(this,s,t,i):Qi(this,s,t,i)}}class Od{constructor(e){this.spec=e}}function Eb(n,e,t){return(i,s,r,o)=>{if(t&&!t(i,s,r,o))return!1;let a=i>=o&&s<=o+r.length?r.slice(i-o,s-o):e.doc.sliceString(i,s);return n(a,e,i,s)}}function Qi(n,e,t,i){let s;return n.wholeWord&&(s=Ub(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(s=Eb(n.test,e,s)),new Yi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),s)}function Ub(n,e){return(t,i,s,r)=>((r>t||r+s.length=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Qi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Db(n,e,t){return(i,s,r)=>(!t||t(i,s,r))&&n(r[0],e,i,s)}function Pi(n,e,t,i){let s;return n.wholeWord&&(s=Lb(e.charCategorizer(e.selection.main.head))),n.test&&(s=Db(n.test,e,s)),new pd(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:s},t,i)}function Js(n,e){return n.slice(Ze(n,e,!1),e)}function er(n,e){return n.slice(e,Ze(n,e))}function Lb(n){return(e,t,i)=>!i[0].length||(n(Js(i.input,i.index))!=ye.Word||n(er(i.input,i.index))!=ye.Word)&&(n(er(i.input,i.index+i[0].length))!=ye.Word||n(Js(i.input,i.index+i[0].length))!=ye.Word)}class Xb extends Od{nextMatch(e,t,i){let s=Pi(this.spec,e,i,e.doc.length).next();return s.done&&(s=Pi(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=Pi(this.spec,e,r,i),a=null;for(;!o.next().done;)a=o.value;if(a&&(r==t||a.from>r+10))return a;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let s=i.length;s>0;s--){let r=+i.slice(0,s);if(r>0&&r=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Pi(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Zn=z.define(),Ha=z.define(),Gt=Te.define({create(n){return new ao(aa(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Zn)?n=new ao(t.value.create(),n.panel):t.is(Ha)&&(n=new ao(n.query,t.value?Ga:null));return n},provide:n=>Vi.from(n,e=>e.panel)});class ao{constructor(e,t){this.query=e,this.panel=t}}const Bb=B.mark({class:"cm-searchMatch"}),Ib=B.mark({class:"cm-searchMatch cm-searchMatch-selected"}),qb=xe.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Gt))}update(n){let e=n.state.field(Gt);(e!=n.startState.field(Gt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return B.none;let{view:t}=this,i=new Bt;for(let s=0,r=t.visibleRanges,o=r.length;sr[s+1].from-500;)l=r[++s].to;n.highlight(t.state,a,l,(c,h)=>{let u=t.state.selection.ranges.some(f=>f.from==c&&f.to==h);i.add(c,h,u?Ib:Bb)})}return i.finish()}},{decorations:n=>n.decorations});function Wn(n){return e=>{let t=e.state.field(Gt,!1);return t&&t.query.spec.valid?n(e,t):bd(e)}}const tr=Wn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=A.single(i.from,i.to),r=n.state.facet(tn);return n.dispatch({selection:s,effects:[_a(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Ad(n),!0}),ir=Wn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=A.single(s.from,s.to),o=n.state.facet(tn);return n.dispatch({selection:r,effects:[_a(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Ad(n),!0}),Wb=Wn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:A.create(t.map(i=>A.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),zb=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let a=new Yi(n.doc,n.sliceDoc(i,s));!a.next().done;){if(r.length>1e3)return!1;a.value.from==i&&(o=r.length),r.push(A.range(a.value.from,a.value.to))}return e(n.update({selection:A.create(r,o),userEvent:"select.search.matches"})),!0},th=Wn((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,a=[],l,c,h=[];o.precise?o.from==i&&o.to==s&&(c=t.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),h.push($.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let u=n.state.changes(a);return o&&(l=A.single(o.from,o.to).map(u),h.push(_a(n,o)),h.push(t.facet(tn).scrollToMatch(l.main,n))),n.dispatch({changes:u,selection:l,effects:h,userEvent:"input.replace"}),!0}),Vb=Wn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let s of e.matchAll(n.state,1e9)){let{from:r,to:o,precise:a}=s;a&&t.push({from:r,to:o,insert:e.getReplacement(s)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:$.announce.of(i),userEvent:"input.replace.all"}),!0});function Ga(n){return n.state.facet(tn).createPanel(n)}function aa(n,e){var t,i,s,r,o;let a=n.selection.main,l=a.empty||a.to>a.from+100?"":n.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=n.facet(tn);return new gd({search:((t=e?.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(s=e?.literal)!==null&&s!==void 0?s:c.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function yd(n){let e=Fu(n,Ga);return e&&e.dom.querySelector("[main-field]")}function Ad(n){let e=yd(n);e&&e==n.root.activeElement&&e.select()}const bd=n=>{let e=n.state.field(Gt,!1);if(e&&e.panel){let t=yd(n);if(t&&t!=n.root.activeElement){let i=aa(n.state,e.query.spec);i.valid&&n.dispatch({effects:Zn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Ha.of(!0),e?Zn.of(aa(n.state,e.query.spec)):z.appendConfig.of(Hb)]});return!0},Sd=n=>{let e=n.state.field(Gt,!1);if(!e||!e.panel)return!1;let t=Fu(n,Ga);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Ha.of(!1)}),!0},jb=[{key:"Mod-f",run:bd,scope:"editor search-panel"},{key:"F3",run:tr,shift:ir,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:tr,shift:ir,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Sd,scope:"editor search-panel"},{key:"Mod-Shift-l",run:zb},{key:"Mod-Alt-g",run:vb},{key:"Mod-d",run:Mb,preventDefault:!0}];class Yb{constructor(e){this.view=e;let t=this.query=e.state.field(Gt).query.spec;this.commit=this.commit.bind(this),this.searchField=he("input",{value:t.search,placeholder:st(e,"Find"),"aria-label":st(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=he("input",{value:t.replace,placeholder:st(e,"Replace"),"aria-label":st(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=he("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=he("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=he("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return he("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=he("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>tr(e),[st(e,"next")]),i("prev",()=>ir(e),[st(e,"previous")]),i("select",()=>Wb(e),[st(e,"all")]),he("label",null,[this.caseField,st(e,"match case")]),he("label",null,[this.reField,st(e,"regexp")]),he("label",null,[this.wordField,st(e,"by word")]),...e.state.readOnly?[]:[he("br"),this.replaceField,i("replace",()=>th(e),[st(e,"replace")]),i("replaceAll",()=>Vb(e),[st(e,"replace all")])],he("button",{name:"close",onclick:()=>Sd(e),"aria-label":st(e,"close"),type:"button"},["×"])])}commit(){let e=new gd({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Zn.of(e)}))}keydown(e){sg(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ir:tr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),th(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Zn)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(tn).top}}function st(n,e){return n.state.phrase(e)}const fs=30,ds=/[\s\.,:;?!]/;function _a(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-fs),o=Math.min(s,t+fs),a=n.state.sliceDoc(r,o);if(r!=i.from){for(let l=0;la.length-fs;l--)if(!ds.test(a[l-1])&&ds.test(a[l])){a=a.slice(0,l);break}}return $.announce.of(`${n.state.phrase("current match")}. ${a} ${n.state.phrase("on line")} ${i.number}.`)}const Nb=$.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Hb=[Gt,ri.low(qb),Nb];class ih{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class di{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=i.facet(Kt).markerFilter;s&&(e=s(e,i));let r=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Bt,a=[],l=0,c=i.doc.iter(),h=0,u=i.doc.length;for(let d=0;;){let p=d==r.length?null:r[d];if(!p&&!a.length)break;let m,g;if(a.length)m=l,g=a.reduce((x,C)=>Math.min(x,C.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>u)break;g=p.to,a.push(p),d++}for(;dx.from||x.to==m))a.push(x),d++,g=Math.min(x.to,g);else{g=Math.min(x.from,g);break}}g=Math.min(g,u);let y=!1;if(a.some(x=>x.from==m&&(x.to==g||g==u))&&(y=m==g,!y&&g-m<10)){let x=m-(h+c.value.length);x>0&&(c.next(x),h=m);for(let C=m;;){if(C>=g){y=!0;break}if(!c.lineBreak&&h+c.value.length>C)break;C=h+c.value.length,h+=c.value.length,c.next()}}let b=Td(a);if(y)o.add(m,m,B.widget({widget:new nS(b),diagnostics:a.slice()}));else{let x=a.reduce((C,k)=>k.markClass?C+" "+k.markClass:C,"");o.add(m,g,B.mark({class:"cm-lintRange cm-lintRange-"+b+x,diagnostics:a.slice(),inclusiveEnd:a.some(C=>C.to>g)}))}if(l=g,l==u)break;for(let x=0;x{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new ih(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ih(i.from,r,i.diagnostic)}}),i}function xd(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(Kt).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(Qr))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function Gb(n,e){return n.field(gt,!1)?e:e.concat(z.appendConfig.of(Kd))}function vd(n,e){return{effects:Gb(n,[Qr.of(e)])}}const Qr=z.define(),wd=z.define(),kd=z.define(),gt=Te.define({create(){return new di(B.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Ni(t,n.selected.diagnostic,r)||Ni(t,null,r)}!t.size&&s&&e.state.facet(Kt).autoPanel&&(s=null),n=new di(t,s,i)}for(let t of e.effects)if(t.is(Qr)){let i=e.state.facet(Kt).autoPanel?t.value.length?nr.open:null:n.panel;n=di.init(t.value,i,e.state)}else t.is(wd)?n=new di(n.diagnostics,t.value?nr.open:null,n.selected):t.is(kd)&&(n=new di(n.diagnostics,n.panel,t.value));return n},provide:n=>[Vi.from(n,e=>e.panel),$.decorations.from(n,e=>e.diagnostics)]}),_b=B.mark({class:"cm-lintRange cm-lintRange-active"});function Jb(n,e,t){let{diagnostics:i}=n.state.field(gt),s,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:h})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(eCd(n,t,!1)))}const nh=n=>{let e=n.state.field(gt,!1);return!e||!e.panel?!1:(n.dispatch({effects:wd.of(!1)}),!0)},eS=xe.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(Kt);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(nPromise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(vd(this.view.state,i.reduce((s,r)=>s.concat(r))))},i=>{ze(this.view.state,i)})}}update(n){let e=n.state.facet(Kt);(n.docChanged||e!=n.startState.facet(Kt)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function tS(n,e,t){let i=[],s=-1;for(let r of n)r.then(o=>{i.push(o),clearTimeout(s),i.length==n.length?e(i):s=setTimeout(()=>e(i),200)},t)}const Kt=K.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...yt(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:sh,tooltipFilter:sh,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,s,r)=>e(i,s,r)||t(i,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function sh(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function iS(n,e={}){return[Kt.of({source:n,config:e}),eS,Kd]}function Pd(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;ir.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Cd(n,e,t){var i;let s=t?Pd(e.actions):[];return he("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},he("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=Ni(n.state.field(gt).diagnostics,e);p&&r.apply(n,p.from,p.to)},{name:c}=r,h=s[o]?c.indexOf(s[o]):-1,u=h<0?c:[c.slice(0,h),he("u",c.slice(h,h+1)),c.slice(h+1)],f=r.markClass?" "+r.markClass:"";return he("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${h<0?"":` (access key "${s[o]})"`}.`},u)}),e.source&&he("div",{class:"cm-diagnosticSource"},e.source))}class nS extends Ut{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return he("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class rh{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Cd(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class nr{constructor(e){this.view=e,this.items=[];let t=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)nh(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Pd(r.actions);for(let a=0;a{for(let r=0;rnh(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(gt).selected;if(!e)return-1;for(let t=0;t{for(let h of c.diagnostics){if(o.has(h))continue;o.add(h);let u=-1,f;for(let d=i;di&&(this.items.splice(i,u-i),s=!0)),t&&f.diagnostic==t.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),r=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),i++}});i({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.topl.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(gt),i=Ni(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:kd.of(i)})}static open(e){return new nr(e)}}function Qs(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function ps(n){return Qs(``,'width="6" height="3"')}const sS=$.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ps("#f11")},".cm-lintRange-warning":{backgroundImage:ps("orange")},".cm-lintRange-info":{backgroundImage:ps("#999")},".cm-lintRange-hint":{backgroundImage:ps("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function rS(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function Td(n){let e="hint",t=1;for(let i of n){let s=rS(i.severity);s>t&&(t=s,e=i.severity)}return e}class Rd extends Mt{constructor(e){super(),this.diagnostics=e,this.severity=Td(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,s=e.state.facet(Pr).tooltipFilter;return s&&(i=s(i,e.state)),i.length&&(t.onmouseover=()=>aS(e,t,i)),t}}function oS(n,e){let t=i=>{let s=e.getBoundingClientRect();if(!(i.clientX>s.left-10&&i.clientXs.top-10&&i.clientYe.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,oS(n,e)}let{hoverTime:s}=n.state.facet(Pr),r=setTimeout(i,s);e.onmouseout=()=>{clearTimeout(r),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,s)}}function lS(n,e){let t=Object.create(null);for(let s of e){let r=n.lineAt(s.from);(t[r.from]||(t[r.from]=[])).push(s)}let i=[];for(let s in t)i.push(new Rd(t[s]).range(+s));return N.of(i,!0)}const cS=Bu({class:"cm-gutter-lint",markers:n=>n.state.field(la),widgetMarker:(n,e,t)=>{let i=[];return n.state.field(la).between(t.from,t.to,(s,r,o)=>{s>t.from&&si.is(Ja)?i.value:t,n)},provide:n=>gr.from(n)}),hS=$.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Qs('')},".cm-lint-marker-warning":{content:Qs('')},".cm-lint-marker-error":{content:Qs('')}}),uS=Eu(Jb,{hideOn:xd}),Kd=[gt,$.decorations.compute([gt],n=>{let{selected:e,panel:t}=n.field(gt);return!e||!t||e.from==e.to?B.none:B.set([_b.range(e.from,e.to)])}),uS,sS],Pr=K.define({combine(n){return yt(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function fS(n={}){return[Pr.of(n),la,cS,hS,$d]}const Zd=1,Ue=Object.freeze({ready:"studio.ready",documentOpen:"document.open",documentReplace:"document.replace",documentChanged:"document.changed",documentSave:"document.save",documentSetReadOnly:"document.setReadOnly",documentResources:"document.resources",editorInsert:"editor.insert",editorFormat:"editor.format",editorSetTheme:"editor.setTheme",editorGetState:"editor.getState",diagnosticsPublish:"diagnostics.publish"});function dS(n,e={},t=null,i=null){return{protocolVersion:Zd,type:n,documentID:t,...i===null?{}:{sessionID:i},payload:e}}function pS(n){if(window.WKWebViewJavascriptBridge){n(window.WKWebViewJavascriptBridge);return}if(window.WKWVJBCallbacks){window.WKWVJBCallbacks.push(n);return}window.webkit?.messageHandlers?.iOS_Native_InjectJavascript&&(window.WKWVJBCallbacks=[n],window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage(null))}function nn(n,e,t={},i=null,s=()=>{},r=null){if(!n){s({result:"unavailable"});return}n.callHandler(e,dS(e,t,i,r),s)}function mS(n){const e={capabilities:["jsx","format","search","completion","diagnostics"]};nn(n,Ue.ready,e)}const gS=[{id:"$storage.getString",arguments:["key"],returns:"string",documentation:"Read a package-scoped string. Missing keys return an empty string."},{id:"$storage.setString",arguments:["key","value"],returns:"boolean",documentation:"Set a package-scoped string, limited to 256 KiB of UTF-8. Check the success result."},{id:"$storage.getJSON",arguments:["key"],returns:"json",documentation:"Read a package-scoped JSON object. Missing or invalid values return an empty object."},{id:"$storage.setJSON",arguments:["key","value"],returns:"boolean",documentation:"Store a valid JSON object, limited to 256 KiB encoded. Check the success result."},{id:"$storage.compareAndSetString",arguments:["key","expected","value"],returns:"boolean",minimumRuntimeVersion:"1.3",documentation:"Atomically replace a string only when it still matches expected. A missing key matches an empty string. Conflicts return false; reread and retry a bounded number of times. Requires the shared storage container."},{id:"$storage.compareAndSetJSON",arguments:["key","expected","value"],returns:"boolean",minimumRuntimeVersion:"1.3",documentation:"Atomically replace a JSON object if its current value equals expected, independent of property order. A missing key matches an empty object. Wrong types and conflicts return false. Requires the shared storage container."},{id:"$storage.remove",arguments:["key"],returns:"boolean",documentation:"Remove a key from this package only."},{id:"$storage.keys",arguments:[],returns:"string[]",documentation:"List keys in this package's namespace."},{id:"$storage.clear",arguments:[],returns:"boolean",documentation:"Clear this package's storage. Other packages are unaffected."}].map(n=>({minimumRuntimeVersion:"1.0",...n,preview:"initialState"})),OS=[{id:"$notifications.status",group:"notifications",value:{authorization:"authorized"},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift",operation:"read",mock:"editable"},{id:"$notifications.pending",group:"notifications",value:[],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift",operation:"read",mock:"editable"},{id:"$notifications.schedule",group:"notifications",value:{key:"daily",status:"scheduled"},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift",operation:"write",mock:"editable"},{id:"$notifications.cancel",group:"notifications",value:{key:"daily",status:"cancellationRequested"},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeNotifications.swift",operation:"write",mock:"editable"},{id:"$health.dailyStatistics",group:"health",value:{metric:"steps",unit:"count",aggregation:"sum",timeZone:"UTC",items:[{date:"2026-01-01",value:6840,hasSamples:!0}]},platforms:["ios"],authorization:"healthRead",notes:"Runtime 1.6. Read-only daily HealthKit statistics on installed iPhone/iPad widgets. Declare health and minimumRuntimeVersion 1.6, review Health access in native Settings. No separate System Access toggle. Missing readings are null/hasSamples false and cannot establish read denial. No raw samples, persistence or queries in future/Live Activity presentations. Preview fixtures never access real Health data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHealth.swift",operation:"read",mock:"editable"},{id:"$calendar.create",group:"calendar",value:{id:"sample.event",calendarID:"sample.calendar",status:"applied",replayed:!1},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift",operation:"write",mock:"editable"},{id:"$calendar.update",group:"calendar",value:{id:"sample.event",calendarID:"sample.calendar",status:"applied",replayed:!1},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data. Calendar writes need calendar and calendarWrite; updates are limited to events this installation created.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeCalendar.swift",operation:"write",mock:"editable"},{id:"$weather.forecast",group:"weather",value:{provider:"MET Norway",attribution:{text:"Weather data from MET Norway",url:"https://www.met.no/en/free-meteorological-data/Download-services"},latitude:37.33,longitude:-122.01,fetchedAt:"2026-01-01T12:00:00Z",isStale:!1,hours:[{time:"2026-01-01T12:00:00Z",temperatureC:21,windMetersPerSecond:2,precipitationMM:0,condition:"partlycloudy_day"}]},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeWeather.swift",operation:"read",mock:"editable"},{id:"$alarms.status",group:"alarms",value:{authorization:"authorized"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"read",mock:"editable"},{id:"$alarms.pending",group:"alarms",value:[],platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"read",mock:"editable"},{id:"$alarms.schedule",group:"alarms",value:{key:"focus",status:"scheduled",replayed:!1},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$alarms.cancel",group:"alarms",value:{key:"focus",status:"requested"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$alarms.stop",group:"alarms",value:{key:"focus",status:"requested"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$alarms.pause",group:"alarms",value:{key:"focus",status:"requested"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$alarms.resume",group:"alarms",value:{key:"focus",status:"requested"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["key"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeAlarms.swift",operation:"write",mock:"editable"},{id:"$documents.list",group:"documents",value:[{id:"550e8400-e29b-41d4-a716-446655440000",name:"Sample.json",type:"json",bytes:17},{id:"550e8400-e29b-41d4-a716-446655440001",name:"Sample.csv",type:"csv",bytes:24}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift",operation:"read",mock:"editable"},{id:"$documents.readJSON",group:"documents",value:{goal:12,done:7},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["id"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift",operation:"read",mock:"editable"},{id:"$documents.readCSV",group:"documents",value:{headers:["day","value"],rows:[["Monday","7"],["Tuesday","9"]],truncated:!1},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["id"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeDocuments.swift",operation:"read",mock:"editable"},{id:"$contacts.selected",group:"contacts",value:[{id:"sample.contact",name:"Alex Example",organization:"Sample",phones:["+1 202 555 0100"],emails:["alex@example.com"]}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeContacts.swift",operation:"read",mock:"editable"},{id:"$maps.search",group:"maps",value:[{name:"Example Park",address:"Sample address",latitude:37.33,longitude:-122.01}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift",operation:"read",mock:"editable"},{id:"$maps.geocode",group:"maps",value:[{name:"Example Park",address:"Sample address",latitude:37.33,longitude:-122.01}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["address"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift",operation:"read",mock:"editable"},{id:"$maps.reverseGeocode",group:"maps",value:[{name:"Example Park",address:"Sample address",latitude:37.33,longitude:-122.01}],platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift",operation:"read",mock:"editable"},{id:"$maps.snapshot",group:"maps",value:{image:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4z8DwHwAFgAI/ScLbtAAAAABJRU5ErkJggg==",width:256,height:256,provider:"Apple Maps"},platforms:["ios","macos"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeMaps.swift",operation:"read",mock:"editable"},{id:"$home.items",group:"home",value:[{id:"sample.light",name:"Living Room Lamp",kind:"power",value:!0,isCached:!0,metric:"power",unit:"boolean"},{id:"scene-sample",name:"Evening",kind:"scene",value:null,isCached:!0,metric:"scene",unit:"none"}],platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:[],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift",operation:"read",mock:"editable"},{id:"$home.setPower",group:"home",value:{id:"sample.light",value:!0,status:"acknowledged"},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift",operation:"write",mock:"editable"},{id:"$home.runScene",group:"home",value:{id:"scene-sample",status:"acknowledged",replayed:!1},platforms:["ios"],authorization:"systemAccess",notes:"Runtime 1.6. Installed widgets require manifest permission, explicit native System Access, system authorization where applicable, an active installation and bounded queries. Writes require a user action; future timelines and Live Activities cannot call this API. Web and CLI fixtures never access real device data.",arguments:["options"],asynchronous:!0,minimumRuntimeVersion:"1.6",nativeSource:"Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntimeHome.swift",operation:"write",mock:"editable"}],ca="2026-01-01T00:00:00Z",zt="2026-01-01T12:00:00Z",lo=(n,e)=>({value:n,unit:e,hasSamples:!0,start:ca,end:zt}),oh=(n,e,t)=>Object.entries(e).map(([i,s])=>({id:`$${n}.${i}`,group:n,value:s,legacy:[t,i]})),yS=[{id:"$music.isAvailable",group:"music",value:!0},{id:"$music.authorizationStatus",group:"music",value:"authorized"},{id:"$music.current",group:"music",value:{provider:"appleMusic",state:"playing",hasItem:!0,title:"Morning Light",artist:"ScriptWidget Sessions",album:"Focus",duration:224,position:86,capturedAt:zt}},{id:"$services.status",group:"services",value:"connected"},{id:"$services.profile",group:"services",value:{service:"github",subject:"42",username:"octocat",displayName:"Mona",publicRepositories:32,privateRepositories:8,followers:128,following:24}},...oh("device",{screen:{width:390,height:844,scale:3},language:"en",model:"iPhone",name:"My iPhone",battery:{level:.8,state:"unplugged"},systemVersion:"26.0",isdarkmode:!1,totalDiskSpace:128e9,freeDiskSpace:64e9},"device"),...oh("system",{appInfo:{name:"ScriptWidget",bundleId:"com.everettjf.scriptwidget",version:"27.1.2",build:"27012"},locale:"en_US",preferredLanguages:["en-US"],timeZone:{identifier:"UTC",abbreviation:"GMT",offsetSeconds:0},is24HourClock:!1,calendarInfo:{identifier:"gregorian",firstWeekday:1,minimumDaysInFirstWeek:1},systemUptime:3600,memory:{physical:8589934592},thermalState:"nominal",lowPowerMode:!1,brightness:.5,reduceMotionEnabled:!1,platform:"ios",hostName:"My iPhone",processName:"ScriptWidgetWidget",osVersionString:"Version 26.0",processorCount:6,activeProcessorCount:6},"system"),{id:"$photos.isAvailable",group:"photos",value:!0},{id:"$photos.authorizationStatus",group:"photos",value:"authorized"},{id:"$photos.requestAuthorization",group:"photos",value:!0},{id:"$photos.items",group:"photos",value:{status:"ready",items:[{id:"sample.photo",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiu08cKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fbPe3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQK/QnooooGFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK7TxwooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi++865Pl26H91CDwo9T6t6mhs5cTiVSXmX/ABx49v8Axdc+UmYbKM/u4vX/AGm9T+g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QqqMkngAV4h4w8ZPqjNpumMVthwzdC/8A9j/OnGNzOpUUFdkvjHxm2oFtL0psQdHcdX9h/s/z+leb0UVslY86c3N3YUUUUyAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvePgx8bNT+Gl8NN1Hdc6PM2ZIurRE9Xjz39V6H2PNeD0UjSlWlSkpwdmftNo+saZr+mQ6xo0y3FtcLvjkQ5BH9COhB5B4NaVflf8IPjJrHww1LyZN1zpU7Znt88g9N8eejDuOjDg9iP038P+INH8UaRDrmhTrcWs67kdf1BHUEdCDyDUNWPrsFjo4mPZ9Uf//S+tKKKK6z8/CiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACmSSRwxtLKwVVGSTwABSTTRW8TTzsERBkseABXhHi3xfLrchsrIlLVT9C5Hc+3oPz9nGNzOpVUFdkvi/xjJrDmw08lbVTyehkI7n29B+ftwNFFbJWPNnNyd2FFFFMkKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvWvhP8W9b+F+r+bBm40+dh9otieG7bk/uuB379D2x5LRSLp1JU5KcHZo//0/rSiiius/PwooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtYWublgiIMsx6AU26ureyt3urpwkaDJY14H4q8V3GvzeTDmO1Q/Kvdvdv8O1OMbmVWqoIk8WeLZtdlNrbZS1Q8Du59T/AEFcXRRWyVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/9T60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKKKKACq15eW2n2z3d44SNBkk0y/v7XTbV7y9cJGg5J/kPU18/eJfE114hucnKW6H5I/6n1P8qqMbmVWqoLzJPFHim58QXGxcx2yH5E9fdvf+VcpRRWqVjzpScndhRRRTJCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9X60ooorrPz8KKKKACiiigAooooAKKKKACiiigAooooAKo6jqNppVo17etsRfzJ9B6mm6pqlnpFm17ettReg7k+gHrXz34h8Q3niC786c7Y1+5GOij+p9TVRjcxq1lBeY/xH4ku/EN1vk+SFD8kfYe59TXOUUVqedKTbuwooopiCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9b60oqRYZX+4pP0FWV03UX+5byH6Kf8K6z4CzKVFay6Drj/AHLKc/SNv8KsJ4V8Tv8Ac026P0hf/CgfJLsYNFdOngvxc/TTbn8Y2H8xVhPAHjN+mnTfiMfzoH7KfZnIUV3C/Dbxu/TT3/FkH82qyvws8dt/y44+skf/AMVQV7Cp/K/uPPqK9JT4S+OG62yL9ZE/oTVlfg94zbqkK/WQf0BosP6vU/lZ5bRXra/Bjxc3V7Zfq7f0U1YX4JeKD9+4tR/wJz/7JRYf1Wr/ACnjlZmravZaLZte3rYUcADqx9BXpXjnwZH8PNCfXPEeoQKv3Y4k3GSV/wC6gIH4noB1r4t1vXL3Xrw3V2cAcIg6KPQf1PeqjG5y4mTo+7Jaj9e1+91+8NzcnCDhEHRR/j6msOiitTy223dhRRRTEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/Z",width:384,height:256},{id:"sample.photo.2",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/ayiiivVAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9D9rKKKK9UAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/0f2sooor1QCiiigAooooAKKKKACiiigAooooAKKKKACiq15eWun2r3t7IsUUY3MzHAApbW6tr62S8tHEkUqhlZeQQaduoFiiiikAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB/9L9rKKKK9UAooooAKKKKACiiigAooooAKKKKACs/VdVsNFsZNS1OQRQxjJJ/kB3J7Cquva/pnhvT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fL/AOG10ugeIGe40OVuV6tbknl09V7sv4jnIP6eabqVhrFhDqmlTJcW86h45EOVZT0INfMYrCyoSs9u561Ksqiui7RRRXKan//R+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigApGZUUu5wBySe1NkkSJDJIQqqMkngADua+f8Axv46fWGbStJYrag4Zuhk/wDsf51dOm5uyJbsT+OPHbamX0jR2xbDh5B1k9h/s/z+leV0UV6UIKKsjJu4UUUVYgooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACvoL4IfHTVfhdfjTNS3XWiztmSHq0RPWSPPf1Xo3sea+faKzq0o1IuE1oVGbi+aJ+5Gi61pXiLS4Na0SdLm1uF3xyIcgj+hHQg8g8HmtSvyU+DHxs1r4Vap5Em660i4bM9tnkHp5keeA47jow4PYj9UPDviPRfFmjQa/4fnW5tbhdyOv6gjqCDwQeQa+ZxeElQl5Hq0ayqLzP//S+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACo5ZYoI2mmYIiDLMTgADuaSeeG2ha4uGCIgyzHgACvnbxp42m1+Q2NgSlmp+hkI7n29B+J9tKVJzdkTKViXxt44k1x203TSUtFPJ6GQjuf9n0H4n284oor0oxUVZGLdwoooqgCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAr2H4QfGLXvhTrPm2+bjTZ2H2m1J4btvT+64Hfv0PbHj1FROEZxcZrQcZOLuj//T+oKKKK+zPKCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKgubm3s7d7q6cRxxjLMegFNu7y2sLZ7y8cRxxjLMe1fN/jDxlc+JJ/IgzHaIflTux/vN7+g7VpSpObJlKxL4y8aXHiKY2lpmOzQ8L0Lkd2/oK4OiivSjFRVkYt3CiiiqAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//1PqCiiivszygooooAKKKKACiiigAooooAKKKKACiiigAooooAKqX19aabave3riOKMZJP+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AAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/byiiiu09MKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKK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n/AJaqP/Zh39Rz617HXlTg4PlZyyjZ2YUUUVAgooooAKKKKACiiigAooooAKKKKACiiigAryieQzTPKerMT+der15RPGYZniPVWI/KsK/Q/O/EDm5KFtry+/S36kVFFFcx+ZhRRRQBLBIYZklHVWB/KvV68ogjM0yRDqzAfnXq9dNDqfpnh/zcle+14/frf9Aooorc/RAooooAKKKKAP/U/byiiiu09MKKKKACiiigAooooAK4Dxx49sPCNr5SYmvZB+7i9P8Aaf0H6n8zWd4++Itr4XibTtOIlv2HTqsYPdvf0H4njr8qXl5dahcve3shllkO5mY5JNdVDD83vS2NYU76sn1TVL/Wb59R1KQyzSHJY/yHoB2FZ9FFeilbY6AooooAKKKKACiiigCSGaW3lWeBijoQysDggjoQa+s/h349i8U2n2G/IW/hX5h08xR/EP6j+lfJFW7G+u9MvI7+xcxzRHcrDqDWVWkqisROPMj75orhvA3jW08X6duOI7uIATR/+zL/ALJ/TpXc15couLszlatowoooqQCiiigAooooAKKKKACiiigAoor5v+OXx2svh5av4f8ADzLPrUq/VbdSOGf1b+6v4njAOlOnKpLlgioU3N8sS58bfjlp/wANrJtH0crca1MvyJ1WEHo8nv8A3V79Tx14j4Z/GOx+IsK2eq7bfWEX94g4WbA++nv/AHl7dRx0+Ab+/vdUvZdR1GVp552LySOcszHkkk0y0u7mxuY7yykaKWJgyOpwykdCCK9eeWQlS5Hv3FnPDtLMsI8LN2e6fZ/5H6wUV4f8HfixB47iXw/rDLFq6D5QcKLgDunbeO6/iOMge6yQTQnEqMp9xivmq1CdGThNH4HmeS4vLqjpYqm1br0foyKipY4JpjiJGY+wzXRWHh2aRhJffIv90dT/AIVnGLexngMpxWOkoYeDfn0Xqw8O2DSTfbpB8qcL7n/61drTI40iQRxjao4AFPrshHlVj9pyXKoZbho4eDu92+7CiiiqPWCiiigAooooA//V/byiiiu09MKKKKACiiigArxz4h/EuLQw+jaEwe8PDydVi/xb+Xf0rK+InxPFr5mheGpMy8rLOv8AD6qh9fU9u3PT50JLEsxyTXb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AUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//2Q==",width:384,height:256},{id:"sample.photo.4",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABgKADAAQAAAABAAABAAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgBAAGAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICBAICBAYEBAQGCAYGBgYICggICAgICgwKCgoKCgoMDAwMDAwMDA4ODg4ODhAQEBAQEhISEhISEhISEv/bAEMBAwMDBQQFCAQECBMNCw0TExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE//dAAQAGP/aAAwDAQACEQMRAD8A/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//Q/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//R/biiiiuc9UKKKKACiiigAooooAKKKKACiiigAooooAKKrXl5a6fave3sgiijG5mY4AFOtbq3vbZLu0cSRSAMrLyCDQO3UnooooEFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9L9uKKKK5z1QooooAKKKKACiiigAooooAKKKKACs/VNUsNGsX1HUpBFDGMkn+Q9Sewqtruvab4c099S1STYi8AfxMeyqO5NfInjDxnqfi+9865PlwIf3UIPCj1Pq3qaaR0UKDqPyL3jjx5f+LrrykzDZRn93Fnr/tN6n9B+p2Phv4/fw3cjStUYmxlbr18pj3H+ye4/Ed8+U0U7HqOlFx5LaH6BI6SoJIyGVhkEcgg9xTq+afhh8Q/7MdPDmtv/AKMxxDIx/wBWT/CT/dPb0+nT6WqTyKtJ05WYUUUUGQUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFRTzw20LXFwwREGWY9AKlrxX4i6+9xd/2HbtiOLBkx/E3UD6Afr9K78twEsbWVGO3V9kcOY46ODoutLfou7DX/iLeXDtb6H+5jHHmEZZvoDwB+v0rzu5vr28YvdzPKT3Zif51Vor9KwmAoYWPLRjbz6/efnOKx9bEy5q0r+XT7i1bX17ZsHtJniI7qxH8q9E0D4i3lu62+ufvozx5gGGX6gcEfr9a8xooxeAoYqPLWjfz6/eGFx9bDS5qMreXT7j6zgnhuYVuLdg6OMqw6EVLXivw6197e7/sO4bMcuTHn+FupH0I/X617VX5rmWAlgqzoy26Puj9Gy7HRxlFVo79V2YUUUVwHcFFFFABRR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5tekNlYkpaKfoXI7n29B+J9k3Y2o0XUdkS+MvGsmtO2nacSlop5PQyEdz7eg/E155RRWbdz1YQUFyxCiiikWFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABXrvwk+L2ufCzWPNt83GnTsPtNqTw3ben91wO/foe2PIqKDOpTjUi4TV0f/T+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACobi4gtIHublwkaDLMegFNu7u2sbZ7u7cRxoMsx7V87+LfF9z4in8iHMdoh+VO7H+839B2pN2NqNF1H5EvjDxjP4gmNra5jtEPC93I7t/QVw1FFZtnqwgorliFFFFIsKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//9T60ooorI+1CiiigAooooAKKKKACiiigAooooAKKKKACiiigAqre3trp1q95euI40GST/nrTNQ1C00u0e9vnCRoOSf5D1Jr5y8U+KrvxJdZOY7dD+7j/qfU/wAqTdjejRdR+RL4r8WXXiO52LmO1Q/Inr/tN7/yrkKKKzPVjFRVkFFFFIoKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP//V+tKKKKyPtQooooAKKKKACiiigAooooAKKKKACiiigAqhqep2ekWb318+yNPzJ9AO5NM1XVrLRbJr6/fai9B3Y9gB3NfN/iPxJe+I7zz7j5Yl/wBXGOij+p9TUt2OihQdR+RJ4m8T3niO78yT5IEP7uPsPc+prmaKKg9SMVFWQUUUUigooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/W+tKKkWKV/uKT9BVlNO1CT7kEjfRT/hWR9rcpUVqpoWuP9yznP0jb/CrK+FvE7/c066P0hf8AwoFzLuYNFdMvgvxc/TTbn8Y2H8xVlfAPjJ+mnTfiMfzoF7SPc5Ciu4X4b+N36ae/4sg/masL8LfHb/8ALjj6yR//ABVIXtYfzI8/or0lPhL44brbIv1kT+hqynwf8Zt1SFfrIP6A0C9tD+ZHltFetL8GPFzdXt1+rt/RTVlfgl4oP37i1H/AnP8A7JQL6xT/AJjxysrWNZsdDsmvr5sKOAB1Y+gHrXpXjvwfF8OdBfXfEmoQKv3Yok3GSV/7qAgZ9z0A618Q69r194gvTd3hwBwiDoo9B/U96TdjrwtNVveWw/xB4hvvEV6bm6O1F4SMdFH+PqawaKKg9dJJWQUUUUhhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH/9k=",width:384,height:256}],unavailableCount:0,fetchedAt:zt,source:"system",stale:!1}},{id:"$calendar.isAvailable",group:"calendar",value:!0},{id:"$calendar.authorizationStatus",group:"calendar",value:"authorized"},{id:"$calendar.requestAuthorization",group:"calendar",value:!0},{id:"$calendar.calendars",group:"calendar",value:[{id:"sample.personal",title:"Personal"}]},{id:"$calendar.events",group:"calendar",value:{status:"ready",items:[{id:"sample.event",calendarID:"sample.personal",title:"Read and recharge",start:"2026-01-01T15:00:00Z",end:"2026-01-01T15:30:00Z",allDay:!1}],fetchedAt:zt,source:"system",stale:!1,truncated:!1}},{id:"$reminders.isAvailable",group:"reminders",value:!0},{id:"$reminders.authorizationStatus",group:"reminders",value:"authorized"},{id:"$reminders.requestAuthorization",group:"reminders",value:!0},{id:"$reminders.lists",group:"reminders",value:[{id:"sample.reminders",title:"Personal"}]},{id:"$reminders.items",group:"reminders",value:{status:"ready",items:[{id:"sample.reminder",listID:"sample.reminders",title:"Read a chapter",due:"2026-01-01T16:00:00Z",hasTime:!0,completed:!1,completedAt:null,priority:0}],fetchedAt:zt,source:"system",stale:!1,truncated:!1}},{id:"$reminders.create",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$reminders.update",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$reminders.setCompleted",group:"reminders",value:{id:"sample.reminder",listID:"sample.reminders",status:"applied",replayed:!1}},{id:"$health.authorizationStatus",group:"health",value:"notDisclosed"},{id:"$health.sleepSummary",group:"health",value:{start:ca,end:zt,timeZone:"UTC",hasSamples:!0,totalSleepSeconds:27e3,inBedSeconds:30600,awakeSeconds:1800,stages:{unspecified:0,core:16200,deep:5400,rem:5400},sourceCount:1,truncated:!1,conflictSeconds:0,aggregation:"union-awake-rem-deep-core-unspecified"}},{id:"$health.activitySummary",group:"health",value:{date:"2026-01-01",timeZone:"UTC",hasSamples:!0,moveMode:"activeEnergy",move:{value:480,goal:600,unit:"kcal"},exercise:{value:26,goal:30,unit:"min"},stand:{value:9,goal:12,unit:"count"}}},{id:"$health.workouts",group:"health",value:{start:ca,end:zt,timeZone:"UTC",hasSamples:!0,truncated:!1,items:[{id:"550e8400-e29b-41d4-a716-446655440000",activity:"running",start:"2026-01-01T09:00:00.000Z",end:"2026-01-01T09:45:00.000Z",duration:2700,energyKcal:285,distanceMeters:5200}]}},{id:"$health.isAvailable",group:"health",value:!0},{id:"$health.requestAuthorization",group:"health",value:!0,legacy:["health"]},{id:"$health.stepCountToday",group:"health",value:lo(6840,"count"),legacy:["health.stepCountToday"]},{id:"$health.activeEnergyToday",group:"health",value:lo(420,"kcal"),legacy:["health.activeEnergyToday"]},{id:"$health.heartRateLatest",group:"health",value:lo(72,"bpm"),legacy:["health.heartRateLatest"]},{id:"$location.isAvailable",group:"location",value:!0},{id:"$location.authorizationStatus",group:"location",value:"authorizedWhenInUse"},{id:"$location.isAuthorizedForWidgetUpdates",group:"location",value:!0},{id:"$location.requestAuthorization",group:"location",value:!0,legacy:["location.authorization"]},{id:"$location.current",group:"location",value:{latitude:37.3349,longitude:-122.009,altitude:0,accuracy:10,verticalAccuracy:10,speed:-1,course:-1,timestamp:zt,accuracyAuthorization:"full",age:0,isStale:!1},legacy:["location"]}],AS={music:{platforms:["ios"],authorization:"musicRead",notes:"Runtime 1.4. Read-only Music app playback, not every audio player. Requires an installed owner, music permission and Music library approval in native Settings. current() is asynchronous and returns provider, state, hasItem, nullable title/artist/album/duration/position and capturedAt. State may be playing while details are absent (Home Sharing). Native player access is main-thread-only: synchronous hosts prepare one snapshot before JSC waits; background previews capture on the main queue. No playback/queue mutation, scans, artwork, credential or subscription inference. No live queries in future entries/Live Activities. Main system-player API is unavailable on macOS; Web supplies editable samples, never actual device access."},services:{platforms:["ios","macos"],authorization:"serviceAccount",notes:"Runtime 1.4: status(service) and profile(service) are asynchronous. Only provider: github. Unknown providers reject with service_operation. Requires an installed owner and services permission. profile additionally requires network and api.github.com in networkDomains, a native connected GitHub account and explicit owner grant. Native Settings handles credentials; scripts cannot log in or obtain tokens. profile returns service, subject, username, displayName, publicRepositories, privateRepositories, followers and following (missing values are null). No live queries in future entries or Live Activities. Eight shared data queries; native requests also share the eight concurrent/32 total network budget, while Web uses its existing preview network budget. Web uses editable best-state samples only; it never authenticates or sends these requests."},photos:{platforms:["ios","macos"],authorization:"photosRead",notes:"Requires photos permission and explicit native photo/album selection (none by default). Limited Photos authorization is supported. items({limit:1..4,offset:0..63,maxAgeSeconds:0..86400}) returns bounded, metadata-stripped JPEG thumbnails as image data URLs. Four 768px / 128KiB thumbnails at most; private snapshots expire after 24h and are rechecked against current access, selected sources and asset revisions. Cloud-only items report unavailableCount; download them in Photos first. Future timeline/Live Activity presentations read matching snapshots only. Web uses editable sample data and photosSelection IDs; no actual library access."},reminders:{platforms:["ios","macos"],authorization:"remindersRead",notes:"Requires reminders in widget.json and full system Reminders access. Reads require native Settings selected lists. create/update/setCompleted additionally require remindersWrite and a native declared action, stable requestID, durable replay receipts and an unchanged selected list. Web writes update preview-only items/receipts; receipt identities are derived from that state, with configurable API errors. Use lists() for IDs. items() selects pending due dates or completed completion dates in a positive window of at most 31 days, up to 50 items. Undated pending reminders are excluded. remindersSelection mocks the user scope without granting permission."},calendar:{platforms:["ios","macos"],authorization:"calendarRead",notes:"Requires calendar in widget.json and full system Calendar access. The user's native Settings source selection limits metadata, events and cached snapshots; scripts cannot enlarge it. Use calendars() for permitted IDs and show setup when no sources are selected. Queries are read-only, limited to 31 days and 50 items. Preview calendarSelection simulates this scope without granting package permission."},device:{platforms:["ios","macos"],authorization:"none",notes:"Device values depend on hardware. Some legacy Mac values are placeholders; inspect the API documentation before using them as measurements."},system:{platforms:["ios","macos"],authorization:"none",notes:"System metadata, not whole-device CPU, FPS or network traffic monitoring. Hardware-specific values may be unavailable."},health:{platforms:["ios"],authorization:"healthRead",notes:"Read-only HealthKit. Request access in the app. Runtime 1.4 adds sleepSummary (up to 7 days / 256 samples, union with explicit stage-conflict precedence), activitySummary (one local Gregorian day including active-energy or move-time mode and optional goals), and workouts (up to 31 days / 50 fully-contained summaries, optional kcal/meters). These require an explicit health manifest; all share the query budget and cannot run in future/Live Activity presentations. No Health readings are persisted by the API. Authorization completion does not reveal whether individual read types were granted; empty results must not be labelled permission denied. API 1.3 readings add hasSamples: false means no readable samples, never a read-denial verdict. Existing value/unit/start/end fields remain."},location:{platforms:["ios"],authorization:"locationWhenInUse",notes:"Package 2.0 requires location permission. Request system access in the app. Widgets also require isAuthorizedForWidgetUpdates. Cache is rechecked against authorization and precision, discarded after 24 hours or revocation, and reports age/isStale."}},bS=[...yS.map(n=>{const e=n.id.split(".")[1],t=n.group==="music"&&e==="current"||n.group==="services"||["calendar","reminders","photos"].includes(n.group)&&!["isAvailable","authorizationStatus"].includes(e)||n.group==="health"&&!["isAvailable","authorizationStatus"].includes(e)||n.group==="location"&&["current","requestAuthorization"].includes(e),i=n.group==="health"&&["sleepSummary","activitySummary","workouts"].includes(e)||n.group==="location"&&["current","requestAuthorization"].includes(e)||["calendar","reminders","photos"].includes(n.group)&&["events","items"].includes(e);return{...n,...AS[n.group],minimumRuntimeVersion:["music","services","reminders","photos"].includes(n.group)||n.group==="health"&&["sleepSummary","activitySummary","workouts"].includes(e)?"1.4":["calendar"].includes(n.group)||["$health.authorizationStatus","$location.isAuthorizedForWidgetUpdates"].includes(n.id)?"1.3":"1.0",arguments:n.group==="services"?["service"]:n.group==="reminders"&&["create","update","setCompleted"].includes(e)?["options"]:i?["options?"]:[],...n.group==="reminders"&&["create","update","setCompleted"].includes(e)?{authorization:"remindersWrite"}:{},asynchronous:t,nativeSource:`Shared/ScriptWidgetRuntime/Widget/API/ScriptWidgetRuntime${n.group[0].toUpperCase()}${n.group.slice(1)}.swift`,operation:n.group==="reminders"&&["create","update","setCompleted"].includes(e)?"write":e==="requestAuthorization"?"authorization":["isAvailable","authorizationStatus","isAuthorizedForWidgetUpdates"].includes(e)?"availability":"read",mock:"editable"}}),...OS],$e={globalProperties:{background:{type:"color",documentation:"Background color, hex value, or named color."},backgroundMaterial:{type:"enum",values:["none","ultraThin","thin","regular","thick","ultraThick"],documentation:"Runtime API 1.4. Public SwiftUI frosted material inside the widget, not Home Screen wallpaper blur or system Liquid Glass. At most four material backgrounds per tree. background supplies an opaque-composited Reduce Transparency fallback. In accented/vibrant mode local material is omitted for system rendering; none keeps the ordinary background."},color:{type:"color",documentation:"Foreground color, hex value, or named color."},font:{type:"enum",values:["largeTitle","title","title2","title3","headline","subheadline","body","callout","footnote","caption","caption2"],documentation:"Semantic text style."},fontWeight:{type:"enum",values:["ultraLight","thin","light","regular","medium","semibold","bold","heavy","black"],documentation:"Font weight."},fontDesign:{type:"enum",values:["default","rounded","serif","monospaced"],documentation:"Font design."},frame:{type:"number|string",documentation:'Square size (64 or "64"), width,height ("64,48"), or flexible frame ("max", "max,48").'},padding:{type:"number|string",documentation:"Padding amount or edge description."},corner:{type:"number",documentation:"Corner radius."},opacity:{type:"number",documentation:"Opacity from 0 through 1."},alignment:{type:"enum",values:["center","leading","trailing","top","bottom","topLeading","topTrailing","bottomLeading","bottomTrailing","firstTextBaseline","lastTextBaseline"],documentation:"Layout alignment."},clip:{type:"enum",values:["circle","rect","capsule","ellipse"],documentation:"Clip the view to a shape."},rotation:{type:"number",documentation:"Rotation in degrees."},rotation3d:{type:"string",documentation:"Static degree,x,y,z rotation with four finite numbers and a nonzero axis. Invalid values are ignored; axis magnitude is normalized. Reduce Motion removes the tilt. This does not read device motion or provide parallax."},shadow:{type:"string",documentation:"Shadow color, radius, and offset description."},animation:{type:"string",documentation:"iOS public SwiftUI scheduled clock/swing effect. Mac renders static standard-clock poses; other effects remain at rest. Signed clockCustom intervals specify a half-turn (full cycle = 2 * abs(interval)), minimum magnitude 0.25 seconds. App previews can animate; WidgetKit decides cadence and may freeze. Reduced motion/luminance freezes standard clock poses and keeps custom/swing effects at rest. Dynamic scripts are not rerun on animation ticks."},widgetAccentable:{type:"boolean",documentation:"Group this view into the accent layer in tinted and vibrant widget appearances."},linkurl:{type:"url",documentation:"Widget deep link URL."}},components:{VStack:{documentation:"Arrange children vertically.",children:!0,properties:{spacing:{type:"number"}}},HStack:{documentation:"Arrange children horizontally.",children:!0,properties:{spacing:{type:"number"}}},ZStack:{documentation:"Overlay children.",children:!0,properties:{}},VGrid:{documentation:"Vertical lazy grid.",children:!0,properties:{columns:{type:"string",required:!0},spacing:{type:"number"},alignment:{type:"enum",values:["leading","center","trailing"]}}},HGrid:{documentation:"Horizontal lazy grid.",children:!0,properties:{columns:{type:"string",required:!0},spacing:{type:"number"},alignment:{type:"enum",values:["top","center","bottom","firstTextBaseline","lastTextBaseline"]}}},Text:{documentation:"Display text content.",children:!1,properties:{text:{type:"string"}}},Date:{documentation:"Display a formatted date.",children:!1,properties:{date:{type:"date|number",required:!0},style:{type:"enum",values:["time","date","relative","offset","timer"]}}},Image:{documentation:"Display a bundled, remote, or SF Symbol image.",children:!1,properties:{systemName:{type:"string"},name:{type:"string"},id:{type:"string",deprecated:"Use name."},url:{type:"url"},src:{type:"url",deprecated:"Use url."},ratio:{type:"number"},mode:{type:"enum",values:["fit","fill"]},accentedRenderingMode:{type:"enum",values:["accented","desaturated","accentedDesaturated","fullColor"],documentation:"Control how the image is rendered in tinted and clear widget appearances."}}},Gif:{documentation:"Display a bounded package GIF using system decoding: up to 8 MiB input and 1,048,576 canvas pixels. iOS retains at most 60 downsampled frames / 4 MiB decoded pixels; more frames fall back to the first frame. Mac, Reduce Motion and reduced luminance use a static first frame. Active iOS previews use public SwiftUI timing with variable frame delays. Snapshots, inactive scenes, Mac and accessibility fallbacks use the first frame. No private clock bridge or continuous WidgetKit guarantee.",children:!1,properties:{file:{type:"string",required:!0}}},Spacer:{documentation:"Flexible layout space.",children:!1,properties:{minLength:{type:"number"}}},Rect:{documentation:"Rectangle shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},RoundedRect:{documentation:"Filled rounded rectangle.",children:!1,properties:{radius:{type:"number"}}},Capsule:{documentation:"Capsule shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Ellipse:{documentation:"Ellipse shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Circle:{documentation:"Circle shape.",children:!1,properties:{trim:{type:"number|string"},stroke:{type:"string"}}},Gauge:{documentation:"Display a gauge or instrument.",children:!1,properties:{type:{type:"string"},value:{type:"number"},style:{type:"enum",values:["circular","linear"]},text:{type:"string"},current:{type:"string"},min:{type:"string"},max:{type:"string"},angle:{type:"number"},thickness:{type:"number"},needleColor:{type:"color"},label:{type:"string"},title:{type:"string"},sections:{type:"string"}}},Chart:{documentation:"Render chart data.",children:!1,availability:{ios:"16.0",macos:"26.0"},properties:{type:{type:"enum",values:["bar","bar-x","bar-y","bar-gantt","line","point","line-point","area","rect","rule-x"]},data:{type:"json",required:!0},category:{type:"boolean"},hideLegend:{type:"boolean"},hideXAxis:{type:"boolean"},hideYAxis:{type:"boolean"}}},Link:{documentation:"Open a URL when selected.",children:!0,properties:{url:{type:"url",required:!0}}},Divider:{documentation:"Horizontal or vertical separator.",children:!1,properties:{thickness:{type:"number"},axis:{type:"enum",values:["horizontal","vertical"]}}},Line:{documentation:"Fixed-length line.",children:!1,properties:{thickness:{type:"number"},length:{type:"number"},axis:{type:"enum",values:["horizontal","vertical"]}}},Icon:{documentation:"SF Symbol icon.",children:!1,properties:{systemName:{type:"string",required:!0},size:{type:"number"}}},Label:{documentation:"Text paired with an SF Symbol.",children:!1,properties:{title:{type:"string"},systemName:{type:"string",required:!0}}},Progress:{documentation:"Linear or circular progress.",children:!1,properties:{value:{type:"number",required:!0},total:{type:"number"},label:{type:"string"},style:{type:"enum",values:["linear","circular"]},trackColor:{type:"color"},thickness:{type:"number"}}},Ring:{documentation:"Circular progress ring.",children:!1,properties:{value:{type:"number",required:!0},thickness:{type:"number"},trackColor:{type:"color"}}},Badge:{documentation:"Compact status badge.",children:!1,properties:{text:{type:"string"},radius:{type:"number"}}},Chip:{documentation:"Outlined metadata chip.",children:!1,properties:{text:{type:"string"},radius:{type:"number"},borderColor:{type:"color"}}},Stat:{documentation:"Title, value, and subtitle statistic.",children:!1,properties:{title:{type:"string"},value:{type:"string",required:!0},subtitle:{type:"string"},mutedColor:{type:"color"}}},Button:{documentation:"Interactive widget button. Use actionID to share a declared Package 2.0 action with Siri, Shortcuts, and Control Widgets.",children:!0,availability:{interactiveIos:"17.0"},requiredAny:["action","onClick","actionID"],properties:{action:{type:"enum",values:["reload"],conflicts:["actionID"]},onClick:{type:"function",conflicts:["actionID"]},actionID:{type:"action-id",conflicts:["action","onClick"]}}},Toggle:{documentation:"Interactive widget toggle. A declared actionID requires a package-relative storage stateKey.",children:!0,availability:{interactiveIos:"17.0"},requiredAny:["onClick","actionID"],properties:{on:{type:"boolean",required:!0},onClick:{type:"function",conflicts:["actionID"]},actionID:{type:"action-id",requires:["stateKey"],conflicts:["onClick"]},stateKey:{type:"storage-key",requires:["actionID"]}}}},functions:{...Object.fromEntries(gS.map(n=>[n.id,n])),...Object.fromEntries(bS.map(n=>[n.id,{documentation:n.notes,minimumRuntimeVersion:n.minimumRuntimeVersion,arguments:n.arguments,returns:n.asynchronous?"Promise":typeof n.value=="object"?"json":typeof n.value}])),"$icloud.readJSON":{documentation:"Read cached JSON and revision; conflicts preserve all heads. Requires icloud permission and a native connection. Never certifies upload.",arguments:["name"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.writeJSON":{documentation:"Save a new immutable JSON revision locally from a user action. Requires the revision from readJSON. Background exchange is eventual.",arguments:["name","value","expectedRevision"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.resolveJSON":{documentation:"Explicitly resolve all observed conflicting heads into a new revision. Stale tokens fail; originals remain.",arguments:["name","value","expectedRevision"],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.sync":{documentation:"Exchange materialized revisions with iCloud; requires a user action. Upload completion is unknown.",arguments:[],returns:"Promise",minimumRuntimeVersion:"1.5"},"$icloud.status":{documentation:"Read native connection state. In the app, explicitly connect packages to separate stores for isolation or the same store ID to share JSON documents. Scripts cannot choose store IDs. Sync is eventual; local $storage is not migrated. Web uses preview mocks.",arguments:[],returns:"Promise",minimumRuntimeVersion:"1.5"},"$file.exists":{documentation:"Return whether a regular file is locally present inside this package, including binary assets. Missing files, directories, unsafe paths and links return false. Does not download iCloud files or read outside the package. Web preview uses workspace file presence.",arguments:["path"],returns:"boolean",minimumRuntimeVersion:"1.3"},"$file.read":{documentation:"Read package-relative UTF-8 text. Missing or unavailable files return an empty string.",arguments:["path"],returns:"string"},"$file.readJSON":{documentation:"Read a package-relative JSON object.",arguments:["path"],returns:"json"},fetch:{documentation:"Perform a network request and return its response text. Existing HTTP methods keep this string result."},"$http.getResponse":{documentation:"GET response metadata: {status, body, headers}. Headers are limited to content-type, cache-control, expires, last-modified, date and retry-after (lowercase; each at most 2048 UTF-8 bytes). Network permissions, public-host policy, redirects, body limits and timeline restrictions still apply. HTTP error statuses resolve; transport errors reject.",arguments:["url","options?"],returns:"Promise",minimumRuntimeVersion:"1.3"},importJS:{documentation:"Import a package-relative JavaScript file."},"$dataSource.request":{documentation:"Call a declared Data Source Plugin operation. Requires Package 2.0 plugins, network permission, and networkDomains declarations.",arguments:["pluginID","operationID","parameters"],returns:"Promise"},"$xml.parse":{documentation:"Parse up to 256 KiB of XML into {name, attributes, text, children}. DTDs and external entities are rejected; depth and node limits apply.",arguments:["source"],returns:"XMLNode"}}};function SS(n,e){const t=Object.entries(e.properties??{}).filter(([,s])=>s.required).map(([s,r])=>`${s}=${r.type.includes("number")||r.type==="boolean"?"{${}}":'"${}"'}`).join(" "),i=t?` ${t}`:"";return e.children?`<${n}${i}> + \${} +`:`<${n}${i} />`}const ah=Object.entries($e.components).map(([n,e])=>({label:n,type:"class",detail:`ScriptWidget · ${Object.keys(e.properties??{}).length} properties`,info:e.documentation,apply:SS(n,e)}));function xS(n){const e=n.match(/<([A-Za-z][\w]*)\b([^<>]*)$/);return!e||e[2].includes(">")?null:{name:e[1],attributes:e[2]}}function vS(n,e){const t=$e.components[n];return t?Object.entries({...$e.globalProperties,...t.properties??{}}).filter(([i])=>!e.has(i)).map(([i,s])=>({label:i,type:"property",detail:s.required?`${s.type} · required`:s.type,info:s.deprecated?`Deprecated: ${s.deprecated}`:s.documentation,apply:`${i}=${s.type.includes("number")||s.type==="boolean"?"{${}}":'"${}"'}`})):[]}function wS(n){const e=n.match(/<([A-Za-z][\w]*)\b[^<>]*\b([A-Za-z][\w]*)\s*=\s*["']([^"']*)$/);if(!e)return null;const t=$e.components[e[1]]?.properties?.[e[2]]??$e.globalProperties[e[2]];return t?.values?{typed:e[3],values:t.values}:null}function kS(n){const e=n.state.doc.sliceString(Math.max(0,n.pos-1200),n.pos),t=wS(e);if(t)return{from:n.pos-t.typed.length,options:t.values.map(o=>({label:o,type:"enum"})),validFor:/^[\w-]*$/};const i=n.matchBefore(/<[A-Za-z]*$/);if(i)return{from:i.from+1,options:ah,validFor:/^[A-Za-z]*$/};const s=xS(e);if(s&&/(?:\s|^)\w*$/.test(s.attributes)){const o=n.matchBefore(/[A-Za-z][\w]*$/),a=new Set([...s.attributes.matchAll(/\b([A-Za-z][\w]*)\s*=/g)].map(l=>l[1]));return{from:o?.from??n.pos,options:vS(s.name,a),validFor:/^[A-Za-z][\w]*$/}}const r=n.matchBefore(/\$[A-Za-z]+\.[A-Za-z]*$/);if(r){const o=r.text.slice(0,r.text.indexOf(".")+1),a=Object.entries($e.functions).filter(([l])=>l.startsWith(o));return a.length?{from:r.from+o.length,options:a.map(([l,c])=>({label:l.slice(o.length),type:"function",detail:c.returns,info:c.documentation})),validFor:/^[A-Za-z]*$/}:null}return n.explicit?{from:n.pos,options:ah,validFor:/^[A-Za-z]*$/}:null}function lh(n,e){const t=[];for(let i=n.node.firstChild;i;i=i.nextSibling)i.name===e&&t.push(i);return t}function Md(n){const e=[];return Ce(n).iterate({enter(t){if(t.name!=="JSXOpenTag"&&t.name!=="JSXSelfClosingTag")return;const s=lh(t,"JSXIdentifier")[0];s&&e.push({name:n.doc.sliceString(s.from,s.to),from:s.from,to:s.to,attributes:lh(t,"JSXAttribute").map(r=>{const o=r.firstChild;return o?{name:n.doc.sliceString(o.from,o.to),from:o.from,to:o.to}:null}).filter(Boolean)})}}),e}function Ed(n){const e=[];for(const t of Md(n.state)){const i=$e.components[t.name];if(!i)continue;const s=new Set([...Object.keys($e.globalProperties),...Object.keys(i.properties??{})]),r=new Set(t.attributes.map(o=>o.name));for(const o of t.attributes){s.has(o.name)||e.push({from:o.from,to:o.to,severity:"warning",message:`“${o.name}” is not supported by <${t.name}>.`});const a=i.properties?.[o.name]??$e.globalProperties[o.name];a?.deprecated&&e.push({from:o.from,to:o.to,severity:"warning",message:`${o.name} is deprecated. ${a.deprecated}`})}for(const[o,a]of Object.entries(i.properties??{}))if(a.required&&!r.has(o)&&e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> requires the “${o}” property.`}),r.has(o)){for(const l of a.requires??[])r.has(l)||e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> “${o}” requires the “${l}” property.`});for(const l of a.conflicts??[])r.has(l)&&o cannot combine “${o}” with “${l}”.`})}i.requiredAny?.length&&!i.requiredAny.some(o=>r.has(o))&&e.push({from:t.from,to:t.to,severity:"error",message:`<${t.name}> requires one of: ${i.requiredAny.map(o=>`“${o}”`).join(", ")}.`})}return e}function QS(n,e){const t=Md(n.state).find(s=>e>=s.from&&e<=s.to);if(!t)return null;const i=$e.components[t.name];return i?{pos:t.from,end:t.to,above:!0,create(){const s=document.createElement("div");s.className="studio-hover";const r=document.createElement("strong");r.textContent=`<${t.name}>`;const o=document.createElement("p");return o.textContent=i.documentation,s.append(r,o),{dom:s}}}:null}const ch={light:{background:"#FAFAFC",foreground:"#202124",gutter:"#F3F3F6",gutterText:"#8A8A93",activeLine:"#EDEEF3",selection:"#B9D7FF",caret:"#0067C0"},dark:{background:"#1E1F22",foreground:"#E8E8ED",gutter:"#191A1D",gutterText:"#777982",activeLine:"#292A2F",selection:"#315A85",caret:"#65B7FF"}};function PS(n,e){return $.theme({"&":{height:"100%",color:n.foreground,backgroundColor:n.background,fontSize:"13px"},".cm-scroller":{fontFamily:'ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace',lineHeight:"1.58",overscrollBehavior:"contain"},".cm-content":{caretColor:n.caret,padding:"12px 0 32px"},".cm-line":{padding:"0 8px"},".cm-cursor, .cm-dropCursor":{borderLeftColor:n.caret},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:n.selection},".cm-activeLine":{backgroundColor:n.activeLine},".cm-gutters":{backgroundColor:n.gutter,color:n.gutterText,border:"none",paddingLeft:"env(safe-area-inset-left)"},".cm-activeLineGutter":{backgroundColor:n.activeLine,color:n.foreground},".cm-foldPlaceholder":{backgroundColor:"transparent",border:`1px solid ${n.gutterText}`,color:n.gutterText},".cm-tooltip":{border:e?"1px solid #41434A":"1px solid #D2D3D8",backgroundColor:e?"#292A2F":"#FFFFFF",borderRadius:"8px",overflow:"hidden",boxShadow:"0 8px 28px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete ul li[aria-selected]":{backgroundColor:e?"#315A85":"#DCEBFA",color:n.foreground},".cm-panels":{backgroundColor:n.gutter,color:n.foreground},".cm-searchMatch":{backgroundColor:e?"#725C1D":"#FFE69A"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e?"#8D6D20":"#FFD45C"}},{dark:e})}const CS=Xn.define([{tag:[O.keyword,O.controlKeyword,O.moduleKeyword,O.operatorKeyword,O.bool,O.null],color:"#FF7AB2"},{tag:[O.string,O.special(O.string)],color:"#FF8170"},{tag:[O.number,O.regexp],color:"#D9C97C"},{tag:[O.comment,O.lineComment,O.blockComment],color:"#7F8C98",fontStyle:"italic"},{tag:[O.tagName,O.typeName,O.className],color:"#5DD8FF"},{tag:O.attributeName,color:"#B281EB"},{tag:[O.propertyName,O.function(O.variableName),O.function(O.propertyName)],color:"#67B7A4"},{tag:O.definition(O.variableName),color:"#4EB0CC"},{tag:[O.variableName,O.operator,O.punctuation,O.bracket],color:"#E8E8ED"},{tag:O.invalid,color:"#FF453A"}]);function Ud(n){const e=n==="dark";return[PS(e?ch.dark:ch.light,e),JO(e?CS:i0)]}const TS=Xt.parser.configure({dialect:"jsx"}),RS=new Map(Object.keys($e.components).map(n=>[n.toLowerCase(),n])),$S=new Set(["VStack","HStack","ZStack","VGrid","HGrid"]),KS=512*1024,ZS=512,MS=32,ci=n=>{const e=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t);return e},hi=(n,e)=>n.slice(e.from,e.to),de=n=>{throw new Error(n)},Fd=n=>{let e=!0;const t=n.replace(/&([^;\s]+);/g,(i,s)=>{const r={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};if(Object.hasOwn(r,s))return r[s];if(/^#(?:[0-9]+|x[0-9a-f]+)$/i.test(s)){const o=s[1].toLowerCase()==="x"?parseInt(s.slice(2),16):Number(s.slice(1));if(o>0&&o<=1114111&&!(o>=55296&&o<=57343))return String.fromCodePoint(o)}return e=!1,i});return e?t:void 0};function co(n,e=!1){if(e)return Fd(n.slice(1,-1));const t=n.trim();if(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(t)){const i=Number(t);return Number.isFinite(i)?i:void 0}if(t==="true"||t==="false")return t==="true";if(t.startsWith('"'))try{const i=JSON.parse(t);return typeof i=="string"?i:void 0}catch{}}function vi(n){const e={formatVersion:1,source:n,nodes:[],roots:[],issue:""};if(typeof n!="string"||new TextEncoder().encode(n).length>KS)return{...e,issue:"Layout editing supports source files up to 512 KiB."};const t=TS.parse(n);let i=!1;if(t.iterate({enter:r=>{r.type.isError&&(i=!0)}}),i)return{...e,issue:"Fix the JavaScript/JSX syntax before using Layout. Your source is preserved."};function s(r,o,a){(a>MS||e.nodes.length>=ZS)&&de("Layout editing supports up to 512 layers and 32 nesting levels.");const l=ci(r),c=l[0],h=l.at(-1),u=ci(c).find(S=>["JSXBuiltin","JSXIdentifier","JSXNamespacedName","JSXMemberExpression"].includes(S.name)),f=u?hi(n,u):"Fragment",d=RS.get(f.toLowerCase()),p=$e.components[d],m={...$e.globalProperties,...p?.properties??{}},g=c.name==="JSXOpenTag"&&h?.name==="JSXCloseTag",y=g?ci(h).find(S=>["JSXBuiltin","JSXIdentifier","JSXNamespacedName","JSXMemberExpression"].includes(S.name)):null;u&&g&&(!y||hi(n,y)!==f)&&de("Opening and closing JSX tags must match before using Layout.");const b={id:String(r.from),parentID:o,tag:f,component:d??null,from:r.from,to:r.to,openingEnd:c.to,insertAt:c.to-(g?1:2),contentFrom:c.to,contentTo:g?h.from:c.to,children:[],properties:[],locked:!p,structure:!1,text:null,textEditable:!1,depth:a};let x=!1;for(const S of ci(c)){if(S.name==="JSXSpreadAttribute"&&(x=!0),S.name!=="JSXAttribute")continue;const w=ci(S),U=hi(n,w[0]),F=w[2],V=F?co(hi(n,F),F.name==="JSXAttributeValue"):!0,E=F?.name==="JSXEscape"?co(n.slice(F.from+1,F.to-1)):V,M=Object.hasOwn(m,U)?m[U]:null;b.properties.push({name:U,value:E??null,from:S.from,to:S.to,editable:!!(p&&M&&M.type!=="function"&&E!==void 0),definition:M??null})}const C=new Set(b.properties.map(S=>S.name)).size!==b.properties.length;b.locked||=x||C,b.reason=x?"Spread properties are preserved; edit this element in Code.":C?"Duplicate properties are preserved; resolve them in Code.":p?"":"Custom components and fragments are preserved; edit them in Code.",b.locked&&b.properties.forEach(S=>{S.editable=!1}),e.nodes.push(b);const k=g?l.slice(1,-1):[];for(const S of k)S.name==="JSXElement"&&b.children.push(s(S,b.id,a+1).id);if(b.structure=!b.locked&&g&&$S.has(d)&&k.every(S=>S.name==="JSXElement"||S.name==="JSXText"&&!hi(n,S).trim())&&b.children.every(S=>!e.nodes.find(w=>w.id===S).locked),!b.locked&&d==="Text"&&g&&k.length===1){const S=k[0],w=hi(n,S),U=S.name==="JSXText"&&!/[\r\n]/.test(w)?Fd(w):S.name==="JSXEscape"?co(w.slice(1,-1)):void 0;typeof U=="string"&&(b.text=U,b.textEditable=!0)}return b}try{t.iterate({enter(r){if(r.name!=="CallExpression")return;const o=ci(r.node);if(o[0]?.name!=="VariableName"||hi(n,o[0])!=="$render"||o[1]?.name!=="ArgList")return;const a=ci(o[1]).filter(l=>!["(",")"].includes(l.name));if(a.length===1&&a[0].name==="JSXElement")return e.roots.push(s(a[0],null,0).id),!1}})}catch(r){return{...e,nodes:[],roots:[],issue:r.message}}return e.roots.length||(e.issue="Layout needs a direct $render(…) or another native JSX element. Variables, loops and functions stay editable in Code."),e}function ha(n){return!n?.component||n.locked?{}:{...$e.globalProperties,...$e.components[n.component]?.properties??{}}}function ES(n,e,t){(n.source!==e||n.issue)&&de("Layout changed. Select the layer again before editing.");const i=n.nodes.find(l=>l.id===t.id);(!i||i.locked)&&de("This layer is locked. Edit its source in Code.");let s=[],r=i.from;if(t.type==="property"){const l=ha(i),c=Object.hasOwn(l,t.name)?l[t.name]:null,h=i.properties.find(d=>d.name===t.name);(!c||c.type==="function"||h&&!h.editable)&&de("Dynamic or unsupported properties must be edited in Code.");const u=new Set(i.properties.map(d=>d.name)),f=$e.components[i.component];if(t.remove?(f.requiredAny?.includes(t.name)&&!f.requiredAny.some(d=>d!==t.name&&u.has(d))&&de("Keep at least one required component property."),Object.entries(f.properties??{}).some(([d,p])=>u.has(d)&&p.requires?.includes(t.name))&&de("Another property requires this value. Edit the dependent properties together in Code.")):(c.requires?.some(d=>!u.has(d))&&de("Add the required related properties together in Code."),(c.conflicts?.some(d=>u.has(d))||Object.entries(f.properties??{}).some(([d,p])=>d!==t.name&&u.has(d)&&p.conflicts?.includes(t.name)))&&de("This property conflicts with another component property.")),t.remove)(!h||c.required)&&de("This property cannot be removed."),s=[{from:h.from,to:h.to,insert:""}];else{const d=t.value;(!["string","number","boolean"].includes(typeof d)||typeof d=="number"&&!Number.isFinite(d)||typeof d=="string"&&d.length>8192)&&de("Use a bounded string, finite number or Boolean."),c.values&&!c.values.includes(d)&&de("Choose one of the supported property values."),c.type==="boolean"&&typeof d!="boolean"&&de("This property needs true or false."),c.type==="number"&&!(typeof d=="number"||typeof d=="string"&&d.trim()&&Number.isFinite(Number(d)))&&de("This property needs a number."),typeof d=="boolean"&&c.type!=="boolean"&&de("This property does not accept a Boolean."),typeof d=="number"&&!c.type.includes("number")&&de("This property needs a string value."),t.name==="opacity"&&!(Number(d)>=0&&Number(d)<=1)&&de("Opacity must be between zero and one.");const p=`${t.name}={${JSON.stringify(d)}}`;s=h?[{from:h.from,to:h.to,insert:p}]:[{from:i.insertAt,to:i.insertAt,insert:` ${p}`}]}}else if(t.type==="text")(!i.textEditable||typeof t.value!="string"||t.value.length>8192)&&de("Dynamic text is preserved. Edit it in Code."),s=[{from:i.contentFrom,to:i.contentTo,insert:`{${JSON.stringify(t.value)}}`}];else if(t.type==="move"||t.type==="remove")if(n.nodes.find(c=>c.id===i.parentID)?.structure||de("Only literal children of a supported stack/grid can be moved or removed."),t.type==="remove")s=[{from:i.from,to:i.to,insert:""}];else{const c=n.nodes.find(p=>p.id===t.parentID);(!c?.structure||c.from>=i.from&&c.to<=i.to)&&de("Choose a supported container outside this layer.");const h=p=>{for(;p.parentID!==null;)p=n.nodes.find(m=>m.id===p.parentID);return p.id};h(i)!==h(c)&&de("Layers cannot move between render branches or JavaScript scopes.");const u=c.children.filter(p=>p!==i.id),f=t.index;(!Number.isInteger(f)||f<0||f>u.length)&&de("Invalid layer position.");const d=f===u.length?c.contentTo:n.nodes.find(p=>p.id===u[f]).from;if(d===i.from||d===i.to)return{changes:[],selectedFrom:r};s=[{from:i.from,to:i.to,insert:""},{from:d,to:d,insert:e.slice(i.from,i.to)}],r=d-(d>i.to?i.to-i.from:0)}else if(t.type==="add"){i.structure||de("Choose a supported container with literal JSX children.");const l={text:'New text',spacer:"",stack:'',icon:''};Object.hasOwn(l,t.kind)||de("Unsupported new layer."),s=[{from:i.contentTo,to:i.contentTo,insert:l[t.kind]}],r=i.contentTo}else de("Unsupported layout operation.");s.sort((l,c)=>l.from-c.from);let o=e;for(const l of[...s].reverse())o=o.slice(0,l.from)+l.insert+o.slice(l.to);return vi(o).issue&&de("This edit would leave the supported layout. Your source was not changed."),{changes:s,selectedFrom:r}}const Dd=Xt.parser.configure({dialect:"jsx"}),Ci=n=>{const e=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t);return e},Qe=n=>{throw new Error(n)},Hi=Object.freeze({background:{type:"color"},surface:{type:"color"},foreground:{type:"color"},muted:{type:"color"},accent:{type:"color"},titleFont:{values:$e.globalProperties.font.values},bodyFont:{values:$e.globalProperties.font.values},fontDesign:{values:$e.globalProperties.fontDesign.values},corner:{type:"number",maximum:48},padding:{type:"number",maximum:48},spacing:{type:"number",maximum:32}}),ms={titleFont:"headline",bodyFont:"caption",fontDesign:"rounded",corner:20,padding:16,spacing:10},sr=Object.freeze({Meadow:Object.freeze({...ms,background:"#F2FAF5",surface:"#FFFFFF",foreground:"#193F31",muted:"#607C70",accent:"#328963"}),Paper:Object.freeze({...ms,background:"#F4F7FD",surface:"#FFFFFF",foreground:"#243454",muted:"#687795",accent:"#4777D6"}),Peach:Object.freeze({...ms,background:"#FFF5EE",surface:"#FFFFFF",foreground:"#56392C",muted:"#967461",accent:"#C86B43"}),Midnight:Object.freeze({...ms,background:"#192332",surface:"#283548",foreground:"#F1F5FC",muted:"#AABAD0",accent:"#8EB7FF"})});function Ld(n,e){Object.hasOwn(Hi,n)||Qe("Unknown theme token.");const t=Hi[n];t.type==="color"&&!(typeof e=="string"&&/^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/i.test(e))&&Qe(`${n} needs a six or eight digit hex color.`),t.values&&!t.values.includes(e)&&Qe(`${n} needs a supported font value.`),t.type==="number"&&!(typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=t.maximum)&&Qe(`${n} needs a number from zero to ${t.maximum}.`)}function el(n){(!n||typeof n!="object"||Array.isArray(n)||Object.keys(n).length!==Object.keys(Hi).length)&&Qe("A theme needs exactly the documented tokens.");for(const e of Object.keys(n))Ld(e,n[e]);return n}function Xd(n){(typeof n!="string"||new TextEncoder().encode(n).length>4096)&&Qe("Theme JSON is limited to 4 KiB.");const e=JSON.parse(n);return(!e||Array.isArray(e)||Object.keys(e).sort().join()!=="formatVersion,name,tokens"||e.formatVersion!==1||typeof e.name!="string"||!e.name.trim()||/[\u0000-\u001f]/.test(e.name)||new TextEncoder().encode(e.name).length>64)&&Qe("Use a version 1 theme with a name of at most 64 bytes."),el(e.tokens),e}function US(n,e="My theme"){const t=JSON.stringify({formatVersion:1,name:e,tokens:n},null,2);return Xd(t),t}function rr(n){const e={source:n,tokens:null,ranges:{},issue:"",canInitialize:!1};try{(typeof n!="string"||new TextEncoder().encode(n).length>512*1024)&&Qe("Theme editing supports files up to 512 KiB.");const t=Dd.parse(n),i=[],s=[];if(t.iterate({enter(l){l.type.isError&&Qe("Fix JavaScript syntax before editing the theme."),["VariableDefinition","VariableName"].includes(l.name)&&n.slice(l.from,l.to).includes("\\")&&Qe("Escaped identifiers stay in Code."),n.slice(l.from,l.to)==="widgetTheme"&&["VariableDefinition","VariableName"].includes(l.name)&&(l.name==="VariableDefinition"?i:s).push(l.node)}}),!i.length&&!s.length){const l=vi(n);e.canInitialize=!l.issue&&l.roots.length===1&&!l.nodes[0].locked;let c=!1;for(const h of Ci(t.topNode)){const u=h.firstChild;l.nodes[0]&&h.name==="ExpressionStatement"&&u?.name==="CallExpression"&&n.slice(u.firstChild.from,u.firstChild.to)==="$render"&&u.froml.nodes[0].to&&(c=!0)}return e.canInitialize&&=c,e}i.length!==1&&Qe("Keep one top-level const widgetTheme object. Other bindings stay in Code.");const r=i[0].parent,o=Ci(r);(r.name!=="VariableDeclaration"||r.parent?.name!=="Script"||o[0]?.name!=="const"||o[1]?.from!==i[0].from||o[2]?.name!=="Equals"||o[3]?.name!=="ObjectExpression"||o.slice(4).some(l=>l.name!==";"))&&Qe("Theme editing needs a single top-level const widgetTheme = { … } declaration.");const a={};for(const l of Ci(o[3])){if(["{","}",","].includes(l.name))continue;const c=Ci(l),h=c[0]?n.slice(c[0].from,c[0].to):"",u=c[0]?.name==="String"&&h.startsWith('"')?JSON.parse(h):h;(l.name!=="Property"||c.length!==3||!["PropertyDefinition","String"].includes(c[0].name)||c[1].name!==":"||!["String","Number"].includes(c[2].name)||Object.hasOwn(a,u))&&Qe("Theme tokens must be unique literal properties. Computed or dynamic values stay in Code.");let f;try{f=JSON.parse(n.slice(c[2].from,c[2].to))}catch{Qe("Theme values use JSON strings or numbers. Edit this declaration in Code.")}Ld(u,f),a[u]=f,e.ranges[u]={from:c[2].from,to:c[2].to}}el(a);for(const l of s){const c=l.parent,h=Ci(c),u=h[2]?n.slice(h[2].from,h[2].to):"";(c.name!=="MemberExpression"||h[0].from!==l.from||h[1]?.name!=="."||h[2]?.name!=="PropertyName"||!Object.hasOwn(Hi,u))&&Qe("Theme references must read widgetTheme.token. Other uses stay in Code."),c.parent?.name==="MemberExpression"&&Qe("Mutable theme references stay in Code.");for(let f=c.parent;f;f=f.parent)(["UpdateExpression","PostfixExpression"].includes(f.name)||f.name==="UnaryExpression"&&/^(?:delete|\+\+|--)/.test(n.slice(f.from,c.from).trim())||f.name==="AssignmentExpression"&&f.firstChild.from<=c.from&&f.firstChild.to>=c.to||f.name==="ForOfSpec"||f.name==="ForInSpec")&&Qe("Mutable theme references stay in Code.")}e.tokens=a}catch(t){e.issue=t.message}return e}function ho(n,e,t){return(n.source!==e||n.issue||!n.tokens)&&Qe("Theme changed or is unsupported. Reopen Theme before editing."),el(t),{changes:Object.keys(Hi).filter(s=>t[s]!==n.tokens[s]).map(s=>({...n.ranges[s],insert:JSON.stringify(t[s])})).sort((s,r)=>s.from-r.from)}}function FS(n,e="Meadow"){(!rr(n).canInitialize||!Object.hasOwn(sr,e))&&Qe("Start with a literal top-level layout without an existing widgetTheme binding.");const i=vi(n),s=i.nodes[0],r=[];function o(c,h,u,f=!1){const d=c.properties.find(m=>m.name===h);if(c.locked||d&&!d.editable||!d&&!f)return;const p=`${h}={widgetTheme.${u}}`;r.push(d?{from:d.from,to:d.to,insert:p}:{from:c.insertAt,to:c.insertAt,insert:` ${p}`})}for(const c of["background","corner","padding"])o(s,c,c,!0);s.structure&&o(s,"spacing","spacing",!0);for(const c of i.nodes)if(c.component==="Text"){const h=c.properties.find(f=>f.name==="font")?.value,u=["headline","largeTitle","title","title2","title3"].includes(h);o(c,"font",u?"titleFont":"bodyFont",!0),o(c,"color",u?"foreground":"muted",!0),o(c,"fontDesign","fontDesign",!0)}else c.component==="Icon"&&o(c,"color","accent",!0);let a=0;for(const c of Ci(Dd.parse(n).topNode))if(!(c.name==="LineComment"||c.name==="BlockComment"))if(c.name==="ExpressionStatement"&&c.firstChild?.name==="String")a=c.to;else break;r.push({from:a,to:a,insert:` +const widgetTheme = ${JSON.stringify(sr[e],null,2)}; +`}),r.sort((c,h)=>c.from-h.from);let l=n;for(const c of[...r].reverse())l=l.slice(0,c.from)+c.insert+l.slice(c.to);return(!rr(l).tokens||vi(l).issue)&&Qe("This layout cannot be themed automatically. Your source was preserved."),{changes:r}}function Bd(n){if(!Array.isArray(n)||n.length>4096)return[];const e=new Map,t=new Set;for(const i of n){if(typeof i!="string"||new TextEncoder().encode(i).length>1024||/[\\\u0000-\u001f\u007f-\u009f]/.test(i))continue;const s=i.split("/");if(s.length!==2||s[0]!=="image"||!s[1]||new TextEncoder().encode(s[1]).length>255||s[1]!==s[1].trim()||s[1].includes("..")||!/\.(png|jpe?g|webp)$/i.test(s[1]))continue;const r=i.normalize("NFC").toLowerCase();e.has(r)&&e.get(r)!==i&&t.add(r),e.set(r,i)}return[...e].filter(([i])=>!t.has(i)).map(([,i])=>i).sort().slice(0,256)}const tl=z.define(),or=Te.define({create:()=>[],update(n,e){for(const t of e.effects)t.is(tl)&&(n=Bd(t.value));return n}});function il(n,e){n.state.field(or,!1)!==void 0&&n.dispatch({effects:tl.of(e)})}const Id=Object.freeze({bloom:Object.freeze({name:"Bloom mark",description:"A small four-petal flower",kind:"icon"}),leaf:Object.freeze({name:"Leaf mark",description:"A tilted leaf and stem",kind:"icon"}),pebble:Object.freeze({name:"Pebble friend",description:"A quiet, round-eared companion",kind:"pet"})}),uo=`/* +ScriptWidget original geometric assets 1: Bloom mark, Leaf mark, Pebble friend. +Source: https://github.com/everettjf/scriptwidget (Editor/editorfe/src/visualAssets.js) +SPDX-License-Identifier: MIT +Copyright (c) 2021-2022 everettjf + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +`;function DS(n,e){const t=i=>e?`{widgetTheme.${i}}`:JSON.stringify(sr.Meadow[i]);if(n==="bloom")return``;if(n==="leaf")return``;if(n==="pebble")return``;throw new Error("Choose an original asset from the catalog.")}function LS(n,e,{id:t,kind:i,path:s},r=[]){if(n.source!==e||n.issue)throw new Error("Layout changed. Select the container again.");const o=n.nodes.find(f=>f.id===t);if(!o?.structure)throw new Error("Select a stack/grid with literal JSX children in Layout or Assets.");let a;if(i==="photo"){if(!Bd(r).includes(s))throw new Error("This image is no longer in the package resource list. Refresh images.");a=``}else{if(!Object.hasOwn(Id,i))throw new Error("Choose an original asset from the catalog.");a=DS(i,!!rr(e).tokens)}const l=[{from:o.contentTo,to:o.contentTo,insert:a}];let c=o.contentTo;if(i!=="photo"&&!e.includes(uo)){const f=e.startsWith("#!")?e.indexOf(` +`)+1:0;l.push({from:f,to:f,insert:uo}),c+=uo.length}l.sort((f,d)=>f.from-d.from);let h=e;for(const f of[...l].reverse())h=h.slice(0,f.from)+f.insert+h.slice(f.to);if(vi(h).issue)throw new Error("This asset would exceed the supported layout limits. Your source was preserved.");return{changes:l,selectedFrom:c}}const XS=n=>["string","number","number|string","date|number","boolean","enum","color","url","action-id","storage-key"].includes(n.type);function X(n,e,t){const i=document.createElement(n);return e&&(i.className=e),t!==void 0&&(i.textContent=t),i}function BS(n,e){const t=X("section","sw-layout"),i=X("div","sw-layout-header"),s=X("div","sw-layout-body");t.setAttribute("aria-label","Visual layout editor");let r=!1,o="layout",a=null,l=null,c="",h=null,u=!1,f=0;const d=String(Math.random()),p=(Q,D)=>P=>{if(u||!t.contains(Q)){P.preventDefault();return}return D(P)},m=(Q,D,P)=>Q.addEventListener(D,p(Q,P)),g=(Q,D,P=!1)=>{const j=X("button","sw-layout-button",Q);return j.type="button",j.disabled=P,m(j,"click",D),j},y=g("Layout",()=>{r=o==="layout"?!r:!0,o="layout",Y(),n.requestMeasure()});y.classList.add("sw-layout-toggle"),y.setAttribute("aria-expanded","false");const b=X("span","sw-layout-hint","Select layers and edit literal JSX"),x=g("Undo",()=>La(n)),C=g("Redo",()=>zs(n)),k=g("Theme",()=>{r=o==="theme"?!r:!0,o="theme",Y(),n.requestMeasure()});k.setAttribute("aria-expanded","false");const S=g("Assets",()=>{r=o==="assets"?!r:!0,o="assets",Y(),n.requestMeasure()});S.setAttribute("aria-expanded","false"),i.append(y,k,S,b,x,C),t.append(i,s),s.hidden=x.hidden=C.hidden=!0;const w=X("p","sw-layout-error");w.setAttribute("role","alert"),w.hidden=!0,t.append(w);function U(){a=vi(n.state.doc.toString());const Q=X("div","sw-layout-inspector sw-theme-inspector");if(s.replaceChildren(Q),Q.append(X("div","sw-layout-title","Widget assets")),Q.append(X("p","sw-layout-notice","Insert editable original JSX or a package image. Originals follow connected theme colors; pet artwork is static. Import photos with the app's existing image tools or Web Studio's Add image.")),a.issue){Q.append(X("p","sw-layout-notice",a.issue));return}const D=a.nodes.filter(I=>I.structure),P=X("select");P.setAttribute("aria-label","Asset destination");for(const I of D){const H=X("option","",`${I.tag} · line ${n.state.doc.lineAt(I.from).number}`);H.value=I.id,P.append(H)}D.some(I=>I.id===l)?P.value=l:l=P.value,m(P,"change",()=>{l=P.value}),Q.append(P);const j=n.state.readOnly||!D.length;D.length||Q.append(X("p","sw-layout-notice","Add a stack/grid with literal JSX children in Code to insert assets."));function ae(I,H){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");const ce=LS(a,n.state.doc.toString(),{id:P.value,kind:I,path:H},n.state.field(or));l=P.value,w.hidden=!0,n.dispatch({changes:ce.changes,selection:{anchor:ce.selectedFrom},annotations:ws.of("full"),userEvent:"input.asset",scrollIntoView:!0})}catch(ce){w.textContent=ce.message,w.hidden=!1}}for(const[I,H]of Object.entries(Id)){const ce=X("div","sw-layout-actions");ce.append(g(`Insert ${H.name}`,()=>ae(I),j),X("span","",H.description)),Q.append(ce)}Q.append(X("div","sw-layout-title","Package images"));const J=n.state.field(or),ee=X("select");ee.setAttribute("aria-label","Package image");for(const I of J){const H=X("option","",I);H.value=I,ee.append(H)}ee.disabled=!J.length,Q.append(ee,g("Insert package image",()=>ae("photo",ee.value),j||!J.length)),J.length||Q.append(X("p","sw-layout-notice","No supported images in image/. Add a PNG, JPEG or WebP to the package, then refresh or reopen the editor.")),e.refreshResources&&Q.append(g("Refresh images",async()=>{const I=++f,H=n.state.doc,ce=()=>!u&&I===f&&n.state.doc===H;try{const q=await e.refreshResources();ce()&&(w.hidden=!0,il(n,q))}catch{ce()&&(w.textContent="Images could not be refreshed. Reopen this document and try again.",w.hidden=!1)}})),Q.append(X("p","sw-layout-notice","Bloom mark, Leaf mark and Pebble friend: original ScriptWidget geometry, MIT licensed. Package photos retain their own rights. See the Studio assets documentation."))}function F(Q,D){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");const P=n.state.doc.toString();if(P!==D)throw new Error("Source changed. Reopen Theme before editing.");const j=Q(P);w.hidden=!0,j.changes.length&&n.dispatch({changes:j.changes,annotations:ws.of("full"),userEvent:"input.theme"})}catch(P){w.textContent=P.message,w.hidden=!1}}function V(){const Q=n.state.doc.toString(),D=rr(Q),P=n.state.readOnly,j=X("div","sw-layout-inspector sw-theme-inspector");if(s.replaceChildren(j),j.append(X("div","sw-layout-title","Widget theme")),j.append(X("p","sw-layout-notice","Saved as ordinary JavaScript with your widget. Dynamic values stay in Code. Applying a theme changes the connected colors, fonts and spacing.")),D.issue){j.append(X("p","sw-layout-notice",D.issue));return}if(!D.tokens){j.append(g("Connect layout to Meadow theme",()=>F(ee=>FS(ee),Q),P||!D.canInitialize)),D.canInitialize||j.append(X("p","sw-layout-notice","Use a literal top-level $render layout, or define the documented widgetTheme object in Code."));return}const ae=X("div","sw-layout-actions");for(const[ee,I]of Object.entries(sr))ae.append(g(ee,()=>F(H=>ho(D,H,I),Q),P));j.append(ae);for(const[ee,I]of Object.entries(Hi)){const H=X("form","sw-layout-form"),ce=X("label","",ee),q=X(I.values?"select":"input");if(I.values)for(const re of I.values){const Me=X("option","",re);Me.value=re,q.append(Me)}I.type==="number"&&(q.type="number",q.min="0",q.max=String(I.maximum),q.step="any"),q.value=String(D.tokens[ee]),q.setAttribute("aria-label",`Theme ${ee}`),q.disabled=P;const te=g(`Apply ${ee}`,()=>{},P);te.type="submit",H.append(ce,q,te),m(H,"submit",re=>{re.preventDefault();const Me=I.type==="number"?q.value.trim()?Number(q.value):NaN:q.value;F(Oe=>ho(D,Oe,{...D.tokens,[ee]:Me}),Q)}),j.append(H)}const J=X("textarea");J.rows=5,J.setAttribute("aria-label","Reusable theme JSON"),J.value=US(D.tokens),j.append(X("label","","Copy this JSON to reuse a theme, or paste a version 1 theme and import it."),J,g("Import theme JSON",()=>F(ee=>ho(D,ee,Xd(J.value).tokens),Q),P))}function E(Q,D=a?.source){if(!u)try{if(n.state.readOnly)throw new Error("This document is read only.");if(D!==n.state.doc.toString())throw new Error("Source changed during this operation. Select the layer again.");const P=ES(a,n.state.doc.toString(),Q);if(w.hidden=!0,!P.changes.length)return;n.dispatch({changes:P.changes,selection:{anchor:P.selectedFrom},annotations:ws.of("full"),userEvent:"input.layout",scrollIntoView:!0})}catch(P){w.textContent=P.message,w.hidden=!1}}function M(Q){u||(l=Q.id,c="",n.dispatch({selection:{anchor:Q.from,head:Q.to},scrollIntoView:!0,userEvent:"select.layout"}),Y())}function Y(){if(y.setAttribute("aria-expanded",String(r&&o==="layout")),k.setAttribute("aria-expanded",String(r&&o==="theme")),S.setAttribute("aria-expanded",String(r&&o==="assets")),s.hidden=!r,x.hidden=C.hidden=!r,b.hidden=r,x.disabled=n.state.readOnly||vc(n.state)===0,C.disabled=n.state.readOnly||wc(n.state)===0,!r)return;if(o==="assets"){U();return}if(o==="theme"){V();return}if(a=vi(n.state.doc.toString()),s.replaceChildren(),a.issue){s.append(X("p","sw-layout-notice",a.issue));return}const Q=n.state.selection.main.from,D=a.nodes.filter(q=>q.from<=Q&&Qq.id===l&&q.from<=Q&&Q<=q.to)??D??a.nodes[0];l=P.id;const j=X("div","sw-layout-layers");j.setAttribute("role","tree"),j.setAttribute("aria-label","Layout layers");const ae=n.state.readOnly,J=q=>{const te=q.text??q.properties.find(re=>re.name==="text"&&re.editable&&typeof re.value=="string")?.value;return`<${q.tag}>${te?` · ${te.slice(0,32)}`:""}${q.locked?" · locked":""}`};for(const[q,te]of a.nodes.entries()){const re=a.nodes.find(ie=>ie.id===te.parentID),Me=!ae&&!te.locked&&re?.structure,Oe=g(J(te),()=>M(te));Oe.classList.add("sw-layout-layer"),Oe.dataset.layerId=te.id,Oe.style.paddingInlineStart=`${8+te.depth*14}px`,Oe.setAttribute("role","treeitem"),Oe.setAttribute("aria-level",String(te.depth+1)),Oe.setAttribute("aria-selected",String(te.id===P.id)),Oe.tabIndex=te.id===P.id?0:-1,Oe.draggable=!!Me,m(Oe,"keydown",ie=>{let ve;ie.key==="ArrowUp"&&(ve=a.nodes[Math.max(0,q-1)]),ie.key==="ArrowDown"&&(ve=a.nodes[Math.min(a.nodes.length-1,q+1)]),ie.key==="ArrowLeft"&&(ve=re),ie.key==="ArrowRight"&&(ve=a.nodes.find(Ie=>Ie.id===te.children[0])),ie.key==="Home"&&(ve=a.nodes[0]),ie.key==="End"&&(ve=a.nodes.at(-1)),ve&&(ie.preventDefault(),ie.stopPropagation(),M(ve),ee().find(Ie=>Ie.dataset.layerId===ve.id)?.focus())}),m(Oe,"dragstart",ie=>{if(!Me){ie.preventDefault();return}h={id:te.id,source:a.source},ie.dataTransfer.setData("application/x-scriptwidget-layer",d),ie.dataTransfer.effectAllowed="move"}),m(Oe,"dragover",ie=>{h&&re?.structure&&te.id!==h.id&&(ie.preventDefault(),ie.dataTransfer.dropEffect="move")}),m(Oe,"drop",ie=>{if(!h||ie.dataTransfer.getData("application/x-scriptwidget-layer")!==d||!re?.structure)return;ie.preventDefault();const ve=h;h=null,E({type:"move",id:ve.id,parentID:re.id,index:re.children.filter(Ie=>Ie!==ve.id).indexOf(te.id)},ve.source)}),m(Oe,"dragend",()=>{h=null}),j.append(Oe)}function ee(){return[...t.querySelectorAll(".sw-layout-layer")]}const I=X("div","sw-layout-inspector"),H=X("div","sw-layout-title",`<${P.tag}>`);if(I.append(H),(ae||P.locked)&&I.append(X("p","sw-layout-notice",ae?"This document is read only.":P.reason)),!ae&&!P.locked){let Oe=function(){c=re.value;const oe=ha(P)[c],Ae=P.properties.find(tt=>tt.name===c);if(Me.replaceChildren(),te.onsubmit=tt=>tt.preventDefault(),Ae&&!Ae.editable){Me.append(X("span","sw-layout-notice","Dynamic value: edit it in Code. Connected widgetTheme tokens can be changed in Theme."));return}const le=X(oe.values||oe.type==="boolean"?"select":"input");le.setAttribute("aria-label","Layout property value");for(const tt of oe.values??(oe.type==="boolean"?[!0,!1]:[])){const ai=X("option","",String(tt));ai.value=String(tt),le.append(ai)}le.value=Ae?String(Ae.value):oe.values?.[0]??(oe.type==="boolean"?"true":"");const qe=g("Apply",()=>{});qe.type="submit",Me.append(le,qe,g("Remove",()=>E({type:"property",id:P.id,name:c,remove:!0}),!Ae||oe.required)),te.onsubmit=p(te,tt=>{tt.preventDefault();const ai=oe.type==="boolean"?le.value==="true":oe.type==="number"?le.value.trim()?Number(le.value):NaN:le.value;E({type:"property",id:P.id,name:c,value:ai})})};if(P.textEditable){const oe=X("form","sw-layout-form"),Ae=X("label","","Text"),le=X("input");le.value=P.text,le.setAttribute("aria-label","Layer text");const qe=g("Apply text",()=>{});qe.type="submit",oe.append(Ae,le,qe),m(oe,"submit",tt=>{tt.preventDefault(),E({type:"text",id:P.id,value:le.value})}),I.append(oe)}const q=Object.entries(ha(P)).filter(([,oe])=>XS(oe)),te=X("form","sw-layout-form"),re=X("select");re.setAttribute("aria-label","Layout property");for(const[oe]of q){const Ae=X("option","",oe);Ae.value=oe,re.append(Ae)}q.some(([oe])=>oe===c)||(c=P.structure?"alignment":"color"),re.value=c,re.value||(re.selectedIndex=0,c=re.value);const Me=X("div","sw-layout-property");te.append(re,Me),m(re,"change",Oe),Oe(),I.append(te);const ie=a.nodes.find(oe=>oe.id===P.parentID),ve=ie?.children.indexOf(P.id)??-1,Ie=X("div","sw-layout-actions");if(Ie.append(g("Move up",()=>E({type:"move",id:P.id,parentID:ie.id,index:ve-1}),!ie?.structure||ve<=0),g("Move down",()=>E({type:"move",id:P.id,parentID:ie.id,index:ve+1}),!ie?.structure||ve>=ie.children.length-1),g("Delete layer",()=>E({type:"remove",id:P.id}),!ie?.structure)),I.append(Ie),ie?.structure){const oe=a.nodes.filter(le=>le.structure&&!(le.from>=P.from&&le.to<=P.to)),Ae=X("select");Ae.setAttribute("aria-label","Move layer into container");for(const le of oe){const qe=X("option","",`${le.tag} · line ${n.state.doc.lineAt(le.from).number}`);qe.value=le.id,Ae.append(qe)}I.append(Ae,g("Move inside",()=>{const le=a.nodes.find(qe=>qe.id===Ae.value);E({type:"move",id:P.id,parentID:le.id,index:le.children.filter(qe=>qe!==P.id).length})},!oe.length))}if(P.structure){const oe=X("div","sw-layout-actions");for(const[Ae,le]of[["text","Add text"],["stack","Add stack"],["spacer","Add spacer"],["icon","Add icon"]])oe.append(g(le,()=>E({type:"add",id:P.id,kind:Ae})));I.append(oe)}}const ce=P.properties.filter(q=>!q.editable).map(q=>q.name);ce.length&&I.append(X("p","sw-layout-notice",`Preserved in Code: ${ce.join(", ")}`)),!P.structure&&P.children.length&&I.append(X("p","sw-layout-notice","This child structure stays in Code. Reordering is available on literal stack/grid children.")),s.append(j,I)}return{dom:t,top:!0,update(Q){if(!r)return;const D=n.state.selection.main.from,P=a?.nodes.filter(ae=>ae.from<=D&&Dae.effects.some(J=>J.is(tl)));(Q.docChanged||j||Q.startState.readOnly!==n.state.readOnly||Q.selectionSet&&P!==l)&&(Q.docChanged&&o!=="assets"&&(l=null),Y()),x.disabled=n.state.readOnly||vc(n.state)===0,C.disabled=n.state.readOnly||wc(n.state)===0},destroy(){u=!0}}}const IS=$.baseTheme({".sw-layout":{fontFamily:"system-ui, sans-serif",fontSize:"12px",backgroundColor:"#f6f7fa",color:"#272a34",borderBottom:"1px solid #dce0e9"},"&dark .sw-layout":{backgroundColor:"#252830",color:"#eceef5",borderColor:"#414552"},".sw-layout-header":{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"8px",padding:"6px 10px"},".sw-layout-toggle":{fontWeight:"600"},".sw-layout-hint":{opacity:"0.65",fontSize:"11px"},".sw-layout-button":{fontFamily:"inherit",fontSize:"11px",color:"inherit",backgroundColor:"transparent",border:"1px solid #a0a5b655",borderRadius:"6px",padding:"4px 8px",cursor:"pointer",whiteSpace:"nowrap"},".sw-layout-button:disabled":{opacity:"0.4",cursor:"default"},".sw-layout-body":{display:"grid",gridTemplateColumns:"minmax(120px, 1fr) minmax(180px, 1.6fr)",maxHeight:"280px",overflow:"auto",borderTop:"1px solid #a0a5b633"},".sw-layout-body[hidden]":{display:"none"},".sw-layout-layers":{padding:"6px 2px",overflow:"auto",borderRight:"1px solid #a0a5b633"},".sw-layout-layer":{display:"block",border:0,borderRadius:"4px",width:"100%",textAlign:"left",overflow:"hidden",textOverflow:"ellipsis",margin:"1px 0",paddingBlock:"6px"},'.sw-layout-layer[aria-selected="true"]':{backgroundColor:"#4085f52b",color:"inherit"},".sw-layout-inspector":{padding:"8px 10px",display:"flex",alignItems:"start",flexDirection:"column",gap:"8px",minWidth:0},".sw-theme-inspector":{gridColumn:"1 / -1"},".sw-theme-inspector textarea":{boxSizing:"border-box",width:"100%",fontFamily:"monospace",backgroundColor:"transparent",color:"inherit",border:"1px solid #a0a5b666",borderRadius:"5px"},".sw-layout-title":{fontWeight:"600"},".sw-layout-form":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"5px",width:"100%"},".sw-layout-property,.sw-layout-actions":{display:"flex",flexWrap:"wrap",gap:"5px",alignItems:"center"},".sw-layout input,.sw-layout select":{fontFamily:"inherit",fontSize:"12px",minWidth:0,maxWidth:"100%",padding:"4px 6px",border:"1px solid #a0a5b666",borderRadius:"5px",backgroundColor:"transparent",color:"inherit"},".sw-layout-notice":{margin:"8px",lineHeight:"1.5",fontSize:"11px",opacity:"0.7"},".sw-layout-body > .sw-layout-notice":{gridColumn:"1 / -1"},".sw-layout-error":{margin:"0 10px 6px",color:"#b32636",fontSize:"12px"},"&dark .sw-layout-error":{color:"#ff99a4"},".sw-layout button:focus-visible,.sw-layout input:focus-visible,.sw-layout select:focus-visible":{outline:"2px solid #4085f5",outlineOffset:"1px"},"@media (max-width: 480px)":{".sw-layout-body":{gridTemplateColumns:"minmax(90px, 1fr) minmax(150px, 1.6fr)"},".sw-layout-hint":{display:"none"}}});function qS(n={}){return[IS,or,Vi.of(e=>BS(e,n))]}const qd="scriptwidget.studio.document-state.v1.";function Wd(n,e,t){if(!n||!e)return!1;try{return n.setItem(`${qd}${e}`,JSON.stringify({anchor:Number(t.anchor)||0,head:Number(t.head)||0,scrollTop:Number(t.scrollTop)||0})),!0}catch{return!1}}function WS(n,e,t){if(!n||!e)return null;try{const i=JSON.parse(n.getItem(`${qd}${e}`));if(!i||typeof i!="object")return null;const s=r=>Math.max(0,Math.min(Number(r)||0,t));return{anchor:s(i.anchor),head:s(i.head),scrollTop:Math.max(0,Number(i.scrollTop)||0)}}catch{return null}}const zS="scriptwidget.web-studio.draft.v1:";function nl(n){return`${zS}${n}`}function VS(n,e){if(!e)return null;try{const t=JSON.parse(n.getItem(nl(e))||"null");return t&&typeof t.content=="string"&&typeof t.baseRevision=="string"?t:null}catch{return null}}function hh(n,e,t,i,s=Date.now()){if(!e||typeof i!="string")return null;const r={documentID:e,content:t,baseRevision:i,updatedAt:s};return n.setItem(nl(e),JSON.stringify(r)),r}function fo(n,e){e&&n.removeItem(nl(e))}function jS(n,e,t,i){const s=VS(n,e);return!s||s.content===t?null:{...s,serverContent:t,serverRevision:i,isStale:s.baseRevision!==i}}function YS(){return{connection:"connecting",save:"idle",preview:"idle",conflict:null}}function NS(n,e){switch(e.type){case"CONNECTED":return{...n,connection:"connected"};case"OFFLINE":return{...n,connection:"offline",save:n.save==="saving"?"draft":n.save};case"DISCONNECTED":return{...n,connection:"disconnected"};case"EDITED":return{...n,save:"draft",conflict:null};case"SAVING":return{...n,save:"saving"};case"SAVED":return{...n,save:"saved",preview:e.preview||"requested",conflict:null};case"SAVE_FAILED":return{...n,save:"error"};case"CONFLICT":return{...n,save:"conflict",conflict:e.conflict};default:return n}}class HS{constructor(e){this.send=e,this.epoch=0,this.context=null,this.inFlight=null,this.needsFlush=!1}open({documentID:e,packageID:t,path:i,revision:s,content:r}){return this.epoch+=1,this.context={documentID:e,packageID:t,path:i,revision:s,content:r,generation:0,savedGeneration:0},this.needsFlush=!1,this.snapshot()}edit(e){return this.context?(this.context.content=e,this.context.generation+=1,this.snapshot()):null}rebase(e){return this.context&&(this.context.revision=e),this.snapshot()}get isDirty(){return!!(this.context&&this.context.generation!==this.context.savedGeneration)}snapshot(){return this.context?{...this.context,dirty:this.isDirty}:null}async flush(){if(!this.context||!this.isDirty)return{skipped:!0,snapshot:this.snapshot()};if(this.inFlight)return this.needsFlush=!0,this.inFlight.then(()=>this.isDirty?this.flush():{skipped:!0,snapshot:this.snapshot()});const e=this.epoch,t={...this.context};this.needsFlush=!1,this.inFlight=this.send({documentID:t.documentID,packageID:t.packageID,path:t.path,content:t.content,baseRevision:t.revision}).then(s=>this.epoch!==e||this.context?.documentID!==t.documentID?{ignored:!0,result:s,snapshot:this.snapshot()}:(this.context.revision=s.revision,this.context.savedGeneration=t.generation,{result:s,snapshot:this.snapshot()})).finally(()=>{this.inFlight=null});const i=await this.inFlight;return this.needsFlush&&this.isDirty?this.flush():i}}function uh(n){return["draft","saving","error","conflict"].includes(n)}class GS extends Error{constructor(e,t,i={}){super(e),this.name="StudioAPIError",this.status=t,this.body=i}}class _S{constructor({fetchImpl:e=globalThis.fetch,token:t=()=>"",onUnauthorized:i=()=>{}}={}){if(typeof e!="function")throw new TypeError("A fetch implementation is required");this.fetchImpl=e,this.token=t,this.onUnauthorized=i}async request(e,t={}){const i=await this.fetchImpl(e,this.authorizedOptions(t)),s=await i.json().catch(()=>({}));return this.validate(i,e,s),s}async requestBlob(e,t={}){const i=await this.fetchImpl(e,this.authorizedOptions(t));if(!i.ok){const s=await i.json().catch(()=>({}));this.validate(i,e,s)}return i.blob()}authorizedOptions(e){return{...e,headers:{"Content-Type":"application/json","X-Studio-Token":this.token(),...e.headers||{}}}}validate(e,t,i){if(!e.ok){const s=new GS(i.message||`Request failed (${e.status})`,e.status,i);throw e.status===401&&t!=="/api/v1/pair"&&this.onUnauthorized(s),s}}}const sl=/^https?:$/.test(window.location.protocol),JS=document.querySelector(sl?"#editor":"#native-editor"),rl=new Gi,ar=new Gi;let qt=null,me=null,Et=null,at=0,wi=0,ua=!1,Mn=null,fh=null;const dh=document.querySelector("#save-status");let zd=null;function En(n,e="idle"){dh.textContent=n,dh.dataset.state=e}function e1(){window.clearTimeout(fh),fh=window.setTimeout(()=>{const n=W.state.selection.main;Wd(window.localStorage,me,{anchor:n.anchor,head:n.head,scrollTop:W.scrollDOM.scrollTop})},180)}function Vd(){return window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"}function ol(){window.clearTimeout(Mn),En("Saving…","saving"),Mn=window.setTimeout(()=>{const n=W.state.doc.toString(),e=at,t=me,i=Et,s=wi;nn(qt,Ue.documentSave,{content:n,version:e},t,(r={})=>{sl||t!==me||i!==Et||s!==wi||e!==at||En(r.result==="ok"||r.result==="unavailable"?"Saved":"Save failed",r.result==="failed"?"error":"saved")},i)},700)}function t1(n){if((n.selectionSet||n.viewportChanged||n.docChanged)&&e1(),!n.docChanged||ua)return;at+=1,zd?.documentChanged();const e=[];n.changes.iterChanges((t,i,s,r,o)=>{e.push({from:t,to:i,insert:o.toString(),newFrom:s,newTo:r})}),nn(qt,Ue.documentChanged,{changes:e,version:at},me,void 0,Et),ol()}const jd=[nO(),oO(),xg(),w0(),qS({refreshResources:()=>new Promise((n,e)=>{const t=me,i=wi,s=Et,r=window.setTimeout(()=>e(new Error("Resource refresh timed out")),5e3);nn(qt,Ue.documentResources,{},t,(o={})=>{window.clearTimeout(r),t!==me||i!==wi||o.result!=="ok"||o.documentID!==t||!Array.isArray(o.resources)?e(new Error("Document resources are unavailable")):n(o.resources)},s)})}),HO(),hg(),gg(),_.allowMultipleSelections.of(!0),UO(),c0(),uA(),xA({override:[kS],activateOnTyping:!0}),Mg(),Fg(),Cg(),Qb(),fS(),iS(Ed,{delay:350}),Eu(QS),yb({jsx:!0}),mr.of([Py,...mA,...Qy,...jb,...Z0,...VO,...nd]),rl.of(_.readOnly.of(!1)),ar.of(Ud(Vd())),$.updateListener.of(t1),$.contentAttributes.of({autocapitalize:"off",autocomplete:"off",spellcheck:"false"})],W=new $({state:_.create({doc:"",extensions:jd}),parent:JS});function _t(n,e=me,t=0,i=!1){window.clearTimeout(Mn),wi+=1;const s=W.state.selection.main;Wd(window.localStorage,me,{anchor:s.anchor,head:s.head,scrollTop:W.scrollDOM.scrollTop}),ua=!0;const r=e!==me;me=e,at=t;const o=WS(window.localStorage,me,(n??"").length),a=o?{anchor:o.anchor,head:o.head}:{anchor:0};if(r){const l=ar.get(W.state),c=W.state.readOnly;let h=_.create({doc:n??"",extensions:jd,selection:a});h=h.update({effects:[ar.reconfigure(l),rl.reconfigure(_.readOnly.of(c))]}).state,W.setState(h)}else W.dispatch({changes:{from:0,to:W.state.doc.length,insert:n??""},selection:a,scrollIntoView:!0});o&&window.requestAnimationFrame(()=>{W.scrollDOM.scrollTop=o.scrollTop}),ua=!1,i&&nn(qt,Ue.documentChanged,{content:W.state.doc.toString(),version:at},me,void 0,Et),En("Saved","saved")}function ph(n){if(W.state.readOnly)return!1;const e=W.state.selection.main;return W.dispatch({changes:{from:e.from,to:e.to,insert:n},selection:{anchor:e.from+n.length},userEvent:"input"}),W.focus(),!0}async function lr(){if(W.state.readOnly)return!1;const n=W.state.doc.toString(),e=wi,t=at,i=()=>!W.state.readOnly&&e===wi&&t===at&&n===W.state.doc.toString();try{const[{format:s},{default:r},{default:o}]=await Promise.all([Cr(()=>import("./standalone-Cayz_KD-.js"),[],import.meta.url),Cr(()=>import("./babel-BktJt1uC.js"),[],import.meta.url),Cr(()=>import("./estree-DFfjoHvx.js"),[],import.meta.url)]),a=await s(n,{parser:"babel",plugins:[r,o],semi:!0,singleQuote:!0,trailingComma:"es5"});return i()?(_t(a,me,at+1,!0),ol(),!0):!1}catch(s){return i()&&nn(qt,"diagnostics.publish",{message:String(s),severity:"error"},me,void 0,Et),!1}}function Xi(n){W.dispatch({effects:rl.reconfigure(_.readOnly.of(!!n))})}function cr(n){const e=n==="dark"||n==="light"?n:Vd();document.documentElement.dataset.theme=e,W.dispatch({effects:ar.reconfigure(Ud(e))})}function i1(n=[]){const e=n.map(t=>({from:Math.max(0,Math.min(t.from??0,W.state.doc.length)),to:Math.max(0,Math.min(t.to??t.from??0,W.state.doc.length)),severity:t.severity??"error",message:t.message??"Unknown error"}));W.dispatch(vd(W.state,e))}function rt(n,e){qt.registerHandler(n,async(t={},i=()=>{})=>{try{if(Et!==null&&n!==Ue.documentOpen&&n!==Ue.editorSetTheme&&(t.documentID!==me||t.sessionID!==Et))throw new Error("The editor session changed.");i({result:"ok",...await e(t)})}catch(s){i({result:"failed",message:String(s)})}})}pS(n=>{qt=n,rt(Ue.documentOpen,({payload:e={},documentID:t,sessionID:i=null})=>(Et=i,_t(e.content,t,e.version??0),il(W,e.resources??[]),Xi(e.readOnly),e.dirty&&(En("Restored unsaved edits","editing"),e.readOnly||ol()),{protocolVersion:Zd})),rt(Ue.documentReplace,({payload:e={},documentID:t})=>{if(W.state.readOnly||e.expectedContent!==void 0&&e.expectedContent!==W.state.doc.toString())throw new Error("The file changed or is read only.");return _t(e.content,t,e.version??at,!0),{}}),rt(Ue.documentSetReadOnly,({payload:e={}})=>(Xi(e.readOnly),{readOnly:!!e.readOnly})),rt(Ue.editorInsert,({payload:e={}})=>({inserted:ph(e.content??"")})),rt(Ue.editorFormat,async()=>({formatted:await lr()})),rt(Ue.editorSetTheme,({payload:e={}})=>(cr(e.theme),{})),rt(Ue.editorGetState,()=>({content:W.state.doc.toString(),version:at,documentID:me,sessionID:Et,selection:{from:W.state.selection.main.from,to:W.state.selection.main.to}})),rt(Ue.diagnosticsPublish,({payload:e={}})=>(i1(e.items),{})),rt("editor_setValue",({value:e})=>(_t(e),{})),rt("editor_insertValue",({value:e})=>({inserted:ph(e??"")})),rt("editor_getValue",()=>({value:W.state.doc.toString()})),rt("editor_setReadonly",({readonly:e})=>(Xi(e),{readonly:!!e})),rt("editor_formatCode",async()=>({formatted:await lr()})),mS(qt)});sl&&(document.querySelector("#native-editor").hidden=!0,document.querySelector("#web-studio").hidden=!1,n1());async function n1(){const n=document.querySelector("#pair-dialog"),e=document.querySelector("#pair-form"),t=document.querySelector("#pair-error"),i=document.querySelector("#package-select"),s=document.querySelector("#file-select"),r=document.querySelector("#connection-status"),o=document.querySelector("#disconnect-button"),a=document.querySelector("#studio-grid"),l=document.querySelector(".editor-column"),c=document.querySelector("#recovery-banner"),h=document.querySelector("#conflict-banner"),u=document.querySelector("#command-dialog"),f=document.querySelector("#command-search"),d=document.querySelector("#command-list"),p=document.querySelector("#compare-dialog");let m=window.sessionStorage.getItem("scriptwidget.web-studio.token")||"",g=[],y=null,b=null,x=null,C=0,k=null,S="",w="",U=null,F=YS(),V="",E="",M=null;function Y(v="Session ended. Enter the new code shown on your device."){m="",window.sessionStorage.removeItem("scriptwidget.web-studio.token"),o.hidden=!0,Q({type:"DISCONNECTED"}),r.textContent=v,Xi(!0),n.open||n.showModal()}function Q(v){F=NS(F,v);const Z={connecting:"Connecting",connected:"Connected",offline:"Offline",disconnected:"Disconnected"},L={idle:"Ready",draft:"Draft saved locally",saving:"Saving…",saved:"Saved",error:"Save failed",conflict:"Conflict"};r.dataset.state=F.connection,document.querySelector("#status-connection").textContent=Z[F.connection]||F.connection,En(L[F.save]||F.save,F.save),document.querySelector("#dirty-indicator").hidden=!["draft","saving","error","conflict"].includes(F.save),document.querySelector("#status-preview").textContent=F.preview==="requested"?"Preview requested":"Preview idle",document.querySelector("#preview-detail").textContent=F.preview==="requested"?"Requested on device":"Not requested"}const D=new _S({token:()=>m,onUnauthorized:()=>Y()}),P=(v,Z)=>D.request(v,Z);M=new HS(({packageID:v,path:Z,content:L,baseRevision:ne})=>P("/api/v1/document",{method:"PUT",body:JSON.stringify({package:v,path:Z,content:L,baseRevision:ne})}));async function j(v){m=(await P("/api/v1/pair",{method:"POST",body:JSON.stringify({code:v})})).token,window.sessionStorage.setItem("scriptwidget.web-studio.token",m),o.hidden=!1,Q({type:"CONNECTED"}),ae()}function ae(){window.clearInterval(y),y=window.setInterval(async()=>{if(m)try{const v=await P("/api/v1/session");if(!navigator.onLine)return;q(v),Q({type:"CONNECTED"})}catch(v){v.status!==401&&(r.textContent=`Interrupted · ${v.message}`,Q({type:"OFFLINE"}))}},5e3)}async function J(){if(g=(await P("/api/v1/packages")).packages||[],i.replaceChildren(...g.map(Z=>new Option(Z.name,Z.id))),!g.length){r.textContent="No editable widgets",Xi(!0);return}await ee()}async function ee(){const v=g.find(ne=>ne.id===i.value),Z=v?.files||[];s.replaceChildren(...Z.map(ne=>new Option(ne,ne)));const L=Z.includes(v?.entry)?v.entry:Z[0];L&&(s.value=L),await H()}async function I(v=""){g=(await P("/api/v1/packages")).packages||[],i.replaceChildren(...g.map(ge=>new Option(ge.name,ge.id))),V&&(i.value=V);const L=g.find(ge=>ge.id===i.value),ne=L?.files||[];s.replaceChildren(...ne.map(ge=>new Option(ge,ge))),s.value=ne.includes(v)?v:ne.includes(E)?E:L?.entry||ne[0]}async function H(){if(!i.value||!s.value)return;const v=new URLSearchParams({package:i.value,path:s.value}),Z=await P(`/api/v1/document?${v}`),L=`${i.value}/${s.value}`;V=i.value,E=s.value,S=Z.revision,w=Z.content,U=null,h.hidden=!0,_t(Z.content,L,0),il(W,g.find(ge=>ge.id===V)?.files??[]),M.open({documentID:L,packageID:V,path:E,revision:Z.revision,content:Z.content}),Xi(!!Z.readOnly),ce(Z);const ne=jS(window.localStorage,L,Z.content,Z.revision);c.hidden=!ne,c._draft=ne,document.querySelector("#recovery-message").textContent=ne?.isStale?"The device version also changed. Review before saving.":"Restore it or keep the device version.",r.textContent="Connected",Q({type:"CONNECTED"}),o.hidden=!1,Oe(),ae(),Me()}function ce(v){document.querySelector("#breadcrumb-package").textContent=v.packageName||i.value,document.querySelector("#breadcrumb-file").textContent=s.value,document.querySelector("#editor-tab-name").textContent=s.value,document.querySelector("#revision-detail").textContent=S?S.slice(0,8):"—",document.querySelector("#access-detail").textContent=v.readOnly?"Read only":"Editable"}function q(v){v.device&&(document.querySelector("#device-name").textContent=v.device.name||v.device.model,document.querySelector("#device-system").textContent=`${v.device.model} · ${v.device.system}`),v.preview?.package&&(document.querySelector("#preview-target").textContent=v.preview.package),v.preview?.snapshotSequence&&te()}async function te(){try{const v=await D.requestBlob("/api/v1/preview"),Z=URL.createObjectURL(v),L=document.querySelector("#device-preview"),ne=k;k=Z,L.onload=()=>{ne&&URL.revokeObjectURL(ne)},L.src=Z,L.hidden=!1,document.querySelector("#preview-detail").textContent="Rendered on device"}catch{}}function re(v){const Z=document.querySelector("#console-list"),L=document.createElement("li");for(L.className=v.level||"info",L.textContent=v.message||"",Z.append(L);Z.children.length>200;)Z.firstChild.remove();Z.scrollTop=Z.scrollHeight}function Me(){window.clearTimeout(x);const v=async()=>{if(m)try{const Z=await P(`/api/v1/events?after=${C}`);C=Z.nextSequence??C;for(const L of Z.events||[])L.type==="console"&&re(L.payload||{}),L.type==="preview.snapshot"&&te(),L.type==="preview.requested"&&(document.querySelector("#status-preview").textContent="Preview requested",document.querySelector("#preview-detail").textContent="Requested on device"),L.type==="files.changed"&&L.payload?.package===V&&I(E).catch(Ie);Q({type:"CONNECTED"})}catch(Z){Z.status!==401&&Q({type:"OFFLINE"})}finally{m&&(x=window.setTimeout(v,1e3))}};v()}function Oe(){const v=Ed(W);document.querySelector("#problems-list").replaceChildren(...v.map(L=>{const ne=W.state.doc.lineAt(L.from),ge=document.createElement("li");ge.className=`problem-item ${L.severity}`;const it=document.createElement("button");return it.type="button",it.innerHTML=`${L.severity==="error"?"●":"▲"}Ln ${ne.number}`,it.children[1].textContent=L.message,it.addEventListener("click",()=>{W.dispatch({selection:{anchor:L.from},scrollIntoView:!0}),W.focus()}),ge.append(it),ge})),document.querySelector("#problems-count").textContent=String(v.length),document.querySelector("#status-problem-count").textContent=String(v.length),document.querySelector("#problems-summary").textContent=v.length?`${v.filter(L=>L.severity==="error").length} errors, ${v.filter(L=>L.severity!=="error").length} warnings`:"No problems detected"}async function ie(v,Z,L=null){M.snapshot()?.content!==v&&M.edit(v),L&&M.rebase(L),Q({type:"SAVING"});try{const ne=await M.flush();if(ne.ignored){Z({result:"ok",ignored:!0});return}if(ne.skipped){Q({type:"SAVED"}),Z({result:"ok",skipped:!0});return}const ge=ne.result||{},it=M.snapshot();S=it?.revision||S,w=it?.content||v,fo(window.localStorage,me),U=null,h.hidden=!0,document.querySelector("#revision-detail").textContent=S?.slice(0,8)||"—",Q({type:"SAVED",preview:ge.preview?.state}),Z({result:"ok",...ge})}catch(ne){ne.status===409?(U=ne.body,h.hidden=!1,Q({type:"CONFLICT",conflict:U})):Q({type:"SAVE_FAILED"}),Z({result:"failed",message:ne.message})}}qt={registerHandler(){},callHandler(v,Z,L=()=>{}){if(v===Ue.documentSave)ie(Z.payload.content,L);else if(v===Ue.documentResources){const ne=me,ge=V;P("/api/v1/packages").then(it=>{if(ne!==me||Z.documentID!==me||ge!==V){L({result:"failed"});return}L({result:"ok",documentID:ne,resources:(it.packages??[]).find(zn=>zn.id===ge)?.files??[]})}).catch(()=>L({result:"failed"}))}else L({result:"ok"})}},zd={documentChanged(){const v=W.state.doc.toString();M.edit(v),hh(window.localStorage,me,v,M.snapshot()?.revision||S),Q({type:"EDITED"}),window.clearTimeout(b),b=window.setTimeout(Oe,380)}};async function ve(v,Z){if(!uh(F.save)){await v();return}try{if(window.clearTimeout(Mn),await ie(W.state.doc.toString(),()=>{}),!M.isDirty&&F.save!=="conflict"){await v();return}}catch{}window.confirm("This document has changes that are not saved on the device. A browser draft is available. Switch anyway?")?await v():Z()}i.addEventListener("change",()=>{const v=i.value;i.value=V,ve(async()=>{i.value=v,await ee()},()=>{i.value=V}).catch(Ie)}),s.addEventListener("change",()=>{const v=s.value;s.value=E,ve(async()=>{s.value=v,await H()},()=>{s.value=E}).catch(Ie)});function Ie(v){r.textContent=v.message||String(v),Q({type:"SAVE_FAILED"})}e.addEventListener("submit",async v=>{v.preventDefault(),t.textContent="";try{await j(document.querySelector("#pair-code").value),n.close(),await J()}catch(Z){t.textContent=Z.message}}),o.addEventListener("click",async()=>{try{await P("/api/v1/session",{method:"DELETE"})}catch{}Y("Disconnected. Start a new session with the code on your device.")}),document.querySelector("#new-file").addEventListener("click",async()=>{const v=window.prompt("New package-relative text file","source/helper.js")?.trim();if(v)try{await P("/api/v1/document",{method:"POST",body:JSON.stringify({package:V,path:v})}),await I(v),await H()}catch(Z){Ie(Z)}}),document.querySelector("#delete-file").addEventListener("click",async()=>{const v=g.find(Z=>Z.id===V);if(!E||E===v?.entry){window.alert("The widget entry file cannot be deleted.");return}if(window.confirm(`Delete ${E}? This cannot be undone.`))try{const Z=new URLSearchParams({package:V,path:E});await P(`/api/v1/document?${Z}`,{method:"DELETE"}),E="",await I(),await H()}catch(Z){Ie(Z)}}),document.querySelector("#clear-console").addEventListener("click",()=>document.querySelector("#console-list").replaceChildren()),document.querySelector("#restore-draft").addEventListener("click",()=>{const v=c._draft;v&&(_t(v.content,v.documentID,at+1),c.hidden=!0,hh(window.localStorage,me,v.content,S),Q({type:"EDITED"}),Oe())}),document.querySelector("#discard-draft").addEventListener("click",()=>{fo(window.localStorage,me),c.hidden=!0}),document.querySelector("#reload-server").addEventListener("click",()=>{U&&(fo(window.localStorage,me),S=U.currentRevision,w=U.currentContent,_t(w,me,at+1),M.open({documentID:me,packageID:V,path:E,revision:S,content:w}),U=null,h.hidden=!0,Q({type:"SAVED"}),Oe())}),document.querySelector("#keep-local").addEventListener("click",()=>{U&&ie(W.state.doc.toString(),()=>{},U.currentRevision)}),document.querySelector("#compare-conflict").addEventListener("click",()=>{document.querySelector("#compare-local").textContent=W.state.doc.toString(),document.querySelector("#compare-server").textContent=U?.currentContent||w,p.showModal()}),p.querySelector("button").addEventListener("click",()=>p.close());function oe(){const v=l.classList.toggle("problems-collapsed");document.querySelector("#problems-toggle").setAttribute("aria-expanded",String(!v))}function Ae(v){a.classList.toggle(`show-${v}`)}document.querySelector("#problems-toggle").addEventListener("click",oe),document.querySelector("#status-problems").addEventListener("click",()=>{l.classList.remove("problems-collapsed")}),document.querySelector("#explorer-button").addEventListener("click",()=>Ae("explorer")),document.querySelector("#inspector-button").addEventListener("click",()=>Ae("inspector")),document.querySelectorAll("[data-close-panel]").forEach(v=>v.addEventListener("click",()=>a.classList.remove(`show-${v.dataset.closePanel}`)));const le=[{name:"Save Document",keys:"⌘S",run:()=>{window.clearTimeout(Mn),ie(W.state.doc.toString(),()=>{})}},{name:"Format Document",keys:"⇧⌥F",run:lr},{name:"Toggle Problems",keys:"⌘J",run:oe},{name:"Toggle Explorer",keys:"⌘⇧E",run:()=>Ae("explorer")},{name:"Toggle Inspector",keys:"",run:()=>Ae("inspector")},{name:"Use Light Theme",keys:"",run:()=>cr("light")},{name:"Use Dark Theme",keys:"",run:()=>cr("dark")}];function qe(v=""){const Z=le.filter(L=>L.name.toLowerCase().includes(v.toLowerCase()));d.replaceChildren(...Z.map(L=>{const ne=document.createElement("li"),ge=document.createElement("button");ge.type="button",ge.className="command";const it=document.createElement("span");it.textContent=L.name;const zn=document.createElement("kbd");return zn.textContent=L.keys,ge.append(it,zn),ge.addEventListener("click",()=>{u.close(),L.run()}),ne.append(ge),ne}))}function tt(){qe(),u.showModal(),f.value="",f.focus()}document.querySelector("#command-button").addEventListener("click",tt),f.addEventListener("input",()=>qe(f.value)),document.addEventListener("keydown",v=>{const Z=v.metaKey||v.ctrlKey;Z&&v.shiftKey&&v.key.toLowerCase()==="p"?(v.preventDefault(),tt()):Z&&v.key.toLowerCase()==="s"?(v.preventDefault(),le[0].run()):Z&&v.key.toLowerCase()==="j"?(v.preventDefault(),oe()):Z&&v.shiftKey&&v.key.toLowerCase()==="e"?(v.preventDefault(),Ae("explorer")):v.shiftKey&&v.altKey&&v.key.toLowerCase()==="f"&&(v.preventDefault(),lr())}),W.dom.addEventListener("keyup",ai),W.dom.addEventListener("mouseup",ai);function ai(){const v=W.state.selection.main.head,Z=W.state.doc.lineAt(v);document.querySelector("#cursor-position").textContent=`Ln ${Z.number}, Col ${v-Z.from+1}`}window.addEventListener("offline",()=>{r.textContent="Computer is offline",Q({type:"OFFLINE"})}),window.addEventListener("online",()=>{m&&P("/api/v1/session").then(v=>(q(v),Q({type:"CONNECTED"}),J())).catch(Ie)}),window.addEventListener("beforeunload",v=>{uh(F.save)&&(v.preventDefault(),v.returnValue="")});try{await J()}catch{Y("Pair with the code shown on your device.")}}window.matchMedia?.("(prefers-color-scheme: dark)").addEventListener("change",()=>cr("system"));window.webkit||_t(`// ScriptWidget Studio +const widget = ( + + + +); +`); diff --git a/macOS/ScriptWidgetMac/StudioEditor.bundle/index.html b/macOS/ScriptWidgetMac/StudioEditor.bundle/index.html index f08a8fe2..55c4909d 100644 --- a/macOS/ScriptWidgetMac/StudioEditor.bundle/index.html +++ b/macOS/ScriptWidgetMac/StudioEditor.bundle/index.html @@ -5,7 +5,7 @@ ScriptWidget Web Studio - + diff --git a/macOS/ScriptWidgetMac/macOS.entitlements b/macOS/ScriptWidgetMac/macOS.entitlements index bb9318af..45936c64 100644 --- a/macOS/ScriptWidgetMac/macOS.entitlements +++ b/macOS/ScriptWidgetMac/macOS.entitlements @@ -31,5 +31,9 @@ group.everettjf.scriptwidget + com.apple.security.personal-information.addressbook + + com.apple.security.files.user-selected.read-only + diff --git a/macOS/ScriptWidgetMacWidget/Info.plist b/macOS/ScriptWidgetMacWidget/Info.plist index 6945d3c2..c0ade933 100644 --- a/macOS/ScriptWidgetMacWidget/Info.plist +++ b/macOS/ScriptWidgetMacWidget/Info.plist @@ -25,5 +25,11 @@ ATSApplicationFontsPath . + NSContactsUsageDescription + Select contacts to share with your chosen widgets. + NSHomeKitUsageDescription + Read selected home accessories and run selected controls or scenes from widgets. + NSAlarmKitUsageDescription + Schedule alarms and timers you explicitly request from a widget. diff --git a/macOS/ScriptWidgetMacWidget/ScriptWidgetMacWidget.entitlements b/macOS/ScriptWidgetMacWidget/ScriptWidgetMacWidget.entitlements index a9d9948a..cff3a124 100644 --- a/macOS/ScriptWidgetMacWidget/ScriptWidgetMacWidget.entitlements +++ b/macOS/ScriptWidgetMacWidget/ScriptWidgetMacWidget.entitlements @@ -29,5 +29,7 @@ group.everettjf.scriptwidget + com.apple.security.personal-information.addressbook +