@vinena/knobs 0.5.3 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +7 -6
  3. package/dist/context-amfyasb5.js +23 -0
  4. package/dist/context-svtr7vwt.js +22 -0
  5. package/dist/early.global.js +5 -5
  6. package/dist/edit/css.d.ts +59 -0
  7. package/dist/edit/html.d.ts +91 -0
  8. package/dist/edit/keep.d.ts +175 -0
  9. package/dist/edit/log.d.ts +107 -0
  10. package/dist/edit/replay.d.ts +28 -0
  11. package/dist/edit/risk.d.ts +33 -0
  12. package/dist/edit/rule.d.ts +31 -0
  13. package/dist/edit/source.d.ts +12 -0
  14. package/dist/edit/text.d.ts +66 -0
  15. package/dist/elementsview-dm5v3z5a.js +3761 -0
  16. package/dist/elementsview-xm82cvs2.js +3762 -0
  17. package/dist/engine/dock.d.ts +3 -4
  18. package/dist/engine/frame.d.ts +1 -1
  19. package/dist/engine/style.d.ts +15 -0
  20. package/dist/{framekit-cjz0e4y8.js → framekit-622h6w1f.js} +54 -47
  21. package/dist/{framekit-yk1jxjv7.js → framekit-yx612r28.js} +54 -47
  22. package/dist/index-0zp9py56.js +859 -0
  23. package/dist/{index-prjpx67p.js → index-1mstjadm.js} +126 -2167
  24. package/dist/{index-begsqdm0.js → index-4a4x1bt2.js} +1 -1
  25. package/dist/index-58jdczmj.js +44 -0
  26. package/dist/index-5tv6sr74.js +23 -0
  27. package/dist/index-6bc2ztfd.js +688 -0
  28. package/dist/index-7cb4x1vj.js +1885 -0
  29. package/dist/index-a974q3aa.js +34 -0
  30. package/dist/{index-q73py563.js → index-aymfvd8s.js} +1 -1
  31. package/dist/{index-zt3rheck.js → index-aynkv7qk.js} +11 -8
  32. package/dist/{index-p57fdttx.js → index-dzm8ywq0.js} +492 -2365
  33. package/dist/{index-9jhatmky.js → index-f60yax1j.js} +13 -8
  34. package/dist/index-f67wctn3.js +1858 -0
  35. package/dist/{index-vgfn2n1h.js → index-ftjdt358.js} +8 -171
  36. package/dist/{index-j1h13ahg.js → index-gm51cthv.js} +2 -45
  37. package/dist/index-kfdzsyyw.js +1859 -0
  38. package/dist/index-t4kssacm.js +208 -0
  39. package/dist/index-v0ht9q0g.js +1518 -0
  40. package/dist/{index-6wbgqkdz.js → index-x59vz1xx.js} +247 -905
  41. package/dist/index-xh39jtkq.js +32 -0
  42. package/dist/index-yb7fc59g.js +718 -0
  43. package/dist/index-zd6adby9.js +496 -0
  44. package/dist/index.d.ts +62 -0
  45. package/dist/index.global.js +438 -153
  46. package/dist/index.js +594 -486
  47. package/dist/react-0wepdf60.js +1519 -0
  48. package/dist/{react-gefkdkdz.js → react-1gqwa2yw.js} +1 -1
  49. package/dist/{index-sn2y6j09.js → react-3mfz1x2a.js} +126 -2167
  50. package/dist/react-4rbjw9af.js +33 -0
  51. package/dist/react-5rq7bnsy.js +210 -0
  52. package/dist/react-6bz05qk1.js +860 -0
  53. package/dist/{react-qgz9afa2.js → react-6fnxxs30.js} +8 -171
  54. package/dist/react-6q2cw2ya.js +689 -0
  55. package/dist/{react-7vjfsh40.js → react-6t4dbdzn.js} +11 -8
  56. package/dist/react-88es9b5q.js +719 -0
  57. package/dist/react-97b5b8j4.js +46 -0
  58. package/dist/{react-mmq2zya3.js → react-bxzn8vq5.js} +1 -1
  59. package/dist/{react-3rhdj2k1.js → react-cs62p9qh.js} +62 -720
  60. package/dist/react-ethftdxp.js +497 -0
  61. package/dist/react-fp73vhyd.js +36 -0
  62. package/dist/{react-qfpg79hs.js → react-me102s1a.js} +2 -45
  63. package/dist/react-t2qnewz2.js +24 -0
  64. package/dist/react-ttj8f9qp.js +1886 -0
  65. package/dist/{react-806qmkyz.js → react-v8497a41.js} +13 -8
  66. package/dist/{react-6tss0r9f.js → react-wqn4sx0n.js} +265 -2137
  67. package/dist/react.js +590 -486
  68. package/dist/replay-j18rw92k.js +258 -0
  69. package/dist/replay-vtg0vqj2.js +257 -0
  70. package/dist/{storageview-7cv0vpdm.js → storageview-6xj7zb63.js} +11 -7
  71. package/dist/{storageview-dyhpgt8f.js → storageview-pzn8yaad.js} +11 -7
  72. package/dist/styles/force.d.ts +66 -0
  73. package/dist/ui/bindings.d.ts +31 -5
  74. package/dist/ui/changes.d.ts +49 -0
  75. package/dist/ui/cssauto.d.ts +119 -0
  76. package/dist/ui/cssedit.d.ts +80 -0
  77. package/dist/ui/domedit.d.ts +99 -0
  78. package/dist/ui/domtree.d.ts +26 -1
  79. package/dist/ui/elementsview.d.ts +17 -2
  80. package/dist/ui/htmledit.d.ts +62 -0
  81. package/dist/ui/inspector.d.ts +6 -1
  82. package/dist/ui/keys.d.ts +12 -8
  83. package/dist/ui/pane.d.ts +0 -2
  84. package/dist/ui/panel.d.ts +3 -0
  85. package/dist/ui/prefs.d.ts +30 -10
  86. package/dist/ui/settings.d.ts +22 -1
  87. package/dist/ui/size.d.ts +14 -22
  88. package/dist/ui/stylesview.d.ts +30 -1
  89. package/package.json +1 -1
  90. package/skills/devknobs/SKILL.md +95 -0
  91. package/dist/elementsview-1wsxcdtj.js +0 -2874
  92. package/dist/elementsview-3kv34jfx.js +0 -2873
  93. package/dist/index-78r0f8pw.js +0 -27
  94. package/dist/react-adky72h9.js +0 -29
