@pritzlaff/nano-elements 0.1.0 → 0.2.0

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/index.js CHANGED
@@ -103,28 +103,933 @@ class PlacedElement extends ModelElement {
103
103
  }
104
104
  // packages/elements/src/styles.ts
105
105
  import { css } from "lit";
106
+
107
+ // packages/elements/src/tokens.ts
108
+ import { unsafeCSS } from "lit";
109
+ var NANO_TOKENS = {
110
+ bg: "#0D0F13",
111
+ surface: "#14171D",
112
+ "surface-2": "#212632",
113
+ border: "#2A303C",
114
+ "border-strong": "#3A4150",
115
+ fg: "#E7E9EE",
116
+ "fg-2": "#C9CED6",
117
+ muted: "#A3AAB8",
118
+ "on-accent": "#0D0F13",
119
+ accent: "#6FA8FF",
120
+ "accent-soft": "#1C2A44",
121
+ focus: "#6FA8FF",
122
+ good: "#7EE787",
123
+ "good-bg": "#12301C",
124
+ bad: "#FFB4A8",
125
+ "bad-bg": "#3A1D1D",
126
+ warn: "#F2CC60",
127
+ "warn-bg": "#3A3016",
128
+ font: "Inter, system-ui, sans-serif",
129
+ "font-display": "Inter, system-ui, sans-serif",
130
+ "font-mono": "'JetBrains Mono', ui-monospace, monospace",
131
+ radius: "8px",
132
+ "radius-s": "6px",
133
+ s1: "#7EE787",
134
+ s2: "#F5A524",
135
+ s3: "#4CC2FF",
136
+ s4: "#FF7AB6",
137
+ s5: "#D2A8FF",
138
+ s6: "#FFA657",
139
+ s7: "#79C0FF",
140
+ s8: "#F2CC60"
141
+ };
142
+ var t = (name) => unsafeCSS(`var(--nano-${name}, ${NANO_TOKENS[name]})`);
143
+ var tv = (name) => `var(--nano-${name}, ${NANO_TOKENS[name]})`;
144
+
145
+ // packages/elements/src/styles.ts
106
146
  var base = css`
107
- :host { display: block; font-family: Inter, system-ui, sans-serif; font-size: 13px; color: #E7E9EE }
108
- button { font: inherit; font-size: 12px; color: #E7E9EE; background: transparent; border: 1px solid #3A4150; border-radius: 6px; padding: 5px 10px; cursor: pointer }
109
- button.primary { color: #0D0F13; background: #6FA8FF; border: 0; font-weight: 600 }
110
- button.danger { color: #FFB4A8; border-color: #5A3A3A }
111
- button.dashed { border-style: dashed; border-color: #4A5263; font-weight: 600 }
112
- button[aria-pressed='true'] { background: #212632; border-color: #6FA8FF }
113
- input, select { font: inherit; font-size: 12px; color: #E7E9EE; background: #0D0F13; border: 1px solid #3A4150; border-radius: 5px; padding: 4px 6px }
114
- .muted { color: #A3AAB8 }
115
- .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px }
116
- .problem { color: #FFB4A8; font-size: 12px }
147
+ :host { display: block; font-family: ${t("font")}; font-size: 13px; color: ${t("fg")} }
148
+ :focus-visible { outline: 2px solid ${t("focus")}; outline-offset: 1px }
149
+
150
+ /* buttons */
151
+ button, .btn { font: inherit; font-size: 12px; color: ${t("fg")}; background: transparent; border: 1px solid ${t("border-strong")};
152
+ border-radius: ${t("radius-s")}; padding: 5px 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px }
153
+ button:hover, .btn:hover { background: ${t("surface-2")} }
154
+ button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed }
155
+ button.primary, .btn.primary { color: ${t("on-accent")}; background: ${t("accent")}; border-color: ${t("accent")}; font-weight: 600 }
156
+ button.danger, .btn.danger { color: ${t("bad")}; border-color: ${t("bad")} }
157
+ button.dashed, .btn.dashed { border-style: dashed; font-weight: 600 }
158
+ .btn.small { font-size: 11px; padding: 2px 7px }
159
+ .icon-btn { border: 0; background: transparent; padding: 4px; border-radius: ${t("radius-s")}; color: ${t("muted")} }
160
+ .icon-btn:hover { color: ${t("fg")}; background: ${t("surface-2")} }
161
+ button[aria-pressed='true'], .btn[aria-pressed='true'] { background: ${t("surface-2")}; border-color: ${t("accent")} }
162
+
163
+ /* labels */
164
+ .badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: ${t("surface-2")}; color: ${t("fg-2")} }
165
+ .badge.good { background: ${t("good-bg")}; color: ${t("good")} } .badge.bad { background: ${t("bad-bg")}; color: ${t("bad")} }
166
+ .badge.warn { background: ${t("warn-bg")}; color: ${t("warn")} } .badge.accent { background: ${t("accent-soft")}; color: ${t("accent")} }
167
+ .chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid ${t("border")}; border-radius: ${t("radius-s")}; font-size: 12px }
168
+ .pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: ${t("surface-2")}; font-size: 12px }
169
+ .pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor }
170
+
171
+ /* containers and states */
172
+ .card { background: ${t("surface")}; border: 1px solid ${t("border")}; border-radius: ${t("radius")}; padding: 12px }
173
+ .alert { padding: 8px 12px; border-radius: ${t("radius-s")}; border: 1px solid ${t("border")}; background: ${t("surface-2")} }
174
+ .alert.good { background: ${t("good-bg")}; color: ${t("good")}; border-color: transparent }
175
+ .alert.bad, .problem { color: ${t("bad")} } .alert.bad { background: ${t("bad-bg")}; border-color: transparent }
176
+ .problem { font-size: 12px }
177
+
178
+ /* forms */
179
+ input, select, textarea, .input { font: inherit; font-size: 12px; color: ${t("fg")}; background: ${t("bg")}; border: 1px solid ${t("border-strong")};
180
+ border-radius: ${t("radius-s")}; padding: 4px 6px }
181
+ input[type='range'], input[type='checkbox'] { accent-color: ${t("accent")}; padding: 0 }
182
+ .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: ${t("muted")} }
183
+ /* where the browser allows it, a bare select's open list takes the theme too */
184
+ @supports (appearance: base-select) {
185
+ select, ::picker(select) { appearance: base-select }
186
+ ::picker(select) { background: ${t("surface")}; color: ${t("fg")}; border: 1px solid ${t("border")}; border-radius: ${t("radius-s")};
187
+ padding: 4px; margin-top: 4px; box-shadow: 0 4px 16px color-mix(in srgb, ${t("bg")} 40%, transparent) }
188
+ select::picker-icon { color: ${t("muted")} }
189
+ option { padding: 5px 8px; border-radius: ${t("radius-s")} }
190
+ option:is(:hover, :focus-visible) { background: ${t("surface-2")}; outline: 0 }
191
+ option:checked { font-weight: 600 }
192
+ }
193
+ .meter { height: 6px; border-radius: 3px; background: ${t("surface-2")}; overflow: hidden }
194
+ .meter > span { display: block; height: 100%; background: ${t("accent")} }
195
+
196
+ /* data */
197
+ .table { width: 100%; border-collapse: collapse } .table th, .table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid ${t("border")} }
198
+ .table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: ${t("muted")} }
199
+ .tabs { display: flex; gap: 2px; border-bottom: 1px solid ${t("border")} }
200
+ .tabs > button { border: 0; border-radius: 0; border-bottom: 2px solid transparent; background: none; color: ${t("muted")} }
201
+ .tabs > button:is([aria-selected='true'], [aria-pressed='true']) { color: ${t("fg")}; border-bottom-color: ${t("accent")} }
202
+ .list-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid ${t("border")} }
203
+
204
+ /* type */
205
+ .kicker { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: ${t("muted")} }
206
+ .display-s, .display-m, .display-l { font-family: ${t("font-display")}; font-weight: 600; letter-spacing: -.01em; margin: 0 }
207
+ .display-s { font-size: 18px } .display-m { font-size: 24px } .display-l { font-size: 34px }
208
+ .muted { color: ${t("muted")} }
209
+ .mono { font-family: ${t("font-mono")}; font-size: 11px }
210
+
211
+ /* layout */
117
212
  .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap }
118
213
  .col { display: flex; flex-direction: column; gap: 8px }
119
- .card { background: #14171D; border: 1px solid #2A303C; border-radius: 8px; padding: 10px }
214
+ .grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px }
215
+ `;
216
+ // packages/elements/src/kit.ts
217
+ import { css as css2 } from "lit";
218
+ var shadow = css2`0 8px 24px color-mix(in srgb, black 18%, transparent), 0 1px 3px color-mix(in srgb, black 10%, transparent)`;
219
+ var kit = css2`
220
+ /* people and messages */
221
+ .avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex: none;
222
+ background: ${t("surface-2")}; color: ${t("fg-2")}; font-size: 12px; font-weight: 600 }
223
+ .avatar > img { width: 100%; height: 100%; object-fit: cover }
224
+ .avatar.small { width: 24px; height: 24px; font-size: 10px } .avatar.large { width: 40px; height: 40px; font-size: 14px }
225
+ .avatar-stack { display: inline-flex } .avatar-stack > .avatar { box-shadow: 0 0 0 2px ${t("bg")} } .avatar-stack > .avatar + .avatar { margin-left: -8px }
226
+ .bubble { max-width: 75%; width: fit-content; padding: 8px 12px; border-radius: ${t("radius")}; background: ${t("surface-2")}; color: ${t("fg")}; line-height: 1.45 }
227
+ .bubble.mine { margin-left: auto; background: ${t("accent")}; color: ${t("on-accent")} }
228
+ .kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 4px;
229
+ border: 1px solid ${t("border")}; background: ${t("surface-2")}; color: ${t("muted")}; font: 500 11px ${t("font-mono")} }
230
+ .code { font: 12px/1.55 ${t("font-mono")}; background: ${t("surface-2")}; border: 1px solid ${t("border")}; border-radius: ${t("radius-s")};
231
+ padding: 10px 12px; margin: 0; overflow: auto; white-space: pre; color: ${t("fg")} }
232
+
233
+ /* inputs */
234
+ .input-group { display: flex; align-items: center; border: 1px solid ${t("border-strong")}; border-radius: ${t("radius-s")}; background: ${t("bg")} }
235
+ .input-group:focus-within { outline: 2px solid ${t("focus")}; outline-offset: 1px }
236
+ .input-group > input, .input-group > .input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0 }
237
+ .input-group > .addon { padding: 0 8px; color: ${t("muted")}; font-size: 12px; white-space: nowrap }
238
+ .input-group > button { border: 0; border-radius: 0; align-self: stretch }
239
+ .toggle { border-color: transparent } .toggle:hover { color: ${t("fg")} }
240
+ .toggle[aria-pressed='true'] { background: ${t("surface-2")}; border-color: transparent; color: ${t("fg")} }
241
+ .toggle-group { display: inline-flex; border: 1px solid ${t("border")}; border-radius: ${t("radius-s")}; overflow: hidden }
242
+ .toggle-group > button { border: 0; border-radius: 0 } .toggle-group > button + button { border-left: 1px solid ${t("border")} }
243
+ input[type='checkbox'].switch { appearance: none; width: 32px; height: 18px; border-radius: 999px; border: 0; padding: 0; cursor: pointer;
244
+ background: radial-gradient(circle at 9px 50%, ${t("bg")} 6px, transparent 7px), ${t("border-strong")}; transition: background-position .15s }
245
+ input[type='checkbox'].switch:checked { background: radial-gradient(circle at calc(100% - 9px) 50%, ${t("on-accent")} 6px, transparent 7px), ${t("accent")} }
246
+
247
+ /* overlays: native <dialog> (showModal()) and [popover] surfaces */
248
+ dialog.dialog, dialog.drawer { box-sizing: border-box; color: ${t("fg")}; background: ${t("surface")}; border: 1px solid ${t("border")}; box-shadow: ${shadow}; padding: 20px }
249
+ dialog.dialog { border-radius: ${t("radius")}; width: min(480px, calc(100vw - 32px)) }
250
+ dialog.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(380px, 90vw); border-width: 0 0 0 1px; animation: nano-in-right .2s ease-out }
251
+ dialog.drawer.bottom { margin: auto 0 0; width: 100%; max-width: none; height: auto; max-height: 80dvh; border-width: 1px 0 0;
252
+ border-radius: ${t("radius")} ${t("radius")} 0 0; animation-name: nano-in-up }
253
+ dialog::backdrop { background: color-mix(in srgb, black 50%, transparent) }
254
+ dialog > header { margin-bottom: 12px } dialog > header > h2 { margin: 0 0 4px; font: 600 16px ${t("font-display")} }
255
+ dialog > header > p { margin: 0; color: ${t("muted")} }
256
+ dialog > footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px }
257
+ @keyframes nano-in-right { from { transform: translateX(100%) } }
258
+ @keyframes nano-in-up { from { transform: translateY(100%) } }
259
+ .pop { position: fixed; inset: auto; margin: 0; min-width: 8rem; padding: 4px; color: ${t("fg")}; background: ${t("surface")};
260
+ border: 1px solid ${t("border")}; border-radius: ${t("radius-s")}; box-shadow: ${shadow}; font-family: ${t("font")}; font-size: 13px }
261
+ .menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: ${t("radius-s")};
262
+ background: none; color: inherit; font: inherit; text-align: left; cursor: default; justify-content: flex-start }
263
+ .menu-item:is(:hover, .active) { background: ${t("surface-2")} }
264
+ .menu-item.danger { color: ${t("bad")} } .menu-item[aria-disabled='true'] { opacity: .5 }
265
+ .menu-sep { height: 1px; margin: 4px -4px; background: ${t("border")} }
266
+ .menu-label { padding: 6px 8px 2px; font-size: 11px; font-weight: 600; color: ${t("muted")} }
267
+ .shortcut { margin-left: auto; font-size: 11px; letter-spacing: .08em; color: ${t("muted")} }
268
+
269
+ /* toast */
270
+ .toast { display: flex; gap: 10px; align-items: flex-start; width: min(356px, calc(100vw - 32px)); padding: 12px 14px; color: ${t("fg")};
271
+ background: ${t("surface")}; border: 1px solid ${t("border")}; border-radius: ${t("radius")}; box-shadow: ${shadow}; animation: nano-in-up .2s ease-out }
272
+ .toast > .body { flex: 1 } .toast .title { font-weight: 600 } .toast .desc { color: ${t("muted")}; margin-top: 2px }
273
+ .toast.good { border-left: 3px solid ${t("good")} } .toast.bad { border-left: 3px solid ${t("bad")} } .toast.warn { border-left: 3px solid ${t("warn")} }
120
274
  `;
