contour-ds 1.12.0 → 1.13.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/dist/build-manifest.json +80 -80
- package/dist/contour-wc-content.esm.js +8 -1
- package/dist/contour-wc-content.esm.min.js +1 -1
- package/dist/contour-wc-core.esm.js +15 -8
- package/dist/contour-wc-core.esm.min.js +1 -1
- package/dist/contour-wc-dashboard.esm.js +279 -20
- package/dist/contour-wc-dashboard.esm.min.js +1 -1
- package/dist/contour-wc-data.esm.js +279 -20
- package/dist/contour-wc-data.esm.min.js +1 -1
- package/dist/contour-wc-docs.esm.js +4 -0
- package/dist/contour-wc-feedback.esm.js +59 -7
- package/dist/contour-wc-feedback.esm.min.js +1 -1
- package/dist/contour-wc-forms.esm.js +20 -2
- package/dist/contour-wc-forms.esm.min.js +1 -1
- package/dist/contour-wc-interaction.esm.js +4 -0
- package/dist/contour-wc-layout.esm.js +4 -0
- package/dist/contour-wc-map.esm.js +4 -0
- package/dist/contour-wc-misc.esm.js +4 -0
- package/dist/contour-wc-navigation.esm.js +24 -14
- package/dist/contour-wc-navigation.esm.min.js +1 -1
- package/dist/contour-wc-ui.esm.js +290 -13
- package/dist/contour-wc-ui.esm.min.js +1 -1
- package/dist/contour-wc.esm.js +675 -65
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +675 -65
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +1 -1
- package/dist/contour.components.json +175 -16
- package/dist/contour.css +160 -1
- package/dist/contour.d.ts +6 -4
- package/dist/contour.html-data.json +68 -2
- package/dist/contour.min.css +1 -1
- package/dist/contour.react.d.ts +2 -2
- package/dist/contour.single.html +1 -1
- package/dist/contour.single.min.css +1 -1
- package/dist/contour.vue.d.ts +2 -2
- package/dist/contour.web-types.json +68 -3
- package/dist/custom-elements.json +265 -2
- package/dist/docs/actions.md +1 -1
- package/dist/docs/affordances.md +1 -1
- package/dist/docs/apireference.md +1 -1
- package/dist/docs/colour.md +1 -1
- package/dist/docs/componentindex.md +1 -1
- package/dist/docs/data.md +1 -1
- package/dist/docs/docs.md +1 -1
- package/dist/docs/feedback.md +1 -1
- package/dist/docs/field.md +1 -1
- package/dist/docs/forms.md +1 -1
- package/dist/docs/index.json +2 -2
- package/dist/docs/install.md +1 -1
- package/dist/docs/landing.md +1 -1
- package/dist/docs/mapengine.md +1 -1
- package/dist/docs/motion.md +1 -1
- package/dist/docs/navigation.md +1 -1
- package/dist/docs/overlays.md +1 -1
- package/dist/docs/overview.md +1 -1
- package/dist/docs/patterns.md +1 -1
- package/dist/docs/playground.md +1 -1
- package/dist/docs/principles.md +1 -1
- package/dist/docs/recipes.md +1 -1
- package/dist/docs/space.md +1 -1
- package/dist/docs/status.md +1 -1
- package/dist/docs/surfaces.md +1 -1
- package/dist/docs/theming.md +1 -1
- package/dist/docs/type.md +1 -1
- package/dist/docs/webcomponents.md +1 -1
- 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/wc/behaviours.mjs +13 -7
- package/dist/wc/content.mjs +4 -1
- package/dist/wc/core.mjs +1 -0
- package/dist/wc/data-chart.mjs +147 -12
- package/dist/wc/data-export.mjs +43 -5
- package/dist/wc/data-series.mjs +74 -0
- package/dist/wc/data-table.mjs +13 -5
- package/dist/wc/feedback.mjs +55 -7
- package/dist/wc/forms-input.mjs +16 -2
- package/dist/wc/index.mjs +1 -1
- package/dist/wc/navigation-menu.mjs +20 -14
- package/dist/wc/shadow.mjs +4 -0
- package/dist/wc/ui-atoms.mjs +134 -3
- package/dist/wc/ui-data.mjs +67 -0
- package/dist/wc/ui-feedback.mjs +8 -1
- package/dist/wc/ui-overlays.mjs +77 -9
- package/integrations/libreship/contract.json +9 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CLASS_ONLY,CONTOUR_EVENTS,ContourBase,MERCATOR_MAX_LAT,MODS,OBSERVED,REGISTERED,applyLabel,bearing,clampLat,contourId,cssLength,define,flagOn,flagOnValue,formatValue,haversine,headingTag,iconMarkup,isRtl,labelText,levelFromAttributes,mercatorResolution,navKey,normaliseLng,onDispose,safeColor,safeHref,sanitizeHtml,setHTML,simple,statusIcon,supportsUntilFound,unwrapBounds,warnBadJson,wcEmitOverlay,withBrownout,PROPERTY_FIELDS,normalizeProperty,propertyDescriptor,propertyTypeOf,contourDiagnosticsEnabled,setContourDiagnostics,MARKER_SHAPES,arcPath,assignMarkers,barRects,compassNeedle,contourPaths,donutSlices,isMissing,marchingSquares,markerStyles,niceTicks,polylinePoints,scaleBarTicks,smoothPath,modalContain,wcReset,wireCombobox,wireCopy,wireMenu,wirePagination,wireRemovable,wireSegmented,wireTabs,wireTree,STATE_FALLBACK,loadRemote,parseArrayAttr,remoteData,remoteInvalidate,remoteRefresh,remoteVisible,renderEmpty,renderStates,stateLabel,virtualRange,watchViewport,wireStates}from"./contour-wc-core.esm.js";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 s=0;s<t.length;s++)e^=t.charCodeAt(s),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 s="-1";try{const t=e.cssRules;let r="";for(let e=0;e<t.length;e++)r+=t[e].cssText+"\n";s=t.length+":"+_hashCss(r)}catch(t){}t+=(e.href||"inline")+"~"+s+"|"}if(ADOPTED&&t===ADOPTED_KEY)return ADOPTED;ADOPTED_KEY=t,ADOPTED=[];const e=(t,s)=>{let r;try{r=t.cssRules}catch(t){return}if(r)for(const t of r)if(t instanceof CSSImportRule)t.styleSheet&&e(t.styleSheet,s);else try{s.push(t.cssText)}catch(t){}};for(const t of document.styleSheets)try{if(!t.href||new URL(t.href).origin===location.origin){const s=[];e(t,s);const r=new CSSStyleSheet;s.length&&r.replaceSync(s.join("\n")),ADOPTED.push(r)}}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 s=e.getAttribute("aria-controls");if(s){const r=t.querySelector("#"+CSS.escape(s))||document.getElementById(s);r&&!r.hasAttribute("aria-labelledby")&&(e.id||(e.id=contourId("tab")),r.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 s=e.querySelector(".c-field__hint");s&&(s.id||(s.id=contourId("hint")),t.setAttribute("aria-describedby",s.id));const r=e.querySelector(".c-field__error");if(r){r.id||(r.id=contourId("err"));const e=t.getAttribute("aria-describedby")||"";t.setAttribute("aria-describedby",(e+" "+r.id).trim())}}}),t.querySelectorAll(".c-alert").forEach(t=>{const e=t.classList.contains("c-alert--warning")||t.classList.contains("c-alert--danger"),s=e?"alert":"status",r=e?"assertive":"polite";t.hasAttribute("role")&&!t.dataset.contourAutoRole||(t.setAttribute("role",s),t.dataset.contourAutoRole=s),t.hasAttribute("aria-live")&&!t.dataset.contourAutoLive||(t.setAttribute("aria-live",r),t.dataset.contourAutoLive=r)}),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"),s=t.closest(".c-field")||t.parentElement,r=[];if(e)for(const t of e.assignedElements({flatten:!0}))t.matches("input, textarea, select")&&r.push(t);if(!r.length&&s){const t=s.querySelector('slot[name="input"]');if(t)for(const e of t.assignedElements({flatten:!0}))e.matches("input, textarea, select")&&r.push(e)}for(const e of r){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 s=assignedText(t);s&&e.setAttribute("aria-label",s)}if(e._contourLabelWired||(e._contourLabelWired=!0,t.addEventListener("click",t=>{if(!t.target.closest("a, button, input, textarea, select"))try{e.click()}catch(t){}})),s&&!e.hasAttribute("aria-describedby")){const t=s.querySelector(".c-field__hint"),r=s.querySelector(".c-field__error"),i=[];t&&(t.id||(t.id=contourId("hint")),i.push(t.id)),r&&(r.id||(r.id=contourId("err")),i.push(r.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,s,r)=>{const i=t.querySelector(e);i&&i.setAttribute("aria-label",labelText(this,s,r))};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 s=t.querySelector(".c-install__copy, .c-code__copy");s&&"Copy"===s.textContent.trim()&&(s.textContent=labelText(this,"copy","Copy"))}applyMods(){const t=this.shadowRoot.firstElementChild;if(!t||!this._shadowBase)return;const e=[];for(const t of MODS){const s=this.getAttribute(t);if(s)for(const t of this._shadowBase.split(/\s+/))t&&e.push("c-"+t.replace(/^c-/,"")+"--"+s)}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"),s=e?"alert":"status",r=e?"assertive":"polite";t.hasAttribute("role")&&!t.dataset.contourAutoRole||(t.setAttribute("role",s),t.dataset.contourAutoRole=s),t.hasAttribute("aria-live")&&!t.dataset.contourAutoLive||(t.setAttribute("aria-live",r),t.dataset.contourAutoLive=r)}}}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 s=document.createElement("template");setHTML(s,e);const r=class extends ContourShadow{};r.contourTemplate=s,define(t,r)},slotWrapper=(t,e,s)=>"<"+t+' class="c-'+e+'" part="'+(s||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 s of e){shadow("contour-shadow-"+s,slotWrapper(t,s,SHADOW_PARTS[s]||s))}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"),s=t.querySelector('[part="close"]');if(s&&s.addEventListener("click",()=>e?.close()),e){let t=null;e.addEventListener("beforetoggle",s=>{if("open"===s.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 r=e.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(r)try{r.focus()}catch(s){}}else if("closed"===s.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(s){}});const s=()=>{const t="button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])",s=Array.from(e.querySelectorAll(t));for(const r of e.querySelectorAll("slot"))for(const e of r.assignedElements({flatten:!0})){e.matches(t)&&s.push(e);for(const r of e.querySelectorAll(t))s.push(r)}return s},r=()=>this.shadowRoot&&this.shadowRoot.activeElement||document.activeElement;e.addEventListener("keydown",t=>{if("Tab"!==t.key)return;const e=s();if(!e.length)return;const i=e[0],a=e[e.length-1];t.shiftKey&&r()===i?(t.preventDefault(),a.focus()):t.shiftKey||r()!==a||(t.preventDefault(),i.focus())})}}static get observedAttributes(){return[...super.observedAttributes,"open"]}attributeChangedCallback(t,e,s){if(super.attributeChangedCallback(t,e,s),"open"===t&&this.shadowRoot&&!this._syncingOpenAttr){const t=this.shadowRoot.querySelector("dialog");t&&(null===s||t.open?null===s&&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="",s="")=>{const r=SHADOW_MARKUP[t];if("string"!=typeof r)return null;return`<${t}${e?e.startsWith(" ")?e:" "+e:""}><template shadowrootmode="open">${r}</template>${s}</${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};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 s=document.createElement("span");s.className="c-readout__key",s.textContent=t.key||t[0];const r=document.createElement("span");r.className="c-readout__value"+(t.primary?" c-readout__value--primary":"")+(t.accent?" c-readout__value--accent":"")+(t.coord?" c-readout__value--coord":""),r.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&&(r.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(r.textContent=formatValue(n,this.getAttribute("format"),this.getAttribute("locale"),void 0!==t.unit?t.unit:this.getAttribute("unit")),e.appendChild(s),e.appendChild(r),t.order){const s=document.createElement("span");s.className="c-readout__order",s.textContent=t.order,e.appendChild(s)}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"),s=this.getAttribute("delta"),r=this.getAttribute("variant");if(Array.from(this.classList).forEach(t=>{t.startsWith("c-kpi--")&&this.classList.remove(t)}),r&&this.classList.add("c-kpi--"+r),t){const e=this.ensure(".c-kpi__value",()=>{const t=document.createElement("div");return t.className="c-kpi__value",t.setAttribute("aria-live","polite"),t}),s=formatValue(t,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit")),r=null!=this._kpiLastValue&&this._kpiLastValue!==s;this._kpiLastValue=s,e.textContent=s,r&&(e.classList.remove("is-updating"),e.offsetWidth,e.classList.add("is-updating"))}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 s=t.querySelector(".c-kpi__label");s||(s=document.createElement("div"),s.className="c-kpi__label",t.appendChild(s)),s.textContent=e,t.parentNode!==this&&this.insertBefore(t,this.firstChild)}else{const t=this.querySelector(".c-kpi__head");t&&t.remove()}if(s){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 r=this.getAttribute("direction")||"up",i=this.getAttribute("polarity")||"neutral";let a="neutral";"good"===i||"up-good"===i||"auto"===i?a="up"===r?"good":"down"===r?"bad":"neutral":"bad"!==i&&"down-good"!==i||(a="up"===r?"bad":"down"===r?"good":"neutral"),e.className="c-delta c-delta--"+r+" c-delta--"+a,e.textContent="";const n={up:"#i-arrow-up",down:"#i-arrow-down",flat:"#i-minus"}[r]||"#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(" "+s))}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 s=()=>{if(!t.isConnected)return;const s=t.clientWidth,r=t.clientHeight;if(!s||!r)return;const i="undefined"!=typeof window&&window.devicePixelRatio||1;t.width=Math.round(s*i),t.height=Math.round(r*i);const a=t.getContext&&t.getContext("2d");if(!a)return;a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,s,r);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)*(s-4)+2)(i),c=(t=>r-2-(t-n)/o*(r-4))(t);0===i?a.moveTo(l,c):a.lineTo(l,c)}),a.stroke()};"function"==typeof requestAnimationFrame?requestAnimationFrame(s):s(),"undefined"==typeof ResizeObserver||this._sparkRO||(this._sparkRO=new ResizeObserver(()=>s()),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 s=this._cellValue(t[e]);if(""!==s)return String(s)}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,s)=>{this._selectedKeys.has(this._rowKey(t))&&e.add(s)}),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,s){if(t&&"object"==typeof t&&!Array.isArray(t)){const r="string"==typeof e?e:e&&(e.key||e.label||e.title)||"";return r&&void 0!==t[r]?t[r]:t[s]}return t?t[s]:void 0}_compare(t,e,s){const r=this._cellValue(t),i=this._cellValue(e);return"number"===s||"numeric"===s?(parseFloat(r)||0)-(parseFloat(i)||0):String(r).localeCompare(String(i),void 0,{numeric:!0})}_applyVisibleColumns(t){const e=this.getAttribute("visible-columns");if(!e)return;let s=null;try{const t=JSON.parse(e);Array.isArray(t)&&(s=new Set(t.map(Number)))}catch(t){}if(!s||!s.size)return;const r=t=>s.has(t);t.querySelectorAll("thead tr th").forEach((t,e)=>{t.hidden=!r(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=!r(e)})})}render(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Table");let t=this.querySelector(".c-table__selection-status");t||(t=document.createElement("span"),t.className="c-table__selection-status visually-hidden",t.setAttribute("aria-live","polite"),this.appendChild(t));const e=this._selectionControlled?this._selectedKeys?this._selectedKeys.size:0:this._selectedRows?this._selectedRows.size:0;if(t.textContent=e?`${e} selected`:"",wireStates(this),loadRemote(this,"rows"),renderStates(this,"table"))return;const s=this.getAttribute("columns"),r=remoteData(this,"rows"),i=Array.from(this.children).filter(t=>!t.classList||!t.classList.contains("c-table-wrap")&&!t.classList.contains("c-table__selection-status"));if(s&&r&&!i.length)try{const t=JSON.parse(s),e=JSON.parse(r),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 e=Number(i);this._sortCol=Number.isFinite(e)?e:t.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(e)?e.slice():[];if(null!==this._sortCol&&void 0!==this._sortCol&&this._sortCol>=0&&this._sortCol<t.length){const e=this._sortCol,s=this._sortDir||1,r=t[e],i="object"==typeof r&&r&&r.sortType?r.sortType:"text";n.sort((t,a)=>this._compare(this._cellFor(t,r,e),this._cellFor(a,r,e),i)*s)}this._filters||(this._filters={});const o=Object.keys(this._filters).filter(t=>this._filters[t]);o.length&&(n=n.filter(e=>o.every(s=>{const r=Number(s),i=String(this._filters[r]||"").toLowerCase();return!i||String(this._cellValue(this._cellFor(e,t[r],r))).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 b=1,m=n;if(u){b=Math.max(1,Math.ceil(n.length/c)),h>b&&(h=b);const t=(h-1)*c;m=n.slice(t,t+c)}this._page=h,this._totalPages=b,this._pageSize=c,this._rowData=m,this._keyCol=t.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(t),v=g.querySelector("table.c-table")&&this._tableCols===_?g.querySelector("table.c-table"):(()=>{const e=document.createElement("table");e.className="c-table";const s=document.createElement("caption");s.className="visually-hidden",s.textContent=this.getAttribute("title")||this.getAttribute("aria-label")||"Table",e.appendChild(s);const r=document.createElement("thead"),i=document.createElement("tr");return t.forEach((t,e)=>{const s="string"==typeof t?t:t.label||t.title||t,r=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)&&r.classList.add("c-table__number"),o){r.className=r.className.trim();const t=document.createElement("input");t.type="search",t.className="c-table__filter-input",t.placeholder=s,t.setAttribute("aria-label",labelText(this,"filter","Filter")+" "+s),t.dataset.filterIndex=String(e),this._filters&&this._filters[e]&&(t.value=this._filters[e]),r.appendChild(t)}else if(n){r.className=(r.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",r.appendChild(t)}else if(a){r.setAttribute("aria-sort",this._sortCol===e?-1===this._sortDir?"descending":"ascending":"none");const t=document.createElement("span");t.className="c-table__sort",t.textContent=s;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),r.appendChild(t)}else"object"==typeof t&&null!==t&&t.pinned?(r.className="c-table__pinned",r.textContent=s):r.textContent=s;a&&(r.setAttribute("tabindex","0"),r.setAttribute("role","columnheader"),r.dataset.sortIndex=String(e)),i.appendChild(r)}),r.appendChild(i),e.appendChild(r),e.appendChild(document.createElement("tbody")),e})();this._tableCols=_,this._applyVisibleColumns(v),t.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 y=v.querySelector("tbody"),f=null!=this._tablePendingScrollTop?this._tablePendingScrollTop:g.scrollTop;this._tablePendingScrollTop=null,y.innerHTML="";const A=this.hasAttribute("virtual")&&!u&&m.length>100,w=this._measuredRowHeight||cssLength("--data-grid-row-height",32),C=30,x=10;let E=0,S=m;A?(E=virtualRange(f,w,(C-x)*w,m.length,x).start,S=m.slice(E,E+C+2*x),v.setAttribute("aria-rowcount",String(m.length+1)),this._tableWindowStart=E):v.removeAttribute("aria-rowcount");const k=e=>{const s=document.createElement("tr");s.setAttribute("aria-hidden","true");const r=document.createElement("td");r.colSpan=t.length,r.style.blockSize=`${e}px`,r.style.padding="0",s.appendChild(r),y.appendChild(s)};if(A&&k(E*w),0===S.length){const e=document.createElement("tr"),s=document.createElement("td");s.colSpan=t.length,s.textContent=this.getAttribute("empty")||"No data",s.style.textAlign="center",s.style.color="var(--color-text-muted)",e.appendChild(s),y.appendChild(e)}else S.forEach((e,s)=>{const r=document.createElement("tr");r.dataset.rowIndex=String(E+s);const i=this._rowKey(e);r.dataset.rowKey=i,r.setAttribute("tabindex","-1"),t.forEach((t,a)=>{const n="object"==typeof t&&null!==t&&t.select,o="object"==typeof t&&null!==t&&("number"===t.type||"numeric"===t.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(E+s),t.setAttribute("aria-label",labelText(this,"select-row","Select row")+" "+(i??E+s+1)),t.dataset.contourPreserveKey=i,this._selectionControlled?this._selectedKeys.has(i)&&(t.checked=!0):this._selectedRows&&this._selectedRows.has(E+s)&&(t.checked=!0),l.appendChild(t)}else l.textContent=this._cellValue(this._cellFor(e,t,a));r.appendChild(l)}),y.appendChild(r)});if(A&&k(Math.max(0,m.length-E-S.length)*w),!y.querySelector('tr[tabindex="0"]')){const t=y.querySelector("tr[data-row-index]");t&&t.setAttribute("tabindex","0")}if(!this._measuredRowHeight&&!this._measuringRow){const t=y.querySelector("tr[data-row-index]"),e=t?t.getBoundingClientRect().height:0;e>0&&(this._measuredRowHeight=e,Math.abs(e-w)>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&&f>0&&g.scrollTop!==f&&(this._tableScrollRestoredAt="undefined"!=typeof performance&&performance.now?performance.now():Date.now(),g.scrollTop=f),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 s=document.createElement("span");s.textContent=`${labelText(this,"page","Page")} ${h} ${labelText(this,"of","of")} ${b}`;const r=document.createElement("button");r.className="c-btn c-btn--ghost c-btn--sm",r.type="button",r.textContent=labelText(this,"next","Next"),r.disabled=h>=b,r.dataset.action="next",t.appendChild(e),t.appendChild(s),t.appendChild(r)}else{const t=this.querySelector(".c-table__pagination");t&&t.remove()}}catch(t){warnBadJson(this,"attribute",t)}else r||i.length||renderEmpty(this,"table")}_updateSelectionStatus(){const t=this.querySelector(".c-table__selection-status");if(!t)return;const e=this._selectionControlled?this._selectedKeys?this._selectedKeys.size:0:this._selectedRows?this._selectedRows.size:0;t.textContent=e?`${e} selected`:""}_applySelectionToDom(){this.querySelectorAll(".c-table__row-select").forEach(t=>{const e=Number(t.dataset.rowIndex);if(!Number.isFinite(e))return;const s=this._rowData?this._rowData[e]:void 0,r=this._selectionControlled?this._selectedKeys.has(this._rowKey(s)):!(!this._selectedRows||!this._selectedRows.has(e));t.checked!==r&&(t.checked=r)});const t=this.querySelector(".c-table__select-all");if(t){const e=Array.from(this.querySelectorAll(".c-table__row-select")),s=e.filter(t=>t.checked).length;t.checked=e.length>0&&s===e.length,t.indeterminate=s>0&&s<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);if(!Number.isFinite(e))return;this._sortCol===e?1===this._sortDir?this._sortDir=-1:(this._sortCol=null,this._sortDir=1):(this._sortCol=e,this._sortDir=1);const s=this._sortCol===e?1===this._sortDir?"ascending":"descending":"none";this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:!0,composed:!0,detail:{column:e,direction:s}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{sort:this._sortCol===e?e:null,sortDir:s}}})),this.requestRender()};this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest('button[data-action="retry"]'):null;if(s&&this.contains(s))return e.preventDefault(),void this.dispatchEvent(new CustomEvent("contour:retry",{detail:{src:this.getAttribute("src")},bubbles:!0,composed:!0}));const r=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;if(r&&this.contains(r))return e.preventDefault(),void t(r);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 s=null!==this._page?this._page:parseInt(this.getAttribute("page")||"1",10);(!Number.isFinite(s)||s<1)&&(s=1),"prev"===t&&s>1&&(s-=1),"next"===t&&(s+=1),this._page=s,this._pageAttrLast=String(s),this._pageInternal=!0,this.setAttribute("page",String(s)),this.dispatchEvent(new CustomEvent("contour:page",{bubbles:!0,composed:!0,detail:{page:s}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{page:s}}}));const r=this.getAttribute("persist");if("storage"===r&&this.id)try{localStorage.setItem("contour-table:"+this.id,String(s))}catch(e){}else if("url"===r&&this.id)try{const t=new URL(window.location.href);t.searchParams.set("c-table-"+this.id,String(s)),window.history.replaceState(null,"",t.toString())}catch(e){}}}),this.addEventListener("keydown",e=>{if("Enter"!==e.key&&" "!==e.key)return;const s=e.target&&e.target.closest?e.target.closest("th[aria-sort]"):null;s&&this.contains(s)&&(e.preventDefault(),t(s))}),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 s=Number(e.dataset.filterIndex);Number.isFinite(s)&&(this._filters||(this._filters={}),this._filters[s]=e.value,this.requestRender(),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{column:s,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,s=this._measuredRowHeight||cssLength("--data-grid-row-height",32),r=Math.max(0,(this._rowData?this._rowData.length:0)-30),i=Math.min(r,Math.max(0,Math.floor(e.scrollTop/s)-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 s=this._rowKey(this._rowData?this._rowData[t]:void 0);this._selectionControlled?(e.checked?this._selectedKeys.add(s):this._selectedKeys.delete(s),this._syncSelectionRows()):e.checked?this._selectedRows.add(t):this._selectedRows.delete(t),this._applySelectionToDom(),this._updateSelectionStatus();const r=Array.from(this._selectedRows),i=this._selectionKeys();return this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{rows:r,key:s,index:t}})),void this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{selectedRows:r,selectedKeys:i}}}))}const s=t.target&&t.target.closest?t.target.closest(".c-table__select-all"):null;if(s&&this.contains(s)){const t=Array.from(this.querySelectorAll(".c-table__row-select"));t.forEach(t=>{t.checked=s.checked}),this._selectionControlled?(t.forEach(t=>{const e=Number(t.dataset.rowIndex),r=this._rowKey(this._rowData?this._rowData[e]:void 0);s.checked?this._selectedKeys.add(r):this._selectedKeys.delete(r)}),this._syncSelectionRows()):this._selectedRows=new Set(s.checked?t.map(t=>Number(t.dataset.rowIndex)):[]),s.indeterminate=!1,this._updateSelectionStatus();const e=Array.from(this._selectedRows),r=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:r}}}))}}),this.addEventListener("mouseover",t=>{const e=t.target&&t.target.closest?t.target.closest("tbody tr"):null;if(!e||!this.contains(e))return;const s=Number(e.dataset.rowIndex);Number.isFinite(s)&&this._hoveredRow!==s&&(this._hoveredRow=s,this.dispatchEvent(new CustomEvent("contour:hover",{bubbles:!0,composed:!0,detail:{row:s}})))}),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 s=void 0!==e.dataset.rowIndex?e.dataset.rowIndex:e.dataset.row,r=Number(s);if(!Number.isFinite(r))return;const i=this._rowData&&this._rowData[r]||null;this.dispatchEvent(new CustomEvent("contour:zoom",{bubbles:!0,composed:!0,detail:{row:r,index:r,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 s=Number(e.dataset.rowIndex);if(Number.isFinite(s)){if("ArrowDown"===t.key||"ArrowUp"===t.key||"Home"===t.key||"End"===t.key){const s=Array.from(this.querySelectorAll("tbody tr[data-row-index]")),r=s.indexOf(e);let i=r;if("ArrowDown"===t.key?i=Math.min(s.length-1,r+1):"ArrowUp"===t.key?i=Math.max(0,r-1):"Home"===t.key?i=0:"End"===t.key&&(i=s.length-1),i!==r&&s[i]){t.preventDefault(),s.forEach(t=>t.setAttribute("tabindex","-1")),s[i].setAttribute("tabindex","0");try{s[i].focus()}catch(t){}}return}"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0,detail:{row:s}})))}}),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 s=[];try{const t=JSON.parse(this.getAttribute("columns")||"[]");Array.isArray(t)&&(s=t)}catch(t){}e.innerHTML="",s.forEach(t=>{const s="string"==typeof t?t:t.label||t.name||t,r="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=r,i.appendChild(a),i.appendChild(document.createTextNode(" "+s)),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;if(t.every(t=>"number"==typeof t&&Number.isFinite(t)))return decimateMinMax(t,e);const s=Math.ceil(t.length/e),r=[];for(let e=0;e<t.length;e+=s)r.push(t[e]);const i=t[t.length-1];return r[r.length-1]!==i&&r.push(i),r},patchChildren=(t,e)=>{const s=Array.from(e.childNodes),r=Array.from(t.childNodes),i=Math.max(s.length,r.length);for(let e=0;e<i;e++){const i=r[e],a=s[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),s=Number(t.x1),r=Number(t.count);if(!Number.isFinite(e)||!Number.isFinite(s)||!Number.isFinite(r))return null;const i={x0:e,x1:s,count:r},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}_nearestMark(t,e,s=22){const r=this.querySelector(".c-chart__plot");if(!r)return null;const i=r.querySelectorAll(".c-chart__bar, .c-chart__point, .c-donut__slice");let a=null,n=s;for(const s of i){if("true"===s.getAttribute("aria-hidden"))continue;const r=s.getBoundingClientRect();if(!r.width&&!r.height)continue;const i=t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom,o=Math.hypot(t-(r.left+r.width/2),e-(r.top+r.height/2)),l=i?0:o;l<n&&(n=l,a=s)}return a}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")),s=parseFloat(this.getAttribute("brush-end"));return Number.isFinite(e)&&Number.isFinite(s)?[e,s]:null}set range(t){if(null==t)return this._rangeOverride=null,void this.requestRender();const e=Array.isArray(t)?t:[t,t],s=Number(e[0]),r=Number(e[1]);Number.isFinite(s)&&Number.isFinite(r)&&(this._rangeOverride=[s,r],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 s=safeColor(t&&"object"==typeof t?t.color:"");if(s)return s;const r=safeColor(this.getAttribute("color"));return r||"var(--chart-"+(e%8+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),s=this.querySelector(".c-chart__plot");s&&(s.style.backgroundImage=t?"none":"");const r=this.querySelector(".c-chart__axis");r&&(r.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 s=1/0,r=-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<s&&(s=e),e>r&&(r=e))})}),i&&Number.isFinite(s)&&Number.isFinite(r)&&(s=Math.min(0,s),r=Math.max(0,r)),Number.isFinite(s)&&Number.isFinite(r)?[s,r]:null}catch(t){return null}}_renderValueAxis(){const t=this.querySelector(".c-chart__axis");if(!t)return;const e=this._axisConfig(),s=e&&e.y,r=s&&s.domain||this._valueDomain(),i=this.querySelector(".c-chart__axis-x");if(!r)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=s&&s.ticks||niceTicks(r[0],r[1],5),n=s&&s.format||(t=>String(t));t.textContent="";a.forEach(e=>{const s=document.createElement("span");s.className="c-chart__tick",s.textContent="function"==typeof n?n(e):String(e),t.appendChild(s)}),s&&"object"==typeof s&&(s.label||s.title||s.name)&&t.appendChild(((t,e)=>{const s=document.createElement("span");return s.className="c-chart__tick",s.dataset.axisTitle=e,s.textContent=t,s})(s.label||s.title||s.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 s=JSON.parse(t),r=(Array.isArray(s)?s:[]).map((t,e)=>({s:t,i:e})).filter(t=>t.s&&t.s.label);if(!r.length)return void(e&&e.remove());e||(e=document.createElement("div"),e.className="c-chart__legend",this.appendChild(e)),e.textContent="",r.forEach(({s:t,i:s})=>{const r=document.createElement("span");r.className="c-chart__legend-item";const i=document.createElement("span");i.className="c-chart__legend-swatch",i.style.setProperty("--c",this._seriesColor(t,s)),i.dataset.series=String(s%12+1),i.dataset.style=t.style||"line",r.appendChild(i),r.appendChild(document.createTextNode(t.label)),e.appendChild(r)})}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 s=0;s<e;s++){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 s=this.getAttribute("series");if(!s&&this._pushedBins&&this._pushedBins.length&&(s=JSON.stringify([{type:"histogram",bins:this._pushedBins}])),s){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 s=document.createDocumentFragment();if(t.some(t=>t&&(Array.isArray(t.values)||Array.isArray(t.bins))))this._renderedBins=[],this._renderedBackground=[],t.forEach((t,e)=>{const r=this._seriesColor(t,e);if("donut"===t.type){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("viewBox","0 0 200 200"),r.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",r.setAttribute("role","group"),r.setAttribute("aria-label",t.label||"Donut chart"),donutSlices(t.values).forEach((s,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",s.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"),r.appendChild(a)}),s.appendChild(r)}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,s)=>{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",r),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[s])),n.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(i[s])),n.setAttribute("tabindex","0"),n.setAttribute("role","button"),n.dataset.index=String(s),a.appendChild(n)}),s.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),s=(Math.max.apply(null,t)-e||1)/n,r=new Array(n).fill(0);t.forEach(t=>{const i=Math.min(n-1,Math.floor((t-e)/s));r[i]+=1}),u=r,c=r.map((t,r)=>({x0:e+r*s,x1:e+(r+1)*s,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,b=d||(h&&h.length?h:[]);this._renderedBackground=b.slice();const m=b.map(t=>Number(t.count)||0);let p=1;m.length&&u.concat(m).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%",m.length&&barRects(m,{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",r),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,m.length?{max:p}:void 0).forEach((s,i)=>{if(s.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",r),a.setAttribute("x",s.x),a.setAttribute("y",s.y),a.setAttribute("width",s.width),a.setAttribute("height",s.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)}),s.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,b=d-u||1,m=2e3;let p=a;if(a.length>m){const t=Math.ceil(a.length/m);p=a.filter((e,s)=>s%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,s)=>{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(s)),a.style.setProperty("--c",r);const n=(t.x-l)/h*300,o=120-(t.y-u)/b*120;a.setAttribute("cx",n.toFixed(2)),a.setAttribute("cy",o.toFixed(2)),a.setAttribute("r","3"),a.setAttribute("tabindex",0===s?"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+")")),s.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",r),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,s)=>{if(isMissing(t))return;const a=Number(t);if(!Number.isFinite(a))return;const n=s/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(s)),h.style.setProperty("--c",r),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)}),s.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,s)=>{const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("class","c-chart__line"),r.setAttribute("data-series",String(s+1)),r.style.setProperty("--c",this._seriesColor(t,s)),r.setAttribute("d","string"==typeof t.d&&t.d.trim()?t.d:Array.isArray(t.values)?smoothPath(t.values):""),e.appendChild(r)}),s.appendChild(e)}if(patchChildren(e,s),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 r=(this.getAttribute("data-table")||"").trim().toLowerCase(),i="none"===r||"off"===r||"false"===r||"0"===r,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 s=this.getAttribute("title")||this.getAttribute("aria-label")||labelText(this,"chart-data","Chart data"),r=document.createElement("caption");r.textContent=s,e.appendChild(r);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 s=Array.isArray(t.values)?t.values:Array.isArray(t)?t:[],r=document.createElement("tr"),i=document.createElement("th");i.setAttribute("scope","row"),i.textContent=t.label||"Series "+(e+1),r.appendChild(i);for(let t=0;t<o;t++){const e=document.createElement("td");e.textContent=isMissing(s[t])?"":String(s[t]),r.appendChild(e)}l.appendChild(r)}),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||[],s=this.getAttribute("brush-min")||(e.length?String(e[0].x0):"0"),r=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",s),t.setAttribute("max",r),t.setAttribute("start",i?String(i[0]):a?s:this.getAttribute("brush-start")||s),t.setAttribute("end",i?String(i[1]):a?r:this.getAttribute("brush-end")||r);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 s=this.getAttribute("note");let r=this.querySelector(".c-chart__note");s?(r||(r=document.createElement("div"),r.className="c-chart__note",this.appendChild(r)),r.textContent=s):r&&r.remove()}if(!this._chartRevealed){const t=this.querySelector(".c-chart__plot");t&&t.querySelector(".c-chart__bar, .c-chart__line, .c-chart__point, .c-donut__slice")&&(this._chartRevealed=!0,t.querySelectorAll(".c-chart__bar, .c-chart__line, .c-chart__point, .c-donut__slice").forEach((t,e)=>{t.style.animationDelay=30*Math.min(e,11)+"ms"}),t.classList.add("is-revealing"),setTimeout(()=>{t.classList.remove("is-revealing"),t.querySelectorAll(".c-chart__bar, .c-chart__line, .c-chart__point, .c-donut__slice").forEach(t=>t.style.removeProperty("animation-delay"))},600))}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),s=t&&t.detail&&t.detail.index,r=t&&t.detail&&t.detail.pressed;if(null==e&&null==s)return;this.querySelectorAll("[data-series]").forEach(t=>{const i=t.getAttribute("data-series");(String(i)===String(e)||t.getAttribute("data-key")===String(e)||null!=s&&String(i)===String(s+1))&&(t.style.display=!1===r?"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,s=0;const r=this.querySelector(".c-chart__plot");r&&(r.classList.add("c-chart__plot--zoomable"),r.hasAttribute("tabindex")||r.setAttribute("tabindex","0"),r.hasAttribute("aria-label")||r.setAttribute("aria-label",labelText(this,"chart","Chart")+", zoomable. Use plus and minus to zoom, arrow keys to pan, 0 to reset."));const i=this.ensure("[data-chart-zoom-status]",()=>{const t=document.createElement("span");return t.className="visually-hidden",t.setAttribute("data-chart-zoom-status",""),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t}),a=(a=!0)=>{r&&(r.style.transform=`translate(${e}px, ${s}px) scale(${t})`,r.style.transformOrigin="center center",r.classList.toggle("is-zoomed",1!==t||0!==e||0!==s),a&&(i.textContent=`Zoom ${Math.round(100*t)} percent`,this.dispatchEvent(new CustomEvent("contour:chart-zoom",{bubbles:!0,composed:!0,detail:{zoom:t,panX:e,panY:s}}))))},n=e=>{t=Math.min(5,Math.max(.5,t*e)),a()},o=()=>{t=1,e=0,s=0,a()};this.addEventListener("wheel",t=>{t.preventDefault(),n(t.deltaY<0?1.1:.9)},{passive:!1});const l=new Map;let c=!1,u=0,d=0,h=0,b=0,m=0,p=1;const g=()=>{const t=[...l.values()];return t.length>=2?Math.hypot(t[0].x-t[1].x,t[0].y-t[1].y):0};this.addEventListener("pointerdown",r=>{if("mouse"!==r.pointerType||0===r.button){l.set(r.pointerId,{x:r.clientX,y:r.clientY});try{this.setPointerCapture(r.pointerId)}catch(t){}1===l.size?(c=!0,u=r.clientX,d=r.clientY,h=e,b=s,this.style.cursor="grabbing"):2===l.size&&(c=!1,m=g(),p=t)}}),this.addEventListener("pointermove",r=>{if(l.has(r.pointerId)){if(l.set(r.pointerId,{x:r.clientX,y:r.clientY}),l.size>=2&&m)return t=Math.min(5,Math.max(.5,p*(g()/m))),void a();c&&(e=h+(r.clientX-u),s=b+(r.clientY-d),a(!1))}});const _=t=>{l.delete(t.pointerId);try{this.releasePointerCapture(t.pointerId)}catch(t){}l.size<2&&(m=0),0===l.size&&(c=!1,this.style.cursor="",a())};this.addEventListener("pointerup",_),this.addEventListener("pointercancel",_),this.addEventListener("dblclick",o),this.addEventListener("keydown",t=>{t.target===r&&("+"===t.key||"="===t.key?(t.preventDefault(),n(1.1)):"-"===t.key||"_"===t.key?(t.preventDefault(),n(.9)):"0"===t.key?(t.preventDefault(),o()):"ArrowLeft"===t.key?(t.preventDefault(),e+=20,a()):"ArrowRight"===t.key?(t.preventDefault(),e-=20,a()):"ArrowUp"===t.key?(t.preventDefault(),s+=20,a()):"ArrowDown"===t.key&&(t.preventDefault(),s-=20,a()))})}let s=null,r=null;const i=()=>{s=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),s||(s=e.getBoundingClientRect(),r||"function"!=typeof ResizeObserver||(r=new ResizeObserver(i),r.observe(e)));const l=s,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,()=>{r&&(r.disconnect(),r=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 s=t.target&&t.target.closest?t.target.closest(".c-chart__bar"):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 r=t.target&&t.target.closest?t.target.closest(".c-chart__point"):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 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);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e,value:i.getAttribute("data-title")||i.getAttribute("title")}}))}const a=this._nearestMark(t.clientX,t.clientY);if(a){const t=parseInt(a.getAttribute("data-series")||"1",10),e=parseInt(a.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e}}))}}),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-chart__plot");if(!e)return;const s=t.target&&t.target.closest?t.target.closest(".c-chart__bar"):null;if(s&&e.contains(s)){if("Enter"===t.key||" "===t.key){t.preventDefault();const e=parseInt(s.getAttribute("data-series")||"1",10),r=parseInt(s.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:e,index:r}}))}const r=s.getAttribute("data-series");if(r){const i=parseInt(r,10),a=Array.from(e.querySelectorAll('.c-chart__bar[data-series="'+i+'"]'));a.indexOf(s)>=0&&navKey(t,a,{wrap:!1,rtl:isRtl(this),onNavigate:t=>a.forEach((e,s)=>e.setAttribute("tabindex",s===t?"0":"-1")),onKey:()=>{}})}return}const r=t.target&&t.target.closest?t.target.closest(".c-donut__slice"):null;if(r&&e.contains(r)){const s=parseInt(r.getAttribute("data-series")||"1",10);if("Enter"===t.key||" "===t.key){t.preventDefault();const e=parseInt(r.dataset.index||"0",10);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:s,index:e,value:r.getAttribute("data-title")||r.getAttribute("title")}}))}const i=Array.from(e.querySelectorAll('.c-donut__slice[data-series="'+s+'"]'));return void navKey(t,i,{wrap:!1,rtl:isRtl(this),onNavigate:t=>i.forEach((e,s)=>e.setAttribute("tabindex",s===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,s)=>e.setAttribute("tabindex",s===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 s=this._activeSeries;const r="rtl"===(this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"").toLowerCase();if("ArrowRight"===t.key)s=r?Math.max(this._activeSeries-1,0):Math.min(this._activeSeries+1,e-1);else if("ArrowLeft"===t.key)s=r?Math.min(this._activeSeries+1,e-1):Math.max(this._activeSeries-1,0);else if("ArrowDown"===t.key)s=Math.min(this._activeSeries+1,e-1);else if("ArrowUp"===t.key)s=Math.max(this._activeSeries-1,0);else if("Home"===t.key)s=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;s=e-1}s!==this._activeSeries&&(t.preventDefault(),this._activeSeries=s,this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:s}})))}),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 s=this.getAttribute("value");this.style.setProperty("--comparison-pos",(s??"50")+"%");const r=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,s)=>{if(!t)return;let r=t.querySelector(".c-comparison__media--"+s);e?(r||(r=document.createElement("img"),r.className="c-comparison__media c-comparison__media--"+s,r.alt="",t.prepend(r)),r.getAttribute("src")!==e&&r.setAttribute("src",e)):r&&r.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=r}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(s??"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 s=this.querySelector(".c-comparison__divider");s&&s.setAttribute("aria-valuenow",String(Math.round(e))),this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:!0,composed:!0,detail:{value:e}}))};let s=!1;const r=t=>{if(!s)return;const r=this.getBoundingClientRect(),i=(t.clientX-r.left)/r.width*100;e(i)},i=()=>{s=!1,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",i)};onDispose(this,()=>{s=!1,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",i)}),this.addEventListener("pointerdown",r=>{const i=t();if(!i||!i.contains(r.target))return;s=!0;try{this.setPointerCapture(r.pointerId)}catch(t){}const a=this.getBoundingClientRect(),n=(r.clientX-a.left)/a.width*100;e(n),r.preventDefault()}),this.addEventListener("pointermove",t=>{if(!s)return;const r=this.getBoundingClientRect(),i=(t.clientX-r.left)/r.width*100;e(i)});const a=()=>{s=!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",s=>{const r=t();if(!r||document.activeElement!==r)return;const i=parseFloat(this.style.getPropertyValue("--comparison-pos"))||50;"ArrowLeft"===s.key?(s.preventDefault(),e(i-5)):"ArrowRight"===s.key?(s.preventDefault(),e(i+5)):"Home"===s.key?(s.preventDefault(),e(0)):"End"===s.key&&(s.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 s=remoteData(this,"line"),r=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=[],!s&&i.length>1&&(s=smoothPath(i,{width:300,height:192}),this._valuesNums=i,!r)){const t=polylinePoints(i,{width:300,height:192}).split(" ");r=t[t.length-1]}if(!s){const t=this.querySelector(":scope > .c-streaming-chart__plot");return t&&t.remove(),void renderEmpty(this,"streaming-chart")}if(s){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",s),r&&!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 s=r.split(/[ ,]+/);s.length>=2&&(e.setAttribute("cx",s[0]),e.setAttribute("cy",s[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&&!1!==this._tabVisible;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,timestamp:Date.now(),interval:Math.max(1e3,1e3*t)},bubbles:!0,composed:!0}));const e=this.getAttribute("src");e&&(remoteInvalidate(e),this.requestRender())},Math.max(1e3,1e3*t))))};if(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)return;this._wiredStream=!0,this._streamFrame=0,this._tabVisible=!document.hidden;const e=()=>{this._tabVisible=!document.hidden,t()};document.addEventListener("visibilitychange",e),onDispose(this,()=>{void 0!==this._streamTimer&&(clearInterval(this._streamTimer),this._streamTimer=void 0),document.removeEventListener("visibilitychange",e)}),this._streamPausedByUser=!1,this.addEventListener("click",e=>{const s=e.target,r=this.querySelector(".c-streaming-chart__pause");r&&(s===r||r.contains(s))&&(e.preventDefault(),this._streamPausedByUser=!this._streamPausedByUser,r.setAttribute("aria-pressed",String(this._streamPausedByUser)),r.setAttribute("aria-label",this._streamPausedByUser?"Play stream":"Pause stream"),setHTML(r,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 s=this.querySelector(".c-streaming-chart__pause");s&&(s.setAttribute("aria-pressed",String(this._streamPausedByUser)),s.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 s=this.getAttribute("band");s?this.setAttribute("data-band",s):this.removeAttribute("data-band");const r=this.getAttribute("label");let i=this.querySelector(".c-reference-rule__label");r?(i||(i=document.createElement("span"),i.className="c-reference-rule__label",this.appendChild(i)),i.textContent=r):i&&i.remove()}}define("contour-reference-rule",ContourReferenceRule);class ContourSmallMultiples extends ContourBase{static get observed(){return["columns","label","multiples"]}static get properties(){return{columns:{attribute:"columns",type:Number},label:{attribute:"label"},multiples:{attribute:"multiples"}}}render(){this.classList.add("c-small-multiples"),this.hasAttribute("role")||this.setAttribute("role","group");const t=this.getAttribute("label");t?this.setAttribute("aria-label",t):this.removeAttribute("aria-label");const e=this.getAttribute("columns");e?this.style.setProperty("--sm-cols",e):this.style.removeProperty("--sm-cols"),this._smEntries=null;const s=this.getAttribute("multiples");if(!s)return;let r;try{r=JSON.parse(s)}catch(t){return}Array.isArray(r)&&(this._smEntries=r,r.forEach((t,e)=>this._renderCell(t,e)))}_renderCell(t,e){const s=t&&"object"==typeof t?t:{},r=Array.isArray(s.points)?s.points.filter(Number.isFinite):[],i=null!=s.label?String(s.label):`Multiple ${e+1}`,a=document.createElement("figure");a.className="c-small-multiples__cell",a.setAttribute("data-sm-index",String(e)),a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.setAttribute("aria-label",i);const n=document.createElement("figcaption");n.className="c-small-multiples__label",n.textContent=i,a.appendChild(n);const o=document.createElementNS("http://www.w3.org/2000/svg","svg");if(o.setAttribute("class","c-small-multiples__mark"),o.setAttribute("viewBox","0 0 100 30"),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("aria-hidden","true"),r.length>=2){const t=Math.min(...r),e=Math.max(...r)-t||1,s=r.length,i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",r.map((r,i)=>(0===i?"M":"L")+" "+100*i/(s-1)+" "+(30-(r-t)/e*30)).join(" ")),o.appendChild(i)}a.appendChild(o),this.appendChild(a)}enhance(){if(this._wiredSmallMultiples)return;this._wiredSmallMultiples=!0;const t=t=>{const e=t.target&&t.target.closest?t.target.closest(".c-small-multiples__cell[data-sm-index]"):null;if(!e||!this.contains(e))return;const s=Number(e.getAttribute("data-sm-index")),r=(this._smEntries||[])[s]||{},i=Array.isArray(r.points)?r.points.filter(Number.isFinite):[],a=null!=r.value?r.value:i.length?i[i.length-1]:null;this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:s,key:null!=r.key?r.key:null,label:null!=r.label?String(r.label):"",value:a}}))};this.addEventListener("click",t),this.addEventListener("keydown",e=>{if("Enter"!==e.key&&" "!==e.key)return;const s=e.target&&e.target.closest?e.target.closest(".c-small-multiples__cell[data-sm-index]"):null;s&&this.contains(s)&&(e.preventDefault(),t(e))})}}define("contour-small-multiples",ContourSmallMultiples);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||"",s=this.getAttribute("variant");if(Array.from(this.classList).forEach(t=>{t.startsWith("c-meter--")&&this.classList.remove(t)}),s&&this.classList.add("c-meter--"+s),!t&&!e)return void renderEmpty(this,"meter");if(null===t)this.style.removeProperty("--meter-value");else{const e=parseFloat(t),s=parseFloat(this.getAttribute("min"))||0,r=parseFloat(this.getAttribute("max"))||100;if(Number.isFinite(e)){const t=r>s?Math.min(1,Math.max(0,(e-s)/(r-s))):0;this.style.setProperty("--meter-value",String(t))}else this.style.removeProperty("--meter-value")}const r=this.ensure(".c-meter__core",()=>{const t=document.createElement("span");return t.className="c-meter__core",t});let i=r.querySelector(".c-meter__value");i||(i=document.createElement("span"),i.className="c-meter__value",r.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){(r.querySelector(".c-meter__label")||(()=>{const t=document.createElement("span");return t.className="c-meter__label",r.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 s={up:"#i-arrow-up",down:"#i-arrow-down",flat:"#i-minus"}[e]||"#i-arrow-up";this.querySelectorAll("svg").forEach(t=>t.remove());const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("aria-hidden","true");const i=document.createElementNS("http://www.w3.org/2000/svg","use");i.setAttribute("href",s),r.appendChild(i),this.appendChild(r),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"),s=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(s){this.ensure(".c-stat__delta",()=>{const t=document.createElement("div");return t.className="c-stat__delta",t}).textContent=s}else{const t=this.querySelector(".c-stat__delta");t&&t.remove()}const r=this.getAttribute("unit"),i=this.querySelector(".c-stat__value");if(i)if(r){let t=i.querySelector(".c-stat__unit");t||(t=document.createElement("span"),t.className="c-stat__unit",i.appendChild(t)),t.textContent=r}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),s=null!==t&&""!==t&&Number.isFinite(e),r=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(!s){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 s=t.length-1;s>=0;s--)if(e>=(t[s].value||0)){d=t[s];break}}const h=this.shed("dial",3);let b=this.querySelector(".c-gauge__dial");if(h)b&&b.remove();else{b||(b=document.createElementNS("http://www.w3.org/2000/svg","svg"),b.setAttribute("class","c-gauge__dial"),b.setAttribute("part","dial"),b.setAttribute("aria-hidden","true"),b.setAttribute("viewBox","0 0 100 100"),this.appendChild(b)),b.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"),b.appendChild(t),c&&c.length){const t=[...c].sort((t,e)=>(t.value||0)-(e.value||0)),e=t=>{const e=(1-(t-r)/(i-r||1))*Math.PI;return{x:50+40*Math.cos(e),y:90-40*Math.sin(e)}};for(let s=0;s<t.length;s++){const r=t[s].value||0,a=s+1<t.length&&t[s+1].value||i,n=e(r),o=e(a),l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("class","c-gauge__zone"),l.setAttribute("stroke",t[s].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)),b.appendChild(l)}}const s=Math.max(0,Math.min(1,(e-r)/(i-r||1))),a=Math.PI*(1-s),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))),b.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"),b.appendChild(o)}const m=this.ensure(".c-gauge__value",()=>{const t=document.createElement("div");return t.className="c-gauge__value",t.setAttribute("part","value"),t});m.textContent=formatValue(String(e),this.getAttribute("format"),this.getAttribute("locale"))+(this.getAttribute("unit")?" "+this.getAttribute("unit"):""),m.setAttribute("role","meter");const p=Math.max(r,Math.min(i,e));m.setAttribute("aria-valuenow",String(p)),m.setAttribute("aria-valuemin",String(r)),m.setAttribute("aria-valuemax",String(i)),a&&(m.id||(m.id=contourId("gauge-value"))),d?m.setAttribute("aria-valuetext",e+", "+(d.label||">= "+d.value)):m.setAttribute("aria-valuetext",String(e));const g=this.querySelector(".c-gauge__title");g?(g.id||(g.id=contourId("gauge-title")),m.setAttribute("aria-labelledby",g.id),m.removeAttribute("aria-label")):(m.removeAttribute("aria-labelledby"),a?m.setAttribute("aria-label",a):m.setAttribute("aria-label",m.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 s=this.getAttribute("values");if(s)try{e=JSON.parse(s)}catch(t){e=s.split(",").map(t=>t.trim())}const r=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:r},(t,e)=>e),s=t.map(t=>Number(t)).filter(Number.isFinite);let i=s.length?Math.min(...s):0,a=s.length?Math.max(...s):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 s=document.createElement("span");s.className="c-axis__label",s.textContent=formatValue(String(t),this.getAttribute("format"),this.getAttribute("locale")),e.appendChild(s);const r=Number(t);e.style.setProperty("--tick-pos",Number.isFinite(r)?(r-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"),s=parseFloat(this.getAttribute("end")||"100"),r=parseFloat(this.getAttribute("min")||"0"),i=parseFloat(this.getAttribute("max")||"100"),a=i-r||1,n=(e-r)/a*100,o=(s-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:s;n.style.insetInlineStart=(o-r)/a*100+"%",n.setAttribute("role","slider"),n.setAttribute("tabindex","0"),n.setAttribute("aria-valuemin",String(r)),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"),s=()=>parseFloat(this.getAttribute("max")||"100"),r=t=>{const r=this.getBoundingClientRect(),i="rtl"===(this.ownerDocument.defaultView?this.ownerDocument.defaultView.getComputedStyle(this).direction:"ltr")?(r.right-t)/(r.width||1):(t-r.left)/(r.width||1);return e()+Math.max(0,Math.min(1,i))*(s()-e())};this.addEventListener("pointerdown",e=>{const s=e.target&&e.target.classList&&e.target.classList.contains("c-brush__handle")?e.target:null;t=s?s.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=r(i.clientX),n=e(),o=s(),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"),b=this.querySelector(".c-brush__handle--end");h&&(h.style.insetInlineStart=(u-n)/l*100+"%"),b&&(b.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 s=this._brushPending;s&&(this.setAttribute("start",String(s.start)),this.setAttribute("end",String(s.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 r=t.target&&t.target.classList&&t.target.classList.contains("c-brush__handle")?t.target:null,i=r?r.classList.contains("c-brush__handle--start")?"start":"end":null,a=e(),n=s(),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;const d="rtl"===(this.ownerDocument.defaultView?this.ownerDocument.defaultView.getComputedStyle(this).direction:"ltr"),h=d?"ArrowRight":"ArrowLeft",b=d?"ArrowLeft":"ArrowRight";if(t.key===h||"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(t.key===b||"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 s=e.map(t=>"object"==typeof t?t.value||0:Number(t)||0),r=s.some(t=>t<0),i=s.filter(t=>t>0).reduce((t,e)=>t+e,0),a=Math.abs(s.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"))||(r?o:n));this.querySelectorAll(".c-stacked-bar__track").forEach(t=>t.remove());const c=(t,e,r)=>{const i=s[e],a=document.createElement("div");a.className="c-stacked-bar__segment"+(0===i?" c-stacked-bar__segment--zero":""),a.style.inlineSize=r+"%",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.dataset.index=String(e),a.dataset.value=String(i),a.dataset.label=n,a.setAttribute("role","button"),a.setAttribute("tabindex","-1"),a.setAttribute("aria-label",(n?n+": ":"")+i),a};if(r){this.classList.add("c-stacked-bar--diverging");const t=document.createElement("div");t.className="c-stacked-bar__track c-stacked-bar__track--neg";const r=document.createElement("div");r.className="c-stacked-bar__track",e.forEach((e,i)=>{const a=s[i];if(0===a)return;const n=Math.abs(a)/l*100;(a<0?t:r).appendChild(c(e,i,n))}),this.appendChild(t),this.appendChild(r)}else{this.classList.remove("c-stacked-bar--diverging");const t=document.createElement("div");t.className="c-stacked-bar__track",e.forEach((e,r)=>t.appendChild(c(e,r,s[r]/l*100))),this.appendChild(t)}e.length||renderEmpty(this,"stacked-bar");this.querySelectorAll(".c-stacked-bar__segment").forEach((t,e)=>t.setAttribute("tabindex",0===e?"0":"-1"))}enhance(){if(this._wiredStackedBar)return;this._wiredStackedBar=!0;const t=()=>Array.from(this.querySelectorAll(".c-stacked-bar__segment")),e=t=>{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:Number(t.dataset.index||"0"),key:t.dataset.label||String(t.dataset.index||"0"),label:t.dataset.label||"",value:Number(t.dataset.value||"0")}}))};this.addEventListener("click",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-stacked-bar__segment"):null;s&&this.contains(s)&&e(s)}),this.addEventListener("keydown",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-stacked-bar__segment"):null;if(!r||!this.contains(r))return;if("Enter"===s.key||" "===s.key)return s.preventDefault(),void e(r);const i=t();navKey(s,i,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>i.forEach((e,s)=>e.setAttribute("tabindex",s===t?"0":"-1"))})})}}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 s=t.querySelector(".c-category__label");e.push({label:s?s.textContent:t.textContent,value:0})}),t.forEach(t=>t.remove());else{this.getAttribute("items")&&(e=parseArrayAttr(this,"items",warnBadJson))}const s=this.getAttribute("sort")||"value-desc";e.sort((t,e)=>{const r="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"===s?r-i:"alpha-asc"===s?String(a).localeCompare(String(n)):"alpha-desc"===s?String(n).localeCompare(String(a)):i-r});const r=parseInt(this.getAttribute("limit")||"0",10);r>0&&(e=e.slice(0,r));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 s="object"==typeof t?t.value||0:Number(t)||0,r="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=r;const o=document.createElement("div");o.style.flex="1";const l=document.createElement("div");l.className="c-category__bar",l.style.inlineSize=Math.abs(s)/i*100+"%",o.appendChild(l);const c=document.createElement("span");c.className="c-category__value",c.textContent=formatValue(s,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 s=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!s||!this.contains(s))return;const r=t(),i=r.indexOf(s);r.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:s.querySelector(".c-category__label")?s.querySelector(".c-category__label").textContent:s.textContent.trim()}}))}),this.addEventListener("keydown",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-category__item"):null;if(!s||!this.contains(s))return;const r=t(),i=r.indexOf(s);if("Enter"===e.key||" "===e.key)return e.preventDefault(),r.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:s.querySelector(".c-category__label")?s.querySelector(".c-category__label").textContent:s.textContent.trim()}}));navKey(e,r,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>r.forEach((e,s)=>e.setAttribute("tabindex",s===t?"0":"-1")),onKey:()=>{if("Enter"===e.key||" "===e.key){const t=r.indexOf(document.activeElement);r.forEach((e,s)=>e.setAttribute("aria-selected",s===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 s=t.querySelector(".c-donut__swatch"),r=t.querySelector("span:last-child"),i=r?r.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:s?s.dataset&&s.dataset.color||s.style.background:void 0})}),t.forEach(t=>t.remove());else{this.getAttribute("items")&&(e=parseArrayAttr(this,"items",warnBadJson))}const s=e.map(t=>"object"==typeof t?t.value||0:Number(t)||0),r=s.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","group");const r=this.getAttribute("label")||"Donut chart";t.setAttribute("aria-label",r);donutSlices(s,{cx:16,cy:16,r:15,inner:9,gap:.03}).forEach((s,r)=>{const a=e[s.index],n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("class","c-donut__slice"),n.setAttribute("d",s.path),n.setAttribute("fill","var(--c, var(--chart-1))"),n.style.setProperty("--c",safeColor(i||("object"==typeof a&&a.color?a.color:"var(--chart-"+(s.index%8+1)+")"))||"var(--chart-1)"),n.dataset.index=String(s.index);const o=("object"==typeof a?a.label||"":String(a))+" — "+s.value;n.setAttribute("data-title",o),n.setAttribute("aria-label",o),n.setAttribute("tabindex",0===r?"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(r),this.appendChild(a);const n=document.createElement("div");n.className="c-donut__list",n.setAttribute("role","list"),e.forEach((t,e)=>{const r=document.createElement("div");r.className="c-donut__item",r.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)),r.appendChild(a);const o=document.createElement("span");o.textContent=("object"==typeof t?t.label||"":String(t))+" — "+s[e],r.appendChild(o),n.appendChild(r)}),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",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-donut__slice"):null;if(!r||!this.contains(r))return;const i=t(),a=i.indexOf(r);let n=-1;if("ArrowRight"===s.key||"ArrowDown"===s.key)n=Math.min(a+1,i.length-1);else if("ArrowLeft"===s.key||"ArrowUp"===s.key)n=Math.max(a-1,0);else if("Home"===s.key)n=0;else if("End"===s.key)n=i.length-1;else if("Enter"===s.key||" "===s.key)return s.preventDefault(),void e(r);if(n>=0&&n!==a){s.preventDefault(),i.forEach((t,e)=>t.setAttribute("tabindex",e===n?"0":"-1"));try{i[n].focus()}catch(t){}}}),this.addEventListener("click",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-donut__slice"):null;s&&this.contains(s)&&e(s)})}}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 s=(this.getAttribute("style")||"").trim().toLowerCase();t=[{label:"Series 1",values:e,style:this.getAttribute("series-style")||("line"===s||"bar"===s?s:"bar"),color:"var(--chart-1)"}]}}const s=t.reduce((t,e)=>{const s=Array.isArray(e.values)?Math.max(...e.values,0):0;return Math.max(t,s)},1),r=t.reduce((t,e)=>{const s=Array.isArray(e.values)?Math.min(...e.values,0):0;return Math.min(t,s)},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=s-r||1,o=n.length||1,u=n.map((t,e)=>{const s=e/Math.max(1,o-1)*300,i=120-(t-r)/a*120;return s.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((s,i)=>{const n=i/Math.max(1,o-1)*300,l=120-(s-r)/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(s)),u.setAttribute("aria-label",c+": "+String(s)),t.appendChild(u)}),i.appendChild(t)}else n.forEach((t,r)=>{const i=document.createElement("div");i.className="c-time-series__bar",i.setAttribute("data-series",String(e+1)),i.setAttribute("data-index",String(r)),i.style.blockSize=t/s*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===r&&0===e?"0":"-1"),(a[r]||(a[r]=[])).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,s)=>t>=0&&s.indexOf(t)===e).forEach(s=>{const r=document.createElement("span");r.className="c-time-series__tick",r.textContent=Array.isArray(e)&&null!=e[s]?String(e[s]):String(s),t.appendChild(r)}),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 s=Number(e.dataset.series||"0"),r=Number(e.dataset.index||"0");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:s,index:r,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 s=Number(e.dataset.series||"0"),r=Number(e.dataset.index||"0");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:s,index:r,value:e.getAttribute("data-title")||e.getAttribute("title")}}))}),this.addEventListener("keydown",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-time-series__bar"):null,i=s.target&&s.target.closest?s.target.closest(".c-time-series__point"):null,a=r||i;if(!a||!this.contains(a))return;const n=r?t():e(),o=n.indexOf(a);if("Enter"===s.key||" "===s.key){s.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(s,n,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>n.forEach((e,s)=>e.setAttribute("tabindex",s===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 s=t.target&&t.target.closest?t.target.closest(".c-time-series__point"):null;if(s&&this.contains(s)){const t=this.querySelector(".c-time-series__tooltip");t&&(t.textContent=s.getAttribute("data-title")||s.getAttribute("title"),t.removeAttribute("hidden"),t.id&&s.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 s=this.querySelector(".c-time-series__tooltip");s&&!this.contains(t.relatedTarget)&&s.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 s=this.getAttribute("rows")?this.getAttribute("rows").split(",").map(t=>t.trim()).filter(Boolean):[],r=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=s,d=r;if(n&&(u=s.filter(e=>e.toLowerCase().includes(n)||t.some(t=>t.row===e&&String(t.value).toLowerCase().includes(n))),d=r.filter(e=>e.toLowerCase().includes(n)||t.some(t=>t.col===e&&String(t.value).toLowerCase().includes(n)))),!t.length&&!s.length&&!r.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,s="asc"===this._pivotSort.dir?1:-1,r=s=>a(t.filter(t=>t.row===s&&t.col===e).map(t=>Number(t.value)).filter(t=>Number.isFinite(t)));u=u.slice().sort((t,e)=>(r(t)-r(e))*s)}const h=document.createElement("div");h.className="c-table-wrap c-pivot__wrap";const b=document.createElement("table");b.className="c-table c-pivot__table",b.setAttribute("role","grid"),b.setAttribute("aria-rowcount",String(u.length+1)),b.setAttribute("aria-colcount",String(d.length+1));const m=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)}),m.appendChild(p),b.appendChild(m);const v=document.createElement("tbody");u.forEach(e=>{const s=document.createElement("tr");s.setAttribute("role","row");const r=document.createElement("th");r.textContent=e,r.setAttribute("role","rowheader"),r.setAttribute("tabindex",_?"-1":"0"),_=!0,s.appendChild(r),d.forEach(r=>{const i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1"),i.dataset.row=e,i.dataset.col=r;const n=t.filter(t=>t.row===e&&t.col===r),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")),s.appendChild(i)}),v.appendChild(s)}),b.appendChild(v),h.appendChild(b),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,s=t.target&&t.target.closest?t.target.closest("td"):null,r=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(!r&&!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}}))}s&&this.contains(s)&&this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{row:s.dataset.row||"",col:s.dataset.col||"",value:s.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 s=this.querySelector("table");if(!s)return;const r=Array.from(s.querySelectorAll("tr")),i=r.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=r[i+1]&&r[i+1].children[a]:"ArrowUp"===t.key?n=r[i-1]&&r[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","analysis-state"]}static get properties(){return{loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"},retry:{attribute:"retry"},src:{attribute:"src"},"analysis-state":{attribute:"analysis-state"}}}render(){if(this.classList.add("c-widget-state"),wireStates(this),loadRemote(this,[]),renderStates(this,"widget-state"))return;const t=this.getAttribute("analysis-state");if(t){const e=setAnalysisState(this,t);let s=this.querySelector(".c-widget-state__analysis");s||(s=document.createElement("span"),s.className="c-widget-state__analysis visually-hidden",s.dataset.contourGenerated="1",this.appendChild(s)),s.textContent=e}else{setAnalysisState(this,null);const t=this.querySelector(".c-widget-state__analysis");t&&t.remove()}}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 s=this.querySelector(".c-brownout__label");s||(s=document.createElement("span"),s.className="c-brownout__label",this.appendChild(s)),s.textContent=labelText(this,"level","Level")+" "+t;const r=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)&&r>=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 s=document.createElement("span");s.className="c-instrument__value",s.textContent=t.value||t[1]||"",e.appendChild(s),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 s=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")??"3",10)??3)),r=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(${s}, 1fr)`,a.style.gridTemplateRows=`repeat(${s}, 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,s*s)}for(let e=0;e<s;e++)for(let n=0;n<s;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=s-e;o.setAttribute("aria-label",`${r} ${l} of ${s}, ${i} ${n+1} of ${s}`);const c=(s-1-e)*s+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(","),r=parseInt(t[0],10),i=parseInt(t[1],10);Array.from(a.querySelectorAll(`.${this._bvBlock}__cell`)).forEach((t,e)=>{Math.floor(e/s)===r&&e%s===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`),s=Array.from(e?e.querySelectorAll(`.${this._bvBlock}__cell`):[]),r=s.indexOf(t);if(r<0)return;const i=Math.min(12,Math.max(1,parseInt(this.getAttribute("size")||"3",10)||3)),a=Math.floor(r/i),n=r%i;if(s.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 s=e.target&&e.target.closest?e.target.closest(`.${this._bvBlock}__cell`):null;s&&this.contains(s)&&t(s)}),this.addEventListener("keydown",e=>{const s=e.target&&e.target.closest?e.target.closest(`.${this._bvBlock}__cell`):null;if(!s||!this.contains(s))return;if("Enter"===e.key||" "===e.key)return e.preventDefault(),void t(s);const r=this.querySelector(`.${this._bvBlock}__matrix`);if(!r)return;const i=Array.from(r.querySelectorAll(`.${this._bvBlock}__cell`)),a=i.indexOf(s);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,s=this.getAttribute("instrument")||this._remoteData&&this._remoteData.instrument;if(!e)return void renderEmpty(this,"survey");const r=document.createElement("span");if(r.className="c-survey__value",r.textContent=e,this.appendChild(document.createTextNode("Surveyed ")),this.appendChild(r),s){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=s,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,s=this.getAttribute("norm")||this._remoteData&&this._remoteData.norm,r=this.getAttribute("state")||this._remoteData&&this._remoteData.state,i=this.getAttribute("label")||this._remoteData&&this._remoteData.label;if(!e&&!s&&!i)return this.setAttribute("role","status"),void renderEmpty(this,"threshold");"status"===this.getAttribute("role")&&this.setAttribute("role","meter");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,s?labelText(this,"target","target")+" "+s: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(s){this.ensure(".c-threshold__target",()=>{const t=document.createElement("span");return t.className="c-threshold__target",t}).style.setProperty("--target",t(s))}else{const t=this.querySelector(".c-threshold__target");t&&t.remove()}r?this.setAttribute("data-state",r):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 s=document.createElement("div");s.className="c-metrics__value",s.textContent="object"==typeof t&&null!==t?t.value??t.v??"":String(t);const r=document.createElement("div");r.className="c-metrics__label",r.textContent="object"==typeof t&&null!==t?t.label??t.l??"":"",e.appendChild(s),e.appendChild(r),this.appendChild(e)}):t||renderEmpty(this,"metrics")}enhance(){wireStates(this)}}define("contour-metrics",ContourMetricsFull);class ContourSelectionGroup extends ContourBase{static get observed(){return["selected","mode"]}static get properties(){return{selected:{attribute:"selected",controlled:!0},mode:{attribute:"mode"}}}render(){this.classList.add("c-selection-group"),this.hasAttribute("role")||this.setAttribute("role","group");const t=(this.getAttribute("selected")||"").split(",").map(t=>t.trim()).filter(Boolean);for(const e of this.querySelectorAll("[data-selection]"))e.setAttribute("data-selected",t.includes(e.getAttribute("data-selection"))?"true":"false")}enhance(){this._wiredSelGroup||(this._wiredSelGroup=!0,this.addEventListener("contour:select",t=>{const e=t.detail||{},s=null!=e.value?String(e.value):null!=e.key?String(e.key):"",r=s?[s]:[];for(const t of this.querySelectorAll("[data-selection]"))t.setAttribute("data-selected",r.includes(t.getAttribute("data-selection"))?"true":"false");this.dispatchEvent(new CustomEvent("contour:selection",{bubbles:!0,composed:!0,detail:{value:s,mode:this.getAttribute("mode")||"single"}}))}))}}define("contour-selection-group",ContourSelectionGroup);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","domain","reverse"]}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},domain:{attribute:"domain"},reverse:{attribute:"reverse",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 s=Array.from(this.querySelectorAll(":scope > .c-legend__item"));let r=remoteData(this,"items");s.length&&(r=JSON.stringify(s.map(t=>{const e=t.querySelector(".c-legend__swatch"),s=t.querySelector(".c-legend__label")||t;return{label:s?s.textContent.trim():t.textContent.trim(),color:e&&(e.dataset&&e.dataset.color||e.style.background)||void 0}})),s.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(r)try{const s=JSON.parse(r),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="",s.forEach(s=>{const r="string"==typeof s?s:s.label||String(s),i="string"==typeof s?s:s.key||s.label||String(s),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=s&&null!=s.size?s.size:s&&null!=s.value?s.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(s&&s.color){const t=safeColor(s.color);t&&(o.style.background=t,o.dataset.color=t)}if(n.appendChild(o),t&&s&&null!=s.break){const t=document.createElement("span");t.className="c-legend__break-label",t.textContent=String(s.break),n.appendChild(t)}const l=s&&(s.shape||s.marker||s.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),s&&null!=s.size&&(t.style.fontSize="number"==typeof s.size?s.size+"px":String(s.size)),n.appendChild(t)}if(s&&null!=s.break){const t=document.createElement("span");t.className="c-legend__break",t.textContent=String(s.break),n.appendChild(t)}const c=document.createElement("span");c.className="c-legend__label",c.textContent=r,n.dataset.label=r,n.appendChild(c);const u="object"==typeof s&&s&&(s.caption||s.note)||"";if(u){const t=document.createElement("span");t.className="c-legend__caption",t.textContent=u,n.appendChild(t)}s&&(s.threshold||null!=s.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 s=(e.getAttribute("aria-describedby")||"").split(" ").filter(e=>e&&e!==t);s.length?e.setAttribute("aria-describedby",s.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(s){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 s=this.querySelector(".c-legend__ramp-label--start");s||(s=document.createElement("span"),s.className="c-legend__ramp-label c-legend__ramp-label--start",t.appendChild(s)),s.textContent=e[0];let r=this.querySelector(".c-legend__ramp-label--end");r||(r=document.createElement("span"),r.className="c-legend__ramp-label c-legend__ramp-label--end",t.appendChild(r)),r.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 b=this.getAttribute("domain");if(b){const t=this.ensure(".c-legend__domain",()=>{const t=document.createElement("div");return t.className="c-legend__domain",t}),e=b.split(",");t.textContent=(labelText(this,"domain","Domain")||"Domain")+": "+e.join(" – ")}else{const t=this.querySelector(".c-legend__domain");t&&t.remove()}this.hasAttribute("reverse")?this.classList.add("c-legend--reverse"):this.classList.remove("c-legend--reverse");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 s=document.createElement("summary");s.textContent=labelText(this,"data-table","Data table"),e.appendChild(s);const r=document.createElement("table");r.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 s=document.createElement("td");s.textContent=t,e.appendChild(s)}),i.appendChild(e)}),r.appendChild(i),e.appendChild(r)}}else{const t=this.querySelector(".c-legend__table-wrap");t&&t.remove()}const p=this.getAttribute("method");if(p){this.ensure(".c-legend__method",()=>{const t=document.createElement("div");return t.className="c-legend__method",t}).textContent=p}else{const t=this.querySelector(".c-legend__method");t&&t.remove()}const g=this.getAttribute("norm");if(g){this.ensure(".c-legend__norm",()=>{const t=document.createElement("span");return t.className="c-legend__norm",t}).textContent=g}else{const t=this.querySelector(".c-legend__norm");t&&t.remove()}const _=this.getAttribute("ramp");if(_){const t=this.ensure(".c-legend__ramp",()=>{const t=document.createElement("div");return t.className="c-legend__ramp",t});t.style.background=safeColor(_);const e=this.getAttribute("breaks");if(e){let s=null;try{s=JSON.parse(e)}catch(t){s=e.split(",").map(t=>t.trim())}Array.isArray(s)&&(Array.from(t.querySelectorAll(".c-legend__ramp-segment")).forEach(t=>t.remove()),s.forEach((e,s)=>{const r=document.createElement("span");r.className="c-legend__ramp-segment",r.style.flex="1";const i=document.createElement("span");i.className="c-legend__ramp-break",i.textContent=String(e),r.appendChild(i),t.appendChild(r)}))}}else{const t=this.querySelector(".c-legend__ramp");t&&t.remove()}const v=this.getAttribute("scale");if(v){this.ensure(".c-legend__scale",()=>{const t=document.createElement("div");return t.className="c-legend__scale",t}).textContent=v}else{const t=this.querySelector(".c-legend__scale");t&&t.remove()}const y=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=y?"none":"")}),this.querySelectorAll(".c-legend__caption").forEach(t=>{t.style.display=y?"none":""});const A=this.querySelector(".c-legend__items");A&&(A.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 s="true"!==e.getAttribute("aria-pressed");e.setAttribute("aria-pressed",String(s)),this._legendUnpressed=this._legendUnpressed||new Set;const r=e.dataset.key||e.textContent.trim();r&&(s?this._legendUnpressed.delete(r):this._legendUnpressed.add(r));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:s,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 s=document.activeElement,r=e.indexOf(s);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(s&&s.classList.contains("c-legend__item")&&s.click());navKey(t,e,{wrap:!0,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>e.forEach((e,s)=>e.setAttribute("tabindex",s===t?"0":"-1")),onKey:()=>{}})}else if(e.length>7){const s=r>=0?r+1:0;for(let r=0;r<e.length;r++){const i=(s+r)%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"),s=remoteData(this,"point"),r=remoteData(this,"line");if(!(t||e||s||r))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-select 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),s){this.ensure(".c-measure__point",()=>{const t=document.createElement("span");return t.className="c-measure__point",t}).textContent=s}else{const t=this.querySelector(".c-measure__point");t&&t.remove()}if(!r){const t=this.querySelector("svg");return void(t&&t.remove())}if(r){this.ensure(".c-measure__line",()=>{const t=document.createElement("span");return t.className="c-measure__line",t}).style.inlineSize=r}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")),s=remoteData(this,"items");if(s&&!e.length){Array.from(t.querySelectorAll(".c-timeline__item")).forEach(t=>t.remove());try{JSON.parse(s).forEach((e,s)=>{const r=document.createElement("li");if(r.className="c-timeline__item",r.setAttribute("tabindex",0===s?"0":"-1"),e.time){const t=document.createElement("time");t.className="c-timeline__time",t.setAttribute("datetime",String(e.time)),t.textContent=e.time,r.appendChild(t)}if(e.title){const t=document.createElement("div");t.className="c-timeline__title",t.textContent=e.title,r.appendChild(t)}if(e.text){const t=document.createElement("div");t.className="c-timeline__text",t.textContent=e.text,r.appendChild(t)}t.appendChild(r)})}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 s=Array.from(this.querySelectorAll(".c-timeline__item")).indexOf(e);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:s}}))}),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,s)=>e.setAttribute("tabindex",s===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 s=null,r=0;const i=()=>{s=document.createElement("div"),s.setAttribute("role","row"),this.appendChild(s),r=0};i(),t.forEach(t=>{t.setAttribute("role","gridcell"),s.appendChild(t),r++,r===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)),s=e>0?Math.ceil(Math.sqrt(e)):1;if(this.style.gridTemplateColumns="repeat("+s+", 1fr)",this.style.inlineSize="16rem",e>0){let t=[];try{t=JSON.parse(this.getAttribute("values")||"[]")}catch(e){t=[]}const r=t.map(t=>{const e=Number(t);return Number.isFinite(e)?e:null}),i=r.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(r[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===s&&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 s=t.target&&t.target.closest?t.target.closest(".c-heatmap__cell"):null;if(!s||!this.contains(s))return void e.setAttribute("hidden","");const r=s.getAttribute("data-title")||s.getAttribute("title");e.textContent=r||labelText(this,"cell","Cell")+" "+(s.dataset.index||"");const i=this.getBoundingClientRect(),a=s.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")},s=()=>{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)||s()}),this.addEventListener("focusin",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-heatmap__cell"):null;if(s&&this.contains(s)){e({target:s});const t=this.querySelector(".c-heatmap__tooltip");t&&t.id&&s.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)||s()}),this.addEventListener("keydown",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!s||!this.contains(s))return;const r=t(),i=r.indexOf(s);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,r.length-1);else if("ArrowLeft"===e.key)a=n?Math.min(i+1,r.length-1):Math.max(i-1,0);else if("ArrowDown"===e.key)a=Math.min(i+Math.ceil(Math.sqrt(r.length)),r.length-1);else if("ArrowUp"===e.key)a=Math.max(i-Math.ceil(Math.sqrt(r.length)),0);else if("Home"===e.key)a=0;else if("End"===e.key)a=r.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(),r.forEach((t,e)=>t.setAttribute("tabindex",e===a?"0":"-1"));try{r[a].focus()}catch(e){}}}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-heatmap__cell"):null;if(!s||!this.contains(s))return;const r=t().indexOf(s);r>=0&&this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:1,index:r}}))})}}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 s=remoteData(this,"yes")||this._remoteData&&this._remoteData.yes,r=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()),s){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(r){const t=document.createElement("div");t.className="c-compare__no",t.textContent=r,this.appendChild(t)}if(i){const t=document.createElement("p");t.className="c-compare__text",t.textContent=i,this.appendChild(t)}s||r||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),s=Array.isArray(e)?e.filter(Number.isFinite):[];if(0===s.length)throw new Error("empty");Array.from(this.querySelectorAll(".c-sparkline__dot, .c-sparkline__line, .c-sparkline__area")).forEach(t=>t.remove());const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","c-sparkline__line"),r.setAttribute("viewBox","0 0 100 30"),r.setAttribute("preserveAspectRatio","none"),r.style.inlineSize="100%",r.style.blockSize="100%",r.setAttribute("width","100%"),r.setAttribute("height","100%"),r.setAttribute("title",this.getAttribute("aria-label")||"Sparkline");const i=Math.min(...s),a=Math.max(...s)-i||1,n=t=>30-(t-i)/a*30;this._sparkScale={min:i,range:a};const o=s.length,l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",s.map((t,e)=>(0===e?"M":"L")+" "+(1===o?50:100*e/(o-1))+" "+n(t)).join(" ")),r.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"),r.appendChild(c),this.appendChild(r),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"),s=this.querySelector(".c-sparkline__tooltip"),r=this.querySelector(".c-sparkline__dot");if(!s||!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;r&&(r.setAttribute("cx",String(u)),r.setAttribute("cy",String(h)),r.removeAttribute("hidden")),s.textContent=String(c);const b=u/100*i.width;s.style.setProperty("--chart-tip-inline-start",b+"px"),s.style.setProperty("--chart-tip-block-start","0px"),s.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 s=e.getBoundingClientRect();t({clientX:s.left+s.width-1});const r=this.querySelector(".c-sparkline__tooltip");r&&r.id&&this.setAttribute("aria-describedby",r.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 s=this.getAttribute("title");if(s){this.ensure(".c-chart-grid__title",()=>{const t=document.createElement("div");return t.className="c-chart-grid__title",t}).textContent=s}const r=remoteData(this,"series");let i=[];if(r)try{const t=JSON.parse(r);Array.isArray(t)&&(i=t)}catch(t){}Array.from(this.querySelectorAll(".c-chart-grid__cell")).forEach(t=>t.remove()),i.forEach((t,e)=>{const s=Array.isArray(t)?t:t&&Array.isArray(t.values)?t.values:[],r=!Array.isArray(t)&&t&&t.label?t.label:labelText(this,"series","Series")+" "+(e+1),i=s.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=r,a.appendChild(n),i.length>1){const t=Math.min(...i),s=Math.max(...i)-t||1,r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","c-chart-grid__spark"),r.setAttribute("viewBox","0 0 100 30"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("aria-hidden","true");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",i.map((e,r)=>(0===r?"M":"L")+" "+100*r/(i.length-1)+" "+(30-(e-t)/s*30)).join(" ")),n.style.stroke="var(--chart-"+(e%8+1)+")",n.style.fill="none",n.style.strokeWidth="2",r.appendChild(n),a.appendChild(r)}this.appendChild(a)}),i.length||s||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"),s=this.getAttribute("levels");let r=null;if(e)try{r=JSON.parse(e)}catch(t){r=null}let i=[.3,.5,.7];if(s)try{const t=JSON.parse(s);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(r)||0===r.length||!Array.isArray(r[0])||0===r[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(r)&&r.length>1&&Array.isArray(r[0])&&r[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 s=0;contourPaths(r,i,t,e).forEach((t,e)=>{if(!t.d)return;const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",t.d),r.setAttribute("class","c-contour-plot__contour"+(e>0?" c-contour-plot__contour--level-"+(e+1):"")),r.setAttribute("tabindex",0===s?"0":"-1"),r.setAttribute("role","button"),r.setAttribute("aria-label",labelText(this,"level","Level")+" "+(e+1)+": "+t.level),r.dataset.level=String(e+1),r.dataset.value=String(t.level),s+=1,a.appendChild(r)})};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(r)){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 s=t().indexOf(e);if(s<0)return;const r=Number(e.dataset.level),i=Number(e.dataset.value);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{level:r,value:i,index:s}}))};this.addEventListener("click",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-contour-plot__contour"):null;s&&this.contains(s)&&e(s)}),this.addEventListener("keydown",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-contour-plot__contour"):null;if(r&&this.contains(r))if("Enter"===s.key||" "===s.key)s.preventDefault(),e(r);else{const e=t();navKey(s,e,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>e.forEach((e,s)=>e.setAttribute("tabindex",s===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",s=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:s?{message:e,src:s}:{message:e}}))},!0))}}define("contour-error-boundary",ContourErrorBoundary);class ContourDataExport extends ContourBase{static get observed(){return["data","format","filename","label","scope","crs","provenance","selected"]}static get properties(){return{data:{attribute:"data"},format:{attribute:"format"},filename:{attribute:"filename"},label:{attribute:"label"},scope:{attribute:"scope"},crs:{attribute:"crs"},provenance:{attribute:"provenance"},selected:{attribute:"selected"}}}scopeRows(t,e){if("selected"===e){let e=null;const s=this.getAttribute("selected");if(s)try{const t=JSON.parse(s);Array.isArray(t)&&(e=new Set(t.map(t=>String(t))))}catch(t){warnBadJson(this,"selected",t)}return t.filter(t=>e?e.has(String(t&&(t.key??t.id??""))):!(!t||!t.selected))}return"visible"===e?t.filter(t=>t&&!1!==t.visible):"filtered"===e?t.filter(t=>t&&!0!==t.filtered):t}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",s=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(s,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-download" /></svg>'),s.appendChild(document.createTextNode(" "+(this.getAttribute("label")||labelText(this,"export","Export")+" "+e.toUpperCase()))),s.parentNode!==this&&this.appendChild(s)}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 s=e.target&&e.target.closest?e.target.closest(".c-data-export__btn"):null;if(!s||!this.contains(s))return;const r=(this.getAttribute("format")||"json").toLowerCase(),i="csv"===r||"json"===r?r:(console.warn("[contour-data-export] unsupported format:",r),"json"),a=(this.getAttribute("scope")||"all").toLowerCase(),n=this.getAttribute("data")||"[]";let o=[],l=!1;try{const t=JSON.parse(n);Array.isArray(t)&&(o=t,l=!0)}catch(t){warnBadJson(this,"data",t)}const c=this.scopeRows(o,a),u=c.length,d=o.length;let h=n;if(l&&("all"!==a||"csv"===i))if("csv"===i)if(0===c.length)h="";else{const e=Object.keys(c[0]);h=[e.map(t).join(",")].concat(c.map(s=>e.map(e=>t(s[e])).join(","))).join("\r\n")}else h=JSON.stringify(c);const b=new Blob(["csv"===i?"\ufeff"+h:h],{type:"csv"===i?"text/csv":"application/json"}),m=URL.createObjectURL(b),p=this.getAttribute("filename")||"export."+i,g=document.createElement("a");g.href=m,g.download=p,document.body.appendChild(g),g.click(),g.remove(),setTimeout(()=>URL.revokeObjectURL(m),0);const _={format:i,scope:a,count:u,total:d,filename:p},v=this.getAttribute("crs");v&&(_.crs=v);const y=this.getAttribute("provenance");y&&(_.provenance=y),this.dispatchEvent(new CustomEvent("contour:export",{bubbles:!0,composed:!0,detail:_}))})}}function readRuleValue(t){const e=t.querySelector('.c-query-builder__value[data-part="low"]'),s=t.querySelector('.c-query-builder__value[data-part="high"]');if(e||s)return[e?e.value:"",s?s.value:""].join(",");const r=t.querySelector(".c-query-builder__null");return r?r.checked?"null":"":t.querySelector(".c-query-builder__value")?.value||""}define("contour-data-export",ContourDataExport);class ContourQueryBuilder extends ContourBase{static get observed(){return["query","fields","draft"]}static get properties(){return{query:{attribute:"query"},fields:{attribute:"fields"},draft:{attribute:"draft",type:Boolean}}}readRules(){const t=[],e=Array.from(this.querySelectorAll(".c-query-builder__row")),s=Array.from(this.querySelectorAll(".c-query-builder__connector__op"));return e.forEach((e,r)=>{const i={id:e.dataset.ruleId||"r"+r,field:e.querySelector(".c-query-builder__field")?.value||"",op:e.querySelector(".c-query-builder__op")?.value||"=",value:readRuleValue(e)};r>0&&s[r-1]&&(i.connector=s[r-1].value||"AND");const a=e.closest(".c-query-builder__group");a&&(i.group=a._groupName||""),"true"===e.querySelector(".c-query-builder__not")?.getAttribute("aria-pressed")&&(i.not=!0),t.push(i)}),t}static reindexConnectors(t,e){return t.forEach((t,s)=>{s>0&&e&&e[s]?t.connector=e[s]:delete t.connector}),t}attributeChangedCallback(t,e,s){"query"===t&&this._suppressQueryRender||(super.attributeChangedCallback(t,e,s),"draft"===t&&null!=e&&null==s&&this._draftRows&&this.commitDraft())}commit(t,e=!0){const s=this.hasAttribute("draft");if(s)this._draftRows=t;else 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,draft:s}}))}commitDraft(){const t=this._draftRows||this.readRules();this._draftRows=null,this.removeAttribute("draft"),this.setAttribute("query",JSON.stringify(t)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{query:t,draft:!1}}))}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 s=this.getAttribute("query");let r=[];if(this.hasAttribute("draft")&&this._draftRows)r=this._draftRows;else if(s)try{r=JSON.parse(s)}catch(t){r=[]}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;r.forEach((t,s)=>{const n=t&&t.group?String(t.group):"",o=!(!n||!a||a._groupName!==n);let l=null;if(s>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")+" "+s),["AND","OR"].forEach(s=>{const r=document.createElement("option");r.value=s,r.textContent=s,s===(t.connector||"AND")&&(r.selected=!0),e.appendChild(r)}),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 s=document.createElement("button");s.type="button",s.className="c-btn c-btn--sm c-btn--ghost c-query-builder__group-remove",s.setAttribute("aria-label",labelText(this,"remove-group","Remove group")+" "+n),s.setAttribute("data-group",n),s.textContent="×",t.appendChild(e),t.appendChild(s),a.appendChild(t),i.appendChild(a)}else l&&i.appendChild(l),a=null;const c=document.createElement("div");c.className="c-query-builder__row",c.dataset.ruleId=t.id||"r"+s;const u=document.createElement("select");u.className="c-input c-query-builder__field",u.setAttribute("aria-label",labelText(this,"field","Field")+" "+(s+1)),e.forEach(e=>{const s=document.createElement("option");s.value="string"==typeof e?e:e.value||e.label||"",s.textContent="string"==typeof e?e:e.label||e.value||"",s.value===t.field&&(s.selected=!0),u.appendChild(s)});const d=document.createElement("select");d.className="c-input c-query-builder__op",d.setAttribute("aria-label",labelText(this,"operator","Operator")+" "+(s+1)),["=","!=",">","<","contains"].forEach(e=>{const s=document.createElement("option");s.value=e,s.textContent=e,e===t.op&&(s.selected=!0),d.appendChild(s)});const h=(b=t.field,e.find(t=>("string"==typeof t?t:t.value||t.label||"")===b)||{});var b;const m=h.type||"text",p=(t,e,r)=>{const i=document.createElement("input");return i.className="c-input c-query-builder__value",i.type=t,r&&(i.dataset.part=r),i.setAttribute("value",e||""),i.value=e||"",i.setAttribute("aria-label",labelText(this,"value","Value")+" "+(s+1)+(r?" "+r:"")),i};let g;if("enum"===m&&Array.isArray(h.options)&&h.options.length)g=document.createElement("select"),g.className="c-input c-query-builder__value",g.setAttribute("aria-label",labelText(this,"value","Value")+" "+(s+1)),h.options.forEach(e=>{const s=document.createElement("option");s.value="string"==typeof e?e:e.value??e,s.textContent="string"==typeof e?e:e.label??e.value??e,s.value===t.value&&(s.selected=!0),g.appendChild(s)});else if("null"===m)g=document.createElement("input"),g.type="checkbox",g.className="c-query-builder__value c-query-builder__null",g.checked="null"===t.value,g.setAttribute("aria-label",labelText(this,"is-null","Is null")+" "+(s+1));else if("range"===m){const e=String(t.value||"").split(",");g=document.createDocumentFragment(),g.appendChild(p("number",e[0],"low")),g.appendChild(p("number",e[1],"high"))}else g=p("date"===m?"date":"text",t.value);const _=document.createElement("button");_.type="button",_.className="c-btn c-btn--sm c-btn--ghost c-query-builder__not",_.setAttribute("aria-label",labelText(this,"negate","Negate")+" "+(s+1)),_.setAttribute("aria-pressed",t.not?"true":"false"),_.textContent="NOT";const v=document.createElement("button");v.type="button",v.className="c-btn c-btn--sm c-btn--ghost c-query-builder__move c-query-builder__move--up",v.setAttribute("aria-label",labelText(this,"move-rule","Move rule")+" "+(s+1)+" "+labelText(this,"up","up")),v.textContent="↑",0===s&&(v.disabled=!0);const y=document.createElement("button");y.type="button",y.className="c-btn c-btn--sm c-btn--ghost c-query-builder__move c-query-builder__move--down",y.setAttribute("aria-label",labelText(this,"move-rule","Move rule")+" "+(s+1)+" "+labelText(this,"down","down")),y.textContent="↓",s===r.length-1&&(y.disabled=!0);const f=document.createElement("button");f.type="button",f.className="c-btn c-btn--sm c-btn--ghost c-query-builder__remove",f.setAttribute("aria-label",labelText(this,"remove-rule","Remove rule")+" "+(s+1)),f.textContent="×",c.appendChild(u),c.appendChild(d),c.appendChild(g),c.appendChild(_),c.appendChild(v),c.appendChild(y),c.appendChild(f),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;const s=e.closest(".c-query-builder__not");if(s){const t="true"!==s.getAttribute("aria-pressed");return s.setAttribute("aria-pressed",String(t)),void this.commit(this.readRules(),!1)}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 s=this.querySelectorAll(".c-query-builder__row"),r=s[s.length-1],i=r&&r.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(),s=new Set(e.map(t=>t.group).filter(Boolean));let r=1;for(;s.has("Group "+r);)r++;e.push({field:"",op:"=",value:"",group:"Group "+r}),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 i=e.closest(".c-query-builder__move");if(i){const t=i.closest(".c-query-builder__row");if(!t)return;const e=i.classList.contains("c-query-builder__move--up"),s=this.readRules().map(t=>t.connector),r=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>=r.length)return;const o=r[n];r[n]=r[a],r[a]=o,this.commit(ContourQueryBuilder.reindexConnectors(r,s));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 s=this.readRules().map(t=>t.connector),r=this.readRules(),i=Array.from(this.querySelectorAll(".c-query-builder__row")).indexOf(t);i>=0&&r.splice(i,1),this.commit(ContourQueryBuilder.reindexConnectors(r,s))}}))}}function tokenColor(t,e,s,r){const i=safeColor(t.getAttribute(e));if(i)return i;try{const e=getComputedStyle(t).getPropertyValue(s).trim();if(e)return e}catch(t){}return r}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,s=document.createElement("canvas");s.width=e,s.height=e,s.style.inlineSize=e+"px",s.style.blockSize=e+"px";const r=s.getContext("2d");r&&(paintDonutGlyph(r,{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(s))}}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,s=document.createElement("canvas");s.width=e,s.height=e,s.style.inlineSize=e+"px",s.style.blockSize=e+"px";const r=s.getContext("2d");if(!r)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(r,{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(s)}}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,s=document.createElement("canvas");s.width=e,s.height=e,s.style.inlineSize=e+"px",s.style.blockSize=e+"px";const r=s.getContext("2d");r&&(paintPurityRing(r,{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(s))}}define("contour-purity-ring",ContourPurityRing);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:s=0,color:r="#1f77b4",strokeWidth:i,bgColor:a="transparent"}={}){const n=Number(e)||24,o=null!=i?Number(i):spriteStroke(n),l=unit(s),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=r,t.lineCap="round",t.stroke())}export function paintSparklineGlyph(t,{size:e=24,values:s=[],color:r="#1f77b4",strokeWidth:i,bgColor:a="transparent"}={}){const n=Number(e)||24,o=null!=i?Number(i):spriteStroke(n),l=Array.isArray(s)?s.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,b=Math.min(...l),m=Math.max(...l)-b||1;t.beginPath(),l.forEach((e,s)=>{const r=u+s/(c-1)*d,i=(t=>u+h-(t-b)/m*h)(e);0===s?t.moveTo(r,i):t.lineTo(r,i)}),t.lineWidth=o,t.strokeStyle=r,t.lineCap="round",t.lineJoin="round",t.stroke()}export function paintPurityRing(t,{size:e=32,hue:s=0,concentration:r=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,b=Math.max(0,Math.min(4,Math.floor(Number(s)||0))),m=i||categoryColor(b,"#1f77b4"),p=quantise(r,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=m,t.lineCap="round",t.stroke()),a>0){const e=h+c,s=1===a?[c,2*c]:[2*c,c];t.beginPath(),t.arc(u,d,e,0,2*Math.PI),t.lineWidth=c,t.strokeStyle=m,t.setLineDash(s),t.stroke(),t.setLineDash([])}if(o>0&&n>=0){const e=Math.max(0,Math.min(o-1,Math.floor(Number(n)||0))),s=-Math.PI/2+e/o*2*Math.PI,r=u+h*Math.cos(s),i=d+h*Math.sin(s);t.beginPath(),t.arc(r,i,.75*c,0,2*Math.PI),t.fillStyle=m,t.fill()}}export function paintPurityRingPixels(t={}){const e=Number(t.size)||32;let s=t.canvas;if(!s)if("undefined"!=typeof OffscreenCanvas)s=new OffscreenCanvas(e,e);else{if("undefined"==typeof document)throw new Error("paintPurityRingPixels: no OffscreenCanvas or document — pass opts.canvas");s=document.createElement("canvas"),s.width=e,s.height=e}const r=s.getContext("2d");if(!r)throw new Error("paintPurityRingPixels: canvas.getContext('2d') returned null");return paintPurityRing(r,{...t,size:e}),r.getImageData(0,0,e,e)}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),s=this.ensure(".c-dash-toolbar__actions",()=>{const t=document.createElement("div");return t.className="c-dash-toolbar__actions",t});s.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,s.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 s=Array.from(this.querySelectorAll(".c-btn")),r=s.indexOf(e);let i=-1;if("ArrowRight"===t.key?i=Math.min(s.length-1,r+1):"ArrowLeft"===t.key&&(i=Math.max(0,r-1)),i>=0){t.preventDefault();try{s[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,s)=>{const r=document.createElement("contour-kpi");if("object"==typeof e&&null!==e)for(const s of t){const t=e[s];null!=t&&r.setAttribute(s,"string"==typeof t?t:JSON.stringify(t))}else r.setAttribute("value",String(e));r.setAttribute("tabindex",0===s?"0":"-1"),r.dataset.contourGenerated="",this.appendChild(r)})}}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,s)=>e.setAttribute("tabindex",s===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"),s=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});s.parentNode!==this&&this.appendChild(s),this._freshnessText&&this._freshnessText.parentNode||(this._freshnessText=document.createTextNode(""),this.appendChild(this._freshnessText));const r=e?formatValue(e,this.getAttribute("format"),this.getAttribute("locale")):e;this._freshnessText.nodeValue=[t,r].filter(Boolean).join(" ")}}define("contour-dash-freshness",ContourDashFreshness);class ContourSavedView extends ContourBase{static get observed(){return["name","updated","source","active","dirty","conflict","default"]}static get properties(){return{name:{attribute:"name"},updated:{attribute:"updated"},source:{attribute:"source"},active:{attribute:"active",type:Boolean},dirty:{attribute:"dirty",type:Boolean},conflict:{attribute:"conflict",type:Boolean},default:{attribute:"default",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 s=this.getAttribute("updated"),r=this.getAttribute("source");e.replaceChildren();const i=[];if(this.hasAttribute("default")&&i.push(labelText(this,"default","Default")),this.hasAttribute("dirty")&&i.push(labelText(this,"dirty","Unsaved")),this.hasAttribute("conflict")&&i.push(labelText(this,"conflict","Conflict")),i.forEach((t,i)=>{(i>0||s||r)&&e.appendChild(document.createTextNode(" · "));const a=document.createElement("span");a.className="c-saved-view__badge",a.textContent=t,e.appendChild(a)}),s){e.childNodes.length&&e.appendChild(document.createTextNode(" · "));const t=document.createElement("span");t.textContent=`Updated ${s}`,e.appendChild(t)}if(r){e.childNodes.length&&e.appendChild(document.createTextNode(" · "));const t=document.createElement("span");t.textContent=`${labelText(this,"source","Source")}: ${r}`,e.appendChild(t)}let a=this.querySelector(".c-saved-view__actions");a||(a=document.createElement("div"),a.className="c-saved-view__actions",this.appendChild(a));const n=a.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",""),a.appendChild(t),t})();applyLabel(n,this,"apply","Apply");[["rename","rename","Rename"],["duplicate","duplicate","Duplicate"],["share","share","Share"]].forEach(([t,e,s])=>{const r=a.querySelector(`.c-saved-view__${t}`)||(()=>{const e=document.createElement("button");return e.type="button",e.className="c-btn c-btn--ghost c-btn--sm",e.setAttribute(`data-saved-view-${t}`,""),a.appendChild(e),e})();applyLabel(r,this,e,s)});const o=a.querySelector(".c-saved-view__default")||(()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--ghost c-btn--sm",t.setAttribute("data-saved-view-default",""),a.appendChild(t),t})();applyLabel(o,this,"default","Set as default"),o.setAttribute("aria-pressed",this.hasAttribute("default")?"true":"false");const l=a.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",""),a.appendChild(t),t})();applyLabel(l,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;if(!e||!this.contains(e))return;const s=this.getAttribute("name");if(e.hasAttribute("data-saved-view-apply"))this.dispatchEvent(new CustomEvent("contour:apply",{bubbles:!0,composed:!0,detail:{name:s}}));else if(e.hasAttribute("data-saved-view-remove"))this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{name:s}}));else if(e.hasAttribute("data-saved-view-rename"))this.dispatchEvent(new CustomEvent("contour:rename",{bubbles:!0,composed:!0,detail:{name:s}}));else if(e.hasAttribute("data-saved-view-duplicate"))this.dispatchEvent(new CustomEvent("contour:duplicate",{bubbles:!0,composed:!0,detail:{name:s}}));else if(e.hasAttribute("data-saved-view-share"))this.dispatchEvent(new CustomEvent("contour:share",{bubbles:!0,composed:!0,detail:{name:s}}));else if(e.hasAttribute("data-saved-view-default")){const t=!this.hasAttribute("default");this.dispatchEvent(new CustomEvent("contour:default",{bubbles:!0,composed:!0,detail:{name:s,default:t}}))}}))}}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}),s=document.createElement("b");s.textContent=labelText(this,"source","Source")+":",e.replaceChildren(s,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}),s=String(e).toLowerCase(),r="high"===s||"medium"===s||"low"===s;t.className="c-provenance__confidence"+(r?" c-provenance__confidence--"+s:" c-provenance__confidence--unknown"),t.textContent=`Confidence: ${e}`}else{const t=this.querySelector(".c-provenance__confidence");t&&t.remove()}const s=this.getAttribute("resolution");if(s){this.ensure(".c-provenance__resolution",()=>{const t=document.createElement("span");return t.className="c-provenance__resolution",t}).textContent=`Resolution: ${s}`}else{const t=this.querySelector(".c-provenance__resolution");t&&t.remove()}const r=this.getAttribute("coverage");if(r){this.ensure(".c-provenance__coverage",()=>{const t=document.createElement("span");return t.className="c-provenance__coverage",t}).textContent=`Coverage: ${r}`}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()}}}function parseJsonMap(t){if(!t)return{};try{const e=JSON.parse(t);return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}catch(t){return{}}}function isGeometryObject(t){return!(!t||"object"!=typeof t||Array.isArray(t)||"string"!=typeof t.type||!("coordinates"in t||"geometry"in t||"features"in t))}function addInspectorFields(t,e,s,r){for(const[i,a]of Object.entries(e)){if(a&&"object"==typeof a&&!Array.isArray(a)&&!isGeometryObject(a)){const e=document.createElement("div");e.className="c-feature-inspector__group";const n=document.createElement("div");n.className="c-feature-inspector__group-label",n.textContent=i,e.appendChild(n),addInspectorFields(e,a,s,r+1),t.appendChild(e);continue}const e=document.createElement("div");e.className="c-feature-inspector__field";const n=document.createElement("span");n.className="c-feature-inspector__label",n.textContent=i;const o=document.createElement("span");if(o.className="c-feature-inspector__value",Array.isArray(a)){const t=document.createElement("ul");t.className="c-feature-inspector__list",a.forEach(e=>{const s=document.createElement("li");s.textContent=e&&"object"==typeof e?JSON.stringify(e):String(e),t.appendChild(s)}),o.appendChild(t)}else{const t=s.types[i];let e;if("timestamp"===t&&a){const t=new Date(a);e=Number.isNaN(t.getTime())?String(a):t.toISOString()}else e="geometry"===t||isGeometryObject(a)?geometrySummary(a):String(a);if(s.units[i]&&(e+=" "+s.units[i]),o.textContent=e,null!=s.conf[i]&&""!==s.conf[i]){const t=document.createElement("span");t.className="c-feature-inspector__confidence",t.setAttribute("role","img"),t.setAttribute("aria-label",`Confidence ${s.conf[i]}`),t.dataset.confidence=String(s.conf[i]),o.appendChild(document.createTextNode(" ")),o.appendChild(t)}}e.appendChild(n),e.appendChild(o),t.appendChild(e)}}function geometrySummary(t){return t&&"object"==typeof t?"Point"===t.type&&Array.isArray(t.coordinates)?`Point (${t.coordinates.join(", ")})`:Array.isArray(t.coordinates)?`${t.type||"Geometry"} (${t.coordinates.length} pts)`:t.type||"Geometry":String(t)}define("contour-provenance",ContourProvenance);class ContourFeatureInspector extends ContourBase{static get observed(){return["title","open","data","actions","units","types","confidence"]}static get properties(){return{title:{attribute:"title"},open:{attribute:"open",type:Boolean},data:{attribute:"data"},units:{attribute:"units"},types:{attribute:"types"},confidence:{attribute:"confidence"}}}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 s=this.getAttribute("data");if(s)try{const t=JSON.parse(s);if(t&&"object"==typeof t&&!Array.isArray(t)){const s=parseJsonMap(this.getAttribute("units")),r=parseJsonMap(this.getAttribute("types"));addInspectorFields(e,t,{units:s,types:r,conf:parseJsonMap(this.getAttribute("confidence"))},0)}}catch(t){warnBadJson(this,"attribute",t)}const r=this.ensure(".c-feature-inspector__actions",()=>{const t=document.createElement("div");return t.className="c-feature-inspector__actions",t});Array.from(r.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)),r.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}r.style.display=r.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);
|
|
1
|
+
import{CLASS_ONLY,CONTOUR_EVENTS,ContourBase,MERCATOR_MAX_LAT,MODS,OBSERVED,REGISTERED,applyLabel,bearing,clampLat,contourId,cssLength,define,flagOn,flagOnValue,formatValue,haversine,headingTag,iconMarkup,isRtl,labelText,levelFromAttributes,mercatorResolution,navKey,normaliseLng,onDispose,safeColor,safeHref,sanitizeHtml,setHTML,simple,statusIcon,supportsUntilFound,unwrapBounds,warnBadJson,wcEmitOverlay,withBrownout,PROPERTY_FIELDS,normalizeProperty,propertyDescriptor,propertyTypeOf,contourDiagnosticsEnabled,setContourDiagnostics,MARKER_SHAPES,arcPath,assignMarkers,barRects,compassNeedle,contourPaths,donutSlices,isMissing,marchingSquares,markerStyles,niceTicks,polylinePoints,scaleBarTicks,smoothPath,modalContain,wcReset,wireCombobox,wireCopy,wireMenu,wirePagination,wireRemovable,wireSegmented,wireTabs,wireTree,STATE_FALLBACK,loadRemote,parseArrayAttr,remoteData,remoteInvalidate,remoteRefresh,remoteVisible,renderEmpty,renderStates,stateLabel,virtualRange,watchViewport,wireStates}from"./contour-wc-core.esm.js";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};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){const e=this.ensure(".c-kpi__value",()=>{const t=document.createElement("div");return t.className="c-kpi__value",t.setAttribute("aria-live","polite"),t}),r=formatValue(t,this.getAttribute("format"),this.getAttribute("locale"),this.getAttribute("unit")),s=null!=this._kpiLastValue&&this._kpiLastValue!==r;this._kpiLastValue=r,e.textContent=r,s&&(e.classList.remove("is-updating"),e.offsetWidth,e.classList.add("is-updating"))}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(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Table");let t=this.querySelector(".c-table__selection-status");t||(t=document.createElement("span"),t.className="c-table__selection-status visually-hidden",t.setAttribute("aria-live","polite"),this.appendChild(t));const e=this._selectionControlled?this._selectedKeys?this._selectedKeys.size:0:this._selectedRows?this._selectedRows.size:0;if(t.textContent=e?`${e} selected`:"",wireStates(this),loadRemote(this,"rows"),renderStates(this,"table"))return;const r=this.getAttribute("columns"),s=remoteData(this,"rows"),i=Array.from(this.children).filter(t=>!t.classList||!t.classList.contains("c-table-wrap")&&!t.classList.contains("c-table__selection-status"));if(r&&s&&!i.length)try{const t=JSON.parse(r),e=JSON.parse(s),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 e=Number(i);this._sortCol=Number.isFinite(e)?e:t.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(e)?e.slice():[];if(null!==this._sortCol&&void 0!==this._sortCol&&this._sortCol>=0&&this._sortCol<t.length){const e=this._sortCol,r=this._sortDir||1,s=t[e],i="object"==typeof s&&s&&s.sortType?s.sortType:"text";n.sort((t,a)=>this._compare(this._cellFor(t,s,e),this._cellFor(a,s,e),i)*r)}this._filters||(this._filters={});const o=Object.keys(this._filters).filter(t=>this._filters[t]);o.length&&(n=n.filter(e=>o.every(r=>{const s=Number(r),i=String(this._filters[s]||"").toLowerCase();return!i||String(this._cellValue(this._cellFor(e,t[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=t.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(t),v=g.querySelector("table.c-table")&&this._tableCols===_?g.querySelector("table.c-table"):(()=>{const e=document.createElement("table");e.className="c-table";const r=document.createElement("caption");r.className="visually-hidden",r.textContent=this.getAttribute("title")||this.getAttribute("aria-label")||"Table",e.appendChild(r);const s=document.createElement("thead"),i=document.createElement("tr");return t.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),e.appendChild(s),e.appendChild(document.createElement("tbody")),e})();this._tableCols=_,this._applyVisibleColumns(v),t.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 y=v.querySelector("tbody"),f=null!=this._tablePendingScrollTop?this._tablePendingScrollTop:g.scrollTop;this._tablePendingScrollTop=null,y.innerHTML="";const A=this.hasAttribute("virtual")&&!u&&b.length>100,w=this._measuredRowHeight||cssLength("--data-grid-row-height",32),C=30,x=10;let E=0,S=b;A?(E=virtualRange(f,w,(C-x)*w,b.length,x).start,S=b.slice(E,E+C+2*x),v.setAttribute("aria-rowcount",String(b.length+1)),this._tableWindowStart=E):v.removeAttribute("aria-rowcount");const k=e=>{const r=document.createElement("tr");r.setAttribute("aria-hidden","true");const s=document.createElement("td");s.colSpan=t.length,s.style.blockSize=`${e}px`,s.style.padding="0",r.appendChild(s),y.appendChild(r)};if(A&&k(E*w),0===S.length){const e=document.createElement("tr"),r=document.createElement("td");r.colSpan=t.length,r.textContent=this.getAttribute("empty")||"No data",r.style.textAlign="center",r.style.color="var(--color-text-muted)",e.appendChild(r),y.appendChild(e)}else S.forEach((e,r)=>{const s=document.createElement("tr");s.dataset.rowIndex=String(E+r);const i=this._rowKey(e);s.dataset.rowKey=i,s.setAttribute("tabindex","-1"),t.forEach((t,a)=>{const n="object"==typeof t&&null!==t&&t.select,o="object"==typeof t&&null!==t&&("number"===t.type||"numeric"===t.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(E+r),t.setAttribute("aria-label",labelText(this,"select-row","Select row")+" "+(i??E+r+1)),t.dataset.contourPreserveKey=i,this._selectionControlled?this._selectedKeys.has(i)&&(t.checked=!0):this._selectedRows&&this._selectedRows.has(E+r)&&(t.checked=!0),l.appendChild(t)}else l.textContent=this._cellValue(this._cellFor(e,t,a));s.appendChild(l)}),y.appendChild(s)});if(A&&k(Math.max(0,b.length-E-S.length)*w),!y.querySelector('tr[tabindex="0"]')){const t=y.querySelector("tr[data-row-index]");t&&t.setAttribute("tabindex","0")}if(!this._measuredRowHeight&&!this._measuringRow){const t=y.querySelector("tr[data-row-index]"),e=t?t.getBoundingClientRect().height:0;e>0&&(this._measuredRowHeight=e,Math.abs(e-w)>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&&f>0&&g.scrollTop!==f&&(this._tableScrollRestoredAt="undefined"!=typeof performance&&performance.now?performance.now():Date.now(),g.scrollTop=f),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 s||i.length||renderEmpty(this,"table")}_updateSelectionStatus(){const t=this.querySelector(".c-table__selection-status");if(!t)return;const e=this._selectionControlled?this._selectedKeys?this._selectedKeys.size:0:this._selectedRows?this._selectedRows.size:0;t.textContent=e?`${e} selected`:""}_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);if(!Number.isFinite(e))return;this._sortCol===e?1===this._sortDir?this._sortDir=-1:(this._sortCol=null,this._sortDir=1):(this._sortCol=e,this._sortDir=1);const r=this._sortCol===e?1===this._sortDir?"ascending":"descending":"none";this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:!0,composed:!0,detail:{column:e,direction:r}})),this.dispatchEvent(new CustomEvent("contour:filter-change",{bubbles:!0,composed:!0,detail:{source:"table",filter:{sort:this._sortCol===e?e:null,sortDir:r}}})),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(),this._updateSelectionStatus();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,this._updateSelectionStatus();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,s=r?t:t.label||t.name||t.key||t.value||"";let i=r?t:null!=t.key?t.key:null!=t.value?t.value:null!=t.name?t.name:s;i=String(i);const a=document.createElement("label");a.className="c-column-picker__item";const n=document.createElement("input");n.type="checkbox",n.checked=!!r||(null!=t.checked?!!t.checked:null==t.visible||!!t.visible),n.dataset.column=i,a.appendChild(n),a.appendChild(document.createTextNode(" "+(s||i))),e.appendChild(a)})}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;if(t.every(t=>"number"==typeof t&&Number.isFinite(t)))return decimateMinMax(t,e);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);Number.isFinite(a)&&(i.normalized=a);const n=safeColor(t.color);return n&&(i.color=n),i};class ContourChart extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["series","axis","color","colors","label","legend","brownout","brownout-level","empty","loading","error","retry","skeleton","zoomable","data-table","brush","brush-min","brush-max","brush-start","brush-end","note","annotations","mean-marker","median-marker","bucket-count","limit-values","title","cache-key","dir","src"]}static get properties(){return{series:{attribute:"series"},axis:{attribute:"axis"},color:{attribute:"color"},colors:{attribute:"colors"},label:{attribute:"label"},legend:{attribute:"legend"},zoomable:{attribute:"zoomable",type:Boolean},brush:{attribute:"brush",type:Boolean},note:{attribute:"note"},annotations:{attribute:"annotations"},"mean-marker":{attribute:"mean-marker",type:Boolean},"median-marker":{attribute:"median-marker",type:Boolean},"bucket-count":{attribute:"bucket-count"},"limit-values":{attribute:"limit-values"}}}set format(t){this._jsFormat="function"==typeof t?t:null,this.requestRender()}get format(){return this._jsFormat||null}set tooltipFormat(t){this._jsTooltipFormat="function"==typeof t?t:null,this.requestRender()}get tooltipFormat(){return this._jsTooltipFormat||null}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}_nearestMark(t,e,r=22){const s=this.querySelector(".c-chart__plot");if(!s)return null;const i=s.querySelectorAll(".c-chart__bar, .c-chart__point, .c-donut__slice");let a=null,n=r;for(const r of i){if("true"===r.getAttribute("aria-hidden"))continue;const s=r.getBoundingClientRect();if(!s.width&&!s.height)continue;const i=t>=s.left&&t<=s.right&&e>=s.top&&e<=s.bottom,o=Math.hypot(t-(s.left+s.width/2),e-(s.top+s.height/2)),l=i?0:o;l<n&&(n=l,a=r)}return a}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%8+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}}_renderChartMarkers(t){const e=this._plot||this.querySelector(".c-chart__plot");e&&(Array.from(e.querySelectorAll(".c-chart__marker, .c-chart__annotation")).forEach(t=>t.remove()),Array.isArray(t)&&t.length&&t.forEach(t=>{if(!t||!Number.isFinite(t.frac))return;const r=document.createElement("div");if(r.className="annotation"===t.kind?"c-chart__annotation":"c-chart__marker",r.style.left=(100*Math.max(0,Math.min(1,t.frac))).toFixed(3)+"%",t.kind&&"annotation"!==t.kind&&(r.dataset.kind=t.kind),t.label){const e=document.createElement("span");e.className="c-chart__marker-label",e.textContent=t.label,r.appendChild(e)}r.setAttribute("aria-hidden","true"),e.appendChild(r)}))}_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=this._jsFormat||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){let t;try{t=JSON.parse(r)}catch(e){warnBadJson(this,"series",e),t=[]}if(Array.isArray(t)||(t=[]),0===t.length)return void renderEmpty(this,"chart");this._chartSeries=t;const e=this.ensure(".c-chart__plot",()=>{const t=document.createElement("div");return t.className="c-chart__plot",t});this.keepNode(e);const s=document.createDocumentFragment(),i=[];if(t.some(t=>t&&(Array.isArray(t.values)||Array.isArray(t.bins))))this._renderedBins=[],this._renderedBackground=[],t.forEach((t,e)=>{const r=this._seriesColor(t,e);if("donut"===t.type){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("viewBox","0 0 200 200"),r.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",r.setAttribute("role","group"),r.setAttribute("aria-label",t.label||"Donut chart"),donutSlices(t.values).forEach((s,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",s.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"),r.appendChild(a)}),s.appendChild(r)}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,s)=>{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",r),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[s])),n.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(i[s])),n.setAttribute("tabindex","0"),n.setAttribute("role","button"),n.dataset.index=String(s),a.appendChild(n)}),s.appendChild(a)}else if("histogram"===t.type){let a=Array.isArray(t.values)?t.values.slice():[];const n=parseInt(this.getAttribute("limit-values")||"0",10);n>0&&(a=a.slice(0,n));const o=parseInt(this.getAttribute("bucket-count")||"0",10),l=this._pushedBins&&this._pushedBins.length?this._pushedBins:null,c=Array.isArray(t.bins)?t.bins.map(normalizeChartBin).filter(Boolean):null;let u=l||(c&&c.length?c:null),d=a;if(!u&&o>0&&a.length){const t=a.map(t=>Number(t)||0),e=Math.min.apply(null,t),r=(Math.max.apply(null,t)-e||1)/o,s=new Array(o).fill(0);t.forEach(t=>{const i=Math.min(o-1,Math.floor((t-e)/r));s[i]+=1}),d=s,u=s.map((t,s)=>({x0:e+s*r,x1:e+(s+1)*r,count:t}))}u&&(d=u.map(t=>t.count));let h=null;const m=this.getAttribute("colors"),b=m?(()=>{try{return JSON.parse(m)}catch(t){return null}})():Array.isArray(t.colors)?t.colors:null;Array.isArray(b)&&(h=b.map(t=>safeColor(t)).filter(Boolean)),this._renderedBins=u?u.slice():[];const p=this._pushedBackground&&this._pushedBackground.length?this._pushedBackground:null,g=Array.isArray(t.background)?t.background.map(normalizeChartBin).filter(Boolean):null,_=p||(g&&g.length?g:[]);this._renderedBackground=_.slice();const v=_.map(t=>Number(t.count)||0);let y=1;v.length&&d.concat(v).forEach(t=>{const e=Number(t)||0;e>y&&(y=e)});const f=document.createElementNS("http://www.w3.org/2000/svg","svg");if(f.setAttribute("viewBox","0 0 300 120"),f.setAttribute("preserveAspectRatio","none"),f.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%",v.length&&barRects(v,{max:y}).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",r),e.setAttribute("x",t.x),e.setAttribute("y",t.y),e.setAttribute("width",t.width),e.setAttribute("height",t.height),f.appendChild(e)}),barRects(d,v.length?{max:y}:void 0).forEach((s,i)=>{if(s.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));const n=u&&u[i]&&u[i].color||h&&h[i]||r;a.style.setProperty("--c",n),a.setAttribute("x",s.x),a.setAttribute("y",s.y),a.setAttribute("width",s.width),a.setAttribute("height",s.height);const o=u?u[i].count:Array.isArray(t.values)?t.values[i]:i;a.setAttribute("data-title",String(o)),a.setAttribute("aria-label",labelText(this,"series","Series")+" "+(e+1)+": "+String(o)),a.setAttribute("tabindex","0"),a.setAttribute("role","button"),a.dataset.index=String(i),f.appendChild(a)}),s.appendChild(f),u&&u.length){const e=Number(u[0].x0),r=Number(u[u.length-1].x1)-e||1,s=t=>(t-e)/r,a=u.reduce((t,e)=>t+(Number(e.count)||0),0);if(flagOn(this,"mean-marker")&&a>0){let t=0;u.forEach(e=>{const r=(Number(e.x0)+Number(e.x1))/2;t+=r*(Number(e.count)||0)});const e=t/a;i.push({frac:s(e),label:labelText(this,"mean","mean")+" "+formatValue(e),kind:"mean"})}if(flagOn(this,"median-marker")&&a>0){let t=0,r=e;const n=a/2;for(const e of u)if(t+=Number(e.count)||0,t>=n){r=(Number(e.x0)+Number(e.x1))/2;break}i.push({frac:s(r),label:labelText(this,"median","median")+" "+formatValue(r),kind:"median"})}let n=Array.isArray(t.annotations)?t.annotations:null;const o=this.getAttribute("annotations");if(!n&&o)try{const t=JSON.parse(o);Array.isArray(t)&&(n=t)}catch(t){}Array.isArray(n)&&n.forEach(t=>{const e=Number(t&&null!=t.value?t.value:t);if(!Number.isFinite(e))return;const r=t&&"object"==typeof t&&null!=t.label?String(t.label):formatValue(e);i.push({frac:s(e),label:r,kind:"annotation"})})}}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,s)=>{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(s)),a.style.setProperty("--c",r);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===s?"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+")")),s.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",r),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,s)=>{if(isMissing(t))return;const a=Number(t);if(!Number.isFinite(a))return;const n=s/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(s)),h.style.setProperty("--c",r),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)}),s.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)}),s.appendChild(e)}if(patchChildren(e,s),this._renderChartMarkers(i),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 a=(this.getAttribute("data-table")||"").trim().toLowerCase(),n="none"===a||"off"===a||"false"===a||"0"===a,o=t.some(t=>Array.isArray(t&&t.values)&&t.values.length),l=this._renderedBins||[],c=!o&&l.length>0;if(n||!o&&!c){const t=this.querySelector(".c-chart__data-table");t&&t.remove()}else{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");if(s.textContent=r,e.appendChild(s),c){const t=document.createElement("thead"),r=document.createElement("tr"),s=document.createElement("th");s.setAttribute("scope","col"),s.textContent=labelText(this,"range","Range"),r.appendChild(s);const i=document.createElement("th");i.setAttribute("scope","col"),i.textContent=labelText(this,"count","Count"),r.appendChild(i),t.appendChild(r),e.appendChild(t);const a=document.createElement("tbody");l.forEach(t=>{const e=document.createElement("tr"),r=document.createElement("th");r.setAttribute("scope","row"),r.textContent=formatValue(t.x0)+"–"+formatValue(t.x1),e.appendChild(r);const s=document.createElement("td");s.textContent=isMissing(t.count)?"":String(t.count),e.appendChild(s),a.appendChild(e)}),e.appendChild(a)}else{const r=document.createElement("thead"),s=document.createElement("tr"),i=document.createElement("th");i.setAttribute("scope","col"),i.textContent=labelText(this,"series","Series"),s.appendChild(i);const a=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<a;t++){const e=document.createElement("th");e.setAttribute("scope","col"),e.textContent=labelText(this,"value","Value")+" "+(t+1),s.appendChild(e)}r.appendChild(s),e.appendChild(r);const n=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<a;t++){const e=document.createElement("td");e.textContent=isMissing(r[t])?"":String(r[t]),s.appendChild(e)}n.appendChild(s)}),e.appendChild(n)}}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 u=this.getAttribute("note");let d=this.querySelector(".c-chart__note");u?(d||(d=document.createElement("div"),d.className="c-chart__note",this.appendChild(d)),d.textContent=u):d&&d.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()}if(!this._chartRevealed){const t=this.querySelector(".c-chart__plot");t&&t.querySelector(".c-chart__bar, .c-chart__line, .c-chart__point, .c-donut__slice")&&(this._chartRevealed=!0,t.querySelectorAll(".c-chart__bar, .c-chart__line, .c-chart__point, .c-donut__slice").forEach((t,e)=>{t.style.animationDelay=30*Math.min(e,11)+"ms"}),t.classList.add("is-revealing"),setTimeout(()=>{t.classList.remove("is-revealing"),t.querySelectorAll(".c-chart__bar, .c-chart__line, .c-chart__point, .c-donut__slice").forEach(t=>t.style.removeProperty("animation-delay"))},600))}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");s&&(s.classList.add("c-chart__plot--zoomable"),s.hasAttribute("tabindex")||s.setAttribute("tabindex","0"),s.hasAttribute("aria-label")||s.setAttribute("aria-label",labelText(this,"chart","Chart")+", zoomable. Use plus and minus to zoom, arrow keys to pan, 0 to reset."));const i=this.ensure("[data-chart-zoom-status]",()=>{const t=document.createElement("span");return t.className="visually-hidden",t.setAttribute("data-chart-zoom-status",""),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t}),a=(a=!0)=>{s&&(s.style.transform=`translate(${e}px, ${r}px) scale(${t})`,s.style.transformOrigin="center center",s.classList.toggle("is-zoomed",1!==t||0!==e||0!==r),a&&(i.textContent=`Zoom ${Math.round(100*t)} percent`,this.dispatchEvent(new CustomEvent("contour:chart-zoom",{bubbles:!0,composed:!0,detail:{zoom:t,panX:e,panY:r}}))))},n=e=>{t=Math.min(5,Math.max(.5,t*e)),a()},o=()=>{t=1,e=0,r=0,a()};this.addEventListener("wheel",t=>{t.preventDefault(),n(t.deltaY<0?1.1:.9)},{passive:!1});const l=new Map;let c=!1,u=0,d=0,h=0,m=0,b=0,p=1;const g=()=>{const t=[...l.values()];return t.length>=2?Math.hypot(t[0].x-t[1].x,t[0].y-t[1].y):0};this.addEventListener("pointerdown",s=>{if("mouse"!==s.pointerType||0===s.button){l.set(s.pointerId,{x:s.clientX,y:s.clientY});try{this.setPointerCapture(s.pointerId)}catch(t){}1===l.size?(c=!0,u=s.clientX,d=s.clientY,h=e,m=r,this.style.cursor="grabbing"):2===l.size&&(c=!1,b=g(),p=t)}}),this.addEventListener("pointermove",s=>{if(l.has(s.pointerId)){if(l.set(s.pointerId,{x:s.clientX,y:s.clientY}),l.size>=2&&b)return t=Math.min(5,Math.max(.5,p*(g()/b))),void a();c&&(e=h+(s.clientX-u),r=m+(s.clientY-d),a(!1))}});const _=t=>{l.delete(t.pointerId);try{this.releasePointerCapture(t.pointerId)}catch(t){}l.size<2&&(b=0),0===l.size&&(c=!1,this.style.cursor="",a())};this.addEventListener("pointerup",_),this.addEventListener("pointercancel",_),this.addEventListener("dblclick",o),this.addEventListener("keydown",t=>{t.target===s&&("+"===t.key||"="===t.key?(t.preventDefault(),n(1.1)):"-"===t.key||"_"===t.key?(t.preventDefault(),n(.9)):"0"===t.key?(t.preventDefault(),o()):"ArrowLeft"===t.key?(t.preventDefault(),e+=20,a()):"ArrowRight"===t.key?(t.preventDefault(),e-=20,a()):"ArrowUp"===t.key?(t.preventDefault(),r+=20,a()):"ArrowDown"===t.key&&(t.preventDefault(),r-=20,a()))})}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");if(this._jsTooltipFormat)try{const t=n.getAttribute("data-index"),e=this._chartSeries?this._chartSeries[(Number(n.getAttribute("data-series"))||1)-1]:null,r=e&&Array.isArray(e.values)&&null!=t?e.values[Number(t)]:o,s=this._jsTooltipFormat({series:n.getAttribute("data-series"),index:null!=t?Number(t):null,value:r,title:o});(o||null!=s)&&(a.textContent=null==s?o:String(s))}catch(t){o&&(a.textContent=o)}else 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);return void this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e,value:i.getAttribute("data-title")||i.getAttribute("title")}}))}const a=this._nearestMark(t.clientX,t.clientY);if(a){const t=parseInt(a.getAttribute("data-series")||"1",10),e=parseInt(a.dataset.index||"0",10);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{series:t,index:e}}))}}),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&&!1!==this._tabVisible;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,timestamp:Date.now(),interval:Math.max(1e3,1e3*t)},bubbles:!0,composed:!0}));const e=this.getAttribute("src");e&&(remoteInvalidate(e),this.requestRender())},Math.max(1e3,1e3*t))))};if(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)return;this._wiredStream=!0,this._streamFrame=0,this._tabVisible=!document.hidden;const e=()=>{this._tabVisible=!document.hidden,t()};document.addEventListener("visibilitychange",e),onDispose(this,()=>{void 0!==this._streamTimer&&(clearInterval(this._streamTimer),this._streamTimer=void 0),document.removeEventListener("visibilitychange",e)}),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 ContourSmallMultiples extends ContourBase{static get observed(){return["columns","label","multiples"]}static get properties(){return{columns:{attribute:"columns",type:Number},label:{attribute:"label"},multiples:{attribute:"multiples"}}}render(){this.classList.add("c-small-multiples"),this.hasAttribute("role")||this.setAttribute("role","group");const t=this.getAttribute("label");t?this.setAttribute("aria-label",t):this.removeAttribute("aria-label");const e=this.getAttribute("columns");e?this.style.setProperty("--sm-cols",e):this.style.removeProperty("--sm-cols"),this._smEntries=null;const r=this.getAttribute("multiples");if(!r)return;let s;try{s=JSON.parse(r)}catch(t){return}Array.isArray(s)&&(this._smEntries=s,s.forEach((t,e)=>this._renderCell(t,e)))}_renderCell(t,e){const r=t&&"object"==typeof t?t:{},s=Array.isArray(r.points)?r.points.filter(Number.isFinite):[],i=null!=r.label?String(r.label):`Multiple ${e+1}`,a=document.createElement("figure");a.className="c-small-multiples__cell",a.setAttribute("data-sm-index",String(e)),a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.setAttribute("aria-label",i);const n=document.createElement("figcaption");n.className="c-small-multiples__label",n.textContent=i,a.appendChild(n);const o=document.createElementNS("http://www.w3.org/2000/svg","svg");if(o.setAttribute("class","c-small-multiples__mark"),o.setAttribute("viewBox","0 0 100 30"),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("aria-hidden","true"),s.length>=2){const t=Math.min(...s),e=Math.max(...s)-t||1,r=s.length,i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",s.map((s,i)=>(0===i?"M":"L")+" "+100*i/(r-1)+" "+(30-(s-t)/e*30)).join(" ")),o.appendChild(i)}a.appendChild(o),this.appendChild(a)}enhance(){if(this._wiredSmallMultiples)return;this._wiredSmallMultiples=!0;const t=t=>{const e=t.target&&t.target.closest?t.target.closest(".c-small-multiples__cell[data-sm-index]"):null;if(!e||!this.contains(e))return;const r=Number(e.getAttribute("data-sm-index")),s=(this._smEntries||[])[r]||{},i=Array.isArray(s.points)?s.points.filter(Number.isFinite):[],a=null!=s.value?s.value:i.length?i[i.length-1]:null;this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:r,key:null!=s.key?s.key:null,label:null!=s.label?String(s.label):"",value:a}}))};this.addEventListener("click",t),this.addEventListener("keydown",e=>{if("Enter"!==e.key&&" "!==e.key)return;const r=e.target&&e.target.closest?e.target.closest(".c-small-multiples__cell[data-sm-index]"):null;r&&this.contains(r)&&(e.preventDefault(),t(e))})}}define("contour-small-multiples",ContourSmallMultiples);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="rtl"===(this.ownerDocument.defaultView?this.ownerDocument.defaultView.getComputedStyle(this).direction:"ltr")?(s.right-t)/(s.width||1):(t-s.left)/(s.width||1);return e()+Math.max(0,Math.min(1,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;const d="rtl"===(this.ownerDocument.defaultView?this.ownerDocument.defaultView.getComputedStyle(this).direction:"ltr"),h=d?"ArrowRight":"ArrowLeft",m=d?"ArrowLeft":"ArrowRight";if(t.key===h||"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(t.key===m||"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.dataset.index=String(e),a.dataset.value=String(i),a.dataset.label=n,a.setAttribute("role","button"),a.setAttribute("tabindex","-1"),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");this.querySelectorAll(".c-stacked-bar__segment").forEach((t,e)=>t.setAttribute("tabindex",0===e?"0":"-1"))}enhance(){if(this._wiredStackedBar)return;this._wiredStackedBar=!0;const t=()=>Array.from(this.querySelectorAll(".c-stacked-bar__segment")),e=t=>{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:Number(t.dataset.index||"0"),key:t.dataset.label||String(t.dataset.index||"0"),label:t.dataset.label||"",value:Number(t.dataset.value||"0")}}))};this.addEventListener("click",t=>{const r=t.target&&t.target.closest?t.target.closest(".c-stacked-bar__segment"):null;r&&this.contains(r)&&e(r)}),this.addEventListener("keydown",r=>{const s=r.target&&r.target.closest?r.target.closest(".c-stacked-bar__segment"):null;if(!s||!this.contains(s))return;if("Enter"===r.key||" "===r.key)return r.preventDefault(),void e(s);const i=t();navKey(r,i,{wrap:!1,homeEnd:!0,rtl:isRtl(this),onNavigate:t=>i.forEach((e,r)=>e.setAttribute("tabindex",r===t?"0":"-1"))})})}}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","group");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)}_pivotCaptureFocus(){if(this._pivotFocus)return this._pivotFocus;const t=document.activeElement;if(!t||!this.contains(t))return null;if(t.classList&&t.classList.contains("c-pivot__filter"))return{kind:"filter"};const e=t.closest?t.closest("th, td"):null;if(!e||!this.contains(e))return null;const r=e.parentElement;if(!r)return null;const s=r.querySelector?r.querySelector("th[role='rowheader']"):null;return{kind:"cell",row:s?s.textContent:r.dataset?r.dataset.row:void 0,col:Array.from(r.children).indexOf(e),isHeader:!(!e.closest||!e.closest("thead"))}}_pivotRestoreFocus(t){t&&queueMicrotask(()=>{if(!this.isConnected)return;const e=document.activeElement;if(e&&e!==this&&e!==document.body&&!this.contains(e))return;if("filter"===t.kind){const t=this.querySelector(".c-pivot__filter");if(t)try{t.focus()}catch(t){}return}const r=this.querySelector("table");if(!r)return;let s=null;if(t.isHeader){const e=r.querySelector("thead tr");e&&(s=e.children[t.col]||null)}else{const e=null!=t.row?Array.from(r.querySelectorAll("th[role='rowheader']")).find(e=>e.textContent===t.row):null,i=e?e.parentElement:null;i&&i.children[t.col]&&(s=i.children[t.col])}if(s){r.querySelectorAll('[tabindex="0"]').forEach(t=>t.setAttribute("tabindex","-1")),s.setAttribute("tabindex","0");try{s.focus()}catch(t){}}})}render(){this.classList.add("c-pivot");const t=this._pivotCaptureFocus();if(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 e=[];const r=this.getAttribute("data");if(r)try{e=JSON.parse(r)}catch(t){warnBadJson(this,"data",t),e=[]}const s=this.getAttribute("rows")?this.getAttribute("rows").split(",").map(t=>t.trim()).filter(Boolean):[],i=this.getAttribute("columns")?this.getAttribute("columns").split(",").map(t=>t.trim()).filter(Boolean):[],a=this.getAttribute("aggregate")||"sum",n=this._aggregateFn(a),o=(this.getAttribute("filter")||"").toLowerCase().trim(),l=document.createElement("div");l.className="c-pivot__toolbar",l.style.display="flex";const c=document.createElement("input");c.type="search",c.className="c-input c-pivot__filter",c.placeholder=labelText(this,"filter","Filter…"),c.value=this.getAttribute("filter")||"",c.setAttribute("aria-label",labelText(this,"filter-pivot","Filter pivot"));const u=document.createElement("select");u.className="c-select c-pivot__aggregate",u.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===a&&(e.selected=!0),u.appendChild(e)}),l.appendChild(c),l.appendChild(u),this.appendChild(l);let d=s,h=i;if(o&&(d=s.filter(t=>t.toLowerCase().includes(o)||e.some(e=>e.row===t&&String(e.value).toLowerCase().includes(o))),h=i.filter(t=>t.toLowerCase().includes(o)||e.some(e=>e.col===t&&String(e.value).toLowerCase().includes(o)))),!e.length&&!s.length&&!i.length)return void renderEmpty(this,"pivot");if(o&&(!d.length||!h.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 t=this._pivotSort.col,r="asc"===this._pivotSort.dir?1:-1,s=r=>n(e.filter(e=>e.row===r&&e.col===t).map(t=>Number(t.value)).filter(t=>Number.isFinite(t)));d=d.slice().sort((t,e)=>(s(t)-s(e))*r)}const m=document.createElement("div");m.className="c-table-wrap c-pivot__wrap";const b=document.createElement("table");b.className="c-table c-pivot__table",b.setAttribute("role","grid"),b.setAttribute("aria-rowcount",String(d.length+1)),b.setAttribute("aria-colcount",String(h.length+1));const p=document.createElement("thead"),g=document.createElement("tr"),_=document.createElement("th");_.textContent="",_.setAttribute("role","columnheader"),_.setAttribute("aria-label",labelText(this,"row","Row")),g.appendChild(_);let v=!1;h.forEach(t=>{const e=document.createElement("th");e.textContent=t,e.setAttribute("role","columnheader"),e.setAttribute("tabindex",v?"-1":"0"),v=!0,g.appendChild(e)}),p.appendChild(g),b.appendChild(p);const y=document.createElement("tbody");d.forEach(t=>{const r=document.createElement("tr");r.setAttribute("role","row");const s=document.createElement("th");s.textContent=t,s.setAttribute("role","rowheader"),s.setAttribute("tabindex",v?"-1":"0"),v=!0,r.appendChild(s),h.forEach(s=>{const i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1"),i.dataset.row=t,i.dataset.col=s;const a=e.filter(e=>e.row===t&&e.col===s),o=a.map(t=>Number(t.value)).filter(t=>Number.isFinite(t));if(a.length&&o.length===a.length&&o.length){const t=n(o);i.textContent=Number.isInteger(t)?String(t):t.toFixed(2)}else a.length?i.textContent=a.map(t=>t.value).join(", "):i.textContent="";i.textContent.trim()||i.setAttribute("aria-label",labelText(this,"empty","Empty")),r.appendChild(i)}),y.appendChild(r)}),b.appendChild(y),m.appendChild(b),this.appendChild(m),this._pivotRestoreFocus(t)}enhance(){this._wiredPivot||(this._wiredPivot=!0,this.addEventListener("focusin",t=>{const e=t.target;if(!e||!this.contains(e))return;if(e.classList&&e.classList.contains("c-pivot__filter"))return void(this._pivotFocus={kind:"filter"});const r=e.closest?e.closest("th, td"):null;if(!r||!this.contains(r))return;const s=r.parentElement;if(!s)return;const i=s.querySelector?s.querySelector("th[role='rowheader']"):null;this._pivotFocus={kind:"cell",row:i?i.textContent:s.dataset?s.dataset.row:void 0,col:Array.from(s.children).indexOf(r),isHeader:!(!r.closest||!r.closest("thead"))}}),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","analysis-state"]}static get properties(){return{loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"},retry:{attribute:"retry"},src:{attribute:"src"},"analysis-state":{attribute:"analysis-state"}}}render(){if(this.classList.add("c-widget-state"),wireStates(this),loadRemote(this,[]),renderStates(this,"widget-state"))return;const t=this.getAttribute("analysis-state");if(t){const e=setAnalysisState(this,t);let r=this.querySelector(".c-widget-state__analysis");r||(r=document.createElement("span"),r.className="c-widget-state__analysis visually-hidden",r.dataset.contourGenerated="1",this.appendChild(r)),r.textContent=e}else{setAnalysisState(this,null);const t=this.querySelector(".c-widget-state__analysis");t&&t.remove()}}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 this.setAttribute("role","status"),void renderEmpty(this,"threshold");"status"===this.getAttribute("role")&&this.setAttribute("role","meter");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 ContourSelectionGroup extends ContourBase{static get observed(){return["selected","mode"]}static get properties(){return{selected:{attribute:"selected",controlled:!0},mode:{attribute:"mode"}}}render(){this.classList.add("c-selection-group"),this.hasAttribute("role")||this.setAttribute("role","group");const t=(this.getAttribute("selected")||"").split(",").map(t=>t.trim()).filter(Boolean);for(const e of this.querySelectorAll("[data-selection]"))e.setAttribute("data-selected",t.includes(e.getAttribute("data-selection"))?"true":"false")}enhance(){this._wiredSelGroup||(this._wiredSelGroup=!0,this.addEventListener("contour:select",t=>{const e=t.detail||{},r=null!=e.value?String(e.value):null!=e.key?String(e.key):"",s=r?[r]:[];for(const t of this.querySelectorAll("[data-selection]"))t.setAttribute("data-selected",s.includes(t.getAttribute("data-selection"))?"true":"false");this.dispatchEvent(new CustomEvent("contour:selection",{bubbles:!0,composed:!0,detail:{value:r,mode:this.getAttribute("mode")||"single"}}))}))}}define("contour-selection-group",ContourSelectionGroup);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","domain","reverse"]}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},domain:{attribute:"domain"},reverse:{attribute:"reverse",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("domain");if(m){const t=this.ensure(".c-legend__domain",()=>{const t=document.createElement("div");return t.className="c-legend__domain",t}),e=m.split(",");t.textContent=(labelText(this,"domain","Domain")||"Domain")+": "+e.join(" – ")}else{const t=this.querySelector(".c-legend__domain");t&&t.remove()}this.hasAttribute("reverse")?this.classList.add("c-legend--reverse"):this.classList.remove("c-legend--reverse");const b=this.getAttribute("table");if(b){let t=null;try{t=JSON.parse(b)}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 p=this.getAttribute("method");if(p){this.ensure(".c-legend__method",()=>{const t=document.createElement("div");return t.className="c-legend__method",t}).textContent=p}else{const t=this.querySelector(".c-legend__method");t&&t.remove()}const g=this.getAttribute("norm");if(g){this.ensure(".c-legend__norm",()=>{const t=document.createElement("span");return t.className="c-legend__norm",t}).textContent=g}else{const t=this.querySelector(".c-legend__norm");t&&t.remove()}const _=this.getAttribute("ramp");if(_){const t=this.ensure(".c-legend__ramp",()=>{const t=document.createElement("div");return t.className="c-legend__ramp",t});t.style.background=safeColor(_);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 v=this.getAttribute("scale");if(v){this.ensure(".c-legend__scale",()=>{const t=document.createElement("div");return t.className="c-legend__scale",t}).textContent=v}else{const t=this.querySelector(".c-legend__scale");t&&t.remove()}const y=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=y?"none":"")}),this.querySelectorAll(".c-legend__caption").forEach(t=>{t.style.display=y?"none":""});const A=this.querySelector(".c-legend__items");A&&(A.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-select 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","scope","crs","provenance","selected"]}static get properties(){return{data:{attribute:"data"},format:{attribute:"format"},filename:{attribute:"filename"},label:{attribute:"label"},scope:{attribute:"scope"},crs:{attribute:"crs"},provenance:{attribute:"provenance"},selected:{attribute:"selected"}}}scopeRows(t,e){if("selected"===e){let e=null;const r=this.getAttribute("selected");if(r)try{const t=JSON.parse(r);Array.isArray(t)&&(e=new Set(t.map(t=>String(t))))}catch(t){warnBadJson(this,"selected",t)}return t.filter(t=>e?e.has(String(t&&(t.key??t.id??""))):!(!t||!t.selected))}return"visible"===e?t.filter(t=>t&&!1!==t.visible):"filtered"===e?t.filter(t=>t&&!0!==t.filtered):t}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("scope")||"all").toLowerCase(),n=this.getAttribute("data")||"[]";let o=[],l=!1;try{const t=JSON.parse(n);Array.isArray(t)&&(o=t,l=!0)}catch(t){warnBadJson(this,"data",t)}const c=this.scopeRows(o,a),u=c.length,d=o.length;let h=n;if(l&&("all"!==a||"csv"===i))if("csv"===i)if(0===c.length)h="";else{const e=Object.keys(c[0]);h=[e.map(t).join(",")].concat(c.map(r=>e.map(e=>t(r[e])).join(","))).join("\r\n")}else h=JSON.stringify(c);const m=new Blob(["csv"===i?"\ufeff"+h:h],{type:"csv"===i?"text/csv":"application/json"}),b=URL.createObjectURL(m),p=this.getAttribute("filename")||"export."+i,g=document.createElement("a");g.href=b,g.download=p,document.body.appendChild(g),g.click(),g.remove(),setTimeout(()=>URL.revokeObjectURL(b),0);const _={format:i,scope:a,count:u,total:d,filename:p},v=this.getAttribute("crs");v&&(_.crs=v);const y=this.getAttribute("provenance");y&&(_.provenance=y),this.dispatchEvent(new CustomEvent("contour:export",{bubbles:!0,composed:!0,detail:_}))})}}function readRuleValue(t){const e=t.querySelector('.c-query-builder__value[data-part="low"]'),r=t.querySelector('.c-query-builder__value[data-part="high"]');if(e||r)return[e?e.value:"",r?r.value:""].join(",");const s=t.querySelector(".c-query-builder__null");return s?s.checked?"null":"":t.querySelector(".c-query-builder__value")?.value||""}define("contour-data-export",ContourDataExport);class ContourQueryBuilder extends ContourBase{static get observed(){return["query","fields","draft"]}static get properties(){return{query:{attribute:"query"},fields:{attribute:"fields"},draft:{attribute:"draft",type:Boolean}}}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={id:e.dataset.ruleId||"r"+s,field:e.querySelector(".c-query-builder__field")?.value||"",op:e.querySelector(".c-query-builder__op")?.value||"=",value:readRuleValue(e)};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||""),"true"===e.querySelector(".c-query-builder__not")?.getAttribute("aria-pressed")&&(i.not=!0),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),"draft"===t&&null!=e&&null==r&&this._draftRows&&this.commitDraft())}commit(t,e=!0){const r=this.hasAttribute("draft");if(r)this._draftRows=t;else 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,draft:r}}))}commitDraft(){const t=this._draftRows||this.readRules();this._draftRows=null,this.removeAttribute("draft"),this.setAttribute("query",JSON.stringify(t)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{query:t,draft:!1}}))}render(){this.classList.add("c-query-builder");const t=this.getAttribute("fields"),e=t=>"string"==typeof t?t:t.value??t.key??t.label??t.name??"";let r=[];if(t)try{const e=JSON.parse(t);Array.isArray(e)?r=e:e&&"object"==typeof e&&(r=Object.keys(e).map(t=>e[t]&&"object"==typeof e[t]?{value:t,...e[t]}:t))}catch(t){r=[]}const s=this.getAttribute("query");let i=[];if(this.hasAttribute("draft")&&this._draftRows)i=this._draftRows;else if(s)try{const t=JSON.parse(s);Array.isArray(t)?i=t:t&&Array.isArray(t.rules)&&(i=t.rules)}catch(t){i=[]}const a=this.ensure(".c-query-builder__list",()=>{const t=document.createElement("div");return t.className="c-query-builder__list",t});Array.from(a.querySelectorAll(".c-query-builder__row, .c-query-builder__connector, .c-query-builder__group")).forEach(t=>t.remove());let n=null;i.forEach((t,s)=>{const o=t&&t.group?String(t.group):"",l=!(!o||!n||n._groupName!==o);let c=null;if(s>0){c=document.createElement("div"),c.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")+" "+s),["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)}),c.appendChild(e)}if(o)if(l)c&&n.appendChild(c);else{c&&a.appendChild(c),n=document.createElement("div"),n.className="c-query-builder__group",n._groupName=o;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=o;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")+" "+o),r.setAttribute("data-group",o),r.textContent="×",t.appendChild(e),t.appendChild(r),n.appendChild(t),a.appendChild(n)}else c&&a.appendChild(c),n=null;const u=document.createElement("div");u.className="c-query-builder__row",u.dataset.ruleId=t.id||"r"+s;const d=document.createElement("select");d.className="c-input c-query-builder__field",d.setAttribute("aria-label",labelText(this,"field","Field")+" "+(s+1)),r.forEach(r=>{const s=document.createElement("option");s.value=e(r),s.textContent=(t=>"string"==typeof t?t:t.label??t.name??t.value??t.key??"")(r),s.value===t.field&&(s.selected=!0),d.appendChild(s)});const h=document.createElement("select");h.className="c-input c-query-builder__op",h.setAttribute("aria-label",labelText(this,"operator","Operator")+" "+(s+1)),["=","!=",">","<","contains"].forEach(e=>{const r=document.createElement("option");r.value=e,r.textContent=e,e===t.op&&(r.selected=!0),h.appendChild(r)});const m=(b=t.field,r.find(t=>e(t)===b)||{});var b;const p=m.type||"text",g=(t,e,r)=>{const i=document.createElement("input");return i.className="c-input c-query-builder__value",i.type=t,r&&(i.dataset.part=r),i.setAttribute("value",e||""),i.value=e||"",i.setAttribute("aria-label",labelText(this,"value","Value")+" "+(s+1)+(r?" "+r:"")),i};let _;if("enum"===p&&Array.isArray(m.options)&&m.options.length)_=document.createElement("select"),_.className="c-input c-query-builder__value",_.setAttribute("aria-label",labelText(this,"value","Value")+" "+(s+1)),m.options.forEach(e=>{const r=document.createElement("option");r.value="string"==typeof e?e:e.value??e,r.textContent="string"==typeof e?e:e.label??e.value??e,r.value===t.value&&(r.selected=!0),_.appendChild(r)});else if("null"===p)_=document.createElement("input"),_.type="checkbox",_.className="c-query-builder__value c-query-builder__null",_.checked="null"===t.value,_.setAttribute("aria-label",labelText(this,"is-null","Is null")+" "+(s+1));else if("range"===p){const e=String(t.value||"").split(",");_=document.createDocumentFragment(),_.appendChild(g("number",e[0],"low")),_.appendChild(g("number",e[1],"high"))}else _=g("date"===p?"date":"text",t.value);const v=document.createElement("button");v.type="button",v.className="c-btn c-btn--sm c-btn--ghost c-query-builder__not",v.setAttribute("aria-label",labelText(this,"negate","Negate")+" "+(s+1)),v.setAttribute("aria-pressed",t.not?"true":"false"),v.textContent="NOT";const y=document.createElement("button");y.type="button",y.className="c-btn c-btn--sm c-btn--ghost c-query-builder__move c-query-builder__move--up",y.setAttribute("aria-label",labelText(this,"move-rule","Move rule")+" "+(s+1)+" "+labelText(this,"up","up")),y.textContent="↑",0===s&&(y.disabled=!0);const f=document.createElement("button");f.type="button",f.className="c-btn c-btn--sm c-btn--ghost c-query-builder__move c-query-builder__move--down",f.setAttribute("aria-label",labelText(this,"move-rule","Move rule")+" "+(s+1)+" "+labelText(this,"down","down")),f.textContent="↓",s===i.length-1&&(f.disabled=!0);const A=document.createElement("button");A.type="button",A.className="c-btn c-btn--sm c-btn--ghost c-query-builder__remove",A.setAttribute("aria-label",labelText(this,"remove-rule","Remove rule")+" "+(s+1)),A.textContent="×",u.appendChild(d),u.appendChild(h),u.appendChild(_),u.appendChild(v),u.appendChild(y),u.appendChild(f),u.appendChild(A),n?n.appendChild(u):a.appendChild(u)});const o=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(o,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>'),o.appendChild(document.createTextNode(" "+labelText(this,"add-rule","Add rule"))),o.parentNode!==this&&this.appendChild(o);const l=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(l,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>'),l.appendChild(document.createTextNode(" "+labelText(this,"add-group","Add group"))),l.parentNode!==this&&this.appendChild(l)}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;const r=e.closest(".c-query-builder__not");if(r){const t="true"!==r.getAttribute("aria-pressed");return r.setAttribute("aria-pressed",String(t)),void this.commit(this.readRules(),!1)}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 s=e.closest(".c-query-builder__group-remove");if(s){const t=s.getAttribute("data-group")||"",e=this.readRules().map(t=>t.connector),r=this.readRules().filter(e=>(e.group||"")!==t);return void this.commit(ContourQueryBuilder.reindexConnectors(r,e))}const i=e.closest(".c-query-builder__move");if(i){const t=i.closest(".c-query-builder__row");if(!t)return;const e=i.classList.contains("c-query-builder__move--up"),r=this.readRules().map(t=>t.connector),s=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>=s.length)return;const o=s[n];s[n]=s[a],s[a]=o,this.commit(ContourQueryBuilder.reindexConnectors(s,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 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()}}export function paintPurityRingPixels(t={}){const e=Number(t.size)||32;let r=t.canvas;if(!r)if("undefined"!=typeof OffscreenCanvas)r=new OffscreenCanvas(e,e);else{if("undefined"==typeof document)throw new Error("paintPurityRingPixels: no OffscreenCanvas or document — pass opts.canvas");r=document.createElement("canvas"),r.width=e,r.height=e}const s=r.getContext("2d");if(!s)throw new Error("paintPurityRingPixels: canvas.getContext('2d') returned null");return paintPurityRing(s,{...t,size:e}),s.getImageData(0,0,e,e)}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","dirty","conflict","default"]}static get properties(){return{name:{attribute:"name"},updated:{attribute:"updated"},source:{attribute:"source"},active:{attribute:"active",type:Boolean},dirty:{attribute:"dirty",type:Boolean},conflict:{attribute:"conflict",type:Boolean},default:{attribute:"default",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");e.replaceChildren();const i=[];if(this.hasAttribute("default")&&i.push(labelText(this,"default","Default")),this.hasAttribute("dirty")&&i.push(labelText(this,"dirty","Unsaved")),this.hasAttribute("conflict")&&i.push(labelText(this,"conflict","Conflict")),i.forEach((t,i)=>{(i>0||r||s)&&e.appendChild(document.createTextNode(" · "));const a=document.createElement("span");a.className="c-saved-view__badge",a.textContent=t,e.appendChild(a)}),r){e.childNodes.length&&e.appendChild(document.createTextNode(" · "));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 a=this.querySelector(".c-saved-view__actions");a||(a=document.createElement("div"),a.className="c-saved-view__actions",this.appendChild(a));const n=a.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",""),a.appendChild(t),t})();applyLabel(n,this,"apply","Apply");[["rename","rename","Rename"],["duplicate","duplicate","Duplicate"],["share","share","Share"]].forEach(([t,e,r])=>{const s=a.querySelector(`.c-saved-view__${t}`)||(()=>{const e=document.createElement("button");return e.type="button",e.className="c-btn c-btn--ghost c-btn--sm",e.setAttribute(`data-saved-view-${t}`,""),a.appendChild(e),e})();applyLabel(s,this,e,r)});const o=a.querySelector(".c-saved-view__default")||(()=>{const t=document.createElement("button");return t.type="button",t.className="c-btn c-btn--ghost c-btn--sm",t.setAttribute("data-saved-view-default",""),a.appendChild(t),t})();applyLabel(o,this,"default","Set as default"),o.setAttribute("aria-pressed",this.hasAttribute("default")?"true":"false");const l=a.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",""),a.appendChild(t),t})();applyLabel(l,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;if(!e||!this.contains(e))return;const r=this.getAttribute("name");if(e.hasAttribute("data-saved-view-apply"))this.dispatchEvent(new CustomEvent("contour:apply",{bubbles:!0,composed:!0,detail:{name:r}}));else if(e.hasAttribute("data-saved-view-remove"))this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{name:r}}));else if(e.hasAttribute("data-saved-view-rename"))this.dispatchEvent(new CustomEvent("contour:rename",{bubbles:!0,composed:!0,detail:{name:r}}));else if(e.hasAttribute("data-saved-view-duplicate"))this.dispatchEvent(new CustomEvent("contour:duplicate",{bubbles:!0,composed:!0,detail:{name:r}}));else if(e.hasAttribute("data-saved-view-share"))this.dispatchEvent(new CustomEvent("contour:share",{bubbles:!0,composed:!0,detail:{name:r}}));else if(e.hasAttribute("data-saved-view-default")){const t=!this.hasAttribute("default");this.dispatchEvent(new CustomEvent("contour:default",{bubbles:!0,composed:!0,detail:{name:r,default:t}}))}}))}}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()}}}function parseJsonMap(t){if(!t)return{};try{const e=JSON.parse(t);return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}catch(t){return{}}}function isGeometryObject(t){return!(!t||"object"!=typeof t||Array.isArray(t)||"string"!=typeof t.type||!("coordinates"in t||"geometry"in t||"features"in t))}function addInspectorFields(t,e,r,s){for(const[i,a]of Object.entries(e)){if(a&&"object"==typeof a&&!Array.isArray(a)&&!isGeometryObject(a)){const e=document.createElement("div");e.className="c-feature-inspector__group";const n=document.createElement("div");n.className="c-feature-inspector__group-label",n.textContent=i,e.appendChild(n),addInspectorFields(e,a,r,s+1),t.appendChild(e);continue}const e=document.createElement("div");e.className="c-feature-inspector__field";const n=document.createElement("span");n.className="c-feature-inspector__label",n.textContent=i;const o=document.createElement("span");if(o.className="c-feature-inspector__value",Array.isArray(a)){const t=document.createElement("ul");t.className="c-feature-inspector__list",a.forEach(e=>{const r=document.createElement("li");r.textContent=e&&"object"==typeof e?JSON.stringify(e):String(e),t.appendChild(r)}),o.appendChild(t)}else{const t=r.types[i];let e;if("timestamp"===t&&a){const t=new Date(a);e=Number.isNaN(t.getTime())?String(a):t.toISOString()}else e="geometry"===t||isGeometryObject(a)?geometrySummary(a):String(a);if(r.units[i]&&(e+=" "+r.units[i]),o.textContent=e,null!=r.conf[i]&&""!==r.conf[i]){const t=document.createElement("span");t.className="c-feature-inspector__confidence",t.setAttribute("role","img"),t.setAttribute("aria-label",`Confidence ${r.conf[i]}`),t.dataset.confidence=String(r.conf[i]),o.appendChild(document.createTextNode(" ")),o.appendChild(t)}}e.appendChild(n),e.appendChild(o),t.appendChild(e)}}function geometrySummary(t){return t&&"object"==typeof t?"Point"===t.type&&Array.isArray(t.coordinates)?`Point (${t.coordinates.join(", ")})`:Array.isArray(t.coordinates)?`${t.type||"Geometry"} (${t.coordinates.length} pts)`:t.type||"Geometry":String(t)}define("contour-provenance",ContourProvenance);class ContourFeatureInspector extends ContourBase{static get observed(){return["title","open","data","actions","units","types","confidence"]}static get properties(){return{title:{attribute:"title"},open:{attribute:"open",type:Boolean},data:{attribute:"data"},units:{attribute:"units"},types:{attribute:"types"},confidence:{attribute:"confidence"}}}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)){const r=parseJsonMap(this.getAttribute("units")),s=parseJsonMap(this.getAttribute("types"));addInspectorFields(e,t,{units:r,types:s,conf:parseJsonMap(this.getAttribute("confidence"))},0)}}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);
|