@adia-ai/web-modules 0.8.43 → 0.8.45

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog — @adia-ai/web-modules
2
2
 
3
+ ## [0.8.45] — 2026-08-20
4
+
5
+ ### Changed
6
+ - **New `shared/sidebar-persist.js` module extracted from the admin/chat sidebars' duplicated collapse/persist mechanics (gh#1767).** `editor-sidebar` kept bespoke (pane-ui delegation).
7
+ - **`for=`-carrying component normalization (gh#1764/#1780) and `RouteController` dedup onto `@adia-ai/web-components`'s `core/controller.js` (gh#1766) ride along — no `web-modules`-local API change.**
8
+
9
+ ### Note
10
+ - The headline v0.8.45 work shipped in `@adia-ai/web-components`. See `packages/web-components/CHANGELOG.md#0845--2026-08-20` for details.
11
+
12
+ ### Maintenance
13
+ - **`billing/` touched in this release window** (8 file(s), e.g. `billing-overview/billing-overview.class.js`) — carried by the entries above.
14
+ - **`dist/` bundles rebuilt** in this cut's window (1 file(s)) — regenerated from the source changes described above, not independent edits.
15
+ - **`shell/` touched in this release window** (1 file(s), e.g. `admin-sidebar/admin-sidebar.js`) — carried by the entries above.
16
+
17
+ ## [0.8.44] — 2026-08-20
18
+
19
+ ### Fixed
20
+ - **Restored kebab-case props silently dropped from `.d.ts` (gh#1686, `dts-codegen.mjs` fix — see repo-root CHANGELOG).** Props on `admin-command`, `admin-sidebar`, `chat-sidebar`, `simple-shell`, and `theme-panel` are restored to their `.d.ts` files. No runtime behavior change — these props already worked at runtime; only the shipped TypeScript surface was affected.
21
+
22
+ ### Maintenance
23
+ - **`dist/` bundles rebuilt** in this cut's window (5 file(s)) — regenerated from the source changes described above, not independent edits.
24
+
3
25
  ## [0.8.43] — 2026-08-18
4
26
 
5
27
  ### Breaking
@@ -51,6 +51,7 @@
51
51
 
52
52
  import { UIElement } from '@adia-ai/web-components/core/element';
53
53
  import { untracked } from '@adia-ai/web-components/core/signals';
54
+ import { json } from '@adia-ai/web-components/core/transport';
54
55
 
55
56
  const KNOWN_STATUSES = new Set([
56
57
  'active', 'trialing', 'past_due', 'canceled', 'paused',
@@ -187,9 +188,7 @@ export class UIBillingOverview extends UIElement {
187
188
  this.loading = true;
188
189
  this.removeAttribute('error');
189
190
  try {
190
- const res = await fetch(src);
191
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
192
- const data = await res.json();
191
+ const data = await json(src);
193
192
  if (tag !== this.#loadCount) return;
194
193
  this.loading = false;
195
194
  const record = data && typeof data === 'object' && data.account
@@ -214,6 +213,11 @@ export class UIBillingOverview extends UIElement {
214
213
  // ── Lifecycle ─────────────────────────────────────────────────────
215
214
 
216
215
  connected() {
216
+ // gh#1760 — opt this element out of core/data-stream.js's document-level
217
+ // auto-observer. This composite is the sole owner of `data-stream-src`
218
+ // for itself (hand-rolled `refresh()` above); without this marker, a
219
+ // page that also imports the core barrel double-fetches on connect.
220
+ this.setAttribute('data-stream-managed', 'false');
217
221
  this.setAttribute('role', 'region');
218
222
 
219
223
  if (!this.#stamped) {
@@ -29,6 +29,7 @@
29
29
 
30
30
  import { UIElement } from '@adia-ai/web-components/core/element';
31
31
  import { untracked } from '@adia-ai/web-components/core/signals';
32
+ import { json } from '@adia-ai/web-components/core/transport';
32
33
 
33
34
  const KNOWN_STATUSES = new Set(['draft', 'open', 'paid', 'past-due', 'void']);
34
35
 
@@ -177,9 +178,7 @@ export class UIInvoiceDetail extends UIElement {
177
178
  this.loading = true;
178
179
  this.removeAttribute('error');
179
180
  try {
180
- const res = await fetch(src);
181
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
182
- const data = await res.json();
181
+ const data = await json(src);
183
182
  if (tag !== this.#loadCount) return; // stale
184
183
  this.loading = false;
185
184
  // Allow either {invoice: {...}} envelope or the raw record.
@@ -212,6 +211,10 @@ export class UIInvoiceDetail extends UIElement {
212
211
  // ── Lifecycle ─────────────────────────────────────────────────────
213
212
 
214
213
  connected() {
214
+ // gh#1760 — opt out of core/data-stream.js's document-level
215
+ // auto-observer; this composite owns `data-stream-src` itself
216
+ // via the hand-rolled `refresh()` above.
217
+ this.setAttribute('data-stream-managed', 'false');
215
218
  this.setAttribute('role', 'region');
216
219
 
217
220
  if (!this.#stamped) {
@@ -34,6 +34,7 @@
34
34
 
35
35
  import { UIElement } from '@adia-ai/web-components/core/element';
36
36
  import { untracked } from '@adia-ai/web-components/core/signals';
37
+ import { json } from '@adia-ai/web-components/core/transport';
37
38
 
38
39
  const KNOWN_STATUSES = new Set(['draft', 'open', 'paid', 'past-due', 'void']);
39
40
 
@@ -227,9 +228,7 @@ export class InvoiceHistory extends UIElement {
227
228
  this.setAttribute('loading', '');
228
229
  this.removeAttribute('error');
229
230
  try {
230
- const res = await fetch(src);
231
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
232
- const data = await res.json();
231
+ const data = await json(src);
233
232
  if (tag !== this.#loadCount) return; // stale
234
233
  this.removeAttribute('loading');
235
234
  const list = Array.isArray(data)
@@ -255,6 +254,10 @@ export class InvoiceHistory extends UIElement {
255
254
 
256
255
  connected() {
257
256
  super.connected?.();
257
+ // gh#1760 — opt out of core/data-stream.js's document-level
258
+ // auto-observer; this composite owns `data-stream-src` itself
259
+ // via the hand-rolled `refresh()` below.
260
+ this.setAttribute('data-stream-managed', 'false');
258
261
  this.setAttribute('role', 'region');
259
262
  if (!this.hasAttribute('aria-label') && !this.hasAttribute('aria-labelledby')) {
260
263
  this.setAttribute('aria-label', 'Invoice history');
@@ -43,6 +43,7 @@
43
43
 
44
44
  import { UIFormElement } from '@adia-ai/web-components/core/form';
45
45
  import { untracked } from '@adia-ai/web-components/core/signals';
46
+ import { json } from '@adia-ai/web-components/core/transport';
46
47
 
47
48
  const KNOWN_CYCLES = new Set(['monthly', 'annual']);
48
49
 
@@ -185,9 +186,7 @@ export class PlanPicker extends UIFormElement {
185
186
  this.setAttribute('loading', '');
186
187
  this.removeAttribute('error');
187
188
  try {
188
- const res = await fetch(src);
189
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
190
- const data = await res.json();
189
+ const data = await json(src);
191
190
  if (tag !== this.#loadCount) return; // stale
192
191
  this.removeAttribute('loading');
193
192
  const list = Array.isArray(data) ? data : (Array.isArray(data?.plans) ? data.plans : []);
@@ -211,6 +210,10 @@ export class PlanPicker extends UIFormElement {
211
210
 
212
211
  connected() {
213
212
  super.connected();
213
+ // gh#1760 — opt out of core/data-stream.js's document-level
214
+ // auto-observer; this composite owns `data-stream-src` itself
215
+ // via the hand-rolled `refresh()` above.
216
+ this.setAttribute('data-stream-managed', 'false');
214
217
  this.setAttribute('role', 'radiogroup');
215
218
  if (!this.hasAttribute('aria-label') && !this.hasAttribute('aria-labelledby')) {
216
219
  this.setAttribute('aria-label', 'Choose a plan');
@@ -46,6 +46,10 @@ duplicating threshold math.
46
46
  .toggle() / .collapse() / .expand() public methods.
47
47
  */
48
48
  collapsible: boolean;
49
+ /** Optional override for the snap-floor width. Defaults to reading
50
+ CSS min-width via getComputedStyle.
51
+ */
52
+ minWidth: string;
49
53
  /** Identifier for localStorage namespacing. Defaults to slot value
50
54
  ("leading" or "trailing"). Override when running multiple sidebars
51
55
  with the same slot.
@@ -37,13 +37,22 @@
37
37
  * Backwards compat: <chat-shell> still recognizes the legacy
38
38
  * `<aside data-sidebar="leading">` shape via :is() selector. New
39
39
  * code should prefer <chat-sidebar>.
40
+ *
41
+ * gh#1767 (reactivity review R8b) — collapse()/expand()/toggle() and the
42
+ * localStorage persistence now come from ../../shared/sidebar-persist.js,
43
+ * shared verbatim with <admin-sidebar> (the storage-key PREFIX is this
44
+ * component's own — `adia-chat-sidebar-*` — so no existing user's
45
+ * persisted width resets). See that module's header for why
46
+ * editor-sidebar isn't a third consumer.
40
47
  */
41
48
 
42
49
  import { defineIfFree } from '@adia-ai/web-components/core/register';
43
50
  import { UIElement } from '@adia-ai/web-components/core/element';
44
-
45
- const SNAP_THRESHOLD = 96;
46
- const SNAP_MIN_USABLE = 160;
51
+ import {
52
+ attachSidebarCollapsePersist,
53
+ SIDEBAR_SNAP_THRESHOLD as SNAP_THRESHOLD,
54
+ SIDEBAR_SNAP_MIN_USABLE as SNAP_MIN_USABLE,
55
+ } from '../../shared/sidebar-persist.js';
47
56
 
48
57
  class ChatSidebar extends UIElement {
49
58
  static properties = {
@@ -57,17 +66,21 @@ class ChatSidebar extends UIElement {
57
66
 
58
67
  static template = () => null;
59
68
 
60
- // The width the sidebar had before being collapsed — used for restore.
61
- // Map keyed by sidebar name allows multiple sidebars on one host.
62
- #previousExpandedWidth = '';
63
69
  #resizeCleanups = [];
64
70
  #childRO = null;
71
+ // Collapse/expand/toggle/persist mechanics — shared with admin-sidebar
72
+ // (reactivity review R8b, gh#1767); see shared/sidebar-persist.js for
73
+ // why editor-sidebar isn't a third consumer. No `guardZeroWidth` here —
74
+ // chat-sidebar's pre-extraction behavior never guarded a zero-rect
75
+ // connect (unlike admin-sidebar's gh#286 fix), so this stays unguarded
76
+ // too (behavior-preserving, not a bug fix bundled into this extraction).
77
+ #persist = attachSidebarCollapsePersist(this, { prefix: 'adia-chat-sidebar' });
65
78
 
66
79
  connected() {
67
- this.#restoreFromStorage();
80
+ this.#persist.restoreFromStorage();
68
81
  if (this.resizable) this.#setupResizeHandle();
69
82
  this.#setupChildResizeObserver();
70
- this.#syncCollapsedFromWidth();
83
+ this.#persist.syncCollapsedFromWidth();
71
84
  }
72
85
 
73
86
  disconnected() {
@@ -84,68 +97,17 @@ class ChatSidebar extends UIElement {
84
97
  * Returns the new collapsed value.
85
98
  */
86
99
  toggle() {
87
- if (this.collapsed) {
88
- this.expand();
89
- } else {
90
- this.collapse();
91
- }
92
- return this.collapsed;
100
+ return this.#persist.toggle();
93
101
  }
94
102
 
95
103
  /** Collapse to the snap-floor width. Persists to localStorage. */
96
104
  collapse() {
97
- if (this.collapsed) return;
98
- // Remember current expanded width before collapsing
99
- const currentWidth = this.style.width || getComputedStyle(this).width;
100
- if (parseFloat(currentWidth) > SNAP_THRESHOLD) {
101
- this.#previousExpandedWidth = currentWidth;
102
- }
103
- const minW = this.minWidth || getComputedStyle(this).minWidth;
104
- this.style.width = minW;
105
- this.#persist(minW);
106
- this.collapsed = true;
107
- this.#dispatchToggle(false);
105
+ this.#persist.collapse();
108
106
  }
109
107
 
110
108
  /** Restore to the previous expanded width (or default if none). */
111
109
  expand() {
112
- if (!this.collapsed) return;
113
- const restoreWidth = this.#previousExpandedWidth || '';
114
- this.style.width = restoreWidth;
115
- this.#persist(restoreWidth);
116
- this.collapsed = false;
117
- this.#dispatchToggle(true);
118
- }
119
-
120
- // ── Persistence ──
121
-
122
- #storageKey() {
123
- const id = this.name || this.getAttribute('slot') || 'default';
124
- return `adia-chat-sidebar-${id}`;
125
- }
126
-
127
- #persist(width) {
128
- try { localStorage.setItem(this.#storageKey(), width); } catch {}
129
- }
130
-
131
- #restoreFromStorage() {
132
- try {
133
- const saved = localStorage.getItem(this.#storageKey());
134
- if (!saved) return;
135
- this.style.width = saved;
136
- // Only treat as "previous expanded" if actually expanded
137
- const w = parseFloat(saved);
138
- if (!isNaN(w) && w > SNAP_THRESHOLD) {
139
- this.#previousExpandedWidth = saved;
140
- }
141
- } catch {}
142
- }
143
-
144
- // ── Reflect [collapsed] from current measured width ──
145
-
146
- #syncCollapsedFromWidth() {
147
- const w = this.getBoundingClientRect().width;
148
- this.collapsed = w <= SNAP_THRESHOLD;
110
+ this.#persist.expand();
149
111
  }
150
112
 
151
113
  // ── Resize drag handle ──
@@ -189,8 +151,8 @@ class ChatSidebar extends UIElement {
189
151
  this.style.width = `${SNAP_MIN_USABLE}px`;
190
152
  }
191
153
 
192
- this.#persist(this.style.width);
193
- this.#syncCollapsedFromWidth();
154
+ this.#persist.persist(this.style.width);
155
+ this.#persist.syncCollapsedFromWidth();
194
156
  this.dispatchEvent(new CustomEvent('sidebar-resize', {
195
157
  bubbles: true,
196
158
  detail: { name: this.name || slot, width: this.getBoundingClientRect().width },
@@ -220,15 +182,6 @@ class ChatSidebar extends UIElement {
220
182
  });
221
183
  this.#childRO.observe(this);
222
184
  }
223
-
224
- // ── Internal — dispatch the toggle event in a consistent shape ──
225
-
226
- #dispatchToggle(expanded) {
227
- this.dispatchEvent(new CustomEvent('sidebar-toggle', {
228
- bubbles: true,
229
- detail: { name: this.name || this.getAttribute('slot') || 'default', expanded },
230
- }));
231
- }
232
185
  }
233
186
 
234
187
  defineIfFree('chat-sidebar', ChatSidebar);
@@ -38,7 +38,7 @@ var VS=Object.defineProperty;var ee=(i,e,t)=>()=>{if(t)throw t[0];try{return i&&
38
38
  `+c+" Compute the full attr value as a single expression and interpolate the whole.")}continue}let l=+o[1],a=s.name;a[0]==="@"?(r.removeAttribute(a),t[l]={t:"e",n:r,name:a.slice(1),c:void 0,_fx:null}):a[0]==="."?(r.removeAttribute(a),t[l]={t:"p",n:r,name:Wu(r,a.slice(1)),c:void 0,_fx:null,_resolved:!1}):a[0]==="?"?(r.removeAttribute(a),console.warn(`[template] Lit-style boolean attribute "${a}=" is not supported.
39
39
  Element: <${r.tagName.toLowerCase()}>
40
40
  Use .${a.slice(1)}=\${value} (property binding) instead \u2014 the primitive reflects the property to the DOM attribute for you.
41
- See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),t[l]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):t[l]={t:"a",n:r,name:a,c:void 0,_fx:null}}return t}function as(i){for(let e of i)e&&e._fx&&(e._fx(),e._fx=null)}function Bl(i){if(i.n.nodeType===1&&i.n[Wl])return i.n;let e=document.createElement("span");return e.style.display="contents",e.setAttribute("role","presentation"),e[Wl]=!0,i.n.replaceWith(e),i.n=e,e}var Iu=i=>i!=null&&typeof i=="object"&&i.strings,Nu=i=>typeof i=="function"||i!=null&&typeof i.handleEvent=="function";function ql(i,e){if(e!==i.c){if(i.t==="n")if(e!=null&&e._directive)e._commit(Bl(i));else if(Iu(e))ln(e,Bl(i));else if(Array.isArray(e)){let t=Bl(i);t.replaceChildren();for(let n of e)if(Iu(n)){let r=document.createElement("span");r.style.display="contents",r.setAttribute("role","presentation"),t.appendChild(r),ln(n,r)}else t.appendChild(document.createTextNode(n??""))}else if(Dl(e))i.n.replaceWith(e),i.n=e;else if(i.n[Wl]){let t=document.createTextNode(e??"");i.n.replaceWith(t),i.n=t}else i.n.textContent=e??"";else if(i.t==="a")e==null||e===!1?i.n.removeAttribute(i.name):i.n.setAttribute(i.name,e===!0?"":e);else if(i.t==="p"){if(!i._resolved){let t=Wu(i.n,i.name);t!==i.name&&(i.name=t),i._resolved=!0}i.n[i.name]=e}else i.t==="e"&&(Nu(i.c)&&i.n.removeEventListener(i.name,i.c),Nu(e)&&i.n.addEventListener(i.name,e));i.c=e}}function FS(i,e){for(let t=0;t<i.length;t++){let n=i[t];if(!n)continue;let r=e[t],s=n.t!=="e"&&typeof r=="function",o=!s&&n.t!=="e"&&Yl(r);if(n._fx&&!s&&!o&&(n._fx(),n._fx=null),s){n._fx||(n._fx=xi(()=>ql(n,r())));continue}if(o){n._fx||(n._fx=xi(()=>ql(n,r.value)));continue}ql(n,r)}}function HS(i,e,t){return{_directive:!0,_commit(n){let r=n[an]||new Map,s=new Map,o=[];for(let a=0;a<i.length;a++){let h=e(i[a],a);if(s.has(h))continue;o.push(h);let c=t(i[a],a);if(r.has(h)){let f=r.get(h);ln(c,f),s.set(h,f)}else{let f=document.createElement("span");f.style.display="contents",f.setAttribute("role","presentation"),ln(c,f),s.set(h,f)}}for(let[a,h]of r)s.has(a)||(h._i&&as(h._i.p),h.remove());let l=null;for(let a=o.length-1;a>=0;a--){let h=s.get(o[a]);(h.nextSibling!==l||h.parentNode!==n)&&n.insertBefore(h,l),l=h}n[an]=s}}}var In=new Map;function KS(i,e){return e===`data-${i}`||e.startsWith(`data-${i}-`)}function Gu(i,e){return i===e||i.startsWith(`${e}-`)||e.startsWith(`${i}-`)}function JS(i){let e=[i.name,...i.prefixes||[]],t=[...i.attributes||[],...i.config||[]].filter(n=>!e.some(r=>KS(r,n)));if(t.length>0)throw new Error(`Trait "${i.name}" declares attribute(s) outside its owned data-* namespace: ${t.join(", ")}. A trait owns "data-${i.name}" / "data-${i.name}-*" by default; register any other prefix via defineTrait({ ..., prefixes: [...] }) (ADR-0060) or rename the attribute.`)}function e1(i){let e=i.prefixes||[];for(let[t,n]of In){if(t===i.name)continue;let r=n.schema,s=[r.name,...r.prefixes||[]];for(let o of e)for(let l of s)if(Gu(o,l))throw new Error(`Trait "${i.name}"'s registered prefix "${o}" overlaps trait "${r.name}"'s owned namespace ("${l}"). Registered prefixes must be globally exclusive across the trait registry (ADR-0060).`);for(let o of r.prefixes||[])if(Gu(o,i.name))throw new Error(`Trait "${i.name}"'s name overlaps trait "${r.name}"'s registered prefix "${o}". Registered prefixes must be globally exclusive across the trait registry (ADR-0060).`)}}var Uu=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function dT(i){if(!i.name)throw new Error("Trait requires a name");if(!i.setup)throw new Error(`Trait "${i.name}" requires a setup function`);if(!i.category)throw new Error(`Trait "${i.name}" requires a category`);if(!Uu.has(i.category))throw new Error(`Trait "${i.name}" has unknown category "${i.category}". Known: ${[...Uu].join(", ")}`);if(!i.description)throw new Error(`Trait "${i.name}" requires a description`);JS(i),e1(i);let e=Object.freeze({name:i.name,category:i.category,description:i.description,attributes:Object.freeze(i.attributes||[]),events:Object.freeze(i.events||[]),config:Object.freeze(i.config||[]),prefixes:Object.freeze(i.prefixes||[])});function t(){let n=null;return{schema:e,connect(r,s){n=i.setup({host:r,...s||{}})},disconnect(r){n&&(n(),n=null);for(let s of e.attributes)r.hasAttribute(s)&&(console.warn(`Trait "${e.name}": attribute "${s}" still present after disconnect`),r.removeAttribute(s))}}}return t.schema=e,In.set(i.name,t),t}function Fu(i){return In.get(i)||null}function OT(i){return In.get(i)?.schema||null}function pT(){return[...In.keys()]}var Il=Symbol(),Nn=Symbol();function t1(i,e){i[Nn]=new Map,i[Il]=new Map;for(let[t,n]of Object.entries(e)){let r=n.attribute??t.toLowerCase(),s=n.type??String,o=Object.prototype.hasOwnProperty.call(i,t),l=o?i[t]:void 0;o&&delete i[t];let a=on(n.default??void 0);i[Il].set(t,a),Object.defineProperty(i,t,{get(){return a.value},set(h){let c=a.peek();Object.is(c,h)||(i[Nn].set(t,c),a.value=h,n.reflect&&n1(i,r,h,s))},configurable:!0}),o&&(a.value=l)}}var i1=Object.freeze({setFormValue(){},setValidity(){},checkValidity(){return!0},reportValidity(){return!0},get form(){return null},get labels(){return[]},get validity(){return{}},get validationMessage(){return""},get willValidate(){return!1}});function n1(i,e,t,n){n===Boolean?t?i.setAttribute(e,""):i.removeAttribute(e):t==null?i.removeAttribute(e):i.setAttribute(e,String(t))}var Hu=(i,e)=>e===Boolean?i!==null:e===Number?i===null?null:+i:i;function r1(i){if(Object.hasOwn(i,"_sa"))return;i._sa=!0;let e=i.styles;if(!e||!("adoptedStyleSheets"in document))return;let t=Array.isArray(e)?e:[e];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...t.filter(n=>!document.adoptedStyleSheets.includes(n))]}function Ku(i){if(Object.hasOwn(i,"_pp"))return;i._pp={};let e=i.parts;if(e)for(let[t,n]of Object.entries(e)){let r=document.createElement("template");r.innerHTML=n,i._pp[t]=r.content.firstElementChild}}var hn=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let e=Object.entries(this.properties).map(([t,n])=>n.attribute??t.toLowerCase());return e.includes("traits")?e:[...e,"traits"]}#t=[];#r=[];#e=[];#i=null;#o=null;#n=null;#l=on(0);constructor(){super(),this.internals=typeof this.attachInternals=="function"?this.attachInternals():i1,t1(this,this.constructor.properties)}connectedCallback(){let e=this.constructor;e._tag||(e._tag=this.localName),r1(e),Ku(e),os(()=>{for(let[t,n]of Object.entries(e.properties)){let r=n.attribute??t.toLowerCase();this.hasAttribute(r)?this[t]=Hu(this.getAttribute(r),n.type??String):n.reflect&&n.type===Boolean&&this[t]===!0&&this.setAttribute(r,"")}}),os(()=>this.connected()),this.#t.push(xi(()=>{for(let n of this[Il].values())n.value;this.#l.value;let t=e.template(this);if(t&&ln(t,this),this.render(),this[Nn].size){let n=new Map(this[Nn]);this[Nn].clear(),this.updated(n)}},{host:this.localName,onError:this.onError?t=>this.onError(t):null})),this.#n||(this.#n=new Set);for(let t of e.traits)this.#a(t);this.#h(),this.#i&&this.#s()}disconnectedCallback(){this._i&&as(this._i.p);for(let e of this.#t)e();this.#t.length=0;for(let e of this.#e)e.value=void 0;this.#e.length=0;for(let e of this.#r)e.disconnect(this);this.#r.length=0,this.#n?.clear(),this.#o?.(),this.#o=null,this.#i?.disconnect?.(this),this.disconnected()}#s(){let e=this.#i;e.connect?.(this),this.#o=e.subscribe?.(()=>{this.#l.value++})}get controller(){return this.#i}set controller(e){this.#o?.(),this.#o=null,this.#i?.disconnect?.(this),this.#i=e,e&&this.isConnected&&this.#s()}#a(e,{declarative:t=!1}={}){this.#n.add(e);let n=e();n.connect(this,{host:this,signal:on,computed:Vl,effect:xi}),t&&(n._declarative=!0),this.#r.push(n)}addTrait(e){return this.#n||(this.#n=new Set),this.#n.has(e)?this:(this.#a(e),this)}#h(){let e=this.getAttribute("traits");if(e)for(let t of e.split(/\s+/).filter(Boolean)){let n=Fu(t);if(!n){console.warn(`<${this.localName}> traits="${t}" \u2014 trait not found. Did you forget to import it?`);continue}this.#n.has(n)||this.#a(n,{declarative:!0})}}#c(){if(!this.#n)return;let e=[];for(let t of this.#r)if(t._declarative){t.disconnect(this);for(let n of this.#n)if(n.schema?.name&&t.schema?.name===n.schema.name){this.#n.delete(n);break}}else e.push(t);this.#r.length=0,this.#r.push(...e),this.#h()}attributeChangedCallback(e,t,n){if(e==="traits"){this.isConnected&&this.#c();return}for(let[r,s]of Object.entries(this.constructor.properties))if((s.attribute??r.toLowerCase())===e){this[r]=Hu(n,s.type??String);break}}static template=()=>null;static create(e={}){let t=this._tag??customElements.getName?.(this);if(!t)throw new Error("Component not registered");let n=document.createElement(t);for(let[r,s]of Object.entries(e))n[r]=s;return n}signal(e){let t=on(e);return this.#e.push(t),t}ensure(e){for(let s of this.children)if(s.getAttribute("slot")===e)return s;let t=this.#f(e);if(t)return t;Ku(this.constructor);let n=this.constructor._pp?.[e];if(!n)return null;let r=n.cloneNode(!0);return r._uiPart=!0,this.appendChild(r),r}drop(e){for(let n of this.children)if(n.getAttribute("slot")===e){n.remove();return}let t=this.#f(e);t&&t.remove()}#f(e){for(let t of this.querySelectorAll(`[slot="${e}"]`)){let n=t.parentElement,r=!0;for(;n&&n!==this;){if(n.localName.includes("-")){r=!1;break}n=n.parentElement}if(r&&n===this)return t}return null}reconcile(e,t,n,r){let s=e[an]||new Map,o=new Map,l=[];for(let h=0;h<t.length;h++){let c=t[h],f=n(c,h);if(o.has(f))continue;let u=s.get(f);u?r(c,h,u):u=r(c,h,null),o.set(f,u),l.push(f)}for(let[h,c]of s)o.has(h)||c.remove();let a=null;for(let h=l.length-1;h>=0;h--){let c=o.get(l[h]);(c.nextSibling!==a||c.parentNode!==e)&&e.insertBefore(c,a),a=c}e[an]=o}connected(){}render(){}disconnected(){}updated(e){}};var s1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},Ju=i=>i.replace(/[&<>"]/g,e=>s1[e]);function Nl(i){let e=i.split(`
41
+ See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),t[l]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):t[l]={t:"a",n:r,name:a,c:void 0,_fx:null}}return t}function as(i){for(let e of i)e&&e._fx&&(e._fx(),e._fx=null)}function Bl(i){if(i.n.nodeType===1&&i.n[Wl])return i.n;let e=document.createElement("span");return e.style.display="contents",e.setAttribute("role","presentation"),e[Wl]=!0,i.n.replaceWith(e),i.n=e,e}var Iu=i=>i!=null&&typeof i=="object"&&i.strings,Nu=i=>typeof i=="function"||i!=null&&typeof i.handleEvent=="function";function ql(i,e){if(e!==i.c){if(i.t==="n")if(e!=null&&e._directive)e._commit(Bl(i));else if(Iu(e))ln(e,Bl(i));else if(Array.isArray(e)){let t=Bl(i);t.replaceChildren();for(let n of e)if(Iu(n)){let r=document.createElement("span");r.style.display="contents",r.setAttribute("role","presentation"),t.appendChild(r),ln(n,r)}else t.appendChild(document.createTextNode(n??""))}else if(Dl(e))i.n.replaceWith(e),i.n=e;else if(i.n[Wl]){let t=document.createTextNode(e??"");i.n.replaceWith(t),i.n=t}else i.n.textContent=e??"";else if(i.t==="a")e==null||e===!1?i.n.removeAttribute(i.name):i.n.setAttribute(i.name,e===!0?"":e);else if(i.t==="p"){if(!i._resolved){let t=Wu(i.n,i.name);t!==i.name&&(i.name=t),i._resolved=!0}i.n[i.name]=e}else i.t==="e"&&(Nu(i.c)&&i.n.removeEventListener(i.name,i.c),Nu(e)&&i.n.addEventListener(i.name,e));i.c=e}}function FS(i,e){for(let t=0;t<i.length;t++){let n=i[t];if(!n)continue;let r=e[t],s=n.t!=="e"&&typeof r=="function",o=!s&&n.t!=="e"&&Yl(r);if(n._fx&&!s&&!o&&(n._fx(),n._fx=null),s){n._fx||(n._fx=xi(()=>ql(n,r())));continue}if(o){n._fx||(n._fx=xi(()=>ql(n,r.value)));continue}ql(n,r)}}function HS(i,e,t){return{_directive:!0,_commit(n){let r=n[an]||new Map,s=new Map,o=[];for(let a=0;a<i.length;a++){let h=e(i[a],a);if(s.has(h))continue;o.push(h);let c=t(i[a],a);if(r.has(h)){let f=r.get(h);ln(c,f),s.set(h,f)}else{let f=document.createElement("span");f.style.display="contents",f.setAttribute("role","presentation"),ln(c,f),s.set(h,f)}}for(let[a,h]of r)s.has(a)||(h._i&&as(h._i.p),h.remove());let l=null;for(let a=o.length-1;a>=0;a--){let h=s.get(o[a]);(h.nextSibling!==l||h.parentNode!==n)&&n.insertBefore(h,l),l=h}n[an]=s}}}var In=new Map;function KS(i,e){return e===`data-${i}`||e.startsWith(`data-${i}-`)}function Gu(i,e){return i===e||i.startsWith(`${e}-`)||e.startsWith(`${i}-`)}function JS(i){let e=[i.name,...i.prefixes||[]],t=[...i.attributes||[],...i.config||[]].filter(n=>!e.some(r=>KS(r,n)));if(t.length>0)throw new Error(`Trait "${i.name}" declares attribute(s) outside its owned data-* namespace: ${t.join(", ")}. A trait owns "data-${i.name}" / "data-${i.name}-*" by default; register any other prefix via defineTrait({ ..., prefixes: [...] }) (ADR-0060) or rename the attribute.`)}function e1(i){let e=i.prefixes||[];for(let[t,n]of In){if(t===i.name)continue;let r=n.schema,s=[r.name,...r.prefixes||[]];for(let o of e)for(let l of s)if(Gu(o,l))throw new Error(`Trait "${i.name}"'s registered prefix "${o}" overlaps trait "${r.name}"'s owned namespace ("${l}"). Registered prefixes must be globally exclusive across the trait registry (ADR-0060).`);for(let o of r.prefixes||[])if(Gu(o,i.name))throw new Error(`Trait "${i.name}"'s name overlaps trait "${r.name}"'s registered prefix "${o}". Registered prefixes must be globally exclusive across the trait registry (ADR-0060).`)}}var Uu=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function dT(i){if(!i.name)throw new Error("Trait requires a name");if(!i.setup)throw new Error(`Trait "${i.name}" requires a setup function`);if(!i.category)throw new Error(`Trait "${i.name}" requires a category`);if(!Uu.has(i.category))throw new Error(`Trait "${i.name}" has unknown category "${i.category}". Known: ${[...Uu].join(", ")}`);if(!i.description)throw new Error(`Trait "${i.name}" requires a description`);JS(i),e1(i);let e=Object.freeze({name:i.name,category:i.category,description:i.description,attributes:Object.freeze(i.attributes||[]),events:Object.freeze(i.events||[]),config:Object.freeze(i.config||[]),prefixes:Object.freeze(i.prefixes||[])});function t(){let n=null;return{schema:e,connect(r,s){n=i.setup({host:r,...s||{}})},disconnect(r){n&&(n(),n=null);for(let s of e.attributes)r.hasAttribute(s)&&(console.warn(`Trait "${e.name}": attribute "${s}" still present after disconnect`),r.removeAttribute(s))}}}return t.schema=e,In.set(i.name,t),t}function Fu(i){return In.get(i)||null}function OT(i){return In.get(i)?.schema||null}function pT(){return[...In.keys()]}var Il=Symbol(),Nn=Symbol();function t1(i,e){i[Nn]=new Map,i[Il]=new Map;for(let[t,n]of Object.entries(e)){let r=n.attribute??t.toLowerCase(),s=n.type??String,o=Object.prototype.hasOwnProperty.call(i,t),l=o?i[t]:void 0;o&&delete i[t];let a=on(n.default??void 0);i[Il].set(t,a),Object.defineProperty(i,t,{get(){return a.value},set(h){let c=a.peek();Object.is(c,h)||(i[Nn].set(t,c),a.value=h,n.reflect&&n1(i,r,h,s))},configurable:!0}),o&&(a.value=l)}}var i1=Object.freeze({setFormValue(){},setValidity(){},checkValidity(){return!0},reportValidity(){return!0},get form(){return null},get labels(){return[]},get validity(){return{}},get validationMessage(){return""},get willValidate(){return!1}});function n1(i,e,t,n){n===Boolean?t?i.setAttribute(e,""):i.removeAttribute(e):t==null?i.removeAttribute(e):i.setAttribute(e,String(t))}var Hu=(i,e)=>e===Boolean?i!==null&&i!=="false":e===Number?i===null?null:+i:i;function r1(i){if(Object.hasOwn(i,"_sa"))return;i._sa=!0;let e=i.styles;if(!e||!("adoptedStyleSheets"in document))return;let t=Array.isArray(e)?e:[e];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...t.filter(n=>!document.adoptedStyleSheets.includes(n))]}function Ku(i){if(Object.hasOwn(i,"_pp"))return;i._pp={};let e=i.parts;if(e)for(let[t,n]of Object.entries(e)){let r=document.createElement("template");r.innerHTML=n,i._pp[t]=r.content.firstElementChild}}var hn=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let e=Object.entries(this.properties).map(([t,n])=>n.attribute??t.toLowerCase());return e.includes("traits")?e:[...e,"traits"]}#t=[];#r=[];#e=[];#i=null;#o=null;#n=null;#l=on(0);constructor(){super(),this.internals=typeof this.attachInternals=="function"?this.attachInternals():i1,t1(this,this.constructor.properties)}connectedCallback(){let e=this.constructor;e._tag||(e._tag=this.localName),r1(e),Ku(e),os(()=>{for(let[t,n]of Object.entries(e.properties)){let r=n.attribute??t.toLowerCase();this.hasAttribute(r)?this[t]=Hu(this.getAttribute(r),n.type??String):n.reflect&&n.type===Boolean&&this[t]===!0&&this.setAttribute(r,"")}}),os(()=>this.connected()),this.#t.push(xi(()=>{for(let n of this[Il].values())n.value;this.#l.value;let t=e.template(this);if(t&&ln(t,this),this.render(),this[Nn].size){let n=new Map(this[Nn]);this[Nn].clear(),this.updated(n)}},{host:this.localName,onError:this.onError?t=>this.onError(t):null})),this.#n||(this.#n=new Set);for(let t of e.traits)this.#a(t);this.#h(),this.#i&&this.#s()}disconnectedCallback(){this._i&&as(this._i.p);for(let e of this.#t)e();this.#t.length=0;for(let e of this.#e)e.value=void 0;this.#e.length=0;for(let e of this.#r)e.disconnect(this);this.#r.length=0,this.#n?.clear(),this.#o?.(),this.#o=null,this.#i?.disconnect?.(this),this.disconnected()}#s(){let e=this.#i;e.connect?.(this),this.#o=e.subscribe?.(()=>{this.#l.value++})}get controller(){return this.#i}set controller(e){this.#o?.(),this.#o=null,this.#i?.disconnect?.(this),this.#i=e,e&&this.isConnected&&this.#s()}#a(e,{declarative:t=!1}={}){this.#n.add(e);let n=e();n.connect(this,{host:this,signal:on,computed:Vl,effect:xi}),t&&(n._declarative=!0),this.#r.push(n)}addTrait(e){return this.#n||(this.#n=new Set),this.#n.has(e)?this:(this.#a(e),this)}#h(){let e=this.getAttribute("traits");if(e)for(let t of e.split(/\s+/).filter(Boolean)){let n=Fu(t);if(!n){console.warn(`<${this.localName}> traits="${t}" \u2014 trait not found. Did you forget to import it?`);continue}this.#n.has(n)||this.#a(n,{declarative:!0})}}#c(){if(!this.#n)return;let e=[];for(let t of this.#r)if(t._declarative){t.disconnect(this);for(let n of this.#n)if(n.schema?.name&&t.schema?.name===n.schema.name){this.#n.delete(n);break}}else e.push(t);this.#r.length=0,this.#r.push(...e),this.#h()}attributeChangedCallback(e,t,n){if(e==="traits"){this.isConnected&&this.#c();return}for(let[r,s]of Object.entries(this.constructor.properties))if((s.attribute??r.toLowerCase())===e){this[r]=Hu(n,s.type??String);break}}static template=()=>null;static create(e={}){let t=this._tag??customElements.getName?.(this);if(!t)throw new Error("Component not registered");let n=document.createElement(t);for(let[r,s]of Object.entries(e))n[r]=s;return n}signal(e){let t=on(e);return this.#e.push(t),t}ensure(e){for(let s of this.children)if(s.getAttribute("slot")===e)return s;let t=this.#f(e);if(t)return t;Ku(this.constructor);let n=this.constructor._pp?.[e];if(!n)return null;let r=n.cloneNode(!0);return r._uiPart=!0,this.appendChild(r),r}drop(e){for(let n of this.children)if(n.getAttribute("slot")===e){n.remove();return}let t=this.#f(e);t&&t.remove()}#f(e){for(let t of this.querySelectorAll(`[slot="${e}"]`)){let n=t.parentElement,r=!0;for(;n&&n!==this;){if(n.localName.includes("-")){r=!1;break}n=n.parentElement}if(r&&n===this)return t}return null}reconcile(e,t,n,r){let s=e[an]||new Map,o=new Map,l=[];for(let h=0;h<t.length;h++){let c=t[h],f=n(c,h);if(o.has(f))continue;let u=s.get(f);u?r(c,h,u):u=r(c,h,null),o.set(f,u),l.push(f)}for(let[h,c]of s)o.has(h)||c.remove();let a=null;for(let h=l.length-1;h>=0;h--){let c=o.get(l[h]);(c.nextSibling!==a||c.parentNode!==e)&&e.insertBefore(c,a),a=c}e[an]=o}connected(){}render(){}disconnected(){}updated(e){}};var s1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},Ju=i=>i.replace(/[&<>"]/g,e=>s1[e]);function Nl(i){let e=i.split(`
42
42
  `),t=[],n=0;for(;n<e.length;){let r=e[n],s=r.match(/^```(\w*)/);if(s){let a=s[1],h=[];for(n++;n<e.length&&!e[n].startsWith("```");)h.push(Ju(e[n])),n++;n++;let c=h.join(`
43
43
  `);t.push(a?`<code-ui language="${a}">${c}</code-ui>`:`<pre><code>${c}</code></pre>`);continue}if(!r.trim()){n++;continue}let o=r.match(/^(#{1,6})\s+(.+)/);if(o){let a=o[1].length;t.push(`<h${a}>${hs(o[2])}</h${a}>`),n++;continue}if(/^[-*]\s/.test(r)){let a=[];for(;n<e.length&&/^[-*]\s/.test(e[n]);)a.push(`<li>${hs(e[n].replace(/^[-*]\s/,""))}</li>`),n++;t.push(`<ul>${a.join("")}</ul>`);continue}if(/^\d+\.\s/.test(r)){let a=[];for(;n<e.length&&/^\d+\.\s/.test(e[n]);)a.push(`<li>${hs(e[n].replace(/^\d+\.\s/,""))}</li>`),n++;t.push(`<ol>${a.join("")}</ol>`);continue}let l=[];for(;n<e.length&&e[n].trim()&&!/^```|^#{1,6}\s|^[-*]\s|^\d+\.\s/.test(e[n]);)l.push(e[n]),n++;t.push(`<p>${hs(l.join(" "))}</p>`)}return t.join(`
44
44
  `)}var o1=i=>`\0CODE${i}\0`,l1=/\0CODE(\d+)\0/g;function hs(i){let e=Ju(i),t=[],n=e.replace(/`([^`]+)`/g,(r,s)=>{let o=t.length;return t.push(s),o1(o)});return n=n.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/_(.+?)_/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),n=n.replace(l1,(r,s)=>`<code>${t[Number(s)]}</code>`),n}var eT=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),tT={js:"javascript",md:"markdown",yml:"yaml"};function Lu(i){if(!i)return"";let e=String(i).toLowerCase();return tT[e]??e}var ts=class i extends hn{static formAssociated=!0;static properties={language:{type:String,default:"",reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},text:{type:String,default:"",reflect:!0},lineNumbers:{type:Boolean,default:!1,reflect:!0,attribute:"line-numbers"},editable:{type:Boolean,default:!1,reflect:!0},bare:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#r=null;#e=null;#i=0;#o=!1;#n=null;#l="";#s=null;#a=()=>this.#b();connected(){this.#i+=1,!this.inline&&!this.querySelector(":scope > pre")&&this.#h(),this.#t=this.querySelector(':scope > header [slot="copy"]'),this.#t&&this.#t.addEventListener("click",this.#a);let e=Lu(this.language),t=this.hasAttribute("data-line-states")||e==="diff";!this.inline&&!t&&(eT.has(e)||this.editable)&&this.#f()}disconnected(){this.#i+=1,this.#r!=null&&(clearTimeout(this.#r),this.#r=null),this.#t&&(this.#t.removeEventListener("click",this.#a),this.#t=null),this.#e&&(this.#e.destroy(),this.#e=null)}#h(){let e=this.querySelector(":scope > template"),t=this.text?this.text.trim():e?i.#c(e.innerHTML):(this.textContent||"").trim();if(this.textContent="",!this.bare){let a=document.createElement("header"),h=document.createElement("span");h.setAttribute("slot","label"),h.textContent=this.language||"code",a.appendChild(h);let c=document.createElement("div");c.setAttribute("role","button"),c.setAttribute("tabindex","0"),c.setAttribute("slot","copy"),c.textContent="Copy",a.appendChild(c),this.appendChild(a)}let n=document.createElement("pre"),r=document.createElement("code"),s=Lu(this.language),o=this.getAttribute("data-line-states");if(o!=null||s==="diff"){r.setAttribute("data-line-state-mode",""),this.lineNumbers&&r.setAttribute("data-line-numbers","");let a=o?.split(",").map(c=>c.trim())??null;t.split(`
@@ -7,4 +7,4 @@ function me(e,t){customElements.define(e,t)}function R(e,t){return customElement
7
7
  `+u+" Compute the full attr value as a single expression and interpolate the whole.")}continue}let c=+a[1],s=i.name;s[0]==="@"?(o.removeAttribute(s),n[c]={t:"e",n:o,name:s.slice(1),c:void 0,_fx:null}):s[0]==="."?(o.removeAttribute(s),n[c]={t:"p",n:o,name:W(o,s.slice(1)),c:void 0,_fx:null,_resolved:!1}):s[0]==="?"?(o.removeAttribute(s),console.warn(`[template] Lit-style boolean attribute "${s}=" is not supported.
8
8
  Element: <${o.tagName.toLowerCase()}>
9
9
  Use .${s.slice(1)}=\${value} (property binding) instead \u2014 the primitive reflects the property to the DOM attribute for you.
10
- See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),n[c]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):n[c]={t:"a",n:o,name:s,c:void 0,_fx:null}}return n}function T(e){for(let t of e)t&&t._fx&&(t._fx(),t._fx=null)}function j(e){if(e.n.nodeType===1&&e.n[k])return e.n;let t=document.createElement("span");return t.style.display="contents",t.setAttribute("role","presentation"),t[k]=!0,e.n.replaceWith(t),e.n=t,t}var V=e=>e!=null&&typeof e=="object"&&e.strings,z=e=>typeof e=="function"||e!=null&&typeof e.handleEvent=="function";function L(e,t){if(t!==e.c){if(e.t==="n")if(t!=null&&t._directive)t._commit(j(e));else if(V(t))g(t,j(e));else if(Array.isArray(t)){let n=j(e);n.replaceChildren();for(let r of t)if(V(r)){let o=document.createElement("span");o.style.display="contents",o.setAttribute("role","presentation"),n.appendChild(o),g(r,o)}else n.appendChild(document.createTextNode(r??""))}else if(M(t))e.n.replaceWith(t),e.n=t;else if(e.n[k]){let n=document.createTextNode(t??"");e.n.replaceWith(n),e.n=n}else e.n.textContent=t??"";else if(e.t==="a")t==null||t===!1?e.n.removeAttribute(e.name):e.n.setAttribute(e.name,t===!0?"":t);else if(e.t==="p"){if(!e._resolved){let n=W(e.n,e.name);n!==e.name&&(e.name=n),e._resolved=!0}e.n[e.name]=t}else e.t==="e"&&(z(e.c)&&e.n.removeEventListener(e.name,e.c),z(t)&&e.n.addEventListener(e.name,t));e.c=t}}function se(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(!r)continue;let o=t[n],i=r.t!=="e"&&typeof o=="function",a=!i&&r.t!=="e"&&v(o);if(r._fx&&!i&&!a&&(r._fx(),r._fx=null),i){r._fx||(r._fx=p(()=>L(r,o())));continue}if(a){r._fx||(r._fx=p(()=>L(r,o.value)));continue}L(r,o)}}function ae(e,t,n){return{_directive:!0,_commit(r){let o=r[y]||new Map,i=new Map,a=[];for(let s=0;s<e.length;s++){let l=t(e[s],s);if(i.has(l))continue;a.push(l);let u=n(e[s],s);if(o.has(l)){let d=o.get(l);g(u,d),i.set(l,d)}else{let d=document.createElement("span");d.style.display="contents",d.setAttribute("role","presentation"),g(u,d),i.set(l,d)}}for(let[s,l]of o)i.has(s)||(l._i&&T(l._i.p),l.remove());let c=null;for(let s=a.length-1;s>=0;s--){let l=i.get(a[s]);(l.nextSibling!==c||l.parentNode!==r)&&r.insertBefore(l,c),c=l}r[y]=i}}}var x=new Map;function le(e,t){return t===`data-${e}`||t.startsWith(`data-${e}-`)}function U(e,t){return e===t||e.startsWith(`${t}-`)||t.startsWith(`${e}-`)}function ce(e){let t=[e.name,...e.prefixes||[]],n=[...e.attributes||[],...e.config||[]].filter(r=>!t.some(o=>le(o,r)));if(n.length>0)throw new Error(`Trait "${e.name}" declares attribute(s) outside its owned data-* namespace: ${n.join(", ")}. A trait owns "data-${e.name}" / "data-${e.name}-*" by default; register any other prefix via defineTrait({ ..., prefixes: [...] }) (ADR-0060) or rename the attribute.`)}function ue(e){let t=e.prefixes||[];for(let[n,r]of x){if(n===e.name)continue;let o=r.schema,i=[o.name,...o.prefixes||[]];for(let a of t)for(let c of i)if(U(a,c))throw new Error(`Trait "${e.name}"'s registered prefix "${a}" overlaps trait "${o.name}"'s owned namespace ("${c}"). Registered prefixes must be globally exclusive across the trait registry (ADR-0060).`);for(let a of o.prefixes||[])if(U(a,e.name))throw new Error(`Trait "${e.name}"'s name overlaps trait "${o.name}"'s registered prefix "${a}". Registered prefixes must be globally exclusive across the trait registry (ADR-0060).`)}}var G=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function _e(e){if(!e.name)throw new Error("Trait requires a name");if(!e.setup)throw new Error(`Trait "${e.name}" requires a setup function`);if(!e.category)throw new Error(`Trait "${e.name}" requires a category`);if(!G.has(e.category))throw new Error(`Trait "${e.name}" has unknown category "${e.category}". Known: ${[...G].join(", ")}`);if(!e.description)throw new Error(`Trait "${e.name}" requires a description`);ce(e),ue(e);let t=Object.freeze({name:e.name,category:e.category,description:e.description,attributes:Object.freeze(e.attributes||[]),events:Object.freeze(e.events||[]),config:Object.freeze(e.config||[]),prefixes:Object.freeze(e.prefixes||[])});function n(){let r=null;return{schema:t,connect(o,i){r=e.setup({host:o,...i||{}})},disconnect(o){r&&(r(),r=null);for(let i of t.attributes)o.hasAttribute(i)&&(console.warn(`Trait "${t.name}": attribute "${i}" still present after disconnect`),o.removeAttribute(i))}}}return n.schema=t,x.set(e.name,n),n}function K(e){return x.get(e)||null}function Ne(e){return x.get(e)?.schema||null}function Te(){return[...x.keys()]}var P=Symbol(),w=Symbol();function fe(e,t){e[w]=new Map,e[P]=new Map;for(let[n,r]of Object.entries(t)){let o=r.attribute??n.toLowerCase(),i=r.type??String,a=Object.prototype.hasOwnProperty.call(e,n),c=a?e[n]:void 0;a&&delete e[n];let s=m(r.default??void 0);e[P].set(n,s),Object.defineProperty(e,n,{get(){return s.value},set(l){let u=s.peek();Object.is(u,l)||(e[w].set(n,u),s.value=l,r.reflect&&he(e,o,l,i))},configurable:!0}),a&&(s.value=c)}}var de=Object.freeze({setFormValue(){},setValidity(){},checkValidity(){return!0},reportValidity(){return!0},get form(){return null},get labels(){return[]},get validity(){return{}},get validationMessage(){return""},get willValidate(){return!1}});function he(e,t,n,r){r===Boolean?n?e.setAttribute(t,""):e.removeAttribute(t):n==null?e.removeAttribute(t):e.setAttribute(t,String(n))}var J=(e,t)=>t===Boolean?e!==null:t===Number?e===null?null:+e:e;function pe(e){if(Object.hasOwn(e,"_sa"))return;e._sa=!0;let t=e.styles;if(!t||!("adoptedStyleSheets"in document))return;let n=Array.isArray(t)?t:[t];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...n.filter(r=>!document.adoptedStyleSheets.includes(r))]}function X(e){if(Object.hasOwn(e,"_pp"))return;e._pp={};let t=e.parts;if(t)for(let[n,r]of Object.entries(t)){let o=document.createElement("template");o.innerHTML=r,e._pp[n]=o.content.firstElementChild}}var C=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let t=Object.entries(this.properties).map(([n,r])=>r.attribute??n.toLowerCase());return t.includes("traits")?t:[...t,"traits"]}#o=[];#e=[];#n=[];#r=null;#i=null;#t=null;#a=m(0);constructor(){super(),this.internals=typeof this.attachInternals=="function"?this.attachInternals():de,fe(this,this.constructor.properties)}connectedCallback(){let t=this.constructor;t._tag||(t._tag=this.localName),pe(t),X(t),_(()=>{for(let[n,r]of Object.entries(t.properties)){let o=r.attribute??n.toLowerCase();this.hasAttribute(o)?this[n]=J(this.getAttribute(o),r.type??String):r.reflect&&r.type===Boolean&&this[n]===!0&&this.setAttribute(o,"")}}),_(()=>this.connected()),this.#o.push(p(()=>{for(let r of this[P].values())r.value;this.#a.value;let n=t.template(this);if(n&&g(n,this),this.render(),this[w].size){let r=new Map(this[w]);this[w].clear(),this.updated(r)}},{host:this.localName,onError:this.onError?n=>this.onError(n):null})),this.#t||(this.#t=new Set);for(let n of t.traits)this.#s(n);this.#c(),this.#r&&this.#l()}disconnectedCallback(){this._i&&T(this._i.p);for(let t of this.#o)t();this.#o.length=0;for(let t of this.#n)t.value=void 0;this.#n.length=0;for(let t of this.#e)t.disconnect(this);this.#e.length=0,this.#t?.clear(),this.#i?.(),this.#i=null,this.#r?.disconnect?.(this),this.disconnected()}#l(){let t=this.#r;t.connect?.(this),this.#i=t.subscribe?.(()=>{this.#a.value++})}get controller(){return this.#r}set controller(t){this.#i?.(),this.#i=null,this.#r?.disconnect?.(this),this.#r=t,t&&this.isConnected&&this.#l()}#s(t,{declarative:n=!1}={}){this.#t.add(t);let r=t();r.connect(this,{host:this,signal:m,computed:$,effect:p}),n&&(r._declarative=!0),this.#e.push(r)}addTrait(t){return this.#t||(this.#t=new Set),this.#t.has(t)?this:(this.#s(t),this)}#c(){let t=this.getAttribute("traits");if(t)for(let n of t.split(/\s+/).filter(Boolean)){let r=K(n);if(!r){console.warn(`<${this.localName}> traits="${n}" \u2014 trait not found. Did you forget to import it?`);continue}this.#t.has(r)||this.#s(r,{declarative:!0})}}#f(){if(!this.#t)return;let t=[];for(let n of this.#e)if(n._declarative){n.disconnect(this);for(let r of this.#t)if(r.schema?.name&&n.schema?.name===r.schema.name){this.#t.delete(r);break}}else t.push(n);this.#e.length=0,this.#e.push(...t),this.#c()}attributeChangedCallback(t,n,r){if(t==="traits"){this.isConnected&&this.#f();return}for(let[o,i]of Object.entries(this.constructor.properties))if((i.attribute??o.toLowerCase())===t){this[o]=J(r,i.type??String);break}}static template=()=>null;static create(t={}){let n=this._tag??customElements.getName?.(this);if(!n)throw new Error("Component not registered");let r=document.createElement(n);for(let[o,i]of Object.entries(t))r[o]=i;return r}signal(t){let n=m(t);return this.#n.push(n),n}ensure(t){for(let i of this.children)if(i.getAttribute("slot")===t)return i;let n=this.#u(t);if(n)return n;X(this.constructor);let r=this.constructor._pp?.[t];if(!r)return null;let o=r.cloneNode(!0);return o._uiPart=!0,this.appendChild(o),o}drop(t){for(let r of this.children)if(r.getAttribute("slot")===t){r.remove();return}let n=this.#u(t);n&&n.remove()}#u(t){for(let n of this.querySelectorAll(`[slot="${t}"]`)){let r=n.parentElement,o=!0;for(;r&&r!==this;){if(r.localName.includes("-")){o=!1;break}r=r.parentElement}if(o&&r===this)return n}return null}reconcile(t,n,r,o){let i=t[y]||new Map,a=new Map,c=[];for(let l=0;l<n.length;l++){let u=n[l],d=r(u,l);if(a.has(d))continue;let S=i.get(d);S?o(u,l,S):S=o(u,l,null),a.set(d,S),c.push(d)}for(let[l,u]of i)a.has(l)||u.remove();let s=null;for(let l=c.length-1;l>=0;l--){let u=a.get(c[l]);(u.nextSibling!==s||u.parentNode!==t)&&t.insertBefore(u,s),s=u}t[y]=a}connected(){}render(){}disconnected(){}updated(t){}};var O=class extends C{static properties={focusMode:{type:Boolean,default:!1,reflect:!0,attribute:"focus-mode"}};static template=()=>null;#o=null;#e=null;#n=null;connected(){this.#o=this.querySelector("editor-toolbar"),this.#e=this.querySelector("editor-canvas"),this.#r(),this.#n=t=>{let n=t?.detail?.name;n&&(n==="toggle-focus"||n==="full-screen")&&this.toggleFocusMode()},this.addEventListener("toolbar-action",this.#n)}disconnected(){this.#n&&this.removeEventListener("toolbar-action",this.#n),this.#n=null}toggleFocusMode(){this.focusMode=!this.focusMode,this.#o?.tagName?.toLowerCase()==="editor-toolbar"&&(this.#o.fullScreen=this.focusMode),this.#e?.tagName?.toLowerCase()==="editor-canvas"&&(this.focusMode?this.#e.focus?.():this.#e.blur?.()),this.dispatchEvent(new CustomEvent("editor-mode-change",{bubbles:!0,detail:{focusMode:this.focusMode}}))}#r(){for(let t of this.querySelectorAll("select-ui[data-options]"))try{let n=JSON.parse(t.getAttribute("data-options"));t.options=n}catch{}}};R("editor-shell",O);export{O as EditorShell};
10
+ See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),n[c]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):n[c]={t:"a",n:o,name:s,c:void 0,_fx:null}}return n}function T(e){for(let t of e)t&&t._fx&&(t._fx(),t._fx=null)}function j(e){if(e.n.nodeType===1&&e.n[k])return e.n;let t=document.createElement("span");return t.style.display="contents",t.setAttribute("role","presentation"),t[k]=!0,e.n.replaceWith(t),e.n=t,t}var V=e=>e!=null&&typeof e=="object"&&e.strings,z=e=>typeof e=="function"||e!=null&&typeof e.handleEvent=="function";function L(e,t){if(t!==e.c){if(e.t==="n")if(t!=null&&t._directive)t._commit(j(e));else if(V(t))g(t,j(e));else if(Array.isArray(t)){let n=j(e);n.replaceChildren();for(let r of t)if(V(r)){let o=document.createElement("span");o.style.display="contents",o.setAttribute("role","presentation"),n.appendChild(o),g(r,o)}else n.appendChild(document.createTextNode(r??""))}else if(M(t))e.n.replaceWith(t),e.n=t;else if(e.n[k]){let n=document.createTextNode(t??"");e.n.replaceWith(n),e.n=n}else e.n.textContent=t??"";else if(e.t==="a")t==null||t===!1?e.n.removeAttribute(e.name):e.n.setAttribute(e.name,t===!0?"":t);else if(e.t==="p"){if(!e._resolved){let n=W(e.n,e.name);n!==e.name&&(e.name=n),e._resolved=!0}e.n[e.name]=t}else e.t==="e"&&(z(e.c)&&e.n.removeEventListener(e.name,e.c),z(t)&&e.n.addEventListener(e.name,t));e.c=t}}function se(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(!r)continue;let o=t[n],i=r.t!=="e"&&typeof o=="function",a=!i&&r.t!=="e"&&v(o);if(r._fx&&!i&&!a&&(r._fx(),r._fx=null),i){r._fx||(r._fx=p(()=>L(r,o())));continue}if(a){r._fx||(r._fx=p(()=>L(r,o.value)));continue}L(r,o)}}function ae(e,t,n){return{_directive:!0,_commit(r){let o=r[y]||new Map,i=new Map,a=[];for(let s=0;s<e.length;s++){let l=t(e[s],s);if(i.has(l))continue;a.push(l);let u=n(e[s],s);if(o.has(l)){let d=o.get(l);g(u,d),i.set(l,d)}else{let d=document.createElement("span");d.style.display="contents",d.setAttribute("role","presentation"),g(u,d),i.set(l,d)}}for(let[s,l]of o)i.has(s)||(l._i&&T(l._i.p),l.remove());let c=null;for(let s=a.length-1;s>=0;s--){let l=i.get(a[s]);(l.nextSibling!==c||l.parentNode!==r)&&r.insertBefore(l,c),c=l}r[y]=i}}}var x=new Map;function le(e,t){return t===`data-${e}`||t.startsWith(`data-${e}-`)}function U(e,t){return e===t||e.startsWith(`${t}-`)||t.startsWith(`${e}-`)}function ce(e){let t=[e.name,...e.prefixes||[]],n=[...e.attributes||[],...e.config||[]].filter(r=>!t.some(o=>le(o,r)));if(n.length>0)throw new Error(`Trait "${e.name}" declares attribute(s) outside its owned data-* namespace: ${n.join(", ")}. A trait owns "data-${e.name}" / "data-${e.name}-*" by default; register any other prefix via defineTrait({ ..., prefixes: [...] }) (ADR-0060) or rename the attribute.`)}function ue(e){let t=e.prefixes||[];for(let[n,r]of x){if(n===e.name)continue;let o=r.schema,i=[o.name,...o.prefixes||[]];for(let a of t)for(let c of i)if(U(a,c))throw new Error(`Trait "${e.name}"'s registered prefix "${a}" overlaps trait "${o.name}"'s owned namespace ("${c}"). Registered prefixes must be globally exclusive across the trait registry (ADR-0060).`);for(let a of o.prefixes||[])if(U(a,e.name))throw new Error(`Trait "${e.name}"'s name overlaps trait "${o.name}"'s registered prefix "${a}". Registered prefixes must be globally exclusive across the trait registry (ADR-0060).`)}}var G=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"]);function _e(e){if(!e.name)throw new Error("Trait requires a name");if(!e.setup)throw new Error(`Trait "${e.name}" requires a setup function`);if(!e.category)throw new Error(`Trait "${e.name}" requires a category`);if(!G.has(e.category))throw new Error(`Trait "${e.name}" has unknown category "${e.category}". Known: ${[...G].join(", ")}`);if(!e.description)throw new Error(`Trait "${e.name}" requires a description`);ce(e),ue(e);let t=Object.freeze({name:e.name,category:e.category,description:e.description,attributes:Object.freeze(e.attributes||[]),events:Object.freeze(e.events||[]),config:Object.freeze(e.config||[]),prefixes:Object.freeze(e.prefixes||[])});function n(){let r=null;return{schema:t,connect(o,i){r=e.setup({host:o,...i||{}})},disconnect(o){r&&(r(),r=null);for(let i of t.attributes)o.hasAttribute(i)&&(console.warn(`Trait "${t.name}": attribute "${i}" still present after disconnect`),o.removeAttribute(i))}}}return n.schema=t,x.set(e.name,n),n}function K(e){return x.get(e)||null}function Ne(e){return x.get(e)?.schema||null}function Te(){return[...x.keys()]}var P=Symbol(),w=Symbol();function fe(e,t){e[w]=new Map,e[P]=new Map;for(let[n,r]of Object.entries(t)){let o=r.attribute??n.toLowerCase(),i=r.type??String,a=Object.prototype.hasOwnProperty.call(e,n),c=a?e[n]:void 0;a&&delete e[n];let s=m(r.default??void 0);e[P].set(n,s),Object.defineProperty(e,n,{get(){return s.value},set(l){let u=s.peek();Object.is(u,l)||(e[w].set(n,u),s.value=l,r.reflect&&he(e,o,l,i))},configurable:!0}),a&&(s.value=c)}}var de=Object.freeze({setFormValue(){},setValidity(){},checkValidity(){return!0},reportValidity(){return!0},get form(){return null},get labels(){return[]},get validity(){return{}},get validationMessage(){return""},get willValidate(){return!1}});function he(e,t,n,r){r===Boolean?n?e.setAttribute(t,""):e.removeAttribute(t):n==null?e.removeAttribute(t):e.setAttribute(t,String(n))}var J=(e,t)=>t===Boolean?e!==null&&e!=="false":t===Number?e===null?null:+e:e;function pe(e){if(Object.hasOwn(e,"_sa"))return;e._sa=!0;let t=e.styles;if(!t||!("adoptedStyleSheets"in document))return;let n=Array.isArray(t)?t:[t];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...n.filter(r=>!document.adoptedStyleSheets.includes(r))]}function X(e){if(Object.hasOwn(e,"_pp"))return;e._pp={};let t=e.parts;if(t)for(let[n,r]of Object.entries(t)){let o=document.createElement("template");o.innerHTML=r,e._pp[n]=o.content.firstElementChild}}var C=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let t=Object.entries(this.properties).map(([n,r])=>r.attribute??n.toLowerCase());return t.includes("traits")?t:[...t,"traits"]}#o=[];#e=[];#n=[];#r=null;#i=null;#t=null;#a=m(0);constructor(){super(),this.internals=typeof this.attachInternals=="function"?this.attachInternals():de,fe(this,this.constructor.properties)}connectedCallback(){let t=this.constructor;t._tag||(t._tag=this.localName),pe(t),X(t),_(()=>{for(let[n,r]of Object.entries(t.properties)){let o=r.attribute??n.toLowerCase();this.hasAttribute(o)?this[n]=J(this.getAttribute(o),r.type??String):r.reflect&&r.type===Boolean&&this[n]===!0&&this.setAttribute(o,"")}}),_(()=>this.connected()),this.#o.push(p(()=>{for(let r of this[P].values())r.value;this.#a.value;let n=t.template(this);if(n&&g(n,this),this.render(),this[w].size){let r=new Map(this[w]);this[w].clear(),this.updated(r)}},{host:this.localName,onError:this.onError?n=>this.onError(n):null})),this.#t||(this.#t=new Set);for(let n of t.traits)this.#s(n);this.#c(),this.#r&&this.#l()}disconnectedCallback(){this._i&&T(this._i.p);for(let t of this.#o)t();this.#o.length=0;for(let t of this.#n)t.value=void 0;this.#n.length=0;for(let t of this.#e)t.disconnect(this);this.#e.length=0,this.#t?.clear(),this.#i?.(),this.#i=null,this.#r?.disconnect?.(this),this.disconnected()}#l(){let t=this.#r;t.connect?.(this),this.#i=t.subscribe?.(()=>{this.#a.value++})}get controller(){return this.#r}set controller(t){this.#i?.(),this.#i=null,this.#r?.disconnect?.(this),this.#r=t,t&&this.isConnected&&this.#l()}#s(t,{declarative:n=!1}={}){this.#t.add(t);let r=t();r.connect(this,{host:this,signal:m,computed:$,effect:p}),n&&(r._declarative=!0),this.#e.push(r)}addTrait(t){return this.#t||(this.#t=new Set),this.#t.has(t)?this:(this.#s(t),this)}#c(){let t=this.getAttribute("traits");if(t)for(let n of t.split(/\s+/).filter(Boolean)){let r=K(n);if(!r){console.warn(`<${this.localName}> traits="${n}" \u2014 trait not found. Did you forget to import it?`);continue}this.#t.has(r)||this.#s(r,{declarative:!0})}}#f(){if(!this.#t)return;let t=[];for(let n of this.#e)if(n._declarative){n.disconnect(this);for(let r of this.#t)if(r.schema?.name&&n.schema?.name===r.schema.name){this.#t.delete(r);break}}else t.push(n);this.#e.length=0,this.#e.push(...t),this.#c()}attributeChangedCallback(t,n,r){if(t==="traits"){this.isConnected&&this.#f();return}for(let[o,i]of Object.entries(this.constructor.properties))if((i.attribute??o.toLowerCase())===t){this[o]=J(r,i.type??String);break}}static template=()=>null;static create(t={}){let n=this._tag??customElements.getName?.(this);if(!n)throw new Error("Component not registered");let r=document.createElement(n);for(let[o,i]of Object.entries(t))r[o]=i;return r}signal(t){let n=m(t);return this.#n.push(n),n}ensure(t){for(let i of this.children)if(i.getAttribute("slot")===t)return i;let n=this.#u(t);if(n)return n;X(this.constructor);let r=this.constructor._pp?.[t];if(!r)return null;let o=r.cloneNode(!0);return o._uiPart=!0,this.appendChild(o),o}drop(t){for(let r of this.children)if(r.getAttribute("slot")===t){r.remove();return}let n=this.#u(t);n&&n.remove()}#u(t){for(let n of this.querySelectorAll(`[slot="${t}"]`)){let r=n.parentElement,o=!0;for(;r&&r!==this;){if(r.localName.includes("-")){o=!1;break}r=r.parentElement}if(o&&r===this)return n}return null}reconcile(t,n,r,o){let i=t[y]||new Map,a=new Map,c=[];for(let l=0;l<n.length;l++){let u=n[l],d=r(u,l);if(a.has(d))continue;let S=i.get(d);S?o(u,l,S):S=o(u,l,null),a.set(d,S),c.push(d)}for(let[l,u]of i)a.has(l)||u.remove();let s=null;for(let l=c.length-1;l>=0;l--){let u=a.get(c[l]);(u.nextSibling!==s||u.parentNode!==t)&&t.insertBefore(u,s),s=u}t[y]=a}connected(){}render(){}disconnected(){}updated(t){}};var O=class extends C{static properties={focusMode:{type:Boolean,default:!1,reflect:!0,attribute:"focus-mode"}};static template=()=>null;#o=null;#e=null;#n=null;connected(){this.#o=this.querySelector("editor-toolbar"),this.#e=this.querySelector("editor-canvas"),this.#r(),this.#n=t=>{let n=t?.detail?.name;n&&(n==="toggle-focus"||n==="full-screen")&&this.toggleFocusMode()},this.addEventListener("toolbar-action",this.#n)}disconnected(){this.#n&&this.removeEventListener("toolbar-action",this.#n),this.#n=null}toggleFocusMode(){this.focusMode=!this.focusMode,this.#o?.tagName?.toLowerCase()==="editor-toolbar"&&(this.#o.fullScreen=this.focusMode),this.#e?.tagName?.toLowerCase()==="editor-canvas"&&(this.focusMode?this.#e.focus?.():this.#e.blur?.()),this.dispatchEvent(new CustomEvent("editor-mode-change",{bubbles:!0,detail:{focusMode:this.focusMode}}))}#r(){for(let t of this.querySelectorAll("select-ui[data-options]"))try{let n=JSON.parse(t.getAttribute("data-options"));t.options=n}catch{}}};R("editor-shell",O);export{O as EditorShell};