var e="@wcstack/devtools",t="4.26.0";const n="__WCSTACK_DEVTOOLS_HOOK__";function i(){const e=globalThis,t=e[n];if(void 0!==t)return 2!==t.version&&console.warn(`[wcstack/devtools] hook registry version mismatch: found ${t.version}, expected 2. Keeping the existing registry (first-wins).`),t;const i=function(){const e=new Map,t=new Set,n=e=>{if(0===t.size)return void e._setSink(null);const n=e.id;e._setSink(e=>{for(const i of t)i.onEvent?.(n,e)})};return{version:2,sources:e,register(i){if(!e.has(i.id)){e.set(i.id,i),n(i);for(const e of t)e.onSourceRegistered?.(i)}},unregister(n){const i=e.get(n);if(void 0!==i){i._setSink(null),e.delete(n);for(const e of t)e.onSourceUnregistered?.(n)}},addListener(i){t.add(i);for(const t of e.values())n(t),i.onSourceRegistered?.(t);return()=>{if(t.delete(i))for(const t of e.values())n(t)}}}}();return e[n]=i,i}const s=80;function o(e){const t=e.constructor,n=t?.name;return"string"==typeof n&&n.length>0?n:"Object"}function r(e,t=2){switch(typeof e){case"string":return`"${e.length>s?e.slice(0,s)+"…":e}"`;case"number":case"boolean":case"bigint":return String(e);case"symbol":return e.toString();case"undefined":return"undefined";case"function":return"[[Function]]"}if(null===e)return"null";const n=e;if(Array.isArray(n)){if(t<=0)return`[[Array(${n.length})]]`;const e=n.slice(0,3).map(e=>r(e,t-1)),i=n.length>3?`, …(${n.length})`:"";return`[${e.join(", ")}${i}]`}if(function(e){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(n)){if(t<=0)return"[[Object]]";const e=Object.keys(n),i=e.slice(0,3).map(e=>`${e}: ${r(n[e],t-1)}`),s=e.length>3?`, …(${e.length})`:"";return`{${i.join(", ")}${s}}`}return`[[${o(n)}]]`}function a(e){if(null!==e&&"object"==typeof e){const{name:t,message:n}=e;if("string"==typeof n){const i="string"==typeof t&&t.length>0?t:o(e),r=n.length>s?n.slice(0,s)+"…":n;return r.length>0?`${i}: ${r}`:i}}return r(e,1)}function l(e){if(0===e.length)return"";const t=e.slice(0,3).map(e=>{const t=r(e,1);return t.length>s?t.slice(0,s)+"…":t}),n=e.length>3?`, …(${e.length})`:"";return`${t.join(", ")}${n}`}const d=new Set(["watch-error","watch-chain-limit","render-chain-limit","path-unresolved","binding-apply-error","propagation-hop-limit","contract-drift"]);const c=String.fromCharCode(0);function h(e){return e}function u(e,t){return e+c+t}function p(e,t){return e+c+t}function m(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot?`<${e.host.tagName.toLowerCase()}>`:9===e.nodeType?"document":e.nodeName.toLowerCase()}function g(e){return!(Number.parseInt(String(e),10)>=4)}function f(e,t,n){return void 0===n?{kind:e,name:t,status:"never",count:0,note:null}:n.zeroSubscriberCount===n.count?{kind:e,name:t,status:"emitted-unheard",count:n.count,note:`all ${n.count} emit(s) had 0 subscribers`}:{kind:e,name:t,status:"emitted",count:n.count,note:n.zeroSubscriberCount>0?`${n.zeroSubscriberCount}/${n.count} emit(s) had 0 subscribers`:null}}class _{_timelineCapacity;_removeListener=null;_sources=new Map;_roster=new Map;_wiringByPathKey=new Map;_wiringEntryByBinding=new WeakMap;_timeline=[];_failures=[];_failureCount=0;_unresolved=new Map;_seq=0;_paused=!1;_changeListeners=new Set;_observingSince=null;_watchFiredStats=new Map;_tokenEmitStats=new Map;_everAttachedKeys=new Set;constructor(e){this._timelineCapacity=e?.timelineCapacity??500}get connected(){return null!==this._removeListener}get paused(){return this._paused}set paused(e){this._paused=e}connect(){if(null!==this._removeListener)return;this._observingSince=performance.now();const e=i();this._removeListener=e.addListener({onSourceRegistered:e=>{this._sources.set(e.id,e),this._refreshRosterOf(e),this._notify("sources")},onSourceUnregistered:e=>{this._sources.delete(e),this._roster.delete(e),this._notify("sources"),this._notify("roster")},onEvent:(e,t)=>{this._ingest(e,t)}})}disconnect(){null!==this._removeListener&&(this._removeListener(),this._removeListener=null,this._sources.clear(),this._roster.clear(),this._wiringByPathKey.clear(),this._wiringEntryByBinding=new WeakMap,this._observingSince=null,this._watchFiredStats.clear(),this._tokenEmitStats.clear(),this._everAttachedKeys.clear(),this._unresolved.clear(),this._notify("sources"),this._notify("roster"),this._notify("wiring"),this._notify("coverage"))}get observingSince(){return this._observingSince}onChange(e){return this._changeListeners.add(e),()=>{this._changeListeners.delete(e)}}getSources(){return[...this._sources.values()]}getRoster(){const e=[];for(const t of this._roster.values())e.push(...t);return e}refreshRoster(){for(const e of this._sources.values())this._refreshRosterOf(e);this._notify("roster")}getTimeline(){return this._timeline}getFailures(){return this._failures}get failureCount(){return this._failureCount}clearTimeline(){this._timeline=[],this._failures=[],this._failureCount=0,this._notify("timeline")}getUnresolvedReport(e){const t=this._unresolved.get(e.path);if(void 0===t)return null;const n=e.stateElementRef?.deref();for(const i of t)if(i.sourceId===e.sourceId&&(null===i.stateElementRef||void 0===n||i.stateElementRef.deref()===n))return i;return null}getWiringForPath(e,t){const n=this._wiringByPathKey.get(e);if(void 0===n)return[];const i=this._collectAlive(n);return void 0===t?i:i.filter(e=>null===e.stateElementRef||e.stateElementRef.deref()===t)}getAllWiring(){const e=[];for(const t of this._wiringByPathKey.values())e.push(...this._collectAlive(t));return e}getWiringForNode(e){const t=[];for(const n of this._wiringByPathKey.values())for(const i of this._collectAlive(n)){const n=i.bindingRef.deref();(n.node===e||n.replaceNode===e||e.contains(n.node)||e.contains(n.replaceNode))&&t.push(i)}return t}getCanonicalDeclared(){let e=!1;const t=[],n=new Set;for(const[i,s]of this._sources){if("function"!=typeof s.getDeclaredBindings)continue;e=!0;const o=new Set;for(const e of this._roster.get(i)??[])o.add(e.rootNode);for(const e of o)for(const i of s.getDeclaredBindings(e)){const e=[i.statePathName,i.propName,i.bindingType,i.origin,i.raw].join(c);n.has(e)||(n.add(e),t.push(i))}}return e?t:null}getCoverageReport(e){const t=[];for(const n of this.getRoster()){const i=n.summary;if(void 0!==e&&i.element!==e)continue;const s=g(this._sources.get(n.sourceId).packageVersion);for(const e of i.watchPaths??[]){const n=this._measuredFor(this._watchFiredStats,h(e),i.element)?.count??0;if(n>0){t.push({kind:"watch",name:e,status:"fired",count:n,note:null});continue}if(!s){t.push({kind:"watch",name:e,status:"never",count:0,note:null});continue}const o=void 0!==i.keyedListPaths;let r=null;for(let t=e.indexOf(".*");-1!==t;t=e.indexOf(".*",t+2)){const n=e.slice(0,t);if(!(i.paths.list.has(n)||(i.keyedListPaths?.has(n)??!1))){r=n;break}}null===r?t.push({kind:"watch",name:e,status:"never",count:0,note:null}):t.push({kind:"watch",name:e,status:"prerequisite-missing",count:0,note:o?`list "${r}" has no for binding and no $listKeys declaration — list writes never reach its rows (only explicit-index writes can fire this watch)`:`no for binding observed for list "${r}" (a $listKeys declaration would still let list writes fire it)`})}for(const e of i.commandTokenNames)t.push(f("command",e,this._measuredFor(this._tokenEmitStats,u("command",e),i.element)));for(const e of i.eventTokenNames)t.push(f("eventToken",e,this._measuredFor(this._tokenEmitStats,u("event",e),i.element)))}const n=this.getCanonicalDeclared();if(null!==n){const e=new Set;for(const i of n){if("for"===i.bindingType||"if"===i.bindingType||"elseif"===i.bindingType||"else"===i.bindingType)continue;if(i.propName.startsWith("eventToken."))continue;const n=p(i.statePathName,i.propName);if(e.has(n))continue;e.add(n);const s=this._everAttachedKeys.has(n);t.push({kind:"binding",name:`${i.propName} ← ${i.statePathName}`,status:s?"attached":"never-attached",count:s?1:0,note:"fragment"===i.origin?"template interior (attaches when rows materialize)":null})}}return t}keysOf(e){const t=this._sources.get(e.sourceId);return void 0===t||"function"!=typeof t.keys?[]:t.keys(e.rootNode)}overlaysOf(e){const t=this._sources.get(e.sourceId);return void 0===t||"function"!=typeof t.overlays?null:t.overlays(e.rootNode)}keyedSubscriptionsOf(e){const t=this._sources.get(e.sourceId);return void 0===t||"function"!=typeof t.keyedSubscriptions?null:t.keyedSubscriptions(e.rootNode)}readValue(e,t,n){const i=this._sources.get(e.sourceId);if(void 0!==i)return i.read(e.rootNode,t,n)}writeValue(e,t,n,i){const s=this._sources.get(e.sourceId);void 0!==s&&s.write(e.rootNode,t,n,i)}_notify(e){for(const t of this._changeListeners)t(e)}_refreshRosterOf(e){const t=[],n=new Map;for(const i of e.getStateElements()){const s=m(i.rootNode),o=(n.get(s)??0)+1;n.set(s,o),t.push({sourceId:e.id,label:1===o?s:`${s}#${o}`,rootNode:i.rootNode,summary:i})}this._roster.set(e.id,t)}_statFor(e,t,n){let i=e.get(t);void 0===i&&(i=[],e.set(t,i));const s="object"==typeof n&&null!==n?n:null;for(const e of i)if(null===s?null===e.stateElementRef:e.stateElementRef?.deref()===s)return e;const o={stateElementRef:null===s?null:new WeakRef(s),count:0,zeroSubscriberCount:0};return i.push(o),o}_measuredFor(e,t,n){const i=e.get(t);if(void 0===i)return;let s=0,o=0;for(let e=i.length-1;e>=0;e--){const t=i[e].stateElementRef;null===t||void 0!==t.deref()?null!==t&&t.deref()!==n||(s+=i[e].count,o+=i[e].zeroSubscriberCount):i.splice(e,1)}return 0===i.length&&e.delete(t),0===s?void 0:{count:s,zeroSubscriberCount:o}}_collectAlive(e){const t=[];for(const n of e)void 0!==n.bindingRef.deref()?t.push(n):e.delete(n);return t}_appendTimeline(e){const t=(n=e.kind,d.has(n));var n;if(this._paused&&!t)return;const i={...e,seq:this._seq++,time:performance.now()};t&&(this._failureCount++,this._pushBounded(this._failures,i)),this._paused||this._pushBounded(this._timeline,i),this._notify("timeline")}_pushBounded(e,t){e.push(t);const n=e.length-this._timelineCapacity;n>0&&e.splice(0,n)}_recordUnresolved(e,t){const n=t.path,i=(this._unresolved.get(n)??[]).filter(e=>null===e.stateElementRef||void 0!==e.stateElementRef.deref()),s=t.stateElement;i.push({sourceId:e,source:t.source,path:t.path,missingSegment:t.missingSegment,stateElementRef:"object"==typeof s&&null!==s?new WeakRef(s):null}),this._unresolved.set(n,i)}_labelOf(e){const t=e.listIndex?.indexes,n=e.absolutePathInfo.pathInfo.path;return void 0!==t?`${n}[${t.join(",")}]`:n}_ingest(e,t){switch(t.type){case"state:element-registered":{const n=this._sources.get(e);return void 0!==n&&(this._refreshRosterOf(n),this._notify("roster")),void this._appendTimeline({sourceId:e,kind:"element-registered",label:m(t.rootNode),detail:"",subscriberCount:null})}case"state:element-unregistered":{const n=this._sources.get(e);return void 0!==n&&(this._refreshRosterOf(n),this._notify("roster")),void this._appendTimeline({sourceId:e,kind:"element-unregistered",label:m(t.rootNode),detail:"",subscriberCount:null})}case"state:write":{const n=t.hasOldValue?`${r(t.value)} (was ${r(t.oldValue)})`:r(t.value);return void this._appendTimeline({sourceId:e,kind:"write",label:this._labelOf(t.absoluteAddress),detail:n,subscriberCount:null})}case"state:update-batch":{const n=[];let i=0;for(const e of t.addresses)i++,n.length<3&&n.push(this._labelOf(e));if(0===i)return;this._notify("values");const s=i>n.length?`, …(${i})`:"";return void this._appendTimeline({sourceId:e,kind:"batch",label:`${i} address${1===i?"":"es"}`,detail:`${n.join(", ")}${s}`,subscriberCount:null})}case"state:binding-added":{const n=t.absoluteAddress.absolutePathInfo.pathInfo.path,i=n;let s=this._wiringByPathKey.get(i);void 0===s&&(s=new Set,this._wiringByPathKey.set(i,s));const o=t.absoluteAddress.absolutePathInfo.stateElement,r={sourceId:e,path:n,propName:t.binding.propName,bindingType:t.binding.bindingType,bindingRef:new WeakRef(t.binding),stateElementRef:"object"==typeof o&&null!==o?new WeakRef(o):null};return s.add(r),this._wiringEntryByBinding.set(t.binding,r),this._everAttachedKeys.add(p(n,t.binding.propName)),this._notify("wiring"),void this._notify("coverage")}case"state:binding-removed":{const e=this._wiringEntryByBinding.get(t.binding);if(void 0===e)return;this._wiringEntryByBinding.delete(t.binding);const n=e.path,i=this._wiringByPathKey.get(n);return void 0!==i&&(i.delete(e),0===i.size&&this._wiringByPathKey.delete(n)),void this._notify("wiring")}case"state:binding-cleared":{const e=t.absoluteAddress.absolutePathInfo.pathInfo.path;return void(this._wiringByPathKey.delete(e)&&this._notify("wiring"))}case"state:token-emit":{const n=this._statFor(this._tokenEmitStats,u(t.kind,t.tokenName),t.stateElement);return n.count+=1,0===t.subscriberCount&&(n.zeroSubscriberCount+=1),this._notify("coverage"),void this._appendTimeline({sourceId:e,kind:t.kind,label:t.tokenName,detail:l(t.args),subscriberCount:t.subscriberCount})}case"state:watch-fired":return this._statFor(this._watchFiredStats,t.path,t.stateElement).count+=1,void this._notify("coverage");case"state:watch-error":return void this._appendTimeline({sourceId:e,kind:"watch-error",label:t.path,detail:`${t.phase}: ${a(t.error)}`,subscriberCount:null});case"state:watch-chain-limit":return void this._appendTimeline({sourceId:e,kind:"watch-chain-limit",label:`depth > ${t.maxDepth}`,detail:t.paths.join(", "),subscriberCount:null});case"state:render-chain-limit":return void this._appendTimeline({sourceId:e,kind:"render-chain-limit",label:`depth > ${t.maxDepth}`,detail:t.paths.join(", "),subscriberCount:null});case"state:path-unresolved":return this._recordUnresolved(e,t),this._notify("wiring"),void this._appendTimeline({sourceId:e,kind:"path-unresolved",label:t.path,detail:`${t.source}: "${t.missingSegment}" is not declared`,subscriberCount:null});case"state:binding-apply-error":return void this._appendTimeline({sourceId:e,kind:"binding-apply-error",label:t.path,detail:`${t.bindingType}: ${a(t.error)}`,subscriberCount:null});case"propagation:suppressed":return void this._appendTimeline({sourceId:e,kind:"propagation-suppressed",label:t.member,detail:`${t.reason} (tx ${t.transactionId}, edge ${t.edgeId})`,subscriberCount:null});case"propagation:coalesced":return void this._appendTimeline({sourceId:e,kind:"propagation-coalesced",label:this._labelOf(t.absoluteAddress),detail:`tx ${t.droppedTransactionId} dropped (winner tx ${t.winnerTransactionId})`,subscriberCount:null});case"propagation:hop-limit":return void this._appendTimeline({sourceId:e,kind:"propagation-hop-limit",label:this._labelOf(t.absoluteAddress),detail:`hop ${t.hop} (tx ${t.transactionId})`,subscriberCount:null});case"contract:drift":{const n=void 0!==t.member?`: ${t.member}`:"",i="event-mismatch"===t.reason?` (sidecar ${t.sidecarEvent??"?"} / live ${t.liveEvent??"?"})`:"";return void this._appendTimeline({sourceId:e,kind:"contract-drift",label:t.tag,detail:`${t.reason}${n}${i}`,subscriberCount:null})}case"contract:manifest-read":case"contract:unsupported-extension":return}}}const b=["wcs-text","wcs-for","wcs-if","wcs-elseif","wcs-else"];function w(e,t,n){const i=t.trim();if(0===i.length)return null;const s=i.indexOf(":");if(s<0)return null;const o=i.slice(0,s).trim(),r=i.slice(s+1).trim();if(0===o.length||0===r.length)return null;const[a,...l]=r.split("|").map(e=>e.trim());return{element:e,propName:o,path:a,filters:l.filter(e=>e.length>0),origin:n,raw:i}}class y extends HTMLElement{static get observedAttributes(){return["open","dock","hotkey"]}_core=null;_removeCoreListener=null;_panel=null;_badge=null;_stateSelect=null;_paneElements={};_wiringView="wiring";_failuresOnly=!1;_badgeCount=null;_failuresButton=null;_timelineHeading=null;_highlightLayer=null;_dirtyPanes=new Set;_renderScheduled=!1;_selectedRosterKey=null;_selectedPath=null;_pickedNode=null;_pickMode=!1;_expanded=new Set;_hotkeyHandler=null;_pickHandler=null;_editInput=null;_statePointerDown=!1;get core(){return this._core}connectedCallback(){if(document.documentElement.hasAttribute("data-wcs-server"))return;null===this.shadowRoot&&this._buildShadow();const e=Number(this.getAttribute("buffer")??"");this._core=new _({timelineCapacity:Number.isFinite(e)&&e>0?e:void 0}),this._removeCoreListener=this._core.onChange(e=>{"roster"===e||"sources"===e?(this._markDirty("state"),this._markDirty("wiring")):"wiring"===e?this._markDirty("wiring"):"coverage"===e?"coverage"===this._wiringView&&this._markDirty("wiring"):"values"===e?this.open&&this._markDirty("state"):this._markDirty("timeline")}),this._core.connect(),this._applyDock(),this._applyOpen(),this._installHotkey(),this._markDirty("state"),this._markDirty("wiring"),this._markDirty("timeline")}disconnectedCallback(){this._removeCoreListener?.(),this._removeCoreListener=null,this._core?.disconnect(),this._core=null,this._uninstallHotkey(),this._exitPickMode()}attributeChangedCallback(e){null!==this.shadowRoot&&("open"===e?this._applyOpen():"dock"===e?this._applyDock():"hotkey"===e&&(this._uninstallHotkey(),this._installHotkey()))}__flushRenderForTest(){this._renderDirty()}_buildShadow(){const e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent='\n:host {\n all: initial;\n position: fixed;\n z-index: 2147483647;\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 12px;\n inset: auto 0 0 auto;\n}\n* { box-sizing: border-box; }\n.badge {\n position: fixed;\n right: 12px;\n bottom: 12px;\n width: 40px;\n height: 40px;\n border-radius: 20px;\n border: 1px solid #2b4f78;\n background: #10263f;\n color: #9fd0ff;\n font-weight: 700;\n cursor: pointer;\n}\n/* Failures since the panel started observing (or since 🗑): a red count on the badge\'s corner.\n With none the badge stays as it always was. */\n.badge.has-failures { border-color: #c0563f; }\n.badge-count {\n position: absolute;\n top: -6px;\n right: -6px;\n min-width: 18px;\n height: 18px;\n padding: 0 4px;\n border-radius: 9px;\n background: #c0392b;\n color: #fff;\n font-size: 10px;\n line-height: 18px;\n text-align: center;\n}\n.badge-count[hidden] { display: none; }\n.panel {\n position: fixed;\n display: flex;\n flex-direction: column;\n background: #0d1b2a;\n color: #d7e3f4;\n border: 1px solid #2b4f78;\n box-shadow: 0 0 24px rgba(0,0,0,.5);\n}\n.panel.dock-bottom { left: 0; right: 0; bottom: 0; height: 45vh; }\n.panel.dock-right { top: 0; right: 0; bottom: 0; width: 420px; }\n.panel[hidden] { display: none; }\nheader {\n display: flex;\n gap: 6px;\n align-items: center;\n padding: 6px 8px;\n border-bottom: 1px solid #2b4f78;\n background: #10263f;\n}\n/* The header never grows wider than the panel: the title and the middle group shrink (the\n group scrolls sideways when even that is not enough), so dock and × always stay in view —\n the right dock is only 420px wide. */\nheader .title {\n flex: 0 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-weight: 700;\n color: #9fd0ff;\n margin-right: 4px;\n}\nheader .tools {\n flex: 1 1 auto;\n min-width: 0;\n display: flex;\n gap: 6px;\n align-items: center;\n overflow-x: auto;\n}\nheader .tools select { flex: 0 1 auto; min-width: 6em; text-overflow: ellipsis; }\nheader .tools button, header > button { flex: none; white-space: nowrap; }\nheader select, header button {\n font: inherit;\n background: #16324f;\n color: #d7e3f4;\n border: 1px solid #2b4f78;\n border-radius: 4px;\n padding: 2px 8px;\n cursor: pointer;\n}\nheader button[aria-pressed="true"] { background: #2b5d8f; }\n/* The failure count, which also toggles the timeline to failures only. Dim with none, red with some. */\nheader > button.failures { opacity: .7; }\nheader > button.failures.has-failures { opacity: 1; background: #6a3326; color: #ffb3a0; border-color: #a0503a; }\nheader > button.failures[aria-pressed="true"] { box-shadow: inset 0 0 0 1px #ffb3a0; }\n.panes { display: flex; flex: 1; min-height: 0; }\n.pane { flex: 1; min-width: 0; overflow: auto; padding: 6px 8px; border-right: 1px solid #1d3a5c; }\n.pane:last-child { border-right: none; }\n.pane h3 {\n margin: 0 0 6px;\n font-size: 11px;\n text-transform: uppercase;\n letter-spacing: .08em;\n color: #7ba7d4;\n}\n.tree-row { display: flex; gap: 6px; padding: 1px 0; align-items: baseline; white-space: nowrap; }\n.tree-row .toggle { width: 14px; cursor: pointer; color: #7ba7d4; user-select: none; }\n.tree-row .key { color: #9fd0ff; cursor: pointer; }\n.tree-row .value { color: #ffd9a0; overflow: hidden; text-overflow: ellipsis; }\n.tree-row .value.editable { cursor: pointer; }\n.tree-row input { font: inherit; background: #16324f; color: #ffd9a0; border: 1px solid #2b4f78; }\n.badge-tag {\n display: inline-block;\n padding: 0 4px;\n border-radius: 3px;\n font-size: 10px;\n background: #26456a;\n color: #a8c6e8;\n}\n.badge-tag.warn { background: #6a3326; color: #ffb3a0; }\n.badge-tag.declared { background: #4a4426; color: #efe3a0; }\n.wiring-row, .timeline-row { padding: 1px 0; white-space: nowrap; }\n.wiring-row .prop { color: #b7f0c0; }\n.wiring-row .path { color: #9fd0ff; }\n.timeline-row .t { color: #6f88a3; }\n.timeline-row .label { color: #9fd0ff; }\n.timeline-row .detail { color: #ffd9a0; }\n.timeline-row .kind { display: inline-block; min-width: 52px; text-align: center; }\n.empty { color: #6f88a3; font-style: italic; padding: 4px 0; }\n.notice { color: #efe3a0; padding: 2px 0 6px; }\n.notice button { font: inherit; margin-left: 6px; cursor: pointer; }\n.wiring-row .detail { color: #6f88a3; }\n.overlays-heading { margin-top: 10px; }\n.overlay-row { padding: 1px 0; white-space: nowrap; }\n.overlay-row .prop { color: #b7f0c0; }\n.overlay-row .path { color: #9fd0ff; }\n.overlay-row .detail { color: #6f88a3; }\n.keyed-row { padding: 1px 0; white-space: nowrap; }\n.keyed-row .path { color: #9fd0ff; }\n.keyed-row .detail { color: #6f88a3; }\n.wiring-tabs { padding: 0 0 4px; }\n.wiring-tabs button { font: inherit; cursor: pointer; margin-right: 4px; opacity: 0.6; }\n.wiring-tabs button.active { opacity: 1; font-weight: bold; }\n.hl-box {\n position: fixed;\n pointer-events: none;\n border: 1px solid #58c2ff;\n background: rgba(88,194,255,.18);\n}\n',e.append(t);const n=document.createElement("button");n.className="badge",n.title="wcstack DevTools",n.textContent="WCS";const i=document.createElement("span");i.className="badge-count",i.hidden=!0,n.append(i),n.addEventListener("click",()=>this.toggle()),e.append(n),this._badge=n,this._badgeCount=i;const s=document.createElement("div");s.className="panel dock-bottom",s.hidden=!0;const o=document.createElement("header"),r=document.createElement("span");r.className="title",r.textContent="wcstack devtools",o.append(r);const a=this._headerButton(o,"0 failures","show only failures in the timeline");a.classList.add("failures"),a.dataset.role="failures",a.addEventListener("click",()=>{this._failuresOnly=!this._failuresOnly,a.setAttribute("aria-pressed",String(this._failuresOnly)),this._markDirty("timeline")}),this._failuresButton=a;const l=document.createElement("div");l.className="tools",o.append(l);const d=document.createElement("select");d.title="state element",d.addEventListener("change",()=>{this._selectedRosterKey=d.value||null,this._selectedPath=null,this._expanded.clear(),this._markDirty("state"),this._markDirty("wiring")}),l.append(d),this._stateSelect=d;const c=this._headerButton(l,"⌖ pick","pick a page element");c.addEventListener("click",()=>{this._pickMode?this._exitPickMode():this._enterPickMode(),c.setAttribute("aria-pressed",String(this._pickMode))}),c.dataset.role="pick";const h=this._headerButton(l,"⏸","pause timeline");h.addEventListener("click",()=>{const e=this._core;null!==e&&(e.paused=!e.paused,h.setAttribute("aria-pressed",String(e.paused)))}),h.dataset.role="pause";const u=this._headerButton(l,"🗑","clear timeline");u.addEventListener("click",()=>{this._core?.clearTimeline()}),u.dataset.role="clear";const p=this._headerButton(o,"dock","toggle dock position");p.addEventListener("click",()=>{const e="bottom"===(this.getAttribute("dock")??"bottom")?"right":"bottom";this.setAttribute("dock",e)}),p.dataset.role="dock";const m=this._headerButton(o,"×","close");m.addEventListener("click",()=>this.toggle(!1)),m.dataset.role="close",s.append(o);const g=document.createElement("div");g.className="panes";for(const[e,t]of[["state","State"],["wiring","Wiring"],["timeline","Timeline"]]){const n=document.createElement("section");n.className=`pane pane-${e}`;const i=document.createElement("h3");i.textContent=t;const s=document.createElement("div");s.className="pane-body",n.append(i,s),g.append(n),this._paneElements[e]=s,"timeline"===e&&(this._timelineHeading=i)}this._paneElements.state.parentElement.addEventListener("pointerdown",()=>{this._holdStateWhilePressed()}),s.append(g),e.append(s),this._panel=s;const f=document.createElement("div");f.className="hl-layer",e.append(f),this._highlightLayer=f}_headerButton(e,t,n){const i=document.createElement("button");return i.textContent=t,i.title=n,i.setAttribute("aria-pressed","false"),e.append(i),i}get open(){return this.hasAttribute("open")}toggle(e){e??!this.open?this.setAttribute("open",""):this.removeAttribute("open")}_applyOpen(){this._panel.hidden=!this.open,this._badge.hidden=this.open,this.open&&(this._markDirty("state"),this._markDirty("wiring"),this._markDirty("timeline"))}_applyDock(){const e="right"===this.getAttribute("dock")?"right":"bottom";this._panel.classList.toggle("dock-right","right"===e),this._panel.classList.toggle("dock-bottom","bottom"===e)}_installHotkey(){const e=this.getAttribute("hotkey")??"Alt+Shift+D";if("none"===e)return;const t=e.split("+").map(e=>e.trim().toLowerCase()),n=t[t.length-1],i=t.includes("alt"),s=t.includes("shift"),o=t.includes("ctrl"),r=t.includes("meta");this._hotkeyHandler=e=>{e.key.toLowerCase()===n&&e.altKey===i&&e.shiftKey===s&&e.ctrlKey===o&&e.metaKey===r&&(e.preventDefault(),this.toggle())},window.addEventListener("keydown",this._hotkeyHandler)}_uninstallHotkey(){null!==this._hotkeyHandler&&(window.removeEventListener("keydown",this._hotkeyHandler),this._hotkeyHandler=null)}_enterPickMode(){this._pickMode=!0,this._pickHandler=e=>{const t=e.target;t.getRootNode()!==this.shadowRoot&&t!==this&&(e.preventDefault(),e.stopPropagation(),this._pickedNode=t,this._selectedPath=null,this._exitPickMode(),this._markDirty("wiring"))},document.addEventListener("click",this._pickHandler,{capture:!0})}_exitPickMode(){null!==this._pickHandler&&(document.removeEventListener("click",this._pickHandler,{capture:!0}),this._pickHandler=null),this._pickMode=!1;const e=this.shadowRoot?.querySelector('button[data-role="pick"]');e?.setAttribute("aria-pressed","false")}_markDirty(e){this._dirtyPanes.add(e),this._renderScheduled||(this._renderScheduled=!0,requestAnimationFrame(()=>{this._renderDirty()}))}_renderDirty(){if(this._renderScheduled=!1,null===this._core||null===this.shadowRoot)return void this._dirtyPanes.clear();const e=this._dirtyPanes;this._dirtyPanes=new Set,e.has("state")&&(this._stateHeld()?this._dirtyPanes.add("state"):this._renderStatePane()),e.has("wiring")&&this._renderWiringPane(),e.has("timeline")&&(this._renderFailureCount(),this._renderTimelinePane())}_stateHeld(){return!!this._statePointerDown||null!==this._editInput&&this.shadowRoot.activeElement===this._editInput}_releaseState(){this._dirtyPanes.has("state")&&this._markDirty("state")}_holdStateWhilePressed(){this._statePointerDown=!0;const e=()=>{window.removeEventListener("pointerup",e,!0),window.removeEventListener("pointercancel",e,!0),this._statePointerDown=!1,this._releaseState()};window.addEventListener("pointerup",e,!0),window.addEventListener("pointercancel",e,!0)}_rosterKey(e){return`${e.sourceId}:${e.label}`}_selectedRoster(){const e=this._core.getRoster();if(0===e.length)return null;return e.find(e=>this._rosterKey(e)===this._selectedRosterKey)??e[0]}_renderStatePane(){this._editInput=null;const e=this._paneElements.state,t=e.parentElement,n=t.scrollTop;this._renderStateBody(e),t.scrollTop=n}_renderStateBody(e){const t=this._core,n=this._stateSelect,i=t.getRoster(),s=this._selectedRoster();if(n.replaceChildren(...i.map(e=>{const t=document.createElement("option");return t.value=this._rosterKey(e),t.textContent=`${e.label} (${e.sourceId.slice(0,12)})`,t.selected=null!==s&&this._rosterKey(e)===this._rosterKey(s),t})),e.replaceChildren(),null===s)return void e.append(this._emptyRow("no elements observed"));this._selectedRosterKey=this._rosterKey(s);const o=t.keysOf(s);if(0===o.length)return e.append(this._emptyRow("no readable keys (runtime without keys() API?)")),this._renderOverlaysSection(e,s),void this._renderKeyedSection(e,s);for(const t of o)this._renderTreeNode(e,s,{path:t,indexes:[]},t,0);this._renderOverlaysSection(e,s),this._renderKeyedSection(e,s)}_renderKeyedSection(e,t){const n=this._core.keyedSubscriptionsOf(t);if(null===n||0===n.length)return;const i=document.createElement("h3");i.className="overlays-heading",i.textContent=`Keyed selection (${n.length} path${1===n.length?"":"s"})`,e.append(i);for(const t of n)e.append(this._keyedRow(t))}_keyedRow(e){const t=document.createElement("div");t.className="keyed-row";const n=document.createElement("span");if(n.className="path",n.textContent=e.path,t.append(n),e.tracked){const e=document.createElement("span");e.className="badge-tag warn",e.textContent="tracked",e.title="the path is a getter or under one, so $eq cannot subscribe by key: every getter that reads it re-evaluates when it changes",t.append(document.createTextNode(" "),e)}const i=[];e.rows>0&&i.push(`rows ${e.rows} · keys ${e.keys}`),e.lists>0&&i.push(`list watchers ${e.lists}`),e.tracked||i.push(`last ${r(e.lastValue,1)}`);const s=document.createElement("span");return s.className="detail",s.textContent=i.length>0?` ${i.join(" · ")}`:"",t.append(s),t}_renderOverlaysSection(e,t){const n=this._core.overlaysOf(t);if(null===n||0===n.length)return;const i=document.createElement("h3");i.className="overlays-heading",i.textContent=`Overlays (${n.length} mount${1===n.length?"":"s"})`,e.append(i);for(const t of n)e.append(this._overlayRow(t))}_overlayRow(e){const t=document.createElement("div");t.className="overlay-row";const n=document.createElement("span");n.className="badge-tag",n.textContent=e.marker;const i=document.createElement("span");i.className="prop",i.textContent=`<${e.componentTag}>`;const s=document.createElement("span");s.className="path",s.textContent=e.stateProp,t.append(n,document.createTextNode(" "),i,document.createTextNode(" "),s);const o=[];for(const t of e.mountTable)o.push(`${""===t.inner?"(root)":t.inner} → ${t.outer}`);e.delta>0&&o.push(`Δ${e.delta}`),e.privateKeys.length>0&&o.push(`private: ${e.privateKeys.join(", ")}`);const r=e.exports??[];if(r.length>0&&o.push(`exports: ${r.join(", ")}`),e.getterKeys.length>0&&o.push(`getters: ${e.getterKeys.join(", ")}`),o.length>0){const e=document.createElement("span");e.className="detail",e.textContent=` ${o.join(" · ")}`,t.append(e)}return t}_renderTreeNode(e,t,n,i,s){const o=this._core;let a,l=!0;try{a=o.readValue(t,n.path,n.indexes)}catch{l=!1}const d=document.createElement("div");d.className="tree-row",d.style.paddingLeft=14*s+"px";const c=l&&function(e){if(Array.isArray(e))return!0;if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a),h=function(e){return`${e.path}#${e.indexes.join(",")}`}(n),u=c&&this._expanded.has(h),p=document.createElement("span");p.className="toggle",p.textContent=c?u?"▾":"▸":"",c&&p.addEventListener("click",()=>{this._expanded.has(h)?this._expanded.delete(h):this._expanded.add(h),this._markDirty("state")}),d.append(p);const m=document.createElement("span");m.className="key",m.textContent=`${i}:`,m.title=n.path,m.addEventListener("click",()=>{this._selectedPath=n.path,this._pickedNode=null,this._markDirty("wiring"),this._highlightPath(t,n.path)}),d.append(m);const g=document.createElement("span");if(g.className="value",l){g.textContent=r(a,1);(null===a||"object"!=typeof a)&&"function"!=typeof a&&(g.classList.add("editable"),g.title="click to edit",g.addEventListener("click",()=>{this._beginEdit(d,g,t,n,a)}))}else g.textContent="(unreadable getter)";if(d.append(g),e.append(d),u)if(Array.isArray(a)){const i=Math.min(a.length,20);for(let o=0;oi){const t=this._emptyRow(`…(${a.length} items)`);t.style.paddingLeft=14*(s+1)+"px",e.append(t)}}else for(const i of Object.keys(a))this._renderTreeNode(e,t,{path:`${n.path}.${i}`,indexes:n.indexes},i,s+1)}_beginEdit(e,t,n,i,s){const o=document.createElement("input");o.value="string"==typeof s?s:String(s);const r=()=>{this._editInput=null,this._core?.writeValue(n,i.path,function(e){const t=e.trim();try{return JSON.parse(t)}catch{return e}}(o.value),i.indexes),this._markDirty("state")};o.addEventListener("keydown",e=>{"Enter"===e.key?r():"Escape"===e.key&&(this._editInput=null,this._markDirty("state"))}),o.addEventListener("blur",()=>{this._releaseState()}),e.replaceChild(o,t),this._editInput=o,o.focus()}_renderWiringPane(){const e=this._core,t=this._paneElements.wiring;t.replaceChildren();const n=document.createElement("div");n.className="wiring-tabs";for(const[e,t]of[["wiring","wiring"],["coverage","coverage"]]){const i=document.createElement("button");i.textContent=t,this._wiringView===e&&i.classList.add("active"),i.addEventListener("click",()=>{this._wiringView=e,this._markDirty("wiring")}),n.append(i)}if(t.append(n),"coverage"===this._wiringView)return void this._renderCoverageView(t);let i,s;if(null!==this._pickedNode){i=e.getWiringForNode(this._pickedNode);const t=this._pickedNode;s=t instanceof Element?`<${t.tagName.toLowerCase()}>`:t.nodeName}else if(null!==this._selectedPath){const t=this._selectedRoster();i=null!==t?e.getWiringForPath(this._selectedPath,t.summary.element):[],s=this._selectedPath}else i=e.getAllWiring(),s="all";const o=document.createElement("div");if(o.textContent=`context: ${s} — ${i.length} live binding${1===i.length?"":"s"}`,t.append(o),i.length>0){for(const e of i)t.append(this._wiringRow(e));return}const r=e.getCanonicalDeclared(),a=this._selectedRoster(),l=null===r&&null!==a?function(e,t="data-wcs"){const n=[];for(const i of e.querySelectorAll(`[${t}]`)){const e=i.getAttribute(t);for(const t of e.split(";")){const e=w(i,t,"attribute");null!==e&&n.push(e)}}const i=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_COMMENT);let s=i.nextNode();for(;null!==s;){const e=s.textContent.trim(),t=b.find(t=>e===t||e.startsWith(t+":"));if(void 0!==t){const i=s.parentNode instanceof Element?s.parentNode:null;if(null!==i){const s=e===t?"":e.slice(t.length+1).trim();if(s.length>0){const e="wcs-text"===t?"textContent":t.slice(4);n.push(w(i,`${e}: ${s}`,"comment"))}}}s=i.nextNode()}return n}(this._scanRootOf(a)):[];if(0===(r?.length??0)&&0===l.length)return void t.append(this._emptyRow("no bindings observed"));const d=document.createElement("div");d.className="notice";const c=document.createElement("span");c.className="badge-tag declared",c.textContent=null!==r?"declared (canonical)":"declared",d.append(c,document.createTextNode(" attached late — reload to capture live bindings "));const h=document.createElement("button");if(h.textContent="reload",h.addEventListener("click",()=>{location.reload()}),d.append(h),t.append(d),null!==r)for(const e of r)t.append(this._canonicalDeclaredRow(e));else for(const e of l)t.append(this._declaredRow(e))}_renderCoverageView(e){const t=this._core,n=t.observingSince,i=document.createElement("div"),s=null===n?null:new Date(Date.now()-(performance.now()-n)).toLocaleTimeString();i.textContent=null===s?"not observing":`observing since ${s} (declared vs measured after this point)`,e.append(i);const o=this._selectedRoster(),r=t.getCoverageReport(o?.summary.element);if(0!==r.length)for(const t of r){const n=document.createElement("div");n.className="wiring-row";const i=document.createElement("span");i.className="badge-tag",i.textContent=t.kind;const s=document.createElement("span");s.className="badge-tag",s.textContent=t.count>1?`${t.status} ×${t.count}`:t.status,"never"===t.status||"never-attached"===t.status||"emitted-unheard"===t.status?s.classList.add("warn"):"prerequisite-missing"===t.status&&s.classList.add("declared");const o=document.createElement("span");if(o.className="path",o.textContent=` ${t.name} `,n.append(i,document.createTextNode(" "),o,s),null!==t.note){const e=document.createElement("span");e.className="detail",e.textContent=` ${t.note}`,n.append(e)}e.append(n)}else e.append(this._emptyRow("nothing declared to cover"))}_canonicalDeclaredRow(e){const t=document.createElement("div");t.className="wiring-row";const n=document.createElement("span");n.className="badge-tag declared",n.textContent=e.origin;const i=document.createElement("span");i.className="prop",i.textContent=e.propName;const s=document.createElement("span");s.className="path";const o=e.outFilters.map(e=>` | ${e.filterName}(${e.args.join(",")})`).join("");if(s.textContent=`${e.statePathName}${o}`,t.append(n,document.createTextNode(" "),i,document.createTextNode(" ← "),s),null!==e.node){const n=e.node;t.addEventListener("click",()=>{this._highlightNodes([n])})}return t}_scanRootOf(e){const t=e.rootNode;return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t:document}_wiringRow(e){const t=document.createElement("div");t.className="wiring-row";const n=document.createElement("span");n.className="prop",n.textContent=e.propName;const i=document.createTextNode(" ← "),s=document.createElement("span");s.className="path",s.textContent=e.path;const o=document.createElement("span");o.className="badge-tag",o.textContent=e.bindingType,t.append(o,document.createTextNode(" "));const r=this._core.getUnresolvedReport(e);if(null!==r){const e=document.createElement("span");e.className="badge-tag warn",e.textContent="unresolved",e.title=`"${r.path}" does not resolve on the state: "${r.missingSegment}" is not declared (reported by the runtime for a ${r.source}). Updates to this path are dropped.`,t.append(e,document.createTextNode(" "))}return t.append(n,i,s),t.addEventListener("click",()=>{const t=e.bindingRef.deref();void 0!==t&&this._highlightNodes([t.node,t.replaceNode])}),t}_declaredRow(e){const t=document.createElement("div");t.className="wiring-row";const n=document.createElement("span");n.className="badge-tag declared",n.textContent=e.origin;const i=document.createElement("span");i.className="prop",i.textContent=e.propName;const s=document.createElement("span");return s.className="path",s.textContent=e.path,t.append(n,document.createTextNode(" "),i,document.createTextNode(" ← "),s),t.addEventListener("click",()=>{this._highlightNodes([e.element])}),t}_renderFailureCount(){const e=this._core.failureCount,t=`${e} failure${1===e?"":"s"}`,n=this._badge,i=this._badgeCount;i.hidden=0===e,i.textContent=0===e?"":e>99?"99+":String(e),n.classList.toggle("has-failures",e>0),n.title=0===e?"wcstack DevTools":`wcstack DevTools — ${t}`,n.setAttribute("aria-label",n.title);const s=this._failuresButton;s.textContent=0===e?t:`⚠ ${t}`,s.classList.toggle("has-failures",e>0)}_renderTimelinePane(){const e=this._core,t=this._paneElements.timeline,n=this._failuresOnly,i=n?e.getFailures():e.getTimeline(),s=Math.max(0,i.length-200),o=n?e.failureCount-(i.length-s):s,r=[];o>0&&r.push(this._emptyRow(`…(${o} earlier ${n?"failures":"entries"})`));for(let e=s;e{t.replaceChildren()},2e3)}}const v=Symbol.for("wcstack.package"),k=new WeakSet;function x(e,t){Object.defineProperty(e,v,{value:t,configurable:!0})}function E(e,t,n,i,s){if(void 0!==i&&(n===i||n.prototype instanceof i))return;const o=n[v];if(o===s||k.has(e))return;k.add(e);const r=s.slice(0,s.lastIndexOf("@"));console.warn(`[${r}] [wcs/package-twice] <${t}> is already defined by ${o??`another copy of ${r} that does not name its version`}; this copy, ${s}, does nothing. Load each package once.`)}const N="wcs-devtools";function C(n=customElements){!function(e,t,n){for(const[i,s]of n){const n=e.get(i);void 0===n?(x(s,t),e.define(i,s)):E(e,i,n,s,t)}}(n,`${e}@${t}`,[[N,y]])}function $(){null===document.querySelector(N)&&document.body.appendChild(document.createElement(N))}document.documentElement.hasAttribute("data-wcs-server")||(C(),null!==document.body?$():document.addEventListener("DOMContentLoaded",$,{once:!0})); //# sourceMappingURL=auto.min.js.map