{
  "version": 3,
  "sources": ["../../../../shared/src/diffValues.ts", "../../../../shared/src/emptyArray.ts", "../../../../shared/src/errors.ts", "../../../../shared/src/hostInfo.ts", "../../../../shared/src/ServiceMap.ts", "../../../../shared/src/logger.ts", "../../../../shared/src/Mixed.ts", "../../../../shared/src/moduleNames.ts", "../../../../shared/src/readonly.ts", "../../../../shared/src/scheduler.ts", "../../../../shared/src/TaskQueues.ts", "../../src/editorbar-initializer/useDraggableEditButton.tsx", "../../src/editorbar-initializer/EditButton.tsx"],
  "sourcesContent": ["import { type WithObjectMethods, hasObjectMethods } from \"./objectMethodsTrait.ts\"\n\ninterface DiffValueOptions {\n\t/** Ignore difference in prototypes. */\n\tignorePrototypes?: boolean\n\t/** Ignore difference between undefined vs no value. */\n\tignoreMissingOrUndefined?: boolean\n\t/** Ignore dynamic keys such as $control__ or $componentPreset__ */\n\tignoreKnownDynamicKeys?: boolean\n\t/** Ignore keys for which this callback returns true */\n\tignoreKeys?: (key: string) => boolean | undefined\n}\n\n/** This function will compare two js values deeply, and report on what is different, including if\n * fields are missing vs undefined, or if prototypes are difference, etc. When comparing functions\n * or classes, it will not just compare reference equality, but also toString() equality, so two\n * closures of the same function wil be considered the same.\n *\n * Returns null if no difference was found. */\nexport function diffValues(a: unknown, b: unknown, options?: DiffValueOptions): string | null {\n\tconst cx = new DiffContext(options)\n\tcx.diff([], a, b)\n\treturn cx.toResults()\n}\n\nconst missing = Symbol(\"missing\")\n\nclass DiffContext {\n\tresults: string[] = []\n\n\tconstructor(readonly options: DiffValueOptions = {}) {}\n\n\treport(path: string[], a: unknown, b: unknown, withIdOrClass?: Record<string, unknown>): void {\n\t\tlet idOrClass = \"\"\n\t\tconst id = withIdOrClass?.[\"id\"]\n\t\tconst __class = withIdOrClass?.[\"__class\"] ?? withIdOrClass?.constructor?.name\n\t\tif (id && __class) {\n\t\t\tidOrClass = ` (id: ${id} class: ${__class})`\n\t\t} else if (id) {\n\t\t\tidOrClass = ` (id: ${id})`\n\t\t} else if (__class && __class !== \"Object\") {\n\t\t\tidOrClass = ` (class: ${__class})`\n\t\t}\n\n\t\tconst pathString = path.length > 0 ? path.join(\".\") : \"(top)\"\n\t\tthis.results.push(`${pathString}: ${toString(a)} != ${toString(b)}${idOrClass}`)\n\t}\n\n\treportDiff(path: string[], a: string, b: string): void {\n\t\tconst pathString = path.length > 0 ? path.join(\".\") : \"(top)\"\n\t\tthis.results.push(`${pathString}: ${a} != ${b}`)\n\t}\n\n\ttoResults(): string | null {\n\t\tif (this.results.length === 0) return null\n\t\treturn this.results.join(\"\\n\")\n\t}\n\n\tdiff(path: string[], a: unknown, b: unknown, widthIdOrClass?: Record<string, unknown>): void {\n\t\tif (a === b) return\n\n\t\tconst typeA = typeof a\n\t\tconst typeB = typeof b\n\t\tif (typeA !== typeB) {\n\t\t\tthis.report(path, a, b, widthIdOrClass)\n\t\t\treturn\n\t\t}\n\n\t\tif (!a || !b) {\n\t\t\tif (Number.isNaN(a) && Number.isNaN(b)) return\n\t\t\tthis.report(path, a, b, widthIdOrClass)\n\t\t\treturn\n\t\t}\n\n\t\tif (typeA === \"function\") {\n\t\t\tif (a.toString() === b.toString()) return\n\t\t\tthis.report(path, a, b)\n\t\t\treturn\n\t\t} else if (Array.isArray(a)) {\n\t\t\tif (!Array.isArray(b)) {\n\t\t\t\tthis.report(path, a, b, widthIdOrClass)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfor (let i = 0, il = Math.max(a.length, b.length); i < il; i++) {\n\t\t\t\tconst valueA = a[i]\n\t\t\t\tconst valueB = b[i]\n\t\t\t\tif (valueA === valueB) continue\n\t\t\t\tconst missingA = valueA === undefined && a.length <= i\n\t\t\t\tconst missingB = valueB === undefined && b.length <= i\n\t\t\t\tif (missingA || missingB) {\n\t\t\t\t\tif (this.options.ignoreMissingOrUndefined) {\n\t\t\t\t\t\tif (missingA && valueB === undefined) continue\n\t\t\t\t\t\tif (missingB && valueA === undefined) continue\n\t\t\t\t\t}\n\t\t\t\t\tthis.report(path.concat(String(i)), missingA ? missing : valueA, missingB ? missing : valueB, widthIdOrClass)\n\t\t\t\t} else {\n\t\t\t\t\tthis.diff(path.concat(String(i)), valueA, valueB, undefined)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (typeA === \"object\") {\n\t\t\tif (!this.options.ignorePrototypes) {\n\t\t\t\tconst protoA = Object.getPrototypeOf(a)\n\t\t\t\tconst protoB = Object.getPrototypeOf(b)\n\t\t\t\tif (protoA !== protoB) {\n\t\t\t\t\tthis.reportDiff(path.concat(\"prototype\"), prototypeName(protoA), prototypeName(protoB))\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet keysA: string[]\n\t\t\tlet keysB: string[]\n\n\t\t\tlet hasPropA = hasOwnProperty\n\t\t\tlet hasPropB = hasOwnProperty\n\n\t\t\tif (hasObjectMethods(a)) {\n\t\t\t\tkeysA = a.keys()\n\t\t\t\thasPropA = hasPropWithObjMethods as typeof hasOwnProperty\n\t\t\t} else {\n\t\t\t\tkeysA = Object.keys(a)\n\t\t\t}\n\n\t\t\tif (hasObjectMethods(b)) {\n\t\t\t\tkeysB = b.keys()\n\t\t\t\thasPropB = hasPropWithObjMethods as typeof hasOwnProperty\n\t\t\t} else {\n\t\t\t\tkeysB = Object.keys(b)\n\t\t\t}\n\n\t\t\tconst keys = new Set([...keysA, ...keysB])\n\n\t\t\tfor (const key of keys) {\n\t\t\t\tif (this.options.ignoreKeys?.(key)) continue\n\t\t\t\tconst missingA = !hasPropA(a, key)\n\t\t\t\tconst missingB = !hasPropB(b, key)\n\n\t\t\t\tconst valueA = (a as Record<string, unknown>)[key]\n\t\t\t\tconst valueB = (b as Record<string, unknown>)[key]\n\n\t\t\t\tif (missingA || missingB) {\n\t\t\t\t\tif (this.options.ignoreMissingOrUndefined) {\n\t\t\t\t\t\tif (missingA && valueB === undefined) continue\n\t\t\t\t\t\tif (missingB && valueA === undefined) continue\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.options.ignoreKnownDynamicKeys &&\n\t\t\t\t\t\t(key.startsWith(\"$control__\") || key.startsWith(\"$componentPreset__\") || key.startsWith(\"$plugin__\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tthis.report(\n\t\t\t\t\t\tpath.concat(key),\n\t\t\t\t\t\tmissingA ? missing : valueA,\n\t\t\t\t\t\tmissingB ? missing : valueB,\n\t\t\t\t\t\ta as Record<string, unknown>,\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tthis.diff(path.concat(key), valueA, valueB, a as Record<string, unknown>)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.report(path, a, b, widthIdOrClass)\n\t\t}\n\t}\n}\n\nfunction toString(v: unknown) {\n\tif (v === undefined) return \"undefined\"\n\tif (v === missing) return \"missing\"\n\tif (Number.isNaN(v)) return \"NaN\"\n\n\tlet json: string | undefined = undefined\n\ttry {\n\t\tjson = JSON.stringify(v)\n\t} catch {\n\t\tjson = String(v)\n\t}\n\tif (!json) {\n\t\tif (typeof v === \"function\") {\n\t\t\tconst str = String(v)?.replace(/\\s+/gu, \" \")\n\t\t\tif (str.startsWith(\"function\") || str.startsWith(\"class\")) {\n\t\t\t\tjson = `[${str}]`\n\t\t\t} else {\n\t\t\t\tjson = `[Function ${str}]`\n\t\t\t}\n\t\t} else {\n\t\t\tjson = String(v)\n\t\t\tif (!json) {\n\t\t\t\tjson = typeof v\n\t\t\t}\n\t\t}\n\t}\n\tif (json.length <= 30) return json\n\treturn json.slice(0, 27) + \"...\"\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: @TODO add explanation\nfunction prototypeName(proto: any) {\n\treturn proto?.constructor?.name ?? toString(proto)\n}\n\nconst _hasOwnProperty = Object.prototype.hasOwnProperty\nfunction hasOwnProperty(o: object, key: string) {\n\treturn _hasOwnProperty.call(o, key)\n}\n\nfunction hasPropWithObjMethods(o: WithObjectMethods, key: string) {\n\treturn o.hasProp(key)\n}\n", "const frozenEmptyArray = Object.freeze([]) as readonly unknown[]\n\n/**\n * Returns a stable typed empty array for the given type.\n *\n * @example\n * // Get an empty array of strings\n * const myArray = emptyArray<string>();\n */\nexport function emptyArray<T>(): readonly T[] {\n\treturn frozenEmptyArray as readonly T[]\n}\n", "type ErrorWithMetadata = Error & { tags?: Record<string, string>; extras?: Record<string, unknown> }\n\ninterface ErrorReport {\n\terror: ErrorWithMetadata\n\ttags: Record<string, string>\n\textras?: Record<string, unknown>\n\tcritical: boolean\n}\n\nlet errorReporter: undefined | ((_: ErrorReport) => void)\nlet didWarnMissingReporter = false\n\n/**\n * Sets a handler for reportError. If not set, reporting is skipped.\n */\nexport function setErrorReporter(reporter: typeof errorReporter) {\n\terrorReporter = reporter\n}\n\n/**\n * Primitive for error reporting using the externally set handler. If no\n * handler is set, skips reporting and proceeds as normal.\n */\nexport function reportError({\n\terror: maybeError,\n\ttags,\n\textras,\n\tcritical,\n\tcaller,\n}: Omit<ErrorReport, \"error\" | \"critical\"> & {\n\terror: Error | unknown\n\tcritical?: boolean\n\tcaller: Function\n}): Error {\n\tconst error = reportableError(maybeError, caller)\n\n\tif (errorReporter) {\n\t\terrorReporter({\n\t\t\terror,\n\t\t\ttags: { ...error.tags, ...tags },\n\t\t\textras: { ...error.extras, ...extras },\n\t\t\tcritical: !!critical,\n\t\t})\n\t} else if (!didWarnMissingReporter) {\n\t\tdidWarnMissingReporter = true\n\t\t// biome-ignore lint/suspicious/noConsole: fallback when error reporter is not yet initialized\n\t\tconsole.error(\"Set up an error callback with setErrorReporter, or configure Sentry with initializeEnvironment\")\n\t}\n\n\treturn error\n}\n\nexport function unhandledError(error: unknown): void {\n\terror = reportableError(error, unhandledError)\n\tsetTimeout(() => {\n\t\tthrow error\n\t}, 0)\n}\n\nexport function reportableError(error: unknown, caller: Function = reportableError): ErrorWithMetadata {\n\tif (error instanceof Error) {\n\t\treturn error\n\t}\n\n\t// Handle cases where error is not an error instance so we can correctly\n\t// capture a stack trace.\n\treturn new UnhandledError(error, caller)\n}\n\nclass UnhandledError extends Error {\n\tconstructor(error: unknown, caller: Function) {\n\t\tconst message = error ? JSON.stringify(error) : \"No error message provided\"\n\t\tsuper(message)\n\t\tthis.message = message\n\n\t\t// Consistent stack handling across browsers. Chrome allows you to\n\t\t// manipulate the callstack with captureStackTrace and filter\n\t\t// everything above the `caller` argument.\n\t\t// Firefox normally creates the stack on throw, so here we define\n\t\t// it in the constructor to match WebKit & Blink.\n\t\tif (caller && Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, caller)\n\t\t} else {\n\t\t\t// If no start stack function was provided we just use the original stack property\n\t\t\ttry {\n\t\t\t\tthrow new Error()\n\t\t\t} catch (e) {\n\t\t\t\tthis.stack = (e as Error).stack\n\t\t\t}\n\t\t}\n\t}\n}\n", "interface HostMap {\n\tmain: string\n\tpreviewLink: string | undefined\n}\n\nconst hostname = typeof window !== \"undefined\" && !(\"Deno\" in globalThis) ? window.location.hostname : undefined\nconst isLocal = Boolean(hostname && [\"web.framerlocal.com\", \"localhost\", \"127.0.0.1\", \"[::1]\"].includes(hostname))\n\nconst hosts = ((): HostMap | undefined => {\n\tif (!hostname) return // Not running in a browser.\n\n\tif (isLocal) {\n\t\treturn { main: hostname, previewLink: undefined }\n\t}\n\n\t// [0] Entire domain [1] Beta prefix [2] Preview link prefix [3] Stable domain\n\tconst previewHostRegex = /^(([^.]+\\.)?beta\\.)?((?:development\\.)?framer\\.com)$/u\n\tconst match = hostname.match(previewHostRegex)\n\tif (!match || !match[3]) return // Unknown domain.\n\treturn {\n\t\tpreviewLink: match[2] && match[0],\n\t\tmain: match[3],\n\t}\n})()\n\nexport const hostInfo = {\n\thosts,\n\tisDevelopment: hosts?.main === \"development.framer.com\",\n\tisProduction: hosts?.main === \"framer.com\",\n\tisLocal,\n}\n\nconst hostnameRegex = /^(?:[a-z]+:\\/\\/)?(?:[^@/]*@)?(\\[[^\\]]+\\]|[^:/\\s?#]+)/iu\nconst localHostnames = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\"])\n\n/** Returns true if the hostname points to localhost. Also accepts a hostname:port pair or a URL. */\nexport function isLocalHostname(hostname: string): boolean {\n\tif (hostname.includes(\":\") || hostname.includes(\"/\")) {\n\t\thostname = hostnameRegex.exec(hostname)?.[1] ?? \"\"\n\t}\n\treturn localHostnames.has(hostname)\n}\n", "import type { BootstrappedWindow, ServiceMap } from \"@framerjs/bootstrap\"\nexport type { ServiceMap }\n\nlet cachedServiceMap: ServiceMap | undefined\n\nexport function getServiceMap(): ServiceMap {\n\t// In non browser contexts there is no service map so we just return non functional stub which\n\t// is good enough for code to initialize.\n\tif (typeof window === \"undefined\") return {} as ServiceMap\n\n\tif (cachedServiceMap) return cachedServiceMap\n\tcachedServiceMap = extractServiceMap()\n\treturn cachedServiceMap\n}\n\nfunction extractServiceMap(): ServiceMap {\n\tconst location = window.location\n\n\t// First check for the service map embedded on the page.\n\t// TODO: Embed it in a nicer way (a script tag that exposes getServiceMap()).\n\tlet services = (window as BootstrappedWindow)?.bootstrap?.services\n\tif (services) {\n\t\treturn services\n\t}\n\t// If the service map is not available, try accessing the top frame.\n\tlet topOrigin: string | undefined\n\ttry {\n\t\tconst topWindow = window.top as BootstrappedWindow\n\t\t// This fails if we are sandboxed from the top frame.\n\t\ttopOrigin = topWindow.location.origin\n\t\tservices = (window.top as BootstrappedWindow)?.bootstrap?.services\n\t\tif (services) {\n\t\t\treturn services\n\t\t}\n\t} catch (e) {\n\t\t// Ignore\n\t}\n\tif (process.env.NODE_ENV !== \"development\" && topOrigin && topOrigin !== location.origin) {\n\t\tthrow Error(`Unexpectedly embedded by ${topOrigin} (expected ${location.origin})`)\n\t}\n\t// Don't trust any values if we get here on what seems to be a framer.com domain.\n\tif (location.origin.endsWith(\"framer.com\") || location.origin.endsWith(\"framer.dev\")) {\n\t\tthrow Error(\"ServiceMap data was not provided in document\")\n\t}\n\t// If we get here we're sandboxed from the top frame.\n\t// TODO: Provide this data via a trusted endpoint instead of query string.\n\ttry {\n\t\tconst servicesJSON =\n\t\t\tnew URLSearchParams(location.search).get(\"services\") ||\n\t\t\tnew URLSearchParams(location.hash.substring(1)).get(\"services\")\n\t\tif (servicesJSON) {\n\t\t\tservices = JSON.parse(servicesJSON)\n\t\t}\n\t} catch (e) {\n\t\t// Ignore\n\t}\n\tif (services && typeof services === \"object\" && services.api) {\n\t\treturn services\n\t}\n\tthrow Error(\"ServiceMap requested but not available\")\n}\n", "import { getServiceMap } from \"./ServiceMap.ts\"\nimport { reportError } from \"./errors.ts\"\nimport type { Prettify } from \"./prettify.ts\"\n\n// Prepare an object for JSON.stringify, so it is safe and useful to log into a string.\nfunction jsonSafeCopy(\n\tobj: unknown,\n\tdepth: number = 0,\n\tseen: Set<object> = new Set(),\n): string | object | null | undefined {\n\tif (obj === null) return obj\n\tif (typeof obj === \"function\") return `[Function: ${obj.name ?? \"unknown\"}]`\n\tif (typeof obj !== \"object\") return obj\n\tif (obj instanceof Error) return `[${obj.toString()}]`\n\tif (seen.has(obj)) return \"[Circular]\"\n\tif (depth > 2) return \"...\"\n\n\tseen.add(obj)\n\ttry {\n\t\tif (\"toJSON\" in obj && typeof obj.toJSON === \"function\") {\n\t\t\treturn jsonSafeCopy(obj.toJSON(), depth + 1, seen)\n\t\t} else if (Array.isArray(obj)) {\n\t\t\treturn obj.map(v => jsonSafeCopy(v, depth + 1, seen))\n\t\t} else if (Object.getPrototypeOf(obj) !== Object.prototype) {\n\t\t\treturn `[Object: ${(\"__class\" in obj && obj.__class) || obj.constructor?.name}]`\n\t\t} else {\n\t\t\tconst result: Record<string, string | object | null | undefined> = {}\n\t\t\tfor (const [key, v] of Object.entries(obj)) {\n\t\t\t\tresult[key] = jsonSafeCopy(v, depth + 1, seen)\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t} catch (e) {\n\t\treturn `[Throws: ${e instanceof Error ? e.message : e}]`\n\t} finally {\n\t\tseen.delete(obj)\n\t}\n}\n\nexport enum LogLevel {\n\tTrace = 0,\n\tDebug = 1,\n\tInfo = 2,\n\tWarn = 3,\n\tError = 4,\n\tNotLogging = 5,\n}\n\nexport const enum ReportTag {\n\t/**\n\t * Set this tag to a random 5-character error reference that is also\n\t * presented to the user so that we can find errors from user screenshots in\n\t * Sentry by searching tags.\n\t */\n\tErrorRef = \"errorRef\",\n}\n\nexport type ErrorTags = Prettify<\n\t{\n\t\t[reportTag in ReportTag]: string\n\t} & {\n\t\t[key: string]: string\n\t} & {\n\t\textraExperiments?: string\n\t}\n>\nconst levelNames = [\"trace\", \"debug\", \"info\", \"warn\", \"error\"]\nconst consoleLevelEmojis = [\"\uD83D\uDD0D\", \"\uD83E\uDDEA\", \"\u2139\uFE0F\", \"\u26A0\uFE0F\", \"\u274C\"]\nconst postfixNames = [\":trace\", \":debug\", \":info\", \":warn\", \":error\"]\nconst logTimestampsStorageKey = \"logTimestamps\"\nconst isoTimePrefixPattern = /^T?\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z /u\n\nexport function formatLogTimestamp(time: number): string {\n\treturn new Date(time).toISOString().substring(10, 24)\n}\n\nexport function hasLogTimestampPrefix(text: string): boolean {\n\treturn isoTimePrefixPattern.test(text)\n}\n\nfunction applyLogLevelSpec(spec: string, all: Logger[]) {\n\tconst missingSpecs: string[] = []\n\n\t// For every section of the specification string.\n\tfor (const s of spec.split(/[ ,]/u)) {\n\t\tlet match = s.trim()\n\t\tif (match.length === 0) continue\n\n\t\tlet level = LogLevel.Debug\n\t\tlet inverted = false\n\n\t\t// Check if it match should be disabled.\n\t\tif (match.startsWith(\"-\")) {\n\t\t\tmatch = match.slice(1)\n\t\t\tlevel = LogLevel.Warn\n\t\t\tinverted = true\n\t\t}\n\n\t\t// Check the specified log level for this matcher, if any.\n\t\tfor (let i = 0; i <= LogLevel.Error; i++) {\n\t\t\tconst postfix = postfixNames[i]\n\t\t\tif (!postfix) continue\n\t\t\tif (match.endsWith(postfix)) {\n\t\t\t\tlevel = i\n\t\t\t\tif (inverted) {\n\t\t\t\t\t// -:warn should also disable warning, so set log level at one higher\n\t\t\t\t\tlevel += 1\n\t\t\t\t}\n\t\t\t\tmatch = match.slice(0, match.length - postfix.length)\n\t\t\t\tif (match.length === 0) {\n\t\t\t\t\tmatch = \"*\"\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// Make a string matcher and set the log level for every matching logger.\n\t\tconst regex = new RegExp(\"^\" + escapeRegExp(match).replace(/\\\\\\*/gu, \".*\") + \"$\")\n\t\tlet loggersUpdated = 0\n\t\tfor (const logger of all) {\n\t\t\tif (logger.id.match(regex)) {\n\t\t\t\tlogger.level = level\n\t\t\t\t++loggersUpdated\n\t\t\t}\n\t\t}\n\n\t\tif (loggersUpdated === 0) {\n\t\t\tmissingSpecs.push(s)\n\t\t}\n\t}\n\n\treturn missingSpecs\n}\n\nclass LogEntry {\n\tstatic nextId = 0\n\tid: number\n\ttime: number\n\tstringPrefix: string | undefined\n\tprivate cachedMessage: unknown[] | undefined\n\n\tconstructor(\n\t\tpublic logger: Logger,\n\t\tpublic level: LogLevel | -1,\n\t\tpublic parts: unknown[],\n\t) {\n\t\tthis.id = LogEntry.nextId++\n\t\tthis.time = Date.now()\n\t}\n\n\ttoMessage(): unknown[] {\n\t\tif (this.stringPrefix) return this.cachedMessage ?? this.parts\n\n\t\tconst prefixParts = [levelNames[this.level] + \": [\" + this.logger.id + \"]\"]\n\t\tif (logTimestampsEnabled) {\n\t\t\tprefixParts.unshift(formatLogTimestamp(this.time))\n\t\t}\n\t\tthis.stringPrefix = prefixParts.join(\" \")\n\t\tconst firstPart = this.parts[0]\n\t\tif (typeof firstPart === \"string\") {\n\t\t\tconst strippedFirstPart = stripLogEntryPrefix(firstPart, this.logger.id, this.level)\n\t\t\tthis.cachedMessage = [\n\t\t\t\tstrippedFirstPart.length > 0 ? `${this.stringPrefix} ${strippedFirstPart}` : this.stringPrefix,\n\t\t\t\t...this.parts.slice(1),\n\t\t\t]\n\t\t} else {\n\t\t\tthis.cachedMessage = [this.stringPrefix, ...this.parts]\n\t\t}\n\t\treturn this.cachedMessage\n\t}\n\n\tresetMessagePrefix(): void {\n\t\tthis.stringPrefix = undefined\n\t\tthis.cachedMessage = undefined\n\t}\n\n\ttoConsoleMessage(): unknown[] {\n\t\tconst message = this.toMessage().slice()\n\t\tconst firstPart = message[0]\n\t\tif (typeof firstPart !== \"string\") return message\n\n\t\tconst levelName = levelNames[this.level]\n\t\tconst levelEmoji = consoleLevelEmojis[this.level]\n\t\tif (levelName && levelEmoji) {\n\t\t\tmessage[0] = firstPart.replace(`${levelName}:`, `${levelEmoji}`)\n\t\t}\n\n\t\tconst category = `[${this.logger.id}]`\n\t\tconst styledFirstPart = message[0]\n\t\tif (typeof styledFirstPart !== \"string\") return message\n\t\tconst categoryIndex = styledFirstPart.indexOf(category)\n\t\tif (categoryIndex < 0) return message\n\n\t\tmessage[0] =\n\t\t\tstyledFirstPart.slice(0, categoryIndex) +\n\t\t\t\"%c\" +\n\t\t\tcategory +\n\t\t\t\"%c\" +\n\t\t\tstyledFirstPart.slice(categoryIndex + category.length)\n\t\tmessage.splice(1, 0, \"color: #9ca3af\", \"\")\n\t\treturn message\n\t}\n\n\ttoString(): string {\n\t\treturn this.toMessage()\n\t\t\t.map(part => {\n\t\t\t\tconst type = typeof part\n\t\t\t\tif (type === \"string\") return part\n\t\t\t\tif (type === \"function\") return `[Function: ${(part as Function).name ?? \"unknown\"}]`\n\t\t\t\tif (part instanceof Error) return part.stack ?? part.toString()\n\n\t\t\t\t// Create a useful string from any object, making sure it is safe and truncated if needed.\n\t\t\t\tconst json = JSON.stringify(jsonSafeCopy(part))\n\t\t\t\tif (json?.length > 253) {\n\t\t\t\t\treturn json.slice(0, 250) + \"...\"\n\t\t\t\t}\n\t\t\t\treturn json\n\t\t\t})\n\t\t\t.join(\" \")\n\t}\n}\n\n// Default log level.\nlet logLevelSpec = \"*:app:info,app:info\"\nlet logTimestampsEnabled = true\n\n// But different in node and even in CI.\nconst isNode = typeof process !== \"undefined\" && !!process.kill\nconst isCI = isNode && !!process.env.CI\nif (isCI) {\n\tlogLevelSpec = \"-:warn\"\n} else if (isNode) {\n\tlogLevelSpec = \"\"\n}\n\n// Recover the log level specification from local storage or an environment variable.\ntry {\n\tif (typeof window !== \"undefined\" && window.localStorage) {\n\t\tlogLevelSpec = window.localStorage.logLevel || logLevelSpec\n\t\tlogTimestampsEnabled = window.localStorage[logTimestampsStorageKey] !== \"false\"\n\t}\n} catch {\n\t// ignore\n}\ntry {\n\tif (typeof process !== \"undefined\") {\n\t\tlogLevelSpec = process.env.DEBUG || logLevelSpec\n\t}\n} catch {\n\t// ignore\n}\ntry {\n\tif (typeof window !== \"undefined\") {\n\t\tObject.assign(window, { setLogLevel, setLogTimestamps })\n\t}\n} catch {\n\t// ignore\n}\n\ntry {\n\tif (typeof window !== \"undefined\" && !!window.postMessage && window.top === window) {\n\t\t// On the main window, setup a listener for logs sent over postMessage.\n\t\twindow.addEventListener(\"message\", msg => {\n\t\t\tif (!msg.data || typeof msg.data !== \"object\") return\n\n\t\t\tconst { loggerId, level, parts, printed } = msg.data\n\t\t\tif (typeof loggerId !== \"string\") return\n\t\t\tif (!Array.isArray(parts) || parts.length < 1 || typeof level !== \"number\") return\n\n\t\t\tconst logger = getLogger(loggerId)\n\t\t\tif (level < LogLevel.Trace || level > LogLevel.NotLogging) return\n\n\t\t\tparts[0] = parts[0].replace(\"[\", \"*[\")\n\t\t\tconst entry = new LogEntry(logger, level, parts)\n\t\t\tentry.stringPrefix = parts[0]\n\t\t\treplayBuffer.push(entry)\n\n\t\t\t// Print out message if appropriate\n\t\t\tif (printed) return\n\t\t\tif (logger.level > level) return\n\n\t\t\tconsole?.log(...entry.toConsoleMessage())\n\t\t})\n\t}\n} catch {\n\t// ignore\n}\n\nlet postLogEntry: ((entry: LogEntry) => void) | undefined\ntry {\n\tif (\n\t\ttypeof window !== \"undefined\" &&\n\t\t!!window.postMessage &&\n\t\twindow.parent !== window &&\n\t\t// Don't post messages to the top-level site from the Editor Bar\n\t\t!window.location.pathname.startsWith(\"/edit\")\n\t) {\n\t\t// On any iframe window, setup a method that posts logs to the main window.\n\t\tpostLogEntry = (entry: LogEntry) => {\n\t\t\ttry {\n\t\t\t\tconst parts = entry.toMessage().map(p => jsonSafeCopy(p))\n\t\t\t\tconst logger = entry.logger\n\t\t\t\tconst level = entry.level\n\t\t\t\tconst printed = logger.level <= entry.level\n\t\t\t\tconst data = { loggerId: logger.id, level, parts, printed }\n\t\t\t\twindow.parent?.postMessage(data, getServiceMap().app)\n\t\t\t} catch {\n\t\t\t\t// ignore\n\t\t\t}\n\t\t}\n\t}\n} catch {\n\t// ignore\n}\n\nconst loggers: { [key: string]: Logger } = {}\nconst replayBuffer: LogEntry[] = []\nlet maxReplayBufferEntries = 1000\n\nfunction createLogEntry(logger: Logger, level: LogLevel, parts: unknown[]): LogEntry {\n\tconst entry = new LogEntry(logger, level, parts)\n\treplayBuffer.push(entry)\n\tpostLogEntry?.(entry)\n\n\t// Keep a limited number of entries in the replay buffer\n\twhile (replayBuffer.length > maxReplayBufferEntries) {\n\t\treplayBuffer.shift()\n\t}\n\n\treturn entry\n}\n\n/** Get the internal buffer of recent log messages. Use with care! But can be\n * used for scripting browser based tests. */\nexport function getLogReplayBuffer(maxEntries?: number): LogEntry[] {\n\tif (typeof maxEntries === \"number\") {\n\t\tmaxReplayBufferEntries = maxEntries\n\t}\n\treturn replayBuffer\n}\n\nconst pathRegex = /\\/(?<filename>[^/.]+)(?=\\.(?:debug\\.)?html$)/u\nlet cachedFilename: string | undefined\nfunction getFilenameFromWindowPathname() {\n\tif (typeof window === \"undefined\" || !window.location) return\n\tcachedFilename ??= pathRegex.exec(window.location.pathname)?.groups?.filename\n\treturn cachedFilename\n}\n\n/** Get a logger for a certain id, will create a new logger if needed. */\nexport function getLogger(id: string): Logger {\n\tconst path = getFilenameFromWindowPathname()\n\tid = (path ? path + \":\" : \"\") + id\n\tconst existing = loggers[id]\n\tif (existing) return existing\n\n\tconst logger = new Logger(id)\n\tloggers[id] = logger\n\tapplyLogLevelSpec(logLevelSpec, [logger])\n\tpostLogEntry?.(new LogEntry(logger, -1, []))\n\treturn logger\n}\n\nexport function getLoggers(): string[] {\n\treturn Object.keys(loggers)\n}\n\n/** Set all log levels via a string, returns previous setting. */\nexport function setLogLevel(spec: string, replay = true): string {\n\t// Persist the specification via local storage, if applicable.\n\ttry {\n\t\tif (typeof window !== \"undefined\" && window.localStorage) {\n\t\t\twindow.localStorage.logLevel = spec\n\t\t}\n\t} catch {\n\t\t// ignore\n\t}\n\n\tconst previousSpec = logLevelSpec\n\tlogLevelSpec = spec\n\tconst all = Object.values(loggers)\n\n\t// Reset all loggers to default.\n\tfor (const logger of all) {\n\t\tlogger.level = LogLevel.Warn\n\t}\n\n\t// Apply new log rules to all loggers.\n\tconst missingSpecs = applyLogLevelSpec(spec, all)\n\tif (missingSpecs.length > 0) {\n\t\tconsole?.warn(\"Some log level specs matched no loggers:\", missingSpecs)\n\t}\n\n\t// Replay the buffer for new setting.\n\tif (replay && replayBuffer.length > 0) {\n\t\tconsole?.log(\"--- LOG REPLAY ---\")\n\t\tfor (const entry of replayBuffer) {\n\t\t\tif (entry.logger.level > entry.level) continue\n\t\t\tif (entry.level >= LogLevel.Warn) {\n\t\t\t\tconsole?.warn(...entry.toConsoleMessage())\n\t\t\t} else {\n\t\t\t\tconsole?.log(...entry.toConsoleMessage())\n\t\t\t}\n\t\t}\n\t\tconsole?.log(\"--- END OF LOG REPLAY ---\")\n\t}\n\n\treturn previousSpec\n}\n\n/** Enable or disable timestamp prefixes in log output. Returns previous setting. */\nexport function setLogTimestamps(enabled: boolean): boolean {\n\tconst previousEnabled = logTimestampsEnabled\n\tlogTimestampsEnabled = enabled\n\tfor (const entry of replayBuffer) {\n\t\tentry.resetMessagePrefix()\n\t}\n\n\ttry {\n\t\tif (typeof window !== \"undefined\" && window.localStorage) {\n\t\t\twindow.localStorage[logTimestampsStorageKey] = String(enabled)\n\t\t}\n\t} catch {\n\t\t// ignore\n\t}\n\n\treturn previousEnabled\n}\n\nexport function getLogTimestamps(): boolean {\n\treturn logTimestampsEnabled\n}\n\nexport const enrichWithLogs = <Obj extends Record<string, unknown>>(extras: Obj): Obj & { logs: string } => {\n\tconst result = {\n\t\t...extras,\n\t\tlogs: getLogReplayBuffer()\n\t\t\t.slice(-50)\n\t\t\t.map(entry => entry.toString().slice(0, 600))\n\t\t\t.join(\"\\n\"),\n\t}\n\n\tif (extras.logs) {\n\t\tconsole?.warn(\"extras.logs is reserved for log replay buffer, use another key\")\n\t}\n\n\treturn result\n}\n\n/** If you see `logger.ts` show up as the source of log message,  you can\n * blackbox the script (in google chrome):\n * - go to developer tools\n * - open up settings\n * - go to blackbox\n * - add `.*logger.ts` as a pattern. That should make the original point of\n *   logging appear in the right hand side of the console.\n * */\nexport class Logger {\n\tlevel: LogLevel = LogLevel.Warn\n\tprivate didLog: { [key: string]: number } = {}\n\tprivate readonly errorIsCritical: boolean\n\n\tconstructor(\n\t\treadonly id: string,\n\t\terrorIsCritical?: boolean,\n\t) {\n\t\tthis.errorIsCritical = errorIsCritical ?? (id === \"fatal\" || id.endsWith(\":fatal\"))\n\t}\n\n\tpublic extend(name: string): Logger {\n\t\tconst id = this.id + \":\" + name\n\t\treturn getLogger(id)\n\t}\n\n\t/** Returns the messages this logger created that are still in the global replay buffer. */\n\tpublic getBufferedMessages(): LogEntry[] {\n\t\treturn replayBuffer.filter(entry => entry.logger === this)\n\t}\n\n\t/** Set new level and return previous level. */\n\tpublic setLevel(level: LogLevel): LogLevel {\n\t\tconst previous = this.level\n\t\tthis.level = level\n\t\treturn previous\n\t}\n\n\t/** Check if a trace messages will be output. */\n\tpublic isLoggingTraceMessages(): boolean {\n\t\treturn this.level >= LogLevel.Trace\n\t}\n\n\t/**\n\t * Trace level messages are not recorded, send to parent frames, or outputted, unless the logger\n\t * is current set at the trace level.\n\t */\n\ttrace = (...parts: unknown[]) => {\n\t\tif (this.level > LogLevel.Trace) return\n\t\tconst entry = createLogEntry(this, LogLevel.Trace, parts)\n\t\tconsole?.log(...entry.toConsoleMessage())\n\t}\n\n\t/** Debug level is supposed to be used for things that log often and are disabled by default. */\n\tdebug = (...parts: unknown[]) => {\n\t\tconst entry = createLogEntry(this, LogLevel.Debug, parts)\n\t\tif (this.level > LogLevel.Debug) return\n\t\tconsole?.log(...entry.toConsoleMessage())\n\t}\n\n\t/**\n\t * Info level is supposed to be used for once per big user action, or maybe once per minute\n\t * things. Some loggers log at this level by default. Don't overuse.\n\t */\n\tinfo = (...parts: unknown[]) => {\n\t\tconst entry = createLogEntry(this, LogLevel.Info, parts)\n\t\tif (this.level > LogLevel.Info) return\n\t\tconsole?.info(...entry.toConsoleMessage())\n\t}\n\n\twarn = (...parts: unknown[]) => {\n\t\tconst entry = createLogEntry(this, LogLevel.Warn, parts)\n\t\tif (this.level > LogLevel.Warn) return\n\t\tconsole?.warn(...entry.toConsoleMessage())\n\t}\n\n\twarnOncePerMinute = (firstPart: string, ...parts: unknown[]) => {\n\t\tconst lastLoggedTime = this.didLog[firstPart]\n\t\tif (lastLoggedTime && lastLoggedTime > Date.now()) return\n\t\tthis.didLog[firstPart] = Date.now() + 1000 * 60\n\n\t\tparts.unshift(firstPart)\n\t\tconst entry = createLogEntry(this, LogLevel.Warn, parts)\n\t\tif (this.level > LogLevel.Warn) return\n\t\tconsole?.warn(...entry.toConsoleMessage())\n\t}\n\n\terror = (...parts: unknown[]) => {\n\t\tconst entry = createLogEntry(this, LogLevel.Error, parts)\n\t\tif (this.level > LogLevel.Error) return\n\t\tconsole?.error(...entry.toConsoleMessage())\n\t}\n\n\terrorOncePerMinute = (firstPart: string, ...parts: unknown[]) => {\n\t\tconst lastLoggedTime = this.didLog[firstPart]\n\t\tif (lastLoggedTime && lastLoggedTime > Date.now()) return\n\t\tthis.didLog[firstPart] = Date.now() + 1000 * 60\n\n\t\tparts.unshift(firstPart)\n\t\tconst entry = createLogEntry(this, LogLevel.Error, parts)\n\t\tif (this.level > LogLevel.Error) return\n\t\tconsole?.error(...entry.toConsoleMessage())\n\t}\n\n\t/** Reports to Sentry, without logging to the console */\n\treportWithoutLogging = (\n\t\tmaybeError: unknown,\n\t\textras?: Record<string, unknown>,\n\t\ttags?: Partial<ErrorTags>,\n\t\tcritical?: boolean,\n\t) => {\n\t\tconst enrichedExtras = enrichWithLogs(extras ?? {})\n\n\t\tconst enrichedError = reportError({\n\t\t\tcaller: this.reportWithoutLogging,\n\t\t\terror: maybeError,\n\t\t\ttags: {\n\t\t\t\t...tags,\n\t\t\t\thandler: \"logger\",\n\t\t\t\twhere: this.id,\n\t\t\t},\n\t\t\textras,\n\t\t\tcritical: critical ?? this.errorIsCritical,\n\t\t})\n\n\t\treturn [enrichedExtras, enrichedError]\n\t}\n\n\t/** Reports to Sentry */\n\treportError = (\n\t\tmaybeError: unknown,\n\t\textras?: Record<string, unknown>,\n\t\ttags?: Partial<ErrorTags>,\n\t\tcritical?: boolean,\n\t) => {\n\t\tconst [enrichedExtras, enrichedError] = this.reportWithoutLogging(maybeError, extras, tags, critical)\n\n\t\t// Log the error to the console/buffer as well\n\t\tif (enrichedExtras) {\n\t\t\tthis.error(enrichedError, enrichedExtras)\n\t\t} else {\n\t\t\tthis.error(enrichedError)\n\t\t}\n\t}\n\n\t/** Reports to Sentry */\n\treportErrorWithThrottle = (\n\t\tthrottleDurationMs: number,\n\t\terror: unknown,\n\t\textras?: Record<string, unknown>,\n\t\ttags?: Partial<ErrorTags>,\n\t\tcritical?: boolean,\n\t) => {\n\t\tif (!isErrorWithMessage(error)) return\n\t\tconst lastLoggedTime = this.didLog[error.message]\n\t\tif (lastLoggedTime && lastLoggedTime > Date.now()) return\n\n\t\tthis.didLog[error.message] = Date.now() + throttleDurationMs\n\t\tthis.reportError(error, extras, tags, critical)\n\t}\n\n\treportErrorOncePerMinute = (\n\t\terror: unknown,\n\t\textras?: Record<string, unknown>,\n\t\ttags?: Partial<ErrorTags>,\n\t\tcritical?: boolean,\n\t) => {\n\t\treturn this.reportErrorWithThrottle(1000 * 60, error, extras, tags, critical)\n\t}\n\n\treportErrorOnceEveryTenMinutes = (\n\t\terror: unknown,\n\t\textras?: Record<string, unknown>,\n\t\ttags?: Partial<ErrorTags>,\n\t\tcritical?: boolean,\n\t) => {\n\t\treturn this.reportErrorWithThrottle(1000 * 60 * 10, error, extras, tags, critical)\n\t}\n\n\t/** Reports to Sentry */\n\treportCriticalError = (maybeError: unknown, extras?: Record<string, unknown>, tags?: ErrorTags) =>\n\t\tthis.reportError(maybeError, extras, tags, true)\n}\n\nfunction isErrorWithMessage(maybeError: unknown): maybeError is Error {\n\treturn Object.prototype.hasOwnProperty.call(maybeError, \"message\")\n}\n\n// A ponyfill for RegExp.escape(). Source: https://stackoverflow.com/a/3561711\nfunction escapeRegExp(string: string): string {\n\treturn string.replace(/[/\\-\\\\^$*+?.()|[\\]{}]/gu, \"\\\\$&\")\n}\n\nfunction stripLogEntryPrefix(text: string, loggerId: string, level: LogLevel | -1): string {\n\tconst levelName = levelNames[level]\n\tif (!levelName) return text\n\n\tconst loggerPrefix = `${levelName}: [${loggerId}]`\n\tconst loggerPrefixPattern = escapeRegExp(loggerPrefix).replace(\"\\\\[\", \"\\\\*?\\\\[\")\n\tconst prefixPattern = new RegExp(`^(?:T?\\\\d{2}:\\\\d{2}:\\\\d{2}\\\\.\\\\d{3}Z\\\\s+)?${loggerPrefixPattern}\\\\s*`)\n\treturn text.replace(prefixPattern, \"\")\n}\n\n// \u2757\uFE0F\n// The Shared package needs to work in any TypeScript environment. Reference DOM types without importing or depending\n// on them so that the package compiles, but fails or skips functionality when used in a non-DOM environment.\ndeclare const console: (typeof global)[\"console\"] | undefined\n", "/** Represents multiple values that are different. */\nexport const Mixed = Symbol(\"Mixed\")\n\n/** Represents multiple values that are different. */\nexport type Mixed = typeof Mixed\n\nexport function isMixed(value: unknown): value is Mixed {\n\treturn value === Mixed\n}\n", "export const DEPENDENCIES_MODULE_NAME = \"dependencies\" as const\nexport const DEPENDENCIES_MODULE_TYPE = \"config\" as const\nexport const DEPENDENCIES_MODULE_TYPE_SLASH_NAME = `${DEPENDENCIES_MODULE_TYPE}/${DEPENDENCIES_MODULE_NAME}` as const\nconst IMPORT_MAP_FILE_NAME = \"importMap.json\" as const\nconst DEPENDENCIES_FILE_NAME = \"dependencies.json\" as const\nexport const IMPORT_MAP_FILE_ID = `${DEPENDENCIES_MODULE_TYPE_SLASH_NAME}/${IMPORT_MAP_FILE_NAME}` as const\nexport const DEPENDENCIES_FILE_ID = `${DEPENDENCIES_MODULE_TYPE_SLASH_NAME}/${DEPENDENCIES_FILE_NAME}` as const\n\nexport function isDependenciesFileId(id: string): id is typeof IMPORT_MAP_FILE_ID | typeof DEPENDENCIES_FILE_ID {\n\treturn id === IMPORT_MAP_FILE_ID || id === DEPENDENCIES_FILE_ID\n}\n\nexport function getDependenciesFileName(id: string): typeof IMPORT_MAP_FILE_NAME | typeof DEPENDENCIES_FILE_NAME {\n\tif (id === IMPORT_MAP_FILE_ID) return IMPORT_MAP_FILE_NAME\n\tif (id === DEPENDENCIES_FILE_ID) return DEPENDENCIES_FILE_NAME\n\tthrow new Error(`Invalid dependencies file ID: ${id}`)\n}\n", "export const USE_FREEZE = process.env.NODE_ENV !== \"production\"\n\n/** A namespace for extra functions on readonly arrays. These functions take a readonly array, but return a\n * regular array. Once the result is assigned to a readonly variable, these arrays should not be mutated\n * further. These function can be used the same as built-in Array methods like `concat`, `slice` or `map` and\n * `filter`. */\nexport namespace List {\n\t/** Appends one or many new elements to the end of the list. Always returns a copy. */\n\texport function push<T>(ls: readonly T[], ...elements: T[]): readonly T[] {\n\t\treturn ls.concat(elements)\n\t}\n\n\t/** Removes the last element from the list. Always returns a copy. */\n\texport function pop<T>(a: readonly T[]): readonly T[] {\n\t\treturn a.slice(0, -1)\n\t}\n\n\t/** Appends one or many new elements to the beginning of the list. Always returns a copy. */\n\texport function unshift<T>(ls: readonly T[], ...elements: T[]): readonly T[] {\n\t\treturn elements.concat(ls)\n\t}\n\n\t/** Insert a new element into the array. Always returns a copy. */\n\texport function insert<T>(a: readonly T[], index: number, ...elements: T[]): readonly T[] {\n\t\tconst length = a.length\n\t\tif (index < 0 || index > length) throw Error(\"index out of range: \" + index)\n\n\t\tconst copy = a.slice()\n\t\tcopy.splice(index, 0, ...elements)\n\t\treturn copy\n\t}\n\n\t/** Replace an element in the array. Always returns a copy. */\n\texport function replace<T>(a: readonly T[], index: number, replacement: T | T[]): readonly T[] {\n\t\tconst length = a.length\n\t\tif (index < 0 || index >= length) throw Error(\"index out of range: \" + index)\n\n\t\tconst itemsToAdd = Array.isArray(replacement) ? replacement : [replacement]\n\t\tconst copy = a.slice()\n\t\tcopy.splice(index, 1, ...itemsToAdd)\n\t\treturn copy\n\t}\n\n\t/** Remove an element from the array. Always returns a copy. */\n\texport function remove<T>(a: readonly T[], index: number): readonly T[] {\n\t\tconst length = a.length\n\t\tif (index < 0 || index >= length) throw Error(\"index out of range: \" + index)\n\n\t\tconst copy = a.slice()\n\t\tcopy.splice(index, 1)\n\t\treturn copy\n\t}\n\n\t/** Moves an element in the array. Always returns a copy. */\n\texport function move<T>(a: readonly T[], from: number, to: number): readonly T[] {\n\t\tconst length = a.length\n\t\tif (from < 0 || from >= length) throw Error(\"from index out of range: \" + from)\n\t\tif (to < 0 || to >= length) throw Error(\"to index out of range: \" + to)\n\n\t\tconst copy = a.slice()\n\t\tif (to === from) return copy\n\n\t\t// `copy` is a copy of `a`, and we already check above that `from` does not go out of bound. The cast here\n\t\t// is to appease TS.\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\tconst element = copy[from] as T\n\t\tif (from < to) {\n\t\t\tcopy.splice(to + 1, 0, element)\n\t\t\tcopy.splice(from, 1)\n\t\t} else {\n\t\t\tcopy.splice(from, 1)\n\t\t\tcopy.splice(to, 0, element)\n\t\t}\n\t\treturn copy\n\t}\n\n\t/** Takes two lists and returns a list of pairs, matching up a[0] with b[0], ..., a[n] with b[n], until\n\t * one of the list runs out of elements. */\n\texport function zip<T1, T2>(a: readonly T1[], b: readonly T2[]): readonly [T1, T2][] {\n\t\tconst res: [T1, T2][] = []\n\t\tconst length = Math.min(a.length, b.length)\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\t// By picking the minimum length we ensure that a[i]/b[i] won't go out of bound, so the type cast should be\n\t\t\t// safe. We can't early return if the value is undefined, since T1/T2 could be undefined.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TS doesn't recognize the types from the `length` check above\n\t\t\tres.push([a[i] as T1, b[i] as T2])\n\t\t}\n\t\treturn res\n\t}\n\n\t/** Updates an element of an array via a inline body, returns a copy of the array with one element\n\t * replaced. */\n\texport function update<T>(a: readonly T[], index: number, body: (currentElement: T) => T): readonly T[] {\n\t\tconst res = a.slice()\n\t\tconst targetElement = res[index]\n\t\tif (targetElement === undefined) return res\n\t\tres[index] = body(targetElement)\n\t\treturn res\n\t}\n\n\t/**\n\t * Removes any duplicate values from an array and returns a new array\n\t * @param a the array to inspect\n\t */\n\texport function unique<T>(a: readonly T[]): readonly T[] {\n\t\treturn Array.from(new Set(a))\n\t}\n\n\t/**\n\t * Returns a readonly array including any values that does not already exist\n\t * @param a the array to extend\n\t * @param collections the arrays to merge\n\t */\n\texport function union<T>(a: readonly T[], ...collections: ConcatArray<T>[]) {\n\t\treturn Array.from(new Set([...a, ...collections.flat()])) as readonly T[]\n\t}\n\n\t/**\n\t * Returns a readonly array that has only those elements for which the predicate returned true.\n\t */\n\texport function filter<T>(a: readonly T[], predicate: (element: T) => boolean): readonly T[] {\n\t\treturn a.filter(predicate)\n\t}\n}\n\n/** Can be used to create writable placeholders for updates. */\nexport type Writeable<T> = { -readonly [P in keyof T]: T[P] }\n\nconst objectHasOwnProperty = Object.prototype.hasOwnProperty\nfunction hasOwnProperty(object: unknown, property: string) {\n\treturn objectHasOwnProperty.call(object, property)\n}\n\n/** A namespace for a few function that help in the creation and updating of objects that are fully readonly.\n * Best not used directly, but inside objects that have all their fields set to readonly. */\nexport namespace ValueObject {\n\t/** Morphs any object into an object like the template, by deleting extra fields, setting missing fields\n\t * to defaults, and switching the prototype. Can be used on objects deserialized using JSON. */\n\texport function morphUsingTemplate<T extends {}>(values: Record<string, unknown>, template: T): T {\n\t\t// Delete any unknown fields\n\t\tfor (const field of Object.keys(values)) {\n\t\t\tif (!hasOwnProperty(template, field)) {\n\t\t\t\tdelete values[field]\n\t\t\t}\n\t\t}\n\n\t\t// Fill in any missing fields\n\t\tfor (const field of Object.keys(template)) {\n\t\t\tif (values[field] === undefined) {\n\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: @TODO add explanation\n\t\t\t\tvalues[field] = (template as any)[field]\n\t\t\t}\n\t\t}\n\n\t\tObject.setPrototypeOf(values, Object.getPrototypeOf(template))\n\t\tif (USE_FREEZE) {\n\t\t\tObject.freeze(values)\n\t\t}\n\t\treturn values as T\n\t}\n\n\t/** Intended to mutate the object once, can be used in the constructor of the object. */\n\texport function writeOnce<T>(object: Writeable<T>, values?: Record<string, unknown>): void {\n\t\tif (values) {\n\t\t\tObject.assign(object, values)\n\t\t}\n\t\tif (USE_FREEZE) {\n\t\t\tObject.freeze(object)\n\t\t}\n\t}\n\n\t/** Update the current object by making a copy and applying the values to that object. Should be used to create type-safe versions. */\n\texport function update<T>(object: Readonly<T>, values: Record<string, unknown>): T {\n\t\tconst result = Object.assign(Object.create(Object.getPrototypeOf(object)), object, values)\n\t\tif (USE_FREEZE) {\n\t\t\tObject.freeze(result)\n\t\t}\n\t\treturn result\n\t}\n}\n\nexport namespace ReadonlySet {\n\texport function add<T>(set: ReadonlySet<T>, ...items: T[]): ReadonlySet<T> {\n\t\treturn new Set<T>([...set, ...items])\n\t}\n\n\texport function remove<T>(set: ReadonlySet<T>, ...items: T[]): ReadonlySet<T> {\n\t\tconst result = new Set<T>(set)\n\t\tfor (const item of items) {\n\t\t\tresult.delete(item)\n\t\t}\n\n\t\treturn result\n\t}\n\n\texport function union<T>(...sets: ReadonlySet<T>[]): ReadonlySet<T> {\n\t\tconst result = new Set<T>()\n\t\tfor (const set of sets) {\n\t\t\tfor (const item of set) {\n\t\t\t\tresult.add(item)\n\t\t\t}\n\t\t}\n\n\t\treturn result\n\t}\n\n\texport function toggle<T>(set: ReadonlySet<T>, item: T): ReadonlySet<T> {\n\t\tif (set.has(item)) {\n\t\t\treturn ReadonlySet.remove(set, item)\n\t\t}\n\t\treturn ReadonlySet.add(set, item)\n\t}\n}\n\nexport namespace ReadonlyMap {\n\texport function merge<K, V>(\n\t\tmap: ReadonlyMap<K, V>,\n\t\t...otherMaps: (ReadonlyMap<K, V> | undefined | null)[]\n\t): ReadonlyMap<K, V> {\n\t\tconst result = new Map<K, V>()\n\t\tmap.forEach((value, key) => result.set(key, value))\n\n\t\tlet didMergeMaps = false\n\n\t\tfor (const otherMap of otherMaps) {\n\t\t\tif (!otherMap) continue\n\t\t\totherMap.forEach((value, key) => result.set(key, value))\n\t\t\tdidMergeMaps = true\n\t\t}\n\n\t\treturn didMergeMaps ? result : map\n\t}\n\n\texport function set<K, V>(map: ReadonlyMap<K, V>, key: K, value: V): ReadonlyMap<K, V> {\n\t\tconst result = new Map<K, V>(map)\n\t\tresult.set(key, value)\n\n\t\treturn result\n\t}\n\n\texport function remove<K, V>(map: ReadonlyMap<K, V>, key: K): ReadonlyMap<K, V> {\n\t\tconst result = new Map<K, V>(map)\n\t\tresult.delete(key)\n\n\t\treturn result\n\t}\n}\n\n/**\n * Recursive readonly.\n *\n * https://github.com/microsoft/TypeScript/issues/13923#issuecomment-2191862501\n */\nexport type DeepReadonly<T> = T extends Map<infer K, infer V> ? DeepReadonlyMap<K, V> : DeepReadonlyNotMap<T>\ntype DeepReadonlyMap<K, V> = ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>\ntype DeepReadonlyNotMap<T> = T extends Set<infer V> ? DeepReadonlySet<V> : DeepReadonlyNotMapOrSet<T>\ntype DeepReadonlySet<V> = ReadonlySet<DeepReadonly<V>>\ntype DeepReadonlyNotMapOrSet<T> = T extends object ? DeepReadonlyObject<T> : T\ntype DeepReadonlyObject<T> = { readonly [K in keyof T]: DeepReadonly<T[K]> }\n", "// Provides wrappers around scheduler.yield() and scheduler.isInputPending().\n\ndeclare global {\n\tinterface Window {\n\t\tscheduler?: {\n\t\t\tyield?: (options?: {\n\t\t\t\tpriority?: \"background\" | \"user-visible\" | \"user-blocking\"\n\t\t\t\tsignal?: AbortSignal\n\t\t\t}) => Promise<void>\n\t\t\tpostTask?: (\n\t\t\t\ttask: () => void,\n\t\t\t\toptions?: {\n\t\t\t\t\ttimeout?: number\n\t\t\t\t\tpriority?: \"background\" | \"user-visible\" | \"user-blocking\"\n\t\t\t\t\tsignal?: AbortSignal\n\t\t\t\t},\n\t\t\t) => Promise<void>\n\t\t\tisInputPending?: () => boolean\n\t\t}\n\t}\n}\n\nlet hasNativeYield = false\nlet hasNativePostTask = false\nlet hasIsInputPending = false\n\nif (typeof window !== \"undefined\" && window.scheduler) {\n\thasNativeYield = \"yield\" in window.scheduler\n\thasNativePostTask = \"postTask\" in window.scheduler\n\thasIsInputPending = \"isInputPending\" in window.scheduler\n}\n\n/** A wrapper around `scheduler.yield()` falling back to `setTimeout` if not available. */\nexport function schedulerYield(): Promise<void> {\n\tif (hasNativeYield) {\n\t\t// biome-ignore lint/style/noNonNullAssertion: checked by the condition\n\t\treturn window.scheduler!.yield!()\n\t} else if (hasNativePostTask) {\n\t\t// biome-ignore lint/style/noNonNullAssertion: checked by the condition\n\t\treturn window.scheduler!.postTask!(() => {})\n\t} else {\n\t\treturn new Promise(resolve => setTimeout(resolve))\n\t}\n}\n\n/** A wrapper around `scheduler.isInputPending()`. Always returns false if not available. */\nexport function schedulerIsInputPending(): boolean {\n\tif (!hasIsInputPending) return false\n\n\t// eslint-disable-next-line compat/compat\n\treturn window.scheduler!.isInputPending!()\n}\n", "import { assert } from \"./assert.ts\"\nimport { getLogger } from \"./logger.ts\"\n\nconst log = getLogger(\"task-queue\")\n\n/**\n * These queues use a single micro task and a single timer to batch small tasks into one large task.\n * Every queue has an associated delay, which is applied to all of its tasks. And every queue has a\n * priority associated with it, when the overall runner is configured at a higher priority, lower\n * priority queues won't run any tasks at all.\n */\n\nexport interface TaskQueueOptions {\n\tdelay?: number\n\tpriority?: number\n\tmaxBatchSize?: number\n\tuseAnimationFrame?: boolean\n}\n\ntype WrapTaskRunner = (body: () => void) => void\ntype Task = () => void\n\nclass ScheduledTask {\n\tisCancelled = false\n\n\tconstructor(\n\t\tpublic atTime: number,\n\t\treadonly task: Task,\n\t) {}\n\n\tcancel() {\n\t\tthis.isCancelled = true\n\t}\n}\n\nclass TaskQueue {\n\t// TODO: ideally, this delay would mean tasks would be scheduled after the delay - cpu busy time\n\treadonly delay: number = 0\n\treadonly priority: number = 0\n\treadonly maxBatchSize: number = 0\n\treadonly useAnimationFrame: boolean = false\n\n\tincoming: ScheduledTask[] = []\n\tscheduled: ScheduledTask[] = []\n\n\tconstructor(\n\t\tprivate runner: TaskQueueRunner,\n\t\treadonly name: string,\n\t\treadonly options?: TaskQueueOptions,\n\t) {\n\t\tthis.delay = options?.delay ?? 0\n\t\tthis.priority = options?.priority ?? 0\n\t\tthis.maxBatchSize = options?.maxBatchSize ?? 0\n\t\tthis.useAnimationFrame = options?.useAnimationFrame ?? false\n\t}\n\n\tadd(task: Task): ScheduledTask {\n\t\tconst scheduled = new ScheduledTask(-1, task)\n\t\tthis.incoming.push(scheduled)\n\t\tthis.runner.taskAdded()\n\t\treturn scheduled\n\t}\n\n\tscheduleNewTasks(now: number) {\n\t\tif (this.incoming.length === 0) return\n\n\t\tlog.debug(\"scheduling:\", this.name, this.incoming.length)\n\t\tconst atTime = now + this.delay\n\t\tfor (const scheduled of this.incoming) {\n\t\t\tscheduled.atTime = atTime\n\t\t\tthis.scheduled.push(scheduled)\n\t\t}\n\t\tthis.incoming.length = 0\n\t}\n\n\tmillisUntilNextTask(now: number): number {\n\t\tif (!this.scheduled[0]) return Infinity\n\t\tif (this.useAnimationFrame) return -1\n\t\treturn Math.max(0, this.scheduled[0].atTime - now)\n\t}\n\n\trun(now: number) {\n\t\tlet count = this.scheduled.length\n\t\tif (count === 0) return\n\n\t\tif (this.delay > 0) {\n\t\t\tconst lastScheduled = this.scheduled[count - 1]\n\t\t\tif (lastScheduled && lastScheduled.atTime > now) {\n\t\t\t\tcount = this.scheduled.findIndex(task => task.atTime > now)\n\t\t\t}\n\t\t}\n\n\t\tif (this.maxBatchSize > 0 && count > this.maxBatchSize) {\n\t\t\tcount = this.maxBatchSize\n\t\t}\n\n\t\tconst toRun = this.scheduled.splice(0, count)\n\t\tlog.debug(\"running:\", this.name, toRun.length)\n\t\tfor (let i = 0, il = toRun.length; i < il; i++) {\n\t\t\tconst scheduled = toRun[i]\n\t\t\tif (scheduled?.isCancelled) continue\n\t\t\tscheduled?.task()\n\t\t}\n\t}\n}\n\nexport class TaskQueueRunner {\n\tprivate wrapper: WrapTaskRunner = (body: () => void) => body()\n\tprivate queues: TaskQueue[] = []\n\tprivate currentPriority: number = 0\n\n\tsetTaskWrapper(wrapper: WrapTaskRunner): this {\n\t\tthis.wrapper = wrapper\n\t\treturn this\n\t}\n\n\tsetPriority(priority: number): this {\n\t\tif (priority === this.currentPriority) return this\n\n\t\tlog.debug(\"set priority:\", this.currentPriority, \"->\", priority)\n\t\tthis.currentPriority = priority\n\t\tthis.taskAdded()\n\t\treturn this\n\t}\n\n\tgetPriority(): number {\n\t\treturn this.currentPriority\n\t}\n\n\thasImmediateTasksToRun(): boolean {\n\t\treturn this.millisUntilNextTask(performance.now()) <= 0\n\t}\n\n\tgetTaskQueue(name: string, options?: TaskQueueOptions) {\n\t\tconst existing = this.queues.find(q => q.name === name)\n\t\tif (existing) {\n\t\t\tconst same =\n\t\t\t\texisting.options?.delay === options?.delay &&\n\t\t\t\texisting.options?.priority === options?.priority &&\n\t\t\t\texisting.options?.maxBatchSize === options?.maxBatchSize &&\n\t\t\t\texisting.options?.useAnimationFrame === options?.useAnimationFrame\n\t\t\tassert(same, \"queue\", name, \"with different options already exists\")\n\t\t\treturn existing\n\t\t}\n\n\t\tconst queue = new TaskQueue(this, name, options)\n\t\tthis.queues.push(queue)\n\t\tthis.queues.sort((a, b) => a.priority - b.priority)\n\t\treturn queue\n\t}\n\n\tmicroTask = false\n\ttaskAdded() {\n\t\tif (this.microTask) return\n\t\tthis.microTask = true\n\t\tqueueMicrotask(this.scheduleNewTasks)\n\t}\n\n\tprivate scheduleNewTasks = () => {\n\t\tthis.microTask = false\n\t\tconst now = performance.now()\n\t\tthis.queues.forEach(queue => {\n\t\t\tqueue.scheduleNewTasks(now)\n\t\t})\n\t\tthis.rescheduleRun()\n\t}\n\n\tprivate millisUntilNextTask(now: number): number {\n\t\tlet until = Infinity\n\t\tthis.queues.forEach(queue => {\n\t\t\tif (queue.priority < this.currentPriority) return\n\t\t\tuntil = Math.min(until, queue.millisUntilNextTask(now))\n\t\t})\n\t\treturn until\n\t}\n\n\tprivate atTime: number = Infinity\n\tprivate timer: ReturnType<typeof setTimeout> | undefined\n\n\tprivate rescheduleRun() {\n\t\tconst now = performance.now()\n\t\tconst delay = this.millisUntilNextTask(now)\n\t\tif (!Number.isFinite(delay)) return\n\n\t\tconst atTime = now + delay\n\t\tif (atTime > this.atTime) return\n\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer)\n\t\t}\n\t\tif (delay < 0) {\n\t\t\tthis.atTime = now\n\t\t\trequestAnimationFrame(this.run)\n\t\t} else {\n\t\t\tthis.atTime = now + delay\n\t\t\tthis.timer = setTimeout(this.run, delay)\n\t\t}\n\t}\n\n\t/** Actually run tasks */\n\tprivate run = () => {\n\t\tthis.atTime = Infinity\n\t\tthis.timer = undefined\n\n\t\tconst now = performance.now()\n\t\tthis.wrapper(() => {\n\t\t\tthis.queues.forEach(queue => {\n\t\t\t\tif (queue.priority < this.currentPriority) return\n\t\t\t\tqueue.run(now)\n\t\t\t})\n\t\t})\n\n\t\tthis.rescheduleRun()\n\t}\n}\n", "import { assert } from \"@framerjs/shared\"\nimport { EDITOR_BUTTON_POSITION_LOCALSTORAGE_KEY } from \"@framerjs/shared/src/constants.ts\"\nimport type { EditorBarWindow } from \"editorbar/types.ts\"\nimport { useEffect, useRef, useState } from \"react\"\n\ninterface NormalizedPosition {\n\tx: 0 | 1\n\ty: number // 0-1 range\n}\n\ninterface TransformInfo {\n\tx: number\n\ty: number\n\ttransitionTime: number\n}\n\nconst defaultPosition: NormalizedPosition = { x: 1, y: 0.5 }\nconst defaultTransformInfo: TransformInfo = { x: 0, y: 0, transitionTime: 100 }\nconst dragInterpolationDuration = 50 // ms\nconst dragStartThreshold = 2\nconst maxStickyEdgeThreshold = 60\nconst rubberBandingFactor = 0.2\nconst buttonSize = 30\nconst windowMargin = 10\n\ninterface UseDraggableEditButtonProps {\n\tonClick: () => void\n\tonDragStart: () => void\n}\n\ninterface UseDraggableEditButton {\n\tbuttonStyle: React.CSSProperties\n\ttooltipStyle: React.CSSProperties\n\tonMouseDown: (event: React.MouseEvent<HTMLButtonElement>) => void\n\tisDragging: boolean\n}\n\nexport function useDraggableEditButton(props: UseDraggableEditButtonProps): UseDraggableEditButton {\n\tconst useHook = getDraggableEditButtonHookOrMock()\n\treturn useHook(props)\n}\n\nfunction getDraggableEditButtonHookOrMock() {\n\tconst version = (window as unknown as EditorBarWindow).__framer_editorBarDependencies?.__version\n\tif (!version || version <= 2 || !supportsAbortSignalAny()) {\n\t\treturn getDraggableEditButtonMock\n\t}\n\treturn useDraggableEditButtonInternal\n}\n\nfunction useDraggableEditButtonInternal({ onClick, onDragStart }: UseDraggableEditButtonProps): UseDraggableEditButton {\n\tconst unmountController = useUnmountController()\n\tconst [normalizedPosition, setNormalizedPosition] = useState<NormalizedPosition>(getSavedPosition)\n\tconst [transformInfo, setTransformInfo] = useState<TransformInfo>(defaultTransformInfo)\n\tconst [isDragging, setIsDragging] = useState(false)\n\n\tconst buttonStyle = getButtonStyle(normalizedPosition, transformInfo)\n\tconst tooltipStyle = getTooltipStyle(normalizedPosition)\n\n\tfunction onMouseDown(dragStartEvent: React.MouseEvent<HTMLButtonElement>) {\n\t\tconst buttonElement = dragStartEvent.currentTarget\n\n\t\tconst dragController = new AbortController()\n\t\tconst unmountOrDragEndSignal = AbortSignal.any([unmountController.signal, dragController.signal])\n\n\t\tconst buttonStartRect = buttonElement.getBoundingClientRect()\n\t\tconst startMousePosition = {\n\t\t\tx: dragStartEvent.clientX,\n\t\t\ty: dragStartEvent.clientY,\n\t\t}\n\n\t\t// Clear any selected text because that can break the drag interaction.\n\t\twindow.getSelection()?.removeAllRanges()\n\n\t\tlet lastMouseMoveEvent: MouseEvent | null = null\n\t\tconst handleMouseMove = (mouseMoveEvent: MouseEvent) => {\n\t\t\tlastMouseMoveEvent = mouseMoveEvent\n\t\t}\n\n\t\tlet hasDragStarted = false\n\t\tlet previousDragRect = buttonStartRect\n\t\tlet previousAnimationTime = performance.now()\n\t\tlet backdrop: HTMLDivElement | \"unset\" | \"removed\" = \"unset\"\n\n\t\tconst animationTick = () => {\n\t\t\tif (unmountOrDragEndSignal.aborted) return\n\t\t\trequestAnimationFrame(animationTick)\n\n\t\t\tif (!lastMouseMoveEvent) return\n\n\t\t\tconst mouseDelta = {\n\t\t\t\tx: lastMouseMoveEvent.clientX - startMousePosition.x,\n\t\t\t\ty: lastMouseMoveEvent.clientY - startMousePosition.y,\n\t\t\t}\n\n\t\t\tif (!hasDragStarted) {\n\t\t\t\tconst hasMovedX = Math.abs(mouseDelta.x) > dragStartThreshold\n\t\t\t\tconst hasMovedY = Math.abs(mouseDelta.y) > dragStartThreshold\n\t\t\t\thasDragStarted = hasMovedX || hasMovedY\n\t\t\t\tif (!hasDragStarted) return\n\n\t\t\t\tsetIsDragging(true)\n\t\t\t\tonDragStart()\n\n\t\t\t\tif (backdrop !== \"unset\") throw Error(\"Backdrop should not be set until drag start\")\n\t\t\t\tbackdrop = createBackdrop()\n\t\t\t}\n\n\t\t\tconst rectWithoutConstraints = new DOMRect(\n\t\t\t\tbuttonStartRect.x + mouseDelta.x,\n\t\t\t\tbuttonStartRect.y + mouseDelta.y,\n\t\t\t\tbuttonStartRect.width,\n\t\t\t\tbuttonStartRect.height,\n\t\t\t)\n\n\t\t\tconst distanceToLeft = rectWithoutConstraints.left\n\t\t\tconst distanceToRight = window.innerWidth - rectWithoutConstraints.right\n\t\t\tconst side = distanceToLeft < distanceToRight ? \"left\" : \"right\"\n\n\t\t\tconst minY = windowMargin\n\t\t\tconst maxY = window.innerHeight - windowMargin - buttonSize\n\t\t\tconst minX = windowMargin\n\t\t\tconst maxX = window.innerWidth - windowMargin - buttonSize\n\n\t\t\t// The rect where the button will be settled after the drag ends (left or right edge).\n\t\t\tconst dragEndRect = new DOMRect(\n\t\t\t\tside === \"left\" ? minX : maxX,\n\t\t\t\tMath.min(maxY, Math.max(minY, rectWithoutConstraints.y)),\n\t\t\t\trectWithoutConstraints.width,\n\t\t\t\trectWithoutConstraints.height,\n\t\t\t)\n\n\t\t\tconst offset = {\n\t\t\t\tx: rectWithoutConstraints.x - dragEndRect.x,\n\t\t\t\ty: rectWithoutConstraints.y - dragEndRect.y,\n\t\t\t}\n\n\t\t\tconst yOffsetOutOfBounds = rectWithoutConstraints.y < minY || rectWithoutConstraints.y > maxY\n\t\t\tif (yOffsetOutOfBounds) {\n\t\t\t\toffset.y *= rubberBandingFactor\n\t\t\t}\n\n\t\t\tconst stickyEdgeThreshold = Math.min(window.innerWidth * 0.2, maxStickyEdgeThreshold)\n\t\t\tconst shouldStickToEdge = Math.abs(offset.x) < stickyEdgeThreshold\n\n\t\t\tconst xOffsetOutOfBounds = rectWithoutConstraints.x < minX || rectWithoutConstraints.x > maxX\n\t\t\tif (xOffsetOutOfBounds || shouldStickToEdge) {\n\t\t\t\toffset.x *= rubberBandingFactor\n\t\t\t}\n\n\t\t\t// The rect where the button will be settled while dragging if you don't move your mouse.\n\t\t\tconst settledDragRect = new DOMRect(\n\t\t\t\tdragEndRect.x + offset.x,\n\t\t\t\tdragEndRect.y + offset.y,\n\t\t\t\tdragEndRect.width,\n\t\t\t\tdragEndRect.height,\n\t\t\t)\n\n\t\t\tconst now = performance.now()\n\t\t\tconst interpolationAmount = Math.min((now - previousAnimationTime) / dragInterpolationDuration, 1)\n\t\t\tpreviousAnimationTime = now\n\n\t\t\t// Animate the button from the previous drag rect to the settled drag rect.\n\t\t\tconst dragRect = new DOMRect(\n\t\t\t\tlinearInterpolation(previousDragRect.x, settledDragRect.x, interpolationAmount),\n\t\t\t\tlinearInterpolation(previousDragRect.y, settledDragRect.y, interpolationAmount),\n\t\t\t\tlinearInterpolation(previousDragRect.width, settledDragRect.width, interpolationAmount),\n\t\t\t\tlinearInterpolation(previousDragRect.height, settledDragRect.height, interpolationAmount),\n\t\t\t)\n\t\t\tpreviousDragRect = dragRect\n\n\t\t\t// Save and use the normalized position for the button position.\n\t\t\tconst normalizedX = side === \"left\" ? 0 : 1\n\t\t\tconst normalizedY = (dragEndRect.y - minY) / (maxY - minY)\n\t\t\tconst newNormalizedPosition: NormalizedPosition = { x: normalizedX, y: normalizedY }\n\n\t\t\t// Update all state\n\t\t\tsetNormalizedPosition(newNormalizedPosition)\n\t\t\tsavePosition(newNormalizedPosition)\n\t\t\tsetTransformInfo({\n\t\t\t\tx: dragRect.x - dragEndRect.x,\n\t\t\t\ty: dragRect.y - dragEndRect.y,\n\t\t\t\ttransitionTime: 0,\n\t\t\t})\n\t\t}\n\n\t\tunmountOrDragEndSignal.addEventListener(\"abort\", () => {\n\t\t\tsetTransformInfo(defaultTransformInfo)\n\t\t\tsetIsDragging(false)\n\n\t\t\tif (backdrop instanceof HTMLDivElement) {\n\t\t\t\tbackdrop.remove()\n\t\t\t\tbackdrop = \"removed\"\n\t\t\t}\n\t\t})\n\n\t\tconst handleMouseUp = () => {\n\t\t\tdragController.abort()\n\n\t\t\tif (!hasDragStarted) {\n\t\t\t\tonClick()\n\t\t\t}\n\t\t}\n\n\t\tconst handleKeyDown = (keyDownEvent: KeyboardEvent) => {\n\t\t\tif (keyDownEvent.key === \"Escape\") {\n\t\t\t\tdragController.abort()\n\t\t\t}\n\t\t}\n\n\t\tanimationTick() // Start the animation loop.\n\n\t\twindow.addEventListener(\"mousemove\", handleMouseMove, { signal: unmountOrDragEndSignal })\n\t\twindow.addEventListener(\"mouseup\", handleMouseUp, { signal: unmountOrDragEndSignal })\n\t\twindow.addEventListener(\"keydown\", handleKeyDown, { signal: unmountOrDragEndSignal, capture: true })\n\t}\n\n\treturn {\n\t\tbuttonStyle,\n\t\ttooltipStyle,\n\t\tonMouseDown,\n\t\tisDragging,\n\t}\n}\n\nfunction getDraggableEditButtonMock(props: UseDraggableEditButtonProps): UseDraggableEditButton {\n\treturn {\n\t\tbuttonStyle: getButtonStyle(defaultPosition, defaultTransformInfo),\n\t\ttooltipStyle: getTooltipStyle(defaultPosition),\n\t\tonMouseDown: props.onClick,\n\t\tisDragging: false,\n\t}\n}\n\nfunction supportsAbortSignalAny() {\n\treturn typeof AbortSignal.any === \"function\"\n}\n\nfunction getButtonStyle(\n\tsavedPosition: NormalizedPosition,\n\t{ x, y, transitionTime }: TransformInfo,\n): React.CSSProperties {\n\tconst constrainedPositionY = Math.max(0, Math.min(1, savedPosition.y))\n\treturn {\n\t\tleft: savedPosition.x === 0 ? windowMargin : undefined,\n\t\tright: savedPosition.x !== 0 ? windowMargin : undefined,\n\t\t// Make sure the button is always visible within the viewport. Only the temporary drag transform can make it appear outside the viewport.\n\t\ttop: `calc(((100vh - ${buttonSize + windowMargin * 2}px) * ${constrainedPositionY}) + ${windowMargin}px)`,\n\t\ttransform: `translate(${x}px, ${y}px)`,\n\t\ttransition: transitionTime > 0 ? `transform ${transitionTime}ms cubic-bezier(0.2, 0, 0, 1)` : undefined,\n\t\tcursor: x || y ? \"grabbing\" : \"pointer\",\n\t}\n}\n\nfunction getTooltipStyle(savedPosition: NormalizedPosition): React.CSSProperties {\n\treturn {\n\t\tleft: savedPosition.x === 0 ? windowMargin + buttonSize : undefined,\n\t\tright: savedPosition.x !== 0 ? windowMargin + buttonSize : undefined,\n\t}\n}\n\nfunction createBackdrop(): HTMLDivElement {\n\tconst backdrop = document.createElement(\"div\")\n\tbackdrop.style.position = \"fixed\"\n\tbackdrop.style.top = \"0\"\n\tbackdrop.style.left = \"0\"\n\tbackdrop.style.width = \"100vw\"\n\tbackdrop.style.height = \"100vh\"\n\tbackdrop.style.backgroundColor = \"transparent\"\n\tbackdrop.style.zIndex = \"2147483647\" // Max z-index.\n\tbackdrop.style.cursor = \"grabbing\"\n\tdocument.body.appendChild(backdrop)\n\treturn backdrop\n}\n\nfunction useUnmountController(): AbortController {\n\tconst abortControllerRef = useRef<AbortController | null>(null)\n\tif (!abortControllerRef.current) {\n\t\tabortControllerRef.current = new AbortController()\n\t}\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tconst abortController = abortControllerRef.current\n\t\t\tassert(abortController, \"Abort controller should be set\")\n\t\t\tabortController.abort()\n\t\t}\n\t}, [])\n\n\treturn abortControllerRef.current\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === \"string\"\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn Number.isFinite(value)\n}\n\nfunction linearInterpolation(start: number, end: number, amount: number): number {\n\treturn start + (end - start) * amount\n}\n\nfunction getSavedPosition(): NormalizedPosition {\n\ttry {\n\t\tconst stored = localStorage.getItem(EDITOR_BUTTON_POSITION_LOCALSTORAGE_KEY)\n\t\tif (!isString(stored)) return defaultPosition\n\n\t\tconst parsed = JSON.parse(stored)\n\t\tif (!isObject(parsed) || !isNumber(parsed.x) || !isNumber(parsed.y)) return defaultPosition\n\t\tif (parsed.x !== 0 && parsed.x !== 1) return defaultPosition\n\t\tif (parsed.y < 0 || parsed.y > 1) return defaultPosition\n\n\t\treturn { x: parsed.x, y: parsed.y }\n\t} catch {\n\t\treturn defaultPosition\n\t}\n}\n\nfunction savePosition(position: NormalizedPosition) {\n\ttry {\n\t\tlocalStorage.setItem(EDITOR_BUTTON_POSITION_LOCALSTORAGE_KEY, JSON.stringify(position))\n\t} catch {\n\t\t// Ignore errors when localStorage is not available.\n\t}\n}\n", "import { useState } from \"react\"\nimport {\n\tEDITOR_BAR_BUTTON_ID,\n\tEDITOR_BAR_BUTTON_TOOLTIP_VISIBLE_CLASS,\n\tEDITOR_BAR_CONTAINER_ID,\n\tEDITOR_BAR_LABEL_ID,\n\tLOADING_SPINNER_ID,\n} from \"./entryPointStyles.ts\"\nimport { useDraggableEditButton } from \"./useDraggableEditButton.tsx\"\n\nexport interface EditButtonProps {\n\tisLoading: boolean\n\tisEditorVisible: boolean\n\tonClick(): void\n}\n\nexport function EditButton({ isLoading, isEditorVisible, onClick }: EditButtonProps) {\n\tconst [showTooltip, setShowTooltip] = useState(false)\n\tconst [previousEditorVisible, setPreviousEditorVisible] = useState(isEditorVisible)\n\tconst { buttonStyle, tooltipStyle, onMouseDown, isDragging } = useDraggableEditButton({\n\t\tonClick,\n\t\tonDragStart: () => setShowTooltip(false),\n\t})\n\n\tif (previousEditorVisible !== isEditorVisible) {\n\t\tsetPreviousEditorVisible(isEditorVisible)\n\n\t\tif (!isEditorVisible) {\n\t\t\tsetShowTooltip(false)\n\t\t}\n\t}\n\n\tif (isDragging && showTooltip) {\n\t\tsetShowTooltip(false)\n\t}\n\n\treturn (\n\t\t<div id={EDITOR_BAR_CONTAINER_ID} dir=\"ltr\" style={buttonStyle}>\n\t\t\t<span\n\t\t\t\taria-label=\"Edit Framer Content\"\n\t\t\t\tid={EDITOR_BAR_LABEL_ID}\n\t\t\t\tstyle={tooltipStyle}\n\t\t\t\tclassName={showTooltip ? EDITOR_BAR_BUTTON_TOOLTIP_VISIBLE_CLASS : undefined}\n\t\t\t>\n\t\t\t\tEdit Content\n\t\t\t</span>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\taria-labelledby={EDITOR_BAR_LABEL_ID}\n\t\t\t\tid={EDITOR_BAR_BUTTON_ID}\n\t\t\t\tonMouseDown={onMouseDown}\n\t\t\t\tonMouseEnter={() => {\n\t\t\t\t\tif (isDragging) return\n\t\t\t\t\tsetShowTooltip(true)\n\t\t\t\t}}\n\t\t\t\tonMouseLeave={() => setShowTooltip(false)}\n\t\t\t>\n\t\t\t\t{isLoading ? <LoadingSpinner /> : <PencilIcon />}\n\t\t\t</button>\n\t\t</div>\n\t)\n}\n\nfunction PencilIcon() {\n\treturn (\n\t\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" fill=\"none\">\n\t\t\t<path\n\t\t\t\td=\"M8.75 2.25a1.77 1.77 0 0 1 2.5 0h0c.69.69.69 1.81 0 2.5l-7 7h-2.5v-2.5Z\"\n\t\t\t\tfill=\"transparent\"\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t\t<path d=\"M8 11.75h3.75\" fill=\"transparent\" strokeWidth=\"1.5\" stroke=\"currentColor\" strokeLinecap=\"round\" />\n\t\t</svg>\n\t)\n}\n\nfunction LoadingSpinner() {\n\treturn <div id={LOADING_SPINNER_ID} />\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;AAyBA,IAAM,UAAU,OAAO,SAAS;;;ACzBhC,IAAM,mBAAmB,OAAO,OAAO,CAAC,CAAC;;;ACSzC,IAAI;AACJ,IAAI,yBAAyB;AAatB,SAAS,YAAY;AAAA,EAC3B,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAIU;AACT,QAAM,QAAQ,gBAAgB,YAAY,MAAM;AAEhD,MAAI,eAAe;AAClB,kBAAc;AAAA,MACb;AAAA,MACA,MAAM,EAAE,GAAG,MAAM,MAAM,GAAG,KAAK;AAAA,MAC/B,QAAQ,EAAE,GAAG,MAAM,Q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