@leonidstern/labit 0.6.0 → 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.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +44 -0
- package/README.md +20 -127
- package/api/lab-comments.mjs +8 -1
- package/dist/chunk-T4IF6ZJQ.mjs +106 -0
- package/dist/commands-BPVIWBCF.mjs +255 -0
- package/dist/devserver-KCLPMBNL.mjs +56 -0
- package/dist/local.mjs +1487 -0
- package/dist/mcp-BKU67CST.mjs +192 -0
- package/dist/proxy-FLFZV6EI.mjs +74 -0
- package/package.json +8 -6
- package/public/_lab/comments.js +30 -3592
- package/public/_lab/favicon.svg +1 -0
- package/public/_lab/lab.css +12 -0
- package/skills/labit/SKILL.md +7 -3
- package/skills/labit/zoom.md +29 -0
- package/lib/dev.mjs +0 -128
- package/lib/devserver.mjs +0 -58
- package/lib/mcp.mjs +0 -207
- package/lib/proxy.mjs +0 -73
- package/local.mjs +0 -1552
package/public/_lab/comments.js
CHANGED
|
@@ -1,1320 +1,32 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
--_accent: var(--lab-accent, #141414); --_accent-fg: var(--lab-accent-fg, #fff);
|
|
8
|
-
|
|
9
|
-
/* Washes of black (white in dark mode), four steps: soft, hover, line, muted, as lab.css. */
|
|
10
|
-
--_soft: var(--lab-soft, rgba(0,0,0,.05)); --_hover: var(--lab-hover, rgba(0,0,0,.10)); --_line: var(--lab-line, rgba(0,0,0,.15)); --_edge: var(--lab-edge, #c7c7cc); --_muted: var(--lab-muted, rgba(0,0,0,.50));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
button:focus-visible { outline: 2px solid var(--_accent); outline-offset: 2px; }
|
|
27
|
-
.layer { position: absolute; top: 0; left: 0; width: 0; height: 0; }
|
|
28
|
-
.pin { position: absolute; width: 28px; height: 28px; margin: -28px 0 0 0; border-radius: 14px 14px 14px 2px;
|
|
29
|
-
background: var(--_bg); border: 0; box-shadow: 0 0 0 1px var(--_edge), 0 2px 8px rgba(0,0,0,.16);
|
|
30
|
-
display: grid; place-items: center; cursor: pointer; padding: 0; color: var(--_fg); font-size: 12px; font-weight: 500;
|
|
31
|
-
font-variant-numeric: tabular-nums; letter-spacing: 0; transform-origin: 0 100%;
|
|
32
|
-
transition: transform .16s var(--_ease), box-shadow .16s var(--_ease), opacity .16s; }
|
|
33
|
-
/* A 1 px edge in the text colour (dark on light pins, light in dark mode) so a pin shows on white and black alike;
|
|
34
|
-
the one you point at or have open gets a green edge. */
|
|
35
|
-
button.pin:hover, button.pin.open { transform: scale(1.08); box-shadow: 0 0 0 1.5px rgb(36, 160, 70), 0 4px 14px rgba(0,0,0,.2); }
|
|
36
|
-
button.pin:active { transform: scale(.96); }
|
|
37
|
-
.pin.in { animation: lab-pin .26s var(--_ease); }
|
|
38
|
-
/* A new comment lands with one faint halo from its pin. */
|
|
39
|
-
button.pin.in::before { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
|
|
40
|
-
animation: lab-halo .9s cubic-bezier(.2, .7, .3, 1) forwards; }
|
|
41
|
-
.pin.resolved { color: var(--_muted); }
|
|
42
|
-
/* Statuses. A go pin says "go": green in a green outline when placed, the turning stroke while the agent is on it,
|
|
43
|
-
white on green once done (a \u2713 is only ever a done comment). A comment pin: your initial, the stroke, then a green tick. */
|
|
44
|
-
button.pin.go { background: var(--_bg); color: rgb(36, 160, 70); font-size: 11px; font-weight: 600; letter-spacing: .006em;
|
|
45
|
-
box-shadow: inset 0 0 0 1.5px rgb(36, 160, 70), 0 2px 8px rgba(0,0,0,.16); }
|
|
46
|
-
button.pin.go.done { background: rgb(36, 160, 70); color: #fff; box-shadow: 0 0 0 .5px color-mix(in srgb, var(--_fg) 22%, transparent), 0 2px 8px rgba(0,0,0,.16); }
|
|
47
|
-
button.pin.done:not(.go) { color: rgb(36, 160, 70); }
|
|
48
|
-
.pin.moved { opacity: .5; scale: .8; }
|
|
49
|
-
button.pin.moved:hover, button.pin.moved.open { opacity: 1; }
|
|
50
|
-
.pin.grab { touch-action: none; }
|
|
51
|
-
button.pin.dragging { cursor: grabbing; transform: scale(1.1); opacity: 1; box-shadow: 0 0 0 .5px color-mix(in srgb, var(--_fg) 30%, transparent), 0 8px 20px rgba(0,0,0,.22); }
|
|
52
|
-
.zone { position: absolute; background: none;
|
|
53
|
-
border-radius: var(--_radius); pointer-events: none; }
|
|
54
|
-
.zone svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
|
|
55
|
-
.zone rect { fill: none; stroke-linecap: round; stroke-dasharray: 0 4; rx: var(--lab-radius, 12px); ry: var(--lab-radius, 12px); }
|
|
56
|
-
/* Green dots, the same green as quoted words, with no dark ring under them. */
|
|
57
|
-
.zone rect.ring { display: none; }
|
|
58
|
-
.zone rect.dots { stroke: rgb(52, 199, 89); stroke-width: 1.5; } /* 1.5 px round dots, 4 px apart */
|
|
59
|
-
.zone.live { left: 0; top: 0; will-change: transform, width, height; animation: lab-fade .12s ease-out; }
|
|
60
|
-
/* The agent is on it: a green stroke runs round the pin's own teardrop outline. The ring (a still 2 px teardrop mask)
|
|
61
|
-
holds a conic gradient that turns by transform, so the screen turns it without redrawing: 30 such pins cost ~1 ms
|
|
62
|
-
a second, against ~125 ms when the gradient's angle itself was animated. */
|
|
63
|
-
.pin .ring { position: absolute; inset: -4px; border-radius: 18px 18px 18px 6px; padding: 2px; overflow: hidden; pointer-events: none;
|
|
64
|
-
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
|
|
65
|
-
mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
|
|
66
|
-
.ring::before { content: ''; position: absolute; inset: -50%; will-change: transform;
|
|
67
|
-
background: conic-gradient(rgb(52, 199, 89) 0 28%, rgba(52, 199, 89, .22) 28% 100%); animation: lab-turn 1.2s linear infinite; }
|
|
68
|
-
@keyframes lab-turn { to { transform: rotate(360deg); } }
|
|
69
|
-
/* The drawn pointer: your pin, following the mouse (it moves without a transition; only its look eases). */
|
|
70
|
-
.ptr { position: fixed; left: 0; top: 0; width: 28px; height: 28px; border-radius: 14px 14px 14px 2px; corner-shape: round;
|
|
71
|
-
background: var(--_bg); box-shadow: 0 0 0 .5px color-mix(in srgb, var(--_fg) 30%, transparent), 0 2px 6px rgba(0,0,0,.18);
|
|
72
|
-
display: grid; place-items: center; pointer-events: none; z-index: 2147483647; opacity: 0; will-change: transform;
|
|
73
|
-
transition: opacity .12s ease-out, background-color .16s ease-out; }
|
|
74
|
-
.ptr.show { opacity: 1; }
|
|
75
|
-
.ptr span { grid-area: 1 / 1; font-size: 12px; letter-spacing: 0; font-weight: 600; line-height: 1; transition: opacity .16s ease-out, transform .16s ease-out; }
|
|
76
|
-
.ptr .tick { opacity: 0; transform: scale(.5); color: #fff; font-size: 11px; letter-spacing: .006em; }
|
|
77
|
-
.ptr.go { background: rgb(36, 160, 70); }
|
|
78
|
-
.ptr.go .ini { opacity: 0; transform: scale(.5); }
|
|
79
|
-
.ptr.go .tick { opacity: 1; transform: none; }
|
|
80
|
-
.pin.new::after { content: ''; position: absolute; top: -4px; right: -4px; width: 9px; height: 9px; border-radius: 50%;
|
|
81
|
-
background: var(--_fg); box-shadow: 0 0 0 2px var(--_bg); }
|
|
82
|
-
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--_accent); margin: 0 6px 1px 0; }
|
|
83
|
-
.card { position: absolute; width: 320px; max-width: calc(100vw - 24px); background: var(--_bg); border-radius: var(--_radius);
|
|
84
|
-
box-shadow: var(--_shadow); padding: 12px 14px 14px; transform-origin: 14px 0; z-index: 1;
|
|
85
|
-
display: flex; flex-direction: column; max-height: min(460px, 62vh); }
|
|
86
|
-
/* A long thread scrolls inside the card, which keeps one size; the step buttons and the reply box stay put. */
|
|
87
|
-
.card > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin-right: -8px; padding-right: 8px; }
|
|
88
|
-
.card > .foot { flex: none; }
|
|
89
|
-
.card.in, .float.in { animation: lab-in .18s var(--_ease); }
|
|
90
|
-
.card.out, .float.out { animation: lab-out .14s ease-in forwards; pointer-events: none; }
|
|
91
|
-
.item { display: grid; row-gap: 3px; }
|
|
92
|
-
.item + .item { margin-top: 14px; }
|
|
93
|
-
.msg.item { display: block; } .msg.item + .msg.item { margin-top: 0; }
|
|
94
|
-
.meta { display: flex; align-items: baseline; gap: .5em; font-size: 12px; color: var(--_muted); margin: 0;
|
|
95
|
-
white-space: nowrap; letter-spacing: 0; font-variant-numeric: tabular-nums; }
|
|
96
|
-
.meta b { font-weight: 500; font-size: 13px; letter-spacing: -.006em; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
97
|
-
.meta .dot { flex: none; align-self: center; margin: 0; }
|
|
98
|
-
.meta .ago { white-space: nowrap; }
|
|
99
|
-
.text { white-space: pre-wrap; overflow-wrap: anywhere; text-wrap: pretty; }
|
|
100
|
-
.row { display: flex; gap: 12px; justify-content: flex-start; align-items: center; margin-top: 8px; }
|
|
101
|
-
/* A thread's reopen / resolve / delete: small, on the right, out of the reading flow. */
|
|
102
|
-
.card .row:not(.nav) { justify-content: flex-end; gap: 10px; } .card .row:not(.nav) button.btn { font-size: 12px; letter-spacing: 0; }
|
|
103
|
-
button.btn { border: 0; padding: 2px 0; cursor: pointer; background: none; color: var(--_muted); font-size: 12px;
|
|
104
|
-
letter-spacing: 0; border-radius: var(--_r-s); transition: color .12s; }
|
|
105
|
-
button.btn:hover { color: var(--_fg); }
|
|
106
|
-
button.btn.danger, button.btn.danger:hover { color: #e5484d; }
|
|
107
|
-
.row .ask { white-space: nowrap; color: var(--_fg); font-size: 12px; letter-spacing: 0; padding: 2px 0; animation: lab-fade .12s ease-out; }
|
|
108
|
-
.float { position: absolute; width: 320px; max-width: calc(100vw - 24px); transform-origin: 0 20px; z-index: 1; }
|
|
109
|
-
.card .composer { margin-top: 6px; } /* close under resolve / delete */
|
|
110
|
-
.card > .body > .row:not(.nav) { margin-right: 7px; } /* resolve / delete end where the send button does */
|
|
111
|
-
.box { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "text send"; align-items: center; column-gap: 8px;
|
|
112
|
-
border-radius: var(--_radius); padding: 7px 7px 7px 14px; margin: 0; transition: box-shadow .15s;
|
|
113
|
-
/* One box for the chat, threads and new comments: its look comes only from these two, which a place sets on
|
|
114
|
-
its container (never by restyling the box, idle or typing), so the three can't drift apart (Leo, 15 Nov). */
|
|
115
|
-
background: var(--_box-bg, var(--_soft)); box-shadow: var(--_box-edge, none); }
|
|
116
|
-
/* The new comment box on a computer floats over the page: the page's colour, the pins' 1 px edge in the text colour
|
|
117
|
-
(it shows on white and black pages alike) and a soft shadow. */
|
|
118
|
-
.float { --_box-bg: var(--_bg); --_box-edge: 0 0 0 1px var(--_edge), 0 1px 2px rgba(0,0,0,.06), 0 8px 26px rgba(0,0,0,.14); }
|
|
119
|
-
/* Same top and right padding open or closed: the text and the arrow's column stay put while the box grows. */
|
|
120
|
-
.box.open { grid-template-areas: "text text" "line line" "who send"; row-gap: 8px; padding: 7px 7px 8px 14px; }
|
|
121
|
-
/* One line of text is exactly as tall as the send button (20 + 2 + 2 = 24), so the text and the button share one middle. */
|
|
122
|
-
.box textarea { grid-area: text; width: 100%; border: 0; background: none; padding: 2px 0; line-height: 20px; margin: 0; resize: none;
|
|
123
|
-
min-height: 0; max-height: 200px; overflow-y: auto; outline: none; display: block; }
|
|
124
|
-
.box textarea::placeholder, .who input::placeholder { color: var(--_muted); opacity: 1; }
|
|
125
|
-
.line { grid-area: line; height: 0; border-top: var(--_hair); margin: 0 -7px 0 -14px; display: none; }
|
|
126
|
-
.who { grid-area: who; display: none; align-items: baseline; gap: 4px; min-width: 0; font-size: 13px; color: var(--_muted); letter-spacing: -.006em; }
|
|
127
|
-
.who * { font-size: 13px; letter-spacing: -.006em; }
|
|
128
|
-
.who span { color: var(--_muted); }
|
|
129
|
-
.who input { flex: 1; min-width: 0; border: 0; background: none; padding: 0; margin: 0; outline: none; color: var(--_muted); text-overflow: ellipsis; }
|
|
130
|
-
.who input:focus { color: var(--_fg); }
|
|
131
|
-
.box.open .line { display: block; animation: lab-fade .16s ease-out; }
|
|
132
|
-
.box.open .who { display: flex; animation: lab-fade .16s ease-out; }
|
|
133
|
-
/* One line once your name is known: text, a quiet "as <name>" (still editable) and the arrow, side by side.
|
|
134
|
-
The text grows upward; the name and arrow stay on its last line. Only a first comment, with no name yet, opens
|
|
135
|
-
the second row to ask for it. */
|
|
136
|
-
.box.one, .box.one.open { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "text who send"; align-items: end; row-gap: 0; padding: 7px 7px 7px 14px; }
|
|
137
|
-
.box.one .line { display: none !important; }
|
|
138
|
-
.box.one .who { align-self: end; line-height: 20px; padding-bottom: 2px; max-width: 40%; } /* the text's last line box, so they share a line */
|
|
139
|
-
.box.one .who input { flex: none; field-sizing: content; min-width: 2ch; max-width: 9em; }
|
|
140
|
-
.send { grid-area: send; width: 24px; height: 24px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
|
|
141
|
-
background: var(--_hover); color: var(--_muted); display: grid; place-items: center; transition: background .15s, color .15s, transform .15s var(--_ease); }
|
|
142
|
-
.send.ready:hover { transform: scale(1.06); }
|
|
143
|
-
.send.ready:active { transform: scale(.94); }
|
|
144
|
-
.send.ready { background: var(--_accent); color: var(--_accent-fg); }
|
|
145
|
-
/* The send sign: a paper plane, one filled shape cut with clip-path (crisp at any size, no joins); it flies off on send. */
|
|
146
|
-
.send .arr { display: block; position: relative; left: -1px; width: 12px; height: 11px; background: currentColor; clip-path: polygon(0 42%, 100% 0, 66% 100%, 46% 60%); }
|
|
147
|
-
.send * { color: inherit; }
|
|
148
|
-
.error { color: #e5484d; font-size: 12px; padding: 6px 8px 0; letter-spacing: 0; }
|
|
149
|
-
.error:empty { display: none; }
|
|
150
|
-
.error.wait { color: var(--_muted); }
|
|
151
|
-
.bar { position: fixed; right: 16px; bottom: 16px; display: flex; gap: 8px; align-items: center; }
|
|
152
|
-
.bar button { border: 0; border-radius: var(--_radius); padding: 9px 14px; cursor: pointer; background: var(--_bg); color: var(--_fg);
|
|
153
|
-
box-shadow: var(--_shadow); font-size: 13px; font-weight: 500; display: inline-flex; gap: 8px; align-items: center;
|
|
154
|
-
letter-spacing: -.006em; font-variant-numeric: tabular-nums; white-space: nowrap; transition: color .15s, transform .15s var(--_ease); }
|
|
155
|
-
.bar button:active { transform: scale(.97); }
|
|
156
|
-
/* The list and the chat: a header, a part that scrolls, and (the chat) a box at the bottom that doesn't. */
|
|
157
|
-
.list { position: fixed; right: 16px; bottom: 66px; width: min(340px, calc(100vw - 32px)); max-height: min(60vh, 460px); overflow: hidden;
|
|
158
|
-
display: flex; flex-direction: column; background: var(--_bg); color: var(--_fg); border-radius: var(--_radius); box-shadow: var(--_shadow); font-size: 13px; letter-spacing: -.006em; }
|
|
159
|
-
.list .tabs { display: flex; flex-wrap: wrap; gap: 2px; flex: none; padding: 12px 8px 6px; }
|
|
160
|
-
.list .items, .msgs { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
|
|
161
|
-
.list .items { padding: 0 6px 6px; }
|
|
162
|
-
.list .tabs button { border: 0; border-radius: var(--_r-s); padding: 4px 8px; white-space: nowrap; background: none; color: var(--_muted); cursor: pointer; font: inherit; }
|
|
163
|
-
.list .tabs button.on { background: var(--_fg); color: var(--_bg); }
|
|
164
|
-
.list .tabs .hold { margin-left: auto; }
|
|
165
|
-
.list .it { display: block; width: 100%; text-align: left; border: 0; background: none; color: inherit; padding: 7px 8px; border-radius: var(--_r-s); cursor: pointer; font: inherit; }
|
|
166
|
-
.list .it:hover, .list .it.cur { background: var(--_hover); }
|
|
167
|
-
.list .it { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* one line per pin; the rest is in its thread */
|
|
168
|
-
.list .it span, .list .none { color: var(--_muted); }
|
|
169
|
-
.list .it .tag { display: inline-block; padding: 0 7px; border-radius: var(--_r-s); background: var(--_accent); color: var(--_accent-fg);
|
|
170
|
-
font-size: 12px; letter-spacing: 0; font-weight: 600; line-height: 18px; vertical-align: 1px; white-space: nowrap; }
|
|
171
|
-
.list .none { padding: 8px; }
|
|
172
|
-
/* Thin scrollbars inside the dialogs (chat, threads, the list), like macOS overlay ones, on a clear track. */
|
|
173
|
-
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--_fg) 24%, transparent) transparent; }
|
|
174
|
-
@supports not (scrollbar-width: thin) {
|
|
175
|
-
::-webkit-scrollbar { width: 6px; height: 6px; }
|
|
176
|
-
::-webkit-scrollbar-track { background: transparent; }
|
|
177
|
-
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--_fg) 24%, transparent); border-radius: 999px; }
|
|
178
|
-
}
|
|
179
|
-
.list .group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--_muted); padding: 10px 8px 2px; }
|
|
180
|
-
.pin.held { border: 1.5px dashed var(--_muted); opacity: .85; }
|
|
181
|
-
/* Close: a round, quiet button with a drawn cross (not the \u2715 character), darker on hover. */
|
|
182
|
-
.list .tabs .show-done { color: var(--_muted); }
|
|
183
|
-
.chatwin .tabs b { display: none; } /* no "chat" title: the window speaks for itself */
|
|
184
|
-
.list .tabs .x { margin-left: auto; flex: none; width: 26px; height: 26px; padding: 0; border-radius: 50%; display: grid; place-items: center;
|
|
185
|
-
font-size: 0; color: var(--_muted); background: transparent; }
|
|
186
|
-
/* The cross is drawn with CSS: two thin bars, no picture. */
|
|
187
|
-
.list .tabs .x::before, .list .tabs .x::after { content: ''; grid-area: 1 / 1; width: 12px; height: 1.6px; border-radius: 1px; background: currentColor; transform: rotate(45deg); }
|
|
188
|
-
.list .tabs .x::after { transform: rotate(-45deg); }
|
|
189
|
-
.list .tabs .x:hover { color: var(--_fg); } /* hover: the cross darkens, nothing drawn behind it */
|
|
190
|
-
.list .tabs .x:focus-visible { outline: 2px solid var(--_accent); outline-offset: 1px; }
|
|
191
|
-
.chatwin .chat { flex: none; background: var(--_bg); padding: 6px 6px 8px; }
|
|
192
|
-
.chatwin .replying { flex: none; }
|
|
193
|
-
.chatwin .tabs b { padding: 4px 8px; font-weight: 600; margin-right: auto; }
|
|
194
|
-
.msgs { display: flex; flex-direction: column; gap: 8px; padding: 4px 10px 8px; overflow-x: hidden; }
|
|
195
|
-
.msgs > :first-child { margin-top: auto; } /* a short conversation sits by the box, like a chat */
|
|
196
|
-
/* Something just sent eases in; the arrow flies off and comes back. */
|
|
197
|
-
.fresh { animation: lab-rise .2s var(--_ease); }
|
|
198
|
-
.send.sent .arr { animation: lab-fly .32s var(--_ease); }
|
|
199
|
-
@keyframes lab-rise { from { opacity: 0; transform: translateY(6px); } }
|
|
200
|
-
@keyframes lab-fly { 45% { transform: translate(9px, -9px) scale(.6); opacity: 0; } 46% { transform: translate(-7px, 7px) scale(.6); opacity: 0; } }
|
|
201
|
-
.msg { max-width: 85%; padding: 7px 10px; border-radius: var(--_radius); background: var(--_soft); align-self: flex-start; }
|
|
202
|
-
.msg.mine { align-self: flex-end; background: color-mix(in srgb, rgb(52, 199, 89) 15%, var(--_bg)); color: var(--_fg); } /* yours: soft green, dark text */
|
|
203
|
-
.msg b { display: block; font-size: 12px; letter-spacing: 0; font-weight: 600; opacity: .7; margin-bottom: 1px; }
|
|
204
|
-
/* Each agent's messages in its own brand colour: the name in it, the bubble a soft wash of it (Leo, 15 Nov). */
|
|
205
|
-
.msg[data-agent=claude] { --_brand: #d97757; } .msg[data-agent=codex] { --_brand: #10a37f; } .msg[data-agent=cursor] { --_brand: #8a8a8e; }
|
|
206
|
-
.msg[data-agent=gemini] { --_brand: #4285f4; } .msg[data-agent=copilot] { --_brand: #8957e5; } .msg[data-agent=amp] { --_brand: #f34e3f; }
|
|
207
|
-
.msg[data-agent=opencode] { --_brand: #8a8a8e; }
|
|
208
|
-
.msg[data-agent] { background: color-mix(in srgb, var(--_brand) 11%, var(--_bg)); }
|
|
209
|
-
.msg[data-agent] > b { color: var(--_brand); opacity: 1; }
|
|
210
|
-
.msg.mine b { display: none; }
|
|
211
|
-
.msg { position: relative; } .mark { font-weight: 400; font-size: 11px; letter-spacing: .006em; color: var(--_muted); margin-left: 6px; white-space: nowrap; } .mark.done { color: rgb(36, 160, 70); font-weight: 600; font-size: 12px; letter-spacing: 0; } /* a small green tick, as the ticks on messages */
|
|
212
|
-
.msg .quote { display: block; border-left: 2px solid rgb(52, 199, 89); padding: 1px 0 1px 8px; margin: 3px 0 5px; font-size: 12px; letter-spacing: 0; line-height: 1.35;
|
|
213
|
-
color: var(--_muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
|
|
214
|
-
.msg .quote b { display: block; font-size: 12px; letter-spacing: 0; font-weight: 600; color: rgb(36, 160, 70); opacity: 1; margin: 0; } .mine .mark { color: inherit; opacity: .7; } a.link { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; } .msg.to { box-shadow: 0 0 0 2px var(--_accent); }
|
|
215
|
-
.msg .p { display: block; white-space: pre-wrap; overflow-wrap: anywhere; text-wrap: pretty; } /* no lone last word */ .msg .p.gap { margin-top: 6px; }
|
|
216
|
-
.msg .p.li { padding-left: 14px; text-indent: -14px; } .msg .p.li .mk { display: inline-block; width: 14px; text-indent: 0; opacity: .6; }
|
|
217
|
-
.msg i { display: block; font-style: normal; font-size: 12px; letter-spacing: 0; opacity: .7; margin-bottom: 1px; }
|
|
218
|
-
.msg b, .msg i { color: inherit; }
|
|
219
|
-
.msg .stamp { text-indent: 0; color: inherit; position: absolute; right: 10px; bottom: 6px; font-size: 10px; letter-spacing: .012em; line-height: 1; opacity: .55; font-variant-numeric: tabular-nums; }
|
|
220
|
-
.msg .stamp-room { text-indent: 0; visibility: hidden; display: inline-block; margin-left: 10px; font-size: 10px; letter-spacing: .012em; line-height: 1; height: 10px; white-space: nowrap; }
|
|
221
|
-
.msg .stamp-room * { font-size: inherit; }
|
|
222
|
-
.msg .tick { color: inherit; margin-left: 4px; letter-spacing: -.34em; font-size: 10px; } /* \u2713 drawn as tall as the time's digits */
|
|
223
|
-
.msg .tick.got { font-weight: 600; }
|
|
224
|
-
/* Your message the agent is on: the pin's turning green ring, small, by its time; answered: a green \u2713. */
|
|
225
|
-
.msg .stamp:is(.busy, .ans) { opacity: 1; } .msg .stamp:is(.busy, .ans) .tm { opacity: .55; }
|
|
226
|
-
.msg .stamp .tm { font-size: inherit; line-height: inherit; color: inherit; } /* every element gets 14 px by default: the time keeps the stamp's 10 */
|
|
227
|
-
.msg :is(.stamp, .stamp-room) .ring { position: relative; display: inline-block; width: 9px; height: 9px; margin-left: 5px; vertical-align: -1px; border-radius: 50%; overflow: hidden;
|
|
228
|
-
-webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.6px), #000 calc(100% - 1.5px));
|
|
229
|
-
mask: radial-gradient(farthest-side, transparent calc(100% - 1.6px), #000 calc(100% - 1.5px)); }
|
|
230
|
-
.msg .stamp.ans .tick { color: rgb(36, 160, 70); letter-spacing: 0; font-weight: 600; }
|
|
231
|
-
/* One slot for the mark, whatever it is (\u2713, \u2713\u2713, the turning ring, the green \u2713): 12 px wide after a 4 px gap, so the
|
|
232
|
-
time doesn't shift when one turns into another (Leo, 15 Nov: it flicked as \u2713 became the ring). */
|
|
233
|
-
.msg :is(.stamp, .stamp-room) .tick { display: inline-block; width: 12px; height: 10px; line-height: 10px; text-align: center; margin-left: 4px; vertical-align: top; }
|
|
234
|
-
.msg :is(.stamp, .stamp-room) .ring { margin: .5px 1.5px 0 5.5px; vertical-align: top; } /* the same 10 px tall as a \u2713, so the bubble keeps its height */
|
|
235
|
-
.msg .stamp { height: 10px; }
|
|
236
|
-
.replying { display: flex; gap: 6px; align-items: center; font-size: 12px; letter-spacing: 0; color: var(--_muted); padding: 2px 6px; }
|
|
237
|
-
.replying button { border: 0; background: none; color: inherit; cursor: pointer; margin-left: auto; font: inherit; }
|
|
238
|
-
.bar button * { color: inherit; font-weight: inherit; }
|
|
239
|
-
.bar .toggle:not(.secondary)::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--_accent); }
|
|
240
|
-
.bar button.secondary { color: var(--_muted); }
|
|
241
|
-
.bar button.secondary.has-new { color: var(--_fg); font-weight: 600; }
|
|
242
|
-
.bar button.go-btn.on { color: #fff; background: rgb(36, 160, 70); }
|
|
243
|
-
.bar .new-prev, .bar .new-next { padding: 9px 11px; font-size: 15px; letter-spacing: -.016em; line-height: 1; color: var(--_fg); }
|
|
244
|
-
.bar .list-btn, .bar .done-btn { font-variant-numeric: tabular-nums; min-width: 4.6em; justify-content: center; }
|
|
245
|
-
.bar button.quiet { opacity: .45; cursor: default; box-shadow: var(--_shadow); }
|
|
246
|
-
.bar button.go-btn.on kbd { color: #fff !important; }
|
|
247
|
-
.newline { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0; font-weight: 500; color: var(--_muted); }
|
|
248
|
-
.newline::before, .newline::after { content: ''; flex: 1; height: 1px; background: currentColor; opacity: .35; }
|
|
249
|
-
/* The left side: who's listening, then copy link; the right side is the bar. */
|
|
250
|
-
.left { position: fixed; left: 16px; bottom: 16px; display: flex; gap: 8px; align-items: center; }
|
|
251
|
-
.left .copy-all { border: 0; border-radius: var(--_radius); padding: 9px 14px; cursor: pointer; background: var(--_bg); color: var(--_muted);
|
|
252
|
-
box-shadow: var(--_shadow); font: inherit; font-size: 13px; letter-spacing: -.006em; font-weight: 500; white-space: nowrap; }
|
|
253
|
-
.listener { display: inline-flex; gap: 6px; align-items: center; padding: 9px 14px; border-radius: var(--_radius);
|
|
254
|
-
background: var(--_bg); color: var(--_fg); box-shadow: var(--_shadow); font-size: 13px; letter-spacing: -.006em; text-decoration: none; white-space: nowrap; }
|
|
255
|
-
.listener::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--_accent); margin-right: 2px; }
|
|
256
|
-
.listener span { color: var(--_muted); }
|
|
257
|
-
.listener.idle::before { background: var(--_muted); opacity: .5; }
|
|
258
|
-
/* Working: the dot turns green and sends out a soft ring, like a "live" light. */
|
|
259
|
-
/* The ping is a copy of the dot that grows and fades (transform and opacity only), so only it is redrawn. A growing
|
|
260
|
-
shadow repainted the whole layer with every pin on it, each frame: ~170 ms a second on a page with 40 pins. */
|
|
261
|
-
.listener { position: relative; }
|
|
262
|
-
.listener.working::before { background: rgb(36, 160, 70); }
|
|
263
|
-
.listener.working::after { content: ''; position: absolute; left: 14px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px;
|
|
264
|
-
border-radius: 50%; corner-shape: round; background: rgb(52, 199, 89); pointer-events: none; will-change: transform, opacity; animation: lab-ping 1.6s cubic-bezier(0, 0, .2, 1) infinite; }
|
|
265
|
-
@keyframes lab-ping { 0% { transform: scale(1); opacity: .55; } 80%, 100% { transform: scale(2.7); opacity: 0; } }
|
|
266
|
-
.listener { cursor: default; } /* a plain arrow, also where a tap copies the resume command */
|
|
267
|
-
/* Letter spacing follows the size, as Apple's SF text does: looser below 12 px, tighter above (11 +.006em,
|
|
268
|
-
13 \u2212.006, 15 \u2212.016, 17 \u2212.025). Uppercase labels and the \u2713\u2713 overlap keep their own. */
|
|
269
|
-
/* Keys whisper: a small grey letter, no chip; a bit clearer while the pointer is on the bar. */
|
|
270
|
-
kbd { font-size: 10px; letter-spacing: .012em; line-height: 17px; min-width: 0; padding: 0 1px; text-align: center; background: none;
|
|
271
|
-
color: var(--_muted) !important; opacity: .45; transition: opacity .15s; }
|
|
272
|
-
.bar:hover kbd { opacity: .75; }
|
|
273
|
-
.bar button kbd { margin-left: -4px; } /* the hint sits close to its word: chat (c) */
|
|
274
|
-
.bar button.go-btn kbd { font-size: inherit; line-height: inherit; opacity: 1; margin-left: 0; } /* (1/2/3) reads like (c)hat and ne(w) */
|
|
275
|
-
/* One bar of segments, a hairline between them; the less used ones in the \u22EF menu above it (phones too: same bar, bigger to tap). */
|
|
276
|
-
@media all {
|
|
277
|
-
.bar { gap: 0; background: var(--_bg); border-radius: var(--_radius); box-shadow: var(--_shadow); overflow: hidden; }
|
|
278
|
-
.bar > button { box-shadow: inset .5px 0 0 var(--_line); border-radius: 0; background: none; padding: 8px 12px; gap: 6px; }
|
|
279
|
-
.bar > button.first { box-shadow: none; }
|
|
280
|
-
.bar > button:not(:disabled):hover { background: var(--_hover); }
|
|
281
|
-
.bar > button:active { transform: none; background: var(--_hover); }
|
|
282
|
-
.bar > button.quiet { opacity: 1; box-shadow: inset .5px 0 0 var(--_line); color: var(--_muted); }
|
|
283
|
-
.bar > button.quiet.first { box-shadow: none; }
|
|
284
|
-
.bar .list-btn, .bar .done-btn { min-width: 0; }
|
|
285
|
-
.bar .mn { color: var(--_muted); font-weight: 400; }
|
|
286
|
-
/* Words stay grey (as the bar's buttons were); the count is the one thing in the text colour: a plain number. */
|
|
287
|
-
.bar > button.secondary, .bar > button.secondary.has-new { color: var(--_muted); font-weight: 500; }
|
|
288
|
-
.bar .chat-btn, .bar .list-btn { align-items: baseline; } /* the number sits on the word's line */
|
|
289
|
-
.bar .cnt { font-size: 12px; letter-spacing: 0; font-weight: 400; line-height: 16px; text-align: center; background: none; color: var(--_fg); font-variant-numeric: tabular-nums; }
|
|
290
|
-
.bar .cnt.zero { color: var(--_muted); }
|
|
291
|
-
.bar button.go-btn.on { background: none; color: var(--_fg); }
|
|
292
|
-
.bar button.go-btn.on kbd { color: var(--_muted) !important; }
|
|
293
|
-
.gp { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 11px 11px 11px 2px; font-size: 10px; letter-spacing: .012em; font-weight: 600;
|
|
294
|
-
color: rgb(36, 160, 70); box-shadow: inset 0 0 0 1.25px rgb(36, 160, 70); transition: background-color .2s, color .2s; }
|
|
295
|
-
.go-btn.on .gp { background: rgb(36, 160, 70); color: #fff; }
|
|
296
|
-
/* 1, comment: your own pin, small: your initial in a white pin with the pins' edge. */
|
|
297
|
-
.go-btn:not(.on):not(.cursor) .gp { color: var(--_fg); background: var(--_bg); box-shadow: inset 0 0 0 1px var(--_edge); font-size: 10px; letter-spacing: .012em; }
|
|
298
|
-
/* 3, cursor: the switch is the same pin in grey, saying "off" (regular, a touch bigger than go's bold). */
|
|
299
|
-
.go-btn.cursor .gp { box-shadow: inset 0 0 0 1.25px var(--_muted); color: transparent; position: relative; }
|
|
300
|
-
.go-btn.cursor .gp::after { content: 'off'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--_muted);
|
|
301
|
-
font-size: 10px; font-weight: 400; letter-spacing: .012em; }
|
|
302
|
-
.more { font-size: 15px !important; letter-spacing: .05em; }
|
|
303
|
-
.more-menu { position: fixed; right: 16px; bottom: 60px; display: grid; min-width: 180px; padding: 4px; background: var(--_bg);
|
|
304
|
-
border-radius: var(--_radius); box-shadow: var(--_shadow); animation: lab-fade .12s ease-out; }
|
|
305
|
-
.more-menu[hidden] { display: none; }
|
|
306
|
-
.more-menu button { border: 0; background: none; text-align: left; font: inherit; font-size: 13px; letter-spacing: -.006em; color: var(--_fg); padding: 7px 10px;
|
|
307
|
-
border-radius: var(--_r-s); cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; white-space: nowrap; }
|
|
308
|
-
.more-menu button:hover:not(:disabled) { background: var(--_hover); }
|
|
309
|
-
.more-menu button:disabled { color: var(--_muted); cursor: default; }
|
|
310
|
-
.more-menu button[hidden] { display: none; }
|
|
311
|
-
.more-menu kbd { margin: 0; }
|
|
312
|
-
}
|
|
313
|
-
kbd::before { content: '('; } kbd::after { content: ')'; } /* read as a hint: chat (c) */
|
|
314
|
-
.hint { position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); background: var(--_bg); color: var(--_muted);
|
|
315
|
-
box-shadow: var(--_shadow); padding: 8px 14px; border-radius: var(--_radius); font-size: 13px; pointer-events: none; white-space: nowrap;
|
|
316
|
-
letter-spacing: -.006em; animation: lab-fade .2s ease-out; }
|
|
317
|
-
/* 16px fields keep iOS from zooming the page when one is focused. */
|
|
318
|
-
@media (pointer: coarse) { .box textarea, .who input { font-size: 16px; letter-spacing: -.019em; } kbd { display: none; }
|
|
319
|
-
.box textarea { line-height: 22px; padding: 7px 0; } /* phones: 22 + 7 + 7 = 36, the send button's size */
|
|
320
|
-
.box.one .who { line-height: 22px; padding-bottom: 7px; } }
|
|
321
|
-
@keyframes lab-fade { from { opacity: 0; } }
|
|
322
|
-
/* Movement only: a page in the background can stall an animation, and a card stalled mid-fade showed the page through it. */
|
|
323
|
-
@keyframes lab-in { from { transform: translateY(4px) scale(.98); } }
|
|
324
|
-
@keyframes lab-sheet-in { from { transform: translateY(100%); } }
|
|
325
|
-
@keyframes lab-sheet-out { to { transform: translateY(100%); } }
|
|
326
|
-
@keyframes lab-out { to { opacity: 0; transform: translateY(2px) scale(.985); } }
|
|
327
|
-
/* Continuous (Apple-style) corners where the browser draws them; plain rounding elsewhere. */
|
|
328
|
-
/* Apple's continuous corners (squircle) where the browser draws them (Safari 26, Chrome): the same three sizes, a
|
|
329
|
-
smooth curve instead of a circle arc (a squircle needs about 1.8 times the radius to look the same size).
|
|
330
|
-
Circles and the pin's teardrop stay as they are. */
|
|
331
|
-
@supports (corner-shape: squircle) {
|
|
332
|
-
:host { --_radius: calc(var(--lab-radius, 12px) * 1.8); --_r-s: 11px; }
|
|
333
|
-
*, *::before, *::after { corner-shape: squircle; }
|
|
334
|
-
.pin, .pin .ring, .pin.new::after, .dot, .send, .list .tabs .x, .bar .toggle:not(.secondary)::before,
|
|
335
|
-
.listener::before, .list-btn[data-agent]::before, .chat-btn[data-agent]::before, .msg :is(.stamp, .stamp-room) .ring, .gp { corner-shape: round; } /* circles stay circles */
|
|
336
|
-
}
|
|
337
|
-
@keyframes lab-pin { from { transform: scale(1.1); } }
|
|
338
|
-
@keyframes lab-halo { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--_fg) 12%, transparent); }
|
|
339
|
-
to { box-shadow: 0 0 0 16px color-mix(in srgb, var(--_fg) 0%, transparent); } }
|
|
340
|
-
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
|
|
341
|
-
@media (max-width: 480px) { kbd { display: none; } }
|
|
342
|
-
.handle { display: none; }
|
|
343
|
-
/* Phones: a thread or a new comment opens as a sheet from the bottom, full width, instead of beside the pin. */
|
|
344
|
-
@media (pointer: coarse) and (max-width: 560px), (pointer: coarse) and (max-height: 500px) { /* phones, upright or on their side */
|
|
345
|
-
/* Sheets fit what the screen shows (--lab-vh, the visible height, and --lab-kb, the keyboard over the page's
|
|
346
|
-
bottom, are kept up to date from visualViewport); their bottom part is solid down past the screen's edge,
|
|
347
|
-
behind the home bar, the keyboard and Safari's toolbar, so nothing of the page shows below the box. */
|
|
348
|
-
:host { --_safe: env(safe-area-inset-bottom, 0px); --_kb: var(--lab-kb, 0px);
|
|
349
|
-
--_sheet-max: calc(min(72dvh, var(--lab-vh, 100dvh) - 24px) + var(--_kb)); --_pb: calc(12px + var(--_safe) + var(--_kb)); }
|
|
350
|
-
:host([data-kb]) { --_safe: 0px; --_kb: 0px; --_pb: 10px; }
|
|
351
|
-
/* Keyboard up: a thread, the list and the chat fill exactly what the screen shows, like a native composer, so iOS
|
|
352
|
-
panning the page can't push it up and nothing of the page shows above or below it. */
|
|
353
|
-
:host([data-kb]) :is(.card, .list:not([hidden])) { top: var(--lab-top, 0px) !important; bottom: auto !important;
|
|
354
|
-
height: var(--lab-vh, 100dvh) !important; max-height: none !important; border-radius: 0; }
|
|
355
|
-
/* A new comment stays small, just above the keyboard, with the page (dimmed) above it: you see what you comment on. */
|
|
356
|
-
:host([data-kb]) .float { top: auto !important; bottom: var(--lab-kb, 0px) !important; height: auto !important; border-radius: var(--_radius) var(--_radius) 0 0; }
|
|
357
|
-
.card, .float { position: fixed; left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-width: none;
|
|
358
|
-
max-height: var(--_sheet-max); display: flex; flex-direction: column; border-radius: var(--_radius) var(--_radius) 0 0; padding: 8px 0 0; z-index: 3; }
|
|
359
|
-
.card::after, .float::after, .list::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 100vh; background: var(--_bg); }
|
|
360
|
-
/* The same 12 px sides as the chat's, so a thread's reply box sits exactly where the chat's message box does. */
|
|
361
|
-
.card > .body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 4px; margin-right: 0; }
|
|
362
|
-
/* A thread keeps one height, as the chat does (Leo, 15 Nov: it jumped while the chat stays put): the sheet's full
|
|
363
|
-
height whatever its length, a short thread sitting by the reply box, so new replies and the keyboard never
|
|
364
|
-
move its top. */
|
|
365
|
-
.card { height: var(--_sheet-max); }
|
|
366
|
-
.card > .foot, .float > .composer { flex: none; padding: 0 12px var(--_pb); }
|
|
367
|
-
.card > .foot { margin-top: 0; padding-top: 6px; }
|
|
368
|
-
.card .composer { margin-top: 0; }
|
|
369
|
-
.card > .nav { flex: none; margin: -6px 0 0; padding: 0 12px; gap: 20px; }
|
|
370
|
-
.card .nav .btn { font-size: 14px; letter-spacing: -.011em; padding: 0 2px; min-height: 44px; display: inline-flex; align-items: center; } /* 44 px tall to tap (iOS 44 pt) */
|
|
371
|
-
.card .nav { gap: 16px; }
|
|
372
|
-
.card .nav { flex-wrap: wrap; row-gap: 0; } /* too narrow for one row: reopen / delete drop under, on the right */
|
|
373
|
-
.card .nav .acts { margin: 0 0 0 auto; gap: 20px; }
|
|
374
|
-
.box.one .who span { font-size: 16px; letter-spacing: -.019em; } /* "as" the size of the name beside it */ /* reopen / delete share the prev / next row, on the right */
|
|
375
|
-
.card .nav .acts button.btn { font-size: 14px; letter-spacing: -.011em; }
|
|
376
|
-
.float { background: var(--_bg); box-shadow: var(--_shadow); }
|
|
377
|
-
/* The grab handle: the sheet's top strip, where a drag down moves it. The header of the list and the chat does the same. */
|
|
378
|
-
/* Reaching 60 px above the sheet's edge over the dimmed page (Leo, 15 Nov: "the whole top and a bit above", then
|
|
379
|
-
"do more"); the bar and the layout stay as they were. The chat's and the list's header reach up the same way. */
|
|
380
|
-
.handle { display: block; flex: none; height: 86px; margin-top: -68px; touch-action: none; position: relative;
|
|
381
|
-
background: linear-gradient(color-mix(in srgb, var(--_fg) 18%, transparent) 0 0) center 68px / 36px 4px no-repeat; }
|
|
382
|
-
.list .tabs { position: relative; }
|
|
383
|
-
.list .tabs::before { content: ''; position: absolute; left: 0; right: 0; top: -60px; height: 60px; }
|
|
384
|
-
.list .tabs { touch-action: pan-x; }
|
|
385
|
-
.chatwin .tabs { touch-action: none; }
|
|
386
|
-
.list .items, .msgs, .card > .body { touch-action: pan-y; }
|
|
387
|
-
.list .tabs .x { display: none; } /* the handle, a swipe down or a tap on the dimmed page closes it */
|
|
388
|
-
|
|
389
|
-
:host([data-sheet]) :is(.hint, .listener, .left) { visibility: hidden; }
|
|
390
|
-
/* The bar steps down under the screen's edge while a sheet is open and comes back as the sheet goes: --lab-p is
|
|
391
|
-
how far the sheet is on its way out (0 open, 1 gone), set while a finger drags it and while it slides away,
|
|
392
|
-
so the bar rises with it, in step, instead of after it (Leo, 15 Nov). */
|
|
393
|
-
.bar { transition: transform .34s cubic-bezier(.32, .72, 0, 1), opacity .2s; }
|
|
394
|
-
:host([data-sheet]) .bar { transform: translateY(calc((100% + 16px + env(safe-area-inset-bottom, 0px)) * (1 - var(--lab-p, 0))));
|
|
395
|
-
opacity: var(--lab-p, 0); pointer-events: none;
|
|
396
|
-
transition: transform .24s cubic-bezier(.4, 0, 1, 1), opacity .2s .04s; }
|
|
397
|
-
:host([data-sheet]) .bar button { pointer-events: none; }
|
|
398
|
-
/* A sheet stands apart from the page: the page dims behind it (a tap there closes it), and scrolling inside a
|
|
399
|
-
sheet never scrolls the page. */
|
|
400
|
-
:host([data-sheet]) .scrim { display: block; animation: lab-fade .22s ease-out; }
|
|
401
|
-
.card.in, .float.in, .list:not([hidden]) { animation: lab-sheet-in .28s cubic-bezier(.2, .8, .2, 1); }
|
|
402
|
-
.card.out, .float.out { animation: lab-sheet-out .22s cubic-bezier(.4, 0, 1, 1) forwards; }
|
|
403
|
-
.list { left: 0; right: 0; bottom: 0 !important; width: auto; max-height: var(--_sheet-max); overflow: visible; border-radius: var(--_radius) var(--_radius) 0 0;
|
|
404
|
-
font-size: 15px; letter-spacing: -.016em; z-index: 3; }
|
|
405
|
-
/* The chat keeps one height (new messages don't move its top) and opens at the newest. */
|
|
406
|
-
.chatwin { height: var(--_sheet-max); transition: height .38s cubic-bezier(.32, .72, 0, 1); }
|
|
407
|
-
/* Pulled up: the chat takes the whole screen, below the status bar (iOS large / Android expanded). */
|
|
408
|
-
.chatwin.full, .card.full { height: calc(var(--lab-vh, 100dvh) - env(safe-area-inset-top, 0px) - 10px + var(--_kb)); max-height: none; }
|
|
409
|
-
.card { transition: height .38s cubic-bezier(.32, .72, 0, 1); } /* a comment pulls up to full height as the chat does */
|
|
410
|
-
/* The header is the sheet's top edge, grab handle drawn on it; the list scrolls below it, never under or above it. */
|
|
411
|
-
.list .tabs { flex-wrap: nowrap; overflow-x: auto; padding: 18px 12px 8px; border-radius: var(--_radius) var(--_radius) 0 0;
|
|
412
|
-
background: linear-gradient(color-mix(in srgb, var(--_fg) 18%, transparent) 0 0) center 8px / 36px 4px no-repeat, var(--_bg); }
|
|
413
|
-
.list .items { padding: 0 12px calc(10px + var(--_safe)); }
|
|
414
|
-
.chatwin .msgs { padding: 4px 12px 8px; }
|
|
415
|
-
.chatwin .tabs { padding: 18px 12px 0; } /* just the grab strip, as tall as a thread's */
|
|
416
|
-
.chatwin .chat { padding: 6px 12px var(--_pb); }
|
|
417
|
-
/* Glass reply boxes (Leo, 15 Nov; iOS 26's look, Android too): the messages scroll on under the box and show
|
|
418
|
-
through it, blurred. Only the box's own strip overlaps; the new / resolve / delete row stays on the sheet. */
|
|
419
|
-
.chatwin .msgs { margin-bottom: calc(-56px - var(--_pb)); padding-bottom: calc(64px + var(--_pb)); }
|
|
420
|
-
.card > .body { margin-bottom: calc(-56px - var(--_pb)); padding-bottom: calc(64px + var(--_pb)); }
|
|
421
|
-
/* \u2026and fade out behind the box (iOS's scroll edge): from 4 px above its top to 12% at its bottom (Leo, 15 Nov:
|
|
422
|
-
"behind input bottom", "a bit more", "less, it's just black", then "more, darker there"). */
|
|
423
|
-
.chatwin .msgs { -webkit-mask-image: linear-gradient(#000 calc(100% - 60px - var(--_pb)), rgba(0,0,0,.12) calc(100% - var(--_pb)));
|
|
424
|
-
mask-image: linear-gradient(#000 calc(100% - 60px - var(--_pb)), rgba(0,0,0,.12) calc(100% - var(--_pb))); }
|
|
425
|
-
.card > .body { -webkit-mask-image: linear-gradient(#000 calc(100% - 60px - var(--_pb)), rgba(0,0,0,.12) calc(100% - var(--_pb)));
|
|
426
|
-
mask-image: linear-gradient(#000 calc(100% - 60px - var(--_pb)), rgba(0,0,0,.12) calc(100% - var(--_pb))); }
|
|
427
|
-
.chatwin .chat, .card > .foot { position: relative; z-index: 1; background: none; }
|
|
428
|
-
:host { --_box-bg: color-mix(in srgb, var(--_bg) 72%, transparent);
|
|
429
|
-
--_box-edge: inset 0 0 0 .5px color-mix(in srgb, var(--_fg) 16%, transparent), 0 4px 18px rgba(0, 0, 0, .08); }
|
|
430
|
-
.float { --_box-bg: inherit; --_box-edge: inherit; } /* phones: the new comment sheet's box is the same glass */
|
|
431
|
-
.box { -webkit-backdrop-filter: blur(18px) saturate(1.8); backdrop-filter: blur(18px) saturate(1.8); }
|
|
432
|
-
.list .it { padding: 11px 8px; }
|
|
433
|
-
/* Pins a size smaller (22 px), the tail still on the spot: 28 px covered words on a phone. Moved ones smaller still. */
|
|
434
|
-
.pin { scale: .8; }
|
|
435
|
-
/* Messages at 15 px (13 on computers): closer to the phone's own 17 px text, threads still short. */
|
|
436
|
-
.msg .p { font-size: 15px; letter-spacing: -.016em; line-height: 21px; }
|
|
437
|
-
.msg .quote { font-size: 14px; letter-spacing: -.011em; }
|
|
438
|
-
.msg b, .msg .quote b { font-size: 12px; letter-spacing: 0; }
|
|
439
|
-
.pin.moved { scale: .64; }
|
|
440
|
-
/* The same one bar as on computers, each segment 44 px tall to tap (iOS 44 pt); the menu opens above it. */
|
|
441
|
-
.bar > button { padding: 12px 14px; min-height: 44px; }
|
|
442
|
-
.more-menu { bottom: 72px; min-width: 200px; }
|
|
443
|
-
.more-menu button { padding: 11px 12px; font-size: 15px; letter-spacing: -.016em; }
|
|
444
|
-
}
|
|
445
|
-
/* Reaches past the screen's edges, under Safari's status bar and toolbar, so the page is dimmed everywhere. */
|
|
446
|
-
.scrim { cursor: pointer; display: none; position: fixed; inset: -50vh 0; background: rgba(0, 0, 0, .4); z-index: 2; touch-action: none; }
|
|
447
|
-
.sel-chip { position: fixed; transform: translateX(-50%); border: 0; border-radius: var(--_radius); padding: 8px 14px; background: var(--_fg);
|
|
448
|
-
color: var(--_bg); font: 500 14px/1 var(--_font, inherit); box-shadow: var(--_shadow); z-index: 4; }
|
|
449
|
-
/* Phones: the listening label is a light in the "list" button (steady: listening, blinking: working, grey:
|
|
450
|
-
nobody), the bar goes back to the bottom, and the send button is big enough for a thumb. */
|
|
451
|
-
@media (pointer: coarse) and (max-width: 560px), (pointer: coarse) and (max-height: 500px) { /* phones, upright or on their side */
|
|
452
|
-
.listener { display: none !important; }
|
|
453
|
-
.bar { bottom: 16px !important; }
|
|
454
|
-
.hint { bottom: 64px !important; }
|
|
455
|
-
.chat-btn[data-agent]::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--_accent); }
|
|
456
|
-
.chat-btn[data-agent=away]::before { background: var(--_muted); opacity: .5; }
|
|
457
|
-
.chat-btn[data-agent=working]::before { background: rgb(36, 160, 70); }
|
|
458
|
-
.chat-btn[data-agent] { position: relative; }
|
|
459
|
-
.chat-btn[data-agent=working]::after { content: ''; position: absolute; left: 14px; top: 50%; width: 8px; height: 8px; margin-top: -4px;
|
|
460
|
-
border-radius: 50%; corner-shape: round; background: rgb(52, 199, 89); pointer-events: none; will-change: transform, opacity; animation: lab-ping 1.6s cubic-bezier(0, 0, .2, 1) infinite; }
|
|
461
|
-
.send { width: 36px; height: 36px; }
|
|
462
|
-
.send .arr { width: 17px; height: 15px; margin: auto; }
|
|
463
|
-
}
|
|
464
|
-
/* Narrow screens: the buttons sit a row above the listening label, so neither covers the other. */
|
|
465
|
-
@media (max-width: 560px) { .bar { bottom: 64px; } .hint { bottom: 112px; } .list { bottom: 114px; } }
|
|
466
|
-
[hidden] { display: none !important; }
|
|
467
|
-
`;
|
|
468
|
-
|
|
469
|
-
// src/widget/anchoring.ts
|
|
470
|
-
var host;
|
|
471
|
-
var layer;
|
|
472
|
-
var el;
|
|
473
|
-
var store;
|
|
474
|
-
function bindAnchoring(deps) {
|
|
475
|
-
({ host, layer, el, store } = deps);
|
|
476
|
-
}
|
|
477
|
-
function selectorFor(node) {
|
|
478
|
-
const parts = [];
|
|
479
|
-
while (node && node.nodeType === 1 && node !== document.body && node !== document.documentElement) {
|
|
480
|
-
if (node.id && document.querySelectorAll(`#${CSS.escape(node.id)}`).length === 1) {
|
|
481
|
-
parts.unshift(`#${CSS.escape(node.id)}`);
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
484
|
-
const tag = node.localName;
|
|
485
|
-
let index = 1;
|
|
486
|
-
for (let sib = node.previousElementSibling; sib; sib = sib.previousElementSibling) if (sib.localName === tag) index++;
|
|
487
|
-
parts.unshift(`${tag}:nth-of-type(${index})`);
|
|
488
|
-
node = node.parentElement;
|
|
489
|
-
}
|
|
490
|
-
return parts.length ? (parts[0].startsWith("#") ? "" : "body > ") + parts.join(" > ") : "body";
|
|
491
|
-
}
|
|
492
|
-
var docWidth = () => Math.max(document.documentElement.scrollWidth, 1);
|
|
493
|
-
var clamp01 = (v) => Math.min(Math.max(v, 0), 1);
|
|
494
|
-
var short = (v, n) => (v || "").replace(/\s+/g, " ").trim().slice(0, n);
|
|
495
|
-
function fileHint(url) {
|
|
496
|
-
if (!url || url.startsWith("data:")) return "";
|
|
497
|
-
try {
|
|
498
|
-
const u = new URL(url, location.href);
|
|
499
|
-
const inner = u.searchParams.get("href") || u.searchParams.get("url");
|
|
500
|
-
if (inner && /\/_(image|vercel\/image|next\/image)/.test(u.pathname)) return fileHint(inner);
|
|
501
|
-
const parts = u.pathname.split("/").filter(Boolean).map(decodeURIComponent);
|
|
502
|
-
let name = parts.pop() || "";
|
|
503
|
-
if (/^w?\d+(x\d+)?\.\w+$/i.test(name) && parts.length) name = parts.pop();
|
|
504
|
-
return name.replace(/\.(avif|webp|jpe?g|png|gif|svg|mp4|webm|mov)$/i, "").replace(/[._-][A-Za-z0-9_-]{8}$/, "");
|
|
505
|
-
} catch {
|
|
506
|
-
return "";
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
var mediaSrc = (m) => {
|
|
510
|
-
const src = m.currentSrc || m.getAttribute("src") || "";
|
|
511
|
-
if (src && !src.startsWith("data:")) return new URL(src, location.href).href;
|
|
512
|
-
const lazy = m.dataset?.src || (m.getAttribute("srcset") || m.dataset?.srcset || "").split(/\s+/)[0];
|
|
513
|
-
return lazy ? new URL(lazy, location.href).href : "";
|
|
514
|
-
};
|
|
515
|
-
function naturalSpot(m, rect, cx, cy, nw, nh) {
|
|
516
|
-
if (!nw || !nh || !rect.width || !rect.height) return null;
|
|
517
|
-
const cs = getComputedStyle(m);
|
|
518
|
-
const fit = cs.objectFit || "fill";
|
|
519
|
-
const pos = (cs.objectPosition || "50% 50%").split(/\s+/).map(
|
|
520
|
-
(v) => v.endsWith("%") ? parseFloat(v) / 100 : { left: 0, top: 0, right: 1, bottom: 1 }[v] ?? 0.5
|
|
521
|
-
);
|
|
522
|
-
const sx = rect.width / nw;
|
|
523
|
-
const sy = rect.height / nh;
|
|
524
|
-
const scale = { cover: Math.max(sx, sy), contain: Math.min(sx, sy), none: 1, "scale-down": Math.min(1, sx, sy) }[fit];
|
|
525
|
-
const dw = nw * (scale ?? sx);
|
|
526
|
-
const dh = nh * (scale ?? sy);
|
|
527
|
-
const ox = (rect.width - dw) * (pos[0] ?? 0.5);
|
|
528
|
-
const oy = (rect.height - dh) * (pos[1] ?? pos[0] ?? 0.5);
|
|
529
|
-
return { fit, nw, nh, imgX: clamp01((cx - rect.left - ox) / dw), imgY: clamp01((cy - rect.top - oy) / dh) };
|
|
530
|
-
}
|
|
531
|
-
function fileSize(img) {
|
|
532
|
-
let nw = img.naturalWidth;
|
|
533
|
-
let nh = img.naturalHeight;
|
|
534
|
-
const sets = [img.srcset, ...[...img.closest("picture")?.querySelectorAll("source") || []].map((s) => s.srcset)].filter(Boolean);
|
|
535
|
-
for (const set of sets) {
|
|
536
|
-
for (const part of set.split(/,\s+/)) {
|
|
537
|
-
const [url, d = "1x"] = part.trim().split(/\s+/);
|
|
538
|
-
let abs = "";
|
|
539
|
-
try {
|
|
540
|
-
abs = new URL(url, location.href).href;
|
|
541
|
-
} catch {
|
|
542
|
-
}
|
|
543
|
-
if (!url || abs !== img.currentSrc || !nw) continue;
|
|
544
|
-
const v = parseFloat(d);
|
|
545
|
-
if (d.endsWith("w") && v) return { nw: Math.round(v), nh: Math.round(v * nh / nw) };
|
|
546
|
-
if (d.endsWith("x") && v) return { nw: Math.round(nw * v), nh: Math.round(nh * v) };
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
return { nw, nh };
|
|
550
|
-
}
|
|
551
|
-
var PLAIN_NAME = /^[A-Z][A-Za-z0-9]{2,}$/;
|
|
552
|
-
var PLUMBING = /(Provider|Context|Consumer|Boundary|Slot|Portal|Fragment|Presence|Scope|Trap|Root)$/;
|
|
553
|
-
var variantOf = (p) => ["variant", "size", "tone", "intent", "kind"].flatMap((k) => (typeof p?.[k] === "string" || typeof p?.[k] === "number") && /^[\w.-]{1,20}$/.test(String(p[k])) ? [`${k}=${p[k]}`] : []).join(" ");
|
|
554
|
-
var repoPath = (url) => !/^[a-z-]+:\/\//i.test(url) ? url : decodeURIComponent(url.replace(/^[a-z-]+:\/\/\/?(\.\/)?/i, "/").replace(/^\/[^/]*:\d+/, "").split("?")[0]).replace(/^\/(@fs)?/, "").replace(/^\(app-pages-browser\)\/\.?\/?/, "");
|
|
555
|
-
function componentAt(el2) {
|
|
556
|
-
const name = (t, d = 0) => d > 3 ? "" : typeof t === "function" ? t.displayName || t.name || "" : t && typeof t === "object" ? t.displayName || name(t.render || t.type, d + 1) : "";
|
|
557
|
-
const plain = (n) => PLAIN_NAME.test(n) && !PLUMBING.test(n);
|
|
558
|
-
const srcOf = (f) => {
|
|
559
|
-
const d = f?._debugSource;
|
|
560
|
-
if (d?.fileName) return `${repoPath(String(d.fileName))}:${d.lineNumber || 0}`;
|
|
561
|
-
const st = f?._debugStack?.stack;
|
|
562
|
-
if (typeof st !== "string") return "";
|
|
563
|
-
for (const line of st.split("\n").slice(1)) {
|
|
564
|
-
const m = /((?:https?|webpack-internal|file):\/\/[^\s()]+?):(\d+):\d+\)?\s*$/.exec(line);
|
|
565
|
-
if (m && !/node_modules|react-dom|react-jsx|jsx-dev-runtime|react-server|scheduler/.test(m[1])) return `${repoPath(m[1])} (line ${m[2]} as served, may differ from the source)`;
|
|
566
|
-
}
|
|
567
|
-
return "";
|
|
568
|
-
};
|
|
569
|
-
const key = Object.keys(el2).find((k) => k.startsWith("__reactFiber$"));
|
|
570
|
-
if (key) {
|
|
571
|
-
const host2 = el2[key];
|
|
572
|
-
const parts = [];
|
|
573
|
-
let usedAt = "";
|
|
574
|
-
for (let f = host2?.return, i = 0; f && parts.length < 2 && i < 80; f = f.return, i++) {
|
|
575
|
-
if (typeof f.type === "string") continue;
|
|
576
|
-
const n = name(f.type);
|
|
577
|
-
if (!plain(n)) continue;
|
|
578
|
-
if (!parts.length) usedAt = srcOf(f);
|
|
579
|
-
const v = variantOf(f.memoizedProps);
|
|
580
|
-
parts.push(v ? `${n} ${v}` : n);
|
|
581
|
-
}
|
|
582
|
-
if (!parts.length) return srcOf(host2) ? { source: srcOf(host2) } : {};
|
|
583
|
-
return { component: parts.length > 1 ? `${parts[0]} (in ${parts[1]})` : parts[0], source: srcOf(host2) || void 0, usedAt: usedAt || void 0 };
|
|
584
|
-
}
|
|
585
|
-
const vue = el2.__vueParentComponent;
|
|
586
|
-
if (vue?.type) {
|
|
587
|
-
const n = vue.type.name || vue.type.__name || (vue.type.__file || "").replace(/^.*\//, "").replace(/\.vue$/, "");
|
|
588
|
-
const parent = vue.parent?.type;
|
|
589
|
-
const pn = parent && (parent.name || parent.__name);
|
|
590
|
-
const v = variantOf(vue.props);
|
|
591
|
-
return { component: `${n}${v ? " " + v : ""}${pn ? ` (in ${pn})` : ""}`, source: vue.type.__file ? repoPath(vue.type.__file) : void 0, usedAt: parent?.__file ? repoPath(parent.__file) : void 0 };
|
|
592
|
-
}
|
|
593
|
-
const loc = el2.__svelte_meta?.loc;
|
|
594
|
-
if (loc?.file) return { component: loc.file.replace(/^.*\//, "").replace(/\.svelte$/, ""), source: `${repoPath(loc.file)}:${loc.line ?? 0}` };
|
|
595
|
-
return {};
|
|
596
|
-
}
|
|
597
|
-
function looksOf(el2) {
|
|
598
|
-
const cs = getComputedStyle(el2);
|
|
599
|
-
const names = /* @__PURE__ */ new Map();
|
|
600
|
-
const NONE = "rgb(1, 2, 3)";
|
|
601
|
-
const wrap = document.createElement("i");
|
|
602
|
-
wrap.style.cssText = `display:none;color:${NONE}`;
|
|
603
|
-
const probe = wrap.appendChild(document.createElement("i"));
|
|
604
|
-
document.body.append(wrap);
|
|
605
|
-
for (const prop of [...getComputedStyle(document.documentElement)].filter((p) => p.startsWith("--")).slice(0, 400)) {
|
|
606
|
-
probe.style.color = "";
|
|
607
|
-
probe.style.color = `var(${prop})`;
|
|
608
|
-
const v = getComputedStyle(probe).color;
|
|
609
|
-
if (v && v !== NONE && !names.has(v)) names.set(v, prop);
|
|
610
|
-
}
|
|
611
|
-
wrap.remove();
|
|
612
|
-
const say = (v) => names.has(v) ? `${names.get(v)} ${v}` : v;
|
|
613
|
-
const out = [];
|
|
614
|
-
if (!/^(transparent|rgba\(0, 0, 0, 0\))$/.test(cs.backgroundColor)) out.push(`fill ${say(cs.backgroundColor)}`);
|
|
615
|
-
out.push(`text ${say(cs.color)} ${cs.fontSize}/${cs.fontWeight}`);
|
|
616
|
-
if (parseFloat(cs.borderTopLeftRadius)) out.push(`radius ${cs.borderTopLeftRadius}`);
|
|
617
|
-
return short(out.join(", "), 200);
|
|
618
|
-
}
|
|
619
|
-
function untransform(el2, cx, cy) {
|
|
620
|
-
const t = getComputedStyle(el2).transform;
|
|
621
|
-
if (!t || t === "none") return null;
|
|
622
|
-
const m = new DOMMatrix(t);
|
|
623
|
-
if (m.isIdentity) return null;
|
|
624
|
-
const w = el2.offsetWidth || el2.getBoundingClientRect().width;
|
|
625
|
-
const h = el2.offsetHeight || el2.getBoundingClientRect().height;
|
|
626
|
-
const [ox, oy] = getComputedStyle(el2).transformOrigin.split(" ").map(parseFloat);
|
|
627
|
-
const at = (x, y) => m.transformPoint(new DOMPoint(x - ox, y - oy));
|
|
628
|
-
const corners = [at(0, 0), at(w, 0), at(0, h), at(w, h)];
|
|
629
|
-
const r = el2.getBoundingClientRect();
|
|
630
|
-
const origin = { x: r.left - Math.min(...corners.map((p) => p.x)), y: r.top - Math.min(...corners.map((p) => p.y)) };
|
|
631
|
-
const q = m.inverse().transformPoint(new DOMPoint(cx - origin.x, cy - origin.y));
|
|
632
|
-
return { rect: { left: 0, top: 0, width: w, height: h }, x: q.x + ox, y: q.y + oy };
|
|
633
|
-
}
|
|
634
|
-
function svgImageSpot(el2, anchor, cx, cy) {
|
|
635
|
-
const r = el2.getBoundingClientRect();
|
|
636
|
-
const keep = (el2.getAttribute("preserveAspectRatio") || "xMidYMid meet").split(/\s+/);
|
|
637
|
-
const fill = (iw, ih) => {
|
|
638
|
-
if (!iw || !ih || !r.width || !r.height) return;
|
|
639
|
-
let [dw, dh] = [r.width, r.height];
|
|
640
|
-
if (keep[0] !== "none") {
|
|
641
|
-
const k = (keep[1] === "slice" ? Math.max : Math.min)(r.width / iw, r.height / ih);
|
|
642
|
-
[dw, dh] = [iw * k, ih * k];
|
|
643
|
-
}
|
|
644
|
-
const align = (v, room) => v === "Min" ? 0 : v === "Max" ? room : room / 2;
|
|
645
|
-
const ox = keep[0] === "none" ? 0 : align(keep[0].slice(1, 4), r.width - dw);
|
|
646
|
-
const oy = keep[0] === "none" ? 0 : align(keep[0].slice(5, 8), r.height - dh);
|
|
647
|
-
Object.assign(anchor, { nw: iw, nh: ih, imgX: clamp01((cx - r.left - ox) / dw), imgY: clamp01((cy - r.top - oy) / dh) });
|
|
648
|
-
};
|
|
649
|
-
const probe = new Image();
|
|
650
|
-
probe.onload = () => fill(probe.naturalWidth, probe.naturalHeight);
|
|
651
|
-
probe.src = anchor.src;
|
|
652
|
-
if (probe.complete) fill(probe.naturalWidth, probe.naturalHeight);
|
|
653
|
-
}
|
|
654
|
-
function backgroundSpot(n, url, anchor, cx, cy) {
|
|
655
|
-
const r = n.getBoundingClientRect();
|
|
656
|
-
const cs = getComputedStyle(n);
|
|
657
|
-
const layers = (v) => v.split(/,(?![^(]*\))/).map((x) => x.trim());
|
|
658
|
-
const at = Math.max(0, layers(cs.backgroundImage).findIndex((l) => l.includes(url)));
|
|
659
|
-
const pick = (v) => {
|
|
660
|
-
const l = layers(v);
|
|
661
|
-
return l[at % l.length];
|
|
662
|
-
};
|
|
663
|
-
const fill = (iw, ih) => {
|
|
664
|
-
if (!iw || !ih || !r.width || !r.height) return;
|
|
665
|
-
const size = pick(cs.backgroundSize);
|
|
666
|
-
let dw = iw;
|
|
667
|
-
let dh = ih;
|
|
668
|
-
if (size === "cover" || size === "contain") {
|
|
669
|
-
const k = (size === "cover" ? Math.max : Math.min)(r.width / iw, r.height / ih);
|
|
670
|
-
dw = iw * k;
|
|
671
|
-
dh = ih * k;
|
|
672
|
-
} else if (size !== "auto" && size !== "auto auto") {
|
|
673
|
-
const [w, h = "auto"] = size.split(/\s+/);
|
|
674
|
-
const len = (v, of) => v.endsWith("%") ? parseFloat(v) / 100 * of : parseFloat(v);
|
|
675
|
-
dw = w === "auto" ? NaN : len(w, r.width);
|
|
676
|
-
dh = h === "auto" ? NaN : len(h, r.height);
|
|
677
|
-
if (Number.isNaN(dw) && Number.isNaN(dh)) [dw, dh] = [iw, ih];
|
|
678
|
-
else if (Number.isNaN(dw)) dw = dh * iw / ih;
|
|
679
|
-
else if (Number.isNaN(dh)) dh = dw * ih / iw;
|
|
680
|
-
}
|
|
681
|
-
const [px = "50%", py = "50%"] = pick(cs.backgroundPosition).split(/\s+/);
|
|
682
|
-
const off = (v, room) => v.endsWith("%") ? parseFloat(v) / 100 * room : parseFloat(v) || 0;
|
|
683
|
-
const ox = off(px, r.width - dw);
|
|
684
|
-
const oy = off(py, r.height - dh);
|
|
685
|
-
Object.assign(anchor, { nw: iw, nh: ih, fit: `background ${size}`, imgX: clamp01((cx - r.left - ox) / dw), imgY: clamp01((cy - r.top - oy) / dh) });
|
|
686
|
-
};
|
|
687
|
-
const probe = new Image();
|
|
688
|
-
probe.onload = () => fill(probe.naturalWidth, probe.naturalHeight);
|
|
689
|
-
probe.src = url;
|
|
690
|
-
if (probe.complete) fill(probe.naturalWidth, probe.naturalHeight);
|
|
691
|
-
}
|
|
692
|
-
function between(target, cy) {
|
|
693
|
-
const kids = [...target.children].filter((k) => k !== host && k.getBoundingClientRect().height > 0);
|
|
694
|
-
let above = null;
|
|
695
|
-
let below = null;
|
|
696
|
-
for (const k of kids) {
|
|
697
|
-
const kr = k.getBoundingClientRect();
|
|
698
|
-
if (kr.bottom <= cy) above = k;
|
|
699
|
-
else if (kr.top >= cy && !below) below = k;
|
|
700
|
-
else if (kr.top < cy && kr.bottom > cy) return null;
|
|
701
|
-
}
|
|
702
|
-
const say = (k) => {
|
|
703
|
-
if (!k) return void 0;
|
|
704
|
-
const h = k.matches("h1, h2, h3, h4, h5, h6") ? k : k.querySelector("h1, h2, h3, h4, h5, h6");
|
|
705
|
-
return short(`${openingTag(k)} "${short((h || k).textContent, 60)}"`, 160);
|
|
706
|
-
};
|
|
707
|
-
return above || below ? { above: say(above), below: say(below) } : null;
|
|
708
|
-
}
|
|
709
|
-
function schemeAt(target) {
|
|
710
|
-
for (let n = target; n; n = n.parentElement) {
|
|
711
|
-
const m = getComputedStyle(n).backgroundColor.match(/rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)(?:,\s*([\d.]+))?/);
|
|
712
|
-
if (!m || m[4] !== void 0 && parseFloat(m[4]) < 0.5) continue;
|
|
713
|
-
const [r, g, b] = [m[1], m[2], m[3]].map(Number);
|
|
714
|
-
const hex = "#" + [r, g, b].map((v) => Math.round(v).toString(16).padStart(2, "0")).join("");
|
|
715
|
-
return { scheme: 0.2126 * r + 0.7152 * g + 0.0722 * b < 128 ? "dark" : "light", background: hex };
|
|
716
|
-
}
|
|
717
|
-
return { scheme: matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" };
|
|
718
|
-
}
|
|
719
|
-
function quoteAt(cx, cy, shadowRoots = []) {
|
|
720
|
-
let node = null;
|
|
721
|
-
let offset = 0;
|
|
722
|
-
if (document.caretPositionFromPoint) {
|
|
723
|
-
const p = shadowRoots.length ? document.caretPositionFromPoint(cx, cy, { shadowRoots }) : document.caretPositionFromPoint(cx, cy);
|
|
724
|
-
if (p) {
|
|
725
|
-
node = p.offsetNode;
|
|
726
|
-
offset = p.offset;
|
|
727
|
-
}
|
|
728
|
-
} else if (document.caretRangeFromPoint) {
|
|
729
|
-
const r = document.caretRangeFromPoint(cx, cy);
|
|
730
|
-
if (r) {
|
|
731
|
-
node = r.startContainer;
|
|
732
|
-
offset = r.startOffset;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
if (!node || node.nodeType !== 3 || !node.data.trim()) return null;
|
|
736
|
-
const range = document.createRange();
|
|
737
|
-
range.selectNodeContents(node);
|
|
738
|
-
const hit = [...range.getClientRects()].some((r) => cx >= r.left - 4 && cx <= r.right + 4 && cy >= r.top - 4 && cy <= r.bottom + 4);
|
|
739
|
-
if (!hit) return null;
|
|
740
|
-
const text = node.data;
|
|
741
|
-
let a = offset;
|
|
742
|
-
let b = offset;
|
|
743
|
-
const seg = /[\u0e00-\u0e7f\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af\uf900-\ufaff]/.test(text) && typeof Intl !== "undefined" && Intl.Segmenter ? new Intl.Segmenter(node.parentElement?.closest("[lang]")?.lang || void 0, { granularity: "word" }) : null;
|
|
744
|
-
if (seg) {
|
|
745
|
-
for (const w of seg.segment(text)) {
|
|
746
|
-
if (offset >= w.index && offset <= w.index + w.segment.length && w.segment.trim()) {
|
|
747
|
-
a = w.index;
|
|
748
|
-
b = w.index + w.segment.length;
|
|
749
|
-
if (offset < b) break;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
} else {
|
|
753
|
-
while (a > 0 && /\S/.test(text[a - 1])) a--;
|
|
754
|
-
while (b < text.length && /\S/.test(text[b])) b++;
|
|
755
|
-
}
|
|
756
|
-
const block = node.parentElement?.closest("p, li, h1, h2, h3, h4, h5, h6, td, th, figcaption, blockquote, a, button, label, span, div") || node.parentElement;
|
|
757
|
-
const full = block?.textContent || text;
|
|
758
|
-
const before = full.slice(0, full.indexOf(text) + a);
|
|
759
|
-
const after = full.slice(full.indexOf(text) + b);
|
|
760
|
-
const squash = (v) => v.replace(/\s+/g, " ");
|
|
761
|
-
const quote = {
|
|
762
|
-
exact: short(text.slice(a, b), 80),
|
|
763
|
-
prefix: squash(before.slice(-80)).replace(/^\s+/, "").slice(-40),
|
|
764
|
-
suffix: squash(after.slice(0, 80)).replace(/\s+$/, "").slice(0, 40)
|
|
765
|
-
};
|
|
766
|
-
const pre = node.parentElement?.closest("pre, [data-file]") || (getComputedStyle(node.parentElement).whiteSpace.startsWith("pre") ? node.parentElement : null);
|
|
767
|
-
const codeTable = !pre && node.parentElement?.closest('table[data-file], table[class*="code" i]');
|
|
768
|
-
if (pre || codeTable) {
|
|
769
|
-
const box = pre || codeTable;
|
|
770
|
-
const r = document.createRange();
|
|
771
|
-
r.setStart(box, 0);
|
|
772
|
-
r.setEnd(node, offset);
|
|
773
|
-
let upto = r.toString();
|
|
774
|
-
let all = box.textContent;
|
|
775
|
-
const breaks = [...box.querySelectorAll("br, tr")];
|
|
776
|
-
if ((box.localName === "table" || !all.includes("\n")) && breaks.length) {
|
|
777
|
-
const ends = box.querySelectorAll("br").length ? [...box.querySelectorAll("br")] : [...box.querySelectorAll("tr")].slice(0, -1);
|
|
778
|
-
const before2 = ends.filter((e) => e.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING && !e.contains(node)).length;
|
|
779
|
-
const lineRange = document.createRange();
|
|
780
|
-
if (before2) lineRange.setStartAfter(ends[before2 - 1]);
|
|
781
|
-
else lineRange.setStart(box, 0);
|
|
782
|
-
if (ends[before2]) lineRange.setEndBefore(ends[before2]);
|
|
783
|
-
else lineRange.setEnd(box, box.childNodes.length);
|
|
784
|
-
const row2 = box.querySelectorAll("br").length ? null : node.parentElement?.closest("tr");
|
|
785
|
-
quote.line = short((row2 ? row2.textContent : lineRange.toString()).trim(), 200);
|
|
786
|
-
quote.lineNo = before2 + 1;
|
|
787
|
-
quote.lines = ends.length + (box.querySelectorAll("br").length ? 0 : 1);
|
|
788
|
-
} else {
|
|
789
|
-
const from = upto.lastIndexOf("\n") + 1;
|
|
790
|
-
const to = all.indexOf("\n", upto.length);
|
|
791
|
-
quote.line = short(all.slice(from, to < 0 ? void 0 : to).trim(), 200);
|
|
792
|
-
quote.lineNo = upto.split("\n").length;
|
|
793
|
-
quote.lines = all.replace(/\n$/, "").split("\n").length;
|
|
794
|
-
}
|
|
795
|
-
const row = node.parentElement?.closest("tr, [data-line], [data-line-number]");
|
|
796
|
-
if (row) {
|
|
797
|
-
const cell = row.matches("[data-line], [data-line-number]") ? row : row.querySelector("[data-line], [data-line-number]");
|
|
798
|
-
const n = cell?.getAttribute("data-line") || cell?.getAttribute("data-line-number") || [...row.children].map((c) => c.textContent.trim()).find((t) => /^\d+$/.test(t));
|
|
799
|
-
if (n && /^\d+$/.test(n)) quote.pageLineNo = Number(n);
|
|
800
|
-
}
|
|
801
|
-
let label = box.closest("[data-file]")?.getAttribute("data-file") || box.getAttribute("title") || box.getAttribute("aria-label") || "";
|
|
802
|
-
for (let el2 = box.parentElement, i = 0; !label.trim() && el2 && el2 !== document.body && i < 3; el2 = el2.parentElement, i++) {
|
|
803
|
-
label = el2.querySelector(':scope > figcaption, :scope > [class*="title" i]')?.textContent || "";
|
|
804
|
-
}
|
|
805
|
-
if (label.trim()) quote.label = short(label.trim(), 120);
|
|
806
|
-
}
|
|
807
|
-
return quote;
|
|
808
|
-
}
|
|
809
|
-
function openingTag(node) {
|
|
810
|
-
const attrs = [...node.attributes].filter((a) => /^(id|class|alt|role|aria-label|href|data-[\w-]+)$/.test(a.name)).map((a) => `${a.name}="${short(a.value, 60)}"`);
|
|
811
|
-
return `<${node.localName}${attrs.length ? ` ${attrs.join(" ")}` : ""}>`.slice(0, 200);
|
|
812
|
-
}
|
|
813
|
-
function sameKind(node, tag) {
|
|
814
|
-
if (!tag) return true;
|
|
815
|
-
const want = /^<([\w-]+)/.exec(tag)?.[1];
|
|
816
|
-
if (node.localName !== want) return false;
|
|
817
|
-
const id = / id="([^"]*)"/.exec(tag)?.[1];
|
|
818
|
-
if ((id || "") !== short(node.id || "", 60)) return false;
|
|
819
|
-
const classes = (/ class="([^"]*)"/.exec(tag)?.[1] || "").split(/\s+/).filter((c) => c && c !== "\u2026" && !c.endsWith("\u2026"));
|
|
820
|
-
return !classes.length || classes.some((c) => node.classList.contains(c));
|
|
821
|
-
}
|
|
822
|
-
function anchorAt(clientX, clientY) {
|
|
823
|
-
let stack = document.elementsFromPoint(clientX, clientY).filter((n) => n !== host && n !== document.documentElement);
|
|
824
|
-
const shadowRoots = [];
|
|
825
|
-
let shadowHost = null;
|
|
826
|
-
for (let top = stack[0]; top?.shadowRoot && !host.contains(top) && shadowRoots.length < 5; top = stack[0]) {
|
|
827
|
-
shadowHost ||= top;
|
|
828
|
-
shadowRoots.push(top.shadowRoot);
|
|
829
|
-
const inner = top.shadowRoot.elementsFromPoint(clientX, clientY).filter((n) => n !== top);
|
|
830
|
-
if (!inner.length) break;
|
|
831
|
-
stack = [...inner, ...stack];
|
|
832
|
-
}
|
|
833
|
-
const target = stack[0]?.closest("[data-comment-target]") || stack[0] || document.body;
|
|
834
|
-
const rect = target.getBoundingClientRect();
|
|
835
|
-
const anchor = {
|
|
836
|
-
selector: selectorFor(target),
|
|
837
|
-
x: rect.width ? (clientX - rect.left) / rect.width : 0,
|
|
838
|
-
y: rect.height ? (clientY - rect.top) / rect.height : 0,
|
|
839
|
-
docX: (clientX + scrollX) / docWidth(),
|
|
840
|
-
docY: clientY + scrollY,
|
|
841
|
-
width: innerWidth,
|
|
842
|
-
height: innerHeight,
|
|
843
|
-
dpr: Math.round((devicePixelRatio || 1) * 100) / 100,
|
|
844
|
-
element: openingTag(target),
|
|
845
|
-
eh: Math.round(rect.height)
|
|
846
|
-
// its height then: a pin on a big container can tell if the page grew under it
|
|
847
|
-
};
|
|
848
|
-
const own = short(target.textContent, 200);
|
|
849
|
-
if (own && target !== document.body && (target.textContent || "").length < 400) anchor.text = short(own, 80);
|
|
850
|
-
const inside = target.parentElement?.closest("[id], [data-lab]");
|
|
851
|
-
if (inside) anchor.inside = inside.dataset.lab ? `[data-lab="${inside.dataset.lab}"]` : `#${inside.id}`;
|
|
852
|
-
let heading = null;
|
|
853
|
-
for (const h of document.querySelectorAll("h1, h2, h3")) {
|
|
854
|
-
if (h.compareDocumentPosition(target) & Node.DOCUMENT_POSITION_FOLLOWING || h.contains(target)) heading = h;
|
|
855
|
-
}
|
|
856
|
-
if (heading) anchor.section = short(heading.textContent, 100);
|
|
857
|
-
if (shadowHost) anchor.shadow = openingTag(shadowHost);
|
|
858
|
-
for (const [k, v] of Object.entries(componentAt(target))) if (v) anchor[k] = short(v, 200);
|
|
859
|
-
if (target !== document.body) anchor.looks = looksOf(target);
|
|
860
|
-
const select = target.closest?.("select");
|
|
861
|
-
if (select && select.selectedIndex >= 0) {
|
|
862
|
-
anchor.chosen = short(`${select.selectedIndex + 1} of ${select.options.length}: "${select.options[select.selectedIndex].text}"`, 120);
|
|
863
|
-
}
|
|
864
|
-
for (const el2 of [target, target.parentElement]) {
|
|
865
|
-
if (!el2 || el2 === document.body) continue;
|
|
866
|
-
for (const which of ["::before", "::after"]) {
|
|
867
|
-
const c = getComputedStyle(el2, which).content;
|
|
868
|
-
const m = c && c.match(/^"(.+)"$/);
|
|
869
|
-
if (m && m[1].trim()) {
|
|
870
|
-
anchor.cssText = short(`"${m[1]}" from ${which} of ${openingTag(el2)}`, 160);
|
|
871
|
-
break;
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
if (anchor.cssText) break;
|
|
875
|
-
}
|
|
876
|
-
const build = document.querySelector('meta[name="lab-build"]')?.content;
|
|
877
|
-
if (build) anchor.build = short(build, 40);
|
|
878
|
-
const media = stack.slice(0, 5).find((n) => /^(img|video|canvas|svg|image)$/.test(n.localName) && !host.contains(n));
|
|
879
|
-
if (media?.localName === "image" && media.namespaceURI === "http://www.w3.org/2000/svg") {
|
|
880
|
-
anchor.kind = "image";
|
|
881
|
-
anchor.src = new URL(media.getAttribute("href") || media.getAttribute("xlink:href") || "", location.href).href;
|
|
882
|
-
anchor.file = fileHint(anchor.src);
|
|
883
|
-
svgImageSpot(media, anchor, clientX, clientY);
|
|
884
|
-
} else if (media) {
|
|
885
|
-
const r = media.getBoundingClientRect();
|
|
886
|
-
anchor.kind = media.localName === "img" ? "image" : media.localName;
|
|
887
|
-
if (media.localName === "img" || media.localName === "video") {
|
|
888
|
-
const img = media, video = media;
|
|
889
|
-
anchor.src = mediaSrc(media);
|
|
890
|
-
anchor.file = fileHint(anchor.src);
|
|
891
|
-
if (img.alt) anchor.alt = short(img.alt, 120);
|
|
892
|
-
const local = untransform(media, clientX, clientY);
|
|
893
|
-
const [box, px, py] = local ? [local.rect, local.x, local.y] : [r, clientX, clientY];
|
|
894
|
-
const spot = media.localName === "img" ? naturalSpot(media, box, px, py, fileSize(media).nw, fileSize(media).nh) : naturalSpot(media, box, px, py, video.videoWidth, video.videoHeight);
|
|
895
|
-
if (spot) Object.assign(anchor, spot);
|
|
896
|
-
if (local) anchor.transform = short(getComputedStyle(media).transform, 80);
|
|
897
|
-
if (media.localName === "img" && /\.(gif|webp|apng)(\?|#|$)/i.test(img.currentSrc || img.src)) {
|
|
898
|
-
const entry = performance.getEntriesByName(img.currentSrc || img.src)[0];
|
|
899
|
-
const since = entry ? (performance.now() - entry.responseEnd) / 1e3 : performance.now() / 1e3;
|
|
900
|
-
anchor.shownFor = Math.round(since * 10) / 10;
|
|
901
|
-
}
|
|
902
|
-
if (media.localName === "video") {
|
|
903
|
-
anchor.time = Math.round(video.currentTime * 10) / 10;
|
|
904
|
-
if (Number.isFinite(video.duration)) anchor.duration = Math.round(video.duration * 10) / 10;
|
|
905
|
-
if (!anchor.file && video.poster) anchor.file = fileHint(video.poster);
|
|
906
|
-
}
|
|
907
|
-
} else {
|
|
908
|
-
anchor.time = Math.round(performance.now() / 100) / 10;
|
|
909
|
-
anchor.imgX = clamp01((clientX - r.left) / (r.width || 1));
|
|
910
|
-
anchor.imgY = clamp01((clientY - r.top) / (r.height || 1));
|
|
911
|
-
anchor.nw = Math.round(r.width);
|
|
912
|
-
anchor.nh = Math.round(r.height);
|
|
913
|
-
}
|
|
914
|
-
} else {
|
|
915
|
-
const quote = quoteAt(clientX, clientY, shadowRoots);
|
|
916
|
-
if (quote) {
|
|
917
|
-
anchor.kind = "text";
|
|
918
|
-
anchor.quote = quote;
|
|
919
|
-
} else {
|
|
920
|
-
for (let n = target, i = 0; n && n !== document.documentElement && i < 4; n = n.parentElement, i++) {
|
|
921
|
-
const bg = getComputedStyle(n).backgroundImage.match(/url\(["']?(.+?)["']?\)/);
|
|
922
|
-
if (bg) {
|
|
923
|
-
anchor.kind = "background";
|
|
924
|
-
anchor.src = new URL(bg[1], location.href).href;
|
|
925
|
-
anchor.file = fileHint(anchor.src);
|
|
926
|
-
backgroundSpot(n, anchor.src, anchor, clientX, clientY);
|
|
927
|
-
break;
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
anchor.kind ||= "element";
|
|
931
|
-
if (anchor.kind === "element") {
|
|
932
|
-
const gap = between(target, clientY);
|
|
933
|
-
if (gap) Object.assign(anchor, { gapAbove: gap.above, gapBelow: gap.below });
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
Object.assign(anchor, schemeAt(target));
|
|
938
|
-
return anchor;
|
|
939
|
-
}
|
|
940
|
-
function findTarget(anchor) {
|
|
941
|
-
let node = null;
|
|
942
|
-
try {
|
|
943
|
-
node = anchor.selector ? document.querySelector(anchor.selector) : null;
|
|
944
|
-
} catch {
|
|
945
|
-
}
|
|
946
|
-
const matches = (n) => {
|
|
947
|
-
if (!n) return false;
|
|
948
|
-
if (anchor.file && /^(image|video)$/.test(anchor.kind)) {
|
|
949
|
-
const m = n.closest?.("img, video") || n;
|
|
950
|
-
return fileHint(mediaSrc(m)) === anchor.file;
|
|
951
|
-
}
|
|
952
|
-
if (anchor.element && !sameKind(n, anchor.element)) return false;
|
|
953
|
-
if (anchor.quote?.exact) {
|
|
954
|
-
const t = (n.textContent || "").replace(/\s+/g, "");
|
|
955
|
-
const q = anchor.quote.exact.replace(/\s+/g, "").slice(0, 24);
|
|
956
|
-
const before = (anchor.quote.prefix || "").replace(/\s+/g, "").slice(-10);
|
|
957
|
-
const after = (anchor.quote.suffix || "").replace(/\s+/g, "").slice(0, 10);
|
|
958
|
-
return t.includes(q) && (q.length >= 16 || !before && !after || t.includes(before + q) || t.includes(q + after));
|
|
959
|
-
}
|
|
960
|
-
return true;
|
|
961
|
-
};
|
|
962
|
-
const said = short(anchor.text, 400);
|
|
963
|
-
const sectionOf = (n) => {
|
|
964
|
-
let heading = null;
|
|
965
|
-
for (const h of document.querySelectorAll("h1, h2, h3")) if (h.compareDocumentPosition(n) & Node.DOCUMENT_POSITION_FOLLOWING || h.contains(n)) heading = h;
|
|
966
|
-
return heading ? short(heading.textContent, 100) : "";
|
|
967
|
-
};
|
|
968
|
-
const squash = (t) => String(t || "").replace(/\s+/g, "");
|
|
969
|
-
const areaWords = squash(anchor.zoneText).slice(0, 30);
|
|
970
|
-
const saysSame = (n) => anchor.quote?.exact ? true : said ? short(n.textContent, 400).startsWith(said.slice(0, 40)) : areaWords ? squash(n.textContent).includes(areaWords) : anchor.section ? sectionOf(n) === anchor.section : true;
|
|
971
|
-
const atPath = node && node !== document.body && matches(node) ? node : null;
|
|
972
|
-
if (atPath && saysSame(atPath)) return atPath;
|
|
973
|
-
if (anchor.file && /^(image|video)$/.test(anchor.kind)) {
|
|
974
|
-
return [...document.querySelectorAll("img, video")].find((m) => fileHint(mediaSrc(m)) === anchor.file) || null;
|
|
975
|
-
}
|
|
976
|
-
const tag = /^<([\w-]+)/.exec(anchor.element || "")?.[1];
|
|
977
|
-
if (!tag || tag === "body" || tag === "html") return atPath;
|
|
978
|
-
const flat = (t) => short(t, 400);
|
|
979
|
-
let found = null;
|
|
980
|
-
let best = -1;
|
|
981
|
-
let near = Infinity;
|
|
982
|
-
const twins = [...document.querySelectorAll(tag)].slice(0, 400).filter((n) => !host.contains(n) && sameKind(n, anchor.element));
|
|
983
|
-
for (const n of twins) {
|
|
984
|
-
const t = flat(n.textContent);
|
|
985
|
-
let score = 0;
|
|
986
|
-
if (anchor.quote?.exact && matches(n)) score += 4;
|
|
987
|
-
if (said && t === said) score += 4;
|
|
988
|
-
if (areaWords && squash(n.textContent).includes(areaWords)) score += 4;
|
|
989
|
-
else if (said && t.startsWith(said.slice(0, 40))) score += 2;
|
|
990
|
-
if (!score && twins.length > 1) continue;
|
|
991
|
-
if (score && anchor.section && sectionOf(n) === anchor.section) score += 2;
|
|
992
|
-
const d = Math.abs(n.getBoundingClientRect().top + scrollY - (anchor.docY || 0));
|
|
993
|
-
if (score > best || score === best && d < near) [found, best, near] = [n, score, d];
|
|
994
|
-
}
|
|
995
|
-
return best > 0 || !atPath ? found : atPath;
|
|
996
|
-
}
|
|
997
|
-
var wordCache = null;
|
|
998
|
-
function wordSpot(anchor) {
|
|
999
|
-
const m = /^(?:…)?(.*?)\[([^\]]+)\](.*?)(?:…)?$/s.exec(anchor.text || "");
|
|
1000
|
-
if (!m) return null;
|
|
1001
|
-
const before = m[1].replace(/\s+/g, " ").slice(-24);
|
|
1002
|
-
const word = m[2];
|
|
1003
|
-
if (!wordCache || performance.now() - wordCache.at > 400) {
|
|
1004
|
-
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, { acceptNode: (t) => host.contains(t.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT });
|
|
1005
|
-
let text2 = "";
|
|
1006
|
-
const at2 = [];
|
|
1007
|
-
for (let t = walker.nextNode(); t; t = walker.nextNode()) {
|
|
1008
|
-
const v = t.data.replace(/\s+/g, " ");
|
|
1009
|
-
for (let i2 = 0; i2 < v.length; i2++) at2.push([t, i2]);
|
|
1010
|
-
text2 += v;
|
|
1011
|
-
}
|
|
1012
|
-
wordCache = { at: performance.now(), text: text2, map: at2 };
|
|
1013
|
-
}
|
|
1014
|
-
const { text, map: at } = wordCache;
|
|
1015
|
-
let i = text.indexOf(before + word);
|
|
1016
|
-
if (i < 0) return { gone: true };
|
|
1017
|
-
i += before.length;
|
|
1018
|
-
const range = document.createRange();
|
|
1019
|
-
try {
|
|
1020
|
-
range.setStart(...at[i]);
|
|
1021
|
-
range.setEnd(at[i + word.length - 1][0], at[i + word.length - 1][1] + 1);
|
|
1022
|
-
} catch {
|
|
1023
|
-
return { gone: true };
|
|
1024
|
-
}
|
|
1025
|
-
const r = range.getBoundingClientRect();
|
|
1026
|
-
return r.width || r.height ? { left: r.left + scrollX + Math.min(6, r.width / 2), top: r.top + scrollY + r.height / 2 } : { gone: true };
|
|
1027
|
-
}
|
|
1028
|
-
var pageEnd = { at: -Infinity, y: 0 };
|
|
1029
|
-
var inPage = (y, h = 0) => {
|
|
1030
|
-
if (performance.now() - pageEnd.at > 300) {
|
|
1031
|
-
const bottoms = [...document.body.children].filter((c) => c !== host && !host.contains(c)).map((c) => c.getBoundingClientRect().bottom + scrollY);
|
|
1032
|
-
pageEnd = { at: performance.now(), y: Math.max(innerHeight, ...bottoms) };
|
|
1033
|
-
}
|
|
1034
|
-
return Math.max(0, Math.min(y, pageEnd.y - h - 40));
|
|
1035
|
-
};
|
|
1036
|
-
var pinOf = (zone, anchor) => ({ left: zone.left + (anchor.pinX ? zone.width : 0), top: zone.top + (anchor.pinY ? zone.height : 0) });
|
|
1037
|
-
var EDGE = 10;
|
|
1038
|
-
function position(anchor) {
|
|
1039
|
-
const at = spotOf(anchor);
|
|
1040
|
-
return at.moved ? { ...at, left: EDGE } : at;
|
|
1041
|
-
}
|
|
1042
|
-
function spotOf(anchor) {
|
|
1043
|
-
const node = findTarget(anchor);
|
|
1044
|
-
if (node && !anchor.zw && !anchor.docW && /^(html|body|main)$/.test(node.localName) && /\[[^\]]+\]/.test(anchor.text || "")) {
|
|
1045
|
-
const spot = wordSpot(anchor);
|
|
1046
|
-
if (spot && !spot.gone) return { left: spot.left, top: spot.top, zone: null };
|
|
1047
|
-
if (spot?.gone) return { left: anchor.docX * docWidth(), top: inPage(anchor.docY), zone: null, moved: true };
|
|
1048
|
-
}
|
|
1049
|
-
if (node && anchor.eh && !anchor.zw && !anchor.docW && /^(html|body|main)$/.test(node.localName) && !/\[[^\]]+\]/.test(anchor.text || "")) {
|
|
1050
|
-
if (Math.abs(node.getBoundingClientRect().height - anchor.eh) > 40) return { left: anchor.docX * docWidth(), top: inPage(anchor.docY), zone: null, moved: true };
|
|
1051
|
-
}
|
|
1052
|
-
if (node) {
|
|
1053
|
-
const rect = node.getBoundingClientRect();
|
|
1054
|
-
if (rect.width || rect.height) {
|
|
1055
|
-
const left2 = rect.left + scrollX + anchor.x * rect.width;
|
|
1056
|
-
const tall = anchor.zw && Number.isFinite(anchor.oy) && anchor.docH && rect.height > 2 * anchor.docH;
|
|
1057
|
-
const top2 = rect.top + scrollY + (tall ? anchor.oy : anchor.y * rect.height);
|
|
1058
|
-
const zone2 = anchor.zw ? { left: left2, top: top2, width: anchor.zw * rect.width, height: tall ? anchor.docH : anchor.zh * rect.height } : null;
|
|
1059
|
-
return zone2 ? { ...pinOf(zone2, anchor), zone: zone2 } : { left: left2, top: top2, zone: zone2 };
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
const left = anchor.docX * docWidth();
|
|
1063
|
-
const top = inPage(anchor.docY, anchor.docH || 0);
|
|
1064
|
-
const zone = anchor.docW ? { left, top, width: anchor.docW, height: anchor.docH } : null;
|
|
1065
|
-
if (zone) return { ...pinOf(zone, anchor), zone, moved: Boolean(anchor.selector) && anchor.selector !== "body" };
|
|
1066
|
-
return { left, top, zone, moved: Boolean(anchor.selector) && anchor.selector !== "body" };
|
|
1067
|
-
}
|
|
1068
|
-
function quoteRange(anchor) {
|
|
1069
|
-
const q = anchor?.quote;
|
|
1070
|
-
let node = q?.exact ? findTarget(anchor) : null;
|
|
1071
|
-
if (!node) return null;
|
|
1072
|
-
const want = q.exact.replace(/\s+/g, "");
|
|
1073
|
-
const tail = (q.prefix || "").replace(/\s+/g, "").slice(-12);
|
|
1074
|
-
for (let up = 0; node && up < 4; node = node.parentElement, up++) {
|
|
1075
|
-
let text = "";
|
|
1076
|
-
const at = [];
|
|
1077
|
-
const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
|
|
1078
|
-
for (let t = walker.nextNode(); t; t = walker.nextNode())
|
|
1079
|
-
for (let i = 0; i < t.data.length; i++) {
|
|
1080
|
-
if (/\s/.test(t.data[i])) continue;
|
|
1081
|
-
text += t.data[i];
|
|
1082
|
-
at.push([t, i]);
|
|
1083
|
-
}
|
|
1084
|
-
let first = null;
|
|
1085
|
-
for (let i = text.indexOf(want); i !== -1; i = text.indexOf(want, i + 1)) {
|
|
1086
|
-
const range = document.createRange();
|
|
1087
|
-
range.setStart(...at[i]);
|
|
1088
|
-
const [end, k] = at[i + want.length - 1];
|
|
1089
|
-
range.setEnd(end, k + 1);
|
|
1090
|
-
if (!tail || text.slice(0, i).endsWith(tail)) return range;
|
|
1091
|
-
first ||= range;
|
|
1092
|
-
}
|
|
1093
|
-
if (first) return first;
|
|
1094
|
-
}
|
|
1095
|
-
return null;
|
|
1096
|
-
}
|
|
1097
|
-
var nameLine = (name, done) => {
|
|
1098
|
-
const b = el("b", {}, String(name || "").replace(/\s*·\s*session\s+\S+$/i, ""));
|
|
1099
|
-
if (done) b.append(el("span", { class: "mark done", role: "img", "aria-label": "done" }, "\u2713"));
|
|
1100
|
-
return b;
|
|
1101
|
-
};
|
|
1102
|
-
var DRAFT_MODE = false;
|
|
1103
|
-
var drafting = () => DRAFT_MODE && store.get("lab-hold") === "1";
|
|
1104
|
-
var linked = (text) => {
|
|
1105
|
-
const out = [];
|
|
1106
|
-
let at = 0;
|
|
1107
|
-
for (const m of text.matchAll(/\bhttps?:\/\/[^\s<>"']*[^\s<>"'.,;:!?)\]]/g)) {
|
|
1108
|
-
if (m.index > at) out.push(document.createTextNode(text.slice(at, m.index)));
|
|
1109
|
-
const a = el("a", { href: m[0], target: "_blank", rel: "noopener noreferrer", class: "link" }, m[0]);
|
|
1110
|
-
a.addEventListener("click", (e) => e.stopPropagation());
|
|
1111
|
-
out.push(a);
|
|
1112
|
-
at = m.index + m[0].length;
|
|
1113
|
-
}
|
|
1114
|
-
if (at < text.length) out.push(document.createTextNode(text.slice(at)));
|
|
1115
|
-
return out;
|
|
1116
|
-
};
|
|
1117
|
-
var sentences = (t) => t.split(/(?<=[.!?])\s+(?=["'([]?[A-Z0-9])/);
|
|
1118
|
-
var readable = (text) => {
|
|
1119
|
-
const blocks = [];
|
|
1120
|
-
for (const [n, para] of String(text || "").trim().split(/\n\s*\n/).entries()) {
|
|
1121
|
-
const lines = para.split("\n");
|
|
1122
|
-
if (lines.length === 1 && para.length > 240) {
|
|
1123
|
-
const ss = sentences(para);
|
|
1124
|
-
for (let i = 0; i < ss.length; i += 2) blocks.push({ text: ss.slice(i, i + 2).join(" "), gap: n > 0 || i > 0 });
|
|
1125
|
-
continue;
|
|
1126
|
-
}
|
|
1127
|
-
lines.forEach((line, i) => {
|
|
1128
|
-
const item = /^\s*(?:[-•*]|\d+[.)])\s+/.exec(line);
|
|
1129
|
-
const prev = i > 0 ? blocks.at(-1) : null;
|
|
1130
|
-
if (item) blocks.push({ li: /\d/.test(item[0]) ? item[0].trim() : "\u2022", text: line.slice(item[0].length), gap: n > 0 && i === 0 });
|
|
1131
|
-
else if (prev && !prev.li) prev.text += `
|
|
1132
|
-
${line}`;
|
|
1133
|
-
else blocks.push({ text: line, gap: n > 0 && i === 0 || Boolean(prev) });
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1136
|
-
return blocks.map((b) => {
|
|
1137
|
-
const node = el("span", { class: `p${b.li ? " li" : ""}${b.gap ? " gap" : ""}` });
|
|
1138
|
-
if (b.li) node.append(el("span", { class: "mk" }, b.li));
|
|
1139
|
-
node.append(...linked(b.text));
|
|
1140
|
-
return node;
|
|
1141
|
-
});
|
|
1142
|
-
};
|
|
1143
|
-
var canMark = typeof Highlight === "function" && Boolean(CSS.highlights);
|
|
1144
|
-
var markQuote = (anchor) => {
|
|
1145
|
-
if (!canMark) return;
|
|
1146
|
-
const range = anchor && quoteRange(anchor);
|
|
1147
|
-
if (range) CSS.highlights.set("lab-quote", new Highlight(range));
|
|
1148
|
-
else CSS.highlights.delete("lab-quote");
|
|
1149
|
-
};
|
|
1150
|
-
var zoneEl = (cls) => {
|
|
1151
|
-
const z = el("div", { class: `zone ${cls}` });
|
|
1152
|
-
z.innerHTML = '<svg aria-hidden="true"><rect class="ring" width="100%" height="100%"/><rect class="dots" width="100%" height="100%"/></svg>';
|
|
1153
|
-
return z;
|
|
1154
|
-
};
|
|
1155
|
-
var drawZone = (box, cls) => {
|
|
1156
|
-
if (!box) return;
|
|
1157
|
-
const z = zoneEl(cls);
|
|
1158
|
-
Object.assign(z.style, { left: `${box.left}px`, top: `${box.top}px`, width: `${box.width}px`, height: `${box.height}px` });
|
|
1159
|
-
layer.append(z);
|
|
1160
|
-
return z;
|
|
1161
|
-
};
|
|
1162
|
-
function zoneAnchor({ x0, y0, x1, y1 }) {
|
|
1163
|
-
const left = Math.min(x0, x1);
|
|
1164
|
-
const top = Math.min(y0, y1);
|
|
1165
|
-
const right = Math.max(x0, x1);
|
|
1166
|
-
const bottom = Math.max(y0, y1);
|
|
1167
|
-
const anchor = anchorAt((left + right) / 2, (top + bottom) / 2);
|
|
1168
|
-
let box = document.elementsFromPoint((left + right) / 2, (top + bottom) / 2).find((n) => n !== host && !host.contains(n));
|
|
1169
|
-
const area = Math.max(1, (right - left) * (bottom - top));
|
|
1170
|
-
const contains = (r2) => Math.max(0, Math.min(r2.right, right) - Math.max(r2.left, left)) * Math.max(0, Math.min(r2.bottom, bottom) - Math.max(r2.top, top)) / area >= 0.8;
|
|
1171
|
-
while (box && box !== document.body && !contains(box.getBoundingClientRect())) box = box.parentElement;
|
|
1172
|
-
box ||= document.body;
|
|
1173
|
-
const r = box.getBoundingClientRect();
|
|
1174
|
-
Object.assign(anchor, {
|
|
1175
|
-
selector: box === document.body ? "body" : selectorFor(box),
|
|
1176
|
-
element: openingTag(box),
|
|
1177
|
-
x: r.width ? (left - r.left) / r.width : 0,
|
|
1178
|
-
y: r.height ? (top - r.top) / r.height : 0,
|
|
1179
|
-
zw: r.width ? (right - left) / r.width : 0,
|
|
1180
|
-
// may pass 1 a little: the area can reach past its element's edge
|
|
1181
|
-
zh: r.height ? (bottom - top) / r.height : 0,
|
|
1182
|
-
oy: Math.round(top - r.top),
|
|
1183
|
-
// px below the element's top: a share of a tall box drifts when it grows (pictures load)
|
|
1184
|
-
docX: (left + scrollX) / docWidth(),
|
|
1185
|
-
docY: top + scrollY,
|
|
1186
|
-
docW: Math.round(right - left),
|
|
1187
|
-
docH: Math.round(bottom - top),
|
|
1188
|
-
pinX: x1 >= x0 ? 1 : 0,
|
|
1189
|
-
// the drag ended on the right / at the bottom: the pin goes there
|
|
1190
|
-
pinY: y1 >= y0 ? 1 : 0
|
|
1191
|
-
});
|
|
1192
|
-
Object.assign(anchor, schemeAt(box));
|
|
1193
|
-
if (anchor.kind === "text") {
|
|
1194
|
-
delete anchor.quote;
|
|
1195
|
-
anchor.kind = "element";
|
|
1196
|
-
}
|
|
1197
|
-
const boxText = box === document.body ? "" : short(box.textContent, 200);
|
|
1198
|
-
if (boxText && (box.textContent || "").length < 400) anchor.text = short(boxText, 80);
|
|
1199
|
-
else delete anchor.text;
|
|
1200
|
-
if (box !== document.body) anchor.looks = looksOf(box);
|
|
1201
|
-
const words = [];
|
|
1202
|
-
const walker = document.createTreeWalker(box, NodeFilter.SHOW_TEXT);
|
|
1203
|
-
const range = document.createRange();
|
|
1204
|
-
for (let n = walker.nextNode(); n && words.length < 80; n = walker.nextNode()) {
|
|
1205
|
-
if (host.contains(n)) continue;
|
|
1206
|
-
const pr = n.parentElement?.getBoundingClientRect();
|
|
1207
|
-
if (!pr || pr.bottom < top || pr.top > bottom || pr.right < left || pr.left > right) continue;
|
|
1208
|
-
for (const m of n.data.matchAll(/\S+/g)) {
|
|
1209
|
-
range.setStart(n, m.index);
|
|
1210
|
-
range.setEnd(n, m.index + m[0].length);
|
|
1211
|
-
const w = range.getBoundingClientRect();
|
|
1212
|
-
const cx = (w.left + w.right) / 2;
|
|
1213
|
-
const cy = (w.top + w.bottom) / 2;
|
|
1214
|
-
if (w.width && cx >= left && cx <= right && cy >= top && cy <= bottom) words.push(m[0]);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
const text = short(words.join(" "), 300);
|
|
1218
|
-
if (text) anchor.zoneText = text;
|
|
1219
|
-
const inArea = [];
|
|
1220
|
-
const all = box.querySelectorAll("*");
|
|
1221
|
-
for (let i = 0; i < all.length && i < 3e3; i++) {
|
|
1222
|
-
const el2 = all[i];
|
|
1223
|
-
if (host.contains(el2) || inArea.some((x) => x.contains(el2))) continue;
|
|
1224
|
-
const er = el2.getBoundingClientRect();
|
|
1225
|
-
if (er.width < 8 || er.height < 8 || er.left < left - 4 || er.right > right + 4 || er.top < top - 4 || er.bottom > bottom + 4) continue;
|
|
1226
|
-
inArea.push(el2);
|
|
1227
|
-
}
|
|
1228
|
-
if (inArea.length) {
|
|
1229
|
-
anchor.zoneItems = inArea.slice(0, 5).map((el2) => {
|
|
1230
|
-
const c = componentAt(el2);
|
|
1231
|
-
const t = short(el2.textContent, 50);
|
|
1232
|
-
return short([openingTag(el2), t && `"${t}"`, c.component, c.source && `written at ${c.source}`, c.usedAt && `used at ${c.usedAt}`].filter(Boolean).join(" \xB7 "), 500);
|
|
1233
|
-
});
|
|
1234
|
-
if (inArea.length > 5) anchor.zoneItems.push(`and ${inArea.length - 5} more`);
|
|
1235
|
-
}
|
|
1236
|
-
if (/^(img|video)$/.test(box.localName)) {
|
|
1237
|
-
const nw = box.localName === "img" ? fileSize(box).nw : box.videoWidth;
|
|
1238
|
-
const nh = box.localName === "img" ? fileSize(box).nh : box.videoHeight;
|
|
1239
|
-
const a = naturalSpot(box, r, left, top, nw, nh);
|
|
1240
|
-
const b = naturalSpot(box, r, right, bottom, nw, nh);
|
|
1241
|
-
if (a && b) Object.assign(anchor, { imgX: a.imgX, imgY: a.imgY, imgX2: b.imgX, imgY2: b.imgY });
|
|
1242
|
-
} else if (anchor.kind === "image" || anchor.kind === "video") {
|
|
1243
|
-
delete anchor.imgX;
|
|
1244
|
-
delete anchor.imgY;
|
|
1245
|
-
anchor.kind = "element";
|
|
1246
|
-
}
|
|
1247
|
-
return anchor;
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
// src/comments.js
|
|
1251
|
-
/*!
|
|
1252
|
-
* lab comments: anyone with the link clicks anywhere on a lab page to pin a comment. No login, just a name.
|
|
1253
|
-
* https://github.com/leonidstern/labit · MIT
|
|
1254
|
-
* Comments are off by default; the bar button or c turns them on (remembered per browser). When on, click anywhere that isn't a link or control to pin one (alt/option-click pins on those too). c (or the bar button) hides
|
|
1255
|
-
* and shows them; esc or a click outside closes an open comment. Dragging (mouse/pen) marks an area instead of a point.
|
|
1256
|
-
* Include on a page served through your lab domain:
|
|
1257
|
-
* <script src="https://lab.example.com/_lab/comments.js" defer><\/script>
|
|
1258
|
-
* The layer only turns on when the page is opened on the host the script is loaded from (or data-host),
|
|
1259
|
-
* so the deployment's own address and local dev stay clean. data-enable="always" turns it on everywhere.
|
|
1260
|
-
* Admin (resolve / delete / copy agent link): open any page once with ?lab-admin=<LAB_COMMENTS_ADMIN_TOKEN>; it is kept in this browser.
|
|
1261
|
-
*/
|
|
1262
|
-
(() => {
|
|
1263
|
-
const script = (
|
|
1264
|
-
/** @type {HTMLScriptElement | null} */
|
|
1265
|
-
document.currentScript
|
|
1266
|
-
);
|
|
1267
|
-
const labHost = script?.dataset.host || (script?.src ? new URL(script.src, location.href).hostname : location.hostname);
|
|
1268
|
-
const enabled = location.hostname === labHost || script?.dataset.enable === "always";
|
|
1269
|
-
if (!enabled || /** @type {any} */
|
|
1270
|
-
window.__labComments) return;
|
|
1271
|
-
window.__labComments = true;
|
|
1272
|
-
const API = script?.dataset.api || "/_lab/api/comments";
|
|
1273
|
-
const pageNow = () => script?.dataset.page || location.pathname.replace(/\/+$/, "") || "/";
|
|
1274
|
-
let page = pageNow();
|
|
1275
|
-
const store2 = {
|
|
1276
|
-
get: (k) => {
|
|
1277
|
-
try {
|
|
1278
|
-
return localStorage.getItem(k) || "";
|
|
1279
|
-
} catch {
|
|
1280
|
-
return "";
|
|
1281
|
-
}
|
|
1282
|
-
},
|
|
1283
|
-
set: (k, v) => {
|
|
1284
|
-
try {
|
|
1285
|
-
localStorage.setItem(k, v);
|
|
1286
|
-
} catch {
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
};
|
|
1290
|
-
const scopeOf = (key) => key.split(".").length === 3 ? key.split(".")[1] : "";
|
|
1291
|
-
const adminParam = new URLSearchParams(location.hash.slice(1)).get("lab-admin") || new URLSearchParams(location.search).get("lab-admin");
|
|
1292
|
-
if (adminParam) {
|
|
1293
|
-
const scope = scopeOf(adminParam);
|
|
1294
|
-
store2.set(scope ? `lab-admin:${scope}` : "lab-admin", adminParam);
|
|
1295
|
-
const url = new URL(location.href);
|
|
1296
|
-
url.searchParams.delete("lab-admin");
|
|
1297
|
-
if (/lab-admin=/.test(url.hash)) url.hash = "";
|
|
1298
|
-
history.replaceState(null, "", url);
|
|
1299
|
-
}
|
|
1300
|
-
const adminToken = script?.dataset.admin || store2.get(`lab-admin:${page.split("/")[1] || ""}`) || store2.get("lab-admin:*") || store2.get("lab-admin");
|
|
1301
|
-
let comments = [];
|
|
1302
|
-
let isAdmin = false;
|
|
1303
|
-
let on = store2.get("lab-on") ? store2.get("lab-on") === "1" : script?.dataset.on === "1";
|
|
1304
|
-
let openId = null;
|
|
1305
|
-
let closeFast = false;
|
|
1306
|
-
let cardFull = false;
|
|
1307
|
-
let draft = null;
|
|
1308
|
-
const host2 = document.createElement("div");
|
|
1309
|
-
host2.setAttribute("data-lab-comments", "");
|
|
1310
|
-
host2.style.cssText = "position:absolute;top:0;left:0;width:0;height:0;z-index:2147483000;";
|
|
1311
|
-
const root = host2.attachShadow({ mode: "open" });
|
|
1312
|
-
root.innerHTML = `
|
|
1313
|
-
<style>${styles_default}</style>
|
|
1
|
+
(()=>{var qn=':host{all:initial;--_bg: var(--lab-bg, #fff);--_fg: var(--lab-fg, #141414);--_accent: var(--lab-accent, #141414);--_accent-fg: var(--lab-accent-fg, #fff);--_radius: var(--lab-radius, 12px);--_r-s: 6px ;--_soft: var(--lab-soft, rgba(0,0,0,.05));--_hover: var(--lab-hover, rgba(0,0,0,.1));--_line: var(--lab-line, rgba(0,0,0,.15));--_edge: var(--lab-edge, #c7c7cc);--_muted: var(--lab-muted, rgba(0,0,0,.5));--_hair: .5px solid color-mix(in srgb, var(--_fg) 16%, transparent);--_shadow: 0 0 0 .5px color-mix(in srgb, var(--_fg) 14%, transparent), 0 1px 2px rgba(0,0,0,.04), 0 8px 28px rgba(0,0,0,.08);--_ease: cubic-bezier(.2, .8, .2, 1)}@media(prefers-color-scheme:dark){:host{--_bg: var(--lab-bg, #1c1c1e);--_fg: var(--lab-fg, #f4f4f5);--_accent: var(--lab-accent, #f4f4f5);--_accent-fg: var(--lab-accent-fg, #141414);--_soft: var(--lab-soft, rgba(255,255,255,.05));--_hover: var(--lab-hover, rgba(255,255,255,.1));--_line: var(--lab-line, rgba(255,255,255,.15));--_edge: var(--lab-edge, #48484a);--_muted: var(--lab-muted, rgba(255,255,255,.5));--_shadow: 0 0 0 1px color-mix(in srgb, var(--_fg) 16%, transparent), 0 10px 32px rgba(0,0,0,.5)}}*{box-sizing:border-box;font-family:var(--lab-font, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:14px;line-height:1.4;font-weight:400;color:var(--_fg);letter-spacing:-.011em;font-feature-settings:var(--lab-font-features, normal);font-synthesis:none;font-optical-sizing:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility;caret-color:var(--_accent);-webkit-tap-highlight-color:transparent}::selection{background:color-mix(in srgb,var(--_accent) 38%,transparent);color:var(--_fg)}button:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}.layer{position:absolute;top:0;left:0;width:0;height:0}.pin{position:absolute;width:28px;height:28px;margin:-28px 0 0;border-radius:14px 14px 14px 2px;background:var(--_bg);border:0;box-shadow:0 0 0 1px var(--_edge),0 2px 8px #00000029;display:grid;place-items:center;cursor:pointer;padding:0;color:var(--_fg);font-size:12px;font-weight:500;font-variant-numeric:tabular-nums;letter-spacing:0;transform-origin:0 100%;transition:transform .16s var(--_ease),box-shadow .16s var(--_ease),opacity .16s}button.pin:hover,button.pin.open{transform:scale(1.08);box-shadow:0 0 0 1.5px #24a046,0 4px 14px #0003}button.pin:active{transform:scale(.96)}.pin.in{animation:lab-pin .26s var(--_ease)}.pin.arrive{animation:lab-arrive .46s cubic-bezier(.34,1.56,.64,1) both}@keyframes lab-arrive{0%{opacity:0;transform:scale(.7)}}.pin.swap{animation:lab-swap .36s cubic-bezier(.3,.7,.4,1.25)}@keyframes lab-swap{0%{transform:scale(.72);opacity:.35}}.pin .ring.gone{animation:lab-gone .3s ease-in forwards}@keyframes lab-gone{to{opacity:0}}button.pin.in:before{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;animation:lab-halo .9s cubic-bezier(.2,.7,.3,1) forwards}.pin.resolved{color:var(--_muted)}button.pin.go{background:var(--_bg);color:#24a046;font-size:11px;font-weight:600;letter-spacing:.006em;box-shadow:inset 0 0 0 1.5px #24a046,0 2px 8px #00000029}button.pin.go.done{background:#24a046;color:#fff;box-shadow:0 0 0 .5px color-mix(in srgb,var(--_fg) 22%,transparent),0 2px 8px #00000029}button.pin.done:not(.go){color:#24a046}.pin.moved{opacity:.5;scale:.8}button.pin.moved:hover,button.pin.moved.open{opacity:1}.pin.grab{touch-action:none}button.pin.dragging{cursor:grabbing;transform:scale(1.1);opacity:1;box-shadow:0 0 0 .5px color-mix(in srgb,var(--_fg) 30%,transparent),0 8px 20px #00000038}.zone{position:absolute;background:none;border-radius:var(--_radius);pointer-events:none}.zone svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none}.zone rect{fill:none;stroke-linecap:round;stroke-dasharray:0 4;rx:var(--lab-radius, 12px);ry:var(--lab-radius, 12px)}.zone rect.ring{display:none}.zone rect.dots{stroke:#34c759;stroke-width:1.5}.zone.live{left:0;top:0;will-change:transform,width,height;animation:lab-fade .12s ease-out}.pin .ring{position:absolute;inset:-4px;border-radius:18px 18px 18px 6px;padding:2px;overflow:hidden;pointer-events:none;-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}.ring:before{content:"";position:absolute;inset:-50%;will-change:transform;background:conic-gradient(rgb(52,199,89) 0 var(--lab-arc, 66%),rgba(52,199,89,.22) var(--lab-arc, 66%) 100%);animation:lab-turn 1.2s linear infinite}@keyframes lab-turn{to{transform:rotate(360deg)}}.pin .ring.come:before{animation:lab-draw .4s ease-out,lab-turn 1.2s linear infinite}@keyframes lab-draw{0%{--lab-arc: 0%}}.ptr{position:fixed;left:0;top:0;width:28px;height:28px;border-radius:14px 14px 14px 2px;corner-shape:round;background:var(--_bg);box-shadow:0 0 0 .5px color-mix(in srgb,var(--_fg) 30%,transparent),0 2px 6px #0000002e;display:grid;place-items:center;pointer-events:none;z-index:2147483647;opacity:0;will-change:transform;transition:opacity .12s ease-out,background-color .16s ease-out}.ptr.show{opacity:1}.ptr span{grid-area:1 / 1;font-size:12px;letter-spacing:0;font-weight:600;line-height:1;transition:opacity .16s ease-out,transform .16s ease-out}.ptr .tick{opacity:0;transform:scale(.5);color:#fff;font-size:11px;letter-spacing:.006em}.ptr.go{background:#24a046}.ptr.go .ini{opacity:0;transform:scale(.5)}.ptr.go .tick{opacity:1;transform:none}.pin.new:after{content:"";position:absolute;top:-4px;right:-4px;width:9px;height:9px;border-radius:50%;background:var(--_fg);box-shadow:0 0 0 2px var(--_bg)}.dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--_accent);margin:0 6px 1px 0}.card{position:absolute;width:320px;max-width:calc(100vw - 24px);background:var(--_bg);border-radius:var(--_radius);box-shadow:var(--_shadow);padding:12px 14px 14px;transform-origin:14px 0;z-index:1;display:flex;flex-direction:column;max-height:min(460px,62vh)}.card>.body{flex:0 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;margin-right:-8px;padding-right:8px}.card>.foot{flex:none}.card.in,.float.in{animation:lab-in .18s var(--_ease)}.card.out,.float.out{animation:lab-out .14s ease-in forwards;pointer-events:none}.item{display:grid;row-gap:3px}.item+.item{margin-top:14px}.msg.item{display:block}.msg.item+.msg.item{margin-top:0}.meta{display:flex;align-items:baseline;gap:.5em;font-size:12px;color:var(--_muted);margin:0;white-space:nowrap;letter-spacing:0;font-variant-numeric:tabular-nums}.meta b{font-weight:500;font-size:13px;letter-spacing:-.006em;min-width:0;overflow:hidden;text-overflow:ellipsis}.meta .dot{flex:none;align-self:center;margin:0}.meta .ago{white-space:nowrap}.text{white-space:pre-wrap;overflow-wrap:anywhere;text-wrap:pretty}.row{display:flex;gap:12px;justify-content:flex-start;align-items:center;margin-top:8px}.card .row:not(.nav){justify-content:flex-end;gap:10px}.card .row:not(.nav) button.btn{font-size:12px;letter-spacing:0}button.btn{border:0;padding:2px 0;cursor:pointer;background:none;color:var(--_muted);font-size:12px;letter-spacing:0;border-radius:var(--_r-s);transition:color .12s}button.btn:hover{color:var(--_fg)}button.btn.danger,button.btn.danger:hover{color:#e5484d}.row .ask{white-space:nowrap;color:var(--_fg);font-size:12px;letter-spacing:0;padding:2px 0;animation:lab-fade .12s ease-out}.float{position:absolute;width:320px;max-width:calc(100vw - 24px);transform-origin:0 20px;z-index:1}.card .composer{margin-top:6px}.card>.body>.row:not(.nav){margin-right:7px}.box{display:grid;grid-template-columns:1fr auto;grid-template-areas:"text send";align-items:center;column-gap:8px;border-radius:var(--_radius);padding:7px 7px 7px 14px;margin:0;transition:box-shadow .15s;background:var(--_box-bg, var(--_soft));box-shadow:var(--_box-edge, none)}.float{--_box-bg: var(--_bg);--_box-edge: 0 0 0 1px var(--_edge), 0 1px 2px rgba(0,0,0,.06), 0 8px 26px rgba(0,0,0,.14)}.box.open{grid-template-areas:"text text" "line line" "who send";row-gap:8px;padding:7px 7px 8px 14px}.box textarea{grid-area:text;width:100%;border:0;background:none;padding:2px 0;line-height:20px;margin:0;resize:none;min-height:0;max-height:200px;overflow-y:auto;outline:none;display:block}.box textarea::placeholder,.who input::placeholder{color:var(--_muted);opacity:1}.line{grid-area:line;height:0;border-top:var(--_hair);margin:0 -7px 0 -14px;display:none}.who{grid-area:who;display:none;align-items:baseline;gap:4px;min-width:0;font-size:13px;color:var(--_muted);letter-spacing:-.006em}.who *{font-size:13px;letter-spacing:-.006em}.who span{color:var(--_muted)}.who input{flex:1;min-width:0;border:0;background:none;padding:0;margin:0;outline:none;color:var(--_muted);text-overflow:ellipsis}.who input:focus{color:var(--_fg)}.box.open .line{display:block;animation:lab-fade .16s ease-out}.box.open .who{display:flex;animation:lab-fade .16s ease-out}.box.one,.box.one.open{grid-template-columns:minmax(0,1fr) auto auto;grid-template-areas:"text who send";align-items:end;row-gap:0;padding:7px 7px 7px 14px}.box.one .line{display:none!important}.box.one .who{align-self:end;line-height:20px;padding-bottom:2px;max-width:40%}.box.one .who input{flex:none;field-sizing:content;min-width:2ch;max-width:9em}.send{grid-area:send;width:24px;height:24px;border-radius:50%;border:0;padding:0;cursor:pointer;background:var(--_hover);color:var(--_muted);display:grid;place-items:center;transition:background .15s,color .15s,transform .15s var(--_ease)}.send.ready:hover{transform:scale(1.06)}.send.ready:active{transform:scale(.94)}.send.ready{background:var(--_accent);color:var(--_accent-fg);animation:lab-ready .16s ease-out}@keyframes lab-ready{50%{transform:scale(1.08)}}.send .arr{display:block;position:relative;left:-1px;width:12px;height:11px;background:currentColor;clip-path:polygon(0 42%,100% 0,66% 100%,46% 60%)}.send *{color:inherit}.error{color:#e5484d;font-size:12px;padding:6px 8px 0;letter-spacing:0}.error:empty{display:none}.error.wait{color:var(--_muted)}.bar{position:fixed;right:16px;bottom:16px;display:flex;gap:8px;align-items:center}.bar button{border:0;border-radius:var(--_radius);padding:9px 14px;cursor:pointer;background:var(--_bg);color:var(--_fg);box-shadow:var(--_shadow);font-size:13px;font-weight:500;display:inline-flex;gap:8px;align-items:center;letter-spacing:-.006em;font-variant-numeric:tabular-nums;white-space:nowrap;transition:color .15s,transform .15s var(--_ease)}.bar button:active{transform:scale(.97)}.list{position:fixed;right:16px;bottom:66px;width:min(340px,calc(100vw - 32px));max-height:min(60vh,460px);overflow:hidden;display:flex;flex-direction:column;background:var(--_bg);color:var(--_fg);border-radius:var(--_radius);box-shadow:var(--_shadow);font-size:13px;letter-spacing:-.006em}.list .tabs{display:flex;flex-wrap:wrap;gap:2px;flex:none;padding:12px 8px 6px}.list .items,.msgs{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain}.list .items{padding:0 6px 6px}.list .tabs button{border:0;border-radius:var(--_r-s);padding:4px 8px;white-space:nowrap;background:none;color:var(--_muted);cursor:pointer;font:inherit}.list .tabs button.on{background:var(--_fg);color:var(--_bg)}.list .tabs .hold{margin-left:auto}.list .it{display:block;width:100%;text-align:left;border:0;background:none;color:inherit;padding:7px 8px;border-radius:var(--_r-s);cursor:pointer;font:inherit}.list .it:hover,.list .it.cur{background:var(--_hover)}.list .it{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.list .it span,.list .none{color:var(--_muted)}.list .it .tag{display:inline-block;padding:0 7px;border-radius:var(--_r-s);background:var(--_accent);color:var(--_accent-fg);font-size:12px;letter-spacing:0;font-weight:600;line-height:18px;vertical-align:1px;white-space:nowrap}.list .none{padding:8px}*{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--_fg) 24%,transparent) transparent}@supports not (scrollbar-width: thin){::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--_fg) 24%,transparent);border-radius:999px}}.list .group{font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--_muted);padding:10px 8px 2px}.pin.held{border:1.5px dashed var(--_muted);opacity:.85}.list .tabs .show-done{color:var(--_muted)}.chatwin .tabs b{display:none}.list .tabs .x{margin-left:auto;flex:none;width:26px;height:26px;padding:0;border-radius:50%;display:grid;place-items:center;font-size:0;color:var(--_muted);background:transparent}.list .tabs .x:before,.list .tabs .x:after{content:"";grid-area:1 / 1;width:12px;height:1.6px;border-radius:1px;background:currentColor;transform:rotate(45deg)}.list .tabs .x:after{transform:rotate(-45deg)}.list .tabs .x:hover{color:var(--_fg)}.list .tabs .x:focus-visible{outline:2px solid var(--_accent);outline-offset:1px}.chatwin .chat{flex:none;background:var(--_bg);padding:6px 6px 8px}.chatwin .replying{flex:none}.chatwin .tabs b{padding:4px 8px;font-weight:600;margin-right:auto}.msgs{display:flex;flex-direction:column;gap:8px;padding:4px 10px 8px;overflow-x:hidden}.msgs>:first-child{margin-top:auto}.fresh{animation:lab-rise .2s var(--_ease)}.send.sent .arr{animation:lab-fly .32s var(--_ease)}@keyframes lab-rise{0%{opacity:0;transform:translateY(6px)}}@keyframes lab-fly{45%{transform:translate(9px,-9px) scale(.6);opacity:0}46%{transform:translate(-7px,7px) scale(.6);opacity:0}}.msg{max-width:85%;padding:7px 10px;border-radius:var(--_radius);background:var(--_soft);align-self:flex-start}.msg.mine{align-self:flex-end;background:color-mix(in srgb,rgb(52,199,89) 15%,var(--_bg));color:var(--_fg)}.msg b{display:block;font-size:12px;letter-spacing:0;font-weight:600;opacity:.7;margin-bottom:1px}.msg[data-agent=claude]{--_brand: #d97757}.msg[data-agent=codex]{--_brand: #10a37f}.msg[data-agent=cursor]{--_brand: #8a8a8e}.msg[data-agent=gemini]{--_brand: #4285f4}.msg[data-agent=copilot]{--_brand: #8957e5}.msg[data-agent=amp]{--_brand: #f34e3f}.msg[data-agent=opencode]{--_brand: #8a8a8e}.msg[data-agent]{background:color-mix(in srgb,var(--_brand) 11%,var(--_bg))}.msg[data-agent]>b{color:var(--_brand);opacity:1}.msg.mine b{display:none}.msg{position:relative}.mark{font-weight:400;font-size:11px;letter-spacing:.006em;color:var(--_muted);margin-left:6px;white-space:nowrap}.mark.done{color:#24a046;font-weight:600;font-size:12px;letter-spacing:0}.msg .quote{display:block;border-left:2px solid rgb(52,199,89);padding:1px 0 1px 8px;margin:3px 0 5px;font-size:12px;letter-spacing:0;line-height:1.35;color:var(--_muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.msg .quote b{display:block;font-size:12px;letter-spacing:0;font-weight:600;color:#24a046;opacity:1;margin:0}.mine .mark{color:inherit;opacity:.7}a.link{color:inherit;text-decoration:underline;text-underline-offset:2px;overflow-wrap:anywhere}.msg.to{box-shadow:0 0 0 2px var(--_accent)}.msg .p{display:block;white-space:pre-wrap;overflow-wrap:anywhere;text-wrap:pretty}.msg .p.gap{margin-top:6px}.msg .p.li{padding-left:14px;text-indent:-14px}.msg .p.li .mk{display:inline-block;width:14px;text-indent:0;opacity:.6}.msg i{display:block;font-style:normal;font-size:12px;letter-spacing:0;opacity:.7;margin-bottom:1px}.msg b,.msg i{color:inherit}.msg .stamp{text-indent:0;color:inherit;position:absolute;right:10px;bottom:6px;font-size:10px;letter-spacing:.012em;line-height:1;opacity:.55;font-variant-numeric:tabular-nums}.msg .stamp-room{text-indent:0;visibility:hidden;display:inline-block;margin-left:10px;font-size:10px;letter-spacing:.012em;line-height:1;height:10px;white-space:nowrap}.msg .stamp-room *{font-size:inherit}.msg .tick{color:inherit;margin-left:4px;letter-spacing:-.34em;font-size:10px}.msg .tick.got{font-weight:600}.msg .stamp:is(.busy,.ans){opacity:1}.msg .stamp:is(.busy,.ans) .tm{opacity:.55}.msg .stamp .tm{font-size:inherit;line-height:inherit;color:inherit}.msg :is(.stamp,.stamp-room) .ring{position:relative;display:inline-block;width:9px;height:9px;margin-left:5px;vertical-align:-1px;border-radius:50%;overflow:hidden;-webkit-mask:radial-gradient(farthest-side,transparent calc(100% - 1.6px),#000 calc(100% - 1.5px));mask:radial-gradient(farthest-side,transparent calc(100% - 1.6px),#000 calc(100% - 1.5px))}.msg .stamp.ans .tick{color:#24a046;letter-spacing:0;font-weight:600}.msg :is(.stamp,.stamp-room) .tick{display:inline-block;width:12px;height:10px;line-height:10px;text-align:center;margin-left:4px;vertical-align:top}.msg :is(.stamp,.stamp-room) .ring{margin:.5px 1.5px 0 5.5px;vertical-align:top}.msg .stamp{height:10px}.replying{display:flex;gap:6px;align-items:center;font-size:12px;letter-spacing:0;color:var(--_muted);padding:2px 6px}.replying button{border:0;background:none;color:inherit;cursor:pointer;margin-left:auto;font:inherit}.bar button *{color:inherit;font-weight:inherit}.bar .toggle:not(.secondary):before{content:"";width:7px;height:7px;border-radius:50%;background:var(--_accent)}.bar button.secondary{color:var(--_muted)}.bar button.secondary.has-new{color:var(--_fg);font-weight:600}.bar button.go-btn.on{color:#fff;background:#24a046}.bar .new-prev,.bar .new-next{padding:9px 11px;font-size:15px;letter-spacing:-.016em;line-height:1;color:var(--_fg)}.bar .list-btn,.bar .done-btn{font-variant-numeric:tabular-nums;min-width:4.6em;justify-content:center}.bar button.quiet{opacity:.45;cursor:default;box-shadow:var(--_shadow)}.bar button.go-btn.on kbd{color:#fff!important}.newline{display:flex;align-items:center;gap:8px;font-size:12px;letter-spacing:0;font-weight:500;color:var(--_muted)}.newline:before,.newline:after{content:"";flex:1;height:1px;background:currentColor;opacity:.35}.left{position:fixed;left:16px;bottom:16px;display:flex;gap:8px;align-items:center}.left .copy-all{border:0;border-radius:var(--_radius);padding:9px 14px;cursor:pointer;background:var(--_bg);color:var(--_muted);box-shadow:var(--_shadow);font:inherit;font-size:13px;letter-spacing:-.006em;font-weight:500;white-space:nowrap}.listener{display:inline-flex;gap:6px;align-items:center;padding:9px 14px;border-radius:var(--_radius);background:var(--_bg);color:var(--_fg);box-shadow:var(--_shadow);font-size:13px;letter-spacing:-.006em;text-decoration:none;white-space:nowrap}.listener span{color:var(--_muted)}.listener .lbl{display:contents}.mark{width:16px;height:16px;flex:none;overflow:visible;fill:var(--_accent)}.mark .eye{fill:var(--_bg)}.listener .mark{margin:-2px 0 -1px -3px}.listener.idle .mark{fill:var(--_muted);opacity:.5}.listener.working .mark{fill:#24a046}.mark :is(.e1,.e2,.eye){transform-box:fill-box;transform-origin:35% 100%}.mark .eye{transform-origin:50% 50%}.listener:not(.idle,.working) .mark .eye{animation:lab-blink 3.2s ease-in-out infinite}.listener.working .mark :is(.e1,.e2){animation:lab-twitch 2.4s ease-in-out infinite}.listener.working .mark .e2{animation-delay:.18s}@keyframes lab-blink{0%,88%,to{transform:scaleY(1)}92%,96%{transform:scaleY(.08)}}@keyframes lab-twitch{0%,62%,to{transform:rotate(0)}70%{transform:rotate(-9deg)}80%{transform:rotate(5deg)}90%{transform:rotate(-3deg)}}.listener{cursor:default}kbd{font-size:10px;letter-spacing:.012em;line-height:17px;min-width:0;padding:0 1px;text-align:center;background:none;color:var(--_muted)!important;opacity:.45;transition:opacity .15s}.bar:hover kbd{opacity:.75}.bar button kbd{margin-left:-4px}.bar button.go-btn kbd{font-size:inherit;line-height:inherit;opacity:1;margin-left:0}@media all{.bar{gap:0;background:var(--_bg);border-radius:var(--_radius);box-shadow:var(--_shadow);overflow:hidden}.bar>button{box-shadow:inset .5px 0 0 var(--_line);border-radius:0;background:none;padding:8px 12px;gap:6px}.bar>button.first{box-shadow:none}@media(hover:hover)and (pointer:fine){.bar>button:not(:disabled):hover{background:var(--_soft)}.bar>button:active{background:var(--_soft)}}.bar>.more[aria-expanded=true]{background:var(--_soft)}.bar>button:active{transform:none}.bar>button.quiet{opacity:1;box-shadow:inset .5px 0 0 var(--_line);color:var(--_muted)}.bar>button.quiet.first{box-shadow:none}.bar .list-btn,.bar .done-btn{min-width:0}.bar .mn{color:var(--_muted);font-weight:400}.bar>button.secondary,.bar>button.secondary.has-new{color:var(--_muted);font-weight:500}.bar .chat-btn,.bar .list-btn{align-items:baseline}.bar .cnt{font-size:12px;letter-spacing:0;font-weight:400;line-height:16px;text-align:center;background:none;color:var(--_fg);font-variant-numeric:tabular-nums}.bar .cnt.zero{color:var(--_muted)}.bar button.go-btn.on{background:none;color:var(--_fg)}.bar button.go-btn.on kbd{color:var(--_muted)!important}.gp{display:inline-grid;place-items:center;width:22px;height:22px;border-radius:11px 11px 11px 2px;font-size:10px;letter-spacing:.012em;font-weight:600;color:#24a046;box-shadow:inset 0 0 0 1.25px #24a046;transition:background-color .2s,color .2s}.go-btn.on .gp{background:#24a046;color:#fff}.go-btn:not(.on):not(.cursor) .gp{color:var(--_fg);background:var(--_bg);box-shadow:inset 0 0 0 1px var(--_edge);font-size:10px;letter-spacing:.012em}.go-btn.cursor .gp{color:transparent;background:var(--_bg);box-shadow:inset 0 0 0 1px var(--_edge);position:relative}.go-btn.cursor .gp:after{content:"off";position:absolute;inset:0;display:grid;place-items:center;color:var(--_muted);font-size:10px;font-weight:600;letter-spacing:0}.more{font-size:15px!important;letter-spacing:.05em}.more-menu{position:fixed;right:16px;bottom:60px;display:grid;min-width:180px;padding:4px;background:var(--_bg);border-radius:var(--_radius);box-shadow:var(--_shadow);animation:lab-fade .12s ease-out}.more-menu[hidden]{display:none}.more-menu button{border:0;background:none;text-align:left;font:inherit;font-size:13px;letter-spacing:-.006em;color:var(--_fg);padding:7px 10px;border-radius:var(--_r-s);cursor:pointer;display:flex;justify-content:space-between;align-items:center;gap:12px;white-space:nowrap}.more-menu button:hover:not(:disabled){background:var(--_soft)}.more-menu button:disabled{color:var(--_muted);cursor:default}.more-menu button[hidden]{display:none}.more-menu kbd{margin:0}}kbd:before{content:"("}kbd:after{content:")"}.hint{position:fixed;left:50%;bottom:64px;transform:translate(-50%);background:var(--_bg);color:var(--_muted);box-shadow:var(--_shadow);padding:8px 14px;border-radius:var(--_radius);font-size:13px;pointer-events:none;white-space:nowrap;letter-spacing:-.006em;animation:lab-fade .2s ease-out}@media(pointer:coarse){.box textarea,.who input{font-size:16px;letter-spacing:-.019em}kbd{display:none}.box textarea{line-height:22px;padding:7px 0}.box.one .who{line-height:22px;padding-bottom:7px}}@keyframes lab-fade{0%{opacity:0}}@keyframes lab-in{0%{transform:translateY(4px) scale(.98)}}@keyframes lab-out{to{opacity:0;transform:translateY(2px) scale(.985)}}@supports (corner-shape: squircle){:host{--_radius: calc(var(--lab-radius, 12px) * 1.8);--_r-s: 11px}*,*:before,*:after{corner-shape:squircle}.pin,.pin .ring,.pin.new:after,.dot,.send,.list .tabs .x,.bar .toggle:not(.secondary):before,.msg :is(.stamp,.stamp-room) .ring,.gp{corner-shape:round}}@keyframes lab-pin{0%{transform:scale(1.1)}}@keyframes lab-halo{0%{box-shadow:0 0 color-mix(in srgb,var(--_fg) 12%,transparent)}to{box-shadow:0 0 0 16px color-mix(in srgb,var(--_fg) 0%,transparent)}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}@media(max-width:480px){kbd{display:none}}.handle{display:none}@media(pointer:coarse)and (max-width:560px),(pointer:coarse)and (max-height:500px){:host{--_safe: env(safe-area-inset-bottom, 0px);--_kb: var(--lab-kb, 0px);--_sheet-max: calc(min(72dvh, var(--lab-vh, 100dvh) - 24px) + var(--_kb));--_pb: calc(12px + var(--_safe) + var(--_kb))}:host([data-kb]){--_safe: 0px;--_kb: 0px;--_pb: 10px}:host([data-kb]) :is(.card,.list:not([hidden])){top:var(--lab-top, 0px)!important;bottom:auto!important;height:var(--lab-vh, 100dvh)!important;max-height:none!important;border-radius:0}:host([data-kb]) .float{top:auto!important;bottom:var(--lab-kb, 0px)!important;height:auto!important;border-radius:var(--_radius) var(--_radius) 0 0}.card,.float{position:fixed;left:0!important;right:0;top:auto!important;bottom:0;width:auto;max-width:none;max-height:var(--_sheet-max);display:flex;flex-direction:column;border-radius:var(--_radius) var(--_radius) 0 0;padding:8px 0 0;z-index:3}.card:after,.float:after,.list:after{content:"";position:absolute;left:0;right:0;top:100%;height:100vh;background:var(--_bg)}.card>.body{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:0 12px 4px;margin-right:0}.card{height:var(--_sheet-max)}.card>.foot,.float>.composer{flex:none;padding:0 12px var(--_pb)}.card>.foot{margin-top:0;padding-top:6px}.card .composer{margin-top:0}.card>.nav{flex:none;margin:-6px 0 0;padding:0 12px;gap:20px}.card .nav .btn{font-size:14px;letter-spacing:-.011em;padding:0 2px;min-height:44px;display:inline-flex;align-items:center}.card .nav{gap:16px}.card .nav{flex-wrap:wrap;row-gap:0}.card .nav .acts{margin:0 0 0 auto;gap:20px}.box.one .who span{font-size:16px;letter-spacing:-.019em}.card .nav .acts button.btn{font-size:14px;letter-spacing:-.011em}.float{background:var(--_bg);box-shadow:var(--_shadow)}.handle{display:block;flex:none;height:86px;margin-top:-68px;touch-action:none;position:relative}.list .tabs{position:relative}.handle:after,.list .tabs:after{content:"";position:absolute;left:50%;top:68px;width:36px;height:4px;margin-left:-18px;border-radius:2px;background:color-mix(in srgb,var(--_fg) 18%,transparent);pointer-events:none}.list .tabs:after{top:8px}.list .tabs:before{content:"";position:absolute;left:0;right:0;top:-60px;height:60px}.list .tabs{touch-action:pan-x}.chatwin .tabs{touch-action:none}.list .items,.msgs,.card>.body{touch-action:pan-y}.list .tabs .x{display:none}:host([data-sheet]) :is(.hint,.listener,.left){visibility:hidden}.bar{transition:transform .34s cubic-bezier(.32,.72,0,1),opacity .2s}:host([data-sheet]) .bar{transform:translateY(calc((100% + 16px + env(safe-area-inset-bottom,0px)) * (1 - var(--lab-p, 0))));opacity:var(--lab-p, 0);pointer-events:none;transition:transform .24s cubic-bezier(.4,0,1,1),opacity .2s .04s}:host([data-sheet]) .bar button{pointer-events:none}:host([data-sheet]) .scrim{display:block;animation:lab-fade .22s ease-out}:host([data-opening]) :is(.card.in,.float.in,.scrim){animation-play-state:paused}:host([data-leaving]) .scrim{display:block}.list{left:0;right:0;bottom:0!important;width:auto;max-height:var(--_sheet-max);overflow:visible;border-radius:var(--_radius) var(--_radius) 0 0;font-size:15px;letter-spacing:-.016em;z-index:3}.chatwin{height:var(--_sheet-max);transition:height .38s cubic-bezier(.32,.72,0,1)}.chatwin.full,.card.full{height:calc(var(--lab-vh, 100dvh) - env(safe-area-inset-top,0px) - 10px + var(--_kb));max-height:none}.card{transition:height .38s cubic-bezier(.32,.72,0,1)}.list .tabs{flex-wrap:nowrap;overflow-x:auto;padding:18px 12px 8px;border-radius:var(--_radius) var(--_radius) 0 0;background:var(--_bg)}.list .items{padding:0 12px calc(10px + var(--_safe))}.chatwin .msgs{padding:4px 12px 8px}.chatwin .tabs{padding:18px 12px 0}.chatwin .chat{padding:6px 12px var(--_pb)}.chatwin .msgs{margin-bottom:calc(-56px - var(--_pb));padding-bottom:calc(64px + var(--_pb))}.card>.body{margin-bottom:calc(-56px - var(--_pb));padding-bottom:calc(64px + var(--_pb))}.chatwin .msgs{-webkit-mask-image:linear-gradient(#000 calc(100% - 60px - var(--_pb)),rgba(0,0,0,.12) calc(100% - var(--_pb)));mask-image:linear-gradient(#000 calc(100% - 60px - var(--_pb)),#0000001f calc(100% - var(--_pb)))}.card>.body{-webkit-mask-image:linear-gradient(#000 calc(100% - 60px - var(--_pb)),rgba(0,0,0,.12) calc(100% - var(--_pb)));mask-image:linear-gradient(#000 calc(100% - 60px - var(--_pb)),#0000001f calc(100% - var(--_pb)))}.chatwin .chat,.card>.foot{position:relative;z-index:1;background:none}:host{--_box-bg: color-mix(in srgb, var(--_bg) 72%, transparent);--_box-edge: inset 0 0 0 .5px color-mix(in srgb, var(--_fg) 16%, transparent), 0 4px 18px rgba(0, 0, 0, .08)}.float{--_box-bg: inherit;--_box-edge: inherit}.box{-webkit-backdrop-filter:blur(18px) saturate(1.8);backdrop-filter:blur(18px) saturate(1.8)}.list .it{padding:11px 8px}.pin{scale:.8}.pin .hit{display:block;position:absolute;inset:-14px;border-radius:50%}.pin.moved .hit{inset:-21px}.msg .p{font-size:15px;letter-spacing:-.016em;line-height:21px}.msg .quote{font-size:14px;letter-spacing:-.011em}.msg b,.msg .quote b{font-size:12px;letter-spacing:0}.pin.moved{scale:.64}.bar>button{padding:12px 14px;min-height:44px}.more-menu{bottom:72px;min-width:200px}.more-menu button{padding:11px 12px;font-size:15px;letter-spacing:-.016em}}.scrim{cursor:pointer;display:none;position:fixed;inset:-50vh 0;background:#0006;z-index:2;touch-action:none}.sel-chip{position:fixed;transform:translate(-50%);border:0;border-radius:var(--_radius);padding:8px 14px;background:var(--_fg);color:var(--_bg);font:500 14px/1 var(--_font, inherit);box-shadow:var(--_shadow);z-index:4}@media(pointer:coarse)and (max-width:560px),(pointer:coarse)and (max-height:500px){.listener{display:none!important}.bar{bottom:16px!important}.hint{bottom:64px!important}.chat-btn .mark{align-self:center;width:13px;height:13px;margin:0 -2.5px 0 -2px;translate:0 -1.5px}.chat-btn[data-agent=away] .mark{fill:var(--_muted);opacity:.5}.chat-btn[data-agent=working] .mark{fill:#24a046}.chat-btn[data-agent=listening] .mark .eye{animation:lab-blink 3.2s ease-in-out infinite}.chat-btn[data-agent=working] .mark :is(.e1,.e2){animation:lab-twitch 2.4s ease-in-out infinite}.chat-btn[data-agent=working] .mark .e2{animation-delay:.18s}.send{width:36px;height:36px}.send .arr{width:17px;height:15px;margin:auto}}@media(max-width:560px){.bar{bottom:64px}.hint{bottom:112px}.list{bottom:114px}}[hidden]{display:none!important}@media(pointer:coarse)and (max-width:560px),(pointer:coarse)and (max-height:500px){:host{--_gap: 8px;--_card-r: 30px}.card,.float,.list{left:var(--_gap)!important;right:var(--_gap);bottom:var(--_gap)!important;border-radius:var(--_card-r)!important;background:var(--_bg);box-shadow:0 0 0 .5px color-mix(in srgb,var(--_fg) 10%,transparent),0 12px 40px #0000002e;transform-origin:var(--lab-from, 50% 100%)}.list .tabs{border-radius:var(--_card-r) var(--_card-r) 0 0}.card:after,.float:after,.list:after{content:none}:host([data-kb]) :is(.card,.list:not([hidden])){top:calc(var(--lab-top, 0px) + var(--_gap))!important;height:calc(var(--lab-vh, 100dvh) - 2 * var(--_gap))!important}:host([data-kb]) .float{bottom:calc(var(--lab-kb, 0px) + var(--_gap))!important}.chatwin.full,.card.full{height:calc(var(--lab-vh, 100dvh) - env(safe-area-inset-top,0px) - 10px - var(--_gap) + var(--_kb))}.scrim{background:transparent}.card.in,.float.in,.list:not([hidden]){animation:lab-card-in .3s cubic-bezier(.2,.9,.25,1)}}@keyframes lab-card-in{0%{transform:scale(.3);opacity:0}40%{opacity:1}}.zi{display:inline-flex;align-items:center;justify-content:center}.zi svg{width:13px;height:13px;display:block}.go-btn .gp:has(.zw){display:inline-flex;align-items:center;gap:4px;width:auto;padding:0 8px 0 6px;border-radius:11px}.go-btn .gp .zw{line-height:1}';var de,Kn,ze,Yn;function Un(e){({host:de,layer:Kn,el:ze,store:Yn}=e)}function Xn(e){let n=[];for(;e&&e.nodeType===1&&e!==document.body&&e!==document.documentElement;){if(e.id&&document.querySelectorAll(`#${CSS.escape(e.id)}`).length===1){n.unshift(`#${CSS.escape(e.id)}`);break}let r=e.localName,i=1;for(let s=e.previousElementSibling;s;s=s.previousElementSibling)s.localName===r&&i++;n.unshift(`${r}:nth-of-type(${i})`),e=e.parentElement}return n.length?(n[0].startsWith("#")?"":"body > ")+n.join(" > "):"body"}var ut=()=>Math.max(document.documentElement.scrollWidth,1),Oe=e=>Math.min(Math.max(e,0),1),K=(e,n)=>(e||"").replace(/\s+/g," ").trim().slice(0,n);function qe(e){if(!e||e.startsWith("data:"))return"";try{let n=new URL(e,location.href),r=n.searchParams.get("href")||n.searchParams.get("url");if(r&&/\/_(image|vercel\/image|next\/image)/.test(n.pathname))return qe(r);let i=n.pathname.split("/").filter(Boolean).map(decodeURIComponent),s=i.pop()||"";return/^w?\d+(x\d+)?\.\w+$/i.test(s)&&i.length&&(s=i.pop()),s.replace(/\.(avif|webp|jpe?g|png|gif|svg|mp4|webm|mov)$/i,"").replace(/[._-][A-Za-z0-9_-]{8}$/,"")}catch{return""}}var on=e=>{let n=e.currentSrc||e.getAttribute("src")||"";if(n&&!n.startsWith("data:"))return new URL(n,location.href).href;let r=e.dataset?.src||(e.getAttribute("srcset")||e.dataset?.srcset||"").split(/\s+/)[0];return r?new URL(r,location.href).href:""};function Ot(e,n,r,i,s,a){if(!s||!a||!n.width||!n.height)return null;let u=getComputedStyle(e),o=u.objectFit||"fill",l=(u.objectPosition||"50% 50%").split(/\s+/).map(w=>w.endsWith("%")?parseFloat(w)/100:{left:0,top:0,right:1,bottom:1}[w]??.5),p=n.width/s,v=n.height/a,x={cover:Math.max(p,v),contain:Math.min(p,v),none:1,"scale-down":Math.min(1,p,v)}[o],c=s*(x??p),f=a*(x??v),m=(n.width-c)*(l[0]??.5),h=(n.height-f)*(l[1]??l[0]??.5);return{fit:o,nw:s,nh:a,imgX:Oe((r-n.left-m)/c),imgY:Oe((i-n.top-h)/f)}}function Nt(e){let n=e.naturalWidth,r=e.naturalHeight,i=[e.srcset,...[...e.closest("picture")?.querySelectorAll("source")||[]].map(s=>s.srcset)].filter(Boolean);for(let s of i)for(let a of s.split(/,\s+/)){let[u,o="1x"]=a.trim().split(/\s+/),l="";try{l=new URL(u,location.href).href}catch{}if(!u||l!==e.currentSrc||!n)continue;let p=parseFloat(o);if(o.endsWith("w")&&p)return{nw:Math.round(p),nh:Math.round(p*r/n)};if(o.endsWith("x")&&p)return{nw:Math.round(n*p),nh:Math.round(r*p)}}return{nw:n,nh:r}}var qo=/^[A-Z][A-Za-z0-9]{2,}$/,Ho=/(Provider|Context|Consumer|Boundary|Slot|Portal|Fragment|Presence|Scope|Trap|Root)$/,Hn=e=>["variant","size","tone","intent","kind"].flatMap(n=>(typeof e?.[n]=="string"||typeof e?.[n]=="number")&&/^[\w.-]{1,20}$/.test(String(e[n]))?[`${n}=${e[n]}`]:[]).join(" "),pt=e=>/^[a-z-]+:\/\//i.test(e)?decodeURIComponent(e.replace(/^[a-z-]+:\/\/\/?(\.\/)?/i,"/").replace(/^\/[^/]*:\d+/,"").split("?")[0]).replace(/^\/(@fs)?/,"").replace(/^\(app-pages-browser\)\/\.?\/?/,""):e;function Zn(e){let n=(o,l=0)=>l>3?"":typeof o=="function"?o.displayName||o.name||"":o&&typeof o=="object"?o.displayName||n(o.render||o.type,l+1):"",r=o=>qo.test(o)&&!Ho.test(o),i=o=>{let l=o?._debugSource;if(l?.fileName)return`${pt(String(l.fileName))}:${l.lineNumber||0}`;let p=o?._debugStack?.stack;if(typeof p!="string")return"";for(let v of p.split(`
|
|
2
|
+
`).slice(1)){let x=/((?:https?|webpack-internal|file):\/\/[^\s()]+?):(\d+):\d+\)?\s*$/.exec(v);if(x&&!/node_modules|react-dom|react-jsx|jsx-dev-runtime|react-server|scheduler/.test(x[1]))return`${pt(x[1])} (line ${x[2]} as served, may differ from the source)`}return""},s=Object.keys(e).find(o=>o.startsWith("__reactFiber$"));if(s){let o=e[s],l=[],p="";for(let v=o?.return,x=0;v&&l.length<2&&x<80;v=v.return,x++){if(typeof v.type=="string")continue;let c=n(v.type);if(!r(c))continue;l.length||(p=i(v));let f=Hn(v.memoizedProps);l.push(f?`${c} ${f}`:c)}return l.length?{component:l.length>1?`${l[0]} (in ${l[1]})`:l[0],source:i(o)||void 0,usedAt:p||void 0}:i(o)?{source:i(o)}:{}}let a=e.__vueParentComponent;if(a?.type){let o=a.type.name||a.type.__name||(a.type.__file||"").replace(/^.*\//,"").replace(/\.vue$/,""),l=a.parent?.type,p=l&&(l.name||l.__name),v=Hn(a.props);return{component:`${o}${v?" "+v:""}${p?` (in ${p})`:""}`,source:a.type.__file?pt(a.type.__file):void 0,usedAt:l?.__file?pt(l.__file):void 0}}let u=e.__svelte_meta?.loc;return u?.file?{component:u.file.replace(/^.*\//,"").replace(/\.svelte$/,""),source:`${pt(u.file)}:${u.line??0}`}:{}}function Vn(e){let n=getComputedStyle(e),r=new Map,i="rgb(1, 2, 3)",s=document.createElement("i");s.style.cssText=`display:none;color:${i}`;let a=s.appendChild(document.createElement("i"));document.body.append(s);for(let l of[...getComputedStyle(document.documentElement)].filter(p=>p.startsWith("--")).slice(0,400)){a.style.color="",a.style.color=`var(${l})`;let p=getComputedStyle(a).color;p&&p!==i&&!r.has(p)&&r.set(p,l)}s.remove();let u=l=>r.has(l)?`${r.get(l)} ${l}`:l,o=[];return/^(transparent|rgba\(0, 0, 0, 0\))$/.test(n.backgroundColor)||o.push(`fill ${u(n.backgroundColor)}`),o.push(`text ${u(n.color)} ${n.fontSize}/${n.fontWeight}`),parseFloat(n.borderTopLeftRadius)&&o.push(`radius ${n.borderTopLeftRadius}`),K(o.join(", "),200)}function Wo(e,n,r){let i=getComputedStyle(e).transform;if(!i||i==="none")return null;let s=new DOMMatrix(i);if(s.isIdentity)return null;let a=e.offsetWidth||e.getBoundingClientRect().width,u=e.offsetHeight||e.getBoundingClientRect().height,[o,l]=getComputedStyle(e).transformOrigin.split(" ").map(parseFloat),p=(m,h)=>s.transformPoint(new DOMPoint(m-o,h-l)),v=[p(0,0),p(a,0),p(0,u),p(a,u)],x=e.getBoundingClientRect(),c={x:x.left-Math.min(...v.map(m=>m.x)),y:x.top-Math.min(...v.map(m=>m.y))},f=s.inverse().transformPoint(new DOMPoint(n-c.x,r-c.y));return{rect:{left:0,top:0,width:a,height:u},x:f.x+o,y:f.y+l}}function Fo(e,n,r,i){let s=e.getBoundingClientRect(),a=(e.getAttribute("preserveAspectRatio")||"xMidYMid meet").split(/\s+/),u=(l,p)=>{if(!l||!p||!s.width||!s.height)return;let[v,x]=[s.width,s.height];if(a[0]!=="none"){let h=(a[1]==="slice"?Math.max:Math.min)(s.width/l,s.height/p);[v,x]=[l*h,p*h]}let c=(h,w)=>h==="Min"?0:h==="Max"?w:w/2,f=a[0]==="none"?0:c(a[0].slice(1,4),s.width-v),m=a[0]==="none"?0:c(a[0].slice(5,8),s.height-x);Object.assign(n,{nw:l,nh:p,imgX:Oe((r-s.left-f)/v),imgY:Oe((i-s.top-m)/x)})},o=new Image;o.onload=()=>u(o.naturalWidth,o.naturalHeight),o.src=n.src,o.complete&&u(o.naturalWidth,o.naturalHeight)}function jo(e,n,r,i,s){let a=e.getBoundingClientRect(),u=getComputedStyle(e),o=c=>c.split(/,(?![^(]*\))/).map(f=>f.trim()),l=Math.max(0,o(u.backgroundImage).findIndex(c=>c.includes(n))),p=c=>{let f=o(c);return f[l%f.length]},v=(c,f)=>{if(!c||!f||!a.width||!a.height)return;let m=p(u.backgroundSize),h=c,w=f;if(m==="cover"||m==="contain"){let O=(m==="cover"?Math.max:Math.min)(a.width/c,a.height/f);h=c*O,w=f*O}else if(m!=="auto"&&m!=="auto auto"){let[O,P="auto"]=m.split(/\s+/),V=(X,F)=>X.endsWith("%")?parseFloat(X)/100*F:parseFloat(X);h=O==="auto"?NaN:V(O,a.width),w=P==="auto"?NaN:V(P,a.height),Number.isNaN(h)&&Number.isNaN(w)?[h,w]=[c,f]:Number.isNaN(h)?h=w*c/f:Number.isNaN(w)&&(w=h*f/c)}let[b="50%",$="50%"]=p(u.backgroundPosition).split(/\s+/),E=(O,P)=>O.endsWith("%")?parseFloat(O)/100*P:parseFloat(O)||0,M=E(b,a.width-h),z=E($,a.height-w);Object.assign(r,{nw:c,nh:f,fit:`background ${m}`,imgX:Oe((i-a.left-M)/h),imgY:Oe((s-a.top-z)/w)})},x=new Image;x.onload=()=>v(x.naturalWidth,x.naturalHeight),x.src=n,x.complete&&v(x.naturalWidth,x.naturalHeight)}function Ko(e,n){let r=[...e.children].filter(u=>u!==de&&u.getBoundingClientRect().height>0),i=null,s=null;for(let u of r){let o=u.getBoundingClientRect();if(o.bottom<=n)i=u;else if(o.top>=n&&!s)s=u;else if(o.top<n&&o.bottom>n)return null}let a=u=>{if(!u)return;let o=u.matches("h1, h2, h3, h4, h5, h6")?u:u.querySelector("h1, h2, h3, h4, h5, h6");return K(`${Ze(u)} "${K((o||u).textContent,60)}"`,160)};return i||s?{above:a(i),below:a(s)}:null}function Gn(e){for(let n=e;n;n=n.parentElement){let r=getComputedStyle(n).backgroundColor.match(/rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)(?:,\s*([\d.]+))?/);if(!r||r[4]!==void 0&&parseFloat(r[4])<.5)continue;let[i,s,a]=[r[1],r[2],r[3]].map(Number),u="#"+[i,s,a].map(o=>Math.round(o).toString(16).padStart(2,"0")).join("");return{scheme:.2126*i+.7152*s+.0722*a<128?"dark":"light",background:u}}return{scheme:matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}}function Yo(e,n,r=[]){let i=null,s=0;if(document.caretPositionFromPoint){let E=r.length?document.caretPositionFromPoint(e,n,{shadowRoots:r}):document.caretPositionFromPoint(e,n);E&&(i=E.offsetNode,s=E.offset)}else if(document.caretRangeFromPoint){let E=document.caretRangeFromPoint(e,n);E&&(i=E.startContainer,s=E.startOffset)}if(!i||i.nodeType!==3||!i.data.trim())return null;let a=document.createRange();if(a.selectNodeContents(i),![...a.getClientRects()].some(E=>e>=E.left-4&&e<=E.right+4&&n>=E.top-4&&n<=E.bottom+4))return null;let o=i.data,l=s,p=s,v=/[\u0e00-\u0e7f\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af\uf900-\ufaff]/.test(o)&&typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(i.parentElement?.closest("[lang]")?.lang||void 0,{granularity:"word"}):null;if(v){for(let E of v.segment(o))if(s>=E.index&&s<=E.index+E.segment.length&&E.segment.trim()&&(l=E.index,p=E.index+E.segment.length,s<p))break}else{for(;l>0&&/\S/.test(o[l-1]);)l--;for(;p<o.length&&/\S/.test(o[p]);)p++}let c=(i.parentElement?.closest("p, li, h1, h2, h3, h4, h5, h6, td, th, figcaption, blockquote, a, button, label, span, div")||i.parentElement)?.textContent||o,f=c.slice(0,c.indexOf(o)+l),m=c.slice(c.indexOf(o)+p),h=E=>E.replace(/\s+/g," "),w={exact:K(o.slice(l,p),80),prefix:h(f.slice(-80)).replace(/^\s+/,"").slice(-40),suffix:h(m.slice(0,80)).replace(/\s+$/,"").slice(0,40)},b=i.parentElement?.closest("pre, [data-file]")||(getComputedStyle(i.parentElement).whiteSpace.startsWith("pre")?i.parentElement:null),$=!b&&i.parentElement?.closest('table[data-file], table[class*="code" i]');if(b||$){let E=b||$,M=document.createRange();M.setStart(E,0),M.setEnd(i,s);let z=M.toString(),O=E.textContent,P=[...E.querySelectorAll("br, tr")];if((E.localName==="table"||!O.includes(`
|
|
3
|
+
`))&&P.length){let F=E.querySelectorAll("br").length?[...E.querySelectorAll("br")]:[...E.querySelectorAll("tr")].slice(0,-1),Y=F.filter(I=>I.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING&&!I.contains(i)).length,se=document.createRange();Y?se.setStartAfter(F[Y-1]):se.setStart(E,0),F[Y]?se.setEndBefore(F[Y]):se.setEnd(E,E.childNodes.length);let ee=E.querySelectorAll("br").length?null:i.parentElement?.closest("tr");w.line=K((ee?ee.textContent:se.toString()).trim(),200),w.lineNo=Y+1,w.lines=F.length+(E.querySelectorAll("br").length?0:1)}else{let F=z.lastIndexOf(`
|
|
4
|
+
`)+1,Y=O.indexOf(`
|
|
5
|
+
`,z.length);w.line=K(O.slice(F,Y<0?void 0:Y).trim(),200),w.lineNo=z.split(`
|
|
6
|
+
`).length,w.lines=O.replace(/\n$/,"").split(`
|
|
7
|
+
`).length}let V=i.parentElement?.closest("tr, [data-line], [data-line-number]");if(V){let F=V.matches("[data-line], [data-line-number]")?V:V.querySelector("[data-line], [data-line-number]"),Y=F?.getAttribute("data-line")||F?.getAttribute("data-line-number")||[...V.children].map(se=>se.textContent.trim()).find(se=>/^\d+$/.test(se));Y&&/^\d+$/.test(Y)&&(w.pageLineNo=Number(Y))}let X=E.closest("[data-file]")?.getAttribute("data-file")||E.getAttribute("title")||E.getAttribute("aria-label")||"";for(let F=E.parentElement,Y=0;!X.trim()&&F&&F!==document.body&&Y<3;F=F.parentElement,Y++)X=F.querySelector(':scope > figcaption, :scope > [class*="title" i]')?.textContent||"";X.trim()&&(w.label=K(X.trim(),120))}return w}function Ze(e){let n=[...e.attributes].filter(r=>/^(id|class|alt|role|aria-label|href|data-[\w-]+)$/.test(r.name)).map(r=>`${r.name}="${K(r.value,60)}"`);return`<${e.localName}${n.length?` ${n.join(" ")}`:""}>`.slice(0,200)}function Wn(e,n){if(!n)return!0;let r=/^<([\w-]+)/.exec(n)?.[1];if(e.localName!==r||(/ id="([^"]*)"/.exec(n)?.[1]||"")!==K(e.id||"",60))return!1;let s=(/ class="([^"]*)"/.exec(n)?.[1]||"").split(/\s+/).filter(a=>a&&a!=="\u2026"&&!a.endsWith("\u2026"));return!s.length||s.some(a=>e.classList.contains(a))}function He(e,n){let r=document.elementsFromPoint(e,n).filter(m=>m!==de&&m!==document.documentElement),i=[],s=null;for(let m=r[0];m?.shadowRoot&&!de.contains(m)&&i.length<5;m=r[0]){s||=m,i.push(m.shadowRoot);let h=m.shadowRoot.elementsFromPoint(e,n).filter(w=>w!==m);if(!h.length)break;r=[...h,...r]}let a=r[0]?.closest("[data-comment-target]")||r[0]||document.body,u=a.getBoundingClientRect(),o={selector:Xn(a),x:u.width?(e-u.left)/u.width:0,y:u.height?(n-u.top)/u.height:0,docX:(e+scrollX)/ut(),docY:n+scrollY,width:innerWidth,height:innerHeight,dpr:Math.round((devicePixelRatio||1)*100)/100,element:Ze(a),eh:Math.round(u.height)},l=K(a.textContent,200);l&&a!==document.body&&(a.textContent||"").length<400&&(o.text=K(l,80));let p=a.parentElement?.closest("[id], [data-lab]");p&&(o.inside=p.dataset.lab?`[data-lab="${p.dataset.lab}"]`:`#${p.id}`);let v=null;for(let m of document.querySelectorAll("h1, h2, h3"))(m.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING||m.contains(a))&&(v=m);v&&(o.section=K(v.textContent,100)),s&&(o.shadow=Ze(s));for(let[m,h]of Object.entries(Zn(a)))h&&(o[m]=K(h,200));a!==document.body&&(o.looks=Vn(a));let x=a.closest?.("select");x&&x.selectedIndex>=0&&(o.chosen=K(`${x.selectedIndex+1} of ${x.options.length}: "${x.options[x.selectedIndex].text}"`,120));for(let m of[a,a.parentElement])if(!(!m||m===document.body)){for(let h of["::before","::after"]){let w=getComputedStyle(m,h).content,b=w&&w.match(/^"(.+)"$/);if(b&&b[1].trim()){o.cssText=K(`"${b[1]}" from ${h} of ${Ze(m)}`,160);break}}if(o.cssText)break}let c=document.querySelector('meta[name="lab-build"]')?.content;c&&(o.build=K(c,40));let f=r.slice(0,5).find(m=>/^(img|video|canvas|svg|image)$/.test(m.localName)&&!de.contains(m));if(f?.localName==="image"&&f.namespaceURI==="http://www.w3.org/2000/svg")o.kind="image",o.src=new URL(f.getAttribute("href")||f.getAttribute("xlink:href")||"",location.href).href,o.file=qe(o.src),Fo(f,o,e,n);else if(f){let m=f.getBoundingClientRect();if(o.kind=f.localName==="img"?"image":f.localName,f.localName==="img"||f.localName==="video"){let h=f,w=f;o.src=on(f),o.file=qe(o.src),h.alt&&(o.alt=K(h.alt,120));let b=Wo(f,e,n),[$,E,M]=b?[b.rect,b.x,b.y]:[m,e,n],z=f.localName==="img"?Ot(f,$,E,M,Nt(f).nw,Nt(f).nh):Ot(f,$,E,M,w.videoWidth,w.videoHeight);if(z&&Object.assign(o,z),b&&(o.transform=K(getComputedStyle(f).transform,80)),f.localName==="img"&&/\.(gif|webp|apng)(\?|#|$)/i.test(h.currentSrc||h.src)){let O=performance.getEntriesByName(h.currentSrc||h.src)[0],P=O?(performance.now()-O.responseEnd)/1e3:performance.now()/1e3;o.shownFor=Math.round(P*10)/10}f.localName==="video"&&(o.time=Math.round(w.currentTime*10)/10,Number.isFinite(w.duration)&&(o.duration=Math.round(w.duration*10)/10),!o.file&&w.poster&&(o.file=qe(w.poster)))}else o.time=Math.round(performance.now()/100)/10,o.imgX=Oe((e-m.left)/(m.width||1)),o.imgY=Oe((n-m.top)/(m.height||1)),o.nw=Math.round(m.width),o.nh=Math.round(m.height)}else{let m=Yo(e,n,i);if(m)o.kind="text",o.quote=m;else{for(let h=a,w=0;h&&h!==document.documentElement&&w<4;h=h.parentElement,w++){let b=getComputedStyle(h).backgroundImage.match(/url\(["']?(.+?)["']?\)/);if(b){o.kind="background",o.src=new URL(b[1],location.href).href,o.file=qe(o.src),jo(h,o.src,o,e,n);break}}if(o.kind||="element",o.kind==="element"){let h=Ko(a,n);h&&Object.assign(o,{gapAbove:h.above,gapBelow:h.below})}}}Object.assign(o,Gn(a));for(let m=a;m&&m!==document.body&&m!==document.documentElement;m=m.parentElement)if(m.id){o.block=m.id;break}return o}function Jn(e){let n=null;try{n=e.selector?document.querySelector(e.selector):null}catch{}let r=h=>{if(!h)return!1;if(e.file&&/^(image|video)$/.test(e.kind)){let w=h.closest?.("img, video")||h;return qe(on(w))===e.file}if(e.element&&!Wn(h,e.element))return!1;if(e.quote?.exact){let w=(h.textContent||"").replace(/\s+/g,""),b=e.quote.exact.replace(/\s+/g,"").slice(0,24),$=(e.quote.prefix||"").replace(/\s+/g,"").slice(-10),E=(e.quote.suffix||"").replace(/\s+/g,"").slice(0,10);return w.includes(b)&&(b.length>=16||!$&&!E||w.includes($+b)||w.includes(b+E))}return!0},i=K(e.text,400),s=h=>{let w=null;for(let b of document.querySelectorAll("h1, h2, h3"))(b.compareDocumentPosition(h)&Node.DOCUMENT_POSITION_FOLLOWING||b.contains(h))&&(w=b);return w?K(w.textContent,100):""},a=h=>String(h||"").replace(/\s+/g,""),u=a(e.zoneText).slice(0,30),o=h=>e.quote?.exact?!0:i?K(h.textContent,400).startsWith(i.slice(0,40)):u?a(h.textContent).includes(u):e.section?s(h)===e.section:!0,l=n&&n!==document.body&&r(n)?n:null;if(l&&o(l))return l;if(e.file&&/^(image|video)$/.test(e.kind))return[...document.querySelectorAll("img, video")].find(h=>qe(on(h))===e.file)||null;let p=/^<([\w-]+)/.exec(e.element||"")?.[1];if(!p||p==="body"||p==="html")return l;let v=h=>K(h,400),x=null,c=-1,f=1/0,m=[...document.querySelectorAll(p)].slice(0,400).filter(h=>!de.contains(h)&&Wn(h,e.element));for(let h of m){let w=v(h.textContent),b=0;if(e.quote?.exact&&r(h)&&(b+=4),i&&w===i&&(b+=4),u&&a(h.textContent).includes(u)?b+=4:i&&w.startsWith(i.slice(0,40))&&(b+=2),!b&&m.length>1)continue;b&&e.section&&s(h)===e.section&&(b+=2);let $=Math.abs(h.getBoundingClientRect().top+scrollY-(e.docY||0));(b>c||b===c&&$<f)&&([x,c,f]=[h,b,$])}return c>0||!l?x:l}var zt=null;function Uo(e){let n=/^(?:…)?(.*?)\[([^\]]+)\](.*?)(?:…)?$/s.exec(e.text||"");if(!n)return null;let r=n[1].replace(/\s+/g," ").slice(-24),i=n[2];if(!zt||performance.now()-zt.at>400){let p=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:c=>de.contains(c.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),v="",x=[];for(let c=p.nextNode();c;c=p.nextNode()){let f=c.data.replace(/\s+/g," ");for(let m=0;m<f.length;m++)x.push([c,m]);v+=f}zt={at:performance.now(),text:v,map:x}}let{text:s,map:a}=zt,u=s.indexOf(r+i);if(u<0)return{gone:!0};u+=r.length;let o=document.createRange();try{o.setStart(...a[u]),o.setEnd(a[u+i.length-1][0],a[u+i.length-1][1]+1)}catch{return{gone:!0}}let l=o.getBoundingClientRect();return l.width||l.height?{left:l.left+scrollX+Math.min(6,l.width/2),top:l.top+scrollY+l.height/2}:{gone:!0}}var mt={at:-1/0,y:0},ft=(e,n=0)=>{if(performance.now()-mt.at>300){let r=[...document.body.children].filter(i=>i!==de&&!de.contains(i)).map(i=>i.getBoundingClientRect().bottom+scrollY);mt={at:performance.now(),y:Math.max(innerHeight,...r)}}return Math.max(0,Math.min(e,mt.y-n-40))},Fn=(e,n)=>({left:e.left+(n.pinX?e.width:0),top:e.top+(n.pinY?e.height:0)}),jn=10,Xo=30;function Zo(e){let n=s=>Math.max(jn,Math.round(s.left+scrollX-Xo)),r=String(e?.selector||"").split(" > ");for(;r.length>1;){r.pop();let s=null;try{s=document.querySelector(r.join(" > "))}catch{}if(!s||/^(html|body)$/.test(s.localName)||de.contains(s))continue;let a=s.getBoundingClientRect();if(a.width)return n(a)}let i=[...document.body.children].filter(s=>s!==de&&!de.contains(s)).map(s=>s.getBoundingClientRect()).filter(s=>s.width&&s.height);return i.length?n({left:Math.min(...i.map(s=>s.left))}):jn}function We(e){let n=Vo(e);return n.moved?{...n,left:Zo(e)}:n}function Vo(e){let n=Jn(e);if(n&&!e.zw&&!e.docW&&/^(html|body|main)$/.test(n.localName)&&/\[[^\]]+\]/.test(e.text||"")){let a=Uo(e);if(a&&!a.gone)return{left:a.left,top:a.top,zone:null};if(a?.gone)return{left:e.docX*ut(),top:ft(e.docY),zone:null,moved:!0}}if(n&&e.eh&&!e.zw&&!e.docW&&/^(html|body|main)$/.test(n.localName)&&!/\[[^\]]+\]/.test(e.text||"")&&Math.abs(n.getBoundingClientRect().height-e.eh)>40)return{left:e.docX*ut(),top:ft(e.docY),zone:null,moved:!0};if(n){let a=n.getBoundingClientRect();if(a.width||a.height){let u=a.left+scrollX+e.x*a.width,o=e.zw&&Number.isFinite(e.oy)&&e.docH&&a.height>2*e.docH,l=a.top+scrollY+(o?e.oy:e.y*a.height),p=e.zw?{left:u,top:l,width:e.zw*a.width,height:o?e.docH:e.zh*a.height}:null;return p?{...Fn(p,e),zone:p}:{left:u,top:l,zone:p}}}let r=e.docX*ut(),i=ft(e.docY,e.docH||0),s=e.docW?{left:r,top:i,width:e.docW,height:e.docH}:null;return s?{...Fn(s,e),zone:s,moved:!!e.selector&&e.selector!=="body"}:{left:r,top:i,zone:s,moved:!!e.selector&&e.selector!=="body"}}function Go(e){let n=e?.quote,r=n?.exact?Jn(e):null;if(!r)return null;let i=n.exact.replace(/\s+/g,""),s=(n.prefix||"").replace(/\s+/g,"").slice(-12);for(let a=0;r&&a<4;r=r.parentElement,a++){let u="",o=[],l=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let v=l.nextNode();v;v=l.nextNode())for(let x=0;x<v.data.length;x++)/\s/.test(v.data[x])||(u+=v.data[x],o.push([v,x]));let p=null;for(let v=u.indexOf(i);v!==-1;v=u.indexOf(i,v+1)){let x=document.createRange();x.setStart(...o[v]);let[c,f]=o[v+i.length-1];if(x.setEnd(c,f+1),!s||u.slice(0,v).endsWith(s))return x;p||=x}if(p)return p}return null}var Qn=(e,n)=>{let r=ze("b",{},String(e||"").replace(/\s*·\s*session\s+\S+$/i,""));return n&&r.append(ze("span",{class:"mark done",role:"img","aria-label":"done"},"\u2713")),r},an=!1,gt=()=>an&&Yn.get("lab-hold")==="1",Jo=e=>{let n=document.getElementById(e);return!!n&&!n.closest("[data-lab-comments]")},Qo=e=>{let n=[],r=0;for(let i of e.matchAll(/\bhttps?:\/\/[^\s<>"']*[^\s<>"'.,;:!?)\]]|(?<![\w&/#])#([A-Za-z][\w:.-]*[\w])/g)){if(i[1]&&!Jo(i[1]))continue;i.index>r&&n.push(document.createTextNode(e.slice(r,i.index)));let s=i[1]?ze("a",{href:`#${i[1]}`,class:"link"},i[0]):ze("a",{href:i[0],target:"_blank",rel:"noopener noreferrer",class:"link"},i[0]);s.addEventListener("click",a=>{a.stopPropagation(),i[1]&&(a.preventDefault(),dispatchEvent(new CustomEvent("lab-goto",{detail:i[1]})))}),n.push(s),r=i.index+i[0].length}return r<e.length&&n.push(document.createTextNode(e.slice(r))),n},ea=e=>e.split(/(?<=[.!?])\s+(?=["'([]?[A-Z0-9])/),eo=e=>{let n=[];for(let[r,i]of String(e||"").trim().split(/\n\s*\n/).entries()){let s=i.split(`
|
|
8
|
+
`);if(s.length===1&&i.length>240){let a=ea(i);for(let u=0;u<a.length;u+=2)n.push({text:a.slice(u,u+2).join(" "),gap:r>0||u>0});continue}s.forEach((a,u)=>{let o=/^\s*(?:[-•*]|\d+[.)])\s+/.exec(a),l=u>0?n.at(-1):null;o?n.push({li:/\d/.test(o[0])?o[0].trim():"\u2022",text:a.slice(o[0].length),gap:r>0&&u===0}):l&&!l.li?l.text+=`
|
|
9
|
+
${a}`:n.push({text:a,gap:r>0&&u===0||!!l})})}return n.map(r=>{let i=ze("span",{class:`p${r.li?" li":""}${r.gap?" gap":""}`});return r.li&&i.append(ze("span",{class:"mk"},r.li)),i.append(...Qo(r.text)),i})},ta=typeof Highlight=="function"&&!!CSS.highlights,Rt=e=>{if(!ta)return;let n=e&&Go(e);n?CSS.highlights.set("lab-quote",new Highlight(n)):CSS.highlights.delete("lab-quote")},rn=e=>{let n=ze("div",{class:`zone ${e}`});return n.innerHTML='<svg aria-hidden="true"><rect class="ring" width="100%" height="100%"/><rect class="dots" width="100%" height="100%"/></svg>',n},Bt=(e,n)=>{if(!e)return;let r=rn(n);return Object.assign(r.style,{left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`}),Kn.append(r),r};function to({x0:e,y0:n,x1:r,y1:i}){let s=Math.min(e,r),a=Math.min(n,i),u=Math.max(e,r),o=Math.max(n,i),l=He((s+u)/2,(a+o)/2),p=document.elementsFromPoint((s+u)/2,(a+o)/2).find(M=>M!==de&&!de.contains(M)),v=Math.max(1,(u-s)*(o-a)),x=M=>Math.max(0,Math.min(M.right,u)-Math.max(M.left,s))*Math.max(0,Math.min(M.bottom,o)-Math.max(M.top,a))/v>=.8;for(;p&&p!==document.body&&!x(p.getBoundingClientRect());)p=p.parentElement;p||=document.body;let c=p.getBoundingClientRect();Object.assign(l,{selector:p===document.body?"body":Xn(p),element:Ze(p),x:c.width?(s-c.left)/c.width:0,y:c.height?(a-c.top)/c.height:0,zw:c.width?(u-s)/c.width:0,zh:c.height?(o-a)/c.height:0,oy:Math.round(a-c.top),docX:(s+scrollX)/ut(),docY:a+scrollY,docW:Math.round(u-s),docH:Math.round(o-a),pinX:r>=e?1:0,pinY:i>=n?1:0}),Object.assign(l,Gn(p)),l.kind==="text"&&(delete l.quote,l.kind="element");let f=p===document.body?"":K(p.textContent,200);f&&(p.textContent||"").length<400?l.text=K(f,80):delete l.text,p!==document.body&&(l.looks=Vn(p));let m=[],h=document.createTreeWalker(p,NodeFilter.SHOW_TEXT),w=document.createRange();for(let M=h.nextNode();M&&m.length<80;M=h.nextNode()){if(de.contains(M))continue;let z=M.parentElement?.getBoundingClientRect();if(!(!z||z.bottom<a||z.top>o||z.right<s||z.left>u))for(let O of M.data.matchAll(/\S+/g)){w.setStart(M,O.index),w.setEnd(M,O.index+O[0].length);let P=w.getBoundingClientRect(),V=(P.left+P.right)/2,X=(P.top+P.bottom)/2;P.width&&V>=s&&V<=u&&X>=a&&X<=o&&m.push(O[0])}}let b=K(m.join(" "),300);b&&(l.zoneText=b);let $=[],E=p.querySelectorAll("*");for(let M=0;M<E.length&&M<3e3;M++){let z=E[M];if(de.contains(z)||$.some(P=>P.contains(z)))continue;let O=z.getBoundingClientRect();O.width<8||O.height<8||O.left<s-4||O.right>u+4||O.top<a-4||O.bottom>o+4||$.push(z)}if($.length&&(l.zoneItems=$.slice(0,5).map(M=>{let z=Zn(M),O=K(M.textContent,50);return K([Ze(M),O&&`"${O}"`,z.component,z.source&&`written at ${z.source}`,z.usedAt&&`used at ${z.usedAt}`].filter(Boolean).join(" \xB7 "),500)}),$.length>5&&l.zoneItems.push(`and ${$.length-5} more`)),/^(img|video)$/.test(p.localName)){let M=p.localName==="img"?Nt(p).nw:p.videoWidth,z=p.localName==="img"?Nt(p).nh:p.videoHeight,O=Ot(p,c,s,a,M,z),P=Ot(p,c,u,o,M,z);O&&P&&Object.assign(l,{imgX:O.imgX,imgY:O.imgY,imgX2:P.imgX,imgY2:P.imgY})}else(l.kind==="image"||l.kind==="video")&&(delete l.imgX,delete l.imgY,l.kind="element");return l}var na=()=>window.__lab||null;function Pt(e){let n=na();n&&(n.writing=Math.max(0,e),n.writing||n.flush())}var ht;function no(e){ht=e}var Ne=new Set,Dt=new Set,oo=()=>Ne.size>0,oa=e=>{e.value.trim()?Ne.add(e):Ne.delete(e),Pt(Ne.size),ht?.whileWriting?.()},aa='<i class="arr" aria-hidden="true"></i>';function sn({placeholder:e,onSubmit:n,autofocus:r=!1,empty:i="",nameFirst:s=!1,draftKey:a=""}){let{el:u,store:o,root:l,refreshPinCursor:p,syncReads:v,rememberMe:x}=ht,c=u("div",{class:"composer"}),f=u("div",{class:"box"}),m=u("textarea",{placeholder:e,maxlength:"2000",rows:"1","aria-label":e,enterkeyhint:"send",autocomplete:"off",autocorrect:"off",spellcheck:"false",writingsuggestions:"false"}),h=u("label",{class:"who"}),w=u("span",{},"as"),b=u("input",{type:"text",name:"search-lab-who",placeholder:"your name",maxlength:"60",enterkeyhint:"send",autocomplete:"off",autocorrect:"off",autocapitalize:"words",spellcheck:"false",writingsuggestions:"false","data-1p-ignore":"","data-lpignore":"true"});if(b.value=o.get("lab-name"),a&&!Dt.has(a)){let I=o.get(a);I&&(m.value=I,queueMicrotask(()=>P()))}let $=()=>{a&&o.set(a,m.value.trim()?m.value:"")},E=()=>{Ne.delete(m),Pt(Ne.size),ht?.whileWriting?.(),a&&o.set(a,"")};h.append(w,b);let M=u("button",{class:"send",type:"button","aria-label":"send"});M.addEventListener("pointerdown",I=>I.preventDefault()),M.addEventListener("mousedown",I=>I.preventDefault()),M.innerHTML=aa;let z=u("div",{class:"error"});f.append(m,u("div",{class:"line"}),h,M),c.append(f,z),f.addEventListener("click",I=>{I.target!==f&&!I.target.classList?.contains("line")||(m.focus({preventScroll:!0}),m.setSelectionRange(m.value.length,m.value.length))});let O=null;for(let I of[m,b])I.addEventListener("touchstart",te=>O={x:te.touches[0].clientX,y:te.touches[0].clientY},{passive:!0}),I.addEventListener("touchend",te=>{let le=te.changedTouches[0];!O||Math.hypot(le.clientX-O.x,le.clientY-O.y)>10||l.activeElement===I||(te.preventDefault(),I.focus({preventScroll:!0}),I.setSelectionRange(I.value.length,I.value.length))},{passive:!1});let P=()=>{let I=s||m.value.length>0||l.activeElement===b||!!z.textContent,te=I!==f.classList.contains("open")&&!o.get("lab-name")&&f.isConnected&&!matchMedia("(prefers-reduced-motion: reduce)").matches,le=te&&{arrow:M.getBoundingClientRect(),height:f.getBoundingClientRect().height},ne=!!o.get("lab-name");if(f.classList.toggle("one",ne),f.classList.toggle("open",I),w.hidden=!b.value.trim(),ne&&!CSS.supports?.("field-sizing","content")&&(b.style.width=`${Math.max(2,b.value.length+1)}ch`),M.classList.toggle("ready",!!((m.value.trim()||i)&&b.value.trim())),oa(m),m.style.height="auto",m.style.height=`${m.scrollHeight}px`,te){let be=M.getBoundingClientRect(),Be={duration:220,easing:"cubic-bezier(.2, .7, .3, 1)"};M.animate([{transform:`translate(${le.arrow.left-be.left}px, ${le.arrow.top-be.top}px)`},{transform:"none"}],Be),f.style.overflow="hidden",f.animate([{height:`${le.height}px`},{height:`${f.getBoundingClientRect().height}px`}],Be).onfinish=()=>f.style.overflow=""}},V=!1,X=async()=>{if(V)return;let I=m.value.trim()||i;if(!I)return m.focus();if(!b.value.trim())return f.classList.add("open"),b.focus();o.set("lab-name",b.value.trim()),x(b.value.trim()),p(),v(),M.classList.remove("sent"),M.offsetWidth,M.classList.add("sent"),V=!0;let te=m.value;a&&Dt.add(a),z.textContent="",z.classList.remove("wait");let le=setTimeout(()=>{z.textContent="sending\u2026 it goes as soon as the lab is back",z.classList.add("wait")},1500);try{let ne=await n(b.value.trim(),I);E(),a&&Dt.delete(a),clearTimeout(le),z.textContent="",z.classList.remove("wait"),ne?.keep&&(m.value="",P())}catch(ne){clearTimeout(le),z.classList.remove("wait"),z.textContent=ne.message,a&&Dt.delete(a),m.value=te,$(),P()}V=!1},F=I=>{I.key==="Enter"&&!I.shiftKey&&!I.isComposing&&(I.preventDefault(),X())};m.addEventListener("input",P),m.addEventListener("input",$),new MutationObserver(()=>{c.isConnected||(Ne.delete(m),Pt(Ne.size),ht?.whileWriting?.())}).observe(document.documentElement,{childList:!0,subtree:!0}),b.addEventListener("input",P),b.addEventListener("blur",()=>setTimeout(P,0)),m.addEventListener("keydown",F),b.addEventListener("keydown",F);let Y=0;M.addEventListener("touchend",I=>{I.preventDefault(),Y=Date.now(),X()},{passive:!1}),M.addEventListener("click",()=>{Date.now()-Y<700||X()}),M.addEventListener("mousedown",I=>I.preventDefault()),requestAnimationFrame(P);let se=s?b:m;s&&b.setAttribute("data-first","");let ee=()=>se.focus({preventScroll:!0});return r&&queueMicrotask(()=>se.isConnected?ee():setTimeout(ee,0)),c}var ao;function ro(e){ao=e}var io=e=>{let n=e.anchor||{},r=n.quote?.exact||"",i=null;try{i=!r&&n.selector?document.querySelector(n.selector):null}catch{}for(let s=0;i&&i!==document.body&&s<5;i=i.parentElement,s++){let a=i.innerText?.replace(/\s+/g," ").trim()||"";if(a.length>=12){r=a;break}}return r=(r||n.text||n.section||"").replace(/\s+/g," ").trim(),r?`"${r.length>40?`${r.slice(0,39)}\u2026`:r}"`:""},so=(e,n,r="")=>{let{el:i,mine:s,repliesOf:a,workState:u}=ao,o=new Date(e.createdAt),l=o.toDateString()===new Date().toDateString()?o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString([],{day:"numeric",month:"short"}),p=i("span",{class:"stamp"});if(p.append(i("span",{class:"tm"},r+l)),s(e)&&!e.session){let v=n?[n,...a(n.id)]:[e],x=v.some(f=>f.session&&f.createdAt>e.createdAt),c=!v.some(f=>!f.session&&f.createdAt>e.createdAt);if(!x&&c&&n&&u(n)[0]==="now")p.classList.add("busy"),p.append(i("span",{class:"ring",role:"img","aria-label":"the agent is on it"}));else if(x)p.classList.add("ans"),p.append(i("span",{class:"tick",role:"img","aria-label":"answered"},"\u2713"));else{let f=n?.handedAt&&n.handedAt>=e.createdAt;p.append(i("span",{class:`tick${f?" got":""}`,role:"img","aria-label":f?"delivered to the agent":"sent"},f?"\u2713\u2713":"\u2713"))}}return p};var S;function lo(e){S=e}var ra=e=>!!e.closest?.(".handle, .tabs"),ia=(e,n)=>e.composedPath().find(r=>r instanceof HTMLElement&&n.contains(r)&&(r.localName==="textarea"||/auto|scroll/.test(getComputedStyle(r).overflowY))),bt="cubic-bezier(.32,.72,0,1)",sa=["top","bottom","height","max-height","transform","transition","animation","pointer-events","opacity","transform-origin"],ln={x:0,y:0,at:-1e9};function cn(e,n){let r=n||(performance.now()-ln.at<1500?ln:null);if(!r)return e.style.removeProperty("--lab-from");e.style.setProperty("--lab-from",`${Math.round(r.x-e.offsetLeft)}px ${Math.round(r.y-e.offsetTop)}px`)}var It=null;function co(){!S.coarse||!S.host.hasAttribute("data-kb")||S.still.matches||(It??=S.el("input",{"aria-hidden":"true",tabindex:"-1",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false",writingsuggestions:"false",style:"position:fixed;top:0;left:-200px;width:1px;height:1px;opacity:0;font-size:16px;pointer-events:none"}),It.isConnected||S.root.append(It),It.focus({preventScroll:!0}))}function dn(e,n=0,r){let i=r?360:n||200,s=n?"linear":"cubic-bezier(.4, 0, .9, .4)",a=0;try{a=new DOMMatrixReadOnly(getComputedStyle(e).transform).m42||0}catch{}let u=e.getBoundingClientRect(),o=u.top-a,l=getComputedStyle(S.scrim).opacity;for(let[c,f]of[["top",`${o}px`],["bottom","auto"],["height",`${u.height}px`],["max-height","none"],["animation","none"],["transition","none"],["transform",r?"":`translateY(${a}px)`],["pointer-events","none"]])e.style.setProperty(c,f,"important");S.host.setAttribute("data-leaving",""),S.scrim.style.transition="none",S.scrim.style.opacity=l;let p=()=>S.root.activeElement?.blur();r?setTimeout(p,i):p();let x=(r?null:S.root.querySelector(e.classList.contains("card")?".pin.open":e.classList.contains("float")?".pin.draft":"none"))?.getBoundingClientRect();if(x&&cn(e,{x:x.left+x.width/2,y:x.top+x.height/2}),e.offsetHeight,r){e.style.setProperty("transform-origin","50% 50%","important");let c=r.x-(u.left+u.width/2),f=r.y-(o+u.height/2),m=()=>{e.animate([{transform:"none"},{transform:`translate(${c}px, ${f}px) scale(${22/u.width}, ${22/u.height})`}],{duration:i,easing:bt,fill:"forwards"}),e.animate([{opacity:1},{opacity:1,offset:.7},{opacity:0}],{duration:i,fill:"forwards"})};requestAnimationFrame(()=>requestAnimationFrame(m))}else n?(e.style.setProperty("transition",`transform ${i}ms ${s}`,"important"),e.style.setProperty("transform",`translateY(${Math.max(u.height,innerHeight-o)+8}px)`,"important")):(e.style.setProperty("transition",`transform ${i}ms ${s}, opacity ${i}ms ease-in`,"important"),e.style.setProperty("transform",`translateY(${a}px) scale(.3)`,"important"),e.style.setProperty("opacity","0","important"));return S.scrim.style.transition=`opacity ${i}ms ${s}`,S.scrim.style.opacity="0",r?i+120:i}function pn(e){for(let n of sa)e.style.removeProperty(n);S.host.removeAttribute("data-leaving"),S.scrim.style.opacity=S.scrim.style.transition=""}function qt(e,n,r=0){if(!S.coarse||!e||S.still.matches)return n();let i=dn(e,r);S.bar.style.transition=`transform ${i}ms cubic-bezier(.2, .6, .4, 1), opacity ${i}ms`,S.host.style.setProperty("--lab-p","1"),setTimeout(()=>{n(),pn(e),S.bar.style.transition="",S.host.style.removeProperty("--lab-p")},i)}function po(){let e=S.root.querySelector(".float:not(.out)"),n=S.root.querySelector(".pin.draft");if(!S.coarse||!e||!n||!S.vv)return;let r=innerHeight-S.vv.height,i=r>60?r:S.S.kbSeen||Math.round(innerHeight*.42),s=innerHeight-i-e.offsetHeight-8,a=n.getBoundingClientRect(),u=56;(a.top<u||a.bottom>s-16)&&un(scrollY+(a.top+a.bottom)/2-(u+s)/2)}function un(e){if(S.coarse){let n=document.documentElement,r=parseFloat(n.style.getPropertyValue("--lab-room"))||0,i=Math.max(0,Math.ceil(e+innerHeight-(n.scrollHeight-r)));n.style.setProperty("--lab-room",`${i}px`),n.classList.toggle("lab-room",i>0)}scrollTo({top:Math.max(0,e),behavior:S.still.matches?"auto":"smooth"})}function mn(){let e=matchMedia("(pointer: coarse)").matches&&S.host.hasAttribute("data-sheet");if(!e&&S.S.backWatcher){let n=S.S.backWatcher;S.S.backWatcher=null,n.destroy()}if(e&&!S.S.backWatcher&&"CloseWatcher"in window)try{let n=new window.CloseWatcher;n.onclose=()=>{S.S.backWatcher===n&&(S.S.backWatcher=null),S.closeOrNudge(),mn()},S.S.backWatcher=n}catch{}}function xt(e,n,r=!1){if(!S.coarse)return;let i=0,s=-1e9,a=-1e9;e.addEventListener("scroll",()=>s=performance.now(),{capture:!0,passive:!0}),e.addEventListener("click",b=>{performance.now()-a<200&&(b.preventDefault(),b.stopPropagation())},!0),e.addEventListener("focusin",b=>{performance.now()-a<200&&b.target.localName==="textarea"&&b.target.blur()});let u=0,o=0,l=0,p=0,v=null,x=null,c=null,f=!1,m=b=>{if(f=b.currentTarget===S.scrim,f&&S.openSheet()!==e)return void(x="off");let $=b.touches[0];u=$.clientX,o=$.clientY,l=p=i=0,v={y:o,at:b.timeStamp},c=f?null:ia(b,e),x=b.touches.length>1||c?.localName==="textarea"?"off":null};e.addEventListener("touchstart",m,{passive:!0}),S.scrim.addEventListener("touchstart",m,{passive:!0});let h=b=>{if(f!==(b.currentTarget===S.scrim))return;let $=b.touches[0];if(x==="off"&&c&&c.localName!=="textarea"&&b.touches.length===1&&b.cancelable&&c.scrollTop<=0&&$.clientY>v.y+1&&(x="drag",o=$.clientY,p=0,v={y:$.clientY,at:b.timeStamp}),x==="off")return void(v={y:$.clientY,at:b.timeStamp});if(x==="hold")return b.preventDefault();if(!x){let z=$.clientY-o,O=$.clientX-u;if(!z&&!O)return;let P=Math.abs(O)>Math.abs(z),V=!P&&z>0&&o-e.getBoundingClientRect().top<e.offsetHeight*.25;if(f?x=P?"hold":"drag":ra(b.target)?x=P&&b.target.closest(".tabs")?"off":"drag":V&&c?.localName!=="textarea"?x="drag":c?x=!P&&z>0&&c.scrollTop<=0&&performance.now()-s>100?"drag":"off":x=P?"hold":"drag",S.S.dbg?.(`touch ${String(b.target.className||b.target.localName).slice(0,20)} at ${Math.round(o-e.getBoundingClientRect().top)}/${e.offsetHeight} down${Math.round(z)} \u2192 ${x}${b.cancelable?"":" (not cancelable)"}${c?` box${Math.round(c.scrollTop)}`:""}`),x==="off")return;if(x==="hold")return b.preventDefault()}b.preventDefault(),i=$.clientY-o;let E=e.offsetHeight||400;l=i>=0?i:-(1-1/(-i*.55/E+1))*E,b.timeStamp>v.at&&(p=.8*(($.clientY-v.y)/(b.timeStamp-v.at))+.2*p),v={y:$.clientY,at:b.timeStamp},e.style.transition=S.scrim.style.transition="none",e.style.transform=`translateY(${l}px)`;let M=Math.min(1,Math.max(0,l/Math.max(100,innerHeight-(e.getBoundingClientRect().top-l))));S.scrim.style.opacity=String(1-M),S.bar.style.transition="none",S.host.style.setProperty("--lab-p",String(M))};e.addEventListener("touchmove",h,{passive:!1}),S.scrim.addEventListener("touchmove",h,{passive:!1});let w=b=>{if(f!==(b.currentTarget===S.scrim))return;let $=x;if(x=null,$==="drag"&&(S.S.sheetDraggedAt=performance.now()),$!=="drag")return;a=performance.now(),b.timeStamp-v.at>80&&(p=0);let E=e.offsetHeight||innerHeight,M=()=>{e.style.transition=`transform 380ms ${bt}, height 380ms ${bt}`,S.scrim.style.transition="opacity 300ms",e.style.transform=S.scrim.style.opacity="",S.bar.style.transition="",S.host.style.removeProperty("--lab-p"),setTimeout(()=>e.style.transition=S.scrim.style.transition="",400)};if(r&&!e.classList.contains("full")&&(i<-40||p<-.4))return e.classList.add("full"),e.classList.contains("card")&&(S.S.cardFull=!0),M();if(r&&e.classList.contains("full")&&p<1.2&&(i>60||p>.4))return e.classList.remove("full"),e.classList.contains("card")&&(S.S.cardFull=!1),M();let z=l+Math.max(0,p)*499;if(S.S.dbg?.(`let go: moved ${Math.round(l)} speed ${p.toFixed(2)} rest ${Math.round(z)} of half ${Math.round(E/2)} \u2192 ${p>-.1&&z>E/2?"close":"stay"}`),p>-.1&&z>E/2)return qt(e,n,Math.min(320,Math.max(140,(innerHeight-e.getBoundingClientRect().top)/Math.max(p,1.2))));e.style.transition=`transform 380ms ${bt}`,S.scrim.style.transition="opacity 300ms",e.style.transform=S.scrim.style.opacity="",S.bar.style.transition="",S.host.style.removeProperty("--lab-p"),setTimeout(()=>e.style.transition=S.scrim.style.transition="",400)};e.addEventListener("touchend",w),S.scrim.addEventListener("touchend",w),S.scrim.addEventListener("touchcancel",w),e.addEventListener("touchcancel",w)}function uo(){if(S.coarse&&S.vv){let e=S.el("i",{style:"position:fixed;top:0;bottom:0;left:0;width:0;visibility:hidden;pointer-events:none"}),n=S.el("i",{style:"position:absolute;left:0;width:100vw;display:none;background:var(--_bg);z-index:3;pointer-events:none"});S.root.append(e,n);let r="",i=()=>{let s=Math.abs(S.vv.scale-1)>.01,a=e.getBoundingClientRect(),u=S.root.activeElement||document.activeElement,o=/^(textarea|input|select)$/.test(u?.localName||"")||!!u?.isContentEditable,l=s||!o?0:S.vv.offsetTop,p=(l?l+a.top:0)+S.vv.height,v=s?0:Math.max(0,Math.round(a.bottom-p)),x=s?0:Math.max(0,Math.round(p-a.bottom)),c=s?0:Math.round(S.vv.height),f=S.host.hasAttribute("data-sheet"),m=`${v} ${c} ${x} ${f} ${scrollY} ${Math.round(l)}`;if(m===r){let E=f?S.openSheet():null;E?.offsetHeight&&!E.style.transform&&Object.assign(i,{sheet:E,top:E.offsetTop});return}r=m,S.host.style.setProperty("--lab-kb",`${v}px`),S.host.style.setProperty("--lab-top",`${Math.round(l)}px`),c?S.host.style.setProperty("--lab-vh",`${c}px`):S.host.style.removeProperty("--lab-vh"),S.host.toggleAttribute("data-kb",v>60),n.style.display=f&&x?"block":"none",n.style.top=`${Math.round(scrollY+a.bottom)}px`,n.style.height=`${x}px`;let h=f?S.openSheet():null,w=Math.abs((i.vh||c)-c)>60||i.kbUp!==v>60,b=h&&h===i.sheet&&w&&!h.style.transform&&!S.still.matches;b&&(h.style.transition="none",h.offsetHeight);let $=h?h.offsetTop:null;b&&Math.abs(i.top-$)<=8&&(h.style.transition=""),b&&Math.abs(i.top-$)>8&&(h.style.transform=`translateY(${i.top-$}px)`,h.offsetHeight,h.style.transition=`transform 340ms ${bt}`,h.style.transform="",clearTimeout(i.done),i.done=setTimeout(()=>!h.style.transform&&(h.style.transition=""),360)),Object.assign(i,{vh:c,kbUp:v>60},h?.offsetHeight?{sheet:h,top:$}:{sheet:null}),v>60&&(S.S.kbSeen=v)};if(S.S.refit=i,S.root.addEventListener("focusin",()=>setTimeout(i,50)),S.root.addEventListener("focusout",()=>setTimeout(i,50)),S.vv.addEventListener("resize",i),S.vv.addEventListener("scroll",i),addEventListener("pointerdown",s=>ln={x:s.clientX,y:s.clientY,at:performance.now()},{capture:!0,passive:!0}),i(),globalThis.__LAB_DEBUG__!==!1&&/[?&]kbdebug\b/.test(location.search)){let s=[],a=performance.now(),u=0,o=v=>{let x=S.openSheet(),c=x?.getBoundingClientRect();s.push(`${Math.round(performance.now()-a)} ${v} h${Math.round(S.vv.height)} top${Math.round(S.vv.offsetTop)} in${innerHeight} kb${S.host.hasAttribute("data-kb")?1:0}`+(c?` sheet${Math.round(c.top)}/${Math.round(c.height)}${x.getAnimations().length?" anim":""}`:"")+` [${[...document.getAnimations(),...S.root.getAnimations()].map(f=>f.animationName||f.transitionProperty||"js").slice(0,6).join(",")}] scrim${getComputedStyle(S.scrim).opacity.slice(0,4)} scroll${Math.round(scrollY)}`)},l=v=>{o(v);let x=performance.now()+1500,c="",f=()=>{let m=s.length;o("f");let h=s[s.length-1].replace(/^\d+ f /,"");h===c&&(s.length=m),c=h,performance.now()<x&&requestAnimationFrame(f)};requestAnimationFrame(f)};S.root.addEventListener("focusin",()=>(a=performance.now(),l("focus")));let p=()=>{clearTimeout(u),u=setTimeout(async()=>{let v=s.join(`
|
|
10
|
+
`);s=[];for(let x=0;x<v.length;x+=1900)await S.send({name:"kb-log",text:v.slice(x,x+1900),anchor:{kind:"page",selector:"body",x:0,y:0,docX:0,docY:0,width:innerWidth}}).catch(()=>{})},2e3)};S.root.addEventListener("focusout",()=>{s.push("--- let go"),a=performance.now(),l("blur"),p()}),S.S.dbg=v=>{s.push(`${Math.round(performance.now()-a)} ${v}`),p()},S.vv.addEventListener("resize",()=>{l("resize"),s.length>1&&p()})}}}var g;function mo(e){g=e}var Ve=(e,n=!1)=>{g.S.stepping=!!g.S.openId,g.S.keepKeys=g.S.stepping&&(n||g.root.activeElement?.localName==="textarea"),g.S.openId=e.id,g.S.draft=null,g.coarse&&(g.S.listOpen=!1),g.render();let r=g.position(e.anchor||{}).top,i=r-Math.max(40,g.coarse&&g.S.openCard?.isConnected?(innerHeight-g.S.openCard.offsetHeight)/2:innerHeight/3);if(!g.coarse&&g.S.openCard?.isConnected){let a=g.S.openCard.getBoundingClientRect().bottom+scrollY-r+28;i=a<=innerHeight-80?r-28-(innerHeight-a)/2:r-40}un(i)};function Fe(){let e=g.threads();g.listBtn.hidden=!g.S.on||!g.coarse&&!e.length&&!g.held().length,g.goBtn.hidden=!g.S.on,g.goBtn.firstElementChild||g.goBtn.replaceChildren(g.el("span",{class:"gp"},"go"),g.el("kbd",{"aria-hidden":"true"},"1/2/3/4")),g.goFace(),g.goBtn.classList.toggle("on",(g.S.goMode||!!g.S.zoomMode)&&!g.S.cursorMode),g.goBtn.classList.toggle("cursor",g.S.cursorMode),g.goBtn.setAttribute("aria-pressed",String((g.S.goMode||!!g.S.zoomMode)&&!g.S.cursorMode));let n=e.filter(l=>!g.isPage(l)).reduce((l,p)=>l+g.unread(p).length,0);if(g.listBtn.replaceChildren(document.createTextNode(n?`list \xB7 ${n} new`:"list"),g.el("kbd",{"aria-hidden":"true"},"l")),g.newPrev.hidden=g.newNext.hidden=!g.S.on||!e.some(l=>!g.isPage(l)&&g.unread(l).length),!g.LIST_WINDOW){g.newPrev.hidden=g.newNext.hidden=!0,g.listBtn.hidden=!g.S.on,g.listBtn.replaceChildren(g.coarse?"new":g.keyWord("ne","w",""),g.el("b",{class:`cnt${n?"":" zero"}`},String(n))),g.listBtn.setAttribute("aria-label",`next new comment, ${n} new`),g.listBtn.setAttribute("aria-keyshortcuts","w"),g.listBtn.title="next new comment: W, or Control-D while typing (Shift for the one before)",g.listBtn.disabled=!n,g.listBtn.classList.toggle("quiet",!n);let l=e.filter(p=>!g.isPage(p)&&(p.resolved||Re(p)[0]==="done")&&!g.unread(p).length).length;g.doneBtn.hidden=!g.S.on,g.doneBtn.disabled=!l&&!g.S.showDone,g.doneBtn.classList.toggle("quiet",g.doneBtn.disabled),g.doneBtn.replaceChildren(g.S.showDone?`hide done \xB7 ${l}`:`show done \xB7 ${l}`,g.el("kbd",{"aria-hidden":"true"},"d")),g.doneBtn.setAttribute("aria-keyshortcuts","d")}g.placeBar();let r=e.reduce((l,p)=>l+g.unread(p).length,0);(!g.tabTitle.base||!document.title.startsWith("("))&&(g.tabTitle.base=document.title.replace(/^\(\d+\) /,""));let i=r?`(${r}) ${g.tabTitle.base}`:g.tabTitle.base;document.title!==i&&(document.title=i),g.listBtn.classList.toggle("has-new",n>0);let s=g.held().length;if(g.sendBtn.hidden=!s,g.sendBtn.textContent=`send ${s} draft${s===1?"":"s"}`,g.listEl.hidden=!g.S.on||!g.S.listOpen,g.listEl.hidden)return;for(let l of g.listEl.querySelectorAll("[data-f]"))l.classList.toggle("on",l.dataset.f===g.S.filter);let a=e.filter(l=>!g.isPage(l)&&g.unread(l).length).length;g.listEl.querySelector('[data-f="new"]').textContent=a?`new \xB7 ${a}`:"new";for(let l of["work","resolved","mine"])g.$(`[data-f="${l}"]`,g.listEl).hidden=!0;g.holdBtn.hidden=!g.DRAFT_MODE;let u=e.filter(l=>!g.isPage(l)&&(l.resolved||Re(l)[0]==="done")&&!g.unread(l).length).length;if(g.showDoneBtn.hidden=!u,g.showDoneBtn.textContent=g.S.showDone?`hide done \xB7 ${u}`:`show done \xB7 ${u}`,g.holdBtn.classList.toggle("on",g.drafting()),g.S.filter==="work")return g.listEl.querySelector(".items").replaceChildren(...la());let o=g.listed().map(l=>{let p=g.el("button",{class:`it${g.S.openId===l.id?" cur":""}`,type:"button"});return p.append(document.createTextNode(`${l.resolved?"\u2713":g.numberOf(l)} ${l.text.replace(/\s+/g," ").slice(0,70)} `),...g.onWhat(l)?[g.el("span",{},`on ${g.onWhat(l)} `)]:[],g.el("span",{},`\xB7 ${l.name}${!l.resolved&&g.isDone(l)?" \xB7 \u2705 done":""}`),...g.unread(l).length?[" ",g.el("span",{class:"tag"},`${g.unread(l).length} new`)]:[]),p.addEventListener("click",()=>Ve(l)),p});g.listEl.querySelector(".items").replaceChildren(...o.length?o:[g.el("div",{class:"none"},"nothing here")])}var Re=e=>{let n=[e,...g.repliesOf(e.id)],r=n.filter(a=>!a.session).map(a=>a.createdAt).sort().at(-1)||"",i=n.filter(a=>a.session).sort((a,u)=>a.createdAt.localeCompare(u.createdAt)).at(-1),s=i&&i.createdAt>r;return e.resolved||s&&/^done\b/i.test(i.text)?["done",s?i.createdAt:e.createdAt]:s&&/^on it\b/i.test(i.text)?["now",i.createdAt]:!s&&e.handedAt&&e.handedAt>=r?["now",e.handedAt]:s?[null,""]:["next",r]};function la(){let e=new Date().toDateString(),n=[],r=[],i=[];for(let o of g.S.comments.filter(l=>!l.parent)){let[l,p]=Re(o);l==="now"?n.push([o,p]):l==="next"?r.push([o,p]):l==="done"&&new Date(p).toDateString()===e&&i.push([o,p])}let s=([o,l],p)=>{let v=g.el("button",{class:`it${g.S.openId===o.id?" cur":""}`,type:"button"});return v.append(document.createTextNode(`${g.isPage(o)?"chat":o.resolved?"\u2713":g.numberOf(o)} ${o.text.replace(/\s+/g," ").slice(0,70)} `),g.el("span",{},`\xB7 ${p(l)}`)),v.addEventListener("click",()=>g.isPage(o)?(g.S.chatOpen=!0,g.S.listOpen=!1,g.render()):Ve(o)),v},a=(o,l,p,v=!1)=>l.length?[g.el("div",{class:"group"},`${o} \xB7 ${l.length}`),...l.sort((x,c)=>(v?-1:1)*x[1].localeCompare(c[1])).map(x=>s(x,p))]:[],u=[...a("Now",n,o=>`on it ${g.ago(o)}`.replace("on it just now","just started")),...a("Next",r,o=>`sent ${g.ago(o)} ago`.replace("just now ago","just now")),...a("Done today",i,o=>new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),!0)];return u.length?u:[g.el("div",{class:"none"},"nothing in progress on this page")]}var Ge=e=>{let n=g.threads().filter(l=>!g.isPage(l)&&g.unread(l).length);if(!n.length)return;let r=l=>g.position(l.anchor||{}).top;n.sort((l,p)=>r(l)-r(p));let i=g.S.openId&&g.threads().find(l=>l.id===g.S.openId),s=i?r(i):null,a=s==null?-1:n.findIndex(l=>r(l)>s),u=n.findIndex(l=>l.id===g.S.openId),o=u>=0?(u+e+n.length)%n.length:s==null?e>0?0:n.length-1:e>0?a<0?0:a:((a<0?n.length:a)-1+n.length)%n.length;g.S.chatOpen=!1,Ve(n[o],!g.coarse)};var C;function fo(e){C=e}var fn=(e,n)=>{let r=n.cloneNode(!0);r.className="stamp-room",r.setAttribute("aria-hidden","true");for(let s of r.querySelectorAll("[role]"))s.removeAttribute("role");([...e.children].reverse().find(s=>s.classList?.contains("p"))||e).append(r),e.append(n)};function Ht(){let e=new Map(C.S.comments.map(c=>[c.id,c])),n=C.S.comments.filter(c=>C.isPage(c)||c.parent&&C.isPage(e.get(c.parent)||{})).sort((c,f)=>c.createdAt.localeCompare(f.createdAt)).slice(-150);C.S.on&&C.S.chatOpen&&C.chatEl.hidden&&(C.S.newFrom=n.find(C.isNew)?.id||null),C.S.chatOpen||(C.S.newFrom=null),C.S.on&&C.S.chatOpen&&C.markSeen(n.filter(C.isNew));let r=n.filter(C.isNew).length;C.chatBtn.hidden=!C.S.on;{let c=C.chatBtn.querySelector(".mark");for(;C.chatBtn.lastChild&&C.chatBtn.lastChild!==c;)C.chatBtn.lastChild.remove();C.chatBtn.append(C.coarse?"chat":C.keyWord("","c","hat"),C.el("b",{class:`cnt${r?"":" zero"}`},String(r))),C.chatBtn.setAttribute("aria-label",`chat, ${r} new`),C.chatBtn.setAttribute("aria-keyshortcuts","c")}C.chatBtn.classList.toggle("has-new",r>0),C.placeBar();let i=C.chatEl.hidden;if(C.chatEl.hidden=!C.S.on||!C.S.chatOpen,C.chatEl.hidden&&C.chatEl.classList.remove("full"),C.chatEl.hidden&&C.chatEl.contains(C.root.activeElement)&&C.root.activeElement.blur(),C.chatEl.hidden)return;let s=C.$(".msgs",C.chatEl),a=i||s.scrollHeight-s.scrollTop-s.clientHeight<48,u=new Set(i?[]:[...s.children].map(c=>c.dataset.id)),o=new Map([...s.children].filter(c=>c.dataset.id).map(c=>[c.dataset.id,c])),l=c=>{let f=o.get(c.dataset?.id);return f&&f.outerHTML.replace(" fresh","")===c.outerHTML?f:c};C.patchKids(s,n.flatMap(c=>{let f=c.parent?e.get(c.parent):c,m=C.el("div",{class:`msg${C.mine(c)&&!c.session?" mine":""}${f&&C.S.replyTo===f.id?" to":""}${u.size&&!u.has(c.id)?" fresh":""}`,"data-id":c.id,...C.agentOf(c)?{"data-agent":C.agentOf(c)}:{}});if(m.append(C.nameLine(c.name,!1)),c.parent&&f){let h=C.el("div",{class:"quote"});h.append(C.el("b",{},String(f.name||"").replace(/\s*·\s*session\s+\S+$/i,"")),document.createTextNode(f.text.replace(/\s+/g," ").slice(0,90))),h.addEventListener("click",w=>{w.stopPropagation();let b=C.$(".msgs",C.chatEl),$=C.$(`[data-id="${f.id}"]`,b);$&&(b.scrollTo({top:$.offsetTop-b.offsetTop-12,behavior:C.still.matches?"auto":"smooth"}),$.animate?.([{boxShadow:"0 0 0 2px rgb(52,199,89)"},{boxShadow:"0 0 0 0 transparent"}],{duration:900}))}),m.append(h)}return m.append(...C.readable(c.text)),fn(m,C.stampOf(c,f)),c.id===C.S.newFrom&&c!==n[0]?[C.el("div",{class:"newline"},"new"),m]:[m]}).map(l));let p=C.$(".replying",C.chatEl),v=C.S.replyTo&&e.get(C.S.replyTo);if(p.hidden=!v,v){let c=C.el("button",{type:"button",title:"about the page instead"},"\u2715");c.addEventListener("click",()=>(C.S.replyTo=null,Ht())),p.replaceChildren(document.createTextNode(`\u21A9 ${v.name}: ${v.text.replace(/\s+/g," ").slice(0,40)}`),c)}s.firstChild||s.append(C.el("div",{class:"none"},"say something about the page as a whole"));let x=C.chatEl.querySelector(".chat");x.firstChild||x.append(C.composer({placeholder:"message",draftKey:`lab-typing:${C.S.page}:chat`,onSubmit:async(c,f)=>{let{comment:m}=await C.send(C.S.replyTo?{name:c,text:f,parent:C.S.replyTo}:{name:c,text:f,anchor:{kind:"page",width:innerWidth,height:innerHeight,dpr:devicePixelRatio||1}}),h=C.S.replyTo&&C.S.comments.find(w=>w.id===C.S.replyTo);return h?.resolved&&(h.resolved=!1),C.S.replyTo=null,C.S.comments.push(m),C.markSeen([m]),s.scrollTop=s.scrollHeight,C.render(),{keep:!0}}})),x.querySelector("textarea").placeholder=v?"reply":"message",a&&(s.scrollTop=s.scrollHeight)}var A;function go(e){A=e}function gn(e,n,r){A.layer.append(e);let i=e.offsetWidth,s=scrollX+document.documentElement.clientWidth-i-12;e.style.left=`${Math.max(scrollX+12,Math.min(n-14,s))}px`;let a=e.offsetHeight,u=r+10+a>A.contentEnd();e.style.top=`${u?Math.max(scrollY+8,r-40-a):r+10}px`,e.style.transformOrigin=u?"14px 100%":""}function ho(e,n,r){A.layer.append(e);let i=e.offsetWidth,s=scrollX+document.documentElement.clientWidth-12,a=e.offsetHeight,u=A.contentEnd();n+36+i<=s?(e.style.left=`${n+36}px`,e.style.top=`${Math.min(r-37,u-a-8)}px`):(e.style.left=`${Math.max(scrollX+12,Math.min(n-14,s-i))}px`,e.style.top=`${r+10+a>u?Math.max(scrollY+8,r-40-a):r+10}px`)}function bo(e,n){e.addEventListener("pointerdown",r=>{if(r.button!==0)return;let i=e.getBoundingClientRect(),s={dx:r.clientX-i.left,dy:r.clientY-i.bottom},a={x:r.clientX,y:r.clientY,sx:scrollX,sy:scrollY,left:parseFloat(e.style.left),top:parseFloat(e.style.top)},u=!1,o=r;A.S.grabbing=!0,e.setPointerCapture(r.pointerId);let l=()=>{e.style.left=`${a.left+o.clientX-a.x+scrollX-a.sx}px`,e.style.top=`${a.top+o.clientY-a.y+scrollY-a.sy}px`},p=c=>{o=c,!(!u&&Math.hypot(c.clientX-a.x,c.clientY-a.y)<5)&&(u=!0,e.classList.add("dragging"),l())},v=()=>u&&l();addEventListener("scroll",v,!0),A.S.dropDrag=()=>{removeEventListener("scroll",v,!0),A.S.dropDrag=null};let x=async c=>{if(e.removeEventListener("pointermove",p),e.removeEventListener("pointerup",x),e.removeEventListener("pointercancel",x),e.removeEventListener("lostpointercapture",x),A.S.dropDrag?.(),!A.S.grabbing||(A.S.grabbing=!1,!u))return;e.dataset.dragged="1",setTimeout(()=>delete e.dataset.dragged,0);let f=c.clientX-s.dx,m=c.clientY-s.dy,h=document.elementsFromPoint(f,m).find(b=>b!==A.host);if(c.type==="pointercancel"||f<0||m<0||f>innerWidth||m>innerHeight||h?.closest(A.OFF))return A.render();let w=n.anchor;n.anchor={...A.anchorAt(f,m),...w?.zoom?{zoom:w.zoom}:{}},A.render();try{let{comment:b}=await A.send({action:"move",id:n.id,anchor:n.anchor,edit:A.store.get(`lab-edit:${n.id}`)||void 0});Object.assign(n,b)}catch{n.anchor=w,A.render()}};e.addEventListener("pointermove",p),e.addEventListener("pointerup",x),e.addEventListener("pointercancel",x),e.addEventListener("lostpointercapture",x)})}function xo(e,n=new Set,r=!1){let i=A.el("div",{class:"card"}),s=A.el("div",{class:"body"}),a=A.el("div",{class:"foot"});i.append(A.el("div",{class:"handle"}),s,a),i.addEventListener("click",c=>c.stopPropagation()),s.classList.add("msgs");let u=c=>{let f=A.el("div",{class:`item msg${A.mine(c)&&!c.session?" mine":""}`,"data-id":c.id,...A.agentOf(c)?{"data-agent":A.agentOf(c)}:{}});return f.append(A.nameLine(c.name,!1),...A.readable(c.text)),A.stamped(f,A.stampOf(c,e,c===e&&!e.resolved?`#${A.numberOf(e)} \xB7 `:"")),f},o=new Set,l=[e,...A.repliesOf(e.id)],p=l.find(c=>n.has(c.id));for(let c of l)c===p&&c!==e&&s.append(A.el("div",{class:"newline"},"new")),s.append(u(c)),o.add(c.id);i.sync=()=>{for(let c of A.repliesOf(e.id)){if(o.has(c.id))continue;let f=i.querySelectorAll(".item"),m=u(c);m.classList.add("fresh"),f[f.length-1].after(m),o.add(c.id),A.markSeen([c])}};let v=A.store.get(`lab-edit:${e.id}`),x=null;if(A.S.isAdmin||v){x=A.el("div",{class:"row acts"});let c=A.el("button",{class:"btn",type:"button"},e.resolved?"reopen":"resolve"),f=$=>$.textContent="failed, try again";c.addEventListener("click",async()=>{try{let $=!e.resolved,{comment:E}=await A.send({action:e.resolved?"reopen":"resolve",id:e.id,...v?{edit:v}:{}});if(Object.assign(e,E),$&&A.S.openId===e.id)return A.S.closeFast=!0,A.S.openId=null,A.render();A.render()}catch{f(c)}});let m=A.el("button",{class:"btn",type:"button"},"delete"),h=A.el("button",{class:"btn danger",type:"button"},"delete"),w=A.el("button",{class:"btn",type:"button"},"cancel"),b=()=>{x.replaceChildren(c,m),m.focus()};m.addEventListener("click",()=>{x.replaceChildren(A.el("span",{class:"ask"},A.repliesOf(e.id).length?"delete thread?":"delete comment?"),h,w),w.focus()}),w.addEventListener("click",b),x.addEventListener("keydown",$=>{$.key==="Escape"&&h.isConnected&&($.stopPropagation(),b())}),h.addEventListener("click",async()=>{try{await A.send({action:"delete",id:e.id})}catch{return f(h)}A.S.comments=A.S.comments.filter($=>$.id!==e.id&&$.parent!==e.id),A.S.openId=null,A.render()}),x.append(...A.S.isAdmin?[c,m]:[c]),s.append(x)}if(A.coarse){let c=w=>A.position(w.anchor||{}).top,f=c(e),m=A.threads().filter(w=>!A.isPage(w)&&w.id!==e.id&&A.unread(w).length).map(w=>[w,c(w)]);m.sort((w,b)=>(w[1]>f?0:1)-(b[1]>f?0:1)||w[1]-b[1]);let h=A.el("div",{class:"row nav"});if(m.length){let w=A.el("button",{class:"btn",type:"button"},`new \xB7 ${m.length} \u203A`);w.addEventListener("pointerdown",b=>b.preventDefault()),w.addEventListener("click",()=>A.goTo(m[0][0])),h.append(w)}x&&h.append(x),h.firstChild&&i.insertBefore(h,s)}return a.append(A.composer({placeholder:"reply",autofocus:r,draftKey:`lab-typing:${A.S.page}:${e.id}`,onSubmit:async(c,f)=>{let{comment:m}=await A.send({name:c,text:f,parent:e.id});if(A.S.comments.push(m),A.markSeen([m]),e.resolved){e.resolved=!1,A.render();let b=A.S.openCard?.querySelector(".body");return b&&(b.scrollTop=b.scrollHeight),A.S.openCard?.querySelector("textarea")?.focus({preventScroll:!0}),{keep:!0}}o.add(m.id);let h=i.querySelectorAll(".item"),w=u(m);return w.classList.add("fresh"),h[h.length-1].after(w),s.scrollTop=s.scrollHeight,{keep:!0}}})),i}var N;function yo(e){N=e}function vo(){if(N.script?.dataset.live){let xe=function(y){{if(y.widget&&N.script.dataset.widget&&y.widget!==N.script.dataset.widget||(y.lab&&N.script.dataset.lab&&y.lab!==N.script.dataset.lab&&(N.script.dataset.lab=y.lab,N.script.dataset.version=String(y.files),m=y.hot,c=y.comments,I(),N.load()),String(y.files)!==N.script.dataset.version))return a();m!==null&&y.hot!==m&&(y.hot-m>1?te([{kind:"html"},{kind:"css",path:""}]):te(y.hotFiles||[])),m=y.hot,c!==null&&y.comments!==c&&N.loadChanges(c),c=y.comments,y.reads!==f&&(f=y.reads,N.syncReads());let _=y.session,B=_?y.mode||"listening":"away",q=ce=>Object.assign(document.createElement("span"),{textContent:ce}),H=_?.model?`${_.agent||"Claude"} \xB7 ${_.model}`:_?.agent||"Claude",W=_&&_.name!==(_.agent||"Claude")?[q(`(${_.name})`)]:[];B==="listening"?l.replaceChildren(q("talking to"),H,...W):B==="working"?l.replaceChildren(H,q("is working"),...W):l.replaceChildren(q("no agent listening")),u.classList.toggle("idle",B==="away"),u.classList.toggle("working",B==="working"),N.listBtn.dataset.agent=B,N.chatBtn.dataset.agent=B,N.coarse&&!N.chatBtn.querySelector(".mark")&&N.chatBtn.insertAdjacentHTML("afterbegin",o),N.coarse&&(N.chatBtn.title=u.textContent),u.setAttribute("aria-label",u.textContent),_?.url&&B!=="away"?Object.assign(u,{href:_.url,target:"_blank"}):u.removeAttribute("href"),u.title=B==="away"?"Ask your agent to run: npx @leonidstern/labit wait":_?.resume||"",u.hidden=!1}},e="lab-scroll:"+location.pathname;try{let y=JSON.parse(sessionStorage.getItem(e)||"null");y!==null&&(sessionStorage.removeItem(e),y.open&&(N.S.openId=y.open),y.list&&(N.S.listOpen=!0,N.S.filter=["new","open","resolved","mine"].includes(y.filter)?y.filter:N.S.filter),y.chat&&(N.S.chatOpen=!0),addEventListener("load",()=>scrollTo(0,+(y.y??y))))}catch{}let n=0;for(let y of["pointerdown","keydown","wheel","touchstart"])addEventListener(y,()=>n=performance.now(),{capture:!0,passive:!0});let r=()=>N.S.draft||N.S.grabbing||N.S.openId||N.S.chatOpen||N.S.listOpen||N.coarse&&/^(textarea|input)$/.test(N.root.activeElement?.localName||"")||[...N.root.querySelectorAll("textarea")].some(y=>y.value.trim())||performance.now()-n<1500,i=!1,s=0,a=()=>{if(document.hidden)return void(i=!0);if(r()){s||(s=setTimeout(()=>(s=0,a()),500));return}try{sessionStorage.setItem(e,JSON.stringify({y:scrollY,open:N.S.openId,list:N.S.listOpen,filter:N.S.filter,chat:N.S.chatOpen}))}catch{}location.reload()},u=document.createElement("a");u.className="listener";let o='<svg class="mark" viewBox="0 0 64 64" aria-hidden="true"><g transform="translate(-1 -.5)"><path class="e1" d="M18.9 24.67L24.4 3h11.5L31.28 21.2A22.8 22.8 0 0 0 18.9 24.67Z"/><path class="e2" d="M37.07 22.02L41.9 3h11.5L47.1 27.85A22.8 22.8 0 0 0 37.07 22.02Z"/><path d="M31 26a18 18 0 0 1 18 18 18 18 0 0 1-18 18H15.57a2.57 2.57 0 0 1-2.57-2.57V44A18 18 0 0 1 31 26Z"/><circle class="eye" cx="31" cy="45" r="6.2"/></g></svg>';u.innerHTML=o+'<div class="lbl"></div>';let l=u.querySelector(".lbl");u.hidden=!0,N.root.querySelector(".left").prepend(u),document.querySelector('link[rel~="icon"]')||fetch("/favicon.ico",{method:"HEAD"}).then(y=>y.ok&&(y.headers.get("content-type")||"").startsWith("image/")).catch(()=>!1).then(y=>{y||document.querySelector('link[rel~="icon"]')||document.head.append(Object.assign(document.createElement("link"),{rel:"icon",href:"/_lab/favicon.svg"}))});let p=null,v=0,x=y=>{l.replaceChildren(Object.assign(document.createElement("span"),{textContent:y})),u.setAttribute("aria-label",y),u.classList.add("idle"),u.classList.remove("working"),u.hidden=!1},c=null,f=null,m=null,h=y=>{let _=[...document.querySelectorAll('link[rel~="stylesheet"][href]:not([data-lab-swap])')].filter(q=>new URL(q.href,location.href).origin===location.origin),B=_.filter(q=>y.includes(decodeURIComponent(new URL(q.href,location.href).pathname)));for(let q of B.length?B:_){let H=new URL(q.href,location.href);H.searchParams.set("lab-v",Date.now().toString(36));let W=q.cloneNode();W.href=H.href,W.dataset.labSwap="";let ce=H.pathname;W.addEventListener("load",()=>{for(let D of document.querySelectorAll('link[rel~="stylesheet"][href]'))D!==W&&new URL(D.href,location.href).pathname===ce&&D.remove();delete W.dataset.labSwap},{once:!0}),W.addEventListener("error",()=>W.remove(),{once:!0}),q.after(W)}},w=y=>{let _=new URL(y,location.href);return _.searchParams.set("lab-v",Date.now().toString(36)),_.href},b=(y,_)=>{try{let B=new URL(y,location.href);return B.origin===location.origin&&_.includes(decodeURIComponent(B.pathname))}catch{return!1}},$=y=>{let _=0;for(let B of document.querySelectorAll('img, source, video[poster], image, use, link[rel~="icon"]')){if(N.host.contains(B))continue;for(let H of["src","href","poster","xlink:href"]){let W=B.getAttribute(H);if(!W||!b(W.split("#")[0],y))continue;let ce=w(W.split("#")[0]),D=new Image;D.src=ce,(D.decode?D.decode():Promise.resolve()).catch(()=>{}).finally(()=>B.setAttribute(H,ce+(W.includes("#")?W.slice(W.indexOf("#")):""))),_++}let q=B.getAttribute("srcset");q&&q.split(",").some(H=>b(H.trim().split(/\s+/)[0],y))&&(B.setAttribute("srcset",q.split(",").map(H=>{let[W,...ce]=H.trim().split(/\s+/);return[b(W,y)?w(W):W,...ce].join(" ")}).join(", ")),_++)}_||h([])},E=y=>{for(let _ of document.styleSheets){let B;try{B=_.cssRules}catch{continue}for(let q of B||[]){if(!(q instanceof CSSFontFaceRule))continue;let H=q.style.getPropertyValue("src"),W=_.href||location.href;if(!/url\(/.test(H)||![...H.matchAll(/url\(["']?([^"')]+)/g)].some(oe=>b(new URL(oe[1],W).href,y)))continue;let ce=H.replace(/url\(["']?([^"')]+)["']?\)/g,(oe,Z)=>b(new URL(Z,W).href,y)?`url("${w(new URL(Z,W).href)}")`:oe),D=oe=>q.style.getPropertyValue(oe)||void 0;try{new FontFace(D("font-family").replace(/^["']|["']$/g,""),ce,{weight:D("font-weight"),style:D("font-style"),stretch:D("font-stretch"),unicodeRange:D("unicode-range"),display:D("font-display")}).load().then(Z=>document.fonts.add(Z)).catch(()=>{})}catch{}}}},M=()=>new Set([N.fonts,N.pinCursorStyle]),z=y=>[...y.querySelectorAll("script")].filter(_=>!/\/_lab\/comments\.js/.test(_.getAttribute("src")||"")).map(_=>_.getAttribute("src")||_.textContent),O=y=>[...y.querySelectorAll('link[rel~="stylesheet"]')].map(_=>{try{return new URL(_.getAttribute("href"),location.href).pathname}catch{return""}}),P=y=>y===N.host||y.nodeType===1&&y.localName==="script",V=(y,_)=>y.nodeType===_.nodeType&&y.nodeName===_.nodeName&&(y.nodeType!==1||(y.id||"")===(_.id||"")),X=(y,_)=>V(y,_)&&(y.nodeType===1?!!y.id||y.getAttribute("class")===_.getAttribute("class"):y.nodeType!==3||y.data===_.data),F=(y,_)=>{let B=[...y.childNodes].filter(D=>!P(D)),q=[..._.childNodes].filter(D=>!(D.nodeType===1&&D.localName==="script")),H=0,W=null,ce=D=>{let oe=document.importNode(D,!0);return y.insertBefore(oe,W?W.nextSibling:B[H]||y.firstChild),oe};q.forEach((D,oe)=>{let Z=B[H];if(!Z)return void(W=ce(D));if(X(Z,D))return W=Y(Z,D),void H++;if(q.slice(oe+1,oe+8).some(ae=>X(Z,ae)))return void(W=ce(D));let Ee=B.slice(H+1,H+8).findIndex(ae=>X(ae,D));if(Ee>=0){for(let ae of B.slice(H,H+1+Ee))ae.remove();return H+=Ee+1,W=Y(B[H],D),void H++}W=Y(Z,D),H++});for(let D of B.slice(H))D.remove()},Y=(y,_)=>{if(y.nodeType!==_.nodeType||y.nodeName!==_.nodeName||y.nodeType===1&&(y.id||"")!==(_.id||"")){let B=document.importNode(_,!0);return y.replaceWith(B),B}if(y.nodeType===3||y.nodeType===8)return y.data!==_.data&&(y.data=_.data),y;if(y.nodeType!==1)return y;for(let{name:B}of Array.from(y.attributes))!_.hasAttribute(B)&&!(B==="open"&&/^(details|dialog)$/.test(y.localName))&&y.removeAttribute(B);for(let{name:B,value:q}of Array.from(_.attributes))y.getAttribute(B)!==q&&y.setAttribute(B,q);return y===document.activeElement||y.shadowRoot||/^(iframe|canvas|video|audio|textarea|select|input)$/.test(y.localName)||F(y,_),y},se=()=>z(document).length>0,ee=0,I=async()=>{if(se())return a();let y=++ee;try{let _=await fetch(location.href,{cache:"no-store",headers:{accept:"text/html"}});if(!_.ok)return a();let B=await _.text();if(y!==ee)return;let q=new DOMParser().parseFromString(B,"text/html");if(z(q).join(`
|
|
11
|
+
`)!==z(document).join(`
|
|
12
|
+
`)||O(q).join(`
|
|
13
|
+
`)!==O(document).join(`
|
|
14
|
+
`))return a();let H=null;for(let oe of[Math.min(innerHeight/3,240),innerHeight/2,80]){let Z=document.elementFromPoint(innerWidth/2,oe);if(Z&&Z!==document.body&&Z!==document.documentElement&&!N.host.contains(Z)&&Z!==N.host){H=Z;break}}let W=H?.getBoundingClientRect().top,ce=()=>{q.title!==N.tabTitle.base&&(N.tabTitle.base=q.title,document.title=q.title,N.drawList());let oe=M(),Z=[...document.head.querySelectorAll("style")].filter(ae=>!oe.has(ae)),Ee=[...q.head.querySelectorAll("style")];Ee.forEach((ae,_e)=>Z[_e]?Z[_e].textContent!==ae.textContent&&(Z[_e].textContent=ae.textContent):document.head.append(document.importNode(ae,!0)));for(let ae of Z.slice(Ee.length))ae.remove();if(F(document.body,q.body),H?.isConnected){let ae=H.getBoundingClientRect().top-W;Math.abs(ae)>1&&scrollBy(0,ae)}N.reflow(),N.drawZoom()},D=()=>{try{ce()}catch{a()}};document.startViewTransition&&!N.still.matches?document.startViewTransition(D):D()}catch{a()}},te=y=>{let _=q=>y.filter(H=>H.kind===q).map(H=>H.path),B=decodeURIComponent(location.pathname).replace(/\/$/,"/index").replace(/\.html?$/i,"");_("html").some(q=>!q||q.replace(/\.html?$/i,"")===B)&&I(),_("css").length&&h(_("css")),_("img").length&&$(_("img")),_("font").length&&E(_("font"))},le=Math.random().toString(36).slice(2,12),ne=0,be=0,Be=async()=>{try{xe(await(await fetch(`${N.script.dataset.live.replace(/live$/,"state")}?tab=${le}`,{cache:"no-store"})).json())}catch{}},vt=()=>{clearTimeout(be),be=setTimeout(()=>{p?.close(),p=null,clearInterval(ne),ne=setInterval(Be,2e4)},3e4)},wt=()=>{clearTimeout(be),clearInterval(ne),ne=0,Le()},Le=()=>{p||(p=new EventSource(`${N.script.dataset.live}?tab=${le}`),v=Date.now(),p.addEventListener("beat",()=>v=Date.now()),p.onerror=()=>x("reconnecting"),p.onmessage=y=>{v=Date.now(),xe(JSON.parse(y.data))})};document.addEventListener("visibilitychange",()=>{if(document.hidden)return vt();if(i)return a();wt()}),addEventListener("pagehide",()=>{p?.close(),p=null,fetch(N.script.dataset.live.replace(/live$/,"bye"),{method:"POST",keepalive:!0,headers:{"content-type":"application/json"},body:JSON.stringify({tab:le})}).catch(()=>{})}),addEventListener("pageshow",y=>y.persisted&&Le());let Je=Date.now(),ye=()=>{p?.close(),p=null,x("reconnecting"),Le()};setInterval(()=>{let y=Date.now(),_=y-Je>2e4;Je=y,!document.hidden&&(_||p&&y-v>4e4)&&ye()},5e3),addEventListener("online",()=>!document.hidden&&ye()),Le(),document.hidden&&vt()}}var we;function wo(e){we=e}function yt(e){let n=document.createElement("span");n.className="zi",n.setAttribute("aria-hidden","true");let r=e==="in"?"M14 2 9.5 6.5M9.5 3.2v3.3h3.3M2 14l4.5-4.5M6.5 12.8V9.5H3.2":"M9.5 6.5 14 2M10.7 2H14v3.3M6.5 9.5 2 14M2 10.7V14h3.3";return n.innerHTML=`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="${r}"/></svg>`,n}var Wt=[];function hn(e,n){Wt.push({block:e,dir:n,at:Date.now()})}var ca=(e,n)=>{let r=document.querySelector(`[data-zoom="${n}"][data-zoom-of="${CSS.escape(e)}"]`);return r&&!we.host.contains(r)?r:null};function bn(e){let n=e.getBoundingClientRect(),r=matchMedia("(prefers-reduced-motion: reduce)").matches;scrollTo({top:Math.max(0,n.top+scrollY-24),behavior:r?"auto":"smooth"});let i="2px solid rgb(52, 199, 89)";e.animate([{outline:i,outlineOffset:"4px"},{outline:i,outlineOffset:"4px",offset:.7},{outline:"2px solid transparent",outlineOffset:"4px"}],{duration:2e3})}function xn(){for(let e=Wt.length-1;e>=0;e--){let n=Wt[e],r=ca(n.block,n.dir);(r||Date.now()-n.at>30*6e4)&&Wt.splice(e,1),r&&requestAnimationFrame(()=>bn(r))}}function $e(e){e&&we.S.cursorMode&&we.setCursor(!1),we.S.zoomMode=e;try{sessionStorage.setItem("lab-zoom",e)}catch{}we.refreshPinCursor(),we.goFace(),we.recheck(),we.render()}function ko(e,n){return e.key==="Escape"?($e(""),!0):!1}function So(){try{let e=sessionStorage.getItem("lab-zoom");we.S.zoomMode=e==="in"||e==="out"?e:""}catch{we.S.zoomMode=""}}var yn=e=>e==="out"?"zoom out: the bigger picture":"zoom in: dive deeper";/*!
|
|
15
|
+
* lab comments: anyone with the link clicks anywhere on a lab page to pin a comment. No login, just a name.
|
|
16
|
+
* https://github.com/leonidstern/labit · MIT
|
|
17
|
+
* Comments are off by default; the bar button or c turns them on (remembered per browser). When on, click anywhere that isn't a link or control to pin one (alt/option-click pins on those too). c (or the bar button) hides
|
|
18
|
+
* and shows them; esc or a click outside closes an open comment. Dragging (mouse/pen) marks an area instead of a point.
|
|
19
|
+
* Include on a page served through your lab domain:
|
|
20
|
+
* <script src="https://lab.example.com/_lab/comments.js" defer><\/script>
|
|
21
|
+
* The layer only turns on when the page is opened on the host the script is loaded from (or data-host),
|
|
22
|
+
* so the deployment's own address and local dev stay clean. data-enable="always" turns it on everywhere.
|
|
23
|
+
* Admin (resolve / delete / copy agent link): open any page once with ?lab-admin=<LAB_COMMENTS_ADMIN_TOKEN>; it is kept in this browser.
|
|
24
|
+
*/(()=>{let e={dbg:null},n={get $(){return M},get API(){return a},get headers(){return W},get DRAFT_MODE(){return an},get LIST_WINDOW(){return Be},get OFF(){return me},get S(){return e},get agentOf(){return H},get ago(){return Ao},get anchorAt(){return He},get bar(){return V},get chatBtn(){return y},get chatEl(){return ye},get closeOrNudge(){return On},get coarse(){return re},get composer(){return sn},get contentEnd(){return zo},get doneBtn(){return le},get drafting(){return gt},get drawList(){return Fe},get el(){return _},get fonts(){return pe},get goBtn(){return ee},get goFace(){return Kt},get goTo(){return Ve},get held(){return tt},get holdBtn(){return Je},get host(){return $},get isDone(){return Co},get isNew(){return Sn},get isPage(){return wn},get keyWord(){return Mo},get layer(){return z},get listBtn(){return se},get listEl(){return xe},get listed(){return _o},get load(){return D},get loadChanges(){return oe},get markSeen(){return ot},get mine(){return Et},get nameLine(){return Qn},get newNext(){return wt},get newPrev(){return I},get numberOf(){return Yt},get onWhat(){return io},get openSheet(){return zn},get patchKids(){return B},get pinCursorStyle(){return ct},get placeBar(){return To},get position(){return We},get readable(){return eo},get reflow(){return Tt},get drawZoom(){return xn},get refreshPinCursor(){return en},get setCursor(){return Ft},get recheck(){return Ce},get render(){return j},get repliesOf(){return Vt},get root(){return E},get scrim(){return Jt},get script(){return r},get send(){return je},get sendBtn(){return Le},get showDoneBtn(){return te},get stampOf(){return so},get stamped(){return fn},get still(){return Lt},get store(){return o},get syncReads(){return Zt},get tabTitle(){return vt},get threads(){return et},get unread(){return nt},get vv(){return Po}};yo(n),wo(n),mo(n),fo(n),go(n),lo(n);let r=document.currentScript,i=r?.dataset.host||(r?.src?new URL(r.src,location.href).hostname:location.hostname);if(!(location.hostname===i||r?.dataset.enable==="always")||window.__labComments)return;window.__labComments=!0;let a=r?.dataset.api||"/_lab/api/comments",u=()=>r?.dataset.page||location.pathname.replace(/\/+$/,"")||"/";e.page=u();let o={get:t=>{try{return localStorage.getItem(t)||""}catch{return""}},set:(t,d)=>{try{localStorage.setItem(t,d)}catch{}}},l=r?.dataset.me||"";l&&!o.get("lab-name")&&o.set("lab-name",l);let p=r?.dataset.live?r.dataset.live.replace(/live$/,"me"):"",v=l,x=t=>{!p||!t||t===v||(v=t,fetch(p,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t})}).catch(()=>{}))},c=t=>t.split(".").length===3?t.split(".")[1]:"",f=new URLSearchParams(location.hash.slice(1)).get("lab-admin")||new URLSearchParams(location.search).get("lab-admin");if(f){let t=c(f);o.set(t?`lab-admin:${t}`:"lab-admin",f);let d=new URL(location.href);d.searchParams.delete("lab-admin"),/lab-admin=/.test(d.hash)&&(d.hash=""),history.replaceState(null,"",d)}let m=r?.dataset.admin||o.get(`lab-admin:${e.page.split("/")[1]||""}`)||o.get("lab-admin:*")||o.get("lab-admin");e.comments=[],e.isAdmin=!1,e.on=o.get("lab-on")?o.get("lab-on")==="1":r?.dataset.on==="1",e.openId=null,e.closeFast=!1,e.cardFull=!1,e.draft=null;let h=()=>`lab-spot:${e.page}`,w=t=>o.set(h(),t?JSON.stringify(t):""),b=()=>{try{return JSON.parse(o.get(h())||"null")}catch{return null}},$=document.createElement("div");$.setAttribute("data-lab-comments",""),$.style.cssText="position:absolute;top:0;left:0;width:0;height:0;z-index:2147483000;";let E=$.attachShadow({mode:"open"});E.innerHTML=`
|
|
25
|
+
<style>${qn}</style>
|
|
1314
26
|
<div class="scrim"></div>
|
|
1315
27
|
<div class="layer"></div>
|
|
1316
28
|
<button class="sel-chip" type="button" hidden>Comment</button>
|
|
1317
|
-
<div class="hint" role="status" hidden>click to comment \xB7 drag to mark an area \xB7 shift-drag to quote words \xB7 c chat \xB7 w new \xB7 1 comment \xB7 2 go \xB7 3
|
|
29
|
+
<div class="hint" role="status" hidden>click to comment \xB7 drag to mark an area \xB7 shift-drag to quote words \xB7 c chat \xB7 w new \xB7 1 comment \xB7 2 go \xB7 3 in, 3 again out \xB7 4 pointer \xB7 p pause \xB7 m hide</div>
|
|
1318
30
|
<div class="list" hidden><div class="tabs"><button type="button" data-f="new">new</button><button type="button" data-f="open">open</button><button type="button" data-f="work">work</button><button type="button" data-f="resolved">resolved</button><button type="button" data-f="mine">mine</button><button type="button" class="show-done" title="show or hide done pins on the page"></button><button type="button" class="hold" title="new pins wait here as drafts; send them together">draft mode</button><button type="button" class="x" aria-label="close">\u2715</button></div><div class="items"></div></div>
|
|
1319
31
|
<div class="list chatwin" hidden><div class="tabs"><b>chat</b></div><div class="msgs"></div><div class="replying" hidden></div><div class="chat"></div></div>
|
|
1320
32
|
<div class="left"><button class="secondary copy-all" type="button" hidden>copy link</button></div>
|
|
@@ -1325,2284 +37,10 @@ ${line}`;
|
|
|
1325
37
|
<button class="secondary list-btn" type="button" hidden>list</button>
|
|
1326
38
|
<button class="secondary new-next" type="button" hidden aria-label="next new comment">\u203A</button>
|
|
1327
39
|
<button class="secondary done-btn" type="button" hidden title="show or hide done pins on the page"></button>
|
|
1328
|
-
<button class="secondary
|
|
40
|
+
<button class="secondary pause-btn" type="button" aria-pressed="false" title="stop everything that moves on the page, to pin a moment (p)">pause motion</button>
|
|
41
|
+
<button class="secondary over-btn" type="button" aria-pressed="false" title="a click on the page's own links and buttons places a comment too, instead of being theirs (option-click always does)">pin over controls</button>
|
|
42
|
+
<button class="secondary go-btn" type="button" hidden title="tap: comment \u2192 go \u2192 zoom in \u2192 zoom out \xB7 keys: 1 comment \xB7 2 go: every click approves what it's on \xB7 3 zoom in, 3 again zoom out: ask the agent for a deeper look or the bigger picture \xB7 4 pointer: clicks are the page's own">go</button>
|
|
1329
43
|
<button class="toggle" type="button"></button>
|
|
1330
44
|
<button class="secondary more" type="button" hidden aria-label="more options" aria-expanded="false" aria-controls="lab-more">\u22EF</button>
|
|
1331
45
|
</div>
|
|
1332
|
-
<div class="more-menu" id="lab-more" hidden></div>`;
|
|
1333
|
-
const $ = (sel, box = root) => (
|
|
1334
|
-
/** @type {HTMLElement} */
|
|
1335
|
-
box.querySelector(sel)
|
|
1336
|
-
);
|
|
1337
|
-
const layer2 = $(".layer");
|
|
1338
|
-
const hint = $(".hint");
|
|
1339
|
-
if (matchMedia("(pointer: coarse)").matches) hint.textContent = "hold to comment";
|
|
1340
|
-
const toggleBtn = $(".toggle");
|
|
1341
|
-
const bar = (
|
|
1342
|
-
/** @type {HTMLElement} */
|
|
1343
|
-
root.querySelector(".bar")
|
|
1344
|
-
);
|
|
1345
|
-
const moreBtn = $(".more");
|
|
1346
|
-
const moreMenu = $(".more-menu");
|
|
1347
|
-
const copyBtn = $(".copy-all");
|
|
1348
|
-
const listBtn = (
|
|
1349
|
-
/** @type {HTMLButtonElement} */
|
|
1350
|
-
$(".list-btn")
|
|
1351
|
-
);
|
|
1352
|
-
const goBtn = $(".go-btn");
|
|
1353
|
-
const newPrev = $(".new-prev");
|
|
1354
|
-
const showDoneBtn = $(".show-done");
|
|
1355
|
-
const doneBtn = (
|
|
1356
|
-
/** @type {HTMLButtonElement} */
|
|
1357
|
-
$(".done-btn")
|
|
1358
|
-
);
|
|
1359
|
-
const LIST_WINDOW = false;
|
|
1360
|
-
const tabTitle = { base: "" };
|
|
1361
|
-
let showDone = store2.get("lab-show-done") === "1";
|
|
1362
|
-
const newNext = $(".new-next");
|
|
1363
|
-
const sendBtn = $(".send-all");
|
|
1364
|
-
const listEl = $(".list");
|
|
1365
|
-
const holdBtn = $(".hold", listEl);
|
|
1366
|
-
const chatEl = $(".chatwin");
|
|
1367
|
-
const chatBtn = (
|
|
1368
|
-
/** @type {HTMLElement} */
|
|
1369
|
-
root.querySelector(".chat-btn")
|
|
1370
|
-
);
|
|
1371
|
-
let listOpen = false;
|
|
1372
|
-
let filter = "open";
|
|
1373
|
-
let refit = () => {
|
|
1374
|
-
};
|
|
1375
|
-
let chatOpen = false;
|
|
1376
|
-
const el2 = (tag, attrs = {}, text) => {
|
|
1377
|
-
const node = document.createElement(tag);
|
|
1378
|
-
for (const [k, v] of Object.entries(attrs)) node.setAttribute(k, v);
|
|
1379
|
-
if (text != null) node.textContent = text;
|
|
1380
|
-
return node;
|
|
1381
|
-
};
|
|
1382
|
-
bindAnchoring({ host: host2, layer: layer2, el: el2, store: store2 });
|
|
1383
|
-
function patchKids(box, next) {
|
|
1384
|
-
const keep = new Set(next);
|
|
1385
|
-
for (const n of Array.from(box.childNodes)) if (!keep.has(n)) n.remove();
|
|
1386
|
-
let at = box.firstChild;
|
|
1387
|
-
for (const n of next) {
|
|
1388
|
-
if (n === at) at = at.nextSibling;
|
|
1389
|
-
else box.insertBefore(n, at);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
const AGENT_KINDS = ["claude", "codex", "cursor", "gemini", "antigravity", "copilot", "amp", "opencode"];
|
|
1393
|
-
const agentOf = (m) => {
|
|
1394
|
-
if (!m?.session) return "";
|
|
1395
|
-
const k = String(m.session.kind || m.name || "").trim().split(/\W/)[0].toLowerCase();
|
|
1396
|
-
return AGENT_KINDS.includes(k) ? k === "antigravity" ? "gemini" : k : "";
|
|
1397
|
-
};
|
|
1398
|
-
const headers = () => ({ "content-type": "application/json", ...adminToken ? { "x-lab-admin": adminToken } : {} });
|
|
1399
|
-
let gone = false;
|
|
1400
|
-
let loaded = false;
|
|
1401
|
-
let retried = false;
|
|
1402
|
-
const typed = () => Boolean(root.activeElement) || [...root.querySelectorAll("textarea")].some((t) => t.value.trim());
|
|
1403
|
-
async function load() {
|
|
1404
|
-
try {
|
|
1405
|
-
const res = await fetch(`${API}?page=${encodeURIComponent(page)}`, { headers: headers(), cache: "no-store" });
|
|
1406
|
-
if (res.status === 404 && !loaded && script?.dataset.enable !== "always") {
|
|
1407
|
-
if (!retried) {
|
|
1408
|
-
retried = true;
|
|
1409
|
-
setTimeout(load, 1500);
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
gone = true;
|
|
1413
|
-
on = false;
|
|
1414
|
-
document.documentElement.classList.remove("lab-pinning");
|
|
1415
|
-
host2.remove();
|
|
1416
|
-
fonts.remove();
|
|
1417
|
-
return;
|
|
1418
|
-
}
|
|
1419
|
-
if (!res.ok) throw new Error(String(res.status));
|
|
1420
|
-
const data = await res.json();
|
|
1421
|
-
comments = data.comments || [];
|
|
1422
|
-
isAdmin = Boolean(data.admin);
|
|
1423
|
-
loaded = true;
|
|
1424
|
-
} catch {
|
|
1425
|
-
}
|
|
1426
|
-
shownAgain();
|
|
1427
|
-
}
|
|
1428
|
-
async function loadChanges(since) {
|
|
1429
|
-
try {
|
|
1430
|
-
const url = new URL("/_lab/api/changes", new URL(API, location.href));
|
|
1431
|
-
url.search = String(new URLSearchParams({ page, since: String(since) }));
|
|
1432
|
-
const res = await fetch(url, { cache: "no-store" });
|
|
1433
|
-
const data = res.ok ? await res.json() : { full: true };
|
|
1434
|
-
if (data.full || !loaded) return load();
|
|
1435
|
-
const gone2 = new Set(data.del);
|
|
1436
|
-
const fresh = new Map(data.set.map((c) => [c.id, c]));
|
|
1437
|
-
comments = comments.filter((c) => !gone2.has(c.id)).map((c) => fresh.get(c.id) || c);
|
|
1438
|
-
const had = new Set(comments.map((c) => c.id));
|
|
1439
|
-
for (const c of data.set) if (!had.has(c.id)) comments.push(c);
|
|
1440
|
-
comments.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
1441
|
-
} catch {
|
|
1442
|
-
return load();
|
|
1443
|
-
}
|
|
1444
|
-
shownAgain();
|
|
1445
|
-
}
|
|
1446
|
-
function shownAgain() {
|
|
1447
|
-
if (!typed() && !grabbing) render();
|
|
1448
|
-
else {
|
|
1449
|
-
if (openCard?.isConnected) openCard.sync();
|
|
1450
|
-
if (chatOpen) drawChat();
|
|
1451
|
-
drawList();
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
let goMode = store2.get("lab-go") === "1";
|
|
1455
|
-
let cursorMode = store2.get("lab-cursor") === "1";
|
|
1456
|
-
const setCursor = (v) => {
|
|
1457
|
-
cursorMode = v;
|
|
1458
|
-
store2.set("lab-cursor", v ? "1" : "");
|
|
1459
|
-
goBtn.classList.toggle("cursor", v);
|
|
1460
|
-
goBtn.classList.toggle("on", goMode && !v);
|
|
1461
|
-
goFace();
|
|
1462
|
-
document.documentElement.classList.toggle("lab-pinning", on && !v);
|
|
1463
|
-
document.documentElement.classList.toggle("lab-go", on && goMode && !v);
|
|
1464
|
-
recheck();
|
|
1465
|
-
};
|
|
1466
|
-
const setGo = (v) => {
|
|
1467
|
-
if (cursorMode) setCursor(false);
|
|
1468
|
-
goMode = v;
|
|
1469
|
-
queueMicrotask(goFace);
|
|
1470
|
-
store2.set("lab-go", v ? "1" : "");
|
|
1471
|
-
goBtn.classList.toggle("on", v);
|
|
1472
|
-
goBtn.setAttribute("aria-pressed", String(v && !cursorMode));
|
|
1473
|
-
document.documentElement.classList.toggle("lab-go", on && v);
|
|
1474
|
-
ptr.classList.toggle("go", v);
|
|
1475
|
-
recheck();
|
|
1476
|
-
};
|
|
1477
|
-
function begin(anchor) {
|
|
1478
|
-
const name = store2.get("lab-name").trim();
|
|
1479
|
-
if (!goMode || !name) {
|
|
1480
|
-
draft = { anchor };
|
|
1481
|
-
return render();
|
|
1482
|
-
}
|
|
1483
|
-
if (drafting()) {
|
|
1484
|
-
store2.set(heldKey(), JSON.stringify([...held(), { name, text: "go", anchor }]));
|
|
1485
|
-
return render();
|
|
1486
|
-
}
|
|
1487
|
-
send({ name, text: "go", anchor }).then(({ comment, edit }) => {
|
|
1488
|
-
if (edit) store2.set(`lab-edit:${comment.id}`, edit);
|
|
1489
|
-
comments.push(comment);
|
|
1490
|
-
markSeen([comment]);
|
|
1491
|
-
posted = comment.id;
|
|
1492
|
-
render();
|
|
1493
|
-
}).catch(() => (draft = { anchor }, render()));
|
|
1494
|
-
}
|
|
1495
|
-
async function send(payload) {
|
|
1496
|
-
let res = null;
|
|
1497
|
-
if (!payload.action && !payload.nonce) payload = { ...payload, nonce: Math.random().toString(36).slice(2) + Date.now().toString(36) };
|
|
1498
|
-
for (let tries = 0; !res; tries++) {
|
|
1499
|
-
try {
|
|
1500
|
-
res = await fetch(API, { method: "POST", headers: headers(), body: JSON.stringify({ page, ...payload }) });
|
|
1501
|
-
} catch {
|
|
1502
|
-
if (tries >= 150) throw new Error("couldn't reach the lab; your text is still here");
|
|
1503
|
-
await new Promise((r) => setTimeout(r, 2e3));
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
const data = await res.json().catch(() => ({}));
|
|
1507
|
-
if (!res.ok) throw new Error(data.error || `could not save (${res.status})`);
|
|
1508
|
-
if (data.comment && !payload.parent && !payload.action && payload.anchor?.kind !== "page") placed.push(data.comment.id);
|
|
1509
|
-
return data;
|
|
1510
|
-
}
|
|
1511
|
-
const placed = [];
|
|
1512
|
-
async function undoLast() {
|
|
1513
|
-
const id = placed.pop();
|
|
1514
|
-
const c = id && comments.find((x) => x.id === id);
|
|
1515
|
-
if (!c) return;
|
|
1516
|
-
const ownKey = store2.get(`lab-edit:${id}`);
|
|
1517
|
-
try {
|
|
1518
|
-
if (isAdmin) {
|
|
1519
|
-
await send({ action: "delete", id });
|
|
1520
|
-
comments = comments.filter((x) => x.id !== id && x.parent !== id);
|
|
1521
|
-
} else if (ownKey) {
|
|
1522
|
-
const { comment } = await send({ action: "resolve", id, edit: ownKey });
|
|
1523
|
-
Object.assign(c, comment);
|
|
1524
|
-
} else return void placed.push(id);
|
|
1525
|
-
} catch {
|
|
1526
|
-
return void placed.push(id);
|
|
1527
|
-
}
|
|
1528
|
-
if (openId === id) openId = null;
|
|
1529
|
-
render();
|
|
1530
|
-
say(`took back ${/^go$/i.test(c.text.trim()) ? "a go" : "a pin"} \xB7 ${placed.length ? "again for the one before" : "nothing more to take back"}`);
|
|
1531
|
-
}
|
|
1532
|
-
const said = { was: void 0, t: void 0 };
|
|
1533
|
-
function say(words) {
|
|
1534
|
-
said.was ??= hint.textContent;
|
|
1535
|
-
hint.textContent = words;
|
|
1536
|
-
hint.hidden = false;
|
|
1537
|
-
clearTimeout(said.t);
|
|
1538
|
-
said.t = setTimeout(() => {
|
|
1539
|
-
hint.hidden = true;
|
|
1540
|
-
hint.textContent = said.was;
|
|
1541
|
-
said.was = void 0;
|
|
1542
|
-
}, 1800);
|
|
1543
|
-
}
|
|
1544
|
-
const agentLink = () => new URL("/_lab/agent" + page, new URL(API, location.href)).href;
|
|
1545
|
-
async function copy(textPromise, button) {
|
|
1546
|
-
const textValue = await textPromise;
|
|
1547
|
-
try {
|
|
1548
|
-
await navigator.clipboard.writeText(textValue);
|
|
1549
|
-
} catch {
|
|
1550
|
-
const area = document.createElement("textarea");
|
|
1551
|
-
area.value = textValue;
|
|
1552
|
-
area.style.cssText = "position:fixed;opacity:0;";
|
|
1553
|
-
document.body.append(area);
|
|
1554
|
-
area.select();
|
|
1555
|
-
document.execCommand("copy");
|
|
1556
|
-
area.remove();
|
|
1557
|
-
}
|
|
1558
|
-
if (moreMenu.contains(button)) return say("link copied");
|
|
1559
|
-
const label = button.textContent;
|
|
1560
|
-
button.style.width = `${button.getBoundingClientRect().width}px`;
|
|
1561
|
-
button.style.justifyContent = "center";
|
|
1562
|
-
button.textContent = "copied";
|
|
1563
|
-
setTimeout(() => {
|
|
1564
|
-
button.textContent = label;
|
|
1565
|
-
button.style.width = button.style.justifyContent = "";
|
|
1566
|
-
}, 1400);
|
|
1567
|
-
}
|
|
1568
|
-
const threads = () => comments.filter((c) => !c.parent);
|
|
1569
|
-
const heldKey = () => `lab-held:${page}`;
|
|
1570
|
-
const held = () => {
|
|
1571
|
-
try {
|
|
1572
|
-
return JSON.parse(store2.get(heldKey()) || "[]");
|
|
1573
|
-
} catch {
|
|
1574
|
-
return [];
|
|
1575
|
-
}
|
|
1576
|
-
};
|
|
1577
|
-
const listed = () => threads().filter((c) => c.anchor?.kind !== "page").filter((c) => filter === "new" ? unread(c).length : filter === "open" ? !c.resolved : filter === "resolved" ? c.resolved : mine(c)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
1578
|
-
const onWhat = (c) => {
|
|
1579
|
-
const a = c.anchor || {};
|
|
1580
|
-
let w = a.quote?.exact || "";
|
|
1581
|
-
let n = null;
|
|
1582
|
-
try {
|
|
1583
|
-
n = !w && a.selector ? document.querySelector(a.selector) : null;
|
|
1584
|
-
} catch {
|
|
1585
|
-
}
|
|
1586
|
-
for (let up = 0; n && n !== document.body && up < 5; n = n.parentElement, up++) {
|
|
1587
|
-
const t = n.innerText?.replace(/\s+/g, " ").trim() || "";
|
|
1588
|
-
if (t.length >= 12) {
|
|
1589
|
-
w = t;
|
|
1590
|
-
break;
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
w = (w || a.text || a.section || "").replace(/\s+/g, " ").trim();
|
|
1594
|
-
return w ? `"${w.length > 40 ? `${w.slice(0, 39)}\u2026` : w}"` : "";
|
|
1595
|
-
};
|
|
1596
|
-
const isPage = (c) => c.anchor?.kind === "page";
|
|
1597
|
-
let stepping = false;
|
|
1598
|
-
let keepKeys = false;
|
|
1599
|
-
const goTo = (c, keys = false) => {
|
|
1600
|
-
stepping = Boolean(openId);
|
|
1601
|
-
keepKeys = stepping && (keys || root.activeElement?.localName === "textarea");
|
|
1602
|
-
openId = c.id;
|
|
1603
|
-
draft = null;
|
|
1604
|
-
if (coarse) listOpen = false;
|
|
1605
|
-
render();
|
|
1606
|
-
const pinTop = position(c.anchor || {}).top;
|
|
1607
|
-
let top = pinTop - Math.max(40, coarse && openCard?.isConnected ? (innerHeight - openCard.offsetHeight) / 2 : innerHeight / 3);
|
|
1608
|
-
if (!coarse && openCard?.isConnected) {
|
|
1609
|
-
const bottom = openCard.getBoundingClientRect().bottom + scrollY;
|
|
1610
|
-
const tall = bottom - pinTop + 28;
|
|
1611
|
-
top = tall <= innerHeight - 80 ? pinTop - 28 - (innerHeight - tall) / 2 : pinTop - 40;
|
|
1612
|
-
}
|
|
1613
|
-
if (coarse) {
|
|
1614
|
-
const de = document.documentElement;
|
|
1615
|
-
const had = parseFloat(de.style.getPropertyValue("--lab-room")) || 0;
|
|
1616
|
-
const room = Math.max(0, Math.ceil(top + innerHeight - (de.scrollHeight - had)));
|
|
1617
|
-
de.style.setProperty("--lab-room", `${room}px`);
|
|
1618
|
-
de.classList.toggle("lab-room", room > 0);
|
|
1619
|
-
}
|
|
1620
|
-
scrollTo({ top: Math.max(0, top), behavior: still.matches ? "auto" : "smooth" });
|
|
1621
|
-
};
|
|
1622
|
-
const isDone = (c) => c.resolved || workState(c)[0] === "done";
|
|
1623
|
-
const keyWord = (before, key, after) => {
|
|
1624
|
-
const w = el2("span", { class: "kw" });
|
|
1625
|
-
w.append(before, el2("span", { class: "mn", "aria-hidden": "true" }, `(${key})`), after);
|
|
1626
|
-
return w;
|
|
1627
|
-
};
|
|
1628
|
-
function placeBar() {
|
|
1629
|
-
const inMenu = on ? [doneBtn, copyBtn, toggleBtn] : [];
|
|
1630
|
-
for (const b of inMenu) if (b.parentNode !== moreMenu) moreMenu.append(b);
|
|
1631
|
-
if (!on && toggleBtn.parentNode !== bar) bar.insertBefore(toggleBtn, moreBtn);
|
|
1632
|
-
if (!on) root.querySelector(".left").append(copyBtn);
|
|
1633
|
-
moreBtn.hidden = !on;
|
|
1634
|
-
if (!on && !moreMenu.hidden) setMenu(false);
|
|
1635
|
-
let first = true;
|
|
1636
|
-
for (
|
|
1637
|
-
const b of
|
|
1638
|
-
/** @type {HTMLCollectionOf<HTMLElement>} */
|
|
1639
|
-
bar.children
|
|
1640
|
-
) {
|
|
1641
|
-
b.classList.toggle("first", first && !b.hidden);
|
|
1642
|
-
if (!b.hidden) first = false;
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
function goFace() {
|
|
1646
|
-
const gp = goBtn.querySelector(".gp");
|
|
1647
|
-
if (gp) gp.textContent = !goMode && !cursorMode ? initial(store2.get("lab-name")) || "+" : "go";
|
|
1648
|
-
goBtn.setAttribute("aria-label", `a click places: ${cursorMode ? "nothing (cursor)" : goMode ? "go" : "a comment"}`);
|
|
1649
|
-
goBtn.setAttribute("aria-keyshortcuts", "1 2 3");
|
|
1650
|
-
}
|
|
1651
|
-
function drawList() {
|
|
1652
|
-
const all = threads();
|
|
1653
|
-
listBtn.hidden = !on || !coarse && !all.length && !held().length;
|
|
1654
|
-
goBtn.hidden = !on;
|
|
1655
|
-
if (!goBtn.firstElementChild) goBtn.replaceChildren(el2("span", { class: "gp" }, "go"), el2("kbd", { "aria-hidden": "true" }, "1/2/3"));
|
|
1656
|
-
goFace();
|
|
1657
|
-
goBtn.classList.toggle("on", goMode && !cursorMode);
|
|
1658
|
-
goBtn.classList.toggle("cursor", cursorMode);
|
|
1659
|
-
goBtn.setAttribute("aria-pressed", String(goMode && !cursorMode));
|
|
1660
|
-
const freshAll = all.filter((c) => !isPage(c)).reduce((n, c) => n + unread(c).length, 0);
|
|
1661
|
-
listBtn.replaceChildren(document.createTextNode(freshAll ? `list \xB7 ${freshAll} new` : "list"), el2("kbd", { "aria-hidden": "true" }, "l"));
|
|
1662
|
-
newPrev.hidden = newNext.hidden = !on || !all.some((c) => !isPage(c) && unread(c).length);
|
|
1663
|
-
if (!LIST_WINDOW) {
|
|
1664
|
-
newPrev.hidden = newNext.hidden = true;
|
|
1665
|
-
listBtn.hidden = !on;
|
|
1666
|
-
{
|
|
1667
|
-
listBtn.replaceChildren(coarse ? "new" : keyWord("ne", "w", ""), el2("b", { class: `cnt${freshAll ? "" : " zero"}` }, String(freshAll)));
|
|
1668
|
-
listBtn.setAttribute("aria-label", `next new comment, ${freshAll} new`);
|
|
1669
|
-
listBtn.setAttribute("aria-keyshortcuts", "w");
|
|
1670
|
-
}
|
|
1671
|
-
listBtn.title = "next new comment: W, or Control-D while typing (Shift for the one before)";
|
|
1672
|
-
listBtn.disabled = !freshAll;
|
|
1673
|
-
listBtn.classList.toggle("quiet", !freshAll);
|
|
1674
|
-
const doneCount2 = all.filter((c) => !isPage(c) && (c.resolved || workState(c)[0] === "done") && !unread(c).length).length;
|
|
1675
|
-
doneBtn.hidden = !on;
|
|
1676
|
-
doneBtn.disabled = !doneCount2 && !showDone;
|
|
1677
|
-
doneBtn.classList.toggle("quiet", doneBtn.disabled);
|
|
1678
|
-
doneBtn.replaceChildren(showDone ? `hide done \xB7 ${doneCount2}` : `show done \xB7 ${doneCount2}`, el2("kbd", { "aria-hidden": "true" }, "d"));
|
|
1679
|
-
doneBtn.setAttribute("aria-keyshortcuts", "d");
|
|
1680
|
-
}
|
|
1681
|
-
placeBar();
|
|
1682
|
-
const tabNew = all.reduce((n, c) => n + unread(c).length, 0);
|
|
1683
|
-
if (!tabTitle.base || !document.title.startsWith("(")) tabTitle.base = document.title.replace(/^\(\d+\) /, "");
|
|
1684
|
-
const want = tabNew ? `(${tabNew}) ${tabTitle.base}` : tabTitle.base;
|
|
1685
|
-
if (document.title !== want) document.title = want;
|
|
1686
|
-
listBtn.classList.toggle("has-new", freshAll > 0);
|
|
1687
|
-
const h = held().length;
|
|
1688
|
-
sendBtn.hidden = !h;
|
|
1689
|
-
sendBtn.textContent = `send ${h} draft${h === 1 ? "" : "s"}`;
|
|
1690
|
-
listEl.hidden = !on || !listOpen;
|
|
1691
|
-
if (listEl.hidden) return;
|
|
1692
|
-
for (
|
|
1693
|
-
const b of
|
|
1694
|
-
/** @type {NodeListOf<HTMLElement>} */
|
|
1695
|
-
listEl.querySelectorAll("[data-f]")
|
|
1696
|
-
) b.classList.toggle("on", b.dataset.f === filter);
|
|
1697
|
-
const fresh = all.filter((c) => !isPage(c) && unread(c).length).length;
|
|
1698
|
-
listEl.querySelector('[data-f="new"]').textContent = fresh ? `new \xB7 ${fresh}` : "new";
|
|
1699
|
-
for (const f of ["work", "resolved", "mine"]) $(`[data-f="${f}"]`, listEl).hidden = true;
|
|
1700
|
-
holdBtn.hidden = !DRAFT_MODE;
|
|
1701
|
-
const doneCount = all.filter((c) => !isPage(c) && (c.resolved || workState(c)[0] === "done") && !unread(c).length).length;
|
|
1702
|
-
showDoneBtn.hidden = !doneCount;
|
|
1703
|
-
showDoneBtn.textContent = showDone ? `hide done \xB7 ${doneCount}` : `show done \xB7 ${doneCount}`;
|
|
1704
|
-
holdBtn.classList.toggle("on", drafting());
|
|
1705
|
-
if (filter === "work") return listEl.querySelector(".items").replaceChildren(...workItems());
|
|
1706
|
-
const items = listed().map((c) => {
|
|
1707
|
-
const b = el2("button", { class: `it${openId === c.id ? " cur" : ""}`, type: "button" });
|
|
1708
|
-
b.append(document.createTextNode(`${c.resolved ? "\u2713" : numberOf(c)} ${c.text.replace(/\s+/g, " ").slice(0, 70)} `), ...onWhat(c) ? [el2("span", {}, `on ${onWhat(c)} `)] : [], el2("span", {}, `\xB7 ${c.name}${!c.resolved && isDone(c) ? " \xB7 \u2705 done" : ""}`), ...unread(c).length ? [" ", el2("span", { class: "tag" }, `${unread(c).length} new`)] : []);
|
|
1709
|
-
b.addEventListener("click", () => goTo(c));
|
|
1710
|
-
return b;
|
|
1711
|
-
});
|
|
1712
|
-
listEl.querySelector(".items").replaceChildren(...items.length ? items : [el2("div", { class: "none" }, "nothing here")]);
|
|
1713
|
-
}
|
|
1714
|
-
const ago = (iso) => {
|
|
1715
|
-
const m = Math.max(0, Math.round((Date.now() - new Date(iso).getTime()) / 6e4));
|
|
1716
|
-
return m < 1 ? "just now" : m < 60 ? `${m} min` : `${Math.floor(m / 60)} h ${m % 60} min`;
|
|
1717
|
-
};
|
|
1718
|
-
const workState = (c) => {
|
|
1719
|
-
const thread = [c, ...repliesOf(c.id)];
|
|
1720
|
-
const lastPerson = thread.filter((m) => !m.session).map((m) => m.createdAt).sort().at(-1) || "";
|
|
1721
|
-
const answer = thread.filter((m) => m.session).sort((a, b) => a.createdAt.localeCompare(b.createdAt)).at(-1);
|
|
1722
|
-
const answered = answer && answer.createdAt > lastPerson;
|
|
1723
|
-
if (c.resolved || answered && /^done\b/i.test(answer.text)) return ["done", answered ? answer.createdAt : c.createdAt];
|
|
1724
|
-
if (answered && /^on it\b/i.test(answer.text)) return ["now", answer.createdAt];
|
|
1725
|
-
if (!answered && c.handedAt && c.handedAt >= lastPerson) return ["now", c.handedAt];
|
|
1726
|
-
return answered ? [null, ""] : ["next", lastPerson];
|
|
1727
|
-
};
|
|
1728
|
-
function workItems() {
|
|
1729
|
-
const today = (/* @__PURE__ */ new Date()).toDateString();
|
|
1730
|
-
const now = [];
|
|
1731
|
-
const next = [];
|
|
1732
|
-
const done = [];
|
|
1733
|
-
for (const c of comments.filter((x) => !x.parent)) {
|
|
1734
|
-
const [state, at] = workState(c);
|
|
1735
|
-
if (state === "now") now.push([c, at]);
|
|
1736
|
-
else if (state === "next") next.push([c, at]);
|
|
1737
|
-
else if (state === "done" && new Date(at).toDateString() === today) done.push([c, at]);
|
|
1738
|
-
}
|
|
1739
|
-
const row = ([c, at], when) => {
|
|
1740
|
-
const b = el2("button", { class: `it${openId === c.id ? " cur" : ""}`, type: "button" });
|
|
1741
|
-
b.append(document.createTextNode(`${isPage(c) ? "chat" : c.resolved ? "\u2713" : numberOf(c)} ${c.text.replace(/\s+/g, " ").slice(0, 70)} `), el2("span", {}, `\xB7 ${when(at)}`));
|
|
1742
|
-
b.addEventListener("click", () => isPage(c) ? (chatOpen = true, listOpen = false, render()) : goTo(c));
|
|
1743
|
-
return b;
|
|
1744
|
-
};
|
|
1745
|
-
const part = (title, list, when, newest = false) => list.length ? [el2("div", { class: "group" }, `${title} \xB7 ${list.length}`), ...list.sort((a, b) => (newest ? -1 : 1) * a[1].localeCompare(b[1])).map((x) => row(x, when))] : [];
|
|
1746
|
-
const out = [
|
|
1747
|
-
...part("Now", now, (at) => `on it ${ago(at)}`.replace("on it just now", "just started")),
|
|
1748
|
-
...part("Next", next, (at) => `sent ${ago(at)} ago`.replace("just now ago", "just now")),
|
|
1749
|
-
...part("Done today", done, (at) => new Date(at).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), true)
|
|
1750
|
-
];
|
|
1751
|
-
return out.length ? out : [el2("div", { class: "none" }, "nothing in progress on this page")];
|
|
1752
|
-
}
|
|
1753
|
-
const stamped = (bubble, stamp) => {
|
|
1754
|
-
const room = stamp.cloneNode(true);
|
|
1755
|
-
room.className = "stamp-room";
|
|
1756
|
-
room.setAttribute("aria-hidden", "true");
|
|
1757
|
-
for (const n of room.querySelectorAll("[role]")) n.removeAttribute("role");
|
|
1758
|
-
const last = [...bubble.children].reverse().find((n) => n.classList?.contains("p"));
|
|
1759
|
-
(last || bubble).append(room);
|
|
1760
|
-
bubble.append(stamp);
|
|
1761
|
-
};
|
|
1762
|
-
const stampOf = (m, root2, prefix = "") => {
|
|
1763
|
-
const at = new Date(m.createdAt);
|
|
1764
|
-
const time = at.toDateString() === (/* @__PURE__ */ new Date()).toDateString() ? at.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : at.toLocaleDateString([], { day: "numeric", month: "short" });
|
|
1765
|
-
const stamp = el2("span", { class: "stamp" });
|
|
1766
|
-
stamp.append(el2("span", { class: "tm" }, prefix + time));
|
|
1767
|
-
if (mine(m) && !m.session) {
|
|
1768
|
-
const thread = root2 ? [root2, ...repliesOf(root2.id)] : [m];
|
|
1769
|
-
const answered = thread.some((x) => x.session && x.createdAt > m.createdAt);
|
|
1770
|
-
const latest = !thread.some((x) => !x.session && x.createdAt > m.createdAt);
|
|
1771
|
-
if (!answered && latest && root2 && workState(root2)[0] === "now") {
|
|
1772
|
-
stamp.classList.add("busy");
|
|
1773
|
-
stamp.append(el2("span", { class: "ring", role: "img", "aria-label": "the agent is on it" }));
|
|
1774
|
-
} else if (answered) {
|
|
1775
|
-
stamp.classList.add("ans");
|
|
1776
|
-
stamp.append(el2("span", { class: "tick", role: "img", "aria-label": "answered" }, "\u2713"));
|
|
1777
|
-
} else {
|
|
1778
|
-
const got = root2?.handedAt && root2.handedAt >= m.createdAt;
|
|
1779
|
-
stamp.append(el2("span", { class: `tick${got ? " got" : ""}`, role: "img", "aria-label": got ? "delivered to the agent" : "sent" }, got ? "\u2713\u2713" : "\u2713"));
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
return stamp;
|
|
1783
|
-
};
|
|
1784
|
-
let replyTo = null;
|
|
1785
|
-
let newFrom = null;
|
|
1786
|
-
function drawChat() {
|
|
1787
|
-
const byId = new Map(comments.map((c) => [c.id, c]));
|
|
1788
|
-
const msgs = comments.filter((c) => isPage(c) || c.parent && isPage(byId.get(c.parent) || {})).sort((a, b) => a.createdAt.localeCompare(b.createdAt)).slice(-150);
|
|
1789
|
-
if (on && chatOpen && chatEl.hidden) newFrom = msgs.find(isNew)?.id || null;
|
|
1790
|
-
if (!chatOpen) newFrom = null;
|
|
1791
|
-
if (on && chatOpen) markSeen(msgs.filter(isNew));
|
|
1792
|
-
const fresh = msgs.filter(isNew).length;
|
|
1793
|
-
chatBtn.hidden = !on;
|
|
1794
|
-
{
|
|
1795
|
-
chatBtn.replaceChildren(coarse ? "chat" : keyWord("", "c", "hat"), el2("b", { class: `cnt${fresh ? "" : " zero"}` }, String(fresh)));
|
|
1796
|
-
chatBtn.setAttribute("aria-label", `chat, ${fresh} new`);
|
|
1797
|
-
chatBtn.setAttribute("aria-keyshortcuts", "c");
|
|
1798
|
-
}
|
|
1799
|
-
chatBtn.classList.toggle("has-new", fresh > 0);
|
|
1800
|
-
placeBar();
|
|
1801
|
-
const opening = chatEl.hidden;
|
|
1802
|
-
chatEl.hidden = !on || !chatOpen;
|
|
1803
|
-
if (chatEl.hidden) chatEl.classList.remove("full");
|
|
1804
|
-
if (chatEl.hidden && chatEl.contains(root.activeElement)) root.activeElement.blur();
|
|
1805
|
-
if (chatEl.hidden) return;
|
|
1806
|
-
const box = $(".msgs", chatEl);
|
|
1807
|
-
const atEnd = opening || box.scrollHeight - box.scrollTop - box.clientHeight < 48;
|
|
1808
|
-
const before = new Set(opening ? [] : [.../** @type {HTMLCollectionOf<HTMLElement>} */
|
|
1809
|
-
box.children].map((n) => n.dataset.id));
|
|
1810
|
-
const kept = new Map([.../** @type {HTMLCollectionOf<HTMLElement>} */
|
|
1811
|
-
box.children].filter((n) => n.dataset.id).map((n) => [n.dataset.id, n]));
|
|
1812
|
-
const same = (n) => {
|
|
1813
|
-
const old = kept.get(n.dataset?.id);
|
|
1814
|
-
return old && old.outerHTML.replace(" fresh", "") === n.outerHTML ? old : n;
|
|
1815
|
-
};
|
|
1816
|
-
patchKids(box, msgs.flatMap((m) => {
|
|
1817
|
-
const root2 = m.parent ? byId.get(m.parent) : m;
|
|
1818
|
-
const b = el2("div", { class: `msg${mine(m) && !m.session ? " mine" : ""}${root2 && replyTo === root2.id ? " to" : ""}${before.size && !before.has(m.id) ? " fresh" : ""}`, "data-id": m.id, ...agentOf(m) ? { "data-agent": agentOf(m) } : {} });
|
|
1819
|
-
b.append(nameLine(m.name, false));
|
|
1820
|
-
if (m.parent && root2) {
|
|
1821
|
-
const q = el2("div", { class: "quote" });
|
|
1822
|
-
q.append(el2("b", {}, String(root2.name || "").replace(/\s*·\s*session\s+\S+$/i, "")), document.createTextNode(root2.text.replace(/\s+/g, " ").slice(0, 90)));
|
|
1823
|
-
q.addEventListener("click", (e) => {
|
|
1824
|
-
e.stopPropagation();
|
|
1825
|
-
const box2 = $(".msgs", chatEl);
|
|
1826
|
-
const to = $(`[data-id="${root2.id}"]`, box2);
|
|
1827
|
-
if (!to) return;
|
|
1828
|
-
box2.scrollTo({ top: to.offsetTop - box2.offsetTop - 12, behavior: still.matches ? "auto" : "smooth" });
|
|
1829
|
-
to.animate?.([{ boxShadow: "0 0 0 2px rgb(52,199,89)" }, { boxShadow: "0 0 0 0 transparent" }], { duration: 900 });
|
|
1830
|
-
});
|
|
1831
|
-
b.append(q);
|
|
1832
|
-
}
|
|
1833
|
-
b.append(...readable(m.text));
|
|
1834
|
-
stamped(b, stampOf(m, root2));
|
|
1835
|
-
return m.id === newFrom && m !== msgs[0] ? [el2("div", { class: "newline" }, "new"), b] : [b];
|
|
1836
|
-
}).map(same));
|
|
1837
|
-
const strip = $(".replying", chatEl);
|
|
1838
|
-
const target = replyTo && byId.get(replyTo);
|
|
1839
|
-
strip.hidden = !target;
|
|
1840
|
-
if (target) {
|
|
1841
|
-
const x = el2("button", { type: "button", title: "about the page instead" }, "\u2715");
|
|
1842
|
-
x.addEventListener("click", () => (replyTo = null, drawChat()));
|
|
1843
|
-
strip.replaceChildren(document.createTextNode(`\u21A9 ${target.name}: ${target.text.replace(/\s+/g, " ").slice(0, 40)}`), x);
|
|
1844
|
-
}
|
|
1845
|
-
if (!box.firstChild) box.append(el2("div", { class: "none" }, "say something about the page as a whole"));
|
|
1846
|
-
const chat = chatEl.querySelector(".chat");
|
|
1847
|
-
if (!chat.firstChild)
|
|
1848
|
-
chat.append(
|
|
1849
|
-
composer({
|
|
1850
|
-
placeholder: "message",
|
|
1851
|
-
onSubmit: async (name, text) => {
|
|
1852
|
-
const { comment } = await send(
|
|
1853
|
-
replyTo ? { name, text, parent: replyTo } : { name, text, anchor: { kind: "page", width: innerWidth, height: innerHeight, dpr: devicePixelRatio || 1 } }
|
|
1854
|
-
);
|
|
1855
|
-
const answered = replyTo && comments.find((x) => x.id === replyTo);
|
|
1856
|
-
if (answered?.resolved) answered.resolved = false;
|
|
1857
|
-
replyTo = null;
|
|
1858
|
-
comments.push(comment);
|
|
1859
|
-
markSeen([comment]);
|
|
1860
|
-
box.scrollTop = box.scrollHeight;
|
|
1861
|
-
render();
|
|
1862
|
-
return { keep: true };
|
|
1863
|
-
}
|
|
1864
|
-
})
|
|
1865
|
-
);
|
|
1866
|
-
chat.querySelector("textarea").placeholder = target ? "reply" : "message";
|
|
1867
|
-
if (atEnd) box.scrollTop = box.scrollHeight;
|
|
1868
|
-
}
|
|
1869
|
-
const numberOf = (c) => comments.filter((x) => !x.parent && !x.resolved).sort((a, b) => a.createdAt.localeCompare(b.createdAt)).indexOf(c) + 1;
|
|
1870
|
-
const seenKey = () => `lab-seen:${page}`;
|
|
1871
|
-
const readSeen = () => new Set(store2.get(seenKey()).split(",").filter(Boolean));
|
|
1872
|
-
let seen = readSeen();
|
|
1873
|
-
const plain = (n) => String(n || "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
1874
|
-
const mine = (c) => plain(c.name) && plain(c.name) === plain(store2.get("lab-name")) || Boolean(store2.get(`lab-edit:${c.id}`));
|
|
1875
|
-
const isNew = (c) => !seen.has(c.id) && !mine(c);
|
|
1876
|
-
const unread = (c) => [c, ...repliesOf(c.id)].filter(isNew);
|
|
1877
|
-
const markSeen = (items) => {
|
|
1878
|
-
const fresh = items.filter((item) => !seen.has(item.id)).map((item) => item.id);
|
|
1879
|
-
for (const item of items) seen.add(item.id);
|
|
1880
|
-
store2.set(seenKey(), [...seen].join(","));
|
|
1881
|
-
if (fresh.length) shareReads(fresh);
|
|
1882
|
-
};
|
|
1883
|
-
const READS = script?.dataset.live ? script.dataset.live.replace(/live$/, "api/reads") : "";
|
|
1884
|
-
const shareReads = (ids) => {
|
|
1885
|
-
const who = store2.get("lab-name").trim();
|
|
1886
|
-
if (!READS || !who || !ids.length) return;
|
|
1887
|
-
fetch(READS, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ name: who, page, ids }) }).catch(() => {
|
|
1888
|
-
});
|
|
1889
|
-
};
|
|
1890
|
-
async function syncReads() {
|
|
1891
|
-
const who = store2.get("lab-name").trim();
|
|
1892
|
-
if (!READS || !who) return;
|
|
1893
|
-
const at = page;
|
|
1894
|
-
try {
|
|
1895
|
-
const { ids } = await (await fetch(`${READS}?name=${encodeURIComponent(who)}&page=${encodeURIComponent(at)}`, { cache: "no-store" })).json();
|
|
1896
|
-
if (at !== page) return;
|
|
1897
|
-
const theirs = new Set(ids);
|
|
1898
|
-
const mineOnly = [...seen].filter((id) => !theirs.has(id));
|
|
1899
|
-
const added = ids.filter((id) => !seen.has(id));
|
|
1900
|
-
if (mineOnly.length) shareReads(mineOnly);
|
|
1901
|
-
if (!added.length) return;
|
|
1902
|
-
for (const id of added) seen.add(id);
|
|
1903
|
-
store2.set(seenKey(), [...seen].join(","));
|
|
1904
|
-
shownAgain();
|
|
1905
|
-
} catch {
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
const repliesOf = (id) => comments.filter((c) => c.parent === id);
|
|
1909
|
-
const initial = (name) => [...String(name || "").trim()][0]?.toUpperCase() || "";
|
|
1910
|
-
function placeCard(card, left, top) {
|
|
1911
|
-
layer2.append(card);
|
|
1912
|
-
const width = card.offsetWidth;
|
|
1913
|
-
const maxLeft = scrollX + document.documentElement.clientWidth - width - 12;
|
|
1914
|
-
card.style.left = `${Math.max(scrollX + 12, Math.min(left - 14, maxLeft))}px`;
|
|
1915
|
-
const h = card.offsetHeight;
|
|
1916
|
-
const below = top + 10 + h > contentEnd();
|
|
1917
|
-
card.style.top = `${below ? Math.max(scrollY + 8, top - 40 - h) : top + 10}px`;
|
|
1918
|
-
card.style.transformOrigin = below ? "14px 100%" : "";
|
|
1919
|
-
}
|
|
1920
|
-
const contentEnd = () => {
|
|
1921
|
-
inPage(0);
|
|
1922
|
-
return pageEnd.y;
|
|
1923
|
-
};
|
|
1924
|
-
const ARROW = '<i class="arr" aria-hidden="true"></i>';
|
|
1925
|
-
function composer({ placeholder, onSubmit, autofocus = false }) {
|
|
1926
|
-
const wrap = el2("div", { class: "composer" });
|
|
1927
|
-
const box = el2("div", { class: "box" });
|
|
1928
|
-
const text = el2("textarea", { placeholder, maxlength: "2000", rows: "1", "aria-label": placeholder, enterkeyhint: "send", autocomplete: "off", autocorrect: "off", spellcheck: "false", writingsuggestions: "false" });
|
|
1929
|
-
const who = el2("label", { class: "who" });
|
|
1930
|
-
const as = el2("span", {}, "as");
|
|
1931
|
-
const name = el2("input", { type: "text", placeholder: "your name", maxlength: "60", enterkeyhint: "send", autocomplete: "off", autocorrect: "off", autocapitalize: "words", spellcheck: "false", writingsuggestions: "false", "data-1p-ignore": "", "data-lpignore": "true" });
|
|
1932
|
-
name.value = store2.get("lab-name");
|
|
1933
|
-
who.append(as, name);
|
|
1934
|
-
const sendBtn2 = el2("button", { class: "send", type: "button", "aria-label": "send" });
|
|
1935
|
-
sendBtn2.addEventListener("pointerdown", (e) => e.preventDefault());
|
|
1936
|
-
sendBtn2.addEventListener("mousedown", (e) => e.preventDefault());
|
|
1937
|
-
sendBtn2.innerHTML = ARROW;
|
|
1938
|
-
const error = el2("div", { class: "error" });
|
|
1939
|
-
box.append(text, el2("div", { class: "line" }), who, sendBtn2);
|
|
1940
|
-
wrap.append(box, error);
|
|
1941
|
-
box.addEventListener("click", (e) => {
|
|
1942
|
-
if (e.target !== box && !e.target.classList?.contains("line")) return;
|
|
1943
|
-
text.focus({ preventScroll: true });
|
|
1944
|
-
text.setSelectionRange(text.value.length, text.value.length);
|
|
1945
|
-
});
|
|
1946
|
-
const sync = () => {
|
|
1947
|
-
const open = text.value.length > 0 || root.activeElement === name || !!error.textContent;
|
|
1948
|
-
const glide = open !== box.classList.contains("open") && !store2.get("lab-name") && box.isConnected && !matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1949
|
-
const from = glide && { arrow: sendBtn2.getBoundingClientRect(), height: box.getBoundingClientRect().height };
|
|
1950
|
-
const one = Boolean(store2.get("lab-name"));
|
|
1951
|
-
box.classList.toggle("one", one);
|
|
1952
|
-
box.classList.toggle("open", open);
|
|
1953
|
-
as.hidden = !name.value.trim();
|
|
1954
|
-
if (one && !CSS.supports?.("field-sizing", "content")) name.style.width = `${Math.max(2, name.value.length + 1)}ch`;
|
|
1955
|
-
sendBtn2.classList.toggle("ready", Boolean(text.value.trim() && name.value.trim()));
|
|
1956
|
-
text.style.height = "auto";
|
|
1957
|
-
text.style.height = `${text.scrollHeight}px`;
|
|
1958
|
-
if (glide) {
|
|
1959
|
-
const to = sendBtn2.getBoundingClientRect();
|
|
1960
|
-
const timing = { duration: 220, easing: "cubic-bezier(.2, .7, .3, 1)" };
|
|
1961
|
-
sendBtn2.animate([{ transform: `translate(${from.arrow.left - to.left}px, ${from.arrow.top - to.top}px)` }, { transform: "none" }], timing);
|
|
1962
|
-
box.style.overflow = "hidden";
|
|
1963
|
-
box.animate([{ height: `${from.height}px` }, { height: `${box.getBoundingClientRect().height}px` }], timing).onfinish = () => box.style.overflow = "";
|
|
1964
|
-
}
|
|
1965
|
-
};
|
|
1966
|
-
let busy = false;
|
|
1967
|
-
const go = async () => {
|
|
1968
|
-
if (busy) return;
|
|
1969
|
-
if (!text.value.trim()) return text.focus();
|
|
1970
|
-
if (!name.value.trim()) {
|
|
1971
|
-
box.classList.add("open");
|
|
1972
|
-
return name.focus();
|
|
1973
|
-
}
|
|
1974
|
-
store2.set("lab-name", name.value.trim());
|
|
1975
|
-
refreshPinCursor();
|
|
1976
|
-
syncReads();
|
|
1977
|
-
sendBtn2.classList.remove("sent");
|
|
1978
|
-
void sendBtn2.offsetWidth;
|
|
1979
|
-
sendBtn2.classList.add("sent");
|
|
1980
|
-
busy = true;
|
|
1981
|
-
error.textContent = "";
|
|
1982
|
-
error.classList.remove("wait");
|
|
1983
|
-
const slow = setTimeout(() => {
|
|
1984
|
-
error.textContent = "sending\u2026 it goes as soon as the lab is back";
|
|
1985
|
-
error.classList.add("wait");
|
|
1986
|
-
}, 1500);
|
|
1987
|
-
try {
|
|
1988
|
-
const result = await onSubmit(name.value.trim(), text.value.trim());
|
|
1989
|
-
clearTimeout(slow);
|
|
1990
|
-
error.textContent = "";
|
|
1991
|
-
error.classList.remove("wait");
|
|
1992
|
-
if (result?.keep) {
|
|
1993
|
-
text.value = "";
|
|
1994
|
-
sync();
|
|
1995
|
-
}
|
|
1996
|
-
} catch (e) {
|
|
1997
|
-
clearTimeout(slow);
|
|
1998
|
-
error.classList.remove("wait");
|
|
1999
|
-
error.textContent = e.message;
|
|
2000
|
-
sync();
|
|
2001
|
-
}
|
|
2002
|
-
busy = false;
|
|
2003
|
-
};
|
|
2004
|
-
const onKey = (e) => {
|
|
2005
|
-
if (e.key === "Enter" && !e.shiftKey && !e.isComposing) {
|
|
2006
|
-
e.preventDefault();
|
|
2007
|
-
go();
|
|
2008
|
-
}
|
|
2009
|
-
};
|
|
2010
|
-
text.addEventListener("input", sync);
|
|
2011
|
-
name.addEventListener("input", sync);
|
|
2012
|
-
name.addEventListener("blur", () => setTimeout(sync, 0));
|
|
2013
|
-
text.addEventListener("keydown", onKey);
|
|
2014
|
-
name.addEventListener("keydown", onKey);
|
|
2015
|
-
sendBtn2.addEventListener("click", go);
|
|
2016
|
-
sendBtn2.addEventListener("mousedown", (e) => e.preventDefault());
|
|
2017
|
-
requestAnimationFrame(sync);
|
|
2018
|
-
const focus = () => text.focus({ preventScroll: true });
|
|
2019
|
-
if (autofocus) queueMicrotask(() => text.isConnected ? focus() : setTimeout(focus, 0));
|
|
2020
|
-
return wrap;
|
|
2021
|
-
}
|
|
2022
|
-
function placeBeside(node, left, top) {
|
|
2023
|
-
layer2.append(node);
|
|
2024
|
-
const width = node.offsetWidth;
|
|
2025
|
-
const right = scrollX + document.documentElement.clientWidth - 12;
|
|
2026
|
-
const h = node.offsetHeight;
|
|
2027
|
-
const end = contentEnd();
|
|
2028
|
-
if (left + 36 + width <= right) {
|
|
2029
|
-
node.style.left = `${left + 36}px`;
|
|
2030
|
-
node.style.top = `${Math.min(top - 37, end - h - 8)}px`;
|
|
2031
|
-
} else {
|
|
2032
|
-
node.style.left = `${Math.max(scrollX + 12, Math.min(left - 14, right - width))}px`;
|
|
2033
|
-
node.style.top = `${top + 10 + h > end ? Math.max(scrollY + 8, top - 40 - h) : top + 10}px`;
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
let shown = null;
|
|
2037
|
-
let posted = null;
|
|
2038
|
-
const still = matchMedia("(prefers-reduced-motion: reduce)");
|
|
2039
|
-
const pinsById = /* @__PURE__ */ new Map();
|
|
2040
|
-
let dropDrag = null;
|
|
2041
|
-
function render() {
|
|
2042
|
-
grabbing = false;
|
|
2043
|
-
dropDrag?.();
|
|
2044
|
-
const prev = (
|
|
2045
|
-
/** @type {HTMLElement | null} */
|
|
2046
|
-
layer2.querySelector(".card:not(.out), .float:not(.out)")
|
|
2047
|
-
);
|
|
2048
|
-
const prevHeight = stepping && coarse && prev ? prev.offsetHeight : 0;
|
|
2049
|
-
const prevScroll = prev ? prev.querySelector(".body")?.scrollTop ?? null : null;
|
|
2050
|
-
const places = new Map(on ? threads().filter((c) => c.anchor?.kind !== "page").map((c) => [c.id, position(c.anchor || {})]) : []);
|
|
2051
|
-
layer2.replaceChildren();
|
|
2052
|
-
pinsById.clear();
|
|
2053
|
-
const now = on ? draft || openId : null;
|
|
2054
|
-
const appear = now !== shown;
|
|
2055
|
-
const anim = appear ? " in" : "";
|
|
2056
|
-
let quoted = null;
|
|
2057
|
-
const done = () => {
|
|
2058
|
-
if (closeFast && !now && prev) {
|
|
2059
|
-
closeFast = false;
|
|
2060
|
-
prev.inert = true;
|
|
2061
|
-
layer2.append(prev);
|
|
2062
|
-
const gone2 = () => prev.remove();
|
|
2063
|
-
if (still.matches || !prev.animate) gone2();
|
|
2064
|
-
else prev.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 120, easing: "ease-out", fill: "forwards" }).finished.then(gone2, gone2);
|
|
2065
|
-
} else if (coarse && !now && shown && prev && !still.matches && !prev.style.transform) {
|
|
2066
|
-
prev.classList.remove("in");
|
|
2067
|
-
prev.classList.add("out");
|
|
2068
|
-
prev.inert = true;
|
|
2069
|
-
layer2.append(prev);
|
|
2070
|
-
setTimeout(() => prev.remove(), coarse ? 230 : 150);
|
|
2071
|
-
}
|
|
2072
|
-
markQuote(quoted);
|
|
2073
|
-
shown = now;
|
|
2074
|
-
posted = null;
|
|
2075
|
-
};
|
|
2076
|
-
const list = threads();
|
|
2077
|
-
const open = list.filter((c) => !c.resolved && c.anchor?.kind !== "page").length;
|
|
2078
|
-
const fresh = list.filter((c) => !c.resolved && c.anchor?.kind !== "page").reduce((n, c) => n + unread(c).length, 0);
|
|
2079
|
-
toggleBtn.replaceChildren(
|
|
2080
|
-
document.createTextNode((on ? "hide comments" : open ? `comments \xB7 ${open}` : "comments") + (!on && fresh ? ` \xB7 ${fresh} new` : "")),
|
|
2081
|
-
el2("kbd", { "aria-hidden": "true" }, "m")
|
|
2082
|
-
);
|
|
2083
|
-
toggleBtn.classList.toggle("secondary", on);
|
|
2084
|
-
host2.toggleAttribute("data-sheet", Boolean(on && (draft || openId || listOpen || chatOpen)));
|
|
2085
|
-
document.documentElement.classList.toggle("lab-sheet", host2.hasAttribute("data-sheet"));
|
|
2086
|
-
backCloses();
|
|
2087
|
-
refit();
|
|
2088
|
-
document.documentElement.classList.toggle("lab-pinning", on && !cursorMode);
|
|
2089
|
-
document.documentElement.classList.toggle("lab-go", on && goMode && !cursorMode);
|
|
2090
|
-
copyBtn.hidden = !on || !isAdmin || list.every((c) => c.resolved);
|
|
2091
|
-
drawList();
|
|
2092
|
-
drawChat();
|
|
2093
|
-
if (!on) return done();
|
|
2094
|
-
for (const h of held()) {
|
|
2095
|
-
const { left, top } = position(h.anchor);
|
|
2096
|
-
const p = el2("div", { class: "pin held", title: `${h.name}: ${h.text} \xB7 draft, not sent yet` }, initial(h.name));
|
|
2097
|
-
p.style.left = `${left}px`;
|
|
2098
|
-
p.style.top = `${top}px`;
|
|
2099
|
-
layer2.append(p);
|
|
2100
|
-
}
|
|
2101
|
-
list.forEach((c) => {
|
|
2102
|
-
if (isPage(c)) return;
|
|
2103
|
-
if (!showDone && openId !== c.id && (c.resolved || workState(c)[0] === "done") && !unread(c).length) return;
|
|
2104
|
-
const { left, top, moved, zone } = places.get(c.id) || position(c.anchor || {});
|
|
2105
|
-
if (openId === c.id) drawZone(zone, `saved${anim}`);
|
|
2106
|
-
const news = unread(c);
|
|
2107
|
-
const movable = !zone && (isAdmin || store2.get(`lab-edit:${c.id}`));
|
|
2108
|
-
const [state] = workState(c);
|
|
2109
|
-
const pin = el2(
|
|
2110
|
-
"button",
|
|
2111
|
-
{
|
|
2112
|
-
class: `pin${/^go$/i.test(c.text.trim()) ? " go" : ""}${c.resolved ? " resolved" : ""}${state === "done" ? " done" : ""}${state === "now" ? " working" : ""}${news.length ? " new" : ""}${moved ? " moved" : ""}${posted === c.id ? " in" : ""}${movable ? " grab" : ""}${openId === c.id ? " open" : ""}`,
|
|
2113
|
-
type: "button",
|
|
2114
|
-
title: `${c.resolved ? "" : `${numberOf(c)} \xB7 `}${c.name}${moved ? " \xB7 the spot it was pinned to has changed" : ""}${movable ? " \xB7 drag to move" : ""}`,
|
|
2115
|
-
// Its state in words too (the ring, the tick and the new dot are only seen).
|
|
2116
|
-
"aria-label": `${/^go$/i.test(c.text.trim()) ? "go" : "comment"}${c.resolved ? "" : ` ${numberOf(c)}`} by ${c.name}${state === "now" ? ", agent working on it" : state === "done" || c.resolved ? ", done" : ""}${news.length ? `, ${news.length} new` : ""}${moved ? ", moved" : ""}`
|
|
2117
|
-
},
|
|
2118
|
-
/^go$/i.test(c.text.trim()) ? "go" : state === "done" || c.resolved ? "\u2713" : initial(c.name)
|
|
2119
|
-
);
|
|
2120
|
-
if (state === "now") pin.append(el2("i", { class: "ring", "aria-hidden": "true" }));
|
|
2121
|
-
pin.style.left = `${left}px`;
|
|
2122
|
-
pin.style.top = `${top}px`;
|
|
2123
|
-
if (movable) grab(pin, c);
|
|
2124
|
-
if (!coarse && zone && openId !== c.id) {
|
|
2125
|
-
let shown2 = null;
|
|
2126
|
-
pin.addEventListener("pointerenter", () => shown2 = drawZone(zone, "saved"));
|
|
2127
|
-
pin.addEventListener("pointerleave", () => (shown2?.remove(), shown2 = null));
|
|
2128
|
-
} else if (!coarse && c.anchor?.quote && !zone) {
|
|
2129
|
-
pin.addEventListener("pointerenter", () => markQuote(c.anchor));
|
|
2130
|
-
pin.addEventListener("pointerleave", () => markQuote(quoted));
|
|
2131
|
-
}
|
|
2132
|
-
pin.addEventListener("click", (e) => {
|
|
2133
|
-
e.stopPropagation();
|
|
2134
|
-
if (pin.dataset.dragged) return;
|
|
2135
|
-
if (coarse && openId !== c.id) return goTo(c);
|
|
2136
|
-
openId = openId === c.id ? null : c.id;
|
|
2137
|
-
draft = null;
|
|
2138
|
-
render();
|
|
2139
|
-
});
|
|
2140
|
-
layer2.append(pin);
|
|
2141
|
-
pinsById.set(c.id, pin);
|
|
2142
|
-
if (openId === c.id) {
|
|
2143
|
-
const card = threadCard(c, new Set(news.map((x) => x.id)), appear && (coarse ? keepKeys : !stepping || keepKeys));
|
|
2144
|
-
openCard = card;
|
|
2145
|
-
if (appear && !stepping) card.classList.add("in");
|
|
2146
|
-
if (prevHeight) card.style.minHeight = `min(${prevHeight}px, var(--_sheet-max))`;
|
|
2147
|
-
stepping = keepKeys = false;
|
|
2148
|
-
placeCard(card, zone ? left + 14 : left, zone ? zone.top + zone.height : top);
|
|
2149
|
-
if (!appear && prevScroll != null) card.querySelector(".body").scrollTop = prevScroll;
|
|
2150
|
-
else if (appear) {
|
|
2151
|
-
const body = card.querySelector(".body");
|
|
2152
|
-
const first = coarse ? null : body.querySelector(".fresh, .newline");
|
|
2153
|
-
body.scrollTop = first ? first.offsetTop - body.offsetTop - 8 : body.scrollHeight;
|
|
2154
|
-
}
|
|
2155
|
-
if (coarse && cardFull) card.classList.add("full");
|
|
2156
|
-
swipeDown(card, () => (openId = null, cardFull = false, render()), true);
|
|
2157
|
-
markSeen(news);
|
|
2158
|
-
if (news.length) drawList();
|
|
2159
|
-
quoted = zone ? null : c.anchor;
|
|
2160
|
-
}
|
|
2161
|
-
});
|
|
2162
|
-
if (draft) {
|
|
2163
|
-
const { anchor } = draft;
|
|
2164
|
-
const { left, top, zone } = position(anchor);
|
|
2165
|
-
drawZone(zone, "draft");
|
|
2166
|
-
quoted = zone ? null : anchor;
|
|
2167
|
-
const pin = el2("div", { class: `pin draft${anim}` }, initial(store2.get("lab-name")));
|
|
2168
|
-
pin.style.left = `${left}px`;
|
|
2169
|
-
pin.style.top = `${top}px`;
|
|
2170
|
-
layer2.append(pin);
|
|
2171
|
-
const float = el2("div", { class: `float${anim}` });
|
|
2172
|
-
float.append(
|
|
2173
|
-
el2("div", { class: "handle" }),
|
|
2174
|
-
composer({
|
|
2175
|
-
placeholder: "add a comment",
|
|
2176
|
-
autofocus: true,
|
|
2177
|
-
onSubmit: async (name, text) => {
|
|
2178
|
-
if (drafting()) {
|
|
2179
|
-
store2.set(heldKey(), JSON.stringify([...held(), { name, text, anchor }]));
|
|
2180
|
-
draft = null;
|
|
2181
|
-
return render();
|
|
2182
|
-
}
|
|
2183
|
-
const { comment, edit } = await send({ name, text, anchor });
|
|
2184
|
-
if (edit) store2.set(`lab-edit:${comment.id}`, edit);
|
|
2185
|
-
comments.push(comment);
|
|
2186
|
-
markSeen([comment]);
|
|
2187
|
-
draft = null;
|
|
2188
|
-
openId = null;
|
|
2189
|
-
posted = comment.id;
|
|
2190
|
-
render();
|
|
2191
|
-
}
|
|
2192
|
-
})
|
|
2193
|
-
);
|
|
2194
|
-
swipeDown(float, () => (draft = null, render()));
|
|
2195
|
-
if (zone) placeCard(float, left + 14, zone.top + zone.height);
|
|
2196
|
-
else placeBeside(float, left, top);
|
|
2197
|
-
}
|
|
2198
|
-
done();
|
|
2199
|
-
}
|
|
2200
|
-
let grabbing = false;
|
|
2201
|
-
function grab(pin, c) {
|
|
2202
|
-
pin.addEventListener("pointerdown", (e) => {
|
|
2203
|
-
if (e.button !== 0) return;
|
|
2204
|
-
const r = pin.getBoundingClientRect();
|
|
2205
|
-
const tip = { dx: e.clientX - r.left, dy: e.clientY - r.bottom };
|
|
2206
|
-
const start2 = { x: e.clientX, y: e.clientY, sx: scrollX, sy: scrollY, left: parseFloat(pin.style.left), top: parseFloat(pin.style.top) };
|
|
2207
|
-
let moving = false;
|
|
2208
|
-
let last = e;
|
|
2209
|
-
grabbing = true;
|
|
2210
|
-
pin.setPointerCapture(e.pointerId);
|
|
2211
|
-
const place2 = () => {
|
|
2212
|
-
pin.style.left = `${start2.left + last.clientX - start2.x + scrollX - start2.sx}px`;
|
|
2213
|
-
pin.style.top = `${start2.top + last.clientY - start2.y + scrollY - start2.sy}px`;
|
|
2214
|
-
};
|
|
2215
|
-
const move = (ev) => {
|
|
2216
|
-
last = ev;
|
|
2217
|
-
if (!moving && Math.hypot(ev.clientX - start2.x, ev.clientY - start2.y) < 5) return;
|
|
2218
|
-
moving = true;
|
|
2219
|
-
pin.classList.add("dragging");
|
|
2220
|
-
place2();
|
|
2221
|
-
};
|
|
2222
|
-
const scrolled = () => moving && place2();
|
|
2223
|
-
addEventListener("scroll", scrolled, true);
|
|
2224
|
-
dropDrag = () => {
|
|
2225
|
-
removeEventListener("scroll", scrolled, true);
|
|
2226
|
-
dropDrag = null;
|
|
2227
|
-
};
|
|
2228
|
-
const up = async (ev) => {
|
|
2229
|
-
pin.removeEventListener("pointermove", move);
|
|
2230
|
-
pin.removeEventListener("pointerup", up);
|
|
2231
|
-
pin.removeEventListener("pointercancel", up);
|
|
2232
|
-
pin.removeEventListener("lostpointercapture", up);
|
|
2233
|
-
dropDrag?.();
|
|
2234
|
-
if (!grabbing) return;
|
|
2235
|
-
grabbing = false;
|
|
2236
|
-
if (!moving) return;
|
|
2237
|
-
pin.dataset.dragged = "1";
|
|
2238
|
-
setTimeout(() => delete pin.dataset.dragged, 0);
|
|
2239
|
-
const x = ev.clientX - tip.dx;
|
|
2240
|
-
const y = ev.clientY - tip.dy;
|
|
2241
|
-
const under = document.elementsFromPoint(x, y).find((n) => n !== host2);
|
|
2242
|
-
if (ev.type === "pointercancel" || x < 0 || y < 0 || x > innerWidth || y > innerHeight || under?.closest(OFF)) return render();
|
|
2243
|
-
const before = c.anchor;
|
|
2244
|
-
c.anchor = anchorAt(x, y);
|
|
2245
|
-
render();
|
|
2246
|
-
try {
|
|
2247
|
-
const { comment } = await send({ action: "move", id: c.id, anchor: c.anchor, edit: store2.get(`lab-edit:${c.id}`) || void 0 });
|
|
2248
|
-
Object.assign(c, comment);
|
|
2249
|
-
} catch {
|
|
2250
|
-
c.anchor = before;
|
|
2251
|
-
render();
|
|
2252
|
-
}
|
|
2253
|
-
};
|
|
2254
|
-
pin.addEventListener("pointermove", move);
|
|
2255
|
-
pin.addEventListener("pointerup", up);
|
|
2256
|
-
pin.addEventListener("pointercancel", up);
|
|
2257
|
-
pin.addEventListener("lostpointercapture", up);
|
|
2258
|
-
});
|
|
2259
|
-
}
|
|
2260
|
-
let openCard = null;
|
|
2261
|
-
const coarse = matchMedia("(pointer: coarse)").matches;
|
|
2262
|
-
function threadCard(c, fresh = /* @__PURE__ */ new Set(), focus = false) {
|
|
2263
|
-
const card = el2("div", { class: "card" });
|
|
2264
|
-
const body = el2("div", { class: "body" });
|
|
2265
|
-
const foot = el2("div", { class: "foot" });
|
|
2266
|
-
card.append(el2("div", { class: "handle" }), body, foot);
|
|
2267
|
-
card.addEventListener("click", (e) => e.stopPropagation());
|
|
2268
|
-
body.classList.add("msgs");
|
|
2269
|
-
const itemEl = (item) => {
|
|
2270
|
-
const box = el2("div", { class: `item msg${mine(item) && !item.session ? " mine" : ""}`, "data-id": item.id, ...agentOf(item) ? { "data-agent": agentOf(item) } : {} });
|
|
2271
|
-
box.append(nameLine(item.name, false), ...readable(item.text));
|
|
2272
|
-
stamped(box, stampOf(item, c, item === c && !c.resolved ? `#${numberOf(c)} \xB7 ` : ""));
|
|
2273
|
-
return box;
|
|
2274
|
-
};
|
|
2275
|
-
const shown2 = /* @__PURE__ */ new Set();
|
|
2276
|
-
const all = [c, ...repliesOf(c.id)];
|
|
2277
|
-
const firstNew = all.find((x) => fresh.has(x.id));
|
|
2278
|
-
for (const item of all) {
|
|
2279
|
-
if (item === firstNew && item !== c) body.append(el2("div", { class: "newline" }, "new"));
|
|
2280
|
-
body.append(itemEl(item));
|
|
2281
|
-
shown2.add(item.id);
|
|
2282
|
-
}
|
|
2283
|
-
card.sync = () => {
|
|
2284
|
-
for (const r of repliesOf(c.id)) {
|
|
2285
|
-
if (shown2.has(r.id)) continue;
|
|
2286
|
-
const items = card.querySelectorAll(".item");
|
|
2287
|
-
const added = itemEl(r);
|
|
2288
|
-
added.classList.add("fresh");
|
|
2289
|
-
items[items.length - 1].after(added);
|
|
2290
|
-
shown2.add(r.id);
|
|
2291
|
-
markSeen([r]);
|
|
2292
|
-
}
|
|
2293
|
-
};
|
|
2294
|
-
const ownKey = store2.get(`lab-edit:${c.id}`);
|
|
2295
|
-
let actions = null;
|
|
2296
|
-
if (isAdmin || ownKey) {
|
|
2297
|
-
actions = el2("div", { class: "row acts" });
|
|
2298
|
-
const resolve = el2("button", { class: "btn", type: "button" }, c.resolved ? "reopen" : "resolve");
|
|
2299
|
-
const failed = (btn) => btn.textContent = "failed, try again";
|
|
2300
|
-
resolve.addEventListener("click", async () => {
|
|
2301
|
-
try {
|
|
2302
|
-
const closing = !c.resolved;
|
|
2303
|
-
const { comment } = await send({ action: c.resolved ? "reopen" : "resolve", id: c.id, ...ownKey ? { edit: ownKey } : {} });
|
|
2304
|
-
Object.assign(c, comment);
|
|
2305
|
-
if (closing && openId === c.id) return closeFast = true, openId = null, render();
|
|
2306
|
-
render();
|
|
2307
|
-
} catch {
|
|
2308
|
-
failed(resolve);
|
|
2309
|
-
}
|
|
2310
|
-
});
|
|
2311
|
-
const del = el2("button", { class: "btn", type: "button" }, "delete");
|
|
2312
|
-
const yes = el2("button", { class: "btn danger", type: "button" }, "delete");
|
|
2313
|
-
const no = el2("button", { class: "btn", type: "button" }, "cancel");
|
|
2314
|
-
const back = () => {
|
|
2315
|
-
actions.replaceChildren(resolve, del);
|
|
2316
|
-
del.focus();
|
|
2317
|
-
};
|
|
2318
|
-
del.addEventListener("click", () => {
|
|
2319
|
-
actions.replaceChildren(el2("span", { class: "ask" }, repliesOf(c.id).length ? "delete thread?" : "delete comment?"), yes, no);
|
|
2320
|
-
no.focus();
|
|
2321
|
-
});
|
|
2322
|
-
no.addEventListener("click", back);
|
|
2323
|
-
actions.addEventListener("keydown", (e) => {
|
|
2324
|
-
if (e.key === "Escape" && yes.isConnected) {
|
|
2325
|
-
e.stopPropagation();
|
|
2326
|
-
back();
|
|
2327
|
-
}
|
|
2328
|
-
});
|
|
2329
|
-
yes.addEventListener("click", async () => {
|
|
2330
|
-
try {
|
|
2331
|
-
await send({ action: "delete", id: c.id });
|
|
2332
|
-
} catch {
|
|
2333
|
-
return failed(yes);
|
|
2334
|
-
}
|
|
2335
|
-
comments = comments.filter((x) => x.id !== c.id && x.parent !== c.id);
|
|
2336
|
-
openId = null;
|
|
2337
|
-
render();
|
|
2338
|
-
});
|
|
2339
|
-
actions.append(...isAdmin ? [resolve, del] : [resolve]);
|
|
2340
|
-
body.append(actions);
|
|
2341
|
-
}
|
|
2342
|
-
if (coarse) {
|
|
2343
|
-
const topOf = (x) => position(x.anchor || {}).top;
|
|
2344
|
-
const here = topOf(c);
|
|
2345
|
-
const fresh2 = threads().filter((x) => !isPage(x) && x.id !== c.id && unread(x).length).map((x) => [x, topOf(x)]);
|
|
2346
|
-
fresh2.sort((p, q) => (p[1] > here ? 0 : 1) - (q[1] > here ? 0 : 1) || p[1] - q[1]);
|
|
2347
|
-
const nav = el2("div", { class: "row nav" });
|
|
2348
|
-
if (fresh2.length) {
|
|
2349
|
-
const b = el2("button", { class: "btn", type: "button" }, `new \xB7 ${fresh2.length} \u203A`);
|
|
2350
|
-
b.addEventListener("pointerdown", (e) => e.preventDefault());
|
|
2351
|
-
b.addEventListener("click", () => goTo(fresh2[0][0]));
|
|
2352
|
-
nav.append(b);
|
|
2353
|
-
}
|
|
2354
|
-
if (actions) nav.append(actions);
|
|
2355
|
-
if (nav.firstChild) card.insertBefore(nav, body);
|
|
2356
|
-
}
|
|
2357
|
-
foot.append(
|
|
2358
|
-
composer({
|
|
2359
|
-
placeholder: "reply",
|
|
2360
|
-
autofocus: focus,
|
|
2361
|
-
onSubmit: async (name, text) => {
|
|
2362
|
-
const { comment } = await send({ name, text, parent: c.id });
|
|
2363
|
-
comments.push(comment);
|
|
2364
|
-
markSeen([comment]);
|
|
2365
|
-
if (c.resolved) {
|
|
2366
|
-
c.resolved = false;
|
|
2367
|
-
render();
|
|
2368
|
-
const again = openCard?.querySelector(".body");
|
|
2369
|
-
if (again) again.scrollTop = again.scrollHeight;
|
|
2370
|
-
openCard?.querySelector("textarea")?.focus({ preventScroll: true });
|
|
2371
|
-
return { keep: true };
|
|
2372
|
-
}
|
|
2373
|
-
shown2.add(comment.id);
|
|
2374
|
-
const items = card.querySelectorAll(".item");
|
|
2375
|
-
const added = itemEl(comment);
|
|
2376
|
-
added.classList.add("fresh");
|
|
2377
|
-
items[items.length - 1].after(added);
|
|
2378
|
-
body.scrollTop = body.scrollHeight;
|
|
2379
|
-
return { keep: true };
|
|
2380
|
-
}
|
|
2381
|
-
})
|
|
2382
|
-
);
|
|
2383
|
-
return card;
|
|
2384
|
-
}
|
|
2385
|
-
const showHint = () => {
|
|
2386
|
-
if (store2.get("lab-hint-seen") === "1") return;
|
|
2387
|
-
hint.hidden = false;
|
|
2388
|
-
store2.set("lab-hint-seen", "1");
|
|
2389
|
-
setTimeout(() => hint.hidden = true, 5e3);
|
|
2390
|
-
};
|
|
2391
|
-
const setOn = (value) => {
|
|
2392
|
-
on = value;
|
|
2393
|
-
if (!on) ptr.classList.remove("show");
|
|
2394
|
-
else recheck();
|
|
2395
|
-
store2.set("lab-on", on ? "1" : "0");
|
|
2396
|
-
if (on) showHint();
|
|
2397
|
-
draft = null;
|
|
2398
|
-
openId = null;
|
|
2399
|
-
render();
|
|
2400
|
-
};
|
|
2401
|
-
toggleBtn.addEventListener("click", () => setOn(!on));
|
|
2402
|
-
function setMenu(open, refocus = false) {
|
|
2403
|
-
moreMenu.hidden = !open;
|
|
2404
|
-
moreBtn.setAttribute("aria-expanded", String(open));
|
|
2405
|
-
if (open) [...moreMenu.querySelectorAll("button")].find((b) => !b.hidden && !b.disabled)?.focus({ preventScroll: true });
|
|
2406
|
-
else if (refocus) moreBtn.focus({ preventScroll: true });
|
|
2407
|
-
}
|
|
2408
|
-
moreBtn.addEventListener("click", (e) => {
|
|
2409
|
-
e.stopPropagation();
|
|
2410
|
-
setMenu(moreMenu.hidden);
|
|
2411
|
-
});
|
|
2412
|
-
moreMenu.addEventListener("click", () => setTimeout(() => setMenu(false, true), 0));
|
|
2413
|
-
addEventListener("pointerdown", (e) => {
|
|
2414
|
-
if (!moreMenu.hidden && !e.composedPath().some((n) => n === moreMenu || n === moreBtn)) setMenu(false);
|
|
2415
|
-
}, true);
|
|
2416
|
-
addEventListener("keydown", (e) => {
|
|
2417
|
-
if (e.key === "Escape" && !moreMenu.hidden) {
|
|
2418
|
-
setMenu(false, true);
|
|
2419
|
-
e.stopPropagation();
|
|
2420
|
-
}
|
|
2421
|
-
}, true);
|
|
2422
|
-
goBtn.addEventListener("click", () => setGo(!goMode));
|
|
2423
|
-
const stepNew = (dir) => {
|
|
2424
|
-
const fresh = threads().filter((c) => !isPage(c) && unread(c).length);
|
|
2425
|
-
if (!fresh.length) return;
|
|
2426
|
-
const top = (c) => position(c.anchor || {}).top;
|
|
2427
|
-
fresh.sort((a, b) => top(a) - top(b));
|
|
2428
|
-
const open = openId && threads().find((c) => c.id === openId);
|
|
2429
|
-
const here = open ? top(open) : null;
|
|
2430
|
-
const after = here == null ? -1 : fresh.findIndex((c) => top(c) > here);
|
|
2431
|
-
const at = fresh.findIndex((c) => c.id === openId);
|
|
2432
|
-
const next = at >= 0 ? (at + dir + fresh.length) % fresh.length : here == null ? dir > 0 ? 0 : fresh.length - 1 : dir > 0 ? after < 0 ? 0 : after : ((after < 0 ? fresh.length : after) - 1 + fresh.length) % fresh.length;
|
|
2433
|
-
chatOpen = false;
|
|
2434
|
-
goTo(fresh[next], !coarse);
|
|
2435
|
-
};
|
|
2436
|
-
newPrev.addEventListener("click", () => stepNew(-1));
|
|
2437
|
-
doneBtn.addEventListener("click", () => showDoneBtn.click());
|
|
2438
|
-
showDoneBtn.addEventListener("click", () => {
|
|
2439
|
-
showDone = !showDone;
|
|
2440
|
-
store2.set("lab-show-done", showDone ? "1" : "");
|
|
2441
|
-
render();
|
|
2442
|
-
});
|
|
2443
|
-
newNext.addEventListener("click", () => stepNew(1));
|
|
2444
|
-
const showAgain = () => {
|
|
2445
|
-
if (on) return;
|
|
2446
|
-
on = true;
|
|
2447
|
-
store2.set("lab-on", "1");
|
|
2448
|
-
};
|
|
2449
|
-
copyBtn.addEventListener("click", () => copy(agentLink(), copyBtn));
|
|
2450
|
-
listBtn.addEventListener("click", () => LIST_WINDOW ? (listOpen = !listOpen, listOpen && (filter = "new"), chatOpen = false, hint.hidden = true, render()) : stepNew(1));
|
|
2451
|
-
listEl.querySelector(".x").addEventListener("click", () => slideAway(listEl, () => (listOpen = false, render())));
|
|
2452
|
-
chatBtn.addEventListener("click", () => {
|
|
2453
|
-
chatOpen = !chatOpen;
|
|
2454
|
-
listOpen = false;
|
|
2455
|
-
if (chatOpen && !coarse) {
|
|
2456
|
-
openId = null;
|
|
2457
|
-
if (draft && !/** @type {HTMLTextAreaElement | null} */
|
|
2458
|
-
root.querySelector(".float textarea")?.value.trim()) draft = null;
|
|
2459
|
-
}
|
|
2460
|
-
hint.hidden = true;
|
|
2461
|
-
render();
|
|
2462
|
-
if (chatOpen && !coarse) chatEl.querySelector(".chat textarea")?.focus({ preventScroll: true });
|
|
2463
|
-
});
|
|
2464
|
-
let closingClick = false;
|
|
2465
|
-
document.addEventListener("pointerdown", (e) => {
|
|
2466
|
-
closingClick = false;
|
|
2467
|
-
if (coarse || !chatOpen || e.button !== 0) return;
|
|
2468
|
-
const path = e.composedPath();
|
|
2469
|
-
if (path.includes(chatEl) || path.includes(chatBtn)) return;
|
|
2470
|
-
chatOpen = false;
|
|
2471
|
-
if (path.includes(host2)) return void addEventListener("click", () => render(), { once: true });
|
|
2472
|
-
closingClick = true;
|
|
2473
|
-
render();
|
|
2474
|
-
}, true);
|
|
2475
|
-
addEventListener("click", (e) => {
|
|
2476
|
-
if (!closingClick) return;
|
|
2477
|
-
closingClick = false;
|
|
2478
|
-
e.preventDefault();
|
|
2479
|
-
e.stopImmediatePropagation();
|
|
2480
|
-
}, true);
|
|
2481
|
-
for (
|
|
2482
|
-
const b of
|
|
2483
|
-
/** @type {NodeListOf<HTMLElement>} */
|
|
2484
|
-
listEl.querySelectorAll("[data-f]")
|
|
2485
|
-
) b.addEventListener("click", () => (filter = b.dataset.f, drawList()));
|
|
2486
|
-
holdBtn.addEventListener("click", () => (store2.set("lab-hold", drafting() ? "" : "1"), drawList()));
|
|
2487
|
-
sendBtn.addEventListener("click", async () => {
|
|
2488
|
-
const list = held();
|
|
2489
|
-
for (let i = 0; i < list.length; i++) {
|
|
2490
|
-
try {
|
|
2491
|
-
const { comment, edit } = await send(list[i]);
|
|
2492
|
-
if (edit) store2.set(`lab-edit:${comment.id}`, edit);
|
|
2493
|
-
comments.push(comment);
|
|
2494
|
-
markSeen([comment]);
|
|
2495
|
-
store2.set(heldKey(), JSON.stringify(list.slice(i + 1)));
|
|
2496
|
-
} catch {
|
|
2497
|
-
sendBtn.textContent = "send failed, try again";
|
|
2498
|
-
return;
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
render();
|
|
2502
|
-
});
|
|
2503
|
-
const typing = (e) => e.composedPath().some((n) => n instanceof HTMLElement && (n.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(n.tagName)));
|
|
2504
|
-
document.addEventListener("keydown", (e) => {
|
|
2505
|
-
if (gone) return;
|
|
2506
|
-
const inOtherWidget = document.activeElement?.localName.includes("-") && document.activeElement !== host2;
|
|
2507
|
-
if ((e.key === "m" || e.key === "M" || e.code === "KeyM") && !e.metaKey && !e.ctrlKey && !e.altKey && !e.repeat && !typing(e) && !inOtherWidget) {
|
|
2508
|
-
e.preventDefault();
|
|
2509
|
-
setOn(!on);
|
|
2510
|
-
return;
|
|
2511
|
-
}
|
|
2512
|
-
if (on && (e.metaKey || e.ctrlKey) && !e.shiftKey && !e.altKey && (/^z$/i.test(e.key || "") || !/^[a-z]$/i.test(e.key || "") && e.code === "KeyZ") && !typing(e) && !inOtherWidget && placed.length) {
|
|
2513
|
-
e.preventDefault();
|
|
2514
|
-
return void undoLast();
|
|
2515
|
-
}
|
|
2516
|
-
if (on && e.ctrlKey && !e.metaKey && !e.altKey && e.code === "KeyD" && !(typing(e) && !e.composedPath().includes(host2))) {
|
|
2517
|
-
e.preventDefault();
|
|
2518
|
-
const typed2 = (
|
|
2519
|
-
/** @type {HTMLTextAreaElement | null} */
|
|
2520
|
-
root.querySelector(".card textarea, .float textarea")
|
|
2521
|
-
);
|
|
2522
|
-
if (typed2?.value.trim()) return typed2.closest(".card, .float")?.animate([{ transform: "none" }, { transform: "translateX(-6px)" }, { transform: "translateX(6px)" }, { transform: "none" }], { duration: 260 });
|
|
2523
|
-
return stepNew(e.shiftKey ? -1 : 1);
|
|
2524
|
-
}
|
|
2525
|
-
if (on && /^(Digit|Numpad)[123]$/.test(e.code || "") && !e.metaKey && !e.ctrlKey && !e.altKey && !e.repeat && !typing(e) && !inOtherWidget) {
|
|
2526
|
-
e.preventDefault();
|
|
2527
|
-
if (e.code.endsWith("3")) setCursor(true);
|
|
2528
|
-
else setGo(e.code.endsWith("2"));
|
|
2529
|
-
return;
|
|
2530
|
-
}
|
|
2531
|
-
const letter = /^[a-z]$/i.test(e.key || "") ? e.key.toLowerCase() : /^Key[A-Z]$/.test(e.code || "") ? e.code.slice(3).toLowerCase() : "";
|
|
2532
|
-
if (on && !typing(e) && !inOtherWidget && !e.metaKey && !e.ctrlKey && !e.altKey && !e.repeat && /^[cwred]$/.test(letter)) {
|
|
2533
|
-
const k = letter;
|
|
2534
|
-
e.preventDefault();
|
|
2535
|
-
if (k === "c") return chatBtn.click();
|
|
2536
|
-
if (k === "w") return stepNew(e.shiftKey ? -1 : 1);
|
|
2537
|
-
if (k === "d") return showDoneBtn.click();
|
|
2538
|
-
if (k === "r" && openId) root.querySelector(".card textarea")?.focus({ preventScroll: true });
|
|
2539
|
-
else if (k === "e" && openId && isAdmin) [.../** @type {NodeListOf<HTMLElement>} */
|
|
2540
|
-
root.querySelectorAll(".card .btn")].find((b) => /^(resolve|reopen)$/.test(b.textContent))?.click();
|
|
2541
|
-
return;
|
|
2542
|
-
}
|
|
2543
|
-
if (e.key === "Escape" && (draft || openId)) {
|
|
2544
|
-
draft = null;
|
|
2545
|
-
openId = null;
|
|
2546
|
-
render();
|
|
2547
|
-
} else if (e.key === "Escape" && (chatOpen || listOpen)) {
|
|
2548
|
-
if (chatOpen) chatOpen = false;
|
|
2549
|
-
else listOpen = false;
|
|
2550
|
-
render();
|
|
2551
|
-
}
|
|
2552
|
-
});
|
|
2553
|
-
const INTERACTIVE = 'a, button, input, textarea, select, label, summary, video[controls], audio, iframe, [contenteditable], [role="button"], [role="link"], [role="tab"], [role="menuitem"], [role="option"], [role="checkbox"], [role="switch"], [tabindex]:not([tabindex="-1"]), [onclick]';
|
|
2554
|
-
const OFF = "[data-uncommentable]";
|
|
2555
|
-
let drag = null;
|
|
2556
|
-
let afterDrag = false;
|
|
2557
|
-
let liveZone = null;
|
|
2558
|
-
let zoneFrame = 0;
|
|
2559
|
-
const paintZone = () => {
|
|
2560
|
-
zoneFrame = 0;
|
|
2561
|
-
if (!drag?.active || !liveZone) return;
|
|
2562
|
-
const x = Math.min(drag.x0, drag.x1) + scrollX;
|
|
2563
|
-
const y = Math.min(drag.y0, drag.y1) + scrollY;
|
|
2564
|
-
liveZone.style.transform = `translate3d(${x}px, ${y}px, 0)`;
|
|
2565
|
-
liveZone.style.width = `${Math.abs(drag.x1 - drag.x0)}px`;
|
|
2566
|
-
liveZone.style.height = `${Math.abs(drag.y1 - drag.y0)}px`;
|
|
2567
|
-
};
|
|
2568
|
-
const draftHasText = () => Boolean(draft) && [.../** @type {NodeListOf<HTMLTextAreaElement>} */
|
|
2569
|
-
root.querySelectorAll(".float textarea")].some((t) => t.value.trim());
|
|
2570
|
-
function startDrag(e) {
|
|
2571
|
-
if (!on && !e.altKey || cursorMode && !e.altKey || draftHasText() || e.button !== 0 || e.pointerType === "touch" || e.metaKey || e.ctrlKey || e.shiftKey) return;
|
|
2572
|
-
if (e.composedPath().includes(host2)) return;
|
|
2573
|
-
if (!e.altKey && e.target instanceof Element && e.target.closest(INTERACTIVE)) return;
|
|
2574
|
-
if (e.target instanceof Element && e.target.closest(OFF)) return;
|
|
2575
|
-
drag = { x0: e.clientX, y0: e.clientY, x1: e.clientX, y1: e.clientY, active: false };
|
|
2576
|
-
}
|
|
2577
|
-
document.addEventListener(
|
|
2578
|
-
"pointerdown",
|
|
2579
|
-
(e) => {
|
|
2580
|
-
if (e.altKey) return;
|
|
2581
|
-
if (!on && !e.altKey || cursorMode && !e.altKey || draftHasText() || e.button !== 0 || e.pointerType === "touch" || e.metaKey || e.ctrlKey || e.shiftKey) return;
|
|
2582
|
-
if (e.composedPath().includes(host2)) return;
|
|
2583
|
-
if (!e.altKey && e.target instanceof Element && e.target.closest(INTERACTIVE)) return;
|
|
2584
|
-
if (e.target instanceof Element && e.target.closest(OFF)) return;
|
|
2585
|
-
drag = { x0: e.clientX, y0: e.clientY, x1: e.clientX, y1: e.clientY, active: false };
|
|
2586
|
-
},
|
|
2587
|
-
true
|
|
2588
|
-
);
|
|
2589
|
-
document.addEventListener(
|
|
2590
|
-
"pointermove",
|
|
2591
|
-
(e) => {
|
|
2592
|
-
if (!drag) return;
|
|
2593
|
-
drag.x1 = e.clientX;
|
|
2594
|
-
drag.y1 = e.clientY;
|
|
2595
|
-
if (!drag.active && Math.hypot(drag.x1 - drag.x0, drag.y1 - drag.y0) > 8) {
|
|
2596
|
-
drag.active = true;
|
|
2597
|
-
getSelection?.()?.removeAllRanges();
|
|
2598
|
-
document.documentElement.classList.add("lab-dragging");
|
|
2599
|
-
liveZone = zoneEl("draft live");
|
|
2600
|
-
layer2.append(liveZone);
|
|
2601
|
-
}
|
|
2602
|
-
if (!drag.active) return;
|
|
2603
|
-
e.preventDefault();
|
|
2604
|
-
zoneFrame ||= requestAnimationFrame(paintZone);
|
|
2605
|
-
},
|
|
2606
|
-
true
|
|
2607
|
-
);
|
|
2608
|
-
const endDrag = (e) => {
|
|
2609
|
-
if (!drag) return;
|
|
2610
|
-
const d = drag;
|
|
2611
|
-
drag = null;
|
|
2612
|
-
document.documentElement.classList.remove("lab-dragging");
|
|
2613
|
-
cancelAnimationFrame(zoneFrame);
|
|
2614
|
-
zoneFrame = 0;
|
|
2615
|
-
liveZone?.remove();
|
|
2616
|
-
liveZone = null;
|
|
2617
|
-
if (!d.active || e.type === "pointercancel") return;
|
|
2618
|
-
afterDrag = true;
|
|
2619
|
-
setTimeout(() => afterDrag = false, 0);
|
|
2620
|
-
getSelection?.()?.removeAllRanges();
|
|
2621
|
-
for (const [a, b] of [["x0", "x1"], ["y0", "y1"]]) {
|
|
2622
|
-
if (Math.abs(d[b] - d[a]) >= 12) continue;
|
|
2623
|
-
const mid = (d[a] + d[b]) / 2;
|
|
2624
|
-
d[a] = mid - 6;
|
|
2625
|
-
d[b] = mid + 6;
|
|
2626
|
-
}
|
|
2627
|
-
showAgain();
|
|
2628
|
-
openId = null;
|
|
2629
|
-
begin(zoneAnchor(d));
|
|
2630
|
-
};
|
|
2631
|
-
document.addEventListener("pointerup", endDrag, true);
|
|
2632
|
-
document.addEventListener("pointercancel", endDrag, true);
|
|
2633
|
-
document.addEventListener(
|
|
2634
|
-
"dragstart",
|
|
2635
|
-
(e) => {
|
|
2636
|
-
const media = on && e.target instanceof Element && e.target.closest("img, video") && !e.composedPath().includes(host2);
|
|
2637
|
-
if (drag || media) e.preventDefault();
|
|
2638
|
-
},
|
|
2639
|
-
true
|
|
2640
|
-
);
|
|
2641
|
-
document.addEventListener(
|
|
2642
|
-
"click",
|
|
2643
|
-
(e) => {
|
|
2644
|
-
if (!afterDrag) return;
|
|
2645
|
-
e.preventDefault();
|
|
2646
|
-
e.stopPropagation();
|
|
2647
|
-
},
|
|
2648
|
-
true
|
|
2649
|
-
);
|
|
2650
|
-
const optionPress = (e) => e.altKey && !e.metaKey && !e.ctrlKey && e.button === 0 && !e.composedPath().includes(host2) && !(e.target instanceof Element && e.target.closest(OFF));
|
|
2651
|
-
for (const type of ["pointerdown", "mousedown", "pointerup", "mouseup"]) {
|
|
2652
|
-
addEventListener(type, (e) => {
|
|
2653
|
-
if (!optionPress(e)) return;
|
|
2654
|
-
e.preventDefault();
|
|
2655
|
-
e.stopImmediatePropagation();
|
|
2656
|
-
if (type === "pointerdown") startDrag(e);
|
|
2657
|
-
if (type === "pointerup") endDrag(e);
|
|
2658
|
-
}, true);
|
|
2659
|
-
}
|
|
2660
|
-
addEventListener("click", (e) => {
|
|
2661
|
-
if (!optionPress(e)) return;
|
|
2662
|
-
e.preventDefault();
|
|
2663
|
-
e.stopImmediatePropagation();
|
|
2664
|
-
if (!afterDrag) onPageClick(e);
|
|
2665
|
-
}, true);
|
|
2666
|
-
document.addEventListener("click", (e) => onPageClick(e));
|
|
2667
|
-
let lastTouch = 0;
|
|
2668
|
-
let pinnedByHold = false;
|
|
2669
|
-
const selChip = (
|
|
2670
|
-
/** @type {HTMLElement} */
|
|
2671
|
-
root.querySelector(".sel-chip")
|
|
2672
|
-
);
|
|
2673
|
-
const scrim = (
|
|
2674
|
-
/** @type {HTMLElement} */
|
|
2675
|
-
root.querySelector(".scrim")
|
|
2676
|
-
);
|
|
2677
|
-
const openSheet = () => root.querySelector(".card:not(.out), .float:not(.out)") || (listOpen ? listEl : chatOpen ? chatEl : null);
|
|
2678
|
-
const closeAll = () => {
|
|
2679
|
-
draft = null;
|
|
2680
|
-
openId = null;
|
|
2681
|
-
listOpen = false;
|
|
2682
|
-
chatOpen = false;
|
|
2683
|
-
render();
|
|
2684
|
-
};
|
|
2685
|
-
const closeOrNudge = () => {
|
|
2686
|
-
const node = openSheet();
|
|
2687
|
-
if (![...root.querySelectorAll("textarea")].some((t) => t.value.trim() && !chatEl.contains(t))) return slideAway(node, closeAll);
|
|
2688
|
-
node?.animate?.([{ transform: "none" }, { transform: "translateY(12px)" }, { transform: "none" }], { duration: 260, easing: "ease-out" });
|
|
2689
|
-
};
|
|
2690
|
-
let sheetDraggedAt = -1e9;
|
|
2691
|
-
scrim.addEventListener("click", () => performance.now() - sheetDraggedAt > 300 && closeOrNudge());
|
|
2692
|
-
scrim.addEventListener("touchmove", (e) => e.preventDefault(), { passive: false });
|
|
2693
|
-
function slideAway(node, close, ms = 0) {
|
|
2694
|
-
if (!coarse || !node || still.matches) return close();
|
|
2695
|
-
if (!host2.hasAttribute("data-kb")) root.activeElement?.blur();
|
|
2696
|
-
node.style.pointerEvents = "none";
|
|
2697
|
-
node.style.transition = ms ? `transform ${ms}ms cubic-bezier(.2, .6, .4, 1)` : "transform .22s cubic-bezier(.4, 0, 1, 1)";
|
|
2698
|
-
scrim.style.transition = `opacity ${ms || 220}ms`;
|
|
2699
|
-
node.style.transform = "translateY(100%)";
|
|
2700
|
-
scrim.style.opacity = "0";
|
|
2701
|
-
bar.style.transition = `transform ${ms || 220}ms cubic-bezier(.2, .6, .4, 1), opacity ${ms || 220}ms`;
|
|
2702
|
-
host2.style.setProperty("--lab-p", "1");
|
|
2703
|
-
setTimeout(() => {
|
|
2704
|
-
root.activeElement?.blur();
|
|
2705
|
-
close();
|
|
2706
|
-
node.style.pointerEvents = "";
|
|
2707
|
-
node.style.transform = node.style.transition = scrim.style.opacity = scrim.style.transition = bar.style.transition = "";
|
|
2708
|
-
host2.style.removeProperty("--lab-p");
|
|
2709
|
-
}, ms || 220);
|
|
2710
|
-
}
|
|
2711
|
-
const grabArea = (t) => Boolean(t.closest?.(".handle, .tabs"));
|
|
2712
|
-
const scrollerIn = (e, node) => e.composedPath().find((n) => n instanceof HTMLElement && node.contains(n) && (n.localName === "textarea" || /auto|scroll/.test(getComputedStyle(n).overflowY)));
|
|
2713
|
-
const SPRING = "cubic-bezier(.32,.72,0,1)";
|
|
2714
|
-
let backWatcher = null;
|
|
2715
|
-
function backCloses() {
|
|
2716
|
-
const open = matchMedia("(pointer: coarse)").matches && host2.hasAttribute("data-sheet");
|
|
2717
|
-
if (!open && backWatcher) {
|
|
2718
|
-
const w = backWatcher;
|
|
2719
|
-
backWatcher = null;
|
|
2720
|
-
w.destroy();
|
|
2721
|
-
}
|
|
2722
|
-
if (open && !backWatcher && "CloseWatcher" in window) {
|
|
2723
|
-
try {
|
|
2724
|
-
const w = new /** @type {any} */
|
|
2725
|
-
window.CloseWatcher();
|
|
2726
|
-
w.onclose = () => {
|
|
2727
|
-
if (backWatcher === w) backWatcher = null;
|
|
2728
|
-
closeOrNudge();
|
|
2729
|
-
backCloses();
|
|
2730
|
-
};
|
|
2731
|
-
backWatcher = w;
|
|
2732
|
-
} catch {
|
|
2733
|
-
}
|
|
2734
|
-
}
|
|
2735
|
-
}
|
|
2736
|
-
let dbg = null;
|
|
2737
|
-
function swipeDown(node, close, grows = false) {
|
|
2738
|
-
if (!coarse) return;
|
|
2739
|
-
let raw = 0;
|
|
2740
|
-
let scrolledAt = -1e9;
|
|
2741
|
-
let releasedAt = -1e9;
|
|
2742
|
-
node.addEventListener("scroll", () => scrolledAt = performance.now(), { capture: true, passive: true });
|
|
2743
|
-
node.addEventListener("click", (e) => {
|
|
2744
|
-
if (performance.now() - releasedAt < 200) {
|
|
2745
|
-
e.preventDefault();
|
|
2746
|
-
e.stopPropagation();
|
|
2747
|
-
}
|
|
2748
|
-
}, true);
|
|
2749
|
-
node.addEventListener("focusin", (e) => {
|
|
2750
|
-
if (performance.now() - releasedAt < 200 && e.target.localName === "textarea") e.target.blur();
|
|
2751
|
-
});
|
|
2752
|
-
let x0 = 0;
|
|
2753
|
-
let y0 = 0;
|
|
2754
|
-
let dy = 0;
|
|
2755
|
-
let v = 0;
|
|
2756
|
-
let last = null;
|
|
2757
|
-
let mode = null;
|
|
2758
|
-
let box = null;
|
|
2759
|
-
let fromScrim = false;
|
|
2760
|
-
const onStart = (e) => {
|
|
2761
|
-
fromScrim = e.currentTarget === scrim;
|
|
2762
|
-
if (fromScrim && openSheet() !== node) return void (mode = "off");
|
|
2763
|
-
const t = e.touches[0];
|
|
2764
|
-
x0 = t.clientX;
|
|
2765
|
-
y0 = t.clientY;
|
|
2766
|
-
dy = v = raw = 0;
|
|
2767
|
-
last = { y: y0, at: e.timeStamp };
|
|
2768
|
-
box = fromScrim ? null : scrollerIn(e, node);
|
|
2769
|
-
mode = e.touches.length > 1 || box?.localName === "textarea" ? "off" : null;
|
|
2770
|
-
};
|
|
2771
|
-
node.addEventListener("touchstart", onStart, { passive: true });
|
|
2772
|
-
scrim.addEventListener("touchstart", onStart, { passive: true });
|
|
2773
|
-
const onMove = (e) => {
|
|
2774
|
-
if (fromScrim !== (e.currentTarget === scrim)) return;
|
|
2775
|
-
const t = e.touches[0];
|
|
2776
|
-
if (mode === "off" && box && box.localName !== "textarea" && e.touches.length === 1 && e.cancelable && box.scrollTop <= 0 && t.clientY > last.y + 1) {
|
|
2777
|
-
mode = "drag";
|
|
2778
|
-
y0 = t.clientY;
|
|
2779
|
-
v = 0;
|
|
2780
|
-
last = { y: t.clientY, at: e.timeStamp };
|
|
2781
|
-
}
|
|
2782
|
-
if (mode === "off") return void (last = { y: t.clientY, at: e.timeStamp });
|
|
2783
|
-
if (mode === "hold") return e.preventDefault();
|
|
2784
|
-
if (!mode) {
|
|
2785
|
-
const down = t.clientY - y0;
|
|
2786
|
-
const across = t.clientX - x0;
|
|
2787
|
-
if (!down && !across) return;
|
|
2788
|
-
const sideways = Math.abs(across) > Math.abs(down);
|
|
2789
|
-
const nearTop = !sideways && down > 0 && y0 - node.getBoundingClientRect().top < node.offsetHeight * 0.25;
|
|
2790
|
-
if (fromScrim) mode = sideways ? "hold" : "drag";
|
|
2791
|
-
else if (grabArea(e.target)) mode = sideways && e.target.closest(".tabs") ? "off" : "drag";
|
|
2792
|
-
else if (nearTop && box?.localName !== "textarea") mode = "drag";
|
|
2793
|
-
else if (box) mode = !sideways && down > 0 && box.scrollTop <= 0 && performance.now() - scrolledAt > 100 ? "drag" : "off";
|
|
2794
|
-
else mode = sideways ? "hold" : "drag";
|
|
2795
|
-
dbg?.(`touch ${String(e.target.className || e.target.localName).slice(0, 20)} at ${Math.round(y0 - node.getBoundingClientRect().top)}/${node.offsetHeight} down${Math.round(down)} \u2192 ${mode}${e.cancelable ? "" : " (not cancelable)"}${box ? ` box${Math.round(box.scrollTop)}` : ""}`);
|
|
2796
|
-
if (mode === "off") return;
|
|
2797
|
-
if (mode === "hold") return e.preventDefault();
|
|
2798
|
-
}
|
|
2799
|
-
e.preventDefault();
|
|
2800
|
-
raw = t.clientY - y0;
|
|
2801
|
-
const size = node.offsetHeight || 400;
|
|
2802
|
-
dy = raw >= 0 ? raw : -(1 - 1 / (-raw * 0.55 / size + 1)) * size;
|
|
2803
|
-
if (e.timeStamp > last.at) v = 0.8 * ((t.clientY - last.y) / (e.timeStamp - last.at)) + 0.2 * v;
|
|
2804
|
-
last = { y: t.clientY, at: e.timeStamp };
|
|
2805
|
-
node.style.transition = scrim.style.transition = "none";
|
|
2806
|
-
node.style.transform = `translateY(${dy}px)`;
|
|
2807
|
-
scrim.style.opacity = String(Math.min(1, Math.max(0, 1 - dy / 320)));
|
|
2808
|
-
bar.style.transition = "none";
|
|
2809
|
-
host2.style.setProperty("--lab-p", String(Math.min(1, Math.max(0, dy / (node.offsetHeight || 400)))));
|
|
2810
|
-
};
|
|
2811
|
-
node.addEventListener("touchmove", onMove, { passive: false });
|
|
2812
|
-
scrim.addEventListener("touchmove", onMove, { passive: false });
|
|
2813
|
-
const end = (e) => {
|
|
2814
|
-
if (fromScrim !== (e.currentTarget === scrim)) return;
|
|
2815
|
-
const was = mode;
|
|
2816
|
-
mode = null;
|
|
2817
|
-
if (was === "drag") sheetDraggedAt = performance.now();
|
|
2818
|
-
if (was !== "drag") return;
|
|
2819
|
-
releasedAt = performance.now();
|
|
2820
|
-
if (e.timeStamp - last.at > 80) v = 0;
|
|
2821
|
-
const h = node.offsetHeight || innerHeight;
|
|
2822
|
-
const settle = () => {
|
|
2823
|
-
node.style.transition = `transform 380ms ${SPRING}, height 380ms ${SPRING}`;
|
|
2824
|
-
scrim.style.transition = "opacity 300ms";
|
|
2825
|
-
node.style.transform = scrim.style.opacity = "";
|
|
2826
|
-
bar.style.transition = "";
|
|
2827
|
-
host2.style.removeProperty("--lab-p");
|
|
2828
|
-
setTimeout(() => node.style.transition = scrim.style.transition = "", 400);
|
|
2829
|
-
};
|
|
2830
|
-
if (grows && !node.classList.contains("full") && (raw < -40 || v < -0.4)) return node.classList.add("full"), node.classList.contains("card") && (cardFull = true), settle();
|
|
2831
|
-
if (grows && node.classList.contains("full") && v < 1.2 && (raw > 60 || v > 0.4)) return node.classList.remove("full"), node.classList.contains("card") && (cardFull = false), settle();
|
|
2832
|
-
const rest = dy + Math.max(0, v) * 499;
|
|
2833
|
-
dbg?.(`let go: moved ${Math.round(dy)} speed ${v.toFixed(2)} rest ${Math.round(rest)} of half ${Math.round(h / 2)} \u2192 ${v > -0.1 && rest > h / 2 ? "close" : "stay"}`);
|
|
2834
|
-
if (v > -0.1 && rest > h / 2) return slideAway(node, close, Math.min(320, Math.max(140, (h - dy) / Math.max(v, 1.2))));
|
|
2835
|
-
node.style.transition = `transform 380ms ${SPRING}`;
|
|
2836
|
-
scrim.style.transition = "opacity 300ms";
|
|
2837
|
-
node.style.transform = scrim.style.opacity = "";
|
|
2838
|
-
bar.style.transition = "";
|
|
2839
|
-
host2.style.removeProperty("--lab-p");
|
|
2840
|
-
setTimeout(() => node.style.transition = scrim.style.transition = "", 400);
|
|
2841
|
-
};
|
|
2842
|
-
node.addEventListener("touchend", end);
|
|
2843
|
-
scrim.addEventListener("touchend", end);
|
|
2844
|
-
scrim.addEventListener("touchcancel", end);
|
|
2845
|
-
node.addEventListener("touchcancel", end);
|
|
2846
|
-
}
|
|
2847
|
-
const vv = window.visualViewport;
|
|
2848
|
-
if (coarse && vv) {
|
|
2849
|
-
const probe = el2("i", { style: "position:fixed;top:0;bottom:0;left:0;width:0;visibility:hidden;pointer-events:none" });
|
|
2850
|
-
const strip = el2("i", { style: "position:absolute;left:0;width:100vw;display:none;background:var(--_bg);z-index:3;pointer-events:none" });
|
|
2851
|
-
root.append(probe, strip);
|
|
2852
|
-
let fitted = "";
|
|
2853
|
-
const fit = () => {
|
|
2854
|
-
const zoomed = Math.abs(vv.scale - 1) > 0.01;
|
|
2855
|
-
const r = probe.getBoundingClientRect();
|
|
2856
|
-
const field = (
|
|
2857
|
-
/** @type {HTMLElement | null} */
|
|
2858
|
-
root.activeElement || document.activeElement
|
|
2859
|
-
);
|
|
2860
|
-
const typing2 = /^(textarea|input|select)$/.test(field?.localName || "") || Boolean(field?.isContentEditable);
|
|
2861
|
-
const top = zoomed || !typing2 ? 0 : vv.offsetTop;
|
|
2862
|
-
const seen2 = top + vv.height;
|
|
2863
|
-
const kb = zoomed ? 0 : Math.max(0, Math.round(r.bottom - seen2));
|
|
2864
|
-
const gap = zoomed ? 0 : Math.max(0, Math.round(seen2 - r.bottom));
|
|
2865
|
-
const vh = zoomed ? 0 : Math.round(vv.height);
|
|
2866
|
-
const sheet = host2.hasAttribute("data-sheet");
|
|
2867
|
-
const key = `${kb} ${vh} ${gap} ${sheet} ${scrollY} ${Math.round(top)}`;
|
|
2868
|
-
if (key === fitted) {
|
|
2869
|
-
const open2 = sheet ? openSheet() : null;
|
|
2870
|
-
if (open2?.offsetHeight && !open2.style.transform) Object.assign(fit, { sheet: open2, top: open2.getBoundingClientRect().top });
|
|
2871
|
-
return;
|
|
2872
|
-
}
|
|
2873
|
-
fitted = key;
|
|
2874
|
-
host2.style.setProperty("--lab-kb", `${kb}px`);
|
|
2875
|
-
host2.style.setProperty("--lab-top", `${Math.round(top)}px`);
|
|
2876
|
-
if (vh) host2.style.setProperty("--lab-vh", `${vh}px`);
|
|
2877
|
-
else host2.style.removeProperty("--lab-vh");
|
|
2878
|
-
host2.toggleAttribute("data-kb", kb > 60);
|
|
2879
|
-
strip.style.display = sheet && gap ? "block" : "none";
|
|
2880
|
-
strip.style.top = `${Math.round(scrollY + r.bottom)}px`;
|
|
2881
|
-
strip.style.height = `${gap}px`;
|
|
2882
|
-
const open = sheet ? openSheet() : null;
|
|
2883
|
-
const slid = (n) => {
|
|
2884
|
-
try {
|
|
2885
|
-
return new DOMMatrixReadOnly(getComputedStyle(n).transform).m42 || 0;
|
|
2886
|
-
} catch {
|
|
2887
|
-
return 0;
|
|
2888
|
-
}
|
|
2889
|
-
};
|
|
2890
|
-
const keyboardMoved = Math.abs((fit.vh || vh) - vh) > 60 || fit.kbUp !== kb > 60;
|
|
2891
|
-
const sliding = open && open === fit.sheet && keyboardMoved && !open.style.transform && !still.matches;
|
|
2892
|
-
if (sliding) {
|
|
2893
|
-
open.style.transition = "none";
|
|
2894
|
-
void open.offsetHeight;
|
|
2895
|
-
}
|
|
2896
|
-
const at = open ? open.getBoundingClientRect().top - slid(open) : null;
|
|
2897
|
-
if (sliding && Math.abs(fit.top - at) <= 8) open.style.transition = "";
|
|
2898
|
-
if (sliding && Math.abs(fit.top - at) > 8) {
|
|
2899
|
-
open.style.transform = `translateY(${fit.top - at}px)`;
|
|
2900
|
-
void open.offsetHeight;
|
|
2901
|
-
open.style.transition = `transform 340ms ${SPRING}`;
|
|
2902
|
-
open.style.transform = "";
|
|
2903
|
-
clearTimeout(fit.done);
|
|
2904
|
-
fit.done = setTimeout(() => !open.style.transform && (open.style.transition = ""), 360);
|
|
2905
|
-
}
|
|
2906
|
-
Object.assign(fit, { vh, kbUp: kb > 60 }, open?.offsetHeight ? { sheet: open, top: at } : { sheet: null });
|
|
2907
|
-
};
|
|
2908
|
-
refit = fit;
|
|
2909
|
-
root.addEventListener("focusin", () => setTimeout(fit, 50));
|
|
2910
|
-
root.addEventListener("focusout", () => setTimeout(fit, 50));
|
|
2911
|
-
vv.addEventListener("resize", fit);
|
|
2912
|
-
vv.addEventListener("scroll", fit);
|
|
2913
|
-
fit();
|
|
2914
|
-
if (globalThis.__LAB_DEBUG__ !== false && /[?&]kbdebug\b/.test(location.search)) {
|
|
2915
|
-
let lines = [];
|
|
2916
|
-
let t0 = performance.now();
|
|
2917
|
-
let sendTimer = 0;
|
|
2918
|
-
const row = (what) => {
|
|
2919
|
-
const open = openSheet();
|
|
2920
|
-
const r = open?.getBoundingClientRect();
|
|
2921
|
-
lines.push(`${Math.round(performance.now() - t0)} ${what} h${Math.round(vv.height)} top${Math.round(vv.offsetTop)} in${innerHeight} kb${host2.hasAttribute("data-kb") ? 1 : 0}` + (r ? ` sheet${Math.round(r.top)}/${Math.round(r.height)}${open.getAnimations().length ? " anim" : ""}` : "") + // What is moving anywhere (the page, the pins, the dimming): for a flicker that isn't the keyboard.
|
|
2922
|
-
` [${[...document.getAnimations(), ...root.getAnimations()].map((a) => (
|
|
2923
|
-
/** @type {any} */
|
|
2924
|
-
a.animationName || /** @type {any} */
|
|
2925
|
-
a.transitionProperty || "js"
|
|
2926
|
-
)).slice(0, 6).join(",")}] scrim${getComputedStyle(scrim).opacity.slice(0, 4)} scroll${Math.round(scrollY)}`);
|
|
2927
|
-
};
|
|
2928
|
-
const watch = (what) => {
|
|
2929
|
-
row(what);
|
|
2930
|
-
const end = performance.now() + 1500;
|
|
2931
|
-
let prev = "";
|
|
2932
|
-
const f = () => {
|
|
2933
|
-
const before = lines.length;
|
|
2934
|
-
row("f");
|
|
2935
|
-
const last = lines[lines.length - 1].replace(/^\d+ f /, "");
|
|
2936
|
-
if (last === prev) lines.length = before;
|
|
2937
|
-
prev = last;
|
|
2938
|
-
if (performance.now() < end) requestAnimationFrame(f);
|
|
2939
|
-
};
|
|
2940
|
-
requestAnimationFrame(f);
|
|
2941
|
-
};
|
|
2942
|
-
root.addEventListener("focusin", () => (t0 = performance.now(), watch("focus")));
|
|
2943
|
-
const sendSoon = () => {
|
|
2944
|
-
clearTimeout(sendTimer);
|
|
2945
|
-
sendTimer = setTimeout(async () => {
|
|
2946
|
-
const text = lines.join("\n");
|
|
2947
|
-
lines = [];
|
|
2948
|
-
for (let i = 0; i < text.length; i += 1900) {
|
|
2949
|
-
await send({ name: "kb-log", text: text.slice(i, i + 1900), anchor: { kind: "page", selector: "body", x: 0, y: 0, docX: 0, docY: 0, width: innerWidth } }).catch(() => {
|
|
2950
|
-
});
|
|
2951
|
-
}
|
|
2952
|
-
}, 2e3);
|
|
2953
|
-
};
|
|
2954
|
-
root.addEventListener("focusout", () => {
|
|
2955
|
-
lines.push("--- let go");
|
|
2956
|
-
t0 = performance.now();
|
|
2957
|
-
watch("blur");
|
|
2958
|
-
sendSoon();
|
|
2959
|
-
});
|
|
2960
|
-
dbg = (line) => {
|
|
2961
|
-
lines.push(`${Math.round(performance.now() - t0)} ${line}`);
|
|
2962
|
-
sendSoon();
|
|
2963
|
-
};
|
|
2964
|
-
vv.addEventListener("resize", () => {
|
|
2965
|
-
watch("resize");
|
|
2966
|
-
if (lines.length > 1) sendSoon();
|
|
2967
|
-
});
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
|
-
const msgsEl = $(".msgs", chatEl);
|
|
2971
|
-
let stick = true;
|
|
2972
|
-
msgsEl.addEventListener("scroll", () => stick = msgsEl.scrollHeight - msgsEl.scrollTop - msgsEl.clientHeight < 48, { passive: true });
|
|
2973
|
-
if ("ResizeObserver" in window) new ResizeObserver(() => stick && (msgsEl.scrollTop = msgsEl.scrollHeight)).observe(msgsEl);
|
|
2974
|
-
swipeDown(listEl, () => (listOpen = false, render()));
|
|
2975
|
-
swipeDown(chatEl, () => (chatOpen = false, render()), true);
|
|
2976
|
-
let press = null;
|
|
2977
|
-
const stopPress = () => press && (clearTimeout(press.timer), press = null);
|
|
2978
|
-
document.addEventListener(
|
|
2979
|
-
"pointerdown",
|
|
2980
|
-
(e) => {
|
|
2981
|
-
stopPress();
|
|
2982
|
-
pinnedByHold = false;
|
|
2983
|
-
if (e.pointerType === "touch") lastTouch = Date.now();
|
|
2984
|
-
if (e.pointerType !== "touch" || draft || !(e.target instanceof Element) || e.composedPath().includes(host2) || e.target.closest(OFF)) return;
|
|
2985
|
-
const { clientX: x, clientY: y } = e;
|
|
2986
|
-
press = {
|
|
2987
|
-
x,
|
|
2988
|
-
y,
|
|
2989
|
-
timer: setTimeout(() => {
|
|
2990
|
-
press = null;
|
|
2991
|
-
pinnedByHold = true;
|
|
2992
|
-
navigator.vibrate?.(8);
|
|
2993
|
-
getSelection?.()?.removeAllRanges();
|
|
2994
|
-
afterDrag = true;
|
|
2995
|
-
setTimeout(() => afterDrag = false, 800);
|
|
2996
|
-
showAgain();
|
|
2997
|
-
openId = null;
|
|
2998
|
-
begin(anchorAt(x, y));
|
|
2999
|
-
}, 500)
|
|
3000
|
-
};
|
|
3001
|
-
},
|
|
3002
|
-
true
|
|
3003
|
-
);
|
|
3004
|
-
document.addEventListener("pointermove", (e) => press && Math.hypot(e.clientX - press.x, e.clientY - press.y) > 10 && stopPress(), true);
|
|
3005
|
-
document.addEventListener("pointerup", (e) => {
|
|
3006
|
-
if (e.pointerType === "touch") lastTouch = Date.now();
|
|
3007
|
-
stopPress();
|
|
3008
|
-
if (pinnedByHold) root.querySelector(".float textarea")?.focus({ preventScroll: true });
|
|
3009
|
-
}, true);
|
|
3010
|
-
document.addEventListener("touchend", (e) => {
|
|
3011
|
-
if (!pinnedByHold) return;
|
|
3012
|
-
pinnedByHold = false;
|
|
3013
|
-
e.preventDefault();
|
|
3014
|
-
root.querySelector(".float textarea")?.focus({ preventScroll: true });
|
|
3015
|
-
}, { capture: true, passive: false });
|
|
3016
|
-
document.addEventListener("pointercancel", stopPress, true);
|
|
3017
|
-
addEventListener("scroll", stopPress, { passive: true, capture: true });
|
|
3018
|
-
document.addEventListener("contextmenu", (e) => (press || afterDrag) && e.preventDefault(), true);
|
|
3019
|
-
let selRect = null;
|
|
3020
|
-
document.addEventListener("selectionchange", () => {
|
|
3021
|
-
const sel = getSelection?.();
|
|
3022
|
-
const range = sel?.rangeCount && sel.getRangeAt(0);
|
|
3023
|
-
const text = String(sel || "").trim();
|
|
3024
|
-
const inside = range && host2.contains(range.commonAncestorContainer);
|
|
3025
|
-
selRect = coarse && on && !draft && text && range && !inside ? range.getClientRects()[0] || range.getBoundingClientRect() : null;
|
|
3026
|
-
selChip.hidden = !selRect;
|
|
3027
|
-
if (!selRect) return;
|
|
3028
|
-
const below = selRect.bottom + 52 < innerHeight;
|
|
3029
|
-
selChip.style.left = `${Math.min(Math.max(selRect.left + selRect.width / 2, 60), innerWidth - 60)}px`;
|
|
3030
|
-
selChip.style.top = `${below ? selRect.bottom + 10 : Math.max(selRect.top - 46, 8)}px`;
|
|
3031
|
-
});
|
|
3032
|
-
const commentOnSelection = () => {
|
|
3033
|
-
const sel = getSelection?.();
|
|
3034
|
-
const range = sel?.rangeCount && sel.getRangeAt(0);
|
|
3035
|
-
const exact = String(sel || "").replace(/\s+/g, " ").trim();
|
|
3036
|
-
if (!range || !exact || host2.contains(range.commonAncestorContainer)) return false;
|
|
3037
|
-
const rects = range.getClientRects();
|
|
3038
|
-
const first = rects[0] || range.getBoundingClientRect();
|
|
3039
|
-
const last = rects[rects.length - 1] || first;
|
|
3040
|
-
const startEl = range.startContainer.nodeType === 1 ? range.startContainer : range.startContainer.parentElement;
|
|
3041
|
-
const endEl = range.endContainer.nodeType === 1 ? range.endContainer : range.endContainer.parentElement;
|
|
3042
|
-
const anchor = startEl && (startEl === endEl || startEl.contains(endEl)) ? anchorAt(Math.max(last.left, last.right - 2), last.top + last.height / 2) : anchorAt(first.left + 2, first.top + first.height / 2);
|
|
3043
|
-
const at = range.commonAncestorContainer;
|
|
3044
|
-
const block = (
|
|
3045
|
-
/** @type {Element | null} */
|
|
3046
|
-
(at.nodeType === 1 ? at : at.parentElement)?.closest("p, li, h1, h2, h3, h4, h5, h6, td, th, figcaption, blockquote, pre, section, article, div") || document.body
|
|
3047
|
-
);
|
|
3048
|
-
const side = (a, b) => {
|
|
3049
|
-
const r = document.createRange();
|
|
3050
|
-
r.setStart(...a);
|
|
3051
|
-
r.setEnd(...b);
|
|
3052
|
-
return String(r).replace(/\s+/g, " ");
|
|
3053
|
-
};
|
|
3054
|
-
anchor.kind = "text";
|
|
3055
|
-
anchor.quote = {
|
|
3056
|
-
exact: short(exact, 300),
|
|
3057
|
-
prefix: side([block, 0], [range.startContainer, range.startOffset]).replace(/^\s+/, "").slice(-40),
|
|
3058
|
-
suffix: side([range.endContainer, range.endOffset], [block, block.childNodes.length]).replace(/\s+$/, "").slice(0, 40)
|
|
3059
|
-
};
|
|
3060
|
-
sel.removeAllRanges();
|
|
3061
|
-
selChip.hidden = true;
|
|
3062
|
-
showAgain();
|
|
3063
|
-
openId = null;
|
|
3064
|
-
begin(anchor);
|
|
3065
|
-
return true;
|
|
3066
|
-
};
|
|
3067
|
-
selChip.addEventListener("click", (e) => {
|
|
3068
|
-
e.stopPropagation();
|
|
3069
|
-
if (selRect) commentOnSelection();
|
|
3070
|
-
});
|
|
3071
|
-
document.addEventListener("mouseup", (e) => {
|
|
3072
|
-
if (on && !cursorMode && !draft && e.shiftKey && e.button === 0 && !e.composedPath().includes(host2)) setTimeout(commentOnSelection, 0);
|
|
3073
|
-
}, true);
|
|
3074
|
-
function onPageClick(e) {
|
|
3075
|
-
if (e.composedPath().includes(host2)) return;
|
|
3076
|
-
if (draft || openId) {
|
|
3077
|
-
if ([...root.querySelectorAll("textarea")].some((t) => t.value.trim())) return;
|
|
3078
|
-
draft = null;
|
|
3079
|
-
openId = null;
|
|
3080
|
-
render();
|
|
3081
|
-
return;
|
|
3082
|
-
}
|
|
3083
|
-
if (!on && !e.altKey || cursorMode && !e.altKey || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey) return;
|
|
3084
|
-
if (lastTouch && Date.now() - lastTouch < 800) return;
|
|
3085
|
-
if (e.altKey) e.preventDefault();
|
|
3086
|
-
else if (e.defaultPrevented || e.target instanceof Element && e.target.closest(INTERACTIVE)) return;
|
|
3087
|
-
if (e.target instanceof Element && e.target.closest(OFF)) return;
|
|
3088
|
-
if (String(getSelection?.() || "").trim()) return;
|
|
3089
|
-
showAgain();
|
|
3090
|
-
begin(anchorAt(e.clientX, e.clientY));
|
|
3091
|
-
}
|
|
3092
|
-
const movePins = () => {
|
|
3093
|
-
const list = threads().filter((c) => c.anchor?.kind !== "page");
|
|
3094
|
-
if (!on || openId || list.length !== pinsById.size) return render();
|
|
3095
|
-
const places = list.map((c) => [pinsById.get(c.id), position(c.anchor || {})]);
|
|
3096
|
-
if (places.some(([pin]) => !pin)) return render();
|
|
3097
|
-
for (const [pin, { left, top, moved }] of places) {
|
|
3098
|
-
pin.style.left = `${left}px`;
|
|
3099
|
-
pin.style.top = `${top}px`;
|
|
3100
|
-
pin.classList.toggle("moved", Boolean(moved));
|
|
3101
|
-
}
|
|
3102
|
-
};
|
|
3103
|
-
let frame = 0;
|
|
3104
|
-
const reflow = () => {
|
|
3105
|
-
cancelAnimationFrame(frame);
|
|
3106
|
-
frame = requestAnimationFrame(() => {
|
|
3107
|
-
if (draft || root.activeElement || grabbing) return;
|
|
3108
|
-
movePins();
|
|
3109
|
-
});
|
|
3110
|
-
};
|
|
3111
|
-
addEventListener("resize", reflow);
|
|
3112
|
-
addEventListener("scroll", (e) => e.target !== document && !host2.contains(
|
|
3113
|
-
/** @type {Node} */
|
|
3114
|
-
e.target
|
|
3115
|
-
) && reflow(), { capture: true, passive: true });
|
|
3116
|
-
const navigated = () => {
|
|
3117
|
-
if (gone) return;
|
|
3118
|
-
if (!host2.isConnected && document.body) document.body.append(host2);
|
|
3119
|
-
if (!fonts.isConnected) document.head.append(fonts);
|
|
3120
|
-
if (!pinCursorStyle.isConnected) document.head.append(pinCursorStyle);
|
|
3121
|
-
if (pageNow() === page) return;
|
|
3122
|
-
page = pageNow();
|
|
3123
|
-
seen = readSeen();
|
|
3124
|
-
syncReads();
|
|
3125
|
-
comments = [];
|
|
3126
|
-
draft = null;
|
|
3127
|
-
openId = null;
|
|
3128
|
-
render();
|
|
3129
|
-
load();
|
|
3130
|
-
};
|
|
3131
|
-
for (const m of ["pushState", "replaceState"]) {
|
|
3132
|
-
const original = history[m];
|
|
3133
|
-
history[m] = function(...args) {
|
|
3134
|
-
const out = original.apply(this, args);
|
|
3135
|
-
queueMicrotask(navigated);
|
|
3136
|
-
return out;
|
|
3137
|
-
};
|
|
3138
|
-
}
|
|
3139
|
-
addEventListener("popstate", navigated);
|
|
3140
|
-
document.addEventListener("astro:after-swap", navigated);
|
|
3141
|
-
document.addEventListener("visibilitychange", () => {
|
|
3142
|
-
if (document.visibilityState === "visible" && !draft && !root.activeElement) load();
|
|
3143
|
-
});
|
|
3144
|
-
if ("ResizeObserver" in window) new ResizeObserver(reflow).observe(document.body);
|
|
3145
|
-
const fonts = document.createElement("style");
|
|
3146
|
-
if (script?.dataset.fontUrl)
|
|
3147
|
-
fonts.textContent = `@font-face{font-family:'lab comments';font-display:swap;src:url('${new URL(script.dataset.fontUrl, script.src || location.href)}') format('woff2');}`;
|
|
3148
|
-
const fontName = script?.dataset.fontUrl ? "lab comments" : script?.dataset.font;
|
|
3149
|
-
if (fontName) host2.style.setProperty("--lab-font", `'${fontName.replace(/'/g, "")}', system-ui, sans-serif`);
|
|
3150
|
-
const pinCursorStyle = document.createElement("style");
|
|
3151
|
-
const ptr = el2("div", { class: "ptr", "aria-hidden": "true" });
|
|
3152
|
-
ptr.append(el2("span", { class: "ini" }, "+"), el2("span", { class: "tick" }, "go"));
|
|
3153
|
-
root.append(ptr);
|
|
3154
|
-
let mouse = null;
|
|
3155
|
-
const place = (x, y, target) => {
|
|
3156
|
-
const show = Boolean(target) && target !== host2 && !host2.contains(target) && getComputedStyle(target).cursor === "none";
|
|
3157
|
-
ptr.classList.toggle("show", show);
|
|
3158
|
-
ptr.classList.toggle("go", goMode);
|
|
3159
|
-
ptr.style.transform = `translate(${x - 1}px, ${y - 27}px)`;
|
|
3160
|
-
};
|
|
3161
|
-
const recheck = () => mouse && requestAnimationFrame(() => mouse && place(mouse.x, mouse.y, document.elementFromPoint(mouse.x, mouse.y)));
|
|
3162
|
-
addEventListener("pointermove", (e) => {
|
|
3163
|
-
if (e.pointerType !== "mouse") return;
|
|
3164
|
-
document.documentElement.classList.add("lab-drawn");
|
|
3165
|
-
mouse = { x: e.clientX, y: e.clientY };
|
|
3166
|
-
const t = e.composedPath()[0];
|
|
3167
|
-
place(e.clientX, e.clientY, t instanceof Element ? t : null);
|
|
3168
|
-
}, { capture: true, passive: true });
|
|
3169
|
-
addEventListener("scroll", recheck, { capture: true, passive: true });
|
|
3170
|
-
addEventListener("keydown", (e) => (e.key === "Shift" || e.key === "Alt") && recheck(), true);
|
|
3171
|
-
addEventListener("keyup", (e) => (e.key === "Shift" || e.key === "Alt") && recheck(), true);
|
|
3172
|
-
document.documentElement.addEventListener("mouseleave", () => (mouse = null, ptr.classList.remove("show")));
|
|
3173
|
-
addEventListener("blur", () => (mouse = null, ptr.classList.remove("show")));
|
|
3174
|
-
let cursorKey = "";
|
|
3175
|
-
function refreshPinCursor() {
|
|
3176
|
-
const ch = (initial(store2.get("lab-name")) || "+").replace(/[<>&'"]/g, "");
|
|
3177
|
-
if (ch === cursorKey) return;
|
|
3178
|
-
cursorKey = ch;
|
|
3179
|
-
ptr.querySelector(".ini").textContent = ch;
|
|
3180
|
-
const plain2 = `:not(${INTERACTIVE}, a *, button *, label *, [role="button"] *, [contenteditable], [contenteditable] *, ${OFF}, ${OFF} *, [data-lab-comments])`;
|
|
3181
|
-
const top = `dialog, dialog *, [popover], [popover] *, :fullscreen, :fullscreen *`;
|
|
3182
|
-
pinCursorStyle.textContent = `@layer lab-pointer { html.lab-pinning:not(.lab-shift) body, html.lab-pinning:not(.lab-shift) body *${plain2} { cursor: crosshair; } html.lab-drawn.lab-pinning:not(.lab-shift):not(.lab-dragging) body, html.lab-drawn.lab-pinning:not(.lab-shift):not(.lab-dragging) body *${plain2}:not(${top}) { cursor: none; } html.lab-pinning body :is([contenteditable], [contenteditable] *) { cursor: text; } html.lab-pinning body :is(${OFF}, ${OFF} *) { cursor: auto; } }html.lab-alt body, html.lab-alt body *:not([data-lab-comments], [data-lab-comments] *, ${OFF}, ${OFF} *) { cursor: crosshair !important; }html.lab-drawn.lab-alt body, html.lab-drawn.lab-alt body *:not([data-lab-comments], [data-lab-comments] *, ${OFF}, ${OFF} *, ${top}) { cursor: none !important; }html.lab-go:not(.lab-drawn) body, html.lab-go:not(.lab-drawn) body * { cursor: copy !important; }`;
|
|
3183
|
-
}
|
|
3184
|
-
fonts.textContent += `@media (pointer: fine) { html.lab-pinning:not(.lab-shift) body > :not([data-lab-comments]), html.lab-pinning:not(.lab-shift) body > :not([data-lab-comments]) :not(input, textarea, select, [contenteditable], [contenteditable] *) { -webkit-user-select: none; user-select: none; } }`;
|
|
3185
|
-
let shiftOff = 0;
|
|
3186
|
-
const shiftKey = (e) => {
|
|
3187
|
-
clearTimeout(shiftOff);
|
|
3188
|
-
if (e.shiftKey) document.documentElement.classList.add("lab-shift");
|
|
3189
|
-
else shiftOff = setTimeout(() => (document.documentElement.classList.remove("lab-shift"), recheck()), 400);
|
|
3190
|
-
};
|
|
3191
|
-
addEventListener("keydown", shiftKey, true);
|
|
3192
|
-
addEventListener("keyup", shiftKey, true);
|
|
3193
|
-
addEventListener("pointerdown", (e) => {
|
|
3194
|
-
if (e.shiftKey) return shiftKey(e);
|
|
3195
|
-
clearTimeout(shiftOff);
|
|
3196
|
-
document.documentElement.classList.remove("lab-shift");
|
|
3197
|
-
}, true);
|
|
3198
|
-
addEventListener("blur", () => document.documentElement.classList.remove("lab-shift"));
|
|
3199
|
-
fonts.textContent += "html.lab-dragging, html.lab-dragging * { user-select: none !important; -webkit-user-select: none !important; cursor: crosshair !important; }";
|
|
3200
|
-
fonts.textContent += "html.lab-sheet, html.lab-sheet body { overscroll-behavior-y: none; }";
|
|
3201
|
-
fonts.textContent += "html.lab-room body::after { content: ''; display: block; height: var(--lab-room, 0px); }";
|
|
3202
|
-
addEventListener("scroll", () => {
|
|
3203
|
-
const de = document.documentElement;
|
|
3204
|
-
const had = parseFloat(de.style.getPropertyValue("--lab-room")) || 0;
|
|
3205
|
-
if (!had || host2.hasAttribute("data-sheet")) return;
|
|
3206
|
-
const room = Math.max(0, Math.ceil(scrollY + innerHeight - (de.scrollHeight - had)));
|
|
3207
|
-
if (room >= had) return;
|
|
3208
|
-
de.style.setProperty("--lab-room", `${room}px`);
|
|
3209
|
-
if (!room) de.classList.remove("lab-room");
|
|
3210
|
-
}, { passive: true });
|
|
3211
|
-
fonts.textContent += "@media (pointer: coarse) { html.lab-sheet, html.lab-sheet body { overflow: hidden; } }";
|
|
3212
|
-
fonts.textContent += `html.lab-pinning body, html.lab-pinning body * { -webkit-touch-callout: none; }`;
|
|
3213
|
-
fonts.textContent += `@media (pointer: coarse) { html.lab-pinning body > :not([data-lab-comments]) { -webkit-user-select: none; user-select: none; } html.lab-pinning body > :not([data-lab-comments]), html.lab-pinning body > :not([data-lab-comments]) * { -webkit-user-drag: none; } }`;
|
|
3214
|
-
const setAlt = (down) => document.documentElement.classList.toggle("lab-alt", Boolean(down));
|
|
3215
|
-
addEventListener("keydown", (e) => e.key === "Alt" && setAlt(true), true);
|
|
3216
|
-
addEventListener("keyup", (e) => e.key === "Alt" && setAlt(false), true);
|
|
3217
|
-
addEventListener("pointermove", (e) => setAlt(e.altKey), { capture: true, passive: true });
|
|
3218
|
-
addEventListener("blur", () => setAlt(false));
|
|
3219
|
-
const start = () => {
|
|
3220
|
-
document.head.append(fonts, pinCursorStyle);
|
|
3221
|
-
refreshPinCursor();
|
|
3222
|
-
if (on) showHint();
|
|
3223
|
-
document.body.append(host2);
|
|
3224
|
-
const paint = "background-color: rgba(52, 199, 89, .3); color: inherit;";
|
|
3225
|
-
fonts.textContent += `html.lab-pinning ::selection { ${paint} } ::highlight(lab-quote) { ${paint} }`;
|
|
3226
|
-
load();
|
|
3227
|
-
};
|
|
3228
|
-
if (document.body) start();
|
|
3229
|
-
else document.addEventListener("DOMContentLoaded", start);
|
|
3230
|
-
if (script?.dataset.live) {
|
|
3231
|
-
let onState = function(v) {
|
|
3232
|
-
{
|
|
3233
|
-
if (v.widget && script.dataset.widget && v.widget !== script.dataset.widget) return reload();
|
|
3234
|
-
if (v.lab && script.dataset.lab && v.lab !== script.dataset.lab) {
|
|
3235
|
-
script.dataset.lab = v.lab;
|
|
3236
|
-
script.dataset.version = String(v.files);
|
|
3237
|
-
hotAt = v.hot;
|
|
3238
|
-
commentsRev = v.comments;
|
|
3239
|
-
morphPage();
|
|
3240
|
-
load();
|
|
3241
|
-
}
|
|
3242
|
-
if (String(v.files) !== script.dataset.version) return reload();
|
|
3243
|
-
if (hotAt !== null && v.hot !== hotAt) {
|
|
3244
|
-
if (v.hot - hotAt > 1) hotUpdate([{ kind: "html" }, { kind: "css", path: "" }]);
|
|
3245
|
-
else hotUpdate(v.hotFiles || []);
|
|
3246
|
-
}
|
|
3247
|
-
hotAt = v.hot;
|
|
3248
|
-
if (commentsRev !== null && v.comments !== commentsRev) loadChanges(commentsRev);
|
|
3249
|
-
commentsRev = v.comments;
|
|
3250
|
-
if (v.reads !== readsAt) {
|
|
3251
|
-
readsAt = v.reads;
|
|
3252
|
-
syncReads();
|
|
3253
|
-
}
|
|
3254
|
-
const s = v.session;
|
|
3255
|
-
const mode = s ? v.mode || "listening" : "away";
|
|
3256
|
-
const span = (t) => Object.assign(document.createElement("span"), { textContent: t });
|
|
3257
|
-
const agent = s?.agent || "Claude";
|
|
3258
|
-
const tag = s && s.name !== agent ? [span(`(${s.name})`)] : [];
|
|
3259
|
-
if (mode === "listening") who.replaceChildren(span("talking to"), agent, ...tag);
|
|
3260
|
-
else if (mode === "working") who.replaceChildren(agent, span("is working"), ...tag);
|
|
3261
|
-
else who.replaceChildren(span("no agent listening"));
|
|
3262
|
-
who.classList.toggle("idle", mode === "away");
|
|
3263
|
-
who.classList.toggle("working", mode === "working");
|
|
3264
|
-
listBtn.dataset.agent = mode;
|
|
3265
|
-
chatBtn.dataset.agent = mode;
|
|
3266
|
-
if (coarse) chatBtn.title = who.textContent;
|
|
3267
|
-
who.setAttribute("aria-label", who.textContent);
|
|
3268
|
-
if (s?.url && mode !== "away") Object.assign(who, { href: s.url, target: "_blank" });
|
|
3269
|
-
else who.removeAttribute("href");
|
|
3270
|
-
who.dataset.copy = !s?.url && s?.resume && mode !== "away" ? s.resume : "";
|
|
3271
|
-
who.title = mode === "away" ? "Ask your agent to run: npx @leonidstern/labit wait" : s?.resume ? `${s.resume}${who.dataset.copy ? " (tap to copy)" : ""}` : "";
|
|
3272
|
-
who.hidden = false;
|
|
3273
|
-
}
|
|
3274
|
-
};
|
|
3275
|
-
const key = "lab-scroll:" + location.pathname;
|
|
3276
|
-
try {
|
|
3277
|
-
const kept = JSON.parse(sessionStorage.getItem(key) || "null");
|
|
3278
|
-
if (kept !== null) {
|
|
3279
|
-
sessionStorage.removeItem(key);
|
|
3280
|
-
if (kept.open) openId = kept.open;
|
|
3281
|
-
if (kept.list) {
|
|
3282
|
-
listOpen = true;
|
|
3283
|
-
filter = ["new", "open", "resolved", "mine"].includes(kept.filter) ? kept.filter : filter;
|
|
3284
|
-
}
|
|
3285
|
-
if (kept.chat) chatOpen = true;
|
|
3286
|
-
addEventListener("load", () => scrollTo(0, +(kept.y ?? kept)));
|
|
3287
|
-
}
|
|
3288
|
-
} catch {
|
|
3289
|
-
}
|
|
3290
|
-
let touchedAt = 0;
|
|
3291
|
-
for (const t of ["pointerdown", "keydown", "wheel", "touchstart"]) addEventListener(t, () => touchedAt = performance.now(), { capture: true, passive: true });
|
|
3292
|
-
const busy = () => draft || grabbing || openId || chatOpen || listOpen || coarse && /^(textarea|input)$/.test(root.activeElement?.localName || "") || [...root.querySelectorAll("textarea")].some((t) => t.value.trim()) || performance.now() - touchedAt < 1500;
|
|
3293
|
-
let reloadWhenShown = false;
|
|
3294
|
-
let reloadTimer = 0;
|
|
3295
|
-
const reload = () => {
|
|
3296
|
-
if (document.hidden) return void (reloadWhenShown = true);
|
|
3297
|
-
if (busy()) {
|
|
3298
|
-
if (!reloadTimer) reloadTimer = setTimeout(() => (reloadTimer = 0, reload()), 500);
|
|
3299
|
-
return;
|
|
3300
|
-
}
|
|
3301
|
-
try {
|
|
3302
|
-
sessionStorage.setItem(key, JSON.stringify({ y: scrollY, open: openId, list: listOpen, filter, chat: chatOpen }));
|
|
3303
|
-
} catch {
|
|
3304
|
-
}
|
|
3305
|
-
location.reload();
|
|
3306
|
-
};
|
|
3307
|
-
const who = document.createElement("a");
|
|
3308
|
-
who.className = "listener";
|
|
3309
|
-
who.addEventListener("click", async () => {
|
|
3310
|
-
const text = who.dataset.copy;
|
|
3311
|
-
if (!text) return;
|
|
3312
|
-
try {
|
|
3313
|
-
await navigator.clipboard.writeText(text);
|
|
3314
|
-
const was = [...who.childNodes];
|
|
3315
|
-
who.replaceChildren("copied");
|
|
3316
|
-
setTimeout(() => who.textContent === "copied" && who.replaceChildren(...was), 1200);
|
|
3317
|
-
} catch {
|
|
3318
|
-
}
|
|
3319
|
-
});
|
|
3320
|
-
who.hidden = true;
|
|
3321
|
-
root.querySelector(".left").prepend(who);
|
|
3322
|
-
let stream = null;
|
|
3323
|
-
let beat = 0;
|
|
3324
|
-
const showAway = (word) => {
|
|
3325
|
-
who.replaceChildren(Object.assign(document.createElement("span"), { textContent: word }));
|
|
3326
|
-
who.setAttribute("aria-label", word);
|
|
3327
|
-
who.classList.add("idle");
|
|
3328
|
-
who.classList.remove("working");
|
|
3329
|
-
who.hidden = false;
|
|
3330
|
-
};
|
|
3331
|
-
let commentsRev = null;
|
|
3332
|
-
let readsAt = null;
|
|
3333
|
-
let hotAt = null;
|
|
3334
|
-
const swapCss = (files) => {
|
|
3335
|
-
const links = [.../** @type {NodeListOf<HTMLLinkElement>} */
|
|
3336
|
-
document.querySelectorAll('link[rel~="stylesheet"][href]:not([data-lab-swap])')].filter((l) => new URL(l.href, location.href).origin === location.origin);
|
|
3337
|
-
const named = links.filter((l) => files.includes(decodeURIComponent(new URL(l.href, location.href).pathname)));
|
|
3338
|
-
for (const link of named.length ? named : links) {
|
|
3339
|
-
const url = new URL(link.href, location.href);
|
|
3340
|
-
url.searchParams.set("lab-v", Date.now().toString(36));
|
|
3341
|
-
const next = (
|
|
3342
|
-
/** @type {HTMLLinkElement} */
|
|
3343
|
-
link.cloneNode()
|
|
3344
|
-
);
|
|
3345
|
-
next.href = url.href;
|
|
3346
|
-
next.dataset.labSwap = "";
|
|
3347
|
-
const path = url.pathname;
|
|
3348
|
-
next.addEventListener("load", () => {
|
|
3349
|
-
for (
|
|
3350
|
-
const l of
|
|
3351
|
-
/** @type {NodeListOf<HTMLLinkElement>} */
|
|
3352
|
-
document.querySelectorAll('link[rel~="stylesheet"][href]')
|
|
3353
|
-
) if (l !== next && new URL(l.href, location.href).pathname === path) l.remove();
|
|
3354
|
-
delete next.dataset.labSwap;
|
|
3355
|
-
}, { once: true });
|
|
3356
|
-
next.addEventListener("error", () => next.remove(), { once: true });
|
|
3357
|
-
link.after(next);
|
|
3358
|
-
}
|
|
3359
|
-
};
|
|
3360
|
-
const fresh = (u) => {
|
|
3361
|
-
const url = new URL(u, location.href);
|
|
3362
|
-
url.searchParams.set("lab-v", Date.now().toString(36));
|
|
3363
|
-
return url.href;
|
|
3364
|
-
};
|
|
3365
|
-
const samePath = (u, paths) => {
|
|
3366
|
-
try {
|
|
3367
|
-
const url = new URL(u, location.href);
|
|
3368
|
-
return url.origin === location.origin && paths.includes(decodeURIComponent(url.pathname));
|
|
3369
|
-
} catch {
|
|
3370
|
-
return false;
|
|
3371
|
-
}
|
|
3372
|
-
};
|
|
3373
|
-
const swapImages = (paths) => {
|
|
3374
|
-
let hit = 0;
|
|
3375
|
-
for (const n of document.querySelectorAll('img, source, video[poster], image, use, link[rel~="icon"]')) {
|
|
3376
|
-
if (host2.contains(n)) continue;
|
|
3377
|
-
for (const attr of ["src", "href", "poster", "xlink:href"]) {
|
|
3378
|
-
const v = n.getAttribute(attr);
|
|
3379
|
-
if (!v || !samePath(v.split("#")[0], paths)) continue;
|
|
3380
|
-
const next = fresh(v.split("#")[0]);
|
|
3381
|
-
const im = new Image();
|
|
3382
|
-
im.src = next;
|
|
3383
|
-
(im.decode ? im.decode() : Promise.resolve()).catch(() => {
|
|
3384
|
-
}).finally(() => n.setAttribute(attr, next + (v.includes("#") ? v.slice(v.indexOf("#")) : "")));
|
|
3385
|
-
hit++;
|
|
3386
|
-
}
|
|
3387
|
-
const set = n.getAttribute("srcset");
|
|
3388
|
-
if (set && set.split(",").some((c) => samePath(c.trim().split(/\s+/)[0], paths))) {
|
|
3389
|
-
n.setAttribute("srcset", set.split(",").map((c) => {
|
|
3390
|
-
const [u, ...rest] = c.trim().split(/\s+/);
|
|
3391
|
-
return [samePath(u, paths) ? fresh(u) : u, ...rest].join(" ");
|
|
3392
|
-
}).join(", "));
|
|
3393
|
-
hit++;
|
|
3394
|
-
}
|
|
3395
|
-
}
|
|
3396
|
-
if (!hit) swapCss([]);
|
|
3397
|
-
};
|
|
3398
|
-
const reloadFonts = (paths) => {
|
|
3399
|
-
for (const sheet of document.styleSheets) {
|
|
3400
|
-
let rules;
|
|
3401
|
-
try {
|
|
3402
|
-
rules = sheet.cssRules;
|
|
3403
|
-
} catch {
|
|
3404
|
-
continue;
|
|
3405
|
-
}
|
|
3406
|
-
for (const r of rules || []) {
|
|
3407
|
-
if (!(r instanceof CSSFontFaceRule)) continue;
|
|
3408
|
-
const src = r.style.getPropertyValue("src");
|
|
3409
|
-
const base = sheet.href || location.href;
|
|
3410
|
-
if (!/url\(/.test(src) || ![...src.matchAll(/url\(["']?([^"')]+)/g)].some((m) => samePath(new URL(m[1], base).href, paths))) continue;
|
|
3411
|
-
const again = src.replace(/url\(["']?([^"')]+)["']?\)/g, (all, u) => samePath(new URL(u, base).href, paths) ? `url("${fresh(new URL(u, base).href)}")` : all);
|
|
3412
|
-
const d = (k) => r.style.getPropertyValue(k) || void 0;
|
|
3413
|
-
try {
|
|
3414
|
-
const face = new FontFace(
|
|
3415
|
-
d("font-family").replace(/^["']|["']$/g, ""),
|
|
3416
|
-
again,
|
|
3417
|
-
/** @type {any} */
|
|
3418
|
-
{ weight: d("font-weight"), style: d("font-style"), stretch: d("font-stretch"), unicodeRange: d("unicode-range"), display: d("font-display") }
|
|
3419
|
-
);
|
|
3420
|
-
face.load().then((f) => document.fonts.add(f)).catch(() => {
|
|
3421
|
-
});
|
|
3422
|
-
} catch {
|
|
3423
|
-
}
|
|
3424
|
-
}
|
|
3425
|
-
}
|
|
3426
|
-
};
|
|
3427
|
-
const ownStyles = () => /* @__PURE__ */ new Set([fonts, pinCursorStyle]);
|
|
3428
|
-
const scriptsOf = (doc) => [...doc.querySelectorAll("script")].filter((x) => !/\/_lab\/comments\.js/.test(x.getAttribute("src") || "")).map((x) => x.getAttribute("src") || x.textContent);
|
|
3429
|
-
const sheetsOf = (doc) => [...doc.querySelectorAll('link[rel~="stylesheet"]')].map((l) => {
|
|
3430
|
-
try {
|
|
3431
|
-
return new URL(l.getAttribute("href"), location.href).pathname;
|
|
3432
|
-
} catch {
|
|
3433
|
-
return "";
|
|
3434
|
-
}
|
|
3435
|
-
});
|
|
3436
|
-
const keepOut = (n) => n === host2 || n.nodeType === 1 && n.localName === "script";
|
|
3437
|
-
const same = (o, n) => o.nodeType === n.nodeType && o.nodeName === n.nodeName && (o.nodeType !== 1 || (o.id || "") === (n.id || ""));
|
|
3438
|
-
const alike = (o, n) => same(o, n) && (o.nodeType === 1 ? Boolean(o.id) || o.getAttribute("class") === n.getAttribute("class") : o.nodeType !== 3 || o.data === n.data);
|
|
3439
|
-
const morphKids = (a, b) => {
|
|
3440
|
-
const olds = [...a.childNodes].filter((n) => !keepOut(n));
|
|
3441
|
-
const news = [...b.childNodes].filter((n) => !(n.nodeType === 1 && n.localName === "script"));
|
|
3442
|
-
let j = 0;
|
|
3443
|
-
let prev = null;
|
|
3444
|
-
const put = (n) => {
|
|
3445
|
-
const c = document.importNode(n, true);
|
|
3446
|
-
a.insertBefore(c, prev ? prev.nextSibling : olds[j] || a.firstChild);
|
|
3447
|
-
return c;
|
|
3448
|
-
};
|
|
3449
|
-
news.forEach((n, i) => {
|
|
3450
|
-
const o = olds[j];
|
|
3451
|
-
if (!o) return void (prev = put(n));
|
|
3452
|
-
if (alike(o, n)) return void (prev = morphNode(o, n), j++);
|
|
3453
|
-
if (news.slice(i + 1, i + 8).some((m) => alike(o, m))) return void (prev = put(n));
|
|
3454
|
-
const k = olds.slice(j + 1, j + 8).findIndex((m) => alike(m, n));
|
|
3455
|
-
if (k >= 0) {
|
|
3456
|
-
for (const gone2 of olds.slice(j, j + 1 + k)) gone2.remove();
|
|
3457
|
-
j += k + 1;
|
|
3458
|
-
return void (prev = morphNode(olds[j], n), j++);
|
|
3459
|
-
}
|
|
3460
|
-
prev = morphNode(o, n);
|
|
3461
|
-
j++;
|
|
3462
|
-
});
|
|
3463
|
-
for (const o of olds.slice(j)) o.remove();
|
|
3464
|
-
};
|
|
3465
|
-
const morphNode = (o, n) => {
|
|
3466
|
-
if (o.nodeType !== n.nodeType || o.nodeName !== n.nodeName || o.nodeType === 1 && (o.id || "") !== (n.id || "")) {
|
|
3467
|
-
const c = document.importNode(n, true);
|
|
3468
|
-
o.replaceWith(c);
|
|
3469
|
-
return c;
|
|
3470
|
-
}
|
|
3471
|
-
if (o.nodeType === 3 || o.nodeType === 8) {
|
|
3472
|
-
if (o.data !== n.data) o.data = n.data;
|
|
3473
|
-
return o;
|
|
3474
|
-
}
|
|
3475
|
-
if (o.nodeType !== 1) return o;
|
|
3476
|
-
for (const { name } of Array.from(o.attributes)) if (!n.hasAttribute(name) && !(name === "open" && /^(details|dialog)$/.test(o.localName))) o.removeAttribute(name);
|
|
3477
|
-
for (const { name, value } of Array.from(n.attributes)) if (o.getAttribute(name) !== value) o.setAttribute(name, value);
|
|
3478
|
-
if (o === document.activeElement || o.shadowRoot || /^(iframe|canvas|video|audio|textarea|select|input)$/.test(o.localName)) return o;
|
|
3479
|
-
morphKids(o, n);
|
|
3480
|
-
return o;
|
|
3481
|
-
};
|
|
3482
|
-
const ownScripts = () => scriptsOf(document).length > 0;
|
|
3483
|
-
let morphRun = 0;
|
|
3484
|
-
const morphPage = async () => {
|
|
3485
|
-
if (ownScripts()) return reload();
|
|
3486
|
-
const run = ++morphRun;
|
|
3487
|
-
try {
|
|
3488
|
-
const res = await fetch(location.href, { cache: "no-store", headers: { accept: "text/html" } });
|
|
3489
|
-
if (!res.ok) return reload();
|
|
3490
|
-
const html = await res.text();
|
|
3491
|
-
if (run !== morphRun) return;
|
|
3492
|
-
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
3493
|
-
if (scriptsOf(doc).join("\n") !== scriptsOf(document).join("\n") || sheetsOf(doc).join("\n") !== sheetsOf(document).join("\n")) return reload();
|
|
3494
|
-
let mark = null;
|
|
3495
|
-
for (const y of [Math.min(innerHeight / 3, 240), innerHeight / 2, 80]) {
|
|
3496
|
-
const e = document.elementFromPoint(innerWidth / 2, y);
|
|
3497
|
-
if (e && e !== document.body && e !== document.documentElement && !host2.contains(e) && e !== host2) {
|
|
3498
|
-
mark = e;
|
|
3499
|
-
break;
|
|
3500
|
-
}
|
|
3501
|
-
}
|
|
3502
|
-
const markTop = mark?.getBoundingClientRect().top;
|
|
3503
|
-
const apply = () => {
|
|
3504
|
-
if (doc.title !== tabTitle.base) {
|
|
3505
|
-
tabTitle.base = doc.title;
|
|
3506
|
-
document.title = doc.title;
|
|
3507
|
-
drawList();
|
|
3508
|
-
}
|
|
3509
|
-
const mine2 = ownStyles();
|
|
3510
|
-
const olds = [...document.head.querySelectorAll("style")].filter((x) => !mine2.has(x));
|
|
3511
|
-
const news = [...doc.head.querySelectorAll("style")];
|
|
3512
|
-
news.forEach((n, i) => olds[i] ? olds[i].textContent !== n.textContent && (olds[i].textContent = n.textContent) : document.head.append(document.importNode(n, true)));
|
|
3513
|
-
for (const o of olds.slice(news.length)) o.remove();
|
|
3514
|
-
morphKids(document.body, doc.body);
|
|
3515
|
-
if (mark?.isConnected) {
|
|
3516
|
-
const moved = mark.getBoundingClientRect().top - markTop;
|
|
3517
|
-
if (Math.abs(moved) > 1) scrollBy(0, moved);
|
|
3518
|
-
}
|
|
3519
|
-
reflow();
|
|
3520
|
-
};
|
|
3521
|
-
const safe = () => {
|
|
3522
|
-
try {
|
|
3523
|
-
apply();
|
|
3524
|
-
} catch {
|
|
3525
|
-
reload();
|
|
3526
|
-
}
|
|
3527
|
-
};
|
|
3528
|
-
if (document.startViewTransition && !still.matches) document.startViewTransition(safe);
|
|
3529
|
-
else safe();
|
|
3530
|
-
} catch {
|
|
3531
|
-
reload();
|
|
3532
|
-
}
|
|
3533
|
-
};
|
|
3534
|
-
const hotUpdate = (files) => {
|
|
3535
|
-
const of = (kind) => files.filter((f) => f.kind === kind).map((f) => f.path);
|
|
3536
|
-
const here = decodeURIComponent(location.pathname).replace(/\/$/, "/index").replace(/\.html?$/i, "");
|
|
3537
|
-
if (of("html").some((p) => !p || p.replace(/\.html?$/i, "") === here)) morphPage();
|
|
3538
|
-
if (of("css").length) swapCss(of("css"));
|
|
3539
|
-
if (of("img").length) swapImages(of("img"));
|
|
3540
|
-
if (of("font").length) reloadFonts(of("font"));
|
|
3541
|
-
};
|
|
3542
|
-
const tab = Math.random().toString(36).slice(2, 12);
|
|
3543
|
-
let pollTimer = 0;
|
|
3544
|
-
let dropTimer = 0;
|
|
3545
|
-
const poll = async () => {
|
|
3546
|
-
try {
|
|
3547
|
-
onState(await (await fetch(`${script.dataset.live.replace(/live$/, "state")}?tab=${tab}`, { cache: "no-store" })).json());
|
|
3548
|
-
} catch {
|
|
3549
|
-
}
|
|
3550
|
-
};
|
|
3551
|
-
const toBackground = () => {
|
|
3552
|
-
clearTimeout(dropTimer);
|
|
3553
|
-
dropTimer = setTimeout(() => {
|
|
3554
|
-
stream?.close();
|
|
3555
|
-
stream = null;
|
|
3556
|
-
clearInterval(pollTimer);
|
|
3557
|
-
pollTimer = setInterval(poll, 2e4);
|
|
3558
|
-
}, 3e4);
|
|
3559
|
-
};
|
|
3560
|
-
const toFront = () => {
|
|
3561
|
-
clearTimeout(dropTimer);
|
|
3562
|
-
clearInterval(pollTimer);
|
|
3563
|
-
pollTimer = 0;
|
|
3564
|
-
connect();
|
|
3565
|
-
};
|
|
3566
|
-
const connect = () => {
|
|
3567
|
-
if (stream) return;
|
|
3568
|
-
stream = new EventSource(`${script.dataset.live}?tab=${tab}`);
|
|
3569
|
-
beat = Date.now();
|
|
3570
|
-
stream.addEventListener("beat", () => beat = Date.now());
|
|
3571
|
-
stream.onerror = () => showAway("reconnecting");
|
|
3572
|
-
stream.onmessage = (e) => {
|
|
3573
|
-
beat = Date.now();
|
|
3574
|
-
onState(JSON.parse(e.data));
|
|
3575
|
-
};
|
|
3576
|
-
};
|
|
3577
|
-
document.addEventListener("visibilitychange", () => {
|
|
3578
|
-
if (document.hidden) return toBackground();
|
|
3579
|
-
if (reloadWhenShown) return reload();
|
|
3580
|
-
toFront();
|
|
3581
|
-
});
|
|
3582
|
-
addEventListener("pagehide", () => {
|
|
3583
|
-
stream?.close();
|
|
3584
|
-
stream = null;
|
|
3585
|
-
fetch(script.dataset.live.replace(/live$/, "bye"), { method: "POST", keepalive: true, headers: { "content-type": "application/json" }, body: JSON.stringify({ tab }) }).catch(() => {
|
|
3586
|
-
});
|
|
3587
|
-
});
|
|
3588
|
-
addEventListener("pageshow", (e) => e.persisted && connect());
|
|
3589
|
-
let tick = Date.now();
|
|
3590
|
-
const freshStream = () => {
|
|
3591
|
-
stream?.close();
|
|
3592
|
-
stream = null;
|
|
3593
|
-
showAway("reconnecting");
|
|
3594
|
-
connect();
|
|
3595
|
-
};
|
|
3596
|
-
setInterval(() => {
|
|
3597
|
-
const now = Date.now();
|
|
3598
|
-
const slept = now - tick > 2e4;
|
|
3599
|
-
tick = now;
|
|
3600
|
-
if (document.hidden) return;
|
|
3601
|
-
if (slept || stream && now - beat > 4e4) freshStream();
|
|
3602
|
-
}, 5e3);
|
|
3603
|
-
addEventListener("online", () => !document.hidden && freshStream());
|
|
3604
|
-
connect();
|
|
3605
|
-
if (document.hidden) toBackground();
|
|
3606
|
-
}
|
|
3607
|
-
})();
|
|
3608
|
-
})();
|
|
46
|
+
<div class="more-menu" id="lab-more" hidden></div>`;let M=(t,d=E)=>d.querySelector(t),z=M(".layer"),O=M(".hint");matchMedia("(pointer: coarse)").matches&&(O.textContent="hold to comment");let P=M(".toggle"),V=E.querySelector(".bar"),X=M(".more"),F=M(".more-menu"),Y=M(".copy-all"),se=M(".list-btn"),ee=M(".go-btn"),I=M(".new-prev"),te=M(".show-done"),le=M(".done-btn"),ne=M(".pause-btn"),be=M(".over-btn"),Be=!1,vt={base:""};e.showDone=o.get("lab-show-done")==="1";let wt=M(".new-next"),Le=M(".send-all"),xe=M(".list"),Je=M(".hold",xe),ye=M(".chatwin"),y=E.querySelector(".chat-btn");e.listOpen=!1,e.filter="open",e.refit=()=>{},e.chatOpen=!1;let _=(t,d={},k)=>{let T=document.createElement(t);for(let[R,U]of Object.entries(d))T.setAttribute(R,U);return k instanceof Node?T.append(k):k!=null&&(T.textContent=k),T};Un({host:$,layer:z,el:_,store:o}),no({el:_,store:o,root:E,refreshPinCursor:()=>en(),syncReads:()=>Zt(),rememberMe:x,whileWriting:()=>_e()}),ro({el:_,mine:t=>Et(t),repliesOf:t=>Vt(t),workState:t=>Re(t)});function B(t,d){let k=new Set(d);for(let R of Array.from(t.childNodes))k.has(R)||R.remove();let T=t.firstChild;for(let R of d)R===T?T=T.nextSibling:t.insertBefore(R,T)}let q=["claude","codex","cursor","gemini","antigravity","copilot","amp","opencode"],H=t=>{if(!t?.session)return"";let d=String(t.session.kind||t.name||"").trim().split(/\W/)[0].toLowerCase();return q.includes(d)?d==="antigravity"?"gemini":d:""},W=()=>({"content-type":"application/json",...m?{"x-lab-admin":m}:{}});e.gone=!1,e.loaded=!1,e.retried=!1;let ce=()=>!!E.activeElement||[...E.querySelectorAll("textarea")].some(t=>t.value.trim());async function D(){try{let t=await fetch(`${a}?page=${encodeURIComponent(e.page)}`,{headers:W(),cache:"no-store"});if(t.status===404&&!e.loaded&&r?.dataset.enable!=="always"){if(!e.retried){e.retried=!0,setTimeout(D,1500);return}e.gone=!0,e.on=!1,document.documentElement.classList.remove("lab-pinning"),$.remove(),pe.remove();return}if(!t.ok)throw new Error(String(t.status));let d=await t.json();if(e.comments=d.comments||[],e.isAdmin=!!d.admin,!e.loaded&&!e.openId){let k=e.comments.find(T=>!T.parent&&o.get(`lab-typing:${e.page}:${T.id}`));k?e.openId=k.id:!e.draft&&o.get(`lab-typing:${e.page}:new`)&&b()&&(e.draft={anchor:b()})}e.loaded=!0}catch{}Z()}async function oe(t){try{let d=new URL("/_lab/api/changes",new URL(a,location.href));d.search=String(new URLSearchParams({page:e.page,since:String(t)}));let k=await fetch(d,{cache:"no-store"}),T=k.ok?await k.json():{full:!0};if(T.full||!e.loaded)return D();let R=new Set(T.del),U=new Map(T.set.map(G=>[G.id,G]));e.comments=e.comments.filter(G=>!R.has(G.id)).map(G=>U.get(G.id)||G);let ue=new Set(e.comments.map(G=>G.id));for(let G of T.set)ue.has(G.id)||e.comments.push(G);e.comments.sort((G,Me)=>G.createdAt.localeCompare(Me.createdAt))}catch{return D()}Z()}function Z(){!ce()&&!e.grabbing?j():(e.openCard?.isConnected&&e.openCard.sync(),e.chatOpen&&Ht(),Fe())}e.goMode=o.get("lab-go")==="1",e.cursorMode=o.get("lab-cursor")==="1",e.overControls=o.get("lab-over")==="1";let Ee=()=>{be.textContent=e.overControls?"controls keep clicks":"pin over controls",be.setAttribute("aria-pressed",String(e.overControls))},ae=t=>{e.overControls=t,o.set("lab-over",t?"1":""),Ee(),e.ctlTarget=null,e.recheckCtl?.(),_e()};Ee();let _e=()=>{let t=e.on&&!e.cursorMode&&!oo();document.documentElement.classList.toggle("lab-pinning",t),document.documentElement.classList.toggle("lab-go",t&&e.goMode&&!e.zoomMode),Ce()},Ft=t=>{t&&e.zoomMode&&$e(""),e.cursorMode=t,o.set("lab-cursor",t?"1":""),ee.classList.toggle("cursor",t),ee.classList.toggle("on",e.goMode&&!t),Kt(),_e()},jt=t=>{e.cursorMode&&Ft(!1),e.zoomMode&&$e(""),e.goMode=t,queueMicrotask(Kt),o.set("lab-go",t?"1":""),ee.classList.toggle("on",t),ee.setAttribute("aria-pressed",String(t&&!e.cursorMode)),document.documentElement.classList.toggle("lab-go",e.on&&t),ke.classList.toggle("go",t),Ce()};function kt(t){let d=o.get("lab-name").trim(),k=e.zoomMode;if(k&&(t={...t,zoom:k}),!e.goMode&&!k||!d)return e.draft={anchor:t,go:e.goMode&&!k},w(t),j();let T=k?yn(k):"go";if(gt())return o.set(St(),JSON.stringify([...tt(),{name:d,text:T,anchor:t}])),j();je({name:d,text:T,anchor:t}).then(({comment:R,edit:U})=>{U&&o.set(`lab-edit:${R.id}`,U),e.comments.push(R),ot([R]),e.posted=R.id,k&&t.block&&hn(t.block,k),j()}).catch(()=>(e.draft={anchor:t},w(t),j()))}async function je(t){let d=null;!t.action&&!t.nonce&&(t={...t,nonce:Math.random().toString(36).slice(2)+Date.now().toString(36)});for(let T=0;!d;T++)try{d=await fetch(a,{method:"POST",headers:W(),body:JSON.stringify({page:e.page,...t})})}catch{if(T>=150)throw new Error("couldn't reach the lab; your text is still here");await new Promise(R=>setTimeout(R,2e3))}let k=await d.json().catch(()=>({}));if(!d.ok)throw new Error(k.error||`could not save (${d.status})`);return k.comment&&!t.parent&&!t.action&&t.anchor?.kind!=="page"&&Ke.push(k.comment.id),k}let Ke=[];async function Eo(){let t=Ke.pop(),d=t&&e.comments.find(T=>T.id===t);if(!d)return;let k=o.get(`lab-edit:${t}`);try{if(e.isAdmin)await je({action:"delete",id:t}),e.comments=e.comments.filter(T=>T.id!==t&&T.parent!==t);else if(k){let{comment:T}=await je({action:"resolve",id:t,edit:k});Object.assign(d,T)}else return void Ke.push(t)}catch{return void Ke.push(t)}e.openId===t&&(e.openId=null),j(),vn(`took back ${d.anchor?.zoom?"a zoom":/^go$/i.test(d.text.trim())?"a go":"a pin"} \xB7 ${Ke.length?"again for the one before":"nothing more to take back"}`)}let Qe={was:void 0,t:void 0};function vn(t){Qe.was??=O.textContent,O.textContent=t,O.hidden=!1,clearTimeout(Qe.t),Qe.t=setTimeout(()=>{O.hidden=!0,O.textContent=Qe.was,Qe.was=void 0},1800)}let $o=()=>new URL("/_lab/agent"+e.page,new URL(a,location.href)).href;async function Lo(t,d){let k=await t;try{await navigator.clipboard.writeText(k)}catch{let R=document.createElement("textarea");R.value=k,R.style.cssText="position:fixed;opacity:0;",document.body.append(R),R.select(),document.execCommand("copy"),R.remove()}if(F.contains(d))return vn("link copied");let T=d.textContent;d.style.width=`${d.getBoundingClientRect().width}px`,d.style.justifyContent="center",d.textContent="copied",setTimeout(()=>{d.textContent=T,d.style.width=d.style.justifyContent=""},1400)}let et=()=>e.comments.filter(t=>!t.parent),St=()=>`lab-held:${e.page}`,tt=()=>{try{return JSON.parse(o.get(St())||"[]")}catch{return[]}},_o=()=>et().filter(t=>t.anchor?.kind!=="page").filter(t=>e.filter==="new"?nt(t).length:e.filter==="open"?!t.resolved:e.filter==="resolved"?t.resolved:Et(t)).sort((t,d)=>t.createdAt.localeCompare(d.createdAt)),wn=t=>t.anchor?.kind==="page";e.stepping=!1,e.keepKeys=!1;let Co=t=>t.resolved||Re(t)[0]==="done",Mo=(t,d,k)=>{let T=_("span",{class:"kw"});return T.append(t,_("span",{class:"mn","aria-hidden":"true"},`(${d})`),k),T};function To(){let t=e.on?[le,ne,be,Y,P]:[];for(let k of t)k.parentNode!==F&&F.append(k);!e.on&&P.parentNode!==V&&V.insertBefore(P,X),e.on||E.querySelector(".left").append(Y),X.hidden=!e.on,!e.on&&!F.hidden&&it(!1);let d=!0;for(let k of V.children)k.classList.toggle("first",d&&!k.hidden),k.hidden||(d=!1)}function Kt(){let t=ee.querySelector(".gp");t&&t.replaceChildren(...e.zoomMode?[yt(e.zoomMode),...matchMedia("(pointer: coarse)").matches?[]:[_("span",{class:"zw"},e.zoomMode)]]:[!e.goMode&&!e.cursorMode?at(o.get("lab-name"))||"+":"go"]),ee.setAttribute("aria-label",`a click places: ${e.zoomMode?`a zoom ${e.zoomMode}`:e.cursorMode?"nothing (pointer)":e.goMode?"go":"a comment"}`),ee.setAttribute("aria-keyshortcuts","1 2 3 4")}let Ao=t=>{let d=Math.max(0,Math.round((Date.now()-new Date(t).getTime())/6e4));return d<1?"just now":d<60?`${d} min`:`${Math.floor(d/60)} h ${d%60} min`};e.replyTo=null,e.newFrom=null;let Yt=t=>e.comments.filter(d=>!d.parent&&!d.resolved).sort((d,k)=>d.createdAt.localeCompare(k.createdAt)).indexOf(t)+1,Ut=()=>`lab-seen:${e.page}`,kn=()=>new Set(o.get(Ut()).split(",").filter(Boolean));e.seen=kn();let Xt=t=>String(t||"").replace(/\s+/g," ").trim().toLowerCase(),Et=t=>Xt(t.name)&&Xt(t.name)===Xt(o.get("lab-name"))||!!o.get(`lab-edit:${t.id}`),Sn=t=>!e.seen.has(t.id)&&!Et(t),nt=t=>[t,...Vt(t.id)].filter(Sn),ot=t=>{let d=t.filter(k=>!e.seen.has(k.id)).map(k=>k.id);for(let k of t)e.seen.add(k.id);o.set(Ut(),[...e.seen].join(",")),d.length&&En(d)},$t=r?.dataset.live?r.dataset.live.replace(/live$/,"api/reads"):"",En=t=>{let d=o.get("lab-name").trim();!$t||!d||!t.length||fetch($t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:d,page:e.page,ids:t})}).catch(()=>{})};async function Zt(){let t=o.get("lab-name").trim();if(!$t||!t)return;let d=e.page;try{let{ids:k}=await(await fetch(`${$t}?name=${encodeURIComponent(t)}&page=${encodeURIComponent(d)}`,{cache:"no-store"})).json();if(d!==e.page)return;let T=new Set(k),R=[...e.seen].filter(ue=>!T.has(ue)),U=k.filter(ue=>!e.seen.has(ue));if(R.length&&En(R),!U.length)return;for(let ue of U)e.seen.add(ue);o.set(Ut(),[...e.seen].join(",")),Z()}catch{}}let Vt=t=>e.comments.filter(d=>d.parent===t),at=t=>[...String(t||"").trim()][0]?.toUpperCase()||"",zo=()=>(ft(0),mt.y);e.shown=null,e.posted=null;let Lt=matchMedia("(prefers-reduced-motion: reduce)"),rt=new Map;e.faces=new Map,e.dropDrag=null;function j(){e.grabbing=!1,e.dropDrag?.();let t=z.querySelector(".card:not(.out), .float:not(.out)"),d=e.stepping&&re&&t?t.offsetHeight:0,k=t?t.querySelector(".body")?.scrollTop??null:null,T=new Map(e.on?et().filter(L=>L.anchor?.kind!=="page").map(L=>[L.id,We(L.anchor||{})]):[]);z.replaceChildren(),rt.clear();let R=e.on?e.draft||e.openId:null,U=R!==e.shown,ue=U?" in":"",G=null,Me=()=>{if(e.closeFast&&!R&&t){e.closeFast=!1,t.inert=!0,z.append(t);let L=()=>t.remove();Lt.matches||!t.animate?L():t.animate([{opacity:1},{opacity:0}],{duration:120,easing:"ease-out",fill:"forwards"}).finished.then(L,L)}else if(re&&!R&&e.shown&&t&&!Lt.matches&&!t.style.transform){t.classList.remove("in"),t.classList.add("out"),t.inert=!0,z.append(t);let L=e.posted&&rt.get(e.posted),J=L?.getBoundingClientRect();L&&(L.style.animationDelay="250ms");let ge=dn(t,0,J&&{x:J.left+J.width/2,y:J.top+J.height/2});setTimeout(()=>(t.remove(),pn(t)),ge)}if(re){let L=E.querySelector(".card:not(.out), .float:not(.out)")||(e.listOpen?xe:e.chatOpen?ye:null),J=L&&(e.draft?"draft":e.openId||(e.listOpen?"list":e.chatOpen?"chat":""));L&&J!==e.sheetKey&&cn(L),e.sheetKey=J,U&&e.draft&&requestAnimationFrame(po)}Rt(G),e.shown=R,e.posted=null},Te=et(),Ue=Te.filter(L=>!L.resolved&&L.anchor?.kind!=="page").length,dt=Te.filter(L=>!L.resolved&&L.anchor?.kind!=="page").reduce((L,J)=>L+nt(J).length,0);if(P.replaceChildren(document.createTextNode((e.on?"hide comments":Ue?`comments \xB7 ${Ue}`:"comments")+(!e.on&&dt?` \xB7 ${dt} new`:"")),_("kbd",{"aria-hidden":"true"},"m")),P.classList.toggle("secondary",e.on),$.toggleAttribute("data-sheet",!!(e.on&&(e.draft||e.openId||e.listOpen||e.chatOpen))),re&&U&&R&&($.setAttribute("data-opening",""),requestAnimationFrame(()=>requestAnimationFrame(()=>$.removeAttribute("data-opening")))),document.documentElement.classList.toggle("lab-sheet",$.hasAttribute("data-sheet")),mn(),e.refit(),_e(),Y.hidden=!e.on||!e.isAdmin||Te.every(L=>L.resolved),Fe(),Ht(),xn(),!e.on)return Me();for(let L of tt()){let{left:J,top:ge}=We(L.anchor),he=_("div",{class:"pin held",title:`${L.name}: ${L.text} \xB7 draft, not sent yet`},at(L.name));he.style.left=`${J}px`,he.style.top=`${ge}px`,z.append(he)}if(Te.forEach(L=>{if(wn(L)||!e.showDone&&e.openId!==L.id&&(L.resolved||Re(L)[0]==="done")&&!nt(L).length)return;let{left:J,top:ge,moved:he,zone:Q}=T.get(L.id)||We(L.anchor||{});e.openId===L.id&&Bt(Q,`saved${ue}`);let ve=nt(L),Ae=!Q&&(e.isAdmin||o.get(`lab-edit:${L.id}`)),[Se]=Re(L),ie=_("button",{class:`pin${/^go$/i.test(L.text.trim())?" go":""}${L.anchor?.zoom?" zoom":""}${L.resolved?" resolved":""}${Se==="done"?" done":""}${Se==="now"?" working":""}${ve.length?" new":""}${he?" moved":""}${e.posted===L.id?" in":""}${Ae?" grab":""}${e.openId===L.id?" open":""}`,type:"button",title:`${L.resolved?"":`${Yt(L)} \xB7 `}${L.name}${he?" \xB7 the spot it was pinned to has changed":""}${Ae?" \xB7 drag to move":""}`,"aria-label":`${/^go$/i.test(L.text.trim())?"go":L.anchor?.zoom?`zoom ${L.anchor.zoom}`:"comment"}${L.resolved?"":` ${Yt(L)}`} by ${L.name}${Se==="now"?", agent working on it":Se==="done"||L.resolved?", done":""}${ve.length?`, ${ve.length} new`:""}${he?", moved":""}`},/^go$/i.test(L.text.trim())?"go":Se==="done"||L.resolved?"\u2713":L.anchor?.zoom?yt(String(L.anchor.zoom).startsWith("in")?"in":"out"):at(L.name)),De=`${Se}${L.resolved?" resolved":""}${ve.length?" new":""}`,Ie=e.faces.get(L.id);e.faces.set(L.id,De);let nn=Ie!==void 0&&Ie!==De&&!Lt.matches;if(nn&&ie.classList.add("swap"),Se==="now"?ie.append(_("i",{class:`ring${nn&&!Ie.startsWith("now")?" come":""}`,"aria-hidden":"true"})):nn&&Ie.startsWith("now")&&ie.append(_("i",{class:"ring gone","aria-hidden":"true"})),re&&ie.append(_("i",{class:"hit","aria-hidden":"true"})),ie.style.left=`${J}px`,ie.style.top=`${ge}px`,Ae&&bo(ie,L),!re&&Q&&e.openId!==L.id){let fe=null;ie.addEventListener("pointerenter",()=>fe=Bt(Q,"saved")),ie.addEventListener("pointerleave",()=>(fe?.remove(),fe=null))}else!re&&L.anchor?.quote&&!Q&&(ie.addEventListener("pointerenter",()=>Rt(L.anchor)),ie.addEventListener("pointerleave",()=>Rt(G)));if(ie.addEventListener("click",fe=>{if(fe.stopPropagation(),!ie.dataset.dragged){if(re&&e.openId!==L.id)return Ve(L);e.openId=e.openId===L.id?null:L.id,e.draft=null,j()}}),z.append(ie),rt.set(L.id,ie),e.openId===L.id){let fe=xo(L,new Set(ve.map(Xe=>Xe.id)),U&&(re?e.keepKeys:!e.stepping||e.keepKeys));if(e.openCard=fe,U&&!e.stepping&&fe.classList.add("in"),d&&(fe.style.minHeight=`min(${d}px, var(--_sheet-max))`),e.stepping=e.keepKeys=!1,gn(fe,Q?J+14:J,Q?Q.top+Q.height:ge),!U&&k!=null)fe.querySelector(".body").scrollTop=k;else if(U){let Xe=fe.querySelector(".body"),In=re?null:Xe.querySelector(".fresh, .newline");Xe.scrollTop=In?In.offsetTop-Xe.offsetTop-8:Xe.scrollHeight}re&&e.cardFull&&fe.classList.add("full"),xt(fe,()=>(e.openId=null,e.cardFull=!1,j()),!0),ot(ve),ve.length&&Fe(),G=Q?null:L.anchor}}),e.draft){let{anchor:L}=e.draft,{left:J,top:ge,zone:he}=We(L);Bt(he,"draft"),G=he?null:L;let Q=L.zoom,ve=_("div",{class:`pin draft${Q?" zoom":""}${ue}`},Q?yt(Q):at(o.get("lab-name")));ve.style.left=`${J}px`,ve.style.top=`${ge}px`,z.append(ve);let Ae=_("div",{class:`float${ue}`});Ae.append(_("div",{class:"handle"}),sn({placeholder:Q==="in"?"zoom in: what to go deeper into (or just send)":Q==="out"?"zoom out: what to see around it (or just send)":e.draft.go?"go":"add a comment",empty:Q?yn(Q):e.draft.go?"go":"",nameFirst:!!(e.draft.go||Q),autofocus:!0,draftKey:`lab-typing:${e.page}:new`,onSubmit:async(Se,ie)=>{if(gt())return o.set(St(),JSON.stringify([...tt(),{name:Se,text:ie,anchor:L}])),e.draft=null,w(null),j();let{comment:De,edit:Ie}=await je({name:Se,text:ie,anchor:L});Ie&&o.set(`lab-edit:${De.id}`,Ie),Q&&L.block&&hn(L.block,Q),e.comments.push(De),ot([De]),e.draft=null,w(null),e.openId=null,e.posted=De.id,co(),j()}})),xt(Ae,()=>(e.draft=null,w(null),j())),he?gn(Ae,J+14,he.top+he.height):ho(Ae,J,ge)}Me()}e.grabbing=!1,e.openCard=null;let re=matchMedia("(pointer: coarse)").matches,$n=()=>{o.get("lab-hint-seen")!=="1"&&(O.hidden=!1,o.set("lab-hint-seen","1"),setTimeout(()=>O.hidden=!0,5e3))},Ln=t=>{e.on=t,e.on?Ce():ke.classList.remove("show"),o.set("lab-on",e.on?"1":"0"),e.on&&$n(),e.draft=null,e.openId=null,j()};P.addEventListener("click",()=>Ln(!e.on));function it(t,d=!1){F.hidden=!t,X.setAttribute("aria-expanded",String(t)),t?[...F.querySelectorAll("button")].find(k=>!k.hidden&&!k.disabled)?.focus({preventScroll:!0}):d&&X.focus({preventScroll:!0})}X.addEventListener("click",t=>{t.stopPropagation(),it(F.hidden)}),F.addEventListener("click",()=>setTimeout(()=>it(!1,!0),0)),addEventListener("pointerdown",t=>{!F.hidden&&!t.composedPath().some(d=>d===F||d===X)&&it(!1)},!0),addEventListener("keydown",t=>{t.key==="Escape"&&!F.hidden&&(it(!1,!0),t.stopPropagation())},!0),ee.addEventListener("click",()=>{if(e.zoomMode==="in")return $e("out");if(e.zoomMode==="out")return $e(""),jt(!1);if(e.goMode&&!e.cursorMode)return $e("in");jt(!0)}),I.addEventListener("click",()=>Ge(-1)),le.addEventListener("click",()=>te.click()),e.paused=null;let Oo=t=>{let d=t.effect?.target;return!!d&&d.getRootNode()!==E},_n=()=>{for(let t of document.getAnimations())!Oo(t)||t.playState!=="running"||(t.pause(),e.paused.anims.add(t));for(let t of document.querySelectorAll("video"))t.paused||(t.pause(),e.paused.videos.add(t))};be.addEventListener("click",()=>ae(!e.overControls)),ne.addEventListener("click",()=>{if(e.paused){clearInterval(e.paused.timer);for(let t of e.paused.anims)t.play();for(let t of e.paused.videos)t.play().catch(()=>{});e.paused=null}else e.paused={anims:new Set,videos:new Set,timer:setInterval(_n,100)},_n();ne.textContent=e.paused?"play motion":"pause motion",ne.setAttribute("aria-pressed",String(!!e.paused))}),te.addEventListener("click",()=>{e.showDone=!e.showDone,o.set("lab-show-done",e.showDone?"1":""),j()}),wt.addEventListener("click",()=>Ge(1));let _t=()=>{e.on||(e.on=!0,o.set("lab-on","1"))};Y.addEventListener("click",()=>Lo($o(),Y)),addEventListener("lab-goto",t=>{let d=document.getElementById(t.detail);d&&(re&&(e.openId=null,e.chatOpen=!1,e.listOpen=!1,j()),setTimeout(()=>bn(d),re?60:0))}),se.addEventListener("click",()=>Be?(e.listOpen=!e.listOpen,e.listOpen&&(e.filter="new"),e.chatOpen=!1,O.hidden=!0,j()):Ge(1)),xe.querySelector(".x").addEventListener("click",()=>qt(xe,()=>(e.listOpen=!1,j()))),y.addEventListener("click",()=>{e.chatOpen=!e.chatOpen,e.listOpen=!1,e.chatOpen&&!re&&(e.openId=null,e.draft&&!E.querySelector(".float textarea")?.value.trim()&&(e.draft=null)),O.hidden=!0,j(),e.chatOpen&&!re&&ye.querySelector(".chat textarea")?.focus({preventScroll:!0})}),e.closingClick=!1,document.addEventListener("pointerdown",t=>{if(e.closingClick=!1,re||!e.chatOpen||t.button!==0)return;let d=t.composedPath();if(!(d.includes(ye)||d.includes(y))){if(e.chatOpen=!1,d.includes($))return void addEventListener("click",()=>j(),{once:!0});e.closingClick=!0,j()}},!0),addEventListener("click",t=>{e.closingClick&&(e.closingClick=!1,t.preventDefault(),t.stopImmediatePropagation())},!0);for(let t of xe.querySelectorAll("[data-f]"))t.addEventListener("click",()=>(e.filter=t.dataset.f,Fe()));Je.addEventListener("click",()=>(o.set("lab-hold",gt()?"":"1"),Fe())),Le.addEventListener("click",async()=>{let t=tt();for(let d=0;d<t.length;d++)try{let{comment:k,edit:T}=await je(t[d]);T&&o.set(`lab-edit:${k.id}`,T),e.comments.push(k),ot([k]),o.set(St(),JSON.stringify(t.slice(d+1)))}catch{Le.textContent="send failed, try again";return}j()});let Ye=t=>t.composedPath().some(d=>d instanceof HTMLElement&&(d.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(d.tagName)));document.addEventListener("keydown",t=>{if(e.gone)return;let d=document.activeElement?.localName.includes("-")&&document.activeElement!==$;if((t.key==="m"||t.key==="M"||t.code==="KeyM")&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.repeat&&!Ye(t)&&!d){t.preventDefault(),Ln(!e.on);return}if(e.on&&(t.metaKey||t.ctrlKey)&&!t.shiftKey&&!t.altKey&&(/^z$/i.test(t.key||"")||!/^[a-z]$/i.test(t.key||"")&&t.code==="KeyZ")&&!Ye(t)&&!d&&Ke.length)return t.preventDefault(),void Eo();if(e.on&&t.ctrlKey&&!t.metaKey&&!t.altKey&&t.code==="KeyD"&&!(Ye(t)&&!t.composedPath().includes($))){t.preventDefault();let T=E.querySelector(".card textarea, .float textarea");return T?.value.trim()?T.closest(".card, .float")?.animate([{transform:"none"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"none"}],{duration:260}):Ge(t.shiftKey?-1:1)}if(e.on&&/^(Digit|Numpad)[1234]$/.test(t.code||"")&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.repeat&&!Ye(t)&&!d){t.preventDefault();let T=t.code.slice(-1);if(T==="3")return $e(e.zoomMode==="in"?"out":"in");e.zoomMode&&$e(""),T==="4"?Ft(!0):jt(T==="2");return}let k=/^[a-z]$/i.test(t.key||"")?t.key.toLowerCase():/^Key[A-Z]$/.test(t.code||"")?t.code.slice(3).toLowerCase():"";if(e.on&&e.zoomMode&&!e.draft&&!e.openId&&!Ye(t)&&!d&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.repeat&&ko(t,k))return t.preventDefault();if(e.on&&!Ye(t)&&!d&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.repeat&&/^[cwredp]$/.test(k)){let T=k;if(t.preventDefault(),T==="p")return ne.click();if(T==="c")return y.click();if(T==="w")return Ge(t.shiftKey?-1:1);if(T==="d")return te.click();T==="r"&&e.openId?E.querySelector(".card textarea")?.focus({preventScroll:!0}):T==="e"&&e.openId&&e.isAdmin&&[...E.querySelectorAll(".card .btn")].find(R=>/^(resolve|reopen)$/.test(R.textContent))?.click();return}t.key==="Escape"&&(e.draft||e.openId)?(e.draft=null,e.openId=null,j()):t.key==="Escape"&&(e.chatOpen||e.listOpen)&&(e.chatOpen?e.chatOpen=!1:e.listOpen=!1,j())});let Cn='a, button, input, textarea, select, label, summary, video[controls], audio, iframe, [contenteditable], [role="button"], [role="link"], [role="tab"], [role="menuitem"], [role="option"], [role="checkbox"], [role="switch"], [tabindex]:not([tabindex="-1"]), [onclick]',Mn=t=>document.documentElement.classList.toggle("lab-ctl",!e.overControls&&!$.contains(t)&&t!==$&&Ct(t));e.recheckCtl=()=>e.mouse&&Mn(document.elementFromPoint(e.mouse.x,e.mouse.y));let Ct=t=>{if(e.overControls)return!1;for(let d=t instanceof Element?t:null;d&&d!==document.body&&d!==document.documentElement;d=d.parentElement)if(d.matches(Cn)||getComputedStyle(d).cursor==="pointer")return!0;return!1},me="[data-uncommentable]";e.drag=null,e.afterDrag=!1,e.liveZone=null,e.zoneFrame=0;let Mt=12,No=()=>{if(e.zoneFrame=0,!e.drag?.active||!e.liveZone)return;let t=(T,R)=>{let U=Math.max(Math.abs(R-T),Mt);return{start:(T+R)/2-U/2,size:U}},d=t(e.drag.x0,e.drag.x1),k=t(e.drag.y0,e.drag.y1);e.liveZone.style.transform=`translate3d(${d.start+scrollX}px, ${k.start+scrollY}px, 0)`,e.liveZone.style.width=`${d.size}px`,e.liveZone.style.height=`${k.size}px`},Tn=()=>!!e.draft&&[...E.querySelectorAll(".float textarea")].some(t=>t.value.trim());function Ro(t){!e.on&&!t.altKey||e.cursorMode&&!t.altKey||Tn()||t.button!==0||t.pointerType==="touch"||t.metaKey||t.ctrlKey||t.shiftKey||t.composedPath().includes($)||!t.altKey&&Ct(t.target)||t.target instanceof Element&&t.target.closest(me)||(e.drag={x0:t.clientX,y0:t.clientY,x1:t.clientX,y1:t.clientY,active:!1})}document.addEventListener("pointerdown",t=>{t.altKey||!e.on&&!t.altKey||e.cursorMode&&!t.altKey||Tn()||t.button!==0||t.pointerType==="touch"||t.metaKey||t.ctrlKey||t.shiftKey||t.composedPath().includes($)||!t.altKey&&Ct(t.target)||t.target instanceof Element&&t.target.closest(me)||(e.drag={x0:t.clientX,y0:t.clientY,x1:t.clientX,y1:t.clientY,active:!1})},!0),document.addEventListener("pointermove",t=>{e.drag&&(e.drag.x1=t.clientX,e.drag.y1=t.clientY,!e.drag.active&&Math.hypot(e.drag.x1-e.drag.x0,e.drag.y1-e.drag.y0)>8&&(e.drag.active=!0,getSelection?.()?.removeAllRanges(),document.documentElement.classList.add("lab-dragging"),e.liveZone=rn("draft live"),z.append(e.liveZone)),e.drag.active&&(t.preventDefault(),e.zoneFrame||=requestAnimationFrame(No)))},!0);let Gt=t=>{if(!e.drag)return;let d=e.drag;if(e.drag=null,document.documentElement.classList.remove("lab-dragging"),cancelAnimationFrame(e.zoneFrame),e.zoneFrame=0,e.liveZone?.remove(),e.liveZone=null,!(!d.active||t.type==="pointercancel")){e.afterDrag=!0,setTimeout(()=>e.afterDrag=!1,0),getSelection?.()?.removeAllRanges();for(let[k,T]of[["x0","x1"],["y0","y1"]]){if(Math.abs(d[T]-d[k])>=Mt)continue;let R=(d[k]+d[T])/2;d[k]=R-Mt/2,d[T]=R+Mt/2}_t(),e.openId=null,kt(to(d))}};document.addEventListener("pointerup",Gt,!0),document.addEventListener("pointercancel",Gt,!0),document.addEventListener("dragstart",t=>{let d=e.on&&t.target instanceof Element&&t.target.closest("img, video")&&!t.composedPath().includes($);(e.drag||d)&&t.preventDefault()},!0),document.addEventListener("click",t=>{e.afterDrag&&(t.preventDefault(),t.stopPropagation())},!0);let An=t=>t.altKey&&!t.metaKey&&!t.ctrlKey&&t.button===0&&!t.composedPath().includes($)&&!(t.target instanceof Element&&t.target.closest(me));for(let t of["pointerdown","mousedown","pointerup","mouseup"])addEventListener(t,d=>{An(d)&&(d.preventDefault(),d.stopImmediatePropagation(),t==="pointerdown"&&Ro(d),t==="pointerup"&&Gt(d))},!0);addEventListener("click",t=>{An(t)&&(t.preventDefault(),t.stopImmediatePropagation(),e.afterDrag||Rn(t))},!0),e.ctlClick=!1,addEventListener("click",t=>e.ctlClick=Ct(t.target),!0),document.addEventListener("click",t=>Rn(t)),e.lastTouch=0,e.pinnedByHold=!1;let st=E.querySelector(".sel-chip"),Jt=E.querySelector(".scrim"),zn=()=>E.querySelector(".card:not(.out), .float:not(.out)")||(e.listOpen?xe:e.chatOpen?ye:null),Bo=()=>{e.draft=null,e.openId=null,e.listOpen=!1,e.chatOpen=!1,j()},On=()=>{let t=zn();if(![...E.querySelectorAll("textarea")].some(d=>d.value.trim()&&!ye.contains(d)))return qt(t,Bo);t?.animate?.([{transform:"none"},{transform:"translateY(12px)"},{transform:"none"}],{duration:260,easing:"ease-out"})};e.sheetDraggedAt=-1e9,Jt.addEventListener("click",()=>performance.now()-e.sheetDraggedAt>300&&On()),Jt.addEventListener("touchmove",t=>t.preventDefault(),{passive:!1}),e.backWatcher=null;let Po=window.visualViewport;uo();let Pe=M(".msgs",ye);e.stick=!0,Pe.addEventListener("scroll",()=>e.stick=Pe.scrollHeight-Pe.scrollTop-Pe.clientHeight<48,{passive:!0}),"ResizeObserver"in window&&new ResizeObserver(()=>e.stick&&(Pe.scrollTop=Pe.scrollHeight)).observe(Pe),xt(xe,()=>(e.listOpen=!1,j())),xt(ye,()=>(e.chatOpen=!1,j()),!0),e.press=null;let lt=()=>e.press&&(clearTimeout(e.press.timer),e.press=null);document.addEventListener("pointerdown",t=>{if(lt(),e.pinnedByHold=!1,t.pointerType==="touch"&&(e.lastTouch=Date.now()),t.pointerType!=="touch"||e.draft||!(t.target instanceof Element)||t.composedPath().includes($)||t.target.closest(me))return;let{clientX:d,clientY:k}=t;e.press={x:d,y:k,timer:setTimeout(()=>{e.press=null,e.pinnedByHold=!0,navigator.vibrate?.(8),getSelection?.()?.removeAllRanges(),e.afterDrag=!0,setTimeout(()=>e.afterDrag=!1,800),_t(),e.openId=null,kt(He(d,k))},400)}},!0),document.addEventListener("pointermove",t=>e.press&&Math.hypot(t.clientX-e.press.x,t.clientY-e.press.y)>10&<(),!0),document.addEventListener("pointerup",t=>{t.pointerType==="touch"&&(e.lastTouch=Date.now()),lt(),e.pinnedByHold&&(E.querySelector(".float [data-first]")||E.querySelector(".float textarea"))?.focus({preventScroll:!0})},!0),document.addEventListener("touchend",t=>{e.pinnedByHold&&(e.pinnedByHold=!1,t.preventDefault(),(E.querySelector(".float [data-first]")||E.querySelector(".float textarea"))?.focus({preventScroll:!0}))},{capture:!0,passive:!1}),document.addEventListener("pointercancel",lt,!0),addEventListener("scroll",lt,{passive:!0,capture:!0}),document.addEventListener("contextmenu",t=>(e.press||e.afterDrag)&&t.preventDefault(),!0),e.selRect=null,document.addEventListener("selectionchange",()=>{let t=getSelection?.(),d=t?.rangeCount&&t.getRangeAt(0),k=String(t||"").trim(),T=d&&$.contains(d.commonAncestorContainer);if(e.selRect=re&&e.on&&!e.draft&&k&&d&&!T?d.getClientRects()[0]||d.getBoundingClientRect():null,st.hidden=!e.selRect,!e.selRect)return;let R=e.selRect.bottom+52<innerHeight;st.style.left=`${Math.min(Math.max(e.selRect.left+e.selRect.width/2,60),innerWidth-60)}px`,st.style.top=`${R?e.selRect.bottom+10:Math.max(e.selRect.top-46,8)}px`});let Nn=()=>{let t=getSelection?.(),d=t?.rangeCount&&t.getRangeAt(0),k=String(t||"").replace(/\s+/g," ").trim();if(!d||!k||$.contains(d.commonAncestorContainer))return!1;let T=d.getClientRects(),R=T[0]||d.getBoundingClientRect(),U=T[T.length-1]||R,ue=d.startContainer.nodeType===1?d.startContainer:d.startContainer.parentElement,G=d.endContainer.nodeType===1?d.endContainer:d.endContainer.parentElement,Me=ue&&(ue===G||ue.contains(G))?He(Math.max(U.left,U.right-2),U.top+U.height/2):He(R.left+2,R.top+R.height/2),Te=d.commonAncestorContainer,Ue=(Te.nodeType===1?Te:Te.parentElement)?.closest("p, li, h1, h2, h3, h4, h5, h6, td, th, figcaption, blockquote, pre, section, article, div")||document.body,dt=(L,J)=>{let ge=document.createRange();return ge.setStart(...L),ge.setEnd(...J),String(ge).replace(/\s+/g," ")};return Me.kind="text",Me.quote={exact:K(k,300),prefix:dt([Ue,0],[d.startContainer,d.startOffset]).replace(/^\s+/,"").slice(-40),suffix:dt([d.endContainer,d.endOffset],[Ue,Ue.childNodes.length]).replace(/\s+$/,"").slice(0,40)},t.removeAllRanges(),st.hidden=!0,_t(),e.openId=null,kt(Me),!0};st.addEventListener("click",t=>{t.stopPropagation(),e.selRect&&Nn()}),document.addEventListener("mouseup",t=>{e.on&&!e.cursorMode&&!e.draft&&t.shiftKey&&t.button===0&&!t.composedPath().includes($)&&setTimeout(Nn,0)},!0);function Rn(t){if(!t.composedPath().includes($)){if(e.draft||e.openId){if([...E.querySelectorAll("textarea")].some(d=>d.value.trim()))return;e.draft=null,e.openId=null,j();return}if(!(!e.on&&!t.altKey||e.cursorMode&&!t.altKey||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey)&&!(e.lastTouch&&Date.now()-e.lastTouch<800)){if(t.altKey)t.preventDefault();else if(t.defaultPrevented||e.ctlClick)return;t.target instanceof Element&&t.target.closest(me)||String(getSelection?.()||"").trim()||(_t(),kt(He(t.clientX,t.clientY)))}}}let Do=()=>{let t=et().filter(k=>k.anchor?.kind!=="page");if(!e.on||e.openId||t.length!==rt.size)return j();let d=t.map(k=>[rt.get(k.id),We(k.anchor||{})]);if(d.some(([k])=>!k))return j();for(let[k,{left:T,top:R,moved:U}]of d)k.style.left=`${T}px`,k.style.top=`${R}px`,k.classList.toggle("moved",!!U)};e.frame=0;let Tt=()=>{cancelAnimationFrame(e.frame),e.frame=requestAnimationFrame(()=>{e.draft||E.activeElement||e.grabbing||Do()})};addEventListener("resize",Tt),addEventListener("scroll",t=>t.target!==document&&!$.contains(t.target)&&Tt(),{capture:!0,passive:!0});let Qt=()=>{e.gone||(!$.isConnected&&document.body&&document.body.append($),pe.isConnected||document.head.append(pe),ct.isConnected||document.head.append(ct),u()!==e.page&&(e.page=u(),e.seen=kn(),Zt(),e.comments=[],e.draft=null,e.openId=null,j(),D()))};for(let t of["pushState","replaceState"]){let d=history[t];history[t]=function(...k){let T=d.apply(this,k);return queueMicrotask(Qt),T}}addEventListener("popstate",Qt),document.addEventListener("astro:after-swap",Qt),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&!e.draft&&!E.activeElement&&D()}),"ResizeObserver"in window&&new ResizeObserver(Tt).observe(document.body);let pe=document.createElement("style");r?.dataset.fontUrl&&(pe.textContent=`@font-face{font-family:'lab comments';font-display:swap;src:url('${new URL(r.dataset.fontUrl,r.src||location.href)}') format('woff2');}`);let Bn=r?.dataset.fontUrl?"lab comments":r?.dataset.font;Bn&&$.style.setProperty("--lab-font",`'${Bn.replace(/'/g,"")}', system-ui, sans-serif`);let ct=document.createElement("style"),ke=_("div",{class:"ptr","aria-hidden":"true"});ke.append(_("span",{class:"ini"},"+"),_("span",{class:"tick"},"go")),E.append(ke),e.mouse=null;let Pn=(t,d,k)=>{let T=!!k&&k!==$&&!$.contains(k)&&getComputedStyle(k).cursor==="none";ke.classList.toggle("show",T),ke.classList.toggle("go",e.goMode&&!e.zoomMode),ke.style.transform=`translate(${t-1}px, ${d-27}px)`},Ce=()=>e.mouse&&requestAnimationFrame(()=>e.mouse&&Pn(e.mouse.x,e.mouse.y,document.elementFromPoint(e.mouse.x,e.mouse.y)));addEventListener("pointermove",t=>{if(t.pointerType!=="mouse")return;document.documentElement.classList.add("lab-drawn"),e.mouse={x:t.clientX,y:t.clientY};let d=t.composedPath()[0];d!==e.ctlTarget&&(e.ctlTarget=d,Mn(d)),Pn(t.clientX,t.clientY,d instanceof Element?d:null)},{capture:!0,passive:!0}),addEventListener("scroll",Ce,{capture:!0,passive:!0}),addEventListener("keydown",t=>(t.key==="Shift"||t.key==="Alt")&&Ce(),!0),addEventListener("keyup",t=>(t.key==="Shift"||t.key==="Alt")&&Ce(),!0),document.documentElement.addEventListener("mouseleave",()=>(e.mouse=null,ke.classList.remove("show"))),addEventListener("blur",()=>(e.mouse=null,ke.classList.remove("show"))),e.cursorKey="";function en(){let t=e.zoomMode?`zoom-${e.zoomMode}`:(at(o.get("lab-name"))||"+").replace(/[<>&'"]/g,"");if(t===e.cursorKey)return;e.cursorKey=t,ke.querySelector(".ini").replaceChildren(e.zoomMode?yt(e.zoomMode):t);let d=`:not(${Cn}, a *, button *, label *, [role="button"] *, [contenteditable], [contenteditable] *, ${me}, ${me} *, [data-lab-comments])`,k="dialog, dialog *, [popover], [popover] *, :fullscreen, :fullscreen *";ct.textContent=`@layer lab-pointer { html.lab-pinning:not(.lab-shift, .lab-ctl) body, html.lab-pinning:not(.lab-shift, .lab-ctl) body *${d} { cursor: crosshair; } html.lab-drawn.lab-pinning:not(.lab-shift, .lab-ctl):not(.lab-dragging) body, html.lab-drawn.lab-pinning:not(.lab-shift, .lab-ctl):not(.lab-dragging) body *${d}:not(${k}) { cursor: none; } html.lab-pinning body :is([contenteditable], [contenteditable] *) { cursor: text; } html.lab-pinning body :is(${me}, ${me} *) { cursor: auto; } }html.lab-alt body, html.lab-alt body *:not([data-lab-comments], [data-lab-comments] *, ${me}, ${me} *) { cursor: crosshair !important; }html.lab-drawn.lab-alt body, html.lab-drawn.lab-alt body *:not([data-lab-comments], [data-lab-comments] *, ${me}, ${me} *, ${k}) { cursor: none !important; }html.lab-go:not(.lab-drawn) body, html.lab-go:not(.lab-drawn) body * { cursor: copy !important; }`}pe.textContent+="@media (pointer: fine) { html.lab-pinning:not(.lab-shift) body > :not([data-lab-comments]), html.lab-pinning:not(.lab-shift) body > :not([data-lab-comments]) :not(input, textarea, select, [contenteditable], [contenteditable] *) { -webkit-user-select: none; user-select: none; } }",e.shiftOff=0;let tn=t=>{clearTimeout(e.shiftOff),t.shiftKey?document.documentElement.classList.add("lab-shift"):e.shiftOff=setTimeout(()=>(document.documentElement.classList.remove("lab-shift"),Ce()),400)};addEventListener("keydown",tn,!0),addEventListener("keyup",tn,!0),addEventListener("pointerdown",t=>{if(t.shiftKey)return tn(t);clearTimeout(e.shiftOff),document.documentElement.classList.remove("lab-shift")},!0),addEventListener("blur",()=>document.documentElement.classList.remove("lab-shift")),pe.textContent+="html.lab-dragging, html.lab-dragging * { user-select: none !important; -webkit-user-select: none !important; cursor: crosshair !important; }",pe.textContent+="html.lab-sheet, html.lab-sheet body { overscroll-behavior-y: none; }",pe.textContent+='@property --lab-arc { syntax: "<percentage>"; inherits: false; initial-value: 66%; }',pe.textContent+="html.lab-room body::after { content: ''; display: block; height: var(--lab-room, 0px); }",addEventListener("scroll",()=>{let t=document.documentElement,d=parseFloat(t.style.getPropertyValue("--lab-room"))||0;if(!d||$.hasAttribute("data-sheet"))return;let k=Math.max(0,Math.ceil(scrollY+innerHeight-(t.scrollHeight-d)));k>=d||(t.style.setProperty("--lab-room",`${k}px`),k||t.classList.remove("lab-room"))},{passive:!0}),pe.textContent+="@media (pointer: coarse) { html.lab-sheet, html.lab-sheet body { overflow: hidden; } }",pe.textContent+="html.lab-pinning body, html.lab-pinning body * { -webkit-touch-callout: none; }",pe.textContent+="@media (pointer: coarse) { html.lab-pinning body > :not([data-lab-comments]) { -webkit-user-select: none; user-select: none; } html.lab-pinning body > :not([data-lab-comments]), html.lab-pinning body > :not([data-lab-comments]) * { -webkit-user-drag: none; } }";let At=t=>document.documentElement.classList.toggle("lab-alt",!!t);addEventListener("keydown",t=>t.key==="Alt"&&At(!0),!0),addEventListener("keyup",t=>t.key==="Alt"&&At(!1),!0),addEventListener("pointermove",t=>At(t.altKey),{capture:!0,passive:!0}),addEventListener("blur",()=>At(!1));let Dn=()=>{document.head.append(pe,ct),en(),e.on&&$n(),document.body.append($);let t="background-color: rgba(52, 199, 89, .3); color: inherit;";pe.textContent+=`html.lab-pinning ::selection { ${t} } ::highlight(lab-quote) { ${t} }`,D()};document.body?Dn():document.addEventListener("DOMContentLoaded",Dn),So(),vo()})();})();
|