@@ -0,0 +1,1885 @@
1
+ import {
2
+ deviceOf,
3
+ ensureStyle,
4
+ formId,
5
+ formOf,
6
+ inkOn,
7
+ isCustomColor,
8
+ isDevknobsFrame,
9
+ knobFrame,
10
+ newer,
11
+ parseHex,
12
+ realNow,
13
+ removeStyle,
14
+ screenOf,
15
+ stamped,
16
+ turn,
17
+ webStorage
18
+ } from "./index-dzm8ywq0.js";
19
+
20
+ // src/engine/ua.ts
21
+ var CHROME = "154.0.8037.98";
22
+ var EDGE = "154.0.4258.53";
23
+ var SAFARI = "27.0";
24
+ var FIREFOX = "157.0";
25
+ var GREASE = { brand: "Not/A)Brand", version: "24.0.0.0" };
26
+ var APPLE = "Apple Computer, Inc.";
27
+ var GOOGLE = "Google Inc.";
28
+ function major(version) {
29
+ return version.split(".")[0] ?? version;
30
+ }
31
+ function chromeAgent(system, mobile = false) {
32
+ const browser = `Chrome/${major(CHROME)}.0.0.0 ${mobile ? "Mobile " : ""}Safari/537.36`;
33
+ return `Mozilla/5.0 (${system}) AppleWebKit/537.36 (KHTML, like Gecko) ${browser}`;
34
+ }
35
+ function chromium(own, hints) {
36
+ const full = [{ brand: "Chromium", version: CHROME }, GREASE, ...own ? [own] : []];
37
+ return {
38
+ brands: full.map(({ brand, version }) => ({ brand, version: major(version) })),
39
+ hints: { ...hints, fullVersionList: full, uaFullVersion: own?.version ?? CHROME }
40
+ };
41
+ }
42
+ var CHROME_BRAND = { brand: "Google Chrome", version: CHROME };
43
+ var DESKTOP = { model: "", bitness: "64" };
44
+ var WINDOWS = { ...DESKTOP, platformVersion: "19.0.0", architecture: "x86" };
45
+ var MAC_SAFARI = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/${SAFARI} Safari/605.1.15`;
46
+ var UA_PRESETS = [
47
+ {
48
+ id: "iphone-safari",
49
+ label: "iPhone Safari",
50
+ userAgent: `Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/${SAFARI} Mobile/15E148 Safari/604.1`,
51
+ platform: "iPhone",
52
+ vendor: APPLE,
53
+ mobile: true,
54
+ brands: [],
55
+ uaPlatform: "iOS",
56
+ maxTouchPoints: 5
57
+ },
58
+ {
59
+ id: "android-chrome",
60
+ label: "Android Chrome",
61
+ userAgent: chromeAgent("Linux; Android 10; K", true),
62
+ platform: "Linux armv81",
63
+ vendor: GOOGLE,
64
+ mobile: true,
65
+ uaPlatform: "Android",
66
+ maxTouchPoints: 5,
67
+ ...chromium(CHROME_BRAND, {
68
+ platformVersion: "16.0.0",
69
+ model: "Pixel 10",
70
+ architecture: "",
71
+ bitness: ""
72
+ })
73
+ },
74
+ {
75
+ id: "ipad-safari",
76
+ label: "iPad Safari",
77
+ userAgent: MAC_SAFARI,
78
+ platform: "MacIntel",
79
+ vendor: APPLE,
80
+ mobile: false,
81
+ brands: [],
82
+ uaPlatform: "iOS",
83
+ maxTouchPoints: 5
84
+ },
85
+ {
86
+ id: "mac-safari",
87
+ label: "Mac Safari",
88
+ userAgent: MAC_SAFARI,
89
+ platform: "MacIntel",
90
+ vendor: APPLE,
91
+ mobile: false,
92
+ brands: [],
93
+ uaPlatform: "macOS",
94
+ maxTouchPoints: 0
95
+ },
96
+ {
97
+ id: "mac-chrome",
98
+ label: "Mac Chrome",
99
+ userAgent: chromeAgent("Macintosh; Intel Mac OS X 10_15_7"),
100
+ platform: "MacIntel",
101
+ vendor: GOOGLE,
102
+ mobile: false,
103
+ uaPlatform: "macOS",
104
+ maxTouchPoints: 0,
105
+ ...chromium(CHROME_BRAND, { ...DESKTOP, platformVersion: "26.7.1", architecture: "arm" })
106
+ },
107
+ {
108
+ id: "windows-chrome",
109
+ label: "Windows Chrome",
110
+ userAgent: chromeAgent("Windows NT 10.0; Win64; x64"),
111
+ platform: "Win32",
112
+ vendor: GOOGLE,
113
+ mobile: false,
114
+ uaPlatform: "Windows",
115
+ maxTouchPoints: 0,
116
+ ...chromium(CHROME_BRAND, WINDOWS)
117
+ },
118
+ {
119
+ id: "windows-edge",
120
+ label: "Windows Edge",
121
+ userAgent: `${chromeAgent("Windows NT 10.0; Win64; x64")} Edg/${EDGE}`,
122
+ platform: "Win32",
123
+ vendor: GOOGLE,
124
+ mobile: false,
125
+ uaPlatform: "Windows",
126
+ maxTouchPoints: 0,
127
+ ...chromium({ brand: "Microsoft Edge", version: EDGE }, WINDOWS)
128
+ },
129
+ {
130
+ id: "linux-firefox",
131
+ label: "Linux Firefox",
132
+ userAgent: `Mozilla/5.0 (X11; Linux x86_64; rv:${FIREFOX}) Gecko/20100101 Firefox/${FIREFOX}`,
133
+ platform: "Linux x86_64",
134
+ vendor: "",
135
+ mobile: false,
136
+ brands: [],
137
+ uaPlatform: "Linux",
138
+ maxTouchPoints: 0,
139
+ appVersion: "5.0 (X11)"
140
+ },
141
+ {
142
+ id: "googlebot",
143
+ label: "Googlebot",
144
+ userAgent: `Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${CHROME} Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)`,
145
+ platform: "Linux armv81",
146
+ vendor: GOOGLE,
147
+ mobile: true,
148
+ uaPlatform: "Android",
149
+ maxTouchPoints: 1,
150
+ ...chromium(null, {
151
+ platformVersion: "6.0.1",
152
+ model: "Nexus 5X",
153
+ architecture: "",
154
+ bitness: ""
155
+ })
156
+ }
157
+ ];
158
+ function uaPreset(id) {
159
+ return UA_PRESETS.find((preset) => preset.id === id);
160
+ }
161
+ function userAgentOf(value) {
162
+ if (value.preset === "custom")
163
+ return value.custom.trim();
164
+ return uaPreset(value.preset)?.userAgent ?? "";
165
+ }
166
+ function appVersionOf(userAgent) {
167
+ return userAgent.replace(/^Mozilla\//, "");
168
+ }
169
+ var KEYS = [
170
+ "userAgent",
171
+ "appVersion",
172
+ "platform",
173
+ "vendor",
174
+ "maxTouchPoints",
175
+ "userAgentData"
176
+ ];
177
+ var SHARED = Symbol.for("devknobs.ua");
178
+ function isShared(value) {
179
+ return typeof value === "object" && value !== null && "originals" in value;
180
+ }
181
+ function sharedOf(scope) {
182
+ const had = Reflect.get(scope, SHARED);
183
+ if (isShared(had))
184
+ return had;
185
+ const shared = { originals: null };
186
+ Reflect.set(scope, SHARED, shared);
187
+ return shared;
188
+ }
189
+ function prototypeOf(scope) {
190
+ const navigator2 = Reflect.get(scope, "Navigator");
191
+ return typeof navigator2 === "function" ? navigator2.prototype : null;
192
+ }
193
+ function put(target, key, value) {
194
+ Object.defineProperty(target, key, { configurable: true, enumerable: true, get: () => value });
195
+ }
196
+ function restore(shared, target, key) {
197
+ const descriptor = shared.originals?.get(key);
198
+ if (descriptor)
199
+ Object.defineProperty(target, key, descriptor);
200
+ else
201
+ Reflect.deleteProperty(target, key);
202
+ }
203
+ function copy(brands) {
204
+ return brands.map(({ brand, version }) => ({ brand, version }));
205
+ }
206
+ var NO_HINTS = { brands: [], mobile: false, uaPlatform: "" };
207
+ function uaData(source, scope) {
208
+ const brands = Object.freeze(source.brands.map((brand) => Object.freeze({ ...brand })));
209
+ const low = () => ({ brands: copy(brands), mobile: source.mobile, platform: source.uaPlatform });
210
+ const hints = source.hints;
211
+ const high = () => ({
212
+ architecture: hints?.architecture ?? "",
213
+ bitness: hints?.bitness ?? "",
214
+ fullVersionList: copy(hints?.fullVersionList ?? []),
215
+ model: hints?.model ?? "",
216
+ platformVersion: hints?.platformVersion ?? "",
217
+ uaFullVersion: hints?.uaFullVersion ?? ""
218
+ });
219
+ const native = Reflect.get(scope, "NavigatorUAData");
220
+ const proto = typeof native === "function" ? native.prototype : Object.prototype;
221
+ return Object.create(proto, {
222
+ brands: { enumerable: true, get: () => brands },
223
+ mobile: { enumerable: true, get: () => source.mobile },
224
+ platform: { enumerable: true, get: () => source.uaPlatform },
225
+ getHighEntropyValues: {
226
+ value: (asked) => {
227
+ try {
228
+ const values = low();
229
+ const all = high();
230
+ for (const hint of Array.from(asked, String)) {
231
+ if (Object.hasOwn(all, hint))
232
+ values[hint] = all[hint];
233
+ }
234
+ return Promise.resolve(values);
235
+ } catch (error) {
236
+ return Promise.reject(error);
237
+ }
238
+ }
239
+ },
240
+ toJSON: { value: low }
241
+ });
242
+ }
243
+ function apply(value, scope = globalThis) {
244
+ const target = prototypeOf(scope);
245
+ const preset = value.preset === "custom" ? undefined : uaPreset(value.preset);
246
+ const userAgent = userAgentOf(value);
247
+ if (!target || userAgent === "") {
248
+ reset(scope);
249
+ return;
250
+ }
251
+ const shared = sharedOf(scope);
252
+ shared.originals ??= new Map(KEYS.map((key) => [key, Object.getOwnPropertyDescriptor(target, key)]));
253
+ put(target, "userAgent", userAgent);
254
+ put(target, "appVersion", preset?.appVersion ?? appVersionOf(userAgent));
255
+ if (!preset) {
256
+ for (const key of ["platform", "vendor", "maxTouchPoints"]) {
257
+ restore(shared, target, key);
258
+ }
259
+ if (shared.originals.get("userAgentData")) {
260
+ put(target, "userAgentData", uaData(NO_HINTS, scope));
261
+ } else
262
+ restore(shared, target, "userAgentData");
263
+ return;
264
+ }
265
+ put(target, "platform", preset.platform);
266
+ put(target, "vendor", preset.vendor);
267
+ put(target, "maxTouchPoints", preset.maxTouchPoints);
268
+ if (preset.brands.length > 0)
269
+ put(target, "userAgentData", uaData(preset, scope));
270
+ else
271
+ Reflect.deleteProperty(target, "userAgentData");
272
+ }
273
+ function realPlatform() {
274
+ const getter = sharedOf(globalThis).originals?.get("platform")?.get;
275
+ try {
276
+ return String(getter ? getter.call(navigator) : navigator.platform);
277
+ } catch {
278
+ return "";
279
+ }
280
+ }
281
+ function isMac() {
282
+ return /mac|iphone|ipad|ipod/i.test(realPlatform());
283
+ }
284
+ function reset(scope = globalThis) {
285
+ const shared = sharedOf(scope);
286
+ const target = prototypeOf(scope);
287
+ if (!shared.originals)
288
+ return;
289
+ if (target)
290
+ for (const key of KEYS)
291
+ restore(shared, target, key);
292
+ shared.originals = null;
293
+ }
294
+
295
+ // src/engine/scrollkeep.ts
296
+ var SCROLL_KEY = "devknobs:scroll";
297
+ var SCROLL_VERSION = 1;
298
+ var SCROLL_WINDOW = 1e4;
299
+ var HOLD = 2000;
300
+ var HOLD_CAP = 1e4;
301
+ var PUT_BUDGET = 20;
302
+ var INPUTS = ["wheel", "touchstart", "keydown", "mousedown"];
303
+ function placeOf(value) {
304
+ if (typeof value !== "object" || value === null)
305
+ return;
306
+ const path = Reflect.get(value, "path");
307
+ const x = Reflect.get(value, "x");
308
+ const y = Reflect.get(value, "y");
309
+ if (typeof path !== "string" || typeof x !== "number" || typeof y !== "number")
310
+ return;
311
+ return Number.isFinite(x) && Number.isFinite(y) ? { path, x, y } : undefined;
312
+ }
313
+ function parseKept(text) {
314
+ if (!text)
315
+ return null;
316
+ let raw;
317
+ try {
318
+ raw = JSON.parse(text);
319
+ } catch {
320
+ return null;
321
+ }
322
+ if (typeof raw !== "object" || raw === null || newer(raw, SCROLL_VERSION))
323
+ return null;
324
+ const at = Reflect.get(raw, "at");
325
+ if (typeof at !== "number")
326
+ return null;
327
+ const kept = { at };
328
+ const page = placeOf(Reflect.get(raw, "page"));
329
+ const frame = placeOf(Reflect.get(raw, "frame"));
330
+ if (page)
331
+ kept.page = page;
332
+ if (frame)
333
+ kept.frame = frame;
334
+ return kept;
335
+ }
336
+ function stale(at, now) {
337
+ const age = now - at;
338
+ return !(age >= 0 && age < SCROLL_WINDOW);
339
+ }
340
+ function keptWith(kept, role, place, now) {
341
+ const next = { at: now };
342
+ const other = role === "page" ? "frame" : "page";
343
+ const rest = kept && !stale(kept.at, now) ? kept[other] : undefined;
344
+ if (rest)
345
+ next[other] = rest;
346
+ if (place && (place.x !== 0 || place.y !== 0))
347
+ next[role] = place;
348
+ return next.page || next.frame ? next : null;
349
+ }
350
+ function take(kept, role, path, now) {
351
+ if (!kept || stale(kept.at, now))
352
+ return { place: null, rest: null };
353
+ const own = kept[role];
354
+ const other = role === "page" ? "frame" : "page";
355
+ const left = kept[other];
356
+ const rest = left ? { at: kept.at, [other]: left } : null;
357
+ if (!own || own.path !== path)
358
+ return { place: null, rest };
359
+ return { place: { x: own.x, y: own.y }, rest };
360
+ }
361
+ function next(holding, seen) {
362
+ const { target } = holding;
363
+ const there = Math.abs(seen.x - target.x) <= 1 && Math.abs(seen.y - target.y) <= 1;
364
+ const spent = holding.puts >= PUT_BUDGET;
365
+ const over = seen.now - holding.start >= HOLD_CAP || holding.loadedAt !== null && seen.now - holding.loadedAt >= HOLD;
366
+ if (over)
367
+ return there || spent ? "done" : "last";
368
+ if (spent)
369
+ return "done";
370
+ if (there)
371
+ return "wait";
372
+ return seen.maxX >= target.x - 1 && seen.maxY >= target.y - 1 ? "put" : "wait";
373
+ }
374
+ function hold(view, target, now = realNow) {
375
+ const holding = { target, start: now(), loadedAt: null, puts: 0 };
376
+ let over = false;
377
+ const end = () => {
378
+ over = true;
379
+ for (const type of INPUTS)
380
+ view.removeEventListener(type, end, true);
381
+ };
382
+ const frame = () => {
383
+ if (over)
384
+ return;
385
+ const time = now();
386
+ if (holding.loadedAt === null && view.document.readyState === "complete")
387
+ holding.loadedAt = time;
388
+ const root = view.document.documentElement;
389
+ const move = next(holding, {
390
+ x: view.scrollX,
391
+ y: view.scrollY,
392
+ maxX: root ? root.scrollWidth - root.clientWidth : 0,
393
+ maxY: root ? root.scrollHeight - root.clientHeight : 0,
394
+ now: time
395
+ });
396
+ if (move === "put" || move === "last") {
397
+ holding.puts++;
398
+ view.scrollTo({ left: target.x, top: target.y, behavior: "instant" });
399
+ }
400
+ if (move === "last" || move === "done")
401
+ end();
402
+ else
403
+ view.requestAnimationFrame(frame);
404
+ };
405
+ for (const type of INPUTS)
406
+ view.addEventListener(type, end, true);
407
+ frame();
408
+ }
409
+ var framed = null;
410
+ function follow(view) {
411
+ framed = view;
412
+ }
413
+ function placeIn(view) {
414
+ try {
415
+ return view ? { path: view.location.pathname, x: view.scrollX, y: view.scrollY } : null;
416
+ } catch {
417
+ return null;
418
+ }
419
+ }
420
+ function keep(view, role) {
421
+ try {
422
+ const session = webStorage("session");
423
+ if (!session)
424
+ return;
425
+ const kept = keptWith(parseKept(session.getItem(SCROLL_KEY)), role, placeIn(view), realNow());
426
+ if (kept)
427
+ session.setItem(SCROLL_KEY, JSON.stringify(stamped(kept, SCROLL_VERSION)));
428
+ else
429
+ session.removeItem(SCROLL_KEY);
430
+ } catch {}
431
+ }
432
+ function keepOwn() {
433
+ if (isDevknobsFrame()) {
434
+ keep(window, "frame");
435
+ return;
436
+ }
437
+ keep(window, "page");
438
+ keep(framed?.() ?? null, "frame");
439
+ }
440
+ function resume() {
441
+ if (typeof window === "undefined")
442
+ return;
443
+ let target = null;
444
+ try {
445
+ const session = webStorage("session");
446
+ const text = session?.getItem(SCROLL_KEY) ?? null;
447
+ if (!session || text === null)
448
+ return;
449
+ const role = isDevknobsFrame() ? "frame" : "page";
450
+ const { place, rest } = take(parseKept(text), role, window.location.pathname, realNow());
451
+ if (rest)
452
+ session.setItem(SCROLL_KEY, JSON.stringify(stamped(rest, SCROLL_VERSION)));
453
+ else
454
+ session.removeItem(SCROLL_KEY);
455
+ target = place;
456
+ } catch {
457
+ return;
458
+ }
459
+ if (target)
460
+ hold(window, target);
461
+ }
462
+
463
+ // src/engine/mockdata.ts
464
+ function sides(top, right, bottom, left) {
465
+ return { top, right, bottom, left };
466
+ }
467
+ function pill(kind, x, y, width, height) {
468
+ return { kind, x, y, width, height };
469
+ }
470
+ function dot(kind, x, y, size) {
471
+ return { kind, x: x - size / 2, y: y - size / 2, width: size, height: size };
472
+ }
473
+ var left = (at, length) => ({ side: "left", at, length });
474
+ var right = (at, length, out) => ({
475
+ side: "right",
476
+ at,
477
+ length,
478
+ out
479
+ });
480
+ var top = (at, length, out) => ({
481
+ side: "top",
482
+ at,
483
+ length,
484
+ out
485
+ });
486
+ var IPHONE_LEFT = [left(185, 41.7), left(257.4, 67.6), left(343.2, 67.6)];
487
+ function iphoneRight(control) {
488
+ return [right(280.7, 106.9), right(control, 103.3, 1)];
489
+ }
490
+ var BODIES = {
491
+ "iphone-18-pro": {
492
+ bezel: sides(15.7, 15.7, 15.7, 15.7),
493
+ screenRadius: 62,
494
+ bodyRadius: 77.7,
495
+ out: 3,
496
+ front: [pill("sensor", 154, 14.3, 94, 36.1)],
497
+ buttons: [left(186, 41.7), left(258.3, 67.7), left(344, 68), right(281.7, 107, 2.7)]
498
+ },
499
+ "iphone-18-pro-max": {
500
+ bezel: sides(15.3, 15.3, 15.3, 15.3),
501
+ screenRadius: 62,
502
+ bodyRadius: 77.3,
503
+ out: 2.7,
504
+ front: [pill("sensor", 173.2, 14.5, 93.6, 35.8)],
505
+ buttons: [left(186.3, 41.7), left(258.7, 67.7), left(344.3, 67.7), right(282, 106.7)]
506
+ },
507
+ "iphone-duo-closed": {
508
+ bezel: sides(16.3, 16, 16, 25.7),
509
+ screenRadius: [8, 59, 59, 8],
510
+ bodyRadius: [10, 75, 75, 10],
511
+ out: 2.7,
512
+ front: [dot("sensor", 418.35, 47.75, 36.3)],
513
+ buttons: [right(202.7, 112.7), top(235, 65.7, 2.3), top(316, 65.7, 2.3)]
514
+ },
515
+ "iphone-duo-open": {
516
+ bezel: sides(20.3, 20.7, 20.7, 20.7),
517
+ screenRadius: 55,
518
+ bodyRadius: 75.7,
519
+ out: 2.7,
520
+ front: [],
521
+ buttons: [left(134.3, 57), left(206.3, 65.7), top(202.3, 112.7)]
522
+ },
523
+ "iphone-air": {
524
+ bezel: sides(15.3, 15.3, 15.3, 15.3),
525
+ screenRadius: 62,
526
+ bodyRadius: 77.3,
527
+ out: 2.7,
528
+ front: [pill("sensor", 147.33, 20, 125.33, 36.67)],
529
+ buttons: [left(185, 41.7), left(257.3, 67.7), left(343, 67.7), right(280.7, 106.7, 3)]
530
+ },
531
+ "iphone-17": {
532
+ bezel: sides(14.7, 14.7, 14.7, 14.7),
533
+ screenRadius: 62,
534
+ bodyRadius: 76.7,
535
+ out: 3,
536
+ front: [pill("sensor", 138.33, 14, 125.33, 36.67)],
537
+ buttons: [left(185, 41.7), left(257.3, 67.7), left(342.7, 68), right(280.3, 107, 2.7)]
538
+ },
539
+ "iphone-17-pro": {
540
+ bezel: sides(15.7, 15.7, 15.7, 15.7),
541
+ screenRadius: 62,
542
+ bodyRadius: 77.7,
543
+ out: 3,
544
+ front: [pill("sensor", 138.33, 14, 125.33, 36.67)],
545
+ buttons: [left(186, 41.7), left(258.3, 67.7), left(344, 67.7), right(281.7, 107, 2.7)]
546
+ },
547
+ "iphone-17-pro-max": {
548
+ bezel: sides(15.3, 15.3, 15.3, 15.3),
549
+ screenRadius: 62,
550
+ bodyRadius: 77.3,
551
+ out: 2.7,
552
+ front: [pill("sensor", 157.33, 14, 125.33, 36.67)],
553
+ buttons: [left(186.3, 41.7), left(258.7, 67.7), left(344.3, 67.7), right(282, 106.7)]
554
+ },
555
+ "iphone-16": {
556
+ bezel: sides(19.7, 19.7, 19.7, 19.7),
557
+ screenRadius: 55.8,
558
+ bodyRadius: 75.5,
559
+ out: 2.7,
560
+ front: [pill("sensor", 134, 11.3, 124.9, 36.7)],
561
+ buttons: [...IPHONE_LEFT, ...iphoneRight(529.5)]
562
+ },
563
+ "iphone-16-plus": {
564
+ bezel: sides(19.7, 19.7, 19.7, 19.7),
565
+ screenRadius: 55.8,
566
+ bodyRadius: 75.5,
567
+ out: 2.7,
568
+ front: [pill("sensor", 152.3, 11.3, 125.4, 36.7)],
569
+ buttons: [...IPHONE_LEFT, ...iphoneRight(608.5)]
570
+ },
571
+ "iphone-16-pro": {
572
+ bezel: sides(14.7, 14.7, 14.7, 14.7),
573
+ screenRadius: 63.2,
574
+ bodyRadius: 77.9,
575
+ out: 2.7,
576
+ front: [pill("sensor", 138.33, 14, 125.33, 36.67)],
577
+ buttons: [...IPHONE_LEFT, ...iphoneRight(541.3)]
578
+ },
579
+ "iphone-16-pro-max": {
580
+ bezel: sides(14.3, 14.3, 14.3, 14.3),
581
+ screenRadius: 63.6,
582
+ bodyRadius: 77.9,
583
+ out: 2.7,
584
+ front: [pill("sensor", 157.3, 14, 125.4, 36.7)],
585
+ buttons: [...IPHONE_LEFT, ...iphoneRight(622.4)]
586
+ },
587
+ "iphone-se": {
588
+ bezel: sides(110.2, 28.1, 110.3, 28.1),
589
+ screenRadius: 0,
590
+ bodyRadius: 65.6,
591
+ out: 2.6,
592
+ front: [
593
+ pill("slot", 149.5, -55.4, 76.1, 7.7),
594
+ dot("lens", 119.3, -51.5, 14),
595
+ { ...dot("home", 187.5, 718, 69.9), key: 60 }
596
+ ],
597
+ buttons: [left(94.6, 36), left(187.5, 68.1), left(268.3, 68.1), right(188, 68.1)]
598
+ },
599
+ "pixel-10": {
600
+ bezel: sides(21, 22.1, 21.4, 22.5),
601
+ screenRadius: 55,
602
+ bodyRadius: 77,
603
+ out: 3.1,
604
+ front: [dot("sensor", 205.6, 33.9, 29.7)],
605
+ buttons: [right(269.6, 77), right(389.3, 134.2)]
606
+ },
607
+ "pixel-10-pro": {
608
+ bezel: sides(20, 20.7, 17.3, 19.7),
609
+ screenRadius: 59,
610
+ bodyRadius: 79,
611
+ out: 3,
612
+ front: [dot("sensor", 213.6, 34.3, 30.6)],
613
+ buttons: [right(276.4, 78.4), right(399.1, 137)]
614
+ },
615
+ "pixel-10-pro-xl": {
616
+ bezel: sides(18.3, 20.3, 18, 20),
617
+ screenRadius: 52,
618
+ bodyRadius: 71,
619
+ out: 2.3,
620
+ front: [dot("sensor", 224, 34.8, 30.2)],
621
+ buttons: [right(280.5, 77), right(401.2, 134.4)]
622
+ },
623
+ "pixel-10a": {
624
+ bezel: sides(24, 24.8, 24, 24.8),
625
+ screenRadius: 55,
626
+ bodyRadius: 79,
627
+ out: 3.1,
628
+ front: [dot("sensor", 205.2, 33.3, 30.5)],
629
+ buttons: [right(273, 75.9), right(393.1, 132.7)]
630
+ },
631
+ "pixel-9": {
632
+ bezel: sides(21.9, 22.2, 21.9, 22.2),
633
+ screenRadius: 55,
634
+ bodyRadius: 77,
635
+ out: 2.5,
636
+ front: [dot("sensor", 205.5, 33, 32)],
637
+ buttons: [right(290, 70), right(385, 135)]
638
+ },
639
+ "pixel-9-pro": {
640
+ bezel: sides(20.3, 20.3, 19, 20),
641
+ screenRadius: 58,
642
+ bodyRadius: 78,
643
+ out: 2.3,
644
+ front: [dot("sensor", 213.4, 33.7, 30.9)],
645
+ buttons: [right(269.7, 77.7), right(392.1, 142.7)]
646
+ },
647
+ "pixel-9-pro-xl": {
648
+ bezel: sides(18.7, 19.3, 17.3, 19),
649
+ screenRadius: 57,
650
+ bodyRadius: 76,
651
+ out: 2.3,
652
+ front: [dot("sensor", 224, 32.8, 30.8)],
653
+ buttons: [right(274.1, 75.7), right(393.8, 139.4)]
654
+ },
655
+ "ipad-mini": {
656
+ bezel: sides(60.6, 60.4, 60.6, 60.4),
657
+ screenRadius: 21.5,
658
+ bodyRadius: 77,
659
+ out: 2.5,
660
+ front: [dot("lens", 372, -35, 16)],
661
+ buttons: [top(82.3, 64.6), top(159.7, 64.6), top(673.5, 109.9)]
662
+ },
663
+ "ipad-air-11": {
664
+ bezel: sides(53.5, 53.9, 53.5, 53.9),
665
+ screenRadius: 18,
666
+ bodyRadius: 66.5,
667
+ out: 2.5,
668
+ front: [dot("lens", 850.5, 540.6, 16)],
669
+ buttons: [top(772.9, 89), right(75.1, 52.3), right(137.8, 52.3)]
670
+ },
671
+ "ipad-pro-13": {
672
+ bezel: sides(43.7, 44, 43.7, 44),
673
+ screenRadius: 30,
674
+ bodyRadius: 74.8,
675
+ out: 2.5,
676
+ front: [dot("lens", 1051.6, 688, 13.9)],
677
+ buttons: [top(984.7, 62.7), right(74.3, 52.3), right(137, 52.3)]
678
+ }
679
+ };
680
+
681
+ // src/engine/browserui.ts
682
+ var LAYOUTS = {
683
+ safari: ["compact", "bottom", "top", "off"],
684
+ chrome: ["top", "bottom", "off"]
685
+ };
686
+ var DUO_COVER = {
687
+ column: 84,
688
+ bottom: 98,
689
+ minimized: 60,
690
+ axis: 48,
691
+ time: { y: 91.5, size: 15.75 },
692
+ ring: { y: 129.9, radius: 18.9, stroke: 3.5 },
693
+ buttons: [174.2, 234.2],
694
+ capsule: 102,
695
+ gap: 34,
696
+ inset: 24,
697
+ across: {
698
+ top: 80,
699
+ minimized: 26,
700
+ side: 7.33,
701
+ address: { x: 209, width: 260 },
702
+ end: 149.33
703
+ }
704
+ };
705
+ var DUO_INNER = {
706
+ top: 80,
707
+ minimized: 51,
708
+ axis: 47.67,
709
+ time: { x: 99.83, y: 47.4, size: 15.75 },
710
+ ring: { y: 47.9, radius: 18.9, stroke: 3.5 },
711
+ side: 6,
712
+ address: { landscape: { x: 295, width: 361 }, portrait: { x: 184, width: 241.5 } },
713
+ end: 232,
714
+ pill: 23.5
715
+ };
716
+ var DUO_ROW = 26;
717
+ var DUO_PILL = { height: 20, size: 12, pad: 15 };
718
+ function runsUnderBars(id) {
719
+ return !SAFARI2[id]?.duo;
720
+ }
721
+ var DUO_LAYOUTS = ["compact", "off"];
722
+ var STATUS_PRO = { time: 73.83, right: 369.67 };
723
+ var STATUS_MAX = { time: 83.17, right: 401.67 };
724
+ var SAFARI2 = {
725
+ "iphone-18-pro": { top: 62, side: 62, faceId: true },
726
+ "iphone-18-pro-max": { top: 62, side: 62, faceId: true },
727
+ "iphone-duo-closed": { top: 0, side: 0, faceId: true, duo: "cover" },
728
+ "iphone-duo-open": { top: DUO_INNER.top, side: 0, faceId: true, duo: "inner" },
729
+ "iphone-air": { top: 68, side: 68, faceId: true, status: { time: 77.17, right: 387.67 } },
730
+ "iphone-17": { top: 62, side: 62, faceId: true, status: STATUS_PRO },
731
+ "iphone-17-pro": { top: 62, side: 62, faceId: true, status: STATUS_PRO },
732
+ "iphone-17-pro-max": { top: 62, side: 62, faceId: true, status: STATUS_MAX },
733
+ "iphone-16": { top: 59, side: 59, faceId: true },
734
+ "iphone-16-plus": { top: 59, side: 59, faceId: true },
735
+ "iphone-16-pro": { top: 62, side: 62, faceId: true, status: STATUS_PRO },
736
+ "iphone-16-pro-max": { top: 62, side: 62, faceId: true, status: STATUS_MAX },
737
+ "iphone-se": { top: 20, side: 0, faceId: false }
738
+ };
739
+ var CHROME2 = {
740
+ "pixel-10": { top: 69, tall: 923 },
741
+ "pixel-10-pro": { top: 69 },
742
+ "pixel-10-pro-xl": { top: 70, tall: 997 },
743
+ "pixel-10a": { top: 68, tall: 923 },
744
+ "pixel-9": { top: 66, tall: 923 },
745
+ "pixel-9-pro": { top: 68 },
746
+ "pixel-9-pro-xl": { top: 66, tall: 997 }
747
+ };
748
+ var SAFARI_BARS = {
749
+ compact: 98,
750
+ bottom: 158,
751
+ bottomSe: 152,
752
+ topBar: 60,
753
+ topBottom: 92,
754
+ pill: 58,
755
+ topPill: 44,
756
+ landscape: 64
757
+ };
758
+ var CHROME_BARS = { toolbar: 56, chin: 24, landscapeTop: 24 };
759
+ function platformOf(id) {
760
+ if (SAFARI2[id])
761
+ return "safari";
762
+ if (CHROME2[id])
763
+ return "chrome";
764
+ return null;
765
+ }
766
+ function layoutOptions(id) {
767
+ if (SAFARI2[id]?.duo)
768
+ return DUO_LAYOUTS;
769
+ const platform = platformOf(id);
770
+ return platform ? LAYOUTS[platform] : [];
771
+ }
772
+ function layoutOf(id, browser) {
773
+ const options = layoutOptions(id);
774
+ const fallback = options[0];
775
+ if (!fallback)
776
+ return null;
777
+ return browser !== "auto" && options.includes(browser) ? browser : fallback;
778
+ }
779
+ function rect(x, y, width, height) {
780
+ return { x, y, width, height };
781
+ }
782
+ function viewportOf(device, orientation, layout, minimized, edge = false) {
783
+ const { width: W, height: H } = turn(device, orientation);
784
+ const whole = rect(0, 0, W, H);
785
+ if (!layout || layout === "off")
786
+ return whole;
787
+ const safari = SAFARI2[device.id];
788
+ if (safari?.duo === "cover" && orientation === "landscape") {
789
+ const { across } = DUO_COVER;
790
+ const top2 = minimized ? across.minimized : across.top;
791
+ return rect(0, top2, W, H - top2);
792
+ }
793
+ if (safari?.duo === "cover") {
794
+ const bottom = minimized ? DUO_COVER.minimized : DUO_COVER.bottom;
795
+ return rect(0, 0, W - DUO_COVER.column, H - bottom);
796
+ }
797
+ if (safari?.duo === "inner") {
798
+ const top2 = minimized ? DUO_INNER.minimized : DUO_INNER.top;
799
+ return rect(0, top2, W, H - top2);
800
+ }
801
+ if (safari) {
802
+ if (edge && orientation === "landscape")
803
+ return rect(safari.side, 0, W - 2 * safari.side, H);
804
+ if (orientation === "landscape") {
805
+ const top2 = minimized ? 0 : SAFARI_BARS.landscape;
806
+ return rect(safari.side, top2, W - 2 * safari.side, H - top2);
807
+ }
808
+ const T = safari.top;
809
+ if (layout === "top") {
810
+ const top2 = T + (minimized ? SAFARI_BARS.topPill : SAFARI_BARS.topBar);
811
+ const bottom = minimized ? H : H - SAFARI_BARS.topBottom;
812
+ return rect(0, top2, W, bottom - top2);
813
+ }
814
+ const card = safari.faceId ? SAFARI_BARS.bottom : SAFARI_BARS.bottomSe;
815
+ const bar = minimized ? SAFARI_BARS.pill : layout === "bottom" ? card : SAFARI_BARS.compact;
816
+ return rect(0, T, W, H - bar - T);
817
+ }
818
+ const chrome = CHROME2[device.id];
819
+ if (!chrome)
820
+ return whole;
821
+ const toolbar = minimized ? 0 : CHROME_BARS.toolbar;
822
+ if (orientation === "landscape") {
823
+ const top2 = CHROME_BARS.landscapeTop + toolbar;
824
+ return rect(0, top2, W, H - top2);
825
+ }
826
+ const tall = chrome.tall ?? H;
827
+ const chin = minimized ? 0 : CHROME_BARS.chin;
828
+ const height = tall - chrome.top - toolbar - chin;
829
+ return rect(0, chrome.top + (layout === "top" ? toolbar : 0), W, height);
830
+ }
831
+ function capsule(kind, box, marks = []) {
832
+ return { kind, ...box, radius: Math.min(box.width, box.height) / 2, marks };
833
+ }
834
+ function mark(glyph, x, y) {
835
+ return { glyph, x, y };
836
+ }
837
+ var SCRIM = [
838
+ [0, 0.81],
839
+ [20, 0.67],
840
+ [40, 0.41],
841
+ [60, 0.16],
842
+ [80, 0.03],
843
+ [100, 0]
844
+ ];
845
+ function alphaAt(fade, y) {
846
+ const at = y - fade.y;
847
+ const { stops } = fade;
848
+ const first = stops[0];
849
+ if (!first || at <= first.at)
850
+ return first?.alpha ?? 0;
851
+ for (let i = 1;i < stops.length; i++) {
852
+ const from = stops[i - 1];
853
+ const to = stops[i];
854
+ if (!from || !to || at > to.at)
855
+ continue;
856
+ return from.alpha + (to.alpha - from.alpha) * (at - from.at) / (to.at - from.at || 1);
857
+ }
858
+ return stops.at(-1)?.alpha ?? 0;
859
+ }
860
+ function sensorMiddle(id) {
861
+ const sensor = BODIES[id]?.front.find((front) => front.kind === "sensor");
862
+ if (!sensor)
863
+ return null;
864
+ return { x: sensor.x + sensor.width / 2, y: sensor.y + sensor.height / 2, width: sensor.width };
865
+ }
866
+ var SAFARI_TEXT = { field: 17, pill: 13 };
867
+ var SAFARI_PILL = { height: 32, size: SAFARI_TEXT.pill, pad: 33 };
868
+ var BOTTOM_ROW = [0.1032, 0.3056, 0.4965, 0.6925, 0.8872];
869
+ var TOP_ROW = [0.0884, 0.2986, 0.4962, 0.6994, 0.9012];
870
+ var ROW = ["back", "forward", "share", "bookmarks", "tabs"];
871
+ function domainPill(x, top2, look = SAFARI_PILL) {
872
+ const { height, size, pad } = look;
873
+ return {
874
+ kind: "pill",
875
+ x,
876
+ y: top2,
877
+ width: 0,
878
+ height,
879
+ radius: height / 2,
880
+ marks: [],
881
+ text: { x, y: top2 + height / 2, size, pad }
882
+ };
883
+ }
884
+ function address(kind, box, page, reload) {
885
+ const y = box.y + box.height / 2;
886
+ return {
887
+ ...capsule(kind, box, [
888
+ mark("page", box.x + page, y),
889
+ mark("reload", box.x + box.width - reload, y)
890
+ ]),
891
+ text: { x: box.x + box.width / 2, y, size: SAFARI_TEXT.field }
892
+ };
893
+ }
894
+ function acrossRow(left2, right2, y) {
895
+ const s = left2;
896
+ const row = (x2, width2) => rect(x2, y, width2, 44);
897
+ const end = row(right2 - 10 - 132, 132);
898
+ const middle = y + 22;
899
+ const [from, to] = [s + 66 + 44 + 8, end.x - 8];
900
+ const width = Math.min(318, to - from);
901
+ const x = Math.min(Math.max((left2 + right2) / 2 - width / 2, from), to - width);
902
+ return [
903
+ capsule("glass", row(s + 10, 44), [mark("back", s + 32, middle)]),
904
+ capsule("glass", row(s + 66, 44), [mark("bookmarks", s + 88, middle)]),
905
+ address("glass", row(x, width), 24, 22),
906
+ capsule("glass", end, [
907
+ mark("share", end.x + 22, middle),
908
+ mark("plus", end.x + 66, middle),
909
+ mark("tabs", end.x + 110, middle)
910
+ ])
911
+ ];
912
+ }
913
+ function duoRow(side, field, endX, end) {
914
+ const y = DUO_ROW;
915
+ const middle = y + 22;
916
+ const row = (x, width) => rect(x, y, width, 44);
917
+ return [
918
+ capsule("glass", row(side + 10, 44), [mark("back", side + 32, middle)]),
919
+ capsule("glass", row(side + 66, 44), [mark("bookmarks", side + 88, middle)]),
920
+ address("glass", row(field.x, field.width), 22, 24.5),
921
+ capsule("glass", row(endX, 44 * end.length), end.map((glyph, at) => mark(glyph, endX + 22 + 44 * at, middle)))
922
+ ];
923
+ }
924
+ function duoCover(bars, W, H, orientation, minimized) {
925
+ const c = DUO_COVER;
926
+ if (orientation === "landscape") {
927
+ const { across } = c;
928
+ if (minimized)
929
+ bars.shapes = [domainPill(W / 2, (across.minimized - DUO_PILL.height) / 2, DUO_PILL)];
930
+ else
931
+ bars.shapes = duoRow(across.side, across.address, W - across.end, ["share", "plus", "tabs"]);
932
+ return bars;
933
+ }
934
+ const page = W - c.column;
935
+ const x = W - c.axis;
936
+ bars.column = { x, strip: false, time: { x, ...c.time }, ring: { ...c.ring } };
937
+ if (minimized) {
938
+ bars.shapes = [domainPill(page / 2, H - 46)];
939
+ return bars;
940
+ }
941
+ const button = (y, glyph) => capsule("glass", rect(x - 24, y, 48, 48), [mark(glyph, x, y + 24)]);
942
+ const [back = 0, reader = 0] = c.buttons;
943
+ const low = H - c.gap - c.capsule;
944
+ bars.shapes = [
945
+ address("glass", rect(c.inset, H - c.gap - 48, page - 2 * c.inset, 48), 24, 24),
946
+ button(back, "back"),
947
+ button(reader, "bookmarks"),
948
+ capsule("glass", rect(x - 24, low, 48, c.capsule), [mark("plus", x, low + 24), mark("tabs", x, H - c.gap - 24)])
949
+ ];
950
+ return bars;
951
+ }
952
+ function duoInner(bars, W, orientation, minimized) {
953
+ const d = DUO_INNER;
954
+ if (minimized) {
955
+ bars.shapes = [domainPill(W / 2, d.pill, DUO_PILL)];
956
+ return bars;
957
+ }
958
+ bars.column = { x: W - d.axis, strip: true, time: { ...d.time, x: W - d.time.x }, ring: { ...d.ring } };
959
+ bars.shapes = duoRow(d.side, d.address[orientation], W - d.end, ["plus", "tabs"]);
960
+ return bars;
961
+ }
962
+ function safariBars(device, spec, orientation, layout, minimized) {
963
+ const { width: W, height: H } = turn(device, orientation);
964
+ const bars = {
965
+ platform: "safari",
966
+ layout,
967
+ screen: device,
968
+ orientation,
969
+ minimized,
970
+ status: null,
971
+ column: null,
972
+ shapes: [],
973
+ chin: null,
974
+ hairline: null,
975
+ scrim: null,
976
+ edge: false
977
+ };
978
+ if (spec.duo === "cover")
979
+ return duoCover(bars, W, H, orientation, minimized);
980
+ if (spec.duo === "inner")
981
+ return duoInner(bars, W, orientation, minimized);
982
+ if (orientation === "landscape") {
983
+ if (!minimized)
984
+ bars.shapes = acrossRow(spec.side, W - spec.side, 10);
985
+ return bars;
986
+ }
987
+ bars.status = safariStatus(device.id, spec, W);
988
+ const page = viewportOf(device, orientation, layout, minimized);
989
+ const T = spec.top;
990
+ if (minimized) {
991
+ bars.shapes = [domainPill(W / 2, layout === "top" ? T : H - 46)];
992
+ const stops = SCRIM.map(([at, alpha]) => ({ at, alpha }));
993
+ bars.scrim = { y: 0, height: 100, stops, at: { x: W / 2, y: page.y + 1 } };
994
+ return bars;
995
+ }
996
+ if (layout === "compact") {
997
+ const y = H - 82;
998
+ const middle = y + 24;
999
+ bars.shapes = [
1000
+ capsule("glass", rect(34, y, 48, 48), [mark("back", 58, middle)]),
1001
+ address("glass", rect(90, y, W - 180, 48), 24, 22),
1002
+ capsule("glass", rect(W - 82, y, 48, 48), [mark("tabs", W - 58, middle)])
1003
+ ];
1004
+ return bars;
1005
+ }
1006
+ if (layout === "bottom") {
1007
+ const inset = spec.faceId ? 14 : 8;
1008
+ const card = rect(inset, H - inset - 128, W - 2 * inset, 128);
1009
+ const field = rect(card.x + 22, card.y + 16, card.width - 44, 48);
1010
+ const row2 = card.y + 92;
1011
+ bars.shapes = [
1012
+ {
1013
+ kind: "card",
1014
+ ...card,
1015
+ radius: 40,
1016
+ marks: ROW.map((glyph, at) => {
1017
+ return mark(glyph, card.x + card.width * (BOTTOM_ROW[at] ?? 0), row2);
1018
+ })
1019
+ },
1020
+ address("field", field, 18, 16)
1021
+ ];
1022
+ return bars;
1023
+ }
1024
+ const top2 = rect(16, T, W - 32, 44);
1025
+ const bottom = rect(28, H - 76, W - 56, 48);
1026
+ const row = bottom.y + 24;
1027
+ bars.shapes = [
1028
+ address("glass", top2, 23, 18),
1029
+ capsule("glass", bottom, ROW.map((glyph, at) => mark(glyph, bottom.x + bottom.width * (TOP_ROW[at] ?? 0), row)))
1030
+ ];
1031
+ return bars;
1032
+ }
1033
+ function safariStatus(id, spec, W) {
1034
+ const island = sensorMiddle(id);
1035
+ if (!spec.faceId) {
1036
+ return {
1037
+ height: spec.top,
1038
+ time: { x: W / 2, y: 10, size: 15 },
1039
+ icons: { x: 6, y: 10, align: "start" },
1040
+ battery: { x: W - 7, y: 10 },
1041
+ large: false
1042
+ };
1043
+ }
1044
+ const large = W >= 420;
1045
+ const size = large ? 19 : 18;
1046
+ if (!island) {
1047
+ const y = spec.top / 2 + 2;
1048
+ return {
1049
+ height: spec.top,
1050
+ time: { x: 58, y, size },
1051
+ icons: { x: W - 36, y, align: "end" },
1052
+ large
1053
+ };
1054
+ }
1055
+ const left2 = island.x - island.width / 2;
1056
+ if (left2 > W / 2) {
1057
+ return {
1058
+ height: spec.top,
1059
+ time: { x: 52, y: island.y, size },
1060
+ icons: { x: left2 - 12, y: island.y, align: "end" },
1061
+ large
1062
+ };
1063
+ }
1064
+ return {
1065
+ height: spec.top,
1066
+ time: { x: spec.status?.time ?? left2 * 0.535, y: island.y, size },
1067
+ icons: { x: spec.status?.right ?? W - (large ? 38.33 : 32.33), y: island.y, align: "end" },
1068
+ large
1069
+ };
1070
+ }
1071
+ function chromeStatus(id, height, W, orientation) {
1072
+ const hole = orientation === "portrait" ? sensorMiddle(id) : null;
1073
+ const y = hole?.y ?? height / 2;
1074
+ const side = orientation === "portrait" ? 26 : 56;
1075
+ return {
1076
+ height,
1077
+ time: { x: side, y, size: 14 },
1078
+ icons: { x: W - side, y, align: "end" },
1079
+ large: false
1080
+ };
1081
+ }
1082
+ function chromeBars(device, spec, orientation, layout, minimized) {
1083
+ const { width: W, height: H } = turn(device, orientation);
1084
+ const portrait = orientation === "portrait";
1085
+ const statusHeight = portrait ? spec.top : CHROME_BARS.landscapeTop;
1086
+ const page = viewportOf(device, orientation, layout, minimized);
1087
+ const bars = {
1088
+ platform: "chrome",
1089
+ layout,
1090
+ screen: device,
1091
+ orientation,
1092
+ minimized,
1093
+ status: chromeStatus(device.id, statusHeight, W, orientation),
1094
+ column: null,
1095
+ shapes: [],
1096
+ chin: null,
1097
+ hairline: null,
1098
+ scrim: null,
1099
+ edge: false
1100
+ };
1101
+ if (minimized)
1102
+ return bars;
1103
+ const atTop = layout === "top" || !portrait;
1104
+ const toolbarY = atTop ? statusHeight : page.y + page.height;
1105
+ const toolbar = rect(0, toolbarY, W, CHROME_BARS.toolbar);
1106
+ const under = toolbarY + CHROME_BARS.toolbar;
1107
+ const chin = atTop ? page.y + page.height : under;
1108
+ bars.chin = portrait ? rect(0, chin, W, H - chin) : null;
1109
+ bars.hairline = rect(0, atTop ? under : toolbarY, W, 1);
1110
+ const middle = toolbarY + CHROME_BARS.toolbar / 2;
1111
+ const menu = W - 8 - 24;
1112
+ const tabs = menu - 48;
1113
+ const plus = tabs - 24 - 26;
1114
+ const pillLeft = 48 + 4;
1115
+ const pillRight = plus - 26 - 4;
1116
+ const pill2 = rect(pillLeft, middle - 20, pillRight - pillLeft, 40);
1117
+ bars.shapes = [
1118
+ {
1119
+ kind: "toolbar",
1120
+ ...toolbar,
1121
+ radius: 0,
1122
+ marks: [
1123
+ mark("home", 24, middle),
1124
+ mark("plus", plus, middle),
1125
+ mark("switcher", tabs, middle),
1126
+ mark("menu", menu, middle)
1127
+ ]
1128
+ },
1129
+ {
1130
+ ...capsule("field", pill2, [mark("tune", pill2.x + 4 + 14, middle)]),
1131
+ text: { x: pill2.x + 4 + 28 + 4, y: middle, size: 16 }
1132
+ }
1133
+ ];
1134
+ return bars;
1135
+ }
1136
+ function barsOf(device, orientation, layout, minimized, edge = false) {
1137
+ if (!layout || layout === "off")
1138
+ return null;
1139
+ const safari = SAFARI2[device.id];
1140
+ if (safari) {
1141
+ const bars = safariBars(device, safari, orientation, layout, minimized);
1142
+ const upright = orientation === "portrait" || safari.duo !== undefined;
1143
+ return { ...bars, edge: edge || upright };
1144
+ }
1145
+ const chrome = CHROME2[device.id];
1146
+ if (chrome)
1147
+ return chromeBars(device, chrome, orientation, layout, minimized);
1148
+ return null;
1149
+ }
1150
+ var BARS_DOWN = 16;
1151
+ var BARS_UP = 40;
1152
+ var BARS_TOP = 1;
1153
+ var BARS_LOCK = 450;
1154
+ var BARS_START = { minimized: false, anchor: 0, y: 0, lockUntil: 0 };
1155
+ function barsStep(state, event) {
1156
+ if (event.type === "navigate")
1157
+ return BARS_START;
1158
+ if (event.type === "tap")
1159
+ return { ...state, minimized: false, anchor: state.y };
1160
+ if (event.type === "resize")
1161
+ return { ...state, lockUntil: event.time + BARS_LOCK };
1162
+ const { y, time } = event;
1163
+ const room = event.room ?? 0;
1164
+ const near = state.minimized && room > 0 && y - room <= BARS_TOP;
1165
+ if (near)
1166
+ return { ...state, minimized: false, y, anchor: y };
1167
+ if (time < state.lockUntil)
1168
+ return { ...state, y, anchor: y };
1169
+ if (y <= BARS_TOP)
1170
+ return { ...state, minimized: false, y, anchor: y };
1171
+ if (state.minimized) {
1172
+ const anchor2 = Math.max(state.anchor, y);
1173
+ if (anchor2 - y >= BARS_UP)
1174
+ return { ...state, minimized: false, y, anchor: y };
1175
+ return { ...state, y, anchor: anchor2 };
1176
+ }
1177
+ const anchor = Math.min(state.anchor, y);
1178
+ const left2 = room > 0 ? Math.min(y, event.rest ?? Infinity) : y;
1179
+ const clear = left2 - 2 * room >= BARS_DOWN;
1180
+ if (y - anchor >= BARS_DOWN && clear)
1181
+ return { ...state, minimized: true, y, anchor: y };
1182
+ return { ...state, y, anchor };
1183
+ }
1184
+
1185
+ // src/engine/mock.ts
1186
+ function islandOf(id) {
1187
+ const sensor = BODIES[id]?.front.find((front) => front.kind === "sensor");
1188
+ return sensor && sensor.width > sensor.height ? sensor : null;
1189
+ }
1190
+ function round(kind, rect2) {
1191
+ return { kind, ...rect2, radius: Math.min(rect2.width, rect2.height) / 2 };
1192
+ }
1193
+ function bar(button, out, body) {
1194
+ const { side, at, length } = button;
1195
+ if (side === "top") {
1196
+ const y = body.y - out;
1197
+ return { kind: "button", x: body.x + at, y, width: length, height: 2 * out, radius: out };
1198
+ }
1199
+ const x = side === "left" ? body.x - out : body.x + body.width - out;
1200
+ return { kind: "button", x, y: body.y + at, width: 2 * out, height: length, radius: out };
1201
+ }
1202
+ function keyOf(front) {
1203
+ if (front.key === undefined)
1204
+ return null;
1205
+ const gap = (front.width - front.key) / 2;
1206
+ return { x: front.x + gap, y: front.y + gap, width: front.key, height: front.key };
1207
+ }
1208
+ function turnRect(rect2, width, height, clockwise) {
1209
+ const { x, y } = rect2;
1210
+ const turned = { width: rect2.height, height: rect2.width };
1211
+ return clockwise ? { ...rect2, ...turned, x: height - y - rect2.height, y: x } : { ...rect2, ...turned, x: y, y: width - x - rect2.width };
1212
+ }
1213
+ function turnSides(sides2, clockwise = false) {
1214
+ return clockwise ? { top: sides2.left, right: sides2.top, bottom: sides2.right, left: sides2.bottom } : { top: sides2.right, right: sides2.bottom, bottom: sides2.left, left: sides2.top };
1215
+ }
1216
+ function turnRadius(radius, clockwise = false) {
1217
+ if (typeof radius === "number")
1218
+ return radius;
1219
+ const [topLeft, topRight, bottomRight, bottomLeft] = radius;
1220
+ return clockwise ? [bottomLeft, topLeft, topRight, bottomRight] : [topRight, bottomRight, bottomLeft, topLeft];
1221
+ }
1222
+ function placeIn2(mock, room) {
1223
+ const dx = room.inset.left - mock.inset.left;
1224
+ const dy = room.inset.top - mock.inset.top;
1225
+ const move = (rect2) => ({ ...rect2, x: rect2.x + dx, y: rect2.y + dy });
1226
+ const { width, height, inset } = room;
1227
+ return { ...mock, width, height, inset, body: move(mock.body), parts: mock.parts.map(move) };
1228
+ }
1229
+ function mockOf(id, orientation) {
1230
+ const device = screenOf(id);
1231
+ const shape = BODIES[id];
1232
+ if (!device || !shape)
1233
+ return null;
1234
+ const { bezel, screenRadius, bodyRadius } = shape;
1235
+ const out = (button) => button.out ?? shape.out;
1236
+ const most = (side) => Math.max(0, ...shape.buttons.filter((button) => button.side === side).map(out));
1237
+ const room = { top: most("top"), right: most("right"), left: most("left") };
1238
+ const size = turn(device, "portrait");
1239
+ const inset = {
1240
+ top: bezel.top + room.top,
1241
+ right: bezel.right + room.right,
1242
+ bottom: bezel.bottom,
1243
+ left: bezel.left + room.left
1244
+ };
1245
+ const width = size.width + inset.left + inset.right;
1246
+ const height = size.height + inset.top + inset.bottom;
1247
+ const body = {
1248
+ x: room.left,
1249
+ y: room.top,
1250
+ width: size.width + bezel.left + bezel.right,
1251
+ height: size.height + bezel.top + bezel.bottom
1252
+ };
1253
+ const at = ({ x, y, width: width2, height: height2 }) => {
1254
+ return { x: inset.left + x, y: inset.top + y, width: width2, height: height2 };
1255
+ };
1256
+ const parts = [
1257
+ ...shape.buttons.map((button) => bar(button, out(button), body)),
1258
+ ...shape.front.flatMap((front) => {
1259
+ const key = keyOf(front);
1260
+ const shown = round(front.kind, at(front));
1261
+ return key ? [shown, round("key", at(key))] : [shown];
1262
+ })
1263
+ ];
1264
+ const upright = { width, height, inset, body, screenRadius, bodyRadius, parts };
1265
+ if (orientation === "portrait")
1266
+ return upright;
1267
+ const clockwise = device.clockwise === true;
1268
+ return {
1269
+ ...upright,
1270
+ width: height,
1271
+ height: width,
1272
+ inset: turnSides(inset, clockwise),
1273
+ body: turnRect(body, width, height, clockwise),
1274
+ screenRadius: turnRadius(screenRadius, clockwise),
1275
+ bodyRadius: turnRadius(bodyRadius, clockwise),
1276
+ parts: upright.parts.map((part) => turnRect(part, width, height, clockwise))
1277
+ };
1278
+ }
1279
+
1280
+ // src/engine/native.ts
1281
+ var HAND_WAIT = 2000;
1282
+ var SYSTEM_MEDIA = {
1283
+ scheme: "system",
1284
+ motion: "system",
1285
+ contrast: "system",
1286
+ transparency: "system"
1287
+ };
1288
+ function drawnAround(state) {
1289
+ if (state.panel.docked || state.frame || state.vision !== "none" || state.zoom !== "fit")
1290
+ return true;
1291
+ const device = deviceOf(state.device);
1292
+ if (!device)
1293
+ return false;
1294
+ if (device.postures)
1295
+ return true;
1296
+ const id = formId(state.device, state.posture);
1297
+ if (state.mock && mockOf(id, state.orientation) !== null)
1298
+ return true;
1299
+ const layout = layoutOf(id, state.browser);
1300
+ return layout !== null && layout !== "off";
1301
+ }
1302
+ function nativeViewport(state) {
1303
+ if (!knobFrame(state) || drawnAround(state))
1304
+ return null;
1305
+ const device = deviceOf(state.device);
1306
+ const touch = device?.touch === true;
1307
+ return {
1308
+ width: typeof state.width === "number" ? state.width : null,
1309
+ height: typeof state.height === "number" ? state.height : null,
1310
+ dpr: typeof state.dpr === "number" ? state.dpr : null,
1311
+ mobile: device?.kind === "phone" || device?.kind === "tablet",
1312
+ touch,
1313
+ touchPointer: touch && state.touchPointer
1314
+ };
1315
+ }
1316
+ function nativeUa(value) {
1317
+ const preset = uaPreset(value.preset);
1318
+ if (preset) {
1319
+ const { userAgent: userAgent2, platform, mobile, brands, uaPlatform, hints } = preset;
1320
+ return { userAgent: userAgent2, platform, mobile, brands, uaPlatform, ...hints ? { hints } : {} };
1321
+ }
1322
+ const userAgent = userAgentOf(value);
1323
+ return userAgent === "" ? null : { userAgent, platform: "", mobile: false, brands: [], uaPlatform: "" };
1324
+ }
1325
+ function inPage(state, driver) {
1326
+ if (!driver)
1327
+ return state;
1328
+ let next2 = state;
1329
+ if (driver.text)
1330
+ next2 = { ...next2, text: "system" };
1331
+ if (driver.offline)
1332
+ next2 = { ...next2, network: { ...next2.network, online: "system" } };
1333
+ if (driver.media)
1334
+ next2 = { ...next2, ...SYSTEM_MEDIA };
1335
+ return next2;
1336
+ }
1337
+ function framing(state, driver) {
1338
+ if (!driver?.viewport || !nativeViewport(state))
1339
+ return state;
1340
+ return { ...state, width: "full", height: "full", dpr: "system" };
1341
+ }
1342
+ var enabled = true;
1343
+ function nativeEnabled() {
1344
+ return enabled;
1345
+ }
1346
+ function enableNative(on) {
1347
+ enabled = on;
1348
+ }
1349
+ var sent = new Map;
1350
+ var pending = null;
1351
+ function handing() {
1352
+ return pending;
1353
+ }
1354
+ function hand(driver, part, value) {
1355
+ const call = driver[part];
1356
+ if (!call)
1357
+ return;
1358
+ const key = JSON.stringify(value);
1359
+ if (sent.get(part) === key)
1360
+ return;
1361
+ sent.set(part, key);
1362
+ const settled = settles(call(value))?.then(() => {
1363
+ if (pending === settled)
1364
+ pending = null;
1365
+ });
1366
+ if (settled)
1367
+ pending = settled;
1368
+ }
1369
+ function settles(result) {
1370
+ if (!(result instanceof Promise))
1371
+ return null;
1372
+ return Promise.race([
1373
+ result.then(() => {}, () => {}),
1374
+ new Promise((resolve) => setTimeout(resolve, HAND_WAIT))
1375
+ ]);
1376
+ }
1377
+ function drive(driver, state) {
1378
+ hand(driver, "text", state.text);
1379
+ hand(driver, "offline", state.network.online === "offline");
1380
+ const { scheme, motion, contrast, transparency } = state;
1381
+ hand(driver, "media", { scheme, motion, contrast, transparency });
1382
+ if (driver.viewport)
1383
+ hand(driver, "viewport", nativeViewport(state));
1384
+ driveUa(driver, state, driver.viewport !== undefined && nativeViewport(state) !== null);
1385
+ }
1386
+ function hostUa(state, sized) {
1387
+ const brought = [deviceOf(state.device)?.ua, formOf(state.device, state.posture)?.ua];
1388
+ if (sized || !brought.includes(state.ua.preset))
1389
+ return nativeUa(state.ua);
1390
+ const ua = state.panel.realPhone ? nativeUa(state.ua) : null;
1391
+ return ua && { ...ua, frame: true };
1392
+ }
1393
+ function driveUa(driver, state, sized = false) {
1394
+ if (driver.ua)
1395
+ hand(driver, "ua", hostUa(state, sized));
1396
+ }
1397
+ function release(driver, ua = true) {
1398
+ if (sent.size === 0)
1399
+ return;
1400
+ hand(driver, "text", "system");
1401
+ hand(driver, "offline", false);
1402
+ hand(driver, "media", SYSTEM_MEDIA);
1403
+ hand(driver, "viewport", null);
1404
+ if (ua)
1405
+ hand(driver, "ua", null);
1406
+ for (const part of Array.from(sent.keys()))
1407
+ if (ua || part !== "ua")
1408
+ sent.delete(part);
1409
+ }
1410
+
1411
+ // src/engine/screen.ts
1412
+ var KEYS2 = ["width", "height", "availWidth", "availHeight"];
1413
+ function screenSizeOf(state) {
1414
+ const device = formOf(state.device, state.posture);
1415
+ if (!device || device.kind !== "phone" && device.kind !== "tablet")
1416
+ return null;
1417
+ if (device.ua !== "iphone-safari")
1418
+ return turn(device, state.orientation);
1419
+ const { width, height } = turn(deviceOf(state.device) ?? device, "portrait");
1420
+ const across = device.postures !== undefined && state.posture !== "open" && state.orientation === "landscape";
1421
+ return across ? { width, height, availHeight: width } : { width, height };
1422
+ }
1423
+ var ORIGINALS = Symbol.for("devknobs.screen");
1424
+ function originalsOf(own) {
1425
+ const held = Reflect.get(own, ORIGINALS);
1426
+ return held instanceof Map ? held : undefined;
1427
+ }
1428
+ function apply2(size, scope = globalThis) {
1429
+ const own = Reflect.get(scope, "screen");
1430
+ if (typeof own !== "object" || own === null)
1431
+ return;
1432
+ const originals = originalsOf(own);
1433
+ if (!size) {
1434
+ if (!originals)
1435
+ return;
1436
+ for (const [key, descriptor] of originals) {
1437
+ if (descriptor)
1438
+ Object.defineProperty(own, key, descriptor);
1439
+ else
1440
+ Reflect.deleteProperty(own, key);
1441
+ }
1442
+ Reflect.deleteProperty(own, ORIGINALS);
1443
+ return;
1444
+ }
1445
+ if (!originals) {
1446
+ const kept = new Map(KEYS2.map((key) => [key, Object.getOwnPropertyDescriptor(own, key)]));
1447
+ Object.defineProperty(own, ORIGINALS, { configurable: true, value: kept });
1448
+ }
1449
+ for (const key of KEYS2) {
1450
+ const value = key === "width" || key === "availWidth" ? size.width : key === "availHeight" ? size.availHeight ?? size.height : size.height;
1451
+ Object.defineProperty(own, key, { configurable: true, enumerable: true, get: () => value });
1452
+ }
1453
+ }
1454
+ function reset2() {
1455
+ apply2(null);
1456
+ }
1457
+
1458
+ // src/engine/scrollbars.ts
1459
+ var NAME = "scrollbars";
1460
+ var COMMIT_WAIT = 1000;
1461
+ var CSS = "*{scrollbar-width:none!important}::-webkit-scrollbar{display:none!important}";
1462
+ function apply3(value) {
1463
+ if (!value) {
1464
+ reset3();
1465
+ return;
1466
+ }
1467
+ ensureStyle(NAME).textContent = CSS;
1468
+ }
1469
+ function place(doc) {
1470
+ if (doc.documentElement) {
1471
+ ensureStyle(NAME, doc).textContent = CSS;
1472
+ return;
1473
+ }
1474
+ const observer = new MutationObserver(() => {
1475
+ if (!doc.documentElement)
1476
+ return;
1477
+ observer.disconnect();
1478
+ ensureStyle(NAME, doc).textContent = CSS;
1479
+ });
1480
+ observer.observe(doc, { childList: true });
1481
+ }
1482
+ function equip(view) {
1483
+ const blank = view.document;
1484
+ if (!blank)
1485
+ return;
1486
+ if (blank.URL !== "about:blank") {
1487
+ place(blank);
1488
+ return;
1489
+ }
1490
+ const until = performance.now() + COMMIT_WAIT;
1491
+ const channel = new MessageChannel;
1492
+ channel.port1.onmessage = () => {
1493
+ let doc = null;
1494
+ try {
1495
+ doc = view.document;
1496
+ } catch {}
1497
+ if (doc && doc !== blank)
1498
+ place(doc);
1499
+ else if (doc && performance.now() < until) {
1500
+ channel.port2.postMessage(null);
1501
+ return;
1502
+ }
1503
+ channel.port1.close();
1504
+ };
1505
+ channel.port2.postMessage(null);
1506
+ }
1507
+ function reset3() {
1508
+ removeStyle(NAME);
1509
+ }
1510
+
1511
+ // src/engine/touch.ts
1512
+ var TOUCH_POINTS = 5;
1513
+ var handler = false;
1514
+ var points = false;
1515
+ function apply4(value) {
1516
+ if (value.on && !handler && !("ontouchstart" in window)) {
1517
+ Object.defineProperty(window, "ontouchstart", {
1518
+ configurable: true,
1519
+ enumerable: true,
1520
+ writable: true,
1521
+ value: null
1522
+ });
1523
+ handler = true;
1524
+ } else if (!value.on && handler) {
1525
+ Reflect.deleteProperty(window, "ontouchstart");
1526
+ handler = false;
1527
+ }
1528
+ const report = value.on && value.points;
1529
+ if (report && !points) {
1530
+ Object.defineProperty(navigator, "maxTouchPoints", {
1531
+ configurable: true,
1532
+ enumerable: true,
1533
+ get: () => TOUCH_POINTS
1534
+ });
1535
+ points = true;
1536
+ } else if (!report && points) {
1537
+ Reflect.deleteProperty(navigator, "maxTouchPoints");
1538
+ points = false;
1539
+ }
1540
+ }
1541
+ function equip2(view, points2) {
1542
+ if (!("ontouchstart" in view)) {
1543
+ Object.defineProperty(view, "ontouchstart", {
1544
+ configurable: true,
1545
+ enumerable: true,
1546
+ writable: true,
1547
+ value: null
1548
+ });
1549
+ }
1550
+ if (!points2)
1551
+ return;
1552
+ Object.defineProperty(view.navigator, "maxTouchPoints", {
1553
+ configurable: true,
1554
+ enumerable: true,
1555
+ get: () => TOUCH_POINTS
1556
+ });
1557
+ }
1558
+ function reset4() {
1559
+ apply4({ on: false, points: false });
1560
+ }
1561
+
1562
+ // src/engine/matcolors.ts
1563
+ var MAT_COLORS = {
1564
+ blue: {
1565
+ srgb: ["rgb(20, 70, 152)", "rgb(12, 48, 114)", "rgb(7, 31, 80)"],
1566
+ p3: [
1567
+ "color(display-p3 0.1 0.27 0.61)",
1568
+ "color(display-p3 0.06 0.19 0.46)",
1569
+ "color(display-p3 0.035 0.12 0.32)"
1570
+ ],
1571
+ line: "rgb(170, 205, 255)"
1572
+ },
1573
+ green: {
1574
+ srgb: ["rgb(26, 96, 71)", "rgb(14, 71, 51)", "rgb(8, 49, 35)"],
1575
+ p3: [
1576
+ "color(display-p3 0.159 0.377 0.279)",
1577
+ "color(display-p3 0.102 0.277 0.2)",
1578
+ "color(display-p3 0.065 0.194 0.136)"
1579
+ ],
1580
+ line: "rgb(160, 218, 191)"
1581
+ },
1582
+ magenta: {
1583
+ srgb: ["rgb(123, 37, 88)", "rgb(90, 22, 63)", "rgb(62, 12, 42)"],
1584
+ p3: [
1585
+ "color(display-p3 0.462 0.14 0.342)",
1586
+ "color(display-p3 0.34 0.081 0.246)",
1587
+ "color(display-p3 0.234 0.043 0.165)"
1588
+ ],
1589
+ line: "rgb(238, 185, 211)"
1590
+ },
1591
+ purple: {
1592
+ srgb: ["rgb(86, 56, 130)", "rgb(62, 38, 96)", "rgb(42, 24, 67)"],
1593
+ p3: [
1594
+ "color(display-p3 0.326 0.209 0.521)",
1595
+ "color(display-p3 0.233 0.138 0.387)",
1596
+ "color(display-p3 0.156 0.086 0.269)"
1597
+ ],
1598
+ line: "rgb(209, 193, 242)"
1599
+ },
1600
+ red: {
1601
+ srgb: ["rgb(132, 36, 36)", "rgb(97, 21, 22)", "rgb(68, 11, 12)"],
1602
+ p3: [
1603
+ "color(display-p3 0.499 0.139 0.133)",
1604
+ "color(display-p3 0.369 0.079 0.078)",
1605
+ "color(display-p3 0.256 0.041 0.042)"
1606
+ ],
1607
+ line: "rgb(239, 188, 183)"
1608
+ },
1609
+ graphite: {
1610
+ srgb: ["rgb(64, 68, 74)", "rgb(43, 46, 51)", "rgb(26, 28, 32)"],
1611
+ p3: [
1612
+ "color(display-p3 0.25 0.264 0.291)",
1613
+ "color(display-p3 0.169 0.179 0.2)",
1614
+ "color(display-p3 0.102 0.11 0.126)"
1615
+ ],
1616
+ line: "rgb(198, 203, 211)"
1617
+ }
1618
+ };
1619
+ var MAT_COLOR_NAMES = [
1620
+ "blue",
1621
+ "green",
1622
+ "magenta",
1623
+ "purple",
1624
+ "red",
1625
+ "graphite"
1626
+ ];
1627
+ function matGradient(stops) {
1628
+ return `radial-gradient(140% 100% at 50% 0%, ${stops[0]}, ${stops[1]} 60%, ${stops[2]})`;
1629
+ }
1630
+ function isMatName(value) {
1631
+ return MAT_COLOR_NAMES.some((name) => name === value);
1632
+ }
1633
+ var SHADE = [1, 0.82, 0.64];
1634
+ function rgb(color) {
1635
+ return `rgb(${Math.round(color.red)}, ${Math.round(color.green)}, ${Math.round(color.blue)})`;
1636
+ }
1637
+ function shades(color) {
1638
+ const shade = (share) => ({
1639
+ red: color.red * share,
1640
+ green: color.green * share,
1641
+ blue: color.blue * share,
1642
+ alpha: 1
1643
+ });
1644
+ return [shade(SHADE[0]), shade(SHADE[1]), shade(SHADE[2])];
1645
+ }
1646
+ function customColor(mat) {
1647
+ return isCustomColor(mat) ? parseHex(mat) : null;
1648
+ }
1649
+ function matStops(mat) {
1650
+ if (isMatName(mat))
1651
+ return MAT_COLORS[mat];
1652
+ const color = customColor(mat);
1653
+ if (!color)
1654
+ return MAT_COLORS.blue;
1655
+ const [top2, middle, edge] = shades(color);
1656
+ const stops = [rgb(top2), rgb(middle), rgb(edge)];
1657
+ return { srgb: stops, p3: stops };
1658
+ }
1659
+ function matPaint(mat) {
1660
+ if (isMatName(mat))
1661
+ return MAT_COLORS[mat];
1662
+ const color = customColor(mat);
1663
+ return color ? { ...matStops(mat), line: rgb(inkOn(color, shades(color))) } : MAT_COLORS.blue;
1664
+ }
1665
+ var MAT_VARIABLES = ["--mat", "--mat-p3", "--mat-line"];
1666
+ function putMat(node, mat) {
1667
+ if (mat === null)
1668
+ node.removeAttribute("data-mat");
1669
+ else
1670
+ node.setAttribute("data-mat", mat);
1671
+ if (mat === null || isMatName(mat)) {
1672
+ for (const name of MAT_VARIABLES)
1673
+ node.style.removeProperty(name);
1674
+ return;
1675
+ }
1676
+ const paint = matPaint(mat);
1677
+ node.style.setProperty("--mat", matGradient(paint.srgb));
1678
+ node.style.setProperty("--mat-p3", matGradient(paint.p3));
1679
+ node.style.setProperty("--mat-line", paint.line);
1680
+ }
1681
+
1682
+ // src/engine/placeholder.ts
1683
+ var Z_INDEX = 2147483645;
1684
+ var EARLY = "early";
1685
+ var SNAPSHOT_KEY = "devknobs:snapshot";
1686
+ var SNAPSHOT_VERSION = 1;
1687
+ var EARLY_FRAMES = 60;
1688
+ var earlyWait = 0;
1689
+ function snapshotKey(knobs, view) {
1690
+ return JSON.stringify([
1691
+ knobs.width,
1692
+ knobs.height,
1693
+ knobs.frame,
1694
+ knobs.dpr,
1695
+ knobs.vision,
1696
+ knobs.scheme,
1697
+ knobs.device,
1698
+ knobs.orientation,
1699
+ knobs.posture,
1700
+ knobs.mock,
1701
+ knobs.browser,
1702
+ knobs.bars,
1703
+ knobs.edgeToEdge,
1704
+ knobs.zoom,
1705
+ knobs.mat,
1706
+ knobs.panel.open,
1707
+ knobs.panel.side,
1708
+ knobs.panel.docked,
1709
+ view.innerWidth,
1710
+ view.innerHeight,
1711
+ view.devicePixelRatio
1712
+ ]);
1713
+ }
1714
+ var RGB = /^rgb\(\d{1,3}, \d{1,3}, \d{1,3}\)$/;
1715
+ function lookOf(value) {
1716
+ if (typeof value !== "object" || value === null)
1717
+ return null;
1718
+ const read = (key) => Reflect.get(value, key);
1719
+ const background = read("background");
1720
+ const scheme = read("scheme");
1721
+ const host = read("host");
1722
+ const flags = [read("dark"), read("canBack"), read("canForward")];
1723
+ if (typeof background !== "string" || !RGB.test(background)) {
1724
+ return null;
1725
+ }
1726
+ if (scheme !== "light" && scheme !== "dark" || typeof host !== "string")
1727
+ return null;
1728
+ const [dark, canBack, canForward] = flags;
1729
+ if (typeof dark !== "boolean" || typeof canBack !== "boolean")
1730
+ return null;
1731
+ if (typeof canForward !== "boolean")
1732
+ return null;
1733
+ const color = (key) => {
1734
+ const value2 = read(key);
1735
+ return typeof value2 === "string" && RGB.test(value2) ? value2 : background;
1736
+ };
1737
+ const top2 = color("top");
1738
+ const bottom = color("bottom");
1739
+ const header = read("header");
1740
+ if (typeof header !== "boolean")
1741
+ return null;
1742
+ return { background, top: top2, bottom, header, footer: read("footer") === true, under: [], dark, scheme, host, canBack, canForward };
1743
+ }
1744
+ function readSnapshot(knobs, view) {
1745
+ try {
1746
+ const text = webStorage("session")?.getItem(SNAPSHOT_KEY);
1747
+ if (!text)
1748
+ return null;
1749
+ const data = JSON.parse(text);
1750
+ if (typeof data !== "object" || data === null || newer(data, SNAPSHOT_VERSION))
1751
+ return null;
1752
+ const key = Reflect.get(data, "key");
1753
+ const css = Reflect.get(data, "css");
1754
+ const html = Reflect.get(data, "html");
1755
+ const look = lookOf(Reflect.get(data, "look"));
1756
+ if (key !== snapshotKey(knobs, view) || typeof css !== "string")
1757
+ return null;
1758
+ if (typeof html !== "string" || !look)
1759
+ return null;
1760
+ return { key, css, html, look };
1761
+ } catch {
1762
+ return null;
1763
+ }
1764
+ }
1765
+ function writeSnapshot(snapshot) {
1766
+ try {
1767
+ webStorage("session")?.setItem(SNAPSHOT_KEY, JSON.stringify(stamped(snapshot, SNAPSHOT_VERSION)));
1768
+ } catch {
1769
+ clearSnapshot();
1770
+ }
1771
+ }
1772
+ function keepDrawing({ letterbox, zoom, key, css, look }) {
1773
+ const copy2 = letterbox.cloneNode(true);
1774
+ if (!(copy2 instanceof HTMLElement))
1775
+ return;
1776
+ copy2.querySelector("iframe")?.remove();
1777
+ copy2.querySelector(".touchdot")?.remove();
1778
+ copy2.querySelector(".glass")?.removeAttribute("data-touch");
1779
+ for (const line of Array.from(copy2.querySelectorAll(".progress")))
1780
+ line.hidden = true;
1781
+ const blank = copy2.querySelector(".screenblank");
1782
+ if (blank) {
1783
+ blank.hidden = false;
1784
+ blank.style.background = look.background;
1785
+ }
1786
+ for (const option of Array.from(copy2.querySelectorAll("option"))) {
1787
+ option.toggleAttribute("selected", option.value === zoom);
1788
+ }
1789
+ writeSnapshot({ key, css, html: copy2.outerHTML, look });
1790
+ }
1791
+ function clearSnapshot() {
1792
+ try {
1793
+ webStorage("session")?.removeItem(SNAPSHOT_KEY);
1794
+ } catch {}
1795
+ }
1796
+ function earlyHost() {
1797
+ return document.querySelector(`div[data-devknobs="${EARLY}"]`);
1798
+ }
1799
+ function dropEarly() {
1800
+ for (const node of Array.from(document.querySelectorAll(`[data-devknobs="${EARLY}"]`))) {
1801
+ node.remove();
1802
+ }
1803
+ removeStyle(EARLY);
1804
+ }
1805
+ function adoptEarly(pictureLoading) {
1806
+ const early = earlyHost();
1807
+ if (!early || !document.body) {
1808
+ dropEarly();
1809
+ return;
1810
+ }
1811
+ document.body.append(early);
1812
+ let frames = 0;
1813
+ const step = () => {
1814
+ earlyWait = 0;
1815
+ if (pictureLoading() && ++frames < EARLY_FRAMES) {
1816
+ earlyWait = window.requestAnimationFrame(step);
1817
+ return;
1818
+ }
1819
+ earlyWait = window.requestAnimationFrame(() => {
1820
+ earlyWait = 0;
1821
+ dropEarly();
1822
+ });
1823
+ };
1824
+ earlyWait = window.requestAnimationFrame(step);
1825
+ }
1826
+ function stopAdopting() {
1827
+ if (earlyWait)
1828
+ window.cancelAnimationFrame(earlyWait);
1829
+ earlyWait = 0;
1830
+ }
1831
+
1832
+ // src/engine/touchmark.ts
1833
+ var RADIUS = 11;
1834
+ var DOT_LOOK = `
1835
+ .dot {
1836
+ left: 0;
1837
+ top: 0;
1838
+ width: ${RADIUS * 2}px;
1839
+ height: ${RADIUS * 2}px;
1840
+ margin: -${RADIUS}px 0 0 -${RADIUS}px;
1841
+ pointer-events: none;
1842
+ will-change: transform;
1843
+ }
1844
+ .dot[hidden] { display: none; }
1845
+ .dot::after {
1846
+ content: "";
1847
+ position: absolute;
1848
+ inset: 0;
1849
+ box-sizing: border-box;
1850
+ border-radius: 50%;
1851
+ background: rgb(0 0 0 / 0.28);
1852
+ border: 1.5px solid rgb(255 255 255 / 0.85);
1853
+ box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25);
1854
+ transition: transform 80ms ease-out, background-color 80ms ease-out;
1855
+ }
1856
+ .dot.pressed::after {
1857
+ transform: scale(0.82);
1858
+ background: rgb(0 0 0 / 0.45);
1859
+ }
1860
+ @media (prefers-reduced-motion: reduce) {
1861
+ .dot::after { transition: none; }
1862
+ }
1863
+ `;
1864
+ var MARK_EVENT = "devknobs-touch-mark";
1865
+ function finite(value) {
1866
+ return typeof value === "number" && Number.isFinite(value);
1867
+ }
1868
+ function readMark(detail) {
1869
+ if (typeof detail !== "object" || detail === null)
1870
+ return null;
1871
+ const at = Reflect.get(detail, "at");
1872
+ const pressed = Reflect.get(detail, "pressed");
1873
+ const held = Reflect.get(detail, "held");
1874
+ if (typeof pressed !== "boolean" || typeof held !== "boolean")
1875
+ return null;
1876
+ if (at === null)
1877
+ return { at: null, pressed, held };
1878
+ if (typeof at !== "object")
1879
+ return null;
1880
+ const x = Reflect.get(at, "x");
1881
+ const y = Reflect.get(at, "y");
1882
+ return finite(x) && finite(y) ? { at: { x, y }, pressed, held } : null;
1883
+ }
1884
+
1885
+ export { follow, keep, keepOwn, resume, runsUnderBars, platformOf, layoutOptions, layoutOf, viewportOf, alphaAt, SAFARI_TEXT, barsOf, BARS_START, barsStep, islandOf, round, turnRect, turnSides, turnRadius, placeIn2 as placeIn, mockOf, UA_PRESETS, uaPreset, userAgentOf, apply, isMac, reset, nativeViewport, inPage, framing, nativeEnabled, enableNative, handing, settles, drive, driveUa, release, screenSizeOf, apply2 as apply1, reset2 as reset1, apply3 as apply2, equip, reset3 as reset2, apply4 as apply3, equip2 as equip1, reset4 as reset3, DOT_LOOK, MARK_EVENT, readMark, MAT_COLORS, MAT_COLOR_NAMES, matGradient, isMatName, putMat, Z_INDEX, snapshotKey, readSnapshot, keepDrawing, clearSnapshot, dropEarly, adoptEarly, stopAdopting };