275
+ // packages/elements/src/kit/select.ts
276
+ import { LitElement as LitElement2, css as css3, html, nothing } from "lit";
277
+
278
+ // packages/elements/src/kit/popup.ts
279
+ function place(pop, anchor, at) {
280
+ try {
281
+ pop.showPopover?.();
282
+ } catch {}
283
+ const r = at ? { left: at.x, top: at.y, bottom: at.y, width: 0 } : anchor.getBoundingClientRect();
284
+ const { offsetWidth: w, offsetHeight: h } = pop;
285
+ pop.style.minWidth = r.width ? `${r.width}px` : "";
286
+ pop.style.left = `${Math.max(4, Math.min(r.left, innerWidth - w - 4))}px`;
287
+ pop.style.top = `${r.bottom + 4 + h > innerHeight && r.top - h - 4 > 0 ? r.top - h - 4 : r.bottom + 4}px`;
288
+ }
289
+ var hide = (pop) => {
290
+ try {
291
+ pop.hidePopover?.();
292
+ } catch {}
293
+ };
294
+
295
+ // packages/elements/src/kit/select.ts
296
+ var labelOf = (i) => i.label ?? i.value;
297
+ var CHECK = html`<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M3 8.5l3 3 7-7" fill="none" stroke="currentColor" stroke-width="2"/></svg>`;
298
+ var ids = 0;
299
+
300
+ class NanoCommand extends LitElement2 {
301
+ static shadowRootOptions = { ...LitElement2.shadowRootOptions, delegatesFocus: true };
302
+ static properties = { items: { attribute: false }, selected: { attribute: false }, placeholder: {}, q: { state: true }, active: { state: true } };
303
+ static styles = [base, kit, css3`
304
+ :host { display: block; min-width: 220px }
305
+ .search { display: flex; align-items: center; gap: 6px; padding: 0 8px; border-bottom: 1px solid ${t("border")}; color: ${t("muted")} }
306
+ .search input { flex: 1; border: 0; background: none; outline: 0; padding: 9px 0; font-size: 13px }
307
+ [role='listbox'] { max-height: 260px; overflow: auto; padding: 4px }
308
+ .menu-item .check { width: 14px; display: inline-flex }
309
+ .menu-item[aria-disabled='true'] { pointer-events: none }
310
+ .empty { padding: 18px 8px; text-align: center; color: ${t("muted")} }`];
311
+ uid = `c${++ids}`;
312
+ constructor() {
313
+ super();
314
+ this.items = [];
315
+ this.selected = [];
316
+ this.placeholder = "Search…";
317
+ this.q = "";
318
+ this.active = 0;
319
+ }
320
+ get shown() {
321
+ const q = this.q.toLowerCase();
322
+ return this.items.filter((i) => labelOf(i).toLowerCase().includes(q));
323
+ }
324
+ reset() {
325
+ this.q = "";
326
+ this.active = 0;
327
+ }
328
+ pick(i) {
329
+ if (i && !i.disabled)
330
+ this.dispatchEvent(new CustomEvent("pick", { detail: i, bubbles: true, composed: true }));
331
+ }
332
+ onKey(e) {
333
+ const n3 = this.shown.length;
334
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
335
+ e.preventDefault();
336
+ if (n3)
337
+ this.active = (this.active + (e.key === "ArrowDown" ? 1 : -1) + n3) % n3;
338
+ } else if (e.key === "Enter") {
339
+ e.preventDefault();
340
+ this.pick(this.shown[this.active]);
341
+ }
342
+ }
343
+ updated() {
344
+ this.renderRoot.querySelector(".active")?.scrollIntoView?.({ block: "nearest" });
345
+ }
346
+ render() {
347
+ const shown = this.shown;
348
+ let group;
349
+ return html`<div class="search"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><circle cx="7" cy="7" r="4.5" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M10.5 10.5L14 14" stroke="currentColor" stroke-width="1.5"/></svg>
350
+ <input role="combobox" aria-expanded="true" aria-controls=${`${this.uid}-list`} aria-autocomplete="list" placeholder=${this.placeholder} .value=${this.q}
351
+ aria-activedescendant=${shown.length ? `${this.uid}-${this.active}` : nothing}
352
+ @input=${(e) => {
353
+ this.q = e.target.value;
354
+ this.active = 0;
355
+ }} @keydown=${this.onKey}></div>
356
+ <div role="listbox" id=${`${this.uid}-list`} aria-multiselectable=${this.selected.length > 1 ? "true" : nothing}>
357
+ ${shown.length ? shown.map((i, n3) => {
358
+ const head = i.group && i.group !== group ? html`<div class="menu-label" role="presentation">${i.group}</div>` : nothing;
359
+ group = i.group;
360
+ return html`${head}<div role="option" id=${`${this.uid}-${n3}`} data-value=${i.value} class="menu-item ${n3 === this.active ? "active" : ""}"
361
+ aria-selected=${String(this.selected.includes(i.value))} aria-disabled=${i.disabled ? "true" : nothing}
362
+ @pointermove=${() => {
363
+ this.active = n3;
364
+ }} @click=${() => this.pick(i)}>
365
+ <span class="check">${this.selected.includes(i.value) ? CHECK : nothing}</span>${labelOf(i)}${i.shortcut ? html`<span class="shortcut">${i.shortcut}</span>` : nothing}</div>`;
366
+ }) : html`<div class="empty">No results.</div>`}</div>`;
367
+ }
368
+ }
369
+
370
+ class NanoSelect extends LitElement2 {
371
+ static properties = { options: { attribute: false }, value: { attribute: false }, multiple: { type: Boolean }, placeholder: {}, label: {}, open: { state: true } };
372
+ static styles = [base, kit, css3`
373
+ :host { display: inline-block; min-width: 180px }
374
+ [role='combobox'] { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-height: 30px; padding: 3px 8px; cursor: pointer;
375
+ border: 1px solid ${t("border-strong")}; border-radius: ${t("radius-s")}; background: ${t("bg")}; font-size: 12px }
376
+ .placeholder { color: ${t("muted")} } .chev { margin-left: auto; color: ${t("muted")} }
377
+ .chip { padding: 0 2px 0 6px; background: ${t("surface-2")}; border-color: transparent }
378
+ .chip button { border: 0; padding: 0 4px; background: none; color: ${t("muted")} }
379
+ .pop { padding: 0 }`];
380
+ constructor() {
381
+ super();
382
+ this.options = [];
383
+ this.value = "";
384
+ this.multiple = false;
385
+ this.placeholder = "Select…";
386
+ this.label = "";
387
+ this.open = false;
388
+ }
389
+ get items() {
390
+ return this.options.map((o) => typeof o === "string" ? { value: o } : o);
391
+ }
392
+ get chosen() {
393
+ return Array.isArray(this.value) ? this.value : this.value ? [this.value] : [];
394
+ }
395
+ labelFor = (v) => labelOf(this.items.find((i) => i.value === v) ?? { value: v });
396
+ get pop() {
397
+ return this.renderRoot.querySelector(".pop");
398
+ }
399
+ get trigger() {
400
+ return this.renderRoot.querySelector('[role="combobox"]');
401
+ }
402
+ set(v) {
403
+ this.value = v;
404
+ this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
405
+ }
406
+ show(on) {
407
+ if (on === this.open)
408
+ return;
409
+ this.open = on;
410
+ const cmd = this.renderRoot.querySelector("nano-command");
411
+ if (on) {
412
+ cmd.reset();
413
+ place(this.pop, this.trigger);
414
+ cmd.focus();
415
+ } else {
416
+ hide(this.pop);
417
+ this.trigger.focus();
418
+ }
419
+ }
420
+ onPick(e) {
421
+ const v = e.detail.value;
422
+ if (!this.multiple) {
423
+ this.set(v);
424
+ this.show(false);
425
+ return;
426
+ }
427
+ this.set(this.chosen.includes(v) ? this.chosen.filter((x) => x !== v) : [...this.chosen, v]);
428
+ }
429
+ onKey(e) {
430
+ if (e.key === "Escape") {
431
+ e.preventDefault();
432
+ this.show(false);
433
+ } else if (e.target === this.trigger && ["ArrowDown", "Enter", " "].includes(e.key)) {
434
+ e.preventDefault();
435
+ this.show(true);
436
+ } else if (e.target === this.trigger && e.key === "Backspace" && this.multiple && this.chosen.length)
437
+ this.set(this.chosen.slice(0, -1));
438
+ }
439
+ render() {
440
+ const chosen = this.chosen;
441
+ const shown = !chosen.length ? html`<span class="placeholder">${this.placeholder}</span>` : this.multiple ? chosen.map((v) => html`<span class="chip">${this.labelFor(v)}<button tabindex="-1" aria-label=${`Remove ${this.labelFor(v)}`}
442
+ @click=${(e) => {
443
+ e.stopPropagation();
444
+ this.set(chosen.filter((x) => x !== v));
445
+ }}>×</button></span>`) : this.labelFor(chosen[0]);
446
+ return html`<div role="combobox" tabindex="0" aria-label=${this.label || nothing} aria-haspopup="listbox" aria-expanded=${String(this.open)} @click=${() => this.show(!this.open)} @keydown=${this.onKey}>
447
+ ${shown}<svg class="chev" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5"/></svg></div>
448
+ <div class="pop" popover="auto" @toggle=${(e) => {
449
+ if (e.newState === "closed")
450
+ this.open = false;
451
+ }} @keydown=${this.onKey}>
452
+ <nano-command .items=${this.items} .selected=${chosen} @pick=${this.onPick}></nano-command></div>`;
453
+ }
454
+ }
455
+ for (const [tag, cls] of [["nano-command", NanoCommand], ["nano-select", NanoSelect]])
456
+ if (globalThis.customElements && !customElements.get(tag))
457
+ customElements.define(tag, cls);
458
+ // packages/elements/src/kit/calendar.ts
459
+ import { LitElement as LitElement3, css as css4, html as html2, nothing as nothing2 } from "lit";
460
+ var pad = (n3) => String(n3).padStart(2, "0");
461
+ var iso = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
462
+ var parse = (s) => {
463
+ const [y, m, d] = s.split("-").map(Number);
464
+ return y && m && d ? new Date(y, m - 1, d) : undefined;
465
+ };
466
+ var addDays = (s, n3) => {
467
+ const d = parse(s);
468
+ d.setDate(d.getDate() + n3);
469
+ return iso(d);
470
+ };
471
+ var DOW = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
472
+ var chevron = (d) => html2`<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d=${d} fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`;
473
+
474
+ class NanoCalendar extends LitElement3 {
475
+ static properties = { value: {}, view: { state: true }, focusDate: { state: true } };
476
+ static styles = [base, kit, css4`
477
+ :host { display: inline-block; padding: 8px }
478
+ .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px }
479
+ .caption { font-weight: 600 } .head .icon-btn { width: 28px; height: 28px; border: 1px solid ${t("border")} }
480
+ table { border-collapse: collapse } th { width: 32px; font-size: 11px; font-weight: 400; color: ${t("muted")}; padding-bottom: 4px }
481
+ td { padding: 1px } td button { width: 32px; height: 32px; padding: 0; border: 0; border-radius: ${t("radius-s")}; font-size: 12px }
482
+ button.outside { color: ${t("muted")}; opacity: .6 } button.today { background: ${t("surface-2")} }
483
+ button[aria-selected='true'] { background: ${t("accent")}; color: ${t("on-accent")}; opacity: 1 }`];
484
+ constructor() {
485
+ super();
486
+ this.value = "";
487
+ const now = new Date;
488
+ this.view = { y: now.getFullYear(), m: now.getMonth() };
489
+ this.focusDate = "";
490
+ }
491
+ willUpdate(changed) {
492
+ const d = parse(this.value);
493
+ if (changed.has("value") && d) {
494
+ this.view = { y: d.getFullYear(), m: d.getMonth() };
495
+ this.focusDate = this.value;
496
+ }
497
+ }
498
+ shift(n3) {
499
+ const d = new Date(this.view.y, this.view.m + n3, 1);
500
+ this.view = { y: d.getFullYear(), m: d.getMonth() };
501
+ this.focusDate = iso(d);
502
+ }
503
+ focus() {
504
+ this.renderRoot.querySelector('[tabindex="0"]')?.focus();
505
+ }
506
+ pick(date) {
507
+ this.value = date;
508
+ this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
509
+ }
510
+ onKey(e) {
511
+ const step = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 }[e.key];
512
+ const from = this.focusDate || iso(new Date(this.view.y, this.view.m, 1));
513
+ if (step) {
514
+ e.preventDefault();
515
+ this.focusDate = addDays(from, step);
516
+ const d = parse(this.focusDate);
517
+ this.view = { y: d.getFullYear(), m: d.getMonth() };
518
+ this.updateComplete.then(() => this.renderRoot.querySelector('[tabindex="0"]')?.focus());
519
+ } else if (e.key === "Enter" || e.key === " ") {
520
+ e.preventDefault();
521
+ this.pick(from);
522
+ }
523
+ }
524
+ render() {
525
+ const { y, m } = this.view;
526
+ const first = new Date(y, m, 1);
527
+ const days = Array.from({ length: 42 }, (_, i) => new Date(y, m, 1 - first.getDay() + i));
528
+ const today = iso(new Date);
529
+ const focus = this.focusDate.startsWith(`${y}-${pad(m + 1)}-`) ? this.focusDate : iso(first);
530
+ return html2`<div class="head">
531
+ <button class="icon-btn" aria-label="Previous month" @click=${() => this.shift(-1)}>${chevron("M10 4L6 8l4 4")}</button>
532
+ <span class="caption" aria-live="polite">${first.toLocaleString("en", { month: "long" })} ${y}</span>
533
+ <button class="icon-btn" aria-label="Next month" @click=${() => this.shift(1)}>${chevron("M6 4l4 4-4 4")}</button></div>
534
+ <table role="grid" @keydown=${this.onKey}><thead><tr>${DOW.map((d) => html2`<th scope="col">${d}</th>`)}</tr></thead><tbody>
535
+ ${[0, 1, 2, 3, 4, 5].map((w) => html2`<tr>${days.slice(w * 7, w * 7 + 7).map((d) => {
536
+ const s = iso(d);
537
+ return html2`<td role="gridcell"><button data-date=${s} tabindex=${s === focus ? "0" : "-1"} aria-selected=${s === this.value ? "true" : nothing2}
538
+ class="${d.getMonth() !== m ? "outside" : ""} ${s === today ? "today" : ""}" @click=${() => {
539
+ this.focusDate = s;
540
+ this.pick(s);
541
+ }}>${d.getDate()}</button></td>`;
542
+ })}</tr>`)}</tbody></table>`;
543
+ }
544
+ }
545
+
546
+ class NanoDatePicker extends LitElement3 {
547
+ static properties = { value: {}, placeholder: {}, open: { state: true } };
548
+ static styles = [base, kit, css4`
549
+ :host { display: inline-block } .trigger { min-width: 200px; justify-content: flex-start; background: ${t("bg")} }
550
+ .trigger .muted { font-weight: 400 } .pop { padding: 0 }`];
551
+ constructor() {
552
+ super();
553
+ this.value = "";
554
+ this.placeholder = "Pick a date";
555
+ this.open = false;
556
+ }
557
+ get pop() {
558
+ return this.renderRoot.querySelector(".pop");
559
+ }
560
+ get trigger() {
561
+ return this.renderRoot.querySelector(".trigger");
562
+ }
563
+ show(on) {
564
+ this.open = on;
565
+ if (on) {
566
+ place(this.pop, this.trigger);
567
+ this.renderRoot.querySelector("nano-calendar").focus();
568
+ } else
569
+ hide(this.pop);
570
+ }
571
+ onChange(e) {
572
+ e.stopPropagation();
573
+ this.value = e.target.value;
574
+ this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
575
+ this.show(false);
576
+ this.trigger.focus();
577
+ }
578
+ render() {
579
+ const d = parse(this.value);
580
+ return html2`<button class="trigger" aria-haspopup="dialog" aria-expanded=${String(this.open)} @click=${() => this.show(!this.open)}>
581
+ <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><rect x="2" y="3" width="12" height="11" rx="2" fill="none" stroke="currentColor" stroke-width="1.3"/><path d="M2 6.5h12M5 1.5v3M11 1.5v3" stroke="currentColor" stroke-width="1.3"/></svg>
582
+ ${d ? d.toLocaleDateString("en", { month: "short", day: "numeric", year: "numeric" }) : html2`<span class="muted">${this.placeholder}</span>`}</button>
583
+ <div class="pop" popover="auto" role="dialog" aria-label="Choose a date" @toggle=${(e) => {
584
+ if (e.newState === "closed")
585
+ this.open = false;
586
+ }}
587
+ @keydown=${(e) => {
588
+ if (e.key === "Escape") {
589
+ e.preventDefault();
590
+ this.show(false);
591
+ }
592
+ }}>
593
+ <nano-calendar .value=${this.value} @change=${this.onChange}></nano-calendar></div>`;
594
+ }
595
+ }
596
+ for (const [tag, cls] of [["nano-calendar", NanoCalendar], ["nano-date-picker", NanoDatePicker]])
597
+ if (globalThis.customElements && !customElements.get(tag))
598
+ customElements.define(tag, cls);
599
+ // packages/elements/src/kit/overlays.ts
600
+ import { LitElement as LitElement4, css as css5, html as html3, nothing as nothing3 } from "lit";
601
+ var pickable = (i) => ("label" in i) && !i.disabled;
602
+ var menus = 0;
603
+ var define = (tag, cls) => {
604
+ if (globalThis.customElements && !customElements.get(tag))
605
+ customElements.define(tag, cls);
606
+ };
607
+
608
+ class NanoMenu extends LitElement4 {
609
+ static properties = { items: { attribute: false }, open: { type: Boolean, reflect: true }, active: { state: true } };
610
+ static styles = [base, kit, css5`:host { display: contents } [role='menu'] { outline: 0; min-width: 12rem }`];
611
+ constructor() {
612
+ super();
613
+ this.items = [];
614
+ this.open = false;
615
+ this.active = -1;
616
+ this.addEventListener("contextmenu", (e) => {
617
+ e.preventDefault();
618
+ this.show({ x: e.clientX, y: e.clientY });
619
+ });
620
+ }
621
+ uid = `m${++menus}`;
622
+ get menu() {
623
+ return this.renderRoot.querySelector('[role="menu"]');
624
+ }
625
+ async show(at) {
626
+ this.open = true;
627
+ this.active = this.items.findIndex(pickable);
628
+ await this.updateComplete;
629
+ place(this.menu, this, at);
630
+ this.menu.focus();
631
+ }
632
+ close() {
633
+ this.open = false;
634
+ hide(this.menu);
635
+ }
636
+ pick(i) {
637
+ if (!i || !pickable(i))
638
+ return;
639
+ this.dispatchEvent(new CustomEvent("pick", { detail: i, bubbles: true, composed: true }));
640
+ this.close();
641
+ }
642
+ onKey(e) {
643
+ const step = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0;
644
+ if (step) {
645
+ e.preventDefault();
646
+ for (let n3 = 1, len = this.items.length;n3 <= len; n3++) {
647
+ const i = (this.active + step * n3 + len) % len;
648
+ if (pickable(this.items[i])) {
649
+ this.active = i;
650
+ break;
651
+ }
652
+ }
653
+ } else if (e.key === "Enter" || e.key === " ") {
654
+ e.preventDefault();
655
+ this.pick(this.items[this.active]);
656
+ } else if (e.key === "Escape") {
657
+ e.preventDefault();
658
+ this.close();
659
+ }
660
+ }
661
+ render() {
662
+ return html3`<slot></slot><div class="pop" popover="auto" role="menu" tabindex="-1" aria-activedescendant=${this.active >= 0 ? `${this.uid}-${this.active}` : nothing3} @keydown=${this.onKey}
663
+ @toggle=${(e) => {
664
+ if (e.newState === "closed")
665
+ this.open = false;
666
+ }}>
667
+ ${this.items.map((i, n3) => ("separator" in i) ? html3`<div class="menu-sep" role="separator"></div>` : ("heading" in i) ? html3`<div class="menu-label">${i.heading}</div>` : html3`<div role="menuitem" id=${`${this.uid}-${n3}`} class="menu-item ${i.danger ? "danger" : ""} ${n3 === this.active ? "active" : ""}" aria-disabled=${i.disabled ? "true" : nothing3}
668
+ @pointermove=${() => {
669
+ if (!i.disabled)
670
+ this.active = n3;
671
+ }} @click=${() => this.pick(i)}>${i.label}${i.shortcut ? html3`<span class="shortcut">${i.shortcut}</span>` : nothing3}</div>`)}</div>`;
672
+ }
673
+ }
674
+
675
+ class NanoHoverCard extends LitElement4 {
676
+ static properties = { open: { type: Boolean, reflect: true }, openDelay: { type: Number, attribute: "open-delay" }, closeDelay: { type: Number, attribute: "close-delay" } };
677
+ static styles = [base, kit, css5`:host { display: inline-block } .pop { width: 280px; padding: 14px }`];
678
+ timer;
679
+ constructor() {
680
+ super();
681
+ this.open = false;
682
+ this.openDelay = 500;
683
+ this.closeDelay = 200;
684
+ }
685
+ later(open) {
686
+ clearTimeout(this.timer);
687
+ this.timer = setTimeout(() => {
688
+ this.open = open;
689
+ }, open ? this.openDelay : this.closeDelay);
690
+ }
691
+ updated(changed) {
692
+ if (!changed.has("open"))
693
+ return;
694
+ const pop = this.renderRoot.querySelector(".pop");
695
+ if (this.open)
696
+ place(pop, this.renderRoot.querySelector(".trigger"));
697
+ else
698
+ hide(pop);
699
+ pop.style.minWidth = "";
700
+ }
701
+ render() {
702
+ const on = () => this.later(true), off = () => this.later(false);
703
+ return html3`<span class="trigger" @pointerenter=${on} @pointerleave=${off} @focusin=${on} @focusout=${off}><slot></slot></span>
704
+ <div class="pop" popover="manual" @pointerenter=${on} @pointerleave=${off}><slot name="card"></slot></div>`;
705
+ }
706
+ }
707
+ var toastIds = 0;
708
+
709
+ class NanoToaster extends LitElement4 {
710
+ static properties = { toasts: { state: true } };
711
+ static styles = [base, kit, css5`:host { position: fixed; right: 16px; bottom: 16px; z-index: 1000 } ol { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none }`];
712
+ constructor() {
713
+ super();
714
+ this.toasts = [];
715
+ }
716
+ add(toast) {
717
+ this.toasts = [...this.toasts, toast];
718
+ if (toast.duration !== 0)
719
+ setTimeout(() => this.dismiss(toast.id), toast.duration ?? 4000);
720
+ }
721
+ dismiss(id) {
722
+ this.toasts = this.toasts.filter((x) => x.id !== id);
723
+ }
724
+ render() {
725
+ return html3`<ol aria-live="polite">${this.toasts.map((x) => html3`<li class="toast ${x.variant ?? ""}" role="status">
726
+ <div class="body"><div class="title">${x.title}</div>${x.description ? html3`<div class="desc">${x.description}</div>` : nothing3}</div>
727
+ <button class="icon-btn" aria-label="Close" @click=${() => this.dismiss(x.id)}>✕</button></li>`)}</ol>`;
728
+ }
729
+ }
730
+ function toast(title, opts = {}) {
731
+ const el = document.querySelector("nano-toaster") ?? document.body.appendChild(document.createElement("nano-toaster"));
732
+ const id = ++toastIds;
733
+ el.add({ id, title, ...opts });
734
+ return id;
735
+ }
736
+
737
+ class NanoCodeBlock extends LitElement4 {
738
+ static properties = { code: {}, language: {}, copied: { state: true } };
739
+ static styles = [base, kit, css5`
740
+ .frame { position: relative } .bar { position: absolute; top: 4px; right: 4px; display: flex; align-items: center; gap: 6px }
741
+ .lang { font-size: 11px; color: ${t("muted")} } pre.code { padding-right: 90px }`];
742
+ constructor() {
743
+ super();
744
+ this.code = "";
745
+ this.language = "";
746
+ this.copied = false;
747
+ }
748
+ async copy() {
749
+ await navigator.clipboard?.writeText(this.code);
750
+ this.copied = true;
751
+ setTimeout(() => {
752
+ this.copied = false;
753
+ }, 1500);
754
+ }
755
+ render() {
756
+ return html3`<div class="frame"><pre class="code">${this.code}</pre><div class="bar"><span class="lang">${this.language}</span>
757
+ <button class="icon-btn" aria-label="Copy" @click=${this.copy}>${this.copied ? "✓ Copied" : "Copy"}</button></div></div>`;
758
+ }
759
+ }
760
+ define("nano-menu", NanoMenu);
761
+ define("nano-hover-card", NanoHoverCard);
762
+ define("nano-toaster", NanoToaster);
763
+ define("nano-code-block", NanoCodeBlock);
764
+ // packages/elements/src/kit/data-table.ts
765
+ import { LitElement as LitElement5, css as css6, html as html4, nothing as nothing4 } from "lit";
766
+ var cell = (r, k) => String(r[k] ?? "");
767
+ var compare = (a, b) => typeof a === "number" && typeof b === "number" ? a - b : String(a ?? "").localeCompare(String(b ?? ""), undefined, { numeric: true });
768
+
769
+ class NanoDataTable extends LitElement5 {
770
+ static properties = {
771
+ columns: { attribute: false },
772
+ rows: { attribute: false },
773
+ filter: { type: Boolean },
774
+ selectable: { type: Boolean },
775
+ pageSize: { type: Number, attribute: "page-size" },
776
+ q: { state: true },
777
+ sort: { state: true },
778
+ page: { state: true },
779
+ picked: { state: true }
780
+ };
781
+ static styles = [base, kit, css6`
782
+ .frame { border: 1px solid ${t("border")}; border-radius: ${t("radius")}; overflow: auto }
783
+ .table { margin: 0 } .table tr:last-child td { border-bottom: 0 } .table tbody tr:hover { background: ${t("surface-2")} }
784
+ .table tr[aria-selected='true'] { background: ${t("surface-2")} } .table .right { text-align: right } .table .tick { width: 28px }
785
+ th button { border: 0; padding: 0; background: none; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit }
786
+ .filter { width: min(280px, 100%); margin-bottom: 10px } .empty { text-align: center; padding: 24px; color: ${t("muted")} }
787
+ .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; color: ${t("muted")}; font-size: 12px }`];
788
+ constructor() {
789
+ super();
790
+ this.columns = [];
791
+ this.rows = [];
792
+ this.filter = false;
793
+ this.selectable = false;
794
+ this.pageSize = 0;
795
+ this.q = "";
796
+ this.page = 0;
797
+ this.picked = new Set;
798
+ }
799
+ get shown() {
800
+ const q = this.q.toLowerCase();
801
+ const rows = q ? this.rows.filter((r) => this.columns.some((c) => cell(r, c.key).toLowerCase().includes(q))) : [...this.rows];
802
+ const s = this.sort;
803
+ return s ? rows.sort((a, b) => compare(a[s.key], b[s.key]) * s.dir) : rows;
804
+ }
805
+ sortBy(key) {
806
+ this.sort = this.sort?.key === key && this.sort.dir === 1 ? { key, dir: -1 } : { key, dir: 1 };
807
+ }
808
+ pick(rows, on) {
809
+ const next = new Set(this.picked);
810
+ for (const r of rows)
811
+ on ? next.add(r) : next.delete(r);
812
+ this.picked = next;
813
+ this.dispatchEvent(new CustomEvent("selection", { detail: this.rows.filter((r) => next.has(r)), bubbles: true, composed: true }));
814
+ }
815
+ render() {
816
+ const all = this.shown, size = this.pageSize || all.length || 1, pages = Math.max(1, Math.ceil(all.length / size));
817
+ const page = Math.min(this.page, pages - 1), rows = all.slice(page * size, page * size + size);
818
+ const allPicked = rows.length > 0 && rows.every((r) => this.picked.has(r));
819
+ const head = (c) => {
820
+ const sorted = this.sort?.key === c.key ? this.sort.dir === 1 ? "ascending" : "descending" : undefined;
821
+ return html4`<th data-key=${c.key} class=${c.align ?? ""} aria-sort=${c.sortable ? sorted ?? "none" : nothing4}>${c.sortable ? html4`<button @click=${() => this.sortBy(c.key)}>${c.label} ${sorted === "ascending" ? "↑" : sorted === "descending" ? "↓" : "↕"}</button>` : c.label}</th>`;
822
+ };
823
+ return html4`${this.filter ? html4`<input class="input filter" placeholder="Filter…" aria-label="Filter rows" .value=${this.q}
824
+ @input=${(e) => {
825
+ this.q = e.target.value;
826
+ this.page = 0;
827
+ }}>` : nothing4}
828
+ <div class="frame"><table class="table"><thead><tr>
829
+ ${this.selectable ? html4`<th class="tick"><input type="checkbox" aria-label="Select all" .checked=${allPicked} @click=${() => this.pick(rows, !allPicked)}></th>` : nothing4}
830
+ ${this.columns.map(head)}</tr></thead><tbody>
831
+ ${rows.length ? rows.map((r) => html4`<tr aria-selected=${this.selectable ? String(this.picked.has(r)) : nothing4}>
832
+ ${this.selectable ? html4`<td class="tick"><input type="checkbox" aria-label="Select row" .checked=${this.picked.has(r)} @click=${() => this.pick([r], !this.picked.has(r))}></td>` : nothing4}
833
+ ${this.columns.map((c) => html4`<td data-key=${c.key} class=${c.align ?? ""}>${c.render ? c.render(r) : cell(r, c.key)}</td>`)}</tr>`) : html4`<tr><td class="empty" colspan=${this.columns.length + (this.selectable ? 1 : 0)}>No results.</td></tr>`}</tbody></table></div>
834
+ ${this.selectable || this.pageSize ? html4`<div class="foot"><span>${this.selectable ? `${this.picked.size} of ${this.rows.length} row(s) selected.` : ""}</span>
835
+ ${this.pageSize ? html4`<span class="pages row">Page ${page + 1} of ${pages}
836
+ <button class="btn small" aria-label="Previous page" ?disabled=${page === 0} @click=${() => {
837
+ this.page = page - 1;
838
+ }}>‹</button>
839
+ <button class="btn small" aria-label="Next page" ?disabled=${page >= pages - 1} @click=${() => {
840
+ this.page = page + 1;
841
+ }}>›</button></span>` : nothing4}</div>` : nothing4}`;
842
+ }
843
+ }
844
+ if (globalThis.customElements && !customElements.get("nano-data-table"))
845
+ customElements.define("nano-data-table", NanoDataTable);
846
+ // packages/elements/src/agent/parts.ts
847
+ import { LitElement as LitElement6, css as css7, html as html5, nothing as nothing5 } from "lit";
848
+ var json = (v) => typeof v === "string" ? v : JSON.stringify(v, null, 2);
849
+ var STATE = { "input-streaming": ["Pending", ""], "input-available": ["Running", "accent"], "output-available": ["Completed", "good"], "output-error": ["Error", "bad"] };
850
+ var AGENT = { running: ["Running", "accent"], completed: ["Completed", "good"], error: ["Error", "bad"] };
851
+ var ITEM = { completed: "✓", in_progress: "◐", pending: "○" };
852
+ var define2 = (tag, cls) => {
853
+ if (globalThis.customElements && !customElements.get(tag))
854
+ customElements.define(tag, cls);
855
+ };
856
+ var agentStyles = css7`
857
+ details.card { padding: 0 } details.card > summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; list-style: none }
858
+ details.card > summary::-webkit-details-marker { display: none }
859
+ details.card > summary::after { content: '▾'; margin-left: 8px; color: ${t("muted")}; transition: transform .15s } details.card:not([open]) > summary::after { transform: rotate(-90deg) }
860
+ details.card > summary .badge { margin-left: auto } .body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px }
861
+ .name { font-weight: 600 } .kicker { margin-bottom: 4px } .code { max-height: 220px }`;
862
+
863
+ class NanoTool extends LitElement6 {
864
+ static properties = { tool: { attribute: false } };
865
+ static styles = [base, kit, agentStyles];
866
+ render() {
867
+ const p = this.tool;
868
+ if (!p)
869
+ return nothing5;
870
+ const [label, tone] = STATE[p.state];
871
+ return html5`<details class="card" ?open=${p.state === "output-error"}><summary>
872
+ <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M10.5 2.5a3 3 0 0 0-3.9 3.9L2.5 10.5l3 3 4.1-4.1a3 3 0 0 0 3.9-3.9l-2 2-2-2z" fill="none" stroke="currentColor" stroke-width="1.3"/></svg>
873
+ <span class="name">${p.toolName ?? p.type.replace(/^tool-/, "")}</span><span class="badge ${tone}">${label}</span></summary>
874
+ <div class="body">
875
+ <div data-part="input"><div class="kicker">Parameters</div><pre class="code">${json(p.input ?? {})}</pre></div>
876
+ ${p.state === "output-available" ? html5`<div data-part="output"><div class="kicker">Result</div><pre class="code">${json(p.output)}</pre></div>` : nothing5}
877
+ ${p.state === "output-error" ? html5`<div class="alert bad">${p.errorText ?? "The tool failed."}</div>` : nothing5}</div></details>`;
878
+ }
879
+ }
880
+
881
+ class NanoTask extends LitElement6 {
882
+ static properties = { task: { attribute: false } };
883
+ static styles = [base, kit, agentStyles, css7`
884
+ ul { list-style: none; margin: 0; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 6px }
885
+ li { display: flex; gap: 8px; align-items: baseline } .icon { width: 14px; color: ${t("muted")} }
886
+ li[data-status='completed'] { color: ${t("muted")} } li[data-status='completed'] .icon { color: ${t("good")} } li[data-status='in_progress'] .icon { color: ${t("accent")} }
887
+ .file { margin-left: 4px } .count { color: ${t("muted")}; font-size: 12px; margin-left: auto } .count + .badge { margin-left: 0 }`];
888
+ render() {
889
+ const k = this.task;
890
+ if (!k)
891
+ return nothing5;
892
+ const done = k.items.filter((i) => i.status === "completed").length;
893
+ return html5`<details class="card" open><summary><span class="title name">${k.title}</span><span class="count">${done}/${k.items.length}</span></summary>
894
+ <ul>${k.items.map((i) => html5`<li data-status=${i.status ?? "pending"}><span class="icon" aria-hidden="true">${ITEM[i.status ?? "pending"]}</span>
895
+ <span>${i.text}${i.file ? html5`<span class="chip mono file">${i.file.name}</span>` : nothing5}</span></li>`)}</ul></details>`;
896
+ }
897
+ }
898
+
899
+ class NanoSubagent extends LitElement6 {
900
+ static properties = { agent: { attribute: false } };
901
+ static styles = [base, kit, agentStyles, css7`.desc { color: ${t("muted")}; font-size: 12px } .body { border-left: 2px solid ${t("border")}; margin-left: 18px; padding-left: 12px }`];
902
+ render() {
903
+ const a = this.agent;
904
+ if (!a)
905
+ return nothing5;
906
+ const [label, tone] = AGENT[a.status];
907
+ return html5`<details class="card" open><summary><span class="avatar small" aria-hidden="true">${a.name.slice(0, 2).toUpperCase()}</span>
908
+ <span class="col" style="gap:0"><span class="name">${a.name}</span>${a.description ? html5`<span class="desc">${a.description}</span>` : nothing5}</span>
909
+ <span class="badge ${tone}">${label}</span></summary>
910
+ <div class="body">${a.parts.map((p) => html5`<nano-tool .tool=${p}></nano-tool>`)}${a.result ? html5`<div class="bubble">${a.result}</div>` : nothing5}</div></details>`;
911
+ }
912
+ }
913
+
914
+ class NanoCli extends LitElement6 {
915
+ static properties = { runs: { attribute: false } };
916
+ static styles = [base, kit, css7`
917
+ .term { font: 12px/1.6 ${t("font-mono")}; background: ${t("surface-2")}; border: 1px solid ${t("border")}; border-radius: ${t("radius")}; padding: 10px 12px; overflow: auto }
918
+ .run + .run { margin-top: 10px } .line { display: flex; gap: 8px; align-items: center } .prompt { color: ${t("accent")} } .cmd { font-weight: 600 }
919
+ .cwd { color: ${t("muted")} } .exit { margin-left: auto } pre { margin: 2px 0 0; white-space: pre-wrap; color: ${t("fg-2")} }`];
920
+ constructor() {
921
+ super();
922
+ this.runs = [];
923
+ }
924
+ render() {
925
+ return html5`<div class="term">${this.runs.map((r) => html5`<div class="run"><div class="line">${r.cwd ? html5`<span class="cwd">${r.cwd}</span>` : nothing5}
926
+ <span class="prompt">$</span><span class="cmd">${r.command}</span>
927
+ <span class="exit badge ${r.running ? "accent" : r.exitCode === 0 ? "good" : r.exitCode === undefined ? "" : "bad"}">${r.running ? "running…" : r.exitCode === undefined ? "" : `exit ${r.exitCode}`}</span></div>
928
+ ${r.output ? html5`<pre>${r.output}</pre>` : nothing5}</div>`)}</div>`;
929
+ }
930
+ }
931
+ define2("nano-tool", NanoTool);
932
+ define2("nano-task", NanoTask);
933
+ define2("nano-subagent", NanoSubagent);
934
+ define2("nano-cli", NanoCli);
935
+ // packages/elements/src/agent/timeline.ts
936
+ import { LitElement as LitElement7, css as css8, html as html6, nothing as nothing6 } from "lit";
937
+ var ms = (n3) => n3 < 1000 ? `${Math.round(n3)}ms` : `${(n3 / 1000).toFixed(2)}s`;
938
+ var pct = (n3) => `${+n3.toFixed(2)}%`;
939
+ var ordered = (spans) => {
940
+ const ids2 = new Set(spans.map((s) => s.spanId)), out = [];
941
+ const walk = (parent, depth) => spans.filter((s) => parent === undefined ? !s.parentSpanId || !ids2.has(s.parentSpanId) : s.parentSpanId === parent).sort((a, b) => a.startTime - b.startTime).forEach((s) => {
942
+ out.push({ span: s, depth });
943
+ walk(s.spanId, depth + 1);
944
+ });
945
+ walk(undefined, 0);
946
+ return out;
947
+ };
948
+
949
+ class NanoTrace extends LitElement7 {
950
+ static properties = { spans: { attribute: false } };
951
+ static styles = [base, kit, css8`
952
+ .frame { border: 1px solid ${t("border")}; border-radius: ${t("radius")}; padding: 8px 0 }
953
+ .head, .span { display: grid; grid-template-columns: minmax(120px, 30%) 1fr 64px; align-items: center; gap: 8px; padding: 3px 12px }
954
+ .head { color: ${t("muted")}; font-size: 11px; border-bottom: 1px solid ${t("border")}; padding-bottom: 6px; margin-bottom: 4px }
955
+ .span:hover { background: ${t("surface-2")} } .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
956
+ .track { position: relative; height: 14px } .bar { position: absolute; top: 2px; bottom: 2px; min-width: 2px; border-radius: 3px }
957
+ .bar.bad { background: ${t("bad")} !important } .dur, .total { text-align: right; color: ${t("muted")}; font: 11px ${t("font-mono")} }`];
958
+ constructor() {
959
+ super();
960
+ this.spans = [];
961
+ }
962
+ render() {
963
+ if (!this.spans.length)
964
+ return nothing6;
965
+ const t0 = Math.min(...this.spans.map((s) => s.startTime)), total = Math.max(...this.spans.map((s) => s.endTime)) - t0 || 1;
966
+ return html6`<div class="frame"><div class="head"><span>Span</span><span>Timeline</span><span class="total">${ms(total)}</span></div>
967
+ ${ordered(this.spans).map(({ span: s, depth }) => html6`<div class="span" data-depth=${depth} title=${`${s.name}: ${ms(s.endTime - s.startTime)}`}>
968
+ <span class="label" style=${`padding-left:${depth * 14}px`}>${s.name}</span>
969
+ <span class="track"><span class="bar ${s.status === "error" ? "bad" : ""}" style=${`left:${pct((s.startTime - t0) / total * 100)};width:${pct((s.endTime - s.startTime) / total * 100)};background:${tv(`s${depth % 8 + 1}`)}`}></span></span>
970
+ <span class="dur">${ms(s.endTime - s.startTime)}</span></div>`)}</div>`;
971
+ }
972
+ }
973
+ var MARK = { passed: "✓", failed: "✕", skipped: "–" };
974
+
975
+ class NanoTestResults extends LitElement7 {
976
+ static properties = { results: { attribute: false } };
977
+ static styles = [base, kit, agentStyles, css8`
978
+ .summary { display: flex; align-items: center; gap: 8px; margin-bottom: 8px } .dur { margin-left: auto; color: ${t("muted")}; font: 11px ${t("font-mono")} }
979
+ .bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: ${t("surface-2")}; margin-bottom: 12px }
980
+ .seg.passed { background: ${t("good")} } .seg.failed { background: ${t("bad")} } .seg.skipped { background: ${t("muted")} }
981
+ .suites { display: flex; flex-direction: column; gap: 8px } .tests { list-style: none; margin: 0; padding: 0 12px 10px }
982
+ .test { display: grid; grid-template-columns: 16px 1fr auto; gap: 6px; padding: 3px 0 } .test .alert { grid-column: 2 / -1; font: 11px ${t("font-mono")}; white-space: pre-wrap }
983
+ .test.passed .mark { color: ${t("good")} } .test.failed .mark { color: ${t("bad")} } .test.skipped { color: ${t("muted")} }
984
+ .test .ms { color: ${t("muted")}; font: 11px ${t("font-mono")} } summary .muted { font-size: 12px }`];
985
+ render() {
986
+ const r = this.results;
987
+ if (!r)
988
+ return nothing6;
989
+ const { summary: s } = r, tone = { passed: "good", failed: "bad", skipped: "" };
990
+ return html6`<div class="summary">${["passed", "failed", "skipped"].map((k) => html6`<span class="badge ${tone[k]}" data-count=${k}>${s[k]} ${k}</span>`)}
991
+ ${s.duration !== undefined ? html6`<span class="dur">${ms(s.duration)}</span>` : nothing6}</div>
992
+ <div class="bar" role="img" aria-label=${`${s.passed} passed, ${s.failed} failed, ${s.skipped} skipped of ${s.total}`}>
993
+ ${["passed", "failed", "skipped"].map((k) => html6`<span class="seg ${k}" style=${`width:${pct(s[k] / (s.total || 1) * 100)}`}></span>`)}</div>
994
+ <div class="suites">${r.suites.map((suite) => {
995
+ const failed = suite.tests.filter((x) => x.status === "failed").length;
996
+ return html6`<details class="card suite" ?open=${failed > 0}><summary><span class="name">${suite.name}</span>
997
+ <span class="muted">${suite.tests.length - failed}/${suite.tests.length}</span>${failed ? html6`<span class="badge bad">${failed} failed</span>` : nothing6}</summary>
998
+ <ul class="tests">${suite.tests.map((x) => html6`<li class="test ${x.status}"><span class="mark" aria-label=${x.status}>${MARK[x.status]}</span><span>${x.name}</span>
999
+ <span class="ms">${x.duration !== undefined ? ms(x.duration) : ""}</span>${x.error ? html6`<div class="alert bad">${x.error.message}</div>` : nothing6}</li>`)}</ul></details>`;
1000
+ })}</div>`;
1001
+ }
1002
+ }
1003
+ for (const [tag, cls] of [["nano-trace", NanoTrace], ["nano-test-results", NanoTestResults]])
1004
+ if (globalThis.customElements && !customElements.get(tag))
1005
+ customElements.define(tag, cls);
121
1006
  export {
1007
+ tv,
1008
+ toast,
1009
+ t,
122
1010
  providedRegistry,
123
1011
  provide,
1012
+ kit,
124
1013
  base,
125
1014
  PlacedElement,
1015
+ NanoTrace,
1016
+ NanoTool,
1017
+ NanoToaster,
1018
+ NanoTestResults,
1019
+ NanoTask,
1020
+ NanoSubagent,
1021
+ NanoSelect,
1022
+ NanoMenu,
1023
+ NanoHoverCard,
1024
+ NanoDatePicker,
1025
+ NanoDataTable,
1026
+ NanoCommand,
1027
+ NanoCodeBlock,
1028
+ NanoCli,
1029
+ NanoCalendar,
1030
+ NANO_TOKENS,
126
1031
  ModelElement
127
1032
  };
128
1033
 
129
- //# debugId=B432BAB1B5BC587A64756E2164756E21
1034
+ //# debugId=B78D62A066E2B5C464756E2164756E21
130
1035
  //# sourceMappingURL=index.js.map