contour-ds 1.7.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +244 -326
- package/dist/agent-cookbook.json +960 -0
- package/dist/agent-examples.json +65 -0
- package/dist/agent-map-wiring.json +152 -0
- package/dist/agent-rules.json +16 -0
- package/dist/build-manifest.json +344 -126
- package/dist/contour-wc-content.esm.js +1939 -0
- package/dist/contour-wc-content.esm.min.js +1 -0
- package/dist/contour-wc-core.esm.js +3724 -0
- package/dist/contour-wc-core.esm.min.js +1 -0
- package/dist/contour-wc-dashboard.esm.js +6986 -0
- package/dist/contour-wc-dashboard.esm.min.js +1 -0
- package/dist/contour-wc-data.esm.js +6572 -0
- package/dist/contour-wc-data.esm.min.js +1 -0
- package/dist/contour-wc-docs.esm.js +976 -0
- package/dist/contour-wc-docs.esm.min.js +1 -0
- package/dist/contour-wc-feedback.esm.js +1742 -0
- package/dist/contour-wc-feedback.esm.min.js +1 -0
- package/dist/contour-wc-forms.esm.js +2437 -0
- package/dist/contour-wc-forms.esm.min.js +1 -0
- package/dist/contour-wc-interaction.esm.js +1343 -0
- package/dist/contour-wc-interaction.esm.min.js +1 -0
- package/dist/contour-wc-layout.esm.js +845 -0
- package/dist/contour-wc-layout.esm.min.js +1 -0
- package/dist/contour-wc-map.esm.js +2411 -0
- package/dist/contour-wc-map.esm.min.js +1 -0
- package/dist/contour-wc-misc.esm.js +945 -0
- package/dist/contour-wc-misc.esm.min.js +1 -0
- package/dist/contour-wc-navigation.esm.js +2842 -0
- package/dist/contour-wc-navigation.esm.min.js +1 -0
- package/dist/contour-wc-ui.esm.js +6519 -0
- package/dist/contour-wc-ui.esm.min.js +1 -0
- package/dist/contour-wc.esm.js +14435 -5723
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +14436 -5725
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.a11y.json +402 -0
- package/dist/contour.code-snippets +4534 -0
- package/dist/contour.components.json +4870 -1222
- package/dist/contour.css +6672 -4711
- package/dist/contour.d.ts +753 -1085
- package/dist/contour.esm.js +440 -18
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.html-data.json +11343 -0
- package/dist/contour.js +440 -18
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.react.d.ts +422 -0
- package/dist/contour.single.html +17 -0
- package/dist/contour.single.min.css +1 -0
- package/dist/contour.themes.json +56 -12
- package/dist/contour.tokens.json +1318 -1053
- package/dist/contour.vue.d.ts +420 -0
- package/dist/contour.web-types.json +11703 -0
- package/dist/custom-elements.json +36120 -0
- package/dist/docs/actions.md +16 -6
- package/dist/docs/affordances.md +21 -85
- package/dist/docs/apireference.md +9 -5
- package/dist/docs/colour.md +10 -4
- package/dist/docs/componentindex.md +9 -22
- package/dist/docs/data.md +39 -58
- package/dist/docs/docs.md +12 -7
- package/dist/docs/feedback.md +30 -12
- package/dist/docs/field.md +28 -13
- package/dist/docs/forms.md +35 -19
- package/dist/docs/index.json +70 -61
- package/dist/docs/install.md +12 -7
- package/dist/docs/landing.md +7 -4
- package/dist/docs/mapengine.md +30 -8
- package/dist/docs/motion.md +12 -6
- package/dist/docs/navigation.md +31 -7
- package/dist/docs/overlays.md +32 -25
- package/dist/docs/overview.md +3 -2
- package/dist/docs/patterns.md +20 -10
- package/dist/docs/playground.md +11 -4
- package/dist/docs/principles.md +8 -6
- package/dist/docs/recipes.md +117 -13
- package/dist/docs/space.md +10 -6
- package/dist/docs/status.md +13 -14
- package/dist/docs/surfaces.md +17 -22
- package/dist/docs/theming.md +18 -32
- package/dist/docs/type.md +12 -5
- package/dist/docs/webcomponents.md +75 -33
- package/dist/hljs.css +1 -20
- package/dist/map-chrome.mapbox.css +68 -92
- package/dist/map-chrome.maplibre.css +68 -92
- package/dist/registry/items/contour-core.json +2 -2
- package/dist/registry/items/contour-data.json +2 -2
- package/dist/registry/items/contour-docs.json +2 -2
- package/dist/registry/items/contour-landing.json +2 -2
- package/dist/registry/registry.json +8 -8
- package/dist/surfaces/contour-core.min.css +1 -1
- package/dist/surfaces/contour-data.min.css +1 -1
- package/dist/surfaces/contour-docs.min.css +1 -1
- package/dist/surfaces/contour-landing.min.css +1 -1
- package/dist/svg/icons.svg +367 -0
- package/dist/wc/behaviours.mjs +222 -192
- package/dist/wc/content.mjs +486 -142
- package/dist/wc/core.mjs +917 -395
- package/dist/wc/dashboard.mjs +252 -25
- package/dist/wc/data-chart.mjs +1333 -0
- package/dist/wc/data-export.mjs +391 -0
- package/dist/wc/data-gauge.mjs +779 -0
- package/dist/wc/data-geo.mjs +696 -0
- package/dist/wc/data-glyphs.mjs +133 -0
- package/dist/wc/data-legend.mjs +431 -0
- package/dist/wc/data-readout.mjs +227 -0
- package/dist/wc/data-series.mjs +1004 -0
- package/dist/wc/data-table.mjs +751 -0
- package/dist/wc/data.mjs +15 -3707
- package/dist/wc/docs.mjs +113 -19
- package/dist/wc/feedback.mjs +320 -116
- package/dist/wc/forms-controls.mjs +635 -0
- package/dist/wc/forms-field.mjs +547 -0
- package/dist/wc/forms-groups.mjs +347 -0
- package/dist/wc/forms-input.mjs +292 -0
- package/dist/wc/forms.mjs +10 -1122
- package/dist/wc/glyph.mjs +204 -0
- package/dist/wc/index.mjs +16 -7
- package/dist/wc/interaction.mjs +322 -75
- package/dist/wc/layout.mjs +100 -29
- package/dist/wc/map.mjs +888 -285
- package/dist/wc/misc.mjs +137 -26
- package/dist/wc/navigation-menu.mjs +735 -0
- package/dist/wc/navigation-shell.mjs +495 -0
- package/dist/wc/navigation-tree.mjs +995 -0
- package/dist/wc/navigation.mjs +9 -1636
- package/dist/wc/registration.mjs +1 -8
- package/dist/wc/shadow.mjs +285 -113
- package/dist/wc/states.mjs +75 -78
- package/dist/wc/svg.mjs +209 -34
- package/dist/wc/ui-atoms.mjs +608 -0
- package/dist/wc/ui-data.mjs +1404 -0
- package/dist/wc/ui-feedback.mjs +419 -0
- package/dist/wc/ui-inputs.mjs +1570 -0
- package/dist/wc/ui-menus.mjs +307 -0
- package/dist/wc/ui-overlays.mjs +1605 -0
- package/integrations/README.md +25 -5
- package/integrations/ai/CLAUDE.md +6 -3
- package/integrations/ai/COPILOT.md +14 -0
- package/integrations/ai/GEMINI.md +14 -0
- package/integrations/ai/WINDSURF.md +14 -0
- package/integrations/ai/v0-prompt.md +13 -1
- package/integrations/frameworks/README.md +235 -0
- package/integrations/native/README.md +0 -3
- package/integrations/native/style-dictionary.config.json +1 -1
- package/integrations/tailwind/contour-theme.css +71 -13
- package/integrations/validate-markup.mjs +172 -0
- package/package.json +103 -39
- package/dist/wc/ui.mjs +0 -3560
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const REGISTERED=[];const DISPOSERS=new WeakMap();export const onDispose=(host,fn)=>{let list=DISPOSERS.get(host);if(!list){list=[];DISPOSERS.set(host,list)}list.push(fn)};function contourDebugEnabled(){try{if(typeof window!=="undefined"&&(window.ContourDebug||window.__CONTOUR_DEBUG__))return true}catch(e){}try{if(typeof process!=="undefined"&&process.env&&process.env.NODE_ENV!=="production"&&process.env.CONTOUR_DEBUG)return true}catch(e){}return false}const runDisposers=(host)=>{const list=DISPOSERS.get(host);if(!list)return;DISPOSERS.delete(host);for(const fn of list){try{fn()}catch(e){if(contourDebugEnabled()){try{console.warn("Contour disposer failed for",host&&host.tagName,e)}catch(err){}}}}};let _contourIdCounter=0;export const contourId=(prefix)=>prefix+"-"+(++_contourIdCounter).toString(36);export const define=(name,cls)=>{if(typeof customElements==="undefined"||!customElements||typeof customElements.define!=="function")return;if(customElements.get(name))return;customElements.define(name,cls);REGISTERED.push(name)};export const MODS=["variant","size","color"];export const CONTOUR_EVENTS=Object.freeze({"contour:activate":{payload:["row"],composed:true},"contour:add":{payload:["value"],composed:true},"contour:activity-select":{payload:["index","text"],composed:true},"contour:break-change":{payload:["layer","value"],composed:true},"contour:style-resolved":{payload:["applied","items","layer","property","value"],composed:true},"contour:advanced-toggle":{payload:["title"],composed:true},"contour:affordance-activate":{payload:["name"],composed:true},"contour:aggregate":{payload:["aggregate"],composed:true},"contour:bearing":{payload:["direction","degrees"],composed:true},"contour:btn-group-change":{payload:["index","label"],composed:true},"contour:brush-start":{payload:["end","start","value"],composed:true},"contour:brush-end":{payload:["end","start","value"],composed:true},"contour:brush":{payload:["end","start","value"],composed:true},"contour:change":{payload:["checked","color","direction","end","files","high","index","low","month","name","speed","start","unit","value","year"],composed:true},"contour:collapse":{payload:["collapsed"],composed:true},"contour:cluster-toggle":{payload:["count","expanded"],composed:true},"contour:clear":{payload:[],composed:true},"contour:clear-all":{payload:[],composed:true},"contour:close":{payload:["index","label"],composed:true},"contour:copy":{payload:["text"],composed:true},"contour:dash-action":{payload:["label"],composed:true},"contour:diff-activate":{payload:["kind","text"],composed:true},"contour:draw-start":{payload:["mode"],composed:true},"contour:drag":{payload:["delta","key","value"],composed:true},"contour:do-dont-activate":{payload:["kind","text"],composed:true},"contour:docs-nav-select":{payload:["label","href"],composed:true},"contour:dragend":{payload:["value"],composed:true},"contour:dragstart":{payload:["value"],composed:true},"contour:drop":{payload:["value","label"],composed:true},"contour:empty-action":{payload:["state"],composed:true},"contour:filter":{payload:["query"],composed:true},"contour:error":{payload:["src","message","name","status"],composed:true},"contour:export":{payload:["format"],composed:true},"contour:refresh":{payload:[],composed:true},"contour:hide":{payload:[],composed:true},"contour:hover":{payload:["row"],composed:true},"contour:input":{payload:["name","value","checked"],composed:true},"contour:layer-opacity":{payload:["name","opacity"],composed:true},"contour:layer-rename":{payload:["name","newName"],composed:true},"contour:layer-duplicate":{payload:["name"],composed:true},"contour:layer-zoom":{payload:["name"],composed:true},"contour:layer-projection":{payload:["name","projection"],composed:true},"contour:layer-remove":{payload:["name"],composed:true},"contour:layer-reorder":{payload:["layerIds"],composed:true},"contour:layer-toggle":{payload:["name","visible"],composed:true},"contour:layer-visibility":{payload:["name","visible"],composed:true},"contour:legend-toggle":{payload:["key","label","pressed"],composed:true},"contour:leave":{payload:[],composed:true},"contour:load":{payload:["src","count"],composed:true},"contour:map-control":{payload:["control"],composed:true},"contour:map-attach":{payload:[],composed:true},"contour:map-detach":{payload:[],composed:true},"contour:mode-change":{payload:["mode"],composed:true},"contour:move":{payload:["direction","from","to"],composed:true},"contour:open":{payload:[],composed:true},"contour:page":{payload:["page"],composed:true},"contour:ready":{payload:["version","count"],composed:true},"contour:remove":{payload:["key","label","value"],composed:true},"contour:reorder":{payload:["from","to"],composed:true},"contour:range-change":{payload:["value"],composed:true},"contour:resize":{payload:["height","width"],composed:true},"contour:retry":{payload:["src"],composed:true},"contour:loop-change":{payload:["loop"],composed:true},"contour:pause":{payload:[],composed:true},"contour:play":{payload:[],composed:true},"contour:seek":{payload:["progress","value"],composed:true},"contour:select":{payload:["area","col","index","key","label","labels","path","row","rows","series","value"],composed:true},"contour:search":{payload:["query"],composed:true},"contour:speed-change":{payload:["speed"],composed:true},"contour:showcase-activate":{payload:["title"],composed:true},"contour:step-activate":{payload:["index","title"],composed:true},"contour:step-change":{payload:["direction","index","title"],composed:true},"contour:show":{payload:[],composed:true},"contour:sort":{payload:["column","direction"],composed:true},"contour:submit":{payload:["submitting"],composed:true},"contour:stream-state":{payload:["running"],composed:true},"contour:tab-change":{payload:["index","label"],composed:true},"contour:theme-change":{payload:["theme"],composed:true},"contour:tick":{payload:["frame"],composed:true},"contour:time-change":{payload:["progress","value"],composed:true},"contour:time-range-change":{payload:["value"],composed:true},"contour:toggle":{payload:["expanded","label","open","path","playing"],composed:true},"contour:view-enter":{payload:[],composed:true},"contour:view-leave":{payload:[],composed:true},});export function sanitizeHtml(input){const str=String(input==null?"":input);if(typeof DOMParser==="undefined"){return str.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}const doc=new DOMParser().parseFromString(str,"text/html");const drop=new Set(["script","iframe","object","embed","style","link","meta","base","form","input","button"]);const walk=(node)=>{const children=Array.from(node.childNodes);for(const c of children){if(c.nodeType===1){const tag=c.tagName.toLowerCase();if(drop.has(tag)){c.remove();continue}for(const attr of Array.from(c.attributes)){const name=attr.name.toLowerCase();if(name.startsWith("on")){c.removeAttribute(attr.name);continue}const val=String(attr.value||"").trim().toLowerCase();if((name==="href"||name==="src"||name==="xlink:href")&&(val.startsWith("javascript:")||val.startsWith("data:text/html"))){c.removeAttribute(attr.name)}}walk(c)}}};walk(doc.body);return doc.body.innerHTML}export const OBSERVED=["accept","action","actions","active","after","allow-duplicate","allow-remove","allow-rename","allow-zoom","alpha","anchor","answer","area","article","attribution","attribution-mark","audit","autoplay","axis","axis-x","axis-y","brownout","brownout-level","before","body","brand","breakpoint","breaks","brush","brush-end","brush-max","brush-min","brush-start","cache-key","canvas","center","clearable","cols","columns","color","command","cells","checked","chrome","debounce","closable","collapsed","collapsible","classification","colors","continuous","content","controls","copyable","count","data","data-table","date","delta","description","glyphs","demo","density","desc","dir","direction","disabled","distance","dismissible","divider","do","dont","dot","ends","high","input","layer","low","mode","modes","n","opacity","palette","polarity","precision","range","single","empty","exclusive","fallback","filename","format","heading","help","hint","href","icon","illustration","instrument","interval","items","key","layers","level","range-end","range-start","label","lazy","lede","legend","line","limit","link","links","live","loading","locale","loop","max","media","message","method","menu","min","multiple","name","needle","next","no","no-cache","no-data-message","nodes","note","norm","normalize","options","orientation","page-size","pages","pause","paused","pausable","persist","placeholder","playing","point","points","prev","presets","progress","prompt","question","recent","required","quote","ramp","refresh","removable","resolution","reverse","rings","retry","results","rows","scale","selectable","segments","show-header","sparkline","threshold","thresholds","selected","separator","series","shortcut","side","size","skeleton","sort","sort-dir","speed","status","step","submit","submitting","timeout","trigger","virtual","sticky","cluster-count","cluster-expanded","time","resizable","state","steps","style","subtitle","summary","src","table","tabs","tag","text","ticks","title","type","unit","cluster-items","row-height","variant","values","viewport","yes","zoomable","x","y","caption","current-time","is-playing","loop-label","no-data-color","property","show-loop","show-thumb","show-thumb-caption","speeds","item-height","pause-label","play-label","speed-label","time-label","shimmer",];export function headingTag(host,fallback="h3"){const v=host&&host.getAttribute?host.getAttribute("heading"):null;return/^h[1-6]$/.test(v||"")?v:fallback}const _ContourBaseParent=(typeof HTMLElement!=="undefined")?HTMLElement:Object;export class ContourBase extends _ContourBaseParent{static formAssociated=false;constructor(){super();if(this.constructor.formAssociated&&typeof this.attachInternals==="function"){this._internals=this.attachInternals()}}static get observed(){return OBSERVED}static get observedAttributes(){return this.observed}static get properties(){return{}}static get updateMode(){return"scaffold"}brownoutLevel(){const raw=this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0";const n=parseInt(raw,10);return Number.isFinite(n)?n:0}shed(kind,threshold){return this.brownoutLevel()>=(threshold||1)}get renderCount(){return this._contourRenderCount||0}_countRender(){this._contourRenderCount=(this._contourRenderCount||0)+1}static _propsInstalled=false;_installProperties(){const ctor=this.constructor;if(ctor._propsInstalled)return;ctor._propsInstalled=true;const props=ctor.properties||{};for(const[name,spec]of Object.entries(props)){const attr=(spec&&spec.attribute)||name;const type=(spec&&spec.type)||String;Object.defineProperty(ctor.prototype,name,{get(){const raw=this.getAttribute(attr);if(type===Boolean)return raw!==null;if(raw===null)return spec&&spec.default!==undefined?spec.default:null;if(type===Number){const n=Number(raw);return Number.isNaN(n)?null:n}return raw},set(v){if(v===null||v===undefined||v===false)this.removeAttribute(attr);else if(type===Boolean){if(v)this.setAttribute(attr,"");else this.removeAttribute(attr)}else this.setAttribute(attr,String(v))},configurable:true,})}}connectedCallback(){if(this._contourAuthored){this._wireFormData();return}this._installProperties();this._contourAuthored={nodes:Array.from(this.childNodes),cls:this.getAttribute("class"),};const before=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1;this._ensureCache=new Map();this._ensureCacheGen=this._contourRenderGen;this._countRender();try{this.render()}catch(e){console.error("Contour render error:",e);this.textContent="Component failed to render."}this._contourGenerated=Array.from(this.childNodes).filter((n)=>!before.includes(n));this._applyParts(this);this._applyDensity();this.enhance();this._detachInnerFormControls();this._wireFormData()}attributeChangedCallback(name,oldValue,newValue){if(oldValue===newValue)return;if(!this.isConnected||!this._contourAuthored)return;if(this._batchDepth>0){this._batchDirty=true;return}if(this._contourRendering){if(!this._pendingRerender){this._pendingRerender=true;queueMicrotask(()=>{this._pendingRerender=false;if(!this.isConnected||!this._contourAuthored)return;this.attributeChangedCallback("__rerender__",null,"")})}return}if(name==="checked")this._checkedAttrChanged=true;this._contourRendering=true;try{const savedControls=Array.from(this.querySelectorAll("input, textarea, select"));const savedValues=savedControls.map((el)=>({key:el.name||el.id||null,value:el.value,checked:el.checked,type:el.type}));const hadFocus=this.contains(document.activeElement)?document.activeElement:null;const _focusableSelector="button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])";const _focusablesBefore=Array.from(this.querySelectorAll(_focusableSelector));const hadFocusIndex=hadFocus?_focusablesBefore.indexOf(hadFocus):-1;const hadFocusName=hadFocus?(hadFocus.getAttribute("name")||null):null;const savedScrolls=Array.from(this.querySelectorAll("*")).filter((el)=>el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth).map((el)=>({el,top:el.scrollTop,left:el.scrollLeft}));const savedDetails=Array.from(this.querySelectorAll("details")).map((d)=>({id:d.id||null,open:d.open}));for(const g of(this._contourGenerated||[])){if(!g||g.parentNode!==this)continue;let wrapper=null;if(g.classList&&(g.classList.contains("c-panel__body")||g.classList.contains("c-dialog__body")))wrapper=g;else if(g.tagName==="PRE")wrapper=g.querySelector("code")||g;if(wrapper){while(wrapper.firstChild)this.insertBefore(wrapper.firstChild,g)}}for(const g of(this._contourGenerated||[])){if(g.parentNode===this)this.removeChild(g)}const generated=new Set(this._contourGenerated||[]);const authoredNow=Array.from(this.childNodes).filter((n)=>!generated.has(n));this._contourAuthored.nodes=authoredNow;while(this.firstChild)this.removeChild(this.firstChild);for(const node of this._contourAuthored.nodes)this.appendChild(node);if(this._contourAuthored.cls===null)this.removeAttribute("class");else this.setAttribute("class",this._contourAuthored.cls);const before=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1;this._ensureCache=new Map();this._ensureCacheGen=this._contourRenderGen;this._countRender();try{this.render()}catch(e){console.error("Contour render error:",e);this.textContent="Component failed to render."}this._contourGenerated=Array.from(this.childNodes).filter((n)=>!before.includes(n));this._applyParts(this);this._applyDensity();const newControls=Array.from(this.querySelectorAll("input, textarea, select"));const keyed=savedValues.filter((sv)=>sv.key);const unkeyed=savedValues.filter((sv)=>!sv.key);const used=new Set();for(const el of newControls){const key=el.name||el.id||null;if(!key)continue;const match=keyed.find((sv)=>sv.key===key&&!used.has(sv));if(!match)continue;used.add(match);if(el.value===""&&el.getAttribute("value")===null){el.value=match.value}if((el.type==="checkbox"||el.type==="radio")&&typeof match.checked==="boolean"&&!this._checkedAttrChanged){el.checked=match.checked}}let u=0;for(const el of newControls){if(el.name||el.id)continue;const saved=unkeyed[u];u+=1;if(!saved)continue;if(el.value===""&&el.getAttribute("value")===null){el.value=saved.value}if((el.type==="checkbox"||el.type==="radio")&&typeof saved.checked==="boolean"&&!this._checkedAttrChanged){el.checked=saved.checked}}const newDetails=Array.from(this.querySelectorAll("details"));const keyedDetails=savedDetails.filter((sd)=>sd.id);const usedIds=new Set();for(const d of newDetails){const id=d.id||null;if(!id)continue;const match=keyedDetails.find((sd)=>sd.id===id&&!usedIds.has(sd.id));if(!match)continue;usedIds.add(match.id);d.open=match.open}let di=0;const plainSaved=savedDetails.filter((sd)=>!sd.id);for(const d of newDetails){if(d.id)continue;const sd=plainSaved[di];di+=1;if(!sd)break;d.open=sd.open}const newScrolls=Array.from(this.querySelectorAll("*")).filter((el)=>el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth);const keyedScrolls=savedScrolls.filter((s)=>s.el.id);const usedScrolls=new Set();for(const el of newScrolls){const id=el.id||null;if(!id)continue;const match=keyedScrolls.find((s)=>s.el.id===id&&!usedScrolls.has(s.el));if(!match)continue;usedScrolls.add(match.el);el.scrollTop=match.top;el.scrollLeft=match.left}let si=0;const plainScrolls=savedScrolls.filter((s)=>!s.el.id);for(const el of newScrolls){if(el.id)continue;const s=plainScrolls[si];si+=1;if(!s)break;el.scrollTop=s.top;el.scrollLeft=s.left}if(hadFocus){let target=null;if(hadFocus.id){try{target=this.querySelector("#"+CSS.escape(hadFocus.id))}catch(e){target=null}}if(!target&&hadFocusName){try{target=this.querySelector('[name="'+CSS.escape(hadFocusName)+'"]')}catch(e){target=null}}if(!target&&hadFocusIndex>=0){const after=Array.from(this.querySelectorAll(_focusableSelector));if(after.length){target=after[Math.min(hadFocusIndex,after.length-1)]}}if(target&&typeof target.focus==="function"){try{target.focus()}catch(e){}}else if(document.contains(hadFocus)){try{hadFocus.focus()}catch(e){}}else{const first=this.querySelector(_focusableSelector);if(first)try{first.focus()}catch(e){}else try{this.focus()}catch(e){}}}this.enhance();this._detachInnerFormControls();this._checkedAttrChanged=false}finally{this._contourRendering=false}}disconnectedCallback(){this._pendingRerender=false;this._ensureCache=null;this._batchDepth=0;this._batchDirty=false;this._wiredFormData=false;runDisposers(this)}adoptedCallback(){if(this._contourAuthored){this._applyParts(this);this._applyDensity()}}enhance(){}_syncFormValue(){if(!this._internals)return;const ctl=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!ctl)return;const boolean=ctl.type==="checkbox"||ctl.type==="radio";const value=boolean?(ctl.checked?(ctl.value||"on"):null):ctl.value;this._internals.setFormValue(value);this._syncValidity(this.hasAttribute("required")&&!value)}_syncValidity(valueMissing){if(!this._internals)return;if(valueMissing)this._internals.setValidity({valueMissing:true},"This field is required.");else this._internals.setValidity({});this._setCustomState("data-invalid",!!valueMissing)}_setCustomState(name,on){let internals=this._internals;if(!internals){if(this._stateInternals)internals=this._stateInternals;else if(typeof this.attachInternals==="function"){try{internals=this._stateInternals=this.attachInternals()}catch(e){return}}}const states=internals&&internals.states;if(!states)return;if(on){if(!states.has(name))states.add(name)}else if(states.has(name))states.delete(name)}_emitForm(type){if(!this._internals)return;const ctl=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!ctl)return;const boolean=ctl.type==="checkbox"||ctl.type==="radio";this.dispatchEvent(new CustomEvent(type,{bubbles:true,composed:true,detail:{name:this.getAttribute("name"),value:boolean?(ctl.checked?(ctl.value||"on"):null):ctl.value,checked:boolean?ctl.checked:null,},}))}formResetCallback(){for(const ctl of this.querySelectorAll("input, textarea, select")){if(ctl.type==="checkbox"||ctl.type==="radio"){ctl.checked=this.hasAttribute("checked")}else if(ctl.tagName==="SELECT"){const chosen=ctl.querySelector("option[selected], option:first-of-type");ctl.value=chosen?chosen.value:""}else{ctl.value=this.hasAttribute("value")?this.getAttribute("value"):(ctl.getAttribute("value")||"")}}this._syncFormValue()}formDisabledCallback(disabled){for(const ctl of this.querySelectorAll("input, textarea, select, button")){if(disabled)ctl.setAttribute("disabled","");else ctl.removeAttribute("disabled")}}formStateRestoreCallback(state){if(!this._internals||state===null||state===undefined)return;const controls=Array.from(this.querySelectorAll("input, textarea, select"));const str=String(state);const match=controls.find((c)=>(c.type==="checkbox"||c.type==="radio")&&c.value===str);if(match){match.checked=true;for(const other of controls){if(other!==match&&other.type==="radio"&&other.name===match.name)other.checked=false}}else if(controls.length){controls[0].value=str}this._syncFormValue()}checkValidity(){return this._internals?this._internals.checkValidity():true}reportValidity(){return this._internals?this._internals.reportValidity():true}_wireFormData(){if(!this._internals||this._wiredFormData)return;const form=this._internals.form;if(!form)return;this._wiredFormData=true;const myName=this.getAttribute("name");const onFormChange=(e)=>{const t=e.target;if(t&&t.type==="radio"&&t.name&&t.name===myName)this._syncFormValue()};form.addEventListener("change",onFormChange);const onFormData=()=>this._syncFormValue();form.addEventListener("formdata",onFormData);onDispose(this,()=>{form.removeEventListener("change",onFormChange);form.removeEventListener("formdata",onFormData)})}_detachInnerFormControls(){if(!this._internals)return;for(const ctl of this.querySelectorAll("input, textarea, select")){if(ctl.hasAttribute("name")&&ctl.getAttribute("form")!=="")ctl.setAttribute("form","")}}batch(fn){if(typeof fn!=="function")return;this._batchDepth=(this._batchDepth||0)+1;this._batchDirty=this._batchDirty||false;try{fn()}finally{this._batchDepth-=1;if(this._batchDepth===0&&this._batchDirty){this._batchDirty=false;if(this.isConnected&&this._contourAuthored){this.attributeChangedCallback("__rerender__",null,"")}}}}requestRender(){if(this._contourRerenderQueued)return;this._contourRerenderQueued=true;queueMicrotask(()=>{this._contourRerenderQueued=false;if(!this.isConnected||!this._contourAuthored)return;this.attributeChangedCallback("__rerender__",null,"")})}_applyParts(root){const scope=root||this;const nodes=scope.querySelectorAll?Array.from(scope.querySelectorAll("[class]")):[];for(const node of nodes){if(node.hasAttribute("part"))continue;if(typeof node.className!=="string")continue;for(const c of node.className.split(/\s+/)){const m=c.match(/^c-[a-z0-9-]+__([a-z0-9-]+)$/);if(m){node.setAttribute("part",m[1]);break}}}}_applyDensity(){const density=this.getAttribute("density");if(density!==null)this.setAttribute("data-density",density);else if(this.hasAttribute("data-density"))this.removeAttribute("data-density")}_ownerBetween(node,root){for(let p=node.parentElement;p&&p!==root;p=p.parentElement){if(p instanceof ContourBase)return p}return null}ensure(selector,factory,parent){const root=parent||this;if(!root._ensureCache||root._ensureCacheGen!==this._contourRenderGen){root._ensureCache=new Map();root._ensureCacheGen=this._contourRenderGen}const cache=root._ensureCache;const key=root===this?selector:"\u0000"+root+"\u0000"+selector;let node=cache.get(key);if(node===undefined){node=null;for(const candidate of root.querySelectorAll(selector)){if(!this._ownerBetween(candidate,root)){node=candidate;break}}cache.set(key,node)}if(!node){node=factory();if(node&&node.setAttribute&&!node.hasAttribute("part")){const m=String(selector).match(/\.c-[a-z0-9-]+__([a-z0-9-]+)/);if(m)node.setAttribute("part",m[1])}root.appendChild(node);cache.set(key,node)}return node}}export function withBrownout(Base){return class extends Base{static get observed(){const base=(super.observed&&Array.isArray(super.observed))?super.observed:[];const extra=["brownout","brownout-level"];return Array.from(new Set(base.concat(extra)))}brownoutLevel(){return super.brownoutLevel?super.brownoutLevel():(parseInt(this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0",10)||0)}shed(kind,threshold){return this.brownoutLevel()>=(threshold||1)}}}export const simple=(classes)=>class extends ContourBase{render(){classes.forEach((c)=>this.classList.add(c));for(const c of Array.from(this.classList)){if(classes.some((base)=>c.startsWith(base+"--")))this.classList.remove(c)}MODS.forEach((attr)=>{if(this.hasAttribute(attr)){const val=this.getAttribute(attr);classes.forEach((c)=>{const prefix=c.replace("c-","");this.classList.add(`c-${prefix}--${val}`)})}})}};export const CLASS_ONLY=["box","cluster","container","row","scrim","stack"];export function supportsUntilFound(){try{const t=document.createElement("div");t.setAttribute("hidden","until-found");return t.getAttribute("hidden")==="until-found"}catch(e){return false}}export function formatValue(value,format,locale,unit){if(!format)return value;const loc=locale||(typeof navigator!=="undefined"&&navigator.language)||"en";if(format==="date"||format==="time"){try{const opts=format==="time"?{timeStyle:"short"}:undefined;return new Intl.DateTimeFormat(loc,opts).format(new Date(value))}catch(e){return value}}if(format==="relative"){try{const num=Number(value);let seconds=num;if(Number.isNaN(num)){const then=new Date(value).getTime();if(Number.isFinite(then))seconds=(then-Date.now())/1000}const rtf=new Intl.RelativeTimeFormat(loc,{numeric:"auto"});if(Math.abs(seconds)<60)return rtf.format(Math.round(seconds),"second");if(Math.abs(seconds)<3600)return rtf.format(Math.round(seconds/60),"minute");if(Math.abs(seconds)<86400)return rtf.format(Math.round(seconds/3600),"hour");return rtf.format(Math.round(seconds/86400),"day")}catch(e){return value}}let opts={};if(format==="currency")opts={style:"currency",currency:"USD"};else if(format==="percent")opts={style:"percent"};else if(format==="compact")opts={notation:"compact"};else if(format==="unit")opts={style:"unit",unit:unit||"meter"};else if(format!=="number"){try{opts=JSON.parse(format)}catch(e){return value}}try{return new Intl.NumberFormat(loc,opts).format(Number(value))}catch(e){return value}}export function haversine(lat1,lon1,lat2,lon2){const R=6371000;const toRad=(d)=>d*Math.PI/180;const dLat=toRad(lat2-lat1);const dLon=toRad(lon2-lon1);const a=Math.sin(dLat/2)**2+Math.cos(toRad(lat1))*Math.cos(toRad(lat2))*Math.sin(dLon/2)**2;return 2*R*Math.asin(Math.sqrt(a))}export function bearing(lat1,lon1,lat2,lon2){const toRad=(d)=>d*Math.PI/180;const toDeg=(r)=>r*180/Math.PI;const dLon=toRad(lon2-lon1);const y=Math.sin(dLon)*Math.cos(toRad(lat2));const x=Math.cos(toRad(lat1))*Math.sin(toRad(lat2))-Math.sin(toRad(lat1))*Math.cos(toRad(lat2))*Math.cos(dLon);return(toDeg(Math.atan2(y,x))+360)%360}export function mercatorResolution(lat,zoom){return 156543.03392*Math.cos(lat*Math.PI/180)/Math.pow(2,zoom)}"use strict";export function arcPath(cx,cy,r,inner,startAngle,endAngle){cx=Number.isFinite(cx)?cx:0;cy=Number.isFinite(cy)?cy:0;r=Number.isFinite(r)&&r>0?r:0;inner=Number.isFinite(inner)&&inner>=0?inner:0;startAngle=Number.isFinite(startAngle)?startAngle:0;endAngle=Number.isFinite(endAngle)?endAngle:0;const largeArc=endAngle-startAngle>Math.PI?1:0;const x1=cx+r*Math.cos(startAngle);const y1=cy+r*Math.sin(startAngle);const x2=cx+r*Math.cos(endAngle);const y2=cy+r*Math.sin(endAngle);if(inner<=0){return`M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} Z`}const ix1=cx+inner*Math.cos(endAngle);const iy1=cy+inner*Math.sin(endAngle);const ix2=cx+inner*Math.cos(startAngle);const iy2=cy+inner*Math.sin(startAngle);return`M ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} L ${ix1} ${iy1} A ${inner} ${inner} 0 ${largeArc} 0 ${ix2} ${iy2} Z`}export function donutSlices(values,opts){opts=opts||{};const cx=opts.cx!=null?opts.cx:100;const cy=opts.cy!=null?opts.cy:100;const r=opts.r!=null?opts.r:90;const inner=opts.inner!=null?opts.inner:55;const gap=opts.gap!=null?opts.gap:0.02;const total=values.reduce((a,b)=>a+(Number(b)||0),0)||1;let angle=-Math.PI/2;const out=[];values.forEach((v,i)=>{const num=Number(v)||0;const frac=num/total;if(!(num>0)){angle+=frac*Math.PI*2;return}const sweep=frac*Math.PI*2-gap;const start=angle+gap/2;const end=start+Math.max(0,sweep);out.push({path:arcPath(cx,cy,r,inner,start,end),value:num,index:i});angle+=frac*Math.PI*2});return out}export function barRects(values,opts){opts=opts||{};const width=opts.width!=null?opts.width:300;const height=opts.height!=null?opts.height:120;const gap=opts.gap!=null?opts.gap:2;const max=opts.max!=null?opts.max:(Math.max.apply(null,values.map((v)=>Number(v)||0))||1);if(!Number.isFinite(max)||max<=0)return values.map(()=>({x:0,y:height,width:0,height:0}));const n=values.length||1;const slot=width/n;const barW=Math.max(1,slot-gap);return values.map((v,i)=>{const h=((Number(v)||0)/max)*height;return{x:i*slot+gap/2,y:height-h,width:barW,height:h}})}export function polylinePoints(values,opts){opts=opts||{};const width=opts.width!=null?opts.width:300;const height=opts.height!=null?opts.height:120;const nums=values.map((v)=>Number(v)||0);if(!nums.length)return"";const max=opts.max!=null?opts.max:Math.max.apply(null,nums);const min=opts.min!=null?opts.min:Math.min.apply(null,nums);const range=(Number.isFinite(max-min)&&(max-min)!==0)?(max-min):1;const n=nums.length||1;return nums.map((v,i)=>{const x=(i/Math.max(1,n-1))*width;const y=height-((v-min)/range)*height;return x.toFixed(2)+","+y.toFixed(2)}).join(" ")}export function smoothPath(values,opts){const pts=polylinePoints(values,opts).split(" ").map((p)=>p.split(",").map(Number));if(!pts.length)return"";let d=`M ${pts[0][0]} ${pts[0][1]}`;for(let i=1;i<pts.length;i++){const prev=pts[i-1];const cur=pts[i];const cpx=(prev[0]+cur[0])/2;d+=` C ${cpx} ${prev[1]}, ${cpx} ${cur[1]}, ${cur[0]} ${cur[1]}`}return d}export function compassNeedle(cx,cy,length,angleDeg,width){angleDeg=angleDeg==null?0:angleDeg;width=width==null?3:width;const a=(angleDeg-90)*Math.PI/180;const tipX=cx+length*Math.cos(a);const tipY=cy+length*Math.sin(a);const tail=length*0.25;const tailX=cx-tail*Math.cos(a);const tailY=cy-tail*Math.sin(a);const perpX=Math.cos(a+Math.PI/2);const perpY=Math.sin(a+Math.PI/2);const b1x=cx+width*perpX;const b1y=cy+width*perpY;const b2x=cx-width*perpX;const b2y=cy-width*perpY;return`M ${tipX.toFixed(2)} ${tipY.toFixed(2)} L ${b1x.toFixed(2)} ${b1y.toFixed(2)} L ${tailX.toFixed(2)} ${tailY.toFixed(2)} L ${b2x.toFixed(2)} ${b2y.toFixed(2)} Z`}export function scaleBarTicks(value,segments){value=Number(value)||0;segments=Math.max(1,Math.round(segments||4));const out=[];for(let i=0;i<=segments;i++){out.push((value/segments)*i)}return out}export const MARKER_SHAPES=["circle","square","triangle","diamond","star"];export function markerStyles(shape){const map={circle:"border-radius:50%",square:"border-radius:0",triangle:"clip-path:polygon(50% 0%,0% 100%,100% 100%)",diamond:"transform:rotate(45deg)",star:"clip-path:polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)",};return map[shape]||""}export function assignMarkers(items){return(items||[]).map((it,i)=>({...it,marker:MARKER_SHAPES[i%MARKER_SHAPES.length]}))}const WIRED_HOSTS=new WeakMap();export const wcReset=(host)=>{WIRED_HOSTS.delete(host)};const wcClaim=(host,name)=>{let set=WIRED_HOSTS.get(host);if(!set){set=new Set();WIRED_HOSTS.set(host,set)}if(set.has(name))return false;set.add(name);return true};const wcScopes=(host)=>(host.shadowRoot?[host,host.shadowRoot]:[host]);const wcAll=(host,sel)=>{const found=[];for(const scope of wcScopes(host)){for(const el of scope.querySelectorAll(sel))if(!found.includes(el))found.push(el)}return found};const wcOne=(host,sel)=>wcAll(host,sel)[0]||null;const wcSelfOrAll=(host,sel)=>{const found=typeof host.matches==="function"&&host.matches(sel)?[host]:[];for(const el of wcAll(host,sel))if(!found.includes(el))found.push(el);return found};const wcShadowOf=(node)=>{const root=node&&node.getRootNode?node.getRootNode():null;return root&&root.host?root:null};const wcGroup=(host,group,sel)=>{const found=Array.from(group.querySelectorAll(sel));if(wcShadowOf(group)&&wcShadowOf(group).host===host){for(const el of host.querySelectorAll(sel))if(!found.includes(el))found.push(el)}return found};const HEARD=new WeakMap();const wcListen=(host,type,handler)=>{const scoped=(e)=>{let seen=HEARD.get(e);if(!seen){seen=new Set();HEARD.set(e,seen)}if(seen.has(scoped))return;seen.add(scoped);handler(e)};for(const scope of wcScopes(host))scope.addEventListener(type,scoped)};const wcOwned=(host,node)=>!!node&&wcScopes(host).some((scope)=>scope.contains(node));const wcClosest=(host,target,sel)=>(typeof target?.closest==="function"&&wcOwned(host,target))?target.closest(sel):null;const wcEmit=(host,name,detail)=>{host.dispatchEvent(new CustomEvent(name,{detail,bubbles:true,composed:true}))};function isRtl(host){let el=host;while(el&&el.nodeType===1){const d=el.getAttribute&&el.getAttribute("dir");if(d)return d.toLowerCase()==="rtl";el=el.parentElement}try{return(document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl"}catch(e){return false}}export function wireTabs(host){if(!wcClaim(host,"tabs"))return;for(const list of wcSelfOrAll(host,".c-tabs__list, .c-code-tabs__list")){const isCode=list.classList.contains("c-code-tabs__list");const panelSel=isCode?".c-code-tabs__panel":".c-tabs__panel";const tabsOf=()=>wcGroup(host,list,"[role='tab']");const activate=(tab,focus)=>{const tabs=tabsOf();tabs.forEach((t)=>{const selected=t===tab;t.setAttribute("aria-selected",String(selected));t.tabIndex=selected?0:-1;const ctrl=t.getAttribute("aria-controls");if(!ctrl)return;const panel=wcOne(host,"#"+CSS.escape(ctrl))||document.getElementById(ctrl);if(panel)panel.hidden=!selected});const panels=wcAll(host,panelSel);if(panels.length){const index=tabs.indexOf(tab);panels.forEach((p,i)=>{p.hidden=i!==index})}if(focus)try{tab.focus()}catch(e){}const name=tab.getAttribute("aria-controls")||tab.textContent||"";host.dispatchEvent(new CustomEvent("contour:tab-change",{bubbles:true,composed:true,detail:{index:tabs.indexOf(tab),label:name}}))};const runActivation=(tab,focus)=>{const can=!focus&&typeof document.startViewTransition==="function"&&!(typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);if(can){try{document.startViewTransition(()=>activate(tab,focus));return}catch(e){}}activate(tab,focus)};wcListen(host,"click",(e)=>{const tab=wcClosest(host,e.target,"[role='tab']");if(tab&&tabsOf().includes(tab))runActivation(tab,false)});wcListen(host,"keydown",(e)=>{let tab=wcClosest(host,e.target,"[role='tab']");if(!tab&&e.target&&e.target.getAttribute&&e.target.getAttribute("role")==="tab"&&wcOwned(host,e.target))tab=e.target;const tabs=tabsOf();const index=tabs.indexOf(tab);if(index<0)return;const vertical=host.getAttribute("orientation")==="vertical";const rtl=isRtl(host);const move=vertical?(rtl?{ArrowDown:index-1,ArrowUp:index+1,Home:tabs.length-1,End:0}:{ArrowDown:index+1,ArrowUp:index-1,Home:0,End:tabs.length-1}):(rtl?{ArrowRight:index-1,ArrowLeft:index+1,Home:tabs.length-1,End:0}:{ArrowRight:index+1,ArrowLeft:index-1,Home:0,End:tabs.length-1});if(!(e.key in move))return;e.preventDefault();const next=tabs[(move[e.key]+tabs.length)%tabs.length];if(next)runActivation(next,true)});const tabs=tabsOf();const persist=host.getAttribute("persist");let restored=null;if(persist==="storage"&&host.id){try{restored=localStorage.getItem("contour-tabs:"+host.id)}catch(e){restored=null}}else if(persist==="url"){try{const params=new URLSearchParams(window.location.search);const v=params.get("c-tabs");if(v!==null)restored=v}catch(e){restored=null}}const marked=tabs.find((t)=>t.getAttribute("aria-selected")==="true");let first=marked||tabs[0];if(restored!==null){const idx=parseInt(restored,10);if(Number.isFinite(idx)&&tabs[idx])first=tabs[idx]}if(first)activate(first,false);if(persist==="storage"&&host.id){host.addEventListener("contour:tab-change",(e)=>{try{localStorage.setItem("contour-tabs:"+host.id,String(e.detail&&e.detail.index))}catch(err){}})}else if(persist==="url"){host.addEventListener("contour:tab-change",(e)=>{try{const url=new URL(window.location.href);url.searchParams.set("c-tabs",String(e.detail&&e.detail.index));window.history.replaceState(null,"",url.toString())}catch(err){}})}}}export function wireSegmented(host){const groups=wcSelfOrAll(host,".c-segmented");const normalize=()=>{const authored=host.getAttribute("value");const chosen=authored!==host._segAuthorValue?authored:null;if(chosen!==null)host._segAuthorValue=authored;let seen=0;for(const g of groups){if(!g.hasAttribute("role"))g.setAttribute("role","group");const label=host.getAttribute("label");if(label&&!g.hasAttribute("aria-label"))g.setAttribute("aria-label",label);const opts=wcGroup(host,g,"button");seen+=opts.length;opts.forEach((b)=>{b.classList.add("c-segmented__option");b.setAttribute("aria-pressed",chosen!==null&&chosen!==undefined?String(b.dataset.value===chosen):(b.getAttribute("aria-pressed")==="true"?"true":"false"))});const chosenOpt=opts.find((b)=>b.getAttribute("aria-pressed")==="true")||opts[0];opts.forEach((b)=>{b.tabIndex=b===chosenOpt?0:-1})}return seen};if(!normalize()){if(!host._segRetryScheduled){host._segRetryScheduled=true;setTimeout(()=>{host._segRetryScheduled=false;normalize()},0)}}if(!wcClaim(host,"segmented"))return;const activate=(btn)=>{const seg=groups.find((g)=>wcGroup(host,g,"button").includes(btn));if(!seg)return;wcGroup(host,seg,"button").forEach((o)=>{const on=o===btn;o.setAttribute("aria-pressed",String(on));o.tabIndex=on?0:-1});wcEmit(host,"contour:change",{value:btn.dataset.value||btn.textContent.trim()})};wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,"button");if(!btn)return;activate(btn)});wcListen(host,"keydown",(e)=>{const btn=wcClosest(host,e.target,"button");if(!btn)return;const seg=groups.find((g)=>wcGroup(host,g,"button").includes(btn));if(!seg)return;const opts=wcGroup(host,seg,"button");const idx=opts.indexOf(btn);let next=-1;const rtl=isRtl(host);if(e.key==="ArrowRight"||e.key==="ArrowDown")next=rtl?Math.max(idx-1,0):Math.min(idx+1,opts.length-1);else if(e.key==="ArrowLeft"||e.key==="ArrowUp")next=rtl?Math.min(idx+1,opts.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=opts.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();activate(btn);return}if(next>=0&&next!==idx){e.preventDefault();opts[next].focus()}})}export function wireCombobox(host){wireComboboxDocDismiss();const input=wcOne(host,".c-combobox__input");const list=wcOne(host,".c-combobox__list");if(!input||!list)return;const optionList=()=>wcAll(host,".c-combobox__option");if(!list.id)list.id=contourId("c-combobox-list");list.setAttribute("role","listbox");input.setAttribute("role","combobox");input.setAttribute("aria-haspopup","listbox");input.setAttribute("aria-controls",list.id);input.setAttribute("aria-expanded",list.hasAttribute("hidden")?"false":"true");if(!input.hasAttribute("aria-autocomplete"))input.setAttribute("aria-autocomplete","list");optionList().forEach((opt,i)=>{if(!opt.id)opt.id=contourId("c-combobox-option");opt.setAttribute("role","option");if(!opt.hasAttribute("aria-selected"))opt.setAttribute("aria-selected","false")});if(!wcClaim(host,"combobox"))return;const liveInput=()=>wcOne(host,".c-combobox__input");const liveList=()=>wcOne(host,".c-combobox__list");let cursor=-1;const mark=(visible)=>{const field=liveInput();visible.forEach((o,i)=>{const on=i===cursor;o.classList.toggle("c-combobox__option--active",on);o.setAttribute("aria-selected",String(on))});if(field){const active=cursor>=0?visible[cursor]:null;if(active)field.setAttribute("aria-activedescendant",active.id);else field.removeAttribute("aria-activedescendant")}};const filter=(query)=>{const q=(query||"").toLowerCase();if(host._comboboxVirtual&&typeof host._renderComboboxWindow==="function"){host._renderComboboxWindow(q,true);cursor=-1;return}optionList().forEach((o)=>{o.hidden=!!(q&&!o.textContent.toLowerCase().includes(q))});cursor=-1};const open=()=>{const l=liveList();if(!l)return;l.removeAttribute("hidden");const field=liveInput();if(field)field.setAttribute("aria-expanded","true")};const close=()=>{const l=liveList();if(l)l.setAttribute("hidden","");const field=liveInput();if(field){field.setAttribute("aria-expanded","false");field.removeAttribute("aria-activedescendant")}cursor=-1;optionList().forEach((o)=>{o.classList.remove("c-combobox__option--active");o.setAttribute("aria-selected","false")})};if(host._comboboxVirtual&&list&&!list._contourVirtualScroll){list._contourVirtualScroll=true;list.addEventListener("scroll",()=>{if(typeof host._renderComboboxWindow==="function")host._renderComboboxWindow(host._comboboxQuery||"")},{passive:true})}const commit=(opt)=>{const field=liveInput();if(!field)return;if(host.hasAttribute("multiple")){const now=opt.getAttribute("aria-selected")==="true";opt.setAttribute("aria-selected",String(!now));opt.classList.toggle("c-combobox__option--selected",!now);const selected=(host.getAttribute("value")||"").split(",").map((v)=>v.trim()).filter(Boolean);const value=host._comboboxVirtual&&host._comboboxFiltered?host._comboboxFiltered.find((item)=>item.index===Number(opt.dataset.optionIndex))?.value:opt.textContent.trim();const position=selected.indexOf(String(value));if(now&&position>=0)selected.splice(position,1);if(!now&&position<0)selected.push(String(value));host.setAttribute("value",selected.join(","));if(typeof host._syncFormValue==="function")host._syncFormValue();wcEmit(host,"contour:select",{value:selected});field.focus();return}field.value=opt.textContent;wcEmit(host,"contour:select",{value:field.value});close();field.focus()};const isField=(target)=>wcClosest(host,target,".c-combobox__input")!==null;wcListen(host,"input",(e)=>{if(!isField(e.target))return;host._comboboxQuery=e.target.value;filter(e.target.value);open();if(typeof host._emitForm==="function")host._emitForm("contour:input")});wcListen(host,"focusin",(e)=>{if(!isField(e.target))return;filter(e.target.value);open()});wcListen(host,"keydown",(e)=>{if(!isField(e.target))return;const visible=optionList().filter((o)=>!o.hidden);if(e.key==="ArrowDown"){e.preventDefault();cursor=Math.min(cursor+1,visible.length-1);mark(visible)}else if(e.key==="ArrowUp"){e.preventDefault();cursor=Math.max(cursor-1,0);mark(visible)}else if(e.key==="Home"){e.preventDefault();cursor=0;mark(visible)}else if(e.key==="End"){e.preventDefault();cursor=Math.max(0,visible.length-1);mark(visible)}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(cursor>=0&&visible[cursor])commit(visible[cursor])}else if(e.key==="Escape")close()});wcListen(host,"click",(e)=>{const opt=wcClosest(host,e.target,".c-combobox__option");if(opt){commit(opt);return}if(!wcOwned(host,e.target)||!host.contains(e.target))close()})}let _comboboxDocWired=false;function wireComboboxDocDismiss(){if(_comboboxDocWired)return;_comboboxDocWired=true;document.addEventListener("click",(e)=>{for(const host of document.querySelectorAll("contour-combobox, contour-shadow-combobox")){const list=host.shadowRoot?host.shadowRoot.querySelector(".c-combobox__list"):host.querySelector(".c-combobox__list");const input=host.shadowRoot?host.shadowRoot.querySelector(".c-combobox__input"):host.querySelector(".c-combobox__input");if(!list||list.hasAttribute("hidden"))continue;const root=host.shadowRoot||host;if(root.contains(e.target))continue;list.setAttribute("hidden","")}})}const visibleStops=(host)=>wcAll(host,".c-tree__toggle, .c-tree__leaf").filter((el)=>!el.closest(".c-tree__children[hidden]"));export function wireTree(host){const nodes=()=>wcAll(host,".c-tree__node");const rootList=wcSelfOrAll(host,"ul.c-tree")[0];if(rootList&&!rootList.hasAttribute("role"))rootList.setAttribute("role","tree");wcAll(host,".c-tree__children").forEach((ul)=>{if(!ul.hasAttribute("role"))ul.setAttribute("role","group")});const levelOf=(node)=>{let level=1;for(let p=node.parentElement;p;p=p.parentElement)if(p.classList&&p.classList.contains("c-tree__children"))level++;return level};nodes().forEach((node)=>{if(node.getAttribute("role")!=="treeitem")node.setAttribute("role","treeitem");node.setAttribute("aria-level",String(levelOf(node)));const row=node.querySelector(":scope > .c-tree__row");if(row)node.setAttribute("aria-expanded",row.querySelector(":scope > .c-tree__toggle")?.getAttribute("aria-expanded")||"false");else if(node.hasAttribute("aria-expanded"))node.removeAttribute("aria-expanded")});const stops=visibleStops(host);const authored=stops.find((el)=>el.getAttribute("tabindex")==="0");const active=authored||stops.find((el)=>el===document.activeElement)||stops[0];stops.forEach((el)=>el.setAttribute("tabindex",el===active?"0":"-1"));wcAll(host,".c-tree__toggle, .c-tree__leaf").forEach((el)=>{if(!stops.includes(el))el.setAttribute("tabindex","-1")});if(!wcClaim(host,"tree"))return;host._selectedTree=host._selectedTree||new Set();let lastTreeIndex=-1;wcListen(host,"change",(e)=>{const cb=e.target&&e.target.closest?e.target.closest(".c-tree__select"):null;if(!cb||!host.contains(cb))return;const cbs=Array.from(host.querySelectorAll(".c-tree__select"));const idx=cbs.indexOf(cb);const label=(cb.parentElement&&cb.parentElement.textContent||"").trim().slice(0,120);if(e.shiftKey&&lastTreeIndex>=0){const from=Math.min(lastTreeIndex,idx);const to=Math.max(lastTreeIndex,idx);for(let i=from;i<=to;i++){cbs[i].checked=cb.checked;const lbl=(cbs[i].parentElement&&cbs[i].parentElement.textContent||"").trim().slice(0,120);if(cb.checked)host._selectedTree.add(lbl);else host._selectedTree.delete(lbl)}}else if(!e.ctrlKey&&!e.metaKey){if(cb.checked){cbs.forEach((c,i)=>{if(i!==idx&&c.checked){c.checked=false;const lbl=(c.parentElement&&c.parentElement.textContent||"").trim().slice(0,120);host._selectedTree.delete(lbl)}})}if(cb.checked)host._selectedTree.add(label);else host._selectedTree.delete(label)}else{if(cb.checked)host._selectedTree.add(label);else host._selectedTree.delete(label)}lastTreeIndex=idx;wcEmit(host,"contour:select",{labels:Array.from(host._selectedTree)})});wcAll(host,".c-tree__node, .c-tree__leaf").forEach((n)=>{if(!n.hasAttribute("draggable"))n.setAttribute("draggable","true")});let dragLabel=null;wcListen(host,"dragstart",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node)return;dragLabel=(node.textContent||"").trim().slice(0,120);if(e.dataTransfer){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",dragLabel)}catch(err){}}});wcListen(host,"dragover",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node)return;e.preventDefault();if(e.dataTransfer)e.dataTransfer.dropEffect="move"});wcListen(host,"drop",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node||!dragLabel)return;e.preventDefault();const toLabel=(node.textContent||"").trim().slice(0,120);if(toLabel&&toLabel!==dragLabel){wcEmit(host,"contour:move",{from:dragLabel,to:toLabel})}dragLabel=null});const persist=host.getAttribute("persist");if(persist==="storage"&&host.id){try{const saved=localStorage.getItem("contour-tree:"+host.id);if(saved!==null){const labels=JSON.parse(saved);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));wcAll(host,".c-tree__row").forEach((row)=>{const currentToggle=row.querySelector(":scope > .c-tree__toggle");if(currentToggle?.getAttribute("aria-expanded")==="true")return;const label=(row.textContent||"").trim().slice(0,120);if(!want.has(label))return;const toggle=row.querySelector(":scope > .c-tree__toggle");if(!toggle)return;const node=row.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;toggle.setAttribute("aria-expanded","true");if(node)node.setAttribute("aria-expanded","true");if(children)children.removeAttribute("hidden")})}}}catch(e){}}else if(persist==="url"){try{const v=new URLSearchParams(window.location.search).get("c-tree");if(v!==null){const labels=JSON.parse(v);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));wcAll(host,".c-tree__row").forEach((row)=>{const currentToggle=row.querySelector(":scope > .c-tree__toggle");if(currentToggle?.getAttribute("aria-expanded")==="true")return;const label=(row.textContent||"").trim().slice(0,120);if(!want.has(label))return;const toggle=row.querySelector(":scope > .c-tree__toggle");if(!toggle)return;const node=row.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;toggle.setAttribute("aria-expanded","true");if(node)node.setAttribute("aria-expanded","true");if(children)children.removeAttribute("hidden")})}}}catch(e){}}const toggleNode=(toggle)=>{const wasOpen=toggle.getAttribute("aria-expanded")==="true";toggle.setAttribute("aria-expanded",String(!wasOpen));const row=toggle.closest(".c-tree__row")||toggle.parentElement;const node=toggle.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;if(children){if(wasOpen){if(supportsUntilFound())children.setAttribute("hidden","until-found");else children.hidden=true}else{children.removeAttribute("hidden")}}if(node)node.setAttribute("aria-expanded",String(!wasOpen));wcEmit(host,"contour:toggle",{open:!wasOpen,label:(row?row.textContent:"").trim().slice(0,120)});if(persist==="storage"&&host.id){try{const open=[];wcAll(host,".c-tree__row").forEach((r)=>{const toggle=r.querySelector(":scope > .c-tree__toggle");if(toggle?.getAttribute("aria-expanded")==="true")open.push((r.textContent||"").trim().slice(0,120))});localStorage.setItem("contour-tree:"+host.id,JSON.stringify(open))}catch(e){}}else if(persist==="url"){try{const open=[];wcAll(host,".c-tree__row").forEach((r)=>{const toggle=r.querySelector(":scope > .c-tree__toggle");if(toggle?.getAttribute("aria-expanded")==="true")open.push((r.textContent||"").trim().slice(0,120))});const url=new URL(window.location.href);url.searchParams.set("c-tree",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}catch(e){}}};const branchOf=(el)=>(el.classList&&el.classList.contains("c-tree__toggle")?el:null);const stopsOf=()=>visibleStops(host);const rove=(keep)=>{wcAll(host,".c-tree__toggle, .c-tree__leaf").forEach((el)=>el.setAttribute("tabindex",el===keep?"0":"-1"))};wcListen(host,"click",(e)=>{let toggle=wcClosest(host,e.target,".c-tree__toggle");if(!toggle){const row=wcClosest(host,e.target,".c-tree__row");if(row)toggle=row.querySelector(":scope > .c-tree__toggle")}if(!toggle)return;e.preventDefault();e.stopPropagation();toggleNode(toggle)});wcListen(host,"focusin",(e)=>{if(!wcClosest(host,e.target,".c-tree__toggle, .c-tree__leaf"))return;rove(e.target)});wcListen(host,"keydown",(e)=>{const toggle=wcClosest(host,e.target,".c-tree__toggle, .c-tree__leaf");if(!toggle)return;const items=stopsOf();const idx=items.indexOf(toggle);if(e.key==="Enter"||e.key===" "){if(branchOf(toggle)){e.preventDefault();toggleNode(toggle)}return}if(e.key==="ArrowRight"){const branch=branchOf(toggle);const closed=branch&&branch.getAttribute("aria-expanded")==="false";e.preventDefault();if(closed){toggleNode(branch);rove(toggle)}else{const next=items[idx+1];if(next){next.focus();rove(next)}}return}if(e.key==="ArrowLeft"){const branch=branchOf(toggle);if(branch&&branch.getAttribute("aria-expanded")==="true"){e.preventDefault();toggleNode(branch);rove(toggle)}else{const parent=toggle.closest(".c-tree__children");const owner=parent?parent.closest(".c-tree__node"):null;const up=owner?owner.querySelector(":scope > .c-tree__row > .c-tree__toggle"):null;if(up){e.preventDefault();up.focus();rove(up)}}return}let next=-1;if(e.key==="ArrowDown")next=Math.min(idx+1,items.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=items.length-1;if(next>=0&&next!==idx){e.preventDefault();items[next].focus();rove(items[next])}})}export function wireMenu(host){wcAll(host,"[role='menuitem']").forEach((it)=>{if(!it.hasAttribute("tabindex"))it.setAttribute("tabindex",it.getAttribute("aria-disabled")==="true"?"-1":"-1")});const all=()=>wcAll(host,"[role='menuitem']");if(!all().some((it)=>it.getAttribute("tabindex")==="0")&&all().length){const first=all().find((it)=>it.getAttribute("aria-disabled")!=="true");if(first)first.setAttribute("tabindex","0")}if(!wcClaim(host,"menu"))return;const submenusOf=(item)=>item.querySelector(":scope > ul.c-menu, :scope > .c-menu");const closeAllSubmenus=()=>{wcAll(host,"[aria-haspopup='menu']").forEach((it)=>it.setAttribute("aria-expanded","false"))};wcListen(host,"keydown",(e)=>{const its=all().filter((it)=>it.getAttribute("aria-disabled")!=="true");if(!its.length)return;const index=its.indexOf(e.target);const target=index>=0?its[index]:null;const sub=target?submenusOf(target):null;if(target&&target.getAttribute("aria-haspopup")==="menu"&&(e.key==="ArrowRight"||e.key==="Enter"||e.key===" ")){if(sub){e.preventDefault();closeAllSubmenus();target.setAttribute("aria-expanded","true");const firstSub=sub.querySelector("[role='menuitem']");if(firstSub){firstSub.setAttribute("tabindex","0");try{firstSub.focus()}catch(err){}}return}}if(e.key==="ArrowLeft"||e.key==="Escape"){const parent=target?target.closest("ul.c-menu"):null;let ancestor=null;if(target){const ul=target.parentElement&&target.parentElement.tagName==="UL"?target.parentElement:null;let node=target.parentElement;while(node&&node!==host){if(node.getAttribute&&node.getAttribute("aria-haspopup")==="menu"&&node.contains(target)&&node!==target){ancestor=node;break}node=node.parentElement}}if(ancestor){e.preventDefault();ancestor.setAttribute("aria-expanded","false");try{ancestor.focus()}catch(err){}return}if(e.key==="Escape"){closeAllSubmenus()}}let next=-1;if(e.key==="ArrowDown")next=index<0?0:Math.min(index+1,its.length-1);else if(e.key==="ArrowUp")next=index<0?its.length-1:Math.max(index-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=its.length-1;if(next>=0){e.preventDefault();its[next].focus();return}if((e.key==="Enter"||e.key===" ")&&index>=0&&!(target&&target.getAttribute("aria-haspopup")==="menu")){e.preventDefault();wcEmit(host,"contour:select",{index,label:its[index].textContent.trim()});closeAllSubmenus()}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ch=e.key.toLowerCase();const match=its.findIndex((it)=>(it.textContent||"").trim().toLowerCase().startsWith(ch));if(match>=0){e.preventDefault();its[match].focus()}}});wcListen(host,"click",(e)=>{const item=wcClosest(host,e.target,"[role='menuitem']");if(!item)return;if(item.getAttribute("aria-disabled")==="true")return;if(item.getAttribute("aria-haspopup")==="menu"){const sub=submenusOf(item);if(sub){const open=item.getAttribute("aria-expanded")==="true";closeAllSubmenus();item.setAttribute("aria-expanded",open?"false":"true");return}}const index=all().indexOf(item);if(index>=0){wcEmit(host,"contour:select",{index,label:item.textContent.trim()});closeAllSubmenus();if(typeof host.hidePopover==="function"){try{host.hidePopover()}catch(e){}}}})}export function wirePagination(host){wcAll(host,".c-pagination__link").forEach((b)=>{if(!b.hasAttribute("tabindex"))b.setAttribute("tabindex","0")});if(!wcClaim(host,"pagination"))return;const activate=(btn)=>{const page=parseInt(btn.textContent,10);if(!Number.isFinite(page))return;wcAll(host,".c-pagination__link").forEach((b)=>{if(parseInt(b.textContent,10)===page)b.setAttribute("aria-current","page");else b.removeAttribute("aria-current")});host.setAttribute("page",String(page));wcEmit(host,"contour:page",{page});if(host.getAttribute("persist")==="storage"&&host.id){try{localStorage.setItem("contour-pagination:"+host.id,String(page))}catch(e){}}else if(host.getAttribute("persist")==="url"){try{const url=new URL(window.location.href);url.searchParams.set("c-pagination",String(page));window.history.replaceState(null,"",url.toString())}catch(e){}}};wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,".c-pagination__link");if(!btn)return;e.preventDefault();const action=btn.getAttribute("data-action");if(action==="prev"||action==="next"){const links=wcAll(host,".c-pagination__link").filter((b)=>!b.getAttribute("data-action"));const cur=links.find((b)=>b.getAttribute("aria-current")==="page");const curPage=cur?(parseInt(cur.textContent,10)||1):1;const page=action==="prev"?Math.max(1,curPage-1):Math.min(links.length,curPage+1);const target=links.find((b)=>parseInt(b.textContent,10)===page);if(target){activate(target);return}}activate(btn)});wcListen(host,"keydown",(e)=>{const btn=wcClosest(host,e.target,".c-pagination__link");if(!btn)return;const links=wcAll(host,".c-pagination__link");const idx=links.indexOf(btn);let next=-1;const rtl=isRtl(host);if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,links.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,links.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=links.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();activate(btn);return}if(next>=0&&next!==idx){e.preventDefault();links[next].focus()}})}export function wireCopy(host){if(!wcClaim(host,"copy"))return;wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,".c-code__copy, .c-install__copy");if(!btn)return;const owner=wcClosest(host,btn,".c-code")||wcClosest(host,btn,".c-install")||host;const src=owner.querySelector("code, .c-install__command");const text=(src?src.textContent:owner.textContent)||"";const confirm=(ok)=>{const icon=btn.querySelector("use");const originalHref=icon&&icon.getAttribute("href");const originalLabel=btn.getAttribute("aria-label")||btn.title||"";if(ok&&icon)icon.setAttribute("href","#i-check");btn.setAttribute("aria-label",ok?"Copied":"Copy failed");btn.dataset.copied=String(ok);const timer=setTimeout(()=>{if(!btn.isConnected)return;if(icon&&originalHref)icon.setAttribute("href",originalHref);btn.setAttribute("aria-label",originalLabel);delete btn.dataset.copied},1600);onDispose(host,()=>clearTimeout(timer))};const doCopy=async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){await navigator.clipboard.writeText(text);return true}}catch(e){}try{const ta=document.createElement("textarea");ta.value=text;ta.setAttribute("readonly","");ta.style.position="fixed";ta.style.top="-9999px";ta.style.opacity="0";document.body.append(ta);ta.select();const ok=document.execCommand("copy");ta.remove();return ok}catch(e){return false}};doCopy().then((ok)=>confirm(ok));wcEmit(host,"contour:copy",{text})})}export function wireRemovable(host){if(!wcClaim(host,"removable"))return;wcListen(host,"click",(e)=>{const drop=(node)=>{if(node&&node.parentNode)node.parentNode.removeChild(node)};const tagBtn=wcClosest(host,e.target,".c-tag__remove");if(tagBtn){e.preventDefault();const tag=wcClosest(host,tagBtn,".c-tag");wcEmit(host,"contour:remove",{label:(tag&&tag.getAttribute("label"))||(tag?tag.textContent.trim():"")});drop(tag);return}const pillBtn=wcClosest(host,e.target,".c-filter-pill__remove");if(pillBtn){e.preventDefault();const pill=wcClosest(host,pillBtn,".c-filter-pill");wcEmit(host,"contour:remove",{key:pill&&pill.getAttribute("key"),value:pill&&pill.getAttribute("value")});drop(pill);return}if(wcClosest(host,e.target,"[data-empty-action]")){wcEmit(host,"contour:empty-action",{state:host.getAttribute("state")||"empty"})}const alertClose=wcClosest(host,e.target,".c-alert__close");if(alertClose){e.preventDefault();wcEmit(host,"contour:close",{});if(host.shadowRoot?host.shadowRoot.contains(alertClose):true){try{host.remove()}catch(err){}}return}const calloutClose=wcClosest(host,e.target,".c-callout__close");if(calloutClose){e.preventDefault();wcEmit(host,"contour:close",{});try{host.remove()}catch(err){}return}})}const modalDepth={n:0};let modalSavedOverflow=null;let modalSavedX=0;let modalSavedY=0;const modalInerted=new Set();const modalStack=[];let modalTrapWired=false;function modalFocusables(host){return Array.from(host.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter((el)=>!el.hasAttribute("disabled")&&el.getAttribute("aria-hidden")!=="true")}function modalTrapHandler(e){if(e.key!=="Tab")return;const host=modalStack[modalStack.length-1];if(!host)return;const f=modalFocusables(host);if(!f.length){e.preventDefault();return}const first=f[0];const last=f[f.length-1];const active=document.activeElement;if(e.shiftKey){if(active===first||!host.contains(active)){e.preventDefault();last.focus()}}else{if(active===last){e.preventDefault();first.focus()}}}export function modalContain(host,open){if(open){if(modalDepth.n===0){modalSavedX=window.scrollX;modalSavedY=window.scrollY;modalSavedOverflow=document.documentElement.style.overflow;document.documentElement.style.overflow="hidden"}modalDepth.n+=1;modalStack.push(host);if(modalDepth.n===1&&!modalTrapWired){modalTrapWired=true;document.addEventListener("keydown",modalTrapHandler)}for(let el=host;el&&el!==document.body;el=el.parentElement){for(const sib of el.parentElement.children){if(sib===el||sib.inert||modalInerted.has(sib))continue;sib.inert=true;modalInerted.add(sib)}}}else{const idx=modalStack.lastIndexOf(host);if(idx>=0)modalStack.splice(idx,1);modalDepth.n=Math.max(0,modalDepth.n-1);if(modalDepth.n===0){for(const el of modalInerted)el.inert=false;modalInerted.clear();document.documentElement.style.overflow=modalSavedOverflow||"";window.scrollTo(modalSavedX,modalSavedY);if(modalTrapWired){document.removeEventListener("keydown",modalTrapHandler);modalTrapWired=false}}}}export const STATE_FALLBACK={empty:"No data",loading:"Loading…",error:"Could not load.",};const remoteInflight=new Map();const REMOTE_CACHE_MAX=64;const remoteCache=new Map();function cacheResult(src,data){if(remoteCache.size>=REMOTE_CACHE_MAX)remoteCache.delete(remoteCache.keys().next().value);remoteCache.set(src,data)}function setStatus(host,status){host._remoteStatus=status;if(status!=="error")host._remoteError=null;if(status==="loading")host.setAttribute("aria-busy","true");else host.removeAttribute("aria-busy");if(typeof host._setCustomState==="function")host._setCustomState("data-loading",status==="loading")}function emitState(host,name,detail){host.dispatchEvent(new CustomEvent(name,{detail,bubbles:true,composed:true}))}function countOf(data){if(Array.isArray(data))return data.length;if(data&&typeof data==="object")return Object.keys(data).length;return data===null||data===undefined?0:1}function leaveRequest(host){const entry=host._remoteEntry;host._remoteEntry=null;if(!entry)return;entry.hosts.delete(host);if(entry.hosts.size===0&&entry.controller)entry.controller.abort()}export function loadRemote(host,fields){const src=host.getAttribute("src");if(!src){leaveRequest(host);setStatus(host,host._remoteData!==undefined?"ready":"idle");return}remoteRefresh(host);const wanted=typeof fields==="string"?[fields]:fields;if(wanted.every((f)=>host.getAttribute(f)!==null)){leaveRequest(host);setStatus(host,"ready");return}if(!remoteVisible(host)){setStatus(host,"loading");return}const noCache=host.hasAttribute("no-cache");const cacheKey=host.getAttribute("cache-key")||src;if(noCache){if(host._remoteSrc===src&&host._remoteData!==undefined){setStatus(host,"ready");return}}else{const cached=remoteCache.get(cacheKey);if(cached!==undefined){host._remoteSrc=src;host._remoteData=cached;setStatus(host,"ready");return}}if(host._remoteSrc===src&&(host._remoteStatus==="loading"||host._remoteStatus==="error"))return;leaveRequest(host);host._remoteSrc=src;setStatus(host,"loading");let entry=remoteInflight.get(src);if(!entry){entry={hosts:new Set(),controller:new AbortController(),cacheKey};remoteInflight.set(src,entry);entry.promise=startFetch(host,src,entry).then((data)=>{if(remoteInflight.get(src)===entry)remoteInflight.delete(src);cacheResult(src,data);const namedKey=entry.cacheKey;if(namedKey&&namedKey!==src)cacheResult(namedKey,data);for(const h of entry.hosts){h._remoteData=data;h._remoteEntry=null;setStatus(h,"ready");emitState(h,"contour:load",{src,count:countOf(data)})}},(err)=>{if(remoteInflight.get(src)===entry)remoteInflight.delete(src);for(const h of entry.hosts){h._remoteEntry=null;setStatus(h,"error");h._remoteError=err&&err.name==="HttpError"?`Could not load (${err.status})`:STATE_FALLBACK.error;emitState(h,"contour:error",{src,message:h._remoteError,name:err&&err.name,status:err&&err.status,})}}).finally(()=>{for(const h of entry.hosts)if(h.isConnected)h.requestRender();entry.hosts.clear()})}entry.hosts.add(host);host._remoteEntry=entry;if(!host._remoteDisposeRegistered){host._remoteDisposeRegistered=true;onDispose(host,()=>{host._remoteDisposeRegistered=false;leaveRequest(host)})}}export function remoteInvalidate(srcOrKey){remoteCache.delete(srcOrKey)}function startFetch(host,src,entry){const ms=parseInt(host.getAttribute("timeout")||"",10);let timer=null;let signal=entry.controller.signal;if(Number.isFinite(ms)&&ms>0){if(typeof AbortSignal!=="undefined"&&AbortSignal.timeout){signal=AbortSignal.any([signal,AbortSignal.timeout(ms)])}else{timer=setTimeout(()=>entry.controller.abort(),ms)}}onDispose(host,()=>{if(timer)clearTimeout(timer)});return fetch(src,{signal}).then((res)=>{if(timer)clearTimeout(timer);if(!res.ok){const e=new Error(`Could not load (${res.status})`);e.name="HttpError";e.status=res.status;throw e}return res.text()}).then((text)=>{try{return JSON.parse(text)}catch(err){const e=new Error(STATE_FALLBACK.error);e.name="ParseError";e.cause=err;throw e}})}export function remoteData(host,field){const authored=host.getAttribute(field);if(authored!==null)return authored;const data=host._remoteData;if(data===undefined||data===null)return null;if(Array.isArray(data))return JSON.stringify(data);if(typeof data==="object"){const keys=typeof field==="string"?[field]:field;for(const k of keys){if(data[k]===undefined)continue;return typeof data[k]==="string"?data[k]:JSON.stringify(data[k])}return null}return String(data)}export function remoteRefresh(host){const seconds=parseFloat(host.getAttribute("refresh")||"");const want=host.hasAttribute("src")&&Number.isFinite(seconds)&&seconds>0;if(!want){if(host._remoteTimer!==undefined){clearTimeout(host._remoteTimer);host._remoteTimer=undefined}host._remoteLoop=false;return}if(host._remoteLoop)return;host._remoteLoop=true;const tick=()=>{host._remoteTimer=undefined;if(!host.isConnected||!host.hasAttribute("refresh")){host._remoteLoop=false;return}if(document.hidden){host._remoteTimer=setTimeout(tick,1000);return}const src=host.getAttribute("src");const namedKey=host.getAttribute("cache-key");if(namedKey)remoteCache.delete(namedKey);remoteCache.delete(src);host._remoteSrc=null;host._remoteLoop=false;host.requestRender()};host._remoteTimer=setTimeout(tick,Math.max(1000,seconds*1000));onDispose(host,()=>{clearTimeout(host._remoteTimer);host._remoteTimer=undefined;host._remoteLoop=false})}let _sharedLazyIO=null;const _sharedLazyTargets=new Map();export function remoteVisible(host){if(!host.hasAttribute("lazy"))return true;if(typeof IntersectionObserver!=="function")return true;if(host._remoteVisible)return true;if(host._lazyRegistered)return false;if(!_sharedLazyIO){_sharedLazyIO=new IntersectionObserver((records)=>{for(const r of records){const activate=_sharedLazyTargets.get(r.target);if(!activate||!r.isIntersecting)continue;_sharedLazyTargets.delete(r.target);_sharedLazyIO.unobserve(r.target);activate()}},{rootMargin:"200px"})}const activate=()=>{host._remoteVisible=true;host._lazyRegistered=false;host.requestRender()};host._lazyRegistered=true;_sharedLazyTargets.set(host,activate);_sharedLazyIO.observe(host);onDispose(host,()=>{_sharedLazyIO.unobserve(host);_sharedLazyTargets.delete(host);host._lazyRegistered=false});return false}export function watchViewport(host){if(host._contourViewWired)return()=>{};host._contourViewWired=true;const emit=(type)=>host.dispatchEvent(new CustomEvent(type,{bubbles:true,composed:true}));if(typeof IntersectionObserver!=="function"){emit("contour:view-enter");return()=>{}}const io=new IntersectionObserver((records)=>{for(const r of records){if(r.isIntersecting)emit("contour:view-enter");else emit("contour:view-leave")}});io.observe(host);onDispose(host,()=>io.disconnect());return()=>io.disconnect()}function stateNode(block,kind,text){const node=document.createElement("div");node.className="c-"+block+"__"+kind;node.dataset.contourState=kind;node.textContent=text;return node}function skeletonRow(i,total){const node=document.createElement("div");node.className="c-skeleton "+(i===0&&total>1?"c-skeleton--title":"c-skeleton--text");node.dataset.contourState="skeleton";return node}export function renderStates(host,block,opts){const options=opts||{};const loading=host.getAttribute("loading");if(loading!==null||host._remoteStatus==="loading"){host.appendChild(stateNode(block,"loading",loading||STATE_FALLBACK.loading));return true}const error=host.getAttribute("error");if(error!==null||host._remoteStatus==="error"){const message=(error!==null&&error!=="")?error:(host._remoteError||STATE_FALLBACK.error);const node=stateNode(block,"error",message);if(host.hasAttribute("retry")){const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-btn--sm";btn.textContent=host.getAttribute("retry")||"Retry";btn.dataset.action="retry";node.appendChild(btn)}host.appendChild(node);return true}if(host.hasAttribute("skeleton")){const asked=parseInt(host.getAttribute("skeleton")||"3",10);const count=Math.min(options.max||6,Math.max(1,Number.isFinite(asked)?asked:3));for(let i=0;i<count;i++)host.appendChild(skeletonRow(i,count));return true}return false}export function renderEmpty(host,block){host.appendChild(stateNode(block,"empty",host.getAttribute("empty")||STATE_FALLBACK.empty))}export function wireStates(host){if(host._contourStatesWired)return;host._contourStatesWired=true;host.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest('[data-action="retry"]'):null;if(!btn||!host.contains(btn))return;e.preventDefault();const src=host.getAttribute("src");const namedKey=host.getAttribute("cache-key");if(namedKey)remoteCache.delete(namedKey);if(src)remoteCache.delete(src);leaveRequest(host);host._remoteSrc=null;host._remoteData=undefined;setStatus(host,"idle");emitState(host,"contour:retry",{src});host.requestRender()})}class ContourCard extends ContourBase{static get observed(){return["title","variant","heading"]}static get properties(){return{title:{attribute:"title"},variant:{attribute:"variant"}}}render(){this.classList.add("c-card");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-card--"))this.classList.remove(c)});if(variant)this.classList.add("c-card--"+variant);const title=this.getAttribute("title");if(title){const h=this.ensure(".c-card__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-card__title";return el});if(h.parentNode===this&&this.firstChild!==h)this.prepend(h);h.textContent=title}else{const h=this.querySelector(".c-card__title");if(h)h.remove()}}}define("contour-card",ContourCard);class ContourFeature extends ContourBase{static get observed(){return["index","title","body","heading"]}static get properties(){return{index:{attribute:"index"},title:{attribute:"title"},body:{attribute:"body"}}}render(){this.classList.add("c-feature");const index=this.getAttribute("index");const title=this.getAttribute("title");const body=this.getAttribute("body");if(index){const x=this.ensure(".c-feature__index",()=>{const el=document.createElement("span");el.className="c-feature__index";return el});x.textContent=index}else{const x=this.querySelector(".c-feature__index");if(x)x.remove()}if(title){const t=this.ensure(".c-feature__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-feature__title";return el});t.textContent=title}else{const t=this.querySelector(".c-feature__title");if(t)t.remove()}if(body){const b=this.ensure(".c-feature__body",()=>{const el=document.createElement("p");el.className="c-feature__body";return el});b.textContent=body}else{const b=this.querySelector(".c-feature__body");if(b)b.remove()}}}define("contour-feature",ContourFeature);class ContourSteps extends ContourBase{static get observed(){return["steps","current","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current",type:Number},src:{attribute:"src"}}}render(){this.classList.add("c-steps");this.setAttribute("role","list");wireStates(this);loadRemote(this,"steps");if(renderStates(this,"steps"))return;const steps=remoteData(this,"steps");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-steps__item"));if(steps&&!authored.length){Array.from(this.querySelectorAll(".c-steps__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(steps);parsed.forEach((st,i)=>{const item=document.createElement("div");item.className="c-steps__item";item.setAttribute("role","listitem");item.tabIndex=-1;const title=typeof st==="string"?st:st.title;const body=typeof st==="string"?"":st.body;if(title){const h=document.createElement(headingTag(this,"h3"));h.className="c-steps__title";h.textContent=title;item.appendChild(h)}if(body){const p=document.createElement("p");p.className="c-steps__body";p.textContent=body;item.appendChild(p)}this.appendChild(item)})}catch(e){}}else if(!steps&&!authored.length){renderEmpty(this,"steps")}const attrCurrent=this.getAttribute("current");const current=(this._current!=null)?this._current:(attrCurrent!=null?parseInt(attrCurrent,10):NaN);const items=Array.from(this.querySelectorAll(".c-steps__item"));items.forEach((it,i)=>{if(Number.isFinite(current)&&i===current)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=(Number.isFinite(current)&&i===current)?0:-1});if(items.length&&!Number.isFinite(current)){items[0].tabIndex=0}}enhance(){if(!this._wiredSteps){this._wiredSteps=true;this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-steps__item"));if(!items.length)return;const active=document.activeElement;const idx=items.indexOf(active);let next=-1;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowDown")next=idx<0?0:Math.min(items.length-1,idx+1);else if(e.key==="ArrowUp")next=idx<0?0:Math.max(0,idx-1);else if(e.key==="ArrowRight")next=rtl?(idx<0?0:Math.max(0,idx-1)):(idx<0?0:Math.min(items.length-1,idx+1));else if(e.key==="ArrowLeft")next=rtl?(idx<0?0:Math.min(items.length-1,idx+1)):(idx<0?0:Math.max(0,idx-1));else if(e.key==="Home")next=0;else if(e.key==="End")next=items.length-1;if(next>=0&&next!==idx){e.preventDefault();items[next].focus();this._current=next;items.forEach((it,i)=>{if(i===next)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=i===next?0:-1});if(idx>=0)items[idx].tabIndex=-1;const title=items[next].querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{index:next,title}}))}if((e.key==="Enter"||e.key===" ")&&idx>=0){e.preventDefault();const title=items[idx].querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:true,composed:true,detail:{index:idx,title}}))}});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-steps__item"):null;if(!item||!this.contains(item))return;const items=Array.from(this.querySelectorAll(".c-steps__item"));const idx=items.indexOf(item);if(idx<0)return;this._current=idx;items.forEach((it,i)=>{if(i===idx)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=i===idx?0:-1});const title=item.querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:true,composed:true,detail:{index:idx,title}}))})}}}define("contour-steps",ContourSteps);class ContourLink extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-link");const href=this.getAttribute("href");const label=this.getAttribute("label");const prevLink=this.querySelector("a");if(prevLink)prevLink.remove();if(href&&label){const a=document.createElement("a");a.href=href;a.textContent=label;const ariaLabel=this.getAttribute("aria-label");if(ariaLabel)a.setAttribute("aria-label",ariaLabel);this.appendChild(a)}}}define("contour-link",ContourLink);class ContourBrand extends ContourBase{static get observed(){return["name","tag"]}static get properties(){return{name:{attribute:"name"},tag:{attribute:"tag"}}}render(){this.classList.add("c-brand");const name=this.getAttribute("name");const tag=this.getAttribute("tag");if(name){const n=this.ensure(".c-brand__name",()=>{const el=document.createElement("span");el.className="c-brand__name";return el});n.textContent=name}else{const n=this.querySelector(".c-brand__name");if(n)n.remove()}if(tag){const t=this.ensure(".c-brand__tag",()=>{const el=document.createElement("span");el.className="c-brand__tag";return el});t.textContent=tag}else{const t=this.querySelector(".c-brand__tag");if(t)t.remove()}}}define("contour-brand",ContourBrand);class ContourSectionHead extends ContourBase{static get observed(){return["title","desc","heading"]}static get properties(){return{title:{attribute:"title"},desc:{attribute:"desc"}}}render(){this.classList.add("c-section-head");const title=this.getAttribute("title");const desc=this.getAttribute("desc");if(!this.querySelector(".c-icon-badge")){const badge=document.createElement("div");badge.className="c-icon-badge";badge.innerHTML='<svg aria-hidden="true"><use href="#i-crosshair" /></svg>';this.prepend(badge)}let content=this.querySelector(":scope > div:not(.c-icon-badge)");if(!content){content=document.createElement("div");this.appendChild(content)}if(title){const t=this.ensure(".c-section-head__title",()=>{const el=document.createElement(headingTag(this,"h2"));el.className="c-section-head__title";return el});t.textContent=title;if(t.parentNode!==content)content.appendChild(t)}else{const t=this.querySelector(".c-section-head__title");if(t)t.remove()}if(desc){const d=this.ensure(".c-section-head__desc",()=>{const el=document.createElement("p");el.className="c-section-head__desc";return el});d.textContent=desc;if(d.parentNode!==content)content.appendChild(d)}else{const d=this.querySelector(".c-section-head__desc");if(d)d.remove()}}}define("contour-section-head",ContourSectionHead);class ContourDiff extends ContourBase{static get observed(){return["before","after"]}static get properties(){return{before:{attribute:"before"},after:{attribute:"after"}}}render(){this.classList.add("c-diff");this.setAttribute("role","group");this.setAttribute("aria-label","Diff");Array.from(this.querySelectorAll(".c-diff__line")).forEach((n)=>n.remove());const line=(kind,sign,text)=>{const el=document.createElement("div");el.className=kind?`c-diff__line c-diff__line--${kind}`:"c-diff__line";el.setAttribute("role","listitem");el.setAttribute("tabindex","0");const s=document.createElement("span");s.className="c-diff__sign";s.textContent=sign;const code=document.createElement("span");code.textContent=text;el.append(s,code);return el};const before=this.getAttribute("before");const after=this.getAttribute("after");if(before)this.appendChild(line("del","−",before));if(after)this.appendChild(line("add","+",after))}enhance(){if(this._wiredDiff)return;this._wiredDiff=true;this.addEventListener("click",(e)=>{const line=e.target&&e.target.closest?e.target.closest(".c-diff__line"):null;if(line&&this.contains(line)){const kind=line.classList.contains("c-diff__line--add")?"add":line.classList.contains("c-diff__line--del")?"del":"context";const text=line.querySelector("span:last-child")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:diff-activate",{bubbles:true,composed:true,detail:{kind,text}}))}});this.addEventListener("keydown",(e)=>{const line=e.target&&e.target.closest?e.target.closest(".c-diff__line"):null;if(!line||!this.contains(line))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();line.click()}})}}define("contour-diff",ContourDiff);class ContourDoDont extends ContourBase{static get observed(){return["do","dont"]}static get properties(){return{do:{attribute:"do"},dont:{attribute:"dont"}}}render(){this.classList.add("c-do-dont");this.setAttribute("role","group");this.setAttribute("aria-label","Do and don't");Array.from(this.querySelectorAll(".c-do-dont__item")).forEach((n)=>n.remove());const item=(kind,word,text)=>{const el=document.createElement("div");el.className=`c-do-dont__item c-do-dont__item--${kind}`;el.setAttribute("role","listitem");const label=document.createElement("p");label.className="c-do-dont__label";label.textContent=word;const body=document.createElement("p");body.className="u-muted";body.textContent=text;el.append(label,body);return el};const doText=this.getAttribute("do");const dontText=this.getAttribute("dont");if(doText)this.appendChild(item("do","Do",doText));if(dontText)this.appendChild(item("dont","Don't",dontText))}enhance(){if(this._wiredDoDont)return;this._wiredDoDont=true;this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-do-dont__item"):null;if(item&&this.contains(item)){const kind=item.classList.contains("c-do-dont__item--do")?"do":"dont";const text=item.querySelector(".u-muted")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:do-dont-activate",{bubbles:true,composed:true,detail:{kind,text}}))}});Array.from(this.querySelectorAll(".c-do-dont__item")).forEach((it)=>{if(!it.hasAttribute("tabindex"))it.setAttribute("tabindex","0");if(!it.hasAttribute("role"))it.setAttribute("role","button")});this.addEventListener("keydown",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-do-dont__item"):null;if(!item||!this.contains(item))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();item.click()}})}}define("contour-do-dont",ContourDoDont);class ContourFlag extends ContourBase{static get observed(){return["variant","label"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"}}}render(){this.classList.add("c-flag");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-flag--"))this.classList.remove(c)});if(variant)this.classList.add("c-flag--"+variant);const label=this.getAttribute("label");if(label){this.textContent=label}}}define("contour-flag",ContourFlag);class ContourInstallFull extends ContourBase{static get observed(){return["command","prompt","copyable"]}static get properties(){return{command:{attribute:"command"},prompt:{attribute:"prompt"},copyable:{attribute:"copyable"}}}render(){this.classList.add("c-install");const prompt=this.getAttribute("prompt")||"$";const command=this.getAttribute("command")||"";if(command){const p=this.ensure(".c-install__prompt",()=>{const el=document.createElement("span");el.className="c-install__prompt";return el});p.textContent=prompt;const c=this.ensure(".c-install__command",()=>{const el=document.createElement("span");el.className="c-install__command";return el});c.textContent=command;if(this.hasAttribute("copyable")){this.ensure(".c-install__copy",()=>{const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm c-install__copy";btn.type="button";btn.setAttribute("aria-label","Copy command");btn.textContent="Copy";return btn})}else{const btn=this.querySelector(".c-install__copy");if(btn)btn.remove()}}}enhance(){wireCopy(this)}}define("contour-install",ContourInstallFull);class ContourTestimonialFull extends ContourBase{static get observed(){return["quote","name","role"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"},role:{attribute:"role"}}}render(){this.classList.add("c-testimonial");const quote=this.getAttribute("quote");if(quote){const q=this.ensure(".c-testimonial__quote",()=>{const el=document.createElement("blockquote");el.className="c-testimonial__quote";return el});q.textContent=quote}else{const q=this.querySelector(".c-testimonial__quote");if(q)q.remove()}const name=this.getAttribute("name");const role=this.getAttribute("role");if(name){const by=this.ensure(".c-testimonial__byline",()=>{const el=document.createElement("div");el.className="c-testimonial__byline";return el});const n=by.querySelector(".c-testimonial__name")||(()=>{const el=document.createElement("span");el.className="c-testimonial__name";by.appendChild(el);return el})();n.className="c-testimonial__name";n.textContent=name;if(role){const r=by.querySelector(".c-testimonial__role")||(()=>{const el=document.createElement("span");el.className="c-testimonial__role";by.appendChild(el);return el})();r.className="c-testimonial__role";r.textContent=role}else{const r=by.querySelector(".c-testimonial__role");if(r)r.remove()}}else{const by=this.querySelector(".c-testimonial__byline");if(by)by.remove()}}}define("contour-testimonial",ContourTestimonialFull);class ContourShowcaseFull extends ContourBase{static get observed(){return["title","text","media","reverse","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},media:{attribute:"media"},reverse:{attribute:"reverse"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-showcase");this.setAttribute("role","list");if(this.hasAttribute("reverse"))this.classList.add("c-showcase--reverse");else this.classList.remove("c-showcase--reverse");const title=this.getAttribute("title");if(title)this.setAttribute("aria-label",title);else this.removeAttribute("aria-label");this.setAttribute("role","region");wireStates(this);loadRemote(this,"items");if(renderStates(this,"showcase"))return;const items=remoteData(this,"items");const text=this.getAttribute("text");const media=this.getAttribute("media");if(media){const m=this.ensure(".c-showcase__media",()=>{const el=document.createElement("div");el.className="c-showcase__media";el.setAttribute("role","img");return el});m.innerHTML=sanitizeHtml(media);if(title)m.setAttribute("aria-label",title)}else{const m=this.querySelector(".c-showcase__media");if(m)m.remove()}if(title){const t=this.ensure(".c-showcase__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-showcase__title";return el});t.textContent=title}else{const t=this.querySelector(".c-showcase__title");if(t)t.remove()}if(text){const p=this.ensure(".c-showcase__text",()=>{const el=document.createElement("p");el.className="c-showcase__text";return el});p.textContent=text}else{const p=this.querySelector(".c-showcase__text");if(p)p.remove()}const ul=this.querySelector(".c-showcase__list");const authored=ul?Array.from(ul.children).filter((n)=>n.tagName==="LI"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-showcase__list",()=>{const el=document.createElement("ul");el.className="c-showcase__list";return el});l.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("li");li.textContent=typeof it==="string"?it:it.label;l.appendChild(li)})}catch(e){}}else if(!items&&!authored.length&&!title&&!text&&!media){renderEmpty(this,"showcase")}else if(!items&&ul){ul.remove()}}enhance(){if(this._wiredShowcase)return;this._wiredShowcase=true;this.addEventListener("click",(e)=>{const media=e.target&&e.target.closest?e.target.closest(".c-showcase__media"):null;if(media&&this.contains(media)){const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:showcase-activate",{bubbles:true,composed:true,detail:{title}}))}})}}define("contour-showcase",ContourShowcaseFull);class ContourPricingFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-pricing")}}define("contour-pricing",ContourPricingFull);class ContourRecipeFull extends ContourBase{static get observed(){return["title","body","canvas","heading"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},canvas:{attribute:"canvas"}}}render(){this.classList.add("c-recipe");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-recipe__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-recipe__title";return el});t.textContent=title}else{const t=this.querySelector(".c-recipe__title");if(t)t.remove()}const body=this.getAttribute("body");if(body){const b=this.ensure(".c-recipe__desc",()=>{const el=document.createElement("p");el.className="c-recipe__desc";return el});b.textContent=body}else{const b=this.querySelector(".c-recipe__desc");if(b)b.remove()}const canvas=this.getAttribute("canvas");if(canvas){const c=this.ensure(".c-recipe__canvas",()=>{const el=document.createElement("div");el.className="c-recipe__canvas";return el});c.innerHTML=sanitizeHtml(canvas)}else{const c=this.querySelector(".c-recipe__canvas");if(c)c.remove()}}}define("contour-recipe",ContourRecipeFull);class ContourLogosFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-logos");if(!this.querySelector(".c-logos__item")){for(const name of["Cartolab","Nordwand"]){const span=document.createElement("span");span.className="c-logos__item";span.textContent=name;this.appendChild(span)}}}}define("contour-logos",ContourLogosFull);class ContourLandingFeaturesFull extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-landing-features");wireStates(this);loadRemote(this,"items");if(renderStates(this,"landing-features"))return;const items=remoteData(this,"items");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-landing-features__item"));if(items&&!authored.length){try{const parsed=JSON.parse(items);this.querySelectorAll(".c-landing-features__item").forEach((el)=>el.remove());parsed.forEach((it)=>{const item=document.createElement("div");item.className="c-landing-features__item";if(it.icon){const ic=document.createElement("span");ic.className="c-landing-features__icon";ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(it.icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>';item.appendChild(ic)}if(it.title){const t=document.createElement("span");t.className="c-landing-features__title";t.textContent=it.title;item.appendChild(t)}if(it.text){const tx=document.createElement("p");tx.className="c-landing-features__text";tx.textContent=it.text;item.appendChild(tx)}this.appendChild(item)})}catch(e){}}else if(!items&&!authored.length){this.querySelectorAll(".c-landing-features__item").forEach((el)=>el.remove());renderEmpty(this,"landing-features")}}}define("contour-landing-features",ContourLandingFeaturesFull);class ContourLandingHeroFull extends ContourBase{static get observed(){return["actions","title","text","heading"]}static get properties(){return{actions:{attribute:"actions"},title:{attribute:"title"},text:{attribute:"text"}}}render(){this.classList.add("c-landing-hero");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-landing-hero__title",()=>{const el=document.createElement(headingTag(this,"h1"));el.className="c-landing-hero__title";return el});t.textContent=title}const text=this.getAttribute("text");if(text){const t=this.ensure(".c-landing-hero__text",()=>{const el=document.createElement("p");el.className="c-landing-hero__text";return el});t.textContent=text}const actions=this.getAttribute("actions");const a=this.querySelector(".c-landing-hero__actions");const authored=a?Array.from(a.children):[];if(actions&&!authored.length){const el=this.ensure(".c-landing-hero__actions",()=>{const e=document.createElement("div");e.className="c-landing-hero__actions";return e});el.innerHTML=sanitizeHtml(actions)}else if(!actions&&a&&!authored.length){a.remove()}}}define("contour-landing-hero",ContourLandingHeroFull);class ContourLinkishFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-linkish")}}define("contour-linkish",ContourLinkishFull);class ContourPriceFull extends ContourBase{static get observed(){return["value","format","locale"]}static get properties(){return{value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-price");const value=this.getAttribute("value");if(value)this.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"))}}define("contour-price",ContourPriceFull);class ContourProseFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-prose")}}define("contour-prose",ContourProseFull);class ContourPanel extends ContourBase{static get observed(){return["title","subtitle","status","heading","collapsible","collapsed"]}static get properties(){return{title:{attribute:"title"},subtitle:{attribute:"subtitle"},status:{attribute:"status"},collapsible:{attribute:"collapsible",type:Boolean},collapsed:{attribute:"collapsed",type:Boolean}}}render(){this.classList.add("c-panel");const title=this.getAttribute("title");const subtitle=this.getAttribute("subtitle");const status=this.getAttribute("status");if(title){const h=this.ensure(".c-panel__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-panel__title";return el});if(h.parentNode===this&&this.firstChild!==h)this.prepend(h);h.textContent=title}else{const h=this.querySelector(".c-panel__title");if(h)h.remove()}if(subtitle){const sub=this.ensure(".c-panel__subtitle",()=>{const el=document.createElement("p");el.className="c-panel__subtitle";return el});sub.textContent=subtitle}else{const sub=this.querySelector(".c-panel__subtitle");if(sub)sub.remove()}if(status){const st=this.ensure(".c-panel__status",()=>{const el=document.createElement("span");el.className="c-panel__status";return el});st.textContent=status}else{const st=this.querySelector(".c-panel__status");if(st)st.remove()}if(this.hasAttribute("collapsible")){let btn=this.querySelector(".c-panel__collapse");if(!btn){btn=document.createElement("button");btn.type="button";btn.className="c-panel__collapse c-btn c-btn--ghost c-btn--sm";btn.setAttribute("aria-label","Toggle panel");btn.textContent="▾";this.appendChild(btn)}if(this.hasAttribute("collapsed")){this.classList.add("c-panel--collapsed");btn.setAttribute("aria-expanded","false");btn.textContent="▸"}else{this.classList.remove("c-panel--collapsed");btn.setAttribute("aria-expanded","true");btn.textContent="▾"}}else{const btn=this.querySelector(".c-panel__collapse");if(btn)btn.remove();this.classList.remove("c-panel--collapsed")}const body=this.ensure(".c-panel__body",()=>{const el=document.createElement("div");el.className="c-panel__body";return el});const head=this.querySelector(".c-panel__head");Array.from(this.childNodes).forEach((n)=>{if(n===body||n===head)return;if(n.nodeType===1&&(n.classList.contains("c-panel__title")||n.classList.contains("c-panel__subtitle")||n.classList.contains("c-panel__status")))return;body.appendChild(n)});if(!body.parentNode)this.appendChild(body);if(head&&head.parentNode===this&&body.parentNode===this&&head.compareDocumentPosition(body)&Node.DOCUMENT_POSITION_PRECEDING){this.insertBefore(body,head.nextSibling)}}enhance(){if(this._wiredPanel)return;this._wiredPanel=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-panel__collapse"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.toggleAttribute("collapsed");this.dispatchEvent(new CustomEvent("contour:collapse",{bubbles:true,composed:true,detail:{collapsed:this.hasAttribute("collapsed")}}))})}}define("contour-panel",ContourPanel);class ContourCta extends ContourBase{static get observed(){return["title","text","actions","heading"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},actions:{attribute:"actions"}}}render(){this.classList.add("c-cta");const title=this.getAttribute("title");const text=this.getAttribute("text");if(title){const t=this.ensure(".c-cta__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-cta__title";return el});t.textContent=title}else{const t=this.querySelector(".c-cta__title");if(t)t.remove()}if(text){const p=this.ensure(".c-cta__text",()=>{const el=document.createElement("p");el.className="c-cta__text";return el});p.textContent=text}else{const p=this.querySelector(".c-cta__text");if(p)p.remove()}const actions=this.getAttribute("actions");const prevWrap=this.querySelector(".c-cta__actions");if(prevWrap)prevWrap.remove();if(actions){try{const parsed=JSON.parse(actions);const wrap=document.createElement("div");wrap.className="c-cta__actions";parsed.forEach((a)=>{const btn=document.createElement("button");btn.className="c-btn c-btn--primary";btn.type="button";btn.textContent=typeof a==="string"?a:(a.label||a);wrap.appendChild(btn)});this.appendChild(wrap)}catch(e){}}}}define("contour-cta",ContourCta);class ContourCode extends ContourBase{static get observed(){return["title","copyable"]}static get properties(){return{title:{attribute:"title"},copyable:{attribute:"copyable",type:Boolean}}}render(){this.classList.add("c-code");const title=this.getAttribute("title");if(title){const head=this.ensure(".c-code__head",()=>{const el=document.createElement("div");el.className="c-code__head";return el});if(head.parentNode===this&&this.firstChild!==head)this.prepend(head);const t=head.querySelector(".c-code__title")||(()=>{const el=document.createElement("div");el.className="c-code__title";head.appendChild(el);return el})();t.textContent=title}else{const head=this.querySelector(".c-code__head");if(head)head.remove();const t=this.querySelector(".c-code__title");if(t)t.remove()}if(this.hasAttribute("copyable")){this.ensure(".c-code__copy",()=>{const btn=document.createElement("button");btn.className="c-code__copy";btn.type="button";btn.textContent="Copy";return btn})}else{const btn=this.querySelector(".c-code__copy");if(btn)btn.remove()}const pre=this.ensure("pre",()=>{const el=document.createElement("pre");return el});Array.from(this.childNodes).forEach((n)=>{if(n===pre||(n.nodeType===1&&(n.classList.contains("c-code__head")||n.classList.contains("c-code__copy"))))return;pre.appendChild(n)});if(!pre.querySelector("code")){const code=document.createElement("code");while(pre.firstChild)code.appendChild(pre.firstChild);pre.appendChild(code)}if(pre.parentNode!==this)this.appendChild(pre);const head=this.querySelector(".c-code__head");if(head&&head.parentNode===this&&pre.parentNode===this&&head.compareDocumentPosition(pre)&Node.DOCUMENT_POSITION_PRECEDING){this.insertBefore(pre,head.nextSibling)}}enhance(){wireCopy(this)}}define("contour-code",ContourCode);class ContourPlate extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-plate")}}define("contour-plate",ContourPlate);class ContourPullquote extends ContourBase{static get observed(){return["quote","name"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"}}}render(){this.classList.add("c-pullquote");const quote=this.getAttribute("quote");if(quote){Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===3)n.remove()});const cite=this.querySelector("cite");this.insertBefore(document.createTextNode(quote),cite)}const name=this.getAttribute("name");if(name){const by=this.ensure("cite",()=>{const el=document.createElement("cite");this.appendChild(el);return el});by.textContent=name}else{const by=this.querySelector("cite");if(by)by.remove()}}}define("contour-pullquote",ContourPullquote);class ContourAnchor extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-anchor");const href=this.getAttribute("href");const label=this.getAttribute("label");const prevAnchor=this.querySelector("a");if(prevAnchor)prevAnchor.remove();if(href&&label){const a=document.createElement("a");a.href=href;a.textContent=label;const ariaLabel=this.getAttribute("aria-label");if(ariaLabel)a.setAttribute("aria-label",ariaLabel);this.appendChild(a)}}}define("contour-anchor",ContourAnchor);class ContourGeocoder extends ContourBase{static get observed(){return["placeholder","value","results","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{placeholder:{attribute:"placeholder"},value:{attribute:"value"},results:{attribute:"results"},src:{attribute:"src"}}}render(){this.classList.add("c-geocoder");wireStates(this);loadRemote(this,["results"]);if(renderStates(this,"geocoder"))return;let inp=this.querySelector(".c-geocoder__input");if(!inp){inp=document.createElement("input");inp.type="search";inp.className="c-geocoder__input";this.appendChild(inp)}const ph=this.getAttribute("placeholder");if(ph)inp.setAttribute("placeholder",ph);const val=this.getAttribute("value");if(val!==null&&inp.value!==val)inp.value=val;Array.from(this.querySelectorAll(".c-geocoder__result")).forEach((n)=>n.remove());let results=[];const rAttr=this.getAttribute("results");if(rAttr){try{results=JSON.parse(rAttr)}catch(e){results=[]}}const remote=remoteData(this,"results");if(Array.isArray(remote))results=remote;if(Array.isArray(results)&&results.length){const list=document.createElement("ul");list.className="c-geocoder__list";list.setAttribute("role","listbox");results.forEach((r,idx)=>{const li=document.createElement("li");li.className="c-geocoder__result";li.setAttribute("role","option");li.setAttribute("tabindex",idx===0?"0":"-1");li.textContent=(typeof r==="object")?(r.label||r.name||""):String(r);if(typeof r==="object"){if(r.lat!=null)li.dataset.lat=String(r.lat);if(r.lon!=null)li.dataset.lon=String(r.lon)}list.appendChild(li)});this.appendChild(list)}else if(!this.hasAttribute("loading")&&!this.hasAttribute("error")){renderEmpty(this,"geocoder")}}enhance(){if(this._wiredGeocoder)return;this._wiredGeocoder=true;const inp=this.querySelector(".c-geocoder__input");if(inp){let timer=null;inp.addEventListener("input",()=>{if(timer)clearTimeout(timer);timer=setTimeout(()=>{this.dispatchEvent(new CustomEvent("contour:search",{bubbles:true,composed:true,detail:{query:inp.value}}))},200)});inp.addEventListener("keydown",(e)=>{if(e.key==="Enter"){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:search",{bubbles:true,composed:true,detail:{query:inp.value}}))}})}this.addEventListener("click",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-geocoder__result"):null;if(!li||!this.contains(li))return;const result={label:li.textContent.trim(),lat:li.dataset.lat,lon:li.dataset.lon};this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{result}}))});this.addEventListener("keydown",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-geocoder__result"):null;if(!li||!this.contains(li))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();const result={label:li.textContent.trim(),lat:li.dataset.lat,lon:li.dataset.lon};this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{result}}))}})}}define("contour-geocoder",ContourGeocoder);class ContourDashShell extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-dash-shell");this.setAttribute("role","region");const title=this.getAttribute("title");if(title){const bar=this.ensure(".c-dash-toolbar",()=>{const el=document.createElement("div");el.className="c-dash-toolbar";return el});const h=bar.querySelector(".c-dash-toolbar__title")||(()=>{const el=document.createElement("span");el.className="c-dash-toolbar__title";bar.appendChild(el);return el})();h.textContent=title;this.setAttribute("aria-label",title)}}}define("contour-dash-shell",ContourDashShell);class ContourDashToolbar extends ContourBase{static get observed(){return["title","actions"]}static get properties(){return{title:{attribute:"title"},actions:{attribute:"actions"}}}render(){this.classList.add("c-dash-toolbar");this.setAttribute("role","toolbar");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-dash-toolbar__title",()=>{const el=document.createElement("span");el.className="c-dash-toolbar__title";return el});t.textContent=title;this.setAttribute("aria-label",title)}else{const t=this.querySelector(".c-dash-toolbar__title");if(t)t.remove()}const actions=this.getAttribute("actions");if(actions){try{const parsed=JSON.parse(actions);const wrap=this.ensure(".c-dash-toolbar__actions",()=>{const el=document.createElement("div");el.className="c-dash-toolbar__actions";return el});wrap.innerHTML="";parsed.forEach((a)=>{const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm";btn.type="button";btn.textContent=typeof a==="string"?a:(a.label||a);wrap.appendChild(btn)})}catch(e){}}else{const w=this.querySelector(".c-dash-toolbar__actions");if(w)w.remove()}}enhance(){if(this._wiredDashToolbar)return;this._wiredDashToolbar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-btn"):null;if(btn&&this.contains(btn)){const label=btn.textContent||"";this.dispatchEvent(new CustomEvent("contour:dash-action",{bubbles:true,composed:true,detail:{label}}))}});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-btn"):null;if(!btn||!this.contains(btn))return;const btns=Array.from(this.querySelectorAll(".c-btn"));const idx=btns.indexOf(btn);let next=-1;if(e.key==="ArrowRight")next=Math.min(btns.length-1,idx+1);else if(e.key==="ArrowLeft")next=Math.max(0,idx-1);if(next>=0){e.preventDefault();try{btns[next].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}})}}define("contour-dash-toolbar",ContourDashToolbar);class ContourDashKpiRow extends ContourBase{static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-dash-kpi-row");this.setAttribute("role","group");Array.from(this.querySelectorAll("contour-kpi")).forEach((n)=>n.remove());const items=this.getAttribute("items");let parsed=null;if(items){try{parsed=JSON.parse(items)}catch(e){parsed=null}}if(Array.isArray(parsed)&&parsed.length){parsed.forEach((it)=>{const k=document.createElement("contour-kpi");if(typeof it==="object"&&it!==null){if(it.value!==undefined)k.setAttribute("value",String(it.value));if(it.label!==undefined)k.setAttribute("label",String(it.label))}else{k.setAttribute("value",String(it))}this.appendChild(k)})}else if(!this.querySelector("contour-kpi")){const k=document.createElement("contour-kpi");k.setAttribute("value","0");k.setAttribute("label","KPI");this.appendChild(k)}}enhance(){if(this._wiredDashKpiRow)return;this._wiredDashKpiRow=true;this.addEventListener("click",(e)=>{const kpi=e.target&&e.target.closest?e.target.closest("contour-kpi"):null;if(kpi&&this.contains(kpi)){const kpis=Array.from(this.querySelectorAll("contour-kpi"));const idx=kpis.indexOf(kpi);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx}}))}})}}define("contour-dash-kpi-row",ContourDashKpiRow);class ContourDashFreshness extends ContourBase{static get observed(){return["label","value","format","locale"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-dash-freshness");this.setAttribute("role","status");this.setAttribute("aria-live","polite");const label=this.getAttribute("label");const value=this.getAttribute("value");const dot=this.ensure(".c-dot",()=>{const el=document.createElement("span");el.className="c-dot c-dot--live c-dot--accent";el.setAttribute("aria-hidden","true");return el});if(dot.parentNode!==this)this.appendChild(dot);if(!this._freshnessText||!this._freshnessText.parentNode){this._freshnessText=document.createTextNode("");this.appendChild(this._freshnessText)}const formattedValue=value?formatValue(value,this.getAttribute("format"),this.getAttribute("locale")):value;this._freshnessText.nodeValue=[label,formattedValue].filter(Boolean).join(" ")}}define("contour-dash-freshness",ContourDashFreshness);class ContourReadout extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","format","locale"]}static get properties(){return{rows:{attribute:"rows"},format:{attribute:"format"},locale:{attribute:"locale"},src:{attribute:"src"}}}render(){this.classList.add("c-readout");wireStates(this);loadRemote(this,"rows");if(renderStates(this,"readout"))return;const rows=remoteData(this,"rows");Array.from(this.querySelectorAll(".c-readout__row")).forEach((n)=>n.remove());const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-readout__row"));if(rows&&!authored.length){try{const parsed=JSON.parse(rows);parsed.forEach((r)=>{const row=document.createElement("div");row.className="c-readout__row";const key=document.createElement("span");key.className="c-readout__key";key.textContent=r.key||r[0];const val=document.createElement("span");val.className="c-readout__value"+(r.primary?" c-readout__value--primary":"")+(r.accent?" c-readout__value--accent":"")+(r.coord?" c-readout__value--coord":"");val.setAttribute("aria-live","polite");val.textContent=formatValue(r.value||r[1],this.getAttribute("format"),this.getAttribute("locale"),(r.unit!==undefined?r.unit:this.getAttribute("unit")));row.appendChild(key);row.appendChild(val);if(r.order){const ord=document.createElement("span");ord.className="c-readout__order";ord.textContent=r.order;row.appendChild(ord)}this.appendChild(row)})}catch(e){}}else if(!rows&&!authored.length){renderEmpty(this,"readout")}}}define("contour-readout",ContourReadout);class ContourKpi extends ContourBase{static get observed(){return["value","label","delta","direction","note","variant","unit","format","locale","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","thresholds","threshold","sparkline","polarity"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},delta:{attribute:"delta"},direction:{attribute:"direction"},note:{attribute:"note"},variant:{attribute:"variant"},unit:{attribute:"unit"},format:{attribute:"format"},locale:{attribute:"locale"},thresholds:{attribute:"thresholds"},threshold:{attribute:"threshold"},sparkline:{attribute:"sparkline"},polarity:{attribute:"polarity"}}}render(){this.classList.add("c-kpi");wireStates(this);loadRemote(this,["value","label"]);if(renderStates(this,"kpi"))return;const value=remoteData(this,"value");const label=remoteData(this,"label");const delta=this.getAttribute("delta");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-kpi--"))this.classList.remove(c)});if(variant)this.classList.add("c-kpi--"+variant);if(value){const v=this.ensure(".c-kpi__value",()=>{const el=document.createElement("div");el.className="c-kpi__value";el.setAttribute("aria-live","polite");return el});v.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const v=this.querySelector(".c-kpi__value");if(v)v.remove()}if(label){const h=this.ensure(".c-kpi__head",()=>{const el=document.createElement("div");el.className="c-kpi__head";return el});let l=h.querySelector(".c-kpi__label");if(!l){l=document.createElement("div");l.className="c-kpi__label";h.appendChild(l)}l.textContent=label;if(h.parentNode!==this)this.insertBefore(h,this.firstChild)}else{const h=this.querySelector(".c-kpi__head");if(h)h.remove()}if(delta){const f=this.ensure(".c-kpi__foot",()=>{const el=document.createElement("div");el.className="c-kpi__foot";return el});const d=f.querySelector(".c-delta")||document.createElement("span");if(!d.parentNode)f.insertBefore(d,f.firstChild);const dir=this.getAttribute("direction")||"up";const polarity=this.getAttribute("polarity")||"neutral";let tone="neutral";if(polarity==="good")tone=(dir==="up")?"good":"bad";else if(polarity==="bad")tone=(dir==="up")?"bad":"good";d.className="c-delta c-delta--"+dir+" c-delta--"+tone;d.textContent=delta}else{const d=this.querySelector(".c-kpi__foot .c-delta");if(d)d.remove()}const note=this.getAttribute("note");if(note){const f=this.ensure(".c-kpi__foot",()=>{const el=document.createElement("div");el.className="c-kpi__foot";return el});const n=f.querySelector(".c-kpi__note")||(()=>{const el=document.createElement("span");el.className="c-kpi__note";f.appendChild(el);return el})();n.textContent=note}else{const n=this.querySelector(".c-kpi__note");if(n)n.remove()}const unit=this.getAttribute("unit");const v=this.querySelector(".c-kpi__value");if(v){if(unit){let u=v.querySelector(".c-kpi__unit");if(!u){u=document.createElement("span");u.className="c-kpi__unit";v.appendChild(u)}u.textContent=unit}else{const u=v.querySelector(".c-kpi__unit");if(u)u.remove()}}const threshold=this.getAttribute("threshold")||this.getAttribute("thresholds");if(threshold){const f=this.ensure(".c-kpi__foot",()=>{const el=document.createElement("div");el.className="c-kpi__foot";return el});let badge=f.querySelector(".c-kpi__threshold-badge");if(!badge){badge=document.createElement("span");badge.className="c-kpi__threshold-badge";f.appendChild(badge)}badge.textContent=threshold;badge.setAttribute("part","threshold-badge")}else{const b=this.querySelector(".c-kpi__threshold-badge");if(b)b.remove()}const foot=this.querySelector(".c-kpi__foot");if(foot&&!foot.querySelector(".c-delta, .c-kpi__note, .c-kpi__threshold-badge"))foot.remove();const spark=this.getAttribute("sparkline");if(spark){let canvas=this.querySelector(".c-kpi__sparkline-canvas");if(!canvas){canvas=document.createElement("canvas");canvas.className="c-kpi__sparkline-canvas";canvas.setAttribute("part","sparkline-canvas");this.appendChild(canvas)}}else{const c=this.querySelector(".c-kpi__sparkline-canvas");if(c)c.remove()}if(!value&&!label){renderEmpty(this,"kpi")}}}define("contour-kpi",ContourKpi);class ContourTable extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","page-size","sort","sort-dir","virtual","empty","loading","error","retry","skeleton","persist"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page",type:Number},pageSize:{attribute:"page-size",type:Number}}}_cellValue(cell){if(cell===null||cell===undefined)return"";if(typeof cell==="object")return cell.value!==undefined?cell.value:(cell.label!==undefined?cell.label:JSON.stringify(cell));return cell}_compare(a,b,type){const av=this._cellValue(a);const bv=this._cellValue(b);if(type==="number"||type==="numeric"){return(parseFloat(av)||0)-(parseFloat(bv)||0)}return String(av).localeCompare(String(bv),undefined,{numeric:true})}render(){this.setAttribute("role","region");this.setAttribute("aria-label","Table");const columns=this.getAttribute("columns");const rows=this.getAttribute("rows");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-table-wrap"));if(columns&&rows&&!authored.length){try{const cols=JSON.parse(columns);const data=JSON.parse(rows);if(this.hasAttribute("loading")){const wrap=this.ensure(".c-table-wrap",()=>{const el=document.createElement("div");el.className="c-table-wrap";return el});const colsKey=JSON.stringify(cols);const table=(wrap.querySelector("table.c-table")&&this._tableCols===colsKey)?wrap.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");cols.forEach((c)=>{const colLabel=typeof c==="string"?c:(c.label||c.title||c);const th=document.createElement("th");th.textContent=colLabel;tr.appendChild(th)});thead.appendChild(tr);t.appendChild(thead);t.appendChild(document.createElement("tbody"));return t})();this._tableCols=colsKey;const tbody=table.querySelector("tbody");tbody.innerHTML="";const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=cols.length;td.style.textAlign="center";td.style.color="var(--color-text-muted)";td.textContent=this.getAttribute("loading")||"Loading…";tr.appendChild(td);tbody.appendChild(tr);if(table.parentNode!==wrap){wrap.innerHTML="";wrap.appendChild(table)}if(wrap.parentNode!==this)this.appendChild(wrap);const footer=this.querySelector(".c-table__pagination");if(footer)footer.remove();return}if(this.hasAttribute("error")){const wrap=this.ensure(".c-table-wrap",()=>{const el=document.createElement("div");el.className="c-table-wrap";return el});const colsKey=JSON.stringify(cols);const table=(wrap.querySelector("table.c-table")&&this._tableCols===colsKey)?wrap.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");cols.forEach((c)=>{const colLabel=typeof c==="string"?c:(c.label||c.title||c);const th=document.createElement("th");th.textContent=colLabel;tr.appendChild(th)});thead.appendChild(tr);t.appendChild(thead);t.appendChild(document.createElement("tbody"));return t})();this._tableCols=colsKey;const tbody=table.querySelector("tbody");tbody.innerHTML="";const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=cols.length;td.textContent=this.getAttribute("error")||"Error";td.style.textAlign="center";td.style.color="var(--color-danger, var(--color-text))";if(this.hasAttribute("retry")){const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm";btn.type="button";btn.textContent=this.getAttribute("retry")||"Retry";btn.classList.add("u-ms-sm");btn.dataset.action="retry";td.appendChild(btn)}tr.appendChild(td);tbody.appendChild(tr);if(table.parentNode!==wrap){wrap.innerHTML="";wrap.appendChild(table)}if(wrap.parentNode!==this)this.appendChild(wrap);const footer=this.querySelector(".c-table__pagination");if(footer)footer.remove();return}if(this.hasAttribute("skeleton")){const wrap=this.ensure(".c-table-wrap",()=>{const el=document.createElement("div");el.className="c-table-wrap";return el});const colsKey=JSON.stringify(cols);const table=(wrap.querySelector("table.c-table")&&this._tableCols===colsKey)?wrap.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");cols.forEach((c)=>{const colLabel=typeof c==="string"?c:(c.label||c.title||c);const th=document.createElement("th");th.textContent=colLabel;tr.appendChild(th)});thead.appendChild(tr);t.appendChild(thead);t.appendChild(document.createElement("tbody"));return t})();this._tableCols=colsKey;const tbody=table.querySelector("tbody");tbody.innerHTML="";const count=Math.min(5,Math.max(1,parseInt(this.getAttribute("skeleton")||"3",10)||3));for(let i=0;i<count;i++){const tr=document.createElement("tr");cols.forEach(()=>{const td=document.createElement("td");const sk=document.createElement("span");sk.className="c-skeleton";sk.style.display="inline-block";sk.style.inlineSize="60%";sk.style.blockSize="0.8rem";td.appendChild(sk);tr.appendChild(td)});tbody.appendChild(tr)}if(table.parentNode!==wrap){wrap.innerHTML="";wrap.appendChild(table)}if(wrap.parentNode!==this)this.appendChild(wrap);const footer=this.querySelector(".c-table__pagination");if(footer)footer.remove();return}if(this._sortCol===undefined){const sortAttr=this.getAttribute("sort");if(sortAttr!==null){const idx=Number(sortAttr);this._sortCol=Number.isFinite(idx)?idx:cols.findIndex((c)=>(typeof c==="object"&&c&&(c.label||c.title||c)===sortAttr));if(this._sortCol<0)this._sortCol=null}else{this._sortCol=null}const dirAttr=this.getAttribute("sort-dir");this._sortDir=dirAttr==="descending"||dirAttr==="desc"?-1:1}let working=Array.isArray(data)?data.slice():[];if(this._sortCol!==null&&this._sortCol!==undefined&&this._sortCol>=0&&this._sortCol<cols.length){const col=this._sortCol;const dir=this._sortDir||1;const colSpec=cols[col];const type=(typeof colSpec==="object"&&colSpec&&colSpec.sortType)?colSpec.sortType:"text";working.sort((a,b)=>this._compare(a&&a[col],b&&b[col],type)*dir)}if(!this._filters)this._filters={};const activeFilters=Object.keys(this._filters).filter((k)=>this._filters[k]);if(activeFilters.length){working=working.filter((row)=>activeFilters.every((k)=>{const ci=Number(k);const q=String(this._filters[ci]||"").toLowerCase();if(!q)return true;return String(this._cellValue(row[ci])).toLowerCase().includes(q)}))}const pageSizeRaw=this.getAttribute("page-size");const pageSize=pageSizeRaw!==null?parseInt(pageSizeRaw,10):NaN;const usePaging=Number.isFinite(pageSize)&&pageSize>0;let pageAttr=this.getAttribute("page");if(this.getAttribute("persist")&&this.id){const mode=this.getAttribute("persist");let stored=null;if(mode==="storage"){try{stored=localStorage.getItem("contour-table:"+this.id)}catch(e){}}else if(mode==="url"){try{stored=new URLSearchParams(window.location.search).get("c-table")}catch(e){}}if(stored!==null)pageAttr=stored}if(this._pageInternal){this._pageInternal=false;this._pageAttrLast=pageAttr}else if(pageAttr!==this._pageAttrLast){this._page=null;this._pageAttrLast=pageAttr}let page=this._page!==null?this._page:(parseInt(pageAttr||"1",10));if(!Number.isFinite(page)||page<1)page=1;let totalPages=1;let pageData=working;if(usePaging){totalPages=Math.max(1,Math.ceil(working.length/pageSize));if(page>totalPages)page=totalPages;const start=(page-1)*pageSize;pageData=working.slice(start,start+pageSize)}this._page=page;this._totalPages=totalPages;this._pageSize=pageSize;const wrap=this.ensure(".c-table-wrap",()=>{const el=document.createElement("div");el.className="c-table-wrap";return el});const colsKey=JSON.stringify(cols);const table=(wrap.querySelector("table.c-table")&&this._tableCols===colsKey)?wrap.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");cols.forEach((c,i)=>{const colLabel=typeof c==="string"?c:(c.label||c.title||c);const th=document.createElement("th");const sortable=(typeof c==="object"&&c!==null&&c.sort);const isSelect=(typeof c==="object"&&c!==null&&c.select);const isFilter=(typeof c==="object"&&c!==null&&c.filter);if(isFilter){th.className=(th.className+" c-table__filter").trim();const inp=document.createElement("input");inp.type="search";inp.className="c-table__filter-input";inp.placeholder=colLabel;inp.dataset.filterIndex=String(i);if(this._filters&&this._filters[i])inp.value=this._filters[i];th.appendChild(inp)}else if(isSelect){th.className=(th.className+" c-table__select").trim();const cb=document.createElement("input");cb.type="checkbox";cb.className="c-table__select-all";cb.setAttribute("aria-label","Select all rows");th.appendChild(cb)}else if(sortable){th.setAttribute("aria-sort",(this._sortCol===i)?(this._sortDir===-1?"descending":"ascending"):"none");const wrapEl=document.createElement("span");wrapEl.className="c-table__sort";wrapEl.textContent=colLabel;const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");svg.innerHTML='<use href="#i-chevron-down" />';wrapEl.appendChild(svg);th.appendChild(wrapEl)}else if(typeof c==="object"&&c!==null&&c.pinned){th.className="c-table__pinned";th.textContent=colLabel}else{th.textContent=colLabel}if(sortable){th.setAttribute("tabindex","0");th.setAttribute("role","columnheader");th.dataset.sortIndex=String(i)}tr.appendChild(th)});thead.appendChild(tr);t.appendChild(thead);t.appendChild(document.createElement("tbody"));return t})();this._tableCols=colsKey;cols.forEach((c,i)=>{if(typeof c==="object"&&c!==null&&c.sort){const th=table.querySelector("thead tr th:nth-child("+(i+1)+")");if(th)th.setAttribute("aria-sort",(this._sortCol===i)?(this._sortDir===-1?"descending":"ascending"):"none")}});const tbody=table.querySelector("tbody");tbody.innerHTML="";const useVirtual=this.hasAttribute("virtual")&&!usePaging&&pageData.length>100;const rowHeight=36;const windowSize=30;const overscan=10;let windowStart=0;let visibleData=pageData;if(useVirtual){const maxStart=Math.max(0,pageData.length-windowSize);windowStart=Math.min(maxStart,Math.max(0,Math.floor(wrap.scrollTop/rowHeight)-overscan));visibleData=pageData.slice(windowStart,windowStart+windowSize+overscan*2);table.setAttribute("aria-rowcount",String(pageData.length+1))}else{table.removeAttribute("aria-rowcount")}const addSpacer=(height)=>{const tr=document.createElement("tr");tr.setAttribute("aria-hidden","true");const td=document.createElement("td");td.colSpan=cols.length;td.style.blockSize=`${height}px`;td.style.padding="0";tr.appendChild(td);tbody.appendChild(tr)};if(useVirtual)addSpacer(windowStart*rowHeight);if(visibleData.length===0){const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=cols.length;td.textContent=this.getAttribute("empty")||"No data";td.style.textAlign="center";td.style.color="var(--color-text-muted)";tr.appendChild(td);tbody.appendChild(tr)}else{visibleData.forEach((row,ri)=>{const tr=document.createElement("tr");tr.dataset.rowIndex=String(windowStart+ri);tr.setAttribute("tabindex","0");cols.forEach((c,ci)=>{const isSelect=(typeof c==="object"&&c!==null&&c.select);const td=document.createElement("td");if(isSelect){const cb=document.createElement("input");cb.type="checkbox";cb.className="c-table__row-select";cb.dataset.rowIndex=String(windowStart+ri);if(this._selectedRows&&this._selectedRows.has(windowStart+ri))cb.checked=true;td.appendChild(cb)}else{td.textContent=this._cellValue(row[ci])}tr.appendChild(td)});tbody.appendChild(tr)})}if(useVirtual)addSpacer(Math.max(0,pageData.length-windowStart-visibleData.length)*rowHeight);if(table.parentNode!==wrap){wrap.innerHTML="";wrap.appendChild(table)}if(wrap.parentNode!==this)this.appendChild(wrap);if(this.hasAttribute("virtual")){wrap.style.maxHeight=wrap.style.maxHeight||"24rem";wrap.style.overflow="auto";table.classList.add("c-table--virtual")}else{wrap.style.maxHeight="";wrap.style.overflow="";table.classList.remove("c-table--virtual")}if(usePaging){const footer=this.ensure(".c-table__pagination",()=>{const el=document.createElement("div");el.className="c-table__pagination";return el});footer.innerHTML="";const prev=document.createElement("button");prev.className="c-btn c-btn--ghost c-btn--sm";prev.type="button";prev.textContent="Previous";prev.disabled=page<=1;prev.dataset.action="prev";const info=document.createElement("span");info.textContent=`Page ${page} of ${totalPages}`;const next=document.createElement("button");next.className="c-btn c-btn--ghost c-btn--sm";next.type="button";next.textContent="Next";next.disabled=page>=totalPages;next.dataset.action="next";footer.appendChild(prev);footer.appendChild(info);footer.appendChild(next)}else{const footer=this.querySelector(".c-table__pagination");if(footer)footer.remove()}}catch(e){}}}enhance(){if(this._wiredTable)return;this._wiredTable=true;const handleSort=(th)=>{const idx=Number(th.dataset.sortIndex);if(!Number.isFinite(idx))return;if(this._sortCol===idx){this._sortDir=(this._sortDir===1)?-1:1}else{this._sortCol=idx;this._sortDir=1}this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:idx,direction:this._sortDir===1?"ascending":"descending"}}));this.requestRender()};this.addEventListener("click",(e)=>{const retryBtn=e.target&&e.target.closest?e.target.closest('button[data-action="retry"]'):null;if(retryBtn&&this.contains(retryBtn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:retry",{detail:{src:this.getAttribute("src")},bubbles:true,composed:true}));return}const th=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;if(th&&this.contains(th)){e.preventDefault();handleSort(th);return}const btn=e.target&&e.target.closest?e.target.closest(".c-table__pagination button"):null;if(btn&&this.contains(btn)){e.preventDefault();const action=btn.dataset.action;let page=this._page!==null?this._page:(parseInt(this.getAttribute("page")||"1",10));if(!Number.isFinite(page)||page<1)page=1;if(action==="prev"&&page>1)page-=1;if(action==="next")page+=1;this._page=page;this._pageAttrLast=String(page);this._pageInternal=true;this.setAttribute("page",String(page));this.dispatchEvent(new CustomEvent("contour:page",{bubbles:true,composed:true,detail:{page}}));const persist=this.getAttribute("persist");if(persist==="storage"&&this.id){try{localStorage.setItem("contour-table:"+this.id,String(page))}catch(e){}}else if(persist==="url"){try{const url=new URL(window.location.href);url.searchParams.set("c-table",String(page));window.history.replaceState(null,"",url.toString())}catch(e){}}}});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;const th=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;if(th&&this.contains(th)){e.preventDefault();handleSort(th)}});this.addEventListener("input",(e)=>{const inp=e.target&&e.target.closest?e.target.closest(".c-table__filter-input"):null;if(!inp||!this.contains(inp))return;const idx=Number(inp.dataset.filterIndex);if(!Number.isFinite(idx))return;if(!this._filters)this._filters={};this._filters[idx]=inp.value;this.requestRender()});this.addEventListener("scroll",(e)=>{if(!this.hasAttribute("virtual")||!e.target||!e.target.classList||!e.target.classList.contains("c-table-wrap"))return;if(this._tableVirtualRaf)return;const run=()=>{this._tableVirtualRaf=0;this.requestRender()};this._tableVirtualRaf=typeof requestAnimationFrame==="function"?requestAnimationFrame(run):setTimeout(run,16)},true);this._selectedRows=this._selectedRows||new Set();this.addEventListener("change",(e)=>{const cb=e.target&&e.target.closest?e.target.closest(".c-table__row-select"):null;if(cb&&this.contains(cb)){const idx=Number(cb.dataset.rowIndex);if(!Number.isFinite(idx))return;if(cb.checked)this._selectedRows.add(idx);else this._selectedRows.delete(idx);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{rows:Array.from(this._selectedRows)}}));return}const all=e.target&&e.target.closest?e.target.closest(".c-table__select-all"):null;if(all&&this.contains(all)){const cbs=Array.from(this.querySelectorAll(".c-table__row-select"));cbs.forEach((c)=>{c.checked=all.checked});this._selectedRows=new Set(all.checked?cbs.map((c)=>Number(c.dataset.rowIndex)):[]);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{rows:Array.from(this._selectedRows)}}))}});this.addEventListener("mouseover",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;const idx=Number(tr.dataset.rowIndex);if(!Number.isFinite(idx))return;if(this._hoveredRow===idx)return;this._hoveredRow=idx;this.dispatchEvent(new CustomEvent("contour:hover",{bubbles:true,composed:true,detail:{row:idx}}))});this.addEventListener("mouseout",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;const related=e.relatedTarget&&e.relatedTarget.closest?e.relatedTarget.closest("tbody tr"):null;if(related===tr)return;this._hoveredRow=null;this.dispatchEvent(new CustomEvent("contour:leave",{bubbles:true,composed:true,detail:{}}))});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;const tr=e.target&&e.target.closest?e.target.closest("tbody tr"):null;if(!tr||!this.contains(tr))return;e.preventDefault();const idx=Number(tr.dataset.rowIndex);if(!Number.isFinite(idx))return;this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true,detail:{row:idx}}))})}}define("contour-table",ContourTable);class ContourDataTable extends ContourTable{render(){super.render();this.classList.add("c-data-table");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Data table")}}define("contour-data-table",ContourDataTable);class ContourChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["series","axis","empty","loading","error","retry","skeleton","zoomable","data-table","brush","brush-min","brush-max","brush-start","brush-end","note"]}static get properties(){return{series:{attribute:"series"},axis:{attribute:"axis"},zoomable:{attribute:"zoomable",type:Boolean},brush:{attribute:"brush",type:Boolean},note:{attribute:"note"}}}render(){this.classList.add("c-chart");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(this.getAttribute("axis")&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("axis"));if(this.hasAttribute("loading")){const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const loading=document.createElement("div");loading.className="c-chart__loading";loading.textContent=this.getAttribute("loading")||"Loading…";loading.style.display="grid";loading.style.placeItems="center";loading.style.height="100%";loading.style.color="var(--color-text-muted)";plot.appendChild(loading);const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=axis}return}if(this.hasAttribute("error")){const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const err=document.createElement("div");err.className="c-chart__error";err.textContent=this.getAttribute("error")||"Error";err.style.display="grid";err.style.placeItems="center";err.style.height="100%";err.style.color="var(--color-danger, var(--color-text))";if(this.hasAttribute("retry")){const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm";btn.type="button";btn.textContent=this.getAttribute("retry")||"Retry";btn.dataset.action="retry";btn.classList.add("u-mbs-sm");err.appendChild(btn)}plot.appendChild(err);const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=axis}return}if(this.hasAttribute("skeleton")){const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const count=Math.min(5,Math.max(1,parseInt(this.getAttribute("skeleton")||"3",10)||3));for(let i=0;i<count;i++){const sk=document.createElement("div");sk.className="c-skeleton";sk.style.display="block";sk.style.inlineSize="100%";sk.style.blockSize="0.6rem";sk.classList.add("u-mbe-2xs");plot.appendChild(sk)}const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=axis}return}const axis=this.getAttribute("axis");if(axis){const ax=this.ensure(".c-chart__axis",()=>{const el=document.createElement("div");el.className="c-chart__axis";return el});ax.textContent=axis}else{const ax=this.querySelector(".c-chart__axis");if(ax)ax.remove()}const series=this.getAttribute("series");if(series){let parsed=null;try{parsed=JSON.parse(series);const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const hasStructured=parsed.some((s)=>s&&Array.isArray(s.values));if(hasStructured){parsed.forEach((s,i)=>{const color=`var(--chart-${i + 1})`;if(s.type==="donut"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 200 200");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";svg.setAttribute("aria-hidden","true");donutSlices(s.values).forEach((sl,si)=>{const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-chart__line");path.setAttribute("data-series",String(i+1));path.style.setProperty("--c",color);path.setAttribute("d",sl.path);path.setAttribute("title",String(s.values[si]));path.setAttribute("aria-label","Series "+(i+1)+": "+String(s.values[si]));path.setAttribute("role","img");svg.appendChild(path)});plot.appendChild(svg)}else if(s.type==="histogram"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";barRects(s.values).forEach((r,ri)=>{const rect=document.createElementNS("http://www.w3.org/2000/svg","rect");rect.setAttribute("class","c-chart__bar");rect.setAttribute("data-series",String(i+1));rect.style.setProperty("--c",color);rect.setAttribute("x",r.x);rect.setAttribute("y",r.y);rect.setAttribute("width",r.width);rect.setAttribute("height",r.height);rect.setAttribute("title",String(s.values[ri]));rect.setAttribute("aria-label","Series "+(i+1)+": "+String(s.values[ri]));rect.setAttribute("tabindex","0");rect.setAttribute("role","button");rect.dataset.index=String(ri);svg.appendChild(rect)});plot.appendChild(svg)}else if(s.type==="scatter"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const pts=(Array.isArray(s.values)?s.values:[]).map((v)=>{if(Array.isArray(v))return{x:Number(v[0])||0,y:Number(v[1])||0};return{x:Number(v&&v.x)||0,y:Number(v&&v.y)||0}});const xs=pts.map((p)=>p.x);const ys=pts.map((p)=>p.y);const minX=xs.length?Math.min.apply(null,xs):0;const maxX=xs.length?Math.max.apply(null,xs):1;const minY=ys.length?Math.min.apply(null,ys):0;const maxY=ys.length?Math.max.apply(null,ys):1;const xRange=(maxX-minX)||1;const yRange=(maxY-minY)||1;pts.forEach((p,pi)=>{const circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("class","c-chart__point");circle.setAttribute("data-series",String(i+1));circle.setAttribute("data-index",String(pi));circle.style.setProperty("--c",color);const cx=((p.x-minX)/xRange)*300;const cy=120-((p.y-minY)/yRange)*120;circle.setAttribute("cx",cx.toFixed(2));circle.setAttribute("cy",cy.toFixed(2));circle.setAttribute("r","3");circle.setAttribute("tabindex",pi===0?"0":"-1");circle.setAttribute("role","button");circle.setAttribute("title",p.x+", "+p.y);circle.setAttribute("aria-label","Series "+(i+1)+": "+p.x+", "+p.y);svg.appendChild(circle)});plot.appendChild(svg)}else{const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-chart__line");path.setAttribute("data-series",String(i+1));path.style.setProperty("--c",color);path.setAttribute("d",smoothPath(s.values));svg.appendChild(path);const pts=polylinePoints(s.values).split(" ").map((p)=>p.split(",").map(Number));pts.forEach((pt,pi)=>{const circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("class","c-chart__point");circle.setAttribute("data-series",String(i+1));circle.setAttribute("data-index",String(pi));circle.style.setProperty("--c",color);circle.setAttribute("cx",String(pt[0]));circle.setAttribute("cy",String(pt[1]));circle.setAttribute("r","3");circle.setAttribute("tabindex",pi===0?"0":"-1");circle.setAttribute("role","button");circle.setAttribute("title",String(s.values[pi]));circle.setAttribute("aria-label","Series "+(i+1)+": "+String(s.values[pi]));svg.appendChild(circle)});plot.appendChild(svg)}})}else{const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";svg.setAttribute("aria-hidden","true");parsed.forEach((s,i)=>{const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-chart__line");path.setAttribute("data-series",String(i+1));path.style.setProperty("--c",`var(--chart-${i + 1})`);path.setAttribute("d",s.d||s);svg.appendChild(path)});plot.appendChild(svg)}}catch(e){}const tip=this.ensure(".c-chart__tooltip",()=>{const el=document.createElement("div");el.className="c-chart__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","");if(this.hasAttribute("data-table")){let table=this.querySelector(".c-chart__data-table");if(!table){table=document.createElement("table");table.className="c-chart__data-table visually-hidden";this.appendChild(table)}table.innerHTML="";const thead=document.createElement("thead");const hr=document.createElement("tr");const h=document.createElement("th");h.textContent="Series";hr.appendChild(h);const maxLen=parsed.reduce((m,s)=>Math.max(m,Array.isArray(s.values)?s.values.length:(Array.isArray(s)?s.length:0)),0);for(let i=0;i<maxLen;i++){const th=document.createElement("th");th.textContent="Value "+(i+1);hr.appendChild(th)}thead.appendChild(hr);table.appendChild(thead);const tbody=document.createElement("tbody");parsed.forEach((s,si)=>{const vals=Array.isArray(s.values)?s.values:(Array.isArray(s)?s:[]);const tr=document.createElement("tr");const td0=document.createElement("td");td0.textContent=s.label||("Series "+(si+1));tr.appendChild(td0);for(let i=0;i<maxLen;i++){const td=document.createElement("td");td.textContent=vals[i]!=null?String(vals[i]):"";tr.appendChild(td)}tbody.appendChild(tr)});table.appendChild(tbody)}else{const old=this.querySelector(".c-chart__data-table");if(old)old.remove()}if(this.hasAttribute("brush")){const brush=this.ensure("contour-brush",()=>document.createElement("contour-brush"));brush.setAttribute("min",this.getAttribute("brush-min")||"0");brush.setAttribute("max",this.getAttribute("brush-max")||"100");brush.setAttribute("start",this.getAttribute("brush-start")||this.getAttribute("brush-min")||"0");brush.setAttribute("end",this.getAttribute("brush-end")||this.getAttribute("brush-max")||"100");if(brush.previousElementSibling!==plot)this.appendChild(brush)}else{const brush=this.querySelector("contour-brush");if(brush)brush.remove()}const note=this.getAttribute("note");let noteEl=this.querySelector(".c-chart__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-chart__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}else{const plot=this.ensure(".c-chart__plot",()=>{const el=document.createElement("div");el.className="c-chart__plot";return el});plot.innerHTML="";const empty=document.createElement("div");empty.className="c-chart__empty";empty.textContent=this.getAttribute("empty")||"No data";empty.style.display="grid";empty.style.placeItems="center";empty.style.height="100%";empty.style.color="var(--color-text-muted)";plot.appendChild(empty);const note=this.getAttribute("note");let noteEl2=this.querySelector(".c-chart__note");if(note){if(!noteEl2){noteEl2=document.createElement("div");noteEl2.className="c-chart__note";this.appendChild(noteEl2)}noteEl2.textContent=note}else if(noteEl2){noteEl2.remove()}}}enhance(){if(this._wiredChart)return;this._wiredChart=true;if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");this.addEventListener("contour:legend-toggle",(e)=>{const key=e&&e.detail&&(e.detail.key||e.detail.label);const pressed=e&&e.detail&&e.detail.pressed;if(key==null)return;const nodes=this.querySelectorAll("[data-series]");nodes.forEach((n)=>{const s=n.getAttribute("data-series");if(String(s)===String(key)||n.getAttribute("data-key")===String(key)){n.style.display=pressed===false?"none":""}})});this.addEventListener("contour:brush-end",(e)=>{if(!this.hasAttribute("brush")||!e.target||!e.target.matches("contour-brush"))return;this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:e.detail,}))});if(this.hasAttribute("zoomable")){let zoom=1,panX=0,panY=0;const plot=this.querySelector(".c-chart__plot");const apply=()=>{if(!plot)return;plot.style.transform=`translate(${panX}px, ${panY}px) scale(${zoom})`;plot.style.transformOrigin="center center"};this.addEventListener("wheel",(e)=>{e.preventDefault();const factor=e.deltaY<0?1.1:0.9;zoom=Math.min(5,Math.max(0.5,zoom*factor));apply()},{passive:false});let dragging=false,startX=0,startY=0,startPanX=0,startPanY=0;this.addEventListener("mousedown",(e)=>{if(e.button!==0)return;dragging=true;startX=e.clientX;startY=e.clientY;startPanX=panX;startPanY=panY;this.style.cursor="grabbing"});const onMove=(e)=>{if(!dragging)return;panX=startPanX+(e.clientX-startX);panY=startPanY+(e.clientY-startY);apply()};const onUp=()=>{if(dragging){dragging=false;this.style.cursor=""}};window.addEventListener("mousemove",onMove);window.addEventListener("mouseup",onUp);onDispose(this,()=>{window.removeEventListener("mousemove",onMove);window.removeEventListener("mouseup",onUp)});this.addEventListener("dblclick",()=>{zoom=1;panX=0;panY=0;apply()})}let plotRectCache=null;let plotRectObserver=null;const invalidatePlotRect=()=>{plotRectCache=null};const showTip=(e)=>{const plot=this.querySelector(".c-chart__plot");const tip=this.querySelector(".c-chart__tooltip");if(!plot||!tip)return;const mark=e.target&&e.target.closest?e.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line"):null;if(!mark||!plot.contains(mark)){tip.setAttribute("hidden","");return}const title=mark.getAttribute("title");if(title)tip.textContent=title;if(!plotRectCache){plotRectCache=plot.getBoundingClientRect();if(!plotRectObserver&&typeof ResizeObserver==="function"){plotRectObserver=new ResizeObserver(invalidatePlotRect);plotRectObserver.observe(plot)}}const rect=plotRectCache;const mr=mark.getBoundingClientRect();const x=mr.left-rect.left+mr.width/2;const y=mr.top-rect.top;plot.style.setProperty("--chart-tip-inline-start",x+"px");plot.style.setProperty("--chart-tip-block-start",y+"px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-chart__tooltip");if(tip)tip.setAttribute("hidden","")};this.addEventListener("mousemove",showTip);this.addEventListener("mouseleave",hideTip);onDispose(this,()=>{if(plotRectObserver){plotRectObserver.disconnect();plotRectObserver=null}});this.addEventListener("focusin",(e)=>{const mark=e.target&&e.target.closest?e.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line"):null;if(mark&&this.contains(mark))showTip({target:mark})});this.addEventListener("focusout",(e)=>{if(!this.contains(e.relatedTarget))hideTip()});this.addEventListener("click",(e)=>{const plot2=this.querySelector(".c-chart__plot");if(!plot2)return;const bar=e.target&&e.target.closest?e.target.closest(".c-chart__bar"):null;if(bar&&plot2.contains(bar)){const series=parseInt(bar.getAttribute("data-series")||"1",10);const index=parseInt(bar.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}));return}const point=e.target&&e.target.closest?e.target.closest(".c-chart__point"):null;if(point&&plot2.contains(point)){const series=parseInt(point.getAttribute("data-series")||"1",10);const index=parseInt(point.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}))}});this.addEventListener("keydown",(e)=>{const plot2=this.querySelector(".c-chart__plot");if(!plot2)return;const bar=e.target&&e.target.closest?e.target.closest(".c-chart__bar"):null;if(bar&&plot2.contains(bar)){if(e.key==="Enter"||e.key===" "){e.preventDefault();const series=parseInt(bar.getAttribute("data-series")||"1",10);const index=parseInt(bar.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}))}return}const point=e.target&&e.target.closest?e.target.closest(".c-chart__point"):null;if(point&&plot2.contains(point)){if(e.key==="Enter"||e.key===" "){e.preventDefault();const series=parseInt(point.getAttribute("data-series")||"1",10);const index=parseInt(point.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series,index}}))}else if(e.key==="ArrowRight"||e.key==="ArrowLeft"){e.preventDefault();const points=Array.from(plot2.querySelectorAll('.c-chart__point[data-series="'+point.getAttribute("data-series")+'"]'));const idx=points.indexOf(point);const next=e.key==="ArrowRight"?Math.min(idx+1,points.length-1):Math.max(idx-1,0);if(next!==idx&&points[next]){points.forEach((p,i)=>p.setAttribute("tabindex",i===next?"0":"-1"));try{points[next].focus()}catch(err){}}}}});this.addEventListener("keydown",(e)=>{if(e.target!==this)return;let seriesCount=0;try{seriesCount=JSON.parse(this.getAttribute("series")||"[]").length}catch(e){seriesCount=0}if(seriesCount===0)return;if(this._activeSeries===undefined)this._activeSeries=0;let next=this._activeSeries;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowRight")next=rtl?Math.max(this._activeSeries-1,0):Math.min(this._activeSeries+1,seriesCount-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(this._activeSeries+1,seriesCount-1):Math.max(this._activeSeries-1,0);else if(e.key==="ArrowDown")next=Math.min(this._activeSeries+1,seriesCount-1);else if(e.key==="ArrowUp")next=Math.max(this._activeSeries-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=seriesCount-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:this._activeSeries}}));return}else return;if(next!==this._activeSeries){e.preventDefault();this._activeSeries=next;this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:next}}))}})}}define("contour-chart",ContourChart);class ContourComparison extends ContourBase{static get observed(){return["divider","value","before","after"]}static get properties(){return{divider:{attribute:"divider"},value:{attribute:"value"},before:{attribute:"before"},after:{attribute:"after"}}}render(){this.classList.add("c-comparison");this.setAttribute("role","group");this.setAttribute("aria-label","Comparison");if(!this.style.blockSize)this.style.blockSize="12rem";this.style.setProperty("--comparison-pos",(this.getAttribute("value")||"50")+"%");const beforeLabel=this.getAttribute("before")||"Before";const afterLabel=this.getAttribute("after")||"After";if(!this.querySelector(".c-comparison__pane--before")){const p=document.createElement("div");p.className="c-comparison__pane c-comparison__pane--before";p.textContent=beforeLabel;this.appendChild(p)}else{const p=this.querySelector(".c-comparison__pane--before");if(p)p.textContent=beforeLabel}if(!this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)")){const p=document.createElement("div");p.className="c-comparison__pane";p.textContent=afterLabel;this.appendChild(p)}else{const p=this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)");if(p)p.textContent=afterLabel}const divider=this.getAttribute("divider");if(divider!==null){const d=this.ensure(".c-comparison__divider",()=>{const el=document.createElement("div");el.className="c-comparison__divider";el.setAttribute("role","separator");el.setAttribute("aria-orientation","vertical");el.setAttribute("tabindex","0");return el});if(divider)d.textContent=divider}else{const d=this.querySelector(".c-comparison__divider");if(d)d.remove()}}enhance(){if(this._wiredComparison)return;this._wiredComparison=true;const divider=()=>this.querySelector(".c-comparison__divider");const setPos=(pct)=>{const clamped=Math.max(0,Math.min(100,pct));this.style.setProperty("--comparison-pos",clamped+"%");this.setAttribute("value",String(Math.round(clamped)));this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:true,composed:true,detail:{value:clamped}}))};let dragging=false;const onMove=(e)=>{if(!dragging)return;const rect=this.getBoundingClientRect();const pct=((e.clientX-rect.left)/rect.width)*100;setPos(pct)};const onUp=()=>{dragging=false;window.removeEventListener("mousemove",onMove);window.removeEventListener("mouseup",onUp)};onDispose(this,()=>{dragging=false;window.removeEventListener("mousemove",onMove);window.removeEventListener("mouseup",onUp)});this.addEventListener("mousedown",(e)=>{const d=divider();if(!d||!d.contains(e.target))return;dragging=true;window.addEventListener("mousemove",onMove);window.addEventListener("mouseup",onUp);e.preventDefault()});this.addEventListener("keydown",(e)=>{const d=divider();if(!d||document.activeElement!==d)return;const cur=parseFloat(this.style.getPropertyValue("--comparison-pos"))||50;if(e.key==="ArrowLeft"){e.preventDefault();setPos(cur-5)}else if(e.key==="ArrowRight"){e.preventDefault();setPos(cur+5)}})}}define("contour-comparison",ContourComparison);class ContourStreamingChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["line","dot","interval","pause","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{line:{attribute:"line"},dot:{attribute:"dot"},interval:{attribute:"interval",type:Number},pause:{attribute:"pause",type:Boolean},src:{attribute:"src"}}}render(){this.classList.add("c-streaming-chart");this.setAttribute("role","img");this.setAttribute("aria-label","Streaming chart");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");wireStates(this);loadRemote(this,"line");if(renderStates(this,"streaming-chart"))return;const line=remoteData(this,"line");const dot=remoteData(this,"dot");if(!line){const svg=this.querySelector("svg");if(svg)svg.remove();renderEmpty(this,"streaming-chart");return}if(line){let svg=this.querySelector("svg");if(!svg){svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 192");svg.setAttribute("aria-hidden","true");this.appendChild(svg)}let path=svg.querySelector(".c-streaming-chart__line");if(!path){path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-streaming-chart__line");svg.appendChild(path)}path.setAttribute("d",line);if(dot){let circle=svg.querySelector(".c-streaming-chart__live-dot");if(!circle){circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("class","c-streaming-chart__live-dot");circle.setAttribute("r","4");svg.appendChild(circle)}const parts=dot.split(/[ ,]+/);if(parts.length>=2){circle.setAttribute("cx",parts[0]);circle.setAttribute("cy",parts[1])}}}}enhance(){const sync=()=>{const seconds=parseFloat(this.getAttribute("interval")||"");const want=Number.isFinite(seconds)&&seconds>0&&!this.hasAttribute("pause")&&!this._streamPausedByUser&&this._viewVisible!==false;if(want===this._streamRunning)return;this._streamRunning=want;if(this._streamTimer!==undefined){clearInterval(this._streamTimer);this._streamTimer=undefined}this.dispatchEvent(new CustomEvent("contour:stream-state",{detail:{running:want},bubbles:true,composed:true}));if(!want)return;this._streamTimer=setInterval(()=>{if(!this.isConnected||this.hasAttribute("pause"))return;this._streamFrame+=1;this.dispatchEvent(new CustomEvent("contour:tick",{detail:{frame:this._streamFrame},bubbles:true,composed:true}));const src=this.getAttribute("src");if(src){remoteInvalidate(src);this.requestRender()}},Math.max(1000,seconds*1000))};sync();if(!this._wiredStreamView){this._wiredStreamView=true;this._viewVisible=true;watchViewport(this);this.addEventListener("contour:view-enter",()=>{this._viewVisible=true;sync()});this.addEventListener("contour:view-leave",()=>{this._viewVisible=false;sync()})}if(this._wiredStream)return;this._wiredStream=true;this._streamFrame=0;onDispose(this,()=>{if(this._streamTimer!==undefined){clearInterval(this._streamTimer);this._streamTimer=undefined}});this._streamPausedByUser=false;this.addEventListener("keydown",(e)=>{if(e.key===" "||e.key==="Enter"){e.preventDefault();this._streamPausedByUser=!this._streamPausedByUser;if(this._streamPausedByUser)this.setAttribute("data-user-paused","");else this.removeAttribute("data-user-paused");sync()}})}}define("contour-streaming-chart",ContourStreamingChart);class ContourMeter extends ContourBase{static get observed(){return["value","label","variant","min","max","low","high","optimum","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},variant:{attribute:"variant"},min:{attribute:"min"},max:{attribute:"max"},low:{attribute:"low"},high:{attribute:"high"},optimum:{attribute:"optimum"},src:{attribute:"src"}}}render(){this.classList.add("c-meter");wireStates(this);loadRemote(this,["value","label"]);if(renderStates(this,"meter"))return;const rValue=remoteData(this,"value")||(this._remoteData&&this._remoteData.value);const label=remoteData(this,"label")||(this._remoteData&&this._remoteData.label)||"";const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-meter--"))this.classList.remove(c)});if(variant)this.classList.add("c-meter--"+variant);if(!rValue&&!label){renderEmpty(this,"meter");return}if(rValue===null){this.style.removeProperty("--meter-value")}else{const num=parseFloat(rValue);if(Number.isFinite(num))this.style.setProperty("--meter-value",rValue);else this.style.removeProperty("--meter-value")}const core=this.ensure(".c-meter__core",()=>{const el=document.createElement("span");el.className="c-meter__core";return el});let val=core.querySelector(".c-meter__value");if(!val){val=document.createElement("span");val.className="c-meter__value";core.appendChild(val)}const num=parseFloat(rValue);val.textContent=(Number.isFinite(num)?Math.round(num*100):0)+"%";if(label){const lbl=core.querySelector(".c-meter__label")||(()=>{const el=document.createElement("span");el.className="c-meter__label";core.appendChild(el);return el})();lbl.textContent=label}if(!this.hasAttribute("role"))this.setAttribute("role","meter");if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);const ariaValue=rValue===null?"0":rValue;const prevVal=this._meterAriaValue;if(!this.hasAttribute("aria-valuenow")||this.getAttribute("aria-valuenow")===prevVal){this.setAttribute("aria-valuenow",ariaValue);this._meterAriaValue=ariaValue}const min=this.getAttribute("min");const max=this.getAttribute("max");if(min!==null)this.setAttribute("aria-valuemin",min);else if(!this.hasAttribute("aria-valuemin"))this.setAttribute("aria-valuemin","0");if(max!==null)this.setAttribute("aria-valuemax",max);else if(!this.hasAttribute("aria-valuemax"))this.setAttribute("aria-valuemax","1");for(const a of["low","high","optimum"]){const v=this.getAttribute(a);if(v!==null)this.setAttribute("data-"+a,v);else this.removeAttribute("data-"+a)}}}define("contour-meter",ContourMeter);class ContourDelta extends ContourBase{static get observed(){return["value","direction","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{value:{attribute:"value"},direction:{attribute:"direction"},src:{attribute:"src"}}}render(){this.classList.add("c-delta");wireStates(this);loadRemote(this,"value");if(renderStates(this,"delta"))return;const value=remoteData(this,"value")||"";Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-delta--"))this.classList.remove(c)});const direction=this.getAttribute("direction")||(this._remoteData&&this._remoteData.direction)||"up";if(!value){renderEmpty(this,"delta");return}this.classList.add("c-delta--"+direction);const icon={up:"#i-arrow-up",down:"#i-arrow-down",flat:"#i-minus"}[direction]||"#i-arrow-up";this.querySelectorAll("svg").forEach((s)=>s.remove());const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href",icon);svg.appendChild(use);this.appendChild(svg);this.appendChild(document.createTextNode(" "+value))}}define("contour-delta",ContourDelta);class ContourStat extends ContourBase{static get observed(){return["value","label","delta","unit","format","locale","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},delta:{attribute:"delta"},unit:{attribute:"unit"},format:{attribute:"format"},locale:{attribute:"locale"},src:{attribute:"src"}}}render(){this.classList.add("c-stat");wireStates(this);loadRemote(this,["value","label"]);if(renderStates(this,"stat"))return;const value=remoteData(this,"value");const label=remoteData(this,"label");const delta=this.getAttribute("delta");if(value){const v=this.ensure(".c-stat__value",()=>{const el=document.createElement("div");el.className="c-stat__value";el.setAttribute("aria-live","polite");return el});v.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const v=this.querySelector(".c-stat__value");if(v)v.remove()}if(label){const l=this.ensure(".c-stat__label",()=>{const el=document.createElement("div");el.className="c-stat__label";return el});l.textContent=label}else{const l=this.querySelector(".c-stat__label");if(l)l.remove()}if(delta){const d=this.ensure(".c-stat__delta",()=>{const el=document.createElement("div");el.className="c-stat__delta";return el});d.textContent=delta}else{const d=this.querySelector(".c-stat__delta");if(d)d.remove()}const unit=this.getAttribute("unit");const v=this.querySelector(".c-stat__value");if(v){if(unit){let u=v.querySelector(".c-stat__unit");if(!u){u=document.createElement("span");u.className="c-stat__unit";v.appendChild(u)}u.textContent=unit}else{const u=v.querySelector(".c-stat__unit");if(u)u.remove()}}if(!value&&!label){renderEmpty(this,"stat")}}}define("contour-stat",ContourStat);class ContourGauge extends ContourBase{static get observed(){return["value","min","max","heading","thresholds","format","locale","unit","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","brownout","brownout-level","no-data-message","show-header","description"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},heading:{attribute:"heading"},thresholds:{attribute:"thresholds"},format:{attribute:"format"},locale:{attribute:"locale"},unit:{attribute:"unit"},src:{attribute:"src"},brownout:{attribute:"brownout"}}}render(){this.classList.add("c-gauge");wireStates(this);loadRemote(this,["value"]);if(renderStates(this,"gauge"))return;const rawValue=this.getAttribute("value");const num=parseFloat(rawValue);const hasValue=rawValue!==null&&rawValue!==""&&Number.isFinite(num);const min=parseFloat(this.getAttribute("min")||"0");const max=parseFloat(this.getAttribute("max")||"100");const heading=this.getAttribute("heading");const showHeader=this.getAttribute("show-header")!=="false";const description=this.getAttribute("description");const noDataMessage=this.getAttribute("no-data-message")||"No readings in view";const brownoutLevel=this.brownoutLevel();if(!hasValue){if(heading&&showHeader){const t=this.ensure(".c-gauge__title",()=>{const el=document.createElement("div");el.className="c-gauge__title";return el});t.textContent=heading}const empty=this.ensure(".c-gauge__empty",()=>{const el=document.createElement("div");el.className="c-gauge__empty";el.setAttribute("part","empty");return el});empty.textContent=noDataMessage;[".c-gauge__dial",".c-gauge__value",".c-gauge__band"].forEach((sel)=>{const n=this.querySelector(sel);if(n)n.remove()});return}if(heading&&showHeader){const t=this.ensure(".c-gauge__title",()=>{const el=document.createElement("div");el.className="c-gauge__title";el.setAttribute("part","title");return el});t.textContent=heading}else{const t=this.querySelector(".c-gauge__title");if(t)t.remove()}let thresholds=[];const tAttr=this.getAttribute("thresholds");if(tAttr){try{thresholds=JSON.parse(tAttr)}catch(e){thresholds=[]}}let band=null;if(thresholds&&thresholds.length){const sorted=[...thresholds].sort((a,b)=>(a.value||0)-(b.value||0));for(let i=sorted.length-1;i>=0;i--){if(num>=(sorted[i].value||0)){band=sorted[i];break}}}const shedDial=this.shed("dial",3);let dial=this.querySelector(".c-gauge__dial");if(shedDial){if(dial)dial.remove()}else{if(!dial){dial=document.createElementNS("http://www.w3.org/2000/svg","svg");dial.setAttribute("class","c-gauge__dial");dial.setAttribute("part","dial");dial.setAttribute("aria-hidden","true");dial.setAttribute("viewBox","0 0 100 100");this.appendChild(dial)}dial.innerHTML="";const track=document.createElementNS("http://www.w3.org/2000/svg","path");track.setAttribute("class","c-gauge__track");track.setAttribute("d","M 10 90 A 40 40 0 0 1 90 90");dial.appendChild(track);if(thresholds&&thresholds.length){const sorted=[...thresholds].sort((a,b)=>(a.value||0)-(b.value||0));const toPoint=(v)=>{const pos=(1-(v-min)/(max-min||1))*Math.PI;return{x:50+40*Math.cos(pos),y:90-40*Math.sin(pos)}};for(let i=0;i<sorted.length;i++){const v1=sorted[i].value||0;const v2=(i+1<sorted.length)?(sorted[i+1].value||max):max;const p1=toPoint(v1);const p2=toPoint(v2);const z=document.createElementNS("http://www.w3.org/2000/svg","path");z.setAttribute("class","c-gauge__zone");z.setAttribute("stroke",sorted[i].color||"var(--color-primary)");z.setAttribute("d","M "+p1.x.toFixed(2)+" "+p1.y.toFixed(2)+" A 40 40 0 0 1 "+p2.x.toFixed(2)+" "+p2.y.toFixed(2));dial.appendChild(z)}}const ratio=(num-min)/(max-min||1);const angle=Math.PI*(1-ratio);const needle=document.createElementNS("http://www.w3.org/2000/svg","line");needle.setAttribute("class","c-gauge__needle needle");needle.setAttribute("x1","50");needle.setAttribute("y1","90");needle.setAttribute("x2",String(50+35*Math.cos(angle)));needle.setAttribute("y2",String(90-35*Math.sin(angle)));dial.appendChild(needle);const hub=document.createElementNS("http://www.w3.org/2000/svg","circle");hub.setAttribute("class","c-gauge__hub hub");hub.setAttribute("cx","50");hub.setAttribute("cy","90");hub.setAttribute("r","4");dial.appendChild(hub)}const valueEl=this.ensure(".c-gauge__value",()=>{const el=document.createElement("div");el.className="c-gauge__value";el.setAttribute("part","value");return el});valueEl.textContent=formatValue(String(num),this.getAttribute("format"),this.getAttribute("locale"))+(this.getAttribute("unit")?" "+this.getAttribute("unit"):"");valueEl.setAttribute("role","meter");valueEl.setAttribute("aria-valuenow",String(num));valueEl.setAttribute("aria-valuemin",String(min));valueEl.setAttribute("aria-valuemax",String(max));if(heading){if(!valueEl.id)valueEl.id=contourId("gauge-value")}if(band){valueEl.setAttribute("aria-valuetext",num+", "+(band.label||(">= "+band.value)))}else{valueEl.setAttribute("aria-valuetext",String(num))}const titleEl=this.querySelector(".c-gauge__title");if(titleEl){if(!titleEl.id)titleEl.id=contourId("gauge-title");valueEl.setAttribute("aria-labelledby",titleEl.id);valueEl.removeAttribute("aria-label")}else{valueEl.removeAttribute("aria-labelledby");if(heading)valueEl.setAttribute("aria-label",heading)}const bandEl=this.querySelector(".c-gauge__band");if(band){const b=this.ensure(".c-gauge__band",()=>{const el=document.createElement("div");el.className="c-gauge__band";el.setAttribute("part","band");return el});b.textContent=band.label||(">= "+band.value)}else{if(bandEl)bandEl.remove()}if(description){let d=this.querySelector(".c-gauge__desc");if(!d){d=document.createElement("div");d.className="c-gauge__desc";this.appendChild(d)}d.textContent=description}}enhance(){}}define("contour-gauge",ContourGauge);class ContourAxis extends ContourBase{static get observed(){return["orientation","values","ticks","format","locale","padding","min","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{orientation:{attribute:"orientation"},values:{attribute:"values"},ticks:{attribute:"ticks"},format:{attribute:"format"},locale:{attribute:"locale"},padding:{attribute:"padding"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}render(){this.classList.add("c-axis");this.setAttribute("role","img");this.setAttribute("aria-label","Axis");const orientation=this.getAttribute("orientation")||"horizontal";this.classList.toggle("c-axis--horizontal",orientation==="horizontal");this.classList.toggle("c-axis--vertical",orientation==="vertical");if(orientation==="horizontal")this.setAttribute("part","axis-x");else this.setAttribute("part","axis-y");wireStates(this);loadRemote(this,["values"]);if(renderStates(this,"axis"))return;let values=[];const vAttr=this.getAttribute("values");if(vAttr){try{values=JSON.parse(vAttr)}catch(e){values=vAttr.split(",").map((x)=>x.trim())}}const ticks=parseInt(this.getAttribute("ticks")||"0",10)||values.length;const authoredTicks=Array.from(this.querySelectorAll(":scope > .c-axis__tick"));if(authoredTicks.length){authoredTicks.forEach((tick)=>{const label=tick.querySelector(".c-axis__label");if(label&&!label.textContent)label.textContent=tick.textContent})}else{Array.from(this.querySelectorAll(".c-axis__tick")).forEach((n)=>n.remove());const list=values.length?values:Array.from({length:ticks},(_,i)=>i);list.forEach((v)=>{const tick=document.createElement("span");tick.className="c-axis__tick";const label=document.createElement("span");label.className="c-axis__label";label.textContent=formatValue(String(v),this.getAttribute("format"),this.getAttribute("locale"));tick.appendChild(label);this.appendChild(tick)})}}enhance(){}}define("contour-axis",ContourAxis);class ContourBrush extends ContourBase{static get observed(){return["start","end","min","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}render(){this.classList.add("c-brush");this.setAttribute("role","group");this.setAttribute("aria-label","Brush selection");wireStates(this);loadRemote(this,[]);if(renderStates(this,"brush"))return;let sel=this.querySelector(".c-brush__selection");if(!sel){sel=document.createElement("div");sel.className="c-brush__selection";this.appendChild(sel)}const start=parseFloat(this.getAttribute("start")||"0");const end=parseFloat(this.getAttribute("end")||"100");const min=parseFloat(this.getAttribute("min")||"0");const max=parseFloat(this.getAttribute("max")||"100");const range=max-min||1;const left=((start-min)/range)*100;const width=((end-start)/range)*100;sel.style.insetInlineStart=left+"%";sel.style.inlineSize=width+"%";["start","end"].forEach((h)=>{let handle=this.querySelector(".c-brush__handle--"+h);if(!handle){handle=document.createElement("div");handle.className="c-brush__handle c-brush__handle--"+h;this.appendChild(handle)}const val=h==="start"?start:end;handle.style.insetInlineStart=(((val-min)/range)*100)+"%"})}enhance(){if(this._wiredBrush)return;this._wiredBrush=true;let dragging=null;const min=()=>parseFloat(this.getAttribute("min")||"0");const max=()=>parseFloat(this.getAttribute("max")||"100");const toValue=(clientX)=>{const r=this.getBoundingClientRect();const ratio=Math.max(0,Math.min(1,(clientX-r.left)/(r.width||1)));return min()+ratio*(max()-min())};this.addEventListener("pointerdown",(e)=>{const handle=e.target&&e.target.classList&&e.target.classList.contains("c-brush__handle")?e.target:null;dragging=handle?(handle.classList.contains("c-brush__handle--start")?"start":"end"):"move";try{this.setPointerCapture(e.pointerId)}catch(err){}this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:true,composed:true,detail:{value:this.getAttribute("start"),start:this.getAttribute("start"),end:this.getAttribute("end")}}))});this.addEventListener("pointermove",(e)=>{if(!dragging)return;const v=toValue(e.clientX);const mn=min(),mx=max(),range=mx-mn||1;const sel=this.querySelector(".c-brush__selection");let ns=parseFloat(this.getAttribute("start")||"0");let ne=parseFloat(this.getAttribute("end")||"100");if(dragging==="start"){ns=Math.min(v,ne)}else if(dragging==="end"){ne=Math.max(v,ns)}else{const width=ne-ns;ns=v-width/2;ne=v+width/2;if(ns<mn){ne+=mn-ns;ns=mn}if(ne>mx){ns-=ne-mx;ne=mx}}ns=Math.max(mn,Math.min(mx,ns));ne=Math.max(mn,Math.min(mx,ne));if(sel){sel.style.insetInlineStart=(((ns-mn)/range)*100)+"%";sel.style.inlineSize=(((ne-ns)/range)*100)+"%"}const sh=this.querySelector(".c-brush__handle--start");const eh=this.querySelector(".c-brush__handle--end");if(sh)sh.style.insetInlineStart=(((ns-mn)/range)*100)+"%";if(eh)eh.style.insetInlineStart=(((ne-mn)/range)*100)+"%";this._brushPending={start:ns,end:ne};this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:true,composed:true,detail:{start:ns,end:ne,value:ns}}))});this.addEventListener("pointerup",(e)=>{if(!dragging)return;dragging=null;const p=this._brushPending;if(p){this.setAttribute("start",String(p.start));this.setAttribute("end",String(p.end));this._brushPending=null}this.dispatchEvent(new CustomEvent("contour:brush-end",{bubbles:true,composed:true,detail:{value:this.getAttribute("end"),start:this.getAttribute("start"),end:this.getAttribute("end")}}));this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:true,composed:true,detail:{start:this.getAttribute("start"),end:this.getAttribute("end"),value:this.getAttribute("end")}}))});if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:true,composed:true,detail:{value:this.getAttribute("start"),start:this.getAttribute("start"),end:this.getAttribute("end")}}))}})}}define("contour-brush",ContourBrush);class ContourStackedBar extends ContourBase{static get observed(){return["segments","values","colors","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","normalize"]}static get properties(){return{segments:{attribute:"segments"},values:{attribute:"values"},colors:{attribute:"colors"},src:{attribute:"src"},normalize:{attribute:"normalize"}}}render(){this.classList.add("c-stacked-bar");this.setAttribute("role","img");this.setAttribute("aria-label","Stacked bar");wireStates(this);loadRemote(this,["segments","values"]);if(renderStates(this,"stacked-bar"))return;Array.from(this.querySelectorAll(".c-stacked-bar__segment")).forEach((n)=>n.remove());const authoredSegments=Array.from(this.querySelectorAll(":scope > .c-stacked-bar__segment"));let segments=[];if(authoredSegments.length){segments=authoredSegments.map((el)=>({label:el.getAttribute("title")||el.textContent||"",value:parseFloat(el.style.inlineSize)||0,color:(el.dataset&&el.dataset.color)||el.style.background||undefined,}));authoredSegments.forEach((el)=>el.remove())}else{const sAttr=this.getAttribute("segments");if(sAttr){try{segments=JSON.parse(sAttr)}catch(e){segments=[]}}}const values=segments.map((seg)=>(typeof seg==="object"?(seg.value||0):Number(seg)||0));const total=values.reduce((a,b)=>a+b,0)||1;const normalize=this.hasAttribute("normalize");const denom=normalize?total:(parseFloat(this.getAttribute("max")||String(total))||total);segments.forEach((seg,i)=>{const v=values[i];const el=document.createElement("div");el.className="c-stacked-bar__segment";el.style.inlineSize=((v/denom)*100)+"%";el.style.background=(typeof seg==="object"&&seg.color)?seg.color:"var(--chart-"+((i%8)+1)+")";el.dataset.color=(typeof seg==="object"&&seg.color)?seg.color:el.style.background;el.setAttribute("title",(typeof seg==="object"?(seg.label||""):"")+" "+v);this.appendChild(el)});if(!segments.length)renderEmpty(this,"stacked-bar")}enhance(){}}define("contour-stacked-bar",ContourStackedBar);class ContourCategory extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","search","note","limit","sort"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"},search:{attribute:"search"},note:{attribute:"note"},limit:{attribute:"limit"},sort:{attribute:"sort"}}}render(){this.classList.add("c-category");this.setAttribute("role","listbox");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Category");wireStates(this);loadRemote(this,["items"]);if(renderStates(this,"category"))return;Array.from(this.querySelectorAll(".c-category__item")).forEach((n)=>n.remove());const authoredItems=Array.from(this.querySelectorAll(":scope > .c-category__item"));let items=[];if(authoredItems.length){authoredItems.forEach((el)=>{const lbl=el.querySelector(".c-category__label");items.push({label:lbl?lbl.textContent:el.textContent,value:0})});authoredItems.forEach((el)=>el.remove())}else{const iAttr=this.getAttribute("items");if(iAttr){try{items=JSON.parse(iAttr)}catch(e){items=[]}}}const sort=this.getAttribute("sort")||"value-desc";items.sort((a,b)=>{const va=(typeof a==="object")?(a.value||0):(Number(a)||0);const vb=(typeof b==="object")?(b.value||0):(Number(b)||0);const la=(typeof a==="object")?(a.label||a.name||""):String(a);const lb=(typeof b==="object")?(b.label||b.name||""):String(b);if(sort==="value-asc")return va-vb;if(sort==="alpha-asc")return String(la).localeCompare(String(lb));if(sort==="alpha-desc")return String(lb).localeCompare(String(la));return vb-va});const limit=parseInt(this.getAttribute("limit")||"0",10);if(limit>0)items=items.slice(0,limit);const max=items.reduce((m,it)=>Math.max(m,(typeof it==="object"?(it.value||0):Number(it)||0)),0)||1;items.forEach((it,idx)=>{const value=(typeof it==="object")?(it.value||0):(Number(it)||0);const label=(typeof it==="object")?(it.label||it.name||""):String(it);const item=document.createElement("div");item.className="c-category__item";item.setAttribute("role","option");item.setAttribute("aria-selected","false");item.setAttribute("tabindex",idx===0?"0":"-1");const lbl=document.createElement("span");lbl.className="c-category__label";lbl.textContent=label;const barWrap=document.createElement("div");barWrap.style.flex="1";const bar=document.createElement("div");bar.className="c-category__bar";bar.style.inlineSize=((value/max)*100)+"%";barWrap.appendChild(bar);const val=document.createElement("span");val.className="c-category__value";val.textContent=String(value);item.appendChild(lbl);item.appendChild(barWrap);item.appendChild(val);this.appendChild(item)});if(!items.length)renderEmpty(this,"category");const note=this.getAttribute("note");let noteEl=this.querySelector(".c-category__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-category__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}enhance(){if(this._wiredCategory)return;this._wiredCategory=true;const items=()=>Array.from(this.querySelectorAll(".c-category__item"));const showTip=(e)=>{};this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!item||!this.contains(item))return;const all=items();const idx=all.indexOf(item);all.forEach((o,i)=>o.setAttribute("aria-selected",i===idx?"true":"false"));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,label:item.querySelector(".c-category__label")?item.querySelector(".c-category__label").textContent:item.textContent.trim()}}))});this.addEventListener("keydown",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!item||!this.contains(item))return;const all=items();const idx=all.indexOf(item);if(e.key==="Enter"||e.key===" "){e.preventDefault();all.forEach((o,i)=>o.setAttribute("aria-selected",i===idx?"true":"false"));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,label:item.querySelector(".c-category__label")?item.querySelector(".c-category__label").textContent:item.textContent.trim()}}));return}let next=-1;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowDown")next=Math.min(idx+1,all.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,all.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,all.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=all.length-1;if(next<0||next===idx)return;e.preventDefault();all.forEach((c,i)=>c.setAttribute("tabindex",i===next?"0":"-1"));try{all[next].focus()}catch(err){}})}}define("contour-category",ContourCategory);class ContourDonut extends ContourBase{static get observed(){return["value","values","items","label","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","brownout","brownout-level","note"]}static get properties(){return{value:{attribute:"value"},values:{attribute:"values"},items:{attribute:"items"},label:{attribute:"label"},src:{attribute:"src"},note:{attribute:"note"}}}render(){this.classList.add("c-donut");this.setAttribute("role","img");this.setAttribute("aria-label","Donut chart");wireStates(this);loadRemote(this,["items","values"]);if(renderStates(this,"donut"))return;Array.from(this.querySelectorAll(".c-donut__ring, .c-donut__center, .c-donut__list, .c-donut__empty")).forEach((n)=>n.remove());const authoredItems=Array.from(this.querySelectorAll(":scope > .c-donut__item"));let items=[];if(authoredItems.length){authoredItems.forEach((el)=>{const sw=el.querySelector(".c-donut__swatch");const lbl=el.querySelector("span:last-child");const text=lbl?lbl.textContent:el.textContent;const match=text.match(/—\s*(\d+(?:\.\d+)?)$/);items.push({label:text.replace(/—\s*\d+(?:\.\d+)?$/,"").trim(),value:match?Number(match[1]):0,color:sw?(sw.dataset&&sw.dataset.color)||sw.style.background:undefined})});authoredItems.forEach((el)=>el.remove())}else{const iAttr=this.getAttribute("items");if(iAttr){try{items=JSON.parse(iAttr)}catch(e){items=[]}}}const values=items.map((it)=>(typeof it==="object"?(it.value||0):Number(it)||0));const total=values.reduce((a,b)=>a+b,0)||1;const brownoutLevel=this.brownoutLevel();const shedRing=this.shed("ring",3);if(!shedRing){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("class","c-donut__ring");svg.setAttribute("viewBox","0 0 32 32");let offset=0;items.forEach((it,i)=>{const v=values[i];const pct=v/total;const circle=document.createElementNS("http://www.w3.org/2000/svg","circle");circle.setAttribute("cx","16");circle.setAttribute("cy","16");circle.setAttribute("r","12");circle.setAttribute("fill","none");circle.setAttribute("stroke",(typeof it==="object"&&it.color)?it.color:"var(--chart-"+((i%8)+1)+")");circle.setAttribute("stroke-width","6");const circ=2*Math.PI*12;circle.setAttribute("stroke-dasharray",(pct*circ)+" "+(circ-pct*circ));circle.setAttribute("stroke-dashoffset",String(-offset*circ));circle.setAttribute("transform","rotate(-90 16 16)");svg.appendChild(circle);offset+=pct});const hole=document.createElementNS("http://www.w3.org/2000/svg","circle");hole.setAttribute("cx","16");hole.setAttribute("cy","16");hole.setAttribute("r","9");hole.setAttribute("fill","var(--color-surface-0)");svg.appendChild(hole);this.appendChild(svg)}const center=document.createElement("div");center.className="c-donut__center";center.textContent=this.getAttribute("value")||String(total);this.appendChild(center);const list=document.createElement("div");list.className="c-donut__list";list.setAttribute("role","list");items.forEach((it,i)=>{const row=document.createElement("div");row.className="c-donut__item";row.setAttribute("role","listitem");const sw=document.createElement("span");sw.className="c-donut__swatch";sw.style.background=(typeof it==="object"&&it.color)?it.color:"var(--chart-"+((i%8)+1)+")";if(sw.style.background)sw.dataset.color=(typeof it==="object"&&it.color)?it.color:sw.style.background;row.appendChild(sw);const lbl=document.createElement("span");lbl.textContent=(typeof it==="object"?(it.label||""):String(it))+" — "+values[i];row.appendChild(lbl);list.appendChild(row)});this.appendChild(list);if(!items.length)renderEmpty(this,"donut");const note=this.getAttribute("note");let noteEl=this.querySelector(".c-donut__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-donut__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}enhance(){}}define("contour-donut",ContourDonut);class ContourTimeSeries extends ContourBase{static get observed(){return["values","points","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","annotations","note","style"]}static get properties(){return{values:{attribute:"values"},points:{attribute:"points"},src:{attribute:"src"},annotations:{attribute:"annotations"},note:{attribute:"note"},style:{attribute:"style"}}}render(){this.classList.add("c-time-series");this.setAttribute("role","img");this.setAttribute("aria-label","Time series");wireStates(this);loadRemote(this,["values","points"]);if(renderStates(this,"time-series"))return;Array.from(this.querySelectorAll(".c-time-series__plot, .c-time-series__axis")).forEach((n)=>n.remove());let values=[];const vAttr=this.getAttribute("values");if(vAttr){try{values=JSON.parse(vAttr)}catch(e){values=vAttr.split(",").map(Number)}}const max=Math.max(...values,1);const min=Math.min(...values,0);const style=this.getAttribute("style")||"bar";const plot=document.createElement("div");plot.className="c-time-series__plot";plot.setAttribute("part","plot");if(style==="line"){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 300 120");svg.setAttribute("preserveAspectRatio","none");svg.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const range=(max-min)||1;const n=values.length||1;const pts=values.map((v,i)=>{const x=(i/Math.max(1,n-1))*300;const y=120-((v-min)/range)*120;return x.toFixed(2)+","+y.toFixed(2)}).join(" ");const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("class","c-time-series__line");path.setAttribute("d","M "+pts.replace(/ /g," L "));path.style.stroke="var(--chart-1)";path.style.fill="none";path.style.strokeWidth="2";svg.appendChild(path);values.forEach((v,i)=>{const x=(i/Math.max(1,n-1))*300;const y=120-((v-min)/range)*120;const c=document.createElementNS("http://www.w3.org/2000/svg","circle");c.setAttribute("class","c-time-series__point");c.setAttribute("cx",x.toFixed(2));c.setAttribute("cy",y.toFixed(2));c.setAttribute("r","3");c.setAttribute("tabindex",i===0?"0":"-1");c.setAttribute("role","button");c.setAttribute("title",String(v));c.setAttribute("aria-label","Value "+v);svg.appendChild(c)});plot.appendChild(svg)}else{values.forEach((v,i)=>{const bar=document.createElement("div");bar.className="c-time-series__bar";bar.style.blockSize=((v/max)*100)+"%";bar.setAttribute("title",String(v));bar.setAttribute("role","img");bar.setAttribute("aria-label","Value "+v);bar.setAttribute("tabindex",i===0?"0":"-1");plot.appendChild(bar)})}this.appendChild(plot);if(!values.length)renderEmpty(this,"time-series");const note=this.getAttribute("note");let noteEl=this.querySelector(".c-time-series__note");if(note){if(!noteEl){noteEl=document.createElement("div");noteEl.className="c-time-series__note";this.appendChild(noteEl)}noteEl.textContent=note}else if(noteEl){noteEl.remove()}}enhance(){if(this._wiredTimeSeries)return;this._wiredTimeSeries=true;const bars=()=>Array.from(this.querySelectorAll(".c-time-series__bar"));this.addEventListener("click",(e)=>{const bar=e.target&&e.target.closest?e.target.closest(".c-time-series__bar"):null;if(!bar||!this.contains(bar))return;const idx=bars().indexOf(bar);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,value:bar.getAttribute("title")}}))});this.addEventListener("keydown",(e)=>{const bar=e.target&&e.target.closest?e.target.closest(".c-time-series__bar"):null;if(!bar||!this.contains(bar))return;const all=bars();const idx=all.indexOf(bar);if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,value:bar.getAttribute("title")}}));return}let next=-1;if(e.key==="ArrowRight"||e.key==="ArrowDown")next=Math.min(idx+1,all.length-1);else if(e.key==="ArrowLeft"||e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=all.length-1;if(next<0||next===idx)return;e.preventDefault();all.forEach((b,i)=>b.setAttribute("tabindex",i===next?"0":"-1"));try{all[next].focus()}catch(err){}});this.addEventListener("focusin",(e)=>{const bar=e.target&&e.target.closest?e.target.closest(".c-time-series__bar"):null;if(bar&&this.contains(bar)){const tip=this.querySelector(".c-time-series__tooltip");if(tip){tip.textContent=bar.getAttribute("title");tip.removeAttribute("hidden")}}});this.addEventListener("focusout",(e)=>{const tip=this.querySelector(".c-time-series__tooltip");if(tip&&!this.contains(e.relatedTarget))tip.setAttribute("hidden","")})}}define("contour-time-series",ContourTimeSeries);class ContourPivot extends ContourBase{static get observed(){return["rows","columns","values","data","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{rows:{attribute:"rows"},columns:{attribute:"columns"},values:{attribute:"values"},data:{attribute:"data"},src:{attribute:"src"},filter:{attribute:"filter"},aggregate:{attribute:"aggregate"}}}_aggregateFn(name){const n=(name||"sum").toLowerCase();if(n==="avg"||n==="average"||n==="mean")return(vals)=>vals.length?vals.reduce((a,b)=>a+b,0)/vals.length:0;if(n==="count")return(vals)=>vals.length;if(n==="min")return(vals)=>vals.length?Math.min(...vals):0;if(n==="max")return(vals)=>vals.length?Math.max(...vals):0;return(vals)=>vals.reduce((a,b)=>a+b,0)}render(){this.classList.add("c-pivot");wireStates(this);loadRemote(this,["data"]);if(renderStates(this,"pivot"))return;Array.from(this.querySelectorAll("table, .c-pivot__toolbar")).forEach((n)=>n.remove());let data=[];const dAttr=this.getAttribute("data");if(dAttr){try{data=JSON.parse(dAttr)}catch(e){data=[]}}const rows=this.getAttribute("rows")?this.getAttribute("rows").split(",").map((s)=>s.trim()).filter(Boolean):[];const cols=this.getAttribute("columns")?this.getAttribute("columns").split(",").map((s)=>s.trim()).filter(Boolean):[];const aggName=this.getAttribute("aggregate")||"sum";const aggFn=this._aggregateFn(aggName);const filterQ=(this.getAttribute("filter")||"").toLowerCase().trim();const toolbar=document.createElement("div");toolbar.className="c-pivot__toolbar";toolbar.style.display="flex";const filterInput=document.createElement("input");filterInput.type="search";filterInput.className="c-input c-pivot__filter";filterInput.placeholder="Filter…";filterInput.value=this.getAttribute("filter")||"";filterInput.setAttribute("aria-label","Filter pivot");const aggSelect=document.createElement("select");aggSelect.className="c-select c-pivot__aggregate";aggSelect.setAttribute("aria-label","Aggregation");["sum","avg","count","min","max"].forEach((a)=>{const opt=document.createElement("option");opt.value=a;opt.textContent=a;if(a===aggName)opt.selected=true;aggSelect.appendChild(opt)});toolbar.appendChild(filterInput);toolbar.appendChild(aggSelect);this.appendChild(toolbar);let visibleRows=rows;let visibleCols=cols;if(filterQ){visibleRows=rows.filter((r)=>r.toLowerCase().includes(filterQ)||data.some((d)=>d.row===r&&String(d.value).toLowerCase().includes(filterQ)));visibleCols=cols.filter((c)=>c.toLowerCase().includes(filterQ)||data.some((d)=>d.col===c&&String(d.value).toLowerCase().includes(filterQ)));if(!visibleRows.length)visibleRows=rows;if(!visibleCols.length)visibleCols=cols}const table=document.createElement("table");table.setAttribute("role","grid");table.setAttribute("aria-rowcount",String(visibleRows.length+1));table.setAttribute("aria-colcount",String(visibleCols.length+1));const thead=document.createElement("thead");const hr=document.createElement("tr");const corner=document.createElement("th");corner.textContent="";corner.setAttribute("role","columnheader");corner.setAttribute("aria-label","Row");hr.appendChild(corner);visibleCols.forEach((c)=>{const th=document.createElement("th");th.textContent=c;th.setAttribute("role","columnheader");th.setAttribute("tabindex","0");hr.appendChild(th)});thead.appendChild(hr);table.appendChild(thead);const tbody=document.createElement("tbody");visibleRows.forEach((r)=>{const tr=document.createElement("tr");tr.setAttribute("role","row");const th=document.createElement("th");th.textContent=r;th.setAttribute("role","rowheader");th.setAttribute("tabindex","0");tr.appendChild(th);visibleCols.forEach((c)=>{const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","0");const cellData=data.filter((d)=>d.row===r&&d.col===c);const vals=cellData.map((d)=>Number(d.value)).filter((n)=>Number.isFinite(n));if(cellData.length&&vals.length===cellData.length&&vals.length){const v=aggFn(vals);td.textContent=Number.isInteger(v)?String(v):v.toFixed(2)}else if(cellData.length){td.textContent=cellData.map((d)=>d.value).join(", ")}else{td.textContent=""}if(!td.textContent.trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)});table.appendChild(tbody);this.appendChild(table);if(!data.length&&!rows.length&&!cols.length)renderEmpty(this,"pivot")}enhance(){if(this._wiredPivot)return;this._wiredPivot=true;this.addEventListener("click",(e)=>{const th=e.target&&e.target.closest?e.target.closest("th"):null;const td=e.target&&e.target.closest?e.target.closest("td"):null;const filterInput=e.target&&e.target.closest?e.target.closest(".c-pivot__filter"):null;const aggSelect=e.target&&e.target.closest?e.target.closest(".c-pivot__aggregate"):null;if(filterInput)return;if(aggSelect)return;if(th&&this.contains(th)&&th.parentElement&&th.parentElement.parentElement&&th.parentElement.parentElement.tagName==="THEAD"){this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:th.textContent.trim()}}));return}if(td&&this.contains(td)){this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:td.textContent}}))}});this.addEventListener("input",(e)=>{const fi=e.target&&e.target.closest?e.target.closest(".c-pivot__filter"):null;if(fi&&this.contains(fi)){this.setAttribute("filter",fi.value);this.render();this.dispatchEvent(new CustomEvent("contour:filter",{bubbles:true,composed:true,detail:{query:fi.value}}))}});this.addEventListener("change",(e)=>{const as=e.target&&e.target.closest?e.target.closest(".c-pivot__aggregate"):null;if(as&&this.contains(as)){this.setAttribute("aggregate",as.value);this.render();this.dispatchEvent(new CustomEvent("contour:aggregate",{bubbles:true,composed:true,detail:{aggregate:as.value}}))}});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest("th, td"):null;if(!cell||!this.contains(cell))return;const table=this.querySelector("table");if(!table)return;const rows=Array.from(table.querySelectorAll("tr"));const ri=rows.indexOf(cell.parentElement);const ci=Array.from(cell.parentElement.children).indexOf(cell);let target=null;if(e.key==="ArrowRight")target=cell.parentElement.children[ci+1];else if(e.key==="ArrowLeft")target=cell.parentElement.children[ci-1];else if(e.key==="ArrowDown")target=rows[ri+1]&&rows[ri+1].children[ci];else if(e.key==="ArrowUp")target=rows[ri-1]&&rows[ri-1].children[ci];else if(e.key==="Home")target=cell.parentElement.children[0];else if(e.key==="End")target=cell.parentElement.children[cell.parentElement.children.length-1];if(target){e.preventDefault();try{target.focus()}catch(err){}}})}}define("contour-pivot",ContourPivot);class ContourWidgetState extends ContourBase{static get observed(){return["loading","error","empty","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"},retry:{attribute:"retry"},src:{attribute:"src"}}}render(){this.classList.add("c-widget-state");wireStates(this);loadRemote(this,[]);if(renderStates(this,"widget-state"))return}enhance(){}}define("contour-widget-state",ContourWidgetState);class ContourBrownout extends ContourBase{static get observed(){return["level"]}static get properties(){return{level:{attribute:"level"}}}render(){this.classList.add("c-brownout");const level=this.getAttribute("level")||"0";this.dataset.level=level;this.setAttribute("data-level",level)}enhance(){}}define("contour-brownout",ContourBrownout);class ContourInstrument extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{rows:{attribute:"rows"},src:{attribute:"src"}}}render(){this.classList.add("c-instrument");wireStates(this);loadRemote(this,"rows");if(renderStates(this,"instrument"))return;const rows=remoteData(this,"rows");Array.from(this.querySelectorAll(".c-instrument__item")).forEach((n)=>n.remove());if(rows){try{const parsed=JSON.parse(rows);parsed.forEach((r)=>{const item=document.createElement("span");item.className="c-instrument__item";item.appendChild(document.createTextNode(String(r.key||r[0]||"")));const val=document.createElement("span");val.className="c-instrument__value";val.textContent=r.value||r[1]||"";item.appendChild(val);this.appendChild(item)})}catch(e){}}else{renderEmpty(this,"instrument")}}}define("contour-instrument",ContourInstrument);class ContourBivariate extends ContourBase{static get observed(){return["size","axis-x","axis-y","colors","selected"]}static get properties(){return{size:{attribute:"size"},axisX:{attribute:"axis-x"},axisY:{attribute:"axis-y"},colors:{attribute:"colors"},selected:{attribute:"selected"}}}render(){this.classList.add("c-bivariate");this.setAttribute("role","group");this.setAttribute("aria-label","Bivariate legend");const size=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const matrix=this.ensure(".c-bivariate__matrix",()=>{const el=document.createElement("div");el.className="c-bivariate__matrix";return el});matrix.style.gridTemplateColumns=`repeat(${size}, 1fr)`;matrix.style.gridTemplateRows=`repeat(${size}, 1fr)`;const authored=Array.from(matrix.children).filter((n)=>n.classList&&n.classList.contains("c-bivariate__cell"));if(!authored.length){matrix.innerHTML="";let colors=[];const cAttr=this.getAttribute("colors");if(cAttr){try{colors=JSON.parse(cAttr)}catch(e){colors=[]}}for(let r=0;r<size;r++){for(let c=0;c<size;c++){const cell=document.createElement("div");cell.className="c-bivariate__cell";cell.setAttribute("role","button");cell.setAttribute("tabindex","0");cell.setAttribute("aria-label","Cell "+c+","+r);const srcIndex=(size-1-r)*size+c;if(colors[srcIndex]){cell.style.background=colors[srcIndex];cell.dataset.color=colors[srcIndex]}matrix.appendChild(cell)}}const sel=this.getAttribute("selected");if(sel){const parts=sel.split(",");const sr=parseInt(parts[0],10);const sc=parseInt(parts[1],10);const cells=Array.from(matrix.querySelectorAll(".c-bivariate__cell"));cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===sr&&cc===sc)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")})}let live=this.querySelector(".c-bivariate__live");if(!live){live=document.createElement("div");live.className="c-bivariate__live";live.setAttribute("aria-live","polite");live.style.position="absolute";live.style.width="1px";live.style.height="1px";live.style.overflow="hidden";live.style.clip="rect(0,0,0,0)";this.appendChild(live)}}const axisX=this.getAttribute("axis-x");if(axisX){const ax=this.ensure(".c-bivariate__axis--x",()=>{const el=document.createElement("div");el.className="c-bivariate__axis c-bivariate__axis--x";return el});ax.textContent=axisX}else{const ax=this.querySelector(".c-bivariate__axis--x");if(ax)ax.remove()}const axisY=this.getAttribute("axis-y");if(axisY){const ay=this.ensure(".c-bivariate__axis--y",()=>{const el=document.createElement("div");el.className="c-bivariate__axis c-bivariate__axis--y";return el});ay.textContent=axisY}else{const ay=this.querySelector(".c-bivariate__axis--y");if(ay)ay.remove()}}enhance(){if(this._wiredBivariate)return;this._wiredBivariate=true;const selectCell=(cell)=>{const matrix=this.querySelector(".c-bivariate__matrix");const cells=Array.from(matrix?matrix.querySelectorAll(".c-bivariate__cell"):[]);const idx=cells.indexOf(cell);if(idx<0)return;const size=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const row=Math.floor(idx/size);const col=idx%size;cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===row&&cc===col)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")});this.dispatchEvent(new CustomEvent("contour:select",{detail:{row,col},bubbles:true,composed:true}))};this.addEventListener("click",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(cell&&this.contains(cell))selectCell(cell)});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(!cell||!this.contains(cell))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();selectCell(cell)}})}clear(){this.removeAttribute("selected");this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true}))}}define("contour-bivariate",ContourBivariate);class ContourBivariateLegend extends ContourBivariate{static get observed(){return["size","axis-x","axis-y","colors","selected"]}static get properties(){return{size:{attribute:"size"},axisX:{attribute:"axis-x"},axisY:{attribute:"axis-y"},colors:{attribute:"colors"},selected:{attribute:"selected"}}}render(){super.render();this.classList.add("c-bivariate-legend")}enhance(){if(this._wiredBivLegend)return;this._wiredBivLegend=true;const selectCell=(cell)=>{const matrix=this.querySelector(".c-bivariate__matrix");const cells=Array.from(matrix?matrix.querySelectorAll(".c-bivariate__cell"):[]);const idx=cells.indexOf(cell);if(idx<0)return;const size=Math.min(8,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3));const row=Math.floor(idx/size);const col=idx%size;cells.forEach((cell,i)=>{const rr=Math.floor(i/size);const cc=i%size;if(rr===row&&cc===col)cell.setAttribute("data-selected","");else cell.removeAttribute("data-selected")});this.dispatchEvent(new CustomEvent("contour:select",{detail:{row,col},bubbles:true,composed:true}))};this.addEventListener("click",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(cell&&this.contains(cell))selectCell(cell)});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-bivariate__cell"):null;if(!cell||!this.contains(cell))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();selectCell(cell)}})}clear(){this.removeAttribute("selected");this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true}))}}define("contour-bivariate-legend",ContourBivariateLegend);class ContourSurvey extends ContourBase{static get observed(){return["date","instrument","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{date:{attribute:"date"},instrument:{attribute:"instrument"},src:{attribute:"src"}}}render(){this.classList.add("c-survey");wireStates(this);loadRemote(this,"date");if(renderStates(this,"survey"))return;const date=remoteData(this,"date");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE){if(n.textContent.trim()==="Surveyed"||n.textContent.trim()==="·")n.remove()}else if(n.classList&&(n.classList.contains("c-survey__value")||n.classList.contains("c-survey__sep")))n.remove()});const rDate=date||(this._remoteData&&this._remoteData.date);const instrument=this.getAttribute("instrument")||(this._remoteData&&this._remoteData.instrument);if(!rDate){renderEmpty(this,"survey");return}const v=document.createElement("span");v.className="c-survey__value";v.textContent=rDate;this.appendChild(document.createTextNode("Surveyed "));this.appendChild(v);if(instrument){const sep=document.createElement("span");sep.className="c-survey__sep";sep.textContent="·";this.appendChild(sep);const v2=document.createElement("span");v2.className="c-survey__value";v2.textContent=instrument;this.appendChild(v2)}}}define("contour-survey",ContourSurvey);class ContourThreshold extends ContourBase{static get observed(){return["label","norm","state","value","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},norm:{attribute:"norm"},state:{attribute:"state"},value:{attribute:"value"},src:{attribute:"src"}}}render(){this.classList.add("c-threshold");wireStates(this);loadRemote(this,"value");if(renderStates(this,"threshold"))return;const pct=(v)=>{const n=Number(v);if(!Number.isFinite(n))return String(v);return(n<=1?n*100:n)+"%"};const rValue=remoteData(this,"value")||(this._remoteData&&this._remoteData.value);const target=this.getAttribute("norm")||(this._remoteData&&this._remoteData.norm);const state=this.getAttribute("state")||(this._remoteData&&this._remoteData.state);const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(!rValue&&!target&&!label){renderEmpty(this,"threshold");return}if(rValue){const v=this.ensure(".c-threshold__fill",()=>{const el=document.createElement("span");el.className="c-threshold__fill";return el});v.style.setProperty("--value",pct(rValue))}else{const v=this.querySelector(".c-threshold__fill");if(v)v.remove()}if(target){const t=this.ensure(".c-threshold__target",()=>{const el=document.createElement("span");el.className="c-threshold__target";return el});t.style.setProperty("--target",pct(target))}else{const t=this.querySelector(".c-threshold__target");if(t)t.remove()}if(state)this.setAttribute("data-state",state);else this.removeAttribute("data-state");if(label)this.setAttribute("aria-label",label)}}define("contour-threshold",ContourThreshold);class ContourMetricsFull extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-metrics");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"metrics"))return;const items=remoteData(this,"items");Array.from(this.querySelectorAll(".c-metrics__item")).forEach((n)=>n.remove());let parsed=null;if(items){try{parsed=JSON.parse(items)}catch(e){parsed=null}}if(Array.isArray(parsed)&&parsed.length){parsed.forEach((it)=>{const item=document.createElement("div");item.className="c-metrics__item";item.setAttribute("role","listitem");const v=document.createElement("div");v.className="c-metrics__value";v.textContent=(typeof it==="object"&&it!==null)?(it.value??it.v??""):String(it);const l=document.createElement("div");l.className="c-metrics__label";l.textContent=(typeof it==="object"&&it!==null)?(it.label??it.l??""):"";item.appendChild(v);item.appendChild(l);this.appendChild(item)})}else if(!items){renderEmpty(this,"metrics")}}enhance(){wireStates(this)}}define("contour-metrics",ContourMetricsFull);class ContourLegend extends ContourBase{static get observed(){return["title","ramp","scale","items","method","norm","selectable","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","glyphs","thresholds","breaks","no-data-color","size","table","classification","audit","continuous","ends","caption"]}static get properties(){return{title:{attribute:"title"},ramp:{attribute:"ramp"},scale:{attribute:"scale"},items:{attribute:"items"},method:{attribute:"method"},norm:{attribute:"norm"},selectable:{attribute:"selectable",type:Boolean},src:{attribute:"src"}}}render(){this.classList.add("c-legend");const continuous=this.hasAttribute("continuous");if(continuous||this.hasAttribute("selectable")){this.setAttribute("role","group")}else{this.setAttribute("role","list")}wireStates(this);loadRemote(this,"items");if(renderStates(this,"legend"))return;const selectable=this.hasAttribute("selectable");const authoredLegendItems=Array.from(this.querySelectorAll(":scope > .c-legend__item"));let items=remoteData(this,"items");if(authoredLegendItems.length){items=JSON.stringify(authoredLegendItems.map((el)=>{const sw=el.querySelector(".c-legend__swatch");const lbl=el.querySelector(".c-legend__label")||el;return{label:lbl?lbl.textContent.trim():el.textContent.trim(),color:sw?(sw.dataset&&sw.dataset.color)||sw.style.background||undefined:undefined}}));authoredLegendItems.forEach((el)=>el.remove())}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-legend__title",()=>{const el=document.createElement("div");el.className="c-legend__title";return el});t.textContent=title}else{const t=this.querySelector(".c-legend__title");if(t)t.remove()}if(items){try{const parsed=JSON.parse(items);const list=this.ensure(".c-legend__items",()=>{const el=document.createElement("div");el.className="c-legend__items";return el});if(this.hasAttribute("selectable")){list.setAttribute("role","group")}else{list.setAttribute("role","listbox")}if(title)list.setAttribute("aria-label",title);list.innerHTML="";parsed.forEach((it)=>{const label=typeof it==="string"?it:(it.label||String(it));const key=typeof it==="string"?it:(it.key||it.label||String(it));const item=document.createElement("div");item.className="c-legend__item";item.setAttribute("tabindex","-1");if(selectable){item.setAttribute("role","button");item.setAttribute("aria-pressed","true");item.dataset.key=key}else{item.setAttribute("role","option");item.setAttribute("aria-selected","false")}const sw=document.createElement("span");sw.className="c-legend__swatch";if(it&&it.color){sw.style.background=it.color;sw.dataset.color=it.color}item.appendChild(sw);const glyphShape=(it&&(it.shape||it.marker||it.glyph))||this.getAttribute("glyphs");if(glyphShape){const g=document.createElement("span");g.className="c-legend__glyph";g.setAttribute("part","glyph");g.textContent=glyphShape==="circle"?"●":glyphShape==="square"?"■":glyphShape==="triangle"?"▲":glyphShape==="diamond"?"◆":glyphShape==="star"?"★":String(glyphShape);if(it&&it.size!=null)g.style.fontSize=(typeof it.size==="number"?it.size+"px":String(it.size));item.appendChild(g)}if(it&&it.break!=null){const b=document.createElement("span");b.className="c-legend__break";b.textContent=String(it.break);item.appendChild(b)}const lbl=document.createElement("span");lbl.textContent=label;item.appendChild(lbl);const caption=(typeof it==="object"&&it)?(it.caption||it.note||""):"";if(caption){const cap=document.createElement("span");cap.className="c-legend__caption";cap.textContent=caption;item.appendChild(cap)}if(it&&(it.threshold||it.break!=null)){sw.style.outline="2px solid var(--color-border-strong)"}list.appendChild(item)})}catch(e){}}else{const list=this.querySelector(".c-legend__items");if(list)list.remove();const hasOther=this.getAttribute("title")||this.getAttribute("ramp")||this.getAttribute("scale")||this.getAttribute("method")||this.getAttribute("norm");if(!hasOther){renderEmpty(this,"legend")}}const caption=this.getAttribute("caption");let captionEl=this.querySelector(".c-legend__caption");if(caption){if(!captionEl){captionEl=document.createElement("span");captionEl.className="c-legend__caption";this.appendChild(captionEl)}captionEl.id=captionEl.id||("legend-caption-"+Math.random().toString(36).slice(2));captionEl.textContent=caption;captionEl.style.position="absolute";captionEl.style.width="1px";captionEl.style.height="1px";captionEl.style.overflow="hidden";captionEl.style.clip="rect(0,0,0,0)"}else if(captionEl){captionEl.remove()}const _items=this.querySelector(".c-legend__items");if(_items){const opts=Array.from(_items.querySelectorAll(".c-legend__item"));opts.forEach((o,i)=>o.setAttribute("tabindex",i===0?"0":"-1"));if(captionEl)opts.forEach((o)=>o.setAttribute("aria-describedby",captionEl.id))}const ndColor=this.getAttribute("no-data-color");if(ndColor){let nd=this.querySelector(".c-legend__no-data");if(!nd){nd=document.createElement("div");nd.className="c-legend__no-data";this.appendChild(nd)}nd.setAttribute("part","no-data");nd.textContent="No data";const glyph=document.createElement("span");glyph.className="glyph";glyph.style.background=ndColor;glyph.dataset.color=ndColor;nd.prepend(glyph)}else{const nd=this.querySelector(".c-legend__no-data");if(nd)nd.remove()}const audit=this.getAttribute("audit");if(audit){const a=this.ensure(".c-legend__audit",()=>{const el=document.createElement("div");el.className="c-legend__audit";return el});a.textContent=audit}else{const a=this.querySelector(".c-legend__audit");if(a)a.remove()}if(this.hasAttribute("continuous")){const ends=this.getAttribute("ends");let parsedEnds=null;if(ends){try{parsedEnds=JSON.parse(ends)}catch(e){parsedEnds=ends.split(",")}}if(Array.isArray(parsedEnds)&&parsedEnds.length>=2){const r=this.ensure(".c-legend__ramp",()=>{const el=document.createElement("div");el.className="c-legend__ramp";return el});let left=this.querySelector(".c-legend__ramp-label--start");if(!left){left=document.createElement("span");left.className="c-legend__ramp-label c-legend__ramp-label--start";r.appendChild(left)}left.textContent=parsedEnds[0];let right=this.querySelector(".c-legend__ramp-label--end");if(!right){right=document.createElement("span");right.className="c-legend__ramp-label c-legend__ramp-label--end";r.appendChild(right)}right.textContent=parsedEnds[parsedEnds.length-1]}}const sizeAttr=this.getAttribute("size");if(sizeAttr){const sc=this.ensure(".c-legend__size",()=>{const el=document.createElement("div");el.className="c-legend__size";return el});sc.textContent=sizeAttr}else{const sc=this.querySelector(".c-legend__size");if(sc)sc.remove()}const classification=this.getAttribute("classification");if(classification){const c=this.ensure(".c-legend__classification",()=>{const el=document.createElement("div");el.className="c-legend__classification";return el});c.textContent=classification}else{const c=this.querySelector(".c-legend__classification");if(c)c.remove()}const tableAttr=this.getAttribute("table");if(tableAttr){let parsed=null;try{parsed=JSON.parse(tableAttr)}catch(e){parsed=null}if(Array.isArray(parsed)){let det=this.querySelector(".c-legend__table-wrap");if(!det){det=document.createElement("details");det.className="c-legend__table-wrap";this.appendChild(det)}det.innerHTML="";const sum=document.createElement("summary");sum.textContent="Data table";det.appendChild(sum);const tbl=document.createElement("table");tbl.className="c-legend__table";const tbody=document.createElement("tbody");parsed.forEach((row)=>{const tr=document.createElement("tr");const cells=Array.isArray(row)?row:[row.label??row.key??"",row.value??""];cells.forEach((cell)=>{const td=document.createElement("td");td.textContent=cell;tr.appendChild(td)});tbody.appendChild(tr)});tbl.appendChild(tbody);det.appendChild(tbl)}}else{const det=this.querySelector(".c-legend__table-wrap");if(det)det.remove()}if(items){}const method=this.getAttribute("method");if(method){const m=this.ensure(".c-legend__method",()=>{const el=document.createElement("div");el.className="c-legend__method";return el});m.textContent=method}else{const m=this.querySelector(".c-legend__method");if(m)m.remove()}const norm=this.getAttribute("norm");if(norm){const n=this.ensure(".c-legend__norm",()=>{const el=document.createElement("span");el.className="c-legend__norm";return el});n.textContent=norm}else{const n=this.querySelector(".c-legend__norm");if(n)n.remove()}const ramp=this.getAttribute("ramp");if(ramp){const r=this.ensure(".c-legend__ramp",()=>{const el=document.createElement("div");el.className="c-legend__ramp";return el});r.style.background=ramp;const breaksAttr=this.getAttribute("breaks");if(breaksAttr){let breaks=null;try{breaks=JSON.parse(breaksAttr)}catch(e){breaks=breaksAttr.split(",").map((s)=>s.trim())}if(Array.isArray(breaks)){Array.from(r.querySelectorAll(".c-legend__ramp-segment")).forEach((n)=>n.remove());breaks.forEach((b,i)=>{const seg=document.createElement("span");seg.className="c-legend__ramp-segment";seg.style.flex="1";const lbl=document.createElement("span");lbl.className="c-legend__ramp-break";lbl.textContent=String(b);seg.appendChild(lbl);r.appendChild(seg)})}}}else{const r=this.querySelector(".c-legend__ramp");if(r)r.remove()}const scale=this.getAttribute("scale");if(scale){const sc=this.ensure(".c-legend__scale",()=>{const el=document.createElement("div");el.className="c-legend__scale";return el});sc.textContent=scale}else{const sc=this.querySelector(".c-legend__scale");if(sc)sc.remove()}}enhance(){if(this._wiredLegend)return;this._wiredLegend=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-legend__item"):null;if(!btn||!this.contains(btn))return;let selected;const isPressed=btn.getAttribute("aria-pressed");if(btn.getAttribute("aria-pressed")!==null){const pressed=btn.getAttribute("aria-pressed")!=="true";btn.setAttribute("aria-pressed",String(pressed));selected=pressed}else{const selected2=btn.getAttribute("aria-selected")!=="true";btn.setAttribute("aria-selected",String(selected2));selected=selected2}this.dispatchEvent(new CustomEvent("contour:legend-toggle",{detail:{label:btn.textContent.trim(),key:btn.dataset.key||btn.textContent.trim(),pressed:selected},bubbles:true,composed:true,}));this.dispatchEvent(new CustomEvent("contour:select",{detail:{label:btn.textContent.trim(),key:btn.dataset.key||btn.textContent.trim(),value:btn.dataset.key||btn.textContent.trim()},bubbles:true,composed:true,}))});try{let parsed=null;try{parsed=JSON.parse(this.getAttribute("items")||"null")}catch(e){parsed=this.getAttribute("items")}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:this.getAttribute("items"),items:parsed},bubbles:true,composed:true}))}catch(e){}this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList&&t.classList.contains("c-legend__break-input")){this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:t.value},bubbles:true,composed:true}))}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-legend__item"));if(!items.length)return;const idx=items.indexOf(document.activeElement);if(e.key==="ArrowDown"||e.key==="ArrowRight"){e.preventDefault();const next=items[(idx+1)%items.length];if(next){next.focus();items.forEach((o,i)=>o.setAttribute("tabindex",o===next?"0":"-1"))}}else if(e.key==="ArrowUp"||e.key==="ArrowLeft"){e.preventDefault();const prev=items[(idx-1+items.length)%items.length];if(prev){prev.focus();items.forEach((o)=>o.setAttribute("tabindex",o===prev?"0":"-1"))}}else if(e.key==="Home"){if(items.length>4){e.preventDefault();items[0].focus();items.forEach((o,i)=>o.setAttribute("tabindex",i===0?"0":"-1"))}}else if(e.key==="End"){if(items.length>4){e.preventDefault();const last=items[items.length-1];last.focus();items.forEach((o)=>o.setAttribute("tabindex",o===last?"0":"-1"))}}else if(e.key==="Escape"){items.forEach((o)=>{if(o.getAttribute("role")==="option")o.setAttribute("aria-selected","false");else o.setAttribute("aria-pressed","false")});this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true}))}else if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){if(items.length>7){const start=idx>=0?idx+1:0;for(let i=0;i<items.length;i++){const ii=(start+i)%items.length;const txt=(items[ii].textContent||"").trim().toLowerCase();if(txt.startsWith(e.key.toLowerCase())){e.preventDefault();items[ii].focus();items.forEach((o,j)=>o.setAttribute("tabindex",j===ii?"0":"-1"));break}}}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(document.activeElement&&document.activeElement.classList.contains("c-legend__item")){document.activeElement.click()}}})}}define("contour-legend",ContourLegend);class ContourMeasure extends ContourBase{static get observed(){return["label","value","point","line","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},point:{attribute:"point"},line:{attribute:"line"},src:{attribute:"src"}}}render(){this.classList.add("c-measure");this.setAttribute("role","group");this.setAttribute("aria-label","Measure");wireStates(this);loadRemote(this,["label","value","point","line"]);if(renderStates(this,"measure"))return;const rLabel=remoteData(this,"label");const rValue=remoteData(this,"value");const rPoint=remoteData(this,"point");const rLine=remoteData(this,"line");if(!rLabel&&!rValue&&!rPoint&&!rLine){renderEmpty(this,"measure");return}if(rLabel){const l=this.ensure(".c-measure__label",()=>{const el=document.createElement("span");el.className="c-measure__label";return el});l.textContent=rLabel}else{const l=this.querySelector(".c-measure__label");if(l)l.remove()}if(rValue){const r=this.ensure(".c-measure__readout",()=>{const el=document.createElement("span");el.className="c-measure__readout";return el});r.textContent=rValue}else{const r=this.querySelector(".c-measure__readout");if(r)r.remove()}let sel=this.querySelector(".c-measure__unit-select");if(!sel){sel=document.createElement("select");sel.className="c-measure__unit-select";this.appendChild(sel)}["m","km","mi","ft"].forEach((u)=>{if(!sel.querySelector('option[value="'+u+'"]')){const o=document.createElement("option");o.value=u;o.textContent=u;sel.appendChild(o)}});if(rPoint){const p=this.ensure(".c-measure__point",()=>{const el=document.createElement("span");el.className="c-measure__point";return el});p.textContent=rPoint}else{const p=this.querySelector(".c-measure__point");if(p)p.remove()}if(!rLine){const svg=this.querySelector("svg");if(svg)svg.remove();return}if(rLine){const ln=this.ensure(".c-measure__line",()=>{const el=document.createElement("span");el.className="c-measure__line";return el});ln.style.inlineSize=rLine}else{const ln=this.querySelector(".c-measure__line");if(ln)ln.remove()}}enhance(){if(this._wiredMeasure)return;this._wiredMeasure=true;this.addEventListener("change",(e)=>{const sel=e.target&&e.target.closest?e.target.closest(".c-measure__unit-select"):null;if(sel&&this.contains(sel)){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{unit:sel.value}}))}})}}define("contour-measure",ContourMeasure);class ContourTimeline extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-timeline");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"timeline"))return;const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-timeline__item"));const items=remoteData(this,"items");if(items&&!authored.length){Array.from(this.querySelectorAll(".c-timeline__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(items);parsed.forEach((it)=>{const item=document.createElement("div");item.className="c-timeline__item";item.setAttribute("role","listitem");item.setAttribute("tabindex","-1");if(it.time){const t=document.createElement("time");t.className="c-timeline__time";t.textContent=it.time;item.appendChild(t)}if(it.title){const ti=document.createElement("div");ti.className="c-timeline__title";ti.textContent=it.title;item.appendChild(ti)}if(it.text){const tx=document.createElement("div");tx.className="c-timeline__text";tx.textContent=it.text;item.appendChild(tx)}this.appendChild(item)})}catch(e){}}else if(!authored.length){renderEmpty(this,"timeline")}}enhance(){if(this._wiredTimeline)return;this._wiredTimeline=true;const items=Array.from(this.querySelectorAll(".c-timeline__item"));items.forEach((it,i)=>it.setAttribute("tabindex",i===0?"0":"-1"));this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-timeline__item"):null;if(!item||!this.contains(item))return;const items=Array.from(this.querySelectorAll(".c-timeline__item"));const idx=items.indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx}}))});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-timeline__item"));if(!items.length)return;const active=this.querySelector(".c-timeline__item:focus")||items[0];const idx=items.indexOf(active);let next=-1;if(e.key==="ArrowDown")next=Math.min(idx+1,items.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=items.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx}}));return}if(next<0||next===idx)return;e.preventDefault();items.forEach((it,i)=>it.setAttribute("tabindex",i===next?"0":"-1"));try{items[next].focus()}catch(err){}})}}define("contour-timeline",ContourTimeline);class ContourHeatmap extends ContourBase{static get observed(){return["cells","count","legend","empty","loading","values","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{cells:{attribute:"cells"},count:{attribute:"count"},legend:{attribute:"legend"},src:{attribute:"src"}}}render(){this.classList.add("c-heatmap");if(!this.hasAttribute("role"))this.setAttribute("role","grid");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Heatmap");wireStates(this);loadRemote(this,"cells");if(renderStates(this,"heatmap"))return;const authoredCells=Array.from(this.querySelectorAll(":scope > .c-heatmap__cell"));if(authoredCells.length){const cols=Math.ceil(Math.sqrt(authoredCells.length));this.style.gridTemplateColumns="repeat("+cols+", 1fr)";this.style.inlineSize="16rem"}else{Array.from(this.querySelectorAll(".c-heatmap__cell")).forEach((n)=>n.remove());const count=Math.min(200,Math.max(0,parseInt(this.getAttribute("cells")||this.getAttribute("count")||"0",10)||0));const cols=count>0?Math.ceil(Math.sqrt(count)):1;this.style.gridTemplateColumns="repeat("+cols+", 1fr)";this.style.inlineSize="16rem";if(count>0){let values=[];try{values=JSON.parse(this.getAttribute("values")||"[]")}catch(e){values=[]}for(let i=0;i<count;i++){const cell=document.createElement("div");cell.className="c-heatmap__cell";cell.setAttribute("role","gridcell");cell.setAttribute("tabindex",i===0?"0":"-1");cell.dataset.index=String(i);if(values[i]!==undefined)cell.setAttribute("title",String(values[i]));this.appendChild(cell)}const tip=this.ensure(".c-heatmap__tooltip",()=>{const el=document.createElement("div");el.className="c-heatmap__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}else if(!authoredCells.length){renderEmpty(this,"heatmap")}}if(this.hasAttribute("legend")){const leg=this.ensure(".c-heatmap__legend",()=>{const el=document.createElement("div");el.className="c-heatmap__legend";const bar=document.createElement("div");bar.className="c-heatmap__legend-bar";el.appendChild(bar);return el})}else{const leg=this.querySelector(".c-heatmap__legend");if(leg)leg.remove()}}enhance(){if(this._wiredHeatmap)return;this._wiredHeatmap=true;const cells=()=>Array.from(this.querySelectorAll(".c-heatmap__cell"));const showTip=(e)=>{const tip=this.querySelector(".c-heatmap__tooltip");if(!tip)return;const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!cell||!this.contains(cell)){tip.setAttribute("hidden","");return}const title=cell.getAttribute("title");if(title)tip.textContent=title;else tip.textContent="Cell "+(cell.dataset.index||"");const rect=this.getBoundingClientRect();const cr=cell.getBoundingClientRect();this.style.position=this.style.position||"relative";tip.style.setProperty("--chart-tip-inline-start",(cr.left-rect.left+cr.width/2)+"px");tip.style.setProperty("--chart-tip-block-start",(cr.top-rect.top)+"px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-heatmap__tooltip");if(tip)tip.setAttribute("hidden","")};this.addEventListener("mouseover",showTip);this.addEventListener("mouseout",(e)=>{if(!e.relatedTarget||!this.contains(e.relatedTarget))hideTip()});this.addEventListener("focusin",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(cell&&this.contains(cell))showTip({target:cell})});this.addEventListener("focusout",(e)=>{if(!this.contains(e.relatedTarget))hideTip()});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!cell||!this.contains(cell))return;const list=cells();const idx=list.indexOf(cell);let next=-1;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,list.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,list.length-1):Math.max(idx-1,0);else if(e.key==="ArrowDown")next=Math.min(idx+Math.ceil(Math.sqrt(list.length)),list.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-Math.ceil(Math.sqrt(list.length)),0);else if(e.key==="Home")next=0;else if(e.key==="End")next=list.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:1,index:idx}}));return}if(next>=0&&next!==idx){e.preventDefault();list.forEach((c,i)=>c.setAttribute("tabindex",i===next?"0":"-1"));try{list[next].focus()}catch(e){}}});this.addEventListener("click",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!cell||!this.contains(cell))return;const idx=cells().indexOf(cell);if(idx>=0)this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:1,index:idx}}))})}}define("contour-heatmap",ContourHeatmap);class ContourCompare extends ContourBase{static get observed(){return["no","text","yes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{no:{attribute:"no"},text:{attribute:"text"},yes:{attribute:"yes"},src:{attribute:"src"}}}render(){this.classList.add("c-compare");this.setAttribute("role","group");this.setAttribute("aria-label","Comparison");wireStates(this);loadRemote(this,["no","text","yes"]);if(renderStates(this,"compare"))return;const rYes=remoteData(this,"yes")||(this._remoteData&&this._remoteData.yes);const rNo=remoteData(this,"no")||(this._remoteData&&this._remoteData.no);const rText=remoteData(this,"text")||(this._remoteData&&this._remoteData.text);Array.from(this.querySelectorAll(".c-compare__yes, .c-compare__no, .c-compare__text")).forEach((n)=>n.remove());if(rYes){const y=document.createElement("span");y.className="c-compare__yes";y.innerHTML='<svg aria-hidden="true"><use href="#i-check" /></svg>';this.appendChild(y)}if(rNo){const n=document.createElement("div");n.className="c-compare__no";n.textContent=rNo;this.appendChild(n)}if(rText){const t=document.createElement("p");t.className="c-compare__text";t.textContent=rText;this.appendChild(t)}if(!rYes&&!rNo&&!rText){renderEmpty(this,"compare")}}}define("contour-compare",ContourCompare);class ContourSparkline extends ContourBase{static get observed(){return["points","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{points:{attribute:"points"},src:{attribute:"src"}}}render(){this.classList.add("c-sparkline");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Sparkline");wireStates(this);loadRemote(this,"points");if(renderStates(this,"sparkline"))return;const points=remoteData(this,"points");if(points){try{const parsed=JSON.parse(points);if(!Array.isArray(parsed)||parsed.length===0)throw new Error("empty");Array.from(this.querySelectorAll(".c-sparkline__dot, .c-sparkline__line, .c-sparkline__area")).forEach((n)=>n.remove());const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("class","c-sparkline__line");svg.setAttribute("viewBox","0 0 100 30");svg.setAttribute("preserveAspectRatio","none");svg.style.inlineSize="100%";svg.style.blockSize="100%";svg.setAttribute("width","100%");svg.setAttribute("height","100%");svg.setAttribute("title",this.getAttribute("aria-label")||"Sparkline");const path=document.createElementNS("http://www.w3.org/2000/svg","path");path.setAttribute("d",parsed.map((p,i)=>(i===0?"M":"L")+" "+(i*100/(parsed.length-1))+" "+(30-p*30)).join(" "));svg.appendChild(path);const dot=document.createElementNS("http://www.w3.org/2000/svg","circle");dot.setAttribute("class","c-sparkline__dot");dot.setAttribute("r","2");dot.setAttribute("cx","0");dot.setAttribute("cy","15");dot.setAttribute("hidden","");svg.appendChild(dot);this.appendChild(svg);this._sparkPoints=parsed;const tip=this.ensure(".c-sparkline__tooltip",()=>{const el=document.createElement("div");el.className="c-sparkline__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){Array.from(this.querySelectorAll("svg")).forEach((n)=>n.remove());renderEmpty(this,"sparkline")}}else{renderEmpty(this,"sparkline")}}enhance(){if(this._wiredSparkline)return;this._wiredSparkline=true;if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");const showTip=(e)=>{const svg=this.querySelector("svg");const tip=this.querySelector(".c-sparkline__tooltip");const dot=this.querySelector(".c-sparkline__dot");if(!tip||!svg)return;const rect=svg.getBoundingClientRect();const x=e.clientX-rect.left;const pct=Math.max(0,Math.min(1,x/rect.width));const pts=this._sparkPoints||[];if(pts.length===0)return;const idx=Math.round(pct*(pts.length-1));const val=pts[idx];const cx=(idx*100/(pts.length-1));const cy=30-val*30;if(dot){dot.setAttribute("cx",String(cx));dot.setAttribute("cy",String(cy));dot.removeAttribute("hidden")}tip.textContent=String(val);const tipX=(cx/100)*rect.width;tip.style.setProperty("--chart-tip-inline-start",tipX+"px");tip.style.setProperty("--chart-tip-block-start","0px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-sparkline__tooltip");const dot=this.querySelector(".c-sparkline__dot");if(tip)tip.setAttribute("hidden","");if(dot)dot.setAttribute("hidden","")};this.addEventListener("mousemove",showTip);this.addEventListener("mouseleave",hideTip);this.addEventListener("focusin",()=>{const pts=this._sparkPoints||[];if(!pts.length)return;const svg=this.querySelector("svg");if(!svg)return;const r=svg.getBoundingClientRect();showTip({clientX:r.left+r.width-1})});this.addEventListener("focusout",hideTip);this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{series:1}}))}})}}define("contour-sparkline",ContourSparkline);class ContourChartGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["title","series","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{title:{attribute:"title"},series:{attribute:"series"},src:{attribute:"src"}}}render(){this.classList.add("c-chart-grid");this.setAttribute("role","group");this.setAttribute("aria-label","Chart grid");wireStates(this);loadRemote(this,"series");if(renderStates(this,"chart-grid"))return;const title=this.getAttribute("title");if(title){const t=this.ensure(".c-chart-grid__title",()=>{const el=document.createElement("div");el.className="c-chart-grid__title";return el});t.textContent=title}const series=remoteData(this,"series");if(!series&&!title)renderEmpty(this,"chart-grid")}}define("contour-chart-grid",ContourChartGrid);class ContourContourPlot extends ContourBase{static get observed(){return["axis","label"]}static get properties(){return{axis:{attribute:"axis"},label:{attribute:"label"}}}render(){this.classList.add("c-contour-plot");this.setAttribute("role","img");this.setAttribute("aria-label","Contour plot");const axis=this.getAttribute("axis");if(axis){let svg=this.querySelector("svg");if(!svg){svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 100 100");svg.setAttribute("aria-hidden","true");this.appendChild(svg)}let ax=svg.querySelector(".c-contour-plot__axis");if(!ax){ax=document.createElementNS("http://www.w3.org/2000/svg","line");ax.setAttribute("class","c-contour-plot__axis");svg.appendChild(ax)}}const label=this.getAttribute("label");if(label){let svg=this.querySelector("svg");if(!svg){svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("viewBox","0 0 100 100");svg.setAttribute("aria-hidden","true");this.appendChild(svg)}let lbl=svg.querySelector(".c-contour-plot__label");if(!lbl){lbl=document.createElementNS("http://www.w3.org/2000/svg","text");lbl.setAttribute("class","c-contour-plot__label");svg.appendChild(lbl)}lbl.textContent=label}}}class ContourErrorBoundary extends ContourBase{static get observed(){return["fallback","error"]}static get properties(){return{fallback:{attribute:"fallback"},error:{attribute:"error"}}}render(){this.classList.add("c-error-boundary");this.setAttribute("role","region");this.setAttribute("aria-live","polite");const err=this.getAttribute("error");if(err){this.dataset.state="error";Array.from(this.children).forEach((c)=>{if(!c.hasAttribute("data-fallback"))c.style.display="none"});let fb=this.querySelector("[data-fallback]");if(!fb){fb=document.createElement("div");fb.className="c-error-boundary__fallback";fb.dataset.fallback="";fb.textContent=this.getAttribute("fallback")||"Something went wrong.";this.appendChild(fb)}else{fb.textContent=this.getAttribute("fallback")||fb.textContent||"Something went wrong."}}else{this.dataset.state="ready";Array.from(this.children).forEach((c)=>{c.style.display=""});const fb=this.querySelector("[data-fallback]");if(fb)fb.remove()}}enhance(){if(this._wiredErrorBoundary)return;this._wiredErrorBoundary=true;this.addEventListener("error",(e)=>{e.stopPropagation();const msg=(e&&e.error&&e.error.message)?e.error.message:(e&&e.message)?e.message:"Unknown error";this.setAttribute("error",msg)},true)}}define("contour-error-boundary",ContourErrorBoundary);class ContourDataExport extends ContourBase{static get observed(){return["data","format","filename","label"]}static get properties(){return{data:{attribute:"data"},format:{attribute:"format"},filename:{attribute:"filename"},label:{attribute:"label"}}}render(){this.classList.add("c-data-export");const fmt=(this.getAttribute("format")||"json").toLowerCase();const btn=this.ensure(".c-data-export__btn",()=>{const b=document.createElement("button");b.className="c-data-export__btn";b.type="button";return b});btn.textContent=this.getAttribute("label")||("Export "+fmt.toUpperCase());if(btn.parentNode!==this)this.appendChild(btn)}enhance(){if(this._wiredDataExport)return;this._wiredDataExport=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-data-export__btn"):null;if(!btn||!this.contains(btn))return;const fmt=(this.getAttribute("format")||"json").toLowerCase();const raw=this.getAttribute("data")||"[]";let text=raw;if(fmt==="csv"){try{const arr=JSON.parse(raw);if(Array.isArray(arr)&&arr.length){const keys=Object.keys(arr[0]);text=[keys.join(",")].concat(arr.map((r)=>keys.map((k)=>JSON.stringify(r[k]??"")).join(","))).join("\n")}}catch(e){}}const blob=new Blob([text],{type:fmt==="csv"?"text/csv":"application/json"});const url=URL.createObjectURL(blob);const a=document.createElement("a");a.href=url;a.download=this.getAttribute("filename")||("export."+fmt);document.body.appendChild(a);a.click();a.remove();URL.revokeObjectURL(url);this.dispatchEvent(new CustomEvent("contour:export",{bubbles:true,composed:true,detail:{format:fmt}}))})}}define("contour-data-export",ContourDataExport);class ContourDocsNav extends ContourBase{static get observed(){return["items","title","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},title:{attribute:"title"},src:{attribute:"src"}}}render(){this.classList.add("c-docs-nav");this.setAttribute("role","navigation");const title=this.getAttribute("title");if(title)this.setAttribute("aria-label",title);else this.setAttribute("aria-label","Documentation navigation");wireStates(this);loadRemote(this,"items");if(renderStates(this,"docs-nav"))return;const _remote=remoteData(this,"items");const items=this.hasAttribute("src")?_remote:(_remote||(this.hasAttribute("items")?this.getAttribute("items"):null));const list=this.querySelector(".c-docs-nav__list");const authored=list?Array.from(list.children).filter((n)=>n.classList&&n.classList.contains("c-docs-nav__group")):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const list=this.ensure(".c-docs-nav__list",()=>{const el=document.createElement("div");el.className="c-docs-nav__list";return el});list.innerHTML="";parsed.forEach((g)=>{const group=document.createElement("div");group.className="c-docs-nav__group";if(g.title){const gt=document.createElement("div");gt.className="c-docs-nav__group-title";gt.textContent=g.title;group.appendChild(gt)}const ul=document.createElement("div");ul.className="c-docs-nav__list";(g.links||g.items||[]).forEach((l)=>{const a=document.createElement("a");a.className="c-docs-nav__link";a.href=(typeof l==="string"?"#":(l.href||"#"));const label=typeof l==="string"?l:(l.label||l);if(typeof l==="object"&&l!==null&&l.badge){const b=document.createElement("span");b.className="c-docs-nav__badge";b.textContent=l.badge;a.appendChild(b)}a.appendChild(document.createTextNode(label));if(typeof l==="object"&&l!==null&&l.chevron){const ch=document.createElement("span");ch.className="c-docs-nav__chevron";ch.textContent=l.chevron;a.appendChild(ch)}if(typeof l==="object"&&l!==null&&Array.isArray(l.items)){a.classList.add("c-docs-nav__link--nested");const nested=document.createElement("div");nested.className="c-docs-nav__list c-docs-nav__list--nested";l.items.forEach((nl)=>{const na=document.createElement("a");na.className="c-docs-nav__link";na.href=(typeof nl==="string"?"#":(nl.href||"#"));na.textContent=typeof nl==="string"?nl:(nl.label||nl);nested.appendChild(na)});ul.appendChild(a);ul.appendChild(nested)}else{ul.appendChild(a)}});group.appendChild(ul);list.appendChild(group)})}catch(e){}}else if(!items&&list){list.remove();renderEmpty(this,"docs-nav")}else if(!items&&!list){renderEmpty(this,"docs-nav")}}enhance(){if(this._wiredDocsNav)return;this._wiredDocsNav=true;this.addEventListener("click",(e)=>{const link=e.target&&e.target.closest?e.target.closest(".c-docs-nav__link"):null;if(link&&this.contains(link)){const label=link.textContent||"";this.dispatchEvent(new CustomEvent("contour:docs-nav-select",{bubbles:true,composed:true,detail:{label,href:link.getAttribute("href")}}))}})}}define("contour-docs-nav",ContourDocsNav);class ContourDocsShell extends ContourBase{static get observed(){return["title","lede","article","heading"]}static get properties(){return{title:{attribute:"title"},lede:{attribute:"lede"},article:{attribute:"article"}}}render(){this.classList.add("c-docs-shell");this.setAttribute("role","region");const title=this.getAttribute("title");if(title){const h=this.ensure(".c-docs-shell__title",()=>{const el=document.createElement(headingTag(this,"h1"));el.className="c-docs-shell__title";return el});h.textContent=title;this.setAttribute("aria-label",title)}else{const h=this.querySelector(".c-docs-shell__title");if(h)h.remove()}const lede=this.getAttribute("lede");if(lede){const p=this.ensure(".c-docs-shell__lede",()=>{const el=document.createElement("p");el.className="c-docs-shell__lede";return el});p.textContent=lede}else{const p=this.querySelector(".c-docs-shell__lede");if(p)p.remove()}const article=this.getAttribute("article");if(article){const a=this.ensure(".c-docs-shell__article",()=>{const el=document.createElement("article");el.className="c-docs-shell__article";return el});a.innerHTML=sanitizeHtml(article)}else{const a=this.querySelector(".c-docs-shell__article");if(a)a.remove()}}}define("contour-docs-shell",ContourDocsShell);class ContourFileTree extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-file-tree");const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);const renderNode=(node,depth)=>{const row=document.createElement("div");row.className="c-file-tree__row"+(node.dir?" c-file-tree__row--dir":"")+(node.active?" c-file-tree__row--active":"");row.style.paddingInlineStart=(depth*1)+"rem";const label=document.createElement("span");label.textContent=node.label||node.name||"";row.appendChild(label);this.appendChild(row);if(Array.isArray(node.children)){node.children.forEach((c)=>renderNode(c,depth+1))}};Array.from(this.querySelectorAll(".c-file-tree__row")).forEach((n)=>n.remove());parsed.forEach((n)=>renderNode(n,0))}catch(e){}}}}define("contour-file-tree",ContourFileTree);class ContourChangelog extends ContourBase{static get observed(){return["src","max","loading","error"]}static get properties(){return{src:{attribute:"src"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-changelog");const src=this.getAttribute("src");if(src){if(this.dataset.loaded===src)return;this.dataset.loaded="";const loading=this.ensure(".c-changelog__loading",()=>{const el=document.createElement("div");el.className="c-changelog__loading";el.textContent="Loading…";return el});Array.from(this.querySelectorAll(".c-changelog__entry, .c-changelog__error")).forEach((n)=>n.remove());if(!this.querySelector(".c-changelog__loading"))this.appendChild(loading);fetch(src).then((r)=>{if(!r.ok)throw new Error("HTTP "+r.status);return r.text()}).then((text)=>{const ld=this.querySelector(".c-changelog__loading");if(ld)ld.remove();this.dataset.loaded=src;const entries=parseChangelog(text);const max=parseInt(this.getAttribute("max")||"0",10);const list=(max>0)?entries.slice(0,max):entries;if(!list.length){const empty=document.createElement("div");empty.className="c-changelog__empty";empty.textContent="No releases found.";this.appendChild(empty);return}list.forEach((e)=>{const det=document.createElement("details");det.className="c-changelog__entry";const sum=document.createElement("summary");sum.className="c-changelog__summary";const ver=document.createElement("span");ver.className="c-changelog__version";ver.textContent=e.version;sum.appendChild(ver);if(e.date){const d=document.createElement("span");d.className="c-changelog__date";d.textContent=e.date;sum.appendChild(d)}det.appendChild(sum);const body=document.createElement("div");body.className="c-changelog__body";body.innerHTML=renderChangelogBody(e.body);det.appendChild(body);this.appendChild(det)})}).catch((err)=>{const ld=this.querySelector(".c-changelog__loading");if(ld)ld.remove();const er=document.createElement("div");er.className="c-changelog__error";er.textContent="Failed to load changelog: "+(err&&err.message?err.message:err);this.appendChild(er)})}}}define("contour-changelog",ContourChangelog);function parseChangelog(text){const lines=String(text).split(/\r?\n/);const entries=[];let cur=null;for(const line of lines){const m=line.match(/^##\s+\[?([^\]\n]+)\]?\s*[-–—]?\s*(.*)$/);if(m&&(line.startsWith("## "))){const ver=m[1].trim();const rest=m[2].trim();if(/^\d|unreleased/i.test(ver)){if(cur)entries.push(cur);cur={version:ver,date:rest.replace(/^[-–—]\s*/,"").trim(),body:""};continue}}if(cur)cur.body+=line+"\n"}if(cur)entries.push(cur);return entries}function escapeHtml(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function renderChangelogBody(body){const lines=String(body).trim().split(/\r?\n/);const out=[];let inList=false;for(const raw of lines){const line=raw.trimEnd();if(/^###\s+/.test(line)){if(inList){out.push("</ul>");inList=false}out.push("<h4>"+escapeHtml(line.replace(/^###\s+/,""))+"</h4>")}else if(/^##\s+/.test(line)){if(inList){out.push("</ul>");inList=false}out.push("<h3>"+escapeHtml(line.replace(/^##\s+/,""))+"</h3>")}else if(/^[-*]\s+/.test(line)){if(!inList){out.push("<ul>");inList=true}out.push("<li>"+escapeHtml(line.replace(/^[-*]\s+/,""))+"</li>")}else if(line.trim()===""){if(inList){out.push("</ul>");inList=false}}else{if(inList){out.push("</ul>");inList=false}out.push("<p>"+escapeHtml(line)+"</p>")}}if(inList)out.push("</ul>");return out.join("")}class ContourDialog extends ContourBase{static get observed(){return["title","size","heading"]}static get properties(){return{title:{attribute:"title"},size:{attribute:"size"}}}render(){this.classList.add("c-dialog");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-dialog--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-dialog--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","dialog");const title=this.getAttribute("title");let head=this.querySelector(".c-dialog__head");if(title){if(!head){head=document.createElement("div");head.className="c-dialog__head";const h=document.createElement(headingTag(this,"h2"));h.className="c-dialog__title";head.appendChild(h);const closeBtn=document.createElement("button");closeBtn.className="c-btn c-btn--icon c-btn--ghost c-dialog__close";closeBtn.setAttribute("type","button");closeBtn.setAttribute("aria-label","Close");closeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-close" /></svg>';head.appendChild(closeBtn)}const h=head.querySelector(".c-dialog__title");if(h){h.textContent=title;if(!h.id)h.id="contour-dialog-title-"+(this._dialogTitleId=(this._dialogTitleId||0)+1);this.setAttribute("aria-labelledby",h.id)}}if(head&&head.parentNode!==this)this.prepend(head);const body=this.ensure(".c-dialog__body",()=>{const el=document.createElement("div");el.className="c-dialog__body";return el});Array.from(this.childNodes).forEach((n)=>{if(n===body||n===head)return;if(n.nodeType===1&&n.classList&&n.classList.contains("c-dialog__head"))return;body.appendChild(n)});if(head&&head.parentNode===this){if(body.parentNode!==this)this.insertBefore(body,head.nextSibling);else if(head.compareDocumentPosition(body)&Node.DOCUMENT_POSITION_PRECEDING)this.insertBefore(body,head.nextSibling)}else{if(body.parentNode!==this)this.appendChild(body)}}enhance(){if(this._wiredDialog)return;this._wiredDialog=true;onDispose(this,()=>{if(this.hasAttribute("open"))modalContain(this,false)});this.show=()=>{if(this.hasAttribute("open"))return;this._dialogLastFocus=document.activeElement;this.setAttribute("open","");this.setAttribute("aria-modal","true");const dlg=this.querySelector("dialog")||(this.tagName==="DIALOG"?this:null);if(dlg&&typeof dlg.showModal==="function"){try{dlg.showModal()}catch(e){}}modalContain(this,true);const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};this.close=()=>{const wasOpen=this.hasAttribute("open");const dlg=this.querySelector("dialog")||(this.tagName==="DIALOG"?this:null);if(dlg&&typeof dlg.close==="function")dlg.close();if(this.hasAttribute("open"))this.removeAttribute("open");this.removeAttribute("aria-modal");if(wasOpen){modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));const last=this._dialogLastFocus;if(last&&typeof last.focus==="function"){try{last.focus()}catch(e){}}}};this.focus=()=>{const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}else{try{HTMLElement.prototype.focus.call(this)}catch(e){}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-dialog__close"):null;if(btn&&this.contains(btn)){this.close();return}if(e.target===this)this.close()});this.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.hasAttribute("open"))this.close()})}}define("contour-dialog",ContourDialog);class ContourAlert extends ContourBase{static get observed(){return["title","body","variant","icon","closable","action","actions","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},variant:{attribute:"variant"},icon:{attribute:"icon"},closable:{attribute:"closable",type:Boolean},action:{attribute:"action"},actions:{attribute:"actions"}}}render(){this.classList.add("c-alert");if(!this.hasAttribute("role"))this.setAttribute("role","alert");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","assertive");wireStates(this);loadRemote(this,"title");if(renderStates(this,"alert"))return;const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-alert--"))this.classList.remove(c)});if(variant)this.classList.add("c-alert--"+variant);const icon=this.getAttribute("icon");if(icon){const ic=this.ensure(".c-alert__icon",()=>{const el=document.createElement("span");el.className="c-alert__icon";return el});if(ic.parentNode===this&&this.firstChild!==ic)this.prepend(ic);ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'}else{const ic=this.querySelector(".c-alert__icon");if(ic)ic.remove()}const title=this.getAttribute("title")||(this._remoteData&&this._remoteData.title);if(title){const t=this.ensure(".c-alert__title",()=>{const el=document.createElement("div");el.className="c-alert__title";return el});if(t.parentNode===this&&this.firstChild!==t)this.prepend(t);t.textContent=title}else{const t=this.querySelector(".c-alert__title");if(t)t.remove()}const body=this.getAttribute("body");if(body){const b=this.ensure(".c-alert__body",()=>{const el=document.createElement("div");el.className="c-alert__body";return el});b.textContent=body}else{const b=this.querySelector(".c-alert__body");if(b)b.remove()}Array.from(this.querySelectorAll(".c-alert__action")).forEach((n)=>n.remove());const actionsAttr=this.getAttribute("actions");let actionList=[];if(actionsAttr){try{const parsed=JSON.parse(actionsAttr);if(Array.isArray(parsed))actionList=parsed.map((x)=>String(x))}catch(e){actionList=[actionsAttr]}}else{const single=this.getAttribute("action");if(single)actionList=[single]}actionList.forEach((label)=>{const a=document.createElement("button");a.className="c-btn c-btn--sm c-alert__action";a.type="button";a.setAttribute("data-alert-action","");a.textContent=label;this.appendChild(a)});if(this.hasAttribute("closable")){this.ensure(".c-alert__close",()=>{const btn=document.createElement("button");btn.className="c-alert__close";btn.type="button";btn.setAttribute("aria-label","Close");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-alert__close");if(btn)btn.remove()}if(!title&&!body&&!icon){renderEmpty(this,"alert")}}}ContourAlert.prototype.enhance=function(){if(this._wiredAlert)return;this._wiredAlert=true;this.addEventListener("click",(e)=>{const actionBtn=e.target&&e.target.closest?e.target.closest(".c-alert__action"):null;if(actionBtn&&this.contains(actionBtn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:empty-action",{bubbles:true,composed:true,detail:{state:actionBtn.textContent.trim()}}));return}const btn=e.target&&e.target.closest?e.target.closest(".c-alert__close"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()})};define("contour-alert",ContourAlert);class ContourDisclosure extends ContourBase{static get observed(){return["summary","icon"]}static get properties(){return{summary:{attribute:"summary"},icon:{attribute:"icon"}}}disconnectedCallback(){this._disclosureContent=null;super.disconnectedCallback()}connectedCallback(){if(this.innerHTML.trim()&&!this._disclosureContent){this._disclosureContent=this.innerHTML}super.connectedCallback()}attributeChangedCallback(name,oldValue,newValue){const details=this.querySelector("details");if(details){const body=details.querySelector(".c-disclosure__body");if(body)this._disclosureContent=body.innerHTML}else if(this.innerHTML.trim()){this._disclosureContent=this.innerHTML}super.attributeChangedCallback(name,oldValue,newValue)}render(){this.classList.add("c-disclosure");const summary=this.getAttribute("summary");const icon=this.getAttribute("icon");if(summary){let captured=this.innerHTML.trim()?this.innerHTML:(this._disclosureContent||"");if(captured.trim())this._disclosureContent=captured;const details=this.ensure("details",()=>{const d=document.createElement("details");const summ=document.createElement("summary");summ.className="c-disclosure__summary";if(icon){const ic=document.createElement("span");ic.className="c-disclosure__icon";ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>';summ.appendChild(ic)}summ.appendChild(document.createTextNode(summary));d.appendChild(summ);const content=document.createElement("div");content.className="c-disclosure__body";content.innerHTML=captured;d.appendChild(content);return d});const summ=details.querySelector("summary");if(summ){const ic=summ.querySelector(".c-disclosure__icon");if(icon&&!ic){const newIc=document.createElement("span");newIc.className="c-disclosure__icon";newIc.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>';summ.insertBefore(newIc,summ.firstChild)}else if(!icon&&ic){ic.remove()}const textNodes=Array.from(summ.childNodes).filter(n=>n.nodeType===3);textNodes.forEach(n=>n.remove());summ.appendChild(document.createTextNode(summary))}const body=details.querySelector(".c-disclosure__body");if(body)body.innerHTML=captured;if(details.parentNode!==this){this.innerHTML="";this.appendChild(details)}}else{const details=this.querySelector("details");if(details)details.remove()}}enhance(){if(this._wiredDisclosure)return;this._wiredDisclosure=true;this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t.tagName==="DETAILS"){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:t.open},bubbles:true,composed:true}))}},true)}}define("contour-disclosure",ContourDisclosure);class ContourCallout extends ContourBase{static get observed(){return["variant","title","icon","closable"]}static get properties(){return{variant:{attribute:"variant"},title:{attribute:"title"},icon:{attribute:"icon"},closable:{attribute:"closable",type:Boolean}}}render(){this.classList.add("c-callout");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-callout--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-callout--"+variant);const icon=this.getAttribute("icon");if(icon){const ic=this.ensure(".c-callout__icon",()=>{const el=document.createElement("span");el.className="c-callout__icon";return el});if(ic.parentNode===this&&this.firstChild!==ic)this.prepend(ic);ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'}else{const ic=this.querySelector(".c-callout__icon");if(ic)ic.remove()}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-callout__title",()=>{const el=document.createElement("div");el.className="c-callout__title";return el});if(t.parentNode===this&&this.firstChild!==t)this.prepend(t);t.textContent=title}else{const t=this.querySelector(".c-callout__title");if(t)t.remove()}if(this.hasAttribute("closable")){this.ensure(".c-callout__close",()=>{const btn=document.createElement("button");btn.className="c-callout__close";btn.type="button";btn.setAttribute("aria-label","Close");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-callout__close");if(btn)btn.remove()}}}ContourCallout.prototype.enhance=function(){if(this._wiredCallout)return;this._wiredCallout=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-callout__close"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()})};define("contour-callout",ContourCallout);class ContourEmpty extends ContourBase{static get observed(){return["state","title","body","action","icon","illustration","heading"]}static get properties(){return{state:{attribute:"state"},title:{attribute:"title"},body:{attribute:"body"},action:{attribute:"action"},icon:{attribute:"icon"},illustration:{attribute:"illustration"}}}render(){this.classList.add("c-empty");if(!this.hasAttribute("role"))this.setAttribute("role","status");const state=this.getAttribute("state")||"empty";const title=this.getAttribute("title")||(state==="filtered"?"Nothing matches":state==="error"?"Could not load":"No data yet");const body=this.getAttribute("body")||(state==="filtered"?"Try clearing some filters.":state==="error"?"Check your connection and try again.":"There is nothing to show here yet.");const action=this.getAttribute("action")||(state==="filtered"?"Clear filters":state==="error"?"Retry":"");const icon=this.getAttribute("icon");if(icon){const ic=this.ensure(".c-empty__icon",()=>{const el=document.createElement("span");el.className="c-empty__icon";return el});ic.innerHTML='<svg aria-hidden="true"><use href="#'+String(icon).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'}else{const ic=this.querySelector(".c-empty__icon");if(ic)ic.remove()}const illustration=this.getAttribute("illustration");if(illustration){const il=this.ensure(".c-empty__illustration",()=>{const el=document.createElement("div");el.className="c-empty__illustration";return el});il.innerHTML=sanitizeHtml(illustration)}else{const il=this.querySelector(".c-empty__illustration");if(il)il.remove()}if(title){const t=this.ensure(".c-empty__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-empty__title";return el});t.textContent=title}else{const t=this.querySelector(".c-empty__title");if(t)t.remove()}if(body){const b=this.ensure(".c-empty__text",()=>{const el=document.createElement("p");el.className="c-empty__text";return el});b.textContent=body}else{const b=this.querySelector(".c-empty__text");if(b)b.remove()}if(action){const a=this.ensure("button.c-btn[data-empty-action]",()=>{const el=document.createElement("button");el.className="c-btn c-btn--primary";el.type="button";el.setAttribute("data-empty-action","");return el});a.textContent=action}else{const a=this.querySelector("[data-empty-action]");if(a)a.remove()}}enhance(){wireRemovable(this)}}define("contour-empty",ContourEmpty);class ContourFaq extends ContourBase{static get observed(){return["question","answer","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{question:{attribute:"question"},answer:{attribute:"answer"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-faq");wireStates(this);loadRemote(this,"items");if(renderStates(this,"faq"))return;const items=remoteData(this,"items");const question=this.getAttribute("question");const answer=this.getAttribute("answer");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-faq__item"));if(items&&!authored.length){try{const parsed=JSON.parse(items);Array.from(this.querySelectorAll(".c-faq__item")).forEach((n)=>n.remove());parsed.forEach((it,i)=>{const item=document.createElement("details");item.className="c-faq__item";if(i===0)item.setAttribute("open","");const q=document.createElement("summary");q.className="c-faq__question";q.textContent=typeof it==="string"?it:(it.question||it.q||"");const sign=document.createElement("span");sign.className="c-faq__sign";sign.setAttribute("aria-hidden","true");sign.innerHTML='<svg aria-hidden="true"><use href="#i-plus" /></svg>';q.appendChild(sign);item.appendChild(q);const a=document.createElement("div");a.className="c-faq__answer";a.textContent=typeof it==="string"?"":(it.answer||it.a||"");item.appendChild(a);this.appendChild(item)})}catch(e){}}else if(!items){if(!question&&!answer){renderEmpty(this,"faq")}else{const item=this.ensure("details.c-faq__item",()=>{const el=document.createElement("details");el.className="c-faq__item";return el});if(!item.hasAttribute("open"))item.setAttribute("open","");const q=this.ensure("summary.c-faq__question",()=>{const el=document.createElement("summary");el.className="c-faq__question";return el},item);q.textContent=question||"";const sign=this.ensure(".c-faq__sign",()=>{const el=document.createElement("span");el.className="c-faq__sign";return el},q);sign.setAttribute("aria-hidden","true");sign.innerHTML='<svg aria-hidden="true"><use href="#i-plus" /></svg>';const a=this.ensure(".c-faq__answer",()=>{const el=document.createElement("div");el.className="c-faq__answer";return el},item);a.textContent=answer||""}}}}define("contour-faq",ContourFaq);class ContourAccordion extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","exclusive"]}static get properties(){return{items:{attribute:"items"},exclusive:{attribute:"exclusive",type:Boolean},src:{attribute:"src"}}}render(){const authored=Array.from(this.children).filter((n)=>n.tagName==="DETAILS");wireStates(this);loadRemote(this,"items");if(renderStates(this,"accordion"))return;const items=remoteData(this,"items");if(items&&!authored.length){Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>d.remove());try{const parsed=JSON.parse(items);parsed.forEach((item)=>{const details=document.createElement("details");details.className="c-disclosure";const summary=document.createElement("summary");summary.className="c-disclosure__summary";summary.textContent=item.title||item.question||item.q||item.label||"";details.appendChild(summary);const body=document.createElement("div");body.className="c-disclosure__body";body.textContent=item.body||item.answer||item.a||item.content||"";details.appendChild(body);this.appendChild(details)})}catch(e){}}else if(!items&&!authored.length){renderEmpty(this,"accordion")}const persist=this.getAttribute("persist");if(persist){let saved=null;if(persist==="storage"&&this.id){try{saved=localStorage.getItem("contour-accordion:"+this.id)}catch(e){}}else if(persist==="url"){try{saved=new URLSearchParams(window.location.search).get("c-accordion")}catch(e){}}if(saved!==null){try{const labels=JSON.parse(saved);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{const summary=d.querySelector("summary");const label=(summary?summary.textContent:"").trim().slice(0,120);if(want.has(label))d.open=true})}}catch(e){}}}}enhance(){if(this._wiredAccordion)return;this._wiredAccordion=true;this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t.tagName==="DETAILS"){if(t.open&&this.hasAttribute("exclusive")){Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{if(d!==t)d.open=false})}this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:t.open},bubbles:true,composed:true}));const persist=this.getAttribute("persist");if(persist==="storage"&&this.id){try{const open=[];Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{if(d.open){const s=d.querySelector("summary");open.push((s?s.textContent:"").trim().slice(0,120))}});localStorage.setItem("contour-accordion:"+this.id,JSON.stringify(open))}catch(e){}}else if(persist==="url"){try{const open=[];Array.from(this.querySelectorAll("details.c-disclosure")).forEach((d)=>{if(d.open){const s=d.querySelector("summary");open.push((s?s.textContent:"").trim().slice(0,120))}});const url=new URL(window.location.href);url.searchParams.set("c-accordion",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}catch(e){}}}},true)}}define("contour-accordion",ContourAccordion);class ContourDrawer extends ContourBase{static get observed(){return["title","body","size"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},size:{attribute:"size"}}}render(){this.classList.add("c-drawer");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-drawer--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-drawer--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","dialog");const title=this.getAttribute("title");let head=this.querySelector(".c-drawer__head");if(title){if(!head){head=document.createElement("div");head.className="c-drawer__head";const t=document.createElement("div");t.className="c-drawer__title";head.appendChild(t);const closeBtn=document.createElement("button");closeBtn.className="c-btn c-btn--icon c-btn--ghost c-drawer__close";closeBtn.setAttribute("type","button");closeBtn.setAttribute("aria-label","Close");closeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-close" /></svg>';head.appendChild(closeBtn)}const t=head.querySelector(".c-drawer__title");if(t){t.textContent=title;if(!t.id)t.id="contour-drawer-title-"+(this._drawerTitleId=(this._drawerTitleId||0)+1);this.setAttribute("aria-labelledby",t.id)}if(head.parentNode!==this)this.prepend(head)}else if(head){head.remove()}if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const body=this.getAttribute("body");const b=this.querySelector(".c-drawer__body");const authored=b?Array.from(b.children):[];if(body&&!authored.length){const el=this.ensure(".c-drawer__body",()=>{const e=document.createElement("div");e.className="c-drawer__body";return e});el.innerHTML=sanitizeHtml(body)}else if(!body&&b&&!authored.length){b.remove()}}enhance(){if(this._wiredDrawer)return;this._wiredDrawer=true;onDispose(this,()=>{if(this.hasAttribute("open"))modalContain(this,false)});this._drawerLastFocus=null;this.show=()=>{if(this.hasAttribute("open"))return;this._drawerLastFocus=document.activeElement;this.setAttribute("open","");this.setAttribute("aria-modal","true");this.classList.add("is-open");modalContain(this,true);const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};this.close=()=>{if(!this.hasAttribute("open"))return;this.removeAttribute("open");this.removeAttribute("aria-modal");this.classList.remove("is-open");modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));const last=this._drawerLastFocus;if(last&&typeof last.focus==="function"){try{last.focus()}catch(e){}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-drawer__close"):null;if(btn&&this.contains(btn)){this.close();return}if(e.target===this)this.close()});this.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.hasAttribute("open"))this.close()});let touchStartX=0,touchStartY=0;this.addEventListener("touchstart",(e)=>{if(!this.hasAttribute("open"))return;const t=e.touches&&e.touches[0];if(t){touchStartX=t.clientX;touchStartY=t.clientY}},{passive:true});this.addEventListener("touchend",(e)=>{if(!this.hasAttribute("open"))return;const t=e.changedTouches&&e.changedTouches[0];if(!t)return;const dx=t.clientX-touchStartX;const dy=t.clientY-touchStartY;if(Math.abs(dx)>60&&Math.abs(dx)>Math.abs(dy)*1.5)this.close()},{passive:true})}}define("contour-drawer",ContourDrawer);class ContourSheet extends ContourBase{static get observed(){return["title","body","size"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},size:{attribute:"size"}}}render(){this.classList.add("c-sheet");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-sheet--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-sheet--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","dialog");const title=this.getAttribute("title");let head=this.querySelector(".c-sheet__head");if(title){if(!head){head=document.createElement("div");head.className="c-sheet__head";const t=document.createElement("div");t.className="c-sheet__title";head.appendChild(t);const closeBtn=document.createElement("button");closeBtn.className="c-btn c-btn--icon c-btn--ghost c-sheet__close";closeBtn.setAttribute("type","button");closeBtn.setAttribute("aria-label","Close");closeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-close" /></svg>';head.appendChild(closeBtn)}const t=head.querySelector(".c-sheet__title");if(t){t.textContent=title;if(!t.id)t.id="contour-sheet-title-"+(this._sheetTitleId=(this._sheetTitleId||0)+1);this.setAttribute("aria-labelledby",t.id)}if(head.parentNode!==this)this.prepend(head)}else if(head){head.remove()}if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const body=this.getAttribute("body");const b=this.querySelector(".c-sheet__body");const authored=b?Array.from(b.children):[];if(body&&!authored.length){const el=this.ensure(".c-sheet__body",()=>{const e=document.createElement("div");e.className="c-sheet__body";return e});el.innerHTML=sanitizeHtml(body)}else if(!body&&b&&!authored.length){b.remove()}}enhance(){if(this._wiredSheet)return;this._wiredSheet=true;onDispose(this,()=>{if(this.hasAttribute("open"))modalContain(this,false)});this._sheetLastFocus=null;this.show=()=>{if(this.hasAttribute("open"))return;this._sheetLastFocus=document.activeElement;this.setAttribute("open","");this.setAttribute("aria-modal","true");this.classList.add("is-open");modalContain(this,true);const focusable=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable){try{focusable.focus()}catch(e){}}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};this.close=()=>{if(!this.hasAttribute("open"))return;this.removeAttribute("open");this.removeAttribute("aria-modal");this.classList.remove("is-open");modalContain(this,false);this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));const last=this._sheetLastFocus;if(last&&typeof last.focus==="function"){try{last.focus()}catch(e){}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-sheet__close"):null;if(btn&&this.contains(btn)){this.close();return}if(e.target===this)this.close()});this.addEventListener("keydown",(e)=>{if(e.key==="Escape"&&this.hasAttribute("open"))this.close()});let touchStartY=0,touchStartX=0;this.addEventListener("touchstart",(e)=>{if(!this.hasAttribute("open"))return;const t=e.touches&&e.touches[0];if(t){touchStartX=t.clientX;touchStartY=t.clientY}},{passive:true});this.addEventListener("touchend",(e)=>{if(!this.hasAttribute("open"))return;const t=e.changedTouches&&e.changedTouches[0];if(!t)return;const dy=t.clientY-touchStartY;const dx=t.clientX-touchStartX;if(dy>60&&Math.abs(dy)>Math.abs(dx)*1.5)this.close()},{passive:true})}}define("contour-sheet",ContourSheet);class ContourToast extends ContourBase{static get observed(){return["message","variant","duration"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"},duration:{attribute:"duration",type:Number}}}render(){this.classList.add("c-toast");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true");const message=this.getAttribute("message");if(message&&!this.hasChildNodes()){this.textContent=message}const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-toast--"))this.classList.remove(c)});if(variant)this.classList.add("c-toast--"+variant)}enhance(){if(this._wiredToast)return;this._wiredToast=true;const ms=(this.duration&&this.duration>0)?this.duration:1500;const timer=setTimeout(()=>{if(!this.isConnected)return;this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()},ms);onDispose(this,()=>clearTimeout(timer))}}define("contour-toast",ContourToast);class ContourExpandable extends ContourBase{static get observed(){return["summary"]}static get properties(){return{summary:{attribute:"summary"}}}disconnectedCallback(){this._expandableContent=null;super.disconnectedCallback()}connectedCallback(){if(this.innerHTML.trim()&&!this._expandableContent){this._expandableContent=this.innerHTML}super.connectedCallback()}attributeChangedCallback(name,oldValue,newValue){const details=this.querySelector("details");if(details){const body=details.querySelector(".c-expandable__body");if(body)this._expandableContent=body.innerHTML}else if(this.innerHTML.trim()){this._expandableContent=this.innerHTML}super.attributeChangedCallback(name,oldValue,newValue)}render(){this.classList.add("c-expandable");const summary=this.getAttribute("summary");if(summary){let captured=this.innerHTML.trim()?this.innerHTML:(this._expandableContent||"");if(captured.trim())this._expandableContent=captured;const details=this.ensure("details",()=>{const d=document.createElement("details");const summ=document.createElement("summary");summ.className="c-expandable__summary";summ.textContent=summary;d.appendChild(summ);const content=document.createElement("div");content.className="c-expandable__body";content.innerHTML=captured;d.appendChild(content);return d});const summ=details.querySelector("summary");if(summ)summ.textContent=summary;const body=details.querySelector(".c-expandable__body");if(body)body.innerHTML=captured;if(details.parentNode!==this){this.innerHTML="";this.appendChild(details)}}else{const details=this.querySelector("details");if(details)details.remove()}}enhance(){if(this._wiredExpandable)return;this._wiredExpandable=true;this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t.tagName==="DETAILS"){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:t.open},bubbles:true,composed:true}))}},true)}}define("contour-expandable",ContourExpandable);class ContourToastHost extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-toast-host");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}enhance(){if(this._wiredToastHost)return;this._wiredToastHost=true;this._toastQueue=[];this._toastActive=null;const buildToast=(message,opts)=>{opts=opts||{};const toast=document.createElement("div");toast.className="c-toast";toast.setAttribute("role","status");toast.setAttribute("aria-live","polite");toast.setAttribute("aria-atomic","true");if(opts.variant)toast.classList.add("c-toast--"+opts.variant);toast.dataset.message=message==null?"":String(message);const text=document.createElement("span");text.className="c-toast__text";text.textContent=message==null?"":String(message);toast.appendChild(text);if(opts.action&&(typeof opts.action==="string"||(opts.action.label))){const label=(typeof opts.action==="string")?opts.action:opts.action.label;const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-toast__action";btn.textContent=label;btn.addEventListener("click",(e)=>{e.stopPropagation();if(typeof opts.action==="object"&&typeof opts.action.onClick==="function"){try{opts.action.onClick()}catch(err){}}dismiss(toast)});toast.appendChild(btn)}return toast};const dismiss=(toast)=>{if(!toast||!toast.parentNode)return;if(toast._timer){clearTimeout(toast._timer);toast._timer=null}toast.parentNode.removeChild(toast);if(this._toastActive===toast)this._toastActive=null;this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true,detail:{message:toast.textContent}}));pump()};const pump=()=>{if(this._toastActive&&this._toastActive.parentNode)return;while(this._toastQueue.length){const next=this._toastQueue.shift();if(next._deduped)continue;const toast=buildToast(next.message,next.opts);this._toastActive=toast;this.appendChild(toast);const ms=(next.opts&&next.opts.duration&&next.opts.duration>0)?next.opts.duration:3000;toast._timer=setTimeout(()=>dismiss(toast),ms);return}this._toastActive=null};this.show=(message,opts)=>{opts=opts||{};const key=String(message==null?"":message);const active=this._toastActive;if(active&&active.dataset&&active.dataset.message===key&&key!==""){if(active._timer){clearTimeout(active._timer)}const ms=(opts.duration&&opts.duration>0)?opts.duration:3000;active._timer=setTimeout(()=>dismiss(active),ms);return active}const queuedDup=this._toastQueue.find((q)=>String(q.message)===key&&key!=="");if(queuedDup){queuedDup.opts=Object.assign({},queuedDup.opts,opts);return null}const entry={message,opts,_deduped:false};this._toastQueue.push(entry);pump();return this._toastActive};this.hide=()=>{if(this._toastActive)dismiss(this._toastActive);this._toastQueue.length=0;Array.from(this.querySelectorAll(".c-toast")).forEach((t)=>{if(t._timer)clearTimeout(t._timer);if(t.parentNode)t.parentNode.removeChild(t)});this._toastActive=null}}}define("contour-toast-host",ContourToastHost);class ContourCombobox extends ContourBase{static get observed(){return["options","placeholder","label","value","multiple","loading","error","retry","src","lazy","refresh","timeout","empty","skeleton","virtual"]}static get formAssociated(){return true}static get properties(){return{options:{attribute:"options"},placeholder:{attribute:"placeholder"},label:{attribute:"label"},value:{attribute:"value"},multiple:{attribute:"multiple",type:Boolean},virtual:{attribute:"virtual",type:Boolean},src:{attribute:"src"}}}render(){this.classList.add("c-combobox");wireStates(this);loadRemote(this,"options");if(renderStates(this,"combobox"))return;const options=remoteData(this,"options");const authored=Array.from(this.children).filter((n)=>!n.classList||(!n.classList.contains("c-combobox__input")&&!n.classList.contains("c-combobox__list")));if((options)&&!authored.length){try{const parsed=options?JSON.parse(options):[];const input=this.ensure(".c-combobox__input",()=>{const el=document.createElement("input");el.className="c-combobox__input";el.type="text";return el});input.type="text";input.placeholder=this.getAttribute("placeholder")||"Search…";input.setAttribute("aria-label",this.getAttribute("label")||"Search");const val=this.getAttribute("value");if(val!==null)input.value=val;const list=this.ensure(".c-combobox__list",()=>{const el=document.createElement("ul");el.className="c-combobox__list";el.setAttribute("hidden","");return el});list.innerHTML="";list.setAttribute("hidden","");this._comboboxOptions=parsed;this._comboboxVirtual=this.hasAttribute("virtual")&&parsed.length>100;if(this._comboboxVirtual){list.classList.add("c-combobox__list--virtual");list.style.maxBlockSize="20rem";list.style.overflow="auto";this._renderComboboxWindow("",true)}else{list.classList.remove("c-combobox__list--virtual");list.style.maxBlockSize="";list.style.overflow="";this._renderComboboxWindow("",true)}}catch(e){}}else if(!authored.length&&!options){renderEmpty(this,"combobox")}if(this.getAttribute("value")){this.ensure(".c-combobox__clear",()=>{const btn=document.createElement("button");btn.className="c-combobox__clear";btn.type="button";btn.setAttribute("aria-label","Clear");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-combobox__clear");if(btn)btn.remove()}}_renderComboboxWindow(query="",reset=false){const list=this.querySelector(".c-combobox__list");const options=this._comboboxOptions||[];if(!list)return;const q=String(query||"").toLowerCase();const filtered=options.map((opt,index)=>({opt,index,label:typeof opt==="string"?opt:opt.label,value:typeof opt==="string"?opt:opt.value,})).filter((item)=>!q||String(item.label).toLowerCase().includes(q));this._comboboxFiltered=filtered;const rowHeight=32;const windowSize=20;const overscan=6;const oldScrollTop=list.scrollTop;const start=this._comboboxVirtual&&!reset?Math.min(Math.max(0,filtered.length-windowSize),Math.max(0,Math.floor(oldScrollTop/rowHeight)-overscan)):0;this._comboboxWindowStart=start;const end=this._comboboxVirtual?Math.min(filtered.length,start+windowSize+overscan*2):filtered.length;const selectedVals=(this.getAttribute("value")||"").split(",").map((v)=>v.trim()).filter(Boolean);list.innerHTML="";const addSpacer=(height)=>{const spacer=document.createElement("li");spacer.setAttribute("aria-hidden","true");spacer.style.blockSize=`${height}px`;list.appendChild(spacer)};if(this._comboboxVirtual)addSpacer(start*rowHeight);if(!filtered.length){const empty=document.createElement("li");empty.className="c-combobox__empty";empty.setAttribute("role","status");empty.textContent=this.getAttribute("empty")||"No matches";list.appendChild(empty)}if(this.hasAttribute("multiple"))list.setAttribute("aria-multiselectable","true");else list.removeAttribute("aria-multiselectable");filtered.slice(start,end).forEach((item)=>{const li=document.createElement("li");li.className="c-combobox__option";li.dataset.optionIndex=String(item.index);li.setAttribute("role","option");const label=String(item.label);const q=String(query||"").toLowerCase();if(q&&label.toLowerCase().includes(q)){const idx=label.toLowerCase().indexOf(q);const before=label.slice(0,idx);const match=label.slice(idx,idx+q.length);const after=label.slice(idx+q.length);li.innerHTML="";if(before)li.appendChild(document.createTextNode(before));const mark=document.createElement("mark");mark.className="c-combobox__match";mark.textContent=match;li.appendChild(mark);if(after)li.appendChild(document.createTextNode(after))}else{li.textContent=label}const isSelected=this.hasAttribute("multiple")&&selectedVals.includes(String(item.value));li.setAttribute("aria-selected",String(isSelected));if(isSelected)li.classList.add("c-combobox__option--selected");list.appendChild(li)});if(this._comboboxVirtual)addSpacer(Math.max(0,filtered.length-end)*rowHeight);if(this._comboboxVirtual&&!reset)list.scrollTop=oldScrollTop}enhance(){wireCombobox(this);if(this._internals&&!this._wiredComboboxForm){this._wiredComboboxForm=true;this._syncFormValue();this.addEventListener("contour:select",(e)=>{const v=e&&e.detail&&(e.detail.value||e.detail.label);if(v!=null)this.setAttribute("value",String(v));this._syncFormValue()})}if(!this._wiredComboboxClear){this._wiredComboboxClear=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-combobox__clear"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.removeAttribute("value");const input=this.querySelector(".c-combobox__input");if(input)input.value="";this._syncFormValue();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{name:this.getAttribute("name"),value:null,checked:null}}))})}}}define("contour-combobox",ContourCombobox);class ContourField extends ContourBase{static get observed(){return["label","hint","error","placeholder","type","required"]}static get formAssociated(){return true}static get properties(){return{label:{attribute:"label"},hint:{attribute:"hint"},error:{attribute:"error"},placeholder:{attribute:"placeholder"},type:{attribute:"type"},required:{attribute:"required",type:Boolean}}}render(){this.classList.add("c-field");const label=this.getAttribute("label");const hint=this.getAttribute("hint");const error=this.getAttribute("error");const placeholder=this.getAttribute("placeholder")||"";if(label){const lbl=this.ensure(".c-field__label",()=>{const el=document.createElement("label");el.className="c-field__label";return el});lbl.textContent=label}else{const lbl=this.querySelector(".c-field__label");if(lbl)lbl.remove()}const input=this.ensure("input.c-input, textarea, select",()=>{const el=document.createElement("input");el.className="c-input";return el});input.type=this.getAttribute("type")||"text";input.placeholder=placeholder;if(!input.id)input.id=contourId("contour-field");const lbl=this.querySelector(".c-field__label");if(lbl){if(!input.id)input.id=contourId("contour-field");lbl.setAttribute("for",input.id);input.setAttribute("aria-label",lbl.textContent)}if(hint){const h=this.ensure(".c-field__hint",()=>{const el=document.createElement("span");el.className="c-field__hint";return el});h.textContent=hint}else{const h=this.querySelector(".c-field__hint");if(h)h.remove()}if(error){const e=this.ensure(".c-field__error",()=>{const el=document.createElement("span");el.className="c-field__error";return el});e.textContent=error}else{const e=this.querySelector(".c-field__error");if(e)e.remove()}const hintEl=this.querySelector(".c-field__hint");const errEl=this.querySelector(".c-field__error");const describedBy=[];if(hintEl){if(!hintEl.id)hintEl.id=contourId("hint");describedBy.push(hintEl.id)}if(errEl){if(!errEl.id)errEl.id=contourId("err");describedBy.push(errEl.id)}if(describedBy.length)input.setAttribute("aria-describedby",describedBy.join(" "));if(this.hasAttribute("required"))input.setAttribute("aria-required","true")}}ContourField.prototype.enhance=function(){if(this._wiredField)return;this._wiredField=true;const sync=()=>{const input=this.querySelector("input, textarea, select");if(!input||!this._internals)return;this._internals.setFormValue(input.value)};this.addEventListener("input",(e)=>{const input=this.querySelector("input, textarea, select");if(!input||e.target!==input)return;sync();this._emitForm("contour:input")});this.addEventListener("change",(e)=>{const input=this.querySelector("input, textarea, select");if(!input||e.target!==input)return;sync();this._emitForm("contour:change")});this.addEventListener("blur",(e)=>{const input=this.querySelector("input, textarea, select");if(!input||e.target!==input)return;const valid=input.checkValidity();if(valid){input.setAttribute("aria-invalid","false");this.classList.remove("is-invalid");this.removeAttribute("data-invalid")}else{input.setAttribute("aria-invalid","true");this.classList.add("is-invalid");this.setAttribute("data-invalid","");if(!this.getAttribute("error")){const msg=input.validationMessage||"Invalid value";let errEl=this.querySelector(".c-field__error");if(!errEl){errEl=document.createElement("span");errEl.className="c-field__error";this.appendChild(errEl)}errEl.textContent=msg;if(!errEl.id)errEl.id=contourId("err");input.setAttribute("aria-describedby",(input.getAttribute("aria-describedby")||"").split(" ").filter((x)=>x&&x!==errEl.id).concat(errEl.id).join(" "))}}sync()},true);sync()};define("contour-field",ContourField);class ContourFieldGroup extends ContourBase{static get observed(){return["label","hint","error","required"]}static get properties(){return{label:{attribute:"label"},hint:{attribute:"hint"},error:{attribute:"error"},required:{attribute:"required",type:Boolean}}}render(){this.classList.add("c-field-group");this.setAttribute("role","group");const label=this.getAttribute("label");if(label){const lbl=this.ensure(".c-field-group__label",()=>{const el=document.createElement("div");el.className="c-field-group__label";return el});lbl.textContent=label}else{const lbl=this.querySelector(".c-field-group__label");if(lbl)lbl.remove()}const hint=this.getAttribute("hint");if(hint){const h=this.ensure(".c-field-group__hint",()=>{const el=document.createElement("span");el.className="c-field-group__hint";return el});h.textContent=hint}else{const h=this.querySelector(".c-field-group__hint");if(h)h.remove()}const error=this.getAttribute("error");if(error){const e=this.ensure(".c-field-group__error",()=>{const el=document.createElement("span");el.className="c-field-group__error";return el});e.textContent=error}else{const e=this.querySelector(".c-field-group__error");if(e)e.remove()}if(error)this.classList.add("is-error");else this.classList.remove("is-error");if(this.hasAttribute("required"))this.setAttribute("aria-required","true");else this.removeAttribute("aria-required")}enhance(){if(this._wiredFieldGroup)return;this._wiredFieldGroup=true}}define("contour-field-group",ContourFieldGroup);class ContourForm extends ContourBase{static get observed(){return["submitting","error","summary"]}static get properties(){return{submitting:{attribute:"submitting",type:Boolean},error:{attribute:"error"},summary:{attribute:"summary"}}}render(){this.classList.add("c-form");if(this.hasAttribute("submitting"))this.classList.add("is-submitting");else this.classList.remove("is-submitting");const summaryText=this.getAttribute("summary")||this.getAttribute("error");let summary=this.querySelector(".c-form__summary");if(summaryText){if(!summary){summary=document.createElement("div");summary.className="c-form__summary";summary.setAttribute("role","alert");this.prepend(summary)}summary.textContent=summaryText;summary.removeAttribute("hidden")}else if(summary){summary.setAttribute("hidden","")}const submit=this.querySelector("[type='submit'], .c-form__submit");if(submit){if(this.hasAttribute("submitting"))submit.setAttribute("disabled","");else submit.removeAttribute("disabled")}}enhance(){if(this._wiredForm)return;this._wiredForm=true;this.addEventListener("submit",(e)=>{const form=e.target;if(form&&typeof form.checkValidity==="function"&&!form.checkValidity()){e.preventDefault();const invalid=Array.from(form.querySelectorAll(":invalid"));const names=invalid.map((el)=>el.getAttribute("aria-label")||el.name||el.id||"field").join(", ");let summary=this.querySelector(".c-form__summary");if(!summary){summary=document.createElement("div");summary.className="c-form__summary";summary.setAttribute("role","alert");this.prepend(summary)}summary.textContent="Please fix: "+(names||"invalid fields");summary.removeAttribute("hidden");return}this.classList.add("is-submitting");const submit=this.querySelector("[type='submit'], .c-form__submit");if(submit)submit.setAttribute("disabled","");this.dispatchEvent(new CustomEvent("contour:submit",{bubbles:true,composed:true,detail:{submitting:true}}))})}}define("contour-form",ContourForm);class ContourRange extends ContourBase{static get observed(){return["min","max","value","low","high","range","sparkline","label","disabled","error","help"]}static get formAssociated(){return true}static get properties(){return{min:{attribute:"min"},max:{attribute:"max"},value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-range");const min=this.getAttribute("min")||"0";const max=this.getAttribute("max")||"100";const rangeMode=this.hasAttribute("range")||this.hasAttribute("low")||this.hasAttribute("high");const spark=this.getAttribute("sparkline");if(spark){let canvas=this.querySelector(".c-range__sparkline");if(!canvas){canvas=document.createElement("canvas");canvas.className="c-range__sparkline";canvas.setAttribute("part","sparkline-canvas");this.insertBefore(canvas,this.firstChild)}}else{const c=this.querySelector(".c-range__sparkline");if(c)c.remove()}if(rangeMode){const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");let lowInput=this.querySelector("input.c-range__low");if(!lowInput){lowInput=document.createElement("input");lowInput.type="range";lowInput.className="c-range c-range__low";this.appendChild(lowInput)}let highInput=this.querySelector("input.c-range__high");if(!highInput){highInput=document.createElement("input");highInput.type="range";highInput.className="c-range c-range__high";this.appendChild(highInput)}lowInput.min=min;lowInput.max=max;highInput.min=min;highInput.max=max;const lowVal=this.getAttribute("low")||min;const highVal=this.getAttribute("high")||max;if(this._rangeUserLow!==null&&this._rangeAttrLowAtDirty===(this.getAttribute("low")||min))lowInput.value=this._rangeUserLow;else{lowInput.value=lowVal;this._rangeUserLow=null;this._rangeAttrLowAtDirty=null}if(this._rangeUserHigh!==null&&this._rangeAttrHighAtDirty===(this.getAttribute("high")||max))highInput.value=this._rangeUserHigh;else{highInput.value=highVal;this._rangeUserHigh=null;this._rangeAttrHighAtDirty=null}const label=this.getAttribute("label");if(label){lowInput.setAttribute("aria-label",label+" low");highInput.setAttribute("aria-label",label+" high")}}else{Array.from(this.querySelectorAll("input.c-range__low, input.c-range__high")).forEach((n)=>n.remove());const input=this.ensure("input.c-range",()=>{const el=document.createElement("input");el.type="range";return el});input.className="c-range";input.type="range";input.min=min;input.max=max;const attrVal=this.getAttribute("value")||"50";if(this._rangeUserValue!==null&&this._rangeAttrAtDirty===(this.getAttribute("value")||"50")){input.value=this._rangeUserValue}else{input.value=attrVal;this._rangeUserValue=null;this._rangeAttrAtDirty=null}const label=this.getAttribute("label");if(label)input.setAttribute("aria-label",label);else if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label","Range");const updateFill=()=>{const mn=Number(input.min)||0;const mx=Number(input.max)||100;const val=Number(input.value)||0;const pct=mx>mn?((val-mn)/(mx-mn))*100:0;input.style.setProperty("--fill",pct+"%")};updateFill();if(!input._fillWired){input._fillWired=true;input.addEventListener("input",updateFill)}}}}const _origRangeRender=ContourRange.prototype.render;ContourRange.prototype.attributeChangedCallback=function(name,oldValue,newValue){if(name==="value"){this._rangeUserValue=null;this._rangeAttrAtDirty=null}if(name==="low"){this._rangeUserLow=null;this._rangeAttrLowAtDirty=null}if(name==="high"){this._rangeUserHigh=null;this._rangeAttrHighAtDirty=null}return ContourBase.prototype.attributeChangedCallback.call(this,name,oldValue,newValue)};ContourRange.prototype.enhance=function(){if(this._wiredRange)return;this._wiredRange=true;const sync=()=>{const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(this._internals){if(low&&high)this._internals.setFormValue(low.value+","+high.value);else if(single)this._internals.setFormValue(single.value)}};this.addEventListener("input",(e)=>{const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(low&&high&&(e.target===low||e.target===high)){this._rangeUserLow=low.value;this._rangeUserHigh=high.value;this._rangeAttrLowAtDirty=this.getAttribute("low")||(this.getAttribute("min")||"0");this._rangeAttrHighAtDirty=this.getAttribute("high")||(this.getAttribute("max")||"100");sync();this._emitForm("contour:input",{low:Number(low.value),high:Number(high.value)});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{low:Number(low.value),high:Number(high.value)}}))}else if(single&&e.target===single){this._rangeUserValue=single.value;this._rangeAttrAtDirty=this.getAttribute("value")||"50";sync();this._emitForm("contour:input")}});this.addEventListener("change",(e)=>{const low=this.querySelector("input.c-range__low");const high=this.querySelector("input.c-range__high");const single=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");if(low&&high&&(e.target===low||e.target===high)){sync();this._emitForm("contour:change",{low:Number(low.value),high:Number(high.value)});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{low:Number(low.value),high:Number(high.value)}}))}else if(single&&e.target===single){sync();this._emitForm("contour:change")}});sync()};define("contour-range",ContourRange);class ContourSwitch extends ContourBase{static get observed(){return["label","required","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},required:{attribute:"required",type:Boolean},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-switch");const label=this.getAttribute("label");const input=this.ensure("input.c-switch__input",()=>{const el=document.createElement("input");el.className="c-switch__input";el.type="checkbox";return el});input.checked=this.hasAttribute("checked");input.setAttribute("role","switch");input.setAttribute("aria-checked",String(input.checked));this._setCustomState("data-checked",input.checked);if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-switch__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-switch__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-switch__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");if(!input.nextElementSibling||!input.nextElementSibling.classList.contains("c-switch__track")){const track=document.createElement("span");track.className="c-switch__track";track.setAttribute("aria-hidden","true");if(input.nextSibling)this.insertBefore(track,input.nextSibling);else this.appendChild(track)}if(label){input.setAttribute("aria-label",label);const txt=this.querySelector(":scope > span:not([class]):not(.c-switch__track)")||(()=>{const el=document.createElement("span");this.appendChild(el);return el})();txt.textContent=label}}enhance(){const input=this.querySelector("input");if(input&&this._internals){input.setAttribute("aria-checked",String(input.checked));this._setCustomState("data-checked",input.checked);this._internals.setFormValue(input.checked?(input.value||"on"):null);this._syncValidity(this.hasAttribute("required")&&!input.checked)}if(this._wiredSwitch)return;this._wiredSwitch=true;this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;inp.setAttribute("aria-checked",String(inp.checked));this._setCustomState("data-checked",inp.checked);this._internals.setFormValue(inp.checked?(inp.value||"on"):null);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.checked)})}}define("contour-switch",ContourSwitch);class ContourCheck extends ContourBase{static get observed(){return["label","name","value","required","type","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},name:{attribute:"name"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},type:{attribute:"type"},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-check");const label=this.getAttribute("label");const input=this.ensure("input.c-check__input",()=>{const el=document.createElement("input");el.className="c-check__input";el.type=this.getAttribute("type")==="radio"?"radio":"checkbox";return el});input.checked=this.hasAttribute("checked");if(!input.nextElementSibling||!input.nextElementSibling.classList.contains("c-check__box")){const box=document.createElement("span");box.className="c-check__box";box.setAttribute("aria-hidden","true");if(input.nextSibling)this.insertBefore(box,input.nextSibling);else this.appendChild(box)}if(label){input.setAttribute("aria-label",label);const txt=this.querySelector(":scope > span:not([class]):not(.c-check__box)")||(()=>{const el=document.createElement("span");this.appendChild(el);return el})();txt.textContent=label}if(this.hasAttribute("name"))input.name=this.getAttribute("name");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-check__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-check__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-check__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._setCustomState("data-checked",input.checked);this._internals.setFormValue(input.checked?(input.value||"on"):null);this._syncValidity(this.hasAttribute("required")&&!input.checked)}if(this._wiredCheck)return;this._wiredCheck=true;this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._setCustomState("data-checked",inp.checked);this._internals.setFormValue(inp.checked?(inp.value||"on"):null);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.checked)})}}define("contour-check",ContourCheck);class ContourRadio extends ContourBase{static get observed(){return["label","name","value","required","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},name:{attribute:"name"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-radio");const label=this.getAttribute("label");const input=this.ensure("input.c-radio__input",()=>{const el=document.createElement("input");el.className="c-radio__input";el.type="radio";return el});input.checked=this.hasAttribute("checked");if(this.hasAttribute("name"))input.name=this.getAttribute("name");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-radio__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-radio__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-radio__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");if(label){input.setAttribute("aria-label",label);const txt=this.querySelector(":scope > span:not([class])")||(()=>{const el=document.createElement("span");this.appendChild(el);return el})();txt.textContent=label}}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._setCustomState("data-checked",input.checked);this._internals.setFormValue(input.checked?(input.value||"on"):null);this._syncValidity(this.hasAttribute("required")&&!input.checked)}if(this._wiredRadio)return;this._wiredRadio=true;this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._setCustomState("data-checked",inp.checked);this._internals.setFormValue(inp.checked?(inp.value||"on"):null);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.checked)})}}define("contour-radio",ContourRadio);class ContourSelect extends ContourBase{static get observed(){return["options","required","label","placeholder","disabled","error","help"]}static get properties(){return{options:{attribute:"options"},required:{attribute:"required",type:Boolean},label:{attribute:"label"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){this.classList.add("c-select");const options=this.getAttribute("options");const generated=new Set(this._contourGenerated||[]);const authored=Array.from(this.children).filter((n)=>!generated.has(n));if(options&&!authored.length){try{const parsed=JSON.parse(options);const select=this.ensure("select.c-select",()=>{const el=document.createElement("select");el.className="c-select";return el});select.innerHTML="";const label=this.getAttribute("label");if(label){select.setAttribute("aria-label",label)}const placeholder=this.getAttribute("placeholder");if(placeholder){const ph=document.createElement("option");ph.value="";ph.textContent=placeholder;ph.disabled=true;ph.selected=true;select.appendChild(ph)}const groups={};parsed.forEach((opt)=>{const g=(typeof opt==="object"&&opt!==null)?opt.group:null;if(g){if(!groups[g]){groups[g]=document.createElement("optgroup");groups[g].label=g;select.appendChild(groups[g])}const option=document.createElement("option");option.value=typeof opt==="string"?opt:opt.value;option.textContent=typeof opt==="string"?opt:opt.label;groups[g].appendChild(option)}else{const option=document.createElement("option");option.value=typeof opt==="string"?opt:opt.value;option.textContent=typeof opt==="string"?opt:opt.label;select.appendChild(option)}});if(select.parentNode!==this)this.appendChild(select);this.classList.remove("c-select");select.classList.add("c-select")}catch(e){}}const authoredSel=this.querySelector("select");if(authoredSel&&!authoredSel.classList.contains("c-select")){authoredSel.classList.add("c-select");this.classList.remove("c-select")}const sel=this.querySelector("select");if(sel){if(this.hasAttribute("disabled")){sel.setAttribute("disabled","");this.classList.add("is-disabled")}else{sel.removeAttribute("disabled");this.classList.remove("is-disabled")}}const label=this.getAttribute("label");if(label){let lbl=this.querySelector("label.c-select__label");if(!lbl){lbl=document.createElement("label");lbl.className="c-select__label";this.insertBefore(lbl,sel||this.firstChild)}lbl.textContent=label;if(sel)sel.setAttribute("aria-label",label)}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-select__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-select__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-select__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const select=this.querySelector("select");if(select&&this._internals){this._internals.setFormValue(select.value);this._syncValidity(this.hasAttribute("required")&&!select.value)}if(this._wiredSelect)return;this._wiredSelect=true;this.addEventListener("change",(e)=>{const sel=this.querySelector("select");if(!sel||e.target!==sel||!this._internals)return;this._internals.setFormValue(sel.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!sel.value)})}}define("contour-select",ContourSelect);class ContourVersion extends ContourBase{static get observed(){return["options"]}static get formAssociated(){return true}static get properties(){return{options:{attribute:"options"}}}render(){this.classList.add("c-version");const options=this.getAttribute("options");const generated=new Set(this._contourGenerated||[]);const authored=Array.from(this.children).filter((n)=>!generated.has(n));if(options&&!authored.length){try{const parsed=JSON.parse(options);const select=this.ensure("select.c-version",()=>{const el=document.createElement("select");el.className="c-version";return el});select.innerHTML="";if(!select.hasAttribute("aria-label"))select.setAttribute("aria-label","Version");parsed.forEach((opt)=>{const option=document.createElement("option");if(typeof opt==="string"){option.value=opt;option.textContent=opt}else{option.value=opt.value||opt.label;option.textContent=opt.label||opt.value;if(opt.selected)option.selected=true}select.appendChild(option)});if(select.parentNode!==this)this.appendChild(select);this.classList.remove("c-version");select.classList.add("c-version")}catch(e){}}}enhance(){if(this._wiredVersion)return;this._wiredVersion=true;const sync=()=>{const select=this.querySelector("select");if(!select||!this._internals)return;this._internals.setFormValue(select.value)};this.addEventListener("change",(e)=>{const select=this.querySelector("select");if(!select||e.target!==select)return;sync();this._emitForm("contour:change")});sync()}}define("contour-version",ContourVersion);class ContourTextarea extends ContourBase{static get observed(){return["placeholder","required","disabled","error","help"]}static get properties(){return{placeholder:{attribute:"placeholder"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return true}render(){const ta=this.ensure("textarea",()=>{const el=document.createElement("textarea");el.className="c-textarea";return el});ta.className="c-textarea";ta.placeholder=this.getAttribute("placeholder")||"";if(this.hasAttribute("required"))ta.setAttribute("required","");else ta.removeAttribute("required");if(this.hasAttribute("disabled")){ta.setAttribute("disabled","");this.classList.add("is-disabled")}else{ta.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-textarea__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-textarea__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-textarea__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const ta=this.querySelector("textarea");if(ta&&this._internals){this._internals.setFormValue(ta.value);this._syncValidity(this.hasAttribute("required")&&!ta.value.trim())}if(this._wiredTextarea)return;this._wiredTextarea=true;this.addEventListener("input",(e)=>{const t=this.querySelector("textarea");if(!t||e.target!==t||!this._internals)return;this._internals.setFormValue(t.value);this._emitForm("contour:input");this._syncValidity(this.hasAttribute("required")&&!t.value.trim())});this.addEventListener("change",(e)=>{const t=this.querySelector("textarea");if(!t||e.target!==t||!this._internals)return;this._internals.setFormValue(t.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!t.value.trim())})}}define("contour-textarea",ContourTextarea);class ContourInputFull extends ContourBase{static get observed(){return["type","placeholder","required","value","disabled","error","help","label"]}static get properties(){return{type:{attribute:"type"},placeholder:{attribute:"placeholder"},required:{attribute:"required",type:Boolean},value:{attribute:"value"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},label:{attribute:"label"}}}static get formAssociated(){return true}render(){this.classList.add("c-input");const input=this.ensure("input",()=>{const el=document.createElement("input");el.className="c-input";return el});input.className="c-input";input.type=this.getAttribute("type")||"text";input.placeholder=this.getAttribute("placeholder")||"";let label=this.getAttribute("label");if(!label){const field=this.closest("contour-field");if(field)label=field.getAttribute("label")}if(label)input.setAttribute("aria-label",label);else if(!input.getAttribute("aria-label"))input.setAttribute("aria-label","Input");if(this.hasAttribute("value"))input.value=this.getAttribute("value");if(this.hasAttribute("required"))input.setAttribute("required","");else input.removeAttribute("required");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-input__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-input__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-input__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error")}enhance(){const input=this.querySelector("input");if(input&&this._internals){this._internals.setFormValue(input.value);this._syncValidity(this.hasAttribute("required")&&!input.value.trim())}if(this._wiredInput)return;this._wiredInput=true;this.addEventListener("input",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._internals.setFormValue(inp.value);this._emitForm("contour:input");this._syncValidity(this.hasAttribute("required")&&!inp.value.trim())});this.addEventListener("change",(e)=>{const inp=this.querySelector("input");if(!inp||e.target!==inp||!this._internals)return;this._internals.setFormValue(inp.value);this._emitForm("contour:change");this._syncValidity(this.hasAttribute("required")&&!inp.value.trim())})}}define("contour-input",ContourInputFull);class ContourInputGroup extends ContourBase{static get observed(){return["label","placeholder","clearable","submit"]}static get properties(){return{label:{attribute:"label"},placeholder:{attribute:"placeholder"},clearable:{attribute:"clearable",type:Boolean},submit:{attribute:"submit",type:Boolean}}}render(){this.classList.add("c-input-group");const icon=this.ensure("svg",()=>{const el=document.createElementNS("http://www.w3.org/2000/svg","svg");el.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#i-search");el.appendChild(use);return el});const input=this.ensure("input.c-input",()=>{const el=document.createElement("input");el.className="c-input";el.type="text";return el});input.placeholder=this.getAttribute("placeholder")||this.getAttribute("label")||"";const oldClear=this.querySelector(".c-input-group__clear");if(oldClear)oldClear.remove();if(this.hasAttribute("clearable")){const btn=document.createElement("button");btn.className="c-input-group__clear";btn.type="button";btn.setAttribute("aria-label","Clear");btn.textContent="×";this.appendChild(btn)}const oldSubmit=this.querySelector(".c-input-group__submit");if(oldSubmit)oldSubmit.remove();if(this.hasAttribute("submit")){const btn=document.createElement("button");btn.className="c-input-group__submit";btn.type="submit";btn.setAttribute("aria-label","Submit");btn.textContent="→";this.appendChild(btn)}}enhance(){if(this._wiredInputGroup)return;this._wiredInputGroup=true;this.addEventListener("click",(e)=>{const clear=e.target&&e.target.closest?e.target.closest(".c-input-group__clear"):null;if(clear&&this.contains(clear)){e.preventDefault();const input=this.querySelector("input.c-input");if(input){input.value="";input.focus()}this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:""}}))}})}}define("contour-input-group",ContourInputGroup);class ContourRadioList extends ContourBase{static get observed(){return["items","name","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},name:{attribute:"name"},src:{attribute:"src"}}}static get formAssociated(){return true}render(){this.classList.add("c-radio-list");this.setAttribute("role","radiogroup");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("name")||"Options");wireStates(this);loadRemote(this,"items");if(renderStates(this,"radio-list"))return;const items=remoteData(this,"items");Array.from(this.querySelectorAll("label.c-radio")).forEach((l)=>l.remove());if(items){try{const parsed=JSON.parse(items);const groupName=this.getAttribute("name")||contourId("radio-list");parsed.forEach((it)=>{const lbl=document.createElement("label");lbl.className="c-radio";const input=document.createElement("input");input.type="radio";input.className="c-radio__input";input.name=groupName;input.tabIndex=-1;if(typeof it==="string"){input.value=it;lbl.appendChild(input);lbl.appendChild(document.createTextNode(" "+it))}else{input.value=it.value||it.label;if(it.checked)input.checked=true;lbl.appendChild(input);const span=document.createElement("span");span.textContent=it.label||it.value;lbl.appendChild(span)}this.appendChild(lbl)});const radios=Array.from(this.querySelectorAll("input.c-radio__input"));const checked=radios.find((r)=>r.checked)||radios[0];if(checked)checked.tabIndex=0}catch(e){}}else{renderEmpty(this,"radio-list")}}enhance(){const sync=()=>{if(!this._internals)return;const checked=this.querySelector("input.c-radio__input:checked");this._internals.setFormValue(checked?checked.value:null)};sync();if(this._wiredRadioList)return;this._wiredRadioList=true;this.addEventListener("change",(e)=>{const input=e.target&&e.target.closest?e.target.closest("input.c-radio__input"):null;if(!input||!this.contains(input))return;sync();this._emitForm("contour:change")});this.addEventListener("keydown",(e)=>{const radios=Array.from(this.querySelectorAll("input.c-radio__input"));if(!radios.length)return;const idx=radios.indexOf(e.target);if(idx===-1)return;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";let next=-1;if(e.key==="ArrowDown")next=(idx+1)%radios.length;else if(e.key==="ArrowUp")next=(idx-1+radios.length)%radios.length;else if(e.key==="ArrowRight")next=rtl?(idx-1+radios.length)%radios.length:(idx+1)%radios.length;else if(e.key==="ArrowLeft")next=rtl?(idx+1)%radios.length:(idx-1+radios.length)%radios.length;else if(e.key==="Home")next=0;else if(e.key==="End")next=radios.length-1;else return;e.preventDefault();const before=radios.find((r)=>r.checked);for(const r of radios)r.tabIndex=-1;radios[next].tabIndex=0;radios[next].checked=true;radios[next].focus();sync();if(before!==radios[next])this._emitForm("contour:change")})}formResetCallback(){if(this._contourAuthored)this.requestRender()}}define("contour-radio-list",ContourRadioList);class ContourPressableFull extends ContourBase{static get observed(){return["disabled"]}static get properties(){return{disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-pressable");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.hasAttribute("disabled")){this.setAttribute("aria-disabled","true");this.setAttribute("tabindex","-1")}else{this.removeAttribute("aria-disabled");if(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")==="-1")this.setAttribute("tabindex","0")}}enhance(){if(this._wiredPressable)return;this._wiredPressable=true;this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-pressable",ContourPressableFull);class ContourResizeHandleFull extends ContourBase{render(){this.classList.add("c-resize-handle");if(!this.hasAttribute("role"))this.setAttribute("role","separator");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Resize handle");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal")}}define("contour-resize-handle",ContourResizeHandleFull);class ContourSearchTriggerFull extends ContourBase{static get observed(){return["label","shortcut"]}static get properties(){return{label:{attribute:"label"},shortcut:{attribute:"shortcut"}}}render(){this.classList.add("c-search-trigger");const label=this.getAttribute("label")||"Search";if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);const span=this.ensure(".c-search-trigger__text",()=>{const el=document.createElement("span");el.className="c-search-trigger__text";return el});span.className="c-search-trigger__text";if(!span.textContent.trim()||span.textContent.trim()!==label)span.textContent=label;const kbd=this.ensure("kbd.c-search-trigger__kbd",()=>{const el=document.createElement("kbd");el.className="c-search-trigger__kbd";return el});kbd.className="c-search-trigger__kbd";kbd.textContent=this.getAttribute("shortcut")||"⌘K"}}define("contour-search-trigger",ContourSearchTriggerFull);class ContourShortcutListFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-shortcut-list");this.setAttribute("role","list");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-shortcut-list__title",()=>{const el=document.createElement("div");el.className="c-shortcut-list__title";el.style.padding="var(--space-sm)";el.style.fontWeight="var(--weight-semibold)";return el});t.textContent=title}}}define("contour-shortcut-list",ContourShortcutListFull);class ContourShortcutRowFull extends ContourBase{static get observed(){return["desc","key"]}static get properties(){return{desc:{attribute:"desc"},key:{attribute:"key"}}}render(){this.classList.add("c-shortcut-row");this.setAttribute("role","listitem");const key=this.getAttribute("key");const desc=this.getAttribute("desc");if(key){const k=this.ensure(".c-shortcut-row__keys",()=>{const el=document.createElement("kbd");el.className="c-shortcut-row__keys";return el});k.className="c-shortcut-row__keys";k.textContent=key}else{const k=this.querySelector(".c-shortcut-row__keys");if(k)k.remove()}if(desc){const s=this.ensure(".c-shortcut-row__label",()=>{const el=document.createElement("span");el.className="c-shortcut-row__label";return el});s.className="c-shortcut-row__label";s.textContent=desc}else{const s=this.querySelector(".c-shortcut-row__label");if(s)s.remove()}}}define("contour-shortcut-row",ContourShortcutRowFull);class ContourShortcutPanelFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-shortcut-panel");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-shortcut-panel__title",()=>{const el=document.createElement("div");el.className="c-shortcut-panel__title";return el});t.textContent=title}else{const t=this.querySelector(".c-shortcut-panel__title");if(t)t.remove()}}}define("contour-shortcut-panel",ContourShortcutPanelFull);class ContourShortcutOverlayFull extends ContourBase{static get observed(){return["title","open"]}static get properties(){return{title:{attribute:"title"},open:{attribute:"open",type:Boolean}}}render(){this.classList.add("c-shortcut-overlay");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-shortcut-overlay__title",()=>{const el=document.createElement("div");el.className="c-shortcut-overlay__title";return el});t.textContent=title}if(this.hasAttribute("open"))this.removeAttribute("hidden");else if(!this.hasAttribute("hidden"))this.setAttribute("hidden","")}show(){this.setAttribute("open","");this.removeAttribute("hidden");this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))}hide(){this.removeAttribute("open");this.setAttribute("hidden","");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}toggle(){if(this.hasAttribute("open"))this.hide();else this.show()}enhance(){if(this._wiredShortcutOverlay)return;this._wiredShortcutOverlay=true;const keyHandler=(e)=>{if(e.key==="?"&&!e.metaKey&&!e.ctrlKey&&!e.altKey){const tag=(e.target&&e.target.tagName)||"";if(tag==="INPUT"||tag==="TEXTAREA"||(e.target&&e.target.isContentEditable))return;e.preventDefault();this.toggle()}else if(e.key==="Escape"&&this.hasAttribute("open")){this.hide()}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{if(e.target===this)this.hide()})}}define("contour-shortcut-overlay",ContourShortcutOverlayFull);class ContourRowActionFull extends ContourBase{static get observed(){return["label","disabled"]}static get properties(){return{label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-row-action");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.hasAttribute("disabled")){this.setAttribute("aria-disabled","true");this.setAttribute("tabindex","-1")}else{this.removeAttribute("aria-disabled");if(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")==="-1")this.setAttribute("tabindex","0")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label}enhance(){if(this._wiredRowAction)return;this._wiredRowAction=true;this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-row-action",ContourRowActionFull);class ContourSegmented extends ContourBase{static get observed(){return["options","selected","label","value"]}static get properties(){return{options:{attribute:"options"},selected:{attribute:"selected"},label:{attribute:"label"},value:{attribute:"value"}}}render(){this.classList.add("c-segmented");const options=this.getAttribute("options");if(options){let parsed=null;try{parsed=JSON.parse(options)}catch(e){parsed=null}if(Array.isArray(parsed)){Array.from(this.querySelectorAll("button.c-segmented__option")).forEach((n)=>n.remove());const selected=this.getAttribute("selected")||this.getAttribute("value");parsed.forEach((opt,i)=>{const label=typeof opt==="string"?opt:(opt.label||opt.value||"");const val=typeof opt==="string"?opt:(opt.value||opt.label||"");const btn=document.createElement("button");btn.className="c-segmented__option";btn.type="button";btn.textContent=label;btn.dataset.value=val;if(selected!==null&&String(val)===String(selected))btn.setAttribute("aria-pressed","true");else if(selected===null&&i===0)btn.setAttribute("aria-pressed","true");else btn.setAttribute("aria-pressed","false");this.appendChild(btn)})}}}enhance(){wireSegmented(this)}}define("contour-segmented",ContourSegmented);class ContourDraggable extends ContourBase{render(){this.classList.add("c-draggable");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("draggable"))this.setAttribute("draggable","true")}_dragValue(){return this.getAttribute("value")||this.getAttribute("label")||(this.textContent||"").trim()||"draggable"}enhance(){if(this._wiredDraggable)return;this._wiredDraggable=true;this.addEventListener("dragstart",(e)=>{if(!e.dataTransfer)return;const value=this._dragValue();try{e.dataTransfer.effectAllowed="move"}catch(err){}e.dataTransfer.setData("text/plain",value);this.classList.add("c-draggable--dragging");this.dispatchEvent(new CustomEvent("contour:dragstart",{bubbles:true,composed:true,detail:{value}}))});this.addEventListener("dragend",()=>{this.classList.remove("c-draggable--dragging");this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:true,composed:true,detail:{value:this._dragValue()}}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}));return}if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:move",{bubbles:true,composed:true,detail:{direction:e.key==="ArrowUp"?"up":"down"}}))}})}}define("contour-draggable",ContourDraggable);class ContourDragHandle extends ContourBase{render(){this.classList.add("c-drag-handle");if(!this.hasAttribute("role"))this.setAttribute("role","separator");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal")}enhance(){if(this._wiredDragHandle)return;this._wiredDragHandle=true;this.addEventListener("keydown",(e)=>{let delta=0;if(e.key==="ArrowLeft"||e.key==="ArrowDown")delta=-1;else if(e.key==="ArrowRight"||e.key==="ArrowUp")delta=1;else if(e.key==="Home")delta=-Infinity;else if(e.key==="End")delta=Infinity;else return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:true,composed:true,detail:{key:e.key,delta}}))})}}define("contour-drag-handle",ContourDragHandle);class ContourDropIndicator extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-drop-indicator");this.classList.add("c-drop-indicator--visible");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE)n.remove();else if(n.nodeType===Node.ELEMENT_NODE&&n.tagName==="SPAN")n.remove()});const label=this.getAttribute("label");if(label){const t=this.ensure(".c-drop-indicator__label",()=>{const el=document.createElement("span");el.className="c-drop-indicator__label";return el});t.textContent=label}}}define("contour-drop-indicator",ContourDropIndicator);class ContourDropZone extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-drop-zone");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE)n.remove();else if(n.nodeType===Node.ELEMENT_NODE&&n.tagName==="SPAN")n.remove()});const label=this.getAttribute("label");if(label){const t=this.ensure(".c-drop-zone__label",()=>{const el=document.createElement("p");el.className="c-drop-zone__label";return el});t.textContent=label}}enhance(){if(this._wiredDropZone)return;this._wiredDropZone=true;const accepts=(e)=>e.dataTransfer&&Array.from(e.dataTransfer.types).includes("text/plain");const clear=()=>{this.classList.remove("c-drop-zone--active","c-drop-zone--reject")};this.addEventListener("dragenter",(e)=>{if(!e.dataTransfer)return;this.classList.toggle("c-drop-zone--reject",!accepts(e));if(accepts(e)){e.preventDefault();this.classList.add("c-drop-zone--active")}});this.addEventListener("dragover",(e)=>{if(!e.dataTransfer)return;this.classList.toggle("c-drop-zone--reject",!accepts(e));if(accepts(e)){e.preventDefault();this.classList.add("c-drop-zone--active")}});this.addEventListener("dragleave",clear);this.addEventListener("drop",(e)=>{if(!accepts(e))return;e.preventDefault();clear();const value=e.dataTransfer.getData("text/plain")||"";this.dispatchEvent(new CustomEvent("contour:drop",{bubbles:true,composed:true,detail:{value,label:this.getAttribute("label")}}))})}}define("contour-drop-zone",ContourDropZone);class ContourResizable extends ContourBase{static get observed(){return["direction","value"]}static get properties(){return{direction:{attribute:"direction"},value:{attribute:"value"}}}render(){this.classList.add("c-resizable");this.classList.remove("c-resizable--vertical","c-resizable--horizontal");const vertical=this.getAttribute("direction")==="vertical";this.classList.add(vertical?"c-resizable--vertical":"c-resizable--horizontal");if(!this.querySelector(".c-resizable__pane")){const p1=document.createElement("div");p1.className="c-resizable__pane";p1.textContent="Pane A";const handle=document.createElement("div");handle.className="c-resize-handle";handle.setAttribute("tabindex","0");handle.setAttribute("role","separator");const p2=document.createElement("div");p2.className="c-resizable__pane";p2.textContent="Pane B";this.appendChild(p1);this.appendChild(handle);this.appendChild(p2)}const v=this._splitValue||this.getAttribute("value");if(v){const p1=this.querySelector(".c-resizable__pane");if(p1)p1.style.flex=`0 0 ${v}%`}}enhance(){if(this._wiredResizable)return;this._wiredResizable=true;const setSplit=(clientX,clientY)=>{const rect=this.getBoundingClientRect();const vertical=this.classList.contains("c-resizable--vertical");const span=vertical?rect.height:rect.width;const pos=vertical?clientY-rect.top:clientX-rect.left;const frac=span>0?Math.min(0.9,Math.max(0.1,pos/span)):0.5;const p1=this.querySelector(".c-resizable__pane");if(p1)p1.style.flex=`0 0 ${Math.round(frac * 100)}%`;this._splitValue=String(Math.round(frac*100))};this.addEventListener("pointerdown",(e)=>{const handle=this.querySelector(".c-resize-handle");if(!handle||e.target!==handle)return;this._resizing=true;handle.classList.add("c-resize-handle--dragging");if(handle.setPointerCapture){try{handle.setPointerCapture(e.pointerId)}catch(err){}}e.preventDefault()});this.addEventListener("pointermove",(e)=>{if(!this._resizing)return;setSplit(e.clientX,e.clientY)});const stopResize=(e)=>{if(!this._resizing)return;this._resizing=false;if(this._splitValue){this.setAttribute("value",this._splitValue);this._splitValue=null}const handle=this.querySelector(".c-resize-handle");if(handle){handle.classList.remove("c-resize-handle--dragging");if(handle.hasPointerCapture&&handle.hasPointerCapture(e.pointerId)){try{handle.releasePointerCapture(e.pointerId)}catch(err){}}}};this.addEventListener("pointerup",stopResize);this.addEventListener("pointercancel",stopResize);this.addEventListener("keydown",(e)=>{const handle=this.querySelector(".c-resize-handle");if(!handle||document.activeElement!==handle)return;const vertical=this.classList.contains("c-resizable--vertical");const cur=parseFloat(this.getAttribute("value"))||50;if(e.key==="ArrowLeft"||e.key==="ArrowDown"){e.preventDefault();setSplit&&setSplit;const p1=this.querySelector(".c-resizable__pane");if(p1){const nv=Math.max(10,cur-5);p1.style.flex=`0 0 ${nv}%`;this.setAttribute("value",String(nv))}}else if(e.key==="ArrowRight"||e.key==="ArrowUp"){e.preventDefault();const p1=this.querySelector(".c-resizable__pane");if(p1){const nv=Math.min(90,cur+5);p1.style.flex=`0 0 ${nv}%`;this.setAttribute("value",String(nv))}}})}}define("contour-resizable",ContourResizable);class ContourTableWrap extends ContourBase{static get observed(){return[]}static get properties(){return{}}render(){this.classList.add("c-table-wrap");Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===Node.TEXT_NODE)n.remove();else if(n.nodeType===Node.ELEMENT_NODE&&n.tagName==="SPAN")n.remove()});if(!this.querySelector("table")){const t=document.createElement("table");t.className="c-table";const thead=document.createElement("thead");const tr=document.createElement("tr");for(const h of["A","B"]){const th=document.createElement("th");th.textContent=h;tr.appendChild(th)}thead.appendChild(tr);t.appendChild(thead);const tbody=document.createElement("tbody");const tr2=document.createElement("tr");for(const v of["1","2"]){const td=document.createElement("td");td.textContent=v;tr2.appendChild(td)}tbody.appendChild(tr2);t.appendChild(tbody);this.appendChild(t)}}}define("contour-table-wrap",ContourTableWrap);class ContourScrollArea extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-scroll-area");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-scroll-area__title",()=>{const el=document.createElement("div");el.className="c-scroll-area__title";el.style.padding="var(--space-sm)";el.style.fontWeight="var(--weight-semibold)";return el});t.textContent=title}}}define("contour-scroll-area",ContourScrollArea);class ContourBtn extends ContourBase{static get observed(){return["variant","size","color","label","disabled"]}static get properties(){return{variant:{attribute:"variant"},size:{attribute:"size"},color:{attribute:"color"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-btn");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-btn--"))this.classList.remove(c)});for(const attr of["variant","size","color"]){const val=this.getAttribute(attr);if(val)this.classList.add("c-btn--"+val)}if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.hasAttribute("disabled")){this.setAttribute("aria-disabled","true");this.setAttribute("tabindex","-1")}else{this.removeAttribute("aria-disabled");if(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")==="-1")this.setAttribute("tabindex","0")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label;if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label)}enhance(){if(this._wiredBtn)return;this._wiredBtn=true;this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.click();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-btn",ContourBtn);class ContourApp extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-app");const header=this.ensure(".c-app__header",()=>{const el=document.createElement("header");el.className="c-app__header";return el});const title=this.getAttribute("title");if(title){const t=this.ensure(".c-app__title",()=>{const el=document.createElement("div");el.className="c-app__title";return el});t.textContent=title;if(t.parentNode!==header)header.appendChild(t)}const main=this.ensure(".c-app__main",()=>{const el=document.createElement("main");el.className="c-app__main";return el});if(main.parentNode!==this)this.appendChild(main);if(header.parentNode!==this)this.insertBefore(header,main)}}define("contour-app",ContourApp);class ContourAppBody extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-app-body");const main=this.ensure(".c-app-body__main",()=>{const el=document.createElement("main");el.className="c-app-body__main";return el});const title=this.getAttribute("title");if(title){const t=this.ensure(".c-app-body__title",()=>{const el=document.createElement("div");el.className="c-app-body__title";return el});t.textContent=title;if(t.parentNode!==main)main.appendChild(t)}if(main.parentNode!==this)this.appendChild(main)}}define("contour-app-body",ContourAppBody);class ContourBtnGroup extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-btn-group");this.setAttribute("role","group");if(this.getAttribute("title"))this.setAttribute("aria-label",this.getAttribute("title"));if(!this.querySelector(".c-btn")){for(const lbl of["One","Two","Three"]){const b=document.createElement("button");b.className="c-btn c-btn--sm";b.type="button";b.textContent=lbl;this.appendChild(b)}}}enhance(){if(this._wiredBtnGroup)return;this._wiredBtnGroup=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-btn"):null;if(btn&&this.contains(btn)){const buttons=Array.from(this.querySelectorAll(".c-btn"));const index=buttons.indexOf(btn);this.dispatchEvent(new CustomEvent("contour:btn-group-change",{bubbles:true,composed:true,detail:{index,label:btn.textContent}}))}});this.addEventListener("keydown",(e)=>{const buttons=Array.from(this.querySelectorAll(".c-btn"));if(!buttons.length)return;const active=document.activeElement;const idx=buttons.indexOf(active);let next=-1;const rtl=(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowDown")next=idx<0?0:Math.min(buttons.length-1,idx+1);else if(e.key==="ArrowUp")next=idx<0?0:Math.max(0,idx-1);else if(e.key==="ArrowRight")next=rtl?(idx<0?0:Math.max(0,idx-1)):(idx<0?0:Math.min(buttons.length-1,idx+1));else if(e.key==="ArrowLeft")next=rtl?(idx<0?0:Math.min(buttons.length-1,idx+1)):(idx<0?0:Math.max(0,idx-1));else if(e.key==="Home")next=0;else if(e.key==="End")next=buttons.length-1;if(next>=0&&next!==idx){e.preventDefault();buttons[next].focus()}})}}define("contour-btn-group",ContourBtnGroup);class ContourRangeScale extends ContourBase{static get observed(){return["label","value","ticks"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},ticks:{attribute:"ticks"}}}render(){this.classList.add("c-range-scale");this.setAttribute("role","group");if(this.getAttribute("label"))this.setAttribute("aria-label",this.getAttribute("label"));const label=this.getAttribute("label");if(label){const t=this.ensure(".c-range-scale__label",()=>{const el=document.createElement("span");el.className="c-range-scale__label";return el});t.textContent=label}const ticksAttr=this.getAttribute("ticks");Array.from(this.querySelectorAll(".c-range-scale__tick")).forEach((n)=>n.remove());if(ticksAttr){ticksAttr.split(",").map((s)=>s.trim()).filter(Boolean).forEach((tk)=>{const t=document.createElement("span");t.className="c-range-scale__tick";t.textContent=tk;this.appendChild(t)})}}enhance(){if(this._wiredRangeScale)return;this._wiredRangeScale=true;this.addEventListener("input",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-range-scale",ContourRangeScale);class ContourTimeRange extends ContourBase{static get observed(){return["label","value","ticks"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},ticks:{attribute:"ticks"}}}render(){this.classList.add("c-time-range");this.setAttribute("role","group");if(this.getAttribute("label"))this.setAttribute("aria-label",this.getAttribute("label"));const label=this.getAttribute("label");if(label){const t=this.ensure(".c-time-range__label",()=>{const el=document.createElement("span");el.className="c-time-range__label";return el});t.textContent=label}const ticksAttr=this.getAttribute("ticks");Array.from(this.querySelectorAll(".c-time-range__tick")).forEach((n)=>n.remove());if(ticksAttr){ticksAttr.split(",").map((s)=>s.trim()).filter(Boolean).forEach((tk)=>{const t=document.createElement("span");t.className="c-time-range__tick";t.textContent=tk;this.appendChild(t)})}}enhance(){if(this._wiredTimeRange)return;this._wiredTimeRange=true;this.addEventListener("input",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:time-range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.matches&&t.matches("input")){this.dispatchEvent(new CustomEvent("contour:time-range-change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-time-range",ContourTimeRange);function wireMapItems(host,itemSelector,tooltipClass){if(host._wiredMapItems)return;host._wiredMapItems=true;const items=()=>Array.from(host.querySelectorAll(itemSelector));const showTip=(e)=>{const tip=host.querySelector(tooltipClass);if(!tip)return;const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(!item||!host.contains(item)){tip.setAttribute("hidden","");return}const title=item.getAttribute("title");if(title)tip.textContent=title;const rect=host.getBoundingClientRect();const ir=item.getBoundingClientRect();tip.style.setProperty("--chart-tip-inline-start",(ir.left-rect.left+ir.width/2)+"px");tip.style.setProperty("--chart-tip-block-start",(ir.top-rect.top)+"px");tip.removeAttribute("hidden")};const hideTip=()=>{const tip=host.querySelector(tooltipClass);if(tip)tip.setAttribute("hidden","")};host.addEventListener("mouseover",showTip);host.addEventListener("mouseout",(e)=>{if(!e.relatedTarget||!host.contains(e.relatedTarget))hideTip()});host.addEventListener("focusin",(e)=>{const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(item&&host.contains(item))showTip({target:item})});host.addEventListener("focusout",(e)=>{if(!host.contains(e.relatedTarget))hideTip()});host.addEventListener("click",(e)=>{const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(!item||!host.contains(item))return;const all=items();const index=all.indexOf(item);if(index<0)return;host.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index,label:item.getAttribute("title")||item.textContent.trim()}}))});host.addEventListener("keydown",(e)=>{const item=e&&e.target&&typeof e.target.closest==="function"?e.target.closest(itemSelector):null;if(!item||!host.contains(item))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();const all=items();const index=all.indexOf(item);if(index<0)return;host.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index,label:item.getAttribute("title")||item.textContent.trim()}}))}const all=items();const idx=all.indexOf(item);if(idx<0)return;let next=-1;const rtl=(host.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl";if(e.key==="ArrowDown")next=Math.min(idx+1,all.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,all.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,all.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=all.length-1;if(next<0||next===idx)return;e.preventDefault();all.forEach((c,i)=>c.setAttribute("tabindex",i===next?"0":"-1"));try{all[next].focus()}catch(err){}})}class ContourMinimap extends ContourBase{static get observed(){return["label","viewport","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},viewport:{attribute:"viewport"},src:{attribute:"src"}}}render(){this.classList.add("c-minimap");this.setAttribute("role","img");this.setAttribute("aria-label","Minimap");wireStates(this);loadRemote(this,["label","viewport"]);if(renderStates(this,"minimap"))return;const label=remoteData(this,"label")||(this._remoteData&&this._remoteData.label);const viewport=remoteData(this,"viewport")||(this._remoteData&&(this._remoteData.viewport||this._remoteData.value));if(!label&&!viewport){renderEmpty(this,"minimap");return}if(label){const l=this.ensure(".c-minimap__label",()=>{const el=document.createElement("span");el.className="c-minimap__label";return el});l.textContent=label}else{const l=this.querySelector(".c-minimap__label");if(l)l.remove()}if(viewport){const v=this.ensure(".c-minimap__viewport",()=>{const el=document.createElement("div");el.className="c-minimap__viewport";return el});v.textContent=viewport}else{const v=this.querySelector(".c-minimap__viewport");if(v)v.remove()}}enhance(){if(this._wiredMinimap)return;this._wiredMinimap=true;if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");let dragging=false;this.addEventListener("pointerdown",(e)=>{const vp=this.querySelector(".c-minimap__viewport");if(!vp||!vp.contains(e.target))return;dragging=true;try{vp.setPointerCapture(e.pointerId)}catch(err){}});this.addEventListener("pointermove",(e)=>{if(!dragging)return;this.dispatchEvent(new CustomEvent("contour:move",{detail:{direction:"drag"},bubbles:true,composed:true}))});this.addEventListener("pointerup",()=>{dragging=false});this.addEventListener("keydown",(e)=>{let dir=null;if(e.key==="ArrowUp")dir="up";else if(e.key==="ArrowDown")dir="down";else if(e.key==="ArrowLeft")dir="left";else if(e.key==="ArrowRight")dir="right";else if(e.key==="Home")dir="home";else if(e.key==="End")dir="end";if(!dir)return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:move",{detail:{direction:dir},bubbles:true,composed:true}))})}}define("contour-minimap",ContourMinimap);class ContourCoordinate extends ContourBase{static get observed(){return["value","format","locale","precision","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"},precision:{attribute:"precision"},src:{attribute:"src"}}}render(){this.classList.add("c-coordinate");wireStates(this);loadRemote(this,"value");if(renderStates(this,"coordinate"))return;const value=remoteData(this,"value")||(this._remoteData&&(this._remoteData.value||this._remoteData.coordinate));if(!value){renderEmpty(this,"coordinate");return}const format=this.getAttribute("format")||"decimal";let text=String(value);if(format==="dms"){const parts=String(value).split(/[,\s]+/).map(Number);if(parts.length>=2&&Number.isFinite(parts[0])&&Number.isFinite(parts[1])){const prec=parseInt(this.getAttribute("precision")||"1",10);const secDigits=Number.isFinite(prec)&&prec>=0?prec:1;const toDMS=(d,axis)=>{const deg=Math.floor(Math.abs(d));const min=Math.floor((Math.abs(d)-deg)*60);const sec=(((Math.abs(d)-deg)*60)-min)*60;const hemi=axis==="lat"?(d<0?"S":"N"):(d<0?"W":"E");return deg+"°"+min+"'"+sec.toFixed(secDigits)+'"'+hemi};text=toDMS(parts[0],"lat")+" "+toDMS(parts[1],"lon")}}else if(format==="web-mercator"){const parts=String(value).split(/[,\s]+/).map(Number);if(parts.length>=2&&Number.isFinite(parts[0])&&Number.isFinite(parts[1])){const x=parts[1]*20037508.34/180;const y=Math.log(Math.tan((90+parts[0])*Math.PI/360))/(Math.PI/180)*20037508.34/180;text=x.toFixed(2)+", "+y.toFixed(2)}}else{text=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"))}const span=this.ensure(".c-coordinate__value",()=>{const el=document.createElement("span");el.className="c-coordinate__value";el.setAttribute("role","status");el.setAttribute("aria-live","polite");return el});span.textContent=text;let btn=this.querySelector(".c-coordinate__copy");if(!btn){btn=document.createElement("button");btn.type="button";btn.className="c-coordinate__copy";btn.textContent="Copy";btn.setAttribute("aria-label","Copy coordinate");this.appendChild(btn)}btn.onclick=()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(text).catch(()=>{fallbackCopy(text)})}else{fallbackCopy(text)}}catch(e){fallbackCopy(text)}this.dispatchEvent(new CustomEvent("contour:copy",{detail:{text},bubbles:true,composed:true}))};function fallbackCopy(t){try{const ta=document.createElement("textarea");ta.value=t;ta.style.position="fixed";ta.style.opacity="0";document.body.appendChild(ta);ta.select();document.execCommand("copy");document.body.removeChild(ta)}catch(e){}}}}define("contour-coordinate",ContourCoordinate);class ContourLayerPanel extends ContourBase{static get observed(){return["label","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","allow-rename","allow-remove","allow-duplicate","allow-zoom"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-layer-panel");this.setAttribute("role","group");this.setAttribute("aria-label","Layer panel");wireStates(this);loadRemote(this,"items");if(renderStates(this,"layer-panel"))return;const items=remoteData(this,"items");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-layer-panel__label",()=>{const el=document.createElement("span");el.className="c-layer-panel__label";return el});l.textContent=label}else{const l=this.querySelector(".c-layer-panel__label");if(l)l.remove()}const authoredLayerItems=Array.from(this.querySelectorAll(":scope > .c-layer-panel__item"));const savedVisibility=new Map();this.querySelectorAll(".c-layer-panel__item").forEach((el)=>{const nm=el.querySelector(".c-layer-panel__name");const tg=el.querySelector(".c-layer-panel__toggle");if(nm&&tg){const v=tg.hasAttribute("aria-pressed")?tg.getAttribute("aria-pressed")==="true":!!tg.checked;savedVisibility.set(nm.textContent,v)}});let parsed=null;if(authoredLayerItems.length){parsed=authoredLayerItems.map((el)=>{const nm=el.querySelector(".c-layer-panel__name");const tg=el.querySelector(".c-layer-panel__toggle");const visible=tg?(tg.hasAttribute("aria-pressed")?tg.getAttribute("aria-pressed")==="true":!!tg.checked):true;const cap=el.querySelector(".c-layer-panel__caption");return{name:nm?nm.textContent:"",visible,caption:cap?cap.textContent:(el.dataset.caption||undefined)}});authoredLayerItems.forEach((el)=>el.remove())}else if(items){try{parsed=JSON.parse(items);Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach((el)=>el.remove())}catch(e){}}if(parsed){parsed.forEach((it)=>{const name=typeof it==="string"?it:(it.name||it.label||"");const caption=(typeof it==="object"&&it)?(it.caption||it.subtitle||""):"";const item=document.createElement("div");item.className="c-layer-panel__item"+(it.dragging?" c-layer-panel__item--dragging":"");const toggle=document.createElement("button");toggle.type="button";toggle.className="c-layer-panel__toggle";toggle.setAttribute("part","visibility-toggle");toggle.setAttribute("aria-label","Toggle "+(name||"layer"));const isVisible=savedVisibility.has(name)?savedVisibility.get(name):(typeof it==="object"&&it.visible!==false);toggle.setAttribute("aria-pressed",String(!!isVisible));toggle.checked=!!isVisible;toggle.innerHTML=isVisible?'<svg aria-hidden="true"><use href="#i-check" /></svg>':'<svg aria-hidden="true"><use href="#i-minus" /></svg>';item.appendChild(toggle);const nm=document.createElement("span");nm.className="c-layer-panel__name";nm.textContent=name;item.appendChild(nm);if(caption){const cap=document.createElement("span");cap.className="c-layer-panel__caption";cap.textContent=caption;item.appendChild(cap)}const opacity=document.createElement("input");opacity.type="range";opacity.className="c-layer-panel__opacity";opacity.min="0";opacity.max="100";opacity.setAttribute("aria-label","Opacity of "+(name||"layer"));opacity.value=(typeof it==="object"&&it.opacity!=null)?it.opacity:"100";item.appendChild(opacity);if(this.getAttribute("allow-rename")!=="false"){const renameBtn=document.createElement("button");renameBtn.type="button";renameBtn.className="c-layer-panel__rename";renameBtn.textContent="Rename";renameBtn.setAttribute("aria-label","Rename "+(name||"layer"));item.appendChild(renameBtn)}if(this.getAttribute("allow-duplicate")!=="false"){const dupBtn=document.createElement("button");dupBtn.type="button";dupBtn.className="c-layer-panel__duplicate";dupBtn.textContent="Duplicate";dupBtn.setAttribute("aria-label","Duplicate "+(name||"layer"));item.appendChild(dupBtn)}if(this.getAttribute("allow-zoom")!=="false"){const zoomBtn=document.createElement("button");zoomBtn.type="button";zoomBtn.className="c-layer-panel__zoom";zoomBtn.textContent="Zoom";zoomBtn.setAttribute("aria-label","Zoom to "+(name||"layer"));item.appendChild(zoomBtn)}if(this.getAttribute("allow-remove")!=="false"){const removeBtn=document.createElement("button");removeBtn.type="button";removeBtn.className="c-layer-panel__remove";removeBtn.innerHTML='<svg aria-hidden="true"><use href="#i-minus" /></svg>';removeBtn.setAttribute("aria-label","Remove "+(name||"layer"));item.appendChild(removeBtn)}const projSel=document.createElement("select");projSel.className="c-select c-layer-panel__projection";projSel.setAttribute("aria-label","Projection of "+(name||"layer"));["EPSG:4326","EPSG:3857"].forEach((p)=>{const o=document.createElement("option");o.value=p;o.textContent=p;projSel.appendChild(o)});item.appendChild(projSel);this.appendChild(item)})}if(!parsed&&!authoredLayerItems.length&&!items){Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach((el)=>el.remove());renderEmpty(this,"layer-panel")}}enhance(){if(this._wiredLayerPanel)return;this._wiredLayerPanel=true;this.addEventListener("change",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-layer-panel__item"):null;if(!item||!this.contains(item))return;const name=item.querySelector(".c-layer-panel__name")?.textContent||"";if(e.target.classList.contains("c-layer-panel__toggle")){const now=(typeof e.target.checked==="boolean")?e.target.checked:(e.target.getAttribute("aria-pressed")!=="true");e.target.checked=now;e.target.setAttribute("aria-pressed",String(now));e.target.innerHTML=now?'<svg aria-hidden="true"><use href="#i-check" /></svg>':'<svg aria-hidden="true"><use href="#i-minus" /></svg>';this.dispatchEvent(new CustomEvent("contour:layer-visibility",{bubbles:true,composed:true,detail:{name,visible:now}}))}else if(e.target.classList.contains("c-layer-panel__opacity")){this.dispatchEvent(new CustomEvent("contour:layer-opacity",{bubbles:true,composed:true,detail:{name,opacity:Number(e.target.value)}}))}else if(e.target.classList.contains("c-layer-panel__projection")){this.dispatchEvent(new CustomEvent("contour:layer-projection",{bubbles:true,composed:true,detail:{name,projection:e.target.value}}))}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest("button"):null;if(!btn||!this.contains(btn))return;const item=btn.closest(".c-layer-panel__item");if(btn.classList.contains("c-layer-panel__toggle")){if(!item)return;const name=item.querySelector(".c-layer-panel__name")?.textContent||"";const now=btn.getAttribute("aria-pressed")!=="true";btn.setAttribute("aria-pressed",String(now));btn.checked=now;btn.innerHTML=now?'<svg aria-hidden="true"><use href="#i-check" /></svg>':'<svg aria-hidden="true"><use href="#i-minus" /></svg>';this.dispatchEvent(new CustomEvent("contour:layer-visibility",{bubbles:true,composed:true,detail:{name,visible:now}}));return}if(!item)return;const name=item.querySelector(".c-layer-panel__name")?.textContent||"";if(btn.classList.contains("c-layer-panel__rename")){const nm=item.querySelector(".c-layer-panel__name");if(nm){const input=document.createElement("input");input.type="text";input.className="c-input c-layer-panel__rename-input";input.value=name;input.setAttribute("aria-label","Rename layer");nm.replaceWith(input);input.focus();input.select();const commit=()=>{const trimmed=(input.value||"").trim();const span=document.createElement("span");span.className="c-layer-panel__name";span.textContent=trimmed||name;input.replaceWith(span);if(trimmed&&trimmed!==name){this.dispatchEvent(new CustomEvent("contour:layer-rename",{bubbles:true,composed:true,detail:{name,newName:trimmed}}))}};input.addEventListener("keydown",(ev)=>{if(ev.key==="Enter"){ev.preventDefault();commit()}else if(ev.key==="Escape"){ev.preventDefault();input.value=name;commit()}});input.addEventListener("blur",commit,{once:true})}}else if(btn.classList.contains("c-layer-panel__duplicate")){this.dispatchEvent(new CustomEvent("contour:layer-duplicate",{bubbles:true,composed:true,detail:{name}}))}else if(btn.classList.contains("c-layer-panel__zoom")){this.dispatchEvent(new CustomEvent("contour:layer-zoom",{bubbles:true,composed:true,detail:{name}}))}else if(btn.classList.contains("c-layer-panel__remove")){this.dispatchEvent(new CustomEvent("contour:layer-remove",{bubbles:true,composed:true,detail:{name}}))}});this.addEventListener("keydown",(e)=>{if(e.target&&e.target.classList&&e.target.classList.contains("c-layer-panel__toggle")&&(e.key==="Enter"||e.key===" ")){e.preventDefault();e.target.click();return}const item=e.target&&e.target.closest?e.target.closest(".c-layer-panel__item"):null;if(!item||!this.contains(item))return;if(!(e.altKey)||(e.key!=="ArrowUp"&&e.key!=="ArrowDown"))return;e.preventDefault();const items=Array.from(this.querySelectorAll(".c-layer-panel__item"));const idx=items.indexOf(item);if(idx<0)return;const dir=e.key==="ArrowUp"?-1:1;const newIdx=idx+dir;if(newIdx<0||newIdx>=items.length)return;item.classList.add("c-layer-panel__item--dragging");if(dir<0)this.insertBefore(item,items[newIdx]);else this.insertBefore(items[newIdx],item);item.focus();setTimeout(()=>item.classList.remove("c-layer-panel__item--dragging"),200);const layerIds=Array.from(this.querySelectorAll(".c-layer-panel__item")).map((el)=>el.querySelector(".c-layer-panel__name")?.textContent||"");this.dispatchEvent(new CustomEvent("contour:layer-reorder",{bubbles:true,composed:true,detail:{layerIds}}))})}}define("contour-layer-panel",ContourLayerPanel);class ContourTimeSlider extends ContourBase{static get observed(){return["label","value","loop","speed","speeds","show-loop","loop-label","current-time","time-format","is-playing","play-label","pause-label","time-label","speed-label"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},distance:{attribute:"distance"},resolution:{attribute:"resolution"},latitude:{attribute:"latitude"},src:{attribute:"src"},loop:{attribute:"loop",type:Boolean},speed:{attribute:"speed"},speeds:{attribute:"speeds"},showLoop:{attribute:"show-loop",type:Boolean},loopLabel:{attribute:"loop-label"},currentTime:{attribute:"current-time"},timeFormat:{attribute:"time-format"},isPlaying:{attribute:"is-playing",type:Boolean},playLabel:{attribute:"play-label"},pauseLabel:{attribute:"pause-label"},timeLabel:{attribute:"time-label"},speedLabel:{attribute:"speed-label"}}}render(){this.classList.add("c-time-slider");const play=this.ensure(".c-time-slider__play",()=>{const el=document.createElement("button");el.className="c-time-slider__play";el.type="button";el.setAttribute("aria-label",this.getAttribute("play-label")||"Play");el.setAttribute("data-state","play");const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#i-play");svg.appendChild(use);el.appendChild(svg);return el});const track=this.ensure(".c-time-slider__track",()=>{const el=document.createElement("input");el.className="c-time-slider__track";el.type="range";el.min="0";el.max="100";el.setAttribute("aria-label",this.getAttribute("time-label")||"Time");return el});const _attrVal=this.getAttribute("value")||"0";if(this._timeSliderAttrLast!==_attrVal){track.value=_attrVal;this._timeSliderAttrLast=_attrVal}track.setAttribute("aria-label",this.getAttribute("label")||this.getAttribute("time-label")||"Time");const time=this.ensure(".c-time-slider__time",()=>{const el=document.createElement("span");el.className="c-time-slider__time";return el});const ct=this.getAttribute("current-time");time.textContent=ct?ct:(this.getAttribute("label")||"");let speeds=null;const speedsAttr=this.getAttribute("speeds");if(speedsAttr){try{speeds=JSON.parse(speedsAttr)}catch(e){speeds=null}}const speedSel=this.ensure(".c-time-slider__speed",()=>{const el=document.createElement("select");el.className="c-select c-time-slider__speed";el.setAttribute("aria-label",this.getAttribute("speed-label")||"Speed");return el});speedSel.innerHTML="";const speedList=Array.isArray(speeds)?speeds:[0.5,1,2,5,10];speedList.forEach((sp)=>{const opt=document.createElement("option");opt.value=String(sp);opt.textContent=String(sp);if(String(sp)===(this.getAttribute("speed")||""))opt.selected=true;speedSel.appendChild(opt)});const speedAttr=this.getAttribute("speed");if(speedAttr)speedSel.value=speedAttr;const showLoop=this.hasAttribute("show-loop");if(showLoop){const loopBtn=this.ensure(".c-time-slider__loop",()=>{const el=document.createElement("button");el.className="c-time-slider__loop";el.type="button";el.setAttribute("aria-label",this.getAttribute("loop-label")||"Loop");return el});loopBtn.setAttribute("aria-pressed",this.hasAttribute("loop")?"true":"false");loopBtn.textContent=this.getAttribute("loop-label")||"Loop"}else{const lb=this.querySelector(".c-time-slider__loop");if(lb)lb.remove()}if(this.hasAttribute("is-playing")){play.setAttribute("data-state","pause");play.setAttribute("aria-label",this.getAttribute("pause-label")||"Pause");const use=play.querySelector("use");if(use)use.setAttribute("href","#i-pause")}}enhance(){if(this._wiredTimeSlider)return;this._wiredTimeSlider=true;let timer=undefined;const stop=()=>{if(timer!==undefined){clearInterval(timer);timer=undefined}};const step=()=>{const track=this.querySelector(".c-time-slider__track");if(!track){stop();return}const max=Number(track.max)||100;const loop=this.hasAttribute("loop");let next=(Number(track.value)||0)+1;if(next>max){if(loop)next=0;else next=max}track.value=String(next);this.dispatchEvent(new CustomEvent("contour:time-change",{detail:{value:String(next)},bubbles:true,composed:true}));if(!loop&&next>=max){stop();const btn=this.querySelector(".c-time-slider__play");if(btn){btn.setAttribute("data-state","play");btn.setAttribute("aria-label",this.getAttribute("play-label")||"Play");const use=btn.querySelector("use");if(use)use.setAttribute("href","#i-play")}}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-time-slider__play"):null;if(btn){const playing=btn.getAttribute("data-state")==="play";btn.setAttribute("data-state",playing?"pause":"play");btn.setAttribute("aria-label",playing?(this.getAttribute("pause-label")||"Pause"):(this.getAttribute("play-label")||"Play"));const use=btn.querySelector("use");if(use)use.setAttribute("href",playing?"#i-pause":"#i-play");if(playing){stop();const speed=parseFloat(this.getAttribute("speed")||"1")||1;const delay=Math.max(100,1000/speed);timer=setInterval(step,delay);this.dispatchEvent(new CustomEvent("contour:play",{bubbles:true,composed:true}))}else{stop();this.dispatchEvent(new CustomEvent("contour:pause",{bubbles:true,composed:true}))}return}const loopBtn=e.target&&e.target.closest?e.target.closest(".c-time-slider__loop"):null;if(loopBtn){const next=loopBtn.getAttribute("aria-pressed")!=="true";loopBtn.setAttribute("aria-pressed",String(next));this.toggleAttribute("loop",next);this.dispatchEvent(new CustomEvent("contour:loop-change",{detail:{loop:next},bubbles:true,composed:true}))}});this.addEventListener("change",(e)=>{const sel=e.target&&e.target.closest?e.target.closest(".c-time-slider__speed"):null;if(!sel)return;const speed=Number(sel.value);this.dispatchEvent(new CustomEvent("contour:speed-change",{detail:{speed},bubbles:true,composed:true}))});onDispose(this,stop)}disconnectedCallback(){super.disconnectedCallback();this._wiredTimeSlider=false}}define("contour-time-slider",ContourTimeSlider);class ContourHexbin extends ContourBase{static get observed(){return["label","cells","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},cells:{attribute:"cells"},src:{attribute:"src"}}}render(){this.classList.add("c-hexbin");this.setAttribute("role","img");this.setAttribute("aria-label","Hexbin");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-hexbin__label",()=>{const el=document.createElement("span");el.className="c-hexbin__label";return el});l.textContent=label}else{const l=this.querySelector(".c-hexbin__label");if(l)l.remove()}wireStates(this);loadRemote(this,"cells");if(renderStates(this,"hexbin"))return;const cells=remoteData(this,"cells");const effectiveCells=cells||(this._remoteData&&this._remoteData.cells?JSON.stringify(this._remoteData.cells):null);const authoredCells=Array.from(this.querySelectorAll(":scope > .c-hexbin__cell"));let parsed=null;if(authoredCells.length){parsed=authoredCells.map((el)=>el.textContent||el.getAttribute("title")||"");authoredCells.forEach((el)=>el.remove())}else if(effectiveCells){try{parsed=JSON.parse(effectiveCells)}catch(e){parsed=null}}if(parsed){try{Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach((n)=>n.remove());const cols=Math.ceil(Math.sqrt(parsed.length||1));this.style.gridTemplateColumns="repeat("+cols+", 1fr)";this.style.inlineSize="16rem";parsed.forEach((c,i)=>{const cell=document.createElement("div");cell.className="c-hexbin__cell";cell.setAttribute("tabindex",i===0?"0":"-1");if(typeof c==="object"&&c.value!=null){cell.textContent=c.value;cell.setAttribute("title",String(c.value))}else if(typeof c!=="object"){cell.textContent=c;cell.setAttribute("title",String(c))}this.appendChild(cell)});const tip=this.ensure(".c-hexbin__tooltip",()=>{const el=document.createElement("div");el.className="c-hexbin__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){}}else if(!parsed){Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach((n)=>n.remove());renderEmpty(this,"hexbin")}}enhance(){if(this._wiredHexbin)return;this._wiredHexbin=true;wireMapItems(this,".c-hexbin__cell",".c-hexbin__tooltip")}}define("contour-hexbin",ContourHexbin);class ContourFlowMap extends ContourBase{static get observed(){return["label","nodes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},nodes:{attribute:"nodes"},src:{attribute:"src"}}}render(){this.classList.add("c-flow-map");this.setAttribute("role","img");this.setAttribute("aria-label","Flow map");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-flow-map__label",()=>{const el=document.createElement("span");el.className="c-flow-map__label";return el});l.textContent=label}else{const l=this.querySelector(".c-flow-map__label");if(l)l.remove()}wireStates(this);loadRemote(this,"nodes");if(renderStates(this,"flow-map"))return;const nodes=remoteData(this,"nodes");const effectiveNodes=nodes||(this._remoteData&&this._remoteData.nodes?JSON.stringify(this._remoteData.nodes):null);const authoredNodes=Array.from(this.querySelectorAll(":scope > .c-flow-map__node"));let parsed=null;if(authoredNodes.length){parsed=authoredNodes.map((el)=>el.textContent||el.getAttribute("title")||"");authoredNodes.forEach((el)=>el.remove())}else if(effectiveNodes){try{parsed=JSON.parse(effectiveNodes)}catch(e){parsed=null}}if(parsed){try{Array.from(this.querySelectorAll(".c-flow-map__node")).forEach((n)=>n.remove());parsed.forEach((n,i)=>{const node=document.createElement("span");node.className="c-flow-map__node"+(n.source?" c-flow-map__node--source":"")+(n.target?" c-flow-map__node--target":"");node.setAttribute("tabindex",i===0?"0":"-1");node.textContent=typeof n==="string"?n:(n.label||n.name||"");if(typeof n==="object"&&(n.label||n.name))node.setAttribute("title",n.label||n.name);this.appendChild(node)});const tip=this.ensure(".c-flow-map__tooltip",()=>{const el=document.createElement("div");el.className="c-flow-map__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){}}else if(!parsed){Array.from(this.querySelectorAll(".c-flow-map__node")).forEach((n)=>n.remove());renderEmpty(this,"flow-map")}}enhance(){if(this._wiredFlowMap)return;this._wiredFlowMap=true;wireMapItems(this,".c-flow-map__node",".c-flow-map__tooltip")}}define("contour-flow-map",ContourFlowMap);class ContourIsochrone extends ContourBase{static get observed(){return["label","center","rings","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},center:{attribute:"center"},rings:{attribute:"rings"},src:{attribute:"src"}}}render(){this.classList.add("c-isochrone");this.setAttribute("role","img");this.setAttribute("aria-label","Isochrone");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-isochrone__label",()=>{const el=document.createElement("span");el.className="c-isochrone__label";return el});l.textContent=label}else{const l=this.querySelector(".c-isochrone__label");if(l)l.remove()}const center=this.getAttribute("center")||(this._remoteData&&this._remoteData.center);if(center){const c=this.ensure(".c-isochrone__center",()=>{const el=document.createElement("span");el.className="c-isochrone__center";return el});c.textContent=center}else{const c=this.querySelector(".c-isochrone__center");if(c)c.remove()}wireStates(this);loadRemote(this,"rings");if(renderStates(this,"isochrone"))return;const rings=remoteData(this,"rings");const effectiveRings=rings||(this._remoteData&&this._remoteData.rings?JSON.stringify(this._remoteData.rings):null);const authoredRings=Array.from(this.querySelectorAll(":scope > .c-isochrone__ring"));let parsed=null;if(authoredRings.length){parsed=authoredRings.map((el)=>el.textContent||el.getAttribute("title")||"");authoredRings.forEach((el)=>el.remove())}else if(effectiveRings){try{parsed=JSON.parse(effectiveRings)}catch(e){parsed=null}}if(parsed){try{Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n)=>n.remove());parsed.forEach((r,i)=>{const ring=document.createElement("span");ring.className="c-isochrone__ring c-isochrone__ring--"+(r.label||r);ring.setAttribute("tabindex",i===0?"0":"-1");if(r.label)ring.setAttribute("title",r.label||r);this.appendChild(ring)});const tip=this.ensure(".c-isochrone__tooltip",()=>{const el=document.createElement("div");el.className="c-isochrone__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","")}catch(e){}}else if(!parsed){Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n)=>n.remove());renderEmpty(this,"isochrone")}}enhance(){if(this._wiredIsochrone)return;this._wiredIsochrone=true;wireMapItems(this,".c-isochrone__ring",".c-isochrone__tooltip")}}define("contour-isochrone",ContourIsochrone);class ContourCatchment extends ContourBase{static get observed(){return["label","area","center","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},area:{attribute:"area"},center:{attribute:"center"},src:{attribute:"src"}}}render(){this.classList.add("c-catchment");this.setAttribute("role","img");this.setAttribute("aria-label","Catchment");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-catchment__label",()=>{const el=document.createElement("span");el.className="c-catchment__label";return el});l.textContent=label}else{const l=this.querySelector(".c-catchment__label");if(l)l.remove()}const area=this.getAttribute("area")||(this._remoteData&&this._remoteData.area);if(area){const a=this.ensure(".c-catchment__area",()=>{const el=document.createElement("span");el.className="c-catchment__area";return el});a.textContent=area}else{const a=this.querySelector(".c-catchment__area");if(a)a.remove()}const center=this.getAttribute("center")||(this._remoteData&&this._remoteData.center);if(center){const c=this.ensure(".c-catchment__center",()=>{const el=document.createElement("span");el.className="c-catchment__center";return el});c.textContent=center}else{const c=this.querySelector(".c-catchment__center");if(c)c.remove()}wireStates(this);loadRemote(this,["label","area","center"]);if(renderStates(this,"catchment"))return;const rLabel=remoteData(this,"label")||(this._remoteData&&this._remoteData.label);const rArea=remoteData(this,"area")||(this._remoteData&&this._remoteData.area);const rCenter=remoteData(this,"center")||(this._remoteData&&this._remoteData.center);if(!rLabel&&!rArea&&!rCenter){renderEmpty(this,"catchment");return}const tip=this.ensure(".c-catchment__tooltip",()=>{const el=document.createElement("div");el.className="c-catchment__tooltip";el.setAttribute("role","tooltip");el.setAttribute("hidden","");return el});tip.setAttribute("hidden","");if(rArea)tip.textContent=rArea}enhance(){if(this._wiredCatchment)return;this._wiredCatchment=true;const showTip=()=>{const tip=this.querySelector(".c-catchment__tooltip");if(tip)tip.removeAttribute("hidden")};const hideTip=()=>{const tip=this.querySelector(".c-catchment__tooltip");if(tip)tip.setAttribute("hidden","")};this.addEventListener("mouseenter",showTip);this.addEventListener("mouseleave",hideTip);if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");this.addEventListener("focusin",showTip);this.addEventListener("focusout",hideTip);this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{area:this.getAttribute("area")}}))}})}}define("contour-catchment",ContourCatchment);class ContourCompassFull extends ContourBase{static get observed(){return["label","needle","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},needle:{attribute:"needle"},src:{attribute:"src"}}}render(){this.classList.add("c-compass");const label=this.getAttribute("label")||(this._remoteData&&this._remoteData.label);wireStates(this);loadRemote(this,"needle");if(renderStates(this,"compass"))return;const needle=remoteData(this,"needle")||(this._remoteData&&(this._remoteData.needle||this._remoteData.value));for(const dir of["n","s","e","w"]){const cls=".c-compass__label--"+dir;let l=this.querySelector(cls);if(!l){l=document.createElement("span");l.className="c-compass__label "+cls.slice(1);l.textContent=dir.toUpperCase();l.setAttribute("role","button");l.setAttribute("tabindex","0");this.appendChild(l)}}if(label&&label.toLowerCase()!=="compass"){const l=this.ensure(".c-compass__label:not([class*='--'])",()=>{const el=document.createElement("span");el.className="c-compass__label";return el});l.textContent=label}if(needle){const deg=Number(needle)||0;const n=this.ensure("svg.c-compass__needle",()=>{const el=document.createElementNS("http://www.w3.org/2000/svg","svg");el.setAttribute("class","c-compass__needle");el.setAttribute("viewBox","0 0 40 40");el.setAttribute("aria-hidden","true");const pathN=document.createElementNS("http://www.w3.org/2000/svg","path");pathN.setAttribute("class","c-compass__needle--n");pathN.setAttribute("d",compassNeedle(20,20,16,deg));el.appendChild(pathN);const pathS=document.createElementNS("http://www.w3.org/2000/svg","path");pathS.setAttribute("class","c-compass__needle--s");pathS.setAttribute("d",compassNeedle(20,20,16,deg+180));el.appendChild(pathS);return el});const pathN=n.querySelector(".c-compass__needle--n");if(pathN)pathN.setAttribute("d",compassNeedle(20,20,16,deg));const pathS=n.querySelector(".c-compass__needle--s");if(pathS)pathS.setAttribute("d",compassNeedle(20,20,16,deg+180))}else{const n=this.querySelector("svg.c-compass__needle, .c-compass__needle");if(n)n.remove()}if(!needle&&!label){renderEmpty(this,"compass")}}enhance(){if(this._wiredCompass)return;this._wiredCompass=true;const DEGREES={n:0,e:90,s:180,w:270};const setBearing=(dir)=>{const deg=DEGREES[dir];if(deg===undefined)return;const n=this.querySelector(".c-compass__needle");if(n){const pathN=n.querySelector(".c-compass__needle--n");if(pathN)pathN.setAttribute("d",compassNeedle(20,20,16,deg));const pathS=n.querySelector(".c-compass__needle--s");if(pathS)pathS.setAttribute("d",compassNeedle(20,20,16,deg+180))}this.dispatchEvent(new CustomEvent("contour:bearing",{bubbles:true,composed:true,detail:{direction:dir,degrees:deg}}))};this.addEventListener("click",(e)=>{const label=e.target&&e.target.closest?e.target.closest(".c-compass__label--n, .c-compass__label--e, .c-compass__label--s, .c-compass__label--w"):null;if(!label||!this.contains(label))return;const m=label.className.match(/c-compass__label--([nsew])/);if(m)setBearing(m[1])});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;const label=e.target&&e.target.closest?e.target.closest(".c-compass__label--n, .c-compass__label--e, .c-compass__label--s, .c-compass__label--w"):null;if(!label||!this.contains(label))return;e.preventDefault();const m=label.className.match(/c-compass__label--([nsew])/);if(m)setBearing(m[1])})}}define("contour-compass",ContourCompassFull);class ContourLayerSwitch extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-layer-switch");wireStates(this);loadRemote(this,"items");if(renderStates(this,"layer-switch"))return;const items=remoteData(this,"items");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-layer-switch__item"));if(items&&!authored.length){Array.from(this.querySelectorAll(".c-layer-switch__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(items);const capped=Array.isArray(parsed)?parsed.slice(0,50):parsed;capped.forEach((it)=>{const item=document.createElement("div");item.className="c-layer-switch__item";item.setAttribute("role","group");const sw=document.createElement("span");sw.className="c-layer-switch__swatch";if(it.color)sw.style.background=it.color;sw.setAttribute("aria-hidden","true");item.appendChild(sw);const name=document.createElement("span");name.className="c-layer-switch__name";name.textContent=typeof it==="string"?it:(it.name||it.label||"");item.appendChild(name);if(it.count!=null){const c=document.createElement("span");c.className="c-layer-switch__count";c.textContent=it.count;item.appendChild(c)}const toggle=document.createElement("button");toggle.className="c-layer-switch__toggle";toggle.type="button";toggle.setAttribute("aria-label","Toggle "+(typeof it==="string"?it:(it.name||it.label||"layer")));toggle.setAttribute("aria-pressed","true");toggle.innerHTML='<svg aria-hidden="true"><use href="#i-check" /></svg>';item.appendChild(toggle);this.appendChild(item)})}catch(e){}}else if(!items&&!authored.length){Array.from(this.querySelectorAll(".c-layer-switch__item")).forEach((n)=>n.remove());renderEmpty(this,"layer-switch")}}enhance(){if(this._wiredLayerSwitch)return;this._wiredLayerSwitch=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-layer-switch__toggle"):null;if(!btn||!this.contains(btn))return;const item=btn.closest(".c-layer-switch__item");const name=item?(item.querySelector(".c-layer-switch__name")?.textContent||""):"";const now=btn.getAttribute("aria-pressed")!=="true";btn.setAttribute("aria-pressed",String(now));this.dispatchEvent(new CustomEvent("contour:layer-toggle",{bubbles:true,composed:true,detail:{name,visible:now}}))});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-layer-switch__toggle"):null;if(!btn||!this.contains(btn))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}})}}define("contour-layer-switch",ContourLayerSwitch);class ContourMapSlot extends ContourBase{static get observed(){return["attribution","scale","chrome"]}static get properties(){return{attribution:{attribute:"attribution"},scale:{attribute:"scale"},chrome:{attribute:"chrome"}}}render(){this.classList.add("c-map-slot");const chrome=this.getAttribute("chrome");if(chrome){const c=this.ensure(".c-map-slot__chrome",()=>{const el=document.createElement("div");el.className="c-map-slot__chrome";return el});c.textContent=chrome}else{const c=this.querySelector(".c-map-slot__chrome");if(c)c.remove()}const attribution=this.getAttribute("attribution");if(attribution){const a=this.ensure(".c-map-slot__attribution",()=>{const el=document.createElement("div");el.className="c-map-slot__attribution";return el});a.textContent=attribution}else{const a=this.querySelector(".c-map-slot__attribution");if(a)a.remove()}const scale=this.getAttribute("scale");if(scale){const sc=this.ensure(".c-map-slot__scale",()=>{const el=document.createElement("div");el.className="c-map-slot__scale";return el});sc.textContent=scale}else{const sc=this.querySelector(".c-map-slot__scale");if(sc)sc.remove()}}}define("contour-map-slot",ContourMapSlot);class ContourMapArea extends ContourBase{static get observed(){return["attribution","attribution-mark","scale","controls"]}static get properties(){return{attribution:{attribute:"attribution"},"attribution-mark":{attribute:"attribution-mark"},scale:{attribute:"scale"},controls:{attribute:"controls"}}}render(){this.classList.add("c-map-area");const attribution=this.getAttribute("attribution");if(attribution){const a=this.ensure(".c-map-slot__attribution",()=>{const el=document.createElement("div");el.className="c-map-slot__attribution";return el});a.textContent=attribution}else{const a=this.querySelector(".c-map-slot__attribution");if(a)a.remove()}const mark=this.getAttribute("attribution-mark");if(mark){const m=this.ensure(".c-map-slot__attribution-mark",()=>{const el=document.createElement("span");el.className="c-map-slot__attribution-mark";return el});m.textContent=mark}else{const m=this.querySelector(".c-map-slot__attribution-mark");if(m)m.remove()}const scale=this.getAttribute("scale");if(scale){const sc=this.ensure(".c-map-slot__scale",()=>{const el=document.createElement("div");el.className="c-map-slot__scale";return el});sc.textContent=scale}else{const sc=this.querySelector(".c-map-slot__scale");if(sc)sc.remove()}const controls=this.getAttribute("controls");if(controls){try{const parsed=JSON.parse(controls);const wrap=this.ensure(".c-map-slot__controls",()=>{const el=document.createElement("div");el.className="c-map-slot__controls";return el});wrap.innerHTML="";parsed.forEach((c)=>{const btn=document.createElement("button");btn.className="c-map-slot__control";btn.type="button";btn.textContent=typeof c==="string"?c:(c.label||c);wrap.appendChild(btn)})}catch(e){}}else{const w=this.querySelector(".c-map-slot__controls");if(w)w.remove()}}enhance(){if(this._wiredMapArea)return;this._wiredMapArea=true;this._map=null;this.attachMap=(map)=>{this._map=map||null;this.dispatchEvent(new CustomEvent("contour:map-attach",{bubbles:true,composed:true}))};this.detachMap=()=>{this._map=null;this.dispatchEvent(new CustomEvent("contour:map-detach",{bubbles:true,composed:true}))};Object.defineProperty(this,"map",{get:()=>this._map,set:(m)=>this.attachMap(m)});this.getViewport=()=>{const m=this._map;if(!m)return null;try{if(typeof m.getBounds==="function"){const b=m.getBounds();return{west:b.getWest(),south:b.getSouth(),east:b.getEast(),north:b.getNorth()}}if(m.transform&&typeof m.transform==="object"){return{zoom:m.transform.zoom,center:m.transform.center}}}catch(e){}return null};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-map-slot__control"):null;if(!btn||!this.contains(btn))return;this.dispatchEvent(new CustomEvent("contour:map-control",{bubbles:true,composed:true,detail:{control:btn.textContent}}))})}}define("contour-map-area",ContourMapArea);class ContourMapPanel extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-map-panel");if(!this.hasAttribute("role"))this.setAttribute("role","region");const title=this.getAttribute("title");if(title){if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",title)}else{if(this.getAttribute("aria-label")===this.getAttribute("title"))this.removeAttribute("aria-label")}}}define("contour-map-panel",ContourMapPanel);class ContourMapFooter extends ContourBase{static get observed(){return["brand"]}static get properties(){return{brand:{attribute:"brand"}}}render(){this.classList.add("c-map-footer");if(!this.hasAttribute("role"))this.setAttribute("role","contentinfo");const brand=this.getAttribute("brand");if(brand){const b=this.ensure("[data-map-footer-brand]",()=>{const el=document.createElement("span");el.setAttribute("data-map-footer-brand","");return el});b.textContent=brand}else{const b=this.querySelector("[data-map-footer-brand]");if(b)b.remove()}}}define("contour-map-footer",ContourMapFooter);class ContourScaleBar extends ContourBase{static get observed(){return["label","value","distance","resolution","latitude","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},distance:{attribute:"distance"},resolution:{attribute:"resolution"},latitude:{attribute:"latitude"},src:{attribute:"src"}}}render(){this.classList.add("c-scale-bar");wireStates(this);loadRemote(this,["label","value"]);if(renderStates(this,"scale-bar"))return;let value=remoteData(this,"value")||(this._remoteData&&this._remoteData.value);const resolution=parseFloat(this.getAttribute("resolution"));let derivedLabel=null;if(Number.isFinite(resolution)&&resolution>0){const distance=parseFloat(this.getAttribute("distance"))||1000;value=String(Math.round(distance/resolution));if(!this.getAttribute("label")&&!remoteData(this,"label")){derivedLabel=distance>=1000?(distance/1000)+" km":distance+" m"}}const label=derivedLabel||remoteData(this,"label")||(this._remoteData&&this._remoteData.label);if(label){const l=this.ensure(".c-scale-bar__label",()=>{const el=document.createElement("span");el.className="c-scale-bar__label";return el});l.textContent=label}else{const l=this.querySelector(".c-scale-bar__label");if(l)l.remove()}if(!value){renderEmpty(this,"scale-bar");return}const line=this.ensure(".c-scale-bar__line",()=>{const el=document.createElement("span");el.className="c-scale-bar__line";return el});line.style.inlineSize=/^\d+(\.\d+)?$/.test(String(value))?value+"px":value;const ticks=scaleBarTicks(parseFloat(value)||0,4);const max=ticks[ticks.length-1]||1;Array.from(line.querySelectorAll(".c-scale-bar__tick")).forEach((t)=>t.remove());ticks.forEach((tv)=>{const tick=document.createElement("span");tick.className="c-scale-bar__tick";tick.style.insetInlineStart=((tv/max)*100)+"%";line.appendChild(tick)})}}define("contour-scale-bar",ContourScaleBar);class ContourSplitMap extends ContourBase{static get observed(){return["left","right"]}static get properties(){return{left:{attribute:"left"},right:{attribute:"right"}}}render(){this.classList.add("c-split-map");const left=this.ensure(".c-split-map__pane--left",()=>{const e=document.createElement("div");e.className="c-split-map__pane c-split-map__pane--left";return e});const right=this.ensure(".c-split-map__pane--right",()=>{const e=document.createElement("div");e.className="c-split-map__pane c-split-map__pane--right";return e});if(left.parentNode!==this)this.appendChild(left);if(right.parentNode!==this)this.appendChild(right)}}define("contour-split-map",ContourSplitMap);class ContourResizeObserver extends ContourBase{static get observed(){return["debounce"]}static get properties(){return{debounce:{attribute:"debounce"}}}render(){this.classList.add("c-resize-observer");this.setAttribute("aria-hidden","true")}enhance(){if(this._wiredResizeObserver)return;this._wiredResizeObserver=true;if(typeof ResizeObserver!=="function")return;const debounce=parseInt(this.getAttribute("debounce")||"0",10)||0;let timer=null;const ro=new ResizeObserver((entries)=>{const fire=()=>{const e=entries[entries.length-1];const cr=e&&e.contentRect?e.contentRect:this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:true,composed:true,detail:{width:cr.width,height:cr.height}}))};if(debounce>0){clearTimeout(timer);timer=setTimeout(fire,debounce)}else fire()});ro.observe(this);onDispose(this,()=>{ro.disconnect();clearTimeout(timer)})}}define("contour-resize-observer",ContourResizeObserver);class ContourReservedFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-reserved");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-reserved__title",()=>{const el=document.createElement("div");el.className="c-reserved__title";return el});t.textContent=title}}}define("contour-reserved",ContourReservedFull);class ContourThemeScopeFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-theme-scope");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-theme-scope__title",()=>{const el=document.createElement("div");el.className="c-theme-scope__title";el.style.padding="var(--space-sm)";el.style.fontWeight="var(--weight-semibold)";return el});t.textContent=title}}}define("contour-theme-scope",ContourThemeScopeFull);class ContourActivity extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-activity");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"activity"))return;const items=remoteData(this,"items");if(items){try{const parsed=JSON.parse(items);Array.from(this.querySelectorAll(".c-activity__item")).forEach((n)=>n.remove());parsed.forEach((it,i)=>{const item=document.createElement("div");item.className="c-activity__item";item.setAttribute("role","listitem");item.tabIndex=-1;const dot=document.createElement("span");dot.className="c-activity__dot c-activity__dot--"+(it.variant||"primary");dot.setAttribute("aria-hidden","true");item.appendChild(dot);const text=document.createElement("span");text.className="c-activity__text";text.textContent=typeof it==="string"?it:(it.text||it.label||"");item.appendChild(text);if(it.time){const time=document.createElement("span");time.className="c-activity__time";time.textContent=it.time;item.appendChild(time)}this.appendChild(item)})}catch(e){}}else{renderEmpty(this,"activity")}}enhance(){if(this._wiredActivity)return;this._wiredActivity=true;this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-activity__item"):null;if(item&&this.contains(item)){const items=Array.from(this.querySelectorAll(".c-activity__item"));const index=items.indexOf(item);const text=item.querySelector(".c-activity__text")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:true,composed:true,detail:{index,text}}))}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-activity__item"));if(!items.length)return;const active=document.activeElement;const idx=items.indexOf(active);let next=-1;if(e.key==="ArrowDown")next=idx<0?0:Math.min(items.length-1,idx+1);else if(e.key==="ArrowUp")next=idx<0?0:Math.max(0,idx-1);else if(e.key==="Home")next=0;else if(e.key==="End")next=items.length-1;if(next>=0&&next!==idx){e.preventDefault();items[next].focus();items[next].tabIndex=0;if(idx>=0)items[idx].tabIndex=-1}if((e.key==="Enter"||e.key===" ")&&idx>=0){e.preventDefault();const text=items[idx].querySelector(".c-activity__text")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:true,composed:true,detail:{index:idx,text}}))}})}}define("contour-activity",ContourActivity);class ContourAdvanced extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-advanced");this.setAttribute("role","region");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-advanced__title",()=>{const el=document.createElement("div");el.className="c-advanced__title";return el});t.textContent=title;this.setAttribute("aria-label",title)}}enhance(){if(this._wiredAdvanced)return;this._wiredAdvanced=true;this.addEventListener("click",(e)=>{const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:advanced-toggle",{bubbles:true,composed:true,detail:{title}}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:advanced-toggle",{bubbles:true,composed:true,detail:{title}}))}})}}define("contour-advanced",ContourAdvanced);class ContourAffordance extends ContourBase{static get observed(){return["name","note","demo"]}static get properties(){return{name:{attribute:"name"},note:{attribute:"note"},demo:{attribute:"demo"}}}render(){this.classList.add("c-affordance");this.setAttribute("role","group");const name=this.getAttribute("name");if(name){const n=this.ensure(".c-affordance__name",()=>{const el=document.createElement("div");el.className="c-affordance__name";return el});n.textContent=name;this.setAttribute("aria-label",name)}else{const n=this.querySelector(".c-affordance__name");if(n)n.remove()}const note=this.getAttribute("note");if(note){const nt=this.ensure(".c-affordance__note",()=>{const el=document.createElement("div");el.className="c-affordance__note";return el});nt.textContent=note}else{const nt=this.querySelector(".c-affordance__note");if(nt)nt.remove()}const demo=this.getAttribute("demo");if(demo){const d=this.ensure(".c-affordance__demo",()=>{const el=document.createElement("div");el.className="c-affordance__demo";return el});d.textContent=demo}else{const d=this.querySelector(".c-affordance__demo");if(d)d.remove()}}enhance(){if(this._wiredAffordance)return;this._wiredAffordance=true;this.addEventListener("click",(e)=>{const name=this.getAttribute("name")||"";this.dispatchEvent(new CustomEvent("contour:affordance-activate",{bubbles:true,composed:true,detail:{name}}))})}}define("contour-affordance",ContourAffordance);class ContourAffordances extends ContourBase{static get observed(){return["name","title"]}static get properties(){return{name:{attribute:"name"},title:{attribute:"title"}}}render(){this.classList.add("c-affordances");this.setAttribute("role","group");if(!this.querySelector(".c-affordance")){const aff=document.createElement("div");aff.className="c-affordance";const name=this.getAttribute("name")||this.getAttribute("title")||"Affordance";const n=document.createElement("div");n.className="c-affordance__name";n.textContent=name;aff.appendChild(n);const demo=document.createElement("div");demo.className="c-affordance__demo";demo.textContent="Demo";aff.appendChild(demo);this.appendChild(aff)}}}define("contour-affordances",ContourAffordances);class ContourMenu extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-menu");if(!this.hasAttribute("role"))this.setAttribute("role","menu");wireStates(this);loadRemote(this,"items");if(renderStates(this,"menu"))return;const items=remoteData(this,"items");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-menu"));if(authored.length){if(this.querySelector("ul.c-menu"))return;const ul=document.createElement("ul");ul.className="c-menu";ul.setAttribute("role","menu");this.appendChild(ul);return}if(items){try{const parsed=JSON.parse(items);const ul=this.ensure("ul.c-menu",()=>{const el=document.createElement("ul");el.className="c-menu";el.setAttribute("role","menu");return el});ul.innerHTML="";ul.setAttribute("role","menu");parsed.forEach((item)=>{if(item==="---"||item==="separator"){const li=document.createElement("li");li.className="c-menu__separator";li.setAttribute("role","separator");ul.appendChild(li)}else if(typeof item==="string"){const li=document.createElement("li");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=item;ul.appendChild(li)}else if(item.group){const li=document.createElement("li");li.className="c-menu__group";li.setAttribute("role","group");if(item.group)li.setAttribute("aria-label",String(item.group));const hdr=document.createElement("div");hdr.className="c-menu__group-label";hdr.textContent=String(item.group);li.appendChild(hdr);if(Array.isArray(item.items)){const sub=document.createElement("ul");sub.className="c-menu";sub.setAttribute("role","menu");item.items.forEach((subItem)=>{const sli=document.createElement("li");sli.className="c-menu__item"+(subItem.danger?" c-menu__item--danger":"")+(subItem.disabled?" c-menu__item--disabled":"");sli.setAttribute("role","menuitem");if(subItem.disabled)sli.setAttribute("aria-disabled","true");if(subItem.label||subItem.title){const lbl=document.createElement("span");lbl.className="c-menu__label";lbl.textContent=subItem.label||subItem.title||"";sli.appendChild(lbl)}sub.appendChild(sli)});li.appendChild(sub)}ul.appendChild(li)}else{const li=document.createElement("li");li.className="c-menu__item"+(item.danger?" c-menu__item--danger":"")+(item.disabled?" c-menu__item--disabled":"");li.setAttribute("role","menuitem");if(item.disabled)li.setAttribute("aria-disabled","true");if(item.items&&Array.isArray(item.items)){li.setAttribute("aria-haspopup","menu");li.setAttribute("aria-expanded","false")}if(item.label||item.title){const lbl=document.createElement("span");lbl.className="c-menu__label";lbl.textContent=item.label||item.title||"";li.appendChild(lbl)}if(item.shortcut){const sc=document.createElement("span");sc.className="c-menu__shortcut";sc.textContent=item.shortcut;li.appendChild(sc)}ul.appendChild(li)}});if(ul.parentNode!==this)this.appendChild(ul);this.classList.remove("c-menu");ul.classList.add("c-menu")}catch(e){}}else{renderEmpty(this,"menu")}}enhance(){wireMenu(this)}}define("contour-menu",ContourMenu);class ContourTabs extends ContourBase{static get observed(){return["tabs","autoplay","pause","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","orientation","closable"]}static get properties(){return{tabs:{attribute:"tabs"},autoplay:{attribute:"autoplay",type:Number},pause:{attribute:"pause",type:Boolean},src:{attribute:"src"},orientation:{attribute:"orientation"},closable:{attribute:"closable",type:Boolean}}}render(){this.classList.add("c-tabs");wireStates(this);loadRemote(this,"tabs");if(renderStates(this,"tabs"))return;const tabs=remoteData(this,"tabs");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-tabs__list"));if(tabs&&!authored.length){try{const parsed=JSON.parse(tabs);const list=this.ensure(".c-tabs__list",()=>{const el=document.createElement("div");el.className="c-tabs__list";el.setAttribute("role","tablist");return el});list.setAttribute("role","tablist");const orientation=this.getAttribute("orientation")==="vertical"?"vertical":"horizontal";list.setAttribute("aria-orientation",orientation);if(orientation==="vertical")this.classList.add("c-tabs--vertical");else this.classList.remove("c-tabs--vertical");const _prevTabs=Array.from(list.querySelectorAll("[role='tab']"));const _prevSel=_prevTabs.findIndex((t)=>t.getAttribute("aria-selected")==="true");const _keepIdx=_prevSel>=0?_prevSel:0;list.innerHTML="";Array.from(this.querySelectorAll(".c-tabs__panel")).forEach((n)=>n.remove());parsed.forEach((t,i)=>{const label=typeof t==="string"?t:(t.label||t.title||"");const panelId=contourId("c-tabs-panel");const btn=document.createElement("button");btn.className="c-tabs__tab";btn.setAttribute("role","tab");btn.setAttribute("aria-selected",String(i===_keepIdx));btn.setAttribute("aria-controls",panelId);btn.tabIndex=i===_keepIdx?0:-1;btn.textContent=label;if(this.hasAttribute("closable")){const closeBtn=document.createElement("button");closeBtn.type="button";closeBtn.className="c-tabs__close";closeBtn.setAttribute("aria-label","Close "+label);closeBtn.textContent="×";closeBtn.addEventListener("click",(e)=>{e.stopPropagation();const idx=Array.from(list.querySelectorAll("[role='tab']")).indexOf(btn);const ctrl=btn.getAttribute("aria-controls");const panel=ctrl?document.getElementById(ctrl):null;btn.remove();if(panel)panel.remove();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true,detail:{index:idx,label}}));const remaining=list.querySelectorAll("[role='tab']");if(remaining.length)remaining[0].click()});btn.appendChild(closeBtn)}list.appendChild(btn);const panel=document.createElement("div");panel.className="c-tabs__panel";panel.id=panelId;panel.setAttribute("role","tabpanel");if(typeof t==="object"&&t!==null&&t.content!==undefined){panel.textContent=String(t.content)}if(i!==_keepIdx)panel.hidden=true;this.appendChild(panel)});if(list.parentNode!==this)this.prepend(list)}catch(e){}}else if(!tabs&&!authored.length){const list=this.querySelector(".c-tabs__list");if(list)list.remove();renderEmpty(this,"tabs")}}enhance(){wireTabs(this);const sync=()=>{const seconds=parseFloat(this.getAttribute("autoplay")||"");const paused=this.hasAttribute("pause")||this._tabsHover||this._tabsFocus;const reduced=typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches;const want=Number.isFinite(seconds)&&seconds>0&&!paused&&!reduced;if(want===this._tabsAutoplayRunning)return;this._tabsAutoplayRunning=want;if(this._tabsTimer!==undefined){clearInterval(this._tabsTimer);this._tabsTimer=undefined}if(!want)return;this._tabsTimer=setInterval(()=>{if(!this.isConnected||this.hasAttribute("pause")||this._tabsHover||this._tabsFocus)return;const list=this.querySelector(".c-tabs__list");const tabs=list?Array.from(list.querySelectorAll("[role='tab']")):[];if(!tabs.length)return;const cur=tabs.findIndex((t)=>t.getAttribute("aria-selected")==="true");const next=tabs[(cur+1)%tabs.length];if(next)next.click()},Math.max(1000,seconds*1000))};sync();if(this._wiredTabsAutoplay)return;this._wiredTabsAutoplay=true;this.addEventListener("pointerenter",()=>{this._tabsHover=true;sync()});this.addEventListener("pointerleave",()=>{this._tabsHover=false;sync()});this.addEventListener("focusin",()=>{this._tabsFocus=true;sync()});this.addEventListener("focusout",()=>{this._tabsFocus=false;sync()});onDispose(this,()=>{if(this._tabsTimer!==undefined){clearInterval(this._tabsTimer);this._tabsTimer=undefined}})}}define("contour-tabs",ContourTabs);class ContourHeader extends ContourBase{static get observed(){return["brand","links"]}static get properties(){return{brand:{attribute:"brand"},links:{attribute:"links"}}}render(){this.classList.add("c-header");const brand=this.getAttribute("brand");const links=this.getAttribute("links");const inner=this.ensure(".c-header__inner",()=>{const el=document.createElement("div");el.className="container c-header__inner";return el});inner.className="container c-header__inner";let brandEl=inner.querySelector(".c-brand");if(brand){if(!brandEl){brandEl=document.createElement("a");brandEl.className="c-brand";brandEl.setAttribute("data-contour-generated","");brandEl.href="#";brandEl.innerHTML=`<span class="c-mark"><svg aria-hidden="true"><use href="#i-mark" /></svg></span>`;const brandName=document.createElement("span");brandName.className="c-brand__name";brandEl.appendChild(brandName);inner.insertBefore(brandEl,inner.firstChild)}const brandName=brandEl.querySelector(".c-brand__name");if(brandName)brandName.textContent=brand}else if(brandEl&&brandEl.hasAttribute("data-contour-generated")){brandEl.remove()}let nav=inner.querySelector(".c-header__nav");const authoredNav=nav?Array.from(nav.children).filter((n)=>n.tagName==="A"):[];if(links&&!authoredNav.length){try{const parsed=JSON.parse(links);if(!nav){nav=document.createElement("nav");nav.className="c-header__nav";nav.setAttribute("aria-label","Main");nav.setAttribute("data-contour-generated","");inner.appendChild(nav)}nav.innerHTML="";parsed.forEach((l)=>{const a=document.createElement("a");a.href=l.href||"#";a.textContent=l.label||l;nav.appendChild(a)})}catch(e){}}else if(links&&authoredNav.length){}else if(nav&&!links&&!authoredNav.length&&nav.hasAttribute("data-contour-generated")){nav.remove()}if(!inner.querySelector(".c-header__actions")){const actions=document.createElement("div");actions.className="c-header__actions";inner.appendChild(actions)}const navEl=inner.querySelector(".c-header__nav");if(navEl){if(!navEl.id)navEl.id="contour-header-nav";const actions=inner.querySelector(".c-header__actions");if(actions&&!actions.querySelector(".c-header__toggle")){const toggle=document.createElement("button");toggle.type="button";toggle.className="c-header__toggle";toggle.setAttribute("aria-label","Toggle navigation");toggle.setAttribute("aria-expanded","false");toggle.setAttribute("aria-controls",navEl.id);toggle.innerHTML='<svg aria-hidden="true"><use href="#i-grid" /></svg>';actions.appendChild(toggle)}}if(inner.parentNode!==this)this.appendChild(inner)}enhance(){if(this._wiredHeader)return;this._wiredHeader=true;const update=()=>{const y=window.scrollY||document.documentElement.scrollTop||0;this.classList.toggle("c-header--scrolled",y>8)};update();window.addEventListener("scroll",update,{passive:true});onDispose(this,()=>window.removeEventListener("scroll",update));this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-header__toggle"):null;if(!toggle||!this.contains(toggle))return;const nav=this.querySelector("#"+CSS.escape(toggle.getAttribute("aria-controls")||""));if(!nav)return;const open=nav.classList.toggle("is-open");toggle.setAttribute("aria-expanded",String(open))});this.addEventListener("keydown",(e)=>{if(e.key!=="Escape")return;const toggle=this.querySelector(".c-header__toggle");const nav=toggle&&this.querySelector("#"+CSS.escape(toggle.getAttribute("aria-controls")||""));if(!toggle||!nav||!nav.classList.contains("is-open"))return;nav.classList.remove("is-open");toggle.setAttribute("aria-expanded","false")})}}define("contour-header",ContourHeader);class ContourTree extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","virtual","item-height","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","selectable"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"},"item-height":{attribute:"item-height"}}}_itemHeight(){const h=Number(this.getAttribute("item-height"));return Number.isFinite(h)&&h>0?h:28}_labelToPaths(nodes,pathPrefix,map){(nodes||[]).forEach((node,i)=>{const p=pathPrefix+"."+i;const label=String(node.label||node).trim().slice(0,120);if(!map.has(label))map.set(label,[]);map.get(label).push(p);if(Array.isArray(node.children))this._labelToPaths(node.children,p,map)})}_restoreExpanded(){const persist=this.getAttribute("persist");if(!persist||!this._treeData)return;let labels=null;try{if(persist==="storage"&&this.id){const saved=localStorage.getItem("contour-tree:"+this.id);if(saved!==null)labels=JSON.parse(saved)}else if(persist==="url"){const v=new URLSearchParams(window.location.search).get("c-tree");if(v!==null)labels=JSON.parse(v)}}catch(e){labels=null}if(!Array.isArray(labels))return;const want=new Set(labels.map((l)=>String(l)));const map=new Map();this._labelToPaths(this._treeData,"",map);const expanded=this._expanded||(this._expanded=new Set());for(const lbl of want){const paths=map.get(lbl);if(paths)paths.forEach((p)=>expanded.add(p))}}_persistExpanded(){const persist=this.getAttribute("persist");if(!persist||!this._expanded)return;const pathToNode=new Map();const walk=(nodes,pathPrefix)=>{(nodes||[]).forEach((node,i)=>{const p=pathPrefix+"."+i;pathToNode.set(p,node);if(Array.isArray(node.children))walk(node.children,p)})};walk(this._treeData,"");const open=[];for(const p of this._expanded){const node=pathToNode.get(p);if(node)open.push(String(node.label||node).trim().slice(0,120))}try{if(persist==="storage"&&this.id){localStorage.setItem("contour-tree:"+this.id,JSON.stringify(open))}else if(persist==="url"){const url=new URL(window.location.href);url.searchParams.set("c-tree",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}}catch(e){}}_flatten(nodes,pathPrefix,depth,expanded,out){(nodes||[]).forEach((node,i)=>{const p=pathPrefix+"."+i;const hasChildren=Array.isArray(node.children)&&node.children.length>0;const isExpanded=expanded.has(p);out.push({node,path:p,depth,hasChildren,expanded:isExpanded});if(hasChildren&&isExpanded){this._flatten(node.children,p,depth+1,expanded,out)}})}_renderNodeFlat(rootUl,f){const node=f.node;const depth=f.depth;const li=document.createElement("div");li.className="c-tree__node";li.setAttribute("role","treeitem");li.setAttribute("aria-level",String(depth));li.dataset.path=f.path;if(f.hasChildren){li.setAttribute("aria-expanded",String(f.expanded));const row=document.createElement("div");row.className="c-tree__row"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");row.style.paddingInlineStart=((depth-1)*1)+"rem";const toggle=document.createElement("button");toggle.className="c-tree__toggle";toggle.setAttribute("type","button");toggle.setAttribute("aria-expanded",String(f.expanded));toggle.setAttribute("aria-label","Toggle");toggle.innerHTML='<svg aria-hidden="true"><use href="#i-chevron-right" /></svg>';row.appendChild(toggle);const span=document.createElement("span");span.textContent=node.label;row.appendChild(span);li.appendChild(row)}else{const leaf=document.createElement("div");leaf.className="c-tree__leaf"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");leaf.style.paddingInlineStart=(depth*1)+"rem";if(this.hasAttribute("selectable")){const cb=document.createElement("input");cb.type="checkbox";cb.className="c-tree__select";cb.setAttribute("aria-label","Select "+(node.label||node));const label=String(node.label||node).trim().slice(0,120);if(this._selectedTree&&this._selectedTree.has(label))cb.checked=true;leaf.insertBefore(cb,leaf.firstChild)}leaf.appendChild(document.createTextNode(node.label||node));li.appendChild(leaf)}return li}_renderWindow(rootUl,scrollTop){if(!this._treeData)return;const ih=this._itemHeight();const expanded=this._expanded||(this._expanded=new Set());const flat=[];this._flatten(this._treeData,"",1,expanded,flat);const total=flat.length;const viewportSize=rootUl.clientHeight||320;const visibleCount=Math.ceil(viewportSize/ih)+6;let start=Math.floor((scrollTop||0)/ih);if(start<0)start=0;if(start>Math.max(0,total-visibleCount))start=Math.max(0,total-visibleCount);const end=Math.min(total,start+visibleCount);const topSize=start*ih;const bottomSize=Math.max(0,(total-end)*ih);rootUl.innerHTML="";const top=document.createElement("div");top.className="c-tree__spacer c-tree__spacer--top";top.style.height=topSize+"px";rootUl.appendChild(top);for(let i=start;i<end;i++){rootUl.appendChild(this._renderNodeFlat(rootUl,flat[i]))}const bottom=document.createElement("div");bottom.className="c-tree__spacer c-tree__spacer--bottom";bottom.style.height=bottomSize+"px";rootUl.appendChild(bottom)}render(){this.classList.add("c-tree");const authored=Array.from(this.children).filter((n)=>!n.classList||!n.classList.contains("c-tree"));wireStates(this);loadRemote(this,"items");if(renderStates(this,"tree"))return;const items=remoteData(this,"items");if(items&&!authored.length){try{const parsed=JSON.parse(items);const rootUl=this.ensure("div.c-tree",()=>{const el=document.createElement("div");el.className="c-tree";el.setAttribute("role","tree");return el});rootUl.innerHTML="";rootUl.className="c-tree";rootUl.setAttribute("role","tree");const virtual=this.hasAttribute("virtual");if(virtual){this._treeData=parsed;this._expanded=this._expanded||new Set();this._treeRoot=rootUl;this._restoreExpanded();rootUl.style.maxHeight=rootUl.style.maxHeight||"24rem";rootUl.style.overflow="auto";const scrollTop=this._treeScrollTop||0;this._renderWindow(rootUl,scrollTop);try{rootUl.scrollTop=scrollTop}catch(e){}}else{this._treeData=null;const render=(nodes,parent,depth)=>{const ul=parent?document.createElement("div"):rootUl;if(parent){ul.className="c-tree__children";ul.setAttribute("role","group");if(supportsUntilFound())ul.setAttribute("hidden","until-found");else ul.setAttribute("hidden","")}nodes.forEach((node)=>{const li=document.createElement("div");li.className="c-tree__node";li.setAttribute("role","treeitem");li.setAttribute("aria-level",String(depth));if(node.children){li.setAttribute("aria-expanded","false");const row=document.createElement("div");row.className="c-tree__row"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");if(node.indent){const ind=document.createElement("span");ind.className="c-tree__indent";ind.style.inlineSize=(node.indent*1)+"rem";row.appendChild(ind)}const toggle=document.createElement("button");toggle.className="c-tree__toggle";toggle.setAttribute("type","button");toggle.setAttribute("aria-expanded","false");toggle.setAttribute("aria-label","Toggle");toggle.innerHTML='<svg aria-hidden="true"><use href="#i-chevron-right" /></svg>';row.appendChild(toggle);const span=document.createElement("span");span.textContent=node.label;row.appendChild(span);li.appendChild(row);render(node.children,li,depth+1)}else{const leaf=document.createElement("div");leaf.className="c-tree__leaf"+(node.active?" c-tree__row--active":"")+(node.dir?" c-tree__row--dir":"");if(node.indent){const ind=document.createElement("span");ind.className="c-tree__indent";ind.style.inlineSize=(node.indent*1)+"rem";leaf.appendChild(ind)}if(this.hasAttribute("selectable")){const cb=document.createElement("input");cb.type="checkbox";cb.className="c-tree__select";cb.setAttribute("aria-label","Select "+(node.label||node));leaf.insertBefore(cb,leaf.firstChild)}leaf.appendChild(document.createTextNode(node.label||node));li.appendChild(leaf)}ul.appendChild(li)});if(parent)parent.appendChild(ul)};render(parsed,null,1)}this.classList.remove("c-tree");rootUl.classList.add("c-tree");if(rootUl.parentNode!==this)this.appendChild(rootUl)}catch(e){}}else if(!items&&!authored.length){renderEmpty(this,"tree")}}enhance(){if(!this._wiredTreeToggle){this._wiredTreeToggle=true;this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-tree__toggle"):null;if(!toggle||!this.contains(toggle))return;e.stopPropagation();const nodeEl=toggle.closest(".c-tree__node");const path=nodeEl&&nodeEl.dataset?nodeEl.dataset.path:null;const expanded=toggle.getAttribute("aria-expanded")==="true";if(path&&this._expanded){if(expanded)this._expanded.delete(path);else this._expanded.add(path)}toggle.setAttribute("aria-expanded",String(!expanded));const row=toggle.closest(".c-tree__row");if(row)row.setAttribute("aria-expanded",String(!expanded));if(this.hasAttribute("virtual")&&this._treeRoot){const s=this._treeRoot;this._treeScrollTop=s.scrollTop||0;this._renderWindow(s,this._treeScrollTop);try{s.scrollTop=this._treeScrollTop}catch(err){}this._persistExpanded()}})}if(this.hasAttribute("virtual")&&!this._wiredTreeScroll){this._wiredTreeScroll=true;const attach=()=>{const s=this.querySelector(".c-tree");if(!s||s._treeScrollWired)return;s._treeScrollWired=true;let raf=0;const onScroll=()=>{if(raf)return;raf=requestAnimationFrame(()=>{raf=0;this._treeScrollTop=s.scrollTop||0;this._renderWindow(s,this._treeScrollTop);try{s.scrollTop=this._treeScrollTop}catch(err){}})};s.addEventListener("scroll",onScroll,{passive:true});onDispose(this,()=>{s.removeEventListener("scroll",onScroll);if(raf)cancelAnimationFrame(raf)})};attach();if(!this.querySelector(".c-tree")){const mo=new MutationObserver(()=>{if(this.querySelector(".c-tree")){attach();mo.disconnect()}});mo.observe(this,{childList:true,subtree:true});onDispose(this,()=>mo.disconnect())}}if(this.hasAttribute("virtual")&&!this._wiredTreeDragScroll){this._wiredTreeDragScroll=true;let dragScrollRaf=0;let dragScrollDir=0;const tick=()=>{if(!dragScrollDir){dragScrollRaf=0;return}const s=this._treeRoot;if(s){s.scrollTop+=dragScrollDir*8;this._treeScrollTop=s.scrollTop;this._renderWindow(s,this._treeScrollTop)}dragScrollRaf=requestAnimationFrame(tick)};this.addEventListener("dragover",(e)=>{const s=this._treeRoot;if(!s)return;const rect=s.getBoundingClientRect();const edge=40;if(e.clientY<rect.top+edge)dragScrollDir=-1;else if(e.clientY>rect.bottom-edge)dragScrollDir=1;else dragScrollDir=0;if(dragScrollDir&&!dragScrollRaf)dragScrollRaf=requestAnimationFrame(tick)});const stop=()=>{dragScrollDir=0;if(dragScrollRaf){cancelAnimationFrame(dragScrollRaf);dragScrollRaf=0}};this.addEventListener("dragend",stop);this.addEventListener("drop",stop)}wireTree(this)}}define("contour-tree",ContourTree);class ContourCodeTabs extends ContourBase{static get observed(){return["tabs","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist"]}static get properties(){return{tabs:{attribute:"tabs"},src:{attribute:"src"}}}render(){this.classList.add("c-code-tabs");wireStates(this);loadRemote(this,"tabs");if(renderStates(this,"code-tabs"))return;const tabs=remoteData(this,"tabs");const list=this.querySelector(".c-code-tabs__list");const authored=list?Array.from(list.children).filter((n)=>n.getAttribute&&n.getAttribute("role")==="tab"):[];if(tabs&&!authored.length){try{const parsed=JSON.parse(tabs);const l=this.ensure(".c-code-tabs__list",()=>{const el=document.createElement("div");el.className="c-code-tabs__list";el.setAttribute("role","tablist");return el});l.setAttribute("role","tablist");const _prevCodeTabs=Array.from(l.querySelectorAll("[role='tab']"));const _prevCodeSel=_prevCodeTabs.findIndex((t)=>t.getAttribute("aria-selected")==="true");const _keepCodeIdx=_prevCodeSel>=0?_prevCodeSel:0;l.innerHTML="";Array.from(this.querySelectorAll(".c-code-tabs__panel")).forEach((n)=>n.remove());parsed.forEach((t,i)=>{const label=typeof t==="string"?t:(t.label||t.title||"");const panelId=contourId("c-code-tabs-panel");const btn=document.createElement("button");btn.className="c-code-tabs__tab";btn.setAttribute("role","tab");btn.setAttribute("aria-selected",String(i===_keepCodeIdx));btn.setAttribute("aria-controls",panelId);btn.tabIndex=i===_keepCodeIdx?0:-1;btn.textContent=label;l.appendChild(btn);const panel=document.createElement("div");panel.className="c-code-tabs__panel";panel.id=panelId;panel.setAttribute("role","tabpanel");if(typeof t==="object"&&t!==null&&t.content!==undefined){panel.textContent=String(t.content)}if(i!==_keepCodeIdx)panel.hidden=true;this.appendChild(panel)});if(l.parentNode!==this)this.prepend(l)}catch(e){}}else if(!tabs&&list){list.remove();renderEmpty(this,"code-tabs")}else if(!tabs&&!list){renderEmpty(this,"code-tabs")}}enhance(){wireTabs(this)}}define("contour-code-tabs",ContourCodeTabs);class ContourBreadcrumb extends ContourBase{static get observed(){return["items","separator","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},separator:{attribute:"separator"},max:{attribute:"max",type:Number},src:{attribute:"src"}}};render(){this.classList.add("c-breadcrumb");wireStates(this);loadRemote(this,"items");if(renderStates(this,"breadcrumb"))return;const items=remoteData(this,"items");const nav=this.querySelector("nav");const ol=nav?nav.querySelector("ol"):null;const authored=ol?Array.from(ol.children).filter((n)=>n.tagName==="LI"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const n=this.ensure("nav",()=>{const el=document.createElement("nav");el.setAttribute("aria-label","Breadcrumb");el.id="contour-breadcrumb-list";return el});n.setAttribute("aria-label","Breadcrumb");n.id="contour-breadcrumb-list";n.innerHTML="";const sep=this.getAttribute("separator")||"/";const max=this._overflowExpanded?null:this.max;const shown=Number.isFinite(max)&&max>1&&parsed.length>max?parsed.slice(-max):parsed;if(Number.isFinite(max)&&max>1&&parsed.length>max){const btn=document.createElement("button");btn.type="button";btn.className="c-breadcrumb__overflow";btn.setAttribute("aria-label",`Show ${parsed.length - shown.length + 1} more items`);btn.setAttribute("aria-expanded","false");btn.setAttribute("aria-controls","contour-breadcrumb-list");btn.textContent="…";btn.addEventListener("click",()=>{this._overflowExpanded=true;this.requestRender()});n.appendChild(btn)}shown.forEach((item,i)=>{if(i<shown.length-1){const a=document.createElement("a");a.href=item.href||"#";a.textContent=item.label||item;n.appendChild(a);const s=document.createElement("span");s.className="c-breadcrumb__sep";s.setAttribute("aria-hidden","true");s.textContent=sep;n.appendChild(s)}else{const span=document.createElement("span");span.textContent=item.label||item;span.setAttribute("aria-current","page");n.appendChild(span)}})}catch(e){}}else if(!items&&nav){nav.remove()}else if(!items&&!nav){renderEmpty(this,"breadcrumb")}}}define("contour-breadcrumb",ContourBreadcrumb);class ContourPagination extends ContourBase{static get observed(){return["pages","current","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist"]}static get properties(){return{pages:{attribute:"pages"},current:{attribute:"current"},src:{attribute:"src"}}}render(){this.classList.add("c-pagination");wireStates(this);loadRemote(this,"pages");if(renderStates(this,"pagination"))return;const pages=remoteData(this,"pages");Array.from(this.querySelectorAll(".c-pagination__link")).forEach((n)=>n.remove());let currentAttr=this.getAttribute("current")||"1";if(this.getAttribute("persist")==="storage"&&this.id){try{const stored=localStorage.getItem("contour-pagination:"+this.id);if(stored!==null)currentAttr=stored}catch(e){}}else if(this.getAttribute("persist")==="url"){try{const v=new URLSearchParams(window.location.search).get("c-pagination");if(v!==null)currentAttr=v}catch(e){}}const current=parseInt(currentAttr,"10")||1;if(pages){let count=parseInt(pages,10);if(!Number.isFinite(count)||count<1){try{const p=JSON.parse(pages);if(Array.isArray(p))count=p.length}catch(e){}}const prev=document.createElement("button");prev.type="button";prev.className="c-pagination__link c-pagination__prev";prev.setAttribute("data-action","prev");prev.textContent="‹";prev.setAttribute("aria-label","Previous page");this.appendChild(prev);for(let i=1;i<=count;i++){const btn=document.createElement("button");btn.type="button";btn.className="c-pagination__link";btn.textContent=String(i);if(i===current){btn.setAttribute("aria-current","page")}this.appendChild(btn)}const next=document.createElement("button");next.type="button";next.className="c-pagination__link c-pagination__next";next.setAttribute("data-action","next");next.textContent="›";next.setAttribute("aria-label","Next page");this.appendChild(next)}else{renderEmpty(this,"pagination")}}enhance(){wirePagination(this)}}define("contour-pagination",ContourPagination);class ContourPagerFull extends ContourBase{static get observed(){return["prev","next"]}static get properties(){return{prev:{attribute:"prev"},next:{attribute:"next"}}}render(){this.classList.add("c-pager");Array.from(this.querySelectorAll(".c-pager__link")).forEach((n)=>n.remove());const prev=this.getAttribute("prev");const next=this.getAttribute("next");if(prev){const a=document.createElement("a");a.className="c-pager__link";a.href=prev.split("|")[1]||"#";const dir=document.createElement("span");dir.className="c-pager__dir";dir.textContent="← Previous";a.appendChild(dir);const title=document.createElement("span");title.className="c-pager__title";title.textContent=prev.split("|")[0];a.appendChild(title);this.appendChild(a)}if(next){const a=document.createElement("a");a.className="c-pager__link c-pager__link--next";a.href=next.split("|")[1]||"#";const dir=document.createElement("span");dir.className="c-pager__dir";dir.textContent="Next →";a.appendChild(dir);const title=document.createElement("span");title.className="c-pager__title";title.textContent=next.split("|")[0];a.appendChild(title);this.appendChild(a)}}}define("contour-pager",ContourPagerFull);class ContourTocFull extends ContourBase{static get observed(){return["title","items","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{title:{attribute:"title"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-toc");this.setAttribute("role","list");wireStates(this);loadRemote(this,"items");if(renderStates(this,"toc"))return;const items=remoteData(this,"items");const title=this.getAttribute("title")||"On this page";const titleEl=this.ensure(".c-toc__title",()=>{const el=document.createElement("div");el.className="c-toc__title";return el});titleEl.textContent=title;const list=this.querySelector(".c-toc__list");const authored=list?Array.from(list.children).filter((n)=>n.tagName==="A"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-toc__list",()=>{const el=document.createElement("nav");el.className="c-toc__list";return el});l.className="c-toc__list";l.setAttribute("aria-label",title);l.innerHTML="";parsed.forEach((item)=>{const a=document.createElement("a");a.className="c-toc__link"+(item.sub?" c-toc__link--sub":"");a.href=item.href||"#";a.textContent=item.label||item;if(item.current)a.setAttribute("aria-current","true");l.appendChild(a)})}catch(e){}}else if(!items&&list){list.remove();renderEmpty(this,"toc")}else if(!items&&!list){renderEmpty(this,"toc")}}enhance(){if(this._wiredTocSpy)return;if(typeof IntersectionObserver!=="function")return;const links=()=>Array.from(this.querySelectorAll(".c-toc__link"));const targets=links().map((a)=>{const href=a.getAttribute("href")||"";if(!href.startsWith("#")||href.length<2)return null;return document.getElementById(href.slice(1))}).filter(Boolean);if(!targets.length)return;this._wiredTocSpy=true;const spy=new IntersectionObserver((entries)=>{const visible=entries.filter((en)=>en.isIntersecting).map((en)=>en.target.id);if(!visible.length)return;const top=visible[0];links().forEach((a)=>{const href=a.getAttribute("href")||"";const isCurrent=href==="#"+top;if(isCurrent&&a.getAttribute("aria-current")!=="true")a.setAttribute("aria-current","true");else if(!isCurrent&&a.hasAttribute("aria-current"))a.removeAttribute("aria-current")})},{rootMargin:"0px 0px -60% 0px",threshold:0});targets.forEach((t)=>spy.observe(t));onDispose(this,()=>spy.disconnect());if(!this._wiredTocScroll){this._wiredTocScroll=true;this.addEventListener("click",(e)=>{const a=e.target&&e.target.closest?e.target.closest(".c-toc__link"):null;if(!a||!this.contains(a))return;const href=a.getAttribute("href")||"";if(!href.startsWith("#")||href.length<2)return;const target=document.getElementById(href.slice(1));if(!target)return;e.preventDefault();try{target.scrollIntoView({behavior:"smooth",block:"start"})}catch(err){target.scrollIntoView()}})}}}define("contour-toc",ContourTocFull);class ContourFilterBar extends ContourBase{static get observed(){return["label","divider","items","input","placeholder","mode","modes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","count","clearable"]}static get properties(){return{label:{attribute:"label"},divider:{attribute:"divider"},items:{attribute:"items"},src:{attribute:"src"},count:{attribute:"count"},clearable:{attribute:"clearable"}}}render(){this.classList.add("c-filter-bar");wireStates(this);loadRemote(this,"items");if(renderStates(this,"filter-bar"))return;const label=this.getAttribute("label");if(label){const l=this.ensure(".c-filter-bar__label",()=>{const el=document.createElement("span");el.className="c-filter-bar__label";return el});l.textContent=label}else{const l=this.querySelector(".c-filter-bar__label");if(l)l.remove()}if(this.hasAttribute("divider")){this.ensure(".c-filter-bar__divider",()=>{const el=document.createElement("span");el.className="c-filter-bar__divider";return el})}else{const d=this.querySelector(".c-filter-bar__divider");if(d)d.remove()}if(this.hasAttribute("input")||this.hasAttribute("placeholder")){let inp=this.querySelector(".c-filter-bar__input");if(!inp){inp=document.createElement("input");inp.type="search";inp.className="c-filter-bar__input";this.appendChild(inp)}const ph=this.getAttribute("placeholder");if(ph)inp.setAttribute("placeholder",ph)}else{const inp=this.querySelector(".c-filter-bar__input");if(inp)inp.remove()}const modesAttr=this.getAttribute("modes");let modes=null;if(modesAttr){try{modes=JSON.parse(modesAttr)}catch(e){modes=modesAttr.split(",").map((s)=>s.trim())}}if(modes||this.hasAttribute("mode")){let bar=this.querySelector(".c-filter-bar__modes");if(!bar){bar=document.createElement("div");bar.className="c-filter-bar__modes";bar.setAttribute("role","toolbar");bar.setAttribute("aria-label",label||"Filter modes");this.appendChild(bar)}bar.innerHTML="";const current=this.getAttribute("mode");const list=Array.isArray(modes)?modes:["draw","erase","select"];list.forEach((m)=>{const name=typeof m==="string"?m:(m.label||m.value||m);const val=typeof m==="string"?m:(m.value||m.label||m);const btn=document.createElement("button");btn.type="button";btn.className="c-filter-bar__mode";btn.textContent=name;btn.dataset.mode=val;if(current&¤t===val)btn.setAttribute("aria-pressed","true");bar.appendChild(btn)})}else{const bar=this.querySelector(".c-filter-bar__modes");if(bar)bar.remove()}Array.from(this.querySelectorAll(".c-filter-pill")).forEach((n)=>n.remove());const items=remoteData(this,"items");const authoredPills=Array.from(this.querySelectorAll(":scope > .c-filter-pill"));let parsed=null;if(authoredPills.length){parsed=authoredPills.map((p)=>p.textContent.trim());authoredPills.forEach((p)=>p.remove())}else if(items){try{parsed=JSON.parse(items)}catch(e){parsed=null}}if(Array.isArray(parsed)){parsed.forEach((it)=>{const pill=document.createElement("span");pill.className="c-filter-pill";const txt=typeof it==="string"?it:(it.label||it.value||"");pill.textContent=txt;if(typeof it==="object"&&it!==null&&it.removable!==false){const btn=document.createElement("button");btn.className="c-filter-pill__remove";btn.type="button";btn.setAttribute("aria-label","Remove "+txt);btn.textContent="×";pill.appendChild(btn)}this.appendChild(pill)})}Array.from(this.querySelectorAll(".c-filter-bar__clear-all")).forEach((n)=>n.remove());if(this.hasAttribute("clearable")){const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-btn--sm c-filter-bar__clear-all";const count=this.getAttribute("count");btn.textContent=count?("Clear all ("+count+")"):"Clear all";this.appendChild(btn)}if(!parsed&&!label)renderEmpty(this,"filter-bar")}enhance(){wireRemovable(this);if(this._wiredFilterBar)return;this._wiredFilterBar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-filter-bar__mode"):null;if(!btn||!this.contains(btn))return;const mode=btn.dataset.mode||btn.textContent.trim();Array.from(this.querySelectorAll(".c-filter-bar__mode")).forEach((b)=>b.setAttribute("aria-pressed",String(b===btn)));this.dispatchEvent(new CustomEvent("contour:mode-change",{bubbles:true,composed:true,detail:{mode}}))});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-filter-bar__mode"):null;if(!btn||!this.contains(btn))return;const modes=Array.from(this.querySelectorAll(".c-filter-bar__mode"));const idx=modes.indexOf(btn);let next=-1;if(e.key==="ArrowRight")next=Math.min(modes.length-1,idx+1);else if(e.key==="ArrowLeft")next=Math.max(0,idx-1);if(next>=0){e.preventDefault();try{modes[next].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}});const inp=this.querySelector(".c-filter-bar__input");if(inp&&!inp._wiredFilterInput){inp._wiredFilterInput=true;inp.addEventListener("input",()=>{this.dispatchEvent(new CustomEvent("contour:input",{bubbles:true,composed:true,detail:{value:inp.value}}))});inp.addEventListener("change",()=>{this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:inp.value}}))})}if(!this._wiredClearAll){this._wiredClearAll=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-filter-bar__clear-all"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:clear-all",{bubbles:true,composed:true,detail:{}}))})}}}define("contour-filter-bar",ContourFilterBar);class ContourCommand extends ContourBase{static get observed(){return["placeholder","items","recent","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{placeholder:{attribute:"placeholder"},items:{attribute:"items"},recent:{attribute:"recent"},empty:{attribute:"empty"},src:{attribute:"src"}}}render(){this.classList.add("c-command");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Command palette");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");wireStates(this);loadRemote(this,"items");if(renderStates(this,"command"))return;const placeholder=this.getAttribute("placeholder")||"Search…";const input=this.ensure(".c-command__input",()=>{const el=document.createElement("input");el.className="c-command__input";el.type="text";return el});input.type="text";input.placeholder=placeholder;input.setAttribute("aria-label","Command");input.setAttribute("role","combobox");input.setAttribute("aria-autocomplete","list");input.setAttribute("aria-expanded","true");const list=this.querySelector(".c-command__list");if(list&&!list.id)list.id=contourId("c-command-list");if(list&&list.id)input.setAttribute("aria-controls",list.id);const items=remoteData(this,"items");const list2=this.querySelector(".c-command__list");const authored=list2?Array.from(list2.children).filter((n)=>n.classList&&n.classList.contains("c-command__item")||n.classList&&n.classList.contains("c-command__group")):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-command__list",()=>{const el=document.createElement("div");el.className="c-command__list";el.setAttribute("role","listbox");el.id=contourId("c-command-list");return el});l.setAttribute("role","listbox");l.innerHTML="";const recentRaw=this.getAttribute("recent");if(recentRaw){try{const recentParsed=JSON.parse(recentRaw);const group=document.createElement("div");group.className="c-command__group";const gt=document.createElement("div");gt.className="c-command__group-title";gt.textContent="Recent";group.appendChild(gt);recentParsed.forEach((it)=>{const item=document.createElement("div");item.className="c-command__item";item.setAttribute("role","option");const body=document.createElement("div");body.className="c-command__item-body";const t=document.createElement("div");t.className="c-command__item-title";t.textContent=typeof it==="string"?it:(it.title||it.label||"");body.appendChild(t);item.appendChild(body);group.appendChild(item)});l.appendChild(group)}catch(e){}}parsed.forEach((it)=>{if(it.group){const group=document.createElement("div");group.className="c-command__group";const gt=document.createElement("div");gt.className="c-command__group-title";gt.textContent=it.group;group.appendChild(gt);const item=document.createElement("div");item.className="c-command__item";item.setAttribute("role","option");if(it.icon){const ic=document.createElement("span");ic.className="c-command__item-icon";ic.textContent=it.icon;item.appendChild(ic)}const body=document.createElement("div");body.className="c-command__item-body";if(it.title||it.label){const t=document.createElement("div");t.className="c-command__item-title";t.textContent=it.title||it.label;body.appendChild(t)}if(it.hint){const h=document.createElement("span");h.className="c-command__item-hint";h.textContent=it.hint;body.appendChild(h)}if(it.shortcut){const sc=document.createElement("kbd");sc.className="c-command__item-shortcut";sc.textContent=it.shortcut;item.appendChild(sc)}item.appendChild(body);group.appendChild(item);l.appendChild(group)}else{const item=document.createElement("div");item.className="c-command__item";item.setAttribute("role","option");if(it.icon){const ic=document.createElement("span");ic.className="c-command__item-icon";ic.textContent=it.icon;item.appendChild(ic)}const body=document.createElement("div");body.className="c-command__item-body";if(it.title||it.label){const t=document.createElement("div");t.className="c-command__item-title";t.textContent=it.title||it.label;body.appendChild(t)}if(it.hint){const h=document.createElement("span");h.className="c-command__item-hint";h.textContent=it.hint;body.appendChild(h)}if(it.shortcut){const sc=document.createElement("kbd");sc.className="c-command__item-shortcut";sc.textContent=it.shortcut;item.appendChild(sc)}item.appendChild(body);l.appendChild(item)}})}catch(e){}}else if(!items&&list){list.remove()}const empty=this.getAttribute("empty");if(empty){const e=this.ensure(".c-command__empty",()=>{const el=document.createElement("div");el.className="c-command__empty";return el});e.textContent=empty}else{const e=this.querySelector(".c-command__empty");if(e)e.remove()}const status=this.ensure(".c-command__status",()=>{const el=document.createElement("div");el.className="c-command__status";el.setAttribute("role","status");return el});status.textContent="";if(!items&&!list){renderEmpty(this,"command")}}enhance(){if(this._wiredCommand)return;this._wiredCommand=true;const input=()=>this.querySelector(".c-command__input");const items=()=>Array.from(this.querySelectorAll(".c-command__item"));let cursor=-1;const mark=()=>{items().forEach((it,i)=>{it.classList.toggle("c-command__item--active",i===cursor);it.setAttribute("aria-selected",String(i===cursor));if(i===cursor){if(!it.id)it.id="contour-command-option-"+i;const inp=input();if(inp)inp.setAttribute("aria-activedescendant",it.id)}});if(cursor<0){const inp=input();if(inp)inp.removeAttribute("aria-activedescendant")}};this.addEventListener("keydown",(e)=>{const inp=input();if(!inp||e.target!==inp)return;const its=items();if(!its.length)return;if(e.key==="ArrowDown"){e.preventDefault();cursor=Math.min(cursor+1,its.length-1);mark()}else if(e.key==="ArrowUp"){e.preventDefault();cursor=Math.max(cursor-1,0);mark()}else if(e.key==="Home"){e.preventDefault();cursor=0;mark()}else if(e.key==="End"){e.preventDefault();cursor=its.length-1;mark()}else if(e.key==="Enter"){e.preventDefault();if(cursor>=0&&its[cursor]){const item=its[cursor];const idx=items().indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{detail:{index:idx,label:item.textContent.trim()},bubbles:true,composed:true}))}}else if(e.key==="Escape"){if(typeof this.hidePopover==="function")this.hidePopover()}});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-command__item"):null;if(item&&this.contains(item)){const idx=items().indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{detail:{index:idx,label:item.textContent.trim()},bubbles:true,composed:true}))}});this.addEventListener("input",(e)=>{const inp=input();if(!inp||e.target!==inp)return;const q=inp.value.trim().toLowerCase();const all=items();let visible=0;all.forEach((it)=>{const match=!q||(it.textContent||"").toLowerCase().includes(q);it.hidden=!match;if(match)visible+=1});this.querySelectorAll(".c-command__group").forEach((g)=>{const hasVisible=Array.from(g.querySelectorAll(".c-command__item")).some((it)=>!it.hidden);g.hidden=!hasVisible});cursor=-1;mark();const status=this.querySelector(".c-command__status");if(status)status.textContent=q?`${visible} of ${all.length}`:""})}}define("contour-command",ContourCommand);class ContourFooter extends ContourBase{static get observed(){return["brand","note","links","cols","heading"]}static get properties(){return{brand:{attribute:"brand"},note:{attribute:"note"},links:{attribute:"links"},cols:{attribute:"cols"}}}render(){this.classList.add("c-footer");const brand=this.getAttribute("brand");if(brand){const b=this.ensure(".c-footer__brand",()=>{const el=document.createElement("div");el.className="c-footer__brand";return el});b.textContent=brand}else{const b=this.querySelector(".c-footer__brand");if(b)b.remove()}const note=this.getAttribute("note");if(note){const n=this.ensure(".c-footer__note",()=>{const el=document.createElement("p");el.className="c-footer__note";return el});n.textContent=note}else{const n=this.querySelector(".c-footer__note");if(n)n.remove()}const links=this.getAttribute("links");if(links){try{const parsed=JSON.parse(links);const wrap=this.ensure(".c-footer__links",()=>{const el=document.createElement("div");el.className="c-footer__links";return el});wrap.innerHTML="";parsed.forEach((l)=>{const a=document.createElement("a");a.href=typeof l==="string"?"#":(l.href||"#");a.textContent=typeof l==="string"?l:(l.label||l);wrap.appendChild(a)})}catch(e){}}else{const w=this.querySelector(".c-footer__links");if(w)w.remove()}const cols=this.getAttribute("cols");if(cols){try{const parsed=JSON.parse(cols);this.querySelectorAll(".c-footer__col").forEach((c)=>c.remove());parsed.forEach((col)=>{const c=document.createElement("div");c.className="c-footer__col";if(col.title){const h=document.createElement(headingTag(this,"h3"));h.textContent=col.title;c.appendChild(h)}(col.links||[]).forEach((l)=>{const a=document.createElement("a");a.href=typeof l==="string"?"#":(l.href||"#");a.textContent=typeof l==="string"?l:(l.label||l);c.appendChild(a)});this.appendChild(c)})}catch(e){}}else{this.querySelectorAll(".c-footer__col").forEach((c)=>c.remove())}}}define("contour-footer",ContourFooter);class ContourSchemeToggle extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-scheme-toggle")}enhance(){if(this._wiredScheme)return;this._wiredScheme=true;this.addEventListener("click",()=>{const root=document.documentElement;root.classList.add("is-theme-switching");const current=root.getAttribute("data-theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");const next=current==="dark"?"light":"dark";root.setAttribute("data-theme",next);try{localStorage.setItem("contour-theme",next)}catch(e){}requestAnimationFrame(()=>requestAnimationFrame(()=>root.classList.remove("is-theme-switching")));this.dispatchEvent(new CustomEvent("contour:theme-change",{detail:{theme:next},bubbles:true,composed:true}))});try{const stored=localStorage.getItem("contour-theme");if(stored)document.documentElement.setAttribute("data-theme",stored)}catch(e){}}}define("contour-scheme-toggle",ContourSchemeToggle);class ContourSidebar extends ContourBase{static get observed(){return["title","items","collapsed"]}static get properties(){return{title:{attribute:"title"},items:{attribute:"items"},collapsed:{attribute:"collapsed",type:Boolean}}}render(){this.classList.add("c-sidebar");if(this.hasAttribute("collapsed"))this.classList.add("c-sidebar--collapsed");else this.classList.remove("c-sidebar--collapsed");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-sidebar__title",()=>{const el=document.createElement("div");el.className="c-sidebar__title";return el});t.textContent=title}else{const t=this.querySelector(".c-sidebar__title");if(t)t.remove()}const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);const nav=this.ensure("nav.c-sidebar__nav",()=>{const el=document.createElement("nav");el.className="c-sidebar__nav";return el});nav.innerHTML="";parsed.forEach((it)=>{const a=document.createElement("a");a.className="c-sidebar__link";a.href=(it&&it.href)||"#";a.textContent=(it&&(it.label||it))||"";nav.appendChild(a)})}catch(e){}}}enhance(){if(this._wiredSidebar)return;this._wiredSidebar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-sidebar__toggle"):null;if(!btn||!this.contains(btn))return;this.toggleAttribute("collapsed")})}}define("contour-sidebar",ContourSidebar);class ContourToolbar extends ContourBase{static get observed(){return["title","actions","overflow"]}static get properties(){return{title:{attribute:"title"},actions:{attribute:"actions"},overflow:{attribute:"overflow",type:Number}}}render(){this.classList.add("c-toolbar");const title=this.getAttribute("title");this.setAttribute("role","toolbar");if(title)this.setAttribute("aria-label",title);const actions=this.getAttribute("actions");if(actions){try{const parsed=JSON.parse(actions);const limit=this.overflow&&this.overflow>0?this.overflow:parsed.length;const visible=parsed.slice(0,limit);const excess=parsed.slice(limit);visible.forEach((a)=>{const btn=document.createElement("button");btn.className="c-toolbar__btn";btn.type="button";btn.textContent=typeof a==="string"?a:(a.label||a);this.appendChild(btn)});if(excess.length){const wrap=document.createElement("div");wrap.className="c-toolbar__overflow";const btn=document.createElement("button");btn.className="c-toolbar__btn c-toolbar__overflow-btn";btn.type="button";btn.setAttribute("aria-haspopup","menu");btn.setAttribute("aria-expanded","false");btn.textContent="…";wrap.appendChild(btn);const menu=document.createElement("div");menu.className="c-toolbar__overflow-menu";menu.setAttribute("role","menu");menu.setAttribute("hidden","");excess.forEach((a)=>{const mbtn=document.createElement("button");mbtn.className="c-toolbar__btn";mbtn.type="button";mbtn.setAttribute("role","menuitem");mbtn.textContent=typeof a==="string"?a:(a.label||a);menu.appendChild(mbtn)});wrap.appendChild(menu);this.appendChild(wrap)}}catch(e){}}}enhance(){if(this._wiredToolbar)return;this._wiredToolbar=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-toolbar__overflow-btn"):null;if(!btn||!this.contains(btn))return;const menu=btn.parentElement&&btn.parentElement.querySelector(".c-toolbar__overflow-menu");if(!menu)return;const open=menu.hasAttribute("hidden");if(open)menu.removeAttribute("hidden");else menu.setAttribute("hidden","");btn.setAttribute("aria-expanded",String(open))})}}define("contour-toolbar",ContourToolbar);class ContourSpatialFilter extends ContourBase{static get observed(){return["modes","mode","active","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{modes:{attribute:"modes"},mode:{attribute:"mode"},active:{attribute:"active"},src:{attribute:"src"}}}render(){this.classList.add("c-spatial-filter");wireStates(this);loadRemote(this,[]);if(renderStates(this,"spatial-filter"))return;const modesAttr=this.getAttribute("modes");let modes=null;if(modesAttr){try{modes=JSON.parse(modesAttr)}catch(e){modes=modesAttr.split(",").map((s)=>s.trim())}}const list=Array.isArray(modes)?modes:["rect","circle","polygon","clear"];let bar=this.querySelector(".c-spatial-filter__modes");if(!bar){bar=document.createElement("div");bar.className="c-spatial-filter__modes";bar.setAttribute("role","toolbar");this.appendChild(bar)}bar.innerHTML="";const current=this.getAttribute("mode");list.forEach((m)=>{const name=typeof m==="string"?m:(m.label||m.value||m);const val=typeof m==="string"?m:(m.value||m.label||m);const btn=document.createElement("button");btn.type="button";btn.className="c-spatial-filter__mode c-btn c-btn--ghost c-btn--sm";btn.textContent=name;btn.dataset.mode=val;if(current&¤t===val)btn.setAttribute("aria-pressed","true");bar.appendChild(btn)});if(this.hasAttribute("active")){this.classList.add("c-spatial-filter--active")}else{this.classList.remove("c-spatial-filter--active")}}enhance(){if(this._wiredSpatialFilter)return;this._wiredSpatialFilter=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-spatial-filter__mode"):null;if(!btn||!this.contains(btn))return;const mode=btn.dataset.mode||btn.textContent.trim();if(mode==="clear"){this.classList.remove("c-spatial-filter--active");Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach((b)=>b.setAttribute("aria-pressed","false"));this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:true,composed:true,detail:{}}));return}this.classList.add("c-spatial-filter--active");Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach((b)=>b.setAttribute("aria-pressed",String(b===btn)));this.dispatchEvent(new CustomEvent("contour:draw-start",{bubbles:true,composed:true,detail:{mode}}))});this.addEventListener("keydown",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-spatial-filter__mode"):null;if(!btn||!this.contains(btn))return;const modes=Array.from(this.querySelectorAll(".c-spatial-filter__mode"));const idx=modes.indexOf(btn);let next=-1;if(e.key==="ArrowRight")next=Math.min(modes.length-1,idx+1);else if(e.key==="ArrowLeft")next=Math.max(0,idx-1);if(next>=0){e.preventDefault();try{modes[next].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();btn.click()}})}}define("contour-spatial-filter",ContourSpatialFilter);class ContourAvatar extends ContourBase{static get observed(){return["name","size","variant","src","status"]}static get properties(){return{name:{attribute:"name"},size:{attribute:"size"},variant:{attribute:"variant"},src:{attribute:"src"},status:{attribute:"status"}}}render(){this.classList.add("c-avatar");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-avatar--"))this.classList.remove(c)});const name=this.getAttribute("name");const size=this.getAttribute("size");if(size)this.classList.add("c-avatar--"+size);const variant=this.getAttribute("variant");if(variant)this.classList.add("c-avatar--"+variant);const oldImg=this.querySelector("img.c-avatar__img");if(oldImg)oldImg.remove();const oldDot=this.querySelector(".c-avatar__status");if(oldDot)oldDot.remove();const src=this.getAttribute("src");if(src){this.textContent="";const img=document.createElement("img");img.className="c-avatar__img";img.src=src;img.alt=name||"";img.loading="lazy";img.decoding="async";this.appendChild(img)}else if(name){const initials=name.split(" ").map((w)=>w[0]).join("").toUpperCase().slice(0,2);if(!this.querySelector("img.c-avatar__img")){}this.textContent=initials}const status=this.getAttribute("status");if(status){const dot=document.createElement("span");dot.className="c-avatar__status c-avatar__status--"+status;dot.setAttribute("aria-hidden","true");this.appendChild(dot)}}}define("contour-avatar",ContourAvatar);class ContourBadgeFull extends ContourBase{static get observed(){return["variant","label","size","removable"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"},size:{attribute:"size"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-badge");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-badge--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-badge--"+variant);const size=this.getAttribute("size");if(size)this.classList.add("c-badge--"+size);const label=this.getAttribute("label");if(label){let textNode=null;for(const n of this.childNodes){if(n.nodeType===3){textNode=n;break}}if(textNode)textNode.nodeValue=label;else this.insertBefore(document.createTextNode(label),this.firstChild)}if(this.hasAttribute("removable")){this.ensure(".c-badge__remove",()=>{const btn=document.createElement("button");btn.className="c-badge__remove";btn.type="button";btn.setAttribute("aria-label","Remove");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-badge__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-badge",ContourBadgeFull);class ContourChipFull extends ContourBase{static get observed(){return["variant","key","value"]}static get properties(){return{variant:{attribute:"variant"},key:{attribute:"key"},value:{attribute:"value"}}}render(){this.classList.add("c-chip");if(!this.hasAttribute("role"))this.setAttribute("role","status");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-chip--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-chip--"+variant);const key=this.getAttribute("key");const value=this.getAttribute("value");if(key){const k=this.ensure(".c-chip__key",()=>{const el=document.createElement("span");el.className="c-chip__key";return el});k.textContent=key}else{const k=this.querySelector(".c-chip__key");if(k)k.remove()}if(value){const v=this.ensure(".c-chip__value",()=>{const el=document.createElement("span");el.className="c-chip__value";return el});v.textContent=value}else{const v=this.querySelector(".c-chip__value");if(v)v.remove()}}}define("contour-chip",ContourChipFull);class ContourTag extends ContourBase{static get observed(){return["label","removable","variant"]}static get properties(){return{label:{attribute:"label"},removable:{attribute:"removable",type:Boolean},variant:{attribute:"variant"}}}render(){this.classList.add("c-tag");if(!this.hasAttribute("role"))this.setAttribute("role","status");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-tag--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-tag--"+variant);const label=this.getAttribute("label");if(label){let textNode=null;for(const n of this.childNodes){if(n.nodeType===3){textNode=n;break}}if(textNode)textNode.nodeValue=label+" ";else this.insertBefore(document.createTextNode(label+" "),this.firstChild)}if(this.hasAttribute("removable")){this.ensure(".c-tag__remove",()=>{const btn=document.createElement("button");btn.className="c-tag__remove";btn.type="button";btn.setAttribute("aria-label","Remove");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-tag__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-tag",ContourTag);class ContourDot extends ContourBase{static get observed(){return["variant","live"]}static get properties(){return{variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-dot");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","status indicator");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-dot--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-dot--"+variant);if(this.hasAttribute("live"))this.classList.add("c-dot--live");else this.classList.remove("c-dot--live")}}define("contour-dot",ContourDot);class ContourPill extends ContourBase{static get observed(){return["label","live","variant"]}static get properties(){return{label:{attribute:"label"},live:{attribute:"live",type:Boolean},variant:{attribute:"variant"}}}render(){this.classList.add("c-pill");if(!this.hasAttribute("role"))this.setAttribute("role","status");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-pill--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-pill--"+variant);const label=this.getAttribute("label");if(label){this.textContent=label}if(this.hasAttribute("live"))this.classList.add("c-pill--live");else this.classList.remove("c-pill--live")}}define("contour-pill",ContourPill);class ContourKbd extends ContourBase{static get observed(){return["key"]}static get properties(){return{key:{attribute:"key"}}}render(){this.classList.add("c-kbd");const key=this.getAttribute("key");if(key){this.textContent=key}}}define("contour-kbd",ContourKbd);class ContourSpinner extends ContourBase{static get observed(){return["size"]}static get properties(){return{size:{attribute:"size"}}}render(){this.classList.add("c-spinner");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-spinner--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-spinner--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Loading")}}define("contour-spinner",ContourSpinner);class ContourSkeleton extends ContourBase{static get observed(){return["size","shimmer"]}static get properties(){return{size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-skeleton--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-skeleton--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Loading");if(!this.hasAttribute("aria-busy"))this.setAttribute("aria-busy","true");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true");const shimmer=this.getAttribute("shimmer");if(shimmer==="false"||shimmer==="off")this.classList.add("c-skeleton--static");else this.classList.remove("c-skeleton--static")}}define("contour-skeleton",ContourSkeleton);class ContourTooltip extends ContourBase{static get observed(){return["text","anchor","delay","trigger"]}static get properties(){return{text:{attribute:"text"},anchor:{attribute:"anchor"},delay:{attribute:"delay",type:Number},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-tooltip");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.hasAttribute("role"))this.setAttribute("role","tooltip");if(!this.id)this.id=contourId("tip");const text=this.getAttribute("text");if(text!==null&&!this.hasChildNodes()){this.textContent=text}}enhance(){if(this._wiredTooltip)return;this._wiredTooltip=true;const anchorSel=this.getAttribute("anchor");if(anchorSel){let trigger=null;if(anchorSel.startsWith("#")){trigger=document.getElementById(anchorSel.slice(1))}else{trigger=document.querySelector(anchorSel)}if(trigger){trigger.setAttribute("popovertarget",this.id||(this.id=contourId("tip")));trigger.setAttribute("aria-describedby",this.id)}}const delayMs=(this.delay&&this.delay>0)?this.delay:0;let showTimer=null;const hasPopover=typeof this.showPopover==="function";const show=()=>{if(showTimer)clearTimeout(showTimer);if(delayMs>0)showTimer=setTimeout(()=>{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");try{requestAnimationFrame(flipIfNeeded)}catch(e){flipIfNeeded()}},delayMs);else{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");try{requestAnimationFrame(flipIfNeeded)}catch(e){flipIfNeeded()}}};const hide=()=>{if(showTimer){clearTimeout(showTimer);showTimer=null}if(hasPopover){try{this.hidePopover()}catch(e){}}else this.classList.remove("is-open")};const triggerMode=this.getAttribute("trigger")||"hover";const trigger=anchorSel?(anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel)):null;const target=trigger||this;const onEnter=()=>{if(triggerMode!=="click")show()};const onLeave=()=>{if(triggerMode!=="click")hide()};const onFocus=()=>{if(triggerMode!=="click")show()};const onBlur=()=>{if(triggerMode!=="click")hide()};const onClick=()=>{if(triggerMode==="click"||triggerMode==="hover"){if(this.matches(":popover-open"))hide();else show()}};const onTouchStart=()=>{if(triggerMode!=="click")show()};const onTouchEnd=()=>{if(triggerMode!=="click"){setTimeout(hide,1500)}};target.addEventListener("mouseenter",onEnter);target.addEventListener("mouseleave",onLeave);target.addEventListener("focus",onFocus);target.addEventListener("blur",onBlur);target.addEventListener("click",onClick);target.addEventListener("touchstart",onTouchStart,{passive:true});target.addEventListener("touchend",onTouchEnd,{passive:true});const flipIfNeeded=()=>{try{const r=this.getBoundingClientRect();if(r.right>window.innerWidth)this.classList.add("c-tooltip--flip-x");else this.classList.remove("c-tooltip--flip-x");if(r.bottom>window.innerHeight)this.classList.add("c-tooltip--flip-y");else this.classList.remove("c-tooltip--flip-y")}catch(e){}};const origShow=show;onDispose(this,()=>{target.removeEventListener("mouseenter",onEnter);target.removeEventListener("mouseleave",onLeave);target.removeEventListener("focus",onFocus);target.removeEventListener("blur",onBlur);target.removeEventListener("click",onClick);target.removeEventListener("touchstart",onTouchStart);target.removeEventListener("touchend",onTouchEnd);if(showTimer)clearTimeout(showTimer)});this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t===this){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:this.matches(":popover-open")},bubbles:true,composed:true}))}});this.addEventListener("beforetoggle",(e)=>{this.dispatchEvent(new CustomEvent(e.newState==="open"?"contour:show":"contour:hide",{bubbles:true,composed:true}))})}}define("contour-tooltip",ContourTooltip);class ContourProgress extends ContourBase{static get observed(){return["value","label","min","max","paused","pausable"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},min:{attribute:"min"},max:{attribute:"max"},paused:{attribute:"paused",type:Boolean},pausable:{attribute:"pausable",type:Boolean}}}render(){this.classList.add("c-progress");const value=this.getAttribute("value");if(value===null){this.style.removeProperty("--progress");if(this.getAttribute("aria-valuenow")===this._progressAriaValue){this.removeAttribute("aria-valuenow")}this._progressAriaValue=null}else{const num=Number(value);const pct=Number.isFinite(num)?(num<=1&&value.includes(".")?num*100:num):0;const pctStr=Math.max(0,Math.min(100,pct))+"%";this.style.setProperty("--progress",pctStr);const prevVal=this._progressAriaValue;if(!this.hasAttribute("aria-valuenow")||this.getAttribute("aria-valuenow")===prevVal){this.setAttribute("aria-valuenow",String(pct));this._progressAriaValue=String(pct)}}this.ensure(".c-progress__bar",()=>{const el=document.createElement("span");el.className="c-progress__bar";return el});if(!this.hasAttribute("role"))this.setAttribute("role","progressbar");const label=this.getAttribute("label");if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);const min=this.getAttribute("min");const max=this.getAttribute("max");if(min!==null)this.setAttribute("aria-valuemin",min);else if(!this.hasAttribute("aria-valuemin"))this.setAttribute("aria-valuemin","0");if(max!==null)this.setAttribute("aria-valuemax",max);else if(!this.hasAttribute("aria-valuemax"))this.setAttribute("aria-valuemax","100");if(this.hasAttribute("paused"))this.classList.add("c-progress--paused");else Array.from(this.classList).forEach((c)=>{if(c==="c-progress--paused")this.classList.remove(c)});if(this.hasAttribute("pausable")){this.ensure(".c-progress__pause",()=>{const btn=document.createElement("button");btn.className="c-progress__pause";btn.type="button";btn.setAttribute("aria-label","Pause");btn.textContent="⏸";return btn})}else{const btn=this.querySelector(".c-progress__pause");if(btn)btn.remove()}}}define("contour-progress",ContourProgress);class ContourMark extends ContourBase{render(){this.classList.add("c-mark")}}define("contour-mark",ContourMark);class ContourLoading extends ContourBase{render(){this.classList.add("c-loading");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");this.ensure(".c-spinner",()=>{const el=document.createElement("span");el.className="c-spinner";el.setAttribute("aria-hidden","true");return el})}}define("contour-loading",ContourLoading);class ContourElevation extends ContourBase{render(){this.classList.add("c-elevation")}}define("contour-elevation",ContourElevation);class ContourVersionBannerFull extends ContourBase{static get observed(){return["message","link","href","dismissible"]}static get properties(){return{message:{attribute:"message"},link:{attribute:"link"},href:{attribute:"href"},dismissible:{attribute:"dismissible",type:Boolean}}}render(){this.classList.add("c-version-banner");Array.from(this.children).forEach((n)=>n.remove());const message=this.getAttribute("message");if(message){const icon=document.createElement("svg");icon.setAttribute("aria-hidden","true");icon.innerHTML='<use href="#i-info" />';this.appendChild(icon);const span=document.createElement("span");span.textContent=message;this.appendChild(span)}const link=this.getAttribute("link");const href=this.getAttribute("href");if(link&&href){const a=document.createElement("a");a.className="c-version-banner__link";a.href=href;a.textContent=link;this.appendChild(a)}if(this.hasAttribute("dismissible")){const btn=document.createElement("button");btn.className="c-version-banner__dismiss";btn.type="button";btn.setAttribute("aria-label","Dismiss");btn.textContent="×";this.appendChild(btn)}}enhance(){if(this._wiredVersionBanner)return;this._wiredVersionBanner=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-version-banner__dismiss"):null;if(btn&&this.contains(btn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()}})}}define("contour-version-banner",ContourVersionBannerFull);class ContourBanner extends ContourBase{static get observed(){return["message","variant"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"}}}render(){this.classList.add("c-banner");const variant=this.getAttribute("variant");if(variant)this.classList.add("c-banner--"+variant);const message=this.getAttribute("message");if(message){const span=this.ensure(".c-banner__message",()=>{const el=document.createElement("span");el.className="c-banner__message";return el});span.textContent=message}}}define("contour-banner",ContourBanner);class ContourFilterPill extends ContourBase{static get observed(){return["key","value","removable"]}static get properties(){return{key:{attribute:"key"},value:{attribute:"value"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-filter-pill");const key=this.getAttribute("key");const value=this.getAttribute("value");if(key){const k=this.ensure(".c-filter-pill__key",()=>{const el=document.createElement("span");el.className="c-filter-pill__key";return el});k.textContent=key}else{const k=this.querySelector(".c-filter-pill__key");if(k)k.remove()}if(value){const v=this.ensure(".c-filter-pill__value",()=>{const el=document.createElement("span");el.className="c-filter-pill__value";return el});v.textContent=value}else{const v=this.querySelector(".c-filter-pill__value");if(v)v.remove()}if(this.hasAttribute("removable")){this.ensure(".c-filter-pill__remove",()=>{const btn=document.createElement("button");btn.className="c-filter-pill__remove";btn.type="button";btn.setAttribute("aria-label","Remove filter");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-filter-pill__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-filter-pill",ContourFilterPill);class ContourDatamark extends ContourBase{static get observed(){return["value","unit","label"]}static get properties(){return{value:{attribute:"value"},unit:{attribute:"unit"},label:{attribute:"label"}}}render(){this.classList.add("c-datamark");const value=this.getAttribute("value");const unit=this.getAttribute("unit");const label=this.getAttribute("label");const text=value||label;if(text){this.textContent=text;if(unit){const u=document.createElement("span");u.className="u-subtle";u.textContent=" "+unit;this.appendChild(u)}}}}define("contour-datamark",ContourDatamark);class ContourDestructiveHint extends ContourBase{static get observed(){return["text"]}static get properties(){return{text:{attribute:"text"}}}render(){this.classList.add("c-destructive-hint");const text=this.getAttribute("text");if(text)this.textContent=text}}define("contour-destructive-hint",ContourDestructiveHint);class ContourIconBadge extends ContourBase{static get observed(){return["icon"]}static get properties(){return{icon:{attribute:"icon"}}}render(){this.classList.add("c-icon-badge");const icon=this.getAttribute("icon");if(icon){const sanitized=String(icon).replace(/[^a-zA-Z0-9_-]/g,"");if(sanitized&&!sanitized.startsWith("i-")){if(typeof console!=="undefined"&&console.warn){console.warn("ContourIconBadge: icon '"+icon+"' may not exist in the sprite (expected i-* name).")}}const existing=this.querySelector("svg");const svg=existing||document.createElementNS("http://www.w3.org/2000/svg","svg");if(!existing){svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#"+sanitized);svg.appendChild(use);this.appendChild(svg)}else{const use=svg.querySelector("use");if(use)use.setAttribute("href","#"+sanitized)}}else{const svg=this.querySelector("svg");if(svg)svg.remove()}}}define("contour-icon-badge",ContourIconBadge);class ContourLiveBadge extends ContourBase{static get observed(){return["label","state","live"]}static get properties(){return{label:{attribute:"label"},state:{attribute:"state"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-live-badge");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-live-badge--"))this.classList.remove(c)});const state=this.getAttribute("state");if(state){this.classList.add("c-live-badge--"+state)}else if(this.hasAttribute("live")){this.classList.add("c-live-badge--connected")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label}}define("contour-live-badge",ContourLiveBadge);class ContourSkeletonGroup extends ContourBase{static get observed(){return["count"]}static get properties(){return{count:{attribute:"count",type:Number}}}render(){this.classList.add("c-skeleton-group");const count=Math.max(1,parseInt(this.getAttribute("count")||"3",10)||3);Array.from(this.querySelectorAll(".c-skeleton")).forEach((n)=>n.remove());for(let i=0;i<count;i++){const sk=document.createElement("div");sk.className="c-skeleton";this.appendChild(sk)}}}define("contour-skeleton-group",ContourSkeletonGroup);class ContourMapPopup extends ContourBase{static get observed(){return["title","content","cluster-count","cluster-expanded","cluster-items"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},"cluster-count":{attribute:"cluster-count",type:Number},"cluster-expanded":{attribute:"cluster-expanded",type:Boolean},"cluster-items":{attribute:"cluster-items"}}}render(){this.classList.add("c-map-popup");this.setAttribute("role","dialog");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("map-popup");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-map-popup__title",()=>{const el=document.createElement("div");el.className="c-map-popup__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-map-popup__body",()=>{const el=document.createElement("div");el.className="c-map-popup__body";return el});c.textContent=content}const clusterCount=Number(this.getAttribute("cluster-count"));if(Number.isFinite(clusterCount)&&clusterCount>1){const badge=this.ensure(".c-map-popup__cluster",()=>{const el=document.createElement("button");el.className="c-map-popup__cluster c-btn c-btn--sm";el.type="button";return el});const expanded=this.hasAttribute("cluster-expanded");badge.textContent=expanded?"Hide locations":`${clusterCount} locations`;badge.setAttribute("aria-expanded",String(expanded));badge.setAttribute("aria-label",expanded?"Hide locations":`Show ${clusterCount} locations`)}else{const badge=this.querySelector(".c-map-popup__cluster");if(badge)badge.remove()}const expanded=this.hasAttribute("cluster-expanded");let items=[];try{items=this.getAttribute("cluster-items")?JSON.parse(this.getAttribute("cluster-items")):[]}catch(e){items=[]}const list=this.querySelector(".c-map-popup__cluster-list");if(expanded&&Array.isArray(items)&&items.length){const ul=list||document.createElement("ul");ul.className="c-map-popup__cluster-list";ul.innerHTML="";items.forEach((it)=>{const li=document.createElement("li");li.className="c-map-popup__cluster-item";li.textContent=typeof it==="string"?it:(it.label||it.name||JSON.stringify(it));ul.appendChild(li)});if(ul.parentNode!==this)this.appendChild(ul)}else if(list){list.remove()}if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",title||"Map popup")}enhance(){if(this._wiredMapPopup)return;this._wiredMapPopup=true;const close=()=>{try{this.hidePopover()}catch(e){}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const keyHandler=(e)=>{if(e.key==="Escape"&&(this.classList.contains("is-open")||this.matches(":popover-open"))){e.preventDefault();close()}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-map-popup__close"):null;if(btn&&this.contains(btn))close();const cluster=e.target&&e.target.closest?e.target.closest(".c-map-popup__cluster"):null;if(cluster&&this.contains(cluster)){const expanded=!this.hasAttribute("cluster-expanded");this.toggleAttribute("cluster-expanded",expanded);this.dispatchEvent(new CustomEvent("contour:cluster-toggle",{bubbles:true,composed:true,detail:{count:Number(this.getAttribute("cluster-count")),expanded}}))}})}}define("contour-map-popup",ContourMapPopup);class ContourAnimationControls extends ContourBase{static get observed(){return["playing","speed","progress","min","max","caption","show-thumb","show-thumb-caption"]}static get properties(){return{playing:{attribute:"playing",type:Boolean},speed:{attribute:"speed"},progress:{attribute:"progress"},min:{attribute:"min"},max:{attribute:"max"}}}render(){this.classList.add("c-animation-controls");this.setAttribute("role","toolbar");this.setAttribute("aria-label","Animation controls");const playBtn=this.ensure(".c-animation-controls__play",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__play";el.type="button";return el});playBtn.textContent=this.hasAttribute("playing")?"Pause":"Play";playBtn.setAttribute("aria-label",this.hasAttribute("playing")?"Pause":"Play");const speed=this.getAttribute("speed")||"1x";const speedBtn=this.ensure(".c-animation-controls__speed",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__speed";el.type="button";return el});speedBtn.textContent=speed;const scrubber=this.ensure(".c-animation-controls__scrubber",()=>{const el=document.createElement("input");el.className="c-range c-animation-controls__scrubber";el.type="range";return el});if(this.getAttribute("show-thumb")==="false")scrubber.classList.remove("c-animation-controls__scrubber--thumb");else scrubber.classList.add("c-animation-controls__scrubber--thumb");scrubber.min=this.getAttribute("min")||"0";scrubber.max=this.getAttribute("max")||"100";scrubber.value=this.getAttribute("progress")||"0";const caption=this.getAttribute("caption");if(caption)scrubber.setAttribute("aria-label",caption);else if(!scrubber.getAttribute("aria-label"))scrubber.setAttribute("aria-label","Playhead");const showCaption=this.hasAttribute("show-thumb-caption")||this.hasAttribute("show-thumb");if(caption&&showCaption){const cap=this.ensure(".c-animation-controls__caption",()=>{const el=document.createElement("span");el.className="c-animation-controls__caption";return el});cap.textContent=caption}else{const cap=this.querySelector(".c-animation-controls__caption");if(cap)cap.remove()}}enhance(){if(this._wiredAnimControls)return;this._wiredAnimControls=true;this.addEventListener("click",(e)=>{const play=e.target&&e.target.closest?e.target.closest(".c-animation-controls__play"):null;const speed=e.target&&e.target.closest?e.target.closest(".c-animation-controls__speed"):null;if(play&&this.contains(play)){this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{playing:!this.hasAttribute("playing")}}))}if(speed&&this.contains(speed)){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{speed:speed.textContent}}))}});this.addEventListener("input",(e)=>{const scrubber=e.target&&e.target.closest?e.target.closest(".c-animation-controls__scrubber"):null;if(scrubber&&this.contains(scrubber)){const v=Number(scrubber.value);this.dispatchEvent(new CustomEvent("contour:seek",{bubbles:true,composed:true,detail:{progress:v,value:v}}))}});this.addEventListener("keydown",(e)=>{if(e.key===" "||e.key==="Enter"){const play=this.querySelector(".c-animation-controls__play");if(play&&(e.target===play||!e.target||e.target===this)){e.preventDefault();play.click()}}else if(e.key==="ArrowRight"||e.key==="ArrowLeft"){const scrubber=this.querySelector(".c-animation-controls__scrubber");if(scrubber){e.preventDefault();const step=e.key==="ArrowRight"?1:-1;scrubber.value=String(Number(scrubber.value)+step);scrubber.dispatchEvent(new Event("input",{bubbles:true}))}}});let timer=null;const speedFactor=()=>{const s=this.getAttribute("speed")||"1x";const n=parseFloat(s);return Number.isFinite(n)&&n>0?n:1};const tick=()=>{const scrubber=this.querySelector(".c-animation-controls__scrubber");if(!scrubber)return;const min=Number(scrubber.min||0);const max=Number(scrubber.max||100);let v=Number(scrubber.value||0)+speedFactor();if(v>max)v=min;scrubber.value=String(v);this.dispatchEvent(new CustomEvent("contour:time-change",{bubbles:true,composed:true,detail:{progress:v,value:v}}))};const start=()=>{if(timer)return;timer=setInterval(tick,100)};const stop=()=>{if(timer){clearInterval(timer);timer=null}};if(this.hasAttribute("playing"))start();const obs=new MutationObserver(()=>{if(this.hasAttribute("playing"))start();else stop()});obs.observe(this,{attributes:true,attributeFilter:["playing"]});onDispose(this,()=>{stop();obs.disconnect()})}}define("contour-animation-controls",ContourAnimationControls);class ContourDropdown extends ContourBase{static get observed(){return["label","items"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"}}}render(){this.classList.add("c-dropdown");const btn=this.ensure(".c-dropdown__trigger",()=>{const el=document.createElement("button");el.className="c-dropdown__trigger c-btn c-btn--sm";el.type="button";return el});btn.textContent=this.getAttribute("label")||"Menu";const menu=this.ensure(".c-dropdown__menu",()=>{const el=document.createElement("div");el.className="c-dropdown__menu c-menu";el.setAttribute("role","menu");el.hidden=true;return el});const authoredItems=Array.from(this.querySelectorAll(":scope > .c-menu__item"));const items=this.getAttribute("items");if(authoredItems.length){menu.innerHTML="";authoredItems.forEach((it)=>{menu.appendChild(it)})}else if(items){try{const parsed=JSON.parse(items);menu.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("button");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=typeof it==="string"?it:(it.label||it.title||"");menu.appendChild(li)})}catch(e){}}if(menu.parentNode!==this)this.appendChild(menu);if(btn.parentNode!==this)this.insertBefore(btn,menu)}enhance(){if(this._wiredDropdown)return;this._wiredDropdown=true;const btn=()=>this.querySelector(".c-dropdown__trigger");const menu=()=>this.querySelector(".c-dropdown__menu");this.addEventListener("click",(e)=>{const b=btn();const m=menu();const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&m&&m.contains(item)&&!m.hidden){const idx=Array.from(m.querySelectorAll(".c-menu__item")).indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,value:item.textContent}}));m.hidden=true;if(b){b.setAttribute("aria-expanded","false");try{b.focus()}catch(err){}}return}if(e.target===b||(b&&b.contains(e.target))){if(m){m.hidden=!m.hidden;b.setAttribute("aria-expanded",String(!m.hidden));if(!m.hidden){if(!m.id)m.id=(this.id||contourId("dd"))+"-menu";b.setAttribute("aria-controls",m.id);const first=m.querySelector(".c-menu__item");if(first)try{first.focus()}catch(err){}}}}});const docClick=(e)=>{const m=menu();const b=btn();if(m&&!m.hidden&&!this.contains(e.target)){m.hidden=true;if(b)b.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick));const keyHandler=(e)=>{const m=menu();const b=btn();if(e.key==="Escape"&&m&&!m.hidden){e.preventDefault();m.hidden=true;if(b){b.setAttribute("aria-expanded","false");try{b.focus()}catch(err){}}return}if(!m||m.hidden)return;const items=Array.from(m.querySelectorAll(".c-menu__item"));const active=document.activeElement;const idx=items.indexOf(active);if(e.key==="ArrowDown"){e.preventDefault();const next=items[Math.min(items.length-1,idx+1)]||items[0];if(next)try{next.focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();const prev=items[Math.max(0,idx-1)]||items[items.length-1];if(prev)try{prev.focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){if(active&&items.includes(active)){e.preventDefault();active.click()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-dropdown",ContourDropdown);class ContourAnnotation extends ContourBase{static get observed(){return["label","x","y"]}static get properties(){return{label:{attribute:"label"},x:{attribute:"x"},y:{attribute:"y"}}}render(){this.classList.add("c-annotation");this.setAttribute("role","note");const label=this.getAttribute("label");if(label)this.setAttribute("aria-label",label);if(label){const l=this.ensure(".c-annotation__label",()=>{const el=document.createElement("span");el.className="c-annotation__label";return el});l.textContent=label}const x=this.getAttribute("x");const y=this.getAttribute("y");if(x!==null)this.style.setProperty("--annotation-x",x);if(y!==null)this.style.setProperty("--annotation-y",y)}}define("contour-annotation",ContourAnnotation);class ContourStyleSwitcher extends ContourBase{static get observed(){return["items","value"]}static get properties(){return{items:{attribute:"items"},value:{attribute:"value"}}}render(){this.classList.add("c-style-switcher");const items=this.getAttribute("items");const value=this.getAttribute("value");Array.from(this.querySelectorAll(".c-style-switcher__option")).forEach((n)=>n.remove());if(items){try{const parsed=JSON.parse(items);parsed.forEach((it)=>{const name=typeof it==="string"?it:(it.name||it.label||"");const btn=document.createElement("button");btn.className="c-style-switcher__option c-btn c-btn--sm";btn.type="button";btn.textContent=name;if(name===value)btn.classList.add("c-style-switcher__option--active");btn.dataset.value=name;this.appendChild(btn)})}catch(e){}}}enhance(){if(this._wiredStyleSwitcher)return;this._wiredStyleSwitcher=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-style-switcher__option"):null;if(btn&&this.contains(btn)){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:btn.dataset.value}}))}})}}define("contour-style-switcher",ContourStyleSwitcher);class ContourStylePanel extends ContourBase{static get observed(){return["title","layers","layer","single","classification","palette","breaks","opacity","n","colors","property"]}static get properties(){return{title:{attribute:"title"},layers:{attribute:"layers"},classification:{attribute:"classification"},palette:{attribute:"palette"},breaks:{attribute:"breaks"},opacity:{attribute:"opacity"}}}render(){this.classList.add("c-style-panel");this.setAttribute("role","group");this.setAttribute("aria-label","Style panel");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-style-panel__title",()=>{const el=document.createElement("div");el.className="c-style-panel__title";return el});t.textContent=title}const singleMode=this.hasAttribute("single")||!!this.getAttribute("layer");if(singleMode){const body=this.ensure(".c-style-panel__body",()=>{const el=document.createElement("div");el.className="c-style-panel__body";return el});body.innerHTML="";const propLabel=document.createElement("label");propLabel.textContent="Colour field";propLabel.setAttribute("for","property");body.appendChild(propLabel);const propIn=document.createElement("input");propIn.type="text";propIn.id="property";propIn.className="c-style-panel__property c-input";propIn.setAttribute("aria-label","Colour field");const pv=this.getAttribute("property");if(pv)propIn.value=pv;body.appendChild(propIn);const clsLabel=document.createElement("label");clsLabel.textContent="Classification";clsLabel.setAttribute("for","policy");body.appendChild(clsLabel);const clsSel=document.createElement("select");clsSel.id="policy";clsSel.className="c-style-panel__classification c-input";clsSel.setAttribute("aria-label","Classification method");["equal","quantile","jenks","manual"].forEach((m)=>{const o=document.createElement("option");o.value=m;o.textContent=m;clsSel.appendChild(o)});const cls=this.getAttribute("classification");if(cls)clsSel.value=cls;body.appendChild(clsSel);const palLabel=document.createElement("label");palLabel.textContent="Palette";palLabel.setAttribute("for","palette");body.appendChild(palLabel);const pal=document.createElement("input");pal.type="text";pal.id="palette";pal.className="c-style-panel__palette c-input";pal.placeholder="palette";pal.setAttribute("aria-label","Palette");const palv=this.getAttribute("palette");if(palv)pal.value=palv;body.appendChild(pal);const nLabel=document.createElement("label");nLabel.textContent="Classes";nLabel.setAttribute("for","n");body.appendChild(nLabel);const nIn=document.createElement("input");nIn.type="number";nIn.id="n";nIn.className="c-style-panel__n c-input";nIn.min="2";nIn.max="12";nIn.setAttribute("aria-label","Class count");const nv=this.getAttribute("n");if(nv)nIn.value=nv;else nIn.value="5";body.appendChild(nIn);const op=document.createElement("input");op.type="range";op.className="c-style-panel__opacity";op.setAttribute("aria-label","Opacity");op.min="0";op.max="100";const ov=this.getAttribute("opacity");op.value=ov!=null?ov:"100";body.appendChild(op);const breaksAttr=this.getAttribute("breaks");let breaksArr=null;if(breaksAttr){try{breaksArr=JSON.parse(breaksAttr)}catch(e){breaksArr=breaksAttr.split(",").map((s)=>s.trim())}}if(Array.isArray(breaksArr)&&breaksArr.length){const breaksWrap=document.createElement("div");breaksWrap.className="c-style-panel__breaks";breaksArr.forEach((b,i)=>{const br=document.createElement("div");br.className="break";const span=document.createElement("span");span.textContent=String(b);br.appendChild(span);const inp=document.createElement("input");inp.type="number";inp.className="c-style-panel__breaks c-input";inp.setAttribute("aria-label","Class lower bound");inp.value=String(b);br.appendChild(inp);breaksWrap.appendChild(br)});body.appendChild(breaksWrap)}const colorsAttr=this.getAttribute("colors");let colors=null;if(colorsAttr){try{colors=JSON.parse(colorsAttr)}catch(e){colors=colorsAttr.split(",").map((s)=>s.trim())}}if(Array.isArray(colors)){const list=document.createElement("div");list.className="c-style-panel__colors";colors.forEach((c,i)=>{const sw=document.createElement("input");sw.type="color";sw.className="c-style-panel__color c-input";sw.setAttribute("aria-label","Colour for class "+(i+1));sw.value=c;sw.addEventListener("input",()=>{sw.setAttribute("data-edited","true")});list.appendChild(sw)});body.appendChild(list)}const actions=document.createElement("div");actions.className="c-style-panel__actions c-btn-group";const applyBtn=document.createElement("button");applyBtn.type="button";applyBtn.className="c-btn c-btn--primary";applyBtn.textContent="Apply";const revertBtn=document.createElement("button");revertBtn.type="button";revertBtn.className="c-btn";revertBtn.textContent="Revert";actions.appendChild(applyBtn);actions.appendChild(revertBtn);body.appendChild(actions);return}const layers=this.getAttribute("layers");const body=this.ensure(".c-style-panel__body",()=>{const el=document.createElement("div");el.className="c-style-panel__body";return el});const authoredRows=Array.from(this.querySelectorAll(":scope > .c-style-panel__row"));let parsed=null;if(authoredRows.length){parsed=authoredRows.map((row)=>({name:row.querySelector(".c-style-panel__name")?.textContent||"",color:row.querySelector(".c-style-panel__color")?.value,classification:row.querySelector(".c-style-panel__classification")?.value,palette:row.querySelector(".c-style-panel__palette")?.value,breaks:row.querySelector(".c-style-panel__breaks")?.value,opacity:row.querySelector(".c-style-panel__opacity")?.value,}));authoredRows.forEach((row)=>row.remove())}else if(layers){try{parsed=JSON.parse(layers)}catch(e){parsed=null}}if(parsed){body.innerHTML="";parsed.forEach((l)=>{const row=document.createElement("div");row.className="c-style-panel__row";const name=document.createElement("span");name.className="c-style-panel__name";name.textContent=typeof l==="string"?l:(l.name||l.label||"");row.appendChild(name);const input=document.createElement("input");input.type="color";input.className="c-style-panel__color";input.setAttribute("aria-label","Colour for "+(typeof l==="string"?l:(l.name||l.label||"layer")));if(typeof l==="object"&&l.color)input.value=l.color;row.appendChild(input);const clsSel=document.createElement("select");clsSel.className="c-style-panel__classification";clsSel.setAttribute("aria-label","Classification method");["equal","quantile","jenks","manual"].forEach((m)=>{const o=document.createElement("option");o.value=m;o.textContent=m;clsSel.appendChild(o)});if(typeof l==="object"&&l.classification)clsSel.value=l.classification;row.appendChild(clsSel);const pal=document.createElement("input");pal.type="text";pal.className="c-style-panel__palette";pal.setAttribute("aria-label","Palette");pal.placeholder="palette";if(typeof l==="object"&&l.palette)pal.value=l.palette;row.appendChild(pal);const breaks=document.createElement("input");breaks.type="text";breaks.className="c-style-panel__breaks";breaks.placeholder="breaks";if(typeof l==="object"&&l.breaks)breaks.value=(Array.isArray(l.breaks)?l.breaks.join(","):l.breaks);row.appendChild(breaks);const op=document.createElement("input");op.type="range";op.className="c-style-panel__opacity";op.setAttribute("aria-label","Opacity");op.min="0";op.max="100";op.value=(typeof l==="object"&&l.opacity!=null)?l.opacity:"100";row.appendChild(op);body.appendChild(row)})}}enhance(){if(this._wiredStylePanel)return;this._wiredStylePanel=true;this.addEventListener("change",(e)=>{const t=e.target;if(!t||!this.contains(t))return;const row=t.closest(".c-style-panel__row");const name=row?(row.querySelector(".c-style-panel__name")?.textContent||""):"";if(t.classList.contains("c-style-panel__color")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:"color"},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__classification")){this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:t.value,layer:name},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__opacity")){this.dispatchEvent(new CustomEvent("contour:layer-opacity",{detail:{name,opacity:Number(t.value)},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__property")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:"property"},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__n")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:Number(t.value),layer:name,property:"n"},bubbles:true,composed:true}))}});this.addEventListener("input",(e)=>{const t=e.target;if(!t||!this.contains(t))return;if(t.classList.contains("c-style-panel__palette")||t.classList.contains("c-style-panel__breaks")){const row=t.closest(".c-style-panel__row");const name=row?(row.querySelector(".c-style-panel__name")?.textContent||""):"";this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:t.classList.contains("c-style-panel__palette")?"palette":"breaks"},bubbles:true,composed:true}))}});this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target.closest("button"):null;if(!t||!this.contains(t))return;if(t.textContent.trim()==="Apply"){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{applied:true},bubbles:true,composed:true}))}else if(t.textContent.trim()==="Revert"){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{applied:false},bubbles:true,composed:true}))}})}}define("contour-style-panel",ContourStylePanel);class ContourResponsiveContent extends ContourBase{static get observed(){return["breakpoint"]}static get properties(){return{breakpoint:{attribute:"breakpoint"}}}render(){this.classList.add("c-responsive-content");const bp=this.getAttribute("breakpoint")||"md";this.dataset.breakpoint=bp}}define("contour-responsive-content",ContourResponsiveContent);class ContourAvatarGroup extends ContourBase{static get observed(){return["items","max"]}static get properties(){return{items:{attribute:"items"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-avatar-group");const items=this.getAttribute("items");const max=parseInt(this.getAttribute("max")||"4",10)||4;Array.from(this.querySelectorAll(".c-avatar, .c-avatar-group__overflow")).forEach((n)=>n.remove());if(items){try{const parsed=JSON.parse(items);const shown=parsed.slice(0,max);shown.forEach((it)=>{const av=document.createElement("span");av.className="c-avatar";const name=typeof it==="string"?it:(it.name||it.label||"");av.textContent=name.slice(0,2).toUpperCase();if(typeof it==="object"&&it.color){av.style.background=it.color;av.dataset.color=it.color}this.appendChild(av)});if(parsed.length>max){const overflow=document.createElement("span");overflow.className="c-avatar c-avatar-group__overflow";overflow.textContent="+"+(parsed.length-max);this.appendChild(overflow)}}catch(e){}}}}define("contour-avatar-group",ContourAvatarGroup);class ContourDivider extends ContourBase{static get observed(){return["label","orientation"]}static get properties(){return{label:{attribute:"label"},orientation:{attribute:"orientation"}}}render(){this.classList.add("c-divider");const orientation=this.getAttribute("orientation")||"horizontal";this.classList.add("c-divider--"+orientation);const label=this.getAttribute("label");if(label){const l=this.ensure(".c-divider__label",()=>{const el=document.createElement("span");el.className="c-divider__label";return el});l.textContent=label}}}define("contour-divider",ContourDivider);class ContourStatusLight extends ContourBase{static get observed(){return["status","label"]}static get properties(){return{status:{attribute:"status"},label:{attribute:"label"}}}render(){this.classList.add("c-status-light");const status=this.getAttribute("status")||"neutral";this.classList.add("c-status-light--"+status);const label=this.getAttribute("label");if(label){const l=this.ensure(".c-status-light__label",()=>{const el=document.createElement("span");el.className="c-status-light__label";return el});l.textContent=label}}}define("contour-status-light",ContourStatusLight);class ContourSplitButton extends ContourBase{static get observed(){return["label","menu"]}static get properties(){return{label:{attribute:"label"},menu:{attribute:"menu"}}}render(){this.classList.add("c-split-button");const main=this.ensure(".c-split-button__main",()=>{const el=document.createElement("button");el.className="c-btn c-split-button__main";el.type="button";return el});main.textContent=this.getAttribute("label")||"Action";const toggle=this.ensure(".c-split-button__toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--icon c-split-button__toggle";el.type="button";el.setAttribute("aria-label","More options");el.textContent="▾";return el});const menu=this.ensure(".c-split-button__menu",()=>{const el=document.createElement("div");el.className="c-menu c-split-button__menu";el.setAttribute("role","menu");el.hidden=true;return el});const items=this.getAttribute("menu");if(items){try{const parsed=JSON.parse(items);menu.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("button");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=typeof it==="string"?it:(it.label||it.title||"");menu.appendChild(li)})}catch(e){}}if(main.parentNode!==this)this.appendChild(main);if(toggle.parentNode!==this)this.appendChild(toggle);if(menu.parentNode!==this)this.appendChild(menu)}enhance(){if(this._wiredSplitButton)return;this._wiredSplitButton=true;const toggle=()=>this.querySelector(".c-split-button__toggle");const menu=()=>this.querySelector(".c-split-button__menu");this.addEventListener("click",(e)=>{const t=toggle();if(e.target===t||(t&&t.contains(e.target))){const m=menu();if(m){m.hidden=!m.hidden;t.setAttribute("aria-expanded",String(!m.hidden));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{open:!m.hidden}}))}}const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&this.contains(item)){const m=menu();if(m){m.hidden=true;const t=toggle();if(t)t.setAttribute("aria-expanded","false")}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent}}))}});this.addEventListener("keydown",(e)=>{const t=toggle();if((e.target===t||(t&&t.contains(e.target)))&&(e.key==="Enter"||e.key===" ")){e.preventDefault();const m=menu();if(m){m.hidden=!m.hidden;t.setAttribute("aria-expanded",String(!m.hidden))}}else if(e.key==="Escape"){const m=menu();if(m&&!m.hidden){m.hidden=true;if(t)t.setAttribute("aria-expanded","false")}}});const docClick=(e)=>{const m=menu();const t=toggle();if(m&&!m.hidden&&!this.contains(e.target)){m.hidden=true;if(t)t.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick))}}define("contour-split-button",ContourSplitButton);class ContourPaletteEditor extends ContourBase{static get observed(){return["colors"]}static get properties(){return{colors:{attribute:"colors"}}}render(){this.classList.add("c-palette-editor");const colors=this.getAttribute("colors");Array.from(this.querySelectorAll(".c-palette-editor__swatch")).forEach((n)=>n.remove());if(colors){try{const parsed=JSON.parse(colors);parsed.forEach((c)=>{const sw=document.createElement("button");sw.className="c-palette-editor__swatch c-swatch";sw.type="button";sw.style.background=typeof c==="string"?c:(c.color||c.value||"");sw.dataset.color=typeof c==="string"?c:(c.color||c.value||"");sw.setAttribute("aria-label",typeof c==="string"?c:(c.name||c.label||"color"));this.appendChild(sw)})}catch(e){}}}enhance(){if(this._wiredPaletteEditor)return;this._wiredPaletteEditor=true;this.addEventListener("click",(e)=>{const sw=e.target&&e.target.closest?e.target.closest(".c-palette-editor__swatch"):null;if(sw&&this.contains(sw)){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{color:(sw.dataset&&sw.dataset.color)||sw.style.background}}))}});this.addEventListener("keydown",(e)=>{const swatches=Array.from(this.querySelectorAll(".c-palette-editor__swatch"));const active=document.activeElement;const idx=swatches.indexOf(active);if(e.key==="ArrowRight"){e.preventDefault();const next=swatches[Math.min(swatches.length-1,idx+1)]||swatches[0];if(next)try{next.focus()}catch(err){}}else if(e.key==="ArrowLeft"){e.preventDefault();const prev=swatches[Math.max(0,idx-1)]||swatches[swatches.length-1];if(prev)try{prev.focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(active&&active.classList.contains("c-palette-editor__swatch"))active.click()}})}}define("contour-palette-editor",ContourPaletteEditor);class ContourDateRange extends ContourBase{static get observed(){return["start","end","label","time","min","max","locale"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},label:{attribute:"label"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"}}}render(){this.classList.add("c-date-range");this.setAttribute("role","group");this.setAttribute("aria-label","Date range");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-date-range__label",()=>{const el=document.createElement("span");el.className="c-date-range__label";return el});l.textContent=label}const start=this.ensure(".c-date-range__start",()=>{const el=document.createElement("input");el.className="c-input c-date-range__start";return el});start.type=this.hasAttribute("time")?"datetime-local":"date";start.value=this.getAttribute("start")||"";const end=this.ensure(".c-date-range__end",()=>{const el=document.createElement("input");el.className="c-input c-date-range__end";return el});end.type=start.type;end.value=this.getAttribute("end")||"";const min=this.getAttribute("min");const max=this.getAttribute("max");[start,end].forEach((input)=>{if(min)input.min=min;else input.removeAttribute("min");if(max)input.max=max;else input.removeAttribute("max");if(this.getAttribute("locale"))input.lang=this.getAttribute("locale")})}enhance(){if(this._wiredDateRange)return;this._wiredDateRange=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&(t.classList.contains("c-date-range__start")||t.classList.contains("c-date-range__end"))){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{start:this.querySelector(".c-date-range__start")?.value,end:this.querySelector(".c-date-range__end")?.value}}))}})}}define("contour-date-range",ContourDateRange);class ContourShortcut extends ContourBase{static get observed(){return["key","label"]}static get properties(){return{key:{attribute:"key"},label:{attribute:"label"}}}render(){this.classList.add("c-shortcut");const key=this.getAttribute("key")||"";const label=this.getAttribute("label")||"";if(key){const k=this.ensure(".c-shortcut__key",()=>{const el=document.createElement("kbd");el.className="c-shortcut__key";return el});k.textContent=key}if(label){const l=this.ensure(".c-shortcut__label",()=>{const el=document.createElement("span");el.className="c-shortcut__label";return el});l.textContent=label}}enhance(){if(this._wiredShortcut)return;this._wiredShortcut=true;const key=this.getAttribute("key");if(key){const handler=(e)=>{if(e.key===key&&(e.metaKey||e.ctrlKey)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}};document.addEventListener("keydown",handler);onDispose(this,()=>document.removeEventListener("keydown",handler))}}}define("contour-shortcut",ContourShortcut);class ContourPopover extends ContourBase{static get observed(){return["title","content"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"}}}render(){this.classList.add("c-popover");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Popover");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("popover");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-popover__title",()=>{const el=document.createElement("div");el.className="c-popover__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-popover__body",()=>{const el=document.createElement("div");el.className="c-popover__body";return el});c.textContent=content}}enhance(){if(this._wiredPopover)return;this._wiredPopover=true;const close=()=>{try{this.hidePopover()}catch(e){}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const keyHandler=(e)=>{const open=this.classList.contains("is-open")||this.matches(":popover-open");if(!open)return;if(e.key==="Escape"){e.preventDefault();close();return}if(e.key==="Tab"){const focusable=Array.from(this.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!focusable.length){e.preventDefault();return}const first=focusable[0];const last=focusable[focusable.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("contour:show",(e)=>{if(e.target&&e.target!==this&&this.contains(e.target)){this.classList.add("is-parent")}});this.addEventListener("contour:close",(e)=>{if(e.target&&e.target!==this){this.classList.remove("is-parent")}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-popover__close"):null;if(btn&&this.contains(btn))close()})}}define("contour-popover",ContourPopover);class ContourDatePicker extends ContourBase{static get observed(){return["value","range","range-start","range-end","label","disabled","error","help","time","min","max","locale"]}static get properties(){return{value:{attribute:"value"},range:{attribute:"range",type:Boolean},rangeStart:{attribute:"range-start"},rangeEnd:{attribute:"range-end"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"}}}render(){this.classList.add("c-date-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Date picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-date-picker__label",()=>{const el=document.createElement("label");el.className="c-date-picker__label";return el});l.textContent=label}const input=this.ensure(".c-date-picker__input",()=>{const el=document.createElement("input");el.className="c-input c-date-picker__input";return el});const range=this.hasAttribute("range");const type=this.hasAttribute("time")?"datetime-local":"date";const configure=(control,value,name)=>{control.type=type;control.value=value||"";control.setAttribute("aria-label",name);if(this.hasAttribute("min"))control.min=this.getAttribute("min");else control.removeAttribute("min");if(this.hasAttribute("max"))control.max=this.getAttribute("max");else control.removeAttribute("max");if(this.hasAttribute("locale"))control.lang=this.getAttribute("locale");else control.removeAttribute("lang");if(this.hasAttribute("disabled"))control.setAttribute("disabled","");else control.removeAttribute("disabled")};configure(input,range?this.getAttribute("range-start"):this.getAttribute("value"),range?"Start date":(label||"Date"));let end=this.querySelector(".c-date-picker__end");if(range){end=end||document.createElement("input");end.className="c-input c-date-picker__input c-date-picker__end";configure(end,this.getAttribute("range-end"),"End date");if(end.parentNode!==this)this.appendChild(end)}else if(end)end.remove();if(this.hasAttribute("disabled"))this.classList.add("is-disabled");else this.classList.remove("is-disabled");const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-date-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-date-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-date-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}_renderCalendar(){const cal=this.querySelector(".c-date-picker__calendar");if(!cal)return;const input=this.querySelector(".c-date-picker__input");const base=(input&&input.value)?new Date(input.value):new Date();const month=this._calMonth||new Date(base.getFullYear(),base.getMonth(),1);this._calMonth=month;const y=month.getFullYear();const m=month.getMonth();const first=new Date(y,m,1);const startDay=first.getDay();const daysInMonth=new Date(y,m+1,0).getDate();cal.innerHTML="";const header=document.createElement("div");header.className="c-date-picker__calendar-header";const prev=document.createElement("button");prev.type="button";prev.className="c-btn c-btn--sm";prev.textContent="‹";prev.setAttribute("aria-label","Previous month");const title=document.createElement("span");title.className="c-date-picker__calendar-title";title.textContent=month.toLocaleString(this.getAttribute("locale")||undefined,{month:"long",year:"numeric"});const next=document.createElement("button");next.type="button";next.className="c-btn c-btn--sm";next.textContent="›";next.setAttribute("aria-label","Next month");header.appendChild(prev);header.appendChild(title);header.appendChild(next);cal.appendChild(header);const grid=document.createElement("div");grid.className="c-date-picker__calendar-grid";grid.setAttribute("role","grid");const weekdays=["Su","Mo","Tu","We","Th","Fr","Sa"];weekdays.forEach((w)=>{const h=document.createElement("div");h.className="c-date-picker__calendar-weekday";h.textContent=w;grid.appendChild(h)});for(let i=0;i<startDay;i++){const empty=document.createElement("div");empty.className="c-date-picker__calendar-day c-date-picker__calendar-day--empty";grid.appendChild(empty)}const selected=input?input.value:"";for(let d=1;d<=daysInMonth;d++){const btn=document.createElement("button");btn.type="button";btn.className="c-date-picker__calendar-day";btn.textContent=String(d);const iso=`${y}-${String(m + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`;if(selected&&selected.startsWith(iso))btn.classList.add("is-selected");btn.addEventListener("click",()=>{if(input){input.value=iso;input.dispatchEvent(new Event("change",{bubbles:true}))}cal.setAttribute("hidden","");const tgl=this.querySelector(".c-date-picker__calendar-toggle");if(tgl)tgl.setAttribute("aria-expanded","false")});grid.appendChild(btn)}cal.appendChild(grid);prev.addEventListener("click",()=>{this._calMonth=new Date(y,m-1,1);this._renderCalendar()});next.addEventListener("click",()=>{this._calMonth=new Date(y,m+1,1);this._renderCalendar()})}enhance(){if(this._wiredDatePicker)return;this._wiredDatePicker=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-date-picker__input")){const end=this.querySelector(".c-date-picker__end");const detail=end?{start:this.querySelector(".c-date-picker__input").value,end:end.value}:{value:t.value};this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail}))}});const toggle=()=>{const cal=this.querySelector(".c-date-picker__calendar");const btn=this.querySelector(".c-date-picker__calendar-toggle");if(!cal)return;const hidden=cal.hasAttribute("hidden");if(hidden){cal.removeAttribute("hidden");if(btn)btn.setAttribute("aria-expanded","true");this._renderCalendar()}else{cal.setAttribute("hidden","");if(btn)btn.setAttribute("aria-expanded","false")}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-date-picker__calendar-toggle"):null;if(btn&&this.contains(btn)){e.preventDefault();toggle()}})}}define("contour-date-picker",ContourDatePicker);class ContourRating extends ContourBase{static get observed(){return["value","max","color"]}static get properties(){return{value:{attribute:"value",type:Number},max:{attribute:"max",type:Number},color:{attribute:"color"}}}render(){this.classList.add("c-rating");this.setAttribute("role","radiogroup");this.setAttribute("aria-label","Rating");const max=parseInt(this.getAttribute("max")||"5",10)||5;const value=parseInt(this.getAttribute("value")||"0",10)||0;const color=this.getAttribute("color");Array.from(this.querySelectorAll(".c-rating__star")).forEach((n)=>n.remove());for(let i=1;i<=max;i++){const star=document.createElement("button");star.className="c-rating__star"+(i<=value?" c-rating__star--filled":"");star.type="button";star.setAttribute("role","radio");star.setAttribute("aria-checked",String(i===value));star.innerHTML='<span class="c-rating__swatch'+(i<=value?' c-rating__swatch--filled':'')+'" aria-hidden="true"'+(color&&i<=value?' style="background:'+color+';border-color:'+color+'"':'')+'></span>';star.dataset.value=String(i);star.setAttribute("aria-label",i+" star"+(i>1?"s":""));this.appendChild(star)}}enhance(){if(this._wiredRating)return;this._wiredRating=true;this.addEventListener("click",(e)=>{const star=e.target&&e.target.closest?e.target.closest(".c-rating__star"):null;if(star&&this.contains(star)){const v=parseInt(star.dataset.value,10);Array.from(this.querySelectorAll(".c-rating__star")).forEach((st)=>st.setAttribute("aria-checked",String(parseInt(st.dataset.value,10)===v)));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:v}}))}});this.addEventListener("keydown",(e)=>{const stars=Array.from(this.querySelectorAll(".c-rating__star"));const active=document.activeElement;const idx=stars.indexOf(active);if(e.key==="ArrowRight"||e.key==="ArrowUp"){e.preventDefault();const next=stars[Math.min(stars.length-1,idx+1)]||stars[0];if(next){try{next.focus()}catch(err){}}}else if(e.key==="ArrowLeft"||e.key==="ArrowDown"){e.preventDefault();const prev=stars[Math.max(0,idx-1)]||stars[stars.length-1];if(prev){try{prev.focus()}catch(err){}}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(active&&active.classList.contains("c-rating__star")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:parseInt(active.dataset.value,10)}}))}}})}}define("contour-rating",ContourRating);class ContourTimePicker extends ContourBase{static get observed(){return["value","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-time-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Time picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-time-picker__label",()=>{const el=document.createElement("label");el.className="c-time-picker__label";return el});l.textContent=label}const input=this.ensure(".c-time-picker__input",()=>{const el=document.createElement("input");el.className="c-input c-time-picker__input";el.type="time";return el});input.value=this.getAttribute("value")||"";if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-time-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-time-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-time-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}enhance(){if(this._wiredTimePicker)return;this._wiredTimePicker=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-time-picker__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-time-picker",ContourTimePicker);class ContourColorPicker extends ContourBase{static get observed(){return["value","label","disabled","error","help","alpha","presets"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},alpha:{attribute:"alpha",type:Boolean},presets:{attribute:"presets"}}}render(){this.classList.add("c-color-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Color picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-color-picker__label",()=>{const el=document.createElement("label");el.className="c-color-picker__label";return el});l.textContent=label}const input=this.ensure(".c-color-picker__input",()=>{const el=document.createElement("input");el.className="c-color-picker__input";el.type="color";return el});input.value=(this.getAttribute("value")||"#000000").slice(0,7);if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}if(this.hasAttribute("alpha")){const alpha=this.ensure(".c-color-picker__alpha",()=>{const el=document.createElement("input");el.className="c-color-picker__alpha";el.type="range";el.min="0";el.max="1";el.step="0.01";return el});const v=this.getAttribute("value")||"#000000";const a=v.length===9?parseInt(v.slice(7,9),16)/255:1;alpha.value=String(a);alpha.setAttribute("aria-label","Alpha")}else{const a=this.querySelector(".c-color-picker__alpha");if(a)a.remove()}const presetsAttr=this.getAttribute("presets");let presets=[];if(presetsAttr){try{presets=JSON.parse(presetsAttr)}catch(e){presets=[]}}const oldPresets=this.querySelector(".c-color-picker__presets");if(oldPresets)oldPresets.remove();if(Array.isArray(presets)&&presets.length){const wrap=document.createElement("div");wrap.className="c-color-picker__presets";presets.forEach((c)=>{const btn=document.createElement("button");btn.type="button";btn.className="c-color-picker__preset";btn.style.background=c;btn.dataset.color=c;btn.setAttribute("aria-label","Preset "+c);wrap.appendChild(btn)});this.appendChild(wrap)}if(typeof window!=="undefined"&&"EyeDropper"in window){const ed=this.ensure(".c-color-picker__eyedropper",()=>{const el=document.createElement("button");el.className="c-color-picker__eyedropper";el.type="button";el.textContent="Pick";el.setAttribute("aria-label","Pick color from screen");return el});if(this.hasAttribute("disabled"))ed.setAttribute("disabled","");else ed.removeAttribute("disabled")}else{const ed=this.querySelector(".c-color-picker__eyedropper");if(ed)ed.remove()}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-color-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-color-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-color-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}enhance(){if(this._wiredColorPicker)return;this._wiredColorPicker=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-color-picker__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}if(t&&t.classList.contains("c-color-picker__alpha")){const base=(this.getAttribute("value")||"#000000").slice(0,7);const a=Math.round(parseFloat(t.value)*255).toString(16).padStart(2,"0");const val=base+a;this.setAttribute("value",val);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:val}}))}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-color-picker__preset"):null;if(btn&&this.contains(btn)){const c=btn.dataset.color;if(c){this.setAttribute("value",c);const input=this.querySelector(".c-color-picker__input");if(input)input.value=c.slice(0,7);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:c}}))}}const ed=e.target&&e.target.closest?e.target.closest(".c-color-picker__eyedropper"):null;if(ed&&this.contains(ed)&&typeof window!=="undefined"&&"EyeDropper"in window){e.preventDefault();const dropper=new window.EyeDropper();dropper.open().then((r)=>{if(r&&r.sRGBHex){this.setAttribute("value",r.sRGBHex);const input=this.querySelector(".c-color-picker__input");if(input)input.value=r.sRGBHex;this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:r.sRGBHex}}))}}).catch(()=>{})}})}}define("contour-color-picker",ContourColorPicker);class ContourNumberField extends ContourBase{static get observed(){return["value","min","max","step","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},step:{attribute:"step"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-number-field");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-number-field__label",()=>{const el=document.createElement("label");el.className="c-number-field__label";return el});l.textContent=label}const input=this.ensure(".c-number-field__input",()=>{const el=document.createElement("input");el.className="c-input c-number-field__input";el.type="number";el.setAttribute("role","spinbutton");return el});if(this.getAttribute("value")!==null)input.value=this.getAttribute("value");if(this.getAttribute("min")!==null)input.min=this.getAttribute("min");if(this.getAttribute("max")!==null)input.max=this.getAttribute("max");if(this.getAttribute("step")!==null)input.step=this.getAttribute("step");const v=input.value;input.setAttribute("aria-valuenow",v===""?"":v);if(input.min!=="")input.setAttribute("aria-valuemin",input.min);if(input.max!=="")input.setAttribute("aria-valuemax",input.max);if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-number-field__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-number-field__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-number-field__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}enhance(){if(this._wiredNumberField)return;this._wiredNumberField=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-number-field__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("keydown",(e)=>{const input=this.querySelector(".c-number-field__input");if(!input||document.activeElement!==input)return;const step=Number(input.step)||1;const min=input.min===""?-Infinity:Number(input.min);const max=input.max===""?Infinity:Number(input.max);let next=null;if(e.key==="ArrowUp")next=(Number(input.value)||0)+step;else if(e.key==="ArrowDown")next=(Number(input.value)||0)-step;else if(e.key==="Home")next=min===-Infinity?0:min;else if(e.key==="End")next=max===Infinity?(Number(input.value)||0):max;if(next!==null){e.preventDefault();next=Math.min(max,Math.max(min,next));input.value=String(next);input.setAttribute("aria-valuenow",String(next));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:input.value}}))}})}}define("contour-number-field",ContourNumberField);class ContourHoverCard extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},anchor:{attribute:"anchor"}}}render(){this.classList.add("c-hover-card");if(!this.hasAttribute("role"))this.setAttribute("role","tooltip");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Hover card");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("hover-card");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-hover-card__title",()=>{const el=document.createElement("div");el.className="c-hover-card__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-hover-card__body",()=>{const el=document.createElement("div");el.className="c-hover-card__body";return el});c.textContent=content}}enhance(){if(this._wiredHoverCard)return;this._wiredHoverCard=true;const anchorSel=this.getAttribute("anchor");if(anchorSel){const trigger=anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel);if(trigger){trigger.setAttribute("popovertarget",this.id);let showTimer=null;const hasPopover=typeof this.showPopover==="function";const show=()=>{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};const hide=()=>{if(showTimer)clearTimeout(showTimer);if(hasPopover){try{this.hidePopover()}catch(e){}}else this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};trigger.addEventListener("mouseenter",()=>{showTimer=setTimeout(show,300)});trigger.addEventListener("mouseleave",()=>{hide()});trigger.addEventListener("focus",show);trigger.addEventListener("blur",()=>{setTimeout(hide,100)});onDispose(this,()=>{if(showTimer){clearTimeout(showTimer);showTimer=null}})}}const keyHandler=(e)=>{if(e.key==="Escape"&&(this.classList.contains("is-open")||this.matches(":popover-open"))){e.preventDefault();if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-hover-card",ContourHoverCard);class ContourContextMenu extends ContourBase{static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-context-menu");if(!this.hasAttribute("role"))this.setAttribute("role","menu");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("context-menu");const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);this.innerHTML="";parsed.forEach((it)=>{const btn=document.createElement("button");btn.className="c-menu__item";btn.setAttribute("role","menuitem");btn.textContent=typeof it==="string"?it:(it.label||it.title||"");this.appendChild(btn)})}catch(e){}}}enhance(){if(this._wiredContextMenu)return;this._wiredContextMenu=true;this.addEventListener("contextmenu",(e)=>{e.preventDefault();if(typeof this.showPopover==="function"){try{this.showPopover()}catch(err){}}else this.classList.toggle("is-open")});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&this.contains(item)){this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent.trim()}}));if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open")}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-menu__item"));const active=document.activeElement;const idx=items.indexOf(active);if(e.key==="ArrowDown"){e.preventDefault();const next=items[Math.min(items.length-1,idx+1)]||items[0];if(next)try{next.focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();const prev=items[Math.max(0,idx-1)]||items[items.length-1];if(prev)try{prev.focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(active&&active.classList.contains("c-menu__item"))active.click()}else if(e.key==="Escape"){e.preventDefault();if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open")}})}}define("contour-context-menu",ContourContextMenu);class ContourFab extends ContourBase{static get observed(){return["label","icon"]}static get properties(){return{label:{attribute:"label"},icon:{attribute:"icon"}}}render(){this.classList.add("c-fab");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");const label=this.getAttribute("label");if(label)this.setAttribute("aria-label",label);const icon=this.getAttribute("icon");if(icon&&!this.hasChildNodes())this.textContent=icon}enhance(){if(this._wiredFab)return;this._wiredFab=true;this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-fab",ContourFab);class ContourFileUpload extends ContourBase{static get observed(){return["label","accept","multiple","progress"]}static get properties(){return{label:{attribute:"label"},accept:{attribute:"accept"},multiple:{attribute:"multiple",type:Boolean},progress:{attribute:"progress"}}}render(){this.classList.add("c-file-upload");const label=this.getAttribute("label")||"Drop files here or click to browse";const dz=this.ensure(".c-file-upload__dropzone",()=>{const el=document.createElement("div");el.className="c-file-upload__dropzone";el.setAttribute("role","button");el.tabIndex=0;return el});dz.textContent=label;const input=this.ensure(".c-file-upload__input",()=>{const el=document.createElement("input");el.className="c-file-upload__input";el.type="file";el.hidden=true;return el});input.accept=this.getAttribute("accept")||"";input.multiple=this.hasAttribute("multiple");const p=this.getAttribute("progress");if(p!==null){const bar=this.ensure(".c-file-upload__progress",()=>{const el=document.createElement("progress");el.className="c-file-upload__progress";return el});bar.value=Number(p)||0;bar.max=100}else{const bar=this.querySelector(".c-file-upload__progress");if(bar)bar.remove()}const preview=this.ensure(".c-file-upload__preview",()=>{const el=document.createElement("div");el.className="c-file-upload__preview";return el});if(!preview){}}enhance(){if(this._wiredFileUpload)return;this._wiredFileUpload=true;const dz=()=>this.querySelector(".c-file-upload__dropzone");const input=()=>this.querySelector(".c-file-upload__input");const activate=()=>{const i=input();if(i)i.click()};this.addEventListener("click",(e)=>{const d=dz();if(e.target===d||(d&&d.contains(e.target))){activate()}});this.addEventListener("keydown",(e)=>{const d=dz();if((e.target===d||(d&&d.contains(e.target)))&&(e.key==="Enter"||e.key===" ")){e.preventDefault();activate()}});const renderPreview=(files)=>{const preview=this.querySelector(".c-file-upload__preview");if(!preview)return;preview.innerHTML="";Array.from(files||[]).forEach((f)=>{const item=document.createElement("div");item.className="c-file-upload__preview-item";if(f.type&&f.type.startsWith("image/")){const img=document.createElement("img");img.className="c-file-upload__preview-thumb";img.alt=f.name;img.loading="lazy";img.decoding="async";try{img.src=URL.createObjectURL(f)}catch(e){}item.appendChild(img)}else{const name=document.createElement("span");name.className="c-file-upload__preview-name";name.textContent=f.name;item.appendChild(name)}preview.appendChild(item)})};this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-file-upload__input")){renderPreview(t.files);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{files:t.files}}))}});this.addEventListener("dragover",(e)=>{e.preventDefault();this.classList.add("is-dragover")});this.addEventListener("dragleave",()=>this.classList.remove("is-dragover"));this.addEventListener("drop",(e)=>{e.preventDefault();this.classList.remove("is-dragover");const i=input();if(i&&e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){try{i.files=e.dataTransfer.files}catch(err){}const preview=this.querySelector(".c-file-upload__preview");if(preview){preview.innerHTML="";Array.from(e.dataTransfer.files).forEach((f)=>{const item=document.createElement("div");item.className="c-file-upload__preview-item";if(f.type&&f.type.startsWith("image/")){const img=document.createElement("img");img.className="c-file-upload__preview-thumb";img.alt=f.name;try{img.src=URL.createObjectURL(f)}catch(err2){}item.appendChild(img)}else{const name=document.createElement("span");name.className="c-file-upload__preview-name";name.textContent=f.name;item.appendChild(name)}preview.appendChild(item)})}this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{files:e.dataTransfer.files}}))}})}}define("contour-file-upload",ContourFileUpload);class ContourNotificationCenter extends ContourBase{static get observed(){return["count","items","color"]}static get properties(){return{count:{attribute:"count"},items:{attribute:"items"},color:{attribute:"color"}}}render(){this.classList.add("c-notification-center");this.setAttribute("role","list");const btn=this.ensure(".c-notification-center__trigger",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-notification-center__trigger";el.type="button";el.innerHTML='<span class="c-notification-center__bullet" aria-hidden="true"></span>';el.setAttribute("aria-haspopup","dialog");el.setAttribute("aria-expanded","false");return el});const color=this.getAttribute("color");const bullet=btn.querySelector(".c-notification-center__bullet");if(bullet&&color){bullet.style.background=color;bullet.dataset.color=color}const count=this.getAttribute("count");let badge=btn.querySelector(".c-notification-center__badge");if(count&&Number(count)>0){if(!badge){badge=document.createElement("span");badge.className="c-notification-center__badge c-badge c-badge--dot";btn.appendChild(badge)}badge.textContent=count}else if(badge){badge.remove()}const panel=this.ensure(".c-notification-center__panel",()=>{const el=document.createElement("div");el.className="c-notification-center__panel";el.hidden=true;el.setAttribute("role","dialog");el.setAttribute("aria-label","Notifications");return el});const authoredItems=Array.from(this.querySelectorAll(":scope > .c-notification-center__item"));const items=this.getAttribute("items");if(authoredItems.length){panel.innerHTML="";authoredItems.forEach((it)=>{panel.appendChild(it)})}else if(items){try{const parsed=JSON.parse(items);panel.innerHTML="";parsed.forEach((it)=>{const row=document.createElement("div");row.className="c-notification-center__item";row.setAttribute("tabindex","0");row.setAttribute("role","option");row.textContent=typeof it==="string"?it:(it.text||it.title||"");panel.appendChild(row)})}catch(e){}}}enhance(){if(this._wiredNotifCenter)return;this._wiredNotifCenter=true;this.addEventListener("click",(e)=>{const btn=this.querySelector(".c-notification-center__trigger");const panel=this.querySelector(".c-notification-center__panel");if(btn&&(e.target===btn||btn.contains(e.target))){if(panel){panel.hidden=!panel.hidden;btn.setAttribute("aria-expanded",String(!panel.hidden));this.dispatchEvent(new CustomEvent(panel.hidden?"contour:close":"contour:open",{bubbles:true,composed:true}))}}});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-notification-center__item"):null;if(item&&this.contains(item)){this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent}}))}});const docClick=(e)=>{const panel=this.querySelector(".c-notification-center__panel");const btn=this.querySelector(".c-notification-center__trigger");if(panel&&!panel.hidden&&!this.contains(e.target)){panel.hidden=true;if(btn)btn.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick));const keyHandler=(e)=>{const panel=this.querySelector(".c-notification-center__panel");const btn=this.querySelector(".c-notification-center__trigger");if(e.key==="Escape"&&panel&&!panel.hidden){panel.hidden=true;if(btn){btn.setAttribute("aria-expanded","false");try{btn.focus()}catch(err){}}return}if(!panel||panel.hidden)return;const items=Array.from(panel.querySelectorAll(".c-notification-center__item"));if(!items.length)return;const active=document.activeElement;const idx=items.indexOf(active);if(e.key==="ArrowDown"){e.preventDefault();const next=items[Math.min(items.length-1,idx+1)]||items[0];if(next)try{next.focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();const prev=items[Math.max(0,idx-1)]||items[items.length-1];if(prev)try{prev.focus()}catch(err){}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-notification-center",ContourNotificationCenter);class ContourStepper extends ContourBase{static get observed(){return["steps","current"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"}}}render(){this.classList.add("c-stepper");const steps=this.getAttribute("steps");const current=Number(this.getAttribute("current")||0);const list=this.ensure(".c-stepper__list",()=>{const el=document.createElement("ol");el.className="c-stepper__list";return el});list.innerHTML="";const authoredSteps=Array.from(this.querySelectorAll(":scope > .c-stepper__step"));let parsed=[];if(authoredSteps.length){parsed=authoredSteps.map((el)=>el.textContent.trim());authoredSteps.forEach((el)=>el.remove())}else{try{parsed=steps?JSON.parse(steps):[]}catch(e){parsed=[]}}parsed.forEach((s,i)=>{const li=document.createElement("li");li.className="c-stepper__step"+(i===current?" is-current":"")+(i<current?" is-done":"");if(i===current)li.setAttribute("aria-current","step");li.textContent=typeof s==="string"?s:(s.title||s.label||"");list.appendChild(li)});const nav=this.ensure(".c-stepper__nav",()=>{const el=document.createElement("div");el.className="c-stepper__nav c-btn-group";return el});const prev=this.ensure(".c-stepper__prev",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-stepper__prev";el.type="button";el.textContent="Back";return el});const next=this.ensure(".c-stepper__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-stepper__next";el.type="button";el.textContent="Next";return el});if(!nav.contains(prev))nav.appendChild(prev);if(!nav.contains(next))nav.appendChild(next);if(nav.parentNode!==this)this.appendChild(nav)}enhance(){if(this._wiredStepper)return;this._wiredStepper=true;const go=(dir)=>{const list=this.querySelector(".c-stepper__list");const total=list?list.querySelectorAll(".c-stepper__step").length:0;if(!total)return;let cur=Number(this.getAttribute("current")||0);if(dir==="prev")cur=Math.max(0,cur-1);else cur=Math.min(total-1,cur+1);this.setAttribute("current",String(cur));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:dir,index:cur}}))};this.addEventListener("click",(e)=>{const prev=e.target&&e.target.closest?e.target.closest(".c-stepper__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-stepper__next"):null;if(prev&&this.contains(prev))go("prev");if(next&&this.contains(next))go("next")});this.addEventListener("keydown",(e)=>{if(e.key==="ArrowLeft"){e.preventDefault();go("prev")}else if(e.key==="ArrowRight"){e.preventDefault();go("next")}})}}define("contour-stepper",ContourStepper);class ContourVirtualList extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","item-height","orientation","sticky"]}static get properties(){return{items:{attribute:"items"},"item-height":{attribute:"item-height"},orientation:{attribute:"orientation"},sticky:{attribute:"sticky",type:Boolean}}}_items(){const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_itemHeight(){const h=Number(this.getAttribute("item-height"));return Number.isFinite(h)&&h>0?h:28}_autoHeight(){return this.getAttribute("item-height")==="auto"}render(){this.classList.add("c-virtual-list");this.setAttribute("role","list");const scroller=this.ensure(".c-virtual-list__scroller",()=>{const el=document.createElement("div");el.className="c-virtual-list__scroller";return el});scroller.setAttribute("role","presentation");const horizontal=this.getAttribute("orientation")==="horizontal";scroller.style.overflowX=horizontal?"auto":"hidden";scroller.style.overflowY=horizontal?"hidden":"auto";const inner=this.ensure(".c-virtual-list__inner",()=>{const el=document.createElement("div");el.className="c-virtual-list__inner";el.style.position="relative";return el});if(inner.parentNode!==scroller)scroller.appendChild(inner);this._renderWindow(scroller,inner,horizontal?(scroller.scrollLeft||0):(scroller.scrollTop||0))}_measureHeights(inner,horizontal){const rows=Array.from(inner.querySelectorAll(".c-virtual-list__item"));return rows.map((r)=>horizontal?(r.getBoundingClientRect().width||28):(r.getBoundingClientRect().height||28))}_renderWindow(scroller,inner,scrollTop){const items=this._items();const ih=this._itemHeight();const horizontal=this.getAttribute("orientation")==="horizontal";const autoHeight=this._autoHeight();const viewportSize=horizontal?(scroller.clientWidth||320):(scroller.clientHeight||320);const total=items.length;if(this._vlItemCount!==total){this._vlHeights=null;this._vlItemCount=total}let heights=autoHeight?this._vlHeights:null;let cumulative=null;if(autoHeight&&heights&&heights.length===total){cumulative=[0];for(let i=0;i<total;i++)cumulative.push(cumulative[i]+(heights[i]||28))}const visibleCount=autoHeight&&!cumulative?total:(autoHeight?Math.ceil(viewportSize/28)+6:Math.ceil(viewportSize/ih)+4);let start=0;if(autoHeight&&cumulative){let lo=0,hi=total;while(lo<hi){const mid=(lo+hi)>>1;if(cumulative[mid]<(scrollTop||0))lo=mid+1;else hi=mid}start=Math.max(0,lo-3)}else if(!autoHeight){start=Math.floor((scrollTop||0)/ih)}if(start<0)start=0;const end=autoHeight&&cumulative?Math.min(total,start+visibleCount):Math.min(total,start+visibleCount);if(start>Math.max(0,total-visibleCount)&&!autoHeight)start=Math.max(0,total-visibleCount);const topSpacerSize=autoHeight&&cumulative?cumulative[start]:(autoHeight?0:start*ih);const bottomSpacerSize=autoHeight&&cumulative?Math.max(0,cumulative[total]-cumulative[end]):(autoHeight?0:Math.max(0,(total-end)*ih));inner.style.display=horizontal?"flex":"block";inner.style.width=horizontal&&autoHeight?"max-content":"";inner.style.height=horizontal||autoHeight?"":(total*ih)+"px";inner.innerHTML="";const top=document.createElement("div");top.className="c-virtual-list__spacer c-virtual-list__spacer--top";top.style[horizontal?"width":"height"]=topSpacerSize+"px";inner.appendChild(top);for(let i=start;i<end;i++){const row=document.createElement("div");row.className="c-virtual-list__item";row.setAttribute("role","listitem");row.setAttribute("tabindex",i===0?"0":"-1");row.textContent=typeof items[i]==="string"?items[i]:(items[i].label||items[i].text||JSON.stringify(items[i]));if(this.hasAttribute("sticky")&&items[i]&&items[i].sticky){row.style.position="sticky";row.style.insetBlockStart="0";row.style.zIndex="1"}if(horizontal&&!autoHeight)row.style.flex="0 0 "+ih+"px";row.dataset.index=String(i);inner.appendChild(row)}const bottom=document.createElement("div");bottom.className="c-virtual-list__spacer c-virtual-list__spacer--bottom";bottom.style[horizontal?"width":"height"]=bottomSpacerSize+"px";inner.appendChild(bottom);if(horizontal&&!autoHeight)inner.style.width=(total*ih)+"px";if(autoHeight&&!this._vlHeights){requestAnimationFrame(()=>{this._vlHeights=this._measureHeights(inner,horizontal);const s=scroller;const i=inner;if(s&&i)this._renderWindow(s,i,s.scrollTop||0)})}}enhance(){if(this._wiredVirtualList)return;this._wiredVirtualList=true;const scroller=()=>this.querySelector(".c-virtual-list__scroller");const inner=()=>this.querySelector(".c-virtual-list__inner");let raf=0;const onScroll=()=>{if(raf)return;raf=requestAnimationFrame(()=>{raf=0;const s=scroller();const i=inner();if(s&&i)this._renderWindow(s,i,this.getAttribute("orientation")==="horizontal"?s.scrollLeft:s.scrollTop)})};const s=scroller();if(s){s.addEventListener("scroll",onScroll,{passive:true});onDispose(this,()=>{s.removeEventListener("scroll",onScroll);if(raf)cancelAnimationFrame(raf)})}this.addEventListener("keydown",(e)=>{const rows=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(!rows.length)return;const active=this.querySelector(".c-virtual-list__item:focus")||rows[0];const idx=rows.indexOf(active);let next=-1;if(e.key==="ArrowDown")next=Math.min(idx+1,rows.length-1);else if(e.key==="ArrowUp")next=Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=rows.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();const i=Number(active.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i,value:active.textContent}}));return}if(next<0||next===idx)return;e.preventDefault();rows.forEach((r,i)=>r.setAttribute("tabindex",i===next?"0":"-1"));try{rows[next].focus()}catch(err){}});this.addEventListener("click",(e)=>{const row=e.target&&e.target.closest?e.target.closest(".c-virtual-list__item"):null;if(!row||!this.contains(row))return;const i=Number(row.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i,value:row.textContent}}))})}}define("contour-virtual-list",ContourVirtualList);class ContourCommandPalette extends ContourBase{static get observed(){return["open","items"]}static get properties(){return{open:{attribute:"open",type:Boolean},items:{attribute:"items"}}}render(){this.classList.add("c-command-palette");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-modal"))this.setAttribute("aria-modal","true");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");const search=this.ensure(".c-command-palette__search",()=>{const el=document.createElement("input");el.className="c-input c-command-palette__search";el.type="search";el.placeholder="Search…";el.setAttribute("aria-label","Search commands");return el});const list=this.ensure(".c-command-palette__list",()=>{const el=document.createElement("div");el.className="c-command-palette__list";el.setAttribute("role","listbox");return el});const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);list.innerHTML="";parsed.forEach((it,i)=>{const row=document.createElement("div");row.className="c-command-palette__item";row.setAttribute("role","option");row.id=this.id+"-opt-"+i;row.textContent=typeof it==="string"?it:(it.label||it.title||"");row.dataset.index=String(i);row.dataset.label=row.textContent;list.appendChild(row)})}catch(e){}}}show(){if(typeof this.showPopover==="function"){try{this.showPopover()}catch(e){}}this.classList.add("is-open")}hide(){if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(e){}}this.classList.remove("is-open")}toggle(){if(this.classList.contains("is-open")||this.matches(":popover-open"))this.hide();else this.show()}enhance(){this._wiredCmdPalette=true;const search=()=>this.querySelector(".c-command-palette__search");const list=()=>this.querySelector(".c-command-palette__list");const items=()=>Array.from(this.querySelectorAll(".c-command-palette__item"));const visibleItems=()=>items().filter((it)=>!it.hidden);const setActive=(idx)=>{const vis=visibleItems();vis.forEach((it,i)=>it.classList.toggle("is-active",i===idx));const active=vis[idx];const s=search();if(s&&active)s.setAttribute("aria-activedescendant",active.id);else if(s)s.removeAttribute("aria-activedescendant")};const filter=(q)=>{const needle=(q||"").toLowerCase().trim();items().forEach((it)=>{const label=(it.dataset.label||it.textContent||"").toLowerCase();it.hidden=needle!==""&&!label.includes(needle)});setActive(0)};const select=(it)=>{if(!it)return;this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:Number(it.dataset.index),label:it.dataset.label||it.textContent}}));try{this.hidePopover()}catch(e){}this.classList.remove("is-open")};const s=search();if(s){s.setAttribute("role","combobox");s.setAttribute("aria-autocomplete","list");s.setAttribute("aria-controls",list()?list().id||"":"");if(!list().id)list().id=this.id+"-list";s.setAttribute("aria-controls",list().id);s.addEventListener("input",(e)=>filter(e.target.value));s.addEventListener("keydown",(e)=>{const vis=visibleItems();const active=this.querySelector(".c-command-palette__item.is-active");let idx=active?vis.indexOf(active):-1;if(e.key==="ArrowDown"){e.preventDefault();idx=Math.min(vis.length-1,idx+1);if(idx<0)idx=0;setActive(idx)}else if(e.key==="ArrowUp"){e.preventDefault();idx=Math.max(0,idx-1);if(vis.length&&idx<0)idx=0;setActive(idx)}else if(e.key==="Home"){e.preventDefault();setActive(0)}else if(e.key==="End"){e.preventDefault();setActive(vis.length-1)}else if(e.key==="Enter"){e.preventDefault();if(active)select(active)}else if(e.key==="Escape"){e.preventDefault();try{this.hidePopover()}catch(e){}this.classList.remove("is-open")}})}this.addEventListener("click",(e)=>{const it=e.target&&e.target.closest?e.target.closest(".c-command-palette__item"):null;if(it&&this.contains(it)&&!it.hidden)select(it)});let lastFocus=null;this.addEventListener("beforetoggle",(e)=>{if(e.newState==="open")lastFocus=document.activeElement;else if(lastFocus&&typeof lastFocus.focus==="function"){try{lastFocus.focus()}catch(err){}}});setActive(0)}}define("contour-command-palette",ContourCommandPalette);class ContourBadgeOverflow extends ContourBase{static get observed(){return["count","max"]}static get properties(){return{count:{attribute:"count"},max:{attribute:"max"}}}render(){this.classList.add("c-badge-overflow");const count=Number(this.getAttribute("count")||0);const max=Number(this.getAttribute("max")||3);const extra=Math.max(0,count-max);this.textContent="";if(extra>0){const b=document.createElement("span");b.className="c-badge c-badge-overflow__more";b.textContent="+"+extra;this.appendChild(b)}}}define("contour-badge-overflow",ContourBadgeOverflow);class ContourSideSheet extends ContourBase{static get observed(){return["open","side","title"]}static get properties(){return{open:{attribute:"open",type:Boolean},side:{attribute:"side"},title:{attribute:"title"}}}render(){this.classList.add("c-side-sheet");this.setAttribute("role","dialog");this.setAttribute("aria-modal","true");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Side sheet");const side=this.getAttribute("side")||"end";this.classList.add("c-side-sheet--"+side);if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-side-sheet__title",()=>{const el=document.createElement("div");el.className="c-side-sheet__title";return el});t.textContent=title}}enhance(){if(this._wiredSideSheet)return;this._wiredSideSheet=true;let lastFocus=null;const close=()=>this.removeAttribute("open");const keyHandler=(e)=>{if(e.key==="Escape"&&this.hasAttribute("open")){e.preventDefault();close();return}if(e.key==="Tab"&&this.hasAttribute("open")){const focusables=Array.from(this.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter((el)=>!el.hasAttribute("disabled"));if(!focusables.length){e.preventDefault();return}const first=focusables[0],last=focusables[focusables.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{if(e.target===this)close()});const obs=new MutationObserver(()=>{if(this.hasAttribute("open")){lastFocus=document.activeElement;const first=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(first)try{first.focus()}catch(err){}}else if(lastFocus){try{lastFocus.focus()}catch(err){}lastFocus=null}});obs.observe(this,{attributes:true,attributeFilter:["open"]});onDispose(this,()=>obs.disconnect())}}define("contour-side-sheet",ContourSideSheet);class ContourTour extends ContourBase{static get observed(){return["steps","current"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"}}}render(){this.classList.add("c-tour");this.setAttribute("role","dialog");this.setAttribute("aria-modal","true");this.setAttribute("aria-label","Tour");const steps=this.getAttribute("steps");const current=Number(this.getAttribute("current")||0);let parsed=[];try{parsed=steps?JSON.parse(steps):[]}catch(e){parsed=[]}const step=parsed[current]||{};const tip=this.ensure(".c-tour__tip",()=>{const el=document.createElement("div");el.className="c-tour__tip";return el});tip.textContent=typeof step==="string"?step:(step.text||step.title||"");const nav=this.ensure(".c-tour__nav",()=>{const el=document.createElement("div");el.className="c-tour__nav c-btn-group";return el});const next=this.ensure(".c-tour__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-tour__next";el.type="button";el.textContent="Next";return el});if(!nav.contains(next))nav.appendChild(next)}enhance(){if(this._wiredTour)return;this._wiredTour=true;const nextBtn=this.querySelector(".c-tour__next");if(nextBtn)try{nextBtn.focus()}catch(err){}this.addEventListener("click",(e)=>{const next=e.target&&e.target.closest?e.target.closest(".c-tour__next"):null;if(next&&this.contains(next))this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:"next"}}))});const keyHandler=(e)=>{if(e.key==="Escape")this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-tour",ContourTour);class ContourTagsInput extends ContourBase{static get observed(){return["value","placeholder","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-tags-input");const input=this.ensure(".c-tags-input__input",()=>{const el=document.createElement("input");el.className="c-input c-tags-input__input";el.type="text";el.setAttribute("aria-label","Add tag");return el});input.placeholder=this.getAttribute("placeholder")||"Add tag…";if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-tags-input__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-tags-input__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-tags-input__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const tags=this.getAttribute("value");let parsed=[];try{parsed=tags?JSON.parse(tags):[]}catch(e){parsed=tags?tags.split(",").map((s)=>s.trim()).filter(Boolean):[]}Array.from(this.querySelectorAll(".c-tags-input__tag")).forEach((n)=>n.remove());parsed.forEach((t)=>{const chip=document.createElement("span");chip.className="c-tag c-tags-input__tag";chip.textContent=t;const rm=document.createElement("button");rm.className="c-tags-input__remove";rm.type="button";rm.textContent="×";rm.dataset.value=t;chip.appendChild(rm);this.insertBefore(chip,input)})}enhance(){if(this._wiredTagsInput)return;this._wiredTagsInput=true;let live=this.querySelector(".c-tags-input__live");if(!live){live=document.createElement("span");live.className="c-tags-input__live visually-hidden";live.setAttribute("aria-live","polite");live.setAttribute("aria-atomic","true");this.appendChild(live)}const announce=(msg)=>{if(live)live.textContent=msg};this.addEventListener("keydown",(e)=>{const input=this.querySelector(".c-tags-input__input");if(!input)return;if(e.key==="Enter"&&e.target===input){e.preventDefault();const v=input.value.trim();if(v){let tags=[];try{tags=JSON.parse(this.getAttribute("value")||"[]")}catch(err){tags=(this.getAttribute("value")||"").split(",").map((s)=>s.trim()).filter(Boolean)}if(!Array.isArray(tags))tags=[];if(!tags.includes(v))tags.push(v);this.setAttribute("value",JSON.stringify(tags));input.value="";announce("Added "+v);this.dispatchEvent(new CustomEvent("contour:add",{bubbles:true,composed:true,detail:{value:v}}))}}else if(e.key==="Backspace"&&e.target===input&&input.value===""){let tags=[];try{tags=JSON.parse(this.getAttribute("value")||"[]")}catch(err){tags=(this.getAttribute("value")||"").split(",").map((s)=>s.trim()).filter(Boolean)}if(!Array.isArray(tags))tags=[];if(tags.length){const removed=tags.pop();this.setAttribute("value",JSON.stringify(tags));announce("Removed "+removed);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:removed}}))}}});this.addEventListener("click",(e)=>{const rm=e.target&&e.target.closest?e.target.closest(".c-tags-input__remove"):null;if(rm&&this.contains(rm)){const val=rm.dataset.value;let tags=[];try{tags=JSON.parse(this.getAttribute("value")||"[]")}catch(err){tags=(this.getAttribute("value")||"").split(",").map((s)=>s.trim()).filter(Boolean)}if(!Array.isArray(tags))tags=[];const next=tags.filter((t)=>t!==val);this.setAttribute("value",JSON.stringify(next));announce("Removed "+val);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:val}}))}})}}define("contour-tags-input",ContourTagsInput);class ContourSortableList extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-sortable-list");const list=this.ensure(".c-sortable-list__list",()=>{const el=document.createElement("ul");el.className="c-sortable-list__list";return el});const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}list.innerHTML="";parsed.forEach((it,i)=>{const li=document.createElement("li");li.className="c-sortable-list__item";li.setAttribute("draggable","true");li.dataset.index=String(i);const handle=document.createElement("span");handle.className="c-sortable-list__handle";handle.textContent="⋮⋮";handle.setAttribute("role","button");handle.tabIndex=0;li.appendChild(handle);const label=document.createElement("span");label.className="c-sortable-list__label";label.textContent=typeof it==="string"?it:(it.label||it.text||"");li.appendChild(label);list.appendChild(li)})}enhance(){if(this._wiredSortableList)return;this._wiredSortableList=true;const list=()=>this.querySelector(".c-sortable-list__list");let live=this.querySelector(".c-sortable-list__live");if(!live){live=document.createElement("span");live.className="c-sortable-list__live visually-hidden";live.setAttribute("aria-live","polite");live.setAttribute("aria-atomic","true");this.appendChild(live)}const announce=(msg)=>{if(live)live.textContent=msg};const index=(li)=>Array.from(list().children).indexOf(li);let dragFrom=null;this.addEventListener("dragstart",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li))return;dragFrom=index(li);if(e.dataTransfer){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",String(dragFrom))}catch(err){}}li.classList.add("is-dragging")});this.addEventListener("dragover",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li)||dragFrom===null)return;e.preventDefault();if(e.dataTransfer)e.dataTransfer.dropEffect="move"});this.addEventListener("drop",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li)||dragFrom===null)return;e.preventDefault();const to=index(li);const l=list();const fromLi=l.children[dragFrom];if(fromLi&&dragFrom!==to){if(dragFrom<to)l.insertBefore(fromLi,l.children[to+1]||null);else l.insertBefore(fromLi,l.children[to]);const item=fromLi.querySelector(".c-sortable-list__label");announce((item?item.textContent:"Item")+" moved to position "+(to+1));this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from:dragFrom,to}}))}dragFrom=null;Array.from(l.children).forEach((n)=>n.classList.remove("is-dragging"))});this.addEventListener("dragend",()=>{dragFrom=null;const l=list();if(l)Array.from(l.children).forEach((n)=>n.classList.remove("is-dragging"))});this.addEventListener("keydown",(e)=>{const handle=e.target&&e.target.closest?e.target.closest(".c-sortable-list__handle"):null;if(!handle)return;const li=handle.closest(".c-sortable-list__item");if(!li)return;const l=list();const from=index(li);if(e.key==="ArrowUp"&&li.previousElementSibling){e.preventDefault();l.insertBefore(li,li.previousElementSibling);const to=index(li);const label=li.querySelector(".c-sortable-list__label");announce((label?label.textContent:"Item")+" moved to position "+(to+1));this.dispatchEvent(new CustomEvent("contour:move",{bubbles:true,composed:true,detail:{direction:"up",from,to}}));this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from,to}}))}if(e.key==="ArrowDown"&&li.nextElementSibling){e.preventDefault();l.insertBefore(li.nextElementSibling,li);const to=index(li);const label=li.querySelector(".c-sortable-list__label");announce((label?label.textContent:"Item")+" moved to position "+(to+1));this.dispatchEvent(new CustomEvent("contour:move",{bubbles:true,composed:true,detail:{direction:"down",from,to}}));this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from,to}}))}})}}define("contour-sortable-list",ContourSortableList);class ContourSwatch extends ContourBase{static get observed(){return["color","selected","label"]}static get properties(){return{color:{attribute:"color"},selected:{attribute:"selected",type:Boolean},label:{attribute:"label"}}}render(){this.classList.add("c-swatch");const color=this.getAttribute("color")||"#000";this.style.setProperty("--swatch-color",color);if(this.hasAttribute("selected"))this.classList.add("is-selected");else this.classList.remove("is-selected");if(!this.hasAttribute("aria-label")){const label=this.getAttribute("label")||color;this.setAttribute("aria-label",label)}if(!this.querySelector("button")&&!this.querySelector("span")){const btn=document.createElement("button");btn.className="c-swatch__btn";btn.type="button";this.appendChild(btn)}}enhance(){if(this._wiredSwatch)return;this._wiredSwatch=true;this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:this.getAttribute("color")}}))})}}define("contour-swatch",ContourSwatch);class ContourCalendar extends ContourBase{static get observed(){return["value"]}static get properties(){return{value:{attribute:"value"},month:{attribute:"month"},year:{attribute:"year"}}}render(){this.classList.add("c-calendar");const now=new Date();const year=Number(this.getAttribute("year"))||now.getFullYear();const month=Number(this.getAttribute("month"))||now.getMonth();const header=this.ensure(".c-calendar__header",()=>{const el=document.createElement("div");el.className="c-calendar__header";return el});header.innerHTML="";const prev=document.createElement("button");prev.type="button";prev.className="c-btn c-btn--sm c-calendar__prev";prev.textContent="‹";prev.setAttribute("aria-label","Previous month");const title=document.createElement("span");title.className="c-calendar__title";title.textContent=new Date(year,month,1).toLocaleString(undefined,{month:"long",year:"numeric"});const next=document.createElement("button");next.type="button";next.className="c-btn c-btn--sm c-calendar__next";next.textContent="›";next.setAttribute("aria-label","Next month");header.appendChild(prev);header.appendChild(title);header.appendChild(next);const grid=this.ensure(".c-calendar__grid",()=>{const el=document.createElement("div");el.className="c-calendar__grid";el.setAttribute("role","grid");return el});grid.setAttribute("aria-label",title.textContent);grid.innerHTML="";const first=new Date(year,month,1);const startDay=first.getDay();const daysInMonth=new Date(year,month+1,0).getDate();const selected=this.getAttribute("value");for(let i=0;i<startDay;i++){const empty=document.createElement("div");empty.className="c-calendar__day c-calendar__day--empty";grid.appendChild(empty)}for(let d=1;d<=daysInMonth;d++){const cell=document.createElement("button");cell.className="c-calendar__day";cell.type="button";cell.setAttribute("role","gridcell");cell.setAttribute("tabindex","0");cell.textContent=String(d);const iso=year+"-"+String(month+1).padStart(2,"0")+"-"+String(d).padStart(2,"0");if(iso===selected){cell.classList.add("is-selected");cell.setAttribute("aria-selected","true")}else cell.setAttribute("aria-selected","false");const todayIso=now.getFullYear()+"-"+String(now.getMonth()+1).padStart(2,"0")+"-"+String(now.getDate()).padStart(2,"0");if(iso===todayIso)cell.setAttribute("aria-current","date");cell.dataset.value=iso;grid.appendChild(cell)}if(header.parentNode!==this)this.insertBefore(header,grid)}enhance(){if(this._wiredCalendar)return;this._wiredCalendar=true;this.addEventListener("click",(e)=>{const prev=e.target&&e.target.closest?e.target.closest(".c-calendar__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-calendar__next"):null;if(prev&&this.contains(prev)){let m=Number(this.getAttribute("month"))||new Date().getMonth();let y=Number(this.getAttribute("year"))||new Date().getFullYear();m-=1;if(m<0){m=11;y-=1}this.setAttribute("month",String(m));this.setAttribute("year",String(y));this.render();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{month:m,year:y}}));return}if(next&&this.contains(next)){let m=Number(this.getAttribute("month"))||new Date().getMonth();let y=Number(this.getAttribute("year"))||new Date().getFullYear();m+=1;if(m>11){m=0;y+=1}this.setAttribute("month",String(m));this.setAttribute("year",String(y));this.render();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{month:m,year:y}}));return}const cell=e.target&&e.target.closest?e.target.closest(".c-calendar__day"):null;if(cell&&this.contains(cell)&&cell.dataset.value){this.setAttribute("value",cell.dataset.value);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:cell.dataset.value}}))}});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-calendar__day"):null;if(!cell||!this.contains(cell))return;const cells=Array.from(this.querySelectorAll(".c-calendar__day:not(.c-calendar__day--empty)"));const idx=cells.indexOf(cell);let next=null;if(e.key==="ArrowRight")next=cells[idx+1];else if(e.key==="ArrowLeft")next=cells[idx-1];else if(e.key==="ArrowDown")next=cells[idx+7];else if(e.key==="ArrowUp")next=cells[idx-7];else if(e.key==="Enter"||e.key===" "){e.preventDefault();cell.click();return}if(next){e.preventDefault();try{next.focus()}catch(err){}}})}}define("contour-calendar",ContourCalendar);class ContourCarousel extends ContourBase{static get observed(){return["items","index"]}static get properties(){return{items:{attribute:"items"},index:{attribute:"index"}}}_items(){const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_index(){const i=Number(this.getAttribute("index"));const items=this._items();if(Number.isFinite(i)&&i>=0&&i<items.length)return i;return 0}render(){this.classList.add("c-carousel");this.setAttribute("role","region");this.setAttribute("aria-roledescription","carousel");const track=this.ensure(".c-carousel__track",()=>{const el=document.createElement("div");el.className="c-carousel__track";el.setAttribute("role","group");el.setAttribute("aria-roledescription","slide container");return el});const items=this._items();track.innerHTML="";const idx=this._index();items.forEach((it,i)=>{const slide=document.createElement("div");slide.className="c-carousel__slide"+(i===idx?" is-active":"");slide.setAttribute("role","group");slide.setAttribute("aria-roledescription","slide");slide.setAttribute("aria-label",(i+1)+" of "+items.length);slide.setAttribute("aria-hidden",i===idx?"false":"true");slide.textContent=typeof it==="string"?it:(it.label||it.text||"");slide.dataset.index=String(i);track.appendChild(slide)});const prev=this.ensure(".c-carousel__prev",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__prev";el.type="button";el.textContent="‹";el.setAttribute("aria-label","Previous slide");return el});const next=this.ensure(".c-carousel__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__next";el.type="button";el.textContent="›";el.setAttribute("aria-label","Next slide");return el});const status=this.ensure(".c-carousel__status",()=>{const el=document.createElement("span");el.className="c-carousel__status";el.setAttribute("aria-live","polite");return el});status.textContent=(idx+1)+" of "+items.length}enhance(){if(this._wiredCarousel)return;this._wiredCarousel=true;const go=(dir)=>{const items=this._items();if(!items.length)return;let idx=this._index();if(dir==="prev")idx=(idx-1+items.length)%items.length;else idx=(idx+1)%items.length;this.setAttribute("index",String(idx));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:idx,direction:dir}}))};this.addEventListener("click",(e)=>{const prev=e.target&&e.target.closest?e.target.closest(".c-carousel__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-carousel__next"):null;if(prev&&this.contains(prev))go("prev");if(next&&this.contains(next))go("next")});this.addEventListener("keydown",(e)=>{if(e.key==="ArrowLeft"){e.preventDefault();go("prev")}else if(e.key==="ArrowRight"){e.preventDefault();go("next")}else if(e.key==="Home"){e.preventDefault();this.setAttribute("index","0");this.render();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:0,direction:"home"}}))}else if(e.key==="End"){e.preventDefault();const last=this._items().length-1;if(last>=0){this.setAttribute("index",String(last));this.render();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:last,direction:"end"}}))}}})}}define("contour-carousel",ContourCarousel);class ContourDataGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","filter","page-size","resizable","virtual","row-height"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page"},filter:{attribute:"filter"},"page-size":{attribute:"page-size"},resizable:{attribute:"resizable",type:Boolean},virtual:{attribute:"virtual",type:Boolean},"row-height":{attribute:"row-height"}}}render(){this.classList.add("c-data-grid");if(this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const table=this.ensure(".c-data-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-data-grid__table";el.setAttribute("role","grid");return el});const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(tbody.parentNode!==table)table.appendChild(tbody);tbody.innerHTML="";const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=1;td.style.textAlign="center";td.style.color="var(--color-text-muted)";if(this.hasAttribute("loading"))td.textContent=this.getAttribute("loading")||"Loading…";else if(this.hasAttribute("error"))td.textContent=this.getAttribute("error")||"Error";else td.textContent=this.getAttribute("empty")||"No data";tr.appendChild(td);tbody.appendChild(tr);let wrap=this.querySelector(".c-data-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-data-grid__wrap";wrap.style.maxHeight="400px";wrap.style.overflow="auto"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap);return}const table=this.ensure(".c-data-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-data-grid__table";el.setAttribute("role","grid");return el});const thead=this.ensure("thead",()=>{const el=document.createElement("thead");return el});const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(thead.parentNode!==table)table.appendChild(thead);if(tbody.parentNode!==table)table.appendChild(tbody);const cols=this.getAttribute("columns");let parsedCols=[];try{parsedCols=cols?JSON.parse(cols):[]}catch(e){parsedCols=[]}if(parsedCols.length&&!thead.querySelector("tr")){const tr=document.createElement("tr");parsedCols.forEach((c)=>{const th=document.createElement("th");th.setAttribute("role","columnheader");th.setAttribute("aria-sort","none");th.setAttribute("tabindex","0");th.textContent=typeof c==="string"?c:(c.label||c.key||"");tr.appendChild(th)});thead.appendChild(tr)}if(this.hasAttribute("resizable")){Array.from(thead.querySelectorAll("th")).forEach((th)=>{th.style.position="relative";th.setAttribute("data-resizable","true")})}const rows=this.getAttribute("rows");let parsedRows=[];try{parsedRows=rows?JSON.parse(rows):[]}catch(e){parsedRows=[]}table.setAttribute("aria-rowcount",String(parsedRows.length));table.setAttribute("aria-colcount",String(parsedCols.length));const filter=this.getAttribute("filter");if(filter){const q=filter.toLowerCase();parsedRows=parsedRows.filter((r)=>JSON.stringify(r).toLowerCase().includes(q))}const page=Number(this.getAttribute("page")||1);const pageSize=Number(this.getAttribute("page-size")||0);if(pageSize>0){const start=(page-1)*pageSize;parsedRows=parsedRows.slice(start,start+pageSize)}this._dgCols=parsedCols;this._dgRows=parsedRows;this._dgFilteredRows=parsedRows;const virtual=this.hasAttribute("virtual")&&!(Number(this.getAttribute("page-size"))>0);if(virtual){this._renderDataGridWindow(0)}else{tbody.innerHTML="";parsedRows.forEach((r)=>{const tr=document.createElement("tr");parsedCols.forEach((c)=>{const key=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","0");td.textContent=r&&r[key]!=null?r[key]:"";if(!String(td.textContent).trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)})}let wrap=this.querySelector(".c-data-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-data-grid__wrap";wrap.style.maxHeight="400px";wrap.style.overflow="auto"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap)}_rowHeight(){const h=Number(this.getAttribute("row-height"));return Number.isFinite(h)&&h>0?h:32}_renderDataGridWindow(scrollTop){const table=this.querySelector(".c-data-grid__table");const tbody=table&&table.querySelector("tbody");if(!tbody)return;const cols=this._dgCols||[];const rows=this._dgRows||[];const rh=this._rowHeight();const viewport=400;const visibleCount=Math.ceil(viewport/rh)+6;let start=Math.floor((scrollTop||0)/rh);if(start<0)start=0;if(start>Math.max(0,rows.length-visibleCount))start=Math.max(0,rows.length-visibleCount);const end=Math.min(rows.length,start+visibleCount);tbody.innerHTML="";if(start>0){const sp=document.createElement("tr");const td=document.createElement("td");td.colSpan=Math.max(1,cols.length);td.style.blockSize=(start*rh)+"px";td.style.padding="0";sp.appendChild(td);tbody.appendChild(sp)}for(let i=start;i<end;i++){const r=rows[i];const tr=document.createElement("tr");tr.dataset.index=String(i);cols.forEach((c)=>{const key=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","0");td.textContent=r&&r[key]!=null?r[key]:"";if(!String(td.textContent).trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)}if(end<rows.length){const sp=document.createElement("tr");const td=document.createElement("td");td.colSpan=Math.max(1,cols.length);td.style.blockSize=((rows.length-end)*rh)+"px";td.style.padding="0";sp.appendChild(td);tbody.appendChild(sp)}}enhance(){if(this._wiredDataGrid)return;this._wiredDataGrid=true;const wrap=()=>this.querySelector(".c-data-grid__wrap");const onScroll=()=>{const w=wrap();if(w&&this.hasAttribute("virtual"))this._renderDataGridWindow(w.scrollTop)};this.addEventListener("scroll",(e)=>{const w=e.target&&e.target.classList&&e.target.classList.contains("c-data-grid__wrap")?e.target:null;if(w&&this.hasAttribute("virtual"))this._renderDataGridWindow(w.scrollTop)},true);let sortCol=-1,sortDir="asc";this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest("[role='gridcell'], [role='columnheader']"):null;if(!cell||!this.contains(cell))return;const row=cell.parentElement;const table=this.querySelector(".c-data-grid__table");if(!table)return;const rows=Array.from(table.querySelectorAll("tr"));const ri=rows.indexOf(row);const ci=Array.from(row.children).indexOf(cell);let target=null;if(e.key==="ArrowRight")target=row.children[ci+1];else if(e.key==="ArrowLeft")target=row.children[ci-1];else if(e.key==="ArrowDown")target=rows[ri+1]&&rows[ri+1].children[ci];else if(e.key==="ArrowUp")target=rows[ri-1]&&rows[ri-1].children[ci];if(target){e.preventDefault();try{target.focus()}catch(err){}}});this.addEventListener("click",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tr"):null;const th=e.target&&e.target.closest?e.target.closest("th"):null;if(tr&&this.contains(tr)&&!th){const idx=Array.from(tr.parentElement.children).indexOf(tr);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{row:idx}}))}if(th&&this.contains(th)){const idx=Array.from(th.parentElement.children).indexOf(th);if(sortCol===idx)sortDir=sortDir==="asc"?"desc":"asc";else{sortCol=idx;sortDir="asc"}const table=this.querySelector(".c-data-grid__table");const tbody=table&&table.querySelector("tbody");const thead=table&&table.querySelector("thead");if(tbody&&thead){const cols=Array.from(thead.querySelectorAll("th")).map((h)=>h.textContent);const rows=Array.from(tbody.querySelectorAll("tr")).map((tr)=>Array.from(tr.querySelectorAll("td")).map((td)=>td.textContent));rows.sort((a,b)=>{const va=a[idx]||"",vb=b[idx]||"";const na=Number(va),nb=Number(vb);const cmp=(!isNaN(na)&&!isNaN(nb))?na-nb:String(va).localeCompare(String(vb));return sortDir==="asc"?cmp:-cmp});tbody.innerHTML="";rows.forEach((r)=>{const tr=document.createElement("tr");r.forEach((v)=>{const td=document.createElement("td");td.textContent=v;tr.appendChild(td)});tbody.appendChild(tr)})}Array.from(thead.querySelectorAll("th")).forEach((h,i)=>{h.setAttribute("aria-sort",i===idx?(sortDir==="asc"?"ascending":"descending"):"none")});this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:idx,direction:sortDir}}))}});this.addEventListener("pointerdown",(e)=>{if(!this.hasAttribute("resizable"))return;const th=e.target&&e.target.closest?e.target.closest("th[data-resizable]"):null;if(!th||!this.contains(th)||th.getBoundingClientRect().right-e.clientX>10)return;e.preventDefault();const startX=e.clientX;const startWidth=th.getBoundingClientRect().width;const index=Array.from(th.parentElement.children).indexOf(th);const move=(event)=>{const width=Math.max(48,startWidth+event.clientX-startX);const table=this.querySelector(".c-data-grid__table");if(table)Array.from(table.rows).forEach((row)=>{if(row.children[index])row.children[index].style.inlineSize=width+"px"})};const stop=()=>window.removeEventListener("pointermove",move);window.addEventListener("pointermove",move);window.addEventListener("pointerup",stop,{once:true});onDispose(this,stop)})}}define("contour-data-grid",ContourDataGrid);class ContourTreeGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","expanded"]}static get properties(){return{items:{attribute:"items"},expanded:{attribute:"expanded"}}}_expandedSet(){const raw=this.getAttribute("expanded");if(!raw)return new Set();try{return new Set(JSON.parse(raw))}catch(e){return new Set([raw])}}render(){this.classList.add("c-tree-grid");const table=this.ensure(".c-tree-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-tree-grid__table";el.setAttribute("role","treegrid");return el});table.setAttribute("aria-label","Tree grid");const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(tbody.parentNode!==table)table.appendChild(tbody);const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}const expanded=this._expandedSet();tbody.innerHTML="";const rows=[];const renderNode=(node,depth,path)=>{const tr=document.createElement("tr");tr.setAttribute("role","row");tr.setAttribute("tabindex","0");tr.setAttribute("aria-level",String(depth+1));tr.dataset.path=path;const hasChildren=!!(node&&Array.isArray(node.children)&&node.children.length);if(hasChildren){tr.setAttribute("aria-expanded",expanded.has(path)?"true":"false")}const td=document.createElement("td");td.setAttribute("role","gridcell");td.style.paddingInlineStart=(depth*1.25)+"rem";const label=(node&&(node.label||node.text||node.name))||"";if(hasChildren){const toggle=document.createElement("button");toggle.type="button";toggle.className="c-tree-grid__toggle";toggle.textContent=expanded.has(path)?"▾":"▸";toggle.setAttribute("aria-label",(expanded.has(path)?"Collapse":"Expand")+" "+label);td.appendChild(toggle)}const span=document.createElement("span");span.className="c-tree-grid__label";span.textContent=label;td.appendChild(span);tr.appendChild(td);tbody.appendChild(tr);rows.push(tr);if(hasChildren&&expanded.has(path)){node.children.forEach((c,i)=>renderNode(c,depth+1,path+"."+i))}};parsed.forEach((n,i)=>renderNode(n,0,String(i)));if(table.parentNode!==this)this.appendChild(table)}enhance(){if(this._wiredTreeGrid)return;this._wiredTreeGrid=true;const rows=()=>Array.from(this.querySelectorAll("tr[role='row']"));this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-tree-grid__toggle"):null;const tr=e.target&&e.target.closest?e.target.closest("tr[role='row']"):null;if(!tr||!this.contains(tr))return;const path=tr.dataset.path;if(toggle){e.preventDefault();const expanded=this._expandedSet();if(expanded.has(path))expanded.delete(path);else expanded.add(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:expanded.has(path)}}))}else{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{path}}))}});this.addEventListener("keydown",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tr[role='row']"):null;if(!tr||!this.contains(tr))return;const all=rows();const idx=all.indexOf(tr);const path=tr.dataset.path;const hasChildren=tr.getAttribute("aria-expanded")!==null;const expanded=this._expandedSet();if(e.key==="ArrowRight"&&hasChildren&&!expanded.has(path)){e.preventDefault();expanded.add(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:true}}))}else if(e.key==="ArrowLeft"&&hasChildren&&expanded.has(path)){e.preventDefault();expanded.delete(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:false}}))}else if(e.key==="ArrowDown"){e.preventDefault();if(all[idx+1])try{all[idx+1].focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();if(all[idx-1])try{all[idx-1].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();const toggle=tr.querySelector(".c-tree-grid__toggle");if(toggle)toggle.click()}})}}define("contour-tree-grid",ContourTreeGrid);class ContourPullToRefresh extends ContourBase{static get observed(){return["threshold"]}static get properties(){return{threshold:{attribute:"threshold"}}}render(){this.classList.add("c-pull-to-refresh");const ind=this.ensure(".c-pull-to-refresh__indicator",()=>{const e=document.createElement("div");e.className="c-pull-to-refresh__indicator";e.textContent="Pull to refresh";return e});if(ind.parentNode!==this)this.prepend(ind)}enhance(){if(this._wiredPullToRefresh)return;this._wiredPullToRefresh=true;let startY=0;let pulling=false;this.addEventListener("touchstart",(e)=>{if(this.scrollTop>0)return;const t=e.touches&&e.touches[0];if(t){startY=t.clientY;pulling=true}},{passive:true});this.addEventListener("touchmove",(e)=>{if(!pulling)return;const t=e.touches&&e.touches[0];if(!t)return;const dy=t.clientY-startY;if(dy>0&&dy<120){this.style.setProperty("--ptr-offset",dy+"px")}},{passive:true});this.addEventListener("touchend",(e)=>{if(!pulling)return;pulling=false;const t=e.changedTouches&&e.changedTouches[0];const dy=t?t.clientY-startY:0;const thr=Number(this.getAttribute("threshold"))||60;if(dy>=thr){this.classList.add("is-refreshing");this.dispatchEvent(new CustomEvent("contour:refresh",{bubbles:true,composed:true}));setTimeout(()=>this.classList.remove("is-refreshing"),800)}this.style.removeProperty("--ptr-offset")},{passive:true})}}define("contour-pull-to-refresh",ContourPullToRefresh);define("contour-box",simple(["c-box"]));define("contour-cluster",simple(["c-cluster"]));define("contour-container",simple(["c-container"]));define("contour-row",simple(["c-row"]));define("contour-scrim",simple(["c-scrim"]));define("contour-stack",simple(["c-stack"]));let ADOPTED=null;let ADOPTED_KEY="";const adoptedSheets=()=>{let key=document.styleSheets.length+":";for(const sheet of document.styleSheets){let rules=-1;try{rules=sheet.cssRules.length}catch(e){}key+=(sheet.href||"")+"~"+rules+"|"}if(ADOPTED&&key===ADOPTED_KEY)return ADOPTED;ADOPTED_KEY=key;ADOPTED=[];const collect=(sheet,out)=>{let rules;try{rules=sheet.cssRules}catch(e){return}if(!rules)return;for(const r of rules){if(r instanceof CSSImportRule){if(r.styleSheet)collect(r.styleSheet,out)}else{try{out.push(r.cssText)}catch(e){}}}};for(const sheet of document.styleSheets){try{if(sheet.href&&new URL(sheet.href).origin===location.origin){const collected=[];collect(sheet,collected);const built=new CSSStyleSheet();if(collected.length)built.replaceSync(collected.join("\n"));ADOPTED.push(built)}}catch(e){}}return ADOPTED};const _ShadowParent=(typeof HTMLElement!=="undefined")?HTMLElement:Object;class ContourShadow extends _ShadowParent{static get observedAttributes(){return MODS}constructor(){super();const root=this.attachShadow({mode:"open"});const sheets=adoptedSheets();if(sheets.length)root.adoptedStyleSheets=sheets;root.appendChild(this.constructor.contourTemplate.content.cloneNode(true));this._shadowBase=root.firstElementChild?root.firstElementChild.className:""}enhance(root){if(!root)root=this.shadowRoot;if(!root)return;root.querySelectorAll("details").forEach((d)=>{const summary=d.querySelector("summary");if(summary&&!summary.hasAttribute("aria-expanded")){summary.setAttribute("aria-expanded",String(d.open));d.addEventListener("toggle",()=>{summary.setAttribute("aria-expanded",String(d.open))})}});root.querySelectorAll("[data-live]").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite")});root.querySelectorAll(".c-spinner").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite")});root.querySelectorAll(".c-toast, .c-toast-host").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite");if(!el.hasAttribute("aria-atomic"))el.setAttribute("aria-atomic","true")});root.querySelectorAll("[role='tab']").forEach((tab)=>{const ctrl=tab.getAttribute("aria-controls");if(ctrl){const panel=root.querySelector("#"+CSS.escape(ctrl))||document.getElementById(ctrl);if(panel&&!panel.hasAttribute("aria-labelledby")){if(!tab.id)tab.id=contourId("tab");panel.setAttribute("aria-labelledby",tab.id)}}});root.querySelectorAll("input, textarea, select").forEach((input)=>{if(input.hasAttribute("aria-describedby"))return;const field=input.closest(".c-field");if(field){const hint=field.querySelector(".c-field__hint");if(hint){if(!hint.id)hint.id=contourId("hint");input.setAttribute("aria-describedby",hint.id)}const err=field.querySelector(".c-field__error");if(err){if(!err.id)err.id=contourId("err");const existing=input.getAttribute("aria-describedby")||"";input.setAttribute("aria-describedby",(existing+" "+err.id).trim())}}});root.querySelectorAll(".c-alert").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","alert");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","assertive")});root.querySelectorAll("input[required], textarea[required], select[required]").forEach((el)=>{if(!el.hasAttribute("aria-required"))el.setAttribute("aria-required","true")})}connectedCallback(){this.applyMods();try{this.enhance(this.shadowRoot)}catch(e){}try{wcReset(this);wireTabs(this);wireSegmented(this);wireCombobox(this);wireTree(this);wireMenu(this);wirePagination(this);wireCopy(this);wireRemovable(this)}catch(e){}if(this.shadowRoot&&!this._wiredSlotchange){this._wiredSlotchange=true;this.shadowRoot.addEventListener("slotchange",()=>{try{this.enhance(this.shadowRoot);wireTabs(this);wireSegmented(this);wireCombobox(this);wireTree(this);wireMenu(this);wirePagination(this);wireCopy(this);wireRemovable(this)}catch(e){}})}}attributeChangedCallback(){this.applyMods()}applyMods(){const el=this.shadowRoot.firstElementChild;if(!el||!this._shadowBase)return;const mods=[];for(const attr of MODS){const val=this.getAttribute(attr);if(!val)continue;for(const cls of this._shadowBase.split(/\s+/)){if(cls)mods.push("c-"+cls.replace(/^c-/,"")+"--"+val)}}el.className=(this._shadowBase+" "+mods.join(" ")).trim()}}const SHADOW_PARTS_PUBLIC={};const shadow=(name,markup)=>{if(typeof document==="undefined")return;const tpl=document.createElement("template");tpl.innerHTML=markup;SHADOW_PARTS_PUBLIC[name]=[...tpl.content.querySelectorAll("[part]")].flatMap((node)=>(node.getAttribute("part")||"").split(/\s+/)).filter(Boolean);const cls=class extends ContourShadow{};cls.contourTemplate=tpl;define(name,cls)};const slotWrapper=(tag,block,part)=>"<"+tag+' class="c-'+block+'" part="'+(part||block)+'"'+(tag==="button"?' type="button"':"")+"><slot></slot></"+tag+">";const SHADOW_SLOTS={div:["accordion","activity","advanced","affordance","affordances","anchor","app","app-body","box","btn-group","chart-grid","catchment","cluster","command","compare","comparison","compass","contour-plot","cta","dash-freshness","dash-kpi-row","dash-shell","dash-toolbar","datamark","delta","draggable","drag-handle","drop-indicator","drop-zone","destructive-hint","docs-shell","drawer","elevation","filter-bar","flow-map","heatmap","hexbin","icon-badge","input-group","instrument","range-scale","resizable","table-wrap","time-range","toast-host","scroll-area","isochrone","landing-features","landing-hero","layer-panel","layer-switch","legend","logos","map-area","map-footer","map-panel","map-slot","measure","metrics","minimap","pager","pagination","panel","plate","price","pricing","progress","prose","pullquote","radio-list","range","readout","recipe","reserved","resize-handle","row","row-action","scale-bar","scrim","segmented","sheet","shortcut-list","shortcut-overlay","shortcut-panel","shortcut-row","showcase","sidebar","skeleton","sparkline","stack","steps","streaming-chart","survey","theme-scope","time-slider","timeline","toast","toolbar","tooltip","tree","version","version-banner"],button:["btn","pressable","scheme-toggle"],span:["avatar","badge","chip","dot","flag","live-badge","mark","pill"],a:["link","linkish"],kbd:["kbd"],label:["check","radio","switch"],select:["select"],nav:["docs-nav"],};const SHADOW_PARTS={"version-banner":"banner","contour-plot":"plot",};if(typeof document!=="undefined"){for(const[tag,blocks]of Object.entries(SHADOW_SLOTS)){for(const block of blocks){const part=SHADOW_PARTS[block]||block;shadow("contour-shadow-"+block,slotWrapper(tag,block,part))}}}shadow("contour-shadow-callout",`<div class="c-callout" part="callout"><div class="c-callout__title" part="title"><slot name="title"></slot></div><div class="c-callout__body" part="body"><slot></slot></div><button class="c-callout__close" part="close" type="button" aria-label="Close">×</button></div>`);shadow("contour-shadow-empty",`<div class="c-empty" part="empty"><div class="c-empty__illustration" part="illustration"><slot name="illustration"></slot></div><div class="c-empty__title" part="title"><slot name="title"></slot></div><div class="c-empty__text" part="body"><slot></slot></div><div><slot name="action"></slot></div></div>`);shadow("contour-shadow-feature",`<div class="c-feature" part="feature"><span class="c-feature__index" part="index"><slot name="index"></slot></span><div class="c-feature__title" part="title"><slot name="title"></slot></div><div class="c-feature__body" part="body"><slot></slot></div></div>`);shadow("contour-shadow-kpi",`<div class="c-kpi" part="kpi"><div class="c-kpi__value" part="value"><slot name="value"></slot></div><div class="c-kpi__label" part="label"><slot name="label"></slot></div><div class="c-kpi__foot" part="foot"><slot name="delta"></slot><slot name="note"></slot></div></div>`);shadow("contour-shadow-stat",`<div class="c-stat" part="stat"><div class="c-stat__value" part="value"><slot name="value"></slot></div><div class="c-stat__label" part="label"><slot name="label"></slot></div><div class="c-stat__delta" part="delta"><slot name="delta"></slot></div></div>`);shadow("contour-shadow-meter",`<div class="c-meter" part="meter"><span class="c-meter__core" part="core"><span class="c-meter__value" part="value"><slot name="value"></slot></span><span class="c-meter__label" part="label"><slot name="label"></slot></span></span></div>`);shadow("contour-shadow-brownout",`<div class="c-brownout" part="brownout" data-level="0"><slot></slot></div>`);shadow("contour-shadow-widget-state",`<div class="c-widget-state" part="widget-state"><slot></slot></div>`);shadow("contour-shadow-donut",`<div class="c-donut" part="donut"><svg class="c-donut__ring" part="ring" viewBox="0 0 32 32"></svg><div class="c-donut__center" part="center"><slot name="value"></slot></div><div class="c-donut__list" part="list"><slot></slot></div></div>`);shadow("contour-shadow-axis",`<div class="c-axis" part="axis"><slot></slot></div>`);shadow("contour-shadow-brush",`<div class="c-brush" part="brush"><div class="c-brush__selection" part="selection"></div></div>`);shadow("contour-shadow-stacked-bar",`<div class="c-stacked-bar" part="bar"><slot></slot></div>`);shadow("contour-shadow-category",`<div class="c-category" part="category" role="listbox"><slot></slot></div>`);shadow("contour-shadow-gauge",`<div class="c-gauge" part="gauge"><svg class="c-gauge__dial" part="dial" aria-hidden="true" viewBox="0 0 100 100"><path class="c-gauge__track" part="track" d="M 10 90 A 40 40 0 0 1 90 90"></path><g class="c-gauge__zones"></g><line class="c-gauge__needle" part="needle" x1="50" y1="50" x2="50" y2="15"></line><circle class="c-gauge__hub" part="hub" cx="50" cy="50" r="4"></circle></svg><div class="c-gauge__value" part="value"><slot name="value"></slot></div><div class="c-gauge__band" part="band"><slot name="band"></slot></div></div>`);shadow("contour-shadow-diff",`<div class="c-diff" part="diff"><div class="c-diff__line c-diff__line--del" part="before"><span class="c-diff__sign">−</span><span><slot name="before"></slot></span></div><div class="c-diff__line c-diff__line--add" part="after"><span class="c-diff__sign">+</span><span><slot name="after"></slot></span></div></div>`);shadow("contour-shadow-do-dont",`<div class="c-do-dont" part="do-dont"><div class="c-do-dont__item c-do-dont__item--do" part="do"><slot name="do"></slot></div><div class="c-do-dont__item c-do-dont__item--dont" part="dont"><slot name="dont"></slot></div></div>`);shadow("contour-shadow-threshold",`<div class="c-threshold" part="threshold"><span class="c-threshold__fill" part="value"></span><span class="c-threshold__target" part="target"></span></div>`);shadow("contour-shadow-coordinate",`<div class="c-coordinate" part="coordinate"><span class="c-coordinate__value" part="value"><slot name="value"></slot></span></div>`);shadow("contour-shadow-install",`<div class="c-install" part="install"><span class="c-install__prompt" part="prompt"><slot name="prompt"></slot></span><span class="c-install__command" part="command"><slot name="command"></slot></span><button class="c-btn c-btn--ghost c-btn--sm c-install__copy" part="copy" type="button" aria-label="Copy command">Copy</button></div>`);shadow("contour-shadow-toc",`<div class="c-toc" part="toc"><div class="c-toc__title" part="title"><slot name="title"></slot></div><nav class="c-toc__list" part="list"><slot></slot></nav></div>`);shadow("contour-shadow-testimonial",`<div class="c-testimonial" part="testimonial"><blockquote class="c-testimonial__quote" part="quote"><slot name="quote"></slot></blockquote><div class="c-testimonial__byline" part="byline"><span class="c-testimonial__name" part="name"><slot name="name"></slot></span><span class="c-testimonial__role" part="role"><slot name="role"></slot></span></div></div>`);shadow("contour-shadow-search-trigger",`<button class="c-search-trigger" part="trigger"><span><slot name="label"></slot></span><kbd class="c-search-trigger__kbd"><slot name="shortcut"></slot></kbd></button>`);shadow("contour-shadow-brand",`<a class="c-brand" part="brand"><span class="c-mark" part="mark"><slot name="mark"></slot></span><span class="c-brand__name" part="name"><slot name="name"></slot></span></a>`);shadow("contour-shadow-section-head",`<div class="c-section-head" part="head"><h2 class="c-section-head__title" part="title"><slot name="title"></slot></h2><p class="c-section-head__desc" part="desc"><slot name="desc"></slot></p></div>`);shadow("contour-shadow-loading",`<div class="c-loading" part="loading"><span class="c-spinner" part="spinner"></span><slot></slot></div>`);shadow("contour-shadow-tabs",`<div class="c-tabs" part="tabs"><div class="c-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-tabs__panels" role="presentation"><slot></slot></div></div>`);shadow("contour-shadow-breadcrumb",`<nav class="c-breadcrumb" part="breadcrumb" aria-label="Breadcrumb"><ol><slot></slot></ol></nav>`);shadow("contour-shadow-menu",`<div class="c-menu" part="menu" role="menu"><slot></slot></div>`);shadow("contour-shadow-combobox",`<div class="c-combobox" part="combobox"><input class="c-combobox__input" part="input" type="text" /><ul class="c-combobox__list" part="list" hidden><slot></slot></ul></div>`);shadow("contour-shadow-table",`<div class="c-table-wrap" part="wrap"><table class="c-table" part="table"><thead><slot name="head"></slot></thead><tbody><slot></slot></tbody></table></div>`);shadow("contour-shadow-chart",`<div class="c-chart" part="chart"><div class="c-chart__plot" part="plot"><slot></slot></div></div>`);shadow("contour-shadow-bivariate",`<div class="c-bivariate" part="bivariate"><div class="c-bivariate__matrix" part="matrix"><slot></slot></div></div>`);shadow("contour-shadow-bivariate-legend",`<div class="c-bivariate-legend" part="legend"><div class="c-bivariate-legend__matrix" part="matrix"><slot></slot></div></div>`);shadow("contour-shadow-expandable",`<details class="c-expandable" part="expandable"><summary class="c-expandable__summary"><slot name="summary"></slot></summary><div class="c-expandable__body" part="body"><slot></slot></div></details>`);shadow("contour-shadow-disclosure",`<details class="c-disclosure" part="disclosure"><summary><slot name="summary"></slot></summary><div class="c-disclosure__body" part="body"><slot></slot></div></details>`);shadow("contour-shadow-faq",`<div class="c-faq" part="faq"><div class="c-faq__question" part="question"><slot name="question"></slot></div><div class="c-faq__answer" part="answer"><slot name="answer"></slot></div></div>`);shadow("contour-shadow-code-tabs",`<div class="c-code-tabs" part="code-tabs"><div class="c-code-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-code-tabs__panels"><slot></slot></div></div>`);shadow("contour-shadow-header",`<header class="c-header" part="header"><div class="container c-header__inner" part="inner"><a class="c-brand" part="brand"><slot name="brand"></slot></a><nav class="c-header__nav" part="nav"><slot name="nav"></slot></nav><div class="c-header__actions" part="actions"><slot name="actions"></slot></div></div></header>`);shadow("contour-shadow-footer",`<footer class="c-footer" part="footer"><div class="container c-footer__grid" part="grid"><div class="c-footer__brand" part="brand"><slot name="brand"></slot></div><div class="c-footer__links" part="links"><slot name="links"></slot></div></div></footer>`);shadow("contour-shadow-container",`<div class="container" part="container"><slot></slot></div>`);shadow("contour-shadow-input",`<input class="c-input" part="input" />`);shadow("contour-shadow-spinner",`<span class="c-spinner" part="spinner" aria-label="Loading"></span>`);shadow("contour-shadow-textarea",`<textarea class="c-textarea" part="textarea"></textarea>`);shadow("contour-shadow-code",`<pre class="c-code" part="code"><code><slot></slot></code><button class="c-code__copy" part="copy" type="button">Copy</button></pre>`);shadow("contour-shadow-card",`<div class="c-card" part="card"> <div class="c-card__title" part="head"><slot name="title">Untitled</slot></div> <div class="c-card__body" part="body"><slot></slot></div> <div class="c-card__foot" part="foot"><slot name="foot"></slot></div> </div>`);shadow("contour-shadow-field",`<div class="c-field" part="field"> <label class="c-field__label" part="label"><slot name="label">Label</slot></label> <slot name="input"></slot> <span class="c-field__hint" part="hint"><slot name="hint"></slot></span> </div>`);shadow("contour-shadow-alert",`<div class="c-alert" part="alert"> <div class="c-alert__title" part="title"><slot name="title"></slot></div> <div class="c-alert__body" part="body"><slot></slot></div> <div class="c-alert__actions" part="actions"><slot name="action"></slot></div> <button class="c-alert__close" part="close" type="button" aria-label="Close">×</button> </div>`);shadow("contour-shadow-tag",`<span class="c-tag" part="tag"><slot></slot><button class="c-tag__remove" part="remove" type="button" aria-label="Remove">×</button></span>`);shadow("contour-shadow-filter-pill",`<span class="c-filter-pill" part="filter-pill"><slot></slot><button class="c-filter-pill__remove" part="remove" type="button" aria-label="Remove filter">×</button></span>`);class ContourShadowDialog extends ContourShadow{static contourTemplate=(typeof document!=="undefined")?(()=>{const tpl=document.createElement("template");tpl.innerHTML="<dialog class=\"c-dialog\" part=\"dialog\"> <div class=\"c-dialog__head\" part=\"head\"> <slot name=\"title\"></slot> <button class=\"c-btn c-btn--icon c-btn--ghost\" part=\"close\" type=\"button\" aria-label=\"Close\"> <svg aria-hidden=\"true\"><use href=\"#i-close\" /></svg> </button> </div> <div class=\"c-dialog__body\" part=\"body\"><slot></slot></div> <div class=\"c-dialog__foot\" part=\"foot\"><slot name=\"foot\"></slot></div> </dialog>";return tpl})():null;enhance(root){super.enhance(root);if(this._wiredShadowDialog)return;this._wiredShadowDialog=true;const dlg=root.querySelector("dialog");const close=root.querySelector('[part="close"]');if(close)close.addEventListener("click",()=>dlg?.close());if(dlg){let lastFocus=null;dlg.addEventListener("beforetoggle",(e)=>{if(e.newState==="open"){lastFocus=document.activeElement;this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}));const focusable=dlg.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable)try{focusable.focus()}catch(e){}}else if(e.newState==="closed"){this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));if(lastFocus&&typeof lastFocus.focus==="function"){try{lastFocus.focus()}catch(e){}}}});dlg.addEventListener("keydown",(e)=>{if(e.key!=="Tab")return;const focusables=Array.from(dlg.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])"));if(!focusables.length)return;const first=focusables[0];const last=focusables[focusables.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}})}}show(){this.shadowRoot?.querySelector("dialog")?.showModal()}close(){this.shadowRoot?.querySelector("dialog")?.close()}}define("contour-shadow-dialog",ContourShadowDialog);if(typeof window!=="undefined"){window.ContourElements=Object.freeze(REGISTERED.slice());window.ContourShadowParts=Object.freeze(Object.fromEntries(Object.entries(SHADOW_PARTS_PUBLIC).map(([name,parts])=>[name,Object.freeze([...new Set(parts)])]),));window.ContourEvents=Object.freeze(CONTOUR_EVENTS)}
|
|
1
|
+
export var CONTOUR_VERSION="1.9.0";export const REGISTERED=[];const isScroller=t=>{if("function"!=typeof getComputedStyle)return!1;const e=getComputedStyle(t);return("auto"===e.overflowY||"scroll"===e.overflowY||"auto"===e.overflowX||"scroll"===e.overflowX)&&(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)},DISPOSERS=new WeakMap;export const onDispose=(t,e)=>{let r=DISPOSERS.get(t);r||(r=[],DISPOSERS.set(t,r)),r.push(e)};function contourDebugEnabled(){try{if("undefined"!=typeof window&&(window.ContourDebug||window.__CONTOUR_DEBUG__))return!0}catch(t){}try{if("undefined"!=typeof process&&process.env&&"production"!==process.env.NODE_ENV&&process.env.CONTOUR_DEBUG)return!0}catch(t){}return!1}const runDisposers=t=>{const e=DISPOSERS.get(t);if(e){DISPOSERS.delete(t);for(const r of e)try{r()}catch(e){if(contourDebugEnabled())try{console.warn("Contour disposer failed for",t&&t.tagName,e)}catch(t){}}}};let _contourIdCounter=0;export const contourId=t=>t+"-"+(++_contourIdCounter).toString(36);export const define=(t,e)=>{"undefined"!=typeof customElements&&customElements&&"function"==typeof customElements.define&&(customElements.get(t)||"undefined"!=typeof window&&"function"==typeof window.__contourDefineDefer&&window.__contourDefineDefer(t,e)||(customElements.define(t,e),REGISTERED.push(t),"undefined"!=typeof window&&(window.ContourElements=Object.freeze(REGISTERED.slice()))))};export const MODS=["variant","size","color"];const JSON_TYPE=Symbol("JSON");export const CONTOUR_EVENTS=Object.freeze({"contour:activate":{payload:["files","label","row","value"],composed:!0},"contour:add":{payload:["value"],composed:!0},"contour:activity-clear":{payload:[],composed:!0},"contour:activity-filter":{payload:["unread"],composed:!0},"contour:activity-select":{payload:["index","text"],composed:!0},"contour:rendered":{payload:["renderCount"],composed:!0},"contour:cap":{payload:["series","total","shown"],composed:!0},"contour:action":{payload:["label"],composed:!0},"contour:break-change":{payload:["layer","value"],composed:!0},"contour:style-resolved":{payload:["applied","classification","colors","items","layer","n","palette","property","value"],composed:!0},"contour:advanced-toggle":{payload:["title"],composed:!0},"contour:affordance-activate":{payload:["name"],composed:!0},"contour:aggregate":{payload:["aggregate"],composed:!0},"contour:bearing":{payload:["direction","degrees"],composed:!0},"contour:btn-group-change":{payload:["index","label"],composed:!0},"contour:brush-start":{payload:["end","range","start","value"],composed:!0},"contour:brush-end":{payload:["end","range","start","value"],composed:!0},"contour:brush":{payload:["end","range","start","value"],composed:!0},"contour:change":{payload:["checked","color","direction","end","files","high","index","low","month","name","paused","query","speed","start","unit","value","values","year"],composed:!0},"contour:collapse":{payload:["collapsed"],composed:!0},"contour:cluster-toggle":{payload:["count","expanded"],composed:!0},"contour:clear":{payload:[],composed:!0},"contour:clear-all":{payload:[],composed:!0},"contour:close":{payload:["count","index","label","message","open","value"],composed:!0},"contour:copy":{payload:["text"],composed:!0},"contour:apply":{payload:["name"],composed:!0},"contour:dash-action":{payload:["label"],composed:!0},"contour:diff-activate":{payload:["kind","text"],composed:!0},"contour:dismiss":{payload:["label"],composed:!0},"contour:draw-start":{payload:["mode"],composed:!0},"contour:drag":{payload:["delta","key","value"],composed:!0},"contour:do-dont-activate":{payload:["kind","text"],composed:!0},"contour:docs-nav-select":{payload:["label","href"],composed:!0},"contour:dragend":{payload:["value"],composed:!0},"contour:dragstart":{payload:["value"],composed:!0},"contour:drop":{payload:["value","label"],composed:!0},"contour:empty-action":{payload:["state"],composed:!0},"contour:filter":{payload:["query"],composed:!0},"contour:filter-change":{payload:["source","filter"],composed:!0},"contour:error":{payload:["src","message","name","status"],composed:!0},"contour:export":{payload:["format"],composed:!0},"contour:refresh":{payload:[],composed:!0},"contour:hide":{payload:[],composed:!0,deprecated:"use contour:close instead"},"contour:hover":{payload:["row"],composed:!0},"contour:input":{payload:["name","value","checked"],composed:!0},"contour:invalid":{payload:["field","input","message"],composed:!0,cancelable:!0},"contour:inspect-action":{payload:["label","value"],composed:!0},"contour:layer-opacity":{payload:["layerId","name","opacity"],composed:!0},"contour:layer-rename":{payload:["layerId","name","newName"],composed:!0},"contour:layer-duplicate":{payload:["layerId","name"],composed:!0},"contour:layer-zoom":{payload:["layerId","name"],composed:!0},"contour:zoom":{payload:["data","index","row"],composed:!0},"contour:layer-projection":{payload:["layerId","name","projection"],composed:!0},"contour:layer-remove":{payload:["layerId","name"],composed:!0},"contour:layer-reorder":{payload:["layerIds"],composed:!0},"contour:layer-toggle":{payload:["layerId","name","visible"],composed:!0},"contour:layer-visibility":{payload:["layerId","name","visible"],composed:!0},"contour:legend-toggle":{payload:["index","key","label","pressed"],composed:!0},"contour:leave":{payload:[],composed:!0},"contour:load":{payload:["src","count"],composed:!0},"contour:map-control":{payload:["control"],composed:!0},"contour:map-style":{payload:["style","name"],composed:!0},"contour:map-attach":{payload:[],composed:!0},"contour:map-ready":{payload:[],composed:!0},"contour:map-detach":{payload:[],composed:!0},"contour:map-popup-reposition":{payload:["anchor","flippedX","flippedY","left","top"],composed:!0},"contour:map-viewport":{payload:["crossesAntimeridian","west","south","east","north","zoom","center"],composed:!0},"contour:mode-change":{payload:["mode"],composed:!0},"contour:scope-change":{payload:["scope"],composed:!0},"contour:move":{payload:["direction","from","to","dx","dy"],composed:!0},"contour:open":{payload:[],composed:!0},"contour:page":{payload:["page"],composed:!0},"contour:ready":{payload:["version","count"],composed:!0},"contour:read":{payload:["label"],composed:!0},"contour:remove":{payload:["key","label","name","value"],composed:!0},"contour:reorder":{payload:["from","to"],composed:!0},"contour:range-change":{payload:["value"],composed:!0},"contour:resize":{payload:["column","delta","height","value","width"],composed:!0},"contour:retry":{payload:["src"],composed:!0},"contour:loop-change":{payload:["loop"],composed:!0},"contour:pause":{payload:[],composed:!0},"contour:play":{payload:[],composed:!0},"contour:seek":{payload:["progress","value"],composed:!0},"contour:select":{payload:["area","col","expanded","href","index","key","label","labels","level","path","range","result","row","rows","series","value"],composed:!0},"contour:search":{payload:["query"],composed:!0},"contour:spatial-filter":{payload:["action","mode","operator"],composed:!0},"contour:split-change":{payload:["value","width","height"],composed:!0},"contour:speed-change":{payload:["speed"],composed:!0},"contour:showcase-activate":{payload:["title"],composed:!0},"contour:step-activate":{payload:["index","title"],composed:!0},"contour:step-change":{payload:["direction","index","title"],composed:!0},"contour:show":{payload:[],composed:!0,deprecated:"use contour:open instead"},"contour:sort":{payload:["column","direction"],composed:!0},"contour:column-toggle":{payload:["column","visible"],composed:!0},"contour:submit":{payload:["submitting"],composed:!0},"contour:stream-state":{payload:["running"],composed:!0},"contour:tab-change":{payload:["index","label"],composed:!0},"contour:theme-change":{payload:["theme"],composed:!0},"contour:tick":{payload:["frame"],composed:!0},"contour:time-change":{payload:["progress","value"],composed:!0},"contour:time-range-change":{payload:["value"],composed:!0},"contour:toggle":{payload:["collapsed","expanded","label","open","path","playing"],composed:!0},"contour:view-enter":{payload:[],composed:!0},"contour:view-leave":{payload:[],composed:!0}});const SANITIZE_DROP=new Set(["script","iframe","object","embed","style","link","meta","base","form","input","button"]),SANITIZE_ANIMATE=new Set(["animate","animatemotion","animatetransform","set","discard"]),SANITIZE_URL_ATTRS=new Set(["href","src","xlink:href","from","to","values","by","attributename"]);function normalizeUrlCandidate(t){let e=String(null==t?"":t);e=e.replace(/[\t\n\r]/g,""),e=e.replace(/^[\u0000-\u0020]+/,"").replace(/[\u0000-\u0020]+$/,"");try{e=decodeURIComponent(e)}catch(t){}return e.toLowerCase()}function isUnsafeUrl(t){const e=normalizeUrlCandidate(t).replace(/[\u0000-\u001f\u007f]/g,"");return e.startsWith("javascript:")||e.startsWith("vbscript:")||e.startsWith("data:text/html")||e.startsWith("data:image/svg+xml")}export function sanitizeHtml(t){const e=String(null==t?"":t);if("undefined"==typeof DOMParser)return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");const r=(new DOMParser).parseFromString(e,"text/html"),s=t=>{const e=Array.from(t.childNodes);for(const t of e){if(1!==t.nodeType)continue;const e=t.tagName.toLowerCase();if(SANITIZE_DROP.has(e))t.remove();else{if(SANITIZE_ANIMATE.has(e)){const e=Array.from(t.attributes).map(t=>t.name.toLowerCase()),r=String(t.getAttribute("attributename")||"").toLowerCase();if(e.some(t=>SANITIZE_URL_ATTRS.has(t))||SANITIZE_URL_ATTRS.has(r)){t.remove();continue}}for(const e of Array.from(t.attributes)){const r=e.name.toLowerCase();r.startsWith("on")?t.removeAttribute(e.name):"style"!==r&&"srcdoc"!==r?SANITIZE_URL_ATTRS.has(r)&&isUnsafeUrl(e.value)&&t.removeAttribute(e.name):t.removeAttribute(e.name)}s("template"!==e?t:t.content||t)}}};return s(r.body),r.body.innerHTML}export function safeColor(t){const e=String(null==t?"":t).trim();if(!e)return"";if(/[;{}<>"'`\\]/.test(e))return"";if(/url\s*\(/i.test(e)||/expression\s*\(/i.test(e))return"";if(/^#[0-9a-f]{3,8}$/i.test(e))return e;if(/^(rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\(/i.test(e))return e;if(/^(var|light-dark|color-mix)\(/i.test(e)){let t=0;for(let r=0;r<e.length;r++){const s=e[r];if("("===s)t++;else if(")"===s&&(t--,t<0))return""}return 0===t?e:""}return/^[a-z]+$/i.test(e)?e:""}export function safeHref(t){const e=String(null==t?"":t).trim();if(!e)return"#";if(e.startsWith("#")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.startsWith("?"))return e;if("undefined"==typeof document||!document.baseURI)return"#";try{const t=new URL(e,document.baseURI);return["http:","https:","mailto:","tel:"].includes(t.protocol)?e:"#"}catch(t){return"#"}}export function cssLength(t,e){if("undefined"==typeof getComputedStyle||"undefined"==typeof document)return e;const r=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(t));return Number.isFinite(r)&&r>0?r:e}export function warnBadJson(t,e,r){if("undefined"==typeof console||!console.warn)return;const s=t&&t.tagName?t.tagName.toLowerCase():"component",i=r&&r.message||String(r);console.warn(`[contour] ${s}: malformed ${e||"attribute"} — ${i}`)}export const OBSERVED=["accept","action","actions","active","after","allow-duplicate","allow-remove","allow-rename","allow-zoom","alpha","anchor","answer","area","article","attribution","attribution-mark","audit","autoplay","axis","axis-x","axis-y","brownout","brownout-level","before","body","brand","bounds","breakpoint","breaks","brush","brush-end","brush-max","brush-min","brush-start","cache-key","canvas","center","clearable","cols","columns","color","command","cells","checked","chrome","confidence","coverage","debounce","closable","collapsed","collapsible","classification","continuous","content","controls","copyable","count","data","data-table","date","delta","description","glyphs","graduated","demo","density","desc","dir","direction","disabled","distance","dismissible","divider","do","dont","dot","ends","high","input","layer","low","mode","modes","n","opacity","palette","polarity","precision","range","single","empty","exclusive","fallback","filename","format","heading","help","hint","href","icon","illustration","instrument","interval","items","key","layers","level","markers","label","labels","latitude","lazy","lede","legend","left-label","right-label","line","limit","link","links","live","loading","locale","loop","max","media","message","method","methodology","menu","min","multiple","name","needle","next","no","no-cache","no-data-message","nodes","note","norm","options","orientation","page-size","pages","pause","paused","pausable","persist","placeholder","playing","point","points","prev","presets","prompt","question","recent","required","quote","ramp","refresh","removable","resolution","reverse","rings","retry","results","rows","scale","selectable","segments","show-header","sparkline","threshold","thresholds","selected","separator","series","shortcut","side","size","skeleton","sort","sort-dir","status","step","submit","submitting","timeout","trigger","virtual","sticky","cluster-count","cluster-expanded","time","resizable","state","steps","style","subtitle","summary","src","source","table","tabs","tag","text","ticks","title","type","unread-only","unit","updated","row-height","variant","values","viewport","warning","yes","zoom","zoomable","caption","current-time","is-playing","loop-label","no-data-color","no-data-label","property","show-loop","show-thumb","show-thumb-caption","speeds","item-height","pause-label","play-label","speed-label","time-label","shimmer","search","numbered","bucket-count","limit-values","autocomplete","levels","submit-label","fields","gap","flush","head","preview","tags","url","custom-error"];export function headingTag(t,e="h3"){const r=t&&t.getAttribute?t.getAttribute("heading"):null;return/^h[1-6]$/.test(r||"")?r:e}export function flagOn(t,e){if(!t||!t.getAttribute)return!1;const r=t.getAttribute(e);if(null===r)return!1;const s=r.trim().toLowerCase();return"0"!==s&&"false"!==s&&"no"!==s&&"off"!==s&&"null"!==s&&"undefined"!==s}export function flagOnValue(t){if(null==t||!1===t)return!1;if("string"==typeof t){const e=t.trim().toLowerCase();return"0"!==e&&"false"!==e&&"no"!==e&&"off"!==e&&"null"!==e&&"undefined"!==e}return Boolean(t)}export function statusIcon(t){switch(String(t||"").toLowerCase()){case"success":return"i-check-circle";case"warning":return"i-alert";case"danger":case"error":return"i-x";case"info":case"note":case"tip":case"accent":return"i-info";default:return""}}export function wcEmitOverlay(t,e,r){if(!t||!t.dispatchEvent)return;const s="contour:open"===e;if(!s&&!("contour:close"===e))return void t.dispatchEvent(new CustomEvent(e,{detail:r,bubbles:!0,composed:!0}));t.dispatchEvent(new CustomEvent(e,{detail:r,bubbles:!0,composed:!0}));const i=s?"contour:show":"contour:hide";console.warn(`[Contour] ${i} is deprecated, use ${e} instead. Will be removed in v2.0. (host: ${t.tagName||t.constructor.name})`),t.dispatchEvent(new CustomEvent(i,{detail:r,bubbles:!0,composed:!0}))}export function labelText(t,e,r){const s=void 0!==r?r:e,i=t&&t.getAttribute?t.getAttribute("labels"):null;if(!i)return s;try{const t=JSON.parse(i);if(t&&"object"==typeof t&&"string"==typeof t[e]&&t[e])return t[e]}catch(t){}return s}export function iconMarkup(t){return'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+t+'" /></svg>'}let _contourHtmlPolicy=null;export function setHTML(t,e){if(!t)return;const r=null==e||""===e;if(r||"undefined"==typeof window||!window.trustedTypes||"function"!=typeof window.trustedTypes.createPolicy)t.innerHTML=r?"":e;else{if(!_contourHtmlPolicy)try{_contourHtmlPolicy=window.trustedTypes.createPolicy("contour-html",{createHTML:t=>t})}catch(t){_contourHtmlPolicy=null}t.innerHTML=_contourHtmlPolicy?_contourHtmlPolicy.createHTML(e):e}}export function applyLabel(t,e,r,s){t&&(t.dataset&&"true"===t.dataset.contourLabel?t.textContent=labelText(e,r,s):t.textContent||(t.textContent=labelText(e,r,s),t.dataset&&(t.dataset.contourLabel="true")))}const _ContourBaseParent="undefined"!=typeof HTMLElement?HTMLElement:Object,INSTALLED_PROPS=new WeakSet;export class ContourBase extends _ContourBaseParent{static formAssociated=!1;constructor(){super(),this.constructor.formAssociated&&"function"==typeof this.attachInternals&&(this._internals=this.attachInternals())}static get observed(){return OBSERVED}static get observedAttributes(){const t=this.observed;return t.includes("labels")?t:[...t,"labels"]}static get properties(){return{}}static get updateMode(){return"scaffold"}brownoutLevel(){const t=this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0",e=parseInt(t,10);return Number.isFinite(e)?e:0}shed(t,e){return this.brownoutLevel()>=(e||1)}get renderCount(){return this._contourRenderCount||0}get updateComplete(){return this._renderTicket||Promise.resolve(this)}_announceRendered(){const t=this.renderCount;this._renderTicket=new Promise(e=>{queueMicrotask(()=>{this._renderTicket=null,e(this),this.isConnected&&this.dispatchEvent(new CustomEvent("contour:rendered",{bubbles:!0,composed:!0,detail:{renderCount:t}}))})})}_countRender(){this._contourRenderCount=(this._contourRenderCount||0)+1}_installProperties(){const t=this.constructor;if(INSTALLED_PROPS.has(t))return;INSTALLED_PROPS.add(t);const e=t.properties||{},r=new Set,s=t=>"object"==typeof t&&null!==t?JSON.stringify(t):String(t),i=t=>{if(null===t)return null;const e=t.trim();if(e.startsWith("[")||e.startsWith("{"))try{return JSON.parse(e)}catch{}return t};for(const[a,n]of Object.entries(e)){const e=n&&n.attribute||a;r.add(e);const o=n&&n.type||String;Object.defineProperty(t.prototype,a,{get(){const t=this.getAttribute(e);if(o===Boolean)return flagOnValue(t);if(null===t)return n&&void 0!==n.default?n.default:null;if(o===Number){const e=Number(t);return Number.isNaN(e)?null:e}return o===JSON_TYPE?i(t):t},set(t){null==t||!1===t?this.removeAttribute(e):o===Boolean?flagOnValue(t)?this.setAttribute(e,""):this.removeAttribute(e):this.setAttribute(e,s(t))},configurable:!0})}const a=t.observedAttributes;for(const e of a){if(r.has(e))continue;const a=e.replace(/-([a-z])/g,(t,e)=>e.toUpperCase());if(!/^[a-zA-Z_$][\w$]*$/.test(a))continue;if(a in t.prototype)continue;const n="disabled"===e||"checked"===e||"required"===e||"readonly"===e||"multiple"===e||"selected"===e||"open"===e||"hidden"===e;Object.defineProperty(t.prototype,a,{get(){const t=this.getAttribute(e);return n?flagOnValue(t):i(t)},set(t){null==t||!1===t?this.removeAttribute(e):n?flagOnValue(t)?this.setAttribute(e,""):this.removeAttribute(e):this.setAttribute(e,s(t))},configurable:!0})}}connectedCallback(){if(this._contourAuthored){this._wireFormData();for(const t of Object.keys(this))t.startsWith("_wired")&&"_wiredFormData"!==t&&"_wiredValueTracking"!==t&&(this[t]=!1);return void this.attributeChangedCallback("__contour_reconnect__",null,"")}this._installProperties(),this._contourAuthored={nodes:Array.from(this.childNodes)},this._contourOwnedClasses=new Set;for(const t of this._contourAuthored.nodes)1===t.nodeType&&t.setAttribute("data-contour-authored","");const t=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1,this._ensureCache=new Map,this._ensureCacheGen=this._contourRenderGen,this._countRender();const e=new Set(Array.from(this.classList));try{this.render()}catch(t){console.error("Contour render error:",t),this.textContent=labelText(this,"render-error","Component failed to render.")}this._contourGenerated=Array.from(this.childNodes).filter(e=>!t.includes(e)),this._contourOwnedClasses=new Set(Array.from(this.classList).filter(t=>!e.has(t))),this._applyDensity(),this._runEnhance(),this._detachInnerFormControls(),this._wireFormData(),this._wireValueTracking(),this._announceRendered()}attributeChangedCallback(t,e,r){if(e!==r&&this.isConnected&&this._contourAuthored)if(this._batchDepth>0)this._batchDirty=!0;else if(this._contourRendering)this._pendingRerender||(this._pendingRerender=!0,queueMicrotask(()=>{this._pendingRerender=!1,this.isConnected&&this._contourAuthored&&this.attributeChangedCallback("__rerender__",null,"")}));else{"checked"===t&&(this._checkedAttrChanged=!0),this._contourRendering=!0;try{const t=Array.from(this.querySelectorAll("input, textarea, select")).map(t=>({key:t.name||t.id||null,preserveKey:t.getAttribute("data-contour-preserve-key")||null,value:t.value,checked:t.checked,type:t.type,dirty:!!t._contourUserDirty,attrAtDirty:t._contourAttrAtDirty,selected:"SELECT"===t.tagName&&t.multiple?Array.from(t.selectedOptions).map(t=>t.value):null})),e=this.contains(document.activeElement)?document.activeElement:null,r="button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])",s=Array.from(this.querySelectorAll(r)),i=e?s.indexOf(e):-1,a=e&&e.id||null,n=e&&e.getAttribute("data-contour-preserve-key")||null,o=e&&e.getAttribute("name")||null,l=Array.from(this.querySelectorAll("*")).filter(isScroller).map(t=>({el:t,id:t.id||null,preserveKey:t.getAttribute("data-contour-preserve-key")||null,top:t.scrollTop,left:t.scrollLeft})),c=Array.from(this.querySelectorAll("details")).map(t=>({id:t.id||null,preserveKey:t.getAttribute("data-contour-preserve-key")||null,open:t.open}));for(const t of this._contourGenerated||[]){if(!t||t.parentNode!==this)continue;let e=null;if(t.classList&&(t.classList.contains("c-panel__body")||t.classList.contains("c-dialog__body")||t.classList.contains("c-popover__body")||t.classList.contains("c-map-popup__body")||t.classList.contains("c-hover-card__body")||t.classList.contains("c-drawer__body")||t.classList.contains("c-sheet__body")||t.classList.contains("c-alert__body"))?e=t:"PRE"===t.tagName&&(e=t.querySelector("code")||t),e)for(;e.firstChild;)this.insertBefore(e.firstChild,t)}const u=this._contourPersistent,d=t=>!!(u&&u.size&&u.has(t)),h=new Set(this._contourAuthored.nodes||[]);for(const t of this._contourGenerated||[])if(!d(t)){for(const e of Array.from(t.childNodes))h.has(e)&&t.parentNode.insertBefore(e,t);t.parentNode===this&&this.removeChild(t)}const m=new Set(this._contourGenerated||[]),b=Array.from(this.childNodes).filter(t=>!m.has(t)&&!d(t));for(const t of this._contourGenerated||[]){if(d(t))continue;const e=t.querySelectorAll?t.querySelectorAll("[data-contour-authored]"):[];for(const t of e)b.includes(t)||b.push(t)}this._contourAuthored.nodes=b;const p=Array.from(this.childNodes).filter(d);for(const t of p)this.appendChild(t);for(;this.firstChild&&!d(this.firstChild);)this.removeChild(this.firstChild);for(const t of this._contourAuthored.nodes)this.insertBefore(t,this.firstChild&&d(this.firstChild)?this.firstChild:null);for(const t of p)this.appendChild(t);for(const t of this._contourOwnedClasses)this.classList.remove(t);const g=new Set(Array.from(this.classList)),_=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1,this._ensureCache=new Map,this._ensureCacheGen=this._contourRenderGen,this._countRender();try{this.render()}catch(t){console.error("Contour render error:",t),this.textContent=labelText(this,"render-error","Component failed to render.")}this._contourGenerated=Array.from(this.childNodes).filter(t=>!_.includes(t)),this._contourOwnedClasses=new Set(Array.from(this.classList).filter(t=>!g.has(t))),this._applyDensity();const v=Array.from(this.querySelectorAll("input, textarea, select")),f=t.filter(t=>t.key||t.preserveKey),y=t.filter(t=>!t.key&&!t.preserveKey),A=new Set;for(const t of v){const e=t.name||t.id||t.getAttribute("data-contour-preserve-key")||null;if(!e)continue;const r=f.find(t=>(t.key===e||t.preserveKey===e)&&!A.has(t));r&&(A.add(r),this._contourResetting||this._restoreControlValue(t,r),"checkbox"!==t.type&&"radio"!==t.type||"boolean"!=typeof r.checked||this._checkedAttrChanged||this._contourResetting||(t.checked=r.checked))}const C=new Map;for(const t of y){const e=C.get(t.type)||[];e.push(t),C.set(t.type,e)}const w=new Map;for(const t of v){if(t.name||t.id)continue;const e=t.type,r=C.get(e)||[],s=w.get(e)||0;if(s>=r.length)continue;const i=r[s];w.set(e,s+1),this._contourResetting||this._restoreControlValue(t,i),"checkbox"!==t.type&&"radio"!==t.type||"boolean"!=typeof i.checked||this._checkedAttrChanged||this._contourResetting||(t.checked=i.checked)}const E=Array.from(this.querySelectorAll("details")),x=c.filter(t=>t.id||t.preserveKey),S=new Set;for(const t of E){const e=t.id||null,r=t.getAttribute("data-contour-preserve-key")||null;if(!e&&!r)continue;const s=x.find(t=>(t.id===e||t.preserveKey===r)&&!S.has(t.id||t.preserveKey));s&&(S.add(s.id||s.preserveKey),t.open=s.open)}let k=0;const N=c.filter(t=>!t.id);for(const t of E){if(t.id)continue;const e=N[k];if(k+=1,!e)break;t.open=e.open}const L=Array.from(this.querySelectorAll("*")).filter(isScroller),q=l.filter(t=>t.id||t.preserveKey),T=new Set;for(const t of L){const e=t.id||null,r=t.getAttribute("data-contour-preserve-key")||null;if(!e&&!r)continue;const s=q.find(t=>(t.id===e||t.preserveKey===r)&&!T.has(t.el));s&&(T.add(s.el),t.scrollTop=s.top,t.scrollLeft=s.left)}let D=0;const M=l.filter(t=>!t.id&&!t.preserveKey);for(const t of L){if(t.id)continue;const e=M[D];if(D+=1,!e)break;t.scrollTop=e.top,t.scrollLeft=e.left}for(const t of l)t.el&&t.el.isConnected&&u&&u.has(t.el)&&(t.el.scrollTop===t.top&&t.el.scrollLeft===t.left||(t.el.scrollTop=t.top,t.el.scrollLeft=t.left));if(e){let t=null;if(a)try{t=this.querySelector("#"+CSS.escape(a))}catch(e){t=null}if(!t&&n)try{t=this.querySelector('[data-contour-preserve-key="'+CSS.escape(n)+'"]')}catch(e){t=null}if(!t&&o)try{t=this.querySelector('[name="'+CSS.escape(o)+'"]')}catch(e){t=null}if(!t&&i>=0){const e=Array.from(this.querySelectorAll(r));e.length&&(t=e[Math.min(i,e.length-1)])}if(t&&"function"==typeof t.focus)try{t.focus()}catch(t){}else if(document.contains(e))try{e.focus()}catch(t){}else{const t=this.querySelector(r);if(t)try{t.focus()}catch(t){}else try{this.focus()}catch(t){}}}this._runEnhance(),this._detachInnerFormControls(),this._checkedAttrChanged=!1,this._contourResetting=!1}finally{this._contourRendering=!1}this._announceRendered()}}disconnectedCallback(){this._pendingRerender=!1,this._ensureCache=null,this._batchDepth=0,this._batchDirty=!1,this._wiredFormData=!1,this._remoteStatus=null,this._remoteSrc=null,runDisposers(this);const t=this._contourHostListeners;if(t){for(const{type:e,listener:r,options:s}of t)try{this.removeEventListener(e,r,s)}catch(t){}this._contourHostListeners=null}}adoptedCallback(){this._contourAuthored&&this._applyDensity()}enhance(){}addEventListener(t,e,r){if(this._contourHostWiring&&e&&!e._contourBehaviour){let s=this._contourHostListeners;s||(s=[],this._contourHostListeners=s),s.push({type:t,listener:e,options:r})}return super.addEventListener(t,e,r)}_runEnhance(){this._contourHostWiring=!0;try{this.enhance()}finally{this._contourHostWiring=!1}}_syncFormValue(){if(!this._internals)return;const t=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!t)return;const e="checkbox"===t.type||"radio"===t.type?t.checked?t.value||"on":null:t.value;this._internals.setFormValue(e),this._syncValidity(this.hasAttribute("required")&&!e)}_syncValidity(t){if(!this._internals)return;const e=t?{valueMissing:!0}:{};let r=t?"This field is required.":"";const s=this.querySelector("input, textarea, select"),i=s&&s.validity;i&&(i.valueMissing&&(e.valueMissing=!0,r=r||"This field is required."),i.typeMismatch&&(e.typeMismatch=!0,r=r||"Please enter a valid value."),i.patternMismatch&&(e.patternMismatch=!0,r=r||"Please match the requested format."),i.rangeUnderflow&&(e.rangeUnderflow=!0,r=r||"Value is too low."),i.rangeOverflow&&(e.rangeOverflow=!0,r=r||"Value is too high."),i.tooLong&&(e.tooLong=!0,r=r||"Value is too long."),i.tooShort&&(e.tooShort=!0,r=r||"Value is too short."),i.badInput&&(e.badInput=!0,r=r||"Invalid input.")),this._internals.setValidity(e,r),this._setCustomState("data-invalid",Object.keys(e).length>0)}_setCustomState(t,e){let r=this._internals;if(!r)if(this._stateInternals)r=this._stateInternals;else if("function"==typeof this.attachInternals)try{r=this._stateInternals=this.attachInternals()}catch(t){return}const s=r&&r.states;s&&(e?s.has(t)||s.add(t):s.has(t)&&s.delete(t))}_emitForm(t){if(!this._internals)return;const e=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!e)return;const r="checkbox"===e.type||"radio"===e.type;this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:{name:this.getAttribute("name"),value:r?e.checked?e.value||"on":null:e.value,checked:r?e.checked:null}}))}formResetCallback(){for(const t of this.querySelectorAll("input, textarea, select"))if(t._contourUserDirty=!1,"checkbox"===t.type||"radio"===t.type)t.checked=this.hasAttribute("checked");else if("SELECT"===t.tagName){const e=t.querySelector("option[selected], option:first-of-type");t.value=e?e.value:""}else t.value=this.hasAttribute("value")?this.getAttribute("value"):t.getAttribute("value")||"";this._syncFormValue()}formDisabledCallback(t){for(const e of this.querySelectorAll("input, textarea, select, button"))t?e.setAttribute("disabled",""):e.removeAttribute("disabled")}formStateRestoreCallback(t){if(!this._internals||null==t)return;const e=Array.from(this.querySelectorAll("input, textarea, select")),r=String(t),s=e.find(t=>("checkbox"===t.type||"radio"===t.type)&&t.value===r);if(s){s.checked=!0;for(const t of e)t!==s&&"radio"===t.type&&t.name===s.name&&(t.checked=!1)}else e.length&&(e[0].value=r);this._syncFormValue()}checkValidity(){return!this._internals||this._internals.checkValidity()}reportValidity(){return!this._internals||this._internals.reportValidity()}_wireFormData(){if(!this._internals||this._wiredFormData)return;const t=this._internals.form;if(!t)return;this._wiredFormData=!0;const e=this.getAttribute("name"),r=t=>{const r=t.target;r&&"radio"===r.type&&r.name&&r.name===e&&this._syncFormValue()};t.addEventListener("change",r);const s=()=>this._syncFormValue();t.addEventListener("formdata",s),onDispose(this,()=>{t.removeEventListener("change",r),t.removeEventListener("formdata",s)})}_wireValueTracking(){if(!this._internals||this._wiredValueTracking)return;this._wiredValueTracking=!0;const t=t=>{const e=t.target;e&&e.matches&&e.matches("input, textarea, select")&&(this._ownerBetween(e,this)||(e._contourUserDirty=!0,e._contourAttrAtDirty=this.getAttribute("value")))};this.addEventListener("input",t),this.addEventListener("change",t)}_restoreControlValue(t,e){if("file"!==t.type){if(e.dirty&&e.attrAtDirty===this.getAttribute("value")){if(e.selected&&"SELECT"===t.tagName&&t.multiple){const r=new Set(e.selected);for(const e of t.options)e.selected=r.has(e.value)}else t.value=e.value;return t._contourUserDirty=!0,void(t._contourAttrAtDirty=e.attrAtDirty)}""===t.value&&null===t.getAttribute("value")&&(t.value=e.value)}}_detachInnerFormControls(){if(this._internals)for(const t of this.querySelectorAll("input, textarea, select"))t.hasAttribute("name")&&""!==t.getAttribute("form")&&t.setAttribute("form","")}batch(t){if("function"==typeof t){this._batchDepth=(this._batchDepth||0)+1,this._batchDirty=this._batchDirty||!1;try{t()}finally{this._batchDepth-=1,0===this._batchDepth&&this._batchDirty&&(this._batchDirty=!1,this.isConnected&&this._contourAuthored&&this.attributeChangedCallback("__rerender__",null,""))}}}requestRender(){this._contourRerenderQueued||(this._contourRerenderQueued=!0,queueMicrotask(()=>{this._contourRerenderQueued=!1,this.isConnected&&this._contourAuthored&&this.attributeChangedCallback("__rerender__",null,"")}))}_applyDensity(){const t=this.getAttribute("density");null!==t?this.setAttribute("data-density",t):this.hasAttribute("data-density")&&this.removeAttribute("data-density")}_ownerBetween(t,e){for(let r=t.parentElement;r&&r!==e;r=r.parentElement)if(r instanceof ContourBase)return r;return null}keepNode(t){return t?(this._contourPersistent||(this._contourPersistent=new Set),this._contourPersistent.add(t),t):t}ensure(t,e,r){const s=r||this;s._ensureCache&&s._ensureCacheGen===this._contourRenderGen||(s._ensureCache=new Map,s._ensureCacheGen=this._contourRenderGen);const i=s._ensureCache,a=s===this?t:"\0"+s+"\0"+t;let n=i.get(a);if(void 0===n){n=null;for(const e of s.querySelectorAll(t))if(!this._ownerBetween(e,s)){n=e;break}i.set(a,n)}return n||(n=e(),s.appendChild(n),i.set(a,n)),n}}export function withBrownout(t){return class extends t{static get observed(){const t=super.observed&&Array.isArray(super.observed)?super.observed:[];return Array.from(new Set(t.concat(["brownout","brownout-level"])))}brownoutLevel(){return super.brownoutLevel?super.brownoutLevel():parseInt(this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0",10)||0}shed(t,e){return this.brownoutLevel()>=(e||1)}}}export function levelFromAttributes(t={}){const e=t&&(t["brownout-level"]||t.brownout)||"0";return parseInt(e,10)||0}export const simple=t=>class extends ContourBase{render(){t.forEach(t=>this.classList.add(t));for(const e of Array.from(this.classList))t.some(t=>e.startsWith(t+"--"))&&this.classList.remove(e);MODS.forEach(e=>{if(this.hasAttribute(e)){const r=this.getAttribute(e);t.forEach(t=>{const e=t.replace("c-","");this.classList.add(`c-${e}--${r}`)})}})}};export const CLASS_ONLY=["box","cluster","container","row","scrim","stack"];export function supportsUntilFound(){try{const t=document.createElement("div");return t.setAttribute("hidden","until-found"),"until-found"===t.getAttribute("hidden")}catch(t){return!1}}export function formatValue(t,e,r,s){if(!e)return t;const i=r||"undefined"!=typeof navigator&&navigator.language||"en";if("date"===e||"time"===e)try{const r="time"===e?{timeStyle:"short"}:void 0;return new Intl.DateTimeFormat(i,r).format(new Date(t))}catch(e){return t}if("relative"===e)try{const e=Number(t);let r=e;if(Number.isNaN(e)){const e=new Date(t).getTime();Number.isFinite(e)&&(r=(e-Date.now())/1e3)}const s=new Intl.RelativeTimeFormat(i,{numeric:"auto"});return Math.abs(r)<60?s.format(Math.round(r),"second"):Math.abs(r)<3600?s.format(Math.round(r/60),"minute"):Math.abs(r)<86400?s.format(Math.round(r/3600),"hour"):s.format(Math.round(r/86400),"day")}catch(e){return t}let a={};if("currency"===e)a={style:"currency",currency:"USD"};else if("percent"===e)a={style:"percent"};else if("compact"===e)a={notation:"compact"};else if("unit"===e)a={style:"unit",unit:s||"meter"};else if("number"!==e)try{a=JSON.parse(e)}catch(e){return t}try{return new Intl.NumberFormat(i,a).format(Number(t))}catch(e){return t}}export function navKey(t,e,{wrap:r=!0,enter:s=!0,homeEnd:i=!1,onKey:a,onNavigate:n,rtl:o}={}){const l=e.indexOf(document.activeElement);if(l<0)return;let c=-1;const u=o?"ArrowLeft":"ArrowRight",d=o?"ArrowRight":"ArrowLeft";if(t.key===u||"ArrowDown"===t.key?c=r?(l+1)%e.length:Math.min(l+1,e.length-1):t.key===d||"ArrowUp"===t.key?c=r?(l-1+e.length)%e.length:Math.max(0,l-1):(i||r)&&"Home"===t.key?c=0:(i||r)&&"End"===t.key&&(c=e.length-1),c>=0&&c!==l){t.preventDefault();try{e[c].focus()}catch(t){}n&&n(c),a&&a(t.key,l,e[l])}else!s&&!r||"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),a&&a(t.key,l,e[l]))}export function isRtl(t){let e=t;for(;e&&1===e.nodeType;){const t=e.getAttribute&&e.getAttribute("dir");if(t)return"rtl"===t.toLowerCase();e=e.parentElement}try{return"undefined"!=typeof document&&"rtl"===(document.documentElement.getAttribute("dir")||"").toLowerCase()}catch(t){return!1}}export function haversine(t,e,r,s){const i=t=>t*Math.PI/180,a=i(r-t),n=i(s-e),o=Math.sin(a/2)**2+Math.cos(i(t))*Math.cos(i(r))*Math.sin(n/2)**2;return 12742e3*Math.asin(Math.sqrt(o))}export function bearing(t,e,r,s){const i=t=>t*Math.PI/180,a=i(s-e),n=Math.sin(a)*Math.cos(i(r)),o=Math.cos(i(t))*Math.sin(i(r))-Math.sin(i(t))*Math.cos(i(r))*Math.cos(a);return(180*Math.atan2(n,o)/Math.PI+360)%360}export const MERCATOR_MAX_LAT=85.05112878;export function clampLat(t){const e=Number(t);return Number.isFinite(e)?Math.max(-85.05112878,Math.min(85.05112878,e)):NaN}export function normaliseLng(t){const e=Number(t);return Number.isFinite(e)?((e+180)%360+360)%360-180:NaN}export function unwrapBounds(t){const e=t||{},r=normaliseLng(e.west),s=normaliseLng(e.east),i=Number.isFinite(r)&&Number.isFinite(s)&&r>s;return{west:r,south:clampLat(e.south),east:i?s+360:s,north:clampLat(e.north),crossesAntimeridian:i}}export function mercatorResolution(t,e){const r=clampLat(t);return Number.isFinite(r)?156543.03392*Math.cos(r*Math.PI/180)/Math.pow(2,e):NaN}"undefined"!=typeof window&&(window.ContourEvents=Object.freeze(CONTOUR_EVENTS));export function isMissing(t){if(null==t)return!0;if("number"==typeof t)return!Number.isFinite(t);if("string"==typeof t){const e=t.trim();return""===e||"__missing"===e}return!1}export function arcPath(t,e,r,s,i,a){t=Number.isFinite(t)?t:0,e=Number.isFinite(e)?e:0,r=Number.isFinite(r)&&r>0?r:0,s=Number.isFinite(s)&&s>=0?s:0,i=Number.isFinite(i)?i:0;const n=(a=Number.isFinite(a)?a:0)-i>Math.PI?1:0,o=t+r*Math.cos(i),l=e+r*Math.sin(i),c=t+r*Math.cos(a),u=e+r*Math.sin(a);if(s<=0)return`M ${t} ${e} L ${o} ${l} A ${r} ${r} 0 ${n} 1 ${c} ${u} Z`;return`M ${o} ${l} A ${r} ${r} 0 ${n} 1 ${c} ${u} L ${t+s*Math.cos(a)} ${e+s*Math.sin(a)} A ${s} ${s} 0 ${n} 0 ${t+s*Math.cos(i)} ${e+s*Math.sin(i)} Z`}export function donutSlices(t,e){const r=null!=(e=e||{}).cx?e.cx:100,s=null!=e.cy?e.cy:100,i=null!=e.r?e.r:90,a=null!=e.inner?e.inner:55,n=null!=e.gap?e.gap:.02,o=t.reduce((t,e)=>t+(Number(e)>0?Number(e):0),0)||1;let l=-Math.PI/2;const c=[];return t.forEach((t,e)=>{const u=Number(t)||0,d=u/o;if(!(u>0))return void(l+=d*Math.PI*2);const h=d*Math.PI*2-n,m=l+n/2,b=m+Math.max(0,h);c.push({path:arcPath(r,s,i,a,m,b),value:u,index:e}),l+=d*Math.PI*2}),c}export function barRects(t,e){const r=null!=(e=e||{}).width?e.width:300,s=null!=e.height?e.height:120,i=null!=e.gap?e.gap:2,a=t.map(isMissing),n=t.map((t,e)=>a[e]?0:Number(t)||0);let o=Math.min(0,Math.min.apply(null,n.length?n:[0])),l=Math.max(0,Math.max.apply(null,n.length?n:[0]));null!=e.min&&(o=Math.min(o,Number(e.min)||0)),null!=e.max&&(l=Math.max(l,Number(e.max)||0)),Number.isFinite(o)&&Number.isFinite(l)||(o=0,l=1),l===o&&(l=o+1);const c=l-o,u=r/(t.length||1),d=Math.max(1,u-i),h=s-(0-o)/c*s;return n.map((t,e)=>{const r=s-(t-o)/c*s;return{x:e*u+i/2,y:Math.min(r,h),width:d,height:a[e]?0:Math.abs(h-r),zeroY:h,missing:a[e]}})}export function niceTicks(t,e,r){r=r||5;const s=e-t||1;let i=Math.pow(10,Math.floor(Math.log10(s/r)));if(!Number.isFinite(i)||i<=0)return[t,e];const a=r*i/s;a<=.15?i*=10:a<=.35?i*=5:a<=.75&&(i*=2);const n=Math.floor(t/i)*i,o=Math.ceil(e/i)*i,l=[];for(let t=n;t<=o+i/2;t+=i)l.push(Math.round(1e9*t)/1e9);return l}export function polylinePoints(t,e){const r=null!=(e=e||{}).width?e.width:300,s=null!=e.height?e.height:120,i=t.map(t=>Number(t)||0);if(!i.length)return"";const a=null!=e.max?e.max:Math.max.apply(null,i),n=null!=e.min?e.min:Math.min.apply(null,i),o=Number.isFinite(a-n)&&a-n!==0?a-n:1,l=i.length||1;return i.map((t,e)=>{const i=e/Math.max(1,l-1)*r,a=s-(t-n)/o*s;return i.toFixed(2)+","+a.toFixed(2)}).join(" ")}export function smoothPath(t,e){const r=null!=(e=e||{}).width?e.width:300,s=null!=e.height?e.height:120,i=t.filter(t=>!isMissing(t)).map(Number).filter(t=>Number.isFinite(t)),a=null!=e.max?e.max:i.length?Math.max.apply(null,i):1,n=null!=e.min?e.min:i.length?Math.min.apply(null,i):0,o=Number.isFinite(a-n)&&a-n!==0?a-n:1,l=t.length||1,c=t.map((t,e)=>{if(isMissing(t))return null;const i=Number(t);if(!Number.isFinite(i))return null;return[e/Math.max(1,l-1)*r,s-(i-n)/o*s]});let u="",d=[];const h=()=>{if(d.length){u+=` M ${d[0][0]} ${d[0][1]}`;for(let t=1;t<d.length;t++){const e=d[t-1],r=d[t],s=(e[0]+r[0])/2;u+=` C ${s} ${e[1]}, ${s} ${r[1]}, ${r[0]} ${r[1]}`}d=[]}};return c.forEach(t=>{t?d.push(t):h()}),h(),u.trim()}export function compassNeedle(t,e,r,s,i){t=Number.isFinite(Number(t))?Number(t):0,e=Number.isFinite(Number(e))?Number(e):0,r=Number.isFinite(Number(r))?Number(r):0,s=null==s?0:Number.isFinite(Number(s))?Number(s):0,i=null==i?3:Number.isFinite(Number(i))?Number(i):3;const a=(s-90)*Math.PI/180,n=t+r*Math.cos(a),o=e+r*Math.sin(a),l=.25*r,c=t-l*Math.cos(a),u=e-l*Math.sin(a),d=Math.cos(a+Math.PI/2),h=Math.sin(a+Math.PI/2),m=t+i*d,b=e+i*h,p=t-i*d,g=e-i*h;return`M ${n.toFixed(2)} ${o.toFixed(2)} L ${m.toFixed(2)} ${b.toFixed(2)} L ${c.toFixed(2)} ${u.toFixed(2)} L ${p.toFixed(2)} ${g.toFixed(2)} Z`}export function scaleBarTicks(t,e){t=Number(t)||0,e=Math.max(1,Math.round(e||4));const r=[];for(let s=0;s<=e;s++)r.push(t/e*s);return r}export const MARKER_SHAPES=["circle","square","triangle","diamond","star"];export function markerStyles(t){return{circle:"border-radius:50%",square:"border-radius:0",triangle:"clip-path:polygon(50% 0%,0% 100%,100% 100%)",diamond:"transform:rotate(45deg)",star:"clip-path:polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)"}[t]||""}export function assignMarkers(t){return(t||[]).map((t,e)=>({...t,marker:MARKER_SHAPES[e%MARKER_SHAPES.length]}))}export function marchingSquares(t,e){const r=t.length,s=r?t[0].length:0,i=[];if(!r||!s)return i;const a=(t,r,s,i)=>i===s?.5:(e-s)/(i-s);for(let n=0;n<r-1;n++)for(let r=0;r<s-1;r++){const s=t[n][r],o=t[n][r+1],l=t[n+1][r],c=t[n+1][r+1],u=(s>=e?8:0)|(o>=e?4:0)|(c>=e?2:0)|(l>=e?1:0);if(0===u||15===u)continue;const d={x:r+a(0,0,s,o),y:n},h={x:r+1,y:n+a(0,0,o,c)},m={x:r+a(0,0,l,c),y:n+1},b={x:r,y:n+a(0,0,s,l)};let p;const g=(()=>{const t=s-o-l+c;return Math.abs(t)<1e-12?(s+o+l+c)/4:(s*c-o*l)/t})();switch(5===u?p=g>=e?"top-bottom":"left-right":10===u&&(p=g>=e?"left-right":"top-bottom"),u){case 1:case 14:i.push([b,m]);break;case 2:case 13:i.push([m,h]);break;case 3:case 12:i.push([b,h]);break;case 4:case 11:i.push([d,h]);break;case 6:case 9:i.push([d,m]);break;case 7:case 8:i.push([b,d]);break;case 5:"top-bottom"===p?i.push([d,m],[b,h]):i.push([d,h],[b,m]);break;case 10:"left-right"===p?i.push([b,h],[d,m]):i.push([d,h],[b,m])}}return i}export function contourPaths(t,e,r,s){const i=t.length,a=i?t[0].length:0;if(i<2||a<2)return[];const n=r/(a-1),o=s/(i-1);return(e||[]).map(e=>{const r=marchingSquares(t,e);let s="";for(const[t,e]of r)s+=`M ${(t.x*n).toFixed(2)} ${(t.y*o).toFixed(2)} L ${(e.x*n).toFixed(2)} ${(e.y*o).toFixed(2)} `;return{level:e,d:s.trim()}})}const unit=t=>Math.max(0,Math.min(1,Number(t)||0)),quantise=(t,e)=>Math.round(unit(t)*e)/e,categoryColor=(t,e)=>["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd"][Math.max(0,Math.min(4,Math.floor(Number(t)||0)))]||e,spriteStroke=t=>Math.max(1,Math.round((Number(t)||24)/16));export function paintDonutGlyph(t,{size:e=24,value:r=0,color:s="#1f77b4",strokeWidth:i,bgColor:a="transparent"}={}){const n=Number(e)||24,o=null!=i?Number(i):spriteStroke(n),l=unit(r),c=n/2,u=n/2,d=(n-o)/2;a&&"transparent"!==a?(t.fillStyle=a,t.fillRect(0,0,n,n)):t.clearRect(0,0,n,n),t.beginPath(),t.arc(c,u,d,0,2*Math.PI),t.lineWidth=o,t.strokeStyle="rgba(0,0,0,0.12)",t.stroke(),l>0&&(t.beginPath(),t.arc(c,u,d,-Math.PI/2,-Math.PI/2+2*l*Math.PI),t.lineWidth=o,t.strokeStyle=s,t.lineCap="round",t.stroke())}export function paintSparklineGlyph(t,{size:e=24,values:r=[],color:s="#1f77b4",strokeWidth:i,bgColor:a="transparent"}={}){const n=Number(e)||24,o=null!=i?Number(i):spriteStroke(n),l=Array.isArray(r)?r.filter(t=>Number.isFinite(t)):[],c=l.length;if(a&&"transparent"!==a?(t.fillStyle=a,t.fillRect(0,0,n,n)):t.clearRect(0,0,n,n),c<2)return;const u=o+1,d=n-2*u,h=n-2*u,m=Math.min(...l),b=Math.max(...l)-m||1;t.beginPath(),l.forEach((e,r)=>{const s=u+r/(c-1)*d,i=(t=>u+h-(t-m)/b*h)(e);0===r?t.moveTo(s,i):t.lineTo(s,i)}),t.lineWidth=o,t.strokeStyle=s,t.lineCap="round",t.lineJoin="round",t.stroke()}export function paintPurityRing(t,{size:e=32,hue:r=0,concentration:s=0,color:i,uncertainty:a=0,timeStep:n=0,timeSteps:o=4}={}){const l=Number(e)||32,c=spriteStroke(l),u=l/2,d=l/2,h=(l-2*c)/2,m=Math.max(0,Math.min(4,Math.floor(Number(r)||0))),b=i||categoryColor(m,"#1f77b4"),p=quantise(s,8);if(t.clearRect(0,0,l,l),t.beginPath(),t.arc(u,d,h,0,2*Math.PI),t.lineWidth=c,t.strokeStyle="rgba(0,0,0,0.12)",t.stroke(),p>0&&(t.beginPath(),t.arc(u,d,h,-Math.PI/2,-Math.PI/2+2*p*Math.PI),t.lineWidth=c,t.strokeStyle=b,t.lineCap="round",t.stroke()),a>0){const e=h+c,r=1===a?[c,2*c]:[2*c,c];t.beginPath(),t.arc(u,d,e,0,2*Math.PI),t.lineWidth=c,t.strokeStyle=b,t.setLineDash(r),t.stroke(),t.setLineDash([])}if(o>0&&n>=0){const e=Math.max(0,Math.min(o-1,Math.floor(Number(n)||0))),r=-Math.PI/2+e/o*2*Math.PI,s=u+h*Math.cos(r),i=d+h*Math.sin(r);t.beginPath(),t.arc(s,i,.75*c,0,2*Math.PI),t.fillStyle=b,t.fill()}}const WIRED_HOSTS=new WeakMap,WIRED_LISTENERS=new WeakMap,wcTrack=(t,e,r,s,i)=>{let a=WIRED_LISTENERS.get(t);a||(a=[],WIRED_LISTENERS.set(t,a)),a.push({target:e,type:r,fn:s,options:i});try{s._contourBehaviour=!0}catch(t){}e.addEventListener(r,s,i)};export const wcReset=t=>{WIRED_HOSTS.delete(t);const e=WIRED_LISTENERS.get(t);if(e){for(const{target:t,type:r,fn:s,options:i}of e)try{t.removeEventListener(r,s,i)}catch(t){}WIRED_LISTENERS.delete(t)}};const wcClaim=(t,e)=>{let r=WIRED_HOSTS.get(t);return r||(r=new Set,WIRED_HOSTS.set(t,r)),!r.has(e)&&(r.add(e),!0)},wcScopes=t=>t.shadowRoot?[t,t.shadowRoot]:[t],wcAll=(t,e)=>{const r=[];for(const s of wcScopes(t))for(const t of s.querySelectorAll(e))r.includes(t)||r.push(t);return r},wcOne=(t,e)=>wcAll(t,e)[0]||null,wcSelfOrAll=(t,e)=>{const r="function"==typeof t.matches&&t.matches(e)?[t]:[];for(const s of wcAll(t,e))r.includes(s)||r.push(s);return r},wcShadowOf=t=>{const e=t&&t.getRootNode?t.getRootNode():null;return e&&e.host?e:null},wcGroup=(t,e,r)=>{const s=Array.from(e.querySelectorAll(r));if(wcShadowOf(e)&&wcShadowOf(e).host===t)for(const e of t.querySelectorAll(r))s.includes(e)||s.push(e);return s},HEARD=new WeakMap,wcListen=(t,e,r)=>{const s=t=>{let e=HEARD.get(t);e||(e=new Set,HEARD.set(t,e)),e.has(s)||(e.add(s),r(t))};for(const r of wcScopes(t))wcTrack(t,r,e,s)},wcOwned=(t,e)=>!!e&&wcScopes(t).some(t=>t.contains(e)),wcClosest=(t,e,r)=>"function"==typeof e?.closest&&wcOwned(t,e)?e.closest(r):null,wcEmit=(t,e,r)=>{t.dispatchEvent(new CustomEvent(e,{detail:r,bubbles:!0,composed:!0}))};export function wireTabs(t){if(wcClaim(t,"tabs"))for(const e of wcSelfOrAll(t,".c-tabs__list, .c-code-tabs__list")){const r=e.classList.contains("c-code-tabs__list")?".c-code-tabs__panel":".c-tabs__panel",s=()=>wcGroup(t,e,"[role='tab']"),i=(e,i)=>{const a=s();e.id||(e.id=contourId("c-tab")),a.forEach(r=>{const s=r===e;r.setAttribute("aria-selected",String(s)),r.tabIndex=s?0:-1;const i=r.getAttribute("aria-controls");if(!i)return;const a=wcOne(t,"#"+CSS.escape(i))||document.getElementById(i);a&&(a.hidden=!s,s&&a.setAttribute("aria-labelledby",r.id))});const n=wcAll(t,r);if(n.length){const t=a.indexOf(e);n.forEach((e,r)=>{e.hidden=r!==t})}if(i)try{e.focus()}catch(t){}const o=e.textContent.trim()||e.getAttribute("aria-controls")||"";t.dispatchEvent(new CustomEvent("contour:tab-change",{bubbles:!0,composed:!0,detail:{index:a.indexOf(e),label:o}}))},a=(t,e)=>{if(!(e||"function"!=typeof document.startViewTransition||"function"==typeof matchMedia&&matchMedia("(prefers-reduced-motion: reduce)").matches))try{const r=document.startViewTransition(()=>i(t,e));return r&&r.ready&&r.ready.catch(()=>{}),void(r&&r.finished&&r.finished.catch(()=>{}))}catch(t){}i(t,e)};wcListen(t,"click",e=>{const r=wcClosest(t,e.target,"[role='tab']");if(r&&s().includes(r)){const t=e.target&&e.target.closest?e.target.closest("button"):null;if(t&&t!==r&&r.contains(t))return;a(r,!1)}}),wcListen(t,"keydown",e=>{let r=wcClosest(t,e.target,"[role='tab']");!r&&e.target&&e.target.getAttribute&&"tab"===e.target.getAttribute("role")&&wcOwned(t,e.target)&&(r=e.target);const i=s(),n=i.indexOf(r);if(n<0)return;const o="vertical"===t.getAttribute("orientation"),l=isRtl(t),c=o?l?{ArrowDown:n-1,ArrowUp:n+1,Home:i.length-1,End:0}:{ArrowDown:n+1,ArrowUp:n-1,Home:0,End:i.length-1}:l?{ArrowRight:n-1,ArrowLeft:n+1,Home:i.length-1,End:0}:{ArrowRight:n+1,ArrowLeft:n-1,Home:0,End:i.length-1};if(!(e.key in c))return;e.preventDefault();const u=i[(c[e.key]+i.length)%i.length];u&&a(u,!0)});const n=s(),o=t.getAttribute("persist");let l=null;if("storage"===o&&t.id)try{l=localStorage.getItem("contour-tabs:"+t.id)}catch(t){l=null}else if("url"===o)try{const t=new URLSearchParams(window.location.search).get("c-tabs");null!==t&&(l=t)}catch(t){l=null}let c=n.find(t=>"true"===t.getAttribute("aria-selected"))||n[0];if(null!==l){const t=parseInt(l,10);Number.isFinite(t)&&n[t]&&(c=n[t])}c&&i(c,!1),"storage"===o&&t.id?wcTrack(t,t,"contour:tab-change",e=>{try{localStorage.setItem("contour-tabs:"+t.id,String(e.detail&&e.detail.index))}catch(t){}}):"url"===o&&wcTrack(t,t,"contour:tab-change",t=>{try{const e=new URL(window.location.href);e.searchParams.set("c-tabs",String(t.detail&&t.detail.index)),window.history.replaceState(null,"",e.toString())}catch(t){}})}}export function wireSegmented(t){const e=wcSelfOrAll(t,".c-segmented"),r=()=>{const r=t.getAttribute("value"),s=r!==t._segAuthorValue?r:null;null!==s&&(t._segAuthorValue=r);let i=0;for(const r of e){r.hasAttribute("role")||r.setAttribute("role","group");const e=t.getAttribute("label");e&&!r.hasAttribute("aria-label")&&r.setAttribute("aria-label",e);const a=wcGroup(t,r,"button");i+=a.length,a.forEach(t=>{t.classList.add("c-segmented__option"),t.setAttribute("aria-pressed",null!=s?String(t.dataset.value===s):"true"===t.getAttribute("aria-pressed")?"true":"false")});const n=a.find(t=>"true"===t.getAttribute("aria-pressed"))||a[0];a.forEach(t=>{t.tabIndex=t===n?0:-1})}return i};if(r()||t._segRetryScheduled||(t._segRetryScheduled=!0,setTimeout(()=>{t._segRetryScheduled=!1,r()},0)),!wcClaim(t,"segmented"))return;const s=r=>{const s=e.find(e=>wcGroup(t,e,"button").includes(r));s&&(wcGroup(t,s,"button").forEach(t=>{const e=t===r;t.setAttribute("aria-pressed",String(e)),t.tabIndex=e?0:-1}),wcEmit(t,"contour:change",{value:r.dataset.value||r.textContent.trim()}))};wcListen(t,"click",e=>{const r=wcClosest(t,e.target,"button");r&&s(r)}),wcListen(t,"keydown",r=>{const i=wcClosest(t,r.target,"button");if(!i)return;const a=e.find(e=>wcGroup(t,e,"button").includes(i));if(!a)return;const n=wcGroup(t,a,"button");navKey(r,n,{wrap:!1,homeEnd:!0,rtl:isRtl(t),onNavigate:t=>s(n[t]),onKey:t=>{"Enter"!==t&&" "!==t||s(i)}})})}export function wireCombobox(t){wireComboboxDocDismiss();const e=wcOne(t,".c-combobox__input"),r=wcOne(t,".c-combobox__list");if(!e||!r)return;const s=()=>wcAll(t,".c-combobox__option");if(r.id||(r.id=contourId("c-combobox-list")),r.setAttribute("role","listbox"),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-controls",r.id),e.setAttribute("aria-expanded",r.hasAttribute("hidden")?"false":"true"),e.hasAttribute("aria-autocomplete")||e.setAttribute("aria-autocomplete","list"),s().forEach((t,e)=>{t.id||(t.id=contourId("c-combobox-option")),t.setAttribute("role","option"),t.hasAttribute("aria-selected")||t.setAttribute("aria-selected","false")}),!wcClaim(t,"combobox"))return;const i=()=>wcOne(t,".c-combobox__input"),a=()=>wcOne(t,".c-combobox__list");let n=-1;const o=e=>{const r=i(),s=t.hasAttribute("multiple");if(e.forEach((t,e)=>{const r=e===n;t.classList.toggle("c-combobox__option--active",r),s||t.setAttribute("aria-selected",String(r))}),r){const t=n>=0?e[n]:null;t?r.setAttribute("aria-activedescendant",t.id):r.removeAttribute("aria-activedescendant")}},l=e=>{const r=(e||"").toLowerCase();if(t._comboboxVirtual&&"function"==typeof t._renderComboboxWindow)return t._renderComboboxWindow(r,!0),void(n=-1);s().forEach(t=>{t.hidden=!(!r||t.textContent.toLowerCase().includes(r))}),n=-1;const i=a();if(!i)return;const o=s().length,l=s().filter(t=>!t.hidden).length,c=i.querySelector(".c-combobox__empty");if(o>0&&0===l){if(!c){const e=document.createElement("UL"===i.tagName||"OL"===i.tagName?"li":"div");e.className="c-combobox__empty",e.setAttribute("role","option"),e.setAttribute("aria-disabled","true"),e.setAttribute("aria-selected","false"),e.textContent=labelText(t,"no-matches","No matches"),i.appendChild(e)}}else c&&c.remove()},c=()=>{const t=a();if(!t)return;const e=i();if(e){const r=e.getBoundingClientRect();t.style.position="fixed",t.style.insetBlockStart=`${Math.round(r.bottom+4)}px`,t.style.insetInlineStart=`${Math.round(r.left)}px`,t.style.insetInlineEnd="auto",t.style.inlineSize=`${Math.round(r.width)}px`}t.removeAttribute("hidden"),e&&e.setAttribute("aria-expanded","true")},u=()=>{const e=a();e&&e.setAttribute("hidden","");const r=i();r&&(r.setAttribute("aria-expanded","false"),r.removeAttribute("aria-activedescendant")),n=-1;const o=t.hasAttribute("multiple");s().forEach(t=>{t.classList.remove("c-combobox__option--active"),o||t.setAttribute("aria-selected","false")})};t._comboboxVirtual&&r&&!r._contourVirtualScroll&&(r._contourVirtualScroll=!0,r.addEventListener("scroll",()=>{"function"==typeof t._renderComboboxWindow&&t._renderComboboxWindow(t._comboboxQuery||"")},{passive:!0}));const d=e=>{const r=i();if(!r)return;if(t.hasAttribute("multiple")){const s="true"===e.getAttribute("aria-selected");e.setAttribute("aria-selected",String(!s)),e.classList.toggle("c-combobox__option--selected",!s);const i=(t.getAttribute("value")||"").split(",").map(t=>t.trim()).filter(Boolean),a=t._comboboxVirtual&&t._comboboxFiltered?t._comboboxFiltered.find(t=>t.index===Number(e.dataset.optionIndex))?.value:null!=e.dataset.optionValue?e.dataset.optionValue:e.textContent.trim(),n=i.indexOf(String(a));return s&&n>=0&&i.splice(n,1),!s&&n<0&&i.push(String(a)),t.setAttribute("value",i.join(",")),"function"==typeof t._syncFormValue&&t._syncFormValue(),wcEmit(t,"contour:select",{value:i}),void r.focus()}const s=null!=e.dataset.optionValue?e.dataset.optionValue:e.textContent.trim();r.value=e.textContent,t.setAttribute("value",s),"function"==typeof t._syncFormValue&&t._syncFormValue(),wcEmit(t,"contour:select",{value:s}),u(),r.focus()},h=e=>null!==wcClosest(t,e,".c-combobox__input");wcListen(t,"input",e=>{h(e.target)&&(t._comboboxQuery=e.target.value,l(e.target.value),c(),"function"==typeof t._emitForm&&t._emitForm("contour:input"))}),wcListen(t,"focusin",t=>{h(t.target)&&(l(t.target.value),c())}),wcListen(t,"keydown",t=>{if(!h(t.target))return;const e=s().filter(t=>!t.hidden);"ArrowDown"===t.key?(t.preventDefault(),n=Math.min(n+1,e.length-1),o(e)):"ArrowUp"===t.key?(t.preventDefault(),n=Math.max(n-1,0),o(e)):"Home"===t.key?(t.preventDefault(),n=0,o(e)):"End"===t.key?(t.preventDefault(),n=Math.max(0,e.length-1),o(e)):"Enter"===t.key||" "===t.key?(t.preventDefault(),n>=0&&e[n]&&d(e[n])):"Escape"===t.key&&u()}),wcListen(t,"click",e=>{const r=wcClosest(t,e.target,".c-combobox__option");r?d(r):wcOwned(t,e.target)&&t.contains(e.target)||u()})}let _comboboxDocWired=!1;function wireComboboxDocDismiss(){_comboboxDocWired||(_comboboxDocWired=!0,document.addEventListener("click",t=>{for(const e of document.querySelectorAll("contour-combobox, contour-shadow-combobox")){const r=e.shadowRoot?e.shadowRoot.querySelector(".c-combobox__list"):e.querySelector(".c-combobox__list");e.shadowRoot?e.shadowRoot.querySelector(".c-combobox__input"):e.querySelector(".c-combobox__input");if(!r||r.hasAttribute("hidden"))continue;(e.shadowRoot||e).contains(t.target)||r.setAttribute("hidden","")}}))}const visibleStops=t=>wcAll(t,".c-tree__toggle, .c-tree__leaf").filter(t=>!t.closest(".c-tree__children[hidden]"));export function wireTree(t){const e=wcSelfOrAll(t,"ul.c-tree")[0];e&&!e.hasAttribute("role")&&e.setAttribute("role","tree"),wcAll(t,".c-tree__children").forEach(t=>{t.hasAttribute("role")||t.setAttribute("role","group")});wcAll(t,".c-tree__node").forEach(t=>{"treeitem"!==t.getAttribute("role")&&t.setAttribute("role","treeitem"),t.setAttribute("aria-level",String((t=>{let e=1;for(let r=t.parentElement;r;r=r.parentElement)r.classList&&r.classList.contains("c-tree__children")&&e++;return e})(t)));const e=t.querySelector(":scope > .c-tree__row");e?t.setAttribute("aria-expanded",e.querySelector(":scope > .c-tree__toggle")?.getAttribute("aria-expanded")||"false"):t.hasAttribute("aria-expanded")&&t.removeAttribute("aria-expanded")});const r=visibleStops(t),s=r.find(t=>"0"===t.getAttribute("tabindex"))||r.find(t=>t===document.activeElement)||r[0];if(r.forEach(t=>t.setAttribute("tabindex",t===s?"0":"-1")),wcAll(t,".c-tree__toggle, .c-tree__leaf").forEach(t=>{r.includes(t)||t.setAttribute("tabindex","-1")}),!wcClaim(t,"tree"))return;t._selectedTree=t._selectedTree||new Set;let i=-1,a=!1,n=!1;wcListen(t,"pointerdown",t=>{a=Boolean(t.shiftKey),n=Boolean(t.ctrlKey||t.metaKey)}),wcListen(t,"keydown",t=>{a=Boolean(t.shiftKey),n=Boolean(t.ctrlKey||t.metaKey)}),wcListen(t,"change",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-tree__select"):null;if(!r||!t.contains(r))return;const s=Array.from(t.querySelectorAll(".c-tree__select")),o=s.indexOf(r),l=t=>{const e=(t=>t&&t.closest?t.closest(".c-tree__node"):null)(t);return e&&e.dataset?e.dataset.path:null},c=l(r),u=Boolean(e.shiftKey||a),d=Boolean(e.ctrlKey||e.metaKey||n);if(a=!1,n=!1,u&&i>=0){const e=Math.min(i,o),a=Math.max(i,o);for(let i=e;i<=a;i++){s[i].checked=r.checked;const e=l(s[i]);e&&(r.checked?t._selectedTree.add(e):t._selectedTree.delete(e))}}else d||r.checked&&s.forEach((e,r)=>{if(r!==o&&e.checked){e.checked=!1;const r=l(e);r&&t._selectedTree.delete(r)}}),c&&(r.checked?t._selectedTree.add(c):t._selectedTree.delete(c));i=o,wcEmit(t,"contour:select",{paths:Array.from(t._selectedTree)})}),wcAll(t,".c-tree__node, .c-tree__leaf").forEach(t=>{t.hasAttribute("draggable")||t.setAttribute("draggable","true")});let o=null;wcListen(t,"dragstart",e=>{const r=wcClosest(t,e.target,".c-tree__node, .c-tree__leaf");if(r&&(o=(r.textContent||"").trim().slice(0,120),e.dataTransfer)){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",o)}catch(t){}}}),wcListen(t,"dragover",e=>{wcClosest(t,e.target,".c-tree__node, .c-tree__leaf")&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"))}),wcListen(t,"drop",e=>{const r=wcClosest(t,e.target,".c-tree__node, .c-tree__leaf");if(!r||!o)return;e.preventDefault();const s=(r.textContent||"").trim().slice(0,120);s&&s!==o&&wcEmit(t,"contour:move",{from:o,to:s}),o=null});const l=t.getAttribute("persist");if("storage"===l&&t.id)try{const e=localStorage.getItem("contour-tree:"+t.id);if(null!==e){const r=JSON.parse(e);if(Array.isArray(r)){const e=new Set(r.map(t=>String(t)));wcAll(t,".c-tree__row").forEach(t=>{const r=t.querySelector(":scope > .c-tree__toggle");if("true"===r?.getAttribute("aria-expanded"))return;const s=(t.textContent||"").trim().slice(0,120);if(!e.has(s))return;const i=t.querySelector(":scope > .c-tree__toggle");if(!i)return;const a=t.closest(".c-tree__node"),n=a?a.querySelector(":scope > .c-tree__children"):null;i.setAttribute("aria-expanded","true"),a&&a.setAttribute("aria-expanded","true"),n&&n.removeAttribute("hidden")})}}}catch(t){}else if("url"===l)try{const e=new URLSearchParams(window.location.search).get("c-tree");if(null!==e){const r=JSON.parse(e);if(Array.isArray(r)){const e=new Set(r.map(t=>String(t)));wcAll(t,".c-tree__row").forEach(t=>{const r=t.querySelector(":scope > .c-tree__toggle");if("true"===r?.getAttribute("aria-expanded"))return;const s=(t.textContent||"").trim().slice(0,120);if(!e.has(s))return;const i=t.querySelector(":scope > .c-tree__toggle");if(!i)return;const a=t.closest(".c-tree__node"),n=a?a.querySelector(":scope > .c-tree__children"):null;i.setAttribute("aria-expanded","true"),a&&a.setAttribute("aria-expanded","true"),n&&n.removeAttribute("hidden")})}}}catch(t){}const c=e=>{const r="true"===e.getAttribute("aria-expanded");e.setAttribute("aria-expanded",String(!r));const s=e.closest(".c-tree__row")||e.parentElement,i=e.closest(".c-tree__node"),a=i?i.querySelector(":scope > .c-tree__children"):null;if(a&&(r?supportsUntilFound()?a.setAttribute("hidden","until-found"):a.hidden=!0:a.removeAttribute("hidden")),i&&i.setAttribute("aria-expanded",String(!r)),wcEmit(t,"contour:toggle",{open:!r,label:(s?s.textContent:"").trim().slice(0,120)}),"storage"===l&&t.id)try{const e=[];wcAll(t,".c-tree__row").forEach(t=>{const r=t.querySelector(":scope > .c-tree__toggle");"true"===r?.getAttribute("aria-expanded")&&e.push((t.textContent||"").trim().slice(0,120))}),localStorage.setItem("contour-tree:"+t.id,JSON.stringify(e))}catch(t){}else if("url"===l)try{const e=[];wcAll(t,".c-tree__row").forEach(t=>{const r=t.querySelector(":scope > .c-tree__toggle");"true"===r?.getAttribute("aria-expanded")&&e.push((t.textContent||"").trim().slice(0,120))});const r=new URL(window.location.href);r.searchParams.set("c-tree",JSON.stringify(e)),window.history.replaceState(null,"",r.toString())}catch(t){}},u=t=>t.classList&&t.classList.contains("c-tree__toggle")?t:null,d=e=>{wcAll(t,".c-tree__toggle, .c-tree__leaf").forEach(t=>t.setAttribute("tabindex",t===e?"0":"-1"))},h=(e,r)=>{const s=e.closest(".c-tree__node"),i=s&&s.dataset?s.dataset.path:null;i&&t._expanded&&(r?t._expanded.add(i):t._expanded.delete(i));const a=t._treeRoot;if(a){t._treeScrollTop=a.scrollTop||0,t._renderWindow(a,t._treeScrollTop);try{a.scrollTop=t._treeScrollTop}catch(t){}const e=i?a.querySelector('.c-tree__node[data-path="'+i+'"] > .c-tree__row > .c-tree__toggle'):null;e&&(e.focus(),d(e))}t._persistExpanded&&t._persistExpanded()};wcListen(t,"click",e=>{if(t.hasAttribute("virtual"))return;let r=wcClosest(t,e.target,".c-tree__toggle");if(!r){const s=wcClosest(t,e.target,".c-tree__row");s&&(r=s.querySelector(":scope > .c-tree__toggle"))}r&&(e.preventDefault(),e.stopPropagation(),c(r))}),wcListen(t,"focusin",e=>{wcClosest(t,e.target,".c-tree__toggle, .c-tree__leaf")&&d(e.target)}),wcListen(t,"keydown",e=>{const r=wcClosest(t,e.target,".c-tree__toggle, .c-tree__leaf");if(!r)return;const s=visibleStops(t),i=s.indexOf(r);if("Enter"===e.key||" "===e.key){const s=u(r);if(s)return e.preventDefault(),void(t.hasAttribute("virtual")?h(s,"true"!==s.getAttribute("aria-expanded")):c(s));if(t.hasAttribute("selectable")){const t=r.classList.contains("c-tree__leaf")?r:r.closest(".c-tree__leaf"),s=t?t.querySelector(".c-tree__select"):null;s&&(e.preventDefault(),s.click())}return}if("ArrowRight"===e.key){const a=u(r),n=a&&"false"===a.getAttribute("aria-expanded");if(e.preventDefault(),n)t.hasAttribute("virtual")?h(a,!0):(c(a),d(r));else{const t=s[i+1];t&&(t.focus(),d(t))}return}if("ArrowLeft"===e.key){const s=u(r);if(s&&"true"===s.getAttribute("aria-expanded"))e.preventDefault(),t.hasAttribute("virtual")?h(s,!1):(c(s),d(r));else{const t=r.closest(".c-tree__children"),s=t?t.closest(".c-tree__node"):null,i=s?s.querySelector(":scope > .c-tree__row > .c-tree__toggle"):null;i&&(e.preventDefault(),i.focus(),d(i))}return}navKey(e,s,{wrap:!1,homeEnd:!0,onNavigate:t=>d(s[t])})})}export function wireMenu(t){const e="[role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio']";wcAll(t,e).forEach(t=>{t.hasAttribute("tabindex")||t.setAttribute("tabindex",(t.getAttribute("aria-disabled"),"-1"))});const r=()=>wcAll(t,e);if(!r().some(t=>"0"===t.getAttribute("tabindex"))&&r().length){const t=r().find(t=>"true"!==t.getAttribute("aria-disabled"));t&&t.setAttribute("tabindex","0")}if(!wcClaim(t,"menu"))return;const s=t=>t.querySelector(":scope > ul.c-menu, :scope > .c-menu"),i=()=>{wcAll(t,"[aria-haspopup='menu']").forEach(t=>t.setAttribute("aria-expanded","false"))};wcListen(t,"keydown",e=>{const a=r().filter(t=>"true"!==t.getAttribute("aria-disabled"));if(!a.length)return;const n=a.indexOf(e.target),o=n>=0?a[n]:null,l=o?s(o):null;if(o&&"menu"===o.getAttribute("aria-haspopup")&&("ArrowRight"===e.key||"Enter"===e.key||" "===e.key)&&l){e.preventDefault(),i(),o.setAttribute("aria-expanded","true");const t=l.querySelector("[role='menuitem']");if(t){t.setAttribute("tabindex","0");try{t.focus()}catch(t){}}return}if("ArrowLeft"===e.key||"Escape"===e.key){o&&o.closest("ul.c-menu");let r=null;if(o){o.parentElement&&"UL"===o.parentElement.tagName&&o.parentElement;let e=o.parentElement;for(;e&&e!==t;){if(e.getAttribute&&"menu"===e.getAttribute("aria-haspopup")&&e.contains(o)&&e!==o){r=e;break}e=e.parentElement}}if(r){e.preventDefault(),r.setAttribute("aria-expanded","false");try{r.focus()}catch(t){}return}"Escape"===e.key&&i()}if(navKey(e,a,{wrap:!0,homeEnd:!0,onKey:()=>{if("Enter"===e.key||" "===e.key){const e=a.indexOf(document.activeElement);if(e>=0&&(!o||"menu"!==o.getAttribute("aria-haspopup"))){const r=a[e].getAttribute("role");if("menuitemcheckbox"===r||"menuitemradio"===r){const s="true"===a[e].getAttribute("aria-checked");"menuitemradio"===r&&a.forEach(t=>{t!==a[e]&&"menuitemradio"===t.getAttribute("role")&&t.setAttribute("aria-checked","false")}),a[e].setAttribute("aria-checked",String(!s)),wcEmit(t,"contour:select",{index:e,label:a[e].textContent.trim(),checked:!s})}else wcEmit(t,"contour:select",{index:e,label:a[e].textContent.trim()});i()}}}}),1===e.key.length&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const t=e.key.toLowerCase(),r=a.findIndex(e=>(e.textContent||"").trim().toLowerCase().startsWith(t));r>=0&&(e.preventDefault(),a[r].focus())}}),wcListen(t,"click",a=>{const n=wcClosest(t,a.target,e);if(!n)return;if("true"===n.getAttribute("aria-disabled"))return;const o=n.getAttribute("role");if("menuitemcheckbox"===o||"menuitemradio"===o){const e="true"===n.getAttribute("aria-checked");return"menuitemradio"===o&&r().forEach(t=>{t!==n&&"menuitemradio"===t.getAttribute("role")&&t.setAttribute("aria-checked","false")}),n.setAttribute("aria-checked",String(!e)),void wcEmit(t,"contour:select",{index:r().indexOf(n),label:n.textContent.trim(),checked:!e})}if("menu"===n.getAttribute("aria-haspopup")){if(s(n)){const t="true"===n.getAttribute("aria-expanded");return i(),void n.setAttribute("aria-expanded",t?"false":"true")}}const l=r().indexOf(n);if(l>=0&&(wcEmit(t,"contour:select",{index:l,label:n.textContent.trim()}),i(),"function"==typeof t.hidePopover))try{t.hidePopover()}catch(a){}})}export function wirePagination(t){if(wcAll(t,".c-pagination__link").forEach(t=>{t.hasAttribute("tabindex")||t.setAttribute("tabindex","0")}),!wcClaim(t,"pagination"))return;const e=e=>{const r=parseInt(e.textContent,10);if(Number.isFinite(r))if(wcAll(t,".c-pagination__link").forEach(t=>{parseInt(t.textContent,10)===r?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current")}),t.setAttribute("page",String(r)),wcEmit(t,"contour:page",{page:r}),"storage"===t.getAttribute("persist")&&t.id)try{localStorage.setItem("contour-pagination:"+t.id,String(r))}catch(t){}else if("url"===t.getAttribute("persist"))try{const t=new URL(window.location.href);t.searchParams.set("c-pagination",String(r)),window.history.replaceState(null,"",t.toString())}catch(t){}};wcListen(t,"click",r=>{const s=wcClosest(t,r.target,".c-pagination__link");if(!s)return;r.preventDefault();const i=s.getAttribute("data-action");if("prev"===i||"next"===i){const r=wcAll(t,".c-pagination__link").filter(t=>!t.getAttribute("data-action")),s=r.find(t=>"page"===t.getAttribute("aria-current")),a=s&&parseInt(s.textContent,10)||1,n="prev"===i?Math.max(1,a-1):Math.min(r.length,a+1),o=r.find(t=>parseInt(t.textContent,10)===n);if(o)return void e(o)}e(s)}),wcListen(t,"keydown",r=>{const s=wcClosest(t,r.target,".c-pagination__link");if(!s)return;const i=wcAll(t,".c-pagination__link"),a=i.indexOf(s);let n=-1;const o=isRtl(t);if("ArrowRight"===r.key)n=o?Math.max(a-1,0):Math.min(a+1,i.length-1);else if("ArrowLeft"===r.key)n=o?Math.min(a+1,i.length-1):Math.max(a-1,0);else if("Home"===r.key)n=0;else if("End"===r.key)n=i.length-1;else if("Enter"===r.key||" "===r.key)return r.preventDefault(),void e(s);n>=0&&n!==a&&(r.preventDefault(),i[n].focus())})}export function wireCopy(t){wcClaim(t,"copy")&&wcListen(t,"click",e=>{const r=wcClosest(t,e.target,".c-code__copy, .c-install__copy");if(!r)return;const s=wcClosest(t,r,".c-code")||wcClosest(t,r,".c-install")||t,i=s.querySelector("code, .c-install__command"),a=(t=>{const e=t&&t.querySelectorAll?t.querySelectorAll(".c-code__line"):null;return e&&e.length?Array.from(e).map(t=>Array.from(t.childNodes).filter(t=>!(t.classList&&t.classList.contains("c-code__line-number"))).map(t=>t.textContent).join("")).join("\n"):t&&t.textContent||""})(i)||(i?"":s.textContent)||"";(async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(a),!0}catch(t){}try{const t=document.createElement("textarea");t.value=a,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="-9999px",t.style.opacity="0",document.body.append(t),t.select();const e=document.execCommand("copy");return t.remove(),e}catch(t){return!1}})().then(t=>(t=>{const e=r.querySelector("use"),s=e&&e.getAttribute("href"),i=r.getAttribute("aria-label")||r.title||"";t&&e&&e.setAttribute("href","#i-check"),r.setAttribute("aria-label",t?"Copied":"Copy failed"),r.dataset.copied=String(t);const a=setTimeout(()=>{r.isConnected&&(e&&s&&e.setAttribute("href",s),r.setAttribute("aria-label",i),delete r.dataset.copied,r._copyTimer=null)},1600);r._copyTimer&&clearTimeout(r._copyTimer),r._copyTimer=a})(t)),wcEmit(t,"contour:copy",{text:a})})}export function wireRemovable(t){wcClaim(t,"removable")&&wcListen(t,"click",e=>{const r=t=>{t&&t.parentNode&&t.parentNode.removeChild(t)},s=wcClosest(t,e.target,".c-tag__remove");if(s){e.preventDefault();const i=wcClosest(t,s,".c-tag");return wcEmit(t,"contour:remove",{label:i&&i.getAttribute("label")||(i?i.textContent.trim():"")}),void r(i)}const i=wcClosest(t,e.target,".c-filter-pill__remove");if(i){e.preventDefault();const s=wcClosest(t,i,".c-filter-pill");return wcEmit(t,"contour:remove",{key:s&&s.getAttribute("key"),value:s&&s.getAttribute("value")}),void r(s)}wcClosest(t,e.target,"[data-empty-action]")&&wcEmit(t,"contour:empty-action",{state:t.getAttribute("state")||"empty"});const a=wcClosest(t,e.target,".c-alert__close");if(a){if(e.preventDefault(),wcEmit(t,"contour:close",{}),!t.shadowRoot||t.shadowRoot.contains(a))try{t.remove()}catch(t){}return}if(wcClosest(t,e.target,".c-callout__close")){e.preventDefault(),wcEmit(t,"contour:close",{});try{t.remove()}catch(t){}}else;})}const modalDepth={n:0};let modalSavedOverflow=null,modalSavedX=0,modalSavedY=0;const modalInerted=new Set,modalStack=[];let modalTrapWired=!1;const modalInertedBy=new Map;function modalFocusables(t){return Array.from(t.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter(t=>!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-hidden"))}function modalTrapHandler(t){if("Tab"!==t.key)return;const e=modalStack[modalStack.length-1];if(!e)return;const r=modalFocusables(e);if(!r.length)return void t.preventDefault();const s=r[0],i=r[r.length-1],a=document.activeElement;t.shiftKey?a!==s&&e.contains(a)||(t.preventDefault(),i.focus()):a===i&&(t.preventDefault(),s.focus())}export function modalContain(t,e){if(e){0===modalDepth.n&&(modalSavedX=window.scrollX,modalSavedY=window.scrollY,modalSavedOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden"),modalDepth.n+=1,modalStack.push(t),1!==modalDepth.n||modalTrapWired||(modalTrapWired=!0,document.addEventListener("keydown",modalTrapHandler));const e=new Set;for(let r=t;r&&r!==document.body;r=r.parentElement)for(const t of r.parentElement.children)t===r||t.inert||(t.inert=!0,e.add(t));modalInertedBy.set(t,e)}else{const e=modalStack.lastIndexOf(t);e>=0&&modalStack.splice(e,1),modalDepth.n=Math.max(0,modalDepth.n-1);const r=modalInertedBy.get(t);if(r){for(const t of r)t.inert=!1,modalInerted.delete(t);modalInertedBy.delete(t)}if(0===modalDepth.n){for(const t of modalInerted)t.inert=!1;modalInerted.clear(),document.documentElement.style.overflow=modalSavedOverflow||"",window.scrollTo(modalSavedX,modalSavedY),modalTrapWired&&(document.removeEventListener("keydown",modalTrapHandler),modalTrapWired=!1)}}}export const STATE_FALLBACK={empty:"No data",chart:"No data",contour:"No field",dropdown:"No options",loading:"Loading…",error:"Could not load."};export function stateLabel(t,e){const r=STATE_FALLBACK[e]||e,s=t&&t.getAttribute?t.getAttribute("labels"):null;if(!s)return r;try{const t=JSON.parse(s);if(t&&"object"==typeof t&&"string"==typeof t[e]&&t[e])return t[e]}catch(t){}return r}const remoteInflight=new Map,REMOTE_CACHE_MAX=64,remoteCache=new Map;function cacheResult(t,e){remoteCache.size>=64&&remoteCache.delete(remoteCache.keys().next().value),remoteCache.set(t,e)}function setStatus(t,e){t._remoteStatus=e,"error"!==e&&(t._remoteError=null),"loading"===e?t.setAttribute("aria-busy","true"):t.removeAttribute("aria-busy"),"function"==typeof t._setCustomState&&t._setCustomState("data-loading","loading"===e)}function emitState(t,e,r){t.dispatchEvent(new CustomEvent(e,{detail:r,bubbles:!0,composed:!0}))}function countOf(t){return Array.isArray(t)?t.length:t&&"object"==typeof t?Object.keys(t).length:null==t?0:1}function leaveRequest(t){const e=t._remoteEntry;t._remoteEntry=null,e&&(e.hosts.delete(t),0===e.hosts.size&&e.controller&&e.controller.abort())}export function loadRemote(t,e){const r=t.getAttribute("src");if(!r)return leaveRequest(t),void setStatus(t,void 0!==t._remoteData?"ready":"idle");remoteRefresh(t);if(("string"==typeof e?[e]:e).every(e=>null!==t.getAttribute(e)))return leaveRequest(t),void setStatus(t,"ready");if(!remoteVisible(t))return void setStatus(t,"loading");const s=t.hasAttribute("no-cache"),i=t.getAttribute("cache-key")||r;if(s){if(t._remoteSrc===r&&void 0!==t._remoteData)return void setStatus(t,"ready")}else{const e=remoteCache.get(i);if(void 0!==e)return t._remoteSrc=r,t._remoteData=e,void setStatus(t,"ready");if(t._remoteSrc===r&&"ready"===t._remoteStatus&&void 0!==t._remoteData)return}if(t._remoteSrc===r&&("loading"===t._remoteStatus||"error"===t._remoteStatus))return;leaveRequest(t),t._remoteSrc=r,setStatus(t,"loading");let a=remoteInflight.get(r);a||(a={hosts:new Set,controller:new AbortController,cacheKey:i,cacheKeys:new Set},remoteInflight.set(r,a),a.promise=startFetch(t,r,a).then(t=>{remoteInflight.get(r)===a&&remoteInflight.delete(r),cacheResult(r,t);for(const e of a.cacheKeys)e&&e!==r&&cacheResult(e,t);for(const e of a.hosts)e._remoteData=t,e._remoteEntry=null,setStatus(e,"ready"),emitState(e,"contour:load",{src:r,count:countOf(t)})},t=>{remoteInflight.get(r)===a&&remoteInflight.delete(r);for(const e of a.hosts)e._remoteEntry=null,setStatus(e,"error"),e._remoteError=t&&"HttpError"===t.name?`Could not load (${t.status})`:STATE_FALLBACK.error,emitState(e,"contour:error",{src:r,message:e._remoteError,name:t&&t.name,status:t&&t.status})}).finally(()=>{for(const t of a.hosts)t.isConnected&&t.requestRender();a.hosts.clear()})),a.hosts.add(t),!s&&i&&a.cacheKeys.add(i),t._remoteEntry=a,t._remoteDisposeRegistered||(t._remoteDisposeRegistered=!0,onDispose(t,()=>{t._remoteDisposeRegistered=!1,leaveRequest(t)}))}export function remoteInvalidate(t){remoteCache.delete(t)}function startFetch(t,e,r){const s=parseInt(t.getAttribute("timeout")||"",10);let i=null,a=r.controller.signal;Number.isFinite(s)&&s>0&&("undefined"!=typeof AbortSignal&&AbortSignal.timeout?a=AbortSignal.any([a,AbortSignal.timeout(s)]):i=setTimeout(()=>r.controller.abort(),s)),i&&(t._remoteDeadline=i,t._remoteDeadlineWired||(t._remoteDeadlineWired=!0,onDispose(t,()=>{t._remoteDeadlineWired=!1,clearTimeout(t._remoteDeadline),t._remoteDeadline=null})));return fetch(e,{signal:a}).then(e=>{if(i&&(clearTimeout(i),t._remoteDeadline===i&&(t._remoteDeadline=null)),!e.ok){const t=new Error(`Could not load (${e.status})`);throw t.name="HttpError",t.status=e.status,t}return e.text()}).then(t=>{try{return JSON.parse(t)}catch(t){const e=new Error(STATE_FALLBACK.error);throw e.name="ParseError",e.cause=t,e}})}export function remoteData(t,e){const r=t.getAttribute(e);if(null!==r)return r;const s=t._remoteData;if(null==s)return null;if(Array.isArray(s))return JSON.stringify(s);if("object"==typeof s){const t="string"==typeof e?[e]:e;for(const e of t)if(void 0!==s[e])return"string"==typeof s[e]?s[e]:JSON.stringify(s[e]);return null}return String(s)}export function remoteRefresh(t){const e=parseFloat(t.getAttribute("refresh")||"");if(!(t.hasAttribute("src")&&Number.isFinite(e)&&e>0))return void 0!==t._remoteTimer&&(clearTimeout(t._remoteTimer),t._remoteTimer=void 0),void(t._remoteLoop=!1);if(t._remoteLoop)return;t._remoteLoop=!0;const r=()=>{if(t._remoteTimer=void 0,!t.isConnected||!t.hasAttribute("refresh"))return void(t._remoteLoop=!1);if(document.hidden)return void(t._remoteTimer=setTimeout(r,1e3));const e=t.getAttribute("src"),s=t.getAttribute("cache-key");s&&remoteCache.delete(s),remoteCache.delete(e),t._remoteSrc=null,t._remoteLoop=!1,t.requestRender()};t._remoteTimer=setTimeout(r,Math.max(1e3,1e3*e)),onDispose(t,()=>{clearTimeout(t._remoteTimer),t._remoteTimer=void 0,t._remoteLoop=!1})}let _sharedLazyIO=null;const _sharedLazyTargets=new Map;export function remoteVisible(t){if(!t.hasAttribute("lazy"))return!0;if("function"!=typeof IntersectionObserver)return!0;if(t._remoteVisible)return!0;if(t._lazyRegistered)return!1;_sharedLazyIO||(_sharedLazyIO=new IntersectionObserver(t=>{for(const e of t){const t=_sharedLazyTargets.get(e.target);t&&e.isIntersecting&&(_sharedLazyTargets.delete(e.target),_sharedLazyIO.unobserve(e.target),t())}},{rootMargin:"200px"}));return t._lazyRegistered=!0,_sharedLazyTargets.set(t,()=>{t._remoteVisible=!0,t._lazyRegistered=!1,t.requestRender()}),_sharedLazyIO.observe(t),onDispose(t,()=>{_sharedLazyIO.unobserve(t),_sharedLazyTargets.delete(t),t._lazyRegistered=!1}),!1}export function watchViewport(t){if(t._contourViewWired)return()=>{};t._contourViewWired=!0;const e=e=>t.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0}));if("function"!=typeof IntersectionObserver)return e("contour:view-enter"),()=>{};const r=new IntersectionObserver(t=>{for(const r of t)r.isIntersecting?e("contour:view-enter"):e("contour:view-leave")});return r.observe(t),onDispose(t,()=>r.disconnect()),()=>r.disconnect()}function stateNode(t,e,r){const s=document.createElement("div");return s.className="c-"+t+"__"+e,s.dataset.contourState=e,s.textContent=r,s}function skeletonRow(t,e){const r=document.createElement("div");return r.className="c-skeleton "+(0===t&&e>1?"c-skeleton--title":"c-skeleton--text"),r.dataset.contourState="skeleton",r}export function renderStates(t,e,r){const s=r||{},i=t.getAttribute("loading");if(null!==i||"loading"===t._remoteStatus)return t.appendChild(stateNode(e,"loading",i||stateLabel(t,"loading"))),!0;const a=t.getAttribute("error");if(null!==a||"error"===t._remoteStatus){const r=stateNode(e,"error",null!==a&&""!==a?a:t._remoteError||stateLabel(t,"error"));if(t.hasAttribute("retry")){const e=document.createElement("button");e.type="button",e.className="c-btn c-btn--ghost c-btn--sm",setHTML(e,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-refresh" /></svg>'),e.appendChild(document.createTextNode(" "+(t.getAttribute("retry")||"Retry"))),e.dataset.action="retry",r.appendChild(e)}return t.appendChild(r),!0}if(t.hasAttribute("skeleton")){const e=parseInt(t.getAttribute("skeleton")||"3",10),r=Math.min(s.max||6,Math.max(1,Number.isFinite(e)?e:3));for(let e=0;e<r;e++)t.appendChild(skeletonRow(e,r));return!0}return!1}export function renderEmpty(t,e){t.appendChild(stateNode(e,"empty",t.getAttribute("empty")||stateLabel(t,"empty")))}export function parseArrayAttr(t,e,r){const s=t.getAttribute(e);if(!s)return[];try{const i=JSON.parse(s);return Array.isArray(i)?i:(r&&r(t,e,new Error("not an array")),[])}catch(s){return r&&r(t,e,s),[]}}export function wireStates(t){t._contourStatesWired||(t._contourStatesWired=!0,t.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest('[data-action="retry"]'):null;if(!r||!t.contains(r))return;e.preventDefault();const s=t.getAttribute("src"),i=t.getAttribute("cache-key");i&&remoteCache.delete(i),s&&remoteCache.delete(s),leaveRequest(t),t._remoteSrc=null,t._remoteData=void 0,setStatus(t,"idle"),emitState(t,"contour:retry",{src:s}),t.requestRender()}))}const splitCodeLines=t=>{const e=[[]];let r=e[0];const s=(t,i)=>{if(3===t.nodeType)return void String(t.textContent||"").split("\n").forEach((t,s)=>{s&&(r=[],e.push(r)),t&&r.push({chain:i,text:t})});if(1!==t.nodeType)return;const a=i.concat(t);Array.from(t.childNodes).forEach(t=>s(t,a))};Array.from(t.childNodes).forEach(t=>s(t,[]));if(!e[e.length-1].length&&e.length>1&&e.pop(),!e.length)return;const i=document.createDocumentFragment();e.forEach((t,e)=>{const r=document.createElement("span");r.className="c-code__line",r.setAttribute("data-contour-generated","line");const s=[];for(const e of t){for(let t=0;t<e.chain.length;t++)if(!s[t]||s[t]._contourSrc!==e.chain[t]){const i=e.chain[t].cloneNode(!1);i._contourSrc=e.chain[t],0===t?r.appendChild(i):s[t-1].appendChild(i),s[t]=i,s.length=t+1}(e.chain.length?s[e.chain.length-1]:r).appendChild(document.createTextNode(e.text))}const a=document.createElement("span");a.className="c-code__line-number",a.setAttribute("aria-hidden","true"),a.textContent=String(e+1),r.prepend(a),i.appendChild(r)}),t.textContent="",t.appendChild(i)},joinCodeLines=t=>{const e=document.createDocumentFragment();Array.from(t.querySelectorAll(".c-code__line")).forEach(t=>{Array.from(t.childNodes).forEach(t=>{t.classList&&t.classList.contains("c-code__line-number")||e.appendChild(t)}),e.appendChild(document.createTextNode("\n"))}),t.textContent="",t.appendChild(e)};class ContourCard extends ContourBase{static get observed(){return["title","variant","heading"]}static get properties(){return{title:{attribute:"title"},variant:{attribute:"variant"}}}render(){this.classList.add("c-card");const t=this.getAttribute("variant");Array.from(this.classList).forEach(t=>{t.startsWith("c-card--")&&this.classList.remove(t)}),t&&this.classList.add("c-card--"+t);const e=this.getAttribute("title");if(e){const t=this.ensure(".c-card__title",()=>{const t=document.createElement(headingTag(this,"h3"));return t.className="c-card__title",t});t.parentNode===this&&this.firstChild!==t&&this.prepend(t),t.textContent=e}else{const t=this.querySelector(".c-card__title");t&&t.remove()}}}define("contour-card",ContourCard);class ContourFeature extends ContourBase{static get observed(){return["index","title","body","heading"]}static get properties(){return{index:{attribute:"index"},title:{attribute:"title"},body:{attribute:"body"}}}render(){this.classList.add("c-feature");const t=this.getAttribute("index"),e=this.getAttribute("title"),r=this.getAttribute("body");if(t){this.ensure(".c-feature__index",()=>{const t=document.createElement("span");return t.className="c-feature__index",t}).textContent=t}else{const t=this.querySelector(".c-feature__index");t&&t.remove()}if(e){this.ensure(".c-feature__title",()=>{const t=document.createElement(headingTag(this,"h3"));return t.className="c-feature__title",t}).textContent=e}else{const t=this.querySelector(".c-feature__title");t&&t.remove()}if(r){this.ensure(".c-feature__body",()=>{const t=document.createElement("p");return t.className="c-feature__body",t}).textContent=r}else{const t=this.querySelector(".c-feature__body");t&&t.remove()}}}define("contour-feature",ContourFeature);class ContourSteps extends ContourBase{static get observed(){return["steps","current","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading","cache-key","no-cache"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current",type:Number},src:{attribute:"src"}}}render(){this.classList.add("c-steps");let t=this.querySelector(".c-steps__list");if(t||(t=document.createElement("ol"),t.className="c-steps__list",t.setAttribute("aria-label",this.getAttribute("aria-label")||"Steps"),this.appendChild(t)),wireStates(this),loadRemote(this,"steps"),renderStates(this,"steps"))return;const e=remoteData(this,"steps"),r=Array.from(this.children).filter(t=>t.classList&&t.classList.contains("c-steps__item"));if(r.forEach(e=>{e.parentNode!==t&&t.appendChild(e)}),e&&!r.length){Array.from(t.querySelectorAll(".c-steps__item")).forEach(t=>t.remove());try{JSON.parse(e).forEach((e,r)=>{const s=document.createElement("li");s.className="c-steps__item",s.tabIndex=-1;const i="string"==typeof e?e:e.title,a="string"==typeof e?"":e.body;if(i){const t=document.createElement(headingTag(this,"h3"));t.className="c-steps__title",t.textContent=i,s.appendChild(t)}if(a){const t=document.createElement("p");t.className="c-steps__body",t.textContent=a,s.appendChild(t)}t.appendChild(s)})}catch(t){warnBadJson(this,"attribute",t)}}else e||r.length||renderEmpty(this,"steps");const s=this.getAttribute("current"),i=null!=this._current?this._current:null!=s?parseInt(s,10):NaN,a=Array.from(this.querySelectorAll(".c-steps__item"));a.forEach((t,e)=>{Number.isFinite(i)&&e===i?t.setAttribute("aria-current","step"):t.removeAttribute("aria-current"),t.tabIndex=Number.isFinite(i)&&e===i?0:-1}),a.length&&!Number.isFinite(i)&&(a[0].tabIndex=0)}enhance(){this._wiredSteps||(this._wiredSteps=!0,this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-steps__item"));e.length&&navKey(t,e,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>{this._current=t,e.forEach((e,r)=>{r===t?e.setAttribute("aria-current","step"):e.removeAttribute("aria-current"),e.tabIndex=r===t?0:-1});const r=e[t].querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{index:t,title:r}}))},onKey:()=>{if("Enter"===t.key||" "===t.key){const t=e.indexOf(document.activeElement),r=document.activeElement.querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:!0,composed:!0,detail:{index:t,title:r}}))}}})}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-steps__item"):null;if(!e||!this.contains(e))return;const r=Array.from(this.querySelectorAll(".c-steps__item")),s=r.indexOf(e);if(s<0)return;this._current=s,r.forEach((t,e)=>{e===s?t.setAttribute("aria-current","step"):t.removeAttribute("aria-current"),t.tabIndex=e===s?0:-1});const i=e.querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:!0,composed:!0,detail:{index:s,title:i}}))}))}}define("contour-steps",ContourSteps);class ContourLink extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-link");const t=this.getAttribute("href"),e=this.getAttribute("label");if(Array.from(this.querySelectorAll("a[data-contour-generated]")).forEach(t=>t.remove()),t&&e){const r=document.createElement("a");r.dataset.contourGenerated="",r.href=safeHref(t),r.textContent=e;const s=this.getAttribute("aria-label");s&&r.setAttribute("aria-label",s),this.appendChild(r)}}}define("contour-link",ContourLink);class ContourBrand extends ContourBase{static get observed(){return["name","tag"]}static get properties(){return{name:{attribute:"name"},tag:{attribute:"tag"}}}render(){this.classList.add("c-brand");const t=this.getAttribute("name"),e=this.getAttribute("tag");if(t){this.ensure(".c-brand__name",()=>{const t=document.createElement("span");return t.className="c-brand__name",t}).textContent=t}else{const t=this.querySelector(".c-brand__name");t&&t.remove()}if(e){this.ensure(".c-brand__tag",()=>{const t=document.createElement("span");return t.className="c-brand__tag",t}).textContent=e}else{const t=this.querySelector(".c-brand__tag");t&&t.remove()}}}define("contour-brand",ContourBrand);class ContourSectionHead extends ContourBase{static get observed(){return["title","desc","heading"]}static get properties(){return{title:{attribute:"title"},desc:{attribute:"desc"}}}render(){this.classList.add("c-section-head");const t=this.getAttribute("title"),e=this.getAttribute("desc");if(!this.querySelector(".c-icon-badge")){const t=document.createElement("div");t.className="c-icon-badge";const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true");const r=document.createElementNS("http://www.w3.org/2000/svg","use");r.setAttribute("href","#i-crosshair"),e.appendChild(r),t.replaceChildren(e),this.prepend(t)}let r=this.querySelector(":scope > div:not(.c-icon-badge)");if(r||(r=document.createElement("div"),this.appendChild(r)),t){const e=this.ensure(".c-section-head__title",()=>{const t=document.createElement(headingTag(this,"h2"));return t.className="c-section-head__title",t});e.textContent=t,e.parentNode!==r&&r.appendChild(e)}else{const t=this.querySelector(".c-section-head__title");t&&t.remove()}if(e){const t=this.ensure(".c-section-head__desc",()=>{const t=document.createElement("p");return t.className="c-section-head__desc",t});t.textContent=e,t.parentNode!==r&&r.appendChild(t)}else{const t=this.querySelector(".c-section-head__desc");t&&t.remove()}}}define("contour-section-head",ContourSectionHead);class ContourDiff extends ContourBase{static get observed(){return["before","after"]}static get properties(){return{before:{attribute:"before"},after:{attribute:"after"}}}render(){this.classList.add("c-diff"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"diff","Diff")),Array.from(this.querySelectorAll(".c-diff__line")).forEach(t=>t.remove());const t=(t,e,r,s)=>{const i=document.createElement("div");i.className=t?`c-diff__line c-diff__line--${t}`:"c-diff__line",i.setAttribute("role","listitem"),i.setAttribute("tabindex","0");const a=document.createElement("span");a.className="c-diff__sign",a.textContent=e;const n=document.createElement("span");n.className="c-diff__num",n.setAttribute("aria-hidden","true"),n.textContent=String(s||"");const o=document.createElement("span");return o.textContent=r,i.append(a,n,o),i},e=this.getAttribute("before"),r=this.getAttribute("after");let s=1;e&&String(e).split("\n").forEach(e=>{this.appendChild(t("del","−",e,s++))}),r&&String(r).split("\n").forEach(e=>{this.appendChild(t("add","+",e,s++))})}enhance(){this._wiredDiff||(this._wiredDiff=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-diff__line"):null;if(e&&this.contains(e)){const t=e.classList.contains("c-diff__line--add")?"add":e.classList.contains("c-diff__line--del")?"del":"context",r=e.querySelector("span:last-child")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:diff-activate",{bubbles:!0,composed:!0,detail:{kind:t,text:r}}))}}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-diff__line"):null;e&&this.contains(e)&&("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e.click()))}))}}define("contour-diff",ContourDiff);class ContourDoDont extends ContourBase{static get observed(){return["do","dont"]}static get properties(){return{do:{attribute:"do"},dont:{attribute:"dont"}}}render(){this.classList.add("c-do-dont"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"do-and-dont","Do and don't")),Array.from(this.querySelectorAll(".c-do-dont__item")).forEach(t=>t.remove());const t=(t,e,r)=>{const s=document.createElement("div");s.className=`c-do-dont__item c-do-dont__item--${t}`,s.setAttribute("role","button"),s.setAttribute("tabindex","0");const i=document.createElement("p");i.className="c-do-dont__label",i.textContent=e;const a=document.createElement("p");return a.className="u-muted",a.textContent=r,s.append(i,a),s},e=this.getAttribute("do"),r=this.getAttribute("dont");e&&this.appendChild(t("do","Do",e)),r&&this.appendChild(t("dont","Don't",r))}enhance(){this._wiredDoDont||(this._wiredDoDont=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-do-dont__item"):null;if(e&&this.contains(e)){const t=e.classList.contains("c-do-dont__item--do")?"do":"dont",r=e.querySelector(".u-muted")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:do-dont-activate",{bubbles:!0,composed:!0,detail:{kind:t,text:r}}))}}),Array.from(this.querySelectorAll(".c-do-dont__item")).forEach(t=>{t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.hasAttribute("role")||t.setAttribute("role","button")}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-do-dont__item"):null;e&&this.contains(e)&&("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e.click()))}))}}define("contour-do-dont",ContourDoDont);class ContourFlag extends ContourBase{static get observed(){return["variant","label"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"}}}render(){this.classList.add("c-flag");const t=this.getAttribute("variant");Array.from(this.classList).forEach(t=>{t.startsWith("c-flag--")&&this.classList.remove(t)}),t&&this.classList.add("c-flag--"+t);const e=this.getAttribute("label");if(e){let t=Array.from(this.childNodes).find(t=>3===t.nodeType);t||(t=document.createTextNode(""),this.appendChild(t)),t.nodeValue=e}}}define("contour-flag",ContourFlag);class ContourInstallFull extends ContourBase{static get observed(){return["command","prompt","copyable"]}static get properties(){return{command:{attribute:"command"},prompt:{attribute:"prompt"},copyable:{attribute:"copyable"}}}render(){this.classList.add("c-install");const t=this.getAttribute("prompt")||"$",e=this.getAttribute("command")||"";if(e){this.ensure(".c-install__prompt",()=>{const t=document.createElement("span");return t.className="c-install__prompt",t}).textContent=t;if(this.ensure(".c-install__command",()=>{const t=document.createElement("span");return t.className="c-install__command",t}).textContent=e,this.hasAttribute("copyable"))this.ensure(".c-install__copy",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--ghost c-btn--sm c-install__copy",t.type="button",t.setAttribute("aria-label",labelText(this,"copy-command","Copy command")),t.textContent=labelText(this,"copy","Copy"),t});else{const t=this.querySelector(".c-install__copy");t&&t.remove()}}}enhance(){wireCopy(this)}}define("contour-install",ContourInstallFull);class ContourTestimonialFull extends ContourBase{static get observed(){return["quote","name","role"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"},role:{attribute:"role"}}}render(){this.classList.add("c-testimonial");const t=this.getAttribute("quote");if(t){this.ensure(".c-testimonial__quote",()=>{const t=document.createElement("blockquote");return t.className="c-testimonial__quote",t}).textContent=t}else{const t=this.querySelector(".c-testimonial__quote");t&&t.remove()}const e=this.getAttribute("name"),r=this.getAttribute("role");if(e){const t=this.ensure(".c-testimonial__byline",()=>{const t=document.createElement("figcaption");return t.className="c-testimonial__byline",t}),s=t.querySelector(".c-testimonial__name")||(()=>{const e=document.createElement("cite");return e.className="c-testimonial__name",t.appendChild(e),e})();if(s.className="c-testimonial__name",s.textContent=e,r){const e=t.querySelector(".c-testimonial__role")||(()=>{const e=document.createElement("span");return e.className="c-testimonial__role",t.appendChild(e),e})();e.className="c-testimonial__role",e.textContent=r}else{const e=t.querySelector(".c-testimonial__role");e&&e.remove()}}else{const t=this.querySelector(".c-testimonial__byline");t&&t.remove()}}}define("contour-testimonial",ContourTestimonialFull);class ContourShowcaseFull extends ContourBase{static get observed(){return["title","text","media","reverse","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading","cache-key","no-cache"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},media:{attribute:"media"},reverse:{attribute:"reverse"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-showcase"),this.setAttribute("role","list"),this.hasAttribute("reverse")?this.classList.add("c-showcase--reverse"):this.classList.remove("c-showcase--reverse");const t=this.getAttribute("title");if(t?this.setAttribute("aria-label",t):this.removeAttribute("aria-label"),this.setAttribute("role","region"),wireStates(this),loadRemote(this,"items"),renderStates(this,"showcase"))return;const e=remoteData(this,"items"),r=this.getAttribute("text"),s=this.getAttribute("media");if(s){const e=this.ensure(".c-showcase__media",()=>{const t=document.createElement("figure");return t.className="c-showcase__media",t});if(/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(s.trim())){let r=e.querySelector("img");r||(r=document.createElement("img"),e.appendChild(r)),r.src=s.trim(),r.alt=t||""}else setHTML(e,sanitizeHtml(s));if(t){let r=e.querySelector(".c-showcase__caption");r||(r=document.createElement("figcaption"),r.className="c-showcase__caption",e.appendChild(r)),r.textContent=t}}else{const t=this.querySelector(".c-showcase__media");t&&t.remove()}if(t){this.ensure(".c-showcase__title",()=>{const t=document.createElement(headingTag(this,"h3"));return t.className="c-showcase__title",t}).textContent=t}else{const t=this.querySelector(".c-showcase__title");t&&t.remove()}if(r){this.ensure(".c-showcase__text",()=>{const t=document.createElement("p");return t.className="c-showcase__text",t}).textContent=r}else{const t=this.querySelector(".c-showcase__text");t&&t.remove()}const i=this.querySelector(".c-showcase__list"),a=i?Array.from(i.children).filter(t=>"LI"===t.tagName):[];if(e&&!a.length)try{const t=JSON.parse(e),r=this.ensure(".c-showcase__list",()=>{const t=document.createElement("ul");return t.className="c-showcase__list",t});r.replaceChildren(),t.forEach(t=>{const e=document.createElement("li");e.textContent="string"==typeof t?t:t.label||t.title||"",r.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}else e||a.length||t||r||s?!e&&i&&i.remove():renderEmpty(this,"showcase")}enhance(){this._wiredShowcase||(this._wiredShowcase=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-showcase__media"):null;if(e&&this.contains(e)){const t=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:showcase-activate",{bubbles:!0,composed:!0,detail:{title:t}}))}}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest("button, a, input, select, textarea, [role='button'], [role='link'], [role='checkbox'], [role='menuitem'], [role='option'], [role='tab']"):null;if(!(e&&this.contains(e)||"Enter"!==t.key&&" "!==t.key)){if(this.querySelector(".c-showcase__media")){t.preventDefault();const e=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:showcase-activate",{bubbles:!0,composed:!0,detail:{title:e}}))}}}))}}define("contour-showcase",ContourShowcaseFull);class ContourPricingFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-pricing")}}define("contour-pricing",ContourPricingFull);class ContourRecipeFull extends ContourBase{static get observed(){return["title","body","canvas","heading","url","tags","head","index"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},canvas:{attribute:"canvas"},url:{attribute:"url"},tags:{attribute:"tags"},head:{attribute:"head"},index:{attribute:"index"}}}render(){this.classList.add("c-recipe");const t=this.getAttribute("url");let e=this.querySelector(".c-recipe__frame");if(t){if(!e){e=document.createElement("div"),e.className="c-recipe__frame";const t=document.createElement("div");t.className="c-recipe__frame-bar";for(let e=0;e<3;e++){const e=document.createElement("span");e.className="c-recipe__frame-dot",t.appendChild(e)}const r=document.createElement("span");r.className="c-recipe__frame-url",t.appendChild(r),e.appendChild(t),this.prepend(e)}const r=e.querySelector(".c-recipe__frame-url");r&&(r.textContent=t)}else e&&e.remove();const r=this.getAttribute("head");if(r){this.ensure(".c-recipe__head",()=>{const t=document.createElement("div");return t.className="c-recipe__head",t}).textContent=r}else{const t=this.querySelector(".c-recipe__head");t&&t.remove()}const s=this.getAttribute("title");if(s){this.ensure(".c-recipe__title",()=>{const t=document.createElement(headingTag(this,"h3"));return t.className="c-recipe__title",t}).textContent=s}else{const t=this.querySelector(".c-recipe__title");t&&t.remove()}const i=this.getAttribute("index");if(i){this.ensure(".c-recipe__index",()=>{const t=document.createElement("span");return t.className="c-recipe__index",t}).textContent=i}else{const t=this.querySelector(".c-recipe__index");t&&t.remove()}const a=this.getAttribute("body");if(a){this.ensure(".c-recipe__desc",()=>{const t=document.createElement("p");return t.className="c-recipe__desc",t}).textContent=a}else{const t=this.querySelector(".c-recipe__desc");t&&t.remove()}const n=this.getAttribute("tags");if(n){const t=this.ensure(".c-recipe__tags",()=>{const t=document.createElement("div");return t.className="c-recipe__tags",t});t.innerHTML="",n.split(",").map(t=>t.trim()).filter(Boolean).forEach(e=>{const r=document.createElement("span");r.textContent=e,t.appendChild(r)})}else{const t=this.querySelector(".c-recipe__tags");t&&t.remove()}const o=this.getAttribute("canvas");if(o){const t=this.ensure(".c-recipe__canvas",()=>{const t=document.createElement("div");return t.className="c-recipe__canvas",t});if(/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(o.trim())){let e=t.querySelector("img");e||(e=document.createElement("img"),t.appendChild(e)),e.src=o.trim(),e.alt=""}else setHTML(t,sanitizeHtml(o))}else{const t=this.querySelector(".c-recipe__canvas");t&&t.remove()}}}define("contour-recipe",ContourRecipeFull);class ContourLogosFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-logos")}}define("contour-logos",ContourLogosFull);class ContourLandingFeaturesFull extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){if(this.classList.add("c-landing-features"),wireStates(this),loadRemote(this,"items"),renderStates(this,"landing-features"))return;const t=remoteData(this,"items"),e=Array.from(this.children).filter(t=>t.classList&&t.classList.contains("c-landing-features__item"));if(t&&!e.length)try{const e=JSON.parse(t);this.querySelectorAll(".c-landing-features__item").forEach(t=>t.remove()),e.forEach(t=>{const e=document.createElement("div");if(e.className="c-landing-features__item",t.icon){const r=document.createElement("span");r.className="c-landing-features__icon";const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("aria-hidden","true");const i=document.createElementNS("http://www.w3.org/2000/svg","use");i.setAttribute("href","#"+String(t.icon).replace(/[^a-zA-Z0-9_-]/g,"")),s.appendChild(i),r.appendChild(s),e.appendChild(r)}if(t.title){const r=document.createElement("span");r.className="c-landing-features__title",r.textContent=t.title,e.appendChild(r)}if(t.text){const r=document.createElement("p");r.className="c-landing-features__text",r.textContent=t.text,e.appendChild(r)}this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}else t||e.length||(this.querySelectorAll(".c-landing-features__item").forEach(t=>t.remove()),renderEmpty(this,"landing-features"))}}define("contour-landing-features",ContourLandingFeaturesFull);class ContourLandingHeroFull extends ContourBase{static get observed(){return["actions","title","text","heading","preview"]}static get properties(){return{actions:{attribute:"actions"},title:{attribute:"title"},text:{attribute:"text"},preview:{attribute:"preview"}}}render(){this.classList.add("c-landing-hero");const t=this.getAttribute("preview");let e=this.querySelector(".c-landing-hero__preview");if(t){if(!e){e=document.createElement("div"),e.className="c-landing-hero__preview";const t=document.createElement("div");t.className="c-landing-hero__preview-bar";for(let e=0;e<3;e++){const e=document.createElement("span");e.className="c-landing-hero__preview-dot",t.appendChild(e)}const r=document.createElement("div");r.className="c-landing-hero__preview-body",e.appendChild(t),e.appendChild(r),this.appendChild(e)}const r=e.querySelector(".c-landing-hero__preview-body");if(r)if(/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(t.trim())){r.innerHTML="";const e=document.createElement("img");e.src=t.trim(),e.alt="",r.appendChild(e)}else setHTML(r,sanitizeHtml(t))}else e&&e.remove();const r=this.getAttribute("title");if(r){this.ensure(".c-landing-hero__title",()=>{const t=document.createElement(headingTag(this,"h2"));return t.className="c-landing-hero__title",t}).textContent=r}const s=this.getAttribute("text");if(s){this.ensure(".c-landing-hero__text",()=>{const t=document.createElement("p");return t.className="c-landing-hero__text",t}).textContent=s}const i=this.getAttribute("actions"),a=this.querySelector(".c-landing-hero__actions"),n=a?Array.from(a.children):[];if(i&&!n.length){const t=this.ensure(".c-landing-hero__actions",()=>{const t=document.createElement("div");return t.className="c-landing-hero__actions",t});try{const e=JSON.parse(i);Array.isArray(e)?(t.replaceChildren(),e.forEach(e=>{const r=document.createElement(e.href?"a":"button");r.className="c-btn"+(e.primary?" c-btn--primary":""),e.href?r.href=safeHref(e.href):r.type="button",r.textContent=e.label||e.text||"",t.appendChild(r)})):setHTML(t,sanitizeHtml(i))}catch(e){setHTML(t,sanitizeHtml(i))}}else i||!a||n.length||a.remove()}}define("contour-landing-hero",ContourLandingHeroFull);class ContourLinkishFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-linkish")}}define("contour-linkish",ContourLinkishFull);class ContourPriceFull extends ContourBase{static get observed(){return["value","format","locale"]}static get properties(){return{value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-price");const t=this.getAttribute("value");let e=this.querySelector(".c-price__amount");t?(e||(e=document.createElement("span"),e.className="c-price__amount",this.appendChild(e)),e.textContent=formatValue(t,this.getAttribute("format"),this.getAttribute("locale"))):e&&e.remove()}}define("contour-price",ContourPriceFull);class ContourProseFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-prose")}}define("contour-prose",ContourProseFull);class ContourPanel extends ContourBase{static get observed(){return["title","subtitle","status","heading","collapsible","collapsed","flush"]}static get properties(){return{title:{attribute:"title"},subtitle:{attribute:"subtitle"},status:{attribute:"status"},collapsible:{attribute:"collapsible",type:Boolean},collapsed:{attribute:"collapsed",type:Boolean},flush:{attribute:"flush",type:Boolean}}}render(){this.classList.add("c-panel"),this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Panel");const t=this.getAttribute("title"),e=this.getAttribute("subtitle"),r=this.getAttribute("status");if(t){const e=this.ensure(".c-panel__title",()=>{const t=document.createElement(headingTag(this,"h3"));return t.className="c-panel__title",t});e.parentNode===this&&this.firstChild!==e&&this.prepend(e),e.textContent=t}else{const t=this.querySelector(".c-panel__title");t&&t.remove()}if(e){this.ensure(".c-panel__subtitle",()=>{const t=document.createElement("p");return t.className="c-panel__subtitle",t}).textContent=e}else{const t=this.querySelector(".c-panel__subtitle");t&&t.remove()}if(r){const t=this.ensure(".c-panel__status",()=>{const t=document.createElement("span");return t.className="c-panel__status",t});Array.from(t.classList).forEach(e=>{e.startsWith("c-panel__status--")&&t.classList.remove(e)}),"error"!==r&&"live"!==r||t.classList.add("c-panel__status--"+r),t.textContent=r}else{const t=this.querySelector(".c-panel__status");t&&t.remove()}if(this.hasAttribute("collapsible")){let t=this.querySelector(".c-panel__collapse");t||(t=document.createElement("button"),t.type="button",t.className="c-panel__collapse c-btn c-btn--ghost c-btn--sm",t.setAttribute("aria-label",labelText(this,"collapse","Toggle panel")),setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24" width="16" height="16"><use href="#i-chevron-down" /></svg>'),this.appendChild(t)),this.hasAttribute("collapsed")?(this.classList.add("c-panel--collapsed"),t.setAttribute("aria-expanded","false"),setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24" width="16" height="16"><use href="#i-chevron-right" /></svg>')):(this.classList.remove("c-panel--collapsed"),t.setAttribute("aria-expanded","true"),setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24" width="16" height="16"><use href="#i-chevron-down" /></svg>'))}else{const t=this.querySelector(".c-panel__collapse");t&&t.remove(),this.classList.remove("c-panel--collapsed")}const s=this.ensure(".c-panel__body",()=>{const t=document.createElement("div");return t.className="c-panel__body",t});s.classList.toggle("c-panel__body--flush",this.hasAttribute("flush"));const i=this.querySelector(".c-panel__head"),a=this.querySelector(".c-panel__collapse");Array.from(this.childNodes).forEach(t=>{t!==s&&t!==i&&(1===t.nodeType&&(t.classList.contains("c-panel__title")||t.classList.contains("c-panel__subtitle")||t.classList.contains("c-panel__status"))||t!==a&&s.appendChild(t))}),s.parentNode||this.appendChild(s),i&&i.parentNode===this&&s.parentNode===this&&i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_PRECEDING&&this.insertBefore(s,i.nextSibling)}enhance(){this._wiredPanel||(this._wiredPanel=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-panel__collapse"):null;e&&this.contains(e)&&(t.preventDefault(),this.toggleAttribute("collapsed"),this.dispatchEvent(new CustomEvent("contour:collapse",{bubbles:!0,composed:!0,detail:{collapsed:this.hasAttribute("collapsed")}})))}))}}define("contour-panel",ContourPanel);class ContourCta extends ContourBase{static get observed(){return["title","text","actions","heading"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},actions:{attribute:"actions"}}}render(){this.classList.add("c-cta");const t=this.getAttribute("title"),e=this.getAttribute("text");if(t){this.ensure(".c-cta__title",()=>{const t=document.createElement(headingTag(this,"h3"));return t.className="c-cta__title",t}).textContent=t}else{const t=this.querySelector(".c-cta__title");t&&t.remove()}if(e){this.ensure(".c-cta__text",()=>{const t=document.createElement("p");return t.className="c-cta__text",t}).textContent=e}else{const t=this.querySelector(".c-cta__text");t&&t.remove()}const r=this.getAttribute("actions"),s=this.querySelector(".c-cta__actions");if(s&&s.remove(),r)try{const t=JSON.parse(r),e=document.createElement("div");e.className="c-cta__actions";let s=!1;t.forEach(t=>{const r="string"==typeof t?t:t.label||t,i="object"==typeof t&&t?t.href:null,a=!("object"!=typeof t||!t)&&t.primary&&!s;a&&(s=!0);const n=document.createElement(i?"a":"button");n.className=a?"c-btn c-btn--primary":"c-btn c-btn--ghost",i?(n.href=safeHref(i),n.setAttribute("role","button")):n.type="button",n.textContent=r,e.appendChild(n)}),this.appendChild(e)}catch(t){warnBadJson(this,"attribute",t)}}}define("contour-cta",ContourCta);class ContourCode extends ContourBase{static get observed(){return["title","copyable","numbered"]}static get properties(){return{title:{attribute:"title"},copyable:{attribute:"copyable",type:Boolean},numbered:{attribute:"numbered",type:Boolean}}}render(){this.classList.add("c-code");const t=this.getAttribute("title");if(t){const e=this.ensure(".c-code__head",()=>{const t=document.createElement("div");return t.className="c-code__head",t});e.parentNode===this&&this.firstChild!==e&&this.prepend(e);(e.querySelector(".c-code__title")||(()=>{const t=document.createElement("div");return t.className="c-code__title",e.appendChild(t),t})()).textContent=t}else{const t=this.querySelector(".c-code__head");t&&t.remove();const e=this.querySelector(".c-code__title");e&&e.remove()}if(this.hasAttribute("copyable")){const t=this.ensure(".c-code__head",()=>{const t=document.createElement("div");return t.className="c-code__head",t});this.ensure(".c-code__copy",()=>{const e=document.createElement("button");return e.className="c-btn c-btn--ghost c-btn--sm c-code__copy",e.type="button",setHTML(e,'<svg aria-hidden="true" viewBox="0 0 24 24" width="14" height="14"><use href="#i-copy" /></svg>'),e.setAttribute("aria-label",labelText(this,"copy","Copy")),t.appendChild(e),e})}else{const t=this.querySelector(".c-code__copy");t&&t.remove()}const e=this.ensure("pre",()=>document.createElement("pre"));if(Array.from(this.childNodes).forEach(t=>{t===e||1===t.nodeType&&(t.classList.contains("c-code__head")||t.classList.contains("c-code__copy"))||e.appendChild(t)}),!e.querySelector("code")){const t=document.createElement("code");for(;e.firstChild;)t.appendChild(e.firstChild);e.appendChild(t)}e.parentNode!==this&&this.appendChild(e);const r=this.querySelector(".c-code__head");r&&r.parentNode===this&&e.parentNode===this&&r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING&&this.insertBefore(e,r.nextSibling);const s=this.hasAttribute("numbered");this.classList.toggle("c-code--numbered",s);const i=e.querySelector("code");if(i){const t="1"===i.dataset.contourLines;s&&!t?(splitCodeLines(i),i.dataset.contourLines="1"):!s&&t&&(joinCodeLines(i),delete i.dataset.contourLines)}}enhance(){wireCopy(this)}}define("contour-code",ContourCode);class ContourPlate extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-plate")}}define("contour-plate",ContourPlate);class ContourPullquote extends ContourBase{static get observed(){return["quote","name"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"}}}render(){this.classList.add("c-pullquote");const t=this.getAttribute("quote");if(t){Array.from(this.childNodes).forEach(t=>{3===t.nodeType&&t.remove()});const e=this.querySelector("cite");this.insertBefore(document.createTextNode(t),e)}const e=this.getAttribute("name");if(e){this.ensure("cite",()=>{const t=document.createElement("cite");return this.appendChild(t),t}).textContent=e}else{const t=this.querySelector("cite");t&&t.remove()}}}define("contour-pullquote",ContourPullquote);class ContourAnchor extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-anchor");const t=this.getAttribute("href"),e=this.getAttribute("label");if(Array.from(this.querySelectorAll("a[data-contour-generated]")).forEach(t=>t.remove()),t&&e){const r=document.createElement("a");r.dataset.contourGenerated="",r.href=safeHref(t),r.textContent=e;const s=this.getAttribute("aria-label");s&&r.setAttribute("aria-label",s),this.appendChild(r)}}}define("contour-anchor",ContourAnchor);class ContourGeocoder extends ContourBase{static get observed(){return["placeholder","value","results","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{placeholder:{attribute:"placeholder"},value:{attribute:"value"},results:{attribute:"results"},src:{attribute:"src"}}}render(){if(this.classList.add("c-geocoder"),wireStates(this),loadRemote(this,["results"]),renderStates(this,"geocoder"))return;let t=this.querySelector(".c-geocoder__input");t||(t=document.createElement("input"),t.type="search",t.className="c-input c-geocoder__input",t.hasAttribute("aria-label")||t.setAttribute("aria-label",this.getAttribute("placeholder")||"Search location"),t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded","false"),this.appendChild(t));const e=this.getAttribute("placeholder");e&&t.setAttribute("placeholder",e);const r=this.getAttribute("value");null!==r&&t.value!==r&&(t.value=r),Array.from(this.querySelectorAll(".c-geocoder__result")).forEach(t=>t.remove()),Array.from(this.querySelectorAll(".c-geocoder__list")).forEach(t=>t.remove());let s=[];const i=this.getAttribute("results");if(i)try{s=JSON.parse(i)}catch(t){s=[]}const a=remoteData(this,"results");if("string"==typeof a)try{const t=JSON.parse(a);Array.isArray(t)&&(s=t)}catch(t){}else Array.isArray(a)&&(s=a);if(Array.isArray(s)&&s.length){this._geocoderIndex=-1,this._geocoderListId||(this._geocoderListId=contourId("geocoder-list"));const e=document.createElement("ul");e.className="c-geocoder__list",e.id=this._geocoderListId,e.setAttribute("role","listbox"),s.forEach((t,r)=>{const s=document.createElement("li");s.className="c-geocoder__result",s.id=this._geocoderListId+"-"+r,s.setAttribute("role","option"),s.setAttribute("aria-selected","false"),s.setAttribute("tabindex","-1"),s.textContent="object"==typeof t?t.label||t.name||"":String(t),"object"==typeof t&&(null!=t.lat&&(s.dataset.lat=String(t.lat)),null!=t.lon&&(s.dataset.lon=String(t.lon))),e.appendChild(s)}),this.appendChild(e),t.setAttribute("aria-controls",this._geocoderListId),t.setAttribute("aria-expanded","true")}else if(t.removeAttribute("aria-controls"),t.setAttribute("aria-expanded","false"),t.removeAttribute("aria-activedescendant"),this._geocoderIndex=-1,!this.hasAttribute("loading")&&!this.hasAttribute("error")){const t=this.querySelector(".c-geocoder__input");t&&t.value&&renderEmpty(this,"geocoder")}}enhance(){if(this._wiredGeocoder)return;this._wiredGeocoder=!0;const t=this.querySelector(".c-geocoder__input");"number"!=typeof this._geocoderIndex&&(this._geocoderIndex=-1);const e=()=>Array.from(this.querySelectorAll(".c-geocoder__result")),r=()=>{const t=e(),r=this._geocoderIndex;return r>=0&&r<t.length?t[r]:null},s=r=>{const s=e();if(!s.length)return;const i=Math.max(0,Math.min(s.length-1,Number.isFinite(r)?r:0));s.forEach((t,e)=>t.setAttribute("aria-selected",e===i?"true":"false")),this._geocoderIndex=i,t&&(i>=0?t.setAttribute("aria-activedescendant",s[i].id):t.removeAttribute("aria-activedescendant"))},i=()=>{this._geocoderIndex=-1,e().forEach(t=>t.setAttribute("aria-selected","false")),t&&t.removeAttribute("aria-activedescendant")},a=t=>{if(!t)return;const e={label:t.textContent.trim(),lat:t.dataset.lat?Number(t.dataset.lat):void 0,lon:t.dataset.lon?Number(t.dataset.lon):void 0};this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{result:e}}))};t&&(this.addEventListener("input",e=>{e.target===t&&(i(),this._geocoderTimer&&clearTimeout(this._geocoderTimer),this._geocoderTimer=setTimeout(()=>{this._geocoderTimer=null,this.isConnected&&this.dispatchEvent(new CustomEvent("contour:search",{bubbles:!0,composed:!0,detail:{query:t.value}}))},200))}),this.addEventListener("keydown",n=>{if(n.target!==t)return;const o=e();if("ArrowDown"===n.key||"ArrowUp"===n.key){if(!o.length)return;n.preventDefault();const t=this._geocoderIndex<0?"ArrowDown"===n.key?-1:o.length:this._geocoderIndex;return void s(t+("ArrowDown"===n.key?1:-1))}if("Enter"===n.key){n.preventDefault();const e=r();return void(e?(a(e),t.setAttribute("aria-expanded","false"),t.removeAttribute("aria-controls"),i()):this.dispatchEvent(new CustomEvent("contour:search",{bubbles:!0,composed:!0,detail:{query:t.value}})))}if("Escape"===n.key&&o.length&&"true"===t.getAttribute("aria-expanded")){n.preventDefault(),i(),t.setAttribute("aria-expanded","false"),t.removeAttribute("aria-controls");const e=this.querySelector(".c-geocoder__list");e&&e.remove()}})),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-geocoder__result"):null;e&&this.contains(e)&&a(e)}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-geocoder__result"):null;e&&this.contains(e)&&("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),a(e)))})}disconnectedCallback(){this._geocoderTimer&&(clearTimeout(this._geocoderTimer),this._geocoderTimer=null),super.disconnectedCallback()}}define("contour-geocoder",ContourGeocoder);class ContourDashShell extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-dash-shell"),this.setAttribute("role","region");const t=this.getAttribute("title");if(t){const e=this.ensure(".c-dash-toolbar",()=>{const t=document.createElement("div");return t.className="c-dash-toolbar",t});e.parentNode===this&&this.firstChild!==e&&this.prepend(e);(e.querySelector(".c-dash-toolbar__title")||(()=>{const t=document.createElement("span");return t.className="c-dash-toolbar__title",e.appendChild(t),t})()).textContent=t,this.setAttribute("aria-label",t)}}}define("contour-dash-shell",ContourDashShell);class ContourDashToolbar extends ContourBase{static get observed(){return["title","actions"]}static get properties(){return{title:{attribute:"title"},actions:{attribute:"actions"}}}render(){this.classList.add("c-dash-toolbar"),this.setAttribute("role","toolbar");const t=this.getAttribute("title");if(t){this.ensure(".c-dash-toolbar__title",()=>{const t=document.createElement("span");return t.className="c-dash-toolbar__title",t}).textContent=t,this.setAttribute("aria-label",t)}else{const t=this.querySelector(".c-dash-toolbar__title");t&&t.remove()}const e=this.getAttribute("actions");if(e)try{const t=JSON.parse(e),r=this.ensure(".c-dash-toolbar__actions",()=>{const t=document.createElement("div");return t.className="c-dash-toolbar__actions",t});r.innerHTML="",t.forEach(t=>{const e=document.createElement("button");e.className="c-btn c-btn--ghost c-btn--sm",e.type="button",e.textContent="string"==typeof t?t:t.label||t,r.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}else{const t=this.querySelector(".c-dash-toolbar__actions");t&&t.remove()}}enhance(){this._wiredDashToolbar||(this._wiredDashToolbar=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-btn"):null;if(e&&this.contains(e)){const t=e.textContent||"";this.dispatchEvent(new CustomEvent("contour:dash-action",{bubbles:!0,composed:!0,detail:{label:t}}))}}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-btn"):null;if(!e||!this.contains(e))return;const r=Array.from(this.querySelectorAll(".c-btn")),s=r.indexOf(e);let i=-1;if("ArrowRight"===t.key?i=Math.min(r.length-1,s+1):"ArrowLeft"===t.key&&(i=Math.max(0,s-1)),i>=0){t.preventDefault();try{r[i].focus()}catch(t){}}else"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e.click())}))}}define("contour-dash-toolbar",ContourDashToolbar);class ContourDashKpiRow extends ContourBase{static get observed(){return["items","title"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-dash-kpi-row"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"KPI row"),Array.from(this.querySelectorAll("contour-kpi[data-contour-generated]")).forEach(t=>t.remove());const t=this.getAttribute("items");let e=null;if(t)try{e=JSON.parse(t)}catch(t){e=null}if(Array.isArray(e)&&e.length){const t=["value","label","delta","direction","note","unit","format","variant","thresholds","threshold","sparkline","polarity","locale"];e.forEach((e,r)=>{const s=document.createElement("contour-kpi");if("object"==typeof e&&null!==e)for(const r of t){const t=e[r];null!=t&&s.setAttribute(r,"string"==typeof t?t:JSON.stringify(t))}else s.setAttribute("value",String(e));s.setAttribute("tabindex",0===r?"0":"-1"),s.dataset.contourGenerated="",this.appendChild(s)})}}enhance(){this._wiredDashKpiRow||(this._wiredDashKpiRow=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest("contour-kpi"):null;if(e&&this.contains(e)){const t=Array.from(this.querySelectorAll("contour-kpi")).indexOf(e);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:t}}))}}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll("contour-kpi"));e.length&&navKey(t,e,{wrap:!0,homeEnd:!0,onNavigate:t=>{e.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:t}}))},onKey:(t,e)=>{"Enter"!==t&&" "!==t||this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:e}}))}})}))}}define("contour-dash-kpi-row",ContourDashKpiRow);class ContourDashFreshness extends ContourBase{static get observed(){return["label","value","format","locale"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-dash-freshness"),this.setAttribute("role","status"),this.setAttribute("aria-live","polite");const t=this.getAttribute("label"),e=this.getAttribute("value"),r=this.ensure(".c-dot",()=>{const t=document.createElement("span");return t.className="c-dot c-dot--live c-dot--accent",t.setAttribute("aria-hidden","true"),t});r.parentNode!==this&&this.appendChild(r),this._freshnessText&&this._freshnessText.parentNode||(this._freshnessText=document.createTextNode(""),this.appendChild(this._freshnessText));const s=e?formatValue(e,this.getAttribute("format"),this.getAttribute("locale")):e;this._freshnessText.nodeValue=[t,s].filter(Boolean).join(" ")}}define("contour-dash-freshness",ContourDashFreshness);class ContourSavedView extends ContourBase{static get observed(){return["name","updated","source","active"]}static get properties(){return{name:{attribute:"name"},updated:{attribute:"updated"},source:{attribute:"source"},active:{attribute:"active",type:Boolean}}}render(){this.classList.add("c-saved-view"),this.setAttribute("role","region"),this.getAttribute("name")&&this.setAttribute("aria-label",this.getAttribute("name")),this.hasAttribute("active")?this.classList.add("c-saved-view--active"):this.classList.remove("c-saved-view--active");const t=this.ensure(".c-saved-view__thumb",()=>{const t=document.createElement("div");return t.className="c-saved-view__thumb",t});t.setAttribute("role","img"),t.setAttribute("aria-label",`${labelText(this,"preview","Preview")} — ${this.getAttribute("name")||labelText(this,"unnamed","Saved view")}`),t.parentNode!==this&&this.appendChild(t);this.ensure(".c-saved-view__name",()=>{const t=document.createElement("div");return t.className="c-saved-view__name",t}).textContent=this.getAttribute("name")||"Saved view";let e=this.querySelector(".c-saved-view__meta");e||(e=document.createElement("div"),e.className="c-saved-view__meta",this.appendChild(e));const r=this.getAttribute("updated"),s=this.getAttribute("source");if(e.replaceChildren(),r){const t=document.createElement("span");t.textContent=`Updated ${r}`,e.appendChild(t)}if(s){e.childNodes.length&&e.appendChild(document.createTextNode(" · "));const t=document.createElement("span");t.textContent=`${labelText(this,"source","Source")}: ${s}`,e.appendChild(t)}let i=this.querySelector(".c-saved-view__actions");i||(i=document.createElement("div"),i.className="c-saved-view__actions",this.appendChild(i));applyLabel(i.querySelector(".c-saved-view__apply")||(()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--ghost c-btn--sm",t.setAttribute("data-saved-view-apply",""),i.appendChild(t),t})(),this,"apply","Apply");applyLabel(i.querySelector(".c-saved-view__remove")||(()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--ghost c-btn--sm",t.setAttribute("data-saved-view-remove",""),i.appendChild(t),t})(),this,"remove","Remove")}enhance(){this._wiredSavedView||(this._wiredSavedView=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest("button"):null;e&&this.contains(e)&&(e.hasAttribute("data-saved-view-apply")?this.dispatchEvent(new CustomEvent("contour:apply",{bubbles:!0,composed:!0,detail:{name:this.getAttribute("name")}})):e.hasAttribute("data-saved-view-remove")&&this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{name:this.getAttribute("name")}})))}))}}define("contour-saved-view",ContourSavedView);class ContourProvenance extends ContourBase{static get observed(){return["source","confidence","resolution","coverage","warning","methodology"]}static get properties(){return{source:{attribute:"source"},confidence:{attribute:"confidence"},resolution:{attribute:"resolution"},coverage:{attribute:"coverage"},warning:{attribute:"warning"},methodology:{attribute:"methodology"}}}render(){this.classList.add("c-provenance"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"provenance","Data provenance")),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite");const t=this.getAttribute("source");if(t){const e=this.ensure(".c-provenance__source",()=>{const t=document.createElement("span");return t.className="c-provenance__source",t}),r=document.createElement("b");r.textContent=labelText(this,"source","Source")+":",e.replaceChildren(r,document.createTextNode(" "+t))}else{const t=this.querySelector(".c-provenance__source");t&&t.remove()}const e=this.getAttribute("confidence");if(e){const t=this.ensure(".c-provenance__confidence",()=>{const t=document.createElement("span");return t.className="c-provenance__confidence",t}),r=String(e).toLowerCase(),s="high"===r||"medium"===r||"low"===r;t.className="c-provenance__confidence"+(s?" c-provenance__confidence--"+r:" c-provenance__confidence--unknown"),t.textContent=`Confidence: ${e}`}else{const t=this.querySelector(".c-provenance__confidence");t&&t.remove()}const r=this.getAttribute("resolution");if(r){this.ensure(".c-provenance__resolution",()=>{const t=document.createElement("span");return t.className="c-provenance__resolution",t}).textContent=`Resolution: ${r}`}else{const t=this.querySelector(".c-provenance__resolution");t&&t.remove()}const s=this.getAttribute("coverage");if(s){this.ensure(".c-provenance__coverage",()=>{const t=document.createElement("span");return t.className="c-provenance__coverage",t}).textContent=`Coverage: ${s}`}else{const t=this.querySelector(".c-provenance__coverage");t&&t.remove()}const i=this.getAttribute("methodology");if(i){this.ensure(".c-provenance__methodology",()=>{const t=document.createElement("span");return t.className="c-provenance__methodology",t}).textContent=`Methodology: ${i}`}else{const t=this.querySelector(".c-provenance__methodology");t&&t.remove()}const a=this.getAttribute("warning");if(a){this.ensure(".c-provenance__warning",()=>{const t=document.createElement("span");return t.className="c-provenance__warning",t}).textContent=`Warning: ${a}`}else{const t=this.querySelector(".c-provenance__warning");t&&t.remove()}}}define("contour-provenance",ContourProvenance);class ContourFeatureInspector extends ContourBase{static get observed(){return["title","open","data","actions"]}static get properties(){return{title:{attribute:"title"},open:{attribute:"open",type:Boolean},data:{attribute:"data"}}}render(){this.classList.add("c-feature-inspector"),this.hasAttribute("role")||this.setAttribute("role","region"),this.getAttribute("title")&&this.setAttribute("aria-label",this.getAttribute("title"));const t=this.getAttribute("open");null!==t&&"false"!==t?this.setAttribute("open",""):this.removeAttribute("open");this.ensure(".c-feature-inspector__head",()=>{const t=document.createElement("div");return t.className="c-feature-inspector__head",t});this.ensure(".c-feature-inspector__title",()=>{const t=document.createElement("span");return t.className="c-feature-inspector__title",t}).textContent=labelText(this,"title",this.getAttribute("title")||"Feature inspector");const e=this.ensure(".c-feature-inspector__body",()=>{const t=document.createElement("div");return t.className="c-feature-inspector__body",t});this.querySelectorAll(".c-feature-inspector__field").forEach(t=>t.remove());const r=this.getAttribute("data");if(r)try{const t=JSON.parse(r);if(t&&"object"==typeof t&&!Array.isArray(t))for(const[r,s]of Object.entries(t)){const t=document.createElement("div");t.className="c-feature-inspector__field";const i=document.createElement("span");i.className="c-feature-inspector__label",i.textContent=r;const a=document.createElement("span");a.className="c-feature-inspector__value",a.textContent=String(s),t.appendChild(i),t.appendChild(a),e.appendChild(t)}}catch(t){warnBadJson(this,"attribute",t)}const s=this.ensure(".c-feature-inspector__actions",()=>{const t=document.createElement("div");return t.className="c-feature-inspector__actions",t});Array.from(s.querySelectorAll("[data-inspect-action]")).forEach(t=>t.remove());const i=this.getAttribute("actions");if(i)try{const t=JSON.parse(i);Array.isArray(t)&&t.forEach(t=>{const e=document.createElement("button");e.type="button",e.className="c-btn c-btn--sm c-feature-inspector__action",e.setAttribute("data-inspect-action",""),e.textContent="string"==typeof t?t:t&&(t.label||t.action)||"",t&&"object"==typeof t&&void 0!==t.value&&e.setAttribute("data-action",String(t.value)),s.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}s.style.display=s.hasChildNodes()?"":"none"}enhance(){this._wiredFeatureInspector||(this._wiredFeatureInspector=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest("button"):null;e&&this.contains(e)&&this.dispatchEvent(new CustomEvent("contour:inspect-action",{bubbles:!0,composed:!0,detail:{label:e.textContent||"",value:e.getAttribute("data-action")||""}}))}))}}define("contour-feature-inspector",ContourFeatureInspector);class ContourReadout extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","format","locale","unit","precision","cache-key","no-cache"]}static get properties(){return{rows:{attribute:"rows"},format:{attribute:"format"},locale:{attribute:"locale"},precision:{attribute:"precision"},src:{attribute:"src"}}}render(){if(this.classList.add("c-readout"),wireStates(this),loadRemote(this,"rows"),renderStates(this,"readout"))return;const t=remoteData(this,"rows");Array.from(this.querySelectorAll(".c-readout__row")).forEach(t=>t.remove());const e=Array.from(this.children).filter(t=>!t.classList||!t.classList.contains("c-readout__row"));if(t&&!e.length)try{JSON.parse(t).forEach(t=>{const e=document.createElement("div");e.className="c-readout__row";const r=document.createElement("span");r.className="c-readout__key",r.textContent=t.key||t[0];const s=document.createElement("span");s.className="c-readout__value"+(t.primary?" c-readout__value--primary":"")+(t.accent?" c-readout__value--accent":"")+(t.coord?" c-readout__value--coord":""),s.setAttribute("aria-live","polite");const i=void 0!==t.value?t.value:t[1],a=void 0!==t.precision?t.precision:this.getAttribute("precision");null!==a&&""!==a&&(s.dataset.precision=String(a));const n=null!==a&&""!==a&&"number"==typeof i&&Number.isFinite(i)?i.toFixed(Math.max(0,Math.min(20,Number(a)||0))):i;if(s.textContent=formatValue(n,this.getAttribute("format"),this.getAttribute("locale"),void 0!==t.unit?t.unit:this.getAttribute("unit")),e.appendChild(r),e.appendChild(s),t.order){const r=document.createElement("span");r.className="c-readout__order",r.textContent=t.order,e.appendChild(r)}this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}else t||e.length||renderEmpty(this,"readout")}}define("contour-readout",ContourReadout);class ContourKpi extends ContourBase{static get observed(){return["value","label","delta","direction","note","variant","unit","format","locale","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","thresholds","threshold","sparkline","polarity","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},delta:{attribute:"delta"},direction:{attribute:"direction"},note:{attribute:"note"},variant:{attribute:"variant"},unit:{attribute:"unit"},format:{attribute:"format"},locale:{attribute:"locale"},thresholds:{attribute:"thresholds"},threshold:{attribute:"threshold"},sparkline:{attribute:"sparkline"},polarity:{attribute:"polarity"}}}render(){if(this.classList.add("c-kpi"),wireStates(this),loadRemote(this,["value","label"]),renderStates(this,"kpi"))return;const t=remoteData(this,"value"),e=remoteData(this,"label"),r=this.getAttribute("delta"),s=this.getAttribute("variant");if(Array.from(this.classList).forEach(t=>{t.startsWith("c-kpi--")&&this.classList.remove(t)}),s&&this.classList.add("c-kpi--"+s),t){this.ensure(".c-kpi__value",()=>{const t=document.createElement("div");return t.className="c-kpi__value",t.setAttribute("aria-live","polite"),t}).textContent=formatValue(t,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const t=this.querySelector(".c-kpi__value");t&&t.remove()}if(e){const t=this.ensure(".c-kpi__head",()=>{const t=document.createElement("div");return t.className="c-kpi__head",t});let r=t.querySelector(".c-kpi__label");r||(r=document.createElement("div"),r.className="c-kpi__label",t.appendChild(r)),r.textContent=e,t.parentNode!==this&&this.insertBefore(t,this.firstChild)}else{const t=this.querySelector(".c-kpi__head");t&&t.remove()}if(r){const t=this.ensure(".c-kpi__foot",()=>{const t=document.createElement("div");return t.className="c-kpi__foot",t}),e=t.querySelector(".c-delta")||document.createElement("span");e.parentNode||t.insertBefore(e,t.firstChild);const s=this.getAttribute("direction")||"up",i=this.getAttribute("polarity")||"neutral";let a="neutral";"good"===i||"up-good"===i||"auto"===i?a="up"===s?"good":"down"===s?"bad":"neutral":"bad"!==i&&"down-good"!==i||(a="up"===s?"bad":"down"===s?"good":"neutral"),e.className="c-delta c-delta--"+s+" c-delta--"+a,e.textContent="";const n={up:"#i-arrow-up",down:"#i-arrow-down",flat:"#i-minus"}[s]||"#i-arrow-up",o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("aria-hidden","true");const l=document.createElementNS("http://www.w3.org/2000/svg","use");l.setAttribute("href",n),o.appendChild(l),e.appendChild(o),e.appendChild(document.createTextNode(" "+r))}else{const t=this.querySelector(".c-kpi__foot .c-delta");t&&t.remove()}const i=this.getAttribute("note");if(i){const t=this.ensure(".c-kpi__foot",()=>{const t=document.createElement("div");return t.className="c-kpi__foot",t});(t.querySelector(".c-kpi__note")||(()=>{const e=document.createElement("span");return e.className="c-kpi__note",t.appendChild(e),e})()).textContent=i}else{const t=this.querySelector(".c-kpi__note");t&&t.remove()}const a=this.getAttribute("unit"),n=this.querySelector(".c-kpi__value");if(n)if(a){let t=n.querySelector(".c-kpi__unit");t||(t=document.createElement("span"),t.className="c-kpi__unit",n.appendChild(t)),t.textContent=a}else{const t=n.querySelector(".c-kpi__unit");t&&t.remove()}const o=this.getAttribute("threshold")||this.getAttribute("thresholds");if(o){const t=this.ensure(".c-kpi__foot",()=>{const t=document.createElement("div");return t.className="c-kpi__foot",t});let e=t.querySelector(".c-kpi__threshold-badge");e||(e=document.createElement("span"),e.className="c-kpi__threshold-badge",t.appendChild(e)),e.textContent=o,e.setAttribute("part","threshold-badge")}else{const t=this.querySelector(".c-kpi__threshold-badge");t&&t.remove()}const l=this.querySelector(".c-kpi__foot");l&&!l.querySelector(".c-delta, .c-kpi__note, .c-kpi__threshold-badge")&&l.remove();const c=this.getAttribute("sparkline"),u=null!==c&&""!==c&&"0"!==c&&"false"!==c.toLowerCase(),d=this.querySelector(".c-kpi__sparkline-canvas");if(d&&d.remove(),u){let t=null;try{t=JSON.parse(c)}catch(e){t=null}Array.isArray(t)||(t=null);const e=(t||[]).map(t=>Number(t)).filter(t=>Number.isFinite(t));if(e.length>1){const t=document.createElement("canvas");t.className="c-kpi__sparkline-canvas",t.setAttribute("part","sparkline-canvas"),t.setAttribute("aria-hidden","true"),this.appendChild(t),this._sparkSeries=e;const r=()=>{if(!t.isConnected)return;const r=t.clientWidth,s=t.clientHeight;if(!r||!s)return;const i="undefined"!=typeof window&&window.devicePixelRatio||1;t.width=Math.round(r*i),t.height=Math.round(s*i);const a=t.getContext&&t.getContext("2d");if(!a)return;a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,r,s);const n=Math.min.apply(null,e),o=Math.max.apply(null,e)-n||1;let l=getComputedStyle(this).getPropertyValue("--chart-1").trim();if(!l||/^(var|light-dark)\(/.test(l)){const t=document.createElement("span");t.style.display="none",t.style.color=l||"var(--chart-1, #666)",this.appendChild(t),l=getComputedStyle(t).color||"#666",t.remove()}a.beginPath(),a.lineWidth=1.5,a.strokeStyle=l,e.forEach((t,i)=>{const l=(t=>t/(e.length-1)*(r-4)+2)(i),c=(t=>s-2-(t-n)/o*(s-4))(t);0===i?a.moveTo(l,c):a.lineTo(l,c)}),a.stroke()};"function"==typeof requestAnimationFrame?requestAnimationFrame(r):r(),"undefined"==typeof ResizeObserver||this._sparkRO||(this._sparkRO=new ResizeObserver(()=>r()),onDispose(this,()=>{this._sparkRO&&(this._sparkRO.disconnect(),this._sparkRO=null)})),this._sparkRO&&this._sparkRO.observe(t)}}t||e||renderEmpty(this,"kpi")}}define("contour-kpi",ContourKpi);class ContourTable extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","page-size","sort","sort-dir","virtual","title","selected","empty","loading","error","retry","skeleton","persist","density","visible-columns","cache-key","lazy","no-cache","refresh","src","timeout"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page",type:Number},pageSize:{attribute:"page-size",type:Number}}}get selected(){return this._selectionKeys()}set selected(t){this._pushedSelection=Array.isArray(t)?t.map(String):[],this.requestRender()}_rowKey(t){if(t&&"object"==typeof t&&!Array.isArray(t)){if(void 0!==t.id&&null!==t.id)return String(t.id);if(void 0!==t.key&&null!==t.key)return String(t.key)}const e=this._keyCol;if(null!=e&&e>=0&&t&&void 0!==t[e]&&null!==t[e]){const r=this._cellValue(t[e]);if(""!==r)return String(r)}return JSON.stringify(void 0===t?null:t)}_selectionKeys(){if(this._selectionControlled)return Array.from(this._selectedKeys||[]);const t=this._rowData||[];return Array.from(this._selectedRows||[]).map(e=>this._rowKey(t[e]))}_syncSelectionRows(){const t=this._rowData||[],e=new Set;t.forEach((t,r)=>{this._selectedKeys.has(this._rowKey(t))&&e.add(r)}),this._selectedRows=e}_cellValue(t){return null==t?"":"object"==typeof t?void 0!==t.value?t.value:void 0!==t.label?t.label:JSON.stringify(t):t}_cellFor(t,e,r){if(t&&"object"==typeof t&&!Array.isArray(t)){const s="string"==typeof e?e:e&&(e.key||e.label||e.title)||"";return s&&void 0!==t[s]?t[s]:t[r]}return t?t[r]:void 0}_compare(t,e,r){const s=this._cellValue(t),i=this._cellValue(e);return"number"===r||"numeric"===r?(parseFloat(s)||0)-(parseFloat(i)||0):String(s).localeCompare(String(i),void 0,{numeric:!0})}_applyVisibleColumns(t){const e=this.getAttribute("visible-columns");if(!e)return;let r=null;try{const t=JSON.parse(e);Array.isArray(t)&&(r=new Set(t.map(Number)))}catch(t){}if(!r||!r.size)return;const s=t=>r.has(t);t.querySelectorAll("thead tr th").forEach((t,e)=>{t.hidden=!s(e)}),t.querySelectorAll("tbody tr").forEach(t=>{1===t.children.length&&t.children[0].hasAttribute("colspan")||Array.from(t.children).forEach((t,e)=>{t.hidden=!s(e)})})}render(){if(this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Table"),wireStates(this),loadRemote(this,"rows"),renderStates(this,"table"))return;const t=this.getAttribute("columns"),e=remoteData(this,"rows"),r=Array.from(this.children).filter(t=>!t.classList||!t.classList.contains("c-table-wrap"));if(t&&e&&!r.length)try{const r=JSON.parse(t),s=JSON.parse(e),i=this.getAttribute("sort"),a=this.getAttribute("sort-dir");if(void 0===this._sortCol||i!==this._sortAttrLast||a!==this._sortDirAttrLast){if(this._sortAttrLast=i,this._sortDirAttrLast=a,null!==i){const t=Number(i);this._sortCol=Number.isFinite(t)?t:r.findIndex(t=>"object"==typeof t&&t&&(t.label||t.title||t)===i),this._sortCol<0&&(this._sortCol=null)}else this._sortCol=null;this._sortDir="descending"===a||"desc"===a?-1:1}let n=Array.isArray(s)?s.slice():[];if(null!==this._sortCol&&void 0!==this._sortCol&&this._sortCol>=0&&this._sortCol<r.length){const t=this._sortCol,e=this._sortDir||1,s=r[t],i="object"==typeof s&&s&&s.sortType?s.sortType:"text";n.sort((r,a)=>this._compare(this._cellFor(r,s,t),this._cellFor(a,s,t),i)*e)}this._filters||(this._filters={});const o=Object.keys(this._filters).filter(t=>this._filters[t]);o.length&&(n=n.filter(t=>o.every(e=>{const s=Number(e),i=String(this._filters[s]||"").toLowerCase();return!i||String(this._cellValue(this._cellFor(t,r[s],s))).toLowerCase().includes(i)})));const l=this.getAttribute("page-size"),c=null!==l?parseInt(l,10):NaN,u=Number.isFinite(c)&&c>0;let d=this.getAttribute("page");if(this.getAttribute("persist")&&this.id){const t=this.getAttribute("persist");let e=null;if("storage"===t)try{e=localStorage.getItem("contour-table:"+this.id)}catch(t){}else if("url"===t)try{e=new URLSearchParams(window.location.search).get("c-table-"+this.id)}catch(t){}null!==e&&(d=e)}this._pageInternal?(this._pageInternal=!1,this._pageAttrLast=d):d!==this._pageAttrLast&&(this._page=null,this._pageAttrLast=d);let h=null!==this._page?this._page:parseInt(d||"1",10);(!Number.isFinite(h)||h<1)&&(h=1);let m=1,b=n;if(u){m=Math.max(1,Math.ceil(n.length/c)),h>m&&(h=m);const t=(h-1)*c;b=n.slice(t,t+c)}this._page=h,this._totalPages=m,this._pageSize=c,this._rowData=b,this._keyCol=r.findIndex(t=>"object"==typeof t&&null!==t&&!0===t.key),this._selectedRows=this._selectedRows||new Set,this._selectedKeys=this._selectedKeys||new Set;const p=this.getAttribute("selected");if(p!==this._selectedAttrLast)if(this._selectedAttrLast=p,null!==p)try{const t=JSON.parse(p);Array.isArray(t)?(this._selectedKeys=new Set(t.map(String)),this._selectionControlled=!0):warnBadJson(this,"selected",new Error("not an array"))}catch(t){warnBadJson(this,"selected",t)}else void 0===this._pushedSelection&&(this._selectionControlled=!1);void 0!==this._pushedSelection&&(this._selectedKeys=new Set(this._pushedSelection),this._selectionControlled=!0),this._selectionControlled&&this._syncSelectionRows();const g=this._virtualWrap||this.keepNode(this.ensure(".c-table-wrap",()=>{const t=document.createElement("div");return t.className="c-table-wrap",t.setAttribute("tabindex","0"),t.setAttribute("role","region"),t.setAttribute("aria-label",labelText(this,"table-data","Table data")),t}));this._virtualWrap=g;const _=JSON.stringify(r),v=g.querySelector("table.c-table")&&this._tableCols===_?g.querySelector("table.c-table"):(()=>{const t=document.createElement("table");t.className="c-table";const e=document.createElement("caption");e.className="visually-hidden",e.textContent=this.getAttribute("title")||this.getAttribute("aria-label")||"Table",t.appendChild(e);const s=document.createElement("thead"),i=document.createElement("tr");return r.forEach((t,e)=>{const r="string"==typeof t?t:t.label||t.title||t,s=document.createElement("th"),a="object"==typeof t&&null!==t&&t.sort,n="object"==typeof t&&null!==t&&t.select,o="object"==typeof t&&null!==t&&t.filter;if("object"==typeof t&&null!==t&&("number"===t.type||"numeric"===t.type)&&s.classList.add("c-table__number"),o){s.className=s.className.trim();const t=document.createElement("input");t.type="search",t.className="c-table__filter-input",t.placeholder=r,t.setAttribute("aria-label",labelText(this,"filter","Filter")+" "+r),t.dataset.filterIndex=String(e),this._filters&&this._filters[e]&&(t.value=this._filters[e]),s.appendChild(t)}else if(n){s.className=(s.className+" c-table__select").trim();const t=document.createElement("input");t.type="checkbox",t.className="c-table__select-all",t.setAttribute("aria-label",labelText(this,"select-all-rows","Select all rows")),t.dataset.contourPreserveKey="select-all",s.appendChild(t)}else if(a){s.setAttribute("aria-sort",this._sortCol===e?-1===this._sortDir?"descending":"ascending":"none");const t=document.createElement("span");t.className="c-table__sort",t.textContent=r;const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("aria-hidden","true"),setHTML(i,'<use href="#i-chevron-down" />'),t.appendChild(i),s.appendChild(t)}else"object"==typeof t&&null!==t&&t.pinned?(s.className="c-table__pinned",s.textContent=r):s.textContent=r;a&&(s.setAttribute("tabindex","0"),s.setAttribute("role","columnheader"),s.dataset.sortIndex=String(e)),i.appendChild(s)}),s.appendChild(i),t.appendChild(s),t.appendChild(document.createElement("tbody")),t})();this._tableCols=_,this._applyVisibleColumns(v),r.forEach((t,e)=>{if("object"==typeof t&&null!==t&&t.sort){const t=v.querySelector("thead tr th:nth-child("+(e+1)+")");t&&t.setAttribute("aria-sort",this._sortCol===e?-1===this._sortDir?"descending":"ascending":"none")}});const f=v.querySelector("tbody"),y=null!=this._tablePendingScrollTop?this._tablePendingScrollTop:g.scrollTop;this._tablePendingScrollTop=null,f.innerHTML="";const A=this.hasAttribute("virtual")&&!u&&b.length>100,C=this._measuredRowHeight||cssLength("--data-grid-row-height",32),w=30,E=10;let x=0,S=b;if(A){const t=Math.max(0,b.length-w);x=Math.min(t,Math.max(0,Math.floor(y/C)-E)),S=b.slice(x,x+w+2*E),v.setAttribute("aria-rowcount",String(b.length+1)),this._tableWindowStart=x}else v.removeAttribute("aria-rowcount");const k=t=>{const e=document.createElement("tr");e.setAttribute("aria-hidden","true");const s=document.createElement("td");s.colSpan=r.length,s.style.blockSize=`${t}px`,s.style.padding="0",e.appendChild(s),f.appendChild(e)};if(A&&k(x*C),0===S.length){const t=document.createElement("tr"),e=document.createElement("td");e.colSpan=r.length,e.textContent=this.getAttribute("empty")||"No data",e.style.textAlign="center",e.style.color="var(--color-text-muted)",t.appendChild(e),f.appendChild(t)}else S.forEach((t,e)=>{const s=document.createElement("tr");s.dataset.rowIndex=String(x+e);const i=this._rowKey(t);s.dataset.rowKey=i,s.setAttribute("tabindex","-1"),r.forEach((r,a)=>{const n="object"==typeof r&&null!==r&&r.select,o="object"==typeof r&&null!==r&&("number"===r.type||"numeric"===r.type),l=document.createElement("td");if(o&&l.classList.add("c-table__number"),n){const t=document.createElement("input");t.type="checkbox",t.className="c-table__row-select",t.dataset.rowIndex=String(x+e),t.dataset.contourPreserveKey=i,this._selectionControlled?this._selectedKeys.has(i)&&(t.checked=!0):this._selectedRows&&this._selectedRows.has(x+e)&&(t.checked=!0),l.appendChild(t)}else l.textContent=this._cellValue(this._cellFor(t,r,a));s.appendChild(l)}),f.appendChild(s)});if(A&&k(Math.max(0,b.length-x-S.length)*C),!f.querySelector('tr[tabindex="0"]')){const t=f.querySelector("tr[data-row-index]");t&&t.setAttribute("tabindex","0")}if(!this._measuredRowHeight&&!this._measuringRow){const t=f.querySelector("tr[data-row-index]"),e=t?t.getBoundingClientRect().height:0;e>0&&(this._measuredRowHeight=e,Math.abs(e-C)>1&&(this._measuringRow=!0,requestAnimationFrame(()=>{this._measuringRow=!1,this.render()})))}if(v.parentNode!==g){for(;g.firstChild;)g.removeChild(g.firstChild);g.appendChild(v)}if(g.parentNode!==this&&this.appendChild(g),A&&y>0&&g.scrollTop!==y&&(this._tableScrollRestoredAt="undefined"!=typeof performance&&performance.now?performance.now():Date.now(),g.scrollTop=y),this.hasAttribute("virtual")?(g.style.maxHeight=g.style.maxHeight||"24rem",g.style.overflow="auto",g.style.contentVisibility="visible",v.classList.add("c-table--virtual")):(g.style.maxHeight="",g.style.overflow="",g.style.contentVisibility="",v.classList.remove("c-table--virtual")),u){const t=this.ensure(".c-table__pagination",()=>{const t=document.createElement("div");return t.className="c-table__pagination",t});t.innerHTML="";const e=document.createElement("button");e.className="c-btn c-btn--ghost c-btn--sm",e.type="button",e.textContent=labelText(this,"prev","Previous"),e.disabled=h<=1,e.dataset.action="prev";const r=document.createElement("span");r.textContent=`${labelText(this,"page","Page")} ${h} ${labelText(this,"of","of")} ${m}`;const s=document.createElement("button");s.className="c-btn c-btn--ghost c-btn--sm",s.type="button",s.textContent=labelText(this,"next","Next"),s.disabled=h>=m,s.dataset.action="next",t.appendChild(e),t.appendChild(r),t.appendChild(s)}else{const t=this.querySelector(".c-table__pagination");t&&t.remove()}}catch(t){warnBadJson(this,"attribute",t)}else e||r.length||renderEmpty(this,"table")}_applySelectionToDom(){this.querySelectorAll(".c-table__row-select").forEach(t=>{const e=Number(t.dataset.rowIndex);if(!Number.isFinite(e))return;const r=this._rowData?this._rowData[e]:void 0,s=this._selectionControlled?this._selectedKeys.has(this._rowKey(r)):!(!this._selectedRows||!this._selectedRows.has(e));t.checked!==s&&(t.checked=s)});const t=this.querySelector(".c-table__select-all");if(t){const e=Array.from(this.querySelectorAll(".c-table__row-select")),r=e.filter(t=>t.checked).length;t.checked=e.length>0&&r===e.length,t.indeterminate=r>0&&r<e.length,t.setAttribute("aria-label",flagOn(this,"virtual")?labelText(this,"select-visible-rows","Select visible rows"):labelText(this,"select-all-rows","Select all rows"))}}enhance(){if(this._applySelectionToDom(),this._wiredTable)return;this._wiredTable=!0;const t=t=>{const e=Number(t.dataset.sortIndex);Number.isFinite(e)&&(this._sortCol===e?this._sortDir=1===this._sortDir?-1:1:(this._sortCol=e,this._sortDir=1),this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:!0,composed:!0,detail:{column:e,direction:1===this._sortDir?"ascending":"descending"}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{sort:e,sortDir:1===this._sortDir?"ascending":"descending"}}})),this.requestRender())};this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest('button[data-action="retry"]'):null;if(r&&this.contains(r))return e.preventDefault(),void this.dispatchEvent(new CustomEvent("contour:retry",{detail:{src:this.getAttribute("src")},bubbles:!0,composed:!0}));const s=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;if(s&&this.contains(s))return e.preventDefault(),void t(s);const i=e.target&&e.target.closest?e.target.closest(".c-table__pagination button"):null;if(i&&this.contains(i)){e.preventDefault();const t=i.dataset.action;let r=null!==this._page?this._page:parseInt(this.getAttribute("page")||"1",10);(!Number.isFinite(r)||r<1)&&(r=1),"prev"===t&&r>1&&(r-=1),"next"===t&&(r+=1),this._page=r,this._pageAttrLast=String(r),this._pageInternal=!0,this.setAttribute("page",String(r)),this.dispatchEvent(new CustomEvent("contour:page",{bubbles:!0,composed:!0,detail:{page:r}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{page:r}}}));const s=this.getAttribute("persist");if("storage"===s&&this.id)try{localStorage.setItem("contour-table:"+this.id,String(r))}catch(e){}else if("url"===s&&this.id)try{const t=new URL(window.location.href);t.searchParams.set("c-table-"+this.id,String(r)),window.history.replaceState(null,"",t.toString())}catch(e){}}}),this.addEventListener("keydown",e=>{if("Enter"!==e.key&&" "!==e.key)return;const r=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;r&&this.contains(r)&&(e.preventDefault(),t(r))}),this.addEventListener("input",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-table__filter-input"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.filterIndex);Number.isFinite(r)&&(this._filters||(this._filters={}),this._filters[r]=e.value,this.requestRender(),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{column:r,value:e.value}}})))}),this.addEventListener("scroll",t=>{if(!(this.hasAttribute("virtual")&&t.target&&t.target.classList&&t.target.classList.contains("c-table-wrap")))return;const e=t.target,r=this._measuredRowHeight||cssLength("--data-grid-row-height",32),s=Math.max(0,(this._rowData?this._rowData.length:0)-30),i=Math.min(s,Math.max(0,Math.floor(e.scrollTop/r)-10));if(this._tableWindowStart===i)return;if(this._tableVirtualRaf)return;this._tablePendingScrollTop=e.scrollTop;const a=()=>{this._tableVirtualRaf=0,this.requestRender()};this._tableVirtualRaf="function"==typeof requestAnimationFrame?requestAnimationFrame(a):setTimeout(a,16)},!0),onDispose(this,()=>{this._tableVirtualRaf&&("function"==typeof cancelAnimationFrame?cancelAnimationFrame(this._tableVirtualRaf):clearTimeout(this._tableVirtualRaf),this._tableVirtualRaf=0)}),this._selectedRows=this._selectedRows||new Set,this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-table__row-select"):null;if(e&&this.contains(e)){const t=Number(e.dataset.rowIndex);if(!Number.isFinite(t))return;const r=this._rowKey(this._rowData?this._rowData[t]:void 0);this._selectionControlled?(e.checked?this._selectedKeys.add(r):this._selectedKeys.delete(r),this._syncSelectionRows()):e.checked?this._selectedRows.add(t):this._selectedRows.delete(t),this._applySelectionToDom();const s=Array.from(this._selectedRows),i=this._selectionKeys();return this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{rows:s,key:r,index:t}})),void this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{selectedRows:s,selectedKeys:i}}}))}const r=t.target&&t.target.closest?t.target.closest(".c-table__select-all"):null;if(r&&this.contains(r)){const t=Array.from(this.querySelectorAll(".c-table__row-select"));t.forEach(t=>{t.checked=r.checked}),this._selectionControlled?(t.forEach(t=>{const e=Number(t.dataset.rowIndex),s=this._rowKey(this._rowData?this._rowData[e]:void 0);r.checked?this._selectedKeys.add(s):this._selectedKeys.delete(s)}),this._syncSelectionRows()):this._selectedRows=new Set(r.checked?t.map(t=>Number(t.dataset.rowIndex)):[]),r.indeterminate=!1;const e=Array.from(this._selectedRows),s=this._selectionKeys();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{rows:e}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{selectedRows:e,selectedKeys:s}}}))}}),this.addEventListener("mouseover",t=>{const e=t.target&&t.target.closest?t.target.closest("tbody tr"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.rowIndex);Number.isFinite(r)&&this._hoveredRow!==r&&(this._hoveredRow=r,this.dispatchEvent(new CustomEvent("contour:hover",{bubbles:!0,composed:!0,detail:{row:r}})))}),this.addEventListener("mouseout",t=>{const e=t.target&&t.target.closest?t.target.closest("tbody tr"):null;if(!e||!this.contains(e))return;(t.relatedTarget&&t.relatedTarget.closest?t.relatedTarget.closest("tbody tr"):null)!==e&&(this._hoveredRow=null,this.dispatchEvent(new CustomEvent("contour:leave",{bubbles:!0,composed:!0,detail:{}})))}),this.addEventListener("click",t=>{if(t.target&&t.target.closest&&t.target.closest("input, button, select, textarea, a[href], label"))return;const e=t.target&&t.target.closest?t.target.closest("tbody tr"):null;if(!e||!this.contains(e))return;const r=void 0!==e.dataset.rowIndex?e.dataset.rowIndex:e.dataset.row,s=Number(r);if(!Number.isFinite(s))return;const i=this._rowData&&this._rowData[s]||null;this.dispatchEvent(new CustomEvent("contour:zoom",{bubbles:!0,composed:!0,detail:{row:s,index:s,data:i}}))}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest("tbody tr"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.rowIndex);if(Number.isFinite(r)){if("ArrowDown"===t.key||"ArrowUp"===t.key||"Home"===t.key||"End"===t.key){const r=Array.from(this.querySelectorAll("tbody tr[data-row-index]")),s=r.indexOf(e);let i=s;if("ArrowDown"===t.key?i=Math.min(r.length-1,s+1):"ArrowUp"===t.key?i=Math.max(0,s-1):"Home"===t.key?i=0:"End"===t.key&&(i=r.length-1),i!==s&&r[i]){t.preventDefault(),r.forEach(t=>t.setAttribute("tabindex","-1")),r[i].setAttribute("tabindex","0");try{r[i].focus()}catch(t){}}return}"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0,detail:{row:r}})))}}),this.addEventListener("contour:clear-all",()=>{let t=!1;this.hasAttribute("sort")&&(this.removeAttribute("sort"),t=!0),this.hasAttribute("sort-dir")&&(this.removeAttribute("sort-dir"),t=!0),null!==this._sortCol&&void 0!==this._sortCol&&(this._sortCol=null,this._sortDir=1,t=!0),this.hasAttribute("page")&&(this.removeAttribute("page"),t=!0),this._filters&&Object.keys(this._filters).length&&(this._filters={},this.querySelectorAll(".c-table__filter-input").forEach(t=>{t.value=""}),t=!0),this._selectedRows&&this._selectedRows.size&&(this._selectedRows.clear(),t=!0),!this._selectionControlled&&this._selectedKeys&&this._selectedKeys.size&&(this._selectedKeys.clear(),t=!0),t&&(this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{sort:null,sortDir:null,page:null,filters:null}}})),this.requestRender())})}}define("contour-table",ContourTable);class ContourDataTable extends ContourTable{render(){super.render(),this.classList.add("c-data-table"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"data-table","Data table"))}}define("contour-data-table",ContourDataTable);class ContourColumnPicker extends ContourBase{static get observed(){return["columns","label"]}static get properties(){return{columns:{attribute:"columns"},label:{attribute:"label"}}}render(){this.classList.add("c-column-picker");const t=this.ensure(".c-column-picker__trigger",()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--sm c-column-picker__trigger",t});setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-sliders" /></svg>'),t.appendChild(document.createTextNode(" "+(this.getAttribute("label")||labelText(this,"columns","Columns"))));const e=this.ensure(".c-column-picker__panel",()=>{const t=document.createElement("div");return t.className="c-column-picker__panel",t});let r=[];try{const t=JSON.parse(this.getAttribute("columns")||"[]");Array.isArray(t)&&(r=t)}catch(t){}e.innerHTML="",r.forEach(t=>{const r="string"==typeof t?t:t.label||t.name||t,s="string"==typeof t?t:t.value||t.name||t,i=document.createElement("label");i.className="c-column-picker__item";const a=document.createElement("input");a.type="checkbox",a.checked=!0,a.dataset.column=s,i.appendChild(a),i.appendChild(document.createTextNode(" "+r)),e.appendChild(i)})}enhance(){this._wiredColPicker||(this._wiredColPicker=!0,this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-column-picker__item input"):null;e&&this.contains(e)&&this.dispatchEvent(new CustomEvent("contour:column-toggle",{bubbles:!0,composed:!0,detail:{column:e.dataset.column,visible:e.checked}}))}))}}define("contour-column-picker",ContourColumnPicker);const STREAM_BUFFER_MAX=600,capBuffer=(t,e=600)=>{if(!Array.isArray(t)||t.length<=e)return t;const r=Math.ceil(t.length/e),s=[];for(let e=0;e<t.length;e+=r)s.push(t[e]);const i=t[t.length-1];return s[s.length-1]!==i&&s.push(i),s},patchChildren=(t,e)=>{const r=Array.from(e.childNodes),s=Array.from(t.childNodes),i=Math.max(r.length,s.length);for(let e=0;e<i;e++){const i=s[e],a=r[e];if(i)if(a)if(1===i.nodeType&&1===a.nodeType&&i.tagName===a.tagName){for(const t of Array.from(i.attributes))a.hasAttribute(t.name)||i.removeAttribute(t.name);for(const t of Array.from(a.attributes)){const e=a.getAttribute(t.name);i.getAttribute(t.name)!==e&&i.setAttribute(t.name,e)}patchChildren(i,a)}else 3===i.nodeType&&3===a.nodeType?i.textContent!==a.textContent&&(i.textContent=a.textContent):t.replaceChild(a,i);else t.removeChild(i);else a&&t.appendChild(a)}},normalizeChartBin=t=>{if(!t||"object"!=typeof t)return null;const e=Number(t.x0),r=Number(t.x1),s=Number(t.count);if(!Number.isFinite(e)||!Number.isFinite(r)||!Number.isFinite(s))return null;const i={x0:e,x1:r,count:s},a=Number(t.normalized);return Number.isFinite(a)&&(i.normalized=a),i};class ContourChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["series","axis","color","label","legend","brownout","brownout-level","empty","loading","error","retry","skeleton","zoomable","data-table","brush","brush-min","brush-max","brush-start","brush-end","note","bucket-count","limit-values","title","cache-key","dir","src"]}static get properties(){return{series:{attribute:"series"},axis:{attribute:"axis"},color:{attribute:"color"},label:{attribute:"label"},legend:{attribute:"legend"},zoomable:{attribute:"zoomable",type:Boolean},brush:{attribute:"brush",type:Boolean},note:{attribute:"note"},"bucket-count":{attribute:"bucket-count"},"limit-values":{attribute:"limit-values"}}}get bins(){const t=this._pushedBins;return(t&&t.length?t:this._renderedBins||[]).map(t=>({...t}))}set bins(t){this._pushedBins=capBuffer(Array.isArray(t)?t.map(normalizeChartBin).filter(Boolean):[]),this.requestRender()}get backgroundData(){const t=this._pushedBackground;return(t&&t.length?t:this._renderedBackground||[]).map(t=>({...t}))}set backgroundData(t){this._pushedBackground=Array.isArray(t)?t.map(normalizeChartBin).filter(Boolean):[],this.requestRender()}_showsBrush(){return this.hasAttribute("brush")||void 0!==this._rangeOverride}get range(){const t=this._rangeOverride;if(void 0!==t)return t?t.slice():null;if(!this.hasAttribute("brush"))return null;const e=parseFloat(this.getAttribute("brush-start")),r=parseFloat(this.getAttribute("brush-end"));return Number.isFinite(e)&&Number.isFinite(r)?[e,r]:null}set range(t){if(null==t)return this._rangeOverride=null,void this.requestRender();const e=Array.isArray(t)?t:[t,t],r=Number(e[0]),s=Number(e[1]);Number.isFinite(r)&&Number.isFinite(s)&&(this._rangeOverride=[r,s],this.requestRender())}_axisLabel(){const t=this.getAttribute("axis");if(!t)return"";try{const e=JSON.parse(t);if(e&&"object"==typeof e){const t=e.x;return e.label||e.title||e.name||t&&"object"==typeof t&&(t.label||t.title||t.name)||""}return String(e)}catch(e){return t}}_seriesColor(t,e){const r=safeColor(t&&"object"==typeof t?t.color:"");if(r)return r;const s=safeColor(this.getAttribute("color"));return s||"var(--chart-"+(e%12+1)+")"}_legendOff(){const t=(this.getAttribute("legend")||"").trim().toLowerCase();return"off"===t||"false"===t||"none"===t||"0"===t}_applyBrownout(){const t=this.shed("chrome",2),e=this.shed("marks",3),r=this.querySelector(".c-chart__plot");r&&(r.style.backgroundImage=t?"none":"");const s=this.querySelector(".c-chart__axis");s&&(s.style.display=e?"none":"");const i=this.querySelector(".c-chart__note");i&&(i.style.display=e?"none":"");const a=this.querySelector("contour-brush");a&&(a.style.display=e?"none":"")}_axisConfig(){const t=this.getAttribute("axis");if(!t)return null;try{const e=JSON.parse(t);return e&&"object"==typeof e?e:null}catch(t){return null}}_valueDomain(){const t=this.getAttribute("series");if(!t)return null;try{const e=JSON.parse(t);let r=1/0,s=-1/0,i=!1;return(Array.isArray(e)?e:[]).forEach(t=>{!t||"bar"!==t.type&&"histogram"!==t.type&&"stacked"!==t.type||(i=!0),t&&Array.isArray(t.values)&&t.values.forEach(t=>{const e=Number(t);Number.isFinite(e)&&(e<r&&(r=e),e>s&&(s=e))})}),i&&Number.isFinite(r)&&Number.isFinite(s)&&(r=Math.min(0,r),s=Math.max(0,s)),Number.isFinite(r)&&Number.isFinite(s)?[r,s]:null}catch(t){return null}}_renderValueAxis(){const t=this.querySelector(".c-chart__axis");if(!t)return;const e=this._axisConfig(),r=e&&e.y,s=r&&r.domain||this._valueDomain(),i=this.querySelector(".c-chart__axis-x");if(!s)return this.classList.remove("c-chart--value-axis"),t.className="c-chart__axis",t.textContent=this._axisLabel(),void(i&&i.remove());this.classList.add("c-chart--value-axis"),t.className="c-chart__axis c-chart__axis--y";const a=r&&r.ticks||niceTicks(s[0],s[1],5),n=r&&r.format||(t=>String(t));t.textContent="";a.forEach(e=>{const r=document.createElement("span");r.className="c-chart__tick",r.textContent="function"==typeof n?n(e):String(e),t.appendChild(r)}),r&&"object"==typeof r&&(r.label||r.title||r.name)&&t.appendChild(((t,e)=>{const r=document.createElement("span");return r.className="c-chart__tick",r.dataset.axisTitle=e,r.textContent=t,r})(r.label||r.title||r.name,"y"));const o=this._axisLabel();let l=i;o?(l||(l=document.createElement("div"),l.className="c-chart__axis-x",this.appendChild(l)),l.textContent=o):l&&l.remove(),this.style.setProperty("--chart-ticks",String(a.length))}_renderLegend(){const t=this.getAttribute("series");let e=this.querySelector(".c-chart__legend");if(!t||this._legendOff()||this.shed("legend",2))e&&e.remove();else try{const r=JSON.parse(t),s=(Array.isArray(r)?r:[]).map((t,e)=>({s:t,i:e})).filter(t=>t.s&&t.s.label);if(!s.length)return void(e&&e.remove());e||(e=document.createElement("div"),e.className="c-chart__legend",this.appendChild(e)),e.textContent="",s.forEach(({s:t,i:r})=>{const s=document.createElement("span");s.className="c-chart__legend-item";const i=document.createElement("span");i.className="c-chart__legend-swatch",i.style.setProperty("--c",this._seriesColor(t,r)),i.dataset.series=String(r%12+1),i.dataset.style=t.style||"line",s.appendChild(i),s.appendChild(document.createTextNode(t.label)),e.appendChild(s)})}catch(t){}}render(){this.classList.add("c-chart"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-roledescription")||this.setAttribute("aria-roledescription","chart");const t=this.getAttribute("label")||this._axisLabel(),e=this.getAttribute("aria-label");if(!t||null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t),this.hasAttribute("loading")){this.setAttribute("aria-busy","true");const t=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});t.innerHTML="";const e=document.createElement("div");e.className="c-chart__loading",e.textContent=this.getAttribute("loading")||"Loading…",e.style.display="grid",e.style.placeItems="center",e.style.height="100%",e.style.color="var(--color-text-muted)",t.appendChild(e);if(this.getAttribute("axis")){this.ensure(".c-chart__axis",()=>{const t=document.createElement("div");return t.className="c-chart__axis",t}).textContent=this._axisLabel()}return}if(this.removeAttribute("aria-busy"),this.hasAttribute("error")){const t=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});t.innerHTML="";const e=document.createElement("div");if(e.className="c-chart__error",e.textContent=this.getAttribute("error")||"Error",e.style.display="grid",e.style.placeItems="center",e.style.height="100%",e.style.color="var(--color-danger, var(--color-text))",this.hasAttribute("retry")){const t=document.createElement("button");t.className="c-btn c-btn--ghost c-btn--sm",t.type="button",t.textContent=this.getAttribute("retry")||"Retry",t.dataset.action="retry",t.classList.add("u-mbs-sm"),e.appendChild(t)}t.appendChild(e);if(this.getAttribute("axis")){this.ensure(".c-chart__axis",()=>{const t=document.createElement("div");return t.className="c-chart__axis",t}).textContent=this._axisLabel()}return}if(this.hasAttribute("skeleton")){const t=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});t.innerHTML="";const e=Math.min(5,Math.max(1,parseInt(this.getAttribute("skeleton")||"3",10)||3));for(let r=0;r<e;r++){const e=document.createElement("div");e.className="c-skeleton",e.style.display="block",e.style.inlineSize="100%",e.style.blockSize="0.6rem",e.classList.add("u-mbe-2xs"),t.appendChild(e)}if(this.getAttribute("axis")){this.ensure(".c-chart__axis",()=>{const t=document.createElement("div");return t.className="c-chart__axis",t}).textContent=this._axisLabel()}return}if(this.getAttribute("axis")){this.ensure(".c-chart__axis",()=>{const t=document.createElement("div");return t.className="c-chart__axis",t}).textContent=this._axisLabel()}else{const t=this.querySelector(".c-chart__axis");t&&t.remove()}this._renderValueAxis(),this._renderLegend();let r=this.getAttribute("series");if(!r&&this._pushedBins&&this._pushedBins.length&&(r=JSON.stringify([{type:"histogram",bins:this._pushedBins}])),r){const t=parseArrayAttr(this,"series",warnBadJson);if(0===t.length)return void renderEmpty(this,"chart");const e=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});this.keepNode(e);const r=document.createDocumentFragment();if(t.some(t=>t&&(Array.isArray(t.values)||Array.isArray(t.bins))))this._renderedBins=[],this._renderedBackground=[],t.forEach((t,e)=>{const s=this._seriesColor(t,e);if("donut"===t.type){const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("viewBox","0 0 200 200"),s.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",s.setAttribute("role","group"),s.setAttribute("aria-label",t.label||"Donut chart"),donutSlices(t.values).forEach((r,i)=>{const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("class","c-donut__slice"),a.setAttribute("data-series",String(e+1)),a.dataset.index=String(i),a.style.setProperty("--c",safeColor("var(--chart-"+(i%12+1)+")")||"var(--chart-1)"),a.setAttribute("d",r.path),a.setAttribute("data-title",String(t.values[i])),a.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(t.values[i])),a.setAttribute("role","button"),a.setAttribute("tabindex",0===i?"0":"-1"),s.appendChild(a)}),r.appendChild(s)}else if("bar"===t.type){const i=Array.isArray(t.values)?t.values:[],a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("viewBox","0 0 300 120"),a.setAttribute("preserveAspectRatio","none"),a.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",barRects(i).forEach((t,r)=>{if(t.missing)return;const n=document.createElementNS("http://www.w3.org/2000/svg","rect");n.setAttribute("class","c-chart__bar"),n.setAttribute("data-series",String(e+1)),n.style.setProperty("--c",s),n.setAttribute("x",t.x),n.setAttribute("y",t.y),n.setAttribute("width",t.width),n.setAttribute("height",t.height),n.setAttribute("data-title",String(i[r])),n.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(i[r])),n.setAttribute("tabindex","0"),n.setAttribute("role","button"),n.dataset.index=String(r),a.appendChild(n)}),r.appendChild(a)}else if("histogram"===t.type){let i=Array.isArray(t.values)?t.values.slice():[];const a=parseInt(this.getAttribute("limit-values")||"0",10);a>0&&(i=i.slice(0,a));const n=parseInt(this.getAttribute("bucket-count")||"0",10),o=this._pushedBins&&this._pushedBins.length?this._pushedBins:null,l=Array.isArray(t.bins)?t.bins.map(normalizeChartBin).filter(Boolean):null;let c=o||(l&&l.length?l:null),u=i;if(!c&&n>0&&i.length){const t=i.map(t=>Number(t)||0),e=Math.min.apply(null,t),r=(Math.max.apply(null,t)-e||1)/n,s=new Array(n).fill(0);t.forEach(t=>{const i=Math.min(n-1,Math.floor((t-e)/r));s[i]+=1}),u=s,c=s.map((t,s)=>({x0:e+s*r,x1:e+(s+1)*r,count:t}))}c&&(u=c.map(t=>t.count)),this._renderedBins=c?c.slice():[];const d=this._pushedBackground&&this._pushedBackground.length?this._pushedBackground:null,h=Array.isArray(t.background)?t.background.map(normalizeChartBin).filter(Boolean):null,m=d||(h&&h.length?h:[]);this._renderedBackground=m.slice();const b=m.map(t=>Number(t.count)||0);let p=1;b.length&&u.concat(b).forEach(t=>{const e=Number(t)||0;e>p&&(p=e)});const g=document.createElementNS("http://www.w3.org/2000/svg","svg");g.setAttribute("viewBox","0 0 300 120"),g.setAttribute("preserveAspectRatio","none"),g.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",b.length&&barRects(b,{max:p}).forEach(t=>{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("class","c-chart__bar"),e.setAttribute("data-context",""),e.setAttribute("aria-hidden","true"),e.style.setProperty("--c",s),e.setAttribute("x",t.x),e.setAttribute("y",t.y),e.setAttribute("width",t.width),e.setAttribute("height",t.height),g.appendChild(e)}),barRects(u,b.length?{max:p}:void 0).forEach((r,i)=>{if(r.missing)return;const a=document.createElementNS("http://www.w3.org/2000/svg","rect");a.setAttribute("class","c-chart__bar"),a.setAttribute("data-series",String(e+1)),a.style.setProperty("--c",s),a.setAttribute("x",r.x),a.setAttribute("y",r.y),a.setAttribute("width",r.width),a.setAttribute("height",r.height);const n=c?c[i].count:Array.isArray(t.values)?t.values[i]:i;a.setAttribute("data-title",String(n)),a.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(n)),a.setAttribute("tabindex","0"),a.setAttribute("role","button"),a.dataset.index=String(i),g.appendChild(a)}),r.appendChild(g)}else if("scatter"===t.type){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("viewBox","0 0 300 120"),i.setAttribute("preserveAspectRatio","none"),i.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const a=(Array.isArray(t.values)?t.values:[]).filter(t=>!isMissing(t)).map(t=>Array.isArray(t)?{x:Number(t[0])||0,y:Number(t[1])||0}:{x:Number(t&&t.x)||0,y:Number(t&&t.y)||0}),n=a.map(t=>t.x),o=a.map(t=>t.y),l=n.length?Math.min.apply(null,n):0,c=n.length?Math.max.apply(null,n):1,u=o.length?Math.min.apply(null,o):0,d=o.length?Math.max.apply(null,o):1,h=c-l||1,m=d-u||1,b=2e3;let p=a;if(a.length>b){const t=Math.ceil(a.length/b);p=a.filter((e,r)=>r%t===0),this.dispatchEvent(new CustomEvent("contour:cap",{bubbles:!0,composed:!0,detail:{series:e+1,total:a.length,shown:p.length}}))}p.forEach((t,r)=>{const a=document.createElementNS("http://www.w3.org/2000/svg","circle");a.setAttribute("class","c-chart__point"),a.setAttribute("data-series",String(e+1)),a.setAttribute("data-index",String(r)),a.style.setProperty("--c",s);const n=(t.x-l)/h*300,o=120-(t.y-u)/m*120;a.setAttribute("cx",n.toFixed(2)),a.setAttribute("cy",o.toFixed(2)),a.setAttribute("r","3"),a.setAttribute("tabindex",0===r?"0":"-1"),a.setAttribute("role","button"),a.setAttribute("data-title",t.x+", "+t.y),a.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+t.x+", "+t.y),i.appendChild(a)}),p.length!==a.length&&(i.setAttribute("data-decimated",String(a.length)),i.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+" ("+p.length+" "+labelText(this,"of","of")+" "+a.length+")")),r.appendChild(i)}else{const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("viewBox","0 0 300 120"),i.setAttribute("preserveAspectRatio","none"),i.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("class","c-chart__line"),a.setAttribute("data-series",String(e+1)),a.style.setProperty("--c",s),a.setAttribute("d",smoothPath(t.values)),i.appendChild(a);const n=t.values.filter(t=>!isMissing(t)).map(Number).filter(t=>Number.isFinite(t)),o=n.reduce((t,e)=>e>t?e:t,n.length?n[0]:1),l=n.reduce((t,e)=>e<t?e:t,n.length?n[0]:0),c=o-l||1,u=t.values.length||1;let d=!0;t.values.forEach((t,r)=>{if(isMissing(t))return;const a=Number(t);if(!Number.isFinite(a))return;const n=r/Math.max(1,u-1)*300,o=120-(a-l)/c*120,h=document.createElementNS("http://www.w3.org/2000/svg","circle");h.setAttribute("class","c-chart__point"),h.setAttribute("data-series",String(e+1)),h.setAttribute("data-index",String(r)),h.style.setProperty("--c",s),h.setAttribute("cx",String(n)),h.setAttribute("cy",String(o)),h.setAttribute("r","3"),h.setAttribute("tabindex",d?"0":"-1"),d=!1,h.setAttribute("role","button"),h.setAttribute("data-title",String(t)),h.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(t)),i.appendChild(h)}),r.appendChild(i)}});else{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 300 120"),e.setAttribute("preserveAspectRatio","none"),e.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",e.setAttribute("aria-hidden","true"),t.forEach((t,r)=>{const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("class","c-chart__line"),s.setAttribute("data-series",String(r+1)),s.style.setProperty("--c",this._seriesColor(t,r)),s.setAttribute("d","string"==typeof t.d&&t.d.trim()?t.d:Array.isArray(t.values)?smoothPath(t.values):""),e.appendChild(s)}),r.appendChild(e)}if(patchChildren(e,r),this.shed("tooltip",2)){const t=this.querySelector(".c-chart__tooltip");t&&t.remove()}else{this.ensure(".c-chart__tooltip",()=>{const t=document.createElement("div");return t.className="c-chart__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t.id=contourId("chart-tip"),t}).setAttribute("hidden","")}const s=(this.getAttribute("data-table")||"").trim().toLowerCase(),i="none"===s||"off"===s||"false"===s||"0"===s,a=t.some(t=>Array.isArray(t&&t.values)&&t.values.length);if(!i&&a){let e=this.querySelector(".c-chart__data-table");e||(e=document.createElement("table"),e.className="c-chart__data-table visually-hidden",this.appendChild(e)),e.innerHTML="";const r=this.getAttribute("title")||this.getAttribute("aria-label")||labelText(this,"chart-data","Chart data"),s=document.createElement("caption");s.textContent=r,e.appendChild(s);const i=document.createElement("thead"),a=document.createElement("tr"),n=document.createElement("th");n.setAttribute("scope","col"),n.textContent=labelText(this,"series","Series"),a.appendChild(n);const o=t.reduce((t,e)=>Math.max(t,Array.isArray(e.values)?e.values.length:Array.isArray(e)?e.length:0),0);for(let t=0;t<o;t++){const e=document.createElement("th");e.setAttribute("scope","col"),e.textContent=labelText(this,"value","Value")+" "+(t+1),a.appendChild(e)}i.appendChild(a),e.appendChild(i);const l=document.createElement("tbody");t.forEach((t,e)=>{const r=Array.isArray(t.values)?t.values:Array.isArray(t)?t:[],s=document.createElement("tr"),i=document.createElement("th");i.setAttribute("scope","row"),i.textContent=t.label||"Series "+(e+1),s.appendChild(i);for(let t=0;t<o;t++){const e=document.createElement("td");e.textContent=isMissing(r[t])?"":String(r[t]),s.appendChild(e)}l.appendChild(s)}),e.appendChild(l)}else{const t=this.querySelector(".c-chart__data-table");t&&t.remove()}if(this._showsBrush()){const t=this.ensure("contour-brush",()=>document.createElement("contour-brush")),e=this._renderedBins||[],r=this.getAttribute("brush-min")||(e.length?String(e[0].x0):"0"),s=this.getAttribute("brush-max")||(e.length?String(e[e.length-1].x1):"100"),i=Array.isArray(this._rangeOverride)?this._rangeOverride:null,a=null===this._rangeOverride;t.setAttribute("min",r),t.setAttribute("max",s),t.setAttribute("start",i?String(i[0]):a?r:this.getAttribute("brush-start")||r),t.setAttribute("end",i?String(i[1]):a?s:this.getAttribute("brush-end")||s);const n=this.querySelector(".c-chart__plot");t.previousElementSibling!==n&&this.insertBefore(t,n?n.nextSibling:null)}else{const t=this.querySelector("contour-brush");t&&t.remove()}const n=this.getAttribute("note");let o=this.querySelector(".c-chart__note");n?(o||(o=document.createElement("div"),o.className="c-chart__note",this.appendChild(o)),o.textContent=n):o&&o.remove()}else{this._renderedBins=[],this._renderedBackground=[];const t=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});t.innerHTML="";const e=document.createElement("div");e.className="c-chart__empty",e.textContent=this.getAttribute("empty")||"No data",e.style.display="grid",e.style.placeItems="center",e.style.height="100%",e.style.color="var(--color-text-muted)",t.appendChild(e);const r=this.getAttribute("note");let s=this.querySelector(".c-chart__note");r?(s||(s=document.createElement("div"),s.className="c-chart__note",this.appendChild(s)),s.textContent=r):s&&s.remove()}this._applyBrownout()}enhance(){if(this._wiredChart)return;this._wiredChart=!0,wireStates(this);const t=this.parentElement||document,e=t=>{const e=t&&t.detail&&(null!=t.detail.key?t.detail.key:t.detail.label),r=t&&t.detail&&t.detail.index,s=t&&t.detail&&t.detail.pressed;if(null==e&&null==r)return;this.querySelectorAll("[data-series]").forEach(t=>{const i=t.getAttribute("data-series");(String(i)===String(e)||t.getAttribute("data-key")===String(e)||null!=r&&String(i)===String(r+1))&&(t.style.display=!1===s?"none":"")})};if(t.addEventListener("contour:legend-toggle",e),onDispose(this,()=>t.removeEventListener("contour:legend-toggle",e)),this.addEventListener("contour:brush-end",t=>{this._showsBrush()&&t.target&&t.target.matches("contour-brush")&&(void 0!==this._rangeOverride&&t.detail&&Array.isArray(t.detail.range)&&(this._rangeOverride=t.detail.range.slice()),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:t.detail})))}),this.hasAttribute("zoomable")){let t=1,e=0,r=0;const s=this.querySelector(".c-chart__plot"),i=()=>{s&&(s.style.transform=`translate(${e}px, ${r}px) scale(${t})`,s.style.transformOrigin="center center")};this.addEventListener("wheel",e=>{e.preventDefault();const r=e.deltaY<0?1.1:.9;t=Math.min(5,Math.max(.5,t*r)),i()},{passive:!1});let a=!1,n=0,o=0,l=0,c=0;this.addEventListener("mousedown",t=>{0===t.button&&(a=!0,n=t.clientX,o=t.clientY,l=e,c=r,this.style.cursor="grabbing")});const u=t=>{a&&(e=l+(t.clientX-n),r=c+(t.clientY-o),i())},d=()=>{a&&(a=!1,this.style.cursor="")};window.addEventListener("mousemove",u),window.addEventListener("mouseup",d),onDispose(this,()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",d)}),this.addEventListener("dblclick",()=>{t=1,e=0,r=0,i()})}let r=null,s=null;const i=()=>{r=null},a=t=>{const e=this.querySelector(".c-chart__plot"),a=this.querySelector(".c-chart__tooltip");if(!e||!a)return;const n=t.target&&t.target.closest?t.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line, .c-donut__slice"):null;if(!n||!e.contains(n))return void a.setAttribute("hidden","");const o=n.getAttribute("data-title")||n.getAttribute("title");o&&(a.textContent=o),r||(r=e.getBoundingClientRect(),s||"function"!=typeof ResizeObserver||(s=new ResizeObserver(i),s.observe(e)));const l=r,c=n.getBoundingClientRect(),u=c.left-l.left+c.width/2,d=c.top-l.top;e.style.setProperty("--chart-tip-inline-start",u+"px"),e.style.setProperty("--chart-tip-block-start",d+"px"),a.removeAttribute("hidden")},n=()=>{const t=this.querySelector(".c-chart__tooltip");t&&t.setAttribute("hidden","")};this.addEventListener("mousemove",a),this.addEventListener("mouseleave",n),onDispose(this,()=>{s&&(s.disconnect(),s=null)}),this.addEventListener("focusin",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line, .c-donut__slice"):null;if(e&&this.contains(e)){a({target:e});const t=this.querySelector(".c-chart__tooltip");t&&t.id&&e.setAttribute("aria-describedby",t.id)}}),this.addEventListener("focusout",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line, .c-donut__slice"):null;e&&this.contains(e)&&e.removeAttribute("aria-describedby"),this.contains(t.relatedTarget)||n()}),this.addEventListener("click",t=>{const e=this.querySelector(".c-chart__plot");if(!e)return;const r=t.target&&t.target.closest?t.target.closest(".c-chart__bar"):null;if(r&&e.contains(r)){const t=parseInt(r.getAttribute("data-series")||"1",10),e=parseInt(r.dataset.index||"0",10);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e}}))}const s=t.target&&t.target.closest?t.target.closest(".c-chart__point"):null;if(s&&e.contains(s)){const t=parseInt(s.getAttribute("data-series")||"1",10),e=parseInt(s.dataset.index||"0",10);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e}}))}const i=t.target&&t.target.closest?t.target.closest(".c-donut__slice"):null;if(i&&e.contains(i)){const t=parseInt(i.getAttribute("data-series")||"1",10),e=parseInt(i.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e,value:i.getAttribute("data-title")||i.getAttribute("title")}}))}}),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-chart__plot");if(!e)return;const r=t.target&&t.target.closest?t.target.closest(".c-chart__bar"):null;if(r&&e.contains(r)){if("Enter"===t.key||" "===t.key){t.preventDefault();const e=parseInt(r.getAttribute("data-series")||"1",10),s=parseInt(r.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:e,index:s}}))}const s=r.getAttribute("data-series");if(s){const i=parseInt(s,10),a=Array.from(e.querySelectorAll('.c-chart__bar[data-series="'+i+'"]'));a.indexOf(r)>=0&&navKey(t,a,{wrap:!1,rtl:isRtl(this),onNavigate:t=>a.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}return}const s=t.target&&t.target.closest?t.target.closest(".c-donut__slice"):null;if(s&&e.contains(s)){const r=parseInt(s.getAttribute("data-series")||"1",10);if("Enter"===t.key||" "===t.key){t.preventDefault();const e=parseInt(s.dataset.index||"0",10);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:r,index:e,value:s.getAttribute("data-title")||s.getAttribute("title")}}))}const i=Array.from(e.querySelectorAll('.c-donut__slice[data-series="'+r+'"]'));return void navKey(t,i,{wrap:!1,rtl:isRtl(this),onNavigate:t=>i.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}const i=t.target&&t.target.closest?t.target.closest(".c-chart__point"):null;if(!i||!e.contains(i))return;const a=parseInt(i.getAttribute("data-series")||"1",10),n=Array.from(e.querySelectorAll('.c-chart__point[data-series="'+a+'"]'));n.indexOf(i);if("Enter"===t.key||" "===t.key){t.preventDefault();const e=parseInt(i.dataset.index||"0",10);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:a,index:e}}))}navKey(t,n,{wrap:!1,rtl:isRtl(this),onNavigate:t=>n.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}),this.addEventListener("keydown",t=>{if(t.target!==this)return;let e=0;try{e=JSON.parse(this.getAttribute("series")||"[]").length}catch(t){e=0}if(0===e)return;void 0===this._activeSeries&&(this._activeSeries=0);let r=this._activeSeries;const s="rtl"===(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase();if("ArrowRight"===t.key)r=s?Math.max(this._activeSeries-1,0):Math.min(this._activeSeries+1,e-1);else if("ArrowLeft"===t.key)r=s?Math.min(this._activeSeries+1,e-1):Math.max(this._activeSeries-1,0);else if("ArrowDown"===t.key)r=Math.min(this._activeSeries+1,e-1);else if("ArrowUp"===t.key)r=Math.max(this._activeSeries-1,0);else if("Home"===t.key)r=0;else{if("End"!==t.key)return"Enter"===t.key||" "===t.key?(t.preventDefault(),void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:this._activeSeries}}))):void 0;r=e-1}r!==this._activeSeries&&(t.preventDefault(),this._activeSeries=r,this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:r}})))}),this.addEventListener("contour:clear-all",()=>{this.hasAttribute("brush")&&(this.removeAttribute("brush"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"chart",filter:{brush:null}}})),this.requestRender())})}}define("contour-chart",ContourChart);class ContourComparison extends ContourBase{static get observed(){return["divider","value","before","after","before-src","after-src"]}static get properties(){return{divider:{attribute:"divider"},value:{attribute:"value"},before:{attribute:"before"},after:{attribute:"after"},beforeSrc:{attribute:"before-src"},afterSrc:{attribute:"after-src"}}}render(){this.classList.add("c-comparison"),this.setAttribute("role","group");const t="Comparison",e=this.getAttribute("aria-label");null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t),this.style.blockSize||(this.style.blockSize="12rem");const r=this.getAttribute("value");this.style.setProperty("--comparison-pos",(r??"50")+"%");const s=this.getAttribute("before")??"Before",i=this.getAttribute("after")??"After";if(!this.querySelector(".c-comparison__pane--before")){const t=document.createElement("div");t.className="c-comparison__pane c-comparison__pane--before",this.appendChild(t)}if(!this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)")){const t=document.createElement("div");t.className="c-comparison__pane",this.appendChild(t)}const a=(t,e,r)=>{if(!t)return;let s=t.querySelector(".c-comparison__media--"+r);e?(s||(s=document.createElement("img"),s.className="c-comparison__media c-comparison__media--"+r,s.alt="",t.prepend(s)),s.getAttribute("src")!==e&&s.setAttribute("src",e)):s&&s.remove()};a(this.querySelector(".c-comparison__pane--before"),this.getAttribute("before-src"),"before"),a(this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)"),this.getAttribute("after-src"),"after");const n=this.querySelector(".c-comparison__pane--before");if(n){let t=n.querySelector(".c-comparison__label--before");t||(t=document.createElement("span"),t.className="c-comparison__label c-comparison__label--before",n.appendChild(t)),t.textContent=s}const o=this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)");if(o){let t=o.querySelector(".c-comparison__label--after");t||(t=document.createElement("span"),t.className="c-comparison__label c-comparison__label--after",o.appendChild(t)),t.textContent=i}const l=this.getAttribute("divider");if(null!==l){const t=this.ensure(".c-comparison__divider",()=>{const t=document.createElement("div");return t.className="c-comparison__divider",t.setAttribute("role","slider"),t.setAttribute("aria-orientation","vertical"),t.setAttribute("aria-valuemin","0"),t.setAttribute("aria-valuemax","100"),t.setAttribute("aria-valuenow",String(Math.round(parseFloat(r??"50")))),t.setAttribute("aria-label",labelText(this,"comparison-divider","Comparison divider")),t.setAttribute("tabindex","0"),t});l&&(t.textContent=l)}else{const t=this.querySelector(".c-comparison__divider");t&&t.remove()}}enhance(){if(this._wiredComparison)return;this._wiredComparison=!0;const t=()=>this.querySelector(".c-comparison__divider"),e=t=>{const e=Math.max(0,Math.min(100,t));this.style.setProperty("--comparison-pos",e+"%"),this.setAttribute("value",String(Math.round(e)));const r=this.querySelector(".c-comparison__divider");r&&r.setAttribute("aria-valuenow",String(Math.round(e))),this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:!0,composed:!0,detail:{value:e}}))};let r=!1;const s=t=>{if(!r)return;const s=this.getBoundingClientRect(),i=(t.clientX-s.left)/s.width*100;e(i)},i=()=>{r=!1,window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",i)};onDispose(this,()=>{r=!1,window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",i)}),this.addEventListener("pointerdown",s=>{const i=t();if(!i||!i.contains(s.target))return;r=!0;try{this.setPointerCapture(s.pointerId)}catch(t){}const a=this.getBoundingClientRect(),n=(s.clientX-a.left)/a.width*100;e(n),s.preventDefault()}),this.addEventListener("pointermove",t=>{if(!r)return;const s=this.getBoundingClientRect(),i=(t.clientX-s.left)/s.width*100;e(i)});const a=()=>{r=!1;try{this.releasePointerCapture&&this.releasePointerCapture(this._comparisonPointer)}catch(t){}this._comparisonPointer=null};this.addEventListener("pointerup",a),this.addEventListener("pointercancel",a),onDispose(this,()=>{this.removeEventListener("pointerup",a),this.removeEventListener("pointercancel",a)}),this.addEventListener("keydown",r=>{const s=t();if(!s||document.activeElement!==s)return;const i=parseFloat(this.style.getPropertyValue("--comparison-pos"))||50;"ArrowLeft"===r.key?(r.preventDefault(),e(i-5)):"ArrowRight"===r.key?(r.preventDefault(),e(i+5)):"Home"===r.key?(r.preventDefault(),e(0)):"End"===r.key&&(r.preventDefault(),e(100))})}}define("contour-comparison",ContourComparison);class ContourStreamingChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["line","dot","values","interval","pause","brownout","brownout-level","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{line:{attribute:"line"},dot:{attribute:"dot"},interval:{attribute:"interval",type:Number},pause:{attribute:"pause",type:Boolean},src:{attribute:"src"}}}get values(){return(this._valuesNums||[]).slice()}set values(t){this._pushedValues=capBuffer(Array.isArray(t)?t.map(Number).filter(Number.isFinite):[]),this.requestRender()}render(){this.classList.add("c-streaming-chart"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"streaming-chart","Streaming chart")),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");let t=this.querySelector(".c-streaming-chart__pause");t||(t=document.createElement("button"),t.className="c-btn c-btn--icon c-btn--ghost c-btn--sm c-streaming-chart__pause",t.type="button",this.appendChild(t));const e=!!this._streamPausedByUser;if(t.setAttribute("aria-pressed",String(e)),t.setAttribute("aria-label",e?labelText(this,"play-stream","Play stream"):labelText(this,"pause-stream","Pause stream")),setHTML(t,e?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-play" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-pause" /></svg>'),wireStates(this),loadRemote(this,["line","values"]),renderStates(this,"streaming-chart"))return;let r=remoteData(this,"line"),s=remoteData(this,"dot"),i=this._pushedValues;if(void 0===i){i=null;const t=remoteData(this,"values");if(t)try{const e=JSON.parse(t);Array.isArray(e)?i=e:warnBadJson(this,"values",new Error("not an array"))}catch(t){warnBadJson(this,"values",t)}}if(i=capBuffer((i||[]).map(Number).filter(Number.isFinite)),this._valuesNums=[],!r&&i.length>1&&(r=smoothPath(i,{width:300,height:192}),this._valuesNums=i,!s)){const t=polylinePoints(i,{width:300,height:192}).split(" ");s=t[t.length-1]}if(!r){const t=this.querySelector(":scope > .c-streaming-chart__plot");return t&&t.remove(),void renderEmpty(this,"streaming-chart")}if(r){let t=this.querySelector(":scope > .c-streaming-chart__plot");t||(t=document.createElementNS("http://www.w3.org/2000/svg","svg"),t.setAttribute("class","c-streaming-chart__plot"),t.setAttribute("viewBox","0 0 300 192"),t.setAttribute("aria-hidden","true"),this.appendChild(t));let e=t.querySelector(".c-streaming-chart__line");if(e||(e=document.createElementNS("http://www.w3.org/2000/svg","path"),e.setAttribute("class","c-streaming-chart__line"),t.appendChild(e)),e.setAttribute("d",r),s&&!this.shed("dot",2)){let e=t.querySelector(".c-streaming-chart__live-dot");e||(e=document.createElementNS("http://www.w3.org/2000/svg","circle"),e.setAttribute("class","c-streaming-chart__live-dot"),e.setAttribute("r","4"),t.appendChild(e));const r=s.split(/[ ,]+/);r.length>=2&&(e.setAttribute("cx",r[0]),e.setAttribute("cy",r[1]))}else{const e=t.querySelector(".c-streaming-chart__live-dot");e&&e.remove()}}}enhance(){const t=()=>{const t=parseFloat(this.getAttribute("interval")||""),e=Number.isFinite(t)&&t>0&&!this.hasAttribute("pause")&&!this._streamPausedByUser&&!1!==this._viewVisible;e!==this._streamRunning&&(this._streamRunning=e,void 0!==this._streamTimer&&(clearInterval(this._streamTimer),this._streamTimer=void 0),this.dispatchEvent(new CustomEvent("contour:stream-state",{detail:{running:e},bubbles:!0,composed:!0})),e&&(this._streamTimer=setInterval(()=>{if(!this.isConnected||this.hasAttribute("pause"))return;this._streamFrame+=1,this.dispatchEvent(new CustomEvent("contour:tick",{detail:{frame:this._streamFrame},bubbles:!0,composed:!0}));const t=this.getAttribute("src");t&&(remoteInvalidate(t),this.requestRender())},Math.max(1e3,1e3*t))))};t(),this._wiredStreamView||(this._wiredStreamView=!0,this._viewVisible=!0,watchViewport(this),this.addEventListener("contour:view-enter",()=>{this._viewVisible=!0,t()}),this.addEventListener("contour:view-leave",()=>{this._viewVisible=!1,t()})),this._wiredStream||(this._wiredStream=!0,this._streamFrame=0,onDispose(this,()=>{void 0!==this._streamTimer&&(clearInterval(this._streamTimer),this._streamTimer=void 0)}),this._streamPausedByUser=!1,this.addEventListener("click",e=>{const r=e.target,s=this.querySelector(".c-streaming-chart__pause");s&&(r===s||s.contains(r))&&(e.preventDefault(),this._streamPausedByUser=!this._streamPausedByUser,s.setAttribute("aria-pressed",String(this._streamPausedByUser)),s.setAttribute("aria-label",this._streamPausedByUser?"Play stream":"Pause stream"),setHTML(s,this._streamPausedByUser?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-play" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-pause" /></svg>'),this._streamPausedByUser?(this.setAttribute("data-user-paused",""),this.setAttribute("data-motion","paused")):(this.removeAttribute("data-user-paused"),this.removeAttribute("data-motion")),t())}),this.addEventListener("keydown",e=>{if(" "===e.key||"Enter"===e.key){e.preventDefault(),this._streamPausedByUser=!this._streamPausedByUser,this._streamPausedByUser?(this.setAttribute("data-user-paused",""),this.setAttribute("data-motion","paused")):(this.removeAttribute("data-user-paused"),this.removeAttribute("data-motion"));const r=this.querySelector(".c-streaming-chart__pause");r&&(r.setAttribute("aria-pressed",String(this._streamPausedByUser)),r.setAttribute("aria-label",this._streamPausedByUser?"Play stream":"Pause stream")),t()}}))}}define("contour-streaming-chart",ContourStreamingChart);class ContourReferenceRule extends ContourBase{static get observed(){return["value","direction","label","band"]}static get properties(){return{value:{attribute:"value"},direction:{attribute:"direction"},label:{attribute:"label"},band:{attribute:"band"}}}render(){this.classList.add("c-reference-rule");const t=this.getAttribute("direction")||"horizontal";this.setAttribute("data-direction",t);let e=this.querySelector(".c-reference-rule__line");e||(e=document.createElement("div"),e.className="c-reference-rule__line",this.appendChild(e));const r=this.getAttribute("band");r?this.setAttribute("data-band",r):this.removeAttribute("data-band");const s=this.getAttribute("label");let i=this.querySelector(".c-reference-rule__label");s?(i||(i=document.createElement("span"),i.className="c-reference-rule__label",this.appendChild(i)),i.textContent=s):i&&i.remove()}}define("contour-reference-rule",ContourReferenceRule);class ContourMeter extends ContourBase{static get observed(){return["value","label","variant","min","max","low","high","optimum","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},variant:{attribute:"variant"},min:{attribute:"min"},max:{attribute:"max"},low:{attribute:"low"},high:{attribute:"high"},optimum:{attribute:"optimum"},src:{attribute:"src"}}}render(){if(this.classList.add("c-meter"),wireStates(this),loadRemote(this,["value","label"]),renderStates(this,"meter"))return;const t=remoteData(this,"value")||this._remoteData&&this._remoteData.value,e=remoteData(this,"label")||this._remoteData&&this._remoteData.label||"",r=this.getAttribute("variant");if(Array.from(this.classList).forEach(t=>{t.startsWith("c-meter--")&&this.classList.remove(t)}),r&&this.classList.add("c-meter--"+r),!t&&!e)return void renderEmpty(this,"meter");if(null===t)this.style.removeProperty("--meter-value");else{const e=parseFloat(t),r=parseFloat(this.getAttribute("min"))||0,s=parseFloat(this.getAttribute("max"))||100;if(Number.isFinite(e)){const t=s>r?Math.min(1,Math.max(0,(e-r)/(s-r))):0;this.style.setProperty("--meter-value",String(t))}else this.style.removeProperty("--meter-value")}const s=this.ensure(".c-meter__core",()=>{const t=document.createElement("span");return t.className="c-meter__core",t});let i=s.querySelector(".c-meter__value");i||(i=document.createElement("span"),i.className="c-meter__value",s.appendChild(i));const a=parseFloat(t),n=parseFloat(this.getAttribute("min"))||0,o=parseFloat(this.getAttribute("max"))||100,l=Number.isFinite(a)&&o>n?Math.min(1,Math.max(0,(a-n)/(o-n))):0;if(i.textContent=Math.round(100*l)+"%",e){(s.querySelector(".c-meter__label")||(()=>{const t=document.createElement("span");return t.className="c-meter__label",s.appendChild(t),t})()).textContent=e}this.hasAttribute("role")||this.setAttribute("role","meter"),e&&!this.hasAttribute("aria-label")&&this.setAttribute("aria-label",e);const c=Number.isFinite(a)?String(a):"0",u=this._meterAriaValue;this.hasAttribute("aria-valuenow")&&this.getAttribute("aria-valuenow")!==u||(this.setAttribute("aria-valuenow",c),this._meterAriaValue=c);const d=this.getAttribute("min"),h=this.getAttribute("max");null!==d?this.setAttribute("aria-valuemin",d):this.setAttribute("aria-valuemin",String(n)),null!==h?this.setAttribute("aria-valuemax",h):this.setAttribute("aria-valuemax",String(o));for(const t of["low","high","optimum"]){const e=this.getAttribute(t);null!==e?this.setAttribute("data-"+t,e):this.removeAttribute("data-"+t)}}}define("contour-meter",ContourMeter);class ContourDelta extends ContourBase{static get observed(){return["value","direction","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},direction:{attribute:"direction"},src:{attribute:"src"}}}render(){if(this.classList.add("c-delta"),wireStates(this),loadRemote(this,"value"),renderStates(this,"delta"))return;const t=remoteData(this,"value")||"";Array.from(this.classList).forEach(t=>{t.startsWith("c-delta--")&&this.classList.remove(t)});const e=this.getAttribute("direction")||this._remoteData&&this._remoteData.direction||"up";if(!t)return void renderEmpty(this,"delta");this.classList.add("c-delta--"+e);const r={up:"#i-arrow-up",down:"#i-arrow-down",flat:"#i-minus"}[e]||"#i-arrow-up";this.querySelectorAll("svg").forEach(t=>t.remove());const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("aria-hidden","true");const i=document.createElementNS("http://www.w3.org/2000/svg","use");i.setAttribute("href",r),s.appendChild(i),this.appendChild(s),this.appendChild(document.createTextNode(" "+t))}}define("contour-delta",ContourDelta);class ContourStat extends ContourBase{static get observed(){return["value","label","delta","unit","format","locale","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},delta:{attribute:"delta"},unit:{attribute:"unit"},format:{attribute:"format"},locale:{attribute:"locale"},src:{attribute:"src"}}}render(){if(this.classList.add("c-stat"),wireStates(this),loadRemote(this,["value","label"]),renderStates(this,"stat"))return;const t=remoteData(this,"value"),e=remoteData(this,"label"),r=this.getAttribute("delta");if(t){this.ensure(".c-stat__value",()=>{const t=document.createElement("div");return t.className="c-stat__value",t.setAttribute("aria-live","polite"),t}).textContent=formatValue(t,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit"))}else{const t=this.querySelector(".c-stat__value");t&&t.remove()}if(e){this.ensure(".c-stat__label",()=>{const t=document.createElement("div");return t.className="c-stat__label",t}).textContent=e}else{const t=this.querySelector(".c-stat__label");t&&t.remove()}if(r){this.ensure(".c-stat__delta",()=>{const t=document.createElement("div");return t.className="c-stat__delta",t}).textContent=r}else{const t=this.querySelector(".c-stat__delta");t&&t.remove()}const s=this.getAttribute("unit"),i=this.querySelector(".c-stat__value");if(i)if(s){let t=i.querySelector(".c-stat__unit");t||(t=document.createElement("span"),t.className="c-stat__unit",i.appendChild(t)),t.textContent=s}else{const t=i.querySelector(".c-stat__unit");t&&t.remove()}t||e||renderEmpty(this,"stat")}}define("contour-stat",ContourStat);class ContourGauge extends ContourBase{static get observed(){return["value","min","max","heading","thresholds","format","locale","unit","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","brownout","brownout-level","no-data-message","show-header","description","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},heading:{attribute:"heading"},thresholds:{attribute:"thresholds"},format:{attribute:"format"},locale:{attribute:"locale"},unit:{attribute:"unit"},src:{attribute:"src"},brownout:{attribute:"brownout"}}}render(){if(this.classList.add("c-gauge"),wireStates(this),loadRemote(this,["value"]),renderStates(this,"gauge"))return;const t=this.getAttribute("value"),e=parseFloat(t),r=null!==t&&""!==t&&Number.isFinite(e),s=Number.isFinite(parseFloat(this.getAttribute("min")))?parseFloat(this.getAttribute("min")):0,i=Number.isFinite(parseFloat(this.getAttribute("max")))?parseFloat(this.getAttribute("max")):100,a=this.getAttribute("heading"),n="false"!==this.getAttribute("show-header"),o=this.getAttribute("description"),l=this.getAttribute("no-data-message")||"No readings in view";this.brownoutLevel();if(!r){if(a&&n){this.ensure(".c-gauge__title",()=>{const t=document.createElement("div");return t.className="c-gauge__title",t}).textContent=a}return this.ensure(".c-gauge__empty",()=>{const t=document.createElement("div");return t.className="c-gauge__empty",t.setAttribute("part","empty"),t}).textContent=l,void[".c-gauge__dial",".c-gauge__value",".c-gauge__band"].forEach(t=>{const e=this.querySelector(t);e&&e.remove()})}if(a&&n){this.ensure(".c-gauge__title",()=>{const t=document.createElement("div");return t.className="c-gauge__title",t.setAttribute("part","title"),t}).textContent=a}else{const t=this.querySelector(".c-gauge__title");t&&t.remove()}let c=[];const u=this.getAttribute("thresholds");if(u)try{const t=JSON.parse(u);Array.isArray(t)?c=t:warnBadJson(this,"thresholds",new Error("not an array"))}catch(t){c=[]}let d=null;if(c&&c.length){const t=[...c].sort((t,e)=>(t.value||0)-(e.value||0));for(let r=t.length-1;r>=0;r--)if(e>=(t[r].value||0)){d=t[r];break}}const h=this.shed("dial",3);let m=this.querySelector(".c-gauge__dial");if(h)m&&m.remove();else{m||(m=document.createElementNS("http://www.w3.org/2000/svg","svg"),m.setAttribute("class","c-gauge__dial"),m.setAttribute("part","dial"),m.setAttribute("aria-hidden","true"),m.setAttribute("viewBox","0 0 100 100"),this.appendChild(m)),m.innerHTML="";const t=document.createElementNS("http://www.w3.org/2000/svg","path");if(t.setAttribute("class","c-gauge__track"),t.setAttribute("d","M 10 90 A 40 40 0 0 1 90 90"),m.appendChild(t),c&&c.length){const t=[...c].sort((t,e)=>(t.value||0)-(e.value||0)),e=t=>{const e=(1-(t-s)/(i-s||1))*Math.PI;return{x:50+40*Math.cos(e),y:90-40*Math.sin(e)}};for(let r=0;r<t.length;r++){const s=t[r].value||0,a=r+1<t.length&&t[r+1].value||i,n=e(s),o=e(a),l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("class","c-gauge__zone"),l.setAttribute("stroke",t[r].color||"var(--color-primary)"),l.setAttribute("d","M "+n.x.toFixed(2)+" "+n.y.toFixed(2)+" A 40 40 0 0 1 "+o.x.toFixed(2)+" "+o.y.toFixed(2)),m.appendChild(l)}}const r=Math.max(0,Math.min(1,(e-s)/(i-s||1))),a=Math.PI*(1-r),n=document.createElementNS("http://www.w3.org/2000/svg","line");n.setAttribute("class","c-gauge__needle needle"),n.setAttribute("x1","50"),n.setAttribute("y1","90"),n.setAttribute("x2",String(50+35*Math.cos(a))),n.setAttribute("y2",String(90-35*Math.sin(a))),m.appendChild(n);const o=document.createElementNS("http://www.w3.org/2000/svg","circle");o.setAttribute("class","c-gauge__hub hub"),o.setAttribute("cx","50"),o.setAttribute("cy","90"),o.setAttribute("r","4"),m.appendChild(o)}const b=this.ensure(".c-gauge__value",()=>{const t=document.createElement("div");return t.className="c-gauge__value",t.setAttribute("part","value"),t});b.textContent=formatValue(String(e),this.getAttribute("format"),this.getAttribute("locale"))+(this.getAttribute("unit")?" "+this.getAttribute("unit"):""),b.setAttribute("role","meter");const p=Math.max(s,Math.min(i,e));b.setAttribute("aria-valuenow",String(p)),b.setAttribute("aria-valuemin",String(s)),b.setAttribute("aria-valuemax",String(i)),a&&(b.id||(b.id=contourId("gauge-value"))),d?b.setAttribute("aria-valuetext",e+", "+(d.label||">= "+d.value)):b.setAttribute("aria-valuetext",String(e));const g=this.querySelector(".c-gauge__title");g?(g.id||(g.id=contourId("gauge-title")),b.setAttribute("aria-labelledby",g.id),b.removeAttribute("aria-label")):(b.removeAttribute("aria-labelledby"),a?b.setAttribute("aria-label",a):b.setAttribute("aria-label",b.textContent||"Gauge"));const _=this.querySelector(".c-gauge__band");if(d){this.ensure(".c-gauge__band",()=>{const t=document.createElement("div");return t.className="c-gauge__band",t.setAttribute("part","band"),t}).textContent=d.label||">= "+d.value}else _&&_.remove();if(o){let t=this.querySelector(".c-gauge__desc");t||(t=document.createElement("div"),t.className="c-gauge__desc",this.appendChild(t)),t.textContent=o}}enhance(){}}define("contour-gauge",ContourGauge);class ContourAxis extends ContourBase{static get observed(){return["orientation","values","ticks","format","locale","min","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{orientation:{attribute:"orientation"},values:{attribute:"values"},ticks:{attribute:"ticks"},format:{attribute:"format"},locale:{attribute:"locale"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}render(){this.classList.add("c-axis"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"axis","Axis"));const t=this.getAttribute("orientation")||"horizontal";if(this.classList.toggle("c-axis--horizontal","horizontal"===t),this.classList.toggle("c-axis--vertical","vertical"===t),"horizontal"===t?this.setAttribute("part","axis-x"):this.setAttribute("part","axis-y"),wireStates(this),loadRemote(this,["values"]),renderStates(this,"axis"))return;let e=[];const r=this.getAttribute("values");if(r)try{e=JSON.parse(r)}catch(t){e=r.split(",").map(t=>t.trim())}const s=parseInt(this.getAttribute("ticks")||"0",10)||e.length,i=Array.from(this.querySelectorAll(":scope > .c-axis__tick"));if(this.classList.toggle("c-axis--value-ticks",!i.length),i.length)i.forEach(t=>{const e=t.querySelector(".c-axis__label");e&&!e.textContent&&(e.textContent=t.textContent)});else{Array.from(this.querySelectorAll(".c-axis__tick")).forEach(t=>t.remove());const t=e.length?e:Array.from({length:s},(t,e)=>e),r=t.map(t=>Number(t)).filter(Number.isFinite);let i=r.length?Math.min(...r):0,a=r.length?Math.max(...r):0;const n=parseFloat(this.getAttribute("min")),o=parseFloat(this.getAttribute("max"));Number.isFinite(n)&&(i=n),Number.isFinite(o)&&(a=o);const l=a-i||1;t.forEach(t=>{const e=document.createElement("span");e.className="c-axis__tick";const r=document.createElement("span");r.className="c-axis__label",r.textContent=formatValue(String(t),this.getAttribute("format"),this.getAttribute("locale")),e.appendChild(r);const s=Number(t);e.style.setProperty("--tick-pos",Number.isFinite(s)?(s-i)/l*100+"%":"0%"),this.appendChild(e)})}}enhance(){}}define("contour-axis",ContourAxis);class ContourBrush extends ContourBase{static get observed(){return["start","end","min","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},min:{attribute:"min"},max:{attribute:"max"},src:{attribute:"src"}}}_rangeValue(){const t=parseFloat(this.getAttribute("start")),e=parseFloat(this.getAttribute("end"));return Number.isFinite(t)&&Number.isFinite(e)?[t,e]:null}_brushDetail(){const t=this._rangeValue();return{start:t?t[0]:null,end:t?t[1]:null,value:t?t[1]:null,range:t}}render(){if(this.classList.add("c-brush"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"brush-selection","Brush selection")),wireStates(this),loadRemote(this,[]),renderStates(this,"brush"))return;let t=this.querySelector(".c-brush__selection");t||(t=document.createElement("div"),t.className="c-brush__selection",this.appendChild(t));const e=parseFloat(this.getAttribute("start")||"0"),r=parseFloat(this.getAttribute("end")||"100"),s=parseFloat(this.getAttribute("min")||"0"),i=parseFloat(this.getAttribute("max")||"100"),a=i-s||1,n=(e-s)/a*100,o=(r-e)/a*100;t.style.insetInlineStart=n+"%",t.style.inlineSize=o+"%",["start","end"].forEach(t=>{let n=this.querySelector(".c-brush__handle--"+t);n||(n=document.createElement("div"),n.className="c-brush__handle c-brush__handle--"+t,this.appendChild(n));const o="start"===t?e:r;n.style.insetInlineStart=(o-s)/a*100+"%",n.setAttribute("role","slider"),n.setAttribute("tabindex","0"),n.setAttribute("aria-valuemin",String(s)),n.setAttribute("aria-valuemax",String(i)),n.setAttribute("aria-valuenow",String(o)),n.setAttribute("aria-label","start"===t?"Start":"End")})}enhance(){if(this._wiredBrush)return;this._wiredBrush=!0;let t=null;const e=()=>parseFloat(this.getAttribute("min")||"0"),r=()=>parseFloat(this.getAttribute("max")||"100"),s=t=>{const s=this.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-s.left)/(s.width||1)));return e()+i*(r()-e())};this.addEventListener("pointerdown",e=>{const r=e.target&&e.target.classList&&e.target.classList.contains("c-brush__handle")?e.target:null;t=r?r.classList.contains("c-brush__handle--start")?"start":"end":"move";try{this.setPointerCapture(e.pointerId)}catch(t){}this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:!0,composed:!0,detail:this._brushDetail()}))}),this.addEventListener("pointermove",i=>{if(!t)return;const a=s(i.clientX),n=e(),o=r(),l=o-n||1,c=this.querySelector(".c-brush__selection");let u=parseFloat(this.getAttribute("start")||"0"),d=parseFloat(this.getAttribute("end")||"100");if("start"===t)u=Math.min(a,d);else if("end"===t)d=Math.max(a,u);else{const t=d-u;u=a-t/2,d=a+t/2,u<n&&(d+=n-u,u=n),d>o&&(u-=d-o,d=o)}u=Math.max(n,Math.min(o,u)),d=Math.max(n,Math.min(o,d)),c&&(c.style.insetInlineStart=(u-n)/l*100+"%",c.style.inlineSize=(d-u)/l*100+"%");const h=this.querySelector(".c-brush__handle--start"),m=this.querySelector(".c-brush__handle--end");h&&(h.style.insetInlineStart=(u-n)/l*100+"%"),m&&(m.style.insetInlineStart=(d-n)/l*100+"%"),this._brushPending={start:u,end:d},this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:!0,composed:!0,detail:{start:u,end:d,value:u,range:[u,d]}}))}),this.addEventListener("pointerup",e=>{if(!t)return;t=null;const r=this._brushPending;r&&(this.setAttribute("start",String(r.start)),this.setAttribute("end",String(r.end)),this._brushPending=null),this.dispatchEvent(new CustomEvent("contour:brush-end",{bubbles:!0,composed:!0,detail:this._brushDetail()})),this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:!0,composed:!0,detail:this._brushDetail()}))}),this.addEventListener("pointercancel",()=>{t&&(t=null,this._brushPending=null,this.requestRender())}),this.addEventListener("keydown",t=>{const s=t.target&&t.target.classList&&t.target.classList.contains("c-brush__handle")?t.target:null,i=s?s.classList.contains("c-brush__handle--start")?"start":"end":null,a=e(),n=r(),o=(n-a)/100||1;let l=parseFloat(this.getAttribute("start")||"0"),c=parseFloat(this.getAttribute("end")||"100");if("Enter"===t.key||" "===t.key)return t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:!0,composed:!0,detail:this._brushDetail()})),void this.dispatchEvent(new CustomEvent("contour:brush-end",{bubbles:!0,composed:!0,detail:this._brushDetail()}));let u=!0;if("ArrowLeft"===t.key||"ArrowDown"===t.key)if("start"===i)l-=o;else if("end"===i)c-=o;else{const t=c-l;l-=o,c=l+t}else if("ArrowRight"===t.key||"ArrowUp"===t.key)if("start"===i)l+=o;else if("end"===i)c+=o;else{const t=c-l;c+=o,l=c-t}else"Home"===t.key?"end"===i?c=l:l=a:"End"===t.key?"start"===i?l=c:c=n:u=!1;if(u){if(t.preventDefault(),l=Math.max(a,Math.min(n,l)),c=Math.max(a,Math.min(n,c)),l>c){const t=l;l=c,c=t}this.dispatchEvent(new CustomEvent("contour:brush-start",{bubbles:!0,composed:!0,detail:this._brushDetail()})),this.setAttribute("start",String(l)),this.setAttribute("end",String(c)),this.dispatchEvent(new CustomEvent("contour:brush",{bubbles:!0,composed:!0,detail:this._brushDetail()})),this.dispatchEvent(new CustomEvent("contour:brush-end",{bubbles:!0,composed:!0,detail:this._brushDetail()}))}}),this.addEventListener("contour:clear-all",()=>{(this.hasAttribute("start")||this.hasAttribute("end"))&&(this.removeAttribute("start"),this.removeAttribute("end"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"brush",filter:{start:null,end:null}}})),this.requestRender())})}}define("contour-brush",ContourBrush);class ContourStackedBar extends ContourBase{static get observed(){return["segments","values","colors","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","max","no-cache"]}static get properties(){return{segments:{attribute:"segments"},values:{attribute:"values"},colors:{attribute:"colors"},src:{attribute:"src"},max:{attribute:"max"}}}render(){if(this.classList.add("c-stacked-bar"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"stacked-bar","Stacked bar")),wireStates(this),loadRemote(this,["segments","values"]),renderStates(this,"stacked-bar"))return;Array.from(this.querySelectorAll(".c-stacked-bar__segment")).forEach(t=>t.remove());const t=Array.from(this.querySelectorAll(":scope > .c-stacked-bar__segment"));let e=[];if(t.length)e=t.map(t=>({label:t.getAttribute("data-title")||t.getAttribute("title")||t.textContent||"",value:parseFloat(t.style.inlineSize)||0,color:t.dataset&&t.dataset.color||t.style.background||void 0})),t.forEach(t=>t.remove());else{this.getAttribute("segments")&&(e=parseArrayAttr(this,"segments",warnBadJson))}const r=e.map(t=>"object"==typeof t?t.value||0:Number(t)||0),s=r.some(t=>t<0),i=r.filter(t=>t>0).reduce((t,e)=>t+e,0),a=Math.abs(r.filter(t=>t<0).reduce((t,e)=>t+e,0)),n=i+a,o=Math.max(i,a,1),l=Math.max(1,parseFloat(this.getAttribute("max"))||(s?o:n));this.querySelectorAll(".c-stacked-bar__track").forEach(t=>t.remove());const c=(t,e,s)=>{const i=r[e],a=document.createElement("div");a.className="c-stacked-bar__segment"+(0===i?" c-stacked-bar__segment--zero":""),a.style.inlineSize=s+"%",a.style.background=safeColor("object"==typeof t&&t.color?t.color:"var(--chart-"+(e%8+1)+")"),a.dataset.color="object"==typeof t&&t.color?t.color:a.style.background;const n="object"==typeof t&&t.label||"";return a.setAttribute("data-title",n+" "+i),a.setAttribute("role","img"),a.setAttribute("aria-label",(n?n+": ":"")+i),a};if(s){this.classList.add("c-stacked-bar--diverging");const t=document.createElement("div");t.className="c-stacked-bar__track c-stacked-bar__track--neg";const s=document.createElement("div");s.className="c-stacked-bar__track",e.forEach((e,i)=>{const a=r[i];if(0===a)return;const n=Math.abs(a)/l*100;(a<0?t:s).appendChild(c(e,i,n))}),this.appendChild(t),this.appendChild(s)}else{this.classList.remove("c-stacked-bar--diverging");const t=document.createElement("div");t.className="c-stacked-bar__track",e.forEach((e,s)=>t.appendChild(c(e,s,r[s]/l*100))),this.appendChild(t)}e.length||renderEmpty(this,"stacked-bar")}enhance(){}}define("contour-stacked-bar",ContourStackedBar);class ContourCategory extends ContourBase{static get observed(){return["items","search","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","note","limit","sort","format","locale","unit","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"},note:{attribute:"note"},limit:{attribute:"limit"},sort:{attribute:"sort"},format:{attribute:"format"},locale:{attribute:"locale"},unit:{attribute:"unit"}}}render(){if(this.classList.add("c-category"),this.setAttribute("role","listbox"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"category","Category")),wireStates(this),loadRemote(this,["items"]),renderStates(this,"category"))return;Array.from(this.querySelectorAll(".c-category__item")).forEach(t=>t.remove());const t=Array.from(this.querySelectorAll(":scope > .c-category__item"));let e=[];if(t.length)t.forEach(t=>{const r=t.querySelector(".c-category__label");e.push({label:r?r.textContent:t.textContent,value:0})}),t.forEach(t=>t.remove());else{this.getAttribute("items")&&(e=parseArrayAttr(this,"items",warnBadJson))}const r=this.getAttribute("sort")||"value-desc";e.sort((t,e)=>{const s="object"==typeof t?t.value||0:Number(t)||0,i="object"==typeof e?e.value||0:Number(e)||0,a="object"==typeof t?t.label||t.name||"":String(t),n="object"==typeof e?e.label||e.name||"":String(e);return"value-asc"===r?s-i:"alpha-asc"===r?String(a).localeCompare(String(n)):"alpha-desc"===r?String(n).localeCompare(String(a)):i-s});const s=parseInt(this.getAttribute("limit")||"0",10);s>0&&(e=e.slice(0,s));const i=e.reduce((t,e)=>Math.max(t,Math.abs("object"==typeof e?e.value||0:Number(e)||0)),0)||1;e.forEach((t,e)=>{const r="object"==typeof t?t.value||0:Number(t)||0,s="object"==typeof t?t.label||t.name||"":String(t),a=document.createElement("div");a.className="c-category__item",a.setAttribute("role","option"),a.setAttribute("aria-selected","false"),a.setAttribute("tabindex",0===e?"0":"-1");const n=document.createElement("span");n.className="c-category__label",n.textContent=s;const o=document.createElement("div");o.style.flex="1";const l=document.createElement("div");l.className="c-category__bar",l.style.inlineSize=Math.abs(r)/i*100+"%",o.appendChild(l);const c=document.createElement("span");c.className="c-category__value",c.textContent=formatValue(r,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit")),a.appendChild(n),a.appendChild(o),a.appendChild(c),this.appendChild(a)}),e.length||renderEmpty(this,"category");const a=this.getAttribute("note");let n=this.querySelector(".c-category__note");a?(n||(n=document.createElement("div"),n.className="c-category__note",this.appendChild(n)),n.textContent=a):n&&n.remove()}enhance(){if(this._wiredCategory)return;this._wiredCategory=!0;const t=()=>Array.from(this.querySelectorAll(".c-category__item"));this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!r||!this.contains(r))return;const s=t(),i=s.indexOf(r);s.forEach((t,e)=>t.setAttribute("aria-selected",e===i?"true":"false")),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:i,label:r.querySelector(".c-category__label")?r.querySelector(".c-category__label").textContent:r.textContent.trim()}}))}),this.addEventListener("keydown",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!r||!this.contains(r))return;const s=t(),i=s.indexOf(r);if("Enter"===e.key||" "===e.key)return e.preventDefault(),s.forEach((t,e)=>t.setAttribute("aria-selected",e===i?"true":"false")),void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:i,label:r.querySelector(".c-category__label")?r.querySelector(".c-category__label").textContent:r.textContent.trim()}}));navKey(e,s,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>s.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{if("Enter"===e.key||" "===e.key){const t=s.indexOf(document.activeElement);s.forEach((e,r)=>e.setAttribute("aria-selected",r===t?"true":"false")),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:t,label:document.activeElement.querySelector(".c-category__label")?document.activeElement.querySelector(".c-category__label").textContent:document.activeElement.textContent.trim()}}))}}})}),this.addEventListener("contour:clear-all",()=>{this.hasAttribute("search")&&(this.removeAttribute("search"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"category",filter:{search:null}}})))})}}define("contour-category",ContourCategory);class ContourDonut extends ContourBase{static get observed(){return["value","values","items","label","color","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","brownout","brownout-level","note","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},values:{attribute:"values"},items:{attribute:"items"},label:{attribute:"label"},color:{attribute:"color"},src:{attribute:"src"},note:{attribute:"note"}}}render(){if(this.classList.add("c-donut"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"donut-chart","Donut chart")),wireStates(this),loadRemote(this,["items","values"]),renderStates(this,"donut"))return;Array.from(this.querySelectorAll(".c-donut__ring, .c-donut__center, .c-donut__list, .c-donut__empty")).forEach(t=>t.remove());const t=Array.from(this.querySelectorAll(":scope > .c-donut__item"));let e=[];if(t.length)t.forEach(t=>{const r=t.querySelector(".c-donut__swatch"),s=t.querySelector("span:last-child"),i=s?s.textContent:t.textContent,a=i.match(/—\s*(\d+(?:\.\d+)?)$/);e.push({label:i.replace(/—\s*\d+(?:\.\d+)?$/,"").trim(),value:a?Number(a[1]):0,color:r?r.dataset&&r.dataset.color||r.style.background:void 0})}),t.forEach(t=>t.remove());else{this.getAttribute("items")&&(e=parseArrayAttr(this,"items",warnBadJson))}const r=e.map(t=>"object"==typeof t?t.value||0:Number(t)||0),s=r.reduce((t,e)=>t+(e>0?e:0),0)||1,i=(this.brownoutLevel(),this.getAttribute("color"));if(!this.shed("ring",3)){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("class","c-donut__ring"),t.setAttribute("viewBox","0 0 32 32"),t.setAttribute("role","img");const s=this.getAttribute("label")||"Donut chart";t.setAttribute("aria-label",s);donutSlices(r,{cx:16,cy:16,r:15,inner:9,gap:.03}).forEach((r,s)=>{const a=e[r.index],n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("class","c-donut__slice"),n.setAttribute("d",r.path),n.setAttribute("fill","var(--c, var(--chart-1))"),n.style.setProperty("--c",safeColor(i||("object"==typeof a&&a.color?a.color:"var(--chart-"+(r.index%8+1)+")"))||"var(--chart-1)"),n.dataset.index=String(r.index);const o=("object"==typeof a?a.label||"":String(a))+" — "+r.value;n.setAttribute("data-title",o),n.setAttribute("aria-label",o),n.setAttribute("tabindex",0===s?"0":"-1"),n.setAttribute("role","button"),t.appendChild(n)}),this.appendChild(t)}const a=document.createElement("div");a.className="c-donut__center",a.textContent=this.getAttribute("value")??String(s),this.appendChild(a);const n=document.createElement("div");n.className="c-donut__list",n.setAttribute("role","list"),e.forEach((t,e)=>{const s=document.createElement("div");s.className="c-donut__item",s.setAttribute("role","listitem");const a=document.createElement("span");a.className="c-donut__swatch",a.style.background=safeColor(i||("object"==typeof t&&t.color?t.color:"var(--chart-"+(e%8+1)+")")),a.style.background&&(a.dataset.color=i||("object"==typeof t&&t.color?t.color:a.style.background)),s.appendChild(a);const o=document.createElement("span");o.textContent=("object"==typeof t?t.label||"":String(t))+" — "+r[e],s.appendChild(o),n.appendChild(s)}),this.appendChild(n),e.length||renderEmpty(this,"donut");const o=this.getAttribute("note");let l=this.querySelector(".c-donut__note");o?(l||(l=document.createElement("div"),l.className="c-donut__note",this.appendChild(l)),l.textContent=o):l&&l.remove()}enhance(){if(this._wiredDonut)return;this._wiredDonut=!0;const t=()=>Array.from(this.querySelectorAll(".c-donut__slice")),e=t=>{const e=Number(t.dataset.index);Number.isFinite(e)&&this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:1,index:e,value:t.getAttribute("data-title")||t.getAttribute("title")}}))};this.addEventListener("keydown",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-donut__slice"):null;if(!s||!this.contains(s))return;const i=t(),a=i.indexOf(s);let n=-1;if("ArrowRight"===r.key||"ArrowDown"===r.key)n=Math.min(a+1,i.length-1);else if("ArrowLeft"===r.key||"ArrowUp"===r.key)n=Math.max(a-1,0);else if("Home"===r.key)n=0;else if("End"===r.key)n=i.length-1;else if("Enter"===r.key||" "===r.key)return r.preventDefault(),void e(s);if(n>=0&&n!==a){r.preventDefault(),i.forEach((t,e)=>t.setAttribute("tabindex",e===n?"0":"-1"));try{i[n].focus()}catch(t){}}}),this.addEventListener("click",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-donut__slice"):null;r&&this.contains(r)&&e(r)})}}define("contour-donut",ContourDonut);class ContourTimeSeries extends ContourBase{static get observed(){return["values","points","series","series-style","title","brownout","brownout-level","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","note","cache-key","no-cache"]}static get properties(){return{values:{attribute:"values"},points:{attribute:"points"},series:{attribute:"series"},src:{attribute:"src"},note:{attribute:"note"}}}render(){if(this.classList.add("c-time-series"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Time series"),wireStates(this),loadRemote(this,["values","points","series"]),renderStates(this,"time-series"))return;this.ensure(".c-time-series__tooltip",()=>{const t=document.createElement("div");return t.className="c-time-series__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t.id=contourId("timeseries-tip"),t}),Array.from(this.querySelectorAll(".c-time-series__plot, .c-time-series__axis")).forEach(t=>t.remove());let t=[];this.getAttribute("series")&&(t=parseArrayAttr(this,"series",warnBadJson));const e=remoteData(this,"series");if(Array.isArray(e)&&(t=e),!t.length){let e=[];if(this.getAttribute("values")&&(e=parseArrayAttr(this,"values",warnBadJson)),e.length){const r=(this.getAttribute("style")||"").trim().toLowerCase();t=[{label:"Series 1",values:e,style:this.getAttribute("series-style")||("line"===r||"bar"===r?r:"bar"),color:"var(--chart-1)"}]}}const r=t.reduce((t,e)=>{const r=Array.isArray(e.values)?Math.max(...e.values,0):0;return Math.max(t,r)},1),s=t.reduce((t,e)=>{const r=Array.isArray(e.values)?Math.min(...e.values,0):0;return Math.min(t,r)},0),i=document.createElement("div");i.className="c-time-series__plot",i.setAttribute("part","plot");const a=[];t.forEach((t,e)=>{const n=Array.isArray(t.values)?t.values:[],o=t.style||"bar",l=t.color||`var(--chart-${e%8+1})`,c=t.label||`Series ${e+1}`;if("line"===o){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 300 120"),t.setAttribute("preserveAspectRatio","none"),t.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%";const a=r-s||1,o=n.length||1,u=n.map((t,e)=>{const r=e/Math.max(1,o-1)*300,i=120-(t-s)/a*120;return r.toFixed(2)+","+i.toFixed(2)}).join(" "),d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("class","c-time-series__line"),d.setAttribute("data-series",String(e+1)),d.setAttribute("d","M "+u.replace(/ /g," L ")),d.style.stroke=l,d.style.fill="none",d.style.strokeWidth="2",t.appendChild(d),n.forEach((r,i)=>{const n=i/Math.max(1,o-1)*300,l=120-(r-s)/a*120,u=document.createElementNS("http://www.w3.org/2000/svg","circle");u.setAttribute("class","c-time-series__point"),u.setAttribute("data-series",String(e+1)),u.setAttribute("data-index",String(i)),u.setAttribute("cx",n.toFixed(2)),u.setAttribute("cy",l.toFixed(2)),u.setAttribute("r","3"),u.setAttribute("tabindex",0===i&&0===e?"0":"-1"),u.setAttribute("role","button"),u.setAttribute("data-title",String(r)),u.setAttribute("aria-label",c+": "+String(r)),t.appendChild(u)}),i.appendChild(t)}else n.forEach((t,s)=>{const i=document.createElement("div");i.className="c-time-series__bar",i.setAttribute("data-series",String(e+1)),i.setAttribute("data-index",String(s)),i.style.blockSize=t/r*100+"%",i.style.background=safeColor(l),i.setAttribute("data-title",String(t)),i.setAttribute("role","button"),i.setAttribute("aria-label",c+": "+String(t)),i.setAttribute("tabindex",0===s&&0===e?"0":"-1"),(a[s]||(a[s]=[])).push(i)})}),a.forEach(t=>{t&&t.forEach(t=>i.appendChild(t))}),this.appendChild(i);const n=t.find(t=>Array.isArray(t.values)&&t.values.length),o=n?n.values.length:0;if(o>1){const t=document.createElement("div");t.className="c-time-series__axis";const e=n.x;[0,Math.floor((o-1)/2),o-1].filter((t,e,r)=>t>=0&&r.indexOf(t)===e).forEach(r=>{const s=document.createElement("span");s.className="c-time-series__tick",s.textContent=Array.isArray(e)&&null!=e[r]?String(e[r]):String(r),t.appendChild(s)}),this.appendChild(t)}t.length&&t.some(t=>Array.isArray(t.values)&&t.values.length)||renderEmpty(this,"time-series");const l=this.getAttribute("note");let c=this.querySelector(".c-time-series__note");l&&!this.shed("note",2)?(c||(c=document.createElement("div"),c.className="c-time-series__note",this.appendChild(c)),c.textContent=l):c&&c.remove();const u=this.querySelector(".c-time-series__axis");u&&(u.style.display=this.shed("axis",3)?"none":"")}enhance(){if(this._wiredTimeSeries)return;this._wiredTimeSeries=!0;const t=()=>Array.from(this.querySelectorAll(".c-time-series__bar")),e=()=>Array.from(this.querySelectorAll(".c-time-series__point"));this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-time-series__bar"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.series||"0"),s=Number(e.dataset.index||"0");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:r,index:s,value:e.getAttribute("data-title")||e.getAttribute("title")}}))});this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-time-series__point"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.series||"0"),s=Number(e.dataset.index||"0");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:r,index:s,value:e.getAttribute("data-title")||e.getAttribute("title")}}))}),this.addEventListener("keydown",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-time-series__bar"):null,i=r.target&&r.target.closest?r.target.closest(".c-time-series__point"):null,a=s||i;if(!a||!this.contains(a))return;const n=s?t():e(),o=n.indexOf(a);if("Enter"===r.key||" "===r.key){r.preventDefault();const t=Number(a.dataset.series||"0");return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:o,value:a.getAttribute("data-title")||a.getAttribute("title")}}))}navKey(r,n,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>n.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}),this.addEventListener("focusin",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-time-series__bar"):null;if(e&&this.contains(e)){const t=this.querySelector(".c-time-series__tooltip");t&&(t.textContent=e.getAttribute("data-title")||e.getAttribute("title"),t.removeAttribute("hidden"),t.id&&e.setAttribute("aria-describedby",t.id))}const r=t.target&&t.target.closest?t.target.closest(".c-time-series__point"):null;if(r&&this.contains(r)){const t=this.querySelector(".c-time-series__tooltip");t&&(t.textContent=r.getAttribute("data-title")||r.getAttribute("title"),t.removeAttribute("hidden"),t.id&&r.setAttribute("aria-describedby",t.id))}}),this.addEventListener("focusout",t=>{const e=(t.target&&t.target.closest?t.target.closest(".c-time-series__bar"):null)||(t.target&&t.target.closest?t.target.closest(".c-time-series__point"):null);e&&this.contains(e)&&e.removeAttribute("aria-describedby");const r=this.querySelector(".c-time-series__tooltip");r&&!this.contains(t.relatedTarget)&&r.setAttribute("hidden","")})}}define("contour-time-series",ContourTimeSeries);class ContourPivot extends ContourBase{static get observed(){return["rows","columns","values","data","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","filter","aggregate","cache-key","no-cache"]}static get properties(){return{rows:{attribute:"rows"},columns:{attribute:"columns"},values:{attribute:"values"},data:{attribute:"data"},src:{attribute:"src"},filter:{attribute:"filter"},aggregate:{attribute:"aggregate"}}}_aggregateFn(t){const e=(t||"sum").toLowerCase();return"avg"===e||"average"===e||"mean"===e?t=>t.length?t.reduce((t,e)=>t+e,0)/t.length:0:"count"===e?t=>t.length:"min"===e?t=>t.length?Math.min(...t):0:"max"===e?t=>t.length?Math.max(...t):0:t=>t.reduce((t,e)=>t+e,0)}render(){if(this.classList.add("c-pivot"),wireStates(this),loadRemote(this,["data"]),renderStates(this,"pivot"))return;Array.from(this.querySelectorAll("table, .c-pivot__wrap, .c-pivot__toolbar, .c-pivot__empty")).forEach(t=>t.remove());let t=[];const e=this.getAttribute("data");if(e)try{t=JSON.parse(e)}catch(e){warnBadJson(this,"data",e),t=[]}const r=this.getAttribute("rows")?this.getAttribute("rows").split(",").map(t=>t.trim()).filter(Boolean):[],s=this.getAttribute("columns")?this.getAttribute("columns").split(",").map(t=>t.trim()).filter(Boolean):[],i=this.getAttribute("aggregate")||"sum",a=this._aggregateFn(i),n=(this.getAttribute("filter")||"").toLowerCase().trim(),o=document.createElement("div");o.className="c-pivot__toolbar",o.style.display="flex";const l=document.createElement("input");l.type="search",l.className="c-input c-pivot__filter",l.placeholder=labelText(this,"filter","Filter…"),l.value=this.getAttribute("filter")||"",l.setAttribute("aria-label",labelText(this,"filter-pivot","Filter pivot"));const c=document.createElement("select");c.className="c-select c-pivot__aggregate",c.setAttribute("aria-label",labelText(this,"aggregation","Aggregation")),["sum","avg","count","min","max"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t,t===i&&(e.selected=!0),c.appendChild(e)}),o.appendChild(l),o.appendChild(c),this.appendChild(o);let u=r,d=s;if(n&&(u=r.filter(e=>e.toLowerCase().includes(n)||t.some(t=>t.row===e&&String(t.value).toLowerCase().includes(n))),d=s.filter(e=>e.toLowerCase().includes(n)||t.some(t=>t.col===e&&String(t.value).toLowerCase().includes(n)))),!t.length&&!r.length&&!s.length)return void renderEmpty(this,"pivot");if(n&&(!u.length||!d.length)){const t=document.createElement("div");return t.className="c-pivot__empty",t.setAttribute("role","status"),t.textContent=this.getAttribute("empty")||labelText(this,"empty","No matching data"),void this.appendChild(t)}if(this._pivotSort&&this._pivotSort.col){const e=this._pivotSort.col,r="asc"===this._pivotSort.dir?1:-1,s=r=>a(t.filter(t=>t.row===r&&t.col===e).map(t=>Number(t.value)).filter(t=>Number.isFinite(t)));u=u.slice().sort((t,e)=>(s(t)-s(e))*r)}const h=document.createElement("div");h.className="c-table-wrap c-pivot__wrap";const m=document.createElement("table");m.className="c-table c-pivot__table",m.setAttribute("role","grid"),m.setAttribute("aria-rowcount",String(u.length+1)),m.setAttribute("aria-colcount",String(d.length+1));const b=document.createElement("thead"),p=document.createElement("tr"),g=document.createElement("th");g.textContent="",g.setAttribute("role","columnheader"),g.setAttribute("aria-label",labelText(this,"row","Row")),p.appendChild(g);let _=!1;d.forEach(t=>{const e=document.createElement("th");e.textContent=t,e.setAttribute("role","columnheader"),e.setAttribute("tabindex",_?"-1":"0"),_=!0,p.appendChild(e)}),b.appendChild(p),m.appendChild(b);const v=document.createElement("tbody");u.forEach(e=>{const r=document.createElement("tr");r.setAttribute("role","row");const s=document.createElement("th");s.textContent=e,s.setAttribute("role","rowheader"),s.setAttribute("tabindex",_?"-1":"0"),_=!0,r.appendChild(s),d.forEach(s=>{const i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1"),i.dataset.row=e,i.dataset.col=s;const n=t.filter(t=>t.row===e&&t.col===s),o=n.map(t=>Number(t.value)).filter(t=>Number.isFinite(t));if(n.length&&o.length===n.length&&o.length){const t=a(o);i.textContent=Number.isInteger(t)?String(t):t.toFixed(2)}else n.length?i.textContent=n.map(t=>t.value).join(", "):i.textContent="";i.textContent.trim()||i.setAttribute("aria-label",labelText(this,"empty","Empty")),r.appendChild(i)}),v.appendChild(r)}),m.appendChild(v),h.appendChild(m),this.appendChild(h)}enhance(){this._wiredPivot||(this._wiredPivot=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest("th"):null,r=t.target&&t.target.closest?t.target.closest("td"):null,s=t.target&&t.target.closest?t.target.closest(".c-pivot__filter"):null,i=t.target&&t.target.closest?t.target.closest(".c-pivot__aggregate"):null;if(!s&&!i){if(e&&this.contains(e)&&e.parentElement&&e.parentElement.parentElement&&"THEAD"===e.parentElement.parentElement.tagName){const t=e.textContent.trim();if(t){const e=this._pivotSort;this._pivotSort={col:t,dir:e&&e.col===t&&"desc"===e.dir?"asc":"desc"},this.requestRender()}return void this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:!0,composed:!0,detail:{column:t}}))}r&&this.contains(r)&&this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{row:r.dataset.row||"",col:r.dataset.col||"",value:r.textContent}}))}}),this.addEventListener("input",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-pivot__filter"):null;e&&this.contains(e)&&(this.setAttribute("filter",e.value),this.dispatchEvent(new CustomEvent("contour:filter",{bubbles:!0,composed:!0,detail:{query:e.value}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"pivot",filter:{filter:e.value}}})))}),this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-pivot__aggregate"):null;e&&this.contains(e)&&(this.setAttribute("aggregate",e.value),this.dispatchEvent(new CustomEvent("contour:aggregate",{bubbles:!0,composed:!0,detail:{aggregate:e.value}})))}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest("th, td"):null;if(!e||!this.contains(e))return;const r=this.querySelector("table");if(!r)return;const s=Array.from(r.querySelectorAll("tr")),i=s.indexOf(e.parentElement),a=Array.from(e.parentElement.children).indexOf(e);let n=null;if("ArrowRight"===t.key?n=e.parentElement.children[a+1]:"ArrowLeft"===t.key?n=e.parentElement.children[a-1]:"ArrowDown"===t.key?n=s[i+1]&&s[i+1].children[a]:"ArrowUp"===t.key?n=s[i-1]&&s[i-1].children[a]:"Home"===t.key?n=e.parentElement.children[0]:"End"===t.key&&(n=e.parentElement.children[e.parentElement.children.length-1]),n){t.preventDefault();try{n.focus()}catch(t){}}}),this.addEventListener("contour:clear-all",()=>{this.hasAttribute("filter")&&(this.removeAttribute("filter"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"pivot",filter:{filter:null}}})))}))}}define("contour-pivot",ContourPivot);class ContourWidgetState extends ContourBase{static get observed(){return["loading","error","empty","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"},retry:{attribute:"retry"},src:{attribute:"src"}}}render(){this.classList.add("c-widget-state"),wireStates(this),loadRemote(this,[]),renderStates(this,"widget-state")}enhance(){}}define("contour-widget-state",ContourWidgetState);class ContourBrownout extends ContourBase{static get observed(){return["level"]}static get properties(){return{level:{attribute:"level"}}}render(){this.classList.add("c-brownout");const t=this.getAttribute("level")||"0";this.dataset.level=t,this.setAttribute("data-level",t);let e=this.querySelector(".c-brownout__decorative");e||(e=document.createElement("span"),e.className="c-brownout__decorative",e.setAttribute("aria-hidden","true"),this.appendChild(e));let r=this.querySelector(".c-brownout__label");r||(r=document.createElement("span"),r.className="c-brownout__label",this.appendChild(r)),r.textContent=labelText(this,"level","Level")+" "+t;const s=parseInt(t,10)||0;this._shedDisplay||(this._shedDisplay=new WeakMap),Array.from(this.children).forEach(t=>{if(t.classList.contains("c-brownout__decorative")||t.classList.contains("c-brownout__label"))return;const e=parseInt(t.getAttribute("data-shed")||"2",10);!t.hasAttribute("data-essential")&&Number.isFinite(e)&&s>=e?(this._shedDisplay.has(t)||this._shedDisplay.set(t,t.style.display),t.style.display="none"):this._shedDisplay.has(t)&&(t.style.display=this._shedDisplay.get(t),this._shedDisplay.delete(t))})}enhance(){}}define("contour-brownout",ContourBrownout);class ContourInstrument extends ContourBase{static get observed(){return["rows","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{rows:{attribute:"rows"},src:{attribute:"src"}}}render(){if(this.classList.add("c-instrument"),wireStates(this),loadRemote(this,"rows"),renderStates(this,"instrument"))return;const t=remoteData(this,"rows");if(Array.from(this.querySelectorAll(".c-instrument__item")).forEach(t=>t.remove()),t)try{JSON.parse(t).forEach(t=>{const e=document.createElement("span");e.className="c-instrument__item",e.appendChild(document.createTextNode(String(t.key||t[0]||"")));const r=document.createElement("span");r.className="c-instrument__value",r.textContent=t.value||t[1]||"",e.appendChild(r),this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}else renderEmpty(this,"instrument")}}define("contour-instrument",ContourInstrument);class ContourBivariate extends ContourBase{static get observed(){return["size","axis-x","axis-y","colors","selected"]}static get properties(){return{size:{attribute:"size"},axisX:{attribute:"axis-x"},axisY:{attribute:"axis-y"},colors:{attribute:"colors"},selected:{attribute:"selected"}}}get _bvBlock(){return"c-bivariate"}get _bvDefaultAxisX(){return"Income"}get _bvDefaultAxisY(){return"Density"}get _bvLiveClassName(){return`${this._bvBlock}__live`}get _bvLiveInlineStyles(){return!0}get _bvAnnounce(){return!1}render(){this.classList.add(this._bvBlock),this.setAttribute("role","group");const t="Bivariate legend",e=this.getAttribute("aria-label");null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t);const r=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")??"3",10)??3)),s=this.getAttribute("axis-y")??this._bvDefaultAxisY,i=this.getAttribute("axis-x")??this._bvDefaultAxisX,a=this.ensure(`.${this._bvBlock}__matrix`,()=>{const t=document.createElement("div");return t.className=`${this._bvBlock}__matrix`,t});a.style.gridTemplateColumns=`repeat(${r}, 1fr)`,a.style.gridTemplateRows=`repeat(${r}, 1fr)`;if(!Array.from(a.children).filter(t=>t.classList&&t.classList.contains(`${this._bvBlock}__cell`)).length){a.innerHTML="";let t=parseArrayAttr(this,"colors",warnBadJson);if(!t.length){t=["#e8e8e8","#b5c0da","#2a5a99","#e4acac","#b07f99","#2d3a6b","#c85a5a","#994d6e","#2a1a30"].slice(0,r*r)}for(let e=0;e<r;e++)for(let n=0;n<r;n++){const o=document.createElement("div");o.className=`${this._bvBlock}__cell`,o.setAttribute("role","button"),o.setAttribute("tabindex",0===e&&0===n?"0":"-1");const l=r-e;o.setAttribute("aria-label",`${s} ${l} of ${r}, ${i} ${n+1} of ${r}`);const c=(r-1-e)*r+n;if(t[c]){const e=safeColor(t[c]);e&&(o.style.background=e,o.dataset.color=e)}a.appendChild(o)}const e=this.getAttribute("selected");if(e){const t=e.split(","),s=parseInt(t[0],10),i=parseInt(t[1],10);Array.from(a.querySelectorAll(`.${this._bvBlock}__cell`)).forEach((t,e)=>{Math.floor(e/r)===s&&e%r===i?t.setAttribute("data-selected",""):t.removeAttribute("data-selected")})}let n=this.querySelector(`.${this._bvBlock}__live`);n||(n=document.createElement("div"),n.className=this._bvLiveClassName,n.setAttribute("aria-live","polite"),this._bvLiveInlineStyles&&(n.style.position="absolute",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n.style.clip="rect(0,0,0,0)"),this.appendChild(n))}const n=this.getAttribute("axis-x");if(n){this.ensure(`.${this._bvBlock}__axis--x`,()=>{const t=document.createElement("div");return t.className=`${this._bvBlock}__axis ${this._bvBlock}__axis--x`,t}).textContent=n}else{const t=this.querySelector(`.${this._bvBlock}__axis--x`);t&&t.remove()}const o=this.getAttribute("axis-y");if(o){this.ensure(`.${this._bvBlock}__axis--y`,()=>{const t=document.createElement("div");return t.className=`${this._bvBlock}__axis ${this._bvBlock}__axis--y`,t}).textContent=o}else{const t=this.querySelector(`.${this._bvBlock}__axis--y`);t&&t.remove()}}enhance(){if(this._wiredBivariate)return;this._wiredBivariate=!0;const t=t=>{const e=this.querySelector(`.${this._bvBlock}__matrix`),r=Array.from(e?e.querySelectorAll(`.${this._bvBlock}__cell`):[]),s=r.indexOf(t);if(s<0)return;const i=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3)),a=Math.floor(s/i),n=s%i;if(r.forEach((t,e)=>{Math.floor(e/i)===a&&e%i===n?t.setAttribute("data-selected",""):t.removeAttribute("data-selected")}),this._bvAnnounce){const e=this.querySelector(`.${this._bvBlock}__live`);e&&(e.textContent=t.getAttribute("aria-label")||"")}this.dispatchEvent(new CustomEvent("contour:select",{detail:{row:a,col:n},bubbles:!0,composed:!0}))};this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(`.${this._bvBlock}__cell`):null;r&&this.contains(r)&&t(r)}),this.addEventListener("keydown",e=>{const r=e.target&&e.target.closest?e.target.closest(`.${this._bvBlock}__cell`):null;if(!r||!this.contains(r))return;if("Enter"===e.key||" "===e.key)return e.preventDefault(),void t(r);const s=this.querySelector(`.${this._bvBlock}__matrix`);if(!s)return;const i=Array.from(s.querySelectorAll(`.${this._bvBlock}__cell`)),a=i.indexOf(r);if(a<0)return;const n=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3)),o=Math.floor(a/n),l=a%n;let c=o,u=l;if("ArrowRight"===e.key)u=Math.min(n-1,l+1);else if("ArrowLeft"===e.key)u=Math.max(0,l-1);else if("ArrowDown"===e.key)c=Math.min(n-1,o+1);else if("ArrowUp"===e.key)c=Math.max(0,o-1);else if("Home"===e.key)c=0,u=0;else{if("End"!==e.key)return;c=n-1,u=n-1}e.preventDefault();const d=i[c*n+u];if(d){i.forEach((t,e)=>t.setAttribute("tabindex",e===c*n+u?"0":"-1"));try{d.focus()}catch(t){}}})}clear(){this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:!0,composed:!0}))}}define("contour-bivariate",ContourBivariate);class ContourBivariateLegend extends ContourBivariate{static get observed(){return["size","axis-x","axis-y","colors","selected"]}static get properties(){return{size:{attribute:"size"},axisX:{attribute:"axis-x"},axisY:{attribute:"axis-y"},colors:{attribute:"colors"},selected:{attribute:"selected"}}}get _bvBlock(){return"c-bivariate-legend"}get _bvDefaultAxisX(){return"X"}get _bvDefaultAxisY(){return"Y"}get _bvLiveClassName(){return"visually-hidden c-bivariate-legend__live"}get _bvLiveInlineStyles(){return!1}get _bvAnnounce(){return!0}clear(){this.removeAttribute("selected");Array.from(this.querySelectorAll(".c-bivariate-legend__cell")).forEach(t=>t.removeAttribute("data-selected")),this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:!0,composed:!0}))}}define("contour-bivariate-legend",ContourBivariateLegend);class ContourSurvey extends ContourBase{static get observed(){return["date","instrument","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{date:{attribute:"date"},instrument:{attribute:"instrument"},src:{attribute:"src"}}}render(){if(this.classList.add("c-survey"),wireStates(this),loadRemote(this,"date"),renderStates(this,"survey"))return;const t=remoteData(this,"date");Array.from(this.childNodes).forEach(t=>{t.nodeType===Node.TEXT_NODE?"Surveyed"!==t.textContent.trim()&&"·"!==t.textContent.trim()||t.remove():t.classList&&(t.classList.contains("c-survey__value")||t.classList.contains("c-survey__sep"))&&t.remove()});const e=t||this._remoteData&&this._remoteData.date,r=this.getAttribute("instrument")||this._remoteData&&this._remoteData.instrument;if(!e)return void renderEmpty(this,"survey");const s=document.createElement("span");if(s.className="c-survey__value",s.textContent=e,this.appendChild(document.createTextNode("Surveyed ")),this.appendChild(s),r){const t=document.createElement("span");t.className="c-survey__sep",t.textContent="·",this.appendChild(t);const e=document.createElement("span");e.className="c-survey__value",e.textContent=r,this.appendChild(e)}}}define("contour-survey",ContourSurvey);class ContourThreshold extends ContourBase{static get observed(){return["label","norm","state","value","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},norm:{attribute:"norm"},state:{attribute:"state"},value:{attribute:"value"},src:{attribute:"src"}}}render(){if(this.classList.add("c-threshold"),this.hasAttribute("role")||this.setAttribute("role","meter"),wireStates(this),loadRemote(this,"value"),renderStates(this,"threshold"))return;const t=t=>{const e=Number(t);return Number.isFinite(e)?(e<=1?100*e:e)+"%":String(t)},e=remoteData(this,"value")||this._remoteData&&this._remoteData.value,r=this.getAttribute("norm")||this._remoteData&&this._remoteData.norm,s=this.getAttribute("state")||this._remoteData&&this._remoteData.state,i=this.getAttribute("label")||this._remoteData&&this._remoteData.label;if(!e&&!r&&!i)return void renderEmpty(this,"threshold");const a=Number(e);if(Number.isFinite(a)){const t=Math.min(100,Math.max(0,a));this.setAttribute("aria-valuenow",String(t)),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100")}else this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuemin"),this.removeAttribute("aria-valuemax");const n=[i,Number.isFinite(a)?String(a):null,r?labelText(this,"target","target")+" "+r:null].filter(Boolean).join(", ");if(n?this.setAttribute("aria-valuetext",n):this.removeAttribute("aria-valuetext"),e){this.ensure(".c-threshold__fill",()=>{const t=document.createElement("span");return t.className="c-threshold__fill",t}).style.setProperty("--value",t(e))}else{const t=this.querySelector(".c-threshold__fill");t&&t.remove()}if(r){this.ensure(".c-threshold__target",()=>{const t=document.createElement("span");return t.className="c-threshold__target",t}).style.setProperty("--target",t(r))}else{const t=this.querySelector(".c-threshold__target");t&&t.remove()}s?this.setAttribute("data-state",s):this.removeAttribute("data-state"),i&&this.setAttribute("aria-label",i)}enhance(){this._wiredThreshold||(this._wiredThreshold=!0,this.addEventListener("contour:clear-all",()=>{(this.hasAttribute("norm")||this.hasAttribute("value"))&&(this.removeAttribute("norm"),this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"threshold",filter:{norm:null,value:null}}})),this.requestRender())}))}}define("contour-threshold",ContourThreshold);class ContourMetricsFull extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){if(this.classList.add("c-metrics"),this.setAttribute("role","list"),wireStates(this),loadRemote(this,"items"),renderStates(this,"metrics"))return;const t=remoteData(this,"items");Array.from(this.querySelectorAll(".c-metrics__item")).forEach(t=>t.remove());let e=null;if(t)try{e=JSON.parse(t)}catch(t){e=null}Array.isArray(e)&&e.length?e.forEach(t=>{const e=document.createElement("div");e.className="c-metrics__item",e.setAttribute("role","listitem");const r=document.createElement("div");r.className="c-metrics__value",r.textContent="object"==typeof t&&null!==t?t.value??t.v??"":String(t);const s=document.createElement("div");s.className="c-metrics__label",s.textContent="object"==typeof t&&null!==t?t.label??t.l??"":"",e.appendChild(r),e.appendChild(s),this.appendChild(e)}):t||renderEmpty(this,"metrics")}enhance(){wireStates(this)}}define("contour-metrics",ContourMetricsFull);class ContourLegend extends ContourBase{static get observed(){return["title","ramp","scale","items","method","norm","selectable","brownout","brownout-level","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","glyphs","thresholds","breaks","no-data-color","no-data-label","size","table","classification","audit","continuous","ends","caption","graduated","cache-key","no-cache"]}static get properties(){return{title:{attribute:"title"},ramp:{attribute:"ramp"},scale:{attribute:"scale"},items:{attribute:"items"},method:{attribute:"method"},norm:{attribute:"norm"},selectable:{attribute:"selectable",type:Boolean},src:{attribute:"src"},graduated:{attribute:"graduated",type:Boolean}}}render(){this.classList.add("c-legend");const t=this.hasAttribute("graduated");t&&this.classList.add("c-legend--graduated");if(this.hasAttribute("continuous")||this.hasAttribute("selectable")?this.setAttribute("role","group"):this.setAttribute("role","list"),wireStates(this),loadRemote(this,"items"),renderStates(this,"legend"))return;const e=this.hasAttribute("selectable");e?this.classList.add("c-legend--interactive"):this.classList.remove("c-legend--interactive");const r=Array.from(this.querySelectorAll(":scope > .c-legend__item"));let s=remoteData(this,"items");r.length&&(s=JSON.stringify(r.map(t=>{const e=t.querySelector(".c-legend__swatch"),r=t.querySelector(".c-legend__label")||t;return{label:r?r.textContent.trim():t.textContent.trim(),color:e&&(e.dataset&&e.dataset.color||e.style.background)||void 0}})),r.forEach(t=>t.remove()));const i=this.getAttribute("title");if(i){this.ensure(".c-legend__title",()=>{const t=document.createElement("div");return t.className="c-legend__title",t}).textContent=i}else{const t=this.querySelector(".c-legend__title");t&&t.remove()}if(s)try{const r=JSON.parse(s),a=this.ensure(".c-legend__items",()=>{const t=document.createElement("div");return t.className="c-legend__items",t});this.hasAttribute("selectable")?a.setAttribute("role","group"):a.removeAttribute("role"),i&&a.setAttribute("aria-label",i),a.innerHTML="",r.forEach(r=>{const s="string"==typeof r?r:r.label||String(r),i="string"==typeof r?r:r.key||r.label||String(r),n=document.createElement("div");if(n.className="c-legend__item",n.setAttribute("tabindex","-1"),e){n.setAttribute("role","button");const t=this._legendUnpressed&&this._legendUnpressed.has(i);n.setAttribute("aria-pressed",t?"false":"true"),n.dataset.key=i}else n.setAttribute("role","listitem");const o=document.createElement("span");if(t){o.className="c-legend__swatch c-legend__swatch--graduated";const t=r&&null!=r.size?r.size:r&&null!=r.value?r.value:1,e=Math.max(6,Math.min(24,4*parseFloat(t)));o.style.inlineSize=e+"px",o.style.blockSize=e+"px"}else o.className="c-legend__swatch";if(r&&r.color){const t=safeColor(r.color);t&&(o.style.background=t,o.dataset.color=t)}if(n.appendChild(o),t&&r&&null!=r.break){const t=document.createElement("span");t.className="c-legend__break-label",t.textContent=String(r.break),n.appendChild(t)}const l=r&&(r.shape||r.marker||r.glyph)||this.getAttribute("glyphs");if(l){const t=document.createElement("span");t.className="c-legend__glyph",t.setAttribute("part","glyph"),t.textContent="circle"===l?"●":"square"===l?"■":"triangle"===l?"▲":"diamond"===l?"◆":"star"===l?"★":String(l),r&&null!=r.size&&(t.style.fontSize="number"==typeof r.size?r.size+"px":String(r.size)),n.appendChild(t)}if(r&&null!=r.break){const t=document.createElement("span");t.className="c-legend__break",t.textContent=String(r.break),n.appendChild(t)}const c=document.createElement("span");c.className="c-legend__label",c.textContent=s,n.dataset.label=s,n.appendChild(c);const u="object"==typeof r&&r&&(r.caption||r.note)||"";if(u){const t=document.createElement("span");t.className="c-legend__caption",t.textContent=u,n.appendChild(t)}r&&(r.threshold||null!=r.break)&&(o.style.outline="2px solid var(--color-border-strong)"),a.appendChild(n)})}catch(t){warnBadJson(this,"attribute",t)}else{const t=this.querySelector(".c-legend__items");t&&t.remove();this.getAttribute("title")||this.getAttribute("ramp")||this.getAttribute("scale")||this.getAttribute("method")||this.getAttribute("norm")||renderEmpty(this,"legend")}const a=this.getAttribute("caption");let n=this.querySelector(".c-legend__caption");if(a)n||(n=document.createElement("span"),n.className="c-legend__caption",this.appendChild(n)),n.id=n.id||contourId("legend-caption"),n.textContent=a,n.style.position="absolute",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n.style.clip="rect(0,0,0,0)";else if(n){const t=n.id;n.remove(),t&&this.querySelectorAll(".c-legend__item").forEach(e=>{const r=(e.getAttribute("aria-describedby")||"").split(" ").filter(e=>e&&e!==t);r.length?e.setAttribute("aria-describedby",r.join(" ")):e.removeAttribute("aria-describedby")})}const o=this.querySelector(".c-legend__items");if(o){const t=Array.from(o.querySelectorAll(".c-legend__item"));e?t.forEach((t,e)=>t.setAttribute("tabindex",0===e?"0":"-1")):t.forEach(t=>t.setAttribute("tabindex","-1")),n&&t.forEach(t=>t.setAttribute("aria-describedby",n.id))}const l=this.getAttribute("no-data-color"),c=this.getAttribute("no-data-label")||"No data";if(l){let t=this.querySelector(".c-legend__no-data");t||(t=document.createElement("div"),t.className="c-legend__no-data",this.appendChild(t)),t.setAttribute("part","no-data"),t.setAttribute("aria-label",c),t.textContent=c;const e=document.createElement("span");e.className="glyph",e.style.background=safeColor(l),e.dataset.color=l,t.prepend(e)}else{const t=this.querySelector(".c-legend__no-data");t&&t.remove()}const u=this.getAttribute("audit");if(u){this.ensure(".c-legend__audit",()=>{const t=document.createElement("div");return t.className="c-legend__audit",t}).textContent=u}else{const t=this.querySelector(".c-legend__audit");t&&t.remove()}if(this.hasAttribute("continuous")){const t=this.getAttribute("ends");let e=null;if(t)try{e=JSON.parse(t)}catch(r){e=t.split(",")}if(Array.isArray(e)&&e.length>=2){const t=this.ensure(".c-legend__ramp",()=>{const t=document.createElement("div");return t.className="c-legend__ramp",t});let r=this.querySelector(".c-legend__ramp-label--start");r||(r=document.createElement("span"),r.className="c-legend__ramp-label c-legend__ramp-label--start",t.appendChild(r)),r.textContent=e[0];let s=this.querySelector(".c-legend__ramp-label--end");s||(s=document.createElement("span"),s.className="c-legend__ramp-label c-legend__ramp-label--end",t.appendChild(s)),s.textContent=e[e.length-1]}}const d=this.getAttribute("size");if(d){this.ensure(".c-legend__size",()=>{const t=document.createElement("div");return t.className="c-legend__size",t}).textContent=d}else{const t=this.querySelector(".c-legend__size");t&&t.remove()}const h=this.getAttribute("classification");if(h){this.ensure(".c-legend__classification",()=>{const t=document.createElement("div");return t.className="c-legend__classification",t}).textContent=h}else{const t=this.querySelector(".c-legend__classification");t&&t.remove()}const m=this.getAttribute("table");if(m){let t=null;try{t=JSON.parse(m)}catch(e){t=null}if(Array.isArray(t)){let e=this.querySelector(".c-legend__table-wrap");e||(e=document.createElement("details"),e.className="c-legend__table-wrap",this.appendChild(e)),e.innerHTML="";const r=document.createElement("summary");r.textContent=labelText(this,"data-table","Data table"),e.appendChild(r);const s=document.createElement("table");s.className="c-legend__table";const i=document.createElement("tbody");t.forEach(t=>{const e=document.createElement("tr");(Array.isArray(t)?t:[t.label??t.key??"",t.value??""]).forEach(t=>{const r=document.createElement("td");r.textContent=t,e.appendChild(r)}),i.appendChild(e)}),s.appendChild(i),e.appendChild(s)}}else{const t=this.querySelector(".c-legend__table-wrap");t&&t.remove()}const b=this.getAttribute("method");if(b){this.ensure(".c-legend__method",()=>{const t=document.createElement("div");return t.className="c-legend__method",t}).textContent=b}else{const t=this.querySelector(".c-legend__method");t&&t.remove()}const p=this.getAttribute("norm");if(p){this.ensure(".c-legend__norm",()=>{const t=document.createElement("span");return t.className="c-legend__norm",t}).textContent=p}else{const t=this.querySelector(".c-legend__norm");t&&t.remove()}const g=this.getAttribute("ramp");if(g){const t=this.ensure(".c-legend__ramp",()=>{const t=document.createElement("div");return t.className="c-legend__ramp",t});t.style.background=safeColor(g);const e=this.getAttribute("breaks");if(e){let r=null;try{r=JSON.parse(e)}catch(t){r=e.split(",").map(t=>t.trim())}Array.isArray(r)&&(Array.from(t.querySelectorAll(".c-legend__ramp-segment")).forEach(t=>t.remove()),r.forEach((e,r)=>{const s=document.createElement("span");s.className="c-legend__ramp-segment",s.style.flex="1";const i=document.createElement("span");i.className="c-legend__ramp-break",i.textContent=String(e),s.appendChild(i),t.appendChild(s)}))}}else{const t=this.querySelector(".c-legend__ramp");t&&t.remove()}const _=this.getAttribute("scale");if(_){this.ensure(".c-legend__scale",()=>{const t=document.createElement("div");return t.className="c-legend__scale",t}).textContent=_}else{const t=this.querySelector(".c-legend__scale");t&&t.remove()}const v=this.shed("chrome",2),f=this.shed("items",3);[".c-legend__ramp",".c-legend__scale"].forEach(t=>{const e=this.querySelector(t);e&&(e.style.display=v?"none":"")}),this.querySelectorAll(".c-legend__caption").forEach(t=>{t.style.display=v?"none":""});const y=this.querySelector(".c-legend__items");y&&(y.style.display=f?"none":"")}enhance(){if(!this._wiredLegend){this._wiredLegend=!0,this.addEventListener("click",t=>{if(!this.hasAttribute("selectable"))return;const e=t.target&&t.target.closest?t.target.closest(".c-legend__item"):null;if(!e||!this.contains(e))return;const r="true"!==e.getAttribute("aria-pressed");e.setAttribute("aria-pressed",String(r)),this._legendUnpressed=this._legendUnpressed||new Set;const s=e.dataset.key||e.textContent.trim();s&&(r?this._legendUnpressed.delete(s):this._legendUnpressed.add(s));const i=Array.from(this.querySelectorAll(".c-legend__item")).indexOf(e),a=e.querySelector(".c-legend__label"),n=e.dataset.label||(a?a.textContent.trim():e.textContent.trim());this.dispatchEvent(new CustomEvent("contour:legend-toggle",{detail:{label:n,key:e.dataset.key||n,pressed:r,index:i},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("contour:select",{detail:{label:n,key:e.dataset.key||n,value:e.dataset.key||n},bubbles:!0,composed:!0}))});try{let t=null;try{t=JSON.parse(this.getAttribute("items")||"null")}catch(e){t=this.getAttribute("items")}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:this.getAttribute("items"),items:t},bubbles:!0,composed:!0}))}catch(t){}this.addEventListener("change",t=>{const e=t.target;e&&e.classList&&e.classList.contains("c-legend__break-input")&&this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:e.value},bubbles:!0,composed:!0}))}),this.addEventListener("keydown",t=>{if(!this.hasAttribute("selectable"))return;const e=Array.from(this.querySelectorAll(".c-legend__item"));if(!e.length)return;const r=document.activeElement,s=e.indexOf(r);if("Escape"===t.key)return e.forEach(t=>t.setAttribute("aria-pressed","false")),void this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:!0,composed:!0}));if(1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey){if("Enter"===t.key||" "===t.key)return t.preventDefault(),void(r&&r.classList.contains("c-legend__item")&&r.click());navKey(t,e,{wrap:!0,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>e.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{}})}else if(e.length>7){const r=s>=0?s+1:0;for(let s=0;s<e.length;s++){const i=(r+s)%e.length;if((e[i].textContent||"").trim().toLowerCase().startsWith(t.key.toLowerCase())){t.preventDefault(),e[i].focus(),e.forEach((t,e)=>t.setAttribute("tabindex",e===i?"0":"-1"));break}}}}),this.addEventListener("contour:clear-all",()=>{const t=Array.from(this.querySelectorAll(".c-legend__item"));let e=!1;t.forEach(t=>{"button"===t.getAttribute("role")&&"true"===t.getAttribute("aria-pressed")&&(t.setAttribute("aria-pressed","false"),e=!0)}),e&&this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"legend",filter:{selection:null}}}))})}}}define("contour-legend",ContourLegend);class ContourMeasure extends ContourBase{static get observed(){return["label","value","point","line","unit","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},point:{attribute:"point"},line:{attribute:"line"},unit:{attribute:"unit"},src:{attribute:"src"}}}render(){if(this.classList.add("c-measure"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"measure","Measure")),wireStates(this),loadRemote(this,["label","value","point","line"]),renderStates(this,"measure"))return;const t=remoteData(this,"label"),e=remoteData(this,"value"),r=remoteData(this,"point"),s=remoteData(this,"line");if(!(t||e||r||s))return void renderEmpty(this,"measure");if(t){this.ensure(".c-measure__label",()=>{const t=document.createElement("span");return t.className="c-measure__label",t}).textContent=t}else{const t=this.querySelector(".c-measure__label");t&&t.remove()}if(e){this.ensure(".c-measure__readout",()=>{const t=document.createElement("span");return t.className="c-measure__readout",t}).textContent=e}else{const t=this.querySelector(".c-measure__readout");t&&t.remove()}let i=this.querySelector(".c-measure__unit-select");i||(i=document.createElement("select"),i.className="c-measure__unit-select",i.setAttribute("aria-label",labelText(this,"unit","Unit")),i.setAttribute("data-contour-label","true"),this.appendChild(i)),["m","km","mi","ft"].forEach(t=>{if(!i.querySelector('option[value="'+t+'"]')){const e=document.createElement("option");e.value=t,e.textContent=t,i.appendChild(e)}});const a=void 0!==this._measureUnit?this._measureUnit:this.getAttribute("unit");if(a&&i.querySelector('option[value="'+a+'"]')&&(i.value=a),r){this.ensure(".c-measure__point",()=>{const t=document.createElement("span");return t.className="c-measure__point",t}).textContent=r}else{const t=this.querySelector(".c-measure__point");t&&t.remove()}if(!s){const t=this.querySelector("svg");return void(t&&t.remove())}if(s){this.ensure(".c-measure__line",()=>{const t=document.createElement("span");return t.className="c-measure__line",t}).style.inlineSize=s}else{const t=this.querySelector(".c-measure__line");t&&t.remove()}}enhance(){this._wiredMeasure||(this._wiredMeasure=!0,this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-measure__unit-select"):null;e&&this.contains(e)&&(this._measureUnit=e.value,this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{unit:e.value}})))}))}}define("contour-measure",ContourMeasure);class ContourTimeline extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-timeline");let t=this.querySelector(".c-timeline__list");if(t||(t=document.createElement("ol"),t.className="c-timeline__list",t.setAttribute("aria-label",this.getAttribute("aria-label")||"Timeline"),this.appendChild(t)),wireStates(this),loadRemote(this,"items"),renderStates(this,"timeline"))return;const e=Array.from(this.children).filter(t=>t.classList&&t.classList.contains("c-timeline__item")),r=remoteData(this,"items");if(r&&!e.length){Array.from(t.querySelectorAll(".c-timeline__item")).forEach(t=>t.remove());try{JSON.parse(r).forEach((e,r)=>{const s=document.createElement("li");if(s.className="c-timeline__item",s.setAttribute("tabindex",0===r?"0":"-1"),e.time){const t=document.createElement("time");t.className="c-timeline__time",t.setAttribute("datetime",String(e.time)),t.textContent=e.time,s.appendChild(t)}if(e.title){const t=document.createElement("div");t.className="c-timeline__title",t.textContent=e.title,s.appendChild(t)}if(e.text){const t=document.createElement("div");t.className="c-timeline__text",t.textContent=e.text,s.appendChild(t)}t.appendChild(s)})}catch(t){warnBadJson(this,"attribute",t)}}else e.length||renderEmpty(this,"timeline")}enhance(){if(this._wiredTimeline)return;this._wiredTimeline=!0;Array.from(this.querySelectorAll(".c-timeline__item")).forEach((t,e)=>t.setAttribute("tabindex",0===e?"0":"-1")),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-timeline__item"):null;if(!e||!this.contains(e))return;const r=Array.from(this.querySelectorAll(".c-timeline__item")).indexOf(e);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:r}}))}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-timeline__item"));e.length&&navKey(t,e,{wrap:!1,homeEnd:!0,onNavigate:t=>e.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{"Enter"!==t.key&&" "!==t.key||this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:e.indexOf(document.activeElement)}}))}})})}}define("contour-timeline",ContourTimeline);class ContourHeatmap extends ContourBase{static get observed(){return["cells","count","legend","brownout","brownout-level","empty","loading","values","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","dir","no-cache"]}static get properties(){return{cells:{attribute:"cells"},count:{attribute:"count"},legend:{attribute:"legend"},src:{attribute:"src"}}}render(){if(this.classList.add("c-heatmap"),this.hasAttribute("role")||this.setAttribute("role","grid"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"heatmap","Heatmap")),wireStates(this),loadRemote(this,"cells"),renderStates(this,"heatmap"))return;const t=Array.from(this.querySelectorAll(":scope > .c-heatmap__cell"));if(t.length){const e=Math.ceil(Math.sqrt(t.length));this.style.gridTemplateColumns="repeat("+e+", 1fr)",this.style.inlineSize="16rem";let r=null,s=0;const i=()=>{r=document.createElement("div"),r.setAttribute("role","row"),this.appendChild(r),s=0};i(),t.forEach(t=>{t.setAttribute("role","gridcell"),r.appendChild(t),s++,s===e&&i()})}else{Array.from(this.querySelectorAll(".c-heatmap__cell")).forEach(t=>t.remove());const e=Math.min(200,Math.max(0,parseInt(this.getAttribute("cells")||this.getAttribute("count")||"0",10)||0)),r=e>0?Math.ceil(Math.sqrt(e)):1;if(this.style.gridTemplateColumns="repeat("+r+", 1fr)",this.style.inlineSize="16rem",e>0){let t=[];try{t=JSON.parse(this.getAttribute("values")||"[]")}catch(e){t=[]}const s=t.map(t=>{const e=Number(t);return Number.isFinite(e)?e:null}),i=s.filter(t=>null!==t),a=i.length?Math.min.apply(null,i):0,n=(i.length?Math.max.apply(null,i):0)-a,o=t=>null===t?0:n<=0?4:Math.min(7,1+Math.floor((t-a)/n*7));let l=null,c=0;const u=()=>{l=document.createElement("div"),l.setAttribute("role","row"),this.appendChild(l),c=0};u();for(let i=0;i<e;i++){const a=document.createElement("div");a.className="c-heatmap__cell",a.setAttribute("role","gridcell"),a.setAttribute("tabindex",0===i?"0":"-1"),a.dataset.index=String(i);const n=o(s[i]);n&&(a.style.setProperty("--c","var(--chart-seq-"+n+")"),a.dataset.band=String(n)),void 0!==t[i]&&a.setAttribute("data-title",String(t[i])),l.appendChild(a),c++,c===r&&i<e-1&&u()}if(this.shed("tooltip",2)){const t=this.querySelector(".c-heatmap__tooltip");t&&t.remove()}else{this.ensure(".c-heatmap__tooltip",()=>{const t=document.createElement("div");return t.className="c-heatmap__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t.id=contourId("heatmap-tip"),t}).setAttribute("hidden","")}}else t.length||renderEmpty(this,"heatmap")}if(this.hasAttribute("legend")&&!this.shed("legend",2)){this.ensure(".c-heatmap__legend",()=>{const t=document.createElement("div");t.className="c-heatmap__legend";const e=document.createElement("div");return e.className="c-heatmap__legend-bar",t.appendChild(e),t})}else{const t=this.querySelector(".c-heatmap__legend");t&&t.remove()}}enhance(){if(this._wiredHeatmap)return;this._wiredHeatmap=!0;const t=()=>Array.from(this.querySelectorAll(".c-heatmap__cell")),e=t=>{const e=this.querySelector(".c-heatmap__tooltip");if(!e)return;const r=t.target&&t.target.closest?t.target.closest(".c-heatmap__cell"):null;if(!r||!this.contains(r))return void e.setAttribute("hidden","");const s=r.getAttribute("data-title")||r.getAttribute("title");e.textContent=s||labelText(this,"cell","Cell")+" "+(r.dataset.index||"");const i=this.getBoundingClientRect(),a=r.getBoundingClientRect();this.style.position=this.style.position||"relative",e.style.setProperty("--chart-tip-inline-start",a.left-i.left+a.width/2+"px"),e.style.setProperty("--chart-tip-block-start",a.top-i.top+"px"),e.removeAttribute("hidden")},r=()=>{const t=this.querySelector(".c-heatmap__tooltip");t&&t.setAttribute("hidden","")};this.addEventListener("mouseover",e),this.addEventListener("mouseout",t=>{t.relatedTarget&&this.contains(t.relatedTarget)||r()}),this.addEventListener("focusin",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-heatmap__cell"):null;if(r&&this.contains(r)){e({target:r});const t=this.querySelector(".c-heatmap__tooltip");t&&t.id&&r.setAttribute("aria-describedby",t.id)}}),this.addEventListener("focusout",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-heatmap__cell"):null;e&&this.contains(e)&&e.removeAttribute("aria-describedby"),this.contains(t.relatedTarget)||r()}),this.addEventListener("keydown",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!r||!this.contains(r))return;const s=t(),i=s.indexOf(r);let a=-1;const n="rtl"===(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase();if("ArrowRight"===e.key)a=n?Math.max(i-1,0):Math.min(i+1,s.length-1);else if("ArrowLeft"===e.key)a=n?Math.min(i+1,s.length-1):Math.max(i-1,0);else if("ArrowDown"===e.key)a=Math.min(i+Math.ceil(Math.sqrt(s.length)),s.length-1);else if("ArrowUp"===e.key)a=Math.max(i-Math.ceil(Math.sqrt(s.length)),0);else if("Home"===e.key)a=0;else if("End"===e.key)a=s.length-1;else if("Enter"===e.key||" "===e.key)return e.preventDefault(),void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:1,index:i}}));if(a>=0&&a!==i){e.preventDefault(),s.forEach((t,e)=>t.setAttribute("tabindex",e===a?"0":"-1"));try{s[a].focus()}catch(e){}}}),this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!r||!this.contains(r))return;const s=t().indexOf(r);s>=0&&this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:1,index:s}}))})}}define("contour-heatmap",ContourHeatmap);class ContourCompare extends ContourBase{static get observed(){return["no","text","yes","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{no:{attribute:"no"},text:{attribute:"text"},yes:{attribute:"yes"},src:{attribute:"src"}}}render(){this.classList.add("c-compare"),this.setAttribute("role","group");const t="Comparison",e=this.getAttribute("aria-label");if(null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t),wireStates(this),loadRemote(this,["no","text","yes"]),renderStates(this,"compare"))return;const r=remoteData(this,"yes")||this._remoteData&&this._remoteData.yes,s=remoteData(this,"no")||this._remoteData&&this._remoteData.no,i=remoteData(this,"text")||this._remoteData&&this._remoteData.text;if(Array.from(this.querySelectorAll(".c-compare__yes, .c-compare__no, .c-compare__text")).forEach(t=>t.remove()),r){const t=document.createElement("span");t.className="c-compare__yes",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-check" /></svg>'),this.appendChild(t)}if(s){const t=document.createElement("div");t.className="c-compare__no",t.textContent=s,this.appendChild(t)}if(i){const t=document.createElement("p");t.className="c-compare__text",t.textContent=i,this.appendChild(t)}r||s||i||renderEmpty(this,"compare")}}define("contour-compare",ContourCompare);class ContourSparkline extends ContourBase{static get observed(){return["points","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{points:{attribute:"points"},src:{attribute:"src"}}}render(){if(this.classList.add("c-sparkline"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"sparkline","Sparkline")),wireStates(this),loadRemote(this,"points"),renderStates(this,"sparkline"))return;const t=remoteData(this,"points");if(t)try{const e=JSON.parse(t),r=Array.isArray(e)?e.filter(Number.isFinite):[];if(0===r.length)throw new Error("empty");Array.from(this.querySelectorAll(".c-sparkline__dot, .c-sparkline__line, .c-sparkline__area")).forEach(t=>t.remove());const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("class","c-sparkline__line"),s.setAttribute("viewBox","0 0 100 30"),s.setAttribute("preserveAspectRatio","none"),s.style.inlineSize="100%",s.style.blockSize="100%",s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("title",this.getAttribute("aria-label")||"Sparkline");const i=Math.min(...r),a=Math.max(...r)-i||1,n=t=>30-(t-i)/a*30;this._sparkScale={min:i,range:a};const o=r.length,l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",r.map((t,e)=>(0===e?"M":"L")+" "+(1===o?50:100*e/(o-1))+" "+n(t)).join(" ")),s.appendChild(l);const c=document.createElementNS("http://www.w3.org/2000/svg","circle");c.setAttribute("class","c-sparkline__dot"),c.setAttribute("r","2"),c.setAttribute("cx","0"),c.setAttribute("cy","15"),s.appendChild(c),this.appendChild(s),this._sparkPoints=e;this.ensure(".c-sparkline__tooltip",()=>{const t=document.createElement("div");return t.className="c-sparkline__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t.id=contourId("sparkline-tip"),t}).setAttribute("hidden","")}catch(t){Array.from(this.querySelectorAll("svg")).forEach(t=>t.remove()),renderEmpty(this,"sparkline")}else renderEmpty(this,"sparkline")}enhance(){if(this._wiredSparkline)return;this._wiredSparkline=!0,this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const t=t=>{const e=this.querySelector("svg"),r=this.querySelector(".c-sparkline__tooltip"),s=this.querySelector(".c-sparkline__dot");if(!r||!e)return;const i=e.getBoundingClientRect(),a=t.clientX-i.left,n=Math.max(0,Math.min(1,a/i.width)),o=this._sparkPoints||[];if(0===o.length)return;const l=Math.round(n*(o.length-1)),c=o[l],u=1===o.length?50:100*l/(o.length-1),d=this._sparkScale||{min:Math.min(...o),range:Math.max(...o)-Math.min(...o)||1},h=30-(c-d.min)/d.range*30;s&&(s.setAttribute("cx",String(u)),s.setAttribute("cy",String(h)),s.removeAttribute("hidden")),r.textContent=String(c);const m=u/100*i.width;r.style.setProperty("--chart-tip-inline-start",m+"px"),r.style.setProperty("--chart-tip-block-start","0px"),r.removeAttribute("hidden")},e=()=>{const t=this.querySelector(".c-sparkline__tooltip"),e=this.querySelector(".c-sparkline__dot");t&&t.setAttribute("hidden",""),e&&e.setAttribute("hidden","")};this.addEventListener("mousemove",t),this.addEventListener("mouseleave",e),this.addEventListener("focusin",()=>{if(!(this._sparkPoints||[]).length)return;const e=this.querySelector("svg");if(!e)return;const r=e.getBoundingClientRect();t({clientX:r.left+r.width-1});const s=this.querySelector(".c-sparkline__tooltip");s&&s.id&&this.setAttribute("aria-describedby",s.id)}),this.addEventListener("focusout",()=>{this.removeAttribute("aria-describedby"),e()}),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:1}})))})}}define("contour-sparkline",ContourSparkline);class ContourChartGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["title","series","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{title:{attribute:"title"},series:{attribute:"series"},src:{attribute:"src"}}}render(){this.classList.add("c-chart-grid"),this.setAttribute("role","group");const t="Chart grid",e=this.getAttribute("aria-label");if(null!==e&&e!==this._lastAutoAria||(this.setAttribute("aria-label",t),this._lastAutoAria=t),wireStates(this),loadRemote(this,"series"),renderStates(this,"chart-grid"))return;const r=this.getAttribute("title");if(r){this.ensure(".c-chart-grid__title",()=>{const t=document.createElement("div");return t.className="c-chart-grid__title",t}).textContent=r}const s=remoteData(this,"series");let i=[];if(s)try{const t=JSON.parse(s);Array.isArray(t)&&(i=t)}catch(t){}Array.from(this.querySelectorAll(".c-chart-grid__cell")).forEach(t=>t.remove()),i.forEach((t,e)=>{const r=Array.isArray(t)?t:t&&Array.isArray(t.values)?t.values:[],s=!Array.isArray(t)&&t&&t.label?t.label:labelText(this,"series","Series")+" "+(e+1),i=r.map(Number).filter(Number.isFinite),a=document.createElement("div");a.className="c-chart-grid__cell";const n=document.createElement("span");if(n.className="c-chart-grid__label",n.textContent=s,a.appendChild(n),i.length>1){const t=Math.min(...i),r=Math.max(...i)-t||1,s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("class","c-chart-grid__spark"),s.setAttribute("viewBox","0 0 100 30"),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("aria-hidden","true");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",i.map((e,s)=>(0===s?"M":"L")+" "+100*s/(i.length-1)+" "+(30-(e-t)/r*30)).join(" ")),n.style.stroke="var(--chart-"+(e%8+1)+")",n.style.fill="none",n.style.strokeWidth="2",s.appendChild(n),a.appendChild(s)}this.appendChild(a)}),i.length||r||renderEmpty(this,"chart-grid")}}define("contour-chart-grid",ContourChartGrid);class ContourContourPlot extends ContourBase{static get observed(){return["values","levels","label","empty"]}static get properties(){return{values:{attribute:"values"},levels:{attribute:"levels"},label:{attribute:"label"}}}render(){this.classList.add("c-contour-plot"),this.hasAttribute("role")||this.setAttribute("role","group");const t=this.getAttribute("label");!t&&this.hasAttribute("aria-label")||this.setAttribute("aria-label",t||"Contour plot");const e=this.getAttribute("values"),r=this.getAttribute("levels");let s=null;if(e)try{s=JSON.parse(e)}catch(t){s=null}let i=[.3,.5,.7];if(r)try{const t=JSON.parse(r);Array.isArray(t)&&t.length&&(i=t)}catch(t){}let a=this.querySelector("svg");if(a||(a=document.createElementNS("http://www.w3.org/2000/svg","svg"),a.setAttribute("class","c-contour-plot__svg"),this.appendChild(a)),a.removeAttribute("aria-hidden"),Array.from(a.querySelectorAll(".c-contour-plot__contour")).forEach(t=>t.remove()),!Array.isArray(s)||0===s.length||!Array.isArray(s[0])||0===s[0].length){const t=document.createElement("div");return t.className="c-contour-plot__empty",t.textContent=this.getAttribute("empty")||stateLabel(this,"contour"),void this.appendChild(t)}if(Array.isArray(s)&&s.length>1&&Array.isArray(s[0])&&s[0].length>1){const t=()=>{const t=this.clientWidth||300,e=this.clientHeight||300;a.setAttribute("viewBox",`0 0 ${t} ${e}`),a.querySelectorAll(".c-contour-plot__contour").forEach(t=>t.remove());let r=0;contourPaths(s,i,t,e).forEach((t,e)=>{if(!t.d)return;const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",t.d),s.setAttribute("class","c-contour-plot__contour"+(e>0?" c-contour-plot__contour--level-"+(e+1):"")),s.setAttribute("tabindex",0===r?"0":"-1"),s.setAttribute("role","button"),s.setAttribute("aria-label",labelText(this,"level","Level")+" "+(e+1)+": "+t.level),s.dataset.level=String(e+1),s.dataset.value=String(t.level),r+=1,a.appendChild(s)})};t(),"undefined"==typeof ResizeObserver||this._contourResize||(this._contourResize=new ResizeObserver(()=>t()),this._contourResize.observe(this),onDispose(this,()=>{this._contourResize.disconnect(),this._contourResize=null}))}else if(!Array.isArray(s)){const t=document.createElement("div");t.className="c-contour-plot__empty",t.textContent=this.getAttribute("empty")||"No field",this.appendChild(t)}}enhance(){if(this._wiredContourPlot)return;this._wiredContourPlot=!0;const t=()=>Array.from(this.querySelectorAll(".c-contour-plot__contour")),e=e=>{const r=t().indexOf(e);if(r<0)return;const s=Number(e.dataset.level),i=Number(e.dataset.value);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{level:s,value:i,index:r}}))};this.addEventListener("click",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-contour-plot__contour"):null;r&&this.contains(r)&&e(r)}),this.addEventListener("keydown",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-contour-plot__contour"):null;if(s&&this.contains(s))if("Enter"===r.key||" "===r.key)r.preventDefault(),e(s);else{const e=t();navKey(r,e,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>e.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1"))})}})}}define("contour-contour-plot",ContourContourPlot);class ContourErrorBoundary extends ContourBase{static get observed(){return["fallback","error"]}static get properties(){return{fallback:{attribute:"fallback"},error:{attribute:"error"}}}render(){this.classList.add("c-error-boundary"),this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite");if(this.getAttribute("error")){this.dataset.state="error",Array.from(this.children).forEach(t=>{t.hasAttribute("data-fallback")||(void 0===t.dataset.contourDisplay&&(t.dataset.contourDisplay=t.style.display),t.style.display="none")});let t=this.querySelector("[data-fallback]");t?("none"===t.style.display&&(t.style.display=""),("1"===t.dataset.contourGenerated||this.hasAttribute("fallback"))&&(t.textContent=this.getAttribute("fallback")||t.textContent||"Something went wrong.")):(t=document.createElement("div"),t.className="c-error-boundary__fallback",t.dataset.fallback="",t.dataset.contourGenerated="1",t.textContent=this.getAttribute("fallback")||"Something went wrong.",this.appendChild(t))}else this.dataset.state="ready",Array.from(this.children).forEach(t=>{t.hasAttribute("data-fallback")?"1"===t.dataset.contourGenerated?t.remove():t.style.display="none":void 0!==t.dataset.contourDisplay?(t.style.display=t.dataset.contourDisplay,delete t.dataset.contourDisplay):"none"===t.style.display&&(t.style.display="")})}enhance(){this._wiredErrorBoundary||(this._wiredErrorBoundary=!0,this.addEventListener("error",t=>{t.stopPropagation();const e=t&&t.error&&t.error.message?t.error.message:t&&t.message?t.message:"Unknown error",r=t&&t.target&&(t.target.src||t.target.href)?t.target.src||t.target.href:void 0;this.setAttribute("error",e),this.dispatchEvent(new CustomEvent("contour:error",{bubbles:!0,composed:!0,detail:r?{message:e,src:r}:{message:e}}))},!0))}}define("contour-error-boundary",ContourErrorBoundary);class ContourDataExport extends ContourBase{static get observed(){return["data","format","filename","label"]}static get properties(){return{data:{attribute:"data"},format:{attribute:"format"},filename:{attribute:"filename"},label:{attribute:"label"}}}render(){this.classList.add("c-data-export"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"data-export","Data export"));const t=(this.getAttribute("format")||"json").toLowerCase(),e="csv"===t||"json"===t?t:"json",r=this.ensure(".c-data-export__btn",()=>{const t=document.createElement("button");return t.className="c-btn c-data-export__btn",t.type="button",t});setHTML(r,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-download" /></svg>'),r.appendChild(document.createTextNode(" "+(this.getAttribute("label")||labelText(this,"export","Export")+" "+e.toUpperCase()))),r.parentNode!==this&&this.appendChild(r)}enhance(){if(this._wiredDataExport)return;this._wiredDataExport=!0;const t=t=>{let e=null==t?"":String(t);return/^[=+\-@\t\r]/.test(e)&&(e="'"+e),/[",\r\n]/.test(e)?'"'+e.replace(/"/g,'""')+'"':e};this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-data-export__btn"):null;if(!r||!this.contains(r))return;const s=(this.getAttribute("format")||"json").toLowerCase(),i="csv"===s||"json"===s?s:(console.warn("[contour-data-export] unsupported format:",s),"json"),a=this.getAttribute("data")||"[]";let n=a;if("csv"===i)try{const e=JSON.parse(a);if(Array.isArray(e))if(0===e.length)n="";else{const r=Object.keys(e[0]);n=[r.map(t).join(",")].concat(e.map(e=>r.map(r=>t(e[r])).join(","))).join("\r\n")}}catch(t){warnBadJson(this,"data",t)}const o=new Blob(["csv"===i?"\ufeff"+n:n],{type:"csv"===i?"text/csv":"application/json"}),l=URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=this.getAttribute("filename")||"export."+i,document.body.appendChild(c),c.click(),c.remove(),setTimeout(()=>URL.revokeObjectURL(l),0),this.dispatchEvent(new CustomEvent("contour:export",{bubbles:!0,composed:!0,detail:{format:i}}))})}}define("contour-data-export",ContourDataExport);class ContourQueryBuilder extends ContourBase{static get observed(){return["query","fields"]}static get properties(){return{query:{attribute:"query"},fields:{attribute:"fields"}}}readRules(){const t=[],e=Array.from(this.querySelectorAll(".c-query-builder__row")),r=Array.from(this.querySelectorAll(".c-query-builder__connector__op"));return e.forEach((e,s)=>{const i={field:e.querySelector(".c-query-builder__field")?.value||"",op:e.querySelector(".c-query-builder__op")?.value||"=",value:e.querySelector(".c-query-builder__value")?.value||""};s>0&&r[s-1]&&(i.connector=r[s-1].value||"AND");const a=e.closest(".c-query-builder__group");a&&(i.group=a._groupName||""),t.push(i)}),t}static reindexConnectors(t,e){return t.forEach((t,r)=>{r>0&&e&&e[r]?t.connector=e[r]:delete t.connector}),t}attributeChangedCallback(t,e,r){"query"===t&&this._suppressQueryRender||super.attributeChangedCallback(t,e,r)}commit(t,e=!0){if(e)this.setAttribute("query",JSON.stringify(t));else{this._suppressQueryRender=!0;try{this.setAttribute("query",JSON.stringify(t))}finally{this._suppressQueryRender=!1}}this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{query:t}}))}render(){this.classList.add("c-query-builder");const t=this.getAttribute("fields");let e=[];if(t)try{e=JSON.parse(t)}catch(t){e=[]}const r=this.getAttribute("query");let s=[];if(r)try{s=JSON.parse(r)}catch(t){s=[]}const i=this.ensure(".c-query-builder__list",()=>{const t=document.createElement("div");return t.className="c-query-builder__list",t});Array.from(i.querySelectorAll(".c-query-builder__row, .c-query-builder__connector, .c-query-builder__group")).forEach(t=>t.remove());let a=null;s.forEach((t,r)=>{const n=t&&t.group?String(t.group):"",o=!(!n||!a||a._groupName!==n);let l=null;if(r>0){l=document.createElement("div"),l.className="c-query-builder__connector";const e=document.createElement("select");e.className="c-input c-query-builder__connector__op",e.setAttribute("aria-label",labelText(this,"connector","Connector")+" "+r),["AND","OR"].forEach(r=>{const s=document.createElement("option");s.value=r,s.textContent=r,r===(t.connector||"AND")&&(s.selected=!0),e.appendChild(s)}),l.appendChild(e)}if(n)if(o)l&&a.appendChild(l);else{l&&i.appendChild(l),a=document.createElement("div"),a.className="c-query-builder__group",a._groupName=n;const t=document.createElement("div");t.className="c-query-builder__group-head";const e=document.createElement("div");e.className="c-query-builder__group-label",e.textContent=n;const r=document.createElement("button");r.type="button",r.className="c-btn c-btn--sm c-btn--ghost c-query-builder__group-remove",r.setAttribute("aria-label",labelText(this,"remove-group","Remove group")+" "+n),r.setAttribute("data-group",n),r.textContent="×",t.appendChild(e),t.appendChild(r),a.appendChild(t),i.appendChild(a)}else l&&i.appendChild(l),a=null;const c=document.createElement("div");c.className="c-query-builder__row";const u=document.createElement("select");u.className="c-input c-query-builder__field",u.setAttribute("aria-label",labelText(this,"field","Field")+" "+(r+1)),e.forEach(e=>{const r=document.createElement("option");r.value="string"==typeof e?e:e.value||e.label||"",r.textContent="string"==typeof e?e:e.label||e.value||"",r.value===t.field&&(r.selected=!0),u.appendChild(r)});const d=document.createElement("select");d.className="c-input c-query-builder__op",d.setAttribute("aria-label",labelText(this,"operator","Operator")+" "+(r+1)),["=","!=",">","<","contains"].forEach(e=>{const r=document.createElement("option");r.value=e,r.textContent=e,e===t.op&&(r.selected=!0),d.appendChild(r)});const h=document.createElement("input");h.className="c-input c-query-builder__value",h.type="text",h.setAttribute("value",t.value||""),h.value=t.value||"",h.setAttribute("aria-label",labelText(this,"value","Value")+" "+(r+1));const m=document.createElement("button");m.type="button",m.className="c-btn c-btn--sm c-btn--ghost c-query-builder__move c-query-builder__move--up",m.setAttribute("aria-label",labelText(this,"move-rule","Move rule")+" "+(r+1)+" "+labelText(this,"up","up")),m.textContent="↑",0===r&&(m.disabled=!0);const b=document.createElement("button");b.type="button",b.className="c-btn c-btn--sm c-btn--ghost c-query-builder__move c-query-builder__move--down",b.setAttribute("aria-label",labelText(this,"move-rule","Move rule")+" "+(r+1)+" "+labelText(this,"down","down")),b.textContent="↓",r===s.length-1&&(b.disabled=!0);const p=document.createElement("button");p.type="button",p.className="c-btn c-btn--sm c-btn--ghost c-query-builder__remove",p.setAttribute("aria-label",labelText(this,"remove-rule","Remove rule")+" "+(r+1)),p.textContent="×",c.appendChild(u),c.appendChild(d),c.appendChild(h),c.appendChild(m),c.appendChild(b),c.appendChild(p),a?a.appendChild(c):i.appendChild(c)});const n=this.ensure(".c-query-builder__add",()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--sm c-query-builder__add",t});setHTML(n,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>'),n.appendChild(document.createTextNode(" "+labelText(this,"add-rule","Add rule"))),n.parentNode!==this&&this.appendChild(n);const o=this.ensure(".c-query-builder__add-group",()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--sm c-btn--ghost c-query-builder__add-group",t});setHTML(o,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>'),o.appendChild(document.createTextNode(" "+labelText(this,"add-group","Add group"))),o.parentNode!==this&&this.appendChild(o)}enhance(){this._wiredQueryBuilder||(this._wiredQueryBuilder=!0,this.addEventListener("change",t=>{const e=t.target;e instanceof Element&&e.matches(".c-query-builder__field, .c-query-builder__op, .c-query-builder__value, .c-query-builder__connector__op")&&this.commit(this.readRules(),!1)}),this.addEventListener("click",t=>{const e=t.target;if(!(e instanceof Element))return;if(e.closest(".c-query-builder__add")){const t=this.readRules().map(t=>t.connector),e=this.readRules();e.push({field:"",op:"=",value:""}),this.commit(ContourQueryBuilder.reindexConnectors(e,t));const r=this.querySelectorAll(".c-query-builder__row"),s=r[r.length-1],i=s&&s.querySelector(".c-query-builder__field");if(i)try{i.focus()}catch(t){}return}if(e.closest(".c-query-builder__add-group")){const t=this.readRules().map(t=>t.connector),e=this.readRules(),r=new Set(e.map(t=>t.group).filter(Boolean));let s=1;for(;r.has("Group "+s);)s++;e.push({field:"",op:"=",value:"",group:"Group "+s}),this.commit(ContourQueryBuilder.reindexConnectors(e,t));const i=this.querySelectorAll(".c-query-builder__row"),a=i[i.length-1],n=a&&a.querySelector(".c-query-builder__field");if(n)try{n.focus()}catch(t){}return}const r=e.closest(".c-query-builder__group-remove");if(r){const t=r.getAttribute("data-group")||"",e=this.readRules().map(t=>t.connector),s=this.readRules().filter(e=>(e.group||"")!==t);return void this.commit(ContourQueryBuilder.reindexConnectors(s,e))}const s=e.closest(".c-query-builder__move");if(s){const t=s.closest(".c-query-builder__row");if(!t)return;const e=s.classList.contains("c-query-builder__move--up"),r=this.readRules().map(t=>t.connector),i=this.readRules(),a=Array.from(this.querySelectorAll(".c-query-builder__row")).indexOf(t);if(a<0)return;const n=e?a-1:a+1;if(n<0||n>=i.length)return;const o=i[n];i[n]=i[a],i[a]=o,this.commit(ContourQueryBuilder.reindexConnectors(i,r));const l=this.querySelectorAll(".c-query-builder__row")[n],c=l&&l.querySelector(e?".c-query-builder__move--up":".c-query-builder__move--down");if(c&&!c.disabled)try{c.focus()}catch(t){}return}if(e.closest(".c-query-builder__remove")){const t=e.closest(".c-query-builder__row");if(!t)return;const r=this.readRules().map(t=>t.connector),s=this.readRules(),i=Array.from(this.querySelectorAll(".c-query-builder__row")).indexOf(t);i>=0&&s.splice(i,1),this.commit(ContourQueryBuilder.reindexConnectors(s,r))}}))}}function tokenColor(t,e,r,s){const i=safeColor(t.getAttribute(e));if(i)return i;try{const e=getComputedStyle(t).getPropertyValue(r).trim();if(e)return e}catch(t){}return s}define("contour-query-builder",ContourQueryBuilder);class ContourDonutGlyph extends ContourBase{static get observed(){return["size","value","color","stroke-width","bg-color","empty","loading","error","cache-key","no-cache","retry","skeleton","src"]}static get properties(){return{size:{attribute:"size"},value:{attribute:"value"},color:{attribute:"color"},strokeWidth:{attribute:"stroke-width"},bgColor:{attribute:"bg-color"}}}render(){if(this.classList.add("c-donut-glyph"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"donut-glyph","Donut glyph")),wireStates(this),renderStates(this,"donut-glyph"))return;const t=this.querySelector("canvas");t&&t.remove();const e=Number(this.getAttribute("size"))||24,r=document.createElement("canvas");r.width=e,r.height=e,r.style.inlineSize=e+"px",r.style.blockSize=e+"px";const s=r.getContext("2d");s&&(paintDonutGlyph(s,{size:e,value:Number(this.getAttribute("value"))||0,color:tokenColor(this,"color","--color-data","#1f77b4"),strokeWidth:this.getAttribute("stroke-width")?Number(this.getAttribute("stroke-width")):void 0,bgColor:this.getAttribute("bg-color")||"transparent"}),this.appendChild(r))}}define("contour-donut-glyph",ContourDonutGlyph);class ContourSparklineGlyph extends ContourBase{static get observed(){return["size","points","color","stroke-width","bg-color","empty","loading","error","cache-key","no-cache","retry","skeleton","src"]}static get properties(){return{size:{attribute:"size"},points:{attribute:"points"},color:{attribute:"color"},strokeWidth:{attribute:"stroke-width"},bgColor:{attribute:"bg-color"}}}render(){if(this.classList.add("c-sparkline-glyph"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"sparkline-glyph","Sparkline glyph")),wireStates(this),renderStates(this,"sparkline-glyph"))return;const t=this.querySelector("canvas");t&&t.remove();const e=Number(this.getAttribute("size"))||24,r=document.createElement("canvas");r.width=e,r.height=e,r.style.inlineSize=e+"px",r.style.blockSize=e+"px";const s=r.getContext("2d");if(!s)return;let i=[];const a=this.getAttribute("points");if(a)try{const t=JSON.parse(a);i=Array.isArray(t)?t.filter(Number.isFinite):[]}catch(t){warnBadJson(this,"points",t)}paintSparklineGlyph(s,{size:e,values:i,color:tokenColor(this,"color","--color-data","#1f77b4"),strokeWidth:this.getAttribute("stroke-width")?Number(this.getAttribute("stroke-width")):void 0,bgColor:this.getAttribute("bg-color")||"transparent"}),this.appendChild(r)}}define("contour-sparkline-glyph",ContourSparklineGlyph);class ContourPurityRing extends ContourBase{static get observed(){return["size","hue","concentration","color","uncertainty","time-step","time-steps","empty","loading","error","cache-key","no-cache","retry","skeleton","src"]}static get properties(){return{size:{attribute:"size"},hue:{attribute:"hue"},concentration:{attribute:"concentration"},color:{attribute:"color"},uncertainty:{attribute:"uncertainty"},timeStep:{attribute:"time-step"},timeSteps:{attribute:"time-steps"}}}render(){if(this.classList.add("c-purity-ring"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"purity-ring","Purity ring")),wireStates(this),renderStates(this,"purity-ring"))return;const t=this.querySelector("canvas");t&&t.remove();const e=Number(this.getAttribute("size"))||32,r=document.createElement("canvas");r.width=e,r.height=e,r.style.inlineSize=e+"px",r.style.blockSize=e+"px";const s=r.getContext("2d");s&&(paintPurityRing(s,{size:e,hue:Number(this.getAttribute("hue"))||0,concentration:Number(this.getAttribute("concentration"))||0,color:tokenColor(this,"color","--color-data",void 0),uncertainty:Number(this.getAttribute("uncertainty"))||0,timeStep:this.getAttribute("time-step")?Number(this.getAttribute("time-step")):void 0,timeSteps:this.getAttribute("time-steps")?Number(this.getAttribute("time-steps")):4}),this.appendChild(r))}}define("contour-purity-ring",ContourPurityRing);const routeKey=t=>{const e=String(null==t?"":t).trim();if(!e)return"";if(e.startsWith("#"))return"hash:"+e;try{const t="undefined"!=typeof location?location.href:"http://localhost/",r=new URL(e,t);return"path:"+r.pathname.replace(/\/+$/,"")+r.search}catch(t){return"raw:"+e}},hereKey=t=>{const e=String(null==t?"":t).trim();return e?routeKey(e):"undefined"==typeof location?"":"path:"+String(location.pathname||"").replace(/\/+$/,"")+(location.search||"")},hashMatchesHere=t=>{if("undefined"==typeof location)return!1;if(location.hash&&location.hash===t)return!0;const e=String(location.pathname||"").split("/").filter(Boolean).pop()||"";return Boolean(e)&&t==="#"+e};class ContourDocsNav extends ContourBase{static get observed(){return["items","title","current","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","empty","no-cache"]}static get properties(){return{items:{attribute:"items"},title:{attribute:"title"},src:{attribute:"src"}}}render(){this.classList.add("c-docs-nav"),this.setAttribute("role","navigation");const t=this.getAttribute("title");if(t?this.setAttribute("aria-label",t):this.setAttribute("aria-label",labelText(this,"documentation-navigation","Documentation navigation")),wireStates(this),loadRemote(this,"items"),renderStates(this,"docs-nav"))return;const e=remoteData(this,"items"),r=this.hasAttribute("src")?e:e||(this.hasAttribute("items")?this.getAttribute("items"):null),s=this.querySelector(".c-docs-nav__list"),i=s?Array.from(s.children).filter(t=>t.classList&&t.classList.contains("c-docs-nav__group")):[];if(r&&!i.length)try{const t=JSON.parse(r),e=this.ensure(".c-docs-nav__list",()=>{const t=document.createElement("div");return t.className="c-docs-nav__list",t});e.innerHTML="",t.forEach(t=>{const r=document.createElement("div");if(r.className="c-docs-nav__group",t.title){const e=document.createElement("div");e.className="c-docs-nav__group-title",e.textContent=t.title,r.appendChild(e)}const s=document.createElement("div");s.className="c-docs-nav__list",(t.links||t.items||[]).forEach(t=>{const e=document.createElement("a");e.className="c-docs-nav__link",e.href=safeHref("string"==typeof t?"#":t.href||"#");const r="string"==typeof t?t:t.label||t;if("object"==typeof t&&null!==t&&t.badge){const r=document.createElement("span");r.className="c-docs-nav__badge",r.textContent=t.badge,e.appendChild(r)}if(e.appendChild(document.createTextNode(r)),"object"==typeof t&&null!==t&&t.chevron){const t=document.createElement("span");t.className="c-docs-nav__chevron",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),e.appendChild(t)}if("object"==typeof t&&null!==t&&Array.isArray(t.items)){e.classList.add("c-docs-nav__link--nested");const r=document.createElement("div");r.className="c-docs-nav__list c-docs-nav__list--nested",t.items.forEach(t=>{const e=document.createElement("a");e.className="c-docs-nav__link",e.href=safeHref("string"==typeof t?"#":t.href||"#"),e.textContent="string"==typeof t?t:t.label||t,r.appendChild(e)}),s.appendChild(e),s.appendChild(r)}else s.appendChild(e)}),r.appendChild(s),e.appendChild(r)})}catch(t){warnBadJson(this,"attribute",t)}else!r&&s?(s.remove(),renderEmpty(this,"docs-nav")):r||s||renderEmpty(this,"docs-nav");this.applyCurrent()}applyCurrent(){const t=Array.from(this.querySelectorAll(".c-docs-nav__link"));if(!t.length)return;const e=this.getAttribute("current"),r=hereKey(e);t.forEach(t=>{const s=t.getAttribute("href")||"",i=routeKey(s);Boolean(r)&&(i&&i===r||s.startsWith("#")&&!e&&hashMatchesHere(s))?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current")})}enhance(){if(!this._wiredDocsNav&&(this._wiredDocsNav=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-docs-nav__link"):null;if(e&&this.contains(e)){const t=e.textContent||"";this.dispatchEvent(new CustomEvent("contour:docs-nav-select",{bubbles:!0,composed:!0,detail:{label:t,href:e.getAttribute("href")}}))}}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-docs-nav__link"));e.length&&(e.some(t=>0===t.tabIndex)||e.forEach((t,e)=>t.tabIndex=0===e?0:-1),navKey(t,e,{wrap:!0,homeEnd:!0,onNavigate:t=>{e.forEach((e,r)=>e.tabIndex=r===t?0:-1)},onKey:e=>{if("Enter"===e){const e=document.activeElement;e&&(t.preventDefault(),e.click())}}}))}),"undefined"!=typeof window&&window.addEventListener)){const t=()=>this.applyCurrent();window.addEventListener("hashchange",t),window.addEventListener("popstate",t),onDispose(this,()=>{window.removeEventListener("hashchange",t),window.removeEventListener("popstate",t)})}}}define("contour-docs-nav",ContourDocsNav);class ContourDocsShell extends ContourBase{static get observed(){return["title","lede","article","heading"]}static get properties(){return{title:{attribute:"title"},lede:{attribute:"lede"},article:{attribute:"article"}}}render(){this.classList.add("c-docs-shell"),this.setAttribute("role","region");const t=this.getAttribute("title");if(t){this.ensure(".c-docs-shell__title",()=>{const t=document.createElement(headingTag(this,"h2"));return t.className="c-docs-shell__title",t}).textContent=t,this.setAttribute("aria-label",t)}else{const t=this.querySelector(".c-docs-shell__title");t&&t.remove()}const e=this.getAttribute("lede");if(e){this.ensure(".c-docs-shell__lede",()=>{const t=document.createElement("p");return t.className="c-docs-shell__lede",t}).textContent=e}else{const t=this.querySelector(".c-docs-shell__lede");t&&t.remove()}const r=this.getAttribute("article");if(r){setHTML(this.ensure(".c-docs-shell__article",()=>{const t=document.createElement("article");return t.className="c-docs-shell__article",t}),sanitizeHtml(r))}else{const t=this.querySelector(".c-docs-shell__article");t&&t.remove()}}}define("contour-docs-shell",ContourDocsShell);class ContourFileTree extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items"]}static get properties(){return{items:{attribute:"items"}}}render(){this.classList.add("c-file-tree");const t=this.getAttribute("items");if(t)try{const e=JSON.parse(t),r=(t,e)=>{const s=document.createElement("div");s.className="c-file-tree__row"+(t.dir?" c-file-tree__row--dir":"")+(t.active?" c-file-tree__row--active":""),s.style.setProperty("--depth",String(e));const i=document.createElement("span");setHTML(i,t.dir?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-folder" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-file" /></svg>'),i.appendChild(document.createTextNode(" "+(t.label||t.name||""))),s.appendChild(i),this.appendChild(s),Array.isArray(t.children)&&t.children.forEach(t=>r(t,e+1))};Array.from(this.querySelectorAll(".c-file-tree__row")).forEach(t=>t.remove()),e.forEach(t=>r(t,0))}catch(t){warnBadJson(this,"attribute",t)}}}define("contour-file-tree",ContourFileTree);class ContourChangelog extends ContourBase{static get observed(){return["src","max","loading","error"]}static get properties(){return{src:{attribute:"src"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-changelog");const t=this.getAttribute("src");if(t){if(this.dataset.loaded===t)return;this.dataset.loaded="";const e=this.ensure(".c-changelog__loading",()=>{const t=document.createElement("div");return t.className="c-changelog__loading",t});e.textContent=labelText(this,"loading","Loading…"),Array.from(this.querySelectorAll(".c-changelog__entry, .c-changelog__error")).forEach(t=>t.remove()),this.querySelector(".c-changelog__loading")||this.appendChild(e);try{this._changelogAbort&&this._changelogAbort.abort()}catch(t){}this._changelogAbort="undefined"!=typeof AbortController?new AbortController:null,fetch(t,this._changelogAbort?{signal:this._changelogAbort.signal}:void 0).then(t=>{if(!t.ok)throw new Error("HTTP "+t.status);return t.text()}).then(e=>{if(!this.isConnected)return;const r=this.querySelector(".c-changelog__loading");r&&r.remove(),this.dataset.loaded=t;const s=parseChangelog(e),i=parseInt(this.getAttribute("max")||"0",10),a=i>0?s.slice(0,i):s;if(!a.length){const t=document.createElement("div");return t.className="c-changelog__empty",t.textContent=labelText(this,"empty","No releases found."),void this.appendChild(t)}a.forEach(t=>{const e=document.createElement("details");e.className="c-changelog__entry";const r=document.createElement("summary");r.className="c-changelog__summary";const s=document.createElement("span");if(s.className="c-changelog__version",s.textContent=t.version,r.appendChild(s),t.date){const e=document.createElement("span");e.className="c-changelog__date",e.textContent=t.date,r.appendChild(e)}e.appendChild(r);const i=document.createElement("div");i.className="c-changelog__body",setHTML(i,renderChangelogBody(t.body)),e.appendChild(i),this.appendChild(e)})}).catch(t=>{if(!this.isConnected)return;const e=this.querySelector(".c-changelog__loading");e&&e.remove();const r=document.createElement("div");r.className="c-changelog__error",r.textContent=labelText(this,"load-error","Failed to load changelog")+": "+(t&&t.message?t.message:t),this.appendChild(r)})}}disconnectedCallback(){super.disconnectedCallback();try{this._changelogAbort&&this._changelogAbort.abort()}catch(t){}this._changelogAbort=null}}function parseChangelog(t){const e=String(t).split(/\r?\n/),r=[];let s=null;for(const t of e){const e=t.match(/^##\s+\[?([^\]\n]+)\]?\s*[-–—]?\s*(.*)$/);if(e&&t.startsWith("## ")){const t=e[1].trim(),i=e[2].trim();if(/^\d|unreleased/i.test(t)){s&&r.push(s),s={version:t,date:i.replace(/^[-–—]\s*/,"").trim(),body:""};continue}}s&&(s.body+=t+"\n")}return s&&r.push(s),r}function escapeHtml(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function renderChangelogBody(t){const e=String(t).trim().split(/\r?\n/),r=[];let s=!1;for(const t of e){const e=t.trimEnd();/^###\s+/.test(e)?(s&&(r.push("</ul>"),s=!1),r.push("<h3>"+escapeHtml(e.replace(/^###\s+/,""))+"</h3>")):/^##\s+/.test(e)?(s&&(r.push("</ul>"),s=!1),r.push("<h2>"+escapeHtml(e.replace(/^##\s+/,""))+"</h2>")):/^#\s+/.test(e)?(s&&(r.push("</ul>"),s=!1),r.push("<h2>"+escapeHtml(e.replace(/^#\s+/,""))+"</h2>")):/^[-*]\s+/.test(e)?(s||(r.push("<ul>"),s=!0),r.push("<li>"+escapeHtml(e.replace(/^[-*]\s+/,""))+"</li>")):""===e.trim()?s&&(r.push("</ul>"),s=!1):(s&&(r.push("</ul>"),s=!1),r.push("<p>"+escapeHtml(e)+"</p>"))}return s&&r.push("</ul>"),r.join("")}function engageInitialModal(t){if(!t.hasAttribute("open")||t._modalEngaged)return;t._modalEngaged=!0,t.setAttribute("aria-modal","true"),modalContain(t,!0);const e=t.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(e)try{e.focus()}catch(t){}}function syncDeclarativeOpen(t,e,r,s){if("open"===e&&s&&!t._declarativeOpen){t._declarativeOpen=!0;try{null===r||t.hasAttribute("aria-modal")?null===r&&t.hasAttribute("aria-modal")&&t.close():(t.removeAttribute("open"),t.show())}finally{t._declarativeOpen=!1}}}define("contour-changelog",ContourChangelog);class ContourDialog extends ContourBase{static get observed(){return["title","size","heading","open"]}static get properties(){return{title:{attribute:"title"},size:{attribute:"size"}}}attributeChangedCallback(t,e,r){"open"!==t?super.attributeChangedCallback(t,e,r):syncDeclarativeOpen(this,t,r,this._wiredDialog)}showModal(){this.show()}get open(){return this.hasAttribute("open")}set open(t){t?this.show():this.close()}render(){this.classList.add("c-dialog"),Array.from(this.classList).forEach(t=>{t.startsWith("c-dialog--")&&this.classList.remove(t)});const t=this.getAttribute("size");t&&this.classList.add("c-dialog--"+t),this.hasAttribute("role")||this.setAttribute("role","dialog");const e=this.getAttribute("title");let r=this.querySelector(".c-dialog__head");if(e){if(!r){r=document.createElement("div"),r.className="c-dialog__head";const t=document.createElement(headingTag(this,"h2"));t.className="c-dialog__title",r.appendChild(t);const e=document.createElement("button");e.className="c-btn c-btn--icon c-btn--ghost c-dialog__close",e.setAttribute("type","button"),e.setAttribute("aria-label",labelText(this,"close","Close")),setHTML(e,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-x" /></svg>'),r.appendChild(e)}const t=r.querySelector(".c-dialog__title");t&&(t.textContent=e,t.id||(t.id=contourId("contour-dialog-title")),this.setAttribute("aria-labelledby",t.id))}r&&r.parentNode!==this&&this.prepend(r);const s=this.ensure(".c-dialog__body",()=>{const t=document.createElement("div");return t.className="c-dialog__body",t});Array.from(this.childNodes).forEach(t=>{t!==s&&t!==r&&(1===t.nodeType&&t.classList&&t.classList.contains("c-dialog__head")||s.appendChild(t))}),r&&r.parentNode===this?(s.parentNode!==this||r.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_PRECEDING)&&this.insertBefore(s,r.nextSibling):s.parentNode!==this&&this.appendChild(s)}enhance(){this._wiredDialog||(this._wiredDialog=!0,this.returnValue="",onDispose(this,()=>{this.hasAttribute("open")&&modalContain(this,!1)}),this.show=()=>{if(this.hasAttribute("open"))return;this._dialogLastFocus=document.activeElement,this._declarativeOpen=!0;try{this.setAttribute("open","")}finally{this._declarativeOpen=!1}this.setAttribute("aria-modal","true");const t=this.querySelector("dialog")||("DIALOG"===this.tagName?this:null);if(t&&"function"==typeof t.showModal)try{t.showModal()}catch(t){}modalContain(this,!0);const e=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(e)try{e.focus()}catch(t){}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}))},this.close=()=>{const t=this.hasAttribute("open")||this.hasAttribute("aria-modal"),e=this.querySelector("dialog")||("DIALOG"===this.tagName?this:null);e&&"function"==typeof e.close&&e.close(),this._declarativeOpen=!0;try{this.hasAttribute("open")&&this.removeAttribute("open")}finally{this._declarativeOpen=!1}if(this.removeAttribute("aria-modal"),t){modalContain(this,!1),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}));const t=this._dialogLastFocus;if(t&&"function"==typeof t.focus)try{t.focus()}catch(t){}}},this.focus=()=>{const t=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(t)try{t.focus()}catch(t){}else try{HTMLElement.prototype.focus.call(this)}catch(t){}},this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-dialog__close"):null;(e&&this.contains(e)||t.target===this)&&this.close()}),this.addEventListener("keydown",t=>{"Escape"===t.key&&this.hasAttribute("open")&&this.close()}),engageInitialModal(this))}}define("contour-dialog",ContourDialog);class ContourAlert extends ContourBase{static get observed(){return["title","body","variant","icon","closable","action","actions","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},variant:{attribute:"variant"},icon:{attribute:"icon"},closable:{attribute:"closable",type:Boolean},action:{attribute:"action"},actions:{attribute:"actions"}}}render(){this.classList.add("c-alert");const t=/^(warning|danger)$/.test(this.getAttribute("variant")||""),e=t?"alert":"status",r=t?"assertive":"polite";if(this.hasAttribute("role")&&this.getAttribute("role")!==this._autoRole||(this.setAttribute("role",e),this._autoRole=e),this.hasAttribute("aria-live")&&this.getAttribute("aria-live")!==this._autoLive||(this.setAttribute("aria-live",r),this._autoLive=r),wireStates(this),loadRemote(this,"title"),renderStates(this,"alert"))return;const s=this.getAttribute("variant");Array.from(this.classList).forEach(t=>{t.startsWith("c-alert--")&&this.classList.remove(t)}),s&&this.classList.add("c-alert--"+s);const i=this.getAttribute("icon"),a="none"===i?"":i||statusIcon(s);if(a){const t=this.ensure(".c-alert__icon",()=>{const t=document.createElement("span");return t.className="c-alert__icon",t});t.parentNode===this&&this.firstChild!==t&&this.prepend(t),setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+String(a).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>')}else{const t=this.querySelector(".c-alert__icon");t&&t.remove()}const n=this.getAttribute("title")||this._remoteData&&this._remoteData.title;if(n){const t=this.ensure(".c-alert__title",()=>{const t=document.createElement("div");return t.className="c-alert__title",t});t.parentNode===this&&this.firstChild!==t&&this.prepend(t),t.textContent=n}else{const t=this.querySelector(".c-alert__title");t&&t.remove()}const o=this.getAttribute("body"),l=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!(t.classList.contains("c-alert__icon")||t.classList.contains("c-alert__title")||t.classList.contains("c-alert__body")))&&!(3===t.nodeType&&!t.textContent.trim()));if(l.length){const t=this.ensure(".c-alert__body",()=>{const t=document.createElement("div");return t.className="c-alert__body",t});t.textContent="";for(const e of l)t.appendChild(e)}else if(o){this.ensure(".c-alert__body",()=>{const t=document.createElement("div");return t.className="c-alert__body",t}).textContent=o}else{const t=this.querySelector(".c-alert__body");t&&t.remove()}Array.from(this.querySelectorAll(".c-alert__action")).forEach(t=>t.remove());const c=this.getAttribute("actions");let u=[];if(c)try{const t=JSON.parse(c);Array.isArray(t)&&(u=t.map(t=>String(t)))}catch(t){u=[c]}else{const t=this.getAttribute("action");t&&(u=[t])}if(u.forEach(t=>{const e=document.createElement("button");e.className="c-btn c-btn--sm c-alert__action",e.type="button",e.setAttribute("data-alert-action",""),e.textContent=t,this.appendChild(e)}),flagOn(this,"closable"))this.ensure(".c-alert__close",()=>{const t=document.createElement("button");return t.className="c-alert__close",t.type="button",t.setAttribute("aria-label",labelText(this,"close","Close")),t.textContent="×",t});else{const t=this.querySelector(".c-alert__close");t&&t.remove()}n||o||a||l.length||renderEmpty(this,"alert")}}ContourAlert.prototype.enhance=function(){this._wiredAlert||(this._wiredAlert=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-alert__action"):null;if(e&&this.contains(e))return t.preventDefault(),void this.dispatchEvent(new CustomEvent("contour:action",{bubbles:!0,composed:!0,detail:{label:e.textContent.trim()}}));const r=t.target&&t.target.closest?t.target.closest(".c-alert__close"):null;r&&this.contains(r)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})),this.remove())}))},define("contour-alert",ContourAlert);class ContourDisclosure extends ContourBase{static get observed(){return["summary","icon"]}static get properties(){return{summary:{attribute:"summary"},icon:{attribute:"icon"}}}disconnectedCallback(){this._disclosureContent=null,super.disconnectedCallback()}connectedCallback(){this.innerHTML.trim()&&!this._disclosureContent&&(this._disclosureContent=this.innerHTML),super.connectedCallback()}attributeChangedCallback(t,e,r){const s=this.querySelector("details");if(s){const t=s.querySelector(".c-disclosure__body");t&&(this._disclosureContent=t.innerHTML)}else this.innerHTML.trim()&&(this._disclosureContent=this.innerHTML);super.attributeChangedCallback(t,e,r)}render(){this.classList.add("c-disclosure");const t=this.getAttribute("summary"),e=this.getAttribute("icon");if(t){let r=this.innerHTML.trim()?this.innerHTML:this._disclosureContent||"";r.trim()&&(this._disclosureContent=r);const s=this.ensure("details",()=>{const s=document.createElement("details"),i=document.createElement("summary");if(i.className="c-disclosure__summary",e){const t=document.createElement("span");t.className="c-disclosure__icon",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+String(e).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'),i.appendChild(t)}i.appendChild(document.createTextNode(t)),s.appendChild(i);const a=document.createElement("div");return a.className="c-disclosure__body",setHTML(a,r),s.appendChild(a),s}),i=s.querySelector("summary");if(i){const r=i.querySelector(".c-disclosure__icon");if(e&&!r){const t=document.createElement("span");t.className="c-disclosure__icon",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+String(e).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'),i.insertBefore(t,i.firstChild)}else!e&&r&&r.remove();Array.from(i.childNodes).filter(t=>3===t.nodeType).forEach(t=>t.remove()),i.appendChild(document.createTextNode(t))}const a=s.querySelector(".c-disclosure__body");a&&setHTML(a,r),s.parentNode!==this&&(setHTML(this,""),this.appendChild(s))}else{const t=this.querySelector("details");t&&t.remove()}}enhance(){this._wiredDisclosure||(this._wiredDisclosure=!0,this.addEventListener("toggle",t=>{const e=t.target;e&&"DETAILS"===e.tagName&&this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:e.open},bubbles:!0,composed:!0}))},!0))}}define("contour-disclosure",ContourDisclosure);class ContourCallout extends ContourBase{static get observed(){return["variant","title","icon","closable"]}static get properties(){return{variant:{attribute:"variant"},title:{attribute:"title"},icon:{attribute:"icon"},closable:{attribute:"closable",type:Boolean}}}render(){this.classList.add("c-callout"),this.hasAttribute("role")||this.setAttribute("role","note"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Callout"),Array.from(this.classList).forEach(t=>{t.startsWith("c-callout--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-callout--"+t);const e=this.getAttribute("icon"),r="none"===e?"":e||statusIcon(t);if(r){const t=this.ensure(".c-callout__icon",()=>{const t=document.createElement("span");return t.className="c-callout__icon",t});t.parentNode===this&&this.firstChild!==t&&this.prepend(t),setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+String(r).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>')}else{const t=this.querySelector(".c-callout__icon");t&&t.remove()}const s=this.getAttribute("title");if(s){const t=this.ensure(".c-callout__title",()=>{const t=document.createElement("div");return t.className="c-callout__title",t});t.parentNode===this&&this.firstChild!==t&&this.prepend(t),t.textContent=s}else{const t=this.querySelector(".c-callout__title");t&&t.remove()}if(flagOn(this,"closable"))this.ensure(".c-callout__close",()=>{const t=document.createElement("button");return t.className="c-callout__close",t.type="button",t.setAttribute("aria-label",labelText(this,"close","Close")),t.textContent="×",t});else{const t=this.querySelector(".c-callout__close");t&&t.remove()}}}ContourCallout.prototype.enhance=function(){this._wiredCallout||(this._wiredCallout=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-callout__close"):null;e&&this.contains(e)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})),this.remove())}))},define("contour-callout",ContourCallout);class ContourEmpty extends ContourBase{static get observed(){return["state","title","body","action","icon","illustration","heading"]}static get properties(){return{state:{attribute:"state"},title:{attribute:"title"},body:{attribute:"body"},action:{attribute:"action"},icon:{attribute:"icon"},illustration:{attribute:"illustration"}}}render(){this.classList.add("c-empty"),this.hasAttribute("role")||this.setAttribute("role","status");const t=this.getAttribute("state")||"empty",e=this.getAttribute("title")||("filtered"===t?"Nothing matches":"error"===t?"Could not load":"No data yet"),r=this.getAttribute("body")||("filtered"===t?"Try clearing some filters.":"error"===t?"Check your connection and try again.":"There is nothing to show here yet."),s=this.getAttribute("action")||("filtered"===t?"Clear filters":"error"===t?"Retry":""),i=this.getAttribute("icon");if(i){setHTML(this.ensure(".c-empty__icon",()=>{const t=document.createElement("span");return t.className="c-empty__icon",t}),'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+String(i).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>')}else{const t=this.querySelector(".c-empty__icon");t&&t.remove()}const a=this.getAttribute("illustration");if(a){setHTML(this.ensure(".c-empty__illustration",()=>{const t=document.createElement("div");return t.className="c-empty__illustration",t}),sanitizeHtml(a))}else{const t=this.querySelector(".c-empty__illustration");t&&t.remove()}if(e){this.ensure(".c-empty__title",()=>{const t=document.createElement(headingTag(this,"h3"));return t.className="c-empty__title",t}).textContent=e}else{const t=this.querySelector(".c-empty__title");t&&t.remove()}if(r){this.ensure(".c-empty__text",()=>{const t=document.createElement("p");return t.className="c-empty__text",t}).textContent=r}else{const t=this.querySelector(".c-empty__text");t&&t.remove()}if(s){this.ensure("button.c-btn[data-empty-action]",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--primary",t.type="button",t.setAttribute("data-empty-action",""),t}).textContent=s}else{const t=this.querySelector("[data-empty-action]");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-empty",ContourEmpty);class ContourFaq extends ContourBase{static get observed(){return["question","answer","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{question:{attribute:"question"},answer:{attribute:"answer"},items:{attribute:"items"},src:{attribute:"src"}}}render(){if(this.classList.add("c-faq"),wireStates(this),loadRemote(this,"items"),renderStates(this,"faq"))return;const t=remoteData(this,"items"),e=this.getAttribute("question"),r=this.getAttribute("answer"),s=Array.from(this.children).filter(t=>t.classList&&t.classList.contains("c-faq__item"));if(t&&!s.length)try{const e=JSON.parse(t);Array.from(this.querySelectorAll(".c-faq__item")).forEach(t=>t.remove()),e.forEach((t,e)=>{const r=document.createElement("details");r.className="c-faq__item",0===e&&r.setAttribute("open","");const s=document.createElement("summary");s.className="c-faq__question",s.textContent="string"==typeof t?t:t.question||t.q||"";const i=document.createElement("span");i.className="c-faq__sign",i.setAttribute("aria-hidden","true"),setHTML(i,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>'),s.appendChild(i),r.appendChild(s);const a=document.createElement("div");a.className="c-faq__answer",a.textContent="string"==typeof t?"":t.answer||t.a||"",r.appendChild(a),this.appendChild(r)})}catch(t){warnBadJson(this,"attribute",t)}else if(!t)if(e||r){const t=this.ensure("details.c-faq__item",()=>{const t=document.createElement("details");return t.className="c-faq__item",t});t.hasAttribute("open")||t.setAttribute("open","");const s=this.ensure("summary.c-faq__question",()=>{const t=document.createElement("summary");return t.className="c-faq__question",t},t);s.textContent=e||"";const i=this.ensure(".c-faq__sign",()=>{const t=document.createElement("span");return t.className="c-faq__sign",t},s);i.setAttribute("aria-hidden","true"),setHTML(i,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>');this.ensure(".c-faq__answer",()=>{const t=document.createElement("div");return t.className="c-faq__answer",t},t).textContent=r||""}else renderEmpty(this,"faq")}}define("contour-faq",ContourFaq);class ContourAccordion extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","exclusive","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},exclusive:{attribute:"exclusive",type:Boolean},src:{attribute:"src"}}}render(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"accordion","Accordion"));const t=Array.from(this.children).filter(t=>"DETAILS"===t.tagName);if(wireStates(this),loadRemote(this,"items"),renderStates(this,"accordion"))return;const e=remoteData(this,"items");if(e&&!t.length){Array.from(this.querySelectorAll("details.c-disclosure")).forEach(t=>t.remove());try{JSON.parse(e).forEach(t=>{const e=document.createElement("details");e.className="c-disclosure";const r=document.createElement("summary");r.className="c-disclosure__summary",r.textContent=t.title||t.question||t.q||t.label||"",e.appendChild(r);const s=document.createElement("div");s.className="c-disclosure__body",s.textContent=t.body||t.answer||t.a||t.content||"",e.appendChild(s),this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}}else e||t.length||renderEmpty(this,"accordion");const r=this.getAttribute("persist");if(r){let t=null;if("storage"===r&&this.id)try{t=localStorage.getItem("contour-accordion:"+this.id)}catch(t){}else if("url"===r)try{t=new URLSearchParams(window.location.search).get("c-accordion")}catch(t){}if(null!==t)try{const e=JSON.parse(t);if(Array.isArray(e)){const t=new Set(e.map(t=>String(t)));Array.from(this.querySelectorAll("details.c-disclosure")).forEach(e=>{const r=e.querySelector("summary"),s=(r?r.textContent:"").trim().slice(0,120);t.has(s)&&(e.open=!0)})}}catch(t){}}}enhance(){this._wiredAccordion||(this._wiredAccordion=!0,this.addEventListener("toggle",t=>{const e=t.target;if(e&&"DETAILS"===e.tagName){e.open&&this.hasAttribute("exclusive")&&Array.from(this.querySelectorAll("details.c-disclosure")).forEach(t=>{t!==e&&(t.open=!1)}),this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:e.open},bubbles:!0,composed:!0}));const r=this.getAttribute("persist");if("storage"===r&&this.id)try{const t=[];Array.from(this.querySelectorAll("details.c-disclosure")).forEach(e=>{if(e.open){const r=e.querySelector("summary");t.push((r?r.textContent:"").trim().slice(0,120))}}),localStorage.setItem("contour-accordion:"+this.id,JSON.stringify(t))}catch(t){}else if("url"===r)try{const t=[];Array.from(this.querySelectorAll("details.c-disclosure")).forEach(e=>{if(e.open){const r=e.querySelector("summary");t.push((r?r.textContent:"").trim().slice(0,120))}});const e=new URL(window.location.href);e.searchParams.set("c-accordion",JSON.stringify(t)),window.history.replaceState(null,"",e.toString())}catch(t){}}},!0))}}define("contour-accordion",ContourAccordion);class ContourDrawer extends ContourBase{static get observed(){return["title","body","size","open"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},size:{attribute:"size"}}}attributeChangedCallback(t,e,r){"open"!==t?super.attributeChangedCallback(t,e,r):syncDeclarativeOpen(this,t,r,this._wiredDrawer)}showModal(){this.show()}get open(){return this.hasAttribute("open")}set open(t){t?this.show():this.close()}render(){this.classList.add("c-drawer"),Array.from(this.classList).forEach(t=>{t.startsWith("c-drawer--")&&this.classList.remove(t)});const t=this.getAttribute("size");t&&this.classList.add("c-drawer--"+t),this.hasAttribute("role")||this.setAttribute("role","dialog");const e=this.getAttribute("title");let r=this.querySelector(".c-drawer__head");if(e){if(!r){r=document.createElement("div"),r.className="c-drawer__head";const t=document.createElement("div");t.className="c-drawer__title",r.appendChild(t);const e=document.createElement("button");e.className="c-btn c-btn--icon c-btn--ghost c-drawer__close",e.setAttribute("type","button"),e.setAttribute("aria-label",labelText(this,"close","Close")),setHTML(e,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-x" /></svg>'),r.appendChild(e)}const t=r.querySelector(".c-drawer__title");t&&(t.textContent=e,t.id||(t.id=contourId("contour-drawer-title")),this.setAttribute("aria-labelledby",t.id)),r.parentNode!==this&&this.prepend(r)}else if(r){const t=r.querySelector(".c-drawer__title");t&&t.id&&this.getAttribute("aria-labelledby")===t.id&&this.removeAttribute("aria-labelledby"),r.remove()}this.hasAttribute("open")?this.classList.add("is-open"):this.classList.remove("is-open");const s=this.getAttribute("body"),i=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-drawer__head")&&!t.classList.contains("c-drawer__body"))&&!(3===t.nodeType&&!t.textContent.trim()));if(i.length){const t=this.ensure(".c-drawer__body",()=>{const t=document.createElement("div");return t.className="c-drawer__body",t});for(const e of i)t.appendChild(e)}else if(s){setHTML(this.ensure(".c-drawer__body",()=>{const t=document.createElement("div");return t.className="c-drawer__body",t}),sanitizeHtml(s))}else{const t=this.querySelector(".c-drawer__body");t&&t.remove()}}enhance(){if(this._wiredDrawer)return;this._wiredDrawer=!0,this.returnValue="",onDispose(this,()=>{this.hasAttribute("open")&&modalContain(this,!1)}),this._drawerLastFocus=null,this.show=()=>{if(this.hasAttribute("open"))return;this._drawerLastFocus=document.activeElement,this._declarativeOpen=!0;try{this.setAttribute("open","")}finally{this._declarativeOpen=!1}this.setAttribute("aria-modal","true"),this.classList.add("is-open"),modalContain(this,!0);const t=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(t)try{t.focus()}catch(t){}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}))},this.close=()=>{if(!this.hasAttribute("open")&&!this.hasAttribute("aria-modal"))return;this._declarativeOpen=!0;try{this.removeAttribute("open")}finally{this._declarativeOpen=!1}this.removeAttribute("aria-modal"),this.classList.remove("is-open"),modalContain(this,!1),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}));const t=this._drawerLastFocus;if(t&&"function"==typeof t.focus)try{t.focus()}catch(t){}},this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-drawer__close"):null;(e&&this.contains(e)||t.target===this)&&this.close()}),this.addEventListener("keydown",t=>{"Escape"===t.key&&this.hasAttribute("open")&&this.close()});let t=0,e=0;this.addEventListener("touchstart",r=>{if(!this.hasAttribute("open"))return;const s=r.touches&&r.touches[0];s&&(t=s.clientX,e=s.clientY)},{passive:!0}),this.addEventListener("touchend",r=>{if(!this.hasAttribute("open"))return;const s=r.changedTouches&&r.changedTouches[0];if(!s)return;const i=s.clientX-t,a=s.clientY-e;Math.abs(i)>60&&Math.abs(i)>1.5*Math.abs(a)&&this.close()},{passive:!0}),engageInitialModal(this)}}define("contour-drawer",ContourDrawer);class ContourSheet extends ContourBase{static get observed(){return["title","body","size","open"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},size:{attribute:"size"}}}attributeChangedCallback(t,e,r){"open"!==t?super.attributeChangedCallback(t,e,r):syncDeclarativeOpen(this,t,r,this._wiredSheet)}showModal(){this.show()}get open(){return this.hasAttribute("open")}set open(t){t?this.show():this.close()}render(){this.classList.add("c-sheet"),Array.from(this.classList).forEach(t=>{t.startsWith("c-sheet--")&&this.classList.remove(t)});const t=this.getAttribute("size");t&&this.classList.add("c-sheet--"+t),this.hasAttribute("role")||this.setAttribute("role","dialog");const e=this.getAttribute("title");let r=this.querySelector(".c-sheet__head");if(e){if(!r){r=document.createElement("div"),r.className="c-sheet__head";const t=document.createElement("div");t.className="c-sheet__title",r.appendChild(t);const e=document.createElement("button");e.className="c-btn c-btn--icon c-btn--ghost c-sheet__close",e.setAttribute("type","button"),e.setAttribute("aria-label",labelText(this,"close","Close")),setHTML(e,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-x" /></svg>'),r.appendChild(e)}const t=r.querySelector(".c-sheet__title");t&&(t.textContent=e,t.id||(t.id=contourId("contour-sheet-title")),this.setAttribute("aria-labelledby",t.id)),r.parentNode!==this&&this.prepend(r)}else if(r){const t=r.querySelector(".c-sheet__title");t&&t.id&&this.getAttribute("aria-labelledby")===t.id&&this.removeAttribute("aria-labelledby"),r.remove()}this.hasAttribute("open")?this.classList.add("is-open"):this.classList.remove("is-open");const s=this.getAttribute("body"),i=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-sheet__head")&&!t.classList.contains("c-sheet__body"))&&!(3===t.nodeType&&!t.textContent.trim()));if(i.length){const t=this.ensure(".c-sheet__body",()=>{const t=document.createElement("div");return t.className="c-sheet__body",t});for(const e of i)t.appendChild(e)}else if(s){setHTML(this.ensure(".c-sheet__body",()=>{const t=document.createElement("div");return t.className="c-sheet__body",t}),sanitizeHtml(s))}else{const t=this.querySelector(".c-sheet__body");t&&t.remove()}}enhance(){if(this._wiredSheet)return;this._wiredSheet=!0,this.returnValue="",onDispose(this,()=>{this.hasAttribute("open")&&modalContain(this,!1)}),this._sheetLastFocus=null,this.show=()=>{if(this.hasAttribute("open"))return;this._sheetLastFocus=document.activeElement,this._declarativeOpen=!0;try{this.setAttribute("open","")}finally{this._declarativeOpen=!1}this.setAttribute("aria-modal","true"),this.classList.add("is-open"),modalContain(this,!0);const t=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(t)try{t.focus()}catch(t){}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}))},this.close=()=>{if(!this.hasAttribute("open")&&!this.hasAttribute("aria-modal"))return;this._declarativeOpen=!0;try{this.removeAttribute("open")}finally{this._declarativeOpen=!1}this.removeAttribute("aria-modal"),this.classList.remove("is-open"),modalContain(this,!1),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}));const t=this._sheetLastFocus;if(t&&"function"==typeof t.focus)try{t.focus()}catch(t){}},this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-sheet__close"):null;(e&&this.contains(e)||t.target===this)&&this.close()}),this.addEventListener("keydown",t=>{"Escape"===t.key&&this.hasAttribute("open")&&this.close()});let t=0,e=0;this.addEventListener("touchstart",r=>{if(!this.hasAttribute("open"))return;const s=r.touches&&r.touches[0];s&&(e=s.clientX,t=s.clientY)},{passive:!0}),this.addEventListener("touchend",r=>{if(!this.hasAttribute("open"))return;const s=r.changedTouches&&r.changedTouches[0];if(!s)return;const i=s.clientY-t,a=s.clientX-e;i>60&&Math.abs(i)>1.5*Math.abs(a)&&this.close()},{passive:!0}),engageInitialModal(this)}}define("contour-sheet",ContourSheet);class ContourToast extends ContourBase{static get observed(){return["message","variant","duration","action","icon"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"},duration:{attribute:"duration",type:Number},action:{attribute:"action"}}}render(){this.classList.add("c-toast"),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.hasAttribute("aria-atomic")||this.setAttribute("aria-atomic","true");const t=this.getAttribute("message");t&&!this.hasChildNodes()&&(this.textContent=t);const e=this.getAttribute("variant");Array.from(this.classList).forEach(t=>{t.startsWith("c-toast--")&&this.classList.remove(t)}),e&&this.classList.add("c-toast--"+e);const r=this.getAttribute("icon"),s="none"===r?"":r||statusIcon(e);let i=this.querySelector(".c-toast__icon");s?(i||(i=document.createElement("span"),i.className="c-toast__icon"),setHTML(i,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+String(s).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'),this.firstChild!==i&&this.prepend(i)):i&&i.remove();const a=this.getAttribute("action");let n=this.querySelector(".c-toast__action");a?(n||(n=document.createElement("button"),n.className="c-toast__action",n.type="button",this.appendChild(n)),n.textContent=a):n&&n.remove();let o=this.querySelector(".c-toast__close");o||(o=document.createElement("button"),o.className="c-toast__close",o.type="button",o.setAttribute("aria-label",labelText(this,"close","Close")),o.textContent="×",this.appendChild(o))}enhance(){if(this._wiredToast)return;this._wiredToast=!0,this.addEventListener("click",t=>{(t.target&&t.target.closest?t.target.closest(".c-toast__close"):null)&&(t.preventDefault(),this._dismiss())});const t=()=>{clearTimeout(this._toastTimer),this._toastTimer=null};this.addEventListener("mouseenter",t),this.addEventListener("focusin",t),this.addEventListener("mouseleave",()=>this._arm()),this.addEventListener("focusout",()=>this._arm()),this._arm(),onDispose(this,()=>clearTimeout(this._toastTimer))}_durationMs(){const t=null!=this._toastDuration?Number(this._toastDuration):Number(this.duration);return 0===t?0:t>0?t:4e3}_arm(){clearTimeout(this._toastTimer),this._toastTimer=null;const t=this._durationMs();t>0&&(this._toastTimer=setTimeout(()=>this._dismiss(),t))}_dismiss(){clearTimeout(this._toastTimer),this._toastTimer=null,this.setAttribute("hidden",""),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))}show(t,e){const r=null!=t?String(t):this.getAttribute("message"),s=e&&e.variant||this.getAttribute("variant"),i=e&&e.action||this.getAttribute("action");r&&!this.hasChildNodes()&&(this.textContent=r),Array.from(this.classList).forEach(t=>{t.startsWith("c-toast--")&&this.classList.remove(t)}),s&&this.classList.add("c-toast--"+s);let a=this.querySelector(".c-toast__action");i?(a||(a=document.createElement("button"),a.className="c-toast__action",a.type="button",this.appendChild(a)),a.textContent=i):a&&a.remove(),e&&null!=e.duration&&(this._toastDuration=Number(e.duration)),this.removeAttribute("hidden"),this._arm()}}define("contour-toast",ContourToast);class ContourExpandable extends ContourBase{static get observed(){return["summary"]}static get properties(){return{summary:{attribute:"summary"}}}disconnectedCallback(){this._expandableContent=null,super.disconnectedCallback()}connectedCallback(){this.innerHTML.trim()&&!this._expandableContent&&(this._expandableContent=this.innerHTML),super.connectedCallback()}attributeChangedCallback(t,e,r){const s=this.querySelector("details");if(s){const t=s.querySelector(".c-expandable__body");t&&(this._expandableContent=t.innerHTML)}else this.innerHTML.trim()&&(this._expandableContent=this.innerHTML);super.attributeChangedCallback(t,e,r)}render(){this.classList.add("c-expandable"),this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("summary")||"Expandable");const t=this.getAttribute("summary");if(t){let e=this.innerHTML.trim()?this.innerHTML:this._expandableContent||"";e.trim()&&(this._expandableContent=e);const r=this.ensure("details",()=>{const r=document.createElement("details"),s=document.createElement("summary");s.className="c-expandable__summary",s.textContent=t,r.appendChild(s);const i=document.createElement("div");return i.className="c-expandable__body",setHTML(i,e),r.appendChild(i),r}),s=r.querySelector("summary");s&&(s.textContent=t);const i=r.querySelector(".c-expandable__body");i&&setHTML(i,e),r.parentNode!==this&&(setHTML(this,""),this.appendChild(r))}else{const t=this.querySelector("details");t&&t.remove()}}enhance(){this._wiredExpandable||(this._wiredExpandable=!0,this.addEventListener("toggle",t=>{const e=t.target;e&&"DETAILS"===e.tagName&&this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:e.open},bubbles:!0,composed:!0}))},!0))}}define("contour-expandable",ContourExpandable);class ContourToastHost extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-toast-host"),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"toast-host","Toast host")),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.hasAttribute("aria-atomic")||this.setAttribute("aria-atomic","true")}enhance(){if(this._wiredToastHost)return;this._wiredToastHost=!0,this._toastQueue=[],this._toastActive=null;const t=(t,r)=>{r=r||{};const s=document.createElement("div");s.className="c-toast",s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),r.variant&&s.classList.add("c-toast--"+r.variant);const i=statusIcon(r.variant);if(i){const t=document.createElement("span");t.className="c-toast__icon",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+i+'" /></svg>'),s.appendChild(t)}s.dataset.message=null==t?"":String(t);const a=document.createElement("span");if(a.className="c-toast__text",a.textContent=null==t?"":String(t),s.appendChild(a),r.action&&("string"==typeof r.action||r.action.label)){const t="string"==typeof r.action?r.action:r.action.label,i=document.createElement("button");i.type="button",i.className="c-btn c-btn--ghost c-toast__action",i.textContent=t,i.addEventListener("click",t=>{if(t.stopPropagation(),"object"==typeof r.action&&"function"==typeof r.action.onClick)try{r.action.onClick()}catch(t){}e(s)}),s.appendChild(i)}const n=document.createElement("button");return n.type="button",n.className="c-toast__close",n.setAttribute("aria-label",labelText(this,"close","Close")),n.textContent="×",s.appendChild(n),n.addEventListener("click",t=>{t.stopPropagation(),e(s)}),s._arm=()=>{clearTimeout(s._timer);const t=r.duration,i=0===t?0:t>0?t:4e3;i>0&&(s._timer=setTimeout(()=>e(s),i))},s.addEventListener("mouseenter",()=>clearTimeout(s._timer)),s.addEventListener("focusin",()=>clearTimeout(s._timer)),s.addEventListener("mouseleave",s._arm),s.addEventListener("focusout",s._arm),s},e=t=>{t&&t.parentNode&&(t._timer&&(clearTimeout(t._timer),t._timer=null),t.parentNode.removeChild(t),this._toastActive===t&&(this._toastActive=null),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0,detail:{message:t.textContent}})),r())},r=()=>{for(;this._toastQueue.length;){const e=this._toastQueue.shift();if(e._deduped)continue;const r=t(e.message,e.opts);this._toastActive=r,this.appendChild(r),r._arm()}};this.show=(t,s)=>{s=s||{};const i=String(null==t?"":t),a=this._toastActive;if(a&&a.dataset&&a.dataset.message===i&&""!==i){a._timer&&clearTimeout(a._timer);const t=s.duration&&s.duration>0?s.duration:4e3;return a._timer=setTimeout(()=>e(a),t),a}const n=this._toastQueue.find(t=>String(t.message)===i&&""!==i);if(n)return n.opts=Object.assign({},n.opts,s),null;const o={message:t,opts:s,_deduped:!1};return this._toastQueue.push(o),r(),this._toastActive},this.hide=()=>{this._toastActive&&e(this._toastActive),this._toastQueue.length=0,Array.from(this.querySelectorAll(".c-toast")).forEach(t=>{t._timer&&clearTimeout(t._timer),t.parentNode&&t.parentNode.removeChild(t)}),this._toastActive=null}}}define("contour-toast-host",ContourToastHost);class ContourCombobox extends ContourBase{static get observed(){return["options","items","placeholder","label","value","multiple","loading","error","retry","src","lazy","refresh","timeout","empty","skeleton","virtual","disabled","required","name","cache-key","no-cache"]}static get formAssociated(){return!0}static get properties(){return{options:{attribute:"options"},items:{attribute:"items"},placeholder:{attribute:"placeholder"},label:{attribute:"label"},value:{attribute:"value"},multiple:{attribute:"multiple",type:Boolean},virtual:{attribute:"virtual",type:Boolean},src:{attribute:"src"},disabled:{attribute:"disabled",type:Boolean},required:{attribute:"required",type:Boolean},name:{attribute:"name"}}}render(){if(this.classList.add("c-combobox"),void 0===this._comboboxDefault&&(this._comboboxDefault=this.getAttribute("value")),wireStates(this),loadRemote(this,"options"),renderStates(this,"combobox"))return;const t=remoteData(this,"options")||this.getAttribute("options")||this.getAttribute("items"),e=Array.from(this.children).filter(t=>!t.classList||!t.classList.contains("c-combobox__input")&&!t.classList.contains("c-combobox__list"));if(t&&!e.length)try{const e=t?JSON.parse(t):[];this._comboboxOptions=e;const r=this.ensure(".c-combobox__input",()=>{const t=document.createElement("input");return t.className="c-input c-combobox__input",t.type="text",t});r.type="text",r.placeholder=this.getAttribute("placeholder")||labelText(this,"search","Search…"),r.setAttribute("aria-label",this.getAttribute("label")||labelText(this,"search","Search")),this.hasAttribute("disabled")?(r.setAttribute("disabled",""),this.classList.add("is-disabled")):(r.removeAttribute("disabled"),this.classList.remove("is-disabled")),this.hasAttribute("required")?(r.setAttribute("required",""),r.setAttribute("aria-required","true")):(r.removeAttribute("required"),r.removeAttribute("aria-required")),this.hasAttribute("name")&&r.setAttribute("name",this.getAttribute("name"));const s=this.getAttribute("value");if(null!==s){const t=String(s).split(",").map(t=>t.trim()).filter(Boolean).map(t=>{const r=e.find(e=>String("string"==typeof e?e:e.value)===t);return r?String("string"==typeof r?r:r.label):t});if(this.hasAttribute("multiple"))r.value="",r.placeholder=t.join(", ")||this.getAttribute("placeholder")||labelText(this,"search","Search…");else{const t=e.find(t=>String("string"==typeof t?t:t.value)===String(s));r.value=t?String("string"==typeof t?t:t.label):s}}const i=this.ensure(".c-combobox__list",()=>{const t=document.createElement("ul");return t.className="c-combobox__list",t.setAttribute("hidden",""),t});i.innerHTML="",i.setAttribute("hidden",""),this._comboboxVirtual=this.hasAttribute("virtual")&&e.length>100,this._comboboxVirtual?(i.classList.add("c-combobox__list--virtual"),i.style.maxBlockSize="20rem",i.style.overflow="auto",this._renderComboboxWindow("",!0)):(i.classList.remove("c-combobox__list--virtual"),i.style.maxBlockSize="",i.style.overflow="",this._renderComboboxWindow("",!0))}catch(t){warnBadJson(this,"attribute",t)}else if(e.length||t){if(e.length){const t=this.ensure(".c-combobox__input",()=>{const t=document.createElement("input");return t.className="c-input c-combobox__input",t.type="text",t});t.type="text",t.placeholder=this.getAttribute("placeholder")||labelText(this,"search","Search…"),t.setAttribute("aria-label",this.getAttribute("label")||labelText(this,"search","Search")),this.hasAttribute("required")?(t.setAttribute("required",""),t.setAttribute("aria-required","true")):(t.removeAttribute("required"),t.removeAttribute("aria-required")),this.hasAttribute("name")&&t.setAttribute("name",this.getAttribute("name"));const r=this.ensure(".c-combobox__list",()=>{const t=document.createElement("ul");return t.className="c-combobox__list",t.setAttribute("hidden",""),t});for(const t of e)"LI"===t.tagName&&(r.appendChild(t),t.setAttribute("role","option"));this._comboboxOptions=Array.from(r.querySelectorAll("li")).map(t=>({label:t.textContent.trim(),value:null!=t.dataset.value?t.dataset.value:t.textContent.trim()}))}}else renderEmpty(this,"combobox");if(this.getAttribute("value"))this.ensure(".c-combobox__clear",()=>{const t=document.createElement("button");return t.className="c-combobox__clear",t.type="button",t.setAttribute("aria-label",labelText(this,"clear","Clear")),t.textContent="×",t});else{const t=this.querySelector(".c-combobox__clear");t&&t.remove()}}_renderComboboxWindow(t="",e=!1){const r=this.querySelector(".c-combobox__list"),s=this._comboboxOptions||[];if(!r)return;const i=String(t||"").toLowerCase(),a=s.map((t,e)=>({opt:t,index:e,label:"string"==typeof t?t:t.label,value:"string"==typeof t?t:t.value})).filter(t=>!i||String(t.label).toLowerCase().includes(i));this._comboboxFiltered=a;const n=cssLength("--combobox-row-height",32),o=r.scrollTop,l=this._comboboxVirtual&&!e?Math.min(Math.max(0,a.length-20),Math.max(0,Math.floor(o/n)-6)):0;this._comboboxWindowStart=l;const c=this._comboboxVirtual?Math.min(a.length,l+20+12):a.length,u=(this.getAttribute("value")||"").split(",").map(t=>t.trim()).filter(Boolean);r.innerHTML="";const d=t=>{const e=document.createElement("li");e.setAttribute("aria-hidden","true"),e.style.blockSize=`${t}px`,r.appendChild(e)};if(this._comboboxVirtual&&d(l*n),!a.length){const t=document.createElement("li");t.className="c-combobox__empty",t.setAttribute("role","option"),t.setAttribute("aria-disabled","true"),t.setAttribute("aria-selected","false"),t.textContent=this.getAttribute("empty")||labelText(this,"no-matches","No matches"),r.appendChild(t)}this.hasAttribute("multiple")?r.setAttribute("aria-multiselectable","true"):r.removeAttribute("aria-multiselectable"),a.slice(l,c).forEach(e=>{const s=document.createElement("li");s.className="c-combobox__option",s.dataset.optionIndex=String(e.index),s.dataset.optionValue=String(null!=e.value?e.value:e.label),s.setAttribute("role","option");const i=String(e.label),a=String(t||"").toLowerCase();if(a&&i.toLowerCase().includes(a)){const t=i.toLowerCase().indexOf(a),e=i.slice(0,t),r=i.slice(t,t+a.length),n=i.slice(t+a.length);s.innerHTML="",e&&s.appendChild(document.createTextNode(e));const o=document.createElement("mark");o.className="c-combobox__match",o.textContent=r,s.appendChild(o),n&&s.appendChild(document.createTextNode(n))}else s.textContent=i;const n=this.hasAttribute("multiple")&&u.includes(String(e.value));s.setAttribute("aria-selected",String(n)),n&&s.classList.add("c-combobox__option--selected"),r.appendChild(s)}),this._comboboxVirtual&&d(Math.max(0,a.length-c)*n),this._comboboxVirtual&&!e&&(r.scrollTop=o)}_syncFormValue(){if(!this._internals)return;const t=this.getAttribute("value"),e=null!=t&&""!==t?t:null;this._internals.setFormValue(e),this._syncValidity(this.hasAttribute("required")&&!e)}enhance(){wireCombobox(this),this._internals&&!this._wiredComboboxForm&&(this._wiredComboboxForm=!0,this._syncFormValue(),this.addEventListener("contour:select",t=>{const e=t&&t.detail&&(t.detail.value||t.detail.label);null!=e&&this.setAttribute("value",String(e)),this._syncFormValue()})),this._wiredComboboxClear||(this._wiredComboboxClear=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-combobox__clear"):null;if(!e||!this.contains(e))return;t.preventDefault(),this.removeAttribute("value");const r=this.querySelector(".c-combobox__input");r&&(r.value=""),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{name:this.getAttribute("name"),value:null,checked:null}}))}))}formResetCallback(){this._contourResetting=!0;try{const t=this._comboboxDefault??null;null===t?this.removeAttribute("value"):this.setAttribute("value",t),this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-combobox",ContourCombobox);class ContourField extends ContourBase{static get observed(){return["label","hint","error","placeholder","type","required","name","value","disabled","custom-error"]}static get formAssociated(){return!0}static get properties(){return{label:{attribute:"label"},hint:{attribute:"hint"},error:{attribute:"error"},placeholder:{attribute:"placeholder"},type:{attribute:"type"},required:{attribute:"required",type:Boolean},name:{attribute:"name"},value:{attribute:"value"},disabled:{attribute:"disabled",type:Boolean},customError:{attribute:"custom-error"}}}render(){this.classList.add("c-field");const t=this.getAttribute("label"),e=this.getAttribute("hint"),r=this.getAttribute("error"),s=this.getAttribute("placeholder")||"";if(t){this.ensure(".c-field__label",()=>{const t=document.createElement("label");return t.className="c-field__label",t}).textContent=t}else{const t=this.querySelector(".c-field__label");t&&t.remove()}const i=Array.from(this.children).find(t=>t.constructor&&t.constructor.formAssociated)?null:this.ensure("input.c-input, textarea, select",()=>{const t=document.createElement("input");return t.className="c-input",t});if(i){i.type=this.getAttribute("type")||"text",i.placeholder=s,i.id||(i.id=this._fieldInputId||(this._fieldInputId=contourId("contour-field")));const t=this.querySelector(".c-field__label");if(t?(i.id||(i.id=contourId("contour-field")),t.setAttribute("for",i.id),i.setAttribute("aria-label",t.textContent)):i.hasAttribute("aria-label")||i.setAttribute("aria-label",labelText(this,"field","Field")),e){this.ensure(".c-field__hint",()=>{const t=document.createElement("span");return t.className="c-field__hint",t}).textContent=e}else{const t=this.querySelector(".c-field__hint");t&&t.remove()}if(r){this.ensure(".c-field__error",()=>{const t=document.createElement("span");return t.className="c-field__error",t}).textContent=r}else{const t=this.querySelector(".c-field__error");t&&t.remove()}const a=this.getAttribute("custom-error");if(null!==a){i.setAttribute("aria-invalid","true"),this.classList.add("is-invalid"),this.setAttribute("data-invalid","");let t=this.querySelector(".c-field__error");t||(t=document.createElement("span"),t.className="c-field__error",this.appendChild(t)),t.textContent=a,t.id||(t.id=contourId("err")),i.setAttribute("aria-describedby",(i.getAttribute("aria-describedby")||"").split(" ").filter(e=>e&&e!==t.id).concat(t.id).join(" "))}const n=this.querySelector(".c-field__hint"),o=this.querySelector(".c-field__error"),l=[];n&&(n.id||(n.id=contourId("hint")),l.push(n.id)),o&&(o.id||(o.id=contourId("err")),l.push(o.id)),l.length&&i.setAttribute("aria-describedby",l.join(" ")),this.hasAttribute("required")?(i.setAttribute("aria-required","true"),i.setAttribute("required","")):(i.removeAttribute("aria-required"),i.removeAttribute("required")),this.hasAttribute("name")&&i.setAttribute("name",this.getAttribute("name")),this.hasAttribute("value")&&(i.value=this.getAttribute("value")),this.hasAttribute("disabled")?(i.setAttribute("disabled",""),this.classList.add("is-disabled")):(i.removeAttribute("disabled"),this.classList.remove("is-disabled"))}}}ContourField.prototype.enhance=function(){if(this._wiredField)return;this._wiredField=!0;const t=()=>{const t=this.querySelector("input, textarea, select");t&&this._internals&&(this._internals.setFormValue(t.value),this._syncValidity(this.hasAttribute("required")&&!t.value))};this.addEventListener("input",e=>{const r=this.querySelector("input, textarea, select");r&&e.target===r&&(t(),this._emitForm("contour:input"))}),this.addEventListener("change",e=>{const r=this.querySelector("input, textarea, select");r&&e.target===r&&(t(),this._emitForm("contour:change"))}),this.addEventListener("focusout",e=>{const r=this.querySelector("input, textarea, select");if(!r||e.target!==r)return;if(r.checkValidity()){if(r.setAttribute("aria-invalid","false"),this.classList.remove("is-invalid"),this.removeAttribute("data-invalid"),!this.getAttribute("error")){const t=this.querySelector(".c-field__error");if(t){const e=t.id;t.remove(),e&&r.setAttribute("aria-describedby",(r.getAttribute("aria-describedby")||"").split(" ").filter(t=>t&&t!==e).join(" "))}}}else{r.setAttribute("aria-invalid","true"),this.classList.add("is-invalid"),this.setAttribute("data-invalid","");const t=new CustomEvent("contour:invalid",{bubbles:!0,composed:!0,cancelable:!0,detail:{field:this,input:r,message:r.validationMessage||"Invalid value"}});if(this.dispatchEvent(t)&&!this.getAttribute("error")&&!this.getAttribute("custom-error")){const t=r.validationMessage||"Invalid value";let e=this.querySelector(".c-field__error");e||(e=document.createElement("span"),e.className="c-field__error",this.appendChild(e)),e.textContent=t,e.id||(e.id=contourId("err")),r.setAttribute("aria-describedby",(r.getAttribute("aria-describedby")||"").split(" ").filter(t=>t&&t!==e.id).concat(e.id).join(" "))}}t()},!0),t()},define("contour-field",ContourField);class ContourFieldGroup extends ContourBase{static get observed(){return["label","hint","error","required"]}static get properties(){return{label:{attribute:"label"},hint:{attribute:"hint"},error:{attribute:"error"},required:{attribute:"required",type:Boolean}}}render(){this.classList.add("c-field-group"),this.setAttribute("role","group");const t=this.getAttribute("label");if(t){this.ensure(".c-field-group__label",()=>{const t=document.createElement("div");return t.className="c-field-group__label",t}).textContent=t}else{const t=this.querySelector(".c-field-group__label");t&&t.remove()}const e=this.getAttribute("hint");if(e){this.ensure(".c-field-group__hint",()=>{const t=document.createElement("span");return t.className="c-field-group__hint",t}).textContent=e}else{const t=this.querySelector(".c-field-group__hint");t&&t.remove()}const r=this.getAttribute("error");if(r){this.ensure(".c-field-group__error",()=>{const t=document.createElement("span");return t.className="c-field-group__error",t}).textContent=r}else{const t=this.querySelector(".c-field-group__error");t&&t.remove()}r?this.classList.add("is-error"):this.classList.remove("is-error");const s=this.hasAttribute("required");this.querySelectorAll("input, select, textarea").forEach(t=>{s?t.hasAttribute("aria-required")||t.setAttribute("aria-required","true"):"true"===t.getAttribute("aria-required")&&t.removeAttribute("aria-required")})}enhance(){this._wiredFieldGroup||(this._wiredFieldGroup=!0)}}define("contour-field-group",ContourFieldGroup);class ContourForm extends ContourBase{static get observed(){return["submitting","error","summary","title","submit-label"]}static get properties(){return{submitting:{attribute:"submitting",type:Boolean},error:{attribute:"error"},summary:{attribute:"summary"},title:{attribute:"title"},submitLabel:{attribute:"submit-label"}}}render(){this.classList.add("c-form"),this.hasAttribute("submitting")?this.classList.add("is-submitting"):this.classList.remove("is-submitting");const t=this.getAttribute("title");let e=this.querySelector(".c-form__title");t?(e||(e=document.createElement("h2"),e.className="c-form__title",this.prepend(e)),e.textContent=t):e&&e.remove();const r=this.getAttribute("summary")||this.getAttribute("error");let s=this.querySelector(".c-form__summary");r?(s||(s=document.createElement("div"),s.className="c-form__summary",s.setAttribute("role","alert"),this.prepend(s)),s.textContent=r,s.removeAttribute("hidden")):s&&s.setAttribute("hidden","");const i=this.getAttribute("submit-label");let a=this.querySelector(".c-form__submit");a||(a=document.createElement("button"),a.type="submit",a.className="c-btn c-btn--primary c-form__submit",this.appendChild(a)),i?(a.textContent=i,a.dataset&&delete a.dataset.contourLabel):applyLabel(a,this,"submit","Submit"),this.hasAttribute("submitting")?a.setAttribute("disabled",""):a.removeAttribute("disabled")}enhance(){if(this._wiredForm)return;this._wiredForm=!0;const t=this.closest("form")||this,e=t=>{const e=t.target;if(t.preventDefault(),e&&"function"==typeof e.checkValidity&&!e.checkValidity()){const t=Array.from(e.querySelectorAll(":invalid")).map(t=>t.getAttribute("aria-label")||t.name||t.id||"field").join(", ");let r=this.querySelector(".c-form__summary");return r||(r=document.createElement("div"),r.className="c-form__summary",r.setAttribute("role","alert"),this.prepend(r)),r.textContent=labelText(this,"validation-summary","Please fix")+": "+(t||labelText(this,"invalid-fields","invalid fields")),void r.removeAttribute("hidden")}this._submit()};this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-form__submit"):null;e&&this.contains(e)&&(t.target.closest("form")||(t.preventDefault(),this._submit()))}),t.addEventListener("submit",e),onDispose(this,()=>{t!==this&&t.removeEventListener("submit",e)})}_submit(){this.classList.add("is-submitting");const t=this.querySelector("[type='submit'], .c-form__submit");t&&t.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent("contour:submit",{bubbles:!0,composed:!0,detail:{submitting:!0}}))}}define("contour-form",ContourForm);class ContourRange extends ContourBase{static get observed(){return["min","max","value","low","high","range","sparkline","label","disabled","error","help","name","step"]}static get formAssociated(){return!0}static get properties(){return{min:{attribute:"min"},max:{attribute:"max"},value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},name:{attribute:"name"},step:{attribute:"step"}}}render(){this.classList.add("c-range");const t=this.getAttribute("min")||"0",e=this.getAttribute("max")||"100",r=this.hasAttribute("range")||this.hasAttribute("low")||this.hasAttribute("high"),s=this.getAttribute("sparkline");if(s){let t=this.querySelector(".c-range__sparkline");t||(t=document.createElement("canvas"),t.className="c-range__sparkline",t.setAttribute("part","sparkline-canvas"),t.setAttribute("aria-hidden","true"),this.insertBefore(t,this.firstChild)),this._drawRangeSpark(t,s)}else{const t=this.querySelector(".c-range__sparkline");t&&t.remove()}if(r){this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");let r=this.querySelector("input.c-range__low");r||(r=document.createElement("input"),r.type="range",r.className="c-range c-range__low",r.setAttribute("part","input"),this.appendChild(r));let s=this.querySelector("input.c-range__high");s||(s=document.createElement("input"),s.type="range",s.className="c-range c-range__high",s.setAttribute("part","input"),this.appendChild(s)),r.min=t,r.max=e,s.min=t,s.max=e;const i=this.getAttribute("step");i?(r.step=i,s.step=i):(r.removeAttribute("step"),s.removeAttribute("step")),this.hasAttribute("disabled")?(r.setAttribute("disabled",""),s.setAttribute("disabled","")):(r.removeAttribute("disabled"),s.removeAttribute("disabled"));const a=this.getAttribute("low")||t,n=this.getAttribute("high")||e;null!==this._rangeUserLow&&this._rangeAttrLowAtDirty===(this.getAttribute("low")||t)?r.value=this._rangeUserLow:(r.value=a,this._rangeUserLow=null,this._rangeAttrLowAtDirty=null),null!==this._rangeUserHigh&&this._rangeAttrHighAtDirty===(this.getAttribute("high")||e)?s.value=this._rangeUserHigh:(s.value=n,this._rangeUserHigh=null,this._rangeAttrHighAtDirty=null);const o=this.getAttribute("label");o&&(r.setAttribute("aria-label",o+" low"),s.setAttribute("aria-label",o+" high"))}else{Array.from(this.querySelectorAll("input.c-range__low, input.c-range__high, input[type='hidden'][data-range]")).forEach(t=>t.remove());const r=this.ensure("input.c-range",()=>{const t=document.createElement("input");return t.type="range",t.setAttribute("part","input"),t});r.className="c-range",r.type="range",r.min=t,r.max=e;const s=this.getAttribute("step");s?r.step=s:r.removeAttribute("step"),this.hasAttribute("disabled")?r.setAttribute("disabled",""):r.removeAttribute("disabled");const i=this.getAttribute("value")||"50";null!==this._rangeUserValue&&this._rangeAttrAtDirty===(this.getAttribute("value")||"50")?r.value=this._rangeUserValue:(r.value=i,this._rangeUserValue=null,this._rangeAttrAtDirty=null);const a=this.getAttribute("label");a?r.setAttribute("aria-label",a):r.hasAttribute("aria-label")||r.setAttribute("aria-label",labelText(this,"range","Range"));const n=()=>{const t=Number(r.min)||0,e=Number(r.max)||100,s=Number(r.value)||0,i=e>t?(s-t)/(e-t)*100:0;r.style.setProperty("--fill",i+"%")};n(),r._fillWired||(r._fillWired=!0,r.addEventListener("input",n))}}_drawRangeSpark(t,e){let r=[];try{const t=JSON.parse(e);Array.isArray(t)&&(r=t.map(Number).filter(Number.isFinite))}catch(t){}if(r.length<2)return;const s=()=>{if(!t.isConnected)return;const e=t.clientWidth,s=t.clientHeight;if(!e||!s)return;const i="undefined"!=typeof window&&window.devicePixelRatio||1;t.width=Math.round(e*i),t.height=Math.round(s*i);const a=t.getContext&&t.getContext("2d");if(!a)return;a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,e,s);const n=Math.min.apply(null,r),o=Math.max.apply(null,r)-n||1;let l="";try{l=getComputedStyle(this).getPropertyValue("--chart-1").trim()}catch(t){}l&&!/^(var|light-dark)\(/.test(l)||(l="#1f77b4"),a.beginPath(),a.lineWidth=1.5,a.strokeStyle=l,r.forEach((t,i)=>{const l=(t=>t/(r.length-1)*(e-4)+2)(i),c=(t=>s-2-(t-n)/o*(s-4))(t);0===i?a.moveTo(l,c):a.lineTo(l,c)}),a.stroke()};"function"==typeof requestAnimationFrame?requestAnimationFrame(s):s()}}const _origRangeRender=ContourRange.prototype.render;ContourRange.prototype.attributeChangedCallback=function(t,e,r){return"value"===t&&(this._rangeUserValue=null,this._rangeAttrAtDirty=null),"low"===t&&(this._rangeUserLow=null,this._rangeAttrLowAtDirty=null),"high"===t&&(this._rangeUserHigh=null,this._rangeAttrHighAtDirty=null),ContourBase.prototype.attributeChangedCallback.call(this,t,e,r)},ContourRange.prototype._syncFormValue=function(){if(!this._internals)return;const t=this.querySelector("input.c-range__low"),e=this.querySelector("input.c-range__high");if(t&&e){const r=this.getAttribute("name");if(r){const s=new FormData;s.append(r,t.value),s.append(r,e.value),this._internals.setFormValue(s)}else this._internals.setFormValue(null)}else{const t=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");t&&this._internals.setFormValue(t.value)}},ContourRange.prototype.formResetCallback=function(){this._contourResetting=!0;try{this._rangeUserValue=null,this._rangeAttrAtDirty=null,this._rangeUserLow=null,this._rangeAttrLowAtDirty=null,this._rangeUserHigh=null,this._rangeAttrHighAtDirty=null,this.isConnected&&this._contourAuthored&&this.attributeChangedCallback("__rerender__",null,""),this._syncFormValue()}finally{this._contourResetting=!1}},ContourRange.prototype.formStateRestoreCallback=function(t){if(!this._internals||null==t)return;const e=this.querySelector("input.c-range__low"),r=this.querySelector("input.c-range__high");if(e&&r&&t instanceof FormData){const s=t.getAll(this.getAttribute("name"));s.length>=2&&(e.value=String(s[0]),r.value=String(s[1]))}else{const e=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");e&&(e.value=String(t))}this._syncFormValue()},ContourRange.prototype.enhance=function(){if(this._wiredRange)return;this._wiredRange=!0,this._syncFormValue();const t=()=>{this._syncFormValue()};this.addEventListener("input",e=>{const r=this.querySelector("input.c-range__low"),s=this.querySelector("input.c-range__high"),i=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");r&&s&&(e.target===r||e.target===s)?(this._rangeUserLow=r.value,this._rangeUserHigh=s.value,this._rangeAttrLowAtDirty=this.getAttribute("low")||this.getAttribute("min")||"0",this._rangeAttrHighAtDirty=this.getAttribute("high")||this.getAttribute("max")||"100",t(),this._emitForm("contour:input",{low:Number(r.value),high:Number(s.value)}),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{low:Number(r.value),high:Number(s.value)}}))):i&&e.target===i&&(this._rangeUserValue=i.value,this._rangeAttrAtDirty=this.getAttribute("value")||"50",t(),this._emitForm("contour:input"))}),this.addEventListener("change",e=>{const r=this.querySelector("input.c-range__low"),s=this.querySelector("input.c-range__high"),i=this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");r&&s&&(e.target===r||e.target===s)?(t(),this._emitForm("contour:change",{low:Number(r.value),high:Number(s.value)}),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{low:Number(r.value),high:Number(s.value)}}))):i&&e.target===i&&(t(),this._emitForm("contour:change"))}),t()},define("contour-range",ContourRange);class ContourSwitch extends ContourBase{static get observed(){return["label","required","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},required:{attribute:"required",type:Boolean},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return!0}render(){this.classList.add("c-switch"),void 0===this._switchDefaultChecked&&(this._switchDefaultChecked=this.hasAttribute("checked"));const t=this.getAttribute("label"),e=this.ensure("input.c-switch__input",()=>{const t=document.createElement("input");return t.className="c-switch__input",t.type="checkbox",t});e.checked=this.hasAttribute("checked"),e.setAttribute("role","switch"),e.setAttribute("aria-checked",String(e.checked)),this._setCustomState("data-checked",e.checked),this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled"));const r=this.getAttribute("error"),s=this.getAttribute("help");let i=this.querySelector(".c-switch__message");if(r||s?(i||(i=document.createElement("div"),i.className="c-switch__message",this.appendChild(i)),i.textContent=r||s||"",i.classList.toggle("c-switch__message--error",!!r)):i&&i.remove(),r?this.classList.add("is-error"):this.classList.remove("is-error"),t){e.setAttribute("aria-label",t);(this.querySelector(":scope > span:not([class])")||(()=>{const t=document.createElement("span");return this.appendChild(t),t})()).textContent=t}e.hasAttribute("aria-label")||e.setAttribute("aria-label",labelText(this,"switch","Switch"))}enhance(){const t=this.querySelector("input");t&&this._internals&&(t.setAttribute("aria-checked",String(t.checked)),this._setCustomState("data-checked",t.checked),this._internals.setFormValue(t.checked?t.value||"on":null),this._syncValidity(this.hasAttribute("required")&&!t.checked)),this._wiredSwitch||(this._wiredSwitch=!0,this.addEventListener("click",t=>{if(t.target&&t.target.closest&&t.target.closest("input"))return;const e=this.querySelector("input");e&&!e.disabled&&(t.preventDefault(),e.click())}),this.addEventListener("change",t=>{const e=this.querySelector("input");e&&t.target===e&&this._internals&&(e.setAttribute("aria-checked",String(e.checked)),this._setCustomState("data-checked",e.checked),this._setCustomState("data-indeterminate",!1),this.removeAttribute("indeterminate"),this.toggleAttribute("checked",e.checked),this._internals.setFormValue(e.checked?e.value||"on":null),this._emitForm("contour:change"),this._syncValidity(this.hasAttribute("required")&&!e.checked))}))}formResetCallback(){this._contourResetting=!0;try{this.toggleAttribute("checked",!!this._switchDefaultChecked);const t=this.querySelector("input");t&&(t.checked=this.hasAttribute("checked")),this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-switch",ContourSwitch);class ContourCheck extends ContourBase{static get observed(){return["label","name","value","required","type","checked","indeterminate","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},name:{attribute:"name"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},type:{attribute:"type"},checked:{attribute:"checked",type:Boolean},indeterminate:{attribute:"indeterminate",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return!0}render(){this.classList.add("c-check"),void 0===this._checkDefaultChecked&&(this._checkDefaultChecked=this.hasAttribute("checked"));const t=this.getAttribute("label"),e=this.ensure("input.c-check__input",()=>{const t=document.createElement("input");return t.className="c-check__input",t.type="radio"===this.getAttribute("type")?"radio":"checkbox",t});if(e.checked=this.hasAttribute("checked"),e.indeterminate=this.hasAttribute("indeterminate")&&!e.checked,t){e.setAttribute("aria-label",t);(this.querySelector(":scope > span:not([class])")||(()=>{const t=document.createElement("span");return this.appendChild(t),t})()).textContent=t}e.hasAttribute("aria-label")||e.setAttribute("aria-label",labelText(this,"checkbox","Checkbox")),this.hasAttribute("name")&&(e.name=this.getAttribute("name")),this.hasAttribute("value")&&(e.value=this.getAttribute("value")),this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled"));const r=this.getAttribute("error"),s=this.getAttribute("help");let i=this.querySelector(".c-check__message");r||s?(i||(i=document.createElement("div"),i.className="c-check__message",this.appendChild(i)),i.textContent=r||s||"",i.classList.toggle("c-check__message--error",!!r)):i&&i.remove(),r?this.classList.add("is-error"):this.classList.remove("is-error")}enhance(){const t=this.querySelector("input");t&&this._internals&&(this._setCustomState("data-checked",t.checked),this._setCustomState("data-indeterminate",t.indeterminate),this._internals.setFormValue(t.checked?t.value||"on":null),this._syncValidity(this.hasAttribute("required")&&!t.checked)),this._wiredCheck||(this._wiredCheck=!0,this.addEventListener("click",t=>{if(t.target&&t.target.closest&&t.target.closest("input"))return;const e=this.querySelector("input");e&&!e.disabled&&(t.preventDefault(),e.click())}),this.addEventListener("change",t=>{const e=this.querySelector("input");e&&t.target===e&&this._internals&&(this._setCustomState("data-checked",e.checked),this._setCustomState("data-indeterminate",!1),this.removeAttribute("indeterminate"),this.toggleAttribute("checked",e.checked),this._internals.setFormValue(e.checked?e.value||"on":null),this._emitForm("contour:change"),this._syncValidity(this.hasAttribute("required")&&!e.checked))}))}formResetCallback(){this._contourResetting=!0;try{this.toggleAttribute("checked",!!this._checkDefaultChecked);const t=this.querySelector("input");t&&(t.checked=this.hasAttribute("checked")),this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-check",ContourCheck);class ContourRadio extends ContourBase{static get observed(){return["label","name","value","required","checked","disabled","error","help"]}static get properties(){return{label:{attribute:"label"},name:{attribute:"name"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},checked:{attribute:"checked",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}static get formAssociated(){return!0}render(){this.classList.add("c-radio");const t=this.getAttribute("label"),e=this.ensure("input.c-radio__input",()=>{const t=document.createElement("input");return t.className="c-radio__input",t.type="radio",t});e.checked=this.hasAttribute("checked"),this.hasAttribute("name")&&(e.name=this.getAttribute("name")),this.hasAttribute("value")&&(e.value=this.getAttribute("value")),this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled"));const r=this.getAttribute("error"),s=this.getAttribute("help");let i=this.querySelector(".c-radio__message");if(r||s?(i||(i=document.createElement("div"),i.className="c-radio__message",this.appendChild(i)),i.textContent=r||s||"",i.classList.toggle("c-radio__message--error",!!r)):i&&i.remove(),r?this.classList.add("is-error"):this.classList.remove("is-error"),t){e.setAttribute("aria-label",t);(this.querySelector(":scope > span:not([class])")||(()=>{const t=document.createElement("span");return this.appendChild(t),t})()).textContent=t}e.hasAttribute("aria-label")||e.setAttribute("aria-label",labelText(this,"radio","Radio"))}enhance(){const t=this.querySelector("input");t&&this._internals&&(this._setCustomState("data-checked",t.checked),this._setCustomState("data-indeterminate",t.indeterminate),this._internals.setFormValue(t.checked?t.value||"on":null),this._syncValidity(this.hasAttribute("required")&&!t.checked)),this._wiredRadio||(this._wiredRadio=!0,this.addEventListener("click",t=>{if(t.target&&t.target.closest&&t.target.closest("input"))return;const e=this.querySelector("input");e&&!e.disabled&&(t.preventDefault(),e.click())}),this.addEventListener("change",t=>{const e=this.querySelector("input");e&&t.target===e&&this._internals&&(this._setCustomState("data-checked",e.checked),this._internals.setFormValue(e.checked?e.value||"on":null),this._emitForm("contour:change"),this._syncValidity(this.hasAttribute("required")&&!e.checked))}))}}define("contour-radio",ContourRadio);class ContourSelect extends ContourBase{static get observed(){return["options","items","required","label","placeholder","disabled","error","help","value","name","multiple","autocomplete"]}static get properties(){return{options:{attribute:"options"},items:{attribute:"items"},required:{attribute:"required",type:Boolean},label:{attribute:"label"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},value:{attribute:"value"},name:{attribute:"name"},multiple:{attribute:"multiple",type:Boolean},autocomplete:{attribute:"autocomplete"}}}static get formAssociated(){return!0}render(){this.classList.add("c-select"),void 0===this._selectDefault&&(this._selectDefault=this.getAttribute("value"));const t=this.getAttribute("options")||this.getAttribute("items"),e=new Set(this._contourGenerated||[]),r=Array.from(this.children).filter(t=>!e.has(t));if(t&&!r.length)try{const e=JSON.parse(t),r=this.ensure("select.c-select",()=>{const t=document.createElement("select");return t.className="c-select",t});r.innerHTML="";const s=this.getAttribute("label");s&&r.setAttribute("aria-label",s);const i=this.getAttribute("placeholder");if(i){const t=document.createElement("option");t.value="",t.textContent=i,t.disabled=!0,t.selected=!0,r.appendChild(t)}const a={};e.forEach(t=>{const e="object"==typeof t&&null!==t?t.group:null;if(e){a[e]||(a[e]=document.createElement("optgroup"),a[e].label=e,r.appendChild(a[e]));const s=document.createElement("option");s.value="string"==typeof t?t:t.value,s.textContent="string"==typeof t?t:t.label,a[e].appendChild(s)}else{const e=document.createElement("option");e.value="string"==typeof t?t:t.value,e.textContent="string"==typeof t?t:t.label,r.appendChild(e)}}),r.parentNode!==this&&this.appendChild(r),this.classList.remove("c-select"),r.classList.add("c-select")}catch(t){warnBadJson(this,"attribute",t)}const s=this.querySelector("select");s&&!s.classList.contains("c-select")&&(s.classList.add("c-select"),this.classList.remove("c-select"));const i=this.querySelector("select");if(i){this.hasAttribute("disabled")?(i.setAttribute("disabled",""),this.classList.add("is-disabled")):(i.removeAttribute("disabled"),this.classList.remove("is-disabled")),this.hasAttribute("name")&&i.setAttribute("name",this.getAttribute("name")),this.hasAttribute("multiple")?i.setAttribute("multiple",""):i.removeAttribute("multiple"),this.hasAttribute("autocomplete")&&i.setAttribute("autocomplete",this.getAttribute("autocomplete")),this.hasAttribute("required")?i.setAttribute("required",""):i.removeAttribute("required");const t=this.getAttribute("value");if(null!==t)if(i.multiple){const e=new Set(String(t).split(",").map(t=>t.trim()).filter(Boolean));Array.from(i.options).forEach(t=>{t.selected=e.has(t.value)})}else i.value=t}const a=this.getAttribute("label");if(a){let t=this.querySelector("label.c-select__label");t||(t=document.createElement("label"),t.className="c-select__label",this.insertBefore(t,i||this.firstChild)),t.textContent=a,i&&(i.id||(i.id=contourId("contour-select")),t.setAttribute("for",i.id),i.setAttribute("aria-label",a))}if(!this.querySelector("select")?.hasAttribute("aria-label")){const t=this.querySelector("select");t&&t.setAttribute("aria-label",labelText(this,"select","Select"))}const n=this.getAttribute("error"),o=this.getAttribute("help");let l=this.querySelector(".c-select__message");n||o?(l||(l=document.createElement("div"),l.className="c-select__message",this.appendChild(l)),l.textContent=n||o||"",l.classList.toggle("c-select__message--error",!!n)):l&&l.remove(),n?this.classList.add("is-error"):this.classList.remove("is-error")}enhance(){this._internals&&this._syncFormValue(),this._wiredSelect||(this._wiredSelect=!0,this.addEventListener("input",t=>{const e=this.querySelector("select");e&&t.target===e&&this._emitForm("contour:input")}),this.addEventListener("change",t=>{const e=this.querySelector("select");if(!e||t.target!==e||!this._internals)return;const r=e.multiple?Array.from(e.selectedOptions).map(t=>t.value).join(","):e.value;this.setAttribute("value",r),this._syncFormValue(),this._emitForm("contour:change")}))}_syncFormValue(){if(!this._internals)return;const t=this.querySelector("select");if(t)if(t.multiple){const e=Array.from(t.selectedOptions).map(t=>t.value),r=this.getAttribute("name");if(r&&e.length){const t=new FormData;for(const s of e)t.append(r,s);this._internals.setFormValue(t)}else this._internals.setFormValue(null);this._syncValidity(this.hasAttribute("required")&&!e.length)}else this._internals.setFormValue(t.value),this._syncValidity(this.hasAttribute("required")&&!t.value)}formResetCallback(){this._contourResetting=!0;try{const t=this._selectDefault??null;null===t?this.removeAttribute("value"):this.setAttribute("value",t),this._syncFormValue()}finally{this._contourResetting=!1}}formStateRestoreCallback(t){const e=this.querySelector("select");if(!e||!this._internals)return;const r=t instanceof FormData?Array.from(t.getAll(this.getAttribute("name"))).map(String):null==t?[]:String(t).split(",").map(t=>t.trim()).filter(Boolean);this._contourResetting=!0;try{if(e.multiple){const t=new Set(r);for(const r of e.options)r.selected=t.has(r.value);this.setAttribute("value",r.join(","))}else e.value=r[0]||"",this.setAttribute("value",e.value);this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-select",ContourSelect);class ContourVersionControl extends ContourBase{static get observed(){return["options","items","value","name"]}static get formAssociated(){return!0}static get properties(){return{options:{attribute:"options"},items:{attribute:"items"},value:{attribute:"value"},name:{attribute:"name"}}}render(){this.classList.add("c-version"),void 0===this._versionDefault&&(this._versionDefault=this.getAttribute("value"));const t=this.getAttribute("options")||this.getAttribute("items"),e=new Set(this._contourGenerated||[]),r=Array.from(this.children).filter(t=>!e.has(t));if(t&&!r.length)try{const e=JSON.parse(t),r=this.ensure("select.c-version",()=>{const t=document.createElement("select");return t.className="c-version",t});r.innerHTML="",r.hasAttribute("aria-label")||r.setAttribute("aria-label",labelText(this,"version","Version")),e.forEach(t=>{const e=document.createElement("option");"string"==typeof t?(e.value=t,e.textContent=t):(e.value=t.value||t.label,e.textContent=t.label||t.value,t.selected&&(e.selected=!0)),r.appendChild(e)}),r.parentNode!==this&&this.appendChild(r),this.classList.remove("c-version"),r.classList.add("c-version")}catch(t){warnBadJson(this,"attribute",t)}const s=this.querySelector("select");if(s){this.hasAttribute("name")&&s.setAttribute("name",this.getAttribute("name"));const t=this.getAttribute("value");null!==t&&(s.value=t)}}enhance(){const t=()=>{const t=this.querySelector("select");t&&this._internals&&this._internals.setFormValue(t.value)};t(),this._wiredVersion||(this._wiredVersion=!0,this.addEventListener("change",e=>{const r=this.querySelector("select");r&&e.target===r&&(this.setAttribute("value",r.value),t(),this._emitForm("contour:change"))}))}formResetCallback(){this._contourResetting=!0;try{const t=this._versionDefault??null;null===t?this.removeAttribute("value"):this.setAttribute("value",t),this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-version",ContourVersionControl);class ContourTextarea extends ContourBase{static get observed(){return["placeholder","required","disabled","error","help","value","name","label"]}static get properties(){return{placeholder:{attribute:"placeholder"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},value:{attribute:"value"},name:{attribute:"name"},label:{attribute:"label"}}}static get formAssociated(){return!0}render(){const t=this.ensure("textarea",()=>{const t=document.createElement("textarea");return t.className="c-textarea",t});t.className="c-textarea",this.hasAttribute("name")?t.name=this.getAttribute("name"):t.removeAttribute("name"),this.hasAttribute("value")&&(t.value=this.getAttribute("value")),this.hasAttribute("aria-label")&&!t.hasAttribute("aria-label")&&t.setAttribute("aria-label",this.getAttribute("aria-label")),this.hasAttribute("label")&&!t.hasAttribute("aria-label")&&t.setAttribute("aria-label",this.getAttribute("label")),t.hasAttribute("aria-label")||t.setAttribute("aria-label",labelText(this,"textarea","Textarea")),this.hasAttribute("placeholder")?t.placeholder=this.getAttribute("placeholder"):t.removeAttribute("placeholder"),this.hasAttribute("required")?t.setAttribute("required",""):t.removeAttribute("required"),this.hasAttribute("disabled")?(t.setAttribute("disabled",""),this.classList.add("is-disabled")):(t.removeAttribute("disabled"),this.classList.remove("is-disabled"));const e=this.getAttribute("error"),r=this.getAttribute("help");let s=this.querySelector(".c-textarea__message");e||r?(s||(s=document.createElement("div"),s.className="c-textarea__message",this.appendChild(s)),s.textContent=e||r||"",s.classList.toggle("c-textarea__message--error",!!e)):s&&s.remove(),e?this.classList.add("is-error"):this.classList.remove("is-error")}enhance(){const t=this.querySelector("textarea");t&&this._internals&&(this._internals.setFormValue(t.value),this._syncValidity(this.hasAttribute("required")&&!t.value.trim())),this._wiredTextarea||(this._wiredTextarea=!0,this.addEventListener("input",t=>{const e=this.querySelector("textarea");e&&t.target===e&&this._internals&&(this._internals.setFormValue(e.value),this._emitForm("contour:input"),this._syncValidity(this.hasAttribute("required")&&!e.value.trim()))}),this.addEventListener("change",t=>{const e=this.querySelector("textarea");e&&t.target===e&&this._internals&&(this._internals.setFormValue(e.value),this._emitForm("contour:change"),this._syncValidity(this.hasAttribute("required")&&!e.value.trim()))}))}}define("contour-textarea",ContourTextarea);class ContourInputFull extends ContourBase{static get observed(){return["type","placeholder","required","value","disabled","error","help","label","name"]}static get properties(){return{type:{attribute:"type"},placeholder:{attribute:"placeholder"},required:{attribute:"required",type:Boolean},value:{attribute:"value"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},label:{attribute:"label"},name:{attribute:"name"}}}static get formAssociated(){return!0}render(){this.classList.add("c-input");const t=this.ensure("input",()=>{const t=document.createElement("input");return t.className="c-input",t});t.className="c-input",t.type=this.getAttribute("type")||"text",t.placeholder=this.getAttribute("placeholder")||"",this.hasAttribute("name")?t.name=this.getAttribute("name"):t.removeAttribute("name");let e=this.getAttribute("label");if(!e){const t=this.closest("contour-field");t&&(e=t.getAttribute("label"))}e?t.setAttribute("aria-label",e):t.getAttribute("aria-label")||t.setAttribute("aria-label",labelText(this,"input","Input")),this.hasAttribute("value")&&(t.value=this.getAttribute("value")),this.hasAttribute("required")?t.setAttribute("required",""):t.removeAttribute("required"),this.hasAttribute("disabled")?(t.setAttribute("disabled",""),this.classList.add("is-disabled")):(t.removeAttribute("disabled"),this.classList.remove("is-disabled"));const r=this.getAttribute("error"),s=this.getAttribute("help");let i=this.querySelector(".c-input__message");r||s?(i||(i=document.createElement("div"),i.className="c-input__message",this.appendChild(i)),i.textContent=r||s||"",i.classList.toggle("c-input__message--error",!!r)):i&&i.remove(),r?this.classList.add("is-error"):this.classList.remove("is-error")}enhance(){const t=this.querySelector("input");t&&this._internals&&(this._internals.setFormValue(t.value),this._syncValidity(this.hasAttribute("required")&&!t.value.trim())),this._wiredInput||(this._wiredInput=!0,this.addEventListener("input",t=>{const e=this.querySelector("input");e&&t.target===e&&this._internals&&(this._internals.setFormValue(e.value),this._emitForm("contour:input"),this._syncValidity(this.hasAttribute("required")&&!e.value.trim()))}),this.addEventListener("change",t=>{const e=this.querySelector("input");e&&t.target===e&&this._internals&&(this._internals.setFormValue(e.value),this._emitForm("contour:change"),this._syncValidity(this.hasAttribute("required")&&!e.value.trim()))}))}}define("contour-input",ContourInputFull);class ContourInputGroup extends ContourBase{static get observed(){return["label","placeholder","clearable","submit","value","name","required","disabled"]}static get properties(){return{label:{attribute:"label"},placeholder:{attribute:"placeholder"},clearable:{attribute:"clearable",type:Boolean},submit:{attribute:"submit",type:Boolean},value:{attribute:"value"},name:{attribute:"name"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return!0}render(){this.classList.add("c-input-group");this.ensure("svg",()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("aria-hidden","true");const e=document.createElementNS("http://www.w3.org/2000/svg","use");return e.setAttribute("href","#i-search"),t.appendChild(e),t});const t=this.ensure("input.c-input",()=>{const t=document.createElement("input");return t.className="c-input",t.type="text",t});t.placeholder=this.getAttribute("placeholder")||this.getAttribute("label")||"",this.hasAttribute("name")?t.name=this.getAttribute("name"):t.removeAttribute("name"),this.hasAttribute("value")&&(t.value=this.getAttribute("value")),this.hasAttribute("required")?t.setAttribute("required",""):t.removeAttribute("required"),this.hasAttribute("disabled")?(t.setAttribute("disabled",""),this.classList.add("is-disabled")):(t.removeAttribute("disabled"),this.classList.remove("is-disabled"));const e=this.getAttribute("label");t.hasAttribute("aria-label")||t.setAttribute("aria-label",e||"Search");const r=this.querySelector(".c-input-group__clear");if(r&&r.remove(),this.hasAttribute("clearable")){const t=document.createElement("button");t.className="c-input-group__clear",t.type="button",t.setAttribute("aria-label",labelText(this,"clear","Clear")),t.textContent="×",this.appendChild(t)}const s=this.querySelector(".c-input-group__submit");if(s&&s.remove(),this.hasAttribute("submit")){const t=document.createElement("button");t.className="c-input-group__submit",t.type="submit",t.setAttribute("aria-label",labelText(this,"submit","Submit")),t.textContent="→",this.appendChild(t)}}enhance(){const t=this.querySelector("input.c-input");t&&this._internals&&(this._internals.setFormValue(t.value),this._syncValidity(this.hasAttribute("required")&&!t.value.trim())),this._wiredInputGroup||(this._wiredInputGroup=!0,this.addEventListener("input",t=>{const e=this.querySelector("input.c-input");e&&t.target===e&&this._internals&&(this._internals.setFormValue(e.value),this._emitForm("contour:input"),this._syncValidity(this.hasAttribute("required")&&!e.value.trim()))}),this.addEventListener("change",t=>{const e=this.querySelector("input.c-input");e&&t.target===e&&this._internals&&(this._internals.setFormValue(e.value),this._emitForm("contour:change"),this._syncValidity(this.hasAttribute("required")&&!e.value.trim()))}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-input-group__clear"):null;if(e&&this.contains(e)){t.preventDefault();const e=this.querySelector("input.c-input");e&&(e.value="",e.focus()),this._internals&&(this._internals.setFormValue(""),this._syncValidity(this.hasAttribute("required"))),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:""}}))}}))}}define("contour-input-group",ContourInputGroup);class ContourRadioList extends ContourBase{static get observed(){return["items","options","name","value","required","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","dir","no-cache"]}static get properties(){return{items:{attribute:"items"},options:{attribute:"options"},name:{attribute:"name"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},src:{attribute:"src"}}}static get formAssociated(){return!0}attributeChangedCallback(t,e,r){"value"===t&&this._radioSync||super.attributeChangedCallback(t,e,r)}render(){if(this.classList.add("c-radio-list"),this.setAttribute("role","radiogroup"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("name")||"Options"),this.hasAttribute("required")?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required"),wireStates(this),loadRemote(this,"items"),renderStates(this,"radio-list"))return;const t=remoteData(this,"items")||this.getAttribute("options")||this.getAttribute("items"),e=this.querySelector("input.c-radio__input:checked"),r=this.hasAttribute("value")?this.getAttribute("value"):e?e.value:null;if(Array.from(this.querySelectorAll("label.c-radio")).forEach(t=>t.remove()),t)try{const e=JSON.parse(t),s=this.getAttribute("name")||contourId("radio-list");e.forEach(t=>{const e=document.createElement("label");e.className="c-radio";const i=document.createElement("input");if(i.type="radio",i.className="c-radio__input",i.name=s,i.tabIndex=-1,"string"==typeof t)i.value=t,t===r&&(i.checked=!0),e.appendChild(i),e.appendChild(document.createTextNode(" "+t));else{i.value=t.value||t.label,(t.checked||null!=r&&String(t.value||t.label)===String(r))&&(i.checked=!0),e.appendChild(i);const s=document.createElement("span");s.textContent=t.label||t.value,e.appendChild(s)}this.appendChild(e)});const i=Array.from(this.querySelectorAll("input.c-radio__input")),a=i.find(t=>t.checked)||i[0];a&&(a.tabIndex=0)}catch(t){warnBadJson(this,"attribute",t)}else renderEmpty(this,"radio-list")}enhance(){const t=()=>{const t=this.querySelector("input.c-radio__input:checked"),e=t?t.value:null;if(this._internals&&this._internals.setFormValue(e),null!=e&&this.getAttribute("value")!==e){this._radioSync=!0;try{this.setAttribute("value",e)}finally{this._radioSync=!1}}this._syncValidity(this.hasAttribute("required")&&null==e)};t(),this._wiredRadioList||(this._wiredRadioList=!0,this.addEventListener("change",e=>{const r=e.target&&e.target.closest?e.target.closest("input.c-radio__input"):null;r&&this.contains(r)&&(t(),this._emitForm("contour:change"))}),this.addEventListener("keydown",e=>{const r=Array.from(this.querySelectorAll("input.c-radio__input"));if(!r.length)return;const s=r.indexOf(e.target);if(-1===s)return;const i="rtl"===(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase();let a=-1;if("ArrowDown"===e.key)a=(s+1)%r.length;else if("ArrowUp"===e.key)a=(s-1+r.length)%r.length;else if("ArrowRight"===e.key)a=i?(s-1+r.length)%r.length:(s+1)%r.length;else if("ArrowLeft"===e.key)a=i?(s+1)%r.length:(s-1+r.length)%r.length;else if("Home"===e.key)a=0;else{if("End"!==e.key)return;a=r.length-1}e.preventDefault();const n=r.find(t=>t.checked);for(const t of r)t.tabIndex=-1;r[a].tabIndex=0,r[a].checked=!0,r[a].focus(),t(),n!==r[a]&&this._emitForm("contour:change")}))}formResetCallback(){this._contourResetting=!0;try{this.isConnected&&this._contourAuthored&&this.attributeChangedCallback("__rerender__",null,""),this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-radio-list",ContourRadioList);class ContourFieldset extends ContourBase{static get observed(){return["legend","disabled"]}static get properties(){return{legend:{attribute:"legend"},disabled:{attribute:"disabled",type:Boolean}}}render(){const t=this.ensure("fieldset",()=>{const t=document.createElement("fieldset");return t.className="c-fieldset",t});this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled");const e=this.getAttribute("legend");let r=t.querySelector("legend");e?(r||(r=document.createElement("legend"),r.className="c-fieldset__legend",t.prepend(r)),r.textContent=e):r&&r.remove();const s=Array.from(this.children).filter(e=>e!==t);s.length&&s.forEach(e=>t.appendChild(e))}}define("contour-fieldset",ContourFieldset);class ContourCheckboxGroup extends ContourBase{static get observed(){return["legend","name","options","items","value","required","disabled"]}static get properties(){return{legend:{attribute:"legend"},name:{attribute:"name"},options:{attribute:"options"},items:{attribute:"items"},value:{attribute:"value"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return!0}render(){this.classList.add("c-checkbox-group"),void 0===this._checkboxGroupDefault&&(this._checkboxGroupDefault=this.getAttribute("value"));const t=this.ensure("fieldset",()=>{const t=document.createElement("fieldset");return t.className="c-checkbox-group__fieldset",t});this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.hasAttribute("required")?t.setAttribute("aria-required","true"):t.removeAttribute("aria-required");const e=this.getAttribute("legend");let r=t.querySelector("legend");e?(r||(r=document.createElement("legend"),r.className="c-checkbox-group__legend",t.prepend(r)),r.textContent=e):r&&r.remove();const s=this.getAttribute("name")||"group",i=this.getAttribute("options")||this.getAttribute("items"),a=(this.getAttribute("value")||"").split(",").map(t=>t.trim()).filter(Boolean);if(i)try{const e=JSON.parse(i);Array.from(t.querySelectorAll(".c-check")).forEach(t=>t.remove()),e.forEach(e=>{const r="string"==typeof e?e:e.label||e.value||"",i="string"==typeof e?e:e.value||e.label||"",n=document.createElement("label");n.className="c-check";const o=document.createElement("input");o.type="checkbox",o.className="c-check__input",o.name=s,o.value=i,o.setAttribute("data-contour-preserve-key",i),a.includes(i)&&(o.checked=!0);const l=document.createElement("span");l.textContent=r,n.appendChild(o),n.appendChild(l),t.appendChild(n)})}catch(t){warnBadJson(this,"attribute",t)}if(a.length){const t=()=>{if(this.isConnected){for(const t of this.querySelectorAll("input[type=checkbox]"))a.includes(t.value)&&(t.checked=!0);this._internals&&this._syncFormValue()}};t(),"function"==typeof queueMicrotask&&queueMicrotask(t),"function"==typeof requestAnimationFrame&&requestAnimationFrame(t)}}enhance(){this._internals&&this._syncFormValue(),this._wiredCheckboxGroup||(this._wiredCheckboxGroup=!0,this.addEventListener("change",t=>{const e=t.target;if(e&&e.matches&&e.matches("input[type=checkbox]")){const t=Array.from(this.querySelectorAll("input[type=checkbox]:checked")).map(t=>t.value);this.setAttribute("value",t.join(",")),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t.join(","),values:t}}))}}))}_syncFormValue(){if(!this._internals)return;const t=Array.from(this.querySelectorAll("input[type=checkbox]:checked")),e=this.getAttribute("name");if(e&&t.length){const r=new FormData;for(const s of t)r.append(e,s.value);this._internals.setFormValue(r)}else this._internals.setFormValue(null);this._syncValidity(this.hasAttribute("required")&&!t.length)}formResetCallback(){this._contourResetting=!0;try{const t=this._checkboxGroupDefault??null;null===t?this.removeAttribute("value"):this.setAttribute("value",t),this._syncFormValue()}finally{this._contourResetting=!1}}formStateRestoreCallback(t){const e=t instanceof FormData?Array.from(t.getAll(this.getAttribute("name"))).map(String):null==t?[]:String(t).split(",").map(t=>t.trim()).filter(Boolean);this._contourResetting=!0;try{this.setAttribute("value",e.join(",")),this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-checkbox-group",ContourCheckboxGroup);class ContourSearchField extends ContourBase{static get observed(){return["value","placeholder","label","name","required","disabled"]}static get properties(){return{value:{attribute:"value"},placeholder:{attribute:"placeholder"},label:{attribute:"label"},name:{attribute:"name"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return!0}render(){this.classList.add("c-search-field");const t=this.ensure("input",()=>{const t=document.createElement("input");return t.type="search",t.className="c-search-field__input",t});t.placeholder=this.getAttribute("placeholder")||"Search",null!==this.getAttribute("value")&&(t.value=this.getAttribute("value")),this.hasAttribute("name")&&(t.name=this.getAttribute("name")),this.hasAttribute("required")?t.setAttribute("required",""):t.removeAttribute("required"),this.hasAttribute("disabled")?(t.setAttribute("disabled",""),this.classList.add("is-disabled")):(t.removeAttribute("disabled"),this.classList.remove("is-disabled"));const e=this.getAttribute("label");e?t.setAttribute("aria-label",e):t.hasAttribute("aria-label")||t.setAttribute("aria-label",labelText(this,"search","Search"))}enhance(){const t=this.querySelector("input");t&&this._internals&&(this._internals.setFormValue(t.value),this._syncValidity(this.hasAttribute("required")&&!t.value.trim())),this._wiredSearchField||(this._wiredSearchField=!0,this.addEventListener("input",t=>{const e=t.target;e&&e.matches&&e.matches("input")&&(this._internals&&(this._internals.setFormValue(e.value),this._syncValidity(this.hasAttribute("required")&&!e.value.trim())),this._emitForm("contour:input"))}),this.addEventListener("change",t=>{const e=t.target;e&&e.matches&&e.matches("input")&&this._internals&&(this._internals.setFormValue(e.value),this._emitForm("contour:change"),this._syncValidity(this.hasAttribute("required")&&!e.value.trim()))}))}}define("contour-search-field",ContourSearchField);class ContourDensityToggle extends ContourBase{static get observed(){return["value","label"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"}}}render(){this.classList.add("c-density-toggle");const t=this.getAttribute("value")||"comfortable";this.setAttribute("data-density",t);const e=this.ensure("button",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-density-toggle__btn",t.type="button",t}),r=this.getAttribute("label")||("compact"===t?"Compact":"Comfortable");e.textContent=r,e.setAttribute("aria-pressed","compact"===t?"true":"false")}enhance(){this._wiredDensityToggle||(this._wiredDensityToggle=!0,this.addEventListener("click",()=>{const t="compact"===this.getAttribute("data-density")?"comfortable":"compact";this.setAttribute("value",t),this.setAttribute("data-density",t);const e=this.querySelector(".c-density-toggle__btn");e&&(e.textContent="compact"===t?"Compact":"Comfortable",e.setAttribute("aria-pressed","compact"===t?"true":"false")),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t}}))}))}}define("contour-density-toggle",ContourDensityToggle);class ContourPressableFull extends ContourBase{static get observed(){return["disabled","label"]}static get properties(){return{disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-pressable"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Pressable"),this.hasAttribute("disabled")?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.hasAttribute("tabindex")&&"-1"!==this.getAttribute("tabindex")||this.setAttribute("tabindex","0"))}enhance(){if(this._wiredPressable)return;this._wiredPressable=!0;const t=()=>this.hasAttribute("disabled")||"true"===this.getAttribute("aria-disabled");this.addEventListener("click",e=>{t()&&(e.preventDefault(),e.stopImmediatePropagation())},!0),this.addEventListener("keydown",e=>{if(t())return e.preventDefault(),void e.stopImmediatePropagation();"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.click(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0})))})}}define("contour-pressable",ContourPressableFull);class ContourResizeHandleFull extends ContourBase{render(){this.classList.add("c-resize-handle"),this.hasAttribute("role")||this.setAttribute("role","separator"),this.hasAttribute("aria-valuenow")||this.setAttribute("aria-valuenow","0"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"resize-handle","Resize handle")),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("aria-orientation")||this.setAttribute("aria-orientation","horizontal")}enhance(){this._wiredResizeHandle||(this._wiredResizeHandle=!0,this.addEventListener("keydown",t=>{const e=Number(this.getAttribute("aria-valuenow"))||0;let r=0;if("ArrowLeft"===t.key||"ArrowDown"===t.key)r=-5;else if("ArrowRight"===t.key||"ArrowUp"===t.key)r=5;else if("Home"===t.key)r=-e;else{if("End"!==t.key)return;r=100-e}t.preventDefault();const s=Math.min(100,Math.max(0,e+r));this.setAttribute("aria-valuenow",String(s)),this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{value:s,delta:r}}))}))}}define("contour-resize-handle",ContourResizeHandleFull);class ContourSearchTriggerFull extends ContourBase{static get observed(){return["label","shortcut"]}static get properties(){return{label:{attribute:"label"},shortcut:{attribute:"shortcut"}}}render(){this.classList.add("c-search-trigger");const t=this.getAttribute("label")||"Search";this.hasAttribute("aria-label")||this.setAttribute("aria-label",t);const e=this.ensure(".c-search-trigger__text",()=>{const t=document.createElement("span");return t.className="c-search-trigger__text",t});e.className="c-search-trigger__text",e.textContent.trim()&&e.textContent.trim()===t||(e.textContent=t);const r=this.ensure("kbd.c-search-trigger__kbd",()=>{const t=document.createElement("kbd");return t.className="c-search-trigger__kbd",t});r.className="c-search-trigger__kbd",r.textContent=this.getAttribute("shortcut")||"⌘K"}}define("contour-search-trigger",ContourSearchTriggerFull);class ContourShortcutListFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-shortcut-list"),this.setAttribute("role","list");const t=this.getAttribute("title");if(t){this.ensure(".c-shortcut-list__title",()=>{const t=document.createElement("div");return t.className="c-shortcut-list__title",t}).textContent=t}}}define("contour-shortcut-list",ContourShortcutListFull);class ContourShortcutRowFull extends ContourBase{static get observed(){return["desc","key"]}static get properties(){return{desc:{attribute:"desc"},key:{attribute:"key"}}}render(){this.classList.add("c-shortcut-row"),this.hasAttribute("role")||this.setAttribute("role","listitem");const t=this.getAttribute("key"),e=this.getAttribute("desc");if(t){const e=this.ensure(".c-shortcut-row__keys",()=>{const t=document.createElement("kbd");return t.className="c-shortcut-row__keys",t});e.className="c-shortcut-row__keys",e.textContent=t}else{const t=this.querySelector(".c-shortcut-row__keys");t&&t.remove()}if(e){const t=this.ensure(".c-shortcut-row__label",()=>{const t=document.createElement("span");return t.className="c-shortcut-row__label",t});t.className="c-shortcut-row__label",t.textContent=e}else{const t=this.querySelector(".c-shortcut-row__label");t&&t.remove()}}}define("contour-shortcut-row",ContourShortcutRowFull);class ContourShortcutPanelFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-shortcut-panel");const t=this.getAttribute("title");if(t){this.ensure(".c-shortcut-panel__title",()=>{const t=document.createElement("div");return t.className="c-shortcut-panel__title",t}).textContent=t}else{const t=this.querySelector(".c-shortcut-panel__title");t&&t.remove()}}}define("contour-shortcut-panel",ContourShortcutPanelFull);class ContourShortcutOverlayFull extends ContourBase{static get observed(){return["title","open","keybind"]}static get properties(){return{title:{attribute:"title"},open:{attribute:"open",type:Boolean},keybind:{attribute:"keybind"}}}render(){this.classList.add("c-shortcut-overlay"),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-modal")||this.setAttribute("aria-modal","true"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Keyboard shortcuts");const t=this.getAttribute("title");if(t){this.ensure(".c-shortcut-overlay__title",()=>{const t=document.createElement("div");return t.className="c-shortcut-overlay__title",t}).textContent=t}this.hasAttribute("open")?this.removeAttribute("hidden"):this.hasAttribute("hidden")||this.setAttribute("hidden","")}show(){if(this.hasAttribute("open"))return;this._opener=document.activeElement,this.setAttribute("open",""),this.removeAttribute("hidden"),modalContain(this,!0),this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}));const t=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");t&&t.focus()}hide(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.setAttribute("hidden",""),modalContain(this,!1),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})),this._opener&&"function"==typeof this._opener.focus&&this._opener.focus(),this._opener=null)}toggle(){this.hasAttribute("open")?this.hide():this.show()}enhance(){if(this._wiredShortcutOverlay)return;this._wiredShortcutOverlay=!0;const t=t=>{if("?"!==t.key||!flagOn(this,"keybind")||t.metaKey||t.ctrlKey||t.altKey)"Escape"===t.key&&this.hasAttribute("open")&&this.hide();else{const e=t.target&&t.target.tagName||"";if("INPUT"===e||"TEXTAREA"===e||t.target&&t.target.isContentEditable)return;t.preventDefault(),this.toggle()}};document.addEventListener("keydown",t),onDispose(this,()=>document.removeEventListener("keydown",t)),this.addEventListener("click",t=>{t.target===this&&this.hide()})}}define("contour-shortcut-overlay",ContourShortcutOverlayFull);class ContourRowActionFull extends ContourBase{static get observed(){return["label","disabled"]}static get properties(){return{label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-row-action"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("disabled")?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.hasAttribute("tabindex")&&"-1"!==this.getAttribute("tabindex")||this.setAttribute("tabindex","0"));const t=this.getAttribute("label");t&&!this.hasChildNodes()&&(this.textContent=t),t&&!this.hasAttribute("aria-label")&&this.setAttribute("aria-label",t)}enhance(){if(this._wiredRowAction)return;this._wiredRowAction=!0;const t=()=>this.hasAttribute("disabled")||"true"===this.getAttribute("aria-disabled");this.addEventListener("click",e=>{t()&&(e.preventDefault(),e.stopImmediatePropagation())},!0),this.addEventListener("keydown",e=>{if(t())return e.preventDefault(),void e.stopImmediatePropagation();"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.click(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0})))})}}define("contour-row-action",ContourRowActionFull);class ContourSegmented extends ContourBase{static get observed(){return["options","items","selected","label","value"]}static get properties(){return{options:{attribute:"options"},items:{attribute:"items"},selected:{attribute:"selected"},label:{attribute:"label"},value:{attribute:"value"}}}render(){this.classList.add("c-segmented");const t=this.getAttribute("options")||this.getAttribute("items");if(t){let e=null;try{e=JSON.parse(t)}catch(t){e=null}if(Array.isArray(e)){Array.from(this.querySelectorAll("button.c-segmented__option")).forEach(t=>t.remove());const t=this.getAttribute("selected")||this.getAttribute("value");e.forEach((e,r)=>{const s="string"==typeof e?e:e.label||e.value||"",i="string"==typeof e?e:e.value||e.label||"",a=document.createElement("button");a.className="c-segmented__option",a.type="button",a.textContent=s,a.dataset.value=i,null!==t&&String(i)===String(t)||null===t&&0===r?a.setAttribute("aria-pressed","true"):a.setAttribute("aria-pressed","false"),this.appendChild(a)})}}}enhance(){wireSegmented(this)}}define("contour-segmented",ContourSegmented);class ContourDraggable extends ContourBase{render(){this.classList.add("c-draggable"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("draggable")||this.setAttribute("draggable","true"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Draggable item")}_dragValue(){return this.getAttribute("value")||this.getAttribute("label")||(this.textContent||"").trim()||"draggable"}enhance(){this._wiredDraggable||(this._wiredDraggable=!0,this.addEventListener("dragstart",t=>{if(!t.dataTransfer)return;const e=this._dragValue();try{t.dataTransfer.effectAllowed="move"}catch(t){}t.dataTransfer.setData("text/plain",e),this.classList.add("c-draggable--dragging"),this.dispatchEvent(new CustomEvent("contour:dragstart",{bubbles:!0,composed:!0,detail:{value:e}}))}),this.addEventListener("dragend",()=>{this.classList.remove("c-draggable--dragging"),this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:!0,composed:!0,detail:{value:this._dragValue()}}))}),this.addEventListener("keydown",t=>{if("Enter"===t.key||" "===t.key)return t.preventDefault(),void this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0}));"ArrowUp"!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:move",{bubbles:!0,composed:!0,detail:{direction:"ArrowUp"===t.key?"up":"down"}})))}))}}define("contour-draggable",ContourDraggable);class ContourDragHandle extends ContourBase{render(){this.classList.add("c-drag-handle"),this.hasAttribute("role")||this.setAttribute("role","separator");const t=this.getAttribute("min")||"0",e=this.getAttribute("max")||"100";this.hasAttribute("aria-valuenow")||this.setAttribute("aria-valuenow",t),this.hasAttribute("aria-valuemin")||this.setAttribute("aria-valuemin",t),this.hasAttribute("aria-valuemax")||this.setAttribute("aria-valuemax",e),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Drag handle"),this.hasAttribute("aria-orientation")||this.setAttribute("aria-orientation","horizontal");const r=this.getAttribute("controls");r&&!this.hasAttribute("aria-controls")&&this.setAttribute("aria-controls",r);const s=this.ensure(".c-drag-handle__grip",()=>{const t=document.createElement("span");return t.className="c-drag-handle__grip",t.setAttribute("aria-hidden","true"),setHTML(t,'<svg viewBox="0 0 24 24"><use href="#i-drag" /></svg>'),t});s.parentNode!==this&&this.appendChild(s)}enhance(){this._wiredDragHandle||(this._wiredDragHandle=!0,this.addEventListener("keydown",t=>{const e=Number(this.getAttribute("aria-valuenow")||0),r=Number(this.getAttribute("aria-valuemin")||0),s=Number(this.getAttribute("aria-valuemax")||100);let i=0;if("ArrowLeft"===t.key||"ArrowDown"===t.key)i=-1;else if("ArrowRight"===t.key||"ArrowUp"===t.key)i=1;else if("Home"===t.key)i=r-e;else{if("End"!==t.key)return;i=s-e}t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:!0,composed:!0,detail:{key:t.key,delta:i,value:e}}))}))}}define("contour-drag-handle",ContourDragHandle);class ContourDropIndicator extends ContourBase{static get observed(){return["label","open"]}static get properties(){return{label:{attribute:"label"},open:{attribute:"open",type:Boolean}}}render(){this.classList.add("c-drop-indicator"),this.classList.toggle("c-drop-indicator--visible",this.hasAttribute("open")),this.hasAttribute("role")||this.setAttribute("role","presentation"),"presentation"===this.getAttribute("role")&&(this.removeAttribute("aria-label"),this.removeAttribute("aria-labelledby")),Array.from(this.childNodes).forEach(t=>{(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ELEMENT_NODE&&"SPAN"===t.tagName)&&t.remove()});const t=this.getAttribute("label");if(t){this.ensure(".c-drop-indicator__label",()=>{const t=document.createElement("span");return t.className="c-drop-indicator__label",t}).textContent=t}}}define("contour-drop-indicator",ContourDropIndicator);class ContourDropZone extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-drop-zone"),this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Drop zone"),Array.from(this.childNodes).forEach(t=>{(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ELEMENT_NODE&&"SPAN"===t.tagName)&&t.remove()});const t=this.getAttribute("label");if(t){const e=this.ensure(".c-drop-zone__label",()=>{const t=document.createElement("p");return t.className="c-drop-zone__label",t});setHTML(e,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-upload" /></svg>'),e.appendChild(document.createTextNode(" "+t))}}enhance(){if(this._wiredDropZone)return;this._wiredDropZone=!0;const t=t=>t.dataTransfer&&Array.from(t.dataTransfer.types).includes("text/plain"),e=()=>{this.classList.remove("c-drop-zone--active","c-drop-zone--reject")};this.addEventListener("dragenter",e=>{e.dataTransfer&&(this.classList.toggle("c-drop-zone--reject",!t(e)),t(e)&&(e.preventDefault(),this.classList.add("c-drop-zone--active")))}),this.addEventListener("dragover",e=>{e.dataTransfer&&(this.classList.toggle("c-drop-zone--reject",!t(e)),t(e)&&(e.preventDefault(),this.classList.add("c-drop-zone--active")))}),this.addEventListener("dragleave",e),this.addEventListener("drop",r=>{if(!t(r))return;r.preventDefault(),e();const s=r.dataTransfer.getData("text/plain")||"";this.dispatchEvent(new CustomEvent("contour:drop",{bubbles:!0,composed:!0,detail:{value:s,label:this.getAttribute("label")}}))})}}define("contour-drop-zone",ContourDropZone);class ContourResizable extends ContourBase{static get observed(){return["direction","value"]}static get properties(){return{direction:{attribute:"direction"},value:{attribute:"value"}}}render(){this.classList.add("c-resizable"),this.classList.remove("c-resizable--vertical","c-resizable--horizontal");const t="vertical"===this.getAttribute("direction");if(this.classList.add(t?"c-resizable--vertical":"c-resizable--horizontal"),!this.querySelector(".c-resizable__pane")){const t=document.createElement("div");t.className="c-resizable__pane";const e=document.createElement("div");e.className="c-resize-handle",e.setAttribute("tabindex","0"),e.setAttribute("role","separator"),e.setAttribute("aria-valuenow","0");const r=document.createElement("div");r.className="c-resizable__pane",this.appendChild(t),this.appendChild(e),this.appendChild(r)}const e=this._splitValue||this.getAttribute("value"),r=this.querySelector(".c-resize-handle");if(r&&(r.setAttribute("role","separator"),r.setAttribute("tabindex","0"),r.setAttribute("aria-valuenow",String(Math.round(parseFloat(e)||50))),r.setAttribute("aria-valuemin","10"),r.setAttribute("aria-valuemax","90"),r.setAttribute("aria-orientation",t?"horizontal":"vertical"),r.setAttribute("aria-label",labelText(this,"resize-panels","Resize panels"))),e){const t=this.querySelector(".c-resizable__pane");t&&(t.style.flex=`0 0 ${e}%`)}}enhance(){if(this._wiredResizable)return;this._wiredResizable=!0;const t=t=>{const e=this.querySelector(".c-resizable__pane");e&&(e.style.flex=`0 0 ${t}%`),this._splitValue=String(t);const r=this.querySelector(".c-resize-handle");if(r){const e=this.classList.contains("c-resizable--vertical");r.setAttribute("role","separator"),r.setAttribute("aria-valuenow",String(t)),r.setAttribute("aria-valuemin","10"),r.setAttribute("aria-valuemax","90"),r.setAttribute("aria-orientation",e?"horizontal":"vertical"),r.setAttribute("aria-label",labelText(this,"resize-panels","Resize panels")),r.setAttribute("tabindex","0")}},e=(e,r)=>{const s=this.getBoundingClientRect(),i=this.classList.contains("c-resizable--vertical"),a=i?s.height:s.width,n=i?r-s.top:e-s.left,o=a>0?Math.min(.9,Math.max(.1,n/a)):.5;t(Math.round(100*o))};this.addEventListener("pointerdown",t=>{const e=this.querySelector(".c-resize-handle");if(e&&t.target===e){if(this._resizing=!0,e.classList.add("c-resize-handle--dragging"),e.setPointerCapture)try{e.setPointerCapture(t.pointerId)}catch(t){}t.preventDefault()}}),this.addEventListener("pointermove",t=>{this._resizing&&e(t.clientX,t.clientY)});const r=t=>{if(!this._resizing)return;this._resizing=!1,this._splitValue&&(this.setAttribute("value",this._splitValue),this._splitValue=null);const e=this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{width:Math.round(e.width),height:Math.round(e.height)}}));const r=this.querySelector(".c-resize-handle");if(r&&(r.classList.remove("c-resize-handle--dragging"),r.hasPointerCapture&&r.hasPointerCapture(t.pointerId)))try{r.releasePointerCapture(t.pointerId)}catch(t){}};this.addEventListener("pointerup",r),this.addEventListener("pointercancel",r),this.addEventListener("keydown",e=>{const r=this.querySelector(".c-resize-handle");if(!r||document.activeElement!==r)return;this.classList.contains("c-resizable--vertical");const s=parseFloat(this.getAttribute("value"))||50;"ArrowLeft"===e.key||"ArrowDown"===e.key?(e.preventDefault(),t(Math.max(10,s-5)),this._splitValue=null,this.setAttribute("value",String(Math.max(10,s-5)))):"ArrowRight"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),t(Math.min(90,s+5)),this._splitValue=null,this.setAttribute("value",String(Math.min(90,s+5))));const i=this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{width:Math.round(i.width),height:Math.round(i.height)}}))})}}define("contour-resizable",ContourResizable);class ContourSplitView extends ContourBase{static get observed(){return["direction","value","left-label","right-label"]}static get properties(){return{direction:{attribute:"direction"},value:{attribute:"value"},"left-label":{attribute:"left-label"},"right-label":{attribute:"right-label"}}}render(){this.classList.add("c-split-view"),this.setAttribute("role","region");const t="vertical"===this.getAttribute("direction");if(t?(this.classList.add("c-split-view--vertical"),this.classList.remove("c-split-view--horizontal")):(this.classList.add("c-split-view--horizontal"),this.classList.remove("c-split-view--vertical")),this.getAttribute("left-label")&&this.setAttribute("aria-label",this.getAttribute("left-label")),!this.querySelector(".c-split-view__pane")){const e=document.createElement("div");e.className="c-split-view__pane c-split-view__pane--left",e.setAttribute("role","region"),this.getAttribute("left-label")&&e.setAttribute("aria-label",this.getAttribute("left-label"));const r=document.createElement("div");r.className="c-split-view__divider",r.setAttribute("tabindex","0"),r.setAttribute("role","separator"),r.setAttribute("aria-valuenow",this.getAttribute("value")||"50"),r.setAttribute("aria-valuemin","10"),r.setAttribute("aria-valuemax","90"),r.setAttribute("aria-orientation",t?"horizontal":"vertical"),r.setAttribute("aria-label",labelText(this,"split-divider","Split divider"));const s=document.createElement("div");s.className="c-split-view__pane c-split-view__pane--right",s.setAttribute("role","region"),this.getAttribute("right-label")&&s.setAttribute("aria-label",this.getAttribute("right-label")),this.appendChild(e),this.appendChild(r),this.appendChild(s)}if(!this.querySelector(".c-split-view__divider")){const e=document.createElement("div");e.className="c-split-view__divider",e.setAttribute("tabindex","0"),e.setAttribute("role","separator"),e.setAttribute("aria-valuenow",this.getAttribute("value")||"50"),e.setAttribute("aria-valuemin","10"),e.setAttribute("aria-valuemax","90"),e.setAttribute("aria-orientation",t?"horizontal":"vertical"),e.setAttribute("aria-label",labelText(this,"split-divider","Split divider")),this.appendChild(e)}const e=this.getAttribute("value")||"50",r=this.querySelector(".c-split-view__pane--left");r&&(r.style.flex=`0 0 ${e}%`);const s=this.querySelector(".c-split-view__divider");s&&(s.setAttribute("aria-valuenow",e),s.setAttribute("aria-valuemin","10"),s.setAttribute("aria-valuemax","90"),s.setAttribute("aria-orientation",t?"horizontal":"vertical"))}enhance(){if(this._wiredSplitView)return;this._wiredSplitView=!0;const t=()=>"column"===getComputedStyle(this).flexDirection,e=()=>{const e=this.querySelector(".c-split-view__divider");e&&e.setAttribute("aria-orientation",t()?"horizontal":"vertical")};if(e(),"function"==typeof ResizeObserver){const t=new ResizeObserver(e);t.observe(this),onDispose(this,()=>t.disconnect())}const r=(e,r)=>{const s=this.getBoundingClientRect(),i=t(),a=i?s.height:s.width,n=i?r-s.top:e-s.left,o=a>0?Math.min(.9,Math.max(.1,n/a)):.5,l=Math.round(100*o),c=this.querySelector(".c-split-view__pane--left");c&&(c.style.flex=`0 0 ${l}%`);const u=this.querySelector(".c-split-view__divider");u&&u.setAttribute("aria-valuenow",String(l)),this.setAttribute("value",String(l))};this.addEventListener("pointerdown",t=>{const e=this.querySelector(".c-split-view__divider");if(e&&t.target===e){if(this._resizing=!0,e.classList.add("c-split-view__divider--dragging"),e.setPointerCapture)try{e.setPointerCapture(t.pointerId)}catch(t){}t.preventDefault()}}),this.addEventListener("pointermove",t=>{this._resizing&&r(t.clientX,t.clientY)});const s=t=>{if(!this._resizing)return;this._resizing=!1;const e=this.querySelector(".c-split-view__divider");if(e&&(e.classList.remove("c-split-view__divider--dragging"),e.hasPointerCapture&&e.hasPointerCapture(t.pointerId)))try{e.releasePointerCapture(t.pointerId)}catch(t){}const r=this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:split-change",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("value"),width:Math.round(r.width),height:Math.round(r.height)}}))};this.addEventListener("pointerup",s),this.addEventListener("pointercancel",s),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-split-view__divider");if(!e||document.activeElement!==e)return;const r=parseFloat(this.getAttribute("value"))||50;if("ArrowLeft"===t.key||"ArrowDown"===t.key){t.preventDefault();const e=Math.max(10,r-5),s=this.querySelector(".c-split-view__pane--left");s&&(s.style.flex=`0 0 ${e}%`),this.setAttribute("value",String(e));const i=this.querySelector(".c-split-view__divider");i&&i.setAttribute("aria-valuenow",String(e))}else if("ArrowRight"===t.key||"ArrowUp"===t.key){t.preventDefault();const e=Math.min(90,r+5),s=this.querySelector(".c-split-view__pane--left");s&&(s.style.flex=`0 0 ${e}%`),this.setAttribute("value",String(e));const i=this.querySelector(".c-split-view__divider");i&&i.setAttribute("aria-valuenow",String(e))}const s=this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:split-change",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("value"),width:Math.round(s.width),height:Math.round(s.height)}}))})}}define("contour-split-view",ContourSplitView);class ContourTableWrap extends ContourBase{static get observed(){return[]}static get properties(){return{}}render(){this.classList.add("c-table-wrap"),Array.from(this.childNodes).forEach(t=>{(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ELEMENT_NODE&&"SPAN"===t.tagName)&&t.remove()})}}define("contour-table-wrap",ContourTableWrap);class ContourScrollArea extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-scroll-area");const t=this.getAttribute("title");if(t){this.ensure(".c-scroll-area__title",()=>{const t=document.createElement("div");return t.className="c-scroll-area__title",t}).textContent=t}}}define("contour-scroll-area",ContourScrollArea);class ContourBtn extends ContourBase{static get observed(){return["variant","size","color","label","disabled","href","loading","title"]}static get properties(){return{variant:{attribute:"variant"},size:{attribute:"size"},color:{attribute:"color"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-btn");for(const t of["variant","size","color"]){const e=this.getAttribute(t);e&&this.classList.add("c-btn--"+e)}this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("disabled")?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.hasAttribute("tabindex")&&"-1"!==this.getAttribute("tabindex")||this.setAttribute("tabindex","0"));const t=this.getAttribute("label")||this.getAttribute("title");t&&!this.hasChildNodes()&&(this.textContent=t),t&&!this.hasAttribute("aria-label")&&this.setAttribute("aria-label",t),this.hasAttribute("loading")?(this.setAttribute("data-loading","true"),this.setAttribute("aria-busy","true")):(this.removeAttribute("data-loading"),this.removeAttribute("aria-busy"))}enhance(){if(this._wiredBtn)return;this._wiredBtn=!0;const t=()=>this.hasAttribute("disabled")||"true"===this.getAttribute("aria-disabled");this.addEventListener("click",e=>{t()&&(e.preventDefault(),e.stopImmediatePropagation())},!0),this.addEventListener("click",e=>{if(t())return;const r=safeHref(this.getAttribute("href"));r&&"#"!==r&&(location.href=r)}),this.addEventListener("keydown",e=>{if(t())return e.preventDefault(),void e.stopImmediatePropagation();"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.click(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0})))})}}define("contour-btn",ContourBtn);class ContourApp extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-app");const t=this.ensure(".c-app__header",()=>{const t=document.createElement("header");return t.className="c-app__header",t}),e=this.getAttribute("title");if(e){const r=this.ensure(".c-app__title",()=>{const t=document.createElement("div");return t.className="c-app__title",t});r.textContent=e,r.parentNode!==t&&t.appendChild(r)}const r=this.ensure(".c-app__main",()=>{const t=document.createElement("main");return t.className="c-app__main",t});r.parentNode!==this&&this.appendChild(r),t.parentNode!==this&&this.insertBefore(t,r),Array.from(this.children).forEach(e=>{e!==t&&e!==r&&r.appendChild(e)})}}define("contour-app",ContourApp);class ContourAppBody extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-app-body");const t=!!(this.parentElement&&this.parentElement.closest&&this.parentElement.closest("contour-app"))?"div":"main";let e=this.querySelector(":scope > .c-app-body__main");e&&e.tagName.toLowerCase()!==t&&(e.remove(),e=null),e||(e=document.createElement(t),e.className="c-app-body__main",this.appendChild(e));const r=this.getAttribute("title");if(r){const t=this.ensure(".c-app-body__title",()=>{const t=document.createElement("div");return t.className="c-app-body__title",t});t.textContent=r,t.parentNode!==e&&e.appendChild(t)}e.parentNode!==this&&this.appendChild(e)}}define("contour-app-body",ContourAppBody);class ContourBtnGroup extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-btn-group"),this.setAttribute("role","group"),this.getAttribute("title")&&this.setAttribute("aria-label",this.getAttribute("title"))}enhance(){this._wiredBtnGroup||(this._wiredBtnGroup=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-btn"):null;if(e&&this.contains(e)){const t=Array.from(this.querySelectorAll(".c-btn")).indexOf(e);this.dispatchEvent(new CustomEvent("contour:btn-group-change",{bubbles:!0,composed:!0,detail:{index:t,label:e.textContent}}))}}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-btn"));e.length&&navKey(t,e,{wrap:!1,homeEnd:!0,rtl:isRtl(this)})}))}}define("contour-btn-group",ContourBtnGroup);class ContourRangeScale extends ContourBase{static get observed(){return["label","ticks"]}static get properties(){return{label:{attribute:"label"},ticks:{attribute:"ticks"}}}render(){this.classList.add("c-range-scale"),this.setAttribute("role","group"),this.getAttribute("label")&&this.setAttribute("aria-label",this.getAttribute("label"));const t=this.getAttribute("label");if(t){this.ensure(".c-range-scale__label",()=>{const t=document.createElement("span");return t.className="c-range-scale__label",t}).textContent=t}const e=this.getAttribute("ticks");Array.from(this.querySelectorAll(".c-range-scale__tick")).forEach(t=>t.remove()),e&&e.split(",").map(t=>t.trim()).filter(Boolean).forEach(t=>{const e=document.createElement("span");e.className="c-range-scale__tick",e.textContent=t,this.appendChild(e)})}enhance(){this._wiredRangeScale||(this._wiredRangeScale=!0,this.addEventListener("input",t=>{const e=t.target;e&&e.matches&&e.matches("input")&&this.dispatchEvent(new CustomEvent("contour:range-change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}),this.addEventListener("change",t=>{const e=t.target;e&&e.matches&&e.matches("input")&&this.dispatchEvent(new CustomEvent("contour:range-change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}))}}define("contour-range-scale",ContourRangeScale);class ContourTimeRange extends ContourBase{static get observed(){return["label","value","ticks","required","disabled"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},ticks:{attribute:"ticks"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}render(){this.classList.add("c-time-range"),this.setAttribute("role","group"),this.getAttribute("label")&&this.setAttribute("aria-label",this.getAttribute("label"));const t=this.getAttribute("label");if(t){this.ensure(".c-time-range__label",()=>{const t=document.createElement("span");return t.className="c-time-range__label",t}).textContent=t}const e=this.querySelector("input");!e||!t||e.hasAttribute("aria-label")||e.labels&&e.labels.length||e.setAttribute("aria-label",t);const r=this.getAttribute("value");null!==r&&e&&e.value!==r&&(e.value=r);const s=this.getAttribute("ticks");Array.from(this.querySelectorAll(".c-time-range__tick")).forEach(t=>t.remove()),s&&s.split(",").map(t=>t.trim()).filter(Boolean).forEach(t=>{const e=document.createElement("span");e.className="c-time-range__tick",e.textContent=t,this.appendChild(e)})}enhance(){this._wiredTimeRange||(this._wiredTimeRange=!0,this.addEventListener("input",t=>{const e=t.target;e&&e.matches&&e.matches("input")&&this.dispatchEvent(new CustomEvent("contour:time-range-change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}),this.addEventListener("change",t=>{const e=t.target;e&&e.matches&&e.matches("input")&&this.dispatchEvent(new CustomEvent("contour:time-range-change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}))}}define("contour-time-range",ContourTimeRange);class ContourSkipLink extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){Array.from(this.childNodes).forEach(t=>{t.nodeType===Node.TEXT_NODE&&t.remove()});const t=this.ensure("a",()=>{const t=document.createElement("a");return t.className="c-skip-link",t});t.setAttribute("href",safeHref(this.getAttribute("href")||"#main")),t.textContent=this.getAttribute("label")||"Skip to content"}}define("contour-skip-link",ContourSkipLink);class ContourIcon extends ContourBase{static get observed(){return["name","size","label"]}static get properties(){return{name:{attribute:"name"},size:{attribute:"size"},label:{attribute:"label"}}}render(){const t=this.getAttribute("name")||"",e=t.startsWith("i-")?t.slice(2):t,r=this.getAttribute("size"),s=this.getAttribute("label");this.innerHTML="";const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("class","c-icon"),i.setAttribute("aria-hidden","true"),r&&(i.style.width=r,i.style.height=r);const a=document.createElementNS("http://www.w3.org/2000/svg","use");a.setAttribute("href","#i-"+e),i.appendChild(a),this.appendChild(i),s?(this.setAttribute("role","img"),this.setAttribute("aria-label",s)):(this.removeAttribute("role"),this.removeAttribute("aria-label"))}}define("contour-icon",ContourIcon);class ContourDashboardGrid extends ContourBase{static get observed(){return["cols","gap"]}static get properties(){return{cols:{attribute:"cols"},gap:{attribute:"gap"}}}render(){this.classList.add("c-dashboard-grid");const t=this.getAttribute("cols");t&&this.style.setProperty("--dashboard-grid-cols",t);const e=this.getAttribute("gap");e&&this.style.setProperty("--dashboard-grid-gap",e)}}define("contour-dashboard-grid",ContourDashboardGrid);class ContourAnalysisStack extends ContourBase{static get observed(){return["title","heading"]}static get properties(){return{title:{attribute:"title"},heading:{attribute:"heading"}}}render(){this.classList.add("c-analysis-stack");const t=this.getAttribute("title");let e=this.querySelector(".c-analysis-stack__header");if(t){e||(e=document.createElement("div"),e.className="c-analysis-stack__header",this.prepend(e));let r=e.querySelector(".c-analysis-stack__title");r||(r=document.createElement(headingTag(this,"h3")),r.className="c-analysis-stack__title",e.appendChild(r)),r.textContent=t}else e&&e.remove()}}define("contour-analysis-stack",ContourAnalysisStack);const SHAPES=new Set(["point","line","polygon","raster","heatmap","symbol"]);function wireMapItems(t,e,r){if(t._wiredMapItems)return;t._wiredMapItems=!0;const s=()=>Array.from(t.querySelectorAll(e)),i=s=>{const i=t.querySelector(r);if(!i)return;const a=s&&s.target&&"function"==typeof s.target.closest?s.target.closest(e):null;if(!a||!t.contains(a))return void i.setAttribute("hidden","");const n=a.getAttribute("data-title")||a.getAttribute("title");n&&(i.textContent=n);const o=t.getBoundingClientRect(),l=a.getBoundingClientRect();i.style.setProperty("--chart-tip-inline-start",l.left-o.left+l.width/2+"px"),i.style.setProperty("--chart-tip-block-start",l.top-o.top+"px"),i.removeAttribute("hidden")},a=()=>{const e=t.querySelector(r);e&&e.setAttribute("hidden","")};t.addEventListener("mouseover",i),t.addEventListener("mouseout",e=>{e.relatedTarget&&t.contains(e.relatedTarget)||a()}),t.addEventListener("focusin",r=>{const s=r&&r.target&&"function"==typeof r.target.closest?r.target.closest(e):null;s&&t.contains(s)&&i({target:s})}),t.addEventListener("focusout",e=>{t.contains(e.relatedTarget)||a()}),t.addEventListener("click",r=>{const i=r&&r.target&&"function"==typeof r.target.closest?r.target.closest(e):null;if(!i||!t.contains(i))return;const a=s().indexOf(i);a<0||t.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:a,label:i.getAttribute("data-title")||i.getAttribute("title")||i.textContent.trim()}}))}),t.addEventListener("keydown",r=>{const i=r&&r.target&&"function"==typeof r.target.closest?r.target.closest(e):null;if(i&&t.contains(i))if("Enter"===r.key||" "===r.key){r.preventDefault();const e=s().indexOf(i);e>=0&&t.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:e,label:i.getAttribute("data-title")||i.getAttribute("title")||i.textContent.trim()}}))}else{const e=s();navKey(r,e,{wrap:!1,homeEnd:!0,rtl:isRtl(t),onNavigate:t=>e.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1"))})}})}class ContourMinimap extends ContourBase{static get observed(){return["label","viewport","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},viewport:{attribute:"viewport"},src:{attribute:"src"}}}render(){if(this.classList.add("c-minimap"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Minimap"),wireStates(this),loadRemote(this,["label","viewport"]),renderStates(this,"minimap"))return;const t=remoteData(this,"label")||this._remoteData&&this._remoteData.label,e=remoteData(this,"viewport")||this._remoteData&&(this._remoteData.viewport||this._remoteData.value);if(t||e){if(t){this.ensure(".c-minimap__label",()=>{const t=document.createElement("span");return t.className="c-minimap__label",t}).textContent=t}else{const t=this.querySelector(".c-minimap__label");t&&t.remove()}if(e){this.ensure(".c-minimap__viewport",()=>{const t=document.createElement("div");return t.className="c-minimap__viewport",t}).textContent=e}else{const t=this.querySelector(".c-minimap__viewport");t&&t.remove()}}else renderEmpty(this,"minimap")}enhance(){if(this._wiredMinimap)return;this._wiredMinimap=!0,this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");let t=!1,e=0,r=0;this.addEventListener("pointerdown",s=>{const i=this.querySelector(".c-minimap__viewport");if(i&&i.contains(s.target)){t=!0,e=s.clientX,r=s.clientY;try{i.setPointerCapture(s.pointerId)}catch(t){}}}),this.addEventListener("pointermove",s=>{if(!t)return;const i=s.clientX-e,a=s.clientY-r;this.dispatchEvent(new CustomEvent("contour:move",{detail:{direction:"drag",dx:i,dy:a},bubbles:!0,composed:!0}))}),this.addEventListener("pointerup",()=>{t=!1}),this.addEventListener("keydown",t=>{let e=null;"ArrowUp"===t.key?e="up":"ArrowDown"===t.key?e="down":"ArrowLeft"===t.key?e="left":"ArrowRight"===t.key?e="right":"Home"===t.key?e="home":"End"===t.key&&(e="end"),e&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:move",{detail:{direction:e},bubbles:!0,composed:!0})))})}}define("contour-minimap",ContourMinimap);class ContourCoordinate extends ContourBase{static get observed(){return["value","format","locale","precision","live","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"},precision:{attribute:"precision"},live:{attribute:"live"},src:{attribute:"src"}}}render(){if(this.classList.add("c-coordinate"),wireStates(this),loadRemote(this,"value"),renderStates(this,"coordinate"))return;const t=remoteData(this,"value")||this._remoteData&&(this._remoteData.value||this._remoteData.coordinate);if(!t)return void renderEmpty(this,"coordinate");const e=this.getAttribute("format")||"decimal";let r=String(t);if("dms"===e){const e=String(t).split(/[,\s]+/).map(Number);if(e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])){const t=parseInt(this.getAttribute("precision")||"1",10),s=Number.isFinite(t)&&t>=0?t:1,i=(t,e)=>{const r=Math.floor(Math.abs(t)),i=Math.floor(60*(Math.abs(t)-r)),a="lat"===e?t<0?"S":"N":t<0?"W":"E";return r+"°"+i+"'"+(60*(60*(Math.abs(t)-r)-i)).toFixed(s)+'"'+a};r=i(e[0],"lat")+" "+i(e[1],"lon")}}else if("web-mercator"===e){const e=String(t).split(/[,\s]+/).map(Number);if(e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])){const t=20037508.34*e[1]/180,s=Math.log(Math.tan((90+e[0])*Math.PI/360))/(Math.PI/180)*20037508.34/180;r=t.toFixed(2)+", "+s.toFixed(2)}}else if("decimal"===e){const e=String(t).split(/[,\s]+/).map(Number),s=parseInt(this.getAttribute("precision")||"",10);r=e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(s)&&s>=0?e[0].toFixed(s)+", "+e[1].toFixed(s):formatValue(t,this.getAttribute("format"),this.getAttribute("locale"))}else r=formatValue(t,this.getAttribute("format"),this.getAttribute("locale"));const s=this.ensure(".c-coordinate__value",()=>{const t=document.createElement("span");return t.className="c-coordinate__value",t});this.hasAttribute("live")?(s.setAttribute("role","status"),s.setAttribute("aria-live","polite")):(s.removeAttribute("role"),s.removeAttribute("aria-live")),s.textContent=r;let i=this.querySelector(".c-coordinate__copy");function a(t){try{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}catch(t){}}i||(i=document.createElement("button"),i.type="button",i.className="c-btn c-btn--sm c-btn--icon c-coordinate__copy",setHTML(i,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-copy" /></svg>'),i.setAttribute("aria-label",labelText(this,"copy-coordinate","Copy coordinate")),i.setAttribute("data-contour-label","true"),this.appendChild(i)),i.onclick=()=>{try{navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(r).catch(()=>{a(r)}):a(r)}catch(t){a(r)}this.dispatchEvent(new CustomEvent("contour:copy",{detail:{text:r},bubbles:!0,composed:!0}))}}}define("contour-coordinate",ContourCoordinate);class ContourLayerPanel extends ContourBase{static get observed(){return["label","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","allow-rename","allow-remove","allow-duplicate","allow-zoom","allow-opacity","allow-reorder","allow-projection","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"},src:{attribute:"src"}}}render(){if(this.classList.add("c-layer-panel"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"layer-panel","Layer panel")),this._layerIdSeen=new Set,wireStates(this),loadRemote(this,"items"),renderStates(this,"layer-panel"))return;const t=remoteData(this,"items"),e=this.getAttribute("label");if(e){this.ensure(".c-layer-panel__label",()=>{const t=document.createElement("span");return t.className="c-layer-panel__label",t}).textContent=e}else{const t=this.querySelector(".c-layer-panel__label");t&&t.remove()}const r=Array.from(this.querySelectorAll(":scope > .c-layer-panel__item")),s=new Map,i=new Map;this.querySelectorAll(".c-layer-panel__item").forEach(t=>{const e=t.querySelector(".c-layer-panel__name"),r=t.querySelector(".c-layer-panel__toggle");if(e&&r){const t=r.hasAttribute("aria-pressed")?"true"===r.getAttribute("aria-pressed"):!!r.checked;s.set(e.textContent,t)}const a=t.querySelector(".c-layer-panel__opacity");e&&a&&i.set(e.textContent,a.value)});let a=null;if(r.length)a=r.map(t=>{const e=t.querySelector(".c-layer-panel__name"),r=t.querySelector(".c-layer-panel__toggle"),s=!r||(r.hasAttribute("aria-pressed")?"true"===r.getAttribute("aria-pressed"):!!r.checked),i=t.querySelector(".c-layer-panel__caption");return{name:e?e.textContent:"",visible:s,caption:i?i.textContent:t.dataset.caption||void 0}}),r.forEach(t=>t.remove());else if(t)try{a=JSON.parse(t),Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach(t=>t.remove())}catch(t){warnBadJson(this,"attribute",t)}a&&a.forEach(t=>{const e="string"==typeof t?t:t.name||t.label||"",r="object"==typeof t&&t&&(t.caption||t.subtitle)||"";null==this._layerIdByName&&(this._layerIdByName=new Map);const a="object"==typeof t&&t&&t.id?String(t.id):"";let n;if(a)n=a;else if(this._layerIdByName.has(e))n=this._layerIdByName.get(e);else{n=(e?e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""):"")||"layer",this._layerIdByName.set(e,n)}if(null==this._layerIdSeen&&(this._layerIdSeen=new Set),this._layerIdSeen.has(n)){let t=2;for(;this._layerIdSeen.has(n+"-"+t);)t++;n=n+"-"+t}this._layerIdSeen.add(n);const o=document.createElement("div");if(o.className="c-layer-panel__item"+(t.dragging?" c-layer-panel__item--dragging":""),o.dataset.layerId=n,"false"!==this.getAttribute("allow-reorder")){const t=document.createElement("button");t.type="button",t.className="c-drag-handle--dots",t.setAttribute("aria-label",labelText(this,"reorder","Reorder")+" "+(e||labelText(this,"layer","layer"))),t.setAttribute("tabindex","0"),o.appendChild(t)}const l=document.createElement("button");l.type="button",l.className="c-layer-panel__toggle",l.setAttribute("part","visibility-toggle"),l.setAttribute("aria-label",labelText(this,"toggle","Toggle")+" "+(e||labelText(this,"layer","layer")));const c=s.has(e)?s.get(e):"object"==typeof t&&!1!==t.visible;l.setAttribute("aria-pressed",String(!!c)),l.checked=!!c,setHTML(l,c?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-check" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-minus" /></svg>'),o.appendChild(l);const u=document.createElement("span");if(u.className="c-layer-panel__name",u.textContent=e,o.appendChild(u),r){const t=document.createElement("span");t.className="c-layer-panel__caption",t.textContent=r,o.appendChild(t)}if("false"!==this.getAttribute("allow-opacity")){const r=document.createElement("input");r.type="range",r.className="c-layer-panel__opacity",r.min="0",r.max="100",r.setAttribute("aria-label",labelText(this,"opacity-of","Opacity of")+" "+(e||"layer")),r.value=i.has(e)?i.get(e):"object"==typeof t&&null!=t.opacity?t.opacity:"100",o.appendChild(r)}if("false"!==this.getAttribute("allow-rename")){const t=document.createElement("button");t.type="button",t.className="c-btn c-btn--icon c-btn--ghost c-btn--sm c-layer-panel__rename",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-pen" /></svg>'),t.setAttribute("aria-label",labelText(this,"rename","Rename")+" "+(e||"layer")),o.appendChild(t)}if("false"!==this.getAttribute("allow-duplicate")){const t=document.createElement("button");t.type="button",t.className="c-btn c-btn--icon c-btn--ghost c-btn--sm c-layer-panel__duplicate",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-copy" /></svg>'),t.setAttribute("aria-label",labelText(this,"duplicate","Duplicate")+" "+(e||"layer")),o.appendChild(t)}if("false"!==this.getAttribute("allow-zoom")){const t=document.createElement("button");t.type="button",t.className="c-layer-panel__zoom",t.textContent=labelText(this,"zoom","Zoom"),t.setAttribute("aria-label",labelText(this,"zoom-to","Zoom to")+" "+(e||"layer")),o.appendChild(t)}if("false"!==this.getAttribute("allow-remove")){const t=document.createElement("button");t.type="button",t.className="c-layer-panel__remove",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-minus" /></svg>'),t.setAttribute("aria-label",labelText(this,"remove","Remove")+" "+(e||"layer")),o.appendChild(t)}if(this.hasAttribute("allow-projection")&&"false"!==this.getAttribute("allow-projection")){const t=document.createElement("select");t.className="c-select c-layer-panel__projection",t.setAttribute("aria-label",labelText(this,"projection-of","Projection of")+" "+(e||labelText(this,"layer","layer"))),["EPSG:4326","EPSG:3857"].forEach(e=>{const r=document.createElement("option");r.value=e,r.textContent=e,t.appendChild(r)}),o.appendChild(t)}this.appendChild(o)}),a||r.length||t||(Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach(t=>t.remove()),renderEmpty(this,"layer-panel"))}enhance(){if(this._wiredLayerPanel)return;this._wiredLayerPanel=!0;const t=t=>t&&t.dataset&&t.dataset.layerId||"";this.addEventListener("change",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-layer-panel__item"):null;if(!r||!this.contains(r))return;const s=r.querySelector(".c-layer-panel__name")?.textContent||"",i=t(r);if(e.target.classList.contains("c-layer-panel__toggle")){const t="boolean"==typeof e.target.checked?e.target.checked:"true"!==e.target.getAttribute("aria-pressed");e.target.checked=t,e.target.setAttribute("aria-pressed",String(t)),setHTML(e.target,t?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-check" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-minus" /></svg>'),this.dispatchEvent(new CustomEvent("contour:layer-visibility",{bubbles:!0,composed:!0,detail:{layerId:i,name:s,visible:t}}))}else e.target.classList.contains("c-layer-panel__opacity")?this.dispatchEvent(new CustomEvent("contour:layer-opacity",{bubbles:!0,composed:!0,detail:{layerId:i,name:s,opacity:Number(e.target.value)}})):e.target.classList.contains("c-layer-panel__projection")&&this.dispatchEvent(new CustomEvent("contour:layer-projection",{bubbles:!0,composed:!0,detail:{layerId:i,name:s,projection:e.target.value}}))}),this.addEventListener("input",e=>{const r=e.target;if(!r||!r.classList||!r.classList.contains("c-layer-panel__opacity"))return;const s=r.closest(".c-layer-panel__item");if(!s||!this.contains(s))return;const i=s.querySelector(".c-layer-panel__name")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:layer-opacity",{bubbles:!0,composed:!0,detail:{layerId:t(s),name:i,opacity:Number(r.value)}}))}),this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest("button"):null;if(!r||!this.contains(r))return;const s=r.closest(".c-layer-panel__item");if(r.classList.contains("c-layer-panel__toggle")){if(!s)return;const e=s.querySelector(".c-layer-panel__name")?.textContent||"",i=t(s),a="true"!==r.getAttribute("aria-pressed");return r.setAttribute("aria-pressed",String(a)),r.checked=a,setHTML(r,a?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-check" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-minus" /></svg>'),void this.dispatchEvent(new CustomEvent("contour:layer-visibility",{bubbles:!0,composed:!0,detail:{layerId:i,name:e,visible:a}}))}if(!s)return;const i=s.querySelector(".c-layer-panel__name")?.textContent||"",a=t(s);if(r.classList.contains("c-layer-panel__rename")){const t=s.querySelector(".c-layer-panel__name");if(t){const e=document.createElement("input");e.type="text",e.className="c-input c-layer-panel__rename-input",e.value=i,e.setAttribute("aria-label",labelText(this,"rename-layer","Rename layer")),t.replaceWith(e),e.focus(),e.select();let r=!1;const s=()=>{if(r)return;if(!e.isConnected)return;r=!0;const t=(e.value||"").trim(),s=document.createElement("span");s.className="c-layer-panel__name",s.textContent=t||i,e.replaceWith(s),t&&t!==i&&(null==this._layerIdByName&&(this._layerIdByName=new Map),this._layerIdByName.set(t,a),this.dispatchEvent(new CustomEvent("contour:layer-rename",{bubbles:!0,composed:!0,detail:{layerId:a,name:i,newName:t}})))};e.addEventListener("keydown",t=>{"Enter"===t.key?(t.preventDefault(),s()):"Escape"===t.key&&(t.preventDefault(),e.value=i,s())}),e.addEventListener("blur",s,{once:!0})}}else r.classList.contains("c-layer-panel__duplicate")?this.dispatchEvent(new CustomEvent("contour:layer-duplicate",{bubbles:!0,composed:!0,detail:{layerId:a,name:i}})):r.classList.contains("c-layer-panel__zoom")?this.dispatchEvent(new CustomEvent("contour:layer-zoom",{bubbles:!0,composed:!0,detail:{layerId:a,name:i}})):r.classList.contains("c-layer-panel__remove")&&this.dispatchEvent(new CustomEvent("contour:layer-remove",{bubbles:!0,composed:!0,detail:{layerId:a,name:i}}))}),this.addEventListener("keydown",t=>{if(t.target&&t.target.classList&&t.target.classList.contains("c-layer-panel__toggle")&&("Enter"===t.key||" "===t.key))return t.preventDefault(),void t.target.click();const e=t.target&&t.target.closest?t.target.closest(".c-layer-panel__item"):null;if(!e||!this.contains(e))return;const r=t.target&&t.target.classList&&t.target.classList.contains("c-drag-handle--dots");if(r&&("ArrowUp"===t.key||"ArrowDown"===t.key)||t.altKey&&("ArrowUp"===t.key||"ArrowDown"===t.key)){t.preventDefault();const s=Array.from(this.querySelectorAll(".c-layer-panel__item")),i=s.indexOf(e);if(i<0)return;const a="ArrowUp"===t.key?-1:1,n=i+a;if(n<0||n>=s.length)return;e.classList.add("c-layer-panel__item--dragging"),a<0?this.insertBefore(e,s[n]):this.insertBefore(s[n],e),(r?t.target:e).focus(),setTimeout(()=>e.classList.remove("c-layer-panel__item--dragging"),200);const o=Array.from(this.querySelectorAll(".c-layer-panel__item")).map((t,e)=>t.dataset.layerId||t.getAttribute("data-layer-id")||String(e));this.dispatchEvent(new CustomEvent("contour:layer-reorder",{bubbles:!0,composed:!0,detail:{layerIds:o}}))}})}}define("contour-layer-panel",ContourLayerPanel);class ContourTimeSlider extends ContourBase{static get observed(){return["label","value","min","max","loop","speed","speeds","show-loop","loop-label","current-time","time-format","is-playing","play-label","pause-label","time-label","speed-label"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},distance:{attribute:"distance"},resolution:{attribute:"resolution"},latitude:{attribute:"latitude"},src:{attribute:"src"},loop:{attribute:"loop",type:Boolean},speed:{attribute:"speed"},speeds:{attribute:"speeds"},showLoop:{attribute:"show-loop",type:Boolean},loopLabel:{attribute:"loop-label"},currentTime:{attribute:"current-time"},timeFormat:{attribute:"time-format"},isPlaying:{attribute:"is-playing",type:Boolean},playLabel:{attribute:"play-label"},pauseLabel:{attribute:"pause-label"},timeLabel:{attribute:"time-label"},speedLabel:{attribute:"speed-label"}}}render(){this.classList.add("c-time-slider"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Time slider");const t=this.ensure(".c-time-slider__play",()=>{const t=document.createElement("button");t.className="c-time-slider__play",t.type="button",t.setAttribute("aria-label",this.getAttribute("play-label")||"Play"),t.setAttribute("data-state","play");const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true");const r=document.createElementNS("http://www.w3.org/2000/svg","use");return r.setAttribute("href","#i-play"),e.appendChild(r),t.appendChild(e),t}),e=this.ensure(".c-time-slider__track",()=>{const t=document.createElement("input");return t.className="c-time-slider__track",t.type="range",t.min="0",t.max="100",t.setAttribute("part","input"),t.setAttribute("aria-label",this.getAttribute("time-label")||"Time"),t});e.min=this.getAttribute("min")||"0",e.max=this.getAttribute("max")||"100";const r=this.getAttribute("value")||"0";this._timeSliderAttrLast!==r&&(e.value=r,this._timeSliderAttrLast=r),e.setAttribute("aria-label",this.getAttribute("label")||this.getAttribute("time-label")||"Time");const s=this.ensure(".c-time-slider__time",()=>{const t=document.createElement("span");return t.className="c-time-slider__time",t}),i=this.getAttribute("current-time"),a=this.getAttribute("time-format");i?(s.textContent=i,e.setAttribute("aria-valuetext",i)):a?(s.textContent=formatValue(String(e.value),a),e.removeAttribute("aria-valuetext")):(s.textContent=String(e.value),e.removeAttribute("aria-valuetext"));const n=this.ensure("datalist",()=>document.createElement("datalist"));n.id||(n.id=contourId("time-slider-ticks")),setHTML(n,"");const o=Number(e.min)||0,l=Number(e.max)||100;for(let t=0;t<5;t++){const e=document.createElement("option");e.value=String(Math.round(o+t/4*(l-o))),n.appendChild(e)}e.setAttribute("list",n.id),n.parentNode!==this&&this.appendChild(n);let c=null;const u=this.getAttribute("speeds");if(u)try{c=JSON.parse(u)}catch(t){c=null}const d=this.ensure(".c-time-slider__speed",()=>{const t=document.createElement("select");return t.className="c-select c-time-slider__speed",t.setAttribute("aria-label",this.getAttribute("speed-label")||"Speed"),t});setHTML(d,"");(Array.isArray(c)?c:[.5,1,2,5,10]).forEach(t=>{const e=document.createElement("option");e.value=String(t),e.textContent=String(t),String(t)===(this.getAttribute("speed")||"")&&(e.selected=!0),d.appendChild(e)});const h=this.getAttribute("speed");h&&(d.value=h);if(this.hasAttribute("show-loop")){const t=this.ensure(".c-time-slider__loop",()=>{const t=document.createElement("button");return t.className="c-time-slider__loop",t.type="button",t.setAttribute("aria-label",this.getAttribute("loop-label")||"Loop"),t});t.setAttribute("aria-pressed",this.hasAttribute("loop")?"true":"false"),setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-refresh" /></svg>')}else{const t=this.querySelector(".c-time-slider__loop");t&&t.remove()}const m=this.hasAttribute("is-playing");t.setAttribute("data-state",m?"pause":"play"),t.setAttribute("aria-label",m?this.getAttribute("pause-label")||"Pause":this.getAttribute("play-label")||"Play");const b=t.querySelector("use");b&&b.setAttribute("href",m?"#i-pause":"#i-play")}enhance(){if(this._timeSliderReconcile&&this._timeSliderReconcile(),this._wiredTimeSlider)return;let t;this._wiredTimeSlider=!0;const e=()=>{void 0!==t&&(clearInterval(t),t=void 0)},r=()=>{const t=this.querySelector(".c-time-slider__track");if(!t)return;const e=this.querySelector(".c-time-slider__time"),r=this.getAttribute("current-time"),s=this.getAttribute("time-format");e&&(e.textContent=r||(s?formatValue(String(t.value),s):String(t.value))),r?t.setAttribute("aria-valuetext",r):t.removeAttribute("aria-valuetext")},s=()=>{const t=this.querySelector(".c-time-slider__track");if(!t)return void e();const s=Number(t.max)||100,i=Number(t.min)||0,a=this.hasAttribute("loop");let n=(Number(t.value)||0)+1;n>s&&(n=a?i:s),t.value=String(n);const o=this.querySelector(".c-time-slider__speed");this._timeSliderScrubbing||o&&document.activeElement===o||this.setAttribute("value",String(n)),r(),this.dispatchEvent(new CustomEvent("contour:time-change",{detail:{value:String(n)},bubbles:!0,composed:!0})),!a&&n>=s&&(e(),this.removeAttribute("is-playing"),this.dispatchEvent(new CustomEvent("contour:pause",{bubbles:!0,composed:!0})))},i=()=>{e();const r=parseFloat(this.getAttribute("speed")||"1")||1;t=setInterval(s,Math.max(100,1e3/r))};this._timeSliderReconcile=()=>{const r=this.hasAttribute("is-playing");r&&void 0===t?(i(),this.dispatchEvent(new CustomEvent("contour:play",{bubbles:!0,composed:!0}))):r||void 0===t||(e(),this.dispatchEvent(new CustomEvent("contour:pause",{bubbles:!0,composed:!0})))},this.addEventListener("click",t=>{if(t.target&&t.target.closest?t.target.closest(".c-time-slider__play"):null)return void this.toggleAttribute("is-playing",!this.hasAttribute("is-playing"));const e=t.target&&t.target.closest?t.target.closest(".c-time-slider__loop"):null;if(e){const t="true"!==e.getAttribute("aria-pressed");e.setAttribute("aria-pressed",String(t)),this.toggleAttribute("loop",t),this.dispatchEvent(new CustomEvent("contour:loop-change",{detail:{loop:t},bubbles:!0,composed:!0}))}}),this.addEventListener("pointerdown",t=>{t.target&&t.target.closest&&t.target.closest(".c-time-slider__track")&&(this._timeSliderScrubbing=!0)},{passive:!0});const a=()=>{this._timeSliderScrubbing=!1};this.addEventListener("pointerup",a,{passive:!0}),this.addEventListener("pointercancel",a,{passive:!0}),this.addEventListener("input",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-time-slider__track"):null;e&&(this._timeSliderScrubbing||this.setAttribute("value",e.value),r(),this.dispatchEvent(new CustomEvent("contour:time-change",{detail:{value:e.value},bubbles:!0,composed:!0})))}),this.addEventListener("change",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-time-slider__speed"):null;if(s){const e=Number(s.value);return this.setAttribute("speed",String(e)),void 0!==t&&i(),void this.dispatchEvent(new CustomEvent("contour:speed-change",{detail:{speed:e},bubbles:!0,composed:!0}))}const a=e.target&&e.target.closest?e.target.closest(".c-time-slider__track"):null;a&&(this.setAttribute("value",a.value),r())}),onDispose(this,e),this._timeSliderReconcile()}disconnectedCallback(){super.disconnectedCallback(),this._wiredTimeSlider=!1,this._timeSliderReconcile=null}}define("contour-time-slider",ContourTimeSlider);class ContourHexbin extends ContourBase{static get observed(){return["label","cells","width","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},cells:{attribute:"cells"},width:{attribute:"width"},src:{attribute:"src"}}}render(){this.classList.add("c-hexbin"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Hexbin");const t=this.getAttribute("label")||this._remoteData&&this._remoteData.label;if(t){this.ensure(".c-hexbin__label",()=>{const t=document.createElement("span");return t.className="c-hexbin__label",t}).textContent=t}else{const t=this.querySelector(".c-hexbin__label");t&&t.remove()}if(wireStates(this),loadRemote(this,"cells"),renderStates(this,"hexbin"))return;const e=remoteData(this,"cells")||(this._remoteData&&this._remoteData.cells?JSON.stringify(this._remoteData.cells):null),r=Array.from(this.querySelectorAll(":scope > .c-hexbin__cell"));this.ensure(".c-hexbin__tooltip",()=>{const t=document.createElement("div");return t.className="c-hexbin__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t}).setAttribute("hidden","");const s=this.getAttribute("width");if(s?this.style.inlineSize=s:this.style.removeProperty("inline-size"),r.length){const t=Math.ceil(Math.sqrt(r.length||1));this.style.gridTemplateColumns="repeat("+t+", minmax(0, 1fr))",r.forEach((t,e)=>t.setAttribute("tabindex",0===e?"0":"-1"))}else{let t=null;if(e)try{t=JSON.parse(e)}catch(e){t=null}if(Array.isArray(t))try{Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach(t=>t.remove());const e=Math.ceil(Math.sqrt(t.length||1));this.style.gridTemplateColumns="repeat("+e+", minmax(0, 1fr))";const r=t.map(t=>Number("object"==typeof t&&null!==t?t.value:t)).filter(t=>Number.isFinite(t)),s=r.length?Math.min(...r):0,i=r.length?Math.max(...r):0,a=i-s;if(t.forEach((t,e)=>{const r=document.createElement("div");r.className="c-hexbin__cell",r.setAttribute("tabindex",0===e?"0":"-1");const i="object"==typeof t&&null!==t&&null!=t.value?t.value:t;null!=i&&""!==i&&(r.textContent=i,r.setAttribute("data-title",String(i)));const n=Number(i);if(Number.isFinite(n)){const t=a>0?(n-s)/a:1,e=Math.round(20+60*t);r.style.background="color-mix(in oklab, var(--color-primary) "+e+"%, var(--color-surface-2))"}this.appendChild(r)}),a>0&&r.length){const t=this.ensure(".c-hexbin__legend",()=>{const t=document.createElement("div");return t.className="c-hexbin__legend",t});t.textContent="";const e=document.createElement("div");e.className="c-hexbin__legend-swatch",e.style.background="color-mix(in oklab, var(--color-primary) 20%, var(--color-surface-2))",e.setAttribute("title",String(s));const r=document.createElement("div");r.className="c-hexbin__legend-swatch",r.style.background="color-mix(in oklab, var(--color-primary) 80%, var(--color-surface-2))",r.setAttribute("title",String(i));const a=document.createElement("span");a.className="c-hexbin__legend-label",a.textContent=String(s);const n=document.createElement("span");n.className="c-hexbin__legend-label",n.textContent=String(i),t.appendChild(e),t.appendChild(a),t.appendChild(r),t.appendChild(n)}}catch(t){warnBadJson(this,"attribute",t)}else Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach(t=>t.remove()),renderEmpty(this,"hexbin")}}enhance(){this._wiredHexbin||(this._wiredHexbin=!0,wireMapItems(this,".c-hexbin__cell",".c-hexbin__tooltip"))}}define("contour-hexbin",ContourHexbin);class ContourFlowMap extends ContourBase{static get observed(){return["label","nodes","flows","edges","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},nodes:{attribute:"nodes"},flows:{attribute:"flows"},edges:{attribute:"edges"},src:{attribute:"src"}}}render(){this.classList.add("c-flow-map"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Flow map");const t=this.getAttribute("label")||this._remoteData&&this._remoteData.label;if(t){this.ensure(".c-flow-map__label",()=>{const t=document.createElement("span");return t.className="c-flow-map__label",t}).textContent=t}else{const t=this.querySelector(".c-flow-map__label");t&&t.remove()}if(wireStates(this),loadRemote(this,"nodes"),renderStates(this,"flow-map"))return;const e=remoteData(this,"nodes")||(this._remoteData&&this._remoteData.nodes?JSON.stringify(this._remoteData.nodes):null),r=Array.from(this.querySelectorAll(":scope > .c-flow-map__node"));let s=null;if(r.length)s=r.map(t=>t.textContent||t.getAttribute("data-title")||t.getAttribute("title")||""),r.forEach(t=>t.remove());else if(e)try{s=JSON.parse(e)}catch(t){s=null}if(s)try{Array.from(this.querySelectorAll(".c-flow-map__node")).forEach(t=>t.remove()),s.forEach((t,e)=>{const r=document.createElement("span");r.className="c-flow-map__node"+(t.source?" c-flow-map__node--source":"")+(t.target?" c-flow-map__node--target":""),r.setAttribute("tabindex",0===e?"0":"-1"),r.textContent="string"==typeof t?t:t.label||t.name||"","object"==typeof t&&(t.label||t.name)&&r.setAttribute("data-title",t.label||t.name),this.appendChild(r)});this.ensure(".c-flow-map__tooltip",()=>{const t=document.createElement("div");return t.className="c-flow-map__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t}).setAttribute("hidden","")}catch(t){warnBadJson(this,"attribute",t)}else s||(Array.from(this.querySelectorAll(".c-flow-map__node")).forEach(t=>t.remove()),renderEmpty(this,"flow-map"));const i=null!=this.flows&&""!==this.flows?this.flows:null!=this.edges&&""!==this.edges?this.edges:this._remoteData&&null!=this._remoteData.flows?JSON.stringify(this._remoteData.flows):null;let a=null;if(null!=i)try{const t=JSON.parse(i);Array.isArray(t)?a=t:warnBadJson(this,"flows",new Error("expected an array"))}catch(t){warnBadJson(this,"flows",t)}const n=this.querySelector(".c-flow-map__summary");if(a){const t=this.ensure(".c-flow-map__summary",()=>{const t=document.createElement("div");return t.className="c-flow-map__summary c-table-wrap",t});let e=t.querySelector("table");e||(e=document.createElement("table"),e.className="c-table c-flow-map__table",t.appendChild(e)),setHTML(e,"");const r=document.createElement("caption");r.textContent=labelText(this,"flow-summary","Flow summary"),e.appendChild(r);const s=document.createElement("thead"),i=document.createElement("tr");[["source","Source"],["target","Target"],["magnitude","Magnitude"]].forEach(([t,e])=>{const r=document.createElement("th");r.setAttribute("scope","col"),r.textContent=labelText(this,t,e),i.appendChild(r)}),s.appendChild(i),e.appendChild(s);const n=document.createElement("tbody"),o=t=>"string"==typeof t?t:t&&"object"==typeof t?String(t.label||t.name||t.id||""):"";a.forEach(t=>{const e=t&&"object"==typeof t?t:{},r=document.createElement("tr"),s=document.createElement("th");s.setAttribute("scope","row"),s.textContent=o(e.source),r.appendChild(s);const i=document.createElement("td");i.textContent=o(e.target),r.appendChild(i);const a=document.createElement("td"),l=null!=e.value?e.value:e.magnitude,c=Number(l);a.textContent=null==l||""===l?"":Number.isFinite(c)?(c>0?"+":"")+c:String(l),r.appendChild(a),n.appendChild(r)}),e.appendChild(n)}else n&&n.remove()}enhance(){this._wiredFlowMap||(this._wiredFlowMap=!0,wireMapItems(this,".c-flow-map__node",".c-flow-map__tooltip"))}}define("contour-flow-map",ContourFlowMap);class ContourIsochrone extends ContourBase{static get observed(){return["label","center","rings","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},center:{attribute:"center"},rings:{attribute:"rings"},src:{attribute:"src"}}}render(){this.classList.add("c-isochrone"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Isochrone");const t=this.getAttribute("label")||this._remoteData&&this._remoteData.label;if(t){this.ensure(".c-isochrone__label",()=>{const t=document.createElement("span");return t.className="c-isochrone__label",t}).textContent=t}else{const t=this.querySelector(".c-isochrone__label");t&&t.remove()}const e=this.getAttribute("center")||this._remoteData&&this._remoteData.center;if(e){this.ensure(".c-isochrone__center",()=>{const t=document.createElement("span");return t.className="c-isochrone__center",t}).textContent=e}else{const t=this.querySelector(".c-isochrone__center");t&&t.remove()}if(wireStates(this),loadRemote(this,"rings"),renderStates(this,"isochrone"))return;const r=remoteData(this,"rings")||(this._remoteData&&this._remoteData.rings?JSON.stringify(this._remoteData.rings):null),s=Array.from(this.querySelectorAll(":scope > .c-isochrone__ring"));let i=null;if(s.length)i=s.map(t=>t.textContent||t.getAttribute("data-title")||t.getAttribute("title")||""),s.forEach(t=>t.remove());else if(r)try{i=JSON.parse(r)}catch(t){i=null}if(i)try{Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach(t=>t.remove()),i.forEach((t,e)=>{const r=document.createElement("span"),s="string"==typeof t?t:t&&(t.label||t.name||t.value||t.min),i=null==s?"":String(s),a=i.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");r.className="c-isochrone__ring"+(a?" c-isochrone__ring--"+a:""),r.setAttribute("tabindex",0===e?"0":"-1"),r.setAttribute("aria-label",i||"Isochrone ring "+(e+1)),i&&r.setAttribute("data-title",i),this.appendChild(r)});this.ensure(".c-isochrone__tooltip",()=>{const t=document.createElement("div");return t.className="c-isochrone__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t}).setAttribute("hidden","")}catch(t){warnBadJson(this,"attribute",t)}else i||(Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach(t=>t.remove()),renderEmpty(this,"isochrone"))}enhance(){this._wiredIsochrone||(this._wiredIsochrone=!0,wireMapItems(this,".c-isochrone__ring",".c-isochrone__tooltip"))}}define("contour-isochrone",ContourIsochrone);class ContourCatchment extends ContourBase{static get observed(){return["label","area","center","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},area:{attribute:"area"},center:{attribute:"center"},src:{attribute:"src"}}}render(){this.classList.add("c-catchment"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Catchment");const t=this.getAttribute("label")||this._remoteData&&this._remoteData.label;if(t){this.ensure(".c-catchment__label",()=>{const t=document.createElement("span");return t.className="c-catchment__label",t}).textContent=t}else{const t=this.querySelector(".c-catchment__label");t&&t.remove()}const e=this.getAttribute("area")||this._remoteData&&this._remoteData.area;if(e){this.ensure(".c-catchment__area",()=>{const t=document.createElement("span");return t.className="c-catchment__area",t}).textContent=e}else{const t=this.querySelector(".c-catchment__area");t&&t.remove()}const r=this.getAttribute("center")||this._remoteData&&this._remoteData.center;if(r){this.ensure(".c-catchment__center",()=>{const t=document.createElement("span");return t.className="c-catchment__center",t}).textContent=r}else{const t=this.querySelector(".c-catchment__center");t&&t.remove()}if(wireStates(this),loadRemote(this,["label","area","center"]),renderStates(this,"catchment"))return;const s=remoteData(this,"label")||this._remoteData&&this._remoteData.label,i=remoteData(this,"area")||this._remoteData&&this._remoteData.area,a=remoteData(this,"center")||this._remoteData&&this._remoteData.center;if(!s&&!i&&!a)return void renderEmpty(this,"catchment");const n=this.ensure(".c-catchment__tooltip",()=>{const t=document.createElement("div");return t.className="c-catchment__tooltip",t.setAttribute("role","tooltip"),t.setAttribute("hidden",""),t});n.setAttribute("hidden",""),i&&(n.textContent=i)}enhance(){if(this._wiredCatchment)return;this._wiredCatchment=!0;const t=()=>{const t=this.querySelector(".c-catchment__tooltip");t&&t.removeAttribute("hidden")},e=()=>{const t=this.querySelector(".c-catchment__tooltip");t&&t.setAttribute("hidden","")};this.addEventListener("mouseenter",t),this.addEventListener("mouseleave",e),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("focusin",t),this.addEventListener("focusout",e),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{area:this.getAttribute("area")}})))})}}define("contour-catchment",ContourCatchment);class ContourCompassFull extends ContourBase{static get observed(){return["label","needle","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","empty","no-cache"]}static get properties(){return{label:{attribute:"label"},needle:{attribute:"needle"},src:{attribute:"src"}}}render(){this.classList.add("c-compass"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Compass");const t=this.getAttribute("label")||this._remoteData&&this._remoteData.label;if(wireStates(this),loadRemote(this,"needle"),renderStates(this,"compass"))return;const e=remoteData(this,"needle")||this._remoteData&&(this._remoteData.needle||this._remoteData.value);if(e||t){for(const t of["n","s","e","w"]){const e=".c-compass__label--"+t;let r=this.querySelector(e);r||(r=document.createElement("span"),r.className="c-compass__label "+e.slice(1),r.textContent=t.toUpperCase(),r.setAttribute("role","button"),r.setAttribute("tabindex","0"),this.appendChild(r))}if(t&&"compass"!==t.toLowerCase()){this.ensure(".c-compass__label:not([class*='--'])",()=>{const t=document.createElement("span");return t.className="c-compass__label",t}).textContent=t}if(e){const t=Number(e)||0,r=this.ensure("svg.c-compass__needle",()=>{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","c-compass__needle"),e.setAttribute("viewBox","0 0 40 40"),e.setAttribute("aria-hidden","true");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("class","c-compass__needle--n"),r.setAttribute("d",compassNeedle(20,20,16,t)),e.appendChild(r);const s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("class","c-compass__needle--s"),s.setAttribute("d",compassNeedle(20,20,16,t+180)),e.appendChild(s),e}),s=r.querySelector(".c-compass__needle--n");s&&s.setAttribute("d",compassNeedle(20,20,16,t));const i=r.querySelector(".c-compass__needle--s");i&&i.setAttribute("d",compassNeedle(20,20,16,t+180))}else{const t=this.querySelector("svg.c-compass__needle, .c-compass__needle");t&&t.remove()}}else renderEmpty(this,"compass")}enhance(){if(this._wiredCompass)return;this._wiredCompass=!0;const t={n:0,e:90,s:180,w:270},e=e=>{const r=t[e];if(void 0===r)return;const s=this.querySelector(".c-compass__needle");if(s){const t=s.querySelector(".c-compass__needle--n");t&&t.setAttribute("d",compassNeedle(20,20,16,r));const e=s.querySelector(".c-compass__needle--s");e&&e.setAttribute("d",compassNeedle(20,20,16,r+180))}this.dispatchEvent(new CustomEvent("contour:bearing",{bubbles:!0,composed:!0,detail:{direction:e,degrees:r}}))};this.addEventListener("click",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-compass__label--n, .c-compass__label--e, .c-compass__label--s, .c-compass__label--w"):null;if(!r||!this.contains(r))return;const s=r.className.match(/c-compass__label--([nsew])/);s&&e(s[1])}),this.addEventListener("keydown",t=>{if("Enter"!==t.key&&" "!==t.key)return;const r=t.target&&t.target.closest?t.target.closest(".c-compass__label--n, .c-compass__label--e, .c-compass__label--s, .c-compass__label--w"):null;if(!r||!this.contains(r))return;t.preventDefault();const s=r.className.match(/c-compass__label--([nsew])/);s&&e(s[1])})}}define("contour-compass",ContourCompassFull);class ContourLayerSwitch extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){if(this.classList.add("c-layer-switch"),this.hasAttribute("role")||this.setAttribute("role","list"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"layer-switch","Layer switch")),wireStates(this),loadRemote(this,"items"),renderStates(this,"layer-switch"))return;const t=remoteData(this,"items"),e=Array.from(this.children).filter(t=>t.classList&&t.classList.contains("c-layer-switch__item"));if(t&&!e.length){Array.from(this.querySelectorAll(".c-layer-switch__item")).forEach(t=>t.remove());try{const e=JSON.parse(t);(Array.isArray(e)?e.slice(0,50):e).forEach(t=>{const e=document.createElement("div");e.className="c-layer-switch__item",e.setAttribute("role","listitem");const r="string"==typeof t?t:t.name||t.label||"",s="object"==typeof t&&t&&t.id?String(t.id):r?r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""):"";this._layerSwitchSeq=(this._layerSwitchSeq||0)+1,e.dataset.layerId=s||"layer-"+this._layerSwitchSeq;const i=document.createElement("span");i.className="c-layer-switch__swatch";const a="object"==typeof t&&t&&t.shape?String(t.shape):"";if(SHAPES.has(a)&&i.classList.add("c-swatch--"+a),t.color){const e=safeColor(t.color);e&&(SHAPES.has(a)?i.style.color=e:i.style.background=e)}i.setAttribute("aria-hidden","true"),e.appendChild(i);const n=document.createElement("span");if(n.className="c-layer-switch__name",n.textContent="string"==typeof t?t:t.name||t.label||"",e.appendChild(n),null!=t.count){const r=document.createElement("span");r.className="c-layer-switch__count",r.textContent=t.count,e.appendChild(r)}const o=document.createElement("button");o.className="c-layer-switch__toggle",o.type="button",o.setAttribute("aria-label",labelText(this,"toggle","Toggle")+" "+("string"==typeof t?t:t.name||t.label||labelText(this,"layer","layer")));const l="object"!=typeof t||!1!==t.visible;o.setAttribute("aria-pressed",String(l)),setHTML(o,l?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-check" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-minus" /></svg>'),e.appendChild(o),this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}}else t||e.length||(Array.from(this.querySelectorAll(".c-layer-switch__item")).forEach(t=>t.remove()),renderEmpty(this,"layer-switch"))}enhance(){this._wiredLayerSwitch||(this._wiredLayerSwitch=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-layer-switch__toggle"):null;if(!e||!this.contains(e))return;const r=e.closest(".c-layer-switch__item"),s=r&&r.querySelector(".c-layer-switch__name")?.textContent||"",i=r&&r.dataset&&r.dataset.layerId||"",a="true"!==e.getAttribute("aria-pressed");e.setAttribute("aria-pressed",String(a)),this.dispatchEvent(new CustomEvent("contour:layer-toggle",{bubbles:!0,composed:!0,detail:{layerId:i,name:s,visible:a}}))}),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-layer-switch__toggle"):null;e&&this.contains(e)&&("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e.click()))}))}}define("contour-layer-switch",ContourLayerSwitch);class ContourBasemapSwitcher extends ContourBase{static get observed(){return["items","value","label"]}static get properties(){return{items:{attribute:"items"},value:{attribute:"value"},label:{attribute:"label"}}}render(){this.classList.add("c-basemap-switcher"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||labelText(this,"basemap","Basemap"));let t=[];try{const e=JSON.parse(this.getAttribute("items")||"[]");Array.isArray(e)&&(t=e)}catch(t){}const e=this.getAttribute("value");Array.from(this.querySelectorAll(".c-basemap-switcher__item")).forEach(t=>t.remove()),t.forEach(t=>{const r="string"==typeof t?t:t.label||t.value||t,s="string"==typeof t?t:t.value||t.label||t,i=document.createElement("button");i.type="button",i.className="c-basemap-switcher__item c-btn c-btn--sm"+(e===s?" is-active":""),i.textContent=r,i.dataset.value=s,e===s&&i.setAttribute("aria-pressed","true"),this.appendChild(i)})}enhance(){this._wiredBasemap||(this._wiredBasemap=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-basemap-switcher__item"):null;if(!e||!this.contains(e))return;const r=e.dataset.value,s=(e.textContent||"").trim();this.setAttribute("value",r),this.dispatchEvent(new CustomEvent("contour:map-style",{bubbles:!0,composed:!0,detail:{style:r,name:s}}))}))}}define("contour-basemap-switcher",ContourBasemapSwitcher);class ContourMapSlot extends ContourBase{static get observed(){return["attribution","scale","chrome"]}static get properties(){return{attribution:{attribute:"attribution"},scale:{attribute:"scale"},chrome:{attribute:"chrome"}}}render(){this.classList.add("c-map-slot");const t=this.getAttribute("chrome");if(t){this.ensure(".c-map-slot__chrome",()=>{const t=document.createElement("div");return t.className="c-map-slot__chrome",t}).textContent=t}else{const t=this.querySelector(".c-map-slot__chrome");t&&t.remove()}const e=this.getAttribute("attribution");if(e){this.ensure(".c-map-slot__attribution",()=>{const t=document.createElement("div");return t.className="c-map-slot__attribution",t}).textContent=e}else{const t=this.querySelector(".c-map-slot__attribution");t&&t.remove()}const r=this.getAttribute("scale");if(r){this.ensure(".c-map-slot__scale",()=>{const t=document.createElement("div");return t.className="c-map-slot__scale",t}).textContent=r}else{const t=this.querySelector(".c-map-slot__scale");t&&t.remove()}}}define("contour-map-slot",ContourMapSlot);class ContourMapArea extends ContourBase{static get observed(){return["attribution","attribution-mark","scale","controls","style","style-name","src"]}static get properties(){return{attribution:{attribute:"attribution"},"attribution-mark":{attribute:"attribution-mark"},scale:{attribute:"scale"},controls:{attribute:"controls"},"style-name":{attribute:"style-name"}}}render(){this.classList.add("c-map-area"),this.classList.add("c-map-slot");const t=this.getAttribute("style");if(t&&t!==this._lastMapStyle){this._lastMapStyle=t;const e=this.getAttribute("style-name")||t;this.dispatchEvent(new CustomEvent("contour:map-style",{bubbles:!0,composed:!0,detail:{style:t,name:e}})),"function"==typeof requestAnimationFrame&&requestAnimationFrame(()=>this.dispatchEvent(new CustomEvent("contour:map-ready",{bubbles:!0,composed:!0})))}this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"map-area","Map area"));const e=this.getAttribute("attribution");if(e&&"engine"!==e){this.ensure(".c-map-slot__attribution",()=>{const t=document.createElement("div");return t.className="c-map-slot__attribution",t}).textContent=e}else{const t=this.querySelector(".c-map-slot__attribution");t&&t.remove()}const r=this.getAttribute("attribution-mark");if(r){this.ensure(".c-map-slot__attribution-mark",()=>{const t=document.createElement("span");return t.className="c-map-slot__attribution-mark",t}).textContent=r}else{const t=this.querySelector(".c-map-slot__attribution-mark");t&&t.remove()}const s=this.getAttribute("scale");if(s&&"engine"!==s){this.ensure(".c-map-slot__scale",()=>{const t=document.createElement("div");return t.className="c-map-slot__scale",t}).textContent=s}else{const t=this.querySelector(".c-map-slot__scale");t&&t.remove()}const i=this.getAttribute("controls");if(i)try{const t=JSON.parse(i),e=this.ensure(".c-map-slot__controls",()=>{const t=document.createElement("div");return t.className="c-map-slot__controls",t});setHTML(e,""),t.forEach(t=>{const r=document.createElement("button");r.className="c-map-slot__control",r.type="button";const s="object"==typeof t&&t,i=s?t.label||t.action||"":String(t),a=s&&t.action?{zoomIn:"i-plus",zoomOut:"i-minus",zoomReset:"i-crosshair",zoom:"i-zoom",reset:"i-refresh",locate:"i-crosshair",recenter:"i-crosshair"}[String(t.action)]:null;a&&setHTML(r,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+a+'" /></svg>'),r.appendChild(document.createTextNode((a?" ":"")+i)),s&&t.action&&(r.dataset.mapAction=String(t.action)),s&&t.label&&r.setAttribute("aria-label",String(t.label)),e.appendChild(r)})}catch(t){warnBadJson(this,"attribute",t)}else{const t=this.querySelector(".c-map-slot__controls");t&&t.remove()}}enhance(){this._wiredMapArea||(this._wiredMapArea=!0,this._map=null,this.getViewport=()=>{const t=this._map;if(!t)return null;try{if("function"==typeof t.getBounds){const e=t.getBounds();return unwrapBounds({west:e.getWest(),south:e.getSouth(),east:e.getEast(),north:e.getNorth()})}if(t.transform&&"object"==typeof t.transform)return{zoom:t.transform.zoom,center:t.transform.center}}catch(t){}return null},this._emitViewport=()=>{this.dispatchEvent(new CustomEvent("contour:map-viewport",{bubbles:!0,composed:!0,detail:this.getViewport()}))},this._detachEngine=()=>{const t=this._map;if(t&&"function"==typeof t.off){try{t.off("moveend",this._emitViewport)}catch(t){}try{t.off("idle",this._onMapIdle)}catch(t){}try{t.off("load",this._onMapIdle)}catch(t){}}if(this._mapRO){try{this._mapRO.disconnect()}catch(t){}this._mapRO=null}},this._onMapIdle=()=>{this._mapReadySent||(this._mapReadySent=!0,this.dispatchEvent(new CustomEvent("contour:map-ready",{bubbles:!0,composed:!0})))},this.attachMap=t=>{if(this._detachEngine(),this._map=t||null,this._mapReadySent=!1,this._map){const e=()=>{this.isConnected&&this._map===t&&(this.clientWidth&&this.clientHeight||this.dispatchEvent(new CustomEvent("contour:error",{bubbles:!0,composed:!0,detail:{src:this.getAttribute("src")||"",message:"Map container has zero size; the engine cannot render.",name:"map-zero-size",status:0}})))};"function"==typeof requestAnimationFrame?requestAnimationFrame(e):e()}if(this._map&&"function"==typeof this._map.on){try{this._map.on("moveend",this._emitViewport)}catch(t){}try{this._map.on("idle",this._onMapIdle)}catch(t){}try{this._map.on("load",this._onMapIdle)}catch(t){}}if("undefined"!=typeof ResizeObserver&&this._map)try{let t=0;this._mapRO=new ResizeObserver(()=>{t||(t=requestAnimationFrame(()=>{t=0;const e=this._map;if(e)try{"function"==typeof e.resize?e.resize():"function"==typeof e.invalidateSize&&e.invalidateSize()}catch(t){}}))}),this._mapRO.observe(this)}catch(t){this._mapRO=null}if(this.dispatchEvent(new CustomEvent("contour:map-attach",{bubbles:!0,composed:!0})),this._emitViewport(),this._map&&"function"==typeof this._map.loaded)try{this._map.loaded()&&this._onMapIdle()}catch(t){}},this.detachMap=()=>{this._detachEngine(),this._map=null,this.dispatchEvent(new CustomEvent("contour:map-detach",{bubbles:!0,composed:!0}))},this.hasOwnProperty("map")||Object.defineProperty(this,"map",{get:()=>this._map,set:t=>this.attachMap(t)}),this.fitBounds=(t,e)=>{const r=this._map;if(r&&"function"==typeof r.fitBounds)try{r.fitBounds(t,e)}catch(t){}},this.flyTo=t=>{const e=this._map;if(e&&"function"==typeof e.flyTo)try{e.flyTo(t)}catch(t){}},this.attachChrome=t=>{const e=t||this._map;if(!e||this._chromeMap===e)return;this._chromeMap=e,this._chromeDelegated||(this._chromeDelegated=!0,this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-drag-handle--dots, .c-layer-panel__grip"):null;if(!e||!this.contains(e))return;if("ArrowUp"!==t.key&&"ArrowDown"!==t.key)return;const r=e.closest(".c-layer-panel__item");if(!r)return;const s=r.parentNode,i="ArrowUp"===t.key?r.previousElementSibling:r.nextElementSibling;if(!i||!i.classList||!i.classList.contains("c-layer-panel__item"))return;t.preventDefault(),"ArrowUp"===t.key?s.insertBefore(r,i):s.insertBefore(i,r);try{e.focus()}catch(t){}const a=Array.from(s.querySelectorAll(":scope > .c-layer-panel__item")).map((t,e)=>t.dataset.layerId||t.getAttribute("data-layer-id")||String(e));this.dispatchEvent(new CustomEvent("contour:layer-reorder",{bubbles:!0,composed:!0,detail:{layerIds:a}}))}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-map-slot__control"):null;if(!e||!this.contains(e))return;const r=this._map;if(!r)return;const s=e.dataset.mapAction,i=(e.getAttribute("aria-label")||e.textContent||"").toLowerCase(),a=s?/out|minus|zoomout/i.test(s):/out|minus|−|-/.test(i)&&!/in\b/.test(i);try{a?r.zoomOut():r.zoomIn()}catch(t){}}));const r=this.querySelector(".c-readout");if(r&&"function"==typeof e.getCenter){const t=r.querySelector(".c-readout__value--coord"),s=r.querySelector(".c-readout__row:nth-child(2) .c-readout__value"),i=()=>{const r=this._map||e;if("function"!=typeof r.getCenter)return;const i=r.getCenter();t&&i&&(t.textContent=`${i.lng.toFixed(6)}, ${i.lat.toFixed(6)}`),s&&"function"==typeof r.getZoom&&(s.textContent=r.getZoom().toFixed(1))};try{e.on("move",i)}catch(t){}i()}const s=this.querySelector(".c-compass__needle");if(s&&"function"==typeof e.getBearing){const t=s.querySelector(".c-compass__needle--n"),r=s.querySelector(".c-compass__needle--s"),i=s.closest("contour-compass"),a=t=>{const e=t*Math.PI/180;return[20+16*Math.sin(e),20-16*Math.cos(e)]},n=()=>{const s=this._map||e;if("function"!=typeof s.getBearing)return;const n=-s.getBearing(),[o,l]=a(n),[c,u]=a(n+180);if(t&&t.setAttribute("d",`M ${o} ${l} L 20 20 Z`),r&&r.setAttribute("d",`M ${c} ${u} L 20 20 Z`),i){const t=i.getAttribute("aria-label")||"";if(!t||/^compass\b/i.test(t)){const t=Math.round((n%360+360)%360);i.setAttribute("aria-label",`Compass, bearing ${t} degrees`)}}};try{e.on("rotate",n)}catch(t){}n()}},this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-map-slot__control"):null;e&&this.contains(e)&&this.dispatchEvent(new CustomEvent("contour:map-control",{bubbles:!0,composed:!0,detail:{control:e.textContent}}))}))}}define("contour-map-area",ContourMapArea);class ContourMapPanel extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-map-panel"),this.hasAttribute("role")||this.setAttribute("role","region");const t=this.getAttribute("title");if(t){const e=this._mapPanelTitle;(!this.hasAttribute("aria-label")||e&&this.getAttribute("aria-label")===e)&&this.setAttribute("aria-label",t),this._mapPanelTitle=t}else this._mapPanelTitle&&this.getAttribute("aria-label")===this._mapPanelTitle&&(this.removeAttribute("aria-label"),this._mapPanelTitle=null)}}define("contour-map-panel",ContourMapPanel);class ContourMapFooter extends ContourBase{static get observed(){return["brand"]}static get properties(){return{brand:{attribute:"brand"}}}render(){this.classList.add("c-map-footer"),this.hasAttribute("role")||this.setAttribute("role","contentinfo");const t=this.getAttribute("brand");if(t){this.ensure(".c-map-footer__brand",()=>{const t=document.createElement("span");return t.className="c-map-footer__brand",t}).textContent=t}else{const t=this.querySelector(".c-map-footer__brand");t&&t.remove()}}}define("contour-map-footer",ContourMapFooter);class ContourScaleBar extends ContourBase{static get observed(){return["label","value","distance","resolution","latitude","zoom","units","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},value:{attribute:"value"},distance:{attribute:"distance"},resolution:{attribute:"resolution"},latitude:{attribute:"latitude"},zoom:{attribute:"zoom"},src:{attribute:"src"}}}render(){if(this.classList.add("c-scale-bar"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"map-scale","Map scale")),wireStates(this),loadRemote(this,["label","value"]),renderStates(this,"scale-bar"))return;let t=remoteData(this,"value")||this._remoteData&&this._remoteData.value;const e=parseFloat(this.getAttribute("resolution")),r=parseFloat(this.getAttribute("latitude")),s=parseFloat(this.getAttribute("zoom"));let i=e;!Number.isFinite(i)&&Number.isFinite(r)&&Number.isFinite(s)&&(i=mercatorResolution(r,s));let a=null;if(Number.isFinite(i)&&i>0){const e=parseFloat(this.getAttribute("distance"))||1e3;if(t=String(Math.round(e/i)),!this.getAttribute("label")&&!remoteData(this,"label")){a="imperial"===(this.getAttribute("units")||"metric")?e>=1609.34?(e/1609.34).toFixed(1)+" mi":Math.round(3.28084*e)+" ft":e>=1e3?e/1e3+" km":e+" m"}}const n=a||remoteData(this,"label")||this._remoteData&&this._remoteData.label;if(n){this.ensure(".c-scale-bar__label",()=>{const t=document.createElement("span");return t.className="c-scale-bar__label",t}).textContent=n}else{const t=this.querySelector(".c-scale-bar__label");t&&t.remove()}const o=this.ensure(".c-scale-bar__units",()=>{const t=document.createElement("button");return t.type="button",t.className="c-scale-bar__units",t}),l=this.getAttribute("units")||"metric";if(o.textContent="imperial"===l?"mi":"km",o.onclick=()=>{this.setAttribute("units","imperial"===(this.getAttribute("units")||"metric")?"metric":"imperial")},!t)return void renderEmpty(this,"scale-bar");const c=this.ensure(".c-scale-bar__line",()=>{const t=document.createElement("span");return t.className="c-scale-bar__line",t});c.style.inlineSize=/^\d+(\.\d+)?$/.test(String(t))?t+"px":t;const u=scaleBarTicks(parseFloat(t)||0,4),d=u[u.length-1]||1;Array.from(c.querySelectorAll(".c-scale-bar__tick")).forEach(t=>t.remove()),u.forEach(t=>{const e=document.createElement("span");e.className="c-scale-bar__tick",e.style.insetInlineStart=t/d*100+"%",c.appendChild(e)})}}define("contour-scale-bar",ContourScaleBar);class ContourSplitMap extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-split-map");const t=this.ensure(".c-split-map__pane--left",()=>{const t=document.createElement("div");return t.className="c-split-map__pane c-split-map__pane--left",t}),e=this.ensure(".c-split-map__pane--right",()=>{const t=document.createElement("div");return t.className="c-split-map__pane c-split-map__pane--right",t});t.parentNode!==this&&this.appendChild(t),e.parentNode!==this&&this.appendChild(e)}}define("contour-split-map",ContourSplitMap);class ContourMapLegend extends ContourBase{static get observed(){return["items","label","collapsed"]}static get properties(){return{items:{attribute:"items"},label:{attribute:"label"},collapsed:{attribute:"collapsed",type:Boolean}}}render(){this.classList.add("c-map-legend");const t=this.getAttribute("label")||labelText(this,"legend","Legend"),e=this.ensure(".c-map-legend__head",()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--sm c-map-legend__head",t});setHTML(e,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-layers" /></svg>'),e.appendChild(document.createTextNode(" "+t));const r=this.hasAttribute("collapsed");e.setAttribute("aria-expanded",r?"false":"true");let s=[];try{const t=JSON.parse(this.getAttribute("items")||"[]");Array.isArray(t)&&(s=t)}catch(t){}const i=this.ensure(".c-map-legend__list",()=>{const t=document.createElement("ul");return t.className="c-map-legend__list",t});setHTML(i,""),r||s.forEach(t=>{const e="string"==typeof t?t:t.label||t.name||"",r="object"==typeof t&&t?t.color:null,s=document.createElement("li");s.className="c-map-legend__item";const a="object"==typeof t&&t&&t.shape?String(t.shape):"";if(r||SHAPES.has(a)){const t=document.createElement("span");t.className="c-map-legend__swatch",SHAPES.has(a)&&t.classList.add("c-swatch--"+a),r&&(SHAPES.has(a)?t.style.color=r:t.style.setProperty("--c",r)),s.appendChild(t)}s.appendChild(document.createTextNode(" "+e)),i.appendChild(s)})}enhance(){this._wiredMapLegend||(this._wiredMapLegend=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-map-legend__head"):null;e&&this.contains(e)&&this.toggleAttribute("collapsed")}))}}define("contour-map-legend",ContourMapLegend);class ContourResizeObserver extends ContourBase{static get observed(){return["debounce"]}static get properties(){return{debounce:{attribute:"debounce"}}}render(){this.classList.add("c-resize-observer"),this.setAttribute("aria-hidden","true")}enhance(){if(this._wiredResizeObserver)return;if(this._wiredResizeObserver=!0,"function"!=typeof ResizeObserver)return;const t=parseInt(this.getAttribute("debounce")||"0",10)||0;let e=null;const r=new ResizeObserver(r=>{const s=()=>{const t=r[r.length-1],e=t&&t.contentRect?t.contentRect:this.getBoundingClientRect();this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{width:e.width,height:e.height}}))};t>0?(clearTimeout(e),e=setTimeout(s,t)):s()});r.observe(this),onDispose(this,()=>{r.disconnect(),clearTimeout(e)})}}define("contour-resize-observer",ContourResizeObserver);class ContourReservedFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-reserved");const t=this.getAttribute("title");if(t){this.ensure(".c-reserved__title",()=>{const t=document.createElement("div");return t.className="c-reserved__title",t}).textContent=t}}}define("contour-reserved",ContourReservedFull);class ContourThemeScopeFull extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-theme-scope");const t=this.getAttribute("title");if(t){this.ensure(".c-theme-scope__title",()=>{const t=document.createElement("div");return t.className="c-theme-scope__title",t}).textContent=t}}}define("contour-theme-scope",ContourThemeScopeFull);class ContourActivity extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){if(this.classList.add("c-activity"),this.setAttribute("role","group"),wireStates(this),loadRemote(this,"items"),renderStates(this,"activity"))return;const t=remoteData(this,"items");if(t)try{const e=JSON.parse(t);Array.from(this.querySelectorAll(".c-activity__item")).forEach(t=>t.remove()),e.forEach((t,e)=>{const r=document.createElement("div");r.className="c-activity__item",r.setAttribute("role","button"),r.setAttribute("tabindex",0===e?"0":"-1");const s=document.createElement("span");s.className="c-activity__dot c-activity__dot--"+(t.variant||"primary"),s.setAttribute("aria-hidden","true"),r.appendChild(s);const i=document.createElement("span");i.className="c-activity__glyph",i.setAttribute("aria-hidden","true"),setHTML(i,'<svg viewBox="0 0 24 24"><use href="#'+({primary:"i-info",success:"i-check-circle",warning:"i-alert",danger:"i-x"}[t.variant]||"i-info")+'" /></svg>'),r.appendChild(i);const a=document.createElement("span");if(a.className="c-activity__text",a.textContent="string"==typeof t?t:t.text||t.label||"",r.hasAttribute("aria-label")||r.setAttribute("aria-label",a.textContent),r.appendChild(a),t.time){const e=document.createElement("span");e.className="c-activity__time",e.textContent=t.time,r.appendChild(e)}this.appendChild(r)})}catch(t){warnBadJson(this,"attribute",t)}else renderEmpty(this,"activity")}enhance(){this._wiredActivity||(this._wiredActivity=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-activity__item"):null;if(e&&this.contains(e)){const t=Array.from(this.querySelectorAll(".c-activity__item")).indexOf(e),r=e.querySelector(".c-activity__text")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:!0,composed:!0,detail:{index:t,text:r}}))}}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-activity__item"));e.length&&navKey(t,e,{wrap:!1,homeEnd:!0,onNavigate:t=>{e.forEach((e,r)=>e.tabIndex=r===t?0:-1)},onKey:()=>{if("Enter"===t.key||" "===t.key){const t=e.indexOf(document.activeElement);this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:!0,composed:!0,detail:{index:t,text:document.activeElement.querySelector(".c-activity__text")?.textContent||""}}))}}})}))}}define("contour-activity",ContourActivity);class ContourActivityFeed extends ContourBase{static get observed(){return["items","filter","unread-only","empty","loading","error","labels","src","lazy","refresh","timeout","skeleton","cache-key","no-cache","retry"]}static get properties(){return{items:{attribute:"items"},filter:{attribute:"filter"},"unread-only":{attribute:"unread-only",type:Boolean}}}render(){if(this.classList.add("c-activity-feed"),this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"title","Activity feed")),wireStates(this),loadRemote(this,"items"),renderStates(this,"activity-feed"))return;const t=remoteData(this,"items"),e=this.getAttribute("filter"),r=this.hasAttribute("unread-only");let s=this.querySelector(".c-activity-feed__header");s||(s=document.createElement("div"),s.className="c-activity-feed__header",this.insertBefore(s,this.firstChild));let i=s.querySelector(".c-activity-feed__title");i||(i=document.createElement("div"),i.className="c-activity-feed__title",s.appendChild(i)),i.textContent=labelText(this,"title","Activity feed");let a=this.querySelector(".c-activity-feed__toolbar");a||(a=document.createElement("div"),a.className="c-activity-feed__toolbar",this.appendChild(a));a.querySelector("[data-activity-clear]")||(()=>{const t=document.createElement("button");t.type="button",t.className="c-btn c-btn--ghost c-btn--sm",t.setAttribute("data-activity-clear",""),setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-x" /></svg>'),t.appendChild(document.createTextNode(" "+labelText(this,"clear","Clear all"))),a.appendChild(t)})();(a.querySelector("[data-activity-unread]")||(()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--ghost c-btn--sm",t.setAttribute("data-activity-unread",""),t.textContent=labelText(this,"unread","Unread only"),a.appendChild(t),t})()).setAttribute("aria-pressed",r?"true":"false");let n=this.querySelector(".c-activity-feed__list");if(n||(n=document.createElement("ol"),n.className="c-activity-feed__list",this.appendChild(n)),t)try{let s=JSON.parse(t);if(e&&(s=s.filter(t=>String(t.severity||t.type||"").toLowerCase()===e.toLowerCase())),r&&(s=s.filter(t=>!t.read)),Array.from(n.querySelectorAll(".c-activity-feed__item")).forEach(t=>t.remove()),0===s.length){let t=n.querySelector(".c-activity-feed__empty");t||(t=document.createElement("div"),t.className="c-activity-feed__empty",t.textContent=labelText(this,"empty","No activity"),n.appendChild(t))}else{const t=n.querySelector(".c-activity-feed__empty");t&&t.remove(),s.forEach((t,e)=>{const r=document.createElement("li");r.className="c-activity-feed__item"+(t.read?"":" c-activity-feed__item--unread"),r.setAttribute("role","listitem"),r.setAttribute("tabindex",0===e?"0":"-1");const s=document.createElement("span");s.className="c-activity-feed__dot c-activity-feed__dot--"+(t.severity||"info"),s.setAttribute("aria-hidden","true"),r.appendChild(s);const i=document.createElement("span");i.className="c-activity-feed__text",i.textContent="string"==typeof t?t:t.text||t.label||"",r.appendChild(i);const a=document.createElement("time");a.className="c-activity-feed__time",t.time&&a.setAttribute("datetime",String(t.time)),a.textContent=t.time||"",r.appendChild(a);const o=document.createElement("span");o.className="c-activity-feed__severity",o.textContent=t.severity||"",r.appendChild(o),n.appendChild(r)})}}catch(t){warnBadJson(this,"attribute",t)}}enhance(){this._wiredActivityFeed||(this._wiredActivityFeed=!0,this.addEventListener("click",t=>{const e=t.target.closest(".c-activity-feed__item");if(e&&this.contains(e)){const t=Array.from(this.querySelectorAll(".c-activity-feed__item")).indexOf(e),r=e.querySelector(".c-activity-feed__text")?.textContent||"";return e.classList.remove("c-activity-feed__item--unread"),void this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:!0,composed:!0,detail:{index:t,text:r}}))}const r=t.target&&t.target.closest?t.target.closest("button"):null;r&&this.contains(r)&&(r.hasAttribute("data-activity-clear")?this.dispatchEvent(new CustomEvent("contour:activity-clear",{bubbles:!0,composed:!0,detail:{}})):r.hasAttribute("data-activity-unread")&&(this.toggleAttribute("unread-only"),this.dispatchEvent(new CustomEvent("contour:activity-filter",{bubbles:!0,composed:!0,detail:{unread:this.hasAttribute("unread-only")}}))))}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-activity-feed__item"));e.length&&navKey(t,e,{wrap:!1,homeEnd:!0,onNavigate:t=>{e.forEach((e,r)=>e.tabIndex=r===t?0:-1)},onKey:()=>{if("Enter"===t.key||" "===t.key){const t=e.indexOf(document.activeElement);this.dispatchEvent(new CustomEvent("contour:activity-select",{bubbles:!0,composed:!0,detail:{index:t,text:document.activeElement.querySelector(".c-activity-feed__text")?.textContent||""}}))}}})}))}}define("contour-activity-feed",ContourActivityFeed);class ContourAdvanced extends ContourBase{static get observed(){return["title"]}static get properties(){return{title:{attribute:"title"}}}render(){this.classList.add("c-advanced"),this.setAttribute("role","region");const t=this.getAttribute("title");if(t){this.ensure(".c-advanced__title",()=>{const t=document.createElement("div");return t.className="c-advanced__title",t}).textContent=t,this.setAttribute("aria-label",t)}}enhance(){this._wiredAdvanced||(this._wiredAdvanced=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-advanced__title"):null;if(!e||!this.contains(e))return;const r=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:advanced-toggle",{bubbles:!0,composed:!0,detail:{title:r}}))}),this.addEventListener("keydown",t=>{if(t.target===this&&("Enter"===t.key||" "===t.key)){t.preventDefault();const e=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:advanced-toggle",{bubbles:!0,composed:!0,detail:{title:e}}))}}))}}define("contour-advanced",ContourAdvanced);class ContourAffordance extends ContourBase{static get observed(){return["name","note","demo"]}static get properties(){return{name:{attribute:"name"},note:{attribute:"note"},demo:{attribute:"demo"}}}render(){this.classList.add("c-affordance"),this.setAttribute("role","group");const t=this.getAttribute("name");if(t){this.ensure(".c-affordance__name",()=>{const t=document.createElement("div");return t.className="c-affordance__name",t}).textContent=t,this.setAttribute("aria-label",t)}else{const t=this.querySelector(".c-affordance__name");t&&t.remove()}const e=this.getAttribute("note");if(e){this.ensure(".c-affordance__note",()=>{const t=document.createElement("div");return t.className="c-affordance__note",t}).textContent=e}else{const t=this.querySelector(".c-affordance__note");t&&t.remove()}const r=this.getAttribute("demo");if(r){this.ensure(".c-affordance__demo",()=>{const t=document.createElement("div");return t.className="c-affordance__demo",t}).textContent=r}else{const t=this.querySelector(".c-affordance__demo");t&&t.remove()}}enhance(){this._wiredAffordance||(this._wiredAffordance=!0,this.addEventListener("click",t=>{const e=this.getAttribute("name")||"";this.dispatchEvent(new CustomEvent("contour:affordance-activate",{bubbles:!0,composed:!0,detail:{name:e}}))}),this.addEventListener("keydown",t=>{if("Enter"===t.key||" "===t.key){t.preventDefault();const e=this.getAttribute("name")||"";this.dispatchEvent(new CustomEvent("contour:affordance-activate",{bubbles:!0,composed:!0,detail:{name:e}}))}}))}}define("contour-affordance",ContourAffordance);class ContourAffordances extends ContourBase{static get observed(){return["name","title"]}static get properties(){return{name:{attribute:"name"},title:{attribute:"title"}}}render(){if(this.classList.add("c-affordances"),this.setAttribute("role","group"),!this.querySelector(".c-affordance")){const t=document.createElement("div");t.className="c-affordance";const e=this.getAttribute("name")||this.getAttribute("title")||labelText(this,"affordance","Affordance"),r=document.createElement("div");r.className="c-affordance__name",r.textContent=e,t.appendChild(r);const s=document.createElement("div");s.className="c-affordance__demo",s.textContent=labelText(this,"demo","Demo"),t.appendChild(s),this.appendChild(t)}}}define("contour-affordances",ContourAffordances);class ContourMenu extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){if(this.classList.add("c-menu"),this.hasAttribute("role")||this.setAttribute("role","menu"),wireStates(this),loadRemote(this,"items"),renderStates(this,"menu"))return;const t=remoteData(this,"items"),e=Array.from(this.querySelectorAll("li[role='menuitem'], li.c-menu__item, [role='menuitem']")),r=this.querySelector("ul.c-menu");if(e.length){if(r)for(const t of e)t.classList.contains("c-menu__item")||t.classList.add("c-menu__item"),t.getAttribute("role")||t.setAttribute("role","menuitem"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1");else{const t=document.createElement("ul");t.className="c-menu",t.setAttribute("role","menu");for(const r of e)r.parentElement===this&&t.appendChild(r);this.appendChild(t)}const t=e.find(t=>"true"!==t.getAttribute("aria-disabled"));return t&&t.setAttribute("tabindex","0"),this.classList.remove("c-menu"),void(r&&r.classList.add("c-menu"))}if(!r)if(t)try{const e=JSON.parse(t),r=this.ensure("ul.c-menu",()=>{const t=document.createElement("ul");return t.className="c-menu",t.setAttribute("role","menu"),t});r.innerHTML="",r.setAttribute("role","menu"),e.forEach(t=>{if("---"===t||"separator"===t){const t=document.createElement("li");t.className="c-menu__separator",t.setAttribute("role","separator"),r.appendChild(t)}else if("string"==typeof t){const e=document.createElement("li");e.className="c-menu__item",e.setAttribute("role","menuitem"),e.textContent=t,r.appendChild(e)}else if(t.group){const e=document.createElement("li");e.className="c-menu__group",e.setAttribute("role","group"),t.group&&e.setAttribute("aria-label",String(t.group));const s=document.createElement("div");if(s.className="c-menu__group-label",s.textContent=String(t.group),e.appendChild(s),Array.isArray(t.items)){const r=document.createElement("ul");r.className="c-menu",r.setAttribute("role","menu"),t.items.forEach(t=>{const e=document.createElement("li");if(e.className="c-menu__item"+(t.danger?" c-menu__item--danger":"")+(t.disabled?" c-menu__item--disabled":""),e.setAttribute("role","menuitem"),t.disabled&&e.setAttribute("aria-disabled","true"),t.label||t.title){const r=document.createElement("span");r.className="c-menu__label",r.textContent=t.label||t.title||"",e.appendChild(r)}r.appendChild(e)}),e.appendChild(r)}r.appendChild(e)}else{const e=document.createElement("li");e.className="c-menu__item"+(t.danger?" c-menu__item--danger":"")+(t.disabled?" c-menu__item--disabled":"");const s="checkbox"===t.type?"menuitemcheckbox":"radio"===t.type?"menuitemradio":"menuitem";if(e.setAttribute("role",s),"checkbox"!==t.type&&"radio"!==t.type||e.setAttribute("aria-checked",String(!!t.checked)),t.disabled&&e.setAttribute("aria-disabled","true"),t.items&&Array.isArray(t.items)&&(e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded","false")),t.label||t.title){const r=document.createElement("span");r.className="c-menu__label",r.textContent=t.label||t.title||"",e.appendChild(r)}if(t.shortcut){const r=document.createElement("span");r.className="c-menu__shortcut",r.textContent=t.shortcut,e.appendChild(r)}if(t.items&&Array.isArray(t.items)){const r=document.createElement("ul");r.className="c-menu",r.setAttribute("role","menu"),t.items.forEach(t=>{const e=document.createElement("li");if(e.className="c-menu__item"+(t.danger?" c-menu__item--danger":"")+(t.disabled?" c-menu__item--disabled":""),e.setAttribute("role","menuitem"),t.disabled&&e.setAttribute("aria-disabled","true"),t.label||t.title){const r=document.createElement("span");r.className="c-menu__label",r.textContent=t.label||t.title||"",e.appendChild(r)}r.appendChild(e)}),e.appendChild(r)}r.appendChild(e)}}),r.parentNode!==this&&this.appendChild(r),this.classList.remove("c-menu"),r.classList.add("c-menu")}catch(t){warnBadJson(this,"attribute",t)}else renderEmpty(this,"menu")}enhance(){wireMenu(this)}}define("contour-menu",ContourMenu);class ContourTabs extends ContourBase{static get observed(){return["tabs","items","autoplay","pause","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","orientation","closable","cache-key","no-cache"]}static get properties(){return{tabs:{attribute:"tabs"},autoplay:{attribute:"autoplay",type:Number},pause:{attribute:"pause",type:Boolean},src:{attribute:"src"},orientation:{attribute:"orientation"},closable:{attribute:"closable",type:Boolean}}}render(){if(this.classList.add("c-tabs"),wireStates(this),loadRemote(this,"tabs"),renderStates(this,"tabs"))return;const t=remoteData(this,"tabs")||remoteData(this,"items")||this.getAttribute("tabs")||this.getAttribute("items"),e=Array.from(this.querySelectorAll("[role='tab']")),r=this.querySelector(".c-tabs__list"),s=Array.from(this.querySelectorAll(".c-tabs__panel"));if(e.length){if(!r){const t=document.createElement("div");t.className="c-tabs__list",t.setAttribute("role","tablist");const r="vertical"===this.getAttribute("orientation")?"vertical":"horizontal";t.setAttribute("aria-orientation",r),"vertical"===r?this.classList.add("c-tabs--vertical"):this.classList.remove("c-tabs--vertical");for(const r of e)r.parentElement===this&&t.appendChild(r);this.prepend(t)}const t="vertical"===this.getAttribute("orientation")?"vertical":"horizontal";r&&r.setAttribute("aria-orientation",t),"vertical"===t?this.classList.add("c-tabs--vertical"):this.classList.remove("c-tabs--vertical");const i=e.findIndex(t=>"true"===t.getAttribute("aria-selected"));return void e.forEach((t,e)=>{t.classList.contains("c-tabs__tab")||t.classList.add("c-tabs__tab"),t.getAttribute("role")||t.setAttribute("role","tab");let r=t.getAttribute("aria-controls");if(r){let t=s.find(t=>t.id===r);t||(t=document.createElement("div"),t.className="c-tabs__panel",t.id=r,t.setAttribute("role","tabpanel"),this.appendChild(t))}else{const i=s[e];i&&(r=i.id||contourId("c-tabs-panel"),i.id=r,t.setAttribute("aria-controls",r))}const a=i>=0?e===i:0===e;t.setAttribute("aria-selected",String(a)),t.tabIndex=a?0:-1;const n=t.getAttribute("aria-controls"),o=n?document.getElementById(n):null;o&&(o.hidden=!a)})}if(t&&!e.length)try{const e=JSON.parse(t),r=this.ensure(".c-tabs__list",()=>{const t=document.createElement("div");return t.className="c-tabs__list",t.setAttribute("role","tablist"),t});r.setAttribute("role","tablist");const s="vertical"===this.getAttribute("orientation")?"vertical":"horizontal";r.setAttribute("aria-orientation",s),"vertical"===s?this.classList.add("c-tabs--vertical"):this.classList.remove("c-tabs--vertical");const i=Array.from(r.querySelectorAll("[role='tab']")).findIndex(t=>"true"===t.getAttribute("aria-selected")),a=i>=0?i:0;r.innerHTML="",Array.from(this.querySelectorAll(".c-tabs__panel")).forEach(t=>t.remove()),e.forEach((t,e)=>{const s="string"==typeof t?t:t.label||t.title||"",i=contourId("c-tabs-panel"),n=document.createElement(this.hasAttribute("closable")?"div":"button");n.className="c-tabs__tab","BUTTON"===n.tagName&&(n.type="button"),n.setAttribute("role","tab"),n.setAttribute("aria-selected",String(e===a)),n.setAttribute("aria-controls",i),n.tabIndex=e===a?0:-1;const o=document.createElement("span");if(o.textContent=s,n.textContent="",n.appendChild(o),this.hasAttribute("closable")){const t=document.createElement("button");t.type="button",t.className="c-tabs__close",t.setAttribute("aria-label",labelText(this,"close","Close")+" "+s),t.textContent="×",t.addEventListener("click",t=>{t.stopPropagation();const e=Array.from(r.querySelectorAll("[role='tab']")).indexOf(n),i=n.getAttribute("aria-controls"),a=i?document.getElementById(i):null;n.remove(),a&&a.remove(),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0,detail:{index:e,label:s}}));const o=r.querySelectorAll("[role='tab']");o.length&&o[0].click()}),n.appendChild(t)}r.appendChild(n);const l=document.createElement("div");l.className="c-tabs__panel",l.id=i,l.setAttribute("role","tabpanel"),"object"==typeof t&&null!==t&&void 0!==t.content&&(l.textContent=String(t.content)),e!==a&&(l.hidden=!0),this.appendChild(l)}),r.parentNode!==this&&this.prepend(r)}catch(t){warnBadJson(this,"attribute",t)}else if(!t&&!e.length){const t=this.querySelector(".c-tabs__list");t&&t.remove(),renderEmpty(this,"tabs")}}enhance(){wireTabs(this);const t=()=>{const t=parseFloat(this.getAttribute("autoplay")||""),e=this.hasAttribute("pause")||this._tabsHover||this._tabsFocus,r="function"==typeof matchMedia&&matchMedia("(prefers-reduced-motion: reduce)").matches,s=Number.isFinite(t)&&t>0&&!e&&!r;s!==this._tabsAutoplayRunning&&(this._tabsAutoplayRunning=s,void 0!==this._tabsTimer&&(clearInterval(this._tabsTimer),this._tabsTimer=void 0),s&&(this._tabsTimer=setInterval(()=>{if(!this.isConnected||this.hasAttribute("pause")||this._tabsHover||this._tabsFocus)return;const t=this.querySelector(".c-tabs__list"),e=t?Array.from(t.querySelectorAll("[role='tab']")):[];if(!e.length)return;const r=e.findIndex(t=>"true"===t.getAttribute("aria-selected")),s=e[(r+1)%e.length];s&&s.click()},Math.max(1e3,1e3*t))))};t(),this._wiredTabsAutoplay||(this._wiredTabsAutoplay=!0,this.addEventListener("pointerenter",()=>{this._tabsHover=!0,t()}),this.addEventListener("pointerleave",()=>{this._tabsHover=!1,t()}),this.addEventListener("focusin",()=>{this._tabsFocus=!0,t()}),this.addEventListener("focusout",()=>{this._tabsFocus=!1,t()}),onDispose(this,()=>{void 0!==this._tabsTimer&&(clearInterval(this._tabsTimer),this._tabsTimer=void 0)}))}}define("contour-tabs",ContourTabs);class ContourCodeTabs extends ContourBase{static get observed(){return["tabs","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","cache-key","no-cache"]}static get properties(){return{tabs:{attribute:"tabs"},src:{attribute:"src"}}}render(){if(this.classList.add("c-code-tabs"),wireStates(this),loadRemote(this,"tabs"),renderStates(this,"code-tabs"))return;const t=remoteData(this,"tabs"),e=this.querySelector(".c-code-tabs__list"),r=e?Array.from(e.children).filter(t=>t.getAttribute&&"tab"===t.getAttribute("role")):[];if(t&&!r.length)try{const e=JSON.parse(t),r=this.ensure(".c-code-tabs__list",()=>{const t=document.createElement("div");return t.className="c-code-tabs__list",t.setAttribute("role","tablist"),t});r.setAttribute("role","tablist");const s=Array.from(r.querySelectorAll("[role='tab']")).findIndex(t=>"true"===t.getAttribute("aria-selected")),i=s>=0?s:0;r.innerHTML="",Array.from(this.querySelectorAll(".c-code-tabs__panel")).forEach(t=>t.remove()),e.forEach((t,e)=>{const s="string"==typeof t?t:t.label||t.title||"",a=contourId("c-code-tabs-panel"),n=document.createElement("button");n.className="c-code-tabs__tab",n.type="button",n.setAttribute("role","tab"),n.setAttribute("aria-selected",String(e===i)),n.setAttribute("aria-controls",a),n.tabIndex=e===i?0:-1,n.textContent=s,r.appendChild(n);const o=document.createElement("div");if(o.className="c-code-tabs__panel",o.id=a,o.setAttribute("role","tabpanel"),"object"==typeof t&&null!==t&&void 0!==t.content){const e=document.createElement("pre"),r=document.createElement("code");r.textContent=String(t.content),e.appendChild(r),o.appendChild(e);const s=document.createElement("button");s.className="c-btn c-btn--ghost c-btn--sm c-code-tabs__copy",s.type="button",s.textContent=labelText(this,"copy","Copy"),s.setAttribute("aria-label",labelText(this,"copy-code","Copy code")),s.dataset.copy=String(t.content),o.appendChild(s)}e!==i&&(o.hidden=!0),this.appendChild(o)}),r.parentNode!==this&&this.prepend(r)}catch(t){warnBadJson(this,"attribute",t)}else!t&&e?(e.remove(),renderEmpty(this,"code-tabs")):t||e||renderEmpty(this,"code-tabs")}enhance(){wireTabs(this),this._wiredCodeTabs||(this._wiredCodeTabs=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-code-tabs__copy"):null;if(!e||!this.contains(e))return;const r=e.dataset.copy||"";if(r)try{navigator.clipboard.writeText(r),e.textContent=labelText(this,"copied","Copied!"),setTimeout(()=>{e.textContent=labelText(this,"copy","Copy")},2e3)}catch(t){}}))}}define("contour-code-tabs",ContourCodeTabs);class ContourBreadcrumb extends ContourBase{static get observed(){return["items","separator","max","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache"]}static get properties(){return{items:{attribute:"items"},separator:{attribute:"separator"},max:{attribute:"max",type:Number},src:{attribute:"src"}}}render(){if(this.classList.add("c-breadcrumb"),this.hasAttribute("role")||this.setAttribute("role","navigation"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"breadcrumb","Breadcrumb")),wireStates(this),loadRemote(this,"items"),renderStates(this,"breadcrumb"))return;const t=remoteData(this,"items"),e=this.querySelector("nav"),r=e?e.querySelector("ol"):null,s=r?Array.from(r.children).filter(t=>"LI"===t.tagName):[];if(t&&!s.length)try{const e=JSON.parse(t),r=this.ensure("nav",()=>{const t=document.createElement("nav");return t.setAttribute("aria-label",labelText(this,"breadcrumb","Breadcrumb")),t});r.setAttribute("aria-label",labelText(this,"breadcrumb","Breadcrumb")),r.id||(r.id=contourId("contour-breadcrumb-list")),r.innerHTML="";const s=document.createElement("ol");s.className="c-breadcrumb__list",r.appendChild(s);const i=this.getAttribute("separator")||"/",a=this._overflowExpanded?null:this.max,n=Number.isFinite(a)&&a>1&&e.length>a?e.slice(-a):e;if(Number.isFinite(a)&&a>1&&e.length>a){const t=document.createElement("button");t.type="button",t.className="c-breadcrumb__overflow",t.setAttribute("aria-label",`Show ${e.length-n.length+1} more items`),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls",r.id),t.textContent="…",t.addEventListener("click",()=>{this._overflowExpanded=!0,this.requestRender(),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{expanded:!0}}))});const i=document.createElement("li");i.appendChild(t),s.appendChild(i)}n.forEach((t,e)=>{const r=document.createElement("li");if(e<n.length-1){const e=document.createElement("a");e.href=safeHref(t.href||"#"),e.textContent=t.label||t,r.appendChild(e);const s=document.createElement("span");s.className="c-breadcrumb__sep",s.setAttribute("aria-hidden","true"),s.textContent=i,r.appendChild(s)}else{const e=document.createElement("span");e.textContent=t.label||t,e.setAttribute("aria-current","page"),r.appendChild(e)}s.appendChild(r)})}catch(t){warnBadJson(this,"attribute",t)}else!t&&e?e.remove():t||e||renderEmpty(this,"breadcrumb")}}define("contour-breadcrumb",ContourBreadcrumb);class ContourPagination extends ContourBase{static get observed(){return["pages","current","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","cache-key","no-cache"]}static get properties(){return{pages:{attribute:"pages"},current:{attribute:"current"},src:{attribute:"src"}}}render(){if(this.classList.add("c-pagination"),this.hasAttribute("role")||this.setAttribute("role","navigation"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"pagination","Pagination")),wireStates(this),loadRemote(this,"pages"),renderStates(this,"pagination"))return;const t=remoteData(this,"pages");Array.from(this.querySelectorAll(".c-pagination__link")).forEach(t=>t.remove());let e=this.getAttribute("current")||"1";if("storage"===this.getAttribute("persist")&&this.id)try{const t=localStorage.getItem("contour-pagination:"+this.id);null!==t&&(e=t)}catch(t){}else if("url"===this.getAttribute("persist"))try{const t=new URLSearchParams(window.location.search).get("c-pagination");null!==t&&(e=t)}catch(t){}const r=parseInt(e,"10")||1;if(this.setAttribute("page",String(r)),t){let e=parseInt(t,10);if(!Number.isFinite(e)||e<1)try{const r=JSON.parse(t);Array.isArray(r)&&(e=r.length)}catch(t){}const s=document.createElement("button");s.type="button",s.className="c-pagination__link c-pagination__prev",s.setAttribute("data-action","prev"),setHTML(s,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>'),s.setAttribute("aria-label",labelText(this,"prev","Previous page")),r<=1&&s.setAttribute("disabled",""),this.appendChild(s);const i=new Set([1,e,r]);r>1&&i.add(r-1),r<e&&i.add(r+1);const a=[...i].filter(t=>t>=1&&t<=e).sort((t,e)=>t-e);let n=0;for(const t of a){if(n&&t-n>1){const t=document.createElement("span");t.className="c-pagination__ellipsis",t.textContent="…",t.setAttribute("aria-hidden","true"),this.appendChild(t)}const e=document.createElement("button");e.type="button",e.className="c-pagination__link",e.textContent=String(t),t===r&&e.setAttribute("aria-current","page"),this.appendChild(e),n=t}const o=document.createElement("button");o.type="button",o.className="c-pagination__link c-pagination__next",o.setAttribute("data-action","next"),setHTML(o,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),o.setAttribute("aria-label",labelText(this,"next","Next page")),r>=e&&o.setAttribute("disabled",""),this.appendChild(o)}else renderEmpty(this,"pagination")}enhance(){wirePagination(this)}}define("contour-pagination",ContourPagination);class ContourPagerFull extends ContourBase{static get observed(){return["prev","next"]}static get properties(){return{prev:{attribute:"prev"},next:{attribute:"next"}}}render(){this.classList.add("c-pager"),this.hasAttribute("role")||this.setAttribute("role","navigation"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"pagination","Pagination")),Array.from(this.querySelectorAll(".c-pager__link")).forEach(t=>t.remove());const t=this.getAttribute("prev"),e=this.getAttribute("next");if(t){const e=document.createElement("a");e.className="c-pager__link",e.href=safeHref(t.split("|")[1]||"#");const r=document.createElement("span");r.className="c-pager__dir",r.textContent=labelText(this,"previous","← Previous"),e.appendChild(r);const s=document.createElement("span");s.className="c-pager__title",s.textContent=t.split("|")[0],e.appendChild(s),this.appendChild(e)}if(e){const t=document.createElement("a");t.className="c-pager__link c-pager__link--next",t.href=safeHref(e.split("|")[1]||"#");const r=document.createElement("span");r.className="c-pager__dir",r.textContent=labelText(this,"next","Next")+" →",t.appendChild(r);const s=document.createElement("span");s.className="c-pager__title",s.textContent=e.split("|")[0],t.appendChild(s),this.appendChild(t)}}}define("contour-pager",ContourPagerFull);class ContourTocFull extends ContourBase{static get observed(){return["title","items","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","empty","no-cache"]}static get properties(){return{title:{attribute:"title"},items:{attribute:"items"},src:{attribute:"src"}}}render(){if(this.classList.add("c-toc"),this.setAttribute("role","group"),wireStates(this),loadRemote(this,"items"),renderStates(this,"toc"))return;const t=remoteData(this,"items"),e=this.getAttribute("title")||"On this page";this.ensure(".c-toc__title",()=>{const t=document.createElement("div");return t.className="c-toc__title",t}).textContent=e;const r=this.querySelector(".c-toc__list"),s=r?Array.from(r.children).filter(t=>"A"===t.tagName):[];if(t&&!s.length)try{const r=JSON.parse(t),s=this.ensure(".c-toc__list",()=>{const t=document.createElement("nav");return t.className="c-toc__list",t});s.className="c-toc__list",s.setAttribute("aria-label",e),s.innerHTML="",r.forEach((t,e)=>{const r=document.createElement("a");r.className="c-toc__link"+(t.sub?" c-toc__link--sub":""),r.href=safeHref(t.href||"#"),r.textContent=t.label||t,r.tabIndex=0===e?0:-1,t.current&&r.setAttribute("aria-current","true"),s.appendChild(r)})}catch(t){warnBadJson(this,"attribute",t)}else!t&&r?(r.remove(),renderEmpty(this,"toc")):t||r||renderEmpty(this,"toc")}enhance(){if(this._wiredTocSpy)return;const t=()=>Array.from(this.querySelectorAll(".c-toc__link")),e=()=>t().map(t=>{const e=t.getAttribute("href")||"";if(!e.startsWith("#")||e.length<2)return null;const r=document.getElementById(e.slice(1));return r?{a:t,el:r}:null}).filter(Boolean);if(!e().length)return;this._wiredTocSpy=!0;const r=()=>{const r=e();if(!r.length)return;const s=(()=>{const t=parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--header-height"));return(Number.isFinite(t)?t:0)+Math.min(120,.2*window.innerHeight)})();let i=r[0];for(const t of r)t.el.getBoundingClientRect().top<=s&&(i=t);document.documentElement.scrollHeight>window.innerHeight+2&&window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-2&&(i=r[r.length-1]);const a=i.el.id;t().forEach(t=>{t.getAttribute("href")==="#"+a?"true"!==t.getAttribute("aria-current")&&t.setAttribute("aria-current","true"):t.hasAttribute("aria-current")&&t.removeAttribute("aria-current")})};let s=0;const i=()=>{s||(s=requestAnimationFrame(()=>{s=0,r()}))};window.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i),window.addEventListener("hashchange",i),r(),onDispose(this,()=>{window.removeEventListener("scroll",i),window.removeEventListener("resize",i),window.removeEventListener("hashchange",i),s&&cancelAnimationFrame(s)}),this._wiredTocScroll||(this._wiredTocScroll=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-toc__link"):null;if(!e||!this.contains(e))return;const r=e.getAttribute("href")||"";if(!r.startsWith("#")||r.length<2)return;const s=document.getElementById(r.slice(1));if(s){t.preventDefault();try{s.scrollIntoView({behavior:"smooth",block:"start"})}catch(t){s.scrollIntoView()}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{href:r}}))}}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-toc__link"));e.length&&navKey(t,e,{wrap:!0,homeEnd:!0,onNavigate:t=>{e.forEach((e,r)=>e.tabIndex=r===t?0:-1)},onKey:e=>{if("Enter"===e){const e=document.activeElement;e&&(t.preventDefault(),e.click())}}})}))}}define("contour-toc",ContourTocFull);class ContourHeader extends ContourBase{static get observed(){return["brand","brand-href","links"]}static get properties(){return{brand:{attribute:"brand"},"brand-href":{attribute:"brand-href"},links:{attribute:"links"}}}render(){this.classList.add("c-header"),this.hasAttribute("role")||this.setAttribute("role","banner"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("brand")||"Header");const t=this.getAttribute("brand"),e=this.getAttribute("links"),r=this.ensure(".c-header__inner",()=>{const t=document.createElement("div");return t.className="container c-header__inner",t});r.className="container c-header__inner";let s=r.querySelector(".c-brand");if(t){if(!s){s=document.createElement("a"),s.className="c-brand",s.setAttribute("data-contour-generated",""),s.href=safeHref(this.getAttribute("brand-href")||"#"),setHTML(s,'<span class="c-mark"><svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-mark" /></svg></span>');const t=document.createElement("span");t.className="c-brand__name",s.appendChild(t),r.insertBefore(s,r.firstChild)}const e=s.querySelector(".c-brand__name");e&&(e.textContent=t)}else s&&s.hasAttribute("data-contour-generated")&&s.remove();let i=r.querySelector(".c-header__nav");const a=i?Array.from(i.children).filter(t=>"A"===t.tagName):[];if(e&&!a.length)try{const t=JSON.parse(e);i||(i=document.createElement("nav"),i.className="c-header__nav",i.setAttribute("aria-label",labelText(this,"main","Main")),i.setAttribute("data-contour-generated",""),r.appendChild(i)),i.innerHTML="",t.forEach(t=>{const e=document.createElement("a");e.href=safeHref(t.href||"#"),e.textContent=t.label||t,i.appendChild(e)})}catch(t){}else e&&a.length||i&&!e&&!a.length&&i.hasAttribute("data-contour-generated")&&i.remove();if(!r.querySelector(".c-header__actions")){const t=document.createElement("div");t.className="c-header__actions",r.appendChild(t)}const n=r.querySelector(".c-header__nav");if(n){n.id||(n.id=contourId("header-nav"));const t=r.querySelector(".c-header__actions");if(t&&!t.querySelector(".c-header__toggle")){const e=document.createElement("button");e.type="button",e.className="c-header__toggle",e.setAttribute("aria-label",labelText(this,"toggle-navigation","Toggle navigation")),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",n.id),setHTML(e,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-menu" /></svg>'),t.appendChild(e)}}r.parentNode!==this&&this.appendChild(r)}enhance(){if(this._wiredHeader)return;this._wiredHeader=!0;const t=()=>{const t=window.scrollY||document.documentElement.scrollTop||0;this.classList.toggle("c-header--scrolled",t>8)};t(),window.addEventListener("scroll",t,{passive:!0}),onDispose(this,()=>window.removeEventListener("scroll",t)),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-header__toggle"):null;if(!e||!this.contains(e))return;const r=this.querySelector("#"+CSS.escape(e.getAttribute("aria-controls")||""));if(!r)return;const s=r.classList.toggle("is-open");e.setAttribute("aria-expanded",String(s)),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{open:s}}))}),this.addEventListener("keydown",t=>{if("Escape"!==t.key)return;const e=this.querySelector(".c-header__toggle"),r=e&&this.querySelector("#"+CSS.escape(e.getAttribute("aria-controls")||""));e&&r&&r.classList.contains("is-open")&&(r.classList.remove("is-open"),e.setAttribute("aria-expanded","false"))})}}define("contour-header",ContourHeader);class ContourFooter extends ContourBase{static get observed(){return["brand","note","links","cols","heading"]}static get properties(){return{brand:{attribute:"brand"},note:{attribute:"note"},links:{attribute:"links"},cols:{attribute:"cols"}}}render(){this.classList.add("c-footer"),this.hasAttribute("role")||this.setAttribute("role","contentinfo");const t=this.getAttribute("brand");if(t){this.ensure(".c-footer__brand",()=>{const t=document.createElement("div");return t.className="c-footer__brand",t}).textContent=t}else{const t=this.querySelector(".c-footer__brand");t&&t.remove()}const e=this.getAttribute("note");if(e){this.ensure(".c-footer__note",()=>{const t=document.createElement("p");return t.className="c-footer__note",t}).textContent=e}else{const t=this.querySelector(".c-footer__note");t&&t.remove()}const r=this.getAttribute("links");if(r)try{const t=JSON.parse(r),e=this.ensure(".c-footer__links",()=>{const t=document.createElement("div");return t.className="c-footer__links",t});e.innerHTML="",t.forEach(t=>{const r=document.createElement("a");r.href=safeHref("string"==typeof t?"#":t.href||"#"),r.textContent="string"==typeof t?t:t.label||t,e.appendChild(r)})}catch(t){warnBadJson(this,"attribute",t)}else{const t=this.querySelector(".c-footer__links");t&&t.remove()}const s=this.getAttribute("cols");if(s)try{const t=JSON.parse(s);this.querySelectorAll(".c-footer__col").forEach(t=>t.remove()),t.forEach(t=>{const e=document.createElement("div");if(e.className="c-footer__col",t.title){const r=document.createElement(headingTag(this,"h3"));r.textContent=t.title,e.appendChild(r)}(t.links||[]).forEach(t=>{const r=document.createElement("a");r.href=safeHref("string"==typeof t?"#":t.href||"#"),r.textContent="string"==typeof t?t:t.label||t,e.appendChild(r)}),this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}else this.querySelectorAll(".c-footer__col").forEach(t=>t.remove())}}define("contour-footer",ContourFooter);class ContourSchemeToggle extends ContourBase{static get observed(){return[]}_stored(){try{return localStorage.getItem("contour-scheme")??"light dark"}catch(t){return"light dark"}}_resolved(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}_rendered(){const t=this._stored();return"light dark"===t?this._resolved():t}render(){if(this.classList.add("c-scheme-toggle"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),!this.querySelector(".c-scheme-toggle__icons")&&!this.querySelector(".c-scheme-toggle__glyph")){const t=document.createElement("span");t.className="c-scheme-toggle__glyph",t.setAttribute("aria-hidden","true"),this.appendChild(t)}this._sync()}_sync(){const t=this._rendered(),e="dark"===t?"light":"dark";this.setAttribute("aria-pressed",String("dark"===t)),this.setAttribute("aria-label","dark"===e?"Switch to dark theme":"Switch to light theme");const r=this.querySelector(".c-scheme-toggle__glyph");r&&(r.textContent="dark"===t?"☀":"☾")}_apply(t){const e=document.documentElement,r="light dark"===t?this._resolved():t;e.classList.add("is-theme-switching");const s=document.querySelector('meta[name="color-scheme"]');s&&s.setAttribute("content",t),e.setAttribute("data-theme",r);try{"light dark"===t?localStorage.removeItem("contour-scheme"):localStorage.setItem("contour-scheme",t)}catch(t){}requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("is-theme-switching"))),this._sync(),this.dispatchEvent(new CustomEvent("contour:theme-change",{detail:{theme:r},bubbles:!0,composed:!0}))}enhance(){if(this._wiredScheme)return;this._wiredScheme=!0,this.addEventListener("click",()=>{const t="dark"===this._rendered()?"light":"dark";this._apply(t===this._resolved()?"light dark":t)}),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.click())});const t=window.matchMedia("(prefers-color-scheme: dark)");t.addEventListener&&t.addEventListener("change",()=>{"light dark"===this._stored()&&(document.documentElement.setAttribute("data-theme",this._resolved()),this._sync())});try{const t=localStorage.getItem("contour-theme");t&&(localStorage.getItem("contour-scheme")||"dark"!==t&&"light"!==t||localStorage.setItem("contour-scheme",t),localStorage.removeItem("contour-theme"))}catch(t){}const e=this._stored();"light dark"!==e?this._apply(e):this._sync()}}define("contour-scheme-toggle",ContourSchemeToggle);class ContourSidebar extends ContourBase{static get observed(){return["title","items","collapsed"]}static get properties(){return{title:{attribute:"title"},items:{attribute:"items"},collapsed:{attribute:"collapsed",type:Boolean}}}render(){this.classList.add("c-sidebar"),this.hasAttribute("role")||this.setAttribute("role","navigation"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Sidebar"),this.hasAttribute("collapsed")?this.setAttribute("data-collapsed",""):this.removeAttribute("data-collapsed");const t=this.getAttribute("title");if(t){this.ensure(".c-sidebar__title",()=>{const t=document.createElement("div");return t.className="c-sidebar__title",t}).textContent=t}else{const t=this.querySelector(".c-sidebar__title");t&&t.remove()}const e=this.hasAttribute("collapsed"),r=this.ensure(".c-sidebar__toggle",()=>{const t=document.createElement("button");return t.className="c-sidebar__toggle",t.type="button",t});r.setAttribute("aria-label",e?"Expand sidebar":"Collapse sidebar"),r.setAttribute("aria-pressed",String(e)),setHTML(r,e?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-down" /></svg>');const s=this.getAttribute("items");if(s)try{const t=JSON.parse(s),e=this.ensure("nav.c-sidebar__nav",()=>{const t=document.createElement("nav");return t.className="c-sidebar__nav",t});e.innerHTML="",t.forEach((t,r)=>{const s=document.createElement("a");s.className="c-sidebar__link",s.href=safeHref(t&&t.href||"#"),s.textContent=t&&(t.label||t)||"",s.tabIndex=0===r?0:-1,e.appendChild(s)})}catch(t){warnBadJson(this,"attribute",t)}}enhance(){this._wiredSidebar||(this._wiredSidebar=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-sidebar__toggle"):null;e&&this.contains(e)&&(this.toggleAttribute("collapsed"),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{collapsed:this.hasAttribute("collapsed")}})))}),this.addEventListener("keydown",t=>{const e=this.querySelector("nav.c-sidebar__nav");if(!e)return;const r=Array.from(e.querySelectorAll(".c-sidebar__link"));r.length&&navKey(t,r,{wrap:!0,homeEnd:!0,onNavigate:t=>{r.forEach((e,r)=>e.tabIndex=r===t?0:-1)},onKey:e=>{if("Enter"===e){const e=document.activeElement;e&&(t.preventDefault(),e.click())}}})}))}}define("contour-sidebar",ContourSidebar);class ContourToolbar extends ContourBase{static get observed(){return["title","actions","overflow"]}static get properties(){return{title:{attribute:"title"},actions:{attribute:"actions"},overflow:{attribute:"overflow",type:Number}}}render(){this.classList.add("c-toolbar");const t=this.getAttribute("title");this.setAttribute("role","toolbar"),t&&this.setAttribute("aria-label",t);const e=this.getAttribute("actions");if(e)try{const t=JSON.parse(e),r=this.overflow&&this.overflow>0?this.overflow:t.length,s=t.slice(0,r),i=t.slice(r);if(s.forEach((t,e)=>{const r=document.createElement("button");r.className="c-toolbar__btn",r.type="button",r.tabIndex=0===e?0:-1,r.textContent="string"==typeof t?t:t.label||t,("string"==typeof t||t&&t.label)&&r.classList.add("c-toolbar__btn--text"),this.appendChild(r)}),i.length){const t=document.createElement("div");t.className="c-toolbar__overflow";const e=document.createElement("button");e.className="c-toolbar__btn c-toolbar__overflow-btn",e.type="button",e.tabIndex=-1,e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded","false"),e.textContent="…",e.setAttribute("aria-label",labelText(this,"more-options","More options")),t.appendChild(e);const r=document.createElement("div");r.className="c-toolbar__overflow-menu",r.setAttribute("role","menu"),r.setAttribute("hidden",""),i.forEach(t=>{const e=document.createElement("button");e.className="c-toolbar__btn",e.type="button",e.setAttribute("role","menuitem"),e.textContent="string"==typeof t?t:t.label||t,r.appendChild(e)}),t.appendChild(r),this.appendChild(t)}}catch(t){warnBadJson(this,"attribute",t)}}enhance(){this._wiredToolbar||(this._wiredToolbar=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-toolbar__overflow-btn"):null;if(e&&this.contains(e)){const t=e.parentElement&&e.parentElement.querySelector(".c-toolbar__overflow-menu");if(t){const r=t.hasAttribute("hidden");r?t.removeAttribute("hidden"):t.setAttribute("hidden",""),e.setAttribute("aria-expanded",String(r)),e.tabIndex=r?-1:0;const s=Array.from(t.querySelectorAll("[role='menuitem']"));if(s.forEach((t,e)=>t.tabIndex=r&&0===e?0:-1),r)try{s[0]?.focus()}catch(t){}}return}const r=t.target&&t.target.closest?t.target.closest(".c-toolbar__btn"):null;r&&this.contains(r)&&this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0,detail:{label:r.textContent.trim()}}))}),this.addEventListener("keydown",t=>{if("Escape"===t.key){const e=this.querySelector(".c-toolbar__overflow-menu:not([hidden])");if(e){e.setAttribute("hidden","");const r=this.querySelector(".c-toolbar__overflow-btn");return r&&(r.setAttribute("aria-expanded","false"),r.tabIndex=0,r.focus()),void t.preventDefault()}}const e=this.querySelector(".c-toolbar__overflow-menu:not([hidden])");if(e){const r=Array.from(e.querySelectorAll("[role='menuitem']"));if(r.length)return void navKey(t,r,{wrap:!0,homeEnd:!0,onNavigate:t=>{r.forEach((e,r)=>e.tabIndex=r===t?0:-1)},onKey:e=>{if("Enter"===e||" "===e){const e=document.activeElement;e&&(t.preventDefault(),e.click())}}})}const r=Array.from(this.querySelectorAll(":scope > .c-toolbar__btn"));r.length&&navKey(t,r,{wrap:!0,homeEnd:!0,onNavigate:t=>{r.forEach((e,r)=>e.tabIndex=r===t?0:-1)},onKey:e=>{if("Enter"===e||" "===e){const e=document.activeElement;if(e)if(t.preventDefault(),e.classList.contains("c-toolbar__overflow-btn")){const t=e.parentElement&&e.parentElement.querySelector(".c-toolbar__overflow-menu");if(t){const r=t.hasAttribute("hidden");r?t.removeAttribute("hidden"):t.setAttribute("hidden",""),e.setAttribute("aria-expanded",String(r)),e.tabIndex=r?-1:0;const s=Array.from(t.querySelectorAll("[role='menuitem']"));if(s.forEach((t,e)=>t.tabIndex=r&&0===e?0:-1),r)try{s[0]?.focus()}catch(t){}}}else e.click()}}})}),this.addEventListener("focusout",t=>{if(!this.contains(t.relatedTarget)){const t=this.querySelector(".c-toolbar__overflow-menu:not([hidden])");if(t){t.setAttribute("hidden","");const e=this.querySelector(".c-toolbar__overflow-btn");e&&e.setAttribute("aria-expanded","false")}}}))}}define("contour-toolbar",ContourToolbar);class ContourTree extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","virtual","item-height","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","persist","selectable","cache-key","no-cache","density"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"},"item-height":{attribute:"item-height"}}}_itemHeight(){const t=Number(this.getAttribute("item-height"));return Number.isFinite(t)&&t>0?t:cssLength("--virtual-list-item-height",28)}_labelToPaths(t,e,r){(t||[]).forEach((t,s)=>{const i=e+"."+s,a=String(t.label||t).trim().slice(0,120);r.has(a)||r.set(a,[]),r.get(a).push(i),Array.isArray(t.children)&&this._labelToPaths(t.children,i,r)})}_restoreExpanded(){const t=this.getAttribute("persist");if(!t||!this._treeData)return;let e=null;try{if("storage"===t&&this.id){const t=localStorage.getItem("contour-tree:"+this.id);null!==t&&(e=JSON.parse(t))}else if("url"===t){const t=new URLSearchParams(window.location.search).get("c-tree");null!==t&&(e=JSON.parse(t))}}catch(t){e=null}if(!Array.isArray(e))return;const r=new Set(e.map(t=>String(t))),s=new Map;this._labelToPaths(this._treeData,"",s);const i=this._expanded||(this._expanded=new Set);for(const t of r){const e=s.get(t);e&&e.forEach(t=>i.add(t))}}_persistExpanded(){const t=this.getAttribute("persist");if(!t||!this._expanded)return;const e=new Map,r=(t,s)=>{(t||[]).forEach((t,i)=>{const a=s+"."+i;e.set(a,t),Array.isArray(t.children)&&r(t.children,a)})};r(this._treeData,"");const s=[];for(const t of this._expanded){const r=e.get(t);r&&s.push(String(r.label||r).trim().slice(0,120))}try{if("storage"===t&&this.id)localStorage.setItem("contour-tree:"+this.id,JSON.stringify(s));else if("url"===t){const t=new URL(window.location.href);t.searchParams.set("c-tree",JSON.stringify(s)),window.history.replaceState(null,"",t.toString())}}catch(t){}}_flatten(t,e,r,s,i){(t||[]).forEach((t,a)=>{const n=e+"."+a,o=Array.isArray(t.children)&&t.children.length>0,l=s.has(n);i.push({node:t,path:n,depth:r,hasChildren:o,expanded:l}),o&&l&&this._flatten(t.children,n,r+1,s,i)})}_renderNodeFlat(t,e,r,s){const i=e.node,a=e.depth,n=document.createElement("div");if(n.className="c-tree__node",n.setAttribute("role","treeitem"),n.setAttribute("aria-level",String(a)),n.setAttribute("aria-setsize",String(r)),n.setAttribute("aria-posinset",String(s)),n.dataset.path=e.path,e.hasChildren){n.setAttribute("aria-expanded",String(e.expanded));const t=document.createElement("div");t.className="c-tree__row"+(i.active?" c-tree__row--active":"")+(i.dir?" c-tree__row--dir":""),t.style.paddingInlineStart=`calc(${a-1} * 1rem * var(--density, 1))`;const r=document.createElement("button");r.className="c-tree__toggle",r.setAttribute("type","button"),r.setAttribute("aria-expanded",String(e.expanded)),r.setAttribute("aria-label",labelText(this,"toggle","Toggle")),setHTML(r,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),t.appendChild(r);const s=document.createElement("span");s.textContent=i.label,t.appendChild(s),n.appendChild(t)}else{const t=document.createElement("div");if(t.className="c-tree__leaf"+(i.active?" c-tree__row--active":"")+(i.dir?" c-tree__row--dir":""),t.style.paddingInlineStart=`calc(${a} * 1rem * var(--density, 1))`,this.hasAttribute("selectable")){const r=document.createElement("input");r.type="checkbox",r.className="c-tree__select",r.setAttribute("aria-label",labelText(this,"select","Select")+" "+(i.label||i)),this._selectedTree&&this._selectedTree.has(e.path)&&(r.checked=!0),t.insertBefore(r,t.firstChild)}t.appendChild(document.createTextNode(i.label||i)),n.appendChild(t)}return n}_renderWindow(t,e){if(!this._treeData)return;const r=this._itemHeight(),s=this._expanded||(this._expanded=new Set),i=[];this._flatten(this._treeData,"",1,s,i);const a=i.length,n=t.clientHeight||320,o=Math.ceil(n/r)+6;let l=Math.floor((e||0)/r);l<0&&(l=0),l>Math.max(0,a-o)&&(l=Math.max(0,a-o));const c=Math.min(a,l+o),u=l*r,d=Math.max(0,(a-c)*r);setHTML(t,"");const h=document.createElement("div");h.className="c-tree__spacer c-tree__spacer--top",h.style.height=u+"px",t.appendChild(h);const m=new Map;i.forEach((t,e)=>{const r=t.path.includes(".")?t.path.slice(0,t.path.lastIndexOf(".")):"";let s=m.get(r);s||(s=[],m.set(r,s)),s.push(e)});for(let e=l;e<c;e++){const r=i[e],s=r.path.includes(".")?r.path.slice(0,r.path.lastIndexOf(".")):"",a=m.get(s);t.appendChild(this._renderNodeFlat(t,r,a.length,a.indexOf(e)+1))}const b=document.createElement("div");b.className="c-tree__spacer c-tree__spacer--bottom",b.style.height=d+"px",t.appendChild(b)}render(){this.classList.add("c-tree");const t=Array.from(this.children).filter(t=>!t.classList||!t.classList.contains("c-tree"));if(wireStates(this),loadRemote(this,"items"),renderStates(this,"tree"))return;const e=remoteData(this,"items");if(e&&!t.length)try{const t=JSON.parse(e),r=this.ensure("div.c-tree",()=>{const t=document.createElement("div");return t.className="c-tree",t.setAttribute("role","tree"),t});setHTML(r,""),r.className="c-tree",r.setAttribute("role","tree");if(this.hasAttribute("virtual")){this._treeData=t,this._expanded=this._expanded||new Set,this._treeRoot=r,this._restoreExpanded(),r.style.maxHeight=r.style.maxHeight||"24rem",r.style.overflow="auto";const e=this._treeScrollTop||0;this._renderWindow(r,e);try{r.scrollTop=e}catch(t){}}else{this._treeData=null;const e=(t,s,i,a)=>{const n=s?document.createElement("div"):r;s&&(n.className="c-tree__children",n.setAttribute("role","group"),supportsUntilFound()?n.setAttribute("hidden","until-found"):n.setAttribute("hidden","")),t.forEach((r,s)=>{const o=(a||"")+"."+s,l=document.createElement("div");if(l.className="c-tree__node",l.setAttribute("role","treeitem"),l.setAttribute("aria-level",String(i)),l.setAttribute("aria-setsize",String(t.length)),l.setAttribute("aria-posinset",String(s+1)),l.dataset.path=o,r.children){l.setAttribute("aria-expanded","false");const t=document.createElement("div");if(t.className="c-tree__row"+(r.active?" c-tree__row--active":"")+(r.dir?" c-tree__row--dir":""),r.indent){const e=document.createElement("span");e.className="c-tree__indent",e.style.inlineSize=1*r.indent+"rem",t.appendChild(e)}const s=document.createElement("button");s.className="c-tree__toggle",s.setAttribute("type","button"),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-label",labelText(this,"toggle","Toggle")),setHTML(s,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),t.appendChild(s);const a=document.createElement("span");a.textContent=r.label,t.appendChild(a),l.appendChild(t),e(r.children,l,i+1,o)}else{const t=document.createElement("div");if(t.className="c-tree__leaf"+(r.active?" c-tree__row--active":"")+(r.dir?" c-tree__row--dir":""),r.indent){const e=document.createElement("span");e.className="c-tree__indent",e.style.inlineSize=1*r.indent+"rem",t.appendChild(e)}if(this.hasAttribute("selectable")){const e=document.createElement("input");e.type="checkbox",e.className="c-tree__select",e.setAttribute("aria-label",labelText(this,"select","Select")+" "+(r.label||r)),this._selectedTree&&this._selectedTree.has(o)&&(e.checked=!0),t.insertBefore(e,t.firstChild)}t.appendChild(document.createTextNode(r.label||r)),l.appendChild(t)}n.appendChild(l)}),s&&s.appendChild(n)};e(t,null,1,"")}this.classList.remove("c-tree"),r.classList.add("c-tree"),r.parentNode!==this&&this.appendChild(r)}catch(t){warnBadJson(this,"attribute",t)}else e||t.length||renderEmpty(this,"tree")}enhance(){if(this._wiredTreeToggle||(this._wiredTreeToggle=!0,this.addEventListener("click",t=>{if(!this.hasAttribute("virtual"))return;let e=t.target&&t.target.closest?t.target.closest(".c-tree__toggle"):null;if(!e){const r=t.target&&t.target.closest?t.target.closest(".c-tree__row"):null;r&&(e=r.querySelector(":scope > .c-tree__toggle"))}if(!e||!this.contains(e))return;t.stopPropagation();const r=e.closest(".c-tree__node"),s=r&&r.dataset?r.dataset.path:null,i="true"===e.getAttribute("aria-expanded");s&&this._expanded&&(i?this._expanded.delete(s):this._expanded.add(s)),e.setAttribute("aria-expanded",String(!i));const a=e.closest(".c-tree__row");if(a&&a.setAttribute("aria-expanded",String(!i)),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{path:s,expanded:!i}})),this.hasAttribute("virtual")&&this._treeRoot){const t=this._treeRoot;this._treeScrollTop=t.scrollTop||0,this._renderWindow(t,this._treeScrollTop);try{t.scrollTop=this._treeScrollTop}catch(t){}this._persistExpanded()}})),this.hasAttribute("virtual")&&!this._wiredTreeScroll){this._wiredTreeScroll=!0;const t=()=>{const t=this.querySelector(".c-tree");if(!t||t._treeScrollWired)return;t._treeScrollWired=!0;let e=0;const r=()=>{e||(e=requestAnimationFrame(()=>{e=0,this._treeScrollTop=t.scrollTop||0,this._renderWindow(t,this._treeScrollTop);try{t.scrollTop=this._treeScrollTop}catch(t){}}))};t.addEventListener("scroll",r,{passive:!0}),onDispose(this,()=>{t.removeEventListener("scroll",r),e&&cancelAnimationFrame(e)})};if(t(),!this.querySelector(".c-tree")){const e=new MutationObserver(()=>{this.querySelector(".c-tree")&&(t(),e.disconnect())});e.observe(this,{childList:!0,subtree:!0}),onDispose(this,()=>e.disconnect())}}if(this.hasAttribute("virtual")&&!this._wiredTreeDragScroll){this._wiredTreeDragScroll=!0;let t=0,e=0;const r=()=>{if(!e)return void(t=0);const s=this._treeRoot;s&&(s.scrollTop+=8*e,this._treeScrollTop=s.scrollTop,this._renderWindow(s,this._treeScrollTop)),t=requestAnimationFrame(r)};this.addEventListener("dragover",s=>{const i=this._treeRoot;if(!i)return;const a=i.getBoundingClientRect();e=s.clientY<a.top+40?-1:s.clientY>a.bottom-40?1:0,e&&!t&&(t=requestAnimationFrame(r))});const s=()=>{e=0,t&&(cancelAnimationFrame(t),t=0)};this.addEventListener("dragend",s),this.addEventListener("drop",s)}wireTree(this)}}define("contour-tree",ContourTree);class ContourFilterBar extends ContourBase{static get observed(){return["label","divider","items","input","placeholder","mode","modes","scope","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","count","clearable","cache-key","no-cache"]}static get properties(){return{label:{attribute:"label"},divider:{attribute:"divider"},items:{attribute:"items"},src:{attribute:"src"},count:{attribute:"count"},clearable:{attribute:"clearable"},scope:{attribute:"scope"}}}render(){if(this.classList.add("c-filter-bar"),wireStates(this),loadRemote(this,"items"),renderStates(this,"filter-bar"))return;const t=this.getAttribute("label");if(t){this.ensure(".c-filter-bar__label",()=>{const t=document.createElement("span");return t.className="c-filter-bar__label",t}).textContent=t}else{const t=this.querySelector(".c-filter-bar__label");t&&t.remove()}if(this.hasAttribute("divider"))this.ensure(".c-filter-bar__divider",()=>{const t=document.createElement("span");return t.className="c-filter-bar__divider",t});else{const t=this.querySelector(".c-filter-bar__divider");t&&t.remove()}if(this.hasAttribute("input")||this.hasAttribute("placeholder")){let t=this.querySelector(".c-filter-bar__input");t||(t=document.createElement("input"),t.type="search",t.className="c-filter-bar__input",this.appendChild(t));const e=this.getAttribute("placeholder");e&&t.setAttribute("placeholder",e)}else{const t=this.querySelector(".c-filter-bar__input");t&&t.remove()}const e=this.getAttribute("modes");let r=null;if(e)try{r=JSON.parse(e)}catch(t){r=e.split(",").map(t=>t.trim())}if(r||this.hasAttribute("mode")){let e=this.querySelector(".c-filter-bar__modes");e||(e=document.createElement("div"),e.className="c-filter-bar__modes",e.setAttribute("role","toolbar"),e.setAttribute("aria-label",t||"Filter modes"),this.appendChild(e)),setHTML(e,"");const s=this.getAttribute("mode");(Array.isArray(r)?r:["draw","erase","select"]).forEach(t=>{const r="string"==typeof t?t:t.label||t.value||t,i="string"==typeof t?t:t.value||t.label||t,a=document.createElement("button");a.type="button",a.className="c-filter-bar__mode",a.textContent=r,a.dataset.mode=i,s&&s===i&&a.setAttribute("aria-pressed","true"),e.appendChild(a)})}else{const t=this.querySelector(".c-filter-bar__modes");t&&t.remove()}const s=this.getAttribute("scope");if("viewport"===s||"global"===s){Array.from(this.querySelectorAll(".c-filter-bar__scope")).forEach(t=>t.remove());const t=document.createElement("div");t.className="c-filter-bar__modes c-filter-bar__scope",t.setAttribute("role","toolbar"),t.setAttribute("aria-label",labelText(this,"data-scope","Data scope")),["viewport","global"].forEach(e=>{const r=document.createElement("button");r.type="button",r.className="c-filter-bar__mode c-filter-bar__scope-btn",r.textContent="viewport"===e?"Viewport":"Global",r.dataset.scope=e,s===e&&r.setAttribute("aria-pressed","true"),t.appendChild(r)}),this.appendChild(t)}else{const t=this.querySelector(".c-filter-bar__scope");t&&t.remove()}Array.from(this.querySelectorAll(".c-filter-pill")).forEach(t=>t.remove());const i=remoteData(this,"items"),a=Array.from(this.querySelectorAll(":scope > .c-filter-pill"));let n=null;if(a.length)n=a.map(t=>t.textContent.trim()),a.forEach(t=>t.remove());else if(i)try{n=JSON.parse(i)}catch(t){n=null}if(Array.isArray(n)&&n.forEach(t=>{const e=document.createElement("span");e.className="c-filter-pill";const r="object"==typeof t&&null!==t,s="string"==typeof t?t:t.label||t.value||"",i=r?t.key:null,a=r?t.value:t;if(null!=i&&""!==i&&e.setAttribute("key",String(i)),null!=a&&""!==a&&e.setAttribute("value",String(a)),e.textContent=s,!r||!1!==t.removable){const t=document.createElement("button");t.className="c-filter-pill__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove","Remove")+" "+s),t.textContent="×",e.appendChild(t)}this.appendChild(e)}),Array.from(this.querySelectorAll(".c-filter-bar__clear-all")).forEach(t=>t.remove()),this.hasAttribute("clearable")){const t=document.createElement("button");t.type="button",t.className="c-btn c-btn--ghost c-btn--sm c-filter-bar__clear-all";const e=this.getAttribute("count");setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-x" /></svg>'),t.appendChild(document.createTextNode(" "+(e?labelText(this,"clear-all","Clear all")+" ("+e+")":labelText(this,"clear-all","Clear all")))),this.appendChild(t)}n||t||renderEmpty(this,"filter-bar")}enhance(){if(wireRemovable(this),this._wiredFilterBar)return;this._wiredFilterBar=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-filter-bar__mode"):null;if(e&&this.contains(e))if(e.classList.contains("c-filter-bar__scope-btn")){const t=e.dataset.scope||null;Array.from(this.querySelectorAll(".c-filter-bar__scope-btn")).forEach(t=>t.setAttribute("aria-pressed",String(t===e))),t&&this.setAttribute("scope",t),this.dispatchEvent(new CustomEvent("contour:scope-change",{bubbles:!0,composed:!0,detail:{scope:t}}))}else{const t=e.dataset.mode||e.textContent.trim();Array.from(this.querySelectorAll(".c-filter-bar__mode:not(.c-filter-bar__scope-btn)")).forEach(t=>t.setAttribute("aria-pressed",String(t===e))),this.dispatchEvent(new CustomEvent("contour:mode-change",{bubbles:!0,composed:!0,detail:{mode:t}}))}}),this.addEventListener("keydown",t=>{navKey(t,Array.from(this.querySelectorAll(".c-filter-bar__mode")),{wrap:!1,onKey:()=>{document.activeElement.click()}})});const t=this.querySelector(".c-filter-bar__input");t&&!t._wiredFilterInput&&(t._wiredFilterInput=!0,t.addEventListener("input",()=>{this.dispatchEvent(new CustomEvent("contour:input",{bubbles:!0,composed:!0,detail:{value:t.value}}))}),t.addEventListener("change",()=>{this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t.value}}))})),this._wiredClearAll||(this._wiredClearAll=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-filter-bar__clear-all"):null;e&&this.contains(e)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:clear-all",{bubbles:!0,composed:!0,detail:{}})))}))}}define("contour-filter-bar",ContourFilterBar);class ContourCommand extends ContourBase{static get observed(){return["placeholder","items","recent","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","cache-key","no-cache","anchor"]}static get properties(){return{placeholder:{attribute:"placeholder"},items:{attribute:"items"},recent:{attribute:"recent"},empty:{attribute:"empty"},src:{attribute:"src"}}}render(){if(this.classList.add("c-command"),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"command-palette","Command palette")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),wireStates(this),loadRemote(this,"items"),renderStates(this,"command"))return;const t=this.getAttribute("placeholder")||"Search…",e=this.ensure(".c-command__input",()=>{const t=document.createElement("div");return t.className="c-command__input",t}),r=this.ensure(".c-command__field",()=>{const t=document.createElement("input");return t.className="c-command__field",t.type="text",t});e.contains(r)||e.appendChild(r),r.type="text",r.placeholder=t,r.setAttribute("aria-label",labelText(this,"command","Command")),r.setAttribute("role","combobox"),r.setAttribute("aria-autocomplete","list"),r.setAttribute("aria-expanded","true");const s=this.querySelector(".c-command__list");s&&!s.id&&(s.id=contourId("c-command-list")),s&&s.id&&r.setAttribute("aria-controls",s.id),this._applyCommandAnchor();const i=remoteData(this,"items"),a=this.querySelector(".c-command__list"),n=a?Array.from(a.children).filter(t=>t.classList&&t.classList.contains("c-command__item")||t.classList&&t.classList.contains("c-command__group")):[];if(i&&!n.length)try{const t=JSON.parse(i),e=this.ensure(".c-command__list",()=>{const t=document.createElement("div");return t.className="c-command__list",t.setAttribute("role","listbox"),t.id=contourId("c-command-list"),t});e.setAttribute("role","listbox"),setHTML(e,"");const r=this.getAttribute("recent");if(r)try{const t=JSON.parse(r),s=document.createElement("div");s.className="c-command__group";const i=document.createElement("div");i.className="c-command__group-title",i.textContent=labelText(this,"recent","Recent"),s.appendChild(i),t.forEach(t=>{const e=document.createElement("div");e.className="c-command__item",e.setAttribute("role","option");const r=document.createElement("div");r.className="c-command__item-body";const i=document.createElement("div");i.className="c-command__item-title",i.textContent="string"==typeof t?t:t.title||t.label||"",r.appendChild(i),e.appendChild(r),s.appendChild(e)}),e.appendChild(s)}catch(t){}t.forEach(t=>{if(t.group){const r=document.createElement("div");r.className="c-command__group";const s=document.createElement("div");s.className="c-command__group-title",s.textContent=t.group,r.appendChild(s);const i=document.createElement("div");if(i.className="c-command__item",i.setAttribute("role","option"),t.icon){const e=document.createElement("span");e.className="c-command__item-icon",e.textContent=t.icon,i.appendChild(e)}const a=document.createElement("div");if(a.className="c-command__item-body",t.title||t.label){const e=document.createElement("div");e.className="c-command__item-title",e.textContent=t.title||t.label,a.appendChild(e)}if(t.hint){const e=document.createElement("span");e.className="c-command__item-hint",e.textContent=t.hint,a.appendChild(e)}if(t.shortcut){const e=document.createElement("kbd");e.className="c-command__item-shortcut",e.textContent=t.shortcut,i.appendChild(e)}i.appendChild(a),r.appendChild(i),e.appendChild(r)}else{const r=document.createElement("div");if(r.className="c-command__item",r.setAttribute("role","option"),t.icon){const e=document.createElement("span");e.className="c-command__item-icon",e.textContent=t.icon,r.appendChild(e)}const s=document.createElement("div");if(s.className="c-command__item-body",t.title||t.label){const e=document.createElement("div");e.className="c-command__item-title",e.textContent=t.title||t.label,s.appendChild(e)}if(t.hint){const e=document.createElement("span");e.className="c-command__item-hint",e.textContent=t.hint,s.appendChild(e)}if(t.shortcut){const e=document.createElement("kbd");e.className="c-command__item-shortcut",e.textContent=t.shortcut,r.appendChild(e)}r.appendChild(s),e.appendChild(r)}})}catch(t){warnBadJson(this,"attribute",t)}else!i&&s&&s.remove();const o=this.getAttribute("empty");if(o){const t=this.ensure(".c-command__empty",()=>{const t=document.createElement("div");return t.className="c-command__empty",t});t.textContent=o,t.hidden=this.querySelectorAll(".c-command__item").length>0}else{const t=this.querySelector(".c-command__empty");t&&t.remove()}this.ensure(".c-command__status",()=>{const t=document.createElement("div");return t.className="c-command__status",t.setAttribute("role","status"),t}).textContent="",i||s||renderEmpty(this,"command")}_applyCommandAnchor(){const t=this.getAttribute("anchor"),e=t?t.startsWith("#")?document.getElementById(t.slice(1)):document.querySelector(t):null;if(this._commandAnchorEl&&this._commandAnchorEl!==e&&(this._commandAnchorEl.style.removeProperty("anchor-name"),this._commandAnchorEl.removeAttribute("aria-controls"),this._commandAnchorEl.removeAttribute("aria-expanded")),this._commandAnchorEl=e||null,e){const t="--command-"+this.id;e.style.setProperty("anchor-name",t),this.style.setProperty("position-anchor",t),e.setAttribute("aria-controls",this.id),this._commandAnchorDispose||(this._commandAnchorDispose=!0,onDispose(this,()=>{this._commandAnchorEl&&(this._commandAnchorEl.style.removeProperty("anchor-name"),this._commandAnchorEl.removeAttribute("aria-controls"),this._commandAnchorEl.removeAttribute("aria-expanded")),this._commandAnchorDispose=!1}))}else this.style.removeProperty("position-anchor")}show(){if(this.matches(":popover-open"))return void(this.hasAttribute("open")||this.setAttribute("open",""));if("function"==typeof this.showPopover)try{this.showPopover()}catch(t){}this.classList.add("is-open");const t=this.querySelector(".c-command__field");t&&t.setAttribute("aria-expanded","true"),this.hasAttribute("open")||this.setAttribute("open",""),this._setCommandTriggerExpanded(!0)}hide(){if(!this.matches(":popover-open"))return void(this.hasAttribute("open")&&this.removeAttribute("open"));if("function"==typeof this.hidePopover)try{this.hidePopover()}catch(t){}this.classList.remove("is-open");const t=this.querySelector(".c-command__field");t&&t.setAttribute("aria-expanded","false"),this.hasAttribute("open")&&this.removeAttribute("open"),this._setCommandTriggerExpanded(!1)}toggle(){this.matches(":popover-open")?this.hide():this.show()}_setCommandTriggerExpanded(t){const e=this._commandAnchorEl;e&&(e.setAttribute("aria-controls",this.id),e.setAttribute("aria-expanded",String(!!t)))}enhance(){if(this._wiredCommand)return;this._wiredCommand=!0,this.addEventListener("beforetoggle",t=>{if("open"===t.newState){this.classList.add("is-open"),wcEmitOverlay(this,"contour:open",{});const e=this.querySelector(".c-command__field");if(e){e.setAttribute("aria-expanded","true");try{e.focus()}catch(t){}}this._setCommandTriggerExpanded(!0)}else this.classList.remove("is-open"),wcEmitOverlay(this,"contour:close",{}),this._setCommandTriggerExpanded(!1)}),this.addEventListener("toggle",t=>{"open"===t.newState&&requestAnimationFrame(()=>{this._applyCommandAnchor()})});const t=()=>this.querySelector(".c-command__field"),e=()=>Array.from(this.querySelectorAll(".c-command__item")),r=()=>e().filter(t=>!t.hidden&&!t.closest("[hidden]"));let s=-1;const i=()=>{if(r().forEach((e,r)=>{if(e.classList.toggle("c-command__item--active",r===s),e.setAttribute("aria-selected",String(r===s)),r===s){e.id||(e.id=contourId("contour-command-option"));const r=t();r&&r.setAttribute("aria-activedescendant",e.id)}}),s<0){const e=t();e&&e.removeAttribute("aria-activedescendant")}};this.addEventListener("keydown",a=>{const n=t();if(!n||a.target!==n)return;const o=r();if(o.length)if("ArrowDown"===a.key)a.preventDefault(),s=Math.min(s+1,o.length-1),i();else if("ArrowUp"===a.key)a.preventDefault(),s=Math.max(s-1,0),i();else if("Home"===a.key)a.preventDefault(),s=0,i();else if("End"===a.key)a.preventDefault(),s=o.length-1,i();else if("Enter"===a.key){if(a.preventDefault(),s>=0&&o[s]){const t=o[s],r=e().indexOf(t);this.dispatchEvent(new CustomEvent("contour:select",{detail:{index:r,label:t.textContent.trim()},bubbles:!0,composed:!0})),this.hide()}}else"Escape"===a.key&&this.hide()}),this.addEventListener("click",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-command__item"):null;if(r&&this.contains(r)){const t=e().indexOf(r);this.dispatchEvent(new CustomEvent("contour:select",{detail:{index:t,label:r.textContent.trim()},bubbles:!0,composed:!0})),this.hide()}}),this.addEventListener("input",r=>{const a=t();if(!a||r.target!==a)return;const n=a.value.trim().toLowerCase(),o=e();let l=0;o.forEach(t=>{const e=!n||(t.textContent||"").toLowerCase().includes(n);t.hidden=!e,e&&(l+=1)}),this.querySelectorAll(".c-command__group").forEach(t=>{const e=Array.from(t.querySelectorAll(".c-command__item")).some(t=>!t.hidden);t.hidden=!e});const c=o.findIndex(t=>!t.hidden);s=c>=0?0:-1,i();const u=this.querySelector(".c-command__empty");u&&(u.hidden=0!==l);const d=this.querySelector(".c-command__status");d&&(d.textContent=n?`${l} of ${o.length}`:"")})}}define("contour-command",ContourCommand);class ContourSpatialFilter extends ContourBase{static get observed(){return["modes","mode","active","bounds","operator","loading","error","retry","cache-key","skeleton","src"]}static get properties(){return{modes:{attribute:"modes"},mode:{attribute:"mode"},active:{attribute:"active"},bounds:{attribute:"bounds"},operator:{attribute:"operator"}}}render(){if(this.classList.add("c-spatial-filter"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"spatial-filter","Spatial filter")),wireStates(this),renderStates(this,"spatial-filter"))return;const t=this.getAttribute("modes");let e=null;if(t)try{e=JSON.parse(t)}catch(r){e=t.split(",").map(t=>t.trim())}const r=Array.isArray(e)?e:["rect","circle","polygon","clear"];let s=this.querySelector(".c-spatial-filter__modes");s||(s=document.createElement("div"),s.className="c-spatial-filter__modes",s.setAttribute("role","toolbar"),s.setAttribute("aria-label",labelText(this,"spatial-filter-modes","Spatial filter modes")),this.appendChild(s)),setHTML(s,"");const i=this.getAttribute("mode");i!==this._spatialSeenMode&&(this._spatialMode=null,this._spatialSeenMode=i);const a=null!=this._spatialMode?this._spatialMode:i;r.forEach(t=>{const e="string"==typeof t?t:t.label||t.value||t,r="string"==typeof t?t:t.value||t.label||t,i=document.createElement("button");i.type="button",i.className="c-spatial-filter__mode c-btn c-btn--ghost c-btn--sm";const n={rect:"i-square",circle:"i-circle",polygon:"i-triangle",lasso:"i-lasso",clear:"i-x"}[r];n&&setHTML(i,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+n+'" /></svg>'),i.appendChild(document.createTextNode((n?" ":"")+e)),i.dataset.mode=r,a&&a===r&&i.setAttribute("aria-pressed","true"),s.appendChild(i)});let n=this.querySelector(".c-spatial-filter__operator");n||(n=document.createElement("div"),n.className="c-spatial-filter__operator",this.appendChild(n));const o=this.getAttribute("operator")||"intersects";setHTML(n,"");const l=document.createElement("span");l.textContent=labelText(this,"operator","Operator")+":",n.appendChild(l);const c=document.createElement("select");c.className="c-spatial-filter__operator-select",c.setAttribute("aria-label",labelText(this,"operator","Operator")),c.setAttribute("data-contour-label","true"),["intersects","contains","within","disjoint"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t,t===o&&e.setAttribute("selected",""),c.appendChild(e)}),n.appendChild(c);let u=this.querySelector(".c-spatial-filter__readout");u||(u=document.createElement("div"),u.className="c-spatial-filter__readout",this.appendChild(u));const d=this.getAttribute("bounds");u.textContent=d||"—";let h=this.querySelector(".c-spatial-filter__clear-all");h||(h=document.createElement("button"),h.type="button",h.className="c-spatial-filter__clear-all",this.appendChild(h)),applyLabel(h,this,"clear-all","Clear all");const m=this.hasAttribute("active");m!==this._spatialSeenActive&&(this._spatialActive=null,this._spatialSeenActive=m),(null!=this._spatialActive?this._spatialActive:m)?this.classList.add("c-spatial-filter--active"):this.classList.remove("c-spatial-filter--active")}enhance(){this._wiredSpatialFilter||(this._wiredSpatialFilter=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest("button"):null;if(!e||!this.contains(e))return;if(e.classList.contains("c-spatial-filter__clear-all"))return this.classList.remove("c-spatial-filter--active"),Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach(t=>t.setAttribute("aria-pressed","false")),this._spatialActive=!1,this._spatialMode=null,this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:!0,composed:!0,detail:{}})),void this.dispatchEvent(new CustomEvent("contour:spatial-filter",{bubbles:!0,composed:!0,detail:{action:"clear-all"}}));const r=e.closest(".c-spatial-filter__mode");if(!r)return;const s=r.dataset.mode||r.textContent.trim();if("clear"===s)return this.classList.remove("c-spatial-filter--active"),Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach(t=>t.setAttribute("aria-pressed","false")),this._spatialActive=!1,this._spatialMode=null,void this.dispatchEvent(new CustomEvent("contour:clear",{bubbles:!0,composed:!0,detail:{}}));this.classList.add("c-spatial-filter--active"),Array.from(this.querySelectorAll(".c-spatial-filter__mode")).forEach(t=>t.setAttribute("aria-pressed",String(t===r))),this._spatialActive=!0,this._spatialMode=s,this.dispatchEvent(new CustomEvent("contour:draw-start",{bubbles:!0,composed:!0,detail:{mode:s}})),this.dispatchEvent(new CustomEvent("contour:spatial-filter",{bubbles:!0,composed:!0,detail:{action:"draw-start",mode:s}}))}),this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-spatial-filter__operator-select")&&(this.setAttribute("operator",e.value),this.dispatchEvent(new CustomEvent("contour:spatial-filter",{bubbles:!0,composed:!0,detail:{action:"operator",operator:e.value}})))}),this.addEventListener("keydown",t=>{navKey(t,Array.from(this.querySelectorAll(".c-spatial-filter__mode")),{wrap:!1,onKey:()=>{document.activeElement.click()}})}))}}define("contour-spatial-filter",ContourSpatialFilter);class ContourAvatar extends ContourBase{static get observed(){return["name","size","variant","src","status"]}static get properties(){return{name:{attribute:"name"},size:{attribute:"size"},variant:{attribute:"variant"},src:{attribute:"src"},status:{attribute:"status"}}}render(){this.classList.add("c-avatar"),Array.from(this.classList).forEach(t=>{t.startsWith("c-avatar--")&&this.classList.remove(t)});const t=this.getAttribute("name"),e=this.getAttribute("size");e&&this.classList.add("c-avatar--"+e);const r=this.getAttribute("variant");r&&this.classList.add("c-avatar--"+r);const s=this.querySelector("img.c-avatar__img");s&&s.remove();const i=this.querySelector(".c-avatar__status");i&&i.remove();const a=this.getAttribute("src");if(a){this.textContent="";const e=document.createElement("img");e.className="c-avatar__img",e.src=a,e.alt=t||"",e.loading="lazy",e.decoding="async",e.addEventListener("error",()=>{if(e.remove(),t){const e=t.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2);this.textContent=e}}),this.appendChild(e)}else if(t){const e=t.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2);this.querySelector("img.c-avatar__img"),this.textContent=e}const n=this.getAttribute("status");if(n){const t=document.createElement("span");t.className="c-avatar__status c-avatar__status--"+n,t.setAttribute("aria-hidden","true"),this.appendChild(t)}}}define("contour-avatar",ContourAvatar);class ContourBadgeFull extends ContourBase{static get observed(){return["variant","label","size","removable"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"},size:{attribute:"size"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-badge"),Array.from(this.classList).forEach(t=>{t.startsWith("c-badge--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-badge--"+t);const e=this.getAttribute("size");e&&this.classList.add("c-badge--"+e);const r=this.getAttribute("label");if(r){let t=null;for(const e of this.childNodes)if(3===e.nodeType){t=e;break}t?t.nodeValue=r:this.insertBefore(document.createTextNode(r),this.firstChild)}if(flagOn(this,"removable"))this.ensure(".c-badge__remove",()=>{const t=document.createElement("button");return t.className="c-badge__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove","Remove")),t.textContent="×",t});else{const t=this.querySelector(".c-badge__remove");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-badge",ContourBadgeFull);class ContourChipFull extends ContourBase{static get observed(){return["variant","key","value","live"]}static get properties(){return{variant:{attribute:"variant"},key:{attribute:"key"},value:{attribute:"value"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-chip"),flagOn(this,"live")&&!this.hasAttribute("role")?this.setAttribute("role","status"):!flagOn(this,"live")&&"status"===this.getAttribute("role")&&this._autoChipRole&&this.removeAttribute("role"),this._autoChipRole=flagOn(this,"live"),Array.from(this.classList).forEach(t=>{t.startsWith("c-chip--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-chip--"+t);const e=this.getAttribute("key"),r=this.getAttribute("value");if(e){this.ensure(".c-chip__key",()=>{const t=document.createElement("span");return t.className="c-chip__key",t}).textContent=e}else{const t=this.querySelector(".c-chip__key");t&&t.remove()}if(r){this.ensure(".c-chip__value",()=>{const t=document.createElement("span");return t.className="c-chip__value",t}).textContent=r}else{const t=this.querySelector(".c-chip__value");t&&t.remove()}}}define("contour-chip",ContourChipFull);class ContourTag extends ContourBase{static get observed(){return["label","removable","variant","live"]}static get properties(){return{label:{attribute:"label"},removable:{attribute:"removable",type:Boolean},variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-tag"),flagOn(this,"live")&&!this.hasAttribute("role")?this.setAttribute("role","status"):!flagOn(this,"live")&&"status"===this.getAttribute("role")&&this._autoTagRole&&this.removeAttribute("role"),this._autoTagRole=flagOn(this,"live"),Array.from(this.classList).forEach(t=>{t.startsWith("c-tag--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-tag--"+t);const e=this.getAttribute("label");if(e){let t=null;for(const e of this.childNodes)if(3===e.nodeType){t=e;break}t?t.nodeValue=e+" ":this.insertBefore(document.createTextNode(e+" "),this.firstChild)}if(flagOn(this,"removable"))this.ensure(".c-tag__remove",()=>{const t=document.createElement("button");return t.className="c-tag__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove","Remove")),t.textContent="×",t});else{const t=this.querySelector(".c-tag__remove");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-tag",ContourTag);class ContourDot extends ContourBase{static get observed(){return["variant","live"]}static get properties(){return{variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-dot"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","status indicator"),Array.from(this.classList).forEach(t=>{t.startsWith("c-dot--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-dot--"+t),flagOn(this,"live")?this.classList.add("c-dot--live"):this.classList.remove("c-dot--live")}}define("contour-dot",ContourDot);class ContourPill extends ContourBase{static get observed(){return["label","live","variant"]}static get properties(){return{label:{attribute:"label"},live:{attribute:"live",type:Boolean},variant:{attribute:"variant"}}}render(){this.classList.add("c-pill"),flagOn(this,"live")&&!this.hasAttribute("role")?this.setAttribute("role","status"):!flagOn(this,"live")&&"status"===this.getAttribute("role")&&this._autoPillRole&&this.removeAttribute("role"),this._autoPillRole=flagOn(this,"live"),Array.from(this.classList).forEach(t=>{t.startsWith("c-pill--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-pill--"+t);const e=this.getAttribute("label");e&&(this.textContent=e),flagOn(this,"live")?this.classList.add("c-pill--live"):this.classList.remove("c-pill--live")}}define("contour-pill",ContourPill);class ContourKbd extends ContourBase{static get observed(){return["key"]}static get properties(){return{key:{attribute:"key"}}}render(){this.classList.add("c-kbd");const t=this.getAttribute("key");t&&(this.textContent=t)}}define("contour-kbd",ContourKbd);class ContourSpinner extends ContourBase{static get observed(){return["size"]}static get properties(){return{size:{attribute:"size"}}}render(){this.classList.add("c-spinner"),Array.from(this.classList).forEach(t=>{t.startsWith("c-spinner--")&&this.classList.remove(t)});const t=this.getAttribute("size");t&&this.classList.add("c-spinner--"+t),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"loading","Loading"))}}define("contour-spinner",ContourSpinner);class ContourSkeleton extends ContourBase{static get observed(){return["size","shimmer"]}static get properties(){return{size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton"),Array.from(this.classList).forEach(t=>{t.startsWith("c-skeleton--")&&this.classList.remove(t)});const t=this.getAttribute("size");t&&this.classList.add("c-skeleton--"+t),this.hasAttribute("aria-hidden")||this.setAttribute("aria-hidden","true");const e=this.getAttribute("shimmer");flagOn(this,"shimmer")&&"off"!==e?this.classList.remove("c-skeleton--static"):this.classList.add("c-skeleton--static")}}define("contour-skeleton",ContourSkeleton);class ContourMark extends ContourBase{static get observed(){return["src","icon","label"]}static get properties(){return{src:{attribute:"src"},icon:{attribute:"icon"},label:{attribute:"label"}}}render(){this.classList.add("c-mark");const t=this.getAttribute("src")||this.getAttribute("icon");if(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),setHTML(e,'<use href="'+safeHref(t)+'" />'),this.appendChild(e)}const e=this.getAttribute("label");if(e&&!this.querySelector("[data-mark-label]")){const t=document.createElement("span");t.className="c-mark__label",t.setAttribute("data-mark-label",""),t.textContent=e,this.appendChild(t)}}}define("contour-mark",ContourMark);class ContourLoading extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-loading"),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.ensure(".c-spinner",()=>{const t=document.createElement("span");return t.className="c-spinner",t.setAttribute("aria-hidden","true"),t});const t=this.getAttribute("label")||"Loading";let e=this.querySelector("[data-loading-label]");e||(e=document.createElement("span"),e.className="visually-hidden",e.setAttribute("data-loading-label",""),this.appendChild(e)),e.textContent=t,this.hasAttribute("aria-label")||this.setAttribute("aria-label",t)}}define("contour-loading",ContourLoading);class ContourElevation extends ContourBase{render(){this.classList.add("c-elevation")}}define("contour-elevation",ContourElevation);class ContourFilterPill extends ContourBase{static get observed(){return["key","value","removable"]}static get properties(){return{key:{attribute:"key"},value:{attribute:"value"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-filter-pill");const t=this.getAttribute("key"),e=this.getAttribute("value");if(t){this.ensure(".c-filter-pill__key",()=>{const t=document.createElement("span");return t.className="c-filter-pill__key",t}).textContent=t}else{const t=this.querySelector(".c-filter-pill__key");t&&t.remove()}if(e){this.ensure(".c-filter-pill__value",()=>{const t=document.createElement("span");return t.className="c-filter-pill__value",t}).textContent=e}else{const t=this.querySelector(".c-filter-pill__value");t&&t.remove()}if(flagOn(this,"removable"))this.ensure(".c-filter-pill__remove",()=>{const t=document.createElement("button");return t.className="c-filter-pill__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove-filter","Remove filter")),t.textContent="×",t});else{const t=this.querySelector(".c-filter-pill__remove");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-filter-pill",ContourFilterPill);class ContourDatamark extends ContourBase{static get observed(){return["value","unit","label","format","locale"]}static get properties(){return{value:{attribute:"value"},unit:{attribute:"unit"},label:{attribute:"label"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-datamark");const t=this.getAttribute("value"),e=this.getAttribute("unit"),r=this.getAttribute("label"),s=this.getAttribute("format"),i=this.getAttribute("locale"),a=t||r;if(a){const r=t?formatValue(t,s,i,e):a;if(this.textContent=r,e&&t){const t=document.createElement("span");t.className="u-subtle",t.textContent=" "+e,this.appendChild(t)}}}}define("contour-datamark",ContourDatamark);class ContourDestructiveHint extends ContourBase{static get observed(){return["text"]}static get properties(){return{text:{attribute:"text"}}}render(){this.classList.add("c-destructive-hint");const t=this.getAttribute("text");t&&(this.textContent=t)}}define("contour-destructive-hint",ContourDestructiveHint);class ContourIconBadge extends ContourBase{static get observed(){return["icon"]}static get properties(){return{icon:{attribute:"icon"}}}render(){this.classList.add("c-icon-badge");const t=this.getAttribute("icon");if(t){const e=String(t).replace(/[^a-zA-Z0-9_-]/g,"");e&&!e.startsWith("i-")&&"undefined"!=typeof console&&console.warn&&console.warn("ContourIconBadge: icon '"+t+"' may not exist in the sprite (expected i-* name).");const r=this.querySelector("svg"),s=r||document.createElementNS("http://www.w3.org/2000/svg","svg");if(r){const t=s.querySelector("use");t&&t.setAttribute("href","#"+e)}else{s.setAttribute("aria-hidden","true");const t=document.createElementNS("http://www.w3.org/2000/svg","use");t.setAttribute("href","#"+e),s.appendChild(t),this.appendChild(s)}}else{const t=this.querySelector("svg");t&&t.remove()}}}define("contour-icon-badge",ContourIconBadge);class ContourLiveBadge extends ContourBase{static get observed(){return["label","state","live"]}static get properties(){return{label:{attribute:"label"},state:{attribute:"state"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-live-badge"),this.hasAttribute("role")||this.setAttribute("role","status"),Array.from(this.classList).forEach(t=>{t.startsWith("c-live-badge--")&&this.classList.remove(t)});const t=this.getAttribute("state");t?this.classList.add("c-live-badge--"+t):flagOn(this,"live")&&this.classList.add("c-live-badge--connected");const e=this.getAttribute("label");e&&!this.hasChildNodes()&&(this.textContent=e)}}define("contour-live-badge",ContourLiveBadge);class ContourSkeletonGroup extends ContourBase{static get observed(){return["count","size","shimmer"]}static get properties(){return{count:{attribute:"count",type:Number},size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton-group");const t=Math.max(0,parseInt(this.getAttribute("count")||"3",10)||3),e=this.getAttribute("size"),r=this.getAttribute("shimmer");Array.from(this.querySelectorAll(".c-skeleton")).forEach(t=>t.remove());for(let s=0;s<t;s++){const t=document.createElement("div");t.className="c-skeleton",e&&t.classList.add("c-skeleton--"+e),t.setAttribute("aria-hidden","true"),flagOn(this,"shimmer")&&"off"!==r?t.classList.remove("c-skeleton--static"):t.classList.add("c-skeleton--static"),this.appendChild(t)}}}define("contour-skeleton-group",ContourSkeletonGroup);class ContourAvatarGroup extends ContourBase{static get observed(){return["items","max"]}static get properties(){return{items:{attribute:"items"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-avatar-group");const t=this.getAttribute("items"),e=parseInt(this.getAttribute("max")||"4",10)||4;if(Array.from(this.querySelectorAll(".c-avatar, .c-avatar-group__overflow")).forEach(t=>t.remove()),t)try{const r=JSON.parse(t);if(r.slice(0,e).forEach(t=>{const e=document.createElement("span");e.className="c-avatar";const r="string"==typeof t?t:t.name||t.label||"";if(e.textContent=r.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2),"object"==typeof t&&t.color){const r=safeColor(t.color);r&&(e.style.background=r,e.dataset.color=r)}this.appendChild(e)}),r.length>e){const t=document.createElement("span");t.className="c-avatar c-avatar-group__overflow";const s=r.length-e;t.textContent="+"+s,t.setAttribute("aria-label","+"+s+" more"),this.appendChild(t)}}catch(t){warnBadJson(this,"attribute",t)}}}define("contour-avatar-group",ContourAvatarGroup);class ContourDivider extends ContourBase{static get observed(){return["label","orientation"]}static get properties(){return{label:{attribute:"label"},orientation:{attribute:"orientation"}}}render(){this.classList.add("c-divider"),this.hasAttribute("role")||this.setAttribute("role","separator");const t=this.getAttribute("orientation")||"horizontal";this.classList.add("c-divider--"+t);const e=this.getAttribute("label");if(e){this.ensure(".c-divider__label",()=>{const t=document.createElement("span");return t.className="c-divider__label",t}).textContent=e}}}define("contour-divider",ContourDivider);class ContourStatusLight extends ContourBase{static get observed(){return["status","label"]}static get properties(){return{status:{attribute:"status"},label:{attribute:"label"}}}render(){this.classList.add("c-status-light");const t=this.getAttribute("status")||"neutral";this.classList.add("c-status-light--"+t),this.hasAttribute("role")||this.setAttribute("role","img");const e=this.getAttribute("label");if(e&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label",e):e||this.hasAttribute("aria-label")||this.setAttribute("aria-label",t),e){this.ensure(".c-status-light__label",()=>{const t=document.createElement("span");return t.className="c-status-light__label",t}).textContent=e}}}define("contour-status-light",ContourStatusLight);class ContourBadgeOverflow extends ContourBase{static get observed(){return["count","max"]}static get properties(){return{count:{attribute:"count"},max:{attribute:"max"}}}render(){this.classList.add("c-badge-overflow");const t=Number(this.getAttribute("count")||0),e=Number(this.getAttribute("max")||3),r=Math.max(0,t-e),s=this.querySelector(".c-badge-overflow__more");if(s&&s.remove(),r>0){const t=document.createElement("span");t.className="c-badge c-badge-overflow__more",t.textContent="+"+r,this.appendChild(t)}}}define("contour-badge-overflow",ContourBadgeOverflow);class ContourTooltip extends ContourBase{static get observed(){return["text","anchor","delay","trigger"]}static get properties(){return{text:{attribute:"text"},anchor:{attribute:"anchor"},delay:{attribute:"delay",type:Number},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-tooltip"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"tooltip","Tooltip")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.hasAttribute("role")||this.setAttribute("role","tooltip"),this.id||(this.id=contourId("tip"));const t=this.getAttribute("text");null===t||this.hasChildNodes()||(this.textContent=t)}enhance(){if(this._wiredTooltip)return;this._wiredTooltip=!0;const t=this.getAttribute("anchor");if(t){let e=null;e=t.startsWith("#")?document.getElementById(t.slice(1)):document.querySelector(t),e&&(e.setAttribute("popovertarget",this.id||(this.id=contourId("tip"))),e.setAttribute("aria-describedby",this.id))}const e=this.delay&&this.delay>0?this.delay:0,r=this.getAttribute("anchor");let s=null;r&&(s=r.startsWith("#")?document.getElementById(r.slice(1)):document.querySelector(r));const i="--tooltip-"+(this.id||(this.id=contourId("tip")));(()=>{s&&(s.style.setProperty("anchor-name",i),this.style.setProperty("position-anchor",i),this.style.setProperty("position-area","top"))})();const a="function"==typeof this.showPopover;let n=null,o=null;const l=()=>{if(a)try{this.showPopover()}catch(t){}else this.classList.add("is-open"),this.style.zIndex="var(--z-tooltip)";try{requestAnimationFrame(C)}catch(t){C()}},c=()=>{if(o&&(clearTimeout(o),o=null),a)try{this.hidePopover()}catch(t){}else this.classList.remove("is-open"),this.style.removeProperty("z-index")},u=()=>{n&&clearTimeout(n),e>0?n=setTimeout(l,e):l()},d=()=>{n&&(clearTimeout(n),n=null),o&&clearTimeout(o),o=setTimeout(c,300)};this.addEventListener("pointerenter",()=>{o&&(clearTimeout(o),o=null)}),this.addEventListener("pointerleave",d),onDispose(this,()=>{s&&s.style.removeProperty("anchor-name")});const h=this.getAttribute("trigger")||"hover",m=r?r.startsWith("#")?document.getElementById(r.slice(1)):document.querySelector(r):null,b=m||this,p=()=>{"click"!==h&&u()},g=()=>{"click"!==h&&d()},_=()=>{"click"!==h&&u()},v=()=>{"click"!==h&&d()},f=t=>{m&&m.hasAttribute("popovertarget")?"click"!==h&&t&&t.preventDefault&&t.preventDefault():"click"!==h&&"hover"!==h||(this.matches(":popover-open")?d():u())},y=()=>{"click"!==h&&u()},A=()=>{"click"!==h&&setTimeout(d,1500)};b.addEventListener("mouseenter",p),b.addEventListener("mouseleave",g),b.addEventListener("focus",_),b.addEventListener("blur",v),b.addEventListener("click",f),b.addEventListener("touchstart",y,{passive:!0}),b.addEventListener("touchend",A,{passive:!0});const C=()=>{try{const t=this.getBoundingClientRect();t.right>window.innerWidth?this.classList.add("c-tooltip--flip-x"):this.classList.remove("c-tooltip--flip-x"),t.bottom>window.innerHeight?this.classList.add("c-tooltip--flip-y"):this.classList.remove("c-tooltip--flip-y")}catch(t){}};onDispose(this,()=>{b.removeEventListener("mouseenter",p),b.removeEventListener("mouseleave",g),b.removeEventListener("focus",_),b.removeEventListener("blur",v),b.removeEventListener("click",f),b.removeEventListener("touchstart",y),b.removeEventListener("touchend",A),n&&clearTimeout(n)}),this.addEventListener("toggle",t=>{const e=t.target;if(e&&e===this){const t=this.matches(":popover-open");wcEmitOverlay(this,t?"contour:open":"contour:close",{open:t})}})}}define("contour-tooltip",ContourTooltip);class ContourProgress extends ContourBase{static get observed(){return["value","label","min","max","paused","pausable"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},min:{attribute:"min"},max:{attribute:"max"},paused:{attribute:"paused",type:Boolean},pausable:{attribute:"pausable",type:Boolean}}}render(){this.classList.add("c-progress");const t=this.getAttribute("value"),e=this.getAttribute("min"),r=this.getAttribute("max"),s=null!==e?Number(e):0,i=null!==r?Number(r):100,a=i-s||1;if(null===t)this.style.removeProperty("--progress"),this.classList.add("c-progress--indeterminate"),this.getAttribute("aria-valuenow")===this._progressAriaValue&&this.removeAttribute("aria-valuenow"),this._progressAriaValue=null;else{this.classList.remove("c-progress--indeterminate");const e=Number(t);let r;r=Number.isFinite(e)?e<=1&&t.includes(".")?100*e:(e-s)/a*100:0,r=Math.max(0,Math.min(100,r)),this.style.setProperty("--progress",r+"%"),this.classList.toggle("c-progress--complete",r>=100);const n=Number.isFinite(e)?Math.max(s,Math.min(i,e)):s,o=this._progressAriaValue;this.hasAttribute("aria-valuenow")&&this.getAttribute("aria-valuenow")!==o||(this.setAttribute("aria-valuenow",String(n)),this._progressAriaValue=String(n))}this.ensure(".c-progress__bar",()=>{const t=document.createElement("span");return t.className="c-progress__bar",t}),this.hasAttribute("role")||this.setAttribute("role","progressbar");const n=this.getAttribute("label");if(this.hasAttribute("aria-label")||this.setAttribute("aria-label",n||"Progress"),null!==e?this.setAttribute("aria-valuemin",e):this.hasAttribute("aria-valuemin")||this.setAttribute("aria-valuemin","0"),null!==r?this.setAttribute("aria-valuemax",r):this.hasAttribute("aria-valuemax")||this.setAttribute("aria-valuemax","100"),this.hasAttribute("aria-valuenow")){const t=Number(this.getAttribute("aria-valuenow"));Number.isFinite(t)&&this.setAttribute("aria-valuenow",String(Math.max(s,Math.min(i,t))))}if(flagOn(this,"paused")?this.classList.add("c-progress--paused"):Array.from(this.classList).forEach(t=>{"c-progress--paused"===t&&this.classList.remove(t)}),flagOn(this,"pausable")){const t=flagOn(this,"paused"),e=this.ensure(".c-progress__pause",()=>{const t=document.createElement("button");return t.className="c-progress__pause",t.type="button",t});e.setAttribute("aria-label",t?"Resume":"Pause"),e.textContent=t?"▶":"⏸"}else{const t=this.querySelector(".c-progress__pause");t&&t.remove()}}enhance(){this._wiredProgress||(this._wiredProgress=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-progress__pause"):null;if(!e||!this.contains(e))return;t.preventDefault();const r=!flagOn(this,"paused");this.toggleAttribute("paused",r),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{paused:r}}))}))}}define("contour-progress",ContourProgress);class ContourVersionBannerFull extends ContourBase{static get observed(){return["message","link","href","dismissible"]}static get properties(){return{message:{attribute:"message"},link:{attribute:"link"},href:{attribute:"href"},dismissible:{attribute:"dismissible",type:Boolean}}}render(){this.classList.add("c-version-banner"),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("message")||"Version banner"),Array.from(this.children).forEach(t=>t.remove());const t=this.getAttribute("message");if(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),setHTML(e,'<use href="#i-info" />'),this.appendChild(e);const r=document.createElement("span");r.textContent=t,this.appendChild(r)}const e=this.getAttribute("link"),r=this.getAttribute("href");if(e&&r){const t=document.createElement("a");t.className="c-version-banner__link",t.href=safeHref(r),t.textContent=e,this.appendChild(t)}if(flagOn(this,"dismissible")){const t=document.createElement("button");t.className="c-version-banner__dismiss",t.type="button",t.setAttribute("aria-label",labelText(this,"dismiss","Dismiss")),t.textContent="×",this.appendChild(t)}}enhance(){this._wiredVersionBanner||(this._wiredVersionBanner=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-version-banner__dismiss"):null;e&&this.contains(e)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})),this.remove())}))}}define("contour-version-banner",ContourVersionBannerFull);class ContourBanner extends ContourBase{static get observed(){return["message","variant"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"}}}render(){this.classList.add("c-banner");const t=this.getAttribute("variant");Array.from(this.classList).forEach(t=>{t.startsWith("c-banner--")&&this.classList.remove(t)}),t&&["info","success","warning","danger","error"].includes(t)&&this.classList.add("c-banner--"+t);const e=statusIcon(t);let r=this.querySelector(".c-banner__icon");e?(r||(r=document.createElement("span"),r.className="c-banner__icon"),setHTML(r,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+String(e).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'),this.firstChild!==r&&this.prepend(r)):r&&r.remove();const s=this.getAttribute("message");if(s){this.ensure(".c-banner__message",()=>{const t=document.createElement("span");return t.className="c-banner__message",t}).textContent=s}}}define("contour-banner",ContourBanner);class ContourPullToRefresh extends ContourBase{static get observed(){return["threshold"]}static get properties(){return{threshold:{attribute:"threshold"}}}render(){this.classList.add("c-pull-to-refresh"),this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"label","Pull to refresh"));const t=this.ensure(".c-pull-to-refresh__indicator",()=>{const t=document.createElement("div");return t.className="c-pull-to-refresh__indicator",t});t.innerHTML="";const e=document.createElement("span");e.className="c-pull-to-refresh__label",e.setAttribute("aria-live","polite"),e.textContent=this._ptrError?this._ptrError:this._ptrRefreshing?labelText(this,"refreshing","Refreshing…"):labelText(this,"label","Pull to refresh"),t.appendChild(e);const r=document.createElement("button");r.type="button",r.className="c-pull-to-refresh__btn",r.textContent=labelText(this,"refresh","Refresh"),t.appendChild(r),t.parentNode!==this&&this.prepend(t),this.classList.toggle("is-refreshing",!!this._ptrRefreshing),this.classList.toggle("has-error",!!this._ptrError),this.setAttribute("aria-busy",String(!!this._ptrRefreshing))}complete(){this._ptrRefreshing=!1,this._ptrError=null,this.style.removeProperty("--ptr-offset"),this.requestRender()}fail(t){this._ptrRefreshing=!1,this._ptrError=String(t||labelText(this,"error","Refresh failed")),this.style.removeProperty("--ptr-offset"),this.requestRender(),this.dispatchEvent(new CustomEvent("contour:error",{bubbles:!0,composed:!0,detail:{message:this._ptrError}}))}_refresh(){this._ptrRefreshing||(this._ptrRefreshing=!0,this._ptrError=null,this.style.removeProperty("--ptr-offset"),this.requestRender(),this.dispatchEvent(new CustomEvent("contour:refresh",{bubbles:!0,composed:!0})))}enhance(){if(this._wiredPullToRefresh)return;this._wiredPullToRefresh=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-pull-to-refresh__btn"):null;e&&this.contains(e)&&this._refresh()});let t=0,e=!1,r=0;this.addEventListener("pointerdown",s=>{if(!(this._ptrRefreshing||this.scrollTop>0||s.target&&s.target.closest&&s.target.closest(".c-pull-to-refresh__btn"))){t=s.clientY,e=!0,r=0;try{this.setPointerCapture(s.pointerId)}catch(t){}}}),this.addEventListener("pointermove",s=>{if(!e)return;const i=s.clientY-t;i>0&&(r=Math.min(120,.6*i),this.style.setProperty("--ptr-offset",r+"px"))});const s=()=>{if(!e)return;e=!1;const t=Number(this.getAttribute("threshold"))||60;r>=t?this._refresh():this.style.removeProperty("--ptr-offset"),r=0};this.addEventListener("pointerup",s),this.addEventListener("pointercancel",s)}}function menuPopoverCapable(t){return!!t&&"function"==typeof t.showPopover&&"function"==typeof t.hidePopover}function placeMenu(t,e,r,s){if(!t||!e)return;const i=e.getBoundingClientRect(),a=t.offsetWidth||0,n=t.offsetHeight||0;let o=i.bottom+r;o+n>window.innerHeight&&i.top-r-n>=0&&(o=i.top-r-n);let l=s?i.right-a:i.left;l=Math.max(0,Math.min(l,Math.max(0,window.innerWidth-a))),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.top=o+"px",t.style.left=l+"px"}function armMenuReposition(t,e,r,s,i){disarmMenuReposition(t);const a=()=>{e.hidden||placeMenu(e,r(),s,i)};t._menuReposition=a,window.addEventListener("scroll",a,!0),window.addEventListener("resize",a)}function disarmMenuReposition(t){const e=t._menuReposition;e&&(window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),t._menuReposition=null)}function setMenuOpen(t,e,r,s,i){if(e)if(s){if(e.hidden=!1,menuPopoverCapable(e)){e.style.removeProperty("margin");const s=getComputedStyle(e),a=parseFloat(s.marginBlockStart||s.marginTop)||0;try{e.showPopover()}catch(t){}placeMenu(e,r(),a,i),armMenuReposition(t,e,r,a,i)}}else{if(menuPopoverCapable(e)&&e.matches(":popover-open"))try{e.hidePopover()}catch(t){}disarmMenuReposition(t),e.hidden=!0}}define("contour-pull-to-refresh",ContourPullToRefresh);class ContourDropdown extends ContourBase{static get observed(){return["label","items","empty"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"}}}render(){this.classList.add("c-dropdown"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"dropdown","Dropdown"));const t=this.ensure(".c-dropdown__trigger",()=>{const t=document.createElement("button");return t.className="c-dropdown__trigger c-btn c-btn--sm",t.type="button",t});t.textContent=this.getAttribute("label")||"Menu",t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false");const e=this.ensure(".c-dropdown__menu",()=>{const t=document.createElement("div");return t.className="c-dropdown__menu c-menu",t.setAttribute("role","menu"),t.hidden=!0,menuPopoverCapable(t)&&t.setAttribute("popover","manual"),t});e.id||(e.id=(this.id||contourId("dd"))+"-menu"),t.setAttribute("aria-controls",e.id);const r=Array.from(this.querySelectorAll(":scope > .c-menu__item")),s=this.getAttribute("items");if(r.length)e.innerHTML="",r.forEach(t=>{e.appendChild(t)});else if(s){const t=parseArrayAttr(this,"items",warnBadJson);e.innerHTML="",0===t.length?renderEmpty(this,"dropdown"):t.forEach(t=>{const r=document.createElement("button");r.className="c-menu__item",r.type="button",r.setAttribute("role","menuitem"),r.textContent="string"==typeof t?t:t.label||t.title||"",e.appendChild(r)})}e.parentNode!==this&&this.appendChild(e),t.parentNode!==this&&this.insertBefore(t,e)}enhance(){if(this._wiredDropdown)return;this._wiredDropdown=!0;const t=()=>this.querySelector(".c-dropdown__trigger"),e=()=>this.querySelector(".c-dropdown__menu");this.addEventListener("click",r=>{const s=t(),i=e(),a=r.target&&r.target.closest?r.target.closest(".c-menu__item"):null;if(a&&i&&i.contains(a)&&!i.hidden){const e=Array.from(i.querySelectorAll(".c-menu__item")).indexOf(a);if(this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:e,value:a.textContent}})),setMenuOpen(this,i,t,!1,!1),s){s.setAttribute("aria-expanded","false");try{s.focus()}catch(t){}}return}if((r.target===s||s&&s.contains(r.target))&&i){const e=i.hidden;if(setMenuOpen(this,i,t,e,!1),s.setAttribute("aria-expanded",String(e)),e){i.id||(i.id=(this.id||contourId("dd"))+"-menu"),s.setAttribute("aria-controls",i.id);const t=i.querySelector(".c-menu__item");if(t)try{t.focus()}catch(t){}}}});const r=r=>{const s=e(),i=t();!s||s.hidden||this.contains(r.target)||(setMenuOpen(this,s,t,!1,!1),i&&i.setAttribute("aria-expanded","false"))};document.addEventListener("click",r),onDispose(this,()=>document.removeEventListener("click",r)),onDispose(this,()=>disarmMenuReposition(this));const s=r=>{const s=e(),i=t();if("Escape"===r.key&&s&&!s.hidden){if(r.preventDefault(),setMenuOpen(this,s,t,!1,!1),i){i.setAttribute("aria-expanded","false");try{i.focus()}catch(t){}}return}if("ArrowDown"===r.key&&r.target===i&&s&&s.hidden){r.preventDefault(),setMenuOpen(this,s,t,!0,!1),i.setAttribute("aria-expanded","true"),s.id||(s.id=(this.id||contourId("dd"))+"-menu"),i.setAttribute("aria-controls",s.id);const e=s.querySelector(".c-menu__item");if(e)try{e.focus()}catch(t){}return}if(!s||s.hidden)return;const a=Array.from(s.querySelectorAll(".c-menu__item"));if(1===r.key.length&&!r.ctrlKey&&!r.metaKey&&!r.altKey){const t=(this._ddTypeaheadQuery||"")+r.key.toLowerCase();this._ddTypeaheadQuery=t,clearTimeout(this._ddTypeaheadTimer),this._ddTypeaheadTimer=setTimeout(()=>{this._ddTypeaheadQuery=""},800);const e=a.find(e=>e.textContent.toLowerCase().startsWith(t));e&&e.focus()}navKey(r,a,{wrap:!0,enter:!1,onKey:t=>{"Enter"!==t&&" "!==t||document.activeElement.click()}})},i=r=>{const s=e();if(s&&!s.hidden&&!this.contains(r.relatedTarget)){setMenuOpen(this,s,t,!1,!1);const e=t();e&&e.setAttribute("aria-expanded","false")}};this.addEventListener("focusout",i),onDispose(this,()=>this.removeEventListener("focusout",i)),document.addEventListener("keydown",s),onDispose(this,()=>document.removeEventListener("keydown",s))}}define("contour-dropdown",ContourDropdown);class ContourSplitButton extends ContourBase{static get observed(){return["label","menu","empty"]}static get properties(){return{label:{attribute:"label"},menu:{attribute:"menu"}}}render(){this.classList.add("c-split-button");const t=this.ensure(".c-split-button__main",()=>{const t=document.createElement("button");return t.className="c-btn c-split-button__main",t.type="button",t});t.textContent=this.getAttribute("label")||labelText(this,"action","Action");const e=this.ensure(".c-split-button__toggle",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--icon c-split-button__toggle",t.type="button",t.setAttribute("aria-label",labelText(this,"more-options","More options")),t.textContent="▾",t}),r=this.ensure(".c-split-button__menu",()=>{const t=document.createElement("div");return t.className="c-menu c-split-button__menu",t.setAttribute("role","menu"),t.hidden=!0,menuPopoverCapable(t)&&t.setAttribute("popover","manual"),t});r.id||(r.id=(this.id||contourId("split"))+"-menu"),e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-controls",r.id),e.setAttribute("aria-expanded",String(!r.hidden));if(this.getAttribute("menu")){const t=parseArrayAttr(this,"menu",warnBadJson);r.innerHTML="",0===t.length?renderEmpty(this,"split-button"):t.forEach(t=>{const e=document.createElement("button");e.className="c-menu__item",e.type="button",e.setAttribute("role","menuitem"),e.textContent="string"==typeof t?t:t.label||t.title||"",r.appendChild(e)})}t.parentNode!==this&&this.appendChild(t),e.parentNode!==this&&this.appendChild(e),r.parentNode!==this&&this.appendChild(r)}enhance(){if(this._wiredSplitButton)return;this._wiredSplitButton=!0;const t=()=>this.querySelector(".c-split-button__toggle"),e=()=>this.querySelector(".c-split-button__menu"),r=()=>Array.from(e()?.querySelectorAll(".c-menu__item")||[]),s=(s,i)=>{const a=e(),n=t();if(!a)return;const o=!a.hidden;if(setMenuOpen(this,a,t,s,!0),n&&n.setAttribute("aria-expanded",String(s)),s&&i){const t=r()[0];if(t)try{t.focus()}catch(t){}}o!==s&&this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{open:s}}))};onDispose(this,()=>disarmMenuReposition(this)),this.addEventListener("click",i=>{const a=i.target&&i.target.closest?i.target.closest(".c-split-button__main"):null;if(a&&this.contains(a))return void this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0,detail:{label:a.textContent}}));const n=t();if(i.target===n||n&&n.contains(i.target)){const t=e();return void s(!!t&&t.hidden,!0)}const o=i.target&&i.target.closest?i.target.closest(".c-menu__item"):null;if(o&&this.contains(o)){const e=r().indexOf(o);s(!1,!1);try{t()?.focus()}catch(t){}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{label:o.textContent,index:e}}))}}),this.addEventListener("keydown",i=>{const a=t(),n=e(),o=r(),l=i.target===a||a&&a.contains(i.target),c=o.indexOf(i.target);if(!l||"Enter"!==i.key&&" "!==i.key&&"ArrowDown"!==i.key){if(l&&"ArrowUp"===i.key){i.preventDefault(),s(!0,!1);const t=o[o.length-1];if(t)try{t.focus()}catch(t){}}else if(c>=0){if("ArrowDown"===i.key)i.preventDefault(),o[(c+1)%o.length]?.focus();else if("ArrowUp"===i.key)i.preventDefault(),o[(c-1+o.length)%o.length]?.focus();else if("Home"===i.key)i.preventDefault(),o[0]?.focus();else if("End"===i.key)i.preventDefault(),o[o.length-1]?.focus();else if("Escape"===i.key){i.preventDefault(),s(!1,!1);try{a?.focus()}catch(t){}}}else if("Escape"===i.key&&n&&!n.hidden){s(!1,!1);try{a?.focus()}catch(t){}}}else i.preventDefault(),s(!0,!0);if(1===i.key.length&&!i.ctrlKey&&!i.metaKey&&!i.altKey){const t=(this._sbTypeaheadQuery||"")+i.key.toLowerCase();this._sbTypeaheadQuery=t,clearTimeout(this._sbTypeaheadTimer),this._sbTypeaheadTimer=setTimeout(()=>{this._sbTypeaheadQuery=""},800);const e=o.find(e=>e.textContent.toLowerCase().startsWith(t));e&&e.focus()}});const i=t=>{const r=e();!r||r.hidden||this.contains(t.relatedTarget)||s(!1,!1)};this.addEventListener("focusout",i),onDispose(this,()=>this.removeEventListener("focusout",i));const a=t=>{const r=e();!r||r.hidden||this.contains(t.target)||s(!1,!1)};document.addEventListener("click",a),onDispose(this,()=>document.removeEventListener("click",a))}}define("contour-split-button",ContourSplitButton);class ContourMapPopup extends ContourBase{static get observed(){return["title","content","cluster-count","cluster-expanded","cluster-items","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},"cluster-count":{attribute:"cluster-count",type:Number},"cluster-expanded":{attribute:"cluster-expanded",type:Boolean},"cluster-items":{attribute:"cluster-items"}}}render(){this.classList.add("c-map-popup"),this.setAttribute("role","dialog"),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("map-popup"));const t=this.getAttribute("title");if(t){this.ensure(".c-map-popup__title",()=>{const t=document.createElement("div");return t.className="c-map-popup__title",t}).textContent=t}const e=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-map-popup__title")&&!t.classList.contains("c-map-popup__body"))&&!(3===t.nodeType&&!t.textContent.trim())),r=this.getAttribute("content");if(e.length){const t=this.ensure(".c-map-popup__body",()=>{const t=document.createElement("div");return t.className="c-map-popup__body",t});for(const r of e)t.appendChild(r)}else if(r){this.ensure(".c-map-popup__body",()=>{const t=document.createElement("div");return t.className="c-map-popup__body",t}).textContent=r}const s=Number(this.getAttribute("cluster-count"));if(Number.isFinite(s)&&s>1){const t=this.ensure(".c-map-popup__cluster",()=>{const t=document.createElement("button");return t.className="c-map-popup__cluster c-btn c-btn--sm",t.type="button",t}),e=this.hasAttribute("cluster-expanded");t.textContent=e?"Hide locations":`${s} locations`,t.setAttribute("aria-expanded",String(e)),t.setAttribute("aria-label",e?"Hide locations":`Show ${s} locations`)}else{const t=this.querySelector(".c-map-popup__cluster");t&&t.remove()}const i=this.hasAttribute("cluster-expanded");let a=parseArrayAttr(this,"cluster-items",warnBadJson);const n=this.querySelector(".c-map-popup__cluster-list");if(i&&Array.isArray(a)&&a.length){const t=n||document.createElement("ul");t.className="c-map-popup__cluster-list",setHTML(t,""),a.forEach(e=>{const r=document.createElement("li");r.className="c-map-popup__cluster-item",r.textContent="string"==typeof e?e:e.label||e.name||JSON.stringify(e),t.appendChild(r)}),t.parentNode!==this&&this.appendChild(t)}else n&&n.remove();this.hasAttribute("aria-label")||this.setAttribute("aria-label",t||"Map popup");const o=this.getAttribute("anchor");let l=null;o&&(l=o.startsWith("#")?document.getElementById(o.slice(1)):document.querySelector(o)),this._mapPopupAnchorEl=l;const c="--map-popup-"+this.id;l&&(l.style.setProperty("anchor-name",c),this.style.setProperty("position-anchor",c))}enhance(){if(this._wiredMapPopup)return;this._wiredMapPopup=!0;const t=()=>{try{this.hidePopover()}catch(t){}this.classList.remove("is-open"),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))},e=e=>{"Escape"===e.key&&(this.classList.contains("is-open")||this.matches(":popover-open"))&&(e.preventDefault(),t())};document.addEventListener("keydown",e),onDispose(this,()=>document.removeEventListener("keydown",e)),this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-map-popup__close"):null;r&&this.contains(r)&&t();const s=e.target&&e.target.closest?e.target.closest(".c-map-popup__cluster"):null;if(s&&this.contains(s)){const t=!this.hasAttribute("cluster-expanded");this.toggleAttribute("cluster-expanded",t),this.dispatchEvent(new CustomEvent("contour:cluster-toggle",{bubbles:!0,composed:!0,detail:{count:Number(this.getAttribute("cluster-count")),expanded:t}}))}});const r="--map-popup-"+this.id,s=()=>{const t=this._mapPopupAnchorEl;t&&(t.style.setProperty("anchor-name",r),this.style.setProperty("position-anchor",r))},i=()=>{try{const t=this.getBoundingClientRect(),e=t.right>window.innerWidth||t.left<0,r=t.bottom>window.innerHeight||t.top<0,s=e||r;this.classList.toggle("c-map-popup--flip-x",e&&!r),this.classList.toggle("c-map-popup--flip-y",r&&!e),this.classList.toggle("c-map-popup--flip-both",e&&r),s&&this.dispatchEvent(new CustomEvent("contour:map-popup-reposition",{bubbles:!0,composed:!0,detail:{anchor:this.getAttribute("anchor")||"",flippedX:e,flippedY:r,left:Math.round(t.left),top:Math.round(t.top)}}))}catch(t){}};this.addEventListener("toggle",t=>{"open"===t.newState&&requestAnimationFrame(()=>{s(),i()})});const a=()=>i();window.addEventListener("resize",a),onDispose(this,()=>{window.removeEventListener("resize",a),this._mapPopupAnchorEl&&this._mapPopupAnchorEl.style.removeProperty("anchor-name")})}}define("contour-map-popup",ContourMapPopup);class ContourAnimationControls extends ContourBase{static get observed(){return["playing","speed","progress","min","max","caption","show-thumb","show-thumb-caption","loop","step","markers"]}static get properties(){return{playing:{attribute:"playing",type:Boolean},speed:{attribute:"speed"},progress:{attribute:"progress"},min:{attribute:"min"},max:{attribute:"max"},loop:{attribute:"loop",type:Boolean},step:{attribute:"step"},markers:{attribute:"markers"}}}render(){this.classList.add("c-animation-controls"),this.setAttribute("role","toolbar"),this.setAttribute("aria-label",labelText(this,"animation-controls","Animation controls"));const t=this.ensure(".c-animation-controls__play",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-animation-controls__play",t.type="button",t});setHTML(t,this.hasAttribute("playing")?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-pause" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-play" /></svg>'),t.setAttribute("aria-label",this.hasAttribute("playing")?labelText(this,"pause","Pause"):labelText(this,"play","Play"));const e=this.getAttribute("speed")||"1x",r=this.ensure(".c-animation-controls__speed",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-animation-controls__speed",t.type="button",t});r.textContent=e,r.setAttribute("aria-label",labelText(this,"playback-speed","Playback speed")+" "+e);const s=this.ensure(".c-animation-controls__loop",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-animation-controls__loop",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-refresh" /></svg>'),t});s.setAttribute("aria-label",labelText(this,"loop","Loop")),s.setAttribute("aria-pressed",String(this.hasAttribute("loop"))),t.tabIndex=0,r.tabIndex=-1,s.tabIndex=-1;const i=this.ensure(".c-animation-controls__scrubber",()=>{const t=document.createElement("input");return t.className="c-range c-animation-controls__scrubber",t.type="range",t});"false"===this.getAttribute("show-thumb")?i.classList.remove("c-animation-controls__scrubber--thumb"):i.classList.add("c-animation-controls__scrubber--thumb"),i.min=this.getAttribute("min")||"0",i.max=this.getAttribute("max")||"100",i.step=this.getAttribute("step")||"1",i.value=this.getAttribute("progress")||"0";{const t=Number(i.min)||0,e=Number(i.max)||100,r=Number(i.value)||0,s=e===t?0:(r-t)/(e-t)*100;i.style.setProperty("--fill",s+"%")}const a=Number(i.min)||0,n=Number(i.max)||100,o=Number(i.value)||a;i.setAttribute("aria-valuenow",String(o)),i.setAttribute("aria-valuetext",String(Math.round(o))),i.setAttribute("aria-valuemin",String(a)),i.setAttribute("aria-valuemax",String(n));const l=this.getAttribute("caption");l?i.setAttribute("aria-label",l):i.getAttribute("aria-label")||i.setAttribute("aria-label",labelText(this,"playhead","Playhead"));const c=this.getAttribute("markers");let u=[];if(c)try{const t=JSON.parse(c);u=Array.isArray(t)?t:[]}catch(t){warnBadJson(this,"markers",t)}const d=this.querySelector("datalist.c-animation-controls__markers");if(u.length){const t=this.ensure("datalist.c-animation-controls__markers",()=>{const t=document.createElement("datalist");return t.className="c-animation-controls__markers",t});t.id||(t.id=this._animMarkersId||(this._animMarkersId=contourId("anim-markers"))),setHTML(t,""),u.forEach(e=>{const r=document.createElement("option"),s="object"==typeof e&&null!==e?e.value:e;r.value=String(s),"object"==typeof e&&null!==e&&e.label&&(r.label=String(e.label)),t.appendChild(r)}),i.setAttribute("list",t.id)}else d&&d.remove(),i.removeAttribute("list");const h=this.hasAttribute("show-thumb-caption")||this.hasAttribute("show-thumb");if(l&&h){this.ensure(".c-animation-controls__caption",()=>{const t=document.createElement("span");return t.className="c-animation-controls__caption",t}).textContent=l}else{const t=this.querySelector(".c-animation-controls__caption");t&&t.remove()}this.hasAttribute("loop")&&this.setAttribute("aria-label",labelText(this,"animation-controls-loop","Animation controls, loop"))}enhance(){if(this._wiredAnimControls)return;this._wiredAnimControls=!0;const t=[.5,1,2,4],e=t=>{this._animScrubbing||this.setAttribute("progress",String(t))};this.addEventListener("pointerdown",t=>{t.target&&t.target.closest&&t.target.closest(".c-animation-controls__scrubber")&&(this._animScrubbing=!0)},{passive:!0});const r=()=>{this._animScrubbing=!1};this.addEventListener("pointerup",r,{passive:!0}),this.addEventListener("pointercancel",r,{passive:!0}),this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-animation-controls__play"):null;if(r&&this.contains(r)){const t=!this.hasAttribute("playing");return this.toggleAttribute("playing",t),void this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{playing:t}}))}const s=e.target&&e.target.closest?e.target.closest(".c-animation-controls__speed"):null;if(s&&this.contains(s)){const e=parseFloat(this.getAttribute("speed")||"1x"),r=t.indexOf(Number.isFinite(e)?e:1),s=t[(r+1)%t.length];return this.setAttribute("speed",s+"x"),void this.dispatchEvent(new CustomEvent("contour:speed-change",{bubbles:!0,composed:!0,detail:{speed:s}}))}const i=e.target&&e.target.closest?e.target.closest(".c-animation-controls__loop"):null;if(i&&this.contains(i)){const t=!this.hasAttribute("loop");this.toggleAttribute("loop",t),this.dispatchEvent(new CustomEvent("contour:loop-change",{bubbles:!0,composed:!0,detail:{loop:t}}))}}),this.addEventListener("input",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-animation-controls__scrubber"):null;if(r&&this.contains(r)){const t=Number(r.value),s=Number(r.min)||0,i=Number(r.max)||100,a=i===s?0:(t-s)/(i-s)*100;r.style.setProperty("--fill",a+"%"),e(t),this.dispatchEvent(new CustomEvent("contour:seek",{bubbles:!0,composed:!0,detail:{progress:t,value:t}}))}}),this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-animation-controls__scrubber"):null;e&&this.contains(e)&&this.setAttribute("progress",e.value)}),this.addEventListener("keydown",t=>{if(t.target&&t.target.closest&&t.target.closest(".c-animation-controls__scrubber"))return;const e=Array.from(this.querySelectorAll(".c-animation-controls__play, .c-animation-controls__speed, .c-animation-controls__loop"));e.includes(t.target)&&navKey(t,e,{wrap:!0,homeEnd:!0,onNavigate:t=>{e.forEach((e,r)=>{e.tabIndex=r===t?0:-1})},onKey:(t,e,r)=>{"Enter"!==t&&" "!==t||r.click()}})});let s=null;const i=()=>{const t=this.getAttribute("speed")||"1x",e=parseFloat(t);return Number.isFinite(e)&&e>0?e:1},a=()=>{const t=this.querySelector(".c-animation-controls__scrubber");if(!t)return;const r=Number(t.min||0),s=Number(t.max||100);let a=Number(t.value||0)+i(),n=!1;a>s&&(this.hasAttribute("loop")?a=r:(a=s,o(),n=!0)),t.value=String(a),e(a),this.dispatchEvent(new CustomEvent("contour:time-change",{bubbles:!0,composed:!0,detail:{progress:a,value:a}})),n&&(this.removeAttribute("playing"),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{playing:!1}})))},n=()=>{s||(s=setInterval(a,100))},o=()=>{s&&(clearInterval(s),s=null)};this.hasAttribute("playing")&&n();const l=new MutationObserver(()=>{this.hasAttribute("playing")?n():o()});l.observe(this,{attributes:!0,attributeFilter:["playing"]}),onDispose(this,()=>{o(),l.disconnect()})}}define("contour-animation-controls",ContourAnimationControls);class ContourAnnotation extends ContourBase{static get observed(){return["label","x","y"]}static get properties(){return{label:{attribute:"label"},x:{attribute:"x"},y:{attribute:"y"}}}render(){this.classList.add("c-annotation"),this.setAttribute("role","note"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const t=this.getAttribute("label");if(t&&this.setAttribute("aria-label",t),t){this.ensure(".c-annotation__label",()=>{const t=document.createElement("span");return t.className="c-annotation__label",t}).textContent=t}const e=this.getAttribute("x"),r=this.getAttribute("y");null!==e&&this.style.setProperty("--annotation-x",e),null!==r&&this.style.setProperty("--annotation-y",r)}enhance(){if(this._wiredAnnotation)return;this._wiredAnnotation=!0;const t=(t,e)=>{const r=parseFloat(t);return Number.isFinite(r)?Math.min(100,Math.max(0,r)):e},e=(t,e,r)=>{this.batch(()=>{this.setAttribute("x",t+"%"),this.setAttribute("y",e+"%")}),this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:!0,composed:!0,detail:{delta:r?1:0,key:r||"pointer",value:t+","+e}}))};let r=null;this.addEventListener("pointerdown",e=>{if(void 0!==e.button&&0!==e.button)return;const s=this.offsetParent||this.parentElement;if(!s)return;const i=s.getBoundingClientRect();r={px:e.clientX,py:e.clientY,x:t(this.getAttribute("x"),50),y:t(this.getAttribute("y"),50),w:i.width||1,h:i.height||1};try{this.setPointerCapture(e.pointerId)}catch(t){}try{this.focus()}catch(t){}e.preventDefault()}),this.addEventListener("pointermove",t=>{if(!r)return;const s=Math.round(10*(r.x+(t.clientX-r.px)/r.w*100))/10,i=Math.round(10*(r.y+(t.clientY-r.py)/r.h*100))/10;e(Math.min(100,Math.max(0,s)),Math.min(100,Math.max(0,i)))});const s=()=>{r&&(r=null,this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:!0,composed:!0,detail:{value:(this.getAttribute("x")||"")+","+(this.getAttribute("y")||"")}})))};this.addEventListener("pointerup",s),this.addEventListener("pointercancel",s),this.addEventListener("keydown",r=>{const s=r.shiftKey?10:1;let i=0,a=0;if("ArrowLeft"===r.key)i=-s;else if("ArrowRight"===r.key)i=s;else if("ArrowUp"===r.key)a=-s;else{if("ArrowDown"!==r.key)return;a=s}r.preventDefault();const n=Math.min(100,Math.max(0,t(this.getAttribute("x"),50)+i)),o=Math.min(100,Math.max(0,t(this.getAttribute("y"),50)+a));e(n,o,r.key),this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:!0,composed:!0,detail:{value:n+","+o}}))})}}define("contour-annotation",ContourAnnotation);class ContourStyleSwitcher extends ContourBase{static get observed(){return["items","value"]}static get properties(){return{items:{attribute:"items"},value:{attribute:"value"}}}render(){this.classList.add("c-style-switcher"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"style-switcher","Style switcher"));const t=this.getAttribute("items"),e=this.getAttribute("value"),r=Array.from(this.children).filter(t=>t.classList&&t.classList.contains("c-style-switcher__option"));if(t&&!r.length){Array.from(this.querySelectorAll(".c-style-switcher__option")).forEach(t=>t.remove());try{JSON.parse(t).forEach(t=>{const e="string"==typeof t?t:t.name||t.label||"",r=document.createElement("button");r.className="c-style-switcher__option c-btn c-btn--sm",r.type="button",r.textContent=e,r.dataset.value=e,this.appendChild(r)})}catch(t){warnBadJson(this,"attribute",t)}}const s=Array.from(this.querySelectorAll(".c-style-switcher__option"));let i=null;s.forEach(t=>{const r=(null!=t.dataset.value?t.dataset.value:t.textContent.trim())===e;t.classList.toggle("c-style-switcher__option--active",r),t.setAttribute("aria-pressed",String(r)),t.tabIndex=-1,r&&!i&&(i=t)}),(i||s[0])?.setAttribute("tabindex","0")}enhance(){if(this._wiredStyleSwitcher)return;this._wiredStyleSwitcher=!0;const t=t=>{const e=null!=t.dataset.value?t.dataset.value:t.textContent.trim();this.setAttribute("value",e),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e}}))};this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-style-switcher__option"):null;r&&this.contains(r)&&t(r)}),this.addEventListener("keydown",e=>{navKey(e,Array.from(this.querySelectorAll(".c-style-switcher__option")),{onKey:e=>{if("Enter"===e||" "===e){const e=document.activeElement;e&&e.classList.contains("c-style-switcher__option")&&t(e)}}})})}}define("contour-style-switcher",ContourStyleSwitcher);class ContourStylePanel extends ContourBase{static get observed(){return["title","layers","layer","single","classification","palette","breaks","opacity","n","colors","property"]}static get properties(){return{title:{attribute:"title"},layers:{attribute:"layers"},classification:{attribute:"classification"},palette:{attribute:"palette"},breaks:{attribute:"breaks"},opacity:{attribute:"opacity"}}}render(){if(this.classList.add("c-style-panel"),!this._stylePanelDefault){this._stylePanelDefault={};for(const t of["property","classification","palette","breaks","opacity","n","colors"])this._stylePanelDefault[t]=this.getAttribute(t)}this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"style-panel","Style panel"));const t=this.getAttribute("title");if(t){this.ensure(".c-style-panel__title",()=>{const t=document.createElement("div");return t.className="c-style-panel__title",t}).textContent=t}if(this.hasAttribute("single")||!!this.getAttribute("layer")){const t=this.ensure(".c-style-panel__body",()=>{const t=document.createElement("div");return t.className="c-style-panel__body",t});setHTML(t,"");const e=contourId("style-panel"),r=e+"-property",s=e+"-policy",i=e+"-palette",a=e+"-n",n=document.createElement("label");n.textContent=labelText(this,"colour-field","Colour field"),n.setAttribute("for",r),t.appendChild(n);const o=document.createElement("input");o.type="text",o.id=r,o.className="c-style-panel__property c-input",o.setAttribute("aria-label",labelText(this,"colour-field","Colour field"));const l=this.getAttribute("property");l&&(o.value=l),t.appendChild(o);const c=document.createElement("label");c.textContent=labelText(this,"classification","Classification"),c.setAttribute("for",s),t.appendChild(c);const u=document.createElement("select");u.id=s,u.className="c-style-panel__classification c-input",u.setAttribute("aria-label",labelText(this,"classification-method","Classification method")),["equal","quantile","jenks","manual"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t,u.appendChild(e)});const d=this.getAttribute("classification");d&&(u.value=d),t.appendChild(u);const h=document.createElement("label");h.textContent=labelText(this,"palette","Palette"),h.setAttribute("for",i),t.appendChild(h);const m=document.createElement("input");m.type="text",m.id=i,m.className="c-style-panel__palette c-input",m.placeholder=labelText(this,"palette","Palette"),m.setAttribute("aria-label",labelText(this,"palette","Palette"));const b=this.getAttribute("palette");b&&(m.value=b),t.appendChild(m);const p=document.createElement("label");p.textContent=labelText(this,"classes","Classes"),p.setAttribute("for",a),t.appendChild(p);const g=document.createElement("input");g.type="number",g.id=a,g.className="c-style-panel__n c-input",g.min="2",g.max="12",g.setAttribute("aria-label",labelText(this,"class-count","Class count"));const _=this.getAttribute("n");g.value=_||"5",t.appendChild(g);const v=document.createElement("input");v.type="range",v.className="c-style-panel__opacity",v.setAttribute("aria-label",labelText(this,"opacity","Opacity")),v.min="0",v.max="100";const f=this.getAttribute("opacity");v.value=null!=f?f:"100",t.appendChild(v);const y=this.getAttribute("breaks");let A=null;if(y)try{A=JSON.parse(y)}catch(t){A=y.split(",").map(t=>t.trim())}if(Array.isArray(A)&&A.length){const e=document.createElement("div");e.className="c-style-panel__breaks",A.forEach((t,r)=>{const s=document.createElement("div");s.className="break";const i=document.createElement("span");i.textContent=String(t),s.appendChild(i);const a=document.createElement("input");a.type="number",a.className="c-style-panel__breaks c-input",a.setAttribute("aria-label",labelText(this,"class-lower-bound","Class lower bound")),a.value=String(t),s.appendChild(a),e.appendChild(s)}),t.appendChild(e)}const C=this.getAttribute("colors");let w=null;if(C)try{w=JSON.parse(C)}catch(t){w=C.split(",").map(t=>t.trim())}if(Array.isArray(w)){const e=document.createElement("div");e.className="c-style-panel__colors",w.forEach((t,r)=>{const s=document.createElement("input");s.type="color",s.className="c-style-panel__color c-input",s.setAttribute("aria-label",labelText(this,"colour-for-class","Colour for class")+" "+(r+1)),s.value=t,e.appendChild(s)}),t.appendChild(e)}const E=document.createElement("div");E.className="c-style-panel__actions c-btn-group";const x=document.createElement("button");x.type="button",x.className="c-btn c-btn--primary",x.textContent=labelText(this,"apply","Apply"),x.dataset.action="apply";const S=document.createElement("button");return S.type="button",S.className="c-btn",S.textContent=labelText(this,"revert","Revert"),S.dataset.action="revert",E.appendChild(x),E.appendChild(S),void t.appendChild(E)}const e=this.getAttribute("layers"),r=this.ensure(".c-style-panel__body",()=>{const t=document.createElement("div");return t.className="c-style-panel__body",t}),s=Array.from(this.querySelectorAll(":scope > .c-style-panel__row"));let i=null;if(s.length)i=s.map(t=>({name:t.querySelector(".c-style-panel__name")?.textContent||"",color:t.querySelector(".c-style-panel__color")?.value,classification:t.querySelector(".c-style-panel__classification")?.value,palette:t.querySelector(".c-style-panel__palette")?.value,breaks:t.querySelector(".c-style-panel__breaks")?.value,opacity:t.querySelector(".c-style-panel__opacity")?.value})),s.forEach(t=>t.remove());else if(e)try{i=JSON.parse(e)}catch(t){warnBadJson(this,"layers",t),i=null}i&&(setHTML(r,""),i.forEach(t=>{const e=document.createElement("div");e.className="c-style-panel__row";const s=document.createElement("span");s.className="c-style-panel__name",s.textContent="string"==typeof t?t:t.name||t.label||"",e.appendChild(s);const i=document.createElement("input");i.type="color",i.className="c-style-panel__color",i.setAttribute("aria-label",labelText(this,"colour-for","Colour for")+" "+("string"==typeof t?t:t.name||t.label||labelText(this,"layer","layer"))),"object"==typeof t&&t.color&&(i.value=t.color),e.appendChild(i);const a=document.createElement("select");a.className="c-style-panel__classification",a.setAttribute("aria-label",labelText(this,"classification-method","Classification method")),["equal","quantile","jenks","manual"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t,a.appendChild(e)}),"object"==typeof t&&t.classification&&(a.value=t.classification),e.appendChild(a);const n=document.createElement("input");n.type="text",n.className="c-style-panel__palette",n.setAttribute("aria-label",labelText(this,"palette","Palette")),n.placeholder="palette","object"==typeof t&&t.palette&&(n.value=t.palette),e.appendChild(n);const o=document.createElement("input");o.type="text",o.className="c-style-panel__breaks",o.placeholder="breaks",o.setAttribute("aria-label",labelText(this,"class-breaks","Class breaks")),"object"==typeof t&&t.breaks&&(o.value=Array.isArray(t.breaks)?t.breaks.join(","):t.breaks),e.appendChild(o);const l=document.createElement("input");l.type="range",l.className="c-style-panel__opacity",l.setAttribute("aria-label",labelText(this,"opacity","Opacity")),l.min="0",l.max="100",l.value="object"==typeof t&&null!=t.opacity?t.opacity:"100",e.appendChild(l),r.appendChild(e)}))}enhance(){this._wiredStylePanel||(this._wiredStylePanel=!0,this.addEventListener("change",t=>{const e=t.target;if(!e||!this.contains(e))return;const r=e.closest(".c-style-panel__row"),s=r&&r.querySelector(".c-style-panel__name")?.textContent||"";if(e.classList.contains("c-style-panel__color"))this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:e.value,layer:s,property:"color"},bubbles:!0,composed:!0}));else if(e.classList.contains("c-style-panel__classification"))this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:e.value,layer:s},bubbles:!0,composed:!0}));else if(e.classList.contains("c-style-panel__opacity")){const t=s?s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""):"";this.dispatchEvent(new CustomEvent("contour:layer-opacity",{detail:{layerId:t,name:s,opacity:Number(e.value)},bubbles:!0,composed:!0}))}else e.classList.contains("c-style-panel__property")?this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:e.value,layer:s,property:"property"},bubbles:!0,composed:!0})):e.classList.contains("c-style-panel__n")&&this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:Number(e.value),layer:s,property:"n"},bubbles:!0,composed:!0}))}),this.addEventListener("input",t=>{const e=t.target;if(e&&this.contains(e)&&(e.classList.contains("c-style-panel__color")&&e.setAttribute("data-edited","true"),e.classList.contains("c-style-panel__palette")||e.classList.contains("c-style-panel__breaks"))){const t=e.closest(".c-style-panel__row"),r=t&&t.querySelector(".c-style-panel__name")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:e.value,layer:r,property:e.classList.contains("c-style-panel__palette")?"palette":"breaks"},bubbles:!0,composed:!0}))}}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest("button"):null;if(e&&this.contains(e))if("apply"===e.dataset.action){const t=this.querySelector(".c-style-panel__body"),e={applied:!0};if(t){const r=t.querySelector(".c-style-panel__property"),s=t.querySelector(".c-style-panel__classification"),i=t.querySelector(".c-style-panel__palette"),a=t.querySelector(".c-style-panel__n"),n=Array.from(t.querySelectorAll(".c-style-panel__color")).map(t=>t.value);r&&(e.property=r.value),s&&(e.classification=s.value),i&&(e.palette=i.value),a&&(e.n=Number(a.value)),n.length&&(e.colors=n)}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:e,bubbles:!0,composed:!0}))}else if("revert"===e.dataset.action){const t=this._stylePanelDefault||{};this._contourResetting=!0;try{for(const e of["property","classification","palette","breaks","opacity","n","colors"])null===t[e]||void 0===t[e]?this.removeAttribute(e):this.setAttribute(e,t[e]);this.attributeChangedCallback("__rerender__",null,"")}finally{this._contourResetting=!1}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{applied:!1},bubbles:!0,composed:!0}))}}))}}define("contour-style-panel",ContourStylePanel);class ContourPopover extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"}}}render(){this.classList.add("c-popover"),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"popover","Popover")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("popover"));const t=this.getAttribute("title");if(t){this.ensure(".c-popover__title",()=>{const t=document.createElement("div");return t.className="c-popover__title",t}).textContent=t}const e=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-popover__title")&&!t.classList.contains("c-popover__body"))&&!(3===t.nodeType&&!t.textContent.trim())),r=this.getAttribute("content");if(e.length){const t=this.ensure(".c-popover__body",()=>{const t=document.createElement("div");return t.className="c-popover__body",t});for(const r of e)t.appendChild(r)}else if(r){this.ensure(".c-popover__body",()=>{const t=document.createElement("div");return t.className="c-popover__body",t}).textContent=r}this._applyPopoverAnchor()}_applyPopoverAnchor(){const t=this.getAttribute("anchor"),e=t?t.startsWith("#")?document.getElementById(t.slice(1)):document.querySelector(t):null;if(this._popoverAnchorEl&&this._popoverAnchorEl!==e&&(this._popoverAnchorEl.style.removeProperty("anchor-name"),this._popoverAnchorEl.removeAttribute("aria-controls"),this._popoverAnchorEl.removeAttribute("aria-expanded")),this._popoverAnchorEl=e||null,e){const t="--popover-"+this.id;e.style.setProperty("anchor-name",t),this.style.setProperty("position-anchor",t),e.setAttribute("aria-controls",this.id),this._popoverAnchorDispose||(this._popoverAnchorDispose=!0,onDispose(this,()=>{this._popoverAnchorEl&&this._popoverAnchorEl.style.removeProperty("anchor-name"),this._popoverAnchorDispose=!1}))}else this.style.removeProperty("position-anchor")}_setPopoverTriggerExpanded(t){const e=this._popoverAnchorEl;e&&(e.setAttribute("aria-controls",this.id),e.setAttribute("aria-expanded",String(!!t)))}enhance(){if(this._wiredPopover)return;this._wiredPopover=!0;const t=()=>{try{this.hidePopover()}catch(t){}this.classList.remove("is-open"),wcEmitOverlay(this,"contour:close",{}),this._setPopoverTriggerExpanded(!1)},e=e=>{if(this.classList.contains("is-open")||this.matches(":popover-open")){if("Escape"===e.key)return e.preventDefault(),void t();if("Tab"===e.key){const t=Array.from(this.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!t.length)return void e.preventDefault();const r=t[0],s=t[t.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),s.focus()):e.shiftKey||document.activeElement!==s||(e.preventDefault(),r.focus())}}};document.addEventListener("keydown",e),onDispose(this,()=>document.removeEventListener("keydown",e));const r=()=>{this.classList.add("is-open"),wcEmitOverlay(this,"contour:open",{});const t=this.querySelector('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(t)try{t.focus()}catch(t){}else try{this.focus()}catch(t){}this._setPopoverTriggerExpanded(!0)};this.addEventListener("beforetoggle",t=>{"open"===t.newState&&r()});const s=t=>{t.target&&t.target!==this&&this.contains(t.target)&&this.classList.add("is-parent")};this.addEventListener("contour:open",s),this.addEventListener("contour:show",s),this.addEventListener("contour:close",t=>{t.target&&t.target!==this&&this.classList.remove("is-parent")}),this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-popover__close"):null;r&&this.contains(r)&&t()})}}define("contour-popover",ContourPopover);class ContourHoverCard extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},anchor:{attribute:"anchor"}}}render(){this.classList.add("c-hover-card"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"hover-card","Hover card")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("hover-card"));const t=this.getAttribute("title");if(t){this.ensure(".c-hover-card__title",()=>{const t=document.createElement("div");return t.className="c-hover-card__title",t}).textContent=t}const e=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-hover-card__title")&&!t.classList.contains("c-hover-card__body"))&&!(3===t.nodeType&&!t.textContent.trim())),r=this.getAttribute("content");if(e.length){const t=this.ensure(".c-hover-card__body",()=>{const t=document.createElement("div");return t.className="c-hover-card__body",t});for(const r of e)t.appendChild(r)}else if(r){this.ensure(".c-hover-card__body",()=>{const t=document.createElement("div");return t.className="c-hover-card__body",t}).textContent=r}if(!this.hasAttribute("role")){const t=!!this.querySelector("a[href], button, input, select, textarea");this.setAttribute("role",t?"dialog":"tooltip")}"function"==typeof this._wireHoverAnchor&&this._wireHoverAnchor()}enhance(){if(this._wiredHoverCard)return;this._wiredHoverCard=!0;let t=null,e=null;const r="function"==typeof this.showPopover,s=()=>{t&&(clearTimeout(t),t=null),e&&(clearTimeout(e),e=null)},i=t=>{if(s(),r)try{this.showPopover(t?{source:t}:void 0)}catch(t){try{this.showPopover()}catch(t){}}else this.classList.add("is-open");this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}))},a=()=>{if(s(),r)try{this.hidePopover()}catch(t){}else this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))},n=()=>{e&&clearTimeout(e),e=setTimeout(a,300)};this.addEventListener("mouseenter",s),this.addEventListener("mouseleave",n),this.addEventListener("focusin",s),this.addEventListener("focusout",t=>{this.contains(t.relatedTarget)||n()}),this._wireHoverAnchor=()=>{const e=this.getAttribute("anchor")||"";if(this._hoverAnchorSel===e&&this._hoverAnchorCleanup)return;if(this._hoverAnchorCleanup&&(this._hoverAnchorCleanup(),this._hoverAnchorCleanup=null),this._hoverAnchorSel=e,!e)return;const r=e.startsWith("#")?document.getElementById(e.slice(1)):document.querySelector(e);if(!r)return;r.setAttribute("popovertarget",this.id),r.setAttribute("aria-describedby",this.id);const a="--hover-card-"+this.id;r.style.setProperty("anchor-name",a),this.style.setProperty("position-anchor",a);const o=()=>{s(),t=setTimeout(()=>i(r),300)},l=()=>{n()},c=()=>i(r),u=()=>{n()},d=t=>{t&&t.preventDefault&&t.preventDefault()};r.addEventListener("mouseenter",o),r.addEventListener("mouseleave",l),r.addEventListener("focus",c),r.addEventListener("blur",u),r.addEventListener("click",d),this._hoverAnchorCleanup=()=>{r.removeEventListener("mouseenter",o),r.removeEventListener("mouseleave",l),r.removeEventListener("focus",c),r.removeEventListener("blur",u),r.removeEventListener("click",d),r.style.removeProperty("anchor-name"),r.getAttribute("aria-describedby")===this.id&&r.removeAttribute("aria-describedby")}},this._wireHoverAnchor();const o=t=>{"Escape"===t.key&&(this.classList.contains("is-open")||this.matches(":popover-open"))&&(t.preventDefault(),a())};document.addEventListener("keydown",o),onDispose(this,()=>{s(),this._hoverAnchorCleanup&&(this._hoverAnchorCleanup(),this._hoverAnchorCleanup=null),this._hoverAnchorSel=null,document.removeEventListener("keydown",o)})}}define("contour-hover-card",ContourHoverCard);class ContourContextMenu extends ContourBase{static get observed(){return["items","trigger"]}static get properties(){return{items:{attribute:"items"},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-context-menu"),this.hasAttribute("role")||this.setAttribute("role","menu"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"context-menu","Context menu")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("context-menu"));const t=this.getAttribute("items");if(t)try{const e=JSON.parse(t);Array.from(this.querySelectorAll("[data-contour-generated='1']")).forEach(t=>t.remove()),e.forEach(t=>{const e=document.createElement("button");e.className="c-menu__item",e.type="button",e.setAttribute("role","menuitem"),e.dataset.contourGenerated="1",e.textContent="string"==typeof t?t:t.label||t.title||"",this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}}enhance(){if(this._wiredContextMenu)return;this._wiredContextMenu=!0;const t=t=>{if("function"==typeof this.hidePopover)try{this.hidePopover()}catch(t){}if(this.classList.remove("is-open"),t&&this._ctxOpener&&this._ctxOpener.isConnected&&"function"==typeof this._ctxOpener.focus)try{this._ctxOpener.focus()}catch(t){}this._ctxOpener=null},e=(t,e)=>{if(this._ctxOpener=document.activeElement,"function"==typeof this.showPopover)try{this.showPopover()}catch(t){}else this.classList.add("is-open");if(Number.isFinite(t)&&Number.isFinite(e)){this.style.position="fixed",this.style.left=t+"px",this.style.top=e+"px";const r=this.getBoundingClientRect(),s=window.innerWidth||document.documentElement.clientWidth,i=window.innerHeight||document.documentElement.clientHeight,a=Math.max(8,Math.min(t,Math.max(8,s-r.width-8))),n=Math.max(8,Math.min(e,Math.max(8,i-r.height-8)));this.style.left=a+"px",this.style.top=n+"px"}const r=this.querySelector(".c-menu__item:not([disabled])");if(r&&"function"==typeof r.focus)try{r.focus()}catch(t){}},r=this.getAttribute("trigger");if(r){const t=document.querySelector(r);if(t){t.hasAttribute("aria-haspopup")||t.setAttribute("aria-haspopup","menu");const r=t=>{t.preventDefault(),e(t.clientX,t.clientY)};t.addEventListener("contextmenu",r),onDispose(this,()=>t.removeEventListener("contextmenu",r))}}this.addEventListener("contextmenu",t=>{t.preventDefault(),e(t.clientX,t.clientY)}),this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;r&&this.contains(r)&&(this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{label:r.textContent.trim()}})),t(!1))}),this.addEventListener("keydown",e=>{const r=Array.from(this.querySelectorAll(".c-menu__item"));navKey(e,r,{wrap:!0,onKey:()=>{"Enter"!==e.key&&" "!==e.key||document.activeElement.click()}}),"Escape"===e.key&&(e.preventDefault(),t(!0))})}}define("contour-context-menu",ContourContextMenu);class ContourFab extends ContourBase{static get observed(){return["label","icon"]}static get properties(){return{label:{attribute:"label"},icon:{attribute:"icon"}}}render(){this.classList.add("c-fab"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const t=this.getAttribute("label");t&&this.setAttribute("aria-label",t);const e=this.getAttribute("icon");if(e&&!this.querySelector("svg")){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("aria-hidden","true"),t.setAttribute("viewBox","0 0 24 24");const r=document.createElementNS("http://www.w3.org/2000/svg","use");r.setAttribute("href",e.startsWith("#")?e:"#"+e),t.appendChild(r),this.appendChild(t)}}enhance(){this._wiredFab||(this._wiredFab=!0,this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0}))}),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0})))}))}}define("contour-fab",ContourFab);class ContourCommandPalette extends ContourBase{static get observed(){return["open","items"]}static get properties(){return{open:{attribute:"open",type:Boolean},items:{attribute:"items"}}}attributeChangedCallback(t,e,r){super.attributeChangedCallback(t,e,r),"open"===t&&this.isConnected&&e!==r&&(null!==r?this.show():this.hide())}_recentsKey(){return"contour-command-palette:"+(this.id||"default")+":recents"}_recents(){try{const t=JSON.parse(localStorage.getItem(this._recentsKey())||"[]");return Array.isArray(t)?t:[]}catch(t){return warnBadJson(this,"recents",t),[]}}_remember(t){try{const e=this._recents().filter(e=>e!==t);e.unshift(t),localStorage.setItem(this._recentsKey(),JSON.stringify(e.slice(0,5)))}catch(t){}}_cmdRow(t,e,r){const s=document.createElement("div");return s.className="c-command-palette__item",s.setAttribute("role","option"),s.id=this.id+"-opt-"+(r?"r":"")+e,s.textContent=t,s.dataset.index=String(e),s.dataset.label=t,r&&(s.dataset.recent="true"),s}render(){this.classList.add("c-command-palette"),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-modal")||this.setAttribute("aria-modal","true"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||this.setAttribute("aria-label",labelText(this,"command-palette","Command palette")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("cmd-palette"));const t=this.ensure(".c-command__input",()=>{const t=document.createElement("div");return t.className="c-command__input",t}),e=this.ensure(".c-command__field",()=>{const t=document.createElement("input");return t.className="c-command__field",t.type="search",t.placeholder=labelText(this,"search","Search…"),t.setAttribute("aria-label",labelText(this,"search-commands","Search commands")),t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded","false"),t}),r=this.hasAttribute("open")||this.classList.contains("is-open")||"function"==typeof this.matches&&this.matches(":popover-open");e.setAttribute("aria-expanded",String(r)),t.contains(e)||t.appendChild(e);const s=this.ensure(".c-command-palette__list",()=>{const t=document.createElement("div");return t.className="c-command-palette__list",t.setAttribute("role","listbox"),t});s.hasAttribute("aria-label")||s.hasAttribute("aria-labelledby")||s.setAttribute("aria-label",labelText(this,"commands","Commands")),s.id||(s.id=this.id+"-list"),e.setAttribute("aria-controls",s.id);let i=[];const a=this.getAttribute("items");if(a)try{i=JSON.parse(a)}catch(t){warnBadJson(this,"items",t)}Array.isArray(i)||(i=[]);const n=t=>"string"==typeof t?t:t.label||t.title||"";setHTML(s,"");const o=(this._cmdQuery||"").toLowerCase().trim()?[]:this._recents().filter(t=>i.some(e=>n(e)===t));if(o.length){const t=document.createElement("div");t.className="c-command-palette__group",t.setAttribute("role","presentation"),t.textContent=labelText(this,"recent","Recent"),s.appendChild(t),o.forEach(t=>s.appendChild(this._cmdRow(t,i.findIndex(e=>n(e)===t),!0)))}let l=null;i.forEach((t,e)=>{const r="object"==typeof t&&null!==t&&t.group||null;if(r&&r!==l){const t=document.createElement("div");t.className="c-command-palette__group",t.setAttribute("role","presentation"),t.textContent=r,s.appendChild(t),l=r}s.appendChild(this._cmdRow(n(t),e,!1))}),this._cmdQuery&&(e.value=this._cmdQuery),this._cmdFilter?this._cmdFilter(this._cmdQuery||""):this._cmdSetActive&&this._cmdSetActive(this._cmdCursor||0)}show(){if(this.classList.contains("is-open")||this.matches(":popover-open"))return void(this.hasAttribute("open")||this.setAttribute("open",""));if("function"==typeof this.showPopover)try{this.showPopover()}catch(t){}this.classList.add("is-open"),modalContain(this,!0);const t=this.querySelector(".c-command__field");if(t){t.setAttribute("aria-expanded","true");try{t.focus()}catch(t){}}this.hasAttribute("open")||this.setAttribute("open","")}hide(){if(!(this.classList.contains("is-open")||this.matches(":popover-open")))return void(this.hasAttribute("open")&&this.removeAttribute("open"));if("function"==typeof this.hidePopover)try{this.hidePopover()}catch(t){}this.classList.remove("is-open"),modalContain(this,!1);const t=this.querySelector(".c-command__field");t&&t.setAttribute("aria-expanded","false"),this.hasAttribute("open")&&this.removeAttribute("open")}toggle(){this.classList.contains("is-open")||this.matches(":popover-open")?this.hide():this.show()}enhance(){if(this._cmdSetActive&&this._cmdSetActive(this._cmdCursor||0),this._wiredCmdPalette)return;this._wiredCmdPalette=!0;const t=()=>this.querySelector(".c-command__field"),e=()=>this.querySelector(".c-command-palette__list"),r=()=>Array.from(this.querySelectorAll(".c-command-palette__item")),s=()=>r().filter(t=>!t.hidden),i=e=>{const r=s();if(!r.length)return void(this._cmdCursor=0);this._cmdCursor=Math.max(0,Math.min(e,r.length-1)),r.forEach((t,e)=>t.classList.toggle("is-active",e===this._cmdCursor));const i=r[this._cmdCursor],a=t();a&&i?a.setAttribute("aria-activedescendant",i.id):a&&a.removeAttribute("aria-activedescendant")},a=t=>{const s=(t||"").toLowerCase().trim();r().forEach(t=>{const e=(t.dataset.label||t.textContent||"").toLowerCase();t.hidden=""!==s&&!e.includes(s)}),Array.from(e().querySelectorAll(".c-command-palette__group")).forEach(t=>{let e=t.nextElementSibling,r=!1;for(;e&&!e.classList.contains("c-command-palette__group");)!e.hidden&&e.classList.contains("c-command-palette__item")&&(r=!0),e=e.nextElementSibling;t.hidden=!r});let a=e().querySelector(".c-command-palette__empty");r().some(t=>!t.hidden)?a&&(a.hidden=!0):(a||(a=document.createElement("div"),a.className="c-command-palette__empty",a.setAttribute("role","status"),e().appendChild(a)),a.textContent=labelText(this,"no-matches","No matches"),a.hidden=!1),i(0)},n=t=>{if(!t)return;const e={index:Number(t.dataset.index),label:t.dataset.label||t.textContent};this.value=e,this._remember(e.label),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:e})),this.hide()};this._cmdSetActive=i,this._cmdFilter=a,this.addEventListener("input",e=>{const r=t();r&&e.target===r&&(this._cmdQuery=r.value,a(r.value))}),this.addEventListener("keydown",e=>{const r=t();if(!r||e.target!==r)return;const a=s();if("Escape"===e.key)return e.preventDefault(),void this.hide();a.length&&("ArrowDown"===e.key?(e.preventDefault(),i(this._cmdCursor+1)):"ArrowUp"===e.key?(e.preventDefault(),i(this._cmdCursor-1)):"Home"===e.key?(e.preventDefault(),i(0)):"End"===e.key?(e.preventDefault(),i(a.length-1)):"Enter"===e.key&&(e.preventDefault(),n(a[this._cmdCursor])))}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-command-palette__item"):null;e&&this.contains(e)&&!e.hidden&&n(e)});let o=null;this.addEventListener("beforetoggle",t=>{if("open"===t.newState)o=document.activeElement,this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}));else if(modalContain(this,!1),o&&"function"==typeof o.focus){this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}));try{o.focus()}catch(t){}}}),onDispose(this,()=>{(this.classList.contains("is-open")||this.matches(":popover-open"))&&modalContain(this,!1)}),i(0)}}define("contour-command-palette",ContourCommandPalette);class ContourSideSheet extends ContourBase{static get observed(){return["open","side","title","mode","size"]}static get properties(){return{open:{attribute:"open",type:Boolean},side:{attribute:"side"},title:{attribute:"title"},mode:{attribute:"mode"},size:{attribute:"size"}}}show(){this.setAttribute("open","")}showModal(){this._sheetForceModal=!0,this.show()}close(){this.removeAttribute("open")}get open(){return this.hasAttribute("open")}set open(t){t?this.show():this.close()}_modal(){return this._sheetForceModal||"non-modal"!==(this.getAttribute("mode")||"modal")}render(){this.classList.add("c-side-sheet"),this.setAttribute("role","dialog"),this._modal()?this.setAttribute("aria-modal","true"):this.removeAttribute("aria-modal"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Side sheet");for(const t of Array.from(this.classList))/^c-side-sheet--(start|end|sm|md|lg)$/.test(t)&&this.classList.remove(t);const t="start"===this.getAttribute("side")?"start":"end";this.classList.add("c-side-sheet--"+t);const e=this.getAttribute("size");"sm"!==e&&"md"!==e&&"lg"!==e||this.classList.add("c-side-sheet--"+e),this.hasAttribute("open")?(this.classList.add("is-open"),this.removeAttribute("inert")):(this.classList.remove("is-open"),this.setAttribute("inert",""));const r=this.getAttribute("title");if(r){this.ensure(".c-side-sheet__title",()=>{const t=document.createElement("div");return t.className="c-side-sheet__title",t}).textContent=r}}enhance(){if(this._wiredSideSheet)return;this._wiredSideSheet=!0;let t=null;const e=t=>{if("Escape"===t.key&&this.hasAttribute("open"))return t.preventDefault(),void this.close();if("Tab"===t.key&&this.hasAttribute("open")&&this._modal()){const e=Array.from(this.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter(t=>!t.hasAttribute("disabled"));if(!e.length)return void t.preventDefault();const r=e[0],s=e[e.length-1];t.shiftKey&&document.activeElement===r?(t.preventDefault(),s.focus()):t.shiftKey||document.activeElement!==s||(t.preventDefault(),r.focus())}};document.addEventListener("keydown",e),onDispose(this,()=>document.removeEventListener("keydown",e)),this.addEventListener("click",t=>{t.target===this&&this.close()});let r=!1;const s=()=>{const e=this.hasAttribute("open");if(e&&!r){r=!0,t=document.activeElement,this._modal()&&modalContain(this,!0);const e=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(e)try{e.focus()}catch(t){}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}))}else if(!e&&r){if(r=!1,this._modal()&&modalContain(this,!1),this._sheetForceModal=!1,t&&"function"==typeof t.focus)try{t.focus()}catch(t){}t=null,this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))}},i=new MutationObserver(s);i.observe(this,{attributes:!0,attributeFilter:["open"]}),this.hasAttribute("open")&&s(),onDispose(this,()=>{i.disconnect(),this.hasAttribute("open")&&this._modal()&&modalContain(this,!1)})}}define("contour-side-sheet",ContourSideSheet);class ContourTour extends ContourBase{static get observed(){return["steps","current","open","persist","id"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"},open:{attribute:"open",type:Boolean},persist:{attribute:"persist",type:Boolean}}}_steps(){let t=[];try{const e=this.getAttribute("steps");t=e?JSON.parse(e):[]}catch(e){warnBadJson(this,"steps",e),t=[]}return Array.isArray(t)?t:[]}_current(t){const e=Number(this.getAttribute("current")||0);return Number.isFinite(e)?Math.min(Math.max(0,e),Math.max(0,t-1)):0}_storageKey(){return this.id?"contour-tour:"+this.id:(this.hasAttribute("persist")&&!this._tourWarnedNoId&&(this._tourWarnedNoId=!0,console.warn("[contour-tour] persist requires an id attribute")),null)}_completed(){if(!this.hasAttribute("persist"))return!1;const t=this._storageKey();try{return!!t&&"done"===localStorage.getItem(t)}catch(t){return!1}}_markCompleted(){if(!this.hasAttribute("persist"))return;const t=this._storageKey();try{t&&localStorage.setItem(t,"done")}catch(t){}}show(){this.setAttribute("open","")}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this._markCompleted(),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})))}render(){this.classList.add("c-tour"),this.setAttribute("role","dialog"),this.setAttribute("aria-label",labelText(this,"tour","Tour"));const t=this._steps();this._tourInitialized||(this._tourInitialized=!0,!t.length||this.hasAttribute("open")||this._completed()||this.setAttribute("open",""));const e=this.hasAttribute("open")&&t.length>0;e?this.removeAttribute("hidden"):this.setAttribute("hidden","");const r=this._current(t.length),s=t[r]||{},i=this.ensure(".c-tour__step",()=>{const t=document.createElement("div");return t.className="c-tour__step",t});i.textContent=labelText(this,"step","Step")+" "+(r+1)+" / "+t.length;const a=this.ensure(".c-tour__tip",()=>{const t=document.createElement("div");return t.className="c-tour__tip",t});a.setAttribute("aria-live","polite"),a.textContent="string"==typeof s?s:s.text||s.title||"",i.nextSibling!==a&&this.insertBefore(i,a);const n=this.ensure(".c-tour__nav",()=>{const t=document.createElement("div");return t.className="c-tour__nav c-btn-group",t}),o=this.ensure(".c-tour__back",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-tour__back",t.type="button",t},n);o.textContent=labelText(this,"back","Back"),o.disabled=0===r;const l=this.ensure(".c-tour__next",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-tour__next",t.type="button",t},n);l.textContent=r>=t.length-1?labelText(this,"done","Done"):labelText(this,"next","Next");const c=this.ensure(".c-tour__close",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-tour__close",t.type="button",t},n);c.textContent=labelText(this,"close","Close"),n.firstChild!==o&&n.insertBefore(o,n.firstChild),o.nextSibling!==l&&n.insertBefore(l,o.nextSibling),l.nextSibling!==c&&n.insertBefore(c,l.nextSibling),this._tourTarget&&this._tourTarget.classList&&this._tourTarget.classList.remove("c-tour__target"),this._tourTarget=null;const u=e&&"object"==typeof s&&s?s.target:null;if(u){const t=document.querySelector(u);if(t&&t.classList&&(t.classList.add("c-tour__target"),this._tourTarget=t,"function"==typeof t.scrollIntoView))try{t.scrollIntoView({block:"nearest"})}catch(t){}}e&&this._positionTour(),e?this._tourFocusStep===r&&this._tourOpen||(this._tourFocusStep=r,queueMicrotask(()=>{if(!this.isConnected||!this.hasAttribute("open"))return;const t=this._tourTarget,e=t&&t.isConnected&&"function"==typeof t.focus&&!t.disabled&&t.matches("a[href], button, input, select, textarea, [tabindex]:not([tabindex='-1'])")?t:this.querySelector(".c-tour__next");if(e)try{e.focus({preventScroll:!0})}catch(t){try{e.focus()}catch(t){}}})):this._tourFocusStep=null,this._tourOpen=e}_positionTour(){const t=window.innerWidth,e=window.innerHeight,r=this.offsetWidth||280,s=this.offsetHeight||120,i=this._tourTarget;if(i&&i.getBoundingClientRect){const a=i.getBoundingClientRect();let n=a.bottom+8;n+s>e-8&&(n=Math.max(8,a.top-s-8));const o=Math.min(Math.max(8,a.left),Math.max(8,t-r-8));this.style.insetBlockStart=n+"px",this.style.insetInlineStart=o+"px",this.style.insetBlockEnd="auto",this.style.transform=""}else this.style.insetBlockStart="auto",this.style.insetBlockEnd="1rem",this.style.insetInlineStart="50%",this.style.transform="translateX(-50%)"}enhance(){if(this._wiredTour)return;this._wiredTour=!0;const t=t=>{const e=this._steps();if(!e.length||!this.hasAttribute("open"))return;const r=this._current(e.length);if("next"===t){if(r>=e.length-1)return void this.close();this.setAttribute("current",String(r+1)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:"next",index:r+1}}))}else{if(0===r)return;this.setAttribute("current",String(r-1)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:"prev",index:r-1}}))}};this._tourStep=t,this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target:null;r&&(r.closest(".c-tour__next")?t("next"):r.closest(".c-tour__back")?t("prev"):r.closest(".c-tour__close")&&this.close())});const e=e=>{if(!this.hasAttribute("open"))return;const r=e.target&&e.target.tagName;if("INPUT"===r||"TEXTAREA"===r||"SELECT"===r)return;if("Escape"===e.key)return void this.close();(this.contains(e.target)||this._tourTarget&&(e.target===this._tourTarget||this._tourTarget.contains(e.target)))&&("ArrowRight"===e.key?(e.preventDefault(),t("next")):"ArrowLeft"===e.key&&(e.preventDefault(),t("prev")))};document.addEventListener("keydown",e);const r=()=>{this.hasAttribute("open")&&this._positionTour()};window.addEventListener("scroll",r,{passive:!0,capture:!0}),window.addEventListener("resize",r,{passive:!0}),onDispose(this,()=>{document.removeEventListener("keydown",e),window.removeEventListener("scroll",r,{capture:!0}),window.removeEventListener("resize",r),this._tourTarget&&this._tourTarget.classList&&this._tourTarget.classList.remove("c-tour__target")})}}define("contour-tour",ContourTour);class ContourResponsiveContent extends ContourBase{static get observed(){return["breakpoint"]}static get properties(){return{breakpoint:{attribute:"breakpoint"}}}render(){this.classList.add("c-responsive-content");const t=this.getAttribute("breakpoint")||"md";this.dataset.breakpoint=t}}define("contour-responsive-content",ContourResponsiveContent);class ContourPaletteEditor extends ContourBase{static get observed(){return["colors"]}static get properties(){return{colors:{attribute:"colors"}}}_palette(){let t=[];try{const e=this.getAttribute("colors");t=e?JSON.parse(e):[]}catch(t){warnBadJson(this,"colors",t)}return Array.isArray(t)||(t=[]),t.map(t=>"string"==typeof t?{color:t,name:t}:{color:String(t.color||t.value||"#000000"),name:String(t.name||t.label||t.color||t.value||"color")})}_writePalette(t){this.setAttribute("colors",JSON.stringify(t.map(t=>t.name===t.color?t.color:{color:t.color,name:t.name})))}render(){this.classList.add("c-palette-editor"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"palette-editor","Palette editor"));const t=this._palette();Array.from(this.querySelectorAll(".c-palette-editor__swatch, .c-palette-editor__edit, .c-palette-editor__remove, .c-palette-editor__add, .c-palette-editor__contrast")).forEach(t=>t.remove()),t.forEach((t,e)=>{const r=document.createElement("button");r.className="c-palette-editor__swatch c-swatch"+(this._paletteSelected===e?" is-selected":""),r.type="button",r.style.background=safeColor(t.color),r.dataset.color=t.color,r.dataset.index=String(e),r.setAttribute("aria-label",t.name),r.setAttribute("aria-pressed",String(this._paletteSelected===e)),this.appendChild(r);const s=document.createElement("input");s.type="color",s.className="c-palette-editor__edit",s.value=/^#[0-9a-f]{6}$/i.test(t.color)?t.color:"#000000",s.dataset.index=String(e),s.setAttribute("aria-label",labelText(this,"edit","Edit")+" "+t.name),this.appendChild(s);const i=document.createElement("button");i.type="button",i.className="c-palette-editor__remove",i.dataset.index=String(e),i.setAttribute("aria-label",labelText(this,"remove","Remove")+" "+t.name),i.textContent="×",this.appendChild(i)});const e=document.createElement("button");e.type="button",e.className="c-palette-editor__add",e.setAttribute("aria-label",labelText(this,"add-color","Add color")),e.textContent="+",this.appendChild(e);const r=t[this._paletteSelected];if(r){const t=(t=>{const e=/^#([0-9a-f]{6})$/i.exec(t);if(!e)return null;const r=parseInt(e[1],16),s=[r>>16&255,r>>8&255,255&r].map(t=>(t/=255)<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4));return.2126*s[0]+.7152*s[1]+.0722*s[2]})(r.color),e=document.createElement("span");if(e.className="c-palette-editor__contrast",null===t)e.textContent=r.color;else{const s=(t,e)=>(Math.max(t,e)+.05)/(Math.min(t,e)+.05),i=s(t,1),a=s(t,0),n=Math.max(i,a);e.textContent=r.name+": "+i.toFixed(1)+":1 on white, "+a.toFixed(1)+":1 on black — "+(n>=4.5?"AA":"below AA")}this.appendChild(e)}}enhance(){this._wiredPaletteEditor||(this._wiredPaletteEditor=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target:null;if(!e)return;const r=e.closest(".c-palette-editor__swatch");if(r&&this.contains(r))return this._paletteSelected=Number(r.dataset.index),this.requestRender(),void this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{color:r.dataset.color}}));const s=e.closest(".c-palette-editor__remove");if(s&&this.contains(s)){const t=this._palette(),e=Number(s.dataset.index),[r]=t.splice(e,1);return this._paletteSelected>=t.length&&(this._paletteSelected=t.length-1),this._writePalette(t),void this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{value:r?r.color:""}}))}if(e.closest(".c-palette-editor__add")){const t=this._palette(),e="#888888";t.push({color:e,name:e}),this._paletteSelected=t.length-1,this._writePalette(t),this.dispatchEvent(new CustomEvent("contour:add",{bubbles:!0,composed:!0,detail:{value:e}}))}}),this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-palette-editor__edit"):null;if(!e||!this.contains(e))return;const r=this._palette(),s=Number(e.dataset.index);r[s]&&(r[s].color=e.value,(r[s].name===r[s].color||/^#[0-9a-f]{6}$/i.test(r[s].name))&&(r[s].name=e.value),this._writePalette(r),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{color:e.value,values:r.map(t=>t.color)}})))}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-palette-editor__swatch"));e.includes(t.target)&&navKey(t,e,{wrap:!0,enter:!0,onKey:(t,e,r)=>{"Enter"!==t&&" "!==t||r.click()}})}))}}define("contour-palette-editor",ContourPaletteEditor);class ContourDateRange extends ContourBase{static get observed(){return["start","end","label","time","min","max","locale","name","required","disabled"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},label:{attribute:"label"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"},name:{attribute:"name"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return!0}render(){this.classList.add("c-date-range"),void 0===this._dateRangeDefaultStart&&(this._dateRangeDefaultStart=this.getAttribute("start"),this._dateRangeDefaultEnd=this.getAttribute("end")),this.setAttribute("role","group"),this.setAttribute("aria-label",this.getAttribute("label")||"Date range");const t=this.getAttribute("label");if(t){this.ensure(".c-date-range__label",()=>{const t=document.createElement("span");return t.className="c-date-range__label",t}).textContent=t}const e=this.ensure(".c-date-range__start",()=>{const t=document.createElement("input");return t.className="c-input c-date-range__start",t});e.type=this.hasAttribute("time")?"datetime-local":"date",e.value=this.getAttribute("start")||"",e.setAttribute("aria-label",t?t+" — start":"Start date");const r=this.ensure(".c-date-range__end",()=>{const t=document.createElement("input");return t.className="c-input c-date-range__end",t});r.type=e.type,r.value=this.getAttribute("end")||"",r.setAttribute("aria-label",t?t+" — end":"End date");const s=this.getAttribute("min"),i=this.getAttribute("max");[e,r].forEach(t=>{s?t.min=s:t.removeAttribute("min"),i?t.max=i:t.removeAttribute("max"),this.getAttribute("locale")&&(t.lang=this.getAttribute("locale")),this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled")}),e.value&&(r.min=s&&s>e.value?s:e.value),r.value&&(e.max=i&&i<r.value?i:r.value),this.hasAttribute("required")?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required"),this._internals&&this._syncFormValue()}enhance(){this._wiredDateRange||(this._wiredDateRange=!0,this.addEventListener("change",t=>{const e=t.target;if(e&&(e.classList.contains("c-date-range__start")||e.classList.contains("c-date-range__end"))){const t=this.querySelector(".c-date-range__start"),e=this.querySelector(".c-date-range__end");this.batch(()=>{t&&this.setAttribute("start",t.value),e&&this.setAttribute("end",e.value)}),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{start:t?.value,end:e?.value}}))}}))}_syncFormValue(){if(!this._internals)return;const t=this.querySelector(".c-date-range__start")?.value||"",e=this.querySelector(".c-date-range__end")?.value||"",r=this.getAttribute("name");if(r&&(t||e)){const s=new FormData;t&&s.append(r,t),e&&s.append(r,e),this._internals.setFormValue(s)}else this._internals.setFormValue(null);const s=this.hasAttribute("required")&&(!t||!e),i=!!(t&&e&&t>e);s?this._internals.setValidity({valueMissing:!0},"Both dates are required."):i?this._internals.setValidity({customError:!0},"Start must be on or before end."):this._internals.setValidity({}),this._setCustomState("data-invalid",s||i);for(const t of this.querySelectorAll("input"))t.setAttribute("aria-invalid",String(s||i))}formResetCallback(){this._contourResetting=!0;try{null===this._dateRangeDefaultStart?this.removeAttribute("start"):this.setAttribute("start",this._dateRangeDefaultStart),null===this._dateRangeDefaultEnd?this.removeAttribute("end"):this.setAttribute("end",this._dateRangeDefaultEnd),this._syncFormValue()}finally{this._contourResetting=!1}}formStateRestoreCallback(t){if(!this._internals||null==t)return;const e=t instanceof FormData?Array.from(t.getAll(this.getAttribute("name"))).map(String):String(t).split(",");this._contourResetting=!0;try{this.setAttribute("start",e[0]||""),this.setAttribute("end",e[1]||""),this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-date-range",ContourDateRange);class ContourShortcut extends ContourBase{static get observed(){return["key","label"]}static get properties(){return{key:{attribute:"key"},label:{attribute:"label"}}}render(){this.classList.add("c-shortcut"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Keyboard shortcut");const t=this.getAttribute("key")||"",e=this.getAttribute("label")||"";if(t){this.ensure(".c-shortcut__key",()=>{const t=document.createElement("kbd");return t.className="c-shortcut__key",t}).textContent=t}if(e){this.ensure(".c-shortcut__label",()=>{const t=document.createElement("span");return t.className="c-shortcut__label",t}).textContent=e}}enhance(){if(this._wiredShortcut)return;this._wiredShortcut=!0;const t=t=>{const e=this.getAttribute("key");e&&t.key===e&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0})))};document.addEventListener("keydown",t),onDispose(this,()=>document.removeEventListener("keydown",t))}}define("contour-shortcut",ContourShortcut);class ContourDatePicker extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","range","range-start","range-end","label","disabled","error","help","time","min","max","locale","required","name"]}static get properties(){return{value:{attribute:"value"},range:{attribute:"range",type:Boolean},rangeStart:{attribute:"range-start"},rangeEnd:{attribute:"range-end"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"}}}render(){this.classList.add("c-date-picker"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"date-picker","Date picker"));const t=this.getAttribute("label");if(t){this.ensure(".c-date-picker__label",()=>{const t=document.createElement("label");return t.className="c-date-picker__label",t}).textContent=t}const e=this.keepNode(this.ensure(".c-date-picker__input",()=>{const t=document.createElement("input");return t.className="c-input c-date-picker__input",t})),r=this.hasAttribute("range"),s=this.hasAttribute("time")?"datetime-local":"date",i=(t,e,r)=>{t.type=s;const i=e||"";document.activeElement!==t&&t.value!==i&&(t.value=i),t.setAttribute("aria-label",r),this.hasAttribute("min")?t.min=this.getAttribute("min"):t.removeAttribute("min"),this.hasAttribute("max")?t.max=this.getAttribute("max"):t.removeAttribute("max"),this.hasAttribute("locale")?t.lang=this.getAttribute("locale"):t.removeAttribute("lang"),this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled")};i(e,r?this.getAttribute("range-start"):this.getAttribute("value"),r?"Start date":t||"Date");let a=this.querySelector(".c-date-picker__end");r?(a=this.keepNode(a||document.createElement("input")),a.className="c-input c-date-picker__input c-date-picker__end",i(a,this.getAttribute("range-end"),"End date"),a.parentNode!==this&&this.appendChild(a)):a&&a.remove();const n=this.getAttribute("min"),o=this.getAttribute("max"),l=t=>{if(!n&&!o)return;const e=t.value;if(!e)return;let r=e;n&&r<n&&(r=n),o&&r>o&&(r=o),r!==e&&document.activeElement!==t&&(t.value=r)};l(e),a&&l(a),this.hasAttribute("disabled")?this.classList.add("is-disabled"):this.classList.remove("is-disabled");const c=this.getAttribute("error"),u=this.getAttribute("help");let d=this.querySelector(".c-date-picker__message");c||u?(d||(d=document.createElement("div"),d.className="c-date-picker__message",d.id||(d.id=contourId("c-date-picker-message")),this.appendChild(d)),d.textContent=c||u||"",d.classList.toggle("c-date-picker__message--error",!!c)):d&&d.remove(),c?this.classList.add("is-error"):this.classList.remove("is-error");let h=!!c;this.hasAttribute("range")&&(h=h||this._validateRange());const m=d?d.id:"",b=t=>{h?t.setAttribute("aria-invalid","true"):t.removeAttribute("aria-invalid"),m?t.setAttribute("aria-describedby",m):t.removeAttribute("aria-describedby")};b(e);const p=this.querySelector(".c-date-picker__end");p&&b(p);this.keepNode(this.ensure(".c-date-picker__calendar-toggle",()=>{const t=document.createElement("button");t.className="c-btn c-btn--sm c-date-picker__calendar-toggle",t.type="button",t.setAttribute("aria-label",labelText(this,"open-calendar","Open calendar")),t.setAttribute("aria-expanded","false");const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true");const r=document.createElementNS("http://www.w3.org/2000/svg","use");return r.setAttribute("href","#i-chevron-down"),e.appendChild(r),t.appendChild(e),t}));let g=this.querySelector(".c-date-picker__calendar");g||(g=document.createElement("div"),g.className="c-date-picker__calendar",g.setAttribute("hidden",""),g.setAttribute("role","dialog"),g.setAttribute("aria-label",labelText(this,"calendar","Calendar")),this.appendChild(g)),this.keepNode(g),this._internals&&this._syncFormValue()}_renderCalendar(){const t=this.querySelector(".c-date-picker__calendar");if(!t)return;const e=this.querySelector(".c-date-picker__input"),r=e&&e.value?(t=>{const e=/^(\d{4})-(\d{2})-(\d{2})/.exec(t||"");return e?new Date(Number(e[1]),Number(e[2])-1,Number(e[3])):new Date})(e.value):new Date,s=this._calMonth||new Date(r.getFullYear(),r.getMonth(),1);this._calMonth=s;const i=s.getFullYear(),a=s.getMonth(),n=this.getAttribute("locale")||void 0,o=this._datePickerFirstDayOfWeek(n),l=(new Date(i,a,1).getDay()-o+7)%7,c=new Date(i,a+1,0).getDate();setHTML(t,"");const u=document.createElement("div");u.className="c-date-picker__calendar-header";const d=document.createElement("button");d.type="button",d.className="c-btn c-btn--sm c-btn--icon",setHTML(d,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>'),d.setAttribute("aria-label",labelText(this,"previous-month","Previous month"));const h=document.createElement("span");h.className="c-date-picker__calendar-title",h.textContent=s.toLocaleString(this.getAttribute("locale")||void 0,{month:"long",year:"numeric"});const m=document.createElement("button");m.type="button",m.className="c-btn c-btn--sm c-btn--icon",setHTML(m,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),m.setAttribute("aria-label",labelText(this,"next-month","Next month")),u.appendChild(d),u.appendChild(h),u.appendChild(m),t.appendChild(u);const b=document.createElement("div");b.className="c-date-picker__calendar-grid",b.setAttribute("role","grid"),b.setAttribute("aria-label",h.textContent);const p=()=>{const t=document.createElement("div");return t.className="c-date-picker__calendar-row",t.setAttribute("role","row"),b.appendChild(t),t};let g=p(),_=0;const v=t=>{7===_&&(g=p(),_=0),g.appendChild(t),_++},f=["Su","Mo","Tu","We","Th","Fr","Sa"],y=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];for(let t=0;t<7;t++){const e=(o+t)%7,r=document.createElement("div");r.className="c-date-picker__calendar-weekday",r.setAttribute("role","columnheader");const s=new Date(2026,0,e+1);r.setAttribute("aria-label",s.toLocaleDateString(n,{weekday:"long"})||y[e]),r.textContent=s.toLocaleDateString(n,{weekday:"short"})||f[e],v(r)}for(let t=0;t<l;t++){const t=document.createElement("div");t.className="c-date-picker__calendar-day c-date-picker__calendar-day--empty",t.setAttribute("role","gridcell"),t.setAttribute("aria-hidden","true"),v(t)}const A=e?e.value:"",C=A&&A.slice(0,7)===`${i}-${String(a+1).padStart(2,"0")}`&&parseInt(A.slice(8,10),10)||1,w=this.getAttribute("min"),E=this.getAttribute("max");for(let r=1;r<=c;r++){const s=document.createElement("button");s.type="button",s.className="c-date-picker__calendar-day",s.textContent=String(r),s.setAttribute("role","gridcell"),s.setAttribute("tabindex",r===C?"0":"-1"),s.setAttribute("aria-label",new Date(i,a,r).toLocaleDateString(this.getAttribute("locale")||void 0,{weekday:"long",day:"numeric",month:"long",year:"numeric"}));const n=`${i}-${String(a+1).padStart(2,"0")}-${String(r).padStart(2,"0")}`;A&&A.startsWith(n)&&(s.classList.add("is-selected"),s.setAttribute("aria-selected","true"));const o=w&&n<w||E&&n>E;s.disabled=o,o&&s.setAttribute("aria-disabled","true"),s.setAttribute("tabindex",o?"-1":r===C?"0":"-1"),o?v(s):(s.addEventListener("click",()=>{if(!e)return;if(this.hasAttribute("range")){const t=this.querySelector(".c-date-picker__end");!1!==this._rangeStartNext?(this.setAttribute("range-start",n),this._rangeStartNext=!1):t&&(this.setAttribute("range-end",n),this._rangeStartNext=!0)}else this.setAttribute("value",n);t.setAttribute("hidden","");const r=this.querySelector(".c-date-picker__calendar-toggle");r&&r.setAttribute("aria-expanded","false"),this._validateRange(),this._internals&&this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("value")}}))}),v(s))}t.appendChild(b),d.addEventListener("click",()=>{this._calMonth=new Date(i,a-1,1),this._renderCalendar()}),m.addEventListener("click",()=>{this._calMonth=new Date(i,a+1,1),this._renderCalendar()}),this._internals&&this._syncFormValue()}_syncFormValue(){if(!this._internals)return;const t=this.querySelector(".c-date-picker__input"),e=this.querySelector(".c-date-picker__end");if(this.hasAttribute("range")&&e){const r=t?t.value:"",s=e.value||"",i=this.getAttribute("name");if(i&&(r||s)){const t=new FormData;r&&t.append(i,r),s&&t.append(i,s),this._internals.setFormValue(t)}else this._internals.setFormValue(null)}else this._internals.setFormValue(t&&t.value?t.value:null);this._syncValidity(this.hasAttribute("required")&&!(t&&t.value))}formResetCallback(){const t=()=>{const t=this.querySelector(".c-date-picker__input"),e=this.querySelector(".c-date-picker__end");t&&(t.value=this.getAttribute("range-start")||this.getAttribute("value")||""),e&&(e.value=this.getAttribute("range-end")||""),this._syncFormValue()};t(),"function"==typeof queueMicrotask&&queueMicrotask(t)}_datePickerFirstDayOfWeek(t){return["en-US","en-CA","en-PH","ja-JP","ko-KR","th-TH","ar-SA","he-IL"].includes(String(t||"").toLowerCase())?0:1}_validateRange(){if(!this.hasAttribute("range"))return!1;const t=this.querySelector(".c-date-picker__input"),e=this.querySelector(".c-date-picker__end");if(!t||!e)return!1;const r=!!t.value&&!!e.value&&t.value>e.value;return this.getAttribute("error")||(r?(t.setAttribute("aria-invalid","true"),e.setAttribute("aria-invalid","true")):(t.removeAttribute("aria-invalid"),e.removeAttribute("aria-invalid"))),r}enhance(){if(this._wiredDatePicker)return;this._wiredDatePicker=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;if(e&&e.classList.contains("c-date-picker__input")){const t=this.querySelector(".c-date-picker__end"),r=t?{start:this.querySelector(".c-date-picker__input").value,end:t.value}:{value:e.value};this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:r}))}});const t=()=>{const t=this.querySelector(".c-date-picker__calendar"),e=this.querySelector(".c-date-picker__calendar-toggle");if(!t)return;t.hasAttribute("hidden")?(t.removeAttribute("hidden"),e&&e.setAttribute("aria-expanded","true"),this._renderCalendar()):(t.setAttribute("hidden",""),e&&e.setAttribute("aria-expanded","false"))};this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-date-picker__calendar-toggle"):null;r&&this.contains(r)&&(e.preventDefault(),t());const s=this.querySelector(".c-date-picker__calendar");if(s&&!s.hasAttribute("hidden")&&!s.contains(e.target)&&!r){s.setAttribute("hidden","");const t=this.querySelector(".c-date-picker__calendar-toggle");t&&t.setAttribute("aria-expanded","false")}}),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-date-picker__calendar");if(!e||e.hasAttribute("hidden"))return;if("Escape"===t.key){t.preventDefault(),e.setAttribute("hidden","");const r=this.querySelector(".c-date-picker__calendar-toggle");return void(r&&(r.setAttribute("aria-expanded","false"),r.focus()))}const r=Array.from(e.querySelectorAll('[role="gridcell"]:not([aria-hidden="true"])')),s=r.indexOf(document.activeElement);if(s<0)return;if("PageUp"===t.key||"PageDown"===t.key){t.preventDefault();const e=this.querySelector("PageUp"===t.key?".c-date-picker__calendar-header button:first-child":".c-date-picker__calendar-header button:last-child");return void(e&&e.click())}let i=-1;if("ArrowRight"===t.key)i=s+1;else if("ArrowLeft"===t.key)i=s-1;else if("ArrowDown"===t.key)i=s+7;else if("ArrowUp"===t.key)i=s-7;else if("Home"===t.key)i=0;else{if("End"!==t.key)return;i=r.length-1}t.preventDefault(),i<0||i>=r.length||(r.forEach((t,e)=>t.setAttribute("tabindex",e===i?"0":"-1")),r[i].focus())})}}define("contour-date-picker",ContourDatePicker);class ContourRating extends ContourBase{static get observed(){return["value","max","color","readonly","disabled","name"]}static get properties(){return{value:{attribute:"value",type:Number},max:{attribute:"max",type:Number},color:{attribute:"color"},readonly:{attribute:"readonly",type:Boolean},disabled:{attribute:"disabled",type:Boolean},name:{attribute:"name"}}}static get formAssociated(){return!0}render(){this.classList.add("c-rating"),this.hasAttribute("role")||this.setAttribute("role","radiogroup"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"rating","Rating"));const t=parseInt(this.getAttribute("max")||"5",10)||5,e=parseInt(this.getAttribute("value")||"0",10)||0,r=this.getAttribute("color"),s=flagOn(this,"readonly"),i=flagOn(this,"disabled");Array.from(this.querySelectorAll(".c-rating__star")).forEach(t=>t.remove());const a=e>=1&&e<=t?e:1;for(let n=1;n<=t;n++){const t=document.createElement("button");if(t.className="c-rating__star"+(n<=e?" c-rating__star--filled":""),t.type="button",t.setAttribute("role","radio"),t.setAttribute("aria-checked",String(n===e)),t.setAttribute("aria-label",n+(1===n?" star":" stars")),t.setAttribute("tabindex",String(n===a?0:-1)),(s||i)&&(t.setAttribute("aria-disabled","true"),t.disabled=!0,t.tabIndex=-1),setHTML(t,'<span class="c-rating__swatch'+(n<=e?" c-rating__swatch--filled":"")+'" aria-hidden="true"></span>'),r&&n<=e){const e=t.firstChild,s=safeColor(r);e&&s&&(e.style.backgroundColor=s,e.style.borderColor=s)}t.dataset.value=String(n),t.setAttribute("aria-label",n+" star"+(n>1?"s":"")),this.appendChild(t)}this._internals&&this._syncFormValue()}_syncFormValue(){if(!this._internals)return;const t=this.getAttribute("name"),e=this.getAttribute("value");t&&e?this._internals.setFormValue(e):this._internals.setFormValue(null)}enhance(){if(this._wiredRating)return;this._wiredRating=!0;const t=()=>Array.from(this.querySelectorAll(".c-rating__star")),e=e=>{flagOn(this,"readonly")||flagOn(this,"disabled")||(t().forEach(t=>{const r=parseInt(t.dataset.value,10)===e;t.setAttribute("aria-checked",String(r)),t.setAttribute("tabindex",r?"0":"-1"),t.classList.toggle("c-rating__star--filled",parseInt(t.dataset.value,10)<=e);const s=t.querySelector(".c-rating__swatch");s&&s.classList.toggle("c-rating__swatch--filled",parseInt(t.dataset.value,10)<=e)}),this.setAttribute("value",String(e)),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e}})))};this.addEventListener("click",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-rating__star"):null;r&&this.contains(r)&&e(parseInt(r.dataset.value,10))}),this.addEventListener("keydown",r=>{const s=t();s.length&&navKey(r,s,{wrap:!1,homeEnd:!0,onNavigate:t=>{e(parseInt(s[t].dataset.value,10))},onKey:(t,r)=>{"Enter"!==t&&" "!==t||e(parseInt(s[r].dataset.value,10))}})})}}define("contour-rating",ContourRating);class ContourTimePicker extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-time-picker"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"time-picker","Time picker"));const t=this.getAttribute("label");if(t){this.ensure(".c-time-picker__label",()=>{const t=document.createElement("label");return t.className="c-time-picker__label",t}).textContent=t}const e=this.ensure(".c-time-picker__input",()=>{const t=document.createElement("input");return t.className="c-input c-time-picker__input",t.type="time",t.setAttribute("aria-label",this.getAttribute("label")||"Time picker"),t});e.value=this.getAttribute("value")||"",this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled"));const r=this.getAttribute("error"),s=this.getAttribute("help");let i=this.querySelector(".c-time-picker__message");r||s?(i||(i=document.createElement("div"),i.className="c-time-picker__message",i.id||(i.id=contourId("c-time-picker-message")),this.appendChild(i)),i.textContent=r||s||"",i.classList.toggle("c-time-picker__message--error",!!r)):i&&i.remove(),r?this.classList.add("is-error"):this.classList.remove("is-error");const a=i?i.id:"";r?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"),a?e.setAttribute("aria-describedby",a):e.removeAttribute("aria-describedby"),this._internals&&this._syncFormValue()}enhance(){this._wiredTimePicker||(this._wiredTimePicker=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-time-picker__input")&&this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}))}}define("contour-time-picker",ContourTimePicker);class ContourColorPicker extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","label","disabled","required","error","help","alpha","presets"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},required:{attribute:"required",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},alpha:{attribute:"alpha",type:Boolean},presets:{attribute:"presets"}}}render(){this.classList.add("c-color-picker"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"color-picker","Color picker"));const t=this.getAttribute("label");if(t){this.ensure(".c-color-picker__label",()=>{const t=document.createElement("label");return t.className="c-color-picker__label",t}).textContent=t}const e=this.ensure(".c-color-picker__input",()=>{const t=document.createElement("input");return t.className="c-color-picker__input",t.type="color",t}),r=this.getAttribute("value")||"",s=/^#?[0-9a-f]{6}([0-9a-f]{2})?$/i.test(r);if(s?(e.value=r.slice(0,7),this.removeAttribute("data-empty")):(e.value="",this.setAttribute("data-empty","")),e.hasAttribute("aria-label")||e.setAttribute("aria-label",t||"Color"),this.hasAttribute("required")?e.setAttribute("required",""):e.removeAttribute("required"),this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled")),this.hasAttribute("alpha")){const t=this.ensure(".c-color-picker__alpha",()=>{const t=document.createElement("input");return t.className="c-color-picker__alpha",t.type="range",t.min="0",t.max="1",t.step="0.01",t}),e=s&&9===r.length?parseInt(r.slice(7,9),16)/255:1;t.value=String(e),t.setAttribute("aria-label",labelText(this,"alpha","Alpha"))}else{const t=this.querySelector(".c-color-picker__alpha");t&&t.remove()}const i=this.getAttribute("presets");let a=[];if(i)try{a=JSON.parse(i)}catch(t){warnBadJson(this,"presets",t),a=[]}const n=this.querySelector(".c-color-picker__presets");if(n&&n.remove(),Array.isArray(a)&&a.length){const t=document.createElement("div");t.className="c-color-picker__presets",a.forEach(e=>{const r=document.createElement("button");r.type="button",r.className="c-color-picker__preset";const s=safeColor(e);s&&(r.style.background=s,r.dataset.color=s,r.setAttribute("aria-label",labelText(this,"preset","Preset")+" "+e),t.appendChild(r))}),this.appendChild(t)}if("undefined"!=typeof window&&"EyeDropper"in window){const t=this.ensure(".c-color-picker__eyedropper",()=>{const t=document.createElement("button");return t.className="c-color-picker__eyedropper",t.type="button",t.textContent=labelText(this,"pick","Pick"),t.setAttribute("aria-label",labelText(this,"pick-color","Pick color from screen")),t});this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled")}else{const t=this.querySelector(".c-color-picker__eyedropper");t&&t.remove()}const o=this.getAttribute("error"),l=this.getAttribute("help");let c=this.querySelector(".c-color-picker__message");o||l?(c||(c=document.createElement("div"),c.className="c-color-picker__message",c.id||(c.id=contourId("c-color-picker-message")),this.appendChild(c)),c.textContent=o||l||"",c.classList.toggle("c-color-picker__message--error",!!o)):c&&c.remove(),o?this.classList.add("is-error"):this.classList.remove("is-error");const u=c?c.id:"";o?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"),u?e.setAttribute("aria-describedby",u):e.removeAttribute("aria-describedby"),this._internals&&this._syncFormValue()}enhance(){this._wiredColorPicker||(this._wiredColorPicker=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("contour:change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;if(e&&e.classList.contains("c-color-picker__input")){const t=this.getAttribute("value")||"",r=9===t.length?t.slice(7,9):"",s=e.value.slice(0,7)+r;this.setAttribute("value",s),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:s}}))}if(e&&e.classList.contains("c-color-picker__alpha")){const t=(this.getAttribute("value")||"#000000").slice(0,7)+Math.round(255*parseFloat(e.value)).toString(16).padStart(2,"0");this.setAttribute("value",t),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t}}))}}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-color-picker__preset"):null;if(e&&this.contains(e)){const t=e.dataset.color;if(t){this.setAttribute("value",t);const e=this.querySelector(".c-color-picker__input");e&&(e.value=t.slice(0,7)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t}}))}}const r=t.target&&t.target.closest?t.target.closest(".c-color-picker__eyedropper"):null;if(r&&this.contains(r)&&"undefined"!=typeof window&&"EyeDropper"in window){t.preventDefault();(new window.EyeDropper).open().then(t=>{if(t&&t.sRGBHex){this.setAttribute("value",t.sRGBHex);const e=this.querySelector(".c-color-picker__input");e&&(e.value=t.sRGBHex),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t.sRGBHex}}))}}).catch(()=>{})}}))}}define("contour-color-picker",ContourColorPicker);class ContourNumberField extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","min","max","step","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},step:{attribute:"step"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-number-field");const t=this.getAttribute("label");if(t){this.ensure(".c-number-field__label",()=>{const t=document.createElement("label");return t.className="c-number-field__label",t}).textContent=t}const e=this.ensure(".c-number-field__input",()=>{const t=document.createElement("input");return t.className="c-input c-number-field__input",t.type="number",t.setAttribute("role","spinbutton"),t});e.id||(e.id=contourId("nf-input"));const r=this.querySelector(".c-number-field__label");r&&r.setAttribute("for",e.id),null!==this.getAttribute("value")&&(e.value=this.getAttribute("value")),null!==this.getAttribute("min")&&(e.min=this.getAttribute("min")),null!==this.getAttribute("max")&&(e.max=this.getAttribute("max")),null!==this.getAttribute("step")&&(e.step=this.getAttribute("step"));const s=e.value;e.setAttribute("aria-valuenow",""===s?"":s),""!==e.min&&e.setAttribute("aria-valuemin",e.min),""!==e.max&&e.setAttribute("aria-valuemax",e.max),e.hasAttribute("aria-label")||e.setAttribute("aria-label",t||"Number"),this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled"));const i=this.getAttribute("error"),a=this.getAttribute("help");let n=this.querySelector(".c-number-field__message");i||a?(n||(n=document.createElement("div"),n.className="c-number-field__message",this.appendChild(n)),n.id||(n.id=contourId("nf-msg")),n.textContent=i||a||"",n.classList.toggle("c-number-field__message--error",!!i),i?n.setAttribute("role","alert"):n.removeAttribute("role"),e.setAttribute("aria-describedby",n.id)):(n&&n.remove(),e.removeAttribute("aria-describedby")),i?(this.classList.add("is-error"),e.setAttribute("aria-invalid","true")):(this.classList.remove("is-error"),e.removeAttribute("aria-invalid")),this._internals&&this._syncFormValue()}enhance(){this._wiredNumberField||(this._wiredNumberField=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-number-field__input")&&this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-number-field__input");if(!e||document.activeElement!==e)return;const r=Number(e.step)||1,s=""===e.min?-1/0:Number(e.min),i=""===e.max?1/0:Number(e.max);let a=null;"ArrowUp"===t.key?a=(Number(e.value)||0)+r:"ArrowDown"===t.key?a=(Number(e.value)||0)-r:"Home"===t.key?a=s===-1/0?0:s:"End"===t.key&&(a=i===1/0?Number(e.value)||0:i),null!==a&&(t.preventDefault(),a=Math.min(i,Math.max(s,a)),e.value=String(a),e.setAttribute("aria-valuenow",String(a)),this.setAttribute("value",String(a)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e.value}})))}))}}define("contour-number-field",ContourNumberField);class ContourFileUpload extends ContourBase{static get formAssociated(){return!0}static get observed(){return["label","accept","multiple","progress","name"]}static get properties(){return{label:{attribute:"label"},accept:{attribute:"accept"},multiple:{attribute:"multiple",type:Boolean},progress:{attribute:"progress"},name:{attribute:"name"}}}render(){this.classList.add("c-file-upload"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"File upload");const t=this.getAttribute("label")||"Drop files here or click to browse";this.ensure(".c-file-upload__dropzone",()=>{const t=document.createElement("div");return t.className="c-file-upload__dropzone",t.setAttribute("role","button"),t.tabIndex=0,t}).textContent=t;const e=this.ensure(".c-file-upload__input",()=>{const t=document.createElement("input");return t.className="c-file-upload__input",t.type="file",t.hidden=!0,t});this.keepNode(e),e.accept=this.getAttribute("accept")||"",e.multiple=this.hasAttribute("multiple");const r=this.getAttribute("progress");if(null!==r){const t=this.ensure(".c-file-upload__progress",()=>{const t=document.createElement("progress");return t.className="c-file-upload__progress",t});t.value=Number(r)||0,t.max=100}else{const t=this.querySelector(".c-file-upload__progress");t&&t.remove()}this.ensure(".c-file-upload__preview",()=>{const t=document.createElement("div");return t.className="c-file-upload__preview",t});this._internals&&this._syncFormValue()}enhance(){if(this._wiredFileUpload)return;this._wiredFileUpload=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()});const t=()=>this.querySelector(".c-file-upload__dropzone"),e=()=>this.querySelector(".c-file-upload__input"),r=()=>{const t=e();t&&t.click()},s=(t,e)=>{try{const r=new DataTransfer;Array.from(e||[]).forEach(t=>r.items.add(t)),t.files=r.files}catch(t){}};this.addEventListener("click",e=>{const s=t();(e.target===s||s&&s.contains(e.target))&&r()}),this.addEventListener("keydown",e=>{const s=t();!(e.target===s||s&&s.contains(e.target))||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r())});const i=t=>{const e=this.querySelector(".c-file-upload__preview");e&&(this._revokeObjectUrls(),setHTML(e,""),Array.from(t||[]).forEach(t=>{const r=document.createElement("div");if(r.className="c-file-upload__preview-item",t.type&&t.type.startsWith("image/")){const e=document.createElement("img");e.className="c-file-upload__preview-thumb",e.alt=t.name,e.loading="lazy",e.decoding="async";try{const r=URL.createObjectURL(t);e.src=r,(this._objectUrls||(this._objectUrls=[])).push(r)}catch(t){}r.appendChild(e)}else{const e=document.createElement("span");e.className="c-file-upload__preview-name",e.textContent=t.name,r.appendChild(e)}e.appendChild(r)}))};this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-file-upload__input")&&(i(e.files),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{files:e.files}})))}),this.addEventListener("dragover",t=>{t.preventDefault(),this.classList.add("is-dragover")}),this.addEventListener("dragleave",()=>this.classList.remove("is-dragover")),this.addEventListener("drop",t=>{t.preventDefault(),this.classList.remove("is-dragover");const r=e();if(r&&t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length){const e=this.getAttribute("accept");if(e){const a=e.split(",").map(t=>t.trim().toLowerCase()),n=Array.from(t.dataTransfer.files).filter(t=>{const e=t.name.toLowerCase();return a.some(r=>r.startsWith(".")?e.endsWith(r):r.endsWith("/*")?t.type.toLowerCase().startsWith(r.slice(0,-1)):t.type.toLowerCase()===r)});if(0===n.length)return;s(r,n),i(n),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{files:n}}))}else s(r,t.dataTransfer.files),i(t.dataTransfer.files),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{files:t.dataTransfer.files}}))}})}disconnectedCallback(){super.disconnectedCallback(),this._revokeObjectUrls()}_revokeObjectUrls(){this._objectUrls&&(this._objectUrls.forEach(t=>{try{URL.revokeObjectURL(t)}catch(t){}}),this._objectUrls=[])}_syncFormValue(){if(!this._internals)return;const t=this.querySelector(".c-file-upload__input");if(t&&t.files&&t.files.length){const e=new FormData,r=this.getAttribute("name")||"file";Array.from(t.files).forEach(t=>e.append(r,t)),this._internals.setFormValue(e)}else this._internals.setFormValue(null)}}define("contour-file-upload",ContourFileUpload);class ContourTagsInput extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","placeholder","disabled","error","help","required","max"]}static get properties(){return{value:{attribute:"value"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},required:{attribute:"required",type:Boolean},max:{attribute:"max"}}}render(){this.classList.add("c-tags-input"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"tags-input","Tags input"));const t=this.ensure(".c-tags-input__input",()=>{const t=document.createElement("input");return t.className="c-input c-tags-input__input",t.type="text",t.setAttribute("aria-label",labelText(this,"add-tag","Add tag")),t});t.placeholder=this.getAttribute("placeholder")||"Add tag…",this.hasAttribute("disabled")?(t.setAttribute("disabled",""),this.classList.add("is-disabled")):(t.removeAttribute("disabled"),this.classList.remove("is-disabled"));const e=this.getAttribute("error"),r=this.getAttribute("help");let s=this.querySelector(".c-tags-input__message");e||r?(s||(s=document.createElement("div"),s.className="c-tags-input__message",this.appendChild(s)),s.id||(s.id=contourId("ti-msg")),s.textContent=e||r||"",s.classList.toggle("c-tags-input__message--error",!!e),e?s.setAttribute("role","alert"):s.removeAttribute("role"),t.setAttribute("aria-describedby",s.id)):(s&&s.remove(),t.removeAttribute("aria-describedby")),e?(this.classList.add("is-error"),t.setAttribute("aria-invalid","true")):(this.classList.remove("is-error"),t.removeAttribute("aria-invalid"));const i=this.getAttribute("value");let a=[];try{a=i?JSON.parse(i):[]}catch(t){a=i?i.split(",").map(t=>t.trim()).filter(Boolean):[]}Array.from(this.querySelectorAll(".c-tags-input__tag")).forEach(t=>t.remove()),a.forEach(e=>{const r=document.createElement("span");r.className="c-tag c-tags-input__tag",r.textContent=e;const s=document.createElement("button");s.className="c-tags-input__remove",s.type="button",s.textContent="×",s.setAttribute("aria-label",labelText(this,"remove","Remove")+" "+e),s.dataset.value=e,r.appendChild(s),this.insertBefore(r,t)}),this._internals&&this._syncFormValue()}enhance(){if(this._wiredTagsInput)return;this._wiredTagsInput=!0,this._syncFormValue(),this.addEventListener("contour:add",()=>{this._syncFormValue()}),this.addEventListener("contour:remove",()=>{this._syncFormValue()});const t=t=>{let e=this.querySelector(".c-tags-input__live");e||(e=document.createElement("span"),e.className="c-tags-input__live visually-hidden",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.appendChild(e)),e.textContent=t},e=()=>{const t=this.getAttribute("value")||"";let e=[];try{e=JSON.parse(t)}catch(r){e=t.split(",").map(t=>t.trim()).filter(Boolean)}return Array.isArray(e)?e.map(String):[]},r=r=>{if(this.hasAttribute("disabled"))return;const s=e(),i=Number(this.getAttribute("max")),a=[],n=[];let o=!1;for(const t of r){const e=String(t).trim();if(e)if(s.includes(e))n.push(e);else{if(Number.isFinite(i)&&i>0&&s.length>=i){o=!0;break}s.push(e),a.push(e)}}if(a.length){this.setAttribute("value",JSON.stringify(s));for(const t of a)this.dispatchEvent(new CustomEvent("contour:add",{bubbles:!0,composed:!0,detail:{value:t}}))}const l=[];a.length&&l.push("Added "+a.join(", ")),n.length&&l.push(n.join(", ")+" already added"),o&&l.push("Tag limit reached ("+i+")"),l.length&&t(l.join(". "))};this.addEventListener("keydown",s=>{const i=this.querySelector(".c-tags-input__input");if(i&&!this.hasAttribute("disabled"))if("Enter"===s.key&&s.target===i){s.preventDefault();const t=i.value;i.value="",r([t])}else if("Backspace"===s.key&&s.target===i&&""===i.value){const r=e();if(r.length){const e=r.pop();this.setAttribute("value",JSON.stringify(r)),t("Removed "+e),this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{value:e}}))}}}),this.addEventListener("input",t=>{const e=this.querySelector(".c-tags-input__input");if(e&&t.target===e&&!this.hasAttribute("disabled")&&e.value.includes(",")){const t=e.value.split(",");e.value=t.pop(),r(t)}}),this.addEventListener("paste",t=>{const e=this.querySelector(".c-tags-input__input");if(!e||t.target!==e||this.hasAttribute("disabled"))return;const s=t.clipboardData&&t.clipboardData.getData("text/plain");s&&/[,;\n]/.test(s)&&(t.preventDefault(),r(s.split(/[,;\n]+/)))}),this.addEventListener("click",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-tags-input__remove"):null;if(s&&this.contains(s)&&!this.hasAttribute("disabled")){const r=s.dataset.value,i=e().filter(t=>t!==r);this.setAttribute("value",JSON.stringify(i)),t("Removed "+r),this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{value:r}}))}})}_syncFormValue(){if(!this._internals)return;this._internals.setFormValue(this.getAttribute("value")||"[]");let t=0;try{const e=JSON.parse(this.getAttribute("value")||"[]");t=Array.isArray(e)?e.length:0}catch(e){t=(this.getAttribute("value")||"").split(",").filter(t=>t.trim()).length}this._syncValidity(this.hasAttribute("required")&&0===t)}}define("contour-tags-input",ContourTagsInput);class ContourSwatch extends ContourBase{static get observed(){return["color","selected","label"]}static get properties(){return{color:{attribute:"color"},selected:{attribute:"selected",type:Boolean},label:{attribute:"label"}}}render(){this.classList.add("c-swatch"),this.hasAttribute("role")||this.setAttribute("role","button"),"button"!==this.getAttribute("role")||this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||this.getAttribute("color")||"Swatch");const t=safeColor(this.getAttribute("color"))||"var(--color-surface-3)";if(this.style.setProperty("--swatch-color",t),this.hasAttribute("selected")?this.classList.add("is-selected"):this.classList.remove("is-selected"),"button"===this.getAttribute("role")&&this.setAttribute("aria-pressed",String(this.hasAttribute("selected"))),!this.hasAttribute("aria-label")){const e=this.getAttribute("label")||t;this.setAttribute("aria-label",e)}if(!this.querySelector("button")&&!this.querySelector("span")){const t=document.createElement("span");t.className="c-swatch__btn",t.setAttribute("aria-hidden","true"),this.appendChild(t)}}enhance(){this._wiredSwatch||(this._wiredSwatch=!0,this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("color")}}))}),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("color")}})))}))}}define("contour-swatch",ContourSwatch);class ContourCalendar extends ContourBase{static get observed(){return["value","month","year","range","start","end"]}static get properties(){return{value:{attribute:"value"},month:{attribute:"month"},year:{attribute:"year"},range:{attribute:"range",type:Boolean},start:{attribute:"start"},end:{attribute:"end"}}}_attrNum(t,e){const r=this.getAttribute(t),s=Number(r);return null!==r&&Number.isFinite(s)?s:e}_ym(){const t=new Date;return{year:this._attrNum("year",t.getFullYear()),month:this._attrNum("month",t.getMonth())}}render(){this.classList.add("c-calendar");const t=new Date,{year:e,month:r}=this._ym(),s=this.ensure(".c-calendar__header",()=>{const t=document.createElement("div");return t.className="c-calendar__header",t});setHTML(s,"");const i=(t,e,r)=>{const s=document.createElement("button");return s.type="button",s.className="c-btn c-btn--sm "+t,s.textContent=e,s.setAttribute("aria-label",r),s},a=i("c-calendar__prev-year","","Previous year");setHTML(a,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevrons-left" /></svg>');const n=i("c-calendar__prev","","Previous month");setHTML(n,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>');const o=document.createElement("span");o.className="c-calendar__title",o.textContent=new Date(e,r,1).toLocaleString(void 0,{month:"long",year:"numeric"});const l=i("c-calendar__next","","Next month");setHTML(l,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>');const c=i("c-calendar__next-year","","Next year");setHTML(c,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevrons-right" /></svg>'),s.append(a,n,o,l,c);const u=this.ensure(".c-calendar__grid",()=>{const t=document.createElement("div");return t.className="c-calendar__grid",t.setAttribute("role","grid"),t});u.setAttribute("aria-label",o.textContent),setHTML(u,"");const d=new Date(e,r,1).getDay(),h=new Date(e,r+1,0).getDate(),m=this.hasAttribute("range"),b=this.getAttribute("value"),p=this.getAttribute("start"),g=this.getAttribute("end");let _=null,v=0;const f=()=>{_=document.createElement("div"),_.className="c-calendar__row",_.setAttribute("role","row"),u.appendChild(_),v=0},y=new Intl.DateTimeFormat(void 0,{weekday:"short"});f();for(let t=0;t<7;t++){const e=document.createElement("div");e.className="c-calendar__weekday",e.setAttribute("role","columnheader"),e.textContent=y.format(new Date(2023,0,1+t)),_.appendChild(e)}f();for(let t=0;t<d;t++){const t=document.createElement("div");t.className="c-calendar__day c-calendar__day--empty",_.appendChild(t),v++,7===v&&f()}const A=t.getFullYear()+"-"+String(t.getMonth()+1).padStart(2,"0")+"-"+String(t.getDate()).padStart(2,"0"),C=b&&b.startsWith(e+"-"+String(r+1).padStart(2,"0"))?b:A.startsWith(e+"-"+String(r+1).padStart(2,"0"))?A:e+"-"+String(r+1).padStart(2,"0")+"-01";for(let t=1;t<=h;t++){const s=document.createElement("button");s.className="c-calendar__day",s.type="button",s.setAttribute("role","gridcell"),s.textContent=String(t);const i=e+"-"+String(r+1).padStart(2,"0")+"-"+String(t).padStart(2,"0"),a=m?i===p||i===g:i===b;a&&s.classList.add("is-selected"),m&&p&&g&&i>p&&i<g&&s.classList.add("is-in-range"),s.setAttribute("aria-selected",String(a)),i===A&&s.setAttribute("aria-current","date"),s.setAttribute("tabindex",i===C?"0":"-1"),s.dataset.value=i,_.appendChild(s),v++,7===v&&f()}s.parentNode!==this&&this.insertBefore(s,u)}enhance(){if(this._wiredCalendar)return;this._wiredCalendar=!0;const t=(t,e)=>{this.batch(()=>{this.setAttribute("month",String(t)),this.setAttribute("year",String(e))}),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{month:t,year:e}}))},e=t=>{const e=this.querySelector('.c-calendar__day[data-value="'+t+'"]');if(e)try{e.focus()}catch(t){}};this.addEventListener("focusin",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(e&&this.contains(e)){for(const t of this.querySelectorAll(".c-calendar__day"))t.tabIndex=-1;e.tabIndex=0}}),this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target:null;if(!r)return;const{year:s,month:i}=this._ym();if(r.closest(".c-calendar__prev")){const e=new Date(s,i-1,1);return void t(e.getMonth(),e.getFullYear())}if(r.closest(".c-calendar__next")){const e=new Date(s,i+1,1);return void t(e.getMonth(),e.getFullYear())}if(r.closest(".c-calendar__prev-year"))return void t(i,s-1);if(r.closest(".c-calendar__next-year"))return void t(i,s+1);const a=r.closest(".c-calendar__day");if(a&&this.contains(a)&&a.dataset.value){const t=a.dataset.value;if(this.hasAttribute("range")){const e=this.getAttribute("start"),r=this.getAttribute("end");let s,i;!e||e&&r?(s=t,i=null):(s=t<e?t:e,i=t<e?e:t),this.batch(()=>{this.setAttribute("start",s),null===i?this.removeAttribute("end"):this.setAttribute("end",i)}),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:t,range:i?[s,i]:[s]}}))}else this.setAttribute("value",t),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:t}}))}}),this.addEventListener("keydown",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(!s||!this.contains(s)||!s.dataset.value)return;const[i,a,n]=s.dataset.value.split("-").map(Number),{year:o,month:l}=(new Date(i,a-1,n),this._ym()),c=new Date(o,l+1,0).getDate();let u=null;if("ArrowRight"===r.key)u=new Date(i,a-1,n+1);else if("ArrowLeft"===r.key)u=new Date(i,a-1,n-1);else if("ArrowDown"===r.key)u=new Date(i,a-1,n+7);else if("ArrowUp"===r.key)u=new Date(i,a-1,n-7);else if("PageUp"===r.key)u=r.shiftKey?new Date(i-1,a-1,Math.min(n,new Date(i-1,a,0).getDate())):new Date(i,a-2,Math.min(n,new Date(i,a-1,0).getDate()));else if("PageDown"===r.key)u=r.shiftKey?new Date(i+1,a-1,Math.min(n,new Date(i+1,a,0).getDate())):new Date(i,a,Math.min(n,new Date(i,a+1,0).getDate()));else if("Home"===r.key)u=new Date(o,l,1);else{if("End"!==r.key)return;u=new Date(o,l,c)}r.preventDefault();const d=(h=u).getFullYear()+"-"+String(h.getMonth()+1).padStart(2,"0")+"-"+String(h.getDate()).padStart(2,"0");var h;u.getFullYear()===o&&u.getMonth()===l||t(u.getMonth(),u.getFullYear()),e(d)})}}define("contour-calendar",ContourCalendar);class ContourNotificationCenter extends ContourBase{static get observed(){return["count","items","color"]}static get properties(){return{count:{attribute:"count"},items:{attribute:"items"},color:{attribute:"color"}}}render(){this.classList.add("c-notification-center"),this.setAttribute("role","group");const t=this.ensure(".c-notification-center__trigger",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-notification-center__trigger",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-bell" /></svg><span class="c-notification-center__bullet" aria-hidden="true"></span>'),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-label",labelText(this,"notifications","Notifications")),t}),e=this.getAttribute("color"),r=t.querySelector(".c-notification-center__bullet");r&&e&&(r.style.background=safeColor(e),r.dataset.color=e);const s=this.ensure(".c-notification-center__panel",()=>{const t=document.createElement("div");return t.className="c-notification-center__panel",t.hidden=!0,t.setAttribute("role","dialog"),t.setAttribute("aria-label",labelText(this,"notifications","Notifications")),t});s.hidden=!this._notifOpen,t.setAttribute("aria-expanded",String(!!this._notifOpen));const i=Array.from(this.querySelectorAll(":scope > .c-notification-center__item")),a=this.getAttribute("items");if(i.length){setHTML(s,"");const t=document.createElement("div");t.setAttribute("role","list"),t.setAttribute("aria-label",labelText(this,"notifications","Notifications")),this._notifAuthored||(this._notifAuthored=[]),i.forEach(e=>{t.appendChild(e),this._notifAuthored.push(e)}),s.appendChild(t)}else if(a){let t=null;try{t=JSON.parse(a)}catch(t){warnBadJson(this,"items",t)}if(setHTML(s,""),Array.isArray(t)){const e=document.createElement("div");e.setAttribute("role","list"),e.setAttribute("aria-label",labelText(this,"notifications","Notifications"));const r=this._notifShown||50;t.slice(0,r).forEach(t=>{const r=document.createElement("div");r.className="c-notification-center__item"+(t&&t.read?" is-read":""),r.setAttribute("tabindex","-1"),r.setAttribute("role","listitem"),t&&t.current&&r.setAttribute("aria-current","true"),r.dataset.read=t&&t.read?"true":"false";const s=document.createElement("span");s.className="c-notification-center__item-label",s.textContent="string"==typeof t?t:t.text||t.title||"",r.appendChild(s);const i=document.createElement("button");i.type="button",i.className="c-notification-center__archive",i.setAttribute("aria-label",labelText(this,"archive","Archive notification")),i.textContent="⤓",i.tabIndex=-1,r.appendChild(i);const a=document.createElement("button");a.type="button",a.className="c-notification-center__dismiss",a.setAttribute("aria-label",labelText(this,"dismiss","Dismiss notification")),a.textContent="×",a.tabIndex=-1,r.appendChild(a),e.appendChild(r)});const i=e.querySelector(".c-notification-center__item");if(i&&(i.tabIndex=0),s.appendChild(e),t.length){if(t.length>r){const e=document.createElement("button");e.type="button",e.className="c-btn c-btn--sm c-notification-center__more",e.textContent=labelText(this,"more","Show more")+" ("+(t.length-r)+")",s.appendChild(e)}}else{const t=document.createElement("div");t.className="c-notification-center__empty",t.textContent=labelText(this,"empty","No notifications"),s.appendChild(t)}}else{const t=document.createElement("div");t.className="c-notification-center__error",t.setAttribute("role","alert"),t.textContent=labelText(this,"error","Could not load notifications"),s.appendChild(t)}}this._syncNotifBadge()}_syncNotifBadge(){const t=this.querySelector(".c-notification-center__trigger");if(!t)return;const e=Array.from(this.querySelectorAll(".c-notification-center__item"));let r;r=this._notifInteracted||!this.hasAttribute("count")?e.filter(t=>"true"!==t.dataset.read).length:Number(this.getAttribute("count"))||0;let s=t.querySelector(".c-notification-center__badge");r>0?(s||(s=document.createElement("span"),s.className="c-notification-center__badge c-badge c-badge--dot",t.appendChild(s)),s.textContent=String(r)):s&&s.remove()}enhance(){if(this._wiredNotifCenter)return;this._wiredNotifCenter=!0;const t=t=>{"true"!==t.dataset.read&&(t.dataset.read="true",t.classList.add("is-read"),this._notifInteracted=!0,this._syncNotifBadge(),this.dispatchEvent(new CustomEvent("contour:read",{bubbles:!0,composed:!0,detail:{label:t.querySelector(".c-notification-center__item-label")?.textContent||t.textContent}})));for(const e of this.querySelectorAll(".c-notification-center__item"))e===t?e.setAttribute("aria-current","true"):e.removeAttribute("aria-current");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{label:t.querySelector(".c-notification-center__item-label")?.textContent||t.textContent}}))},e=(t,e)=>{const r=t.querySelector(".c-notification-center__item-label")?.textContent||t.textContent;t.remove(),this._notifInteracted=!0,this._syncNotifBadge(),this.dispatchEvent(new CustomEvent("archive"===e?"contour:remove":"contour:dismiss",{bubbles:!0,composed:!0,detail:{label:r}}))};this.addEventListener("click",r=>{const s=this.querySelector(".c-notification-center__trigger"),i=this.querySelector(".c-notification-center__panel");if(s&&(r.target===s||s.contains(r.target)))return void(i&&(i.hidden=!i.hidden,this._notifOpen=!i.hidden,s.setAttribute("aria-expanded",String(!i.hidden)),this.dispatchEvent(new CustomEvent(i.hidden?"contour:close":"contour:open",{bubbles:!0,composed:!0}))));const a=r.target&&r.target.closest?r.target.closest(".c-notification-center__more"):null;if(a&&this.contains(a))return this._notifShown=(this._notifShown||50)+50,void this.requestRender();const n=r.target&&r.target.closest?r.target.closest(".c-notification-center__archive"):null;if(n&&this.contains(n)){const t=n.closest(".c-notification-center__item");return void(t&&e(t,"archive"))}const o=r.target&&r.target.closest?r.target.closest(".c-notification-center__dismiss"):null;if(o&&this.contains(o)){const t=o.closest(".c-notification-center__item");return void(t&&e(t,"dismiss"))}const l=r.target&&r.target.closest?r.target.closest(".c-notification-center__item"):null;l&&this.contains(l)&&t(l)});const r=t=>{const e=this.querySelector(".c-notification-center__panel"),r=this.querySelector(".c-notification-center__trigger");!e||e.hidden||this.contains(t.target)||(e.hidden=!0,this._notifOpen=!1,r&&r.setAttribute("aria-expanded","false"))};document.addEventListener("click",r),onDispose(this,()=>document.removeEventListener("click",r));const s=r=>{const s=this.querySelector(".c-notification-center__panel"),i=this.querySelector(".c-notification-center__trigger");if("Escape"===r.key&&s&&!s.hidden){if(s.hidden=!0,this._notifOpen=!1,i){i.setAttribute("aria-expanded","false");try{i.focus()}catch(t){}}return}if(!s||s.hidden)return;const a=Array.from(s.querySelectorAll(".c-notification-center__item"));if(a.length){if(("Enter"===r.key||" "===r.key)&&a.includes(r.target))return r.preventDefault(),void t(r.target);if(("Delete"===r.key||"Backspace"===r.key)&&a.includes(r.target)){r.preventDefault();const t=a.indexOf(r.target);e(r.target,"dismiss");const s=a[t+1]||a[t-1];if(s&&s.isConnected)try{s.focus()}catch(t){}return}navKey(r,a,{wrap:!0,onNavigate:t=>{a.forEach((e,r)=>{e.tabIndex=r===t?0:-1})}})}};document.addEventListener("keydown",s),onDispose(this,()=>document.removeEventListener("keydown",s))}}define("contour-notification-center",ContourNotificationCenter);class ContourStepper extends ContourBase{static get observed(){return["steps","current"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"}}}render(){this.classList.add("c-stepper"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"stepper","Stepper"));const t=this.getAttribute("steps"),e=Number(this.getAttribute("current")||0),r=this.ensure(".c-stepper__list",()=>{const t=document.createElement("ol");return t.className="c-stepper__list",t});setHTML(r,"");const s=Array.from(this.querySelectorAll(":scope > .c-stepper__step"));let i=[];if(s.length)i=s.map(t=>t.textContent.trim()),this._stepperAuthored=i,s.forEach(t=>t.remove());else if(t)try{i=JSON.parse(t)}catch(t){warnBadJson(this,"steps",t),i=this._stepperAuthored||[]}else i=this._stepperAuthored||[];i.forEach((t,s)=>{const i=document.createElement("li");i.className="c-stepper__step"+(s===e?" is-current":"")+(s<e?" is-done":""),s===e&&i.setAttribute("aria-current","step"),i.setAttribute("tabindex",s===e?"0":"-1");const a=document.createElement("span");a.className="c-stepper__marker",a.setAttribute("aria-hidden","true"),s<e?setHTML(a,'<svg viewBox="0 0 24 24"><use href="#i-check" /></svg>'):a.textContent=String(s+1),i.appendChild(a);const n=document.createElement("span");n.className="c-stepper__label",n.textContent="string"==typeof t?t:t.title||t.label||"",i.appendChild(n),r.appendChild(i)});const a=this.ensure(".c-stepper__nav",()=>{const t=document.createElement("div");return t.className="c-stepper__nav c-btn-group",t}),n=this.ensure(".c-stepper__prev",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-stepper__prev",t.type="button",t});n.textContent=labelText(this,"prev","Back"),e<=0?n.setAttribute("disabled",""):n.removeAttribute("disabled");const o=this.ensure(".c-stepper__next",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-stepper__next",t.type="button",t});o.textContent=labelText(this,"next","Next"),e>=i.length-1?o.setAttribute("disabled",""):o.removeAttribute("disabled"),a.contains(n)||a.appendChild(n),a.contains(o)||a.appendChild(o),a.parentNode!==this&&this.appendChild(a)}enhance(){if(this._wiredStepper)return;this._wiredStepper=!0;const t=t=>{const e=this.querySelector(".c-stepper__list"),r=e?e.querySelectorAll(".c-stepper__step").length:0;if(!r)return;let s=Number(this.getAttribute("current")||0);s="prev"===t?Math.max(0,s-1):Math.min(r-1,s+1),this.setAttribute("current",String(s)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:t,index:s}}))};this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest(".c-stepper__prev"):null,s=e.target&&e.target.closest?e.target.closest(".c-stepper__next"):null;if(r&&this.contains(r))return void t("prev");if(s&&this.contains(s))return void t("next");const i=e.target&&e.target.closest?e.target.closest(".c-stepper__step"):null;if(i&&this.contains(i)){const t=Array.from(this.querySelectorAll(".c-stepper__step")).indexOf(i);t>=0&&t!==Number(this.getAttribute("current")||0)&&(this.setAttribute("current",String(t)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:"jump",index:t}})))}}),this.addEventListener("keydown",e=>{"ArrowLeft"===e.key?(e.preventDefault(),t("prev")):"ArrowRight"===e.key&&(e.preventDefault(),t("next"))})}}define("contour-stepper",ContourStepper);class ContourVirtualList extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","item-height","orientation","sticky"]}static get properties(){return{items:{attribute:"items"},"item-height":{attribute:"item-height"},orientation:{attribute:"orientation"},sticky:{attribute:"sticky",type:Boolean}}}_items(){const t=this.getAttribute("items");let e=[];try{e=t?JSON.parse(t):[]}catch(t){warnBadJson(this,"items",t),e=[]}return Array.isArray(e)?e:[]}_itemHeight(){const t=Number(this.getAttribute("item-height"));return Number.isFinite(t)&&t>0?t:cssLength("--virtual-list-item-height",28)}_autoHeight(){return"auto"===this.getAttribute("item-height")}render(){this.classList.add("c-virtual-list"),this.setAttribute("role","list"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"virtual-list","Virtual list"));const t=this.ensure(".c-virtual-list__scroller",()=>{const t=document.createElement("div");return t.className="c-virtual-list__scroller",t});t.setAttribute("role","presentation");const e="horizontal"===this.getAttribute("orientation");t.style.overflowX=e?"auto":"hidden",t.style.overflowY=e?"hidden":"auto";const r=this.ensure(".c-virtual-list__inner",()=>{const t=document.createElement("div");return t.className="c-virtual-list__inner",t.style.position="relative",t});r.parentNode!==t&&t.appendChild(r),this._renderWindow(t,r,e?t.scrollLeft||0:t.scrollTop||0)}_measureHeights(t,e){return Array.from(t.querySelectorAll(".c-virtual-list__item")).map(t=>e?t.getBoundingClientRect().width||this._itemHeight():t.getBoundingClientRect().height||this._itemHeight())}_renderWindow(t,e,r){const s=this._items(),i=this._itemHeight(),a="horizontal"===this.getAttribute("orientation"),n=this._autoHeight(),o=a?t.clientWidth||320:t.clientHeight||320,l=s.length;this._vlItemCount!==l&&(this._vlHeights=null,this._vlItemCount=l);let c=n?this._vlHeights:null,u=null;if(n&&c&&c.length===l){u=[0];for(let t=0;t<l;t++)u.push(u[t]+(c[t]||this._itemHeight()))}const d=n&&!u?l:n?Math.ceil(o/this._itemHeight())+6:Math.ceil(o/i)+4;let h=0;if(n&&u){let t=0,e=l;for(;t<e;){const s=t+e>>1;u[s]<(r||0)?t=s+1:e=s}h=Math.max(0,t-3)}else n||(h=Math.floor((r||0)/i));h<0&&(h=0);const m=Math.min(l,h+d);h>Math.max(0,l-d)&&!n&&(h=Math.max(0,l-d));const b=n&&u?u[h]:n?0:h*i,p=n&&u?Math.max(0,u[l]-u[m]):n?0:Math.max(0,(l-m)*i);e.style.display=a?"flex":"block",e.style.width=a&&n?"max-content":"",e.style.height=a||n?"":l*i+"px",setHTML(e,"");const g=document.createElement("div");g.className="c-virtual-list__spacer c-virtual-list__spacer--top",g.style[a?"width":"height"]=b+"px",e.appendChild(g);for(let t=h;t<m;t++){const r=document.createElement("div");r.className="c-virtual-list__item",r.setAttribute("role","listitem"),r.setAttribute("aria-setsize",String(l)),r.setAttribute("aria-posinset",String(t+1)),r.setAttribute("tabindex",0===t?"0":"-1"),r.textContent="string"==typeof s[t]?s[t]:s[t].label||s[t].text||JSON.stringify(s[t]),this.hasAttribute("sticky")&&s[t]&&s[t].sticky&&(r.style.position="sticky",r.style.insetBlockStart="0",r.style.zIndex="1"),a&&!n&&(r.style.flex="0 0 "+i+"px"),r.dataset.index=String(t),e.appendChild(r)}const _=document.createElement("div");_.className="c-virtual-list__spacer c-virtual-list__spacer--bottom",_.style[a?"width":"height"]=p+"px",e.appendChild(_),a&&!n&&(e.style.width=l*i+"px"),n&&!this._vlHeights&&requestAnimationFrame(()=>{this._vlHeights=this._measureHeights(e,a);const r=t,s=e;r&&s&&this._renderWindow(r,s,r.scrollTop||0)})}enhance(){if(this._wiredVirtualList)return;this._wiredVirtualList=!0;const t=()=>this.querySelector(".c-virtual-list__scroller"),e=()=>this.querySelector(".c-virtual-list__inner");let r=0;const s=()=>{r||(r=requestAnimationFrame(()=>{r=0;const s=t(),i=e();s&&i&&this._renderWindow(s,i,"horizontal"===this.getAttribute("orientation")?s.scrollLeft:s.scrollTop)}))};this.addEventListener("scroll",s,{passive:!0,capture:!0}),onDispose(this,()=>{this.removeEventListener("scroll",s,{capture:!0}),r&&cancelAnimationFrame(r)}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(!e.length)return;const r="horizontal"===this.getAttribute("orientation"),s=r?"ArrowRight":"ArrowDown",i=r?"ArrowLeft":"ArrowUp",a=document.activeElement,n=e.indexOf(a),o=this.querySelector(".c-virtual-list__scroller"),l=this.querySelector(".c-virtual-list__inner");if(t.key===s&&n===e.length-1||t.key===i&&0===n&&Number(a&&a.dataset.index)>0){if(t.preventDefault(),o&&l){const e=(t.key===s?1:-1)*this._itemHeight();r?o.scrollLeft+=e:o.scrollTop+=e,this._renderWindow(o,l,r?o.scrollLeft:o.scrollTop);const i=Number(a&&a.dataset.index)+(t.key===s?1:-1);requestAnimationFrame(()=>{const t=this.querySelector(`.c-virtual-list__item[data-index="${i}"]`),e=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(t){e.forEach(t=>t.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0");try{t.focus()}catch(t){}}})}}else navKey(t,e,{wrap:!1,homeEnd:!0,onNavigate:t=>e.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1")),onKey:()=>{if("Enter"===t.key||" "===t.key){const t=Number(document.activeElement.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:t,value:document.activeElement.textContent}}))}}})}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-virtual-list__item"):null;if(!e||!this.contains(e))return;const r=Number(e.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:r,value:e.textContent}}))})}}define("contour-virtual-list",ContourVirtualList);class ContourSortableList extends ContourBase{static get observed(){return["items","order"]}static get properties(){return{items:{attribute:"items"},order:{attribute:"order"}}}render(){this.classList.add("c-sortable-list");const t=this.ensure(".c-sortable-list__list",()=>{const t=document.createElement("ul");return t.className="c-sortable-list__list",t}),e=this.getAttribute("items");let r=[];try{r=e?JSON.parse(e):[]}catch(t){r=[]}Array.isArray(r)||(r=[]);let s=Array.from({length:r.length},(t,e)=>e);const i=this.getAttribute("order");if(i)try{const t=JSON.parse(i);Array.isArray(t)&&t.length===r.length&&t.every(t=>Number.isInteger(t)&&t>=0&&t<r.length)&&(s=t.slice(),r=t.map(t=>r[t]))}catch(t){}this._sortableSourceOrder=s,this._sortableItems=r,setHTML(t,""),r.forEach((e,r)=>{const s=document.createElement("li");s.className="c-sortable-list__item",s.setAttribute("draggable","true"),s.dataset.index=String(r);const i="string"==typeof e?e:e.label||e.text||"",a=document.createElement("span");a.className="c-sortable-list__handle",a.textContent="⋮⋮",a.setAttribute("role","button"),a.setAttribute("aria-label",labelText(this,"reorder","Reorder")+" "+(i||String(r+1))),a.setAttribute("data-contour-preserve-key",i||String(r)),a.tabIndex=0,s.appendChild(a);const n=document.createElement("span");n.className="c-sortable-list__label",n.textContent=i,s.appendChild(n),t.appendChild(s)})}enhance(){if(this._wiredSortableList)return;this._wiredSortableList=!0;const t=()=>this.querySelector(".c-sortable-list__list"),e=t=>{let e=this.querySelector(".c-sortable-list__live");e||(e=document.createElement("span"),e.className="c-sortable-list__live visually-hidden",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.appendChild(e)),e.textContent=t},r=e=>Array.from(t().children).indexOf(e),s=(t,e)=>{const r=(this._sortableItems||[]).length,s=Array.isArray(this._sortableSourceOrder)&&this._sortableSourceOrder.length===r?this._sortableSourceOrder.slice():Array.from({length:r},(t,e)=>e),[i]=s.splice(t,1);s.splice(e,0,i),this.setAttribute("order",JSON.stringify(s))};let i=null;this.addEventListener("dragstart",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-sortable-list__item"):null;if(e&&this.contains(e)){if(i=r(e),t.dataTransfer){t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",String(i))}catch(t){}}e.classList.add("is-dragging")}}),this.addEventListener("dragover",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-sortable-list__item"):null;e&&this.contains(e)&&null!==i&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"))}),this.addEventListener("drop",a=>{const n=a.target&&a.target.closest?a.target.closest(".c-sortable-list__item"):null;if(!n||!this.contains(n)||null===i)return;a.preventDefault();const o=r(n),l=t(),c=l.children[i];if(c&&i!==o){i<o?l.insertBefore(c,l.children[o+1]||null):l.insertBefore(c,l.children[o]);const t=c.querySelector(".c-sortable-list__label");e((t?t.textContent:"Item")+" moved to position "+(o+1));const r=i;s(r,o),this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:!0,composed:!0,detail:{from:r,to:o}}))}i=null,Array.from(l.children).forEach(t=>t.classList.remove("is-dragging"))}),this.addEventListener("dragend",()=>{i=null;const e=t();e&&Array.from(e.children).forEach(t=>t.classList.remove("is-dragging"))}),this.addEventListener("click",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-sortable-list__handle"):null;if(!r||!this.contains(r))return;const s="true"===r.getAttribute("aria-pressed");r.setAttribute("aria-pressed",String(!s)),r.classList.toggle("is-grabbed",!s);const i=r.closest(".c-sortable-list__item"),a=i&&i.querySelector(".c-sortable-list__label"),n=a?a.textContent:"Item";e(s?`${n} released`:`${n} grabbed; use Up or Down arrows to reorder`)}),this.addEventListener("keydown",i=>{const a=i.target&&i.target.closest?i.target.closest(".c-sortable-list__handle"):null;if(!a)return;if("Enter"===i.key||" "===i.key)return i.preventDefault(),void a.click();const n=a.closest(".c-sortable-list__item");if(!n)return;const o=t(),l=r(n),c=(t,r)=>{const i=n.querySelector(".c-sortable-list__label");e((i?i.textContent:"Item")+" moved to position "+(r+1)),s(l,r),this.dispatchEvent(new CustomEvent("contour:move",{bubbles:!0,composed:!0,detail:{direction:t,from:l,to:r}})),this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:!0,composed:!0,detail:{from:l,to:r}}))};"ArrowUp"===i.key&&n.previousElementSibling?(i.preventDefault(),o.insertBefore(n,n.previousElementSibling),c("up",r(n))):"ArrowDown"===i.key&&n.nextElementSibling?(i.preventDefault(),o.insertBefore(n.nextElementSibling,n),c("down",r(n))):"Home"===i.key&&l>0?(i.preventDefault(),o.insertBefore(n,o.firstElementChild),c("up",0)):"End"===i.key&&l<o.children.length-1&&(i.preventDefault(),o.appendChild(n),c("down",o.children.length-1))})}}define("contour-sortable-list",ContourSortableList);class ContourCarousel extends ContourBase{static get observed(){return["items","index","autoplay","paused"]}static get properties(){return{items:{attribute:"items"},index:{attribute:"index"},autoplay:{attribute:"autoplay"},paused:{attribute:"paused",type:Boolean}}}_items(){const t=this.getAttribute("items");let e=[];try{e=t?JSON.parse(t):[]}catch(t){e=[]}return Array.isArray(e)?e:[]}_index(){const t=Number(this.getAttribute("index")),e=this._items();return Number.isFinite(t)&&t>=0&&t<e.length?t:0}render(){this.classList.add("c-carousel"),this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),Array.from(this.children).forEach(t=>{t.classList&&t.classList.contains("c-carousel__slide")&&t.parentElement===this&&t.remove()});const t=this.ensure(".c-carousel__track",()=>{const t=document.createElement("div");return t.className="c-carousel__track",t.setAttribute("role","group"),t.setAttribute("aria-roledescription","slide container"),t}),e=this._items();setHTML(t,"");const r=this._index();e.forEach((s,i)=>{const a=document.createElement("div");a.className="c-carousel__slide"+(i===r?" is-active":""),a.setAttribute("role","group"),a.setAttribute("aria-roledescription","slide"),a.setAttribute("aria-label",i+1+" of "+e.length),a.setAttribute("aria-hidden",i===r?"false":"true");const n="object"==typeof s&&s?s.src||s.image||s.video:null;if(n){const t=!("object"!=typeof s||!s)&&("video"===s.type||!!s.video);a.classList.add("c-carousel__slide--media");const e=document.createElement(t?"video":"img");e.src=n,t?(e.controls=!0,s.poster&&(e.poster=s.poster)):e.alt="object"==typeof s&&(s.alt||s.label)||"",a.appendChild(e)}else a.textContent="string"==typeof s?s:s.label||s.text||"";a.dataset.index=String(i),t.appendChild(a)});this.ensure(".c-carousel__prev",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-carousel__prev",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>'),t.setAttribute("aria-label",labelText(this,"previous-slide","Previous slide")),t}),this.ensure(".c-carousel__next",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-carousel__next",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),t.setAttribute("aria-label",labelText(this,"next-slide","Next slide")),t});const s=this.ensure(".c-carousel__status",()=>{const t=document.createElement("span");return t.className="c-carousel__status",t}),i=Number(this.getAttribute("autoplay")),a=Number.isFinite(i)&&i>0&&!this.hasAttribute("paused")&&!this._reducedMotion();s.setAttribute("aria-live",a?"off":"polite"),s.textContent=e.length?r+1+" of "+e.length:"0 of 0";const n=this.ensure(".c-carousel__dots",()=>{const t=document.createElement("div");return t.className="c-carousel__dots",t.setAttribute("role","group"),t.setAttribute("aria-label",labelText(this,"slide-controls","Slide controls")),t});n.setAttribute("role","group"),n.setAttribute("aria-label",labelText(this,"slide-controls","Slide controls")),setHTML(n,""),e.forEach((t,e)=>{const s=document.createElement("button");s.type="button",s.className="c-carousel__dot"+(e===r?" is-active":""),s.setAttribute("aria-label",labelText(this,"go-to-slide","Go to slide")+" "+(e+1)),s.setAttribute("aria-current",e===r?"true":"false"),s.tabIndex=e===r?0:-1,s.dataset.index=String(e),n.appendChild(s)});const o=i;if(Number.isFinite(o)&&o>0){const t=this.hasAttribute("paused")||this._reducedMotion(),e=this.ensure(".c-carousel__pause",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-carousel__pause",t.type="button",t});setHTML(e,t?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-play" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-pause" /></svg>'),e.setAttribute("aria-label",t?labelText(this,"play-slides","Play slides automatically"):labelText(this,"pause-slides","Pause automatic slides")),e.setAttribute("aria-pressed",String(t)),e.disabled=this._reducedMotion()}else{const t=this.querySelector(".c-carousel__pause");t&&t.remove()}}_reducedMotion(){try{return"function"==typeof matchMedia&&matchMedia("(prefers-reduced-motion: reduce)").matches}catch(t){return!1}}enhance(){const t=Number(this.getAttribute("autoplay")),e=Number.isFinite(t)&&t>0&&!this.hasAttribute("paused")&&!this._reducedMotion()&&this._items().length>1;if(e&&!this._carouselTimer?this._carouselTimer=setInterval(()=>{const t=this._items();if(!t.length)return;const e=(this._index()+1)%t.length;this.setAttribute("index",String(e)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:e,direction:"next"}}))},Math.max(500,t)):!e&&this._carouselTimer&&(clearInterval(this._carouselTimer),this._carouselTimer=null),this._wiredCarousel)return;this._wiredCarousel=!0,onDispose(this,()=>{this._carouselTimer&&(clearInterval(this._carouselTimer),this._carouselTimer=null)});const r=t=>{const e=this._items();if(!e.length)return;let r=this._index();r="prev"===t?(r-1+e.length)%e.length:(r+1)%e.length,this.setAttribute("index",String(r)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:r,direction:t}}))};this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-carousel__pause"):null;if(e&&this.contains(e)){if(this._reducedMotion())return;const t=!this.hasAttribute("paused");return this.toggleAttribute("paused",t),void this.dispatchEvent(new CustomEvent(t?"contour:pause":"contour:play",{bubbles:!0,composed:!0}))}const s=t.target&&t.target.closest?t.target.closest(".c-carousel__prev"):null,i=t.target&&t.target.closest?t.target.closest(".c-carousel__next"):null;if(s&&this.contains(s))return void r("prev");if(i&&this.contains(i))return void r("next");const a=t.target&&t.target.closest?t.target.closest(".c-carousel__dot"):null;if(a&&this.contains(a)){const t=Number(a.dataset.index);Number.isFinite(t)&&t!==this._index()&&(this.setAttribute("index",String(t)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:t,direction:"jump"}})))}});let s=null;this.addEventListener("pointerdown",t=>{s=t.clientX}),this.addEventListener("pointerup",t=>{if(null===s)return;const e=t.clientX-s;s=null,Math.abs(e)>40&&r(e<0?"next":"prev")}),this.addEventListener("pointercancel",()=>{s=null}),this.addEventListener("keydown",t=>{if("ArrowLeft"===t.key)t.preventDefault(),r("prev");else if("ArrowRight"===t.key)t.preventDefault(),r("next");else if("Home"===t.key)t.preventDefault(),this.setAttribute("index","0"),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:0,direction:"home"}}));else if("End"===t.key){t.preventDefault();const e=this._items().length-1;e>=0&&(this.setAttribute("index",String(e)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:e,direction:"end"}})))}})}}define("contour-carousel",ContourCarousel);class ContourDataGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","filter","page-size","resizable","virtual","row-height","selected","loading","error","empty"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page"},filter:{attribute:"filter"},"page-size":{attribute:"page-size"},resizable:{attribute:"resizable",type:Boolean},virtual:{attribute:"virtual",type:Boolean},"row-height":{attribute:"row-height"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}get selected(){return Array.from(this._dgSelectedKeys||[])}set selected(t){this._dgPushedSelection=Array.isArray(t)?t.map(String):[],this._dgSelectionControlled=!0,this.requestRender()}_dgRowKey(t){if(t&&"object"==typeof t&&!Array.isArray(t)){if(void 0!==t.id&&null!==t.id)return String(t.id);if(void 0!==t.key&&null!==t.key)return String(t.key)}const e=this._dgCols||[],r=e.findIndex(t=>t&&"object"==typeof t&&!0===t.key);if(r>=0&&t){const s="string"==typeof e[r].label?e[r].label:"",i=s&&null!=t[s]?String(t[s]):"";if(""!==i)return i}return JSON.stringify(void 0===t?null:t)}_dgReadSelection(){if(this._dgPushedSelection)return void(this._dgSelectedKeys=new Set(this._dgPushedSelection));const t=this.getAttribute("selected");if(null!==t&&t!==this._dgLastSelectedRaw){this._dgLastSelectedRaw=t,this._dgSelectionControlled=!0;try{const e=JSON.parse(t);this._dgSelectedKeys=new Set(Array.isArray(e)?e.map(String):[])}catch(t){this._dgSelectedKeys=new Set}}else this._dgSelectedKeys=this._dgSelectedKeys||new Set}_dgApplySelection(t){if(!t)return;const e=this._dgSelectedKeys||new Set;t.querySelectorAll("tr[data-row-key]").forEach(t=>{t.setAttribute("aria-selected",String(e.has(t.dataset.rowKey)))})}render(){if(this.classList.add("c-data-grid"),this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const t=this.ensure(".c-data-grid__table",()=>{const t=document.createElement("table");return t.className="c-table c-data-grid__table",t.setAttribute("role","grid"),t}),e=this.ensure("tbody",()=>document.createElement("tbody"));e.parentNode!==t&&t.appendChild(e),setHTML(e,"");const r=document.createElement("tr"),s=document.createElement("td");s.colSpan=1,s.style.textAlign="center",s.style.color="var(--color-text-muted)",this.hasAttribute("loading")?s.textContent=this.getAttribute("loading")||"Loading…":this.hasAttribute("error")?s.textContent=this.getAttribute("error")||"Error":s.textContent=this.getAttribute("empty")||"No data",r.appendChild(s),e.appendChild(r);let i=this.querySelector(".c-data-grid__wrap");return i||(i=document.createElement("div"),i.className="c-table-wrap c-data-grid__wrap"),t.parentNode!==i&&i.appendChild(t),void(i.parentNode!==this&&this.appendChild(i))}const t=this.ensure(".c-data-grid__table",()=>{const t=document.createElement("table");return t.className="c-table c-data-grid__table",t.setAttribute("role","grid"),t}),e=this.ensure("thead",()=>document.createElement("thead")),r=this.ensure("tbody",()=>document.createElement("tbody"));e.parentNode!==t&&t.appendChild(e),r.parentNode!==t&&t.appendChild(r);const s=this.getAttribute("columns");let i=[];try{i=s?JSON.parse(s):[]}catch(t){i=[]}if(i.length&&!e.querySelector("tr")){const t=document.createElement("tr");i.forEach(e=>{const r=document.createElement("th");r.setAttribute("role","columnheader"),r.setAttribute("aria-sort","none"),r.setAttribute("tabindex","0"),r.textContent="string"==typeof e?e:e.label||e.key||"",t.appendChild(r)}),e.appendChild(t)}this.hasAttribute("resizable")&&Array.from(e.querySelectorAll("th")).forEach(t=>{t.style.position="relative",t.setAttribute("data-resizable","true")});const a=this.getAttribute("rows");let n=[];try{n=a?JSON.parse(a):[]}catch(t){n=[]}t.setAttribute("aria-rowcount",String(n.length)),t.setAttribute("aria-colcount",String(i.length));const o=this.getAttribute("filter");if(o){const t=o.toLowerCase();n=n.filter(e=>JSON.stringify(e).toLowerCase().includes(t))}if(null!=this._dgSortCol&&this._dgSortCol>=0&&this._dgSortCol<i.length){const t=this._dgSortCol,r=this._dgSortDir||"asc",s=i[t],a=s?"string"==typeof s?s:s.key||s.label||"":String(t);n=n.slice().sort((e,s)=>{const i=Array.isArray(e)?e[t]??"":e&&null!=e[a]?e[a]:"",n=Array.isArray(s)?s[t]??"":s&&null!=s[a]?s[a]:"",o=Number(i),l=Number(n),c=""===i||""===n||isNaN(o)||isNaN(l)?String(i).localeCompare(String(n)):o-l;return"asc"===r?c:-c}),Array.from(e.querySelectorAll("th")).forEach((e,s)=>{e.setAttribute("aria-sort",s===t?"asc"===r?"ascending":"descending":"none")})}this._dgFilteredRows=n;const l=Number(this.getAttribute("page")||1),c=Number(this.getAttribute("page-size")||0);if(c>0){const t=(l-1)*c;n=n.slice(t,t+c)}this._dgCols=i,this._dgRows=n,this._dgReadSelection();if(this.hasAttribute("virtual")&&!(Number(this.getAttribute("page-size"))>0)){const t=this.querySelector(".c-data-grid__wrap");this._renderDataGridWindow(t?t.scrollTop:0)}else{setHTML(r,"");const t=c>0?(l-1)*c:0;n.forEach((e,s)=>{const a=document.createElement("tr");a.dataset.rowKey=this._dgRowKey(e),a.dataset.index=String(t+s),i.forEach((t,r)=>{const s="string"==typeof t?t:t.key||t.label||"",i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1");const n=Array.isArray(e)?e[r]:e?e[s]:void 0;i.textContent=null!=n?n:"",String(i.textContent).trim()||i.setAttribute("aria-label",labelText(this,"empty","Empty")),a.appendChild(i)}),r.appendChild(a)}),this._dgApplySelection(r)}let u=this.querySelector(".c-data-grid__wrap");if(u||(u=document.createElement("div"),u.className="c-table-wrap c-data-grid__wrap"),t.parentNode!==u&&u.appendChild(t),u.parentNode!==this&&this.appendChild(u),!t.querySelector('[tabindex="0"]')){const e=t.querySelector("tbody td, thead th");e&&e.setAttribute("tabindex","0")}}_rowHeight(){const t=Number(this.getAttribute("row-height"));return Number.isFinite(t)&&t>0?t:this._measuredRowHeight>0?this._measuredRowHeight:cssLength("--data-grid-row-height",32)}_renderDataGridWindow(t){const e=this.querySelector(".c-data-grid__table"),r=e&&e.querySelector("tbody");if(!r)return;const s=this._dgCols||[],i=this._dgRows||[],a=this._rowHeight(),n=Math.ceil(400/a)+6;let o=Math.floor((t||0)/a);o<0&&(o=0),o>Math.max(0,i.length-n)&&(o=Math.max(0,i.length-n));const l=Math.min(i.length,o+n);if(setHTML(r,""),o>0){const t=document.createElement("tr"),e=document.createElement("td");e.colSpan=Math.max(1,s.length),e.style.blockSize=o*a+"px",e.style.padding="0",t.appendChild(e),r.appendChild(t)}for(let t=o;t<l;t++){const e=i[t],a=document.createElement("tr");a.dataset.index=String(t),a.dataset.rowKey=this._dgRowKey(e),s.forEach((t,r)=>{const s="string"==typeof t?t:t.key||t.label||"",i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1");const n=Array.isArray(e)?e[r]:e?e[s]:void 0;i.textContent=null!=n?n:"",String(i.textContent).trim()||i.setAttribute("aria-label",labelText(this,"empty","Empty")),a.appendChild(i)}),r.appendChild(a)}if(l<i.length){const t=document.createElement("tr"),e=document.createElement("td");e.colSpan=Math.max(1,s.length),e.style.blockSize=(i.length-l)*a+"px",e.style.padding="0",t.appendChild(e),r.appendChild(t)}if(!r.querySelector('[tabindex="0"]')){const t=r.querySelector("tr[data-index] td");t&&t.setAttribute("tabindex","0")}this._dgApplySelection(r)}enhance(){if(this._wiredDataGrid)return;this._wiredDataGrid=!0;const t=()=>this.querySelector(".c-data-grid__wrap");this.addEventListener("scroll",t=>{const e=t.target&&t.target.classList&&t.target.classList.contains("c-data-grid__wrap")?t.target:null;e&&this.hasAttribute("virtual")&&this._renderDataGridWindow(e.scrollTop)},!0),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest("[role='gridcell'], [role='columnheader']"):null;if(!e||!this.contains(e))return;const r=e.parentElement,s=this.querySelector(".c-data-grid__table");if(!s)return;if(t.altKey&&("ArrowLeft"===t.key||"ArrowRight"===t.key)&&e.hasAttribute("data-resizable")){t.preventDefault();const i=Array.from(r.children).indexOf(e),a=e.getBoundingClientRect().width||100,n=Math.max(48,a+("ArrowRight"===t.key?16:-16));return Array.from(s.rows).forEach(t=>{t.children[i]&&(t.children[i].style.inlineSize=n+"px")}),void this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{column:i,width:n}}))}if("Enter"===t.key||" "===t.key)return t.preventDefault(),void("columnheader"===e.getAttribute("role")?e.click():r&&r.click());const i=Array.from(s.querySelectorAll("tr")),a=i.indexOf(r),n=Array.from(r.children).indexOf(e);let o=null;if("ArrowRight"===t.key?o=r.children[n+1]:"ArrowLeft"===t.key?o=r.children[n-1]:"ArrowDown"===t.key?o=i[a+1]&&i[a+1].children[n]:"ArrowUp"===t.key&&(o=i[a-1]&&i[a-1].children[n]),o){t.preventDefault(),s.querySelectorAll('[tabindex="0"]').forEach(t=>t.setAttribute("tabindex","-1")),o.setAttribute("tabindex","0");try{o.focus()}catch(t){}}}),this.addEventListener("click",e=>{const r=e.target&&e.target.closest?e.target.closest("tr"):null,s=e.target&&e.target.closest?e.target.closest("th"):null;if(r&&this.contains(r)&&!s&&void 0!==r.dataset.rowKey){const t=r.dataset.rowKey,e=Number(r.dataset.index),s=this._dgSelectedKeys||(this._dgSelectedKeys=new Set);s.has(t)?s.delete(t):s.add(t),this._dgApplySelection(r.parentElement),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{row:e,key:t,index:e}}))}if(s&&this.contains(s)){const e=Array.from(s.parentElement.children).indexOf(s);this._dgSortCol===e?this._dgSortDir="asc"===this._dgSortDir?"desc":"asc":(this._dgSortCol=e,this._dgSortDir="asc");const r=this._dgSortDir,i=this.querySelector(".c-data-grid__table"),a=i&&i.querySelector("tbody"),n=i&&i.querySelector("thead"),o=this._dgCols||[],l=o[e]?"string"==typeof o[e]?o[e]:o[e].key||o[e].label||"":String(e),c=(this._dgFilteredRows||[]).slice();if(c.sort((t,s)=>{const i=Array.isArray(t)?t[e]??"":t&&null!=t[l]?t[l]:"",a=Array.isArray(s)?s[e]??"":s&&null!=s[l]?s[l]:"",n=Number(i),o=Number(a),c=""===i||""===a||isNaN(n)||isNaN(o)?String(i).localeCompare(String(a)):n-o;return"asc"===r?c:-c}),this._dgFilteredRows=c,!this.hasAttribute("virtual")||Number(this.getAttribute("page-size"))>0){if(a){const t=Number(this.getAttribute("page")||1),e=Number(this.getAttribute("page-size")||0);let r=c;if(e>0){const s=(t-1)*e;r=c.slice(s,s+e)}setHTML(a,"");const s=e>0?(t-1)*e:0;r.forEach((t,e)=>{const r=document.createElement("tr");r.dataset.rowKey=this._dgRowKey(t),r.dataset.index=String(s+e),o.forEach((e,s)=>{const i="string"==typeof e?e:e.key||e.label||"",a=document.createElement("td");a.setAttribute("role","gridcell"),a.setAttribute("tabindex","-1");const n=Array.isArray(t)?t[s]:t?t[i]:void 0;a.textContent=null!=n?n:"",r.appendChild(a)}),a.appendChild(r)}),this._dgApplySelection(a)}}else{this._dgRows=c;const e=t();this._renderDataGridWindow(e?e.scrollTop:0)}n&&Array.from(n.querySelectorAll("th")).forEach((t,s)=>{t.setAttribute("aria-sort",s===e?"asc"===r?"ascending":"descending":"none")}),this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:!0,composed:!0,detail:{column:e,direction:r}}))}}),this.addEventListener("pointerdown",t=>{if(!this.hasAttribute("resizable"))return;const e=t.target&&t.target.closest?t.target.closest("th[data-resizable]"):null;if(!e||!this.contains(e)||e.getBoundingClientRect().right-t.clientX>10)return;t.preventDefault();const r=t.clientX,s=e.getBoundingClientRect().width,i=Array.from(e.parentElement.children).indexOf(e);let a=s;const n=t=>{a=Math.max(48,s+t.clientX-r);const e=this.querySelector(".c-data-grid__table");e&&Array.from(e.rows).forEach(t=>{t.children[i]&&(t.children[i].style.inlineSize=a+"px")})},o=()=>{window.removeEventListener("pointermove",n),this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{column:i,width:a}}))};window.addEventListener("pointermove",n),window.addEventListener("pointerup",o,{once:!0}),onDispose(this,o)}),this._dgApplySelection(this.querySelector(".c-data-grid__table tbody"))}}define("contour-data-grid",ContourDataGrid);class ContourTreeGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","rows","expanded","loading","error","empty"]}static get properties(){return{items:{attribute:"items"},rows:{attribute:"rows"},expanded:{attribute:"expanded"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}_expandedSet(){const t=this.getAttribute("expanded");if(!t)return new Set;try{return new Set(JSON.parse(t))}catch(e){return new Set([t])}}render(){this.classList.add("c-tree-grid");const t=this.ensure(".c-tree-grid__table",()=>{const t=document.createElement("table");return t.className="c-table c-tree-grid__table",t.setAttribute("role","treegrid"),t});t.setAttribute("aria-label",labelText(this,"tree-grid","Tree grid"));const e=this.ensure("tbody",()=>document.createElement("tbody"));if(e.parentNode!==t&&t.appendChild(e),setHTML(e,""),this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const t=document.createElement("tr"),r=document.createElement("td");r.style.textAlign="center",r.style.color="var(--color-text-muted)",this.hasAttribute("loading")?r.textContent=this.getAttribute("loading")||"Loading…":this.hasAttribute("error")?r.textContent=this.getAttribute("error")||"Error":r.textContent=this.getAttribute("empty")||"No data",t.appendChild(r),e.appendChild(t)}else{const t=this.getAttribute("items")||this.getAttribute("rows");let r=[];try{r=t?JSON.parse(t):[]}catch(t){r=[]}Array.isArray(r)||(r=[]);const s=this._expandedSet(),i=[],a=(t,r,n,o,l)=>{const c=document.createElement("tr");c.setAttribute("role","row"),c.setAttribute("tabindex",0===i.length?"0":"-1"),c.setAttribute("aria-level",String(r+1)),c.setAttribute("aria-posinset",String(o)),c.setAttribute("aria-setsize",String(l)),c.dataset.path=n,this._tgSelectedPath===n&&c.setAttribute("aria-selected","true");const u=!!(t&&Array.isArray(t.children)&&t.children.length);u&&c.setAttribute("aria-expanded",s.has(n)?"true":"false");const d=document.createElement("td");d.setAttribute("role","gridcell"),d.style.setProperty("--tree-depth",String(r));const h=t&&(t.label||t.text||t.name)||"";if(u){const t=document.createElement("button");t.type="button",t.className="c-tree-grid__toggle",t.tabIndex=-1,t.textContent=s.has(n)?"▾":"▸",t.setAttribute("aria-label",(s.has(n)?"Collapse":"Expand")+" "+h),d.appendChild(t)}const m=document.createElement("span");m.className="c-tree-grid__label",m.textContent=h,d.appendChild(m),c.appendChild(d),e.appendChild(c),i.push(c),u&&s.has(n)&&t.children.forEach((e,s)=>a(e,r+1,n+"."+s,s+1,t.children.length))};r.forEach((t,e)=>a(t,0,String(e),e+1,r.length))}let r=this.querySelector(".c-tree-grid__wrap");r||(r=document.createElement("div"),r.className="c-table-wrap c-tree-grid__wrap"),t.parentNode!==r&&r.appendChild(t),r.parentNode!==this&&this.appendChild(r)}enhance(){if(this._wiredTreeGrid)return;this._wiredTreeGrid=!0;const t=()=>Array.from(this.querySelectorAll("tr[role='row']")),e=e=>{if(e){t().forEach(t=>t.setAttribute("tabindex",t===e?"0":"-1"));try{e.focus()}catch(t){}}};this.addEventListener("click",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-tree-grid__toggle"):null,i=r.target&&r.target.closest?r.target.closest("tr[role='row']"):null;if(!i||!this.contains(i))return;const a=i.dataset.path;if(e(i),s){r.preventDefault();const t=this._expandedSet();t.has(a)?t.delete(a):t.add(a),this.setAttribute("expanded",JSON.stringify([...t])),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{path:a,expanded:t.has(a)}}))}else this._tgSelectedPath=a,t().forEach(t=>t.setAttribute("aria-selected",String(t===i))),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{path:a}}))}),this.addEventListener("keydown",r=>{const s=r.target&&r.target.closest?r.target.closest("tr[role='row']"):null;if(!s||!this.contains(s))return;const i=t(),a=i.indexOf(s),n=s.dataset.path||"",o=null!==s.getAttribute("aria-expanded"),l=this._expandedSet();if("ArrowRight"===r.key)r.preventDefault(),o&&!l.has(n)?(l.add(n),this.setAttribute("expanded",JSON.stringify([...l])),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{path:n,expanded:!0}}))):o&&l.has(n)&&i[a+1]&&e(i[a+1]);else if("ArrowLeft"===r.key){if(r.preventDefault(),o&&l.has(n))l.delete(n),this.setAttribute("expanded",JSON.stringify([...l])),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{path:n,expanded:!1}}));else if(n.includes(".")){const t=n.slice(0,n.lastIndexOf(".")),r=i.find(e=>e.dataset.path===t);r&&e(r)}}else if("ArrowDown"===r.key)r.preventDefault(),i[a+1]&&e(i[a+1]);else if("ArrowUp"===r.key)r.preventDefault(),i[a-1]&&e(i[a-1]);else if("Enter"===r.key||" "===r.key){r.preventDefault();const t=s.querySelector(".c-tree-grid__toggle");"Enter"===r.key&&t?t.click():(this._tgSelectedPath=n,i.forEach(t=>t.setAttribute("aria-selected",String(t===s))),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{path:n}})))}})}}define("contour-tree-grid",ContourTreeGrid),define("contour-box",simple(["c-box"])),define("contour-cluster",simple(["c-cluster"])),define("contour-container",simple(["c-container"])),define("contour-row",simple(["c-row"])),define("contour-scrim",simple(["c-scrim"])),define("contour-stack",simple(["c-stack"]));const assignedText=t=>{const e=t.querySelector("slot");return(e?e.assignedElements({flatten:!0}):[]).map(t=>(t.textContent||"").trim()).join(" ").trim()||(t.textContent||"").trim()};let ADOPTED=null,ADOPTED_KEY="";const _hashCss=t=>{let e=2166136261;for(let r=0;r<t.length;r++)e^=t.charCodeAt(r),e=Math.imul(e,16777619);return(e>>>0).toString(36)};export const adoptedSheets=()=>{let t=document.styleSheets.length+":";for(const e of document.styleSheets){let r="-1";try{const t=e.cssRules;let s="";for(let e=0;e<t.length;e++)s+=t[e].cssText+"\n";r=t.length+":"+_hashCss(s)}catch(t){}t+=(e.href||"inline")+"~"+r+"|"}if(ADOPTED&&t===ADOPTED_KEY)return ADOPTED;ADOPTED_KEY=t,ADOPTED=[];const e=(t,r)=>{let s;try{s=t.cssRules}catch(t){return}if(s)for(const t of s)if(t instanceof CSSImportRule)t.styleSheet&&e(t.styleSheet,r);else try{r.push(t.cssText)}catch(t){}};for(const t of document.styleSheets)try{if(!t.href||new URL(t.href).origin===location.origin){const r=[];e(t,r);const s=new CSSStyleSheet;r.length&&s.replaceSync(r.join("\n")),ADOPTED.push(s)}}catch(t){}return ADOPTED};const _ShadowParent="undefined"!=typeof HTMLElement?HTMLElement:Object;class ContourShadow extends _ShadowParent{static get observedAttributes(){return MODS.concat("labels")}constructor(){super();let t=this.shadowRoot;t||(t=this.attachShadow({mode:"open"}),this.constructor.contourTemplate&&t.appendChild(this.constructor.contourTemplate.content.cloneNode(!0)));const e=adoptedSheets();if(e.length)try{t.adoptedStyleSheets=e}catch(t){}this._shadowBase=t.firstElementChild?t.firstElementChild.className:""}enhance(t){t||(t=this.shadowRoot),t&&(t.querySelectorAll("details").forEach(t=>{const e=t.querySelector("summary");e&&!e.hasAttribute("aria-expanded")&&(e.setAttribute("aria-expanded",String(t.open)),t.addEventListener("toggle",()=>{e.setAttribute("aria-expanded",String(t.open))}))}),t.querySelectorAll("[data-live]").forEach(t=>{t.hasAttribute("role")||t.setAttribute("role","status"),t.hasAttribute("aria-live")||t.setAttribute("aria-live","polite")}),t.querySelectorAll(".c-spinner").forEach(t=>{t.hasAttribute("role")||t.setAttribute("role","status"),t.hasAttribute("aria-live")||t.setAttribute("aria-live","polite")}),t.querySelectorAll(".c-toast, .c-toast-host").forEach(t=>{t.hasAttribute("role")||t.setAttribute("role","status"),t.hasAttribute("aria-live")||t.setAttribute("aria-live","polite"),t.hasAttribute("aria-atomic")||t.setAttribute("aria-atomic","true")}),t.querySelectorAll("[role='tab']").forEach(e=>{const r=e.getAttribute("aria-controls");if(r){const s=t.querySelector("#"+CSS.escape(r))||document.getElementById(r);s&&!s.hasAttribute("aria-labelledby")&&(e.id||(e.id=contourId("tab")),s.setAttribute("aria-labelledby",e.id))}}),t.querySelectorAll("input, textarea, select").forEach(t=>{if(t.hasAttribute("aria-describedby"))return;const e=t.closest(".c-field");if(e){const r=e.querySelector(".c-field__hint");r&&(r.id||(r.id=contourId("hint")),t.setAttribute("aria-describedby",r.id));const s=e.querySelector(".c-field__error");if(s){s.id||(s.id=contourId("err"));const e=t.getAttribute("aria-describedby")||"";t.setAttribute("aria-describedby",(e+" "+s.id).trim())}}}),t.querySelectorAll(".c-alert").forEach(t=>{const e=t.classList.contains("c-alert--warning")||t.classList.contains("c-alert--danger"),r=e?"alert":"status",s=e?"assertive":"polite";t.hasAttribute("role")&&!t.dataset.contourAutoRole||(t.setAttribute("role",r),t.dataset.contourAutoRole=r),t.hasAttribute("aria-live")&&!t.dataset.contourAutoLive||(t.setAttribute("aria-live",s),t.dataset.contourAutoLive=s)}),t.querySelectorAll("input[required], textarea[required], select[required]").forEach(t=>{t.hasAttribute("aria-required")||t.setAttribute("aria-required","true")}),this._wireLabels(t),this._wireClose(t))}_wireClose(t){if(!t||this._wiredShadowClose)return;const e=t.querySelectorAll(".c-callout__close, .c-alert__close, .c-tag__remove, .c-filter-pill__remove");if(e.length){this._wiredShadowClose=!0;for(const t of e)t.addEventListener("click",()=>{this.hidden=!0,this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))})}}_wireLabels(t){t&&t.querySelectorAll("label").forEach(t=>{const e=t.querySelector("slot"),r=t.closest(".c-field")||t.parentElement,s=[];if(e)for(const t of e.assignedElements({flatten:!0}))t.matches("input, textarea, select")&&s.push(t);if(!s.length&&r){const t=r.querySelector('slot[name="input"]');if(t)for(const e of t.assignedElements({flatten:!0}))e.matches("input, textarea, select")&&s.push(e)}for(const e of s){if(e.id||(e.id=contourId("shadow-input")),t.hasAttribute("for")||t.setAttribute("for",e.id),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")){const r=assignedText(t);r&&e.setAttribute("aria-label",r)}if(e._contourLabelWired||(e._contourLabelWired=!0,t.addEventListener("click",t=>{if(!t.target.closest("a, button, input, textarea, select"))try{e.click()}catch(t){}})),r&&!e.hasAttribute("aria-describedby")){const t=r.querySelector(".c-field__hint"),s=r.querySelector(".c-field__error"),i=[];t&&(t.id||(t.id=contourId("hint")),i.push(t.id)),s&&(s.id||(s.id=contourId("err")),i.push(s.id)),i.length&&e.setAttribute("aria-describedby",i.join(" "))}}})}connectedCallback(){this.applyMods();try{this.enhance(this.shadowRoot)}catch(t){}this._applyLabels();try{wcReset(this),wireTabs(this),wireSegmented(this),wireCombobox(this),wireTree(this),wireMenu(this),wirePagination(this),wireCopy(this),wireRemovable(this)}catch(t){}this.shadowRoot&&!this._wiredSlotchange&&(this._wiredSlotchange=!0,this.shadowRoot.addEventListener("slotchange",()=>{try{this.enhance(this.shadowRoot),this._applyLabels(),wireTabs(this),wireSegmented(this),wireCombobox(this),wireTree(this),wireMenu(this),wirePagination(this),wireCopy(this),wireRemovable(this)}catch(t){}}))}attributeChangedCallback(){this.applyMods(),this._applyLabels()}_applyLabels(){const t=this.shadowRoot;if(!t)return;const e=(e,r,s)=>{const i=t.querySelector(e);i&&i.setAttribute("aria-label",labelText(this,r,s))};e(".c-callout__close","close","Close"),e(".c-alert__close","close","Close"),e(".c-tag__remove","remove","Remove"),e(".c-filter-pill__remove","remove-filter","Remove filter"),e(".c-breadcrumb","breadcrumb","Breadcrumb"),e(".c-spinner","loading","Loading"),e(".c-install__copy","copy-command","Copy command");const r=t.querySelector(".c-install__copy, .c-code__copy");r&&"Copy"===r.textContent.trim()&&(r.textContent=labelText(this,"copy","Copy"))}applyMods(){const t=this.shadowRoot.firstElementChild;if(!t||!this._shadowBase)return;const e=[];for(const t of MODS){const r=this.getAttribute(t);if(r)for(const t of this._shadowBase.split(/\s+/))t&&e.push("c-"+t.replace(/^c-/,"")+"--"+r)}if(t.className=(this._shadowBase+" "+e.join(" ")).trim(),t.classList.contains("c-alert")){const e=t.classList.contains("c-alert--warning")||t.classList.contains("c-alert--danger"),r=e?"alert":"status",s=e?"assertive":"polite";t.hasAttribute("role")&&!t.dataset.contourAutoRole||(t.setAttribute("role",r),t.dataset.contourAutoRole=r),t.hasAttribute("aria-live")&&!t.dataset.contourAutoLive||(t.setAttribute("aria-live",s),t.dataset.contourAutoLive=s)}}}const SHADOW_PARTS_PUBLIC={},SHADOW_MARKUP={},recordParts=(t,e)=>{SHADOW_PARTS_PUBLIC[t]=[...e.matchAll(/part="([^"]+)"/g)].flatMap(t=>t[1].split(/\s+/)).filter(Boolean)},shadow=(t,e)=>{if(SHADOW_MARKUP[t]=e,recordParts(t,e),"undefined"==typeof document)return;const r=document.createElement("template");setHTML(r,e);const s=class extends ContourShadow{};s.contourTemplate=r,define(t,s)},slotWrapper=(t,e,r)=>"<"+t+' class="c-'+e+'" part="'+(r||e)+'"'+("button"===t?' type="button"':"")+"><slot></slot></"+t+">",SHADOW_SLOTS={div:["accordion","activity","advanced","affordance","affordances","anchor","app","app-body","box","btn-group","chart-grid","catchment","cluster","command","compare","comparison","compass","contour-plot","cta","dash-freshness","dash-kpi-row","dash-shell","dash-toolbar","datamark","delta","draggable","drag-handle","drop-indicator","drop-zone","destructive-hint","docs-shell","drawer","elevation","filter-bar","flow-map","heatmap","hexbin","icon-badge","input-group","instrument","range-scale","resizable","table-wrap","time-range","toast-host","scroll-area","isochrone","landing-features","landing-hero","layer-panel","layer-switch","legend","logos","map-area","map-footer","map-panel","map-slot","measure","metrics","minimap","pager","pagination","panel","plate","price","pricing","progress","prose","pullquote","radio-list","range","readout","recipe","reserved","resize-handle","row","row-action","scale-bar","scrim","segmented","sheet","shortcut-list","shortcut-overlay","shortcut-panel","shortcut-row","showcase","sidebar","skeleton","sparkline","stack","steps","streaming-chart","survey","theme-scope","time-slider","timeline","toast","toolbar","tooltip","tree","version","version-banner"],button:["btn","pressable"],span:["avatar","badge","chip","dot","flag","live-badge","mark","pill"],a:["link","linkish"],kbd:["kbd"],label:["check","radio","switch"],nav:["docs-nav"]},SHADOW_PARTS={"version-banner":"banner","contour-plot":"plot"};for(const[t,e]of Object.entries(SHADOW_SLOTS))for(const r of e){shadow("contour-shadow-"+r,slotWrapper(t,r,SHADOW_PARTS[r]||r))}shadow("contour-shadow-callout",'<div class="c-callout" part="callout"><div class="c-callout__title" part="title"><slot name="title"></slot></div><div class="c-callout__body" part="body"><slot></slot></div><button class="c-callout__close" part="close" type="button" aria-label="Close">×</button></div>'),shadow("contour-shadow-empty",'<div class="c-empty" part="empty"><div class="c-empty__illustration" part="illustration"><slot name="illustration"></slot></div><div class="c-empty__title" part="title"><slot name="title"></slot></div><div class="c-empty__text" part="body"><slot></slot></div><div><slot name="action"></slot></div></div>'),shadow("contour-shadow-feature",'<div class="c-feature" part="feature"><span class="c-feature__index" part="index"><slot name="index"></slot></span><div class="c-feature__title" part="title"><slot name="title"></slot></div><div class="c-feature__body" part="body"><slot></slot></div></div>'),shadow("contour-shadow-kpi",'<div class="c-kpi" part="kpi"><div class="c-kpi__value" part="value"><slot name="value"></slot></div><div class="c-kpi__label" part="label"><slot name="label"></slot></div><div class="c-kpi__foot" part="foot"><slot name="delta"></slot><slot name="note"></slot></div></div>'),shadow("contour-shadow-stat",'<div class="c-stat" part="stat"><div class="c-stat__value" part="value"><slot name="value"></slot></div><div class="c-stat__label" part="label"><slot name="label"></slot></div><div class="c-stat__delta" part="delta"><slot name="delta"></slot></div></div>'),shadow("contour-shadow-meter",'<div class="c-meter" part="meter"><span class="c-meter__core" part="core"><span class="c-meter__value" part="value"><slot name="value"></slot></span><span class="c-meter__label" part="label"><slot name="label"></slot></span></span></div>'),shadow("contour-shadow-brownout",'<div class="c-brownout" part="brownout" data-level="0"><slot></slot></div>'),shadow("contour-shadow-widget-state",'<div class="c-widget-state" part="widget-state"><slot></slot></div>'),shadow("contour-shadow-donut",'<div class="c-donut" part="donut"><svg class="c-donut__ring" part="ring" viewBox="0 0 32 32"></svg><div class="c-donut__center" part="center"><slot name="value"></slot></div><div class="c-donut__list" part="list"><slot></slot></div></div>'),shadow("contour-shadow-axis",'<div class="c-axis" part="axis"><slot></slot></div>'),shadow("contour-shadow-brush",'<div class="c-brush" part="brush"><div class="c-brush__selection" part="selection"></div></div>'),shadow("contour-shadow-stacked-bar",'<div class="c-stacked-bar" part="bar"><slot></slot></div>'),shadow("contour-shadow-category",'<div class="c-category" part="category" role="listbox"><slot></slot></div>'),shadow("contour-shadow-gauge",'<div class="c-gauge" part="gauge"><svg class="c-gauge__dial" part="dial" aria-hidden="true" viewBox="0 0 100 100"><path class="c-gauge__track" part="track" d="M 10 90 A 40 40 0 0 1 90 90"></path><g class="c-gauge__zones"></g><line class="c-gauge__needle" part="needle" x1="50" y1="50" x2="50" y2="15"></line><circle class="c-gauge__hub" part="hub" cx="50" cy="50" r="4"></circle></svg><div class="c-gauge__value" part="value"><slot name="value"></slot></div><div class="c-gauge__band" part="band"><slot name="band"></slot></div></div>'),shadow("contour-shadow-diff",'<div class="c-diff" part="diff"><div class="c-diff__line c-diff__line--del" part="before"><span class="c-diff__sign">−</span><span><slot name="before"></slot></span></div><div class="c-diff__line c-diff__line--add" part="after"><span class="c-diff__sign">+</span><span><slot name="after"></slot></span></div></div>'),shadow("contour-shadow-do-dont",'<div class="c-do-dont" part="do-dont"><div class="c-do-dont__item c-do-dont__item--do" part="do"><slot name="do"></slot></div><div class="c-do-dont__item c-do-dont__item--dont" part="dont"><slot name="dont"></slot></div></div>'),shadow("contour-shadow-threshold",'<div class="c-threshold" part="threshold"><span class="c-threshold__fill" part="value"></span><span class="c-threshold__target" part="target"></span></div>'),shadow("contour-shadow-coordinate",'<div class="c-coordinate" part="coordinate"><span class="c-coordinate__value" part="value"><slot name="value"></slot></span></div>'),shadow("contour-shadow-install",'<div class="c-install" part="install"><span class="c-install__prompt" part="prompt"><slot name="prompt"></slot></span><span class="c-install__command" part="command"><slot name="command"></slot></span><button class="c-btn c-btn--ghost c-btn--sm c-install__copy" part="copy" type="button" aria-label="Copy command">Copy</button></div>'),shadow("contour-shadow-toc",'<div class="c-toc" part="toc"><div class="c-toc__title" part="title"><slot name="title"></slot></div><nav class="c-toc__list" part="list"><slot></slot></nav></div>'),shadow("contour-shadow-testimonial",'<div class="c-testimonial" part="testimonial"><blockquote class="c-testimonial__quote" part="quote"><slot name="quote"></slot></blockquote><div class="c-testimonial__byline" part="byline"><span class="c-testimonial__name" part="name"><slot name="name"></slot></span><span class="c-testimonial__role" part="role"><slot name="role"></slot></span></div></div>'),shadow("contour-shadow-search-trigger",'<button class="c-search-trigger" part="trigger"><span><slot name="label"></slot></span><kbd class="c-search-trigger__kbd"><slot name="shortcut"></slot></kbd></button>'),shadow("contour-shadow-brand",'<a class="c-brand" part="brand"><span class="c-mark" part="mark"><slot name="mark"></slot></span><span class="c-brand__name" part="name"><slot name="name"></slot></span></a>'),shadow("contour-shadow-section-head",'<div class="c-section-head" part="head"><h2 class="c-section-head__title" part="title"><slot name="title"></slot></h2><p class="c-section-head__desc" part="desc"><slot name="desc"></slot></p></div>'),shadow("contour-shadow-loading",'<div class="c-loading" part="loading"><span class="c-spinner" part="spinner"></span><slot></slot></div>'),shadow("contour-shadow-tabs",'<div class="c-tabs" part="tabs"><div class="c-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-tabs__panels" role="presentation"><slot></slot></div></div>'),shadow("contour-shadow-breadcrumb",'<nav class="c-breadcrumb" part="breadcrumb" aria-label="Breadcrumb"><ol><slot></slot></ol></nav>'),shadow("contour-shadow-menu",'<div class="c-menu" part="menu" role="menu"><slot></slot></div>'),shadow("contour-shadow-combobox",'<div class="c-combobox" part="combobox"><input class="c-combobox__input" part="input" type="text" /><ul class="c-combobox__list" part="list" hidden><slot></slot></ul></div>'),shadow("contour-shadow-chart",'<div class="c-chart" part="chart"><div class="c-chart__plot" part="plot"><slot></slot></div></div>'),shadow("contour-shadow-bivariate",'<div class="c-bivariate" part="bivariate"><div class="c-bivariate__matrix" part="matrix"><slot></slot></div></div>'),shadow("contour-shadow-bivariate-legend",'<div class="c-bivariate-legend" part="legend"><div class="c-bivariate-legend__matrix" part="matrix"><slot></slot></div></div>'),shadow("contour-shadow-expandable",'<details class="c-expandable" part="expandable"><summary class="c-expandable__summary"><slot name="summary"></slot></summary><div class="c-expandable__body" part="body"><slot></slot></div></details>'),shadow("contour-shadow-disclosure",'<details class="c-disclosure" part="disclosure"><summary><slot name="summary"></slot></summary><div class="c-disclosure__body" part="body"><slot></slot></div></details>'),shadow("contour-shadow-faq",'<div class="c-faq" part="faq"><div class="c-faq__question" part="question"><slot name="question"></slot></div><div class="c-faq__answer" part="answer"><slot name="answer"></slot></div></div>'),shadow("contour-shadow-code-tabs",'<div class="c-code-tabs" part="code-tabs"><div class="c-code-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-code-tabs__panels"><slot></slot></div></div>'),shadow("contour-shadow-header",'<header class="c-header" part="header"><div class="container c-header__inner" part="inner"><a class="c-brand" part="brand"><slot name="brand"></slot></a><nav class="c-header__nav" part="nav"><slot name="nav"></slot></nav><div class="c-header__actions" part="actions"><slot name="actions"></slot></div></div></header>'),shadow("contour-shadow-footer",'<footer class="c-footer" part="footer"><div class="container c-footer__grid" part="grid"><div class="c-footer__brand" part="brand"><slot name="brand"></slot></div><div class="c-footer__links" part="links"><slot name="links"></slot></div></div></footer>'),shadow("contour-shadow-container",'<div class="container" part="container"><slot></slot></div>'),shadow("contour-shadow-spinner",'<span class="c-spinner" part="spinner" aria-label="Loading"></span>'),shadow("contour-shadow-code",'<pre class="c-code" part="code"><code><slot></slot></code><button class="c-code__copy" part="copy" type="button">Copy</button></pre>'),shadow("contour-shadow-card",'<div class="c-card" part="card"> <div class="c-card__title" part="head"><slot name="title">Untitled</slot></div> <div class="c-card__body" part="body"><slot></slot></div> <div class="c-card__foot" part="foot"><slot name="foot"></slot></div> </div>'),shadow("contour-shadow-field",'<div class="c-field" part="field"> <label class="c-field__label" part="label"><slot name="label">Label</slot></label> <slot name="input"></slot> <span class="c-field__hint" part="hint"><slot name="hint"></slot></span> </div>'),shadow("contour-shadow-alert",'<div class="c-alert" part="alert"> <div class="c-alert__title" part="title"><slot name="title"></slot></div> <div class="c-alert__body" part="body"><slot></slot></div> <div class="c-alert__actions" part="actions"><slot name="action"></slot></div> <button class="c-alert__close" part="close" type="button" aria-label="Close">×</button> </div>'),shadow("contour-shadow-tag",'<span class="c-tag" part="tag"><slot></slot><button class="c-tag__remove" part="remove" type="button" aria-label="Remove">×</button></span>'),shadow("contour-shadow-filter-pill",'<span class="c-filter-pill" part="filter-pill"><slot></slot><button class="c-filter-pill__remove" part="remove" type="button" aria-label="Remove filter">×</button></span>');const DIALOG_MARKUP='<dialog class="c-dialog" part="dialog"> <div class="c-dialog__head" part="head"> <slot name="title"></slot> <button class="c-btn c-btn--icon c-btn--ghost" part="close" type="button" aria-label="Close"> <svg aria-hidden="true" viewBox="0 0 24 24"><path d="m18 6-12 12M6 6l12 12" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg> </button> </div> <div class="c-dialog__body" part="body"><slot></slot></div> <div class="c-dialog__foot" part="foot"><slot name="foot"></slot></div> </dialog>';SHADOW_MARKUP["contour-shadow-dialog"]=DIALOG_MARKUP,recordParts("contour-shadow-dialog",DIALOG_MARKUP);class ContourShadowDialog extends ContourShadow{static contourTemplate="undefined"!=typeof document?(()=>{const t=document.createElement("template");return setHTML(t,DIALOG_MARKUP),t})():null;enhance(t){if(super.enhance(t),this._wiredShadowDialog)return;this._wiredShadowDialog=!0;const e=t.querySelector("dialog"),r=t.querySelector('[part="close"]');if(r&&r.addEventListener("click",()=>e?.close()),e){let t=null;e.addEventListener("beforetoggle",r=>{if("open"===r.newState){t=document.activeElement,this._syncingOpenAttr=!0,this.hasAttribute("open")||this.setAttribute("open",""),this._syncingOpenAttr=!1,this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}));const s=e.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(s)try{s.focus()}catch(r){}}else if("closed"===r.newState&&(this._syncingOpenAttr=!0,this.hasAttribute("open")&&this.removeAttribute("open"),this._syncingOpenAttr=!1,this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})),t&&"function"==typeof t.focus))try{t.focus()}catch(r){}});const r=()=>{const t="button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])",r=Array.from(e.querySelectorAll(t));for(const s of e.querySelectorAll("slot"))for(const e of s.assignedElements({flatten:!0})){e.matches(t)&&r.push(e);for(const s of e.querySelectorAll(t))r.push(s)}return r},s=()=>this.shadowRoot&&this.shadowRoot.activeElement||document.activeElement;e.addEventListener("keydown",t=>{if("Tab"!==t.key)return;const e=r();if(!e.length)return;const i=e[0],a=e[e.length-1];t.shiftKey&&s()===i?(t.preventDefault(),a.focus()):t.shiftKey||s()!==a||(t.preventDefault(),i.focus())})}}static get observedAttributes(){return[...super.observedAttributes,"open"]}attributeChangedCallback(t,e,r){if(super.attributeChangedCallback(t,e,r),"open"===t&&this.shadowRoot&&!this._syncingOpenAttr){const t=this.shadowRoot.querySelector("dialog");t&&(null===r||t.open?null===r&&t.open&&this.close():this.show())}}connectedCallback(){super.connectedCallback(),this.hasAttribute("open")&&this.show()}show(){if(!this.isConnected)return void(this.hasAttribute("open")||this.setAttribute("open",""));const t=this.shadowRoot?.querySelector("dialog");t&&!t.open&&t.showModal()}close(){const t=this.shadowRoot?.querySelector("dialog");t&&t.open&&t.close()}showModal(){this.show()}get open(){return!!this.shadowRoot?.querySelector("dialog")?.open}set open(t){t?this.show():this.close()}get returnValue(){return this.shadowRoot?.querySelector("dialog")?.returnValue??""}set returnValue(t){const e=this.shadowRoot?.querySelector("dialog");e&&(e.returnValue=String(t))}}define("contour-shadow-dialog",ContourShadowDialog);const renderShadowDSD=(t,e="",r="")=>{const s=SHADOW_MARKUP[t];if("string"!=typeof s)return null;return`<${t}${e?e.startsWith(" ")?e:" "+e:""}><template shadowrootmode="open">${s}</template>${r}</${t}>`},FROZEN_SHADOW_MARKUP=Object.freeze({...SHADOW_MARKUP});if("undefined"!=typeof globalThis&&(globalThis.ContourShadowTemplates=FROZEN_SHADOW_MARKUP),"undefined"!=typeof window){window.ContourShadowParts=Object.freeze(Object.fromEntries(Object.entries(SHADOW_PARTS_PUBLIC).map(([t,e])=>[t,Object.freeze([...new Set(e)])]))),window.Contour||(window.Contour={});try{window.Contour.shadowTemplates=FROZEN_SHADOW_MARKUP}catch{}}export{SHADOW_MARKUP,renderShadowDSD};"undefined"!=typeof window&&(window.ContourVersion=CONTOUR_VERSION,window.Contour||(window.Contour={format:{value:formatValue,number:(t,e,r)=>formatValue(t,e,r),time:(t,e)=>{try{return new Intl.DateTimeFormat(e||void 0).format(new Date(t))}catch(e){return String(t)}},locale:t=>t||("undefined"!=typeof navigator?navigator.language:"en")},markers:{shapes:MARKER_SHAPES,styles:markerStyles,assign:assignMarkers}}),queueMicrotask(()=>{try{window.dispatchEvent(new CustomEvent("contour:ready",{detail:{version:CONTOUR_VERSION,count:REGISTERED.length}}))}catch(t){}}));
|