contour-ds 1.8.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +227 -378
  2. package/dist/agent-cookbook.json +960 -0
  3. package/dist/agent-examples.json +65 -0
  4. package/dist/agent-map-wiring.json +152 -0
  5. package/dist/build-manifest.json +320 -179
  6. package/dist/contour-wc-content.esm.js +479 -3665
  7. package/dist/contour-wc-content.esm.min.js +1 -1
  8. package/dist/contour-wc-core.esm.js +3724 -0
  9. package/dist/contour-wc-core.esm.min.js +1 -0
  10. package/dist/contour-wc-dashboard.esm.js +2713 -4381
  11. package/dist/contour-wc-dashboard.esm.min.js +1 -1
  12. package/dist/contour-wc-data.esm.js +2658 -4346
  13. package/dist/contour-wc-data.esm.min.js +1 -1
  14. package/dist/contour-wc-docs.esm.js +218 -3547
  15. package/dist/contour-wc-docs.esm.min.js +1 -1
  16. package/dist/contour-wc-feedback.esm.js +483 -3658
  17. package/dist/contour-wc-feedback.esm.min.js +1 -1
  18. package/dist/contour-wc-forms.esm.js +503 -3754
  19. package/dist/contour-wc-forms.esm.min.js +1 -1
  20. package/dist/contour-wc-interaction.esm.js +379 -3616
  21. package/dist/contour-wc-interaction.esm.min.js +1 -1
  22. package/dist/contour-wc-layout.esm.js +234 -3563
  23. package/dist/contour-wc-layout.esm.min.js +1 -1
  24. package/dist/contour-wc-map.esm.js +949 -3743
  25. package/dist/contour-wc-map.esm.min.js +1 -1
  26. package/dist/contour-wc-misc.esm.js +237 -3556
  27. package/dist/contour-wc-misc.esm.min.js +1 -1
  28. package/dist/contour-wc-navigation.esm.js +2235 -5237
  29. package/dist/contour-wc-navigation.esm.min.js +1 -1
  30. package/dist/contour-wc-ui.esm.js +4638 -7128
  31. package/dist/contour-wc-ui.esm.min.js +1 -1
  32. package/dist/contour-wc.esm.js +11971 -7727
  33. package/dist/contour-wc.esm.min.js +1 -1
  34. package/dist/contour-wc.js +11971 -7727
  35. package/dist/contour-wc.min.js +1 -1
  36. package/dist/contour.a11y.json +402 -0
  37. package/dist/contour.code-snippets +96 -74
  38. package/dist/contour.components.json +2591 -741
  39. package/dist/contour.css +2624 -1888
  40. package/dist/contour.d.ts +421 -228
  41. package/dist/contour.esm.js +433 -18
  42. package/dist/contour.esm.min.js +1 -1
  43. package/dist/contour.html-data.json +1231 -199
  44. package/dist/contour.js +433 -18
  45. package/dist/contour.min.css +1 -1
  46. package/dist/contour.min.js +1 -1
  47. package/dist/contour.react.d.ts +100 -98
  48. package/dist/contour.single.html +2 -2
  49. package/dist/contour.single.min.css +1 -1
  50. package/dist/contour.themes.json +56 -12
  51. package/dist/contour.tokens.json +482 -255
  52. package/dist/contour.vue.d.ts +100 -98
  53. package/dist/contour.web-types.json +1226 -226
  54. package/dist/custom-elements.json +7649 -2237
  55. package/dist/docs/actions.md +15 -6
  56. package/dist/docs/affordances.md +18 -96
  57. package/dist/docs/apireference.md +9 -5
  58. package/dist/docs/colour.md +10 -4
  59. package/dist/docs/componentindex.md +9 -26
  60. package/dist/docs/data.md +36 -60
  61. package/dist/docs/docs.md +10 -12
  62. package/dist/docs/feedback.md +30 -12
  63. package/dist/docs/field.md +28 -13
  64. package/dist/docs/forms.md +35 -19
  65. package/dist/docs/index.json +63 -56
  66. package/dist/docs/install.md +12 -7
  67. package/dist/docs/landing.md +7 -4
  68. package/dist/docs/mapengine.md +18 -13
  69. package/dist/docs/motion.md +12 -6
  70. package/dist/docs/navigation.md +31 -7
  71. package/dist/docs/overlays.md +32 -25
  72. package/dist/docs/overview.md +3 -2
  73. package/dist/docs/patterns.md +19 -9
  74. package/dist/docs/playground.md +9 -22
  75. package/dist/docs/principles.md +8 -6
  76. package/dist/docs/recipes.md +113 -14
  77. package/dist/docs/space.md +10 -6
  78. package/dist/docs/status.md +12 -25
  79. package/dist/docs/surfaces.md +17 -22
  80. package/dist/docs/theming.md +18 -32
  81. package/dist/docs/type.md +12 -5
  82. package/dist/docs/webcomponents.md +66 -38
  83. package/dist/hljs.css +1 -20
  84. package/dist/map-chrome.mapbox.css +68 -92
  85. package/dist/map-chrome.maplibre.css +68 -92
  86. package/dist/registry/items/contour-core.json +2 -2
  87. package/dist/registry/items/contour-data.json +2 -2
  88. package/dist/registry/items/contour-docs.json +2 -2
  89. package/dist/registry/items/contour-landing.json +2 -2
  90. package/dist/registry/registry.json +8 -8
  91. package/dist/surfaces/contour-core.min.css +1 -1
  92. package/dist/surfaces/contour-data.min.css +1 -1
  93. package/dist/surfaces/contour-docs.min.css +1 -1
  94. package/dist/surfaces/contour-landing.min.css +1 -1
  95. package/dist/svg/icons.svg +367 -0
  96. package/dist/wc/behaviours.mjs +190 -148
  97. package/dist/wc/content.mjs +273 -129
  98. package/dist/wc/core.mjs +598 -395
  99. package/dist/wc/dashboard.mjs +64 -44
  100. package/dist/wc/data-chart.mjs +1333 -0
  101. package/dist/wc/data-export.mjs +391 -0
  102. package/dist/wc/data-gauge.mjs +779 -0
  103. package/dist/wc/data-geo.mjs +696 -0
  104. package/dist/wc/data-glyphs.mjs +133 -0
  105. package/dist/wc/data-legend.mjs +431 -0
  106. package/dist/wc/data-readout.mjs +227 -0
  107. package/dist/wc/data-series.mjs +1004 -0
  108. package/dist/wc/data-table.mjs +751 -0
  109. package/dist/wc/data.mjs +15 -4322
  110. package/dist/wc/docs.mjs +12 -11
  111. package/dist/wc/feedback.mjs +277 -122
  112. package/dist/wc/forms-controls.mjs +635 -0
  113. package/dist/wc/forms-field.mjs +547 -0
  114. package/dist/wc/forms-groups.mjs +347 -0
  115. package/dist/wc/forms-input.mjs +292 -0
  116. package/dist/wc/forms.mjs +10 -1751
  117. package/dist/wc/glyph.mjs +204 -0
  118. package/dist/wc/index.mjs +11 -9
  119. package/dist/wc/interaction.mjs +173 -80
  120. package/dist/wc/layout.mjs +28 -27
  121. package/dist/wc/map.mjs +743 -207
  122. package/dist/wc/misc.mjs +31 -20
  123. package/dist/wc/navigation-menu.mjs +735 -0
  124. package/dist/wc/navigation-shell.mjs +495 -0
  125. package/dist/wc/navigation-tree.mjs +995 -0
  126. package/dist/wc/navigation.mjs +9 -1905
  127. package/dist/wc/registration.mjs +1 -8
  128. package/dist/wc/shadow.mjs +206 -110
  129. package/dist/wc/states.mjs +54 -75
  130. package/dist/wc/svg.mjs +118 -47
  131. package/dist/wc/ui-atoms.mjs +608 -0
  132. package/dist/wc/ui-data.mjs +1404 -0
  133. package/dist/wc/ui-feedback.mjs +419 -0
  134. package/dist/wc/ui-inputs.mjs +1570 -0
  135. package/dist/wc/ui-menus.mjs +307 -0
  136. package/dist/wc/ui-overlays.mjs +1605 -0
  137. package/integrations/README.md +23 -5
  138. package/integrations/ai/CLAUDE.md +3 -0
  139. package/integrations/ai/COPILOT.md +14 -0
  140. package/integrations/ai/GEMINI.md +14 -0
  141. package/integrations/ai/WINDSURF.md +14 -0
  142. package/integrations/ai/v0-prompt.md +13 -1
  143. package/integrations/native/README.md +0 -3
  144. package/integrations/tailwind/contour-theme.css +66 -7
  145. package/integrations/validate-markup.mjs +172 -0
  146. package/package.json +77 -42
  147. package/dist/wc/ui.mjs +0 -5072
@@ -1 +1 @@
1
- "use strict";export const REGISTERED=[];const DISPOSERS=new WeakMap();export const onDispose=(host,fn)=>{let list=DISPOSERS.get(host);if(!list){list=[];DISPOSERS.set(host,list)}list.push(fn)};function contourDebugEnabled(){try{if(typeof window!=="undefined"&&(window.ContourDebug||window.__CONTOUR_DEBUG__))return true}catch(e){}try{if(typeof process!=="undefined"&&process.env&&process.env.NODE_ENV!=="production"&&process.env.CONTOUR_DEBUG)return true}catch(e){}return false}const runDisposers=(host)=>{const list=DISPOSERS.get(host);if(!list)return;DISPOSERS.delete(host);for(const fn of list){try{fn()}catch(e){if(contourDebugEnabled()){try{console.warn("Contour disposer failed for",host&&host.tagName,e)}catch(err){}}}}};let _contourIdCounter=0;export const contourId=(prefix)=>prefix+"-"+(++_contourIdCounter).toString(36);export const define=(name,cls)=>{if(typeof customElements==="undefined"||!customElements||typeof customElements.define!=="function")return;if(customElements.get(name))return;customElements.define(name,cls);REGISTERED.push(name)};export const MODS=["variant","size","color"];export const CONTOUR_EVENTS=Object.freeze({"contour:activate":{payload:["files","label","row","value"],composed:true},"contour:add":{payload:["value"],composed:true},"contour:activity-clear":{payload:[],composed:true},"contour:activity-filter":{payload:["unread"],composed:true},"contour:activity-select":{payload:["index","text"],composed:true},"contour:break-change":{payload:["layer","value"],composed:true},"contour:style-resolved":{payload:["applied","classification","colors","items","layer","n","palette","property","value"],composed:true},"contour:advanced-toggle":{payload:["title"],composed:true},"contour:affordance-activate":{payload:["name"],composed:true},"contour:aggregate":{payload:["aggregate"],composed:true},"contour:bearing":{payload:["direction","degrees"],composed:true},"contour:btn-group-change":{payload:["index","label"],composed:true},"contour:brush-start":{payload:["end","range","start","value"],composed:true},"contour:brush-end":{payload:["end","range","start","value"],composed:true},"contour:brush":{payload:["end","range","start","value"],composed:true},"contour:change":{payload:["checked","color","direction","end","files","high","index","low","month","name","paused","query","speed","start","unit","value","values","year"],composed:true},"contour:collapse":{payload:["collapsed"],composed:true},"contour:cluster-toggle":{payload:["count","expanded"],composed:true},"contour:clear":{payload:[],composed:true},"contour:clear-all":{payload:[],composed:true},"contour:close":{payload:["count","index","label","message","open","value"],composed:true},"contour:copy":{payload:["text"],composed:true},"contour:apply":{payload:["name"],composed:true},"contour:dash-action":{payload:["label"],composed:true},"contour:diff-activate":{payload:["kind","text"],composed:true},"contour:dismiss":{payload:["label"],composed:true},"contour:draw-start":{payload:["mode"],composed:true},"contour:drag":{payload:["delta","key","value"],composed:true},"contour:do-dont-activate":{payload:["kind","text"],composed:true},"contour:docs-nav-select":{payload:["label","href"],composed:true},"contour:dragend":{payload:["value"],composed:true},"contour:dragstart":{payload:["value"],composed:true},"contour:drop":{payload:["value","label"],composed:true},"contour:empty-action":{payload:["state"],composed:true},"contour:filter":{payload:["query"],composed:true},"contour:filter-change":{payload:["source","filter"],composed:true},"contour:error":{payload:["src","message","name","status"],composed:true},"contour:export":{payload:["format"],composed:true},"contour:refresh":{payload:[],composed:true},"contour:hide":{payload:[],composed:true},"contour:hover":{payload:["row"],composed:true},"contour:input":{payload:["name","value","checked"],composed:true},"contour:invalid":{payload:["field","input","message"],composed:true,cancelable:true},"contour:inspect-action":{payload:["label"],composed:true},"contour:layer-opacity":{payload:["name","opacity"],composed:true},"contour:layer-rename":{payload:["name","newName"],composed:true},"contour:layer-duplicate":{payload:["name"],composed:true},"contour:layer-zoom":{payload:["name"],composed:true},"contour:zoom":{payload:["data","index","row"],composed:true},"contour:layer-projection":{payload:["name","projection"],composed:true},"contour:layer-remove":{payload:["name"],composed:true},"contour:layer-reorder":{payload:["layerIds"],composed:true},"contour:layer-toggle":{payload:["name","visible"],composed:true},"contour:layer-visibility":{payload:["name","visible"],composed:true},"contour:legend-toggle":{payload:["index","key","label","pressed"],composed:true},"contour:leave":{payload:[],composed:true},"contour:load":{payload:["src","count"],composed:true},"contour:map-control":{payload:["control"],composed:true},"contour:map-attach":{payload:[],composed:true},"contour:map-detach":{payload:[],composed:true},"contour:map-popup-reposition":{payload:["anchor","flippedX","flippedY","left","top"],composed:true},"contour:mode-change":{payload:["mode"],composed:true},"contour:scope-change":{payload:["scope"],composed:true},"contour:move":{payload:["direction","from","to"],composed:true},"contour:open":{payload:[],composed:true},"contour:page":{payload:["page"],composed:true},"contour:ready":{payload:["version","count"],composed:true},"contour:read":{payload:["label"],composed:true},"contour:remove":{payload:["key","label","name","value"],composed:true},"contour:reorder":{payload:["from","to"],composed:true},"contour:range-change":{payload:["value"],composed:true},"contour:resize":{payload:["delta","height","value","width"],composed:true},"contour:retry":{payload:["src"],composed:true},"contour:loop-change":{payload:["loop"],composed:true},"contour:pause":{payload:[],composed:true},"contour:play":{payload:[],composed:true},"contour:seek":{payload:["progress","value"],composed:true},"contour:select":{payload:["area","col","expanded","href","index","key","label","labels","path","range","result","row","rows","series","value"],composed:true},"contour:search":{payload:["query"],composed:true},"contour:spatial-filter":{payload:["action","mode","operator"],composed:true},"contour:split-change":{payload:["value","width","height"],composed:true},"contour:speed-change":{payload:["speed"],composed:true},"contour:showcase-activate":{payload:["title"],composed:true},"contour:step-activate":{payload:["index","title"],composed:true},"contour:step-change":{payload:["direction","index","title"],composed:true},"contour:show":{payload:[],composed:true},"contour:sort":{payload:["column","direction"],composed:true},"contour:submit":{payload:["submitting"],composed:true},"contour:stream-state":{payload:["running"],composed:true},"contour:tab-change":{payload:["index","label"],composed:true},"contour:theme-change":{payload:["theme"],composed:true},"contour:tick":{payload:["frame"],composed:true},"contour:time-change":{payload:["progress","value"],composed:true},"contour:time-range-change":{payload:["value"],composed:true},"contour:toggle":{payload:["collapsed","expanded","label","open","path","playing"],composed:true},"contour:view-enter":{payload:[],composed:true},"contour:view-leave":{payload:[],composed:true},});export function sanitizeHtml(input){const str=String(input==null?"":input);if(typeof DOMParser==="undefined"){return str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const doc=new DOMParser().parseFromString(str,"text/html");const drop=new Set(["script","iframe","object","embed","style","link","meta","base","form","input","button"]);const walk=(node)=>{const children=Array.from(node.childNodes);for(const c of children){if(c.nodeType===1){const tag=c.tagName.toLowerCase();if(drop.has(tag)){c.remove();continue}for(const attr of Array.from(c.attributes)){const name=attr.name.toLowerCase();if(name.startsWith("on")){c.removeAttribute(attr.name);continue}const val=String(attr.value||"").trim().toLowerCase();if((name==="href"||name==="src"||name==="xlink:href")&&(val.startsWith("javascript:")||val.startsWith("data:text/html"))){c.removeAttribute(attr.name)}}walk(c)}}};walk(doc.body);return doc.body.innerHTML}export function safeColor(value){const raw=String(value==null?"":value).trim();if(!raw)return"";if(/[;{}<>"'`\\]/.test(raw))return"";if(/url\s*\(/i.test(raw)||/expression\s*\(/i.test(raw))return"";if(/^#[0-9a-f]{3,8}$/i.test(raw))return raw;if(/^(rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\(/i.test(raw))return raw;if(/^[a-z]+$/i.test(raw))return raw;return""}export function safeHref(value){const raw=String(value==null?"":value).trim();if(!raw)return"#";if(raw.startsWith("#")||raw.startsWith("/")||raw.startsWith("./")||raw.startsWith("../")||raw.startsWith("?"))return raw;if(typeof document==="undefined"||!document.baseURI)return"#";try{const url=new URL(raw,document.baseURI);return["http:","https:","mailto:","tel:"].includes(url.protocol)?raw:"#"}catch(e){return"#"}}export function cssLength(name,fallback){if(typeof getComputedStyle==="undefined"||typeof document==="undefined")return fallback;const v=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(name));return Number.isFinite(v)&&v>0?v:fallback}export function warnBadJson(host,label,error){if(typeof console==="undefined"||!console.warn)return;const name=host&&host.tagName?host.tagName.toLowerCase():"component";const msg=(error&&error.message)||String(error);console.warn(`[contour] ${name}: malformed ${label || "attribute"} — ${msg}`)}export const OBSERVED=["accept","action","actions","active","after","allow-duplicate","allow-remove","allow-rename","allow-zoom","alpha","anchor","answer","area","article","attribution","attribution-mark","audit","autoplay","axis","axis-x","axis-y","brownout","brownout-level","before","body","brand","bounds","breakpoint","breaks","brush","brush-end","brush-max","brush-min","brush-start","cache-key","canvas","center","clearable","cols","columns","color","command","cells","checked","chrome","confidence","coverage","debounce","closable","collapsed","collapsible","classification","continuous","content","controls","copyable","count","data","data-table","date","delta","description","glyphs","graduated","demo","density","desc","dir","direction","disabled","distance","dismissible","divider","do","dont","dot","ends","high","input","layer","low","mode","modes","n","opacity","palette","polarity","precision","range","single","empty","exclusive","fallback","filename","format","heading","help","hint","href","icon","illustration","instrument","interval","items","key","layers","level","markers","range-end","range-start","label","labels","lazy","lede","legend","left-label","right-label","line","limit","link","links","live","loading","locale","loop","max","media","message","method","methodology","menu","min","multiple","name","needle","next","no","no-cache","no-data-message","nodes","note","norm","normalize","options","orientation","page-size","pages","pause","paused","pausable","persist","placeholder","playing","point","points","prev","presets","prompt","question","recent","required","quote","ramp","refresh","removable","resolution","reverse","rings","retry","results","rows","scale","selectable","segments","show-header","sparkline","threshold","thresholds","selected","separator","series","shortcut","side","size","skeleton","sort","sort-dir","status","step","submit","submitting","timeout","trigger","virtual","sticky","cluster-count","cluster-expanded","time","resizable","state","steps","style","subtitle","summary","src","source","table","tabs","tag","text","ticks","title","type","unread-only","unit","updated","cluster-items","row-height","variant","values","viewport","warning","yes","zoomable","caption","current-time","is-playing","loop-label","no-data-color","no-data-label","property","show-loop","show-thumb","show-thumb-caption","speeds","item-height","pause-label","play-label","speed-label","time-label","shimmer","search","numbered","bucket-count","limit-values","autocomplete","levels","submit-label","fields","gap","controls","flush","head","preview","tags","url","custom-error",];export function headingTag(host,fallback="h3"){const v=host&&host.getAttribute?host.getAttribute("heading"):null;return/^h[1-6]$/.test(v||"")?v:fallback}export function labelText(host,key,fallback){const def=fallback!==undefined?fallback:key;const raw=host&&host.getAttribute?host.getAttribute("labels"):null;if(!raw)return def;try{const parsed=JSON.parse(raw);if(parsed&&typeof parsed==="object"&&typeof parsed[key]==="string"&&parsed[key])return parsed[key]}catch(e){}return def}export function applyLabel(node,host,key,fallback){if(!node)return;if(node.dataset&&node.dataset.contourLabel==="true"){node.textContent=labelText(host,key,fallback)}else if(!node.textContent){node.textContent=labelText(host,key,fallback);if(node.dataset)node.dataset.contourLabel="true"}}const _ContourBaseParent=(typeof HTMLElement!=="undefined")?HTMLElement:Object;export class ContourBase extends _ContourBaseParent{static formAssociated=false;constructor(){super();if(this.constructor.formAssociated&&typeof this.attachInternals==="function"){this._internals=this.attachInternals()}}static get observed(){return OBSERVED}static get observedAttributes(){const list=this.observed;return list.includes("labels")?list:[...list,"labels"]}static get properties(){return{}}static get updateMode(){return"scaffold"}brownoutLevel(){const raw=this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0";const n=parseInt(raw,10);return Number.isFinite(n)?n:0}shed(kind,threshold){return this.brownoutLevel()>=(threshold||1)}get renderCount(){return this._contourRenderCount||0}_countRender(){this._contourRenderCount=(this._contourRenderCount||0)+1}static _propsInstalled=false;_installProperties(){const ctor=this.constructor;if(ctor._propsInstalled)return;ctor._propsInstalled=true;const props=ctor.properties||{};const declared=new Set();for(const[name,spec]of Object.entries(props)){const attr=(spec&&spec.attribute)||name;declared.add(attr);const type=(spec&&spec.type)||String;Object.defineProperty(ctor.prototype,name,{get(){const raw=this.getAttribute(attr);if(type===Boolean)return raw!==null;if(raw===null)return spec&&spec.default!==undefined?spec.default:null;if(type===Number){const n=Number(raw);return Number.isNaN(n)?null:n}return raw},set(v){if(v===null||v===undefined||v===false)this.removeAttribute(attr);else if(type===Boolean){if(v)this.setAttribute(attr,"");else this.removeAttribute(attr)}else this.setAttribute(attr,String(v))},configurable:true,})}const observed=ctor.observedAttributes;for(const attr of observed){if(declared.has(attr))continue;const prop=attr.replace(/-([a-z])/g,(_,c)=>c.toUpperCase());if(!/^[a-zA-Z_$][\w$]*$/.test(prop))continue;if(prop in ctor.prototype)continue;const isBool=attr==="disabled"||attr==="checked"||attr==="required"||attr==="readonly"||attr==="multiple"||attr==="selected"||attr==="open"||attr==="hidden";Object.defineProperty(ctor.prototype,prop,{get(){const raw=this.getAttribute(attr);if(isBool)return raw!==null;return raw},set(v){if(v===null||v===undefined||v===false)this.removeAttribute(attr);else if(isBool){if(v)this.setAttribute(attr,"");else this.removeAttribute(attr)}else this.setAttribute(attr,String(v))},configurable:true,})}}connectedCallback(){if(this._contourAuthored){this._wireFormData();return}this._installProperties();this._contourAuthored={nodes:Array.from(this.childNodes),cls:this.getAttribute("class"),};const before=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1;this._ensureCache=new Map();this._ensureCacheGen=this._contourRenderGen;this._countRender();try{this.render()}catch(e){console.error("Contour render error:",e);this.textContent=labelText(this,"render-error","Component failed to render.")}this._contourGenerated=Array.from(this.childNodes).filter((n)=>!before.includes(n));this._applyParts(this);this._applyDensity();this.enhance();this._detachInnerFormControls();this._wireFormData();this._wireValueTracking()}attributeChangedCallback(name,oldValue,newValue){if(oldValue===newValue)return;if(!this.isConnected||!this._contourAuthored)return;if(this._batchDepth>0){this._batchDirty=true;return}if(this._contourRendering){if(!this._pendingRerender){this._pendingRerender=true;queueMicrotask(()=>{this._pendingRerender=false;if(!this.isConnected||!this._contourAuthored)return;this.attributeChangedCallback("__rerender__",null,"")})}return}if(name==="checked")this._checkedAttrChanged=true;this._contourRendering=true;try{const savedControls=Array.from(this.querySelectorAll("input, textarea, select"));const savedValues=savedControls.map((el)=>({key:el.name||el.id||null,preserveKey:el.getAttribute("data-contour-preserve-key")||null,value:el.value,checked:el.checked,type:el.type,dirty:!!el._contourUserDirty,attrAtDirty:el._contourAttrAtDirty,selected:el.tagName==="SELECT"&&el.multiple?Array.from(el.selectedOptions).map((o)=>o.value):null,}));const hadFocus=this.contains(document.activeElement)?document.activeElement:null;const _focusableSelector="button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])";const _focusablesBefore=Array.from(this.querySelectorAll(_focusableSelector));const hadFocusIndex=hadFocus?_focusablesBefore.indexOf(hadFocus):-1;const hadFocusKey=hadFocus?(hadFocus.id||null):null;const hadFocusPreserveKey=hadFocus?(hadFocus.getAttribute("data-contour-preserve-key")||null):null;const hadFocusName=hadFocus?(hadFocus.getAttribute("name")||null):null;const savedScrolls=Array.from(this.querySelectorAll("*")).filter((el)=>el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth).map((el)=>({el,id:el.id||null,preserveKey:el.getAttribute("data-contour-preserve-key")||null,top:el.scrollTop,left:el.scrollLeft}));const savedDetails=Array.from(this.querySelectorAll("details")).map((d)=>({id:d.id||null,preserveKey:d.getAttribute("data-contour-preserve-key")||null,open:d.open}));for(const g of(this._contourGenerated||[])){if(!g||g.parentNode!==this)continue;let wrapper=null;if(g.classList&&(g.classList.contains("c-panel__body")||g.classList.contains("c-dialog__body")))wrapper=g;else if(g.tagName==="PRE")wrapper=g.querySelector("code")||g;if(wrapper){while(wrapper.firstChild)this.insertBefore(wrapper.firstChild,g)}}for(const g of(this._contourGenerated||[])){if(g.parentNode===this)this.removeChild(g)}const generated=new Set(this._contourGenerated||[]);const authoredNow=Array.from(this.childNodes).filter((n)=>!generated.has(n));this._contourAuthored.nodes=authoredNow;while(this.firstChild)this.removeChild(this.firstChild);for(const node of this._contourAuthored.nodes)this.appendChild(node);if(this._contourAuthored.cls===null)this.removeAttribute("class");else this.setAttribute("class",this._contourAuthored.cls);const before=Array.from(this.childNodes);this._contourRenderGen=(this._contourRenderGen||0)+1;this._ensureCache=new Map();this._ensureCacheGen=this._contourRenderGen;this._countRender();try{this.render()}catch(e){console.error("Contour render error:",e);this.textContent=labelText(this,"render-error","Component failed to render.")}this._contourGenerated=Array.from(this.childNodes).filter((n)=>!before.includes(n));this._applyParts(this);this._applyDensity();const newControls=Array.from(this.querySelectorAll("input, textarea, select"));const keyed=savedValues.filter((sv)=>sv.key||sv.preserveKey);const unkeyed=savedValues.filter((sv)=>!sv.key&&!sv.preserveKey);const used=new Set();for(const el of newControls){const key=el.name||el.id||el.getAttribute("data-contour-preserve-key")||null;if(!key)continue;const match=keyed.find((sv)=>(sv.key===key||sv.preserveKey===key)&&!used.has(sv));if(!match)continue;used.add(match);if(!this._contourResetting)this._restoreControlValue(el,match);if((el.type==="checkbox"||el.type==="radio")&&typeof match.checked==="boolean"&&!this._checkedAttrChanged&&!this._contourResetting){el.checked=match.checked}}const savedByType=new Map();for(const sv of unkeyed){const group=savedByType.get(sv.type)||[];group.push(sv);savedByType.set(sv.type,group)}const usedByType=new Map();for(const el of newControls){if(el.name||el.id)continue;const type=el.type;const group=savedByType.get(type)||[];const used=usedByType.get(type)||0;if(used>=group.length)continue;const saved=group[used];usedByType.set(type,used+1);if(!this._contourResetting)this._restoreControlValue(el,saved);if((el.type==="checkbox"||el.type==="radio")&&typeof saved.checked==="boolean"&&!this._checkedAttrChanged&&!this._contourResetting){el.checked=saved.checked}}const newDetails=Array.from(this.querySelectorAll("details"));const keyedDetails=savedDetails.filter((sd)=>sd.id||sd.preserveKey);const usedIds=new Set();for(const d of newDetails){const id=d.id||null;const preserveKey=d.getAttribute("data-contour-preserve-key")||null;if(!id&&!preserveKey)continue;const match=keyedDetails.find((sd)=>(sd.id===id||sd.preserveKey===preserveKey)&&!usedIds.has(sd.id||sd.preserveKey));if(!match)continue;usedIds.add(match.id||match.preserveKey);d.open=match.open}let di=0;const plainSaved=savedDetails.filter((sd)=>!sd.id);for(const d of newDetails){if(d.id)continue;const sd=plainSaved[di];di+=1;if(!sd)break;d.open=sd.open}const newScrolls=Array.from(this.querySelectorAll("*")).filter((el)=>el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth);const keyedScrolls=savedScrolls.filter((s)=>s.id||s.preserveKey);const usedScrolls=new Set();for(const el of newScrolls){const id=el.id||null;const preserveKey=el.getAttribute("data-contour-preserve-key")||null;if(!id&&!preserveKey)continue;const match=keyedScrolls.find((s)=>(s.id===id||s.preserveKey===preserveKey)&&!usedScrolls.has(s.el));if(!match)continue;usedScrolls.add(match.el);el.scrollTop=match.top;el.scrollLeft=match.left}let si=0;const plainScrolls=savedScrolls.filter((s)=>!s.id&&!s.preserveKey);for(const el of newScrolls){if(el.id)continue;const s=plainScrolls[si];si+=1;if(!s)break;el.scrollTop=s.top;el.scrollLeft=s.left}if(hadFocus){let target=null;if(hadFocusKey){try{target=this.querySelector("#"+CSS.escape(hadFocusKey))}catch(e){target=null}}if(!target&&hadFocusPreserveKey){try{target=this.querySelector('[data-contour-preserve-key="'+CSS.escape(hadFocusPreserveKey)+'"]')}catch(e){target=null}}if(!target&&hadFocusName){try{target=this.querySelector('[name="'+CSS.escape(hadFocusName)+'"]')}catch(e){target=null}}if(!target&&hadFocusIndex>=0){const after=Array.from(this.querySelectorAll(_focusableSelector));if(after.length){target=after[Math.min(hadFocusIndex,after.length-1)]}}if(target&&typeof target.focus==="function"){try{target.focus()}catch(e){}}else if(document.contains(hadFocus)){try{hadFocus.focus()}catch(e){}}else{const first=this.querySelector(_focusableSelector);if(first)try{first.focus()}catch(e){}else try{this.focus()}catch(e){}}}this.enhance();this._detachInnerFormControls();this._checkedAttrChanged=false;this._contourResetting=false}finally{this._contourRendering=false}}disconnectedCallback(){this._pendingRerender=false;this._ensureCache=null;this._batchDepth=0;this._batchDirty=false;this._wiredFormData=false;runDisposers(this)}adoptedCallback(){if(this._contourAuthored){this._applyParts(this);this._applyDensity()}}enhance(){}_syncFormValue(){if(!this._internals)return;const ctl=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!ctl)return;const boolean=ctl.type==="checkbox"||ctl.type==="radio";const value=boolean?(ctl.checked?(ctl.value||"on"):null):ctl.value;this._internals.setFormValue(value);this._syncValidity(this.hasAttribute("required")&&!value)}_syncValidity(valueMissing){if(!this._internals)return;if(valueMissing)this._internals.setValidity({valueMissing:true},"This field is required.");else this._internals.setValidity({});this._setCustomState("data-invalid",!!valueMissing)}_setCustomState(name,on){let internals=this._internals;if(!internals){if(this._stateInternals)internals=this._stateInternals;else if(typeof this.attachInternals==="function"){try{internals=this._stateInternals=this.attachInternals()}catch(e){return}}}const states=internals&&internals.states;if(!states)return;if(on){if(!states.has(name))states.add(name)}else if(states.has(name))states.delete(name)}_emitForm(type){if(!this._internals)return;const ctl=this.querySelector("input:checked, textarea, select")||this.querySelector("input, textarea, select");if(!ctl)return;const boolean=ctl.type==="checkbox"||ctl.type==="radio";this.dispatchEvent(new CustomEvent(type,{bubbles:true,composed:true,detail:{name:this.getAttribute("name"),value:boolean?(ctl.checked?(ctl.value||"on"):null):ctl.value,checked:boolean?ctl.checked:null,},}))}formResetCallback(){for(const ctl of this.querySelectorAll("input, textarea, select")){ctl._contourUserDirty=false;if(ctl.type==="checkbox"||ctl.type==="radio"){ctl.checked=this.hasAttribute("checked")}else if(ctl.tagName==="SELECT"){const chosen=ctl.querySelector("option[selected], option:first-of-type");ctl.value=chosen?chosen.value:""}else{ctl.value=this.hasAttribute("value")?this.getAttribute("value"):(ctl.getAttribute("value")||"")}}this._syncFormValue()}formDisabledCallback(disabled){for(const ctl of this.querySelectorAll("input, textarea, select, button")){if(disabled)ctl.setAttribute("disabled","");else ctl.removeAttribute("disabled")}}formStateRestoreCallback(state){if(!this._internals||state===null||state===undefined)return;const controls=Array.from(this.querySelectorAll("input, textarea, select"));const str=String(state);const match=controls.find((c)=>(c.type==="checkbox"||c.type==="radio")&&c.value===str);if(match){match.checked=true;for(const other of controls){if(other!==match&&other.type==="radio"&&other.name===match.name)other.checked=false}}else if(controls.length){controls[0].value=str}this._syncFormValue()}checkValidity(){return this._internals?this._internals.checkValidity():true}reportValidity(){return this._internals?this._internals.reportValidity():true}_wireFormData(){if(!this._internals||this._wiredFormData)return;const form=this._internals.form;if(!form)return;this._wiredFormData=true;const myName=this.getAttribute("name");const onFormChange=(e)=>{const t=e.target;if(t&&t.type==="radio"&&t.name&&t.name===myName)this._syncFormValue()};form.addEventListener("change",onFormChange);const onFormData=()=>this._syncFormValue();form.addEventListener("formdata",onFormData);onDispose(this,()=>{form.removeEventListener("change",onFormChange);form.removeEventListener("formdata",onFormData)})}_wireValueTracking(){if(!this._internals||this._wiredValueTracking)return;this._wiredValueTracking=true;const mark=(e)=>{const t=e.target;if(!t||!t.matches||!t.matches("input, textarea, select"))return;if(this._ownerBetween(t,this))return;t._contourUserDirty=true;t._contourAttrAtDirty=this.getAttribute("value")};this.addEventListener("input",mark);this.addEventListener("change",mark)}_restoreControlValue(el,saved){if(saved.dirty&&saved.attrAtDirty===this.getAttribute("value")){if(saved.selected&&el.tagName==="SELECT"&&el.multiple){const wanted=new Set(saved.selected);for(const o of el.options)o.selected=wanted.has(o.value)}else{el.value=saved.value}el._contourUserDirty=true;el._contourAttrAtDirty=saved.attrAtDirty;return}if(el.value===""&&el.getAttribute("value")===null)el.value=saved.value}_detachInnerFormControls(){if(!this._internals)return;for(const ctl of this.querySelectorAll("input, textarea, select")){if(ctl.hasAttribute("name")&&ctl.getAttribute("form")!=="")ctl.setAttribute("form","")}}batch(fn){if(typeof fn!=="function")return;this._batchDepth=(this._batchDepth||0)+1;this._batchDirty=this._batchDirty||false;try{fn()}finally{this._batchDepth-=1;if(this._batchDepth===0&&this._batchDirty){this._batchDirty=false;if(this.isConnected&&this._contourAuthored){this.attributeChangedCallback("__rerender__",null,"")}}}}requestRender(){if(this._contourRerenderQueued)return;this._contourRerenderQueued=true;queueMicrotask(()=>{this._contourRerenderQueued=false;if(!this.isConnected||!this._contourAuthored)return;this.attributeChangedCallback("__rerender__",null,"")})}_applyParts(root){const scope=root||this;const nodes=scope.querySelectorAll?Array.from(scope.querySelectorAll("[class]")):[];for(const node of nodes){if(node.hasAttribute("part"))continue;if(typeof node.className!=="string")continue;for(const c of node.className.split(/\s+/)){const m=c.match(/^c-[a-z0-9-]+__([a-z0-9-]+)$/);if(m){node.setAttribute("part",m[1]);break}}}}_applyDensity(){const density=this.getAttribute("density");if(density!==null)this.setAttribute("data-density",density);else if(this.hasAttribute("data-density"))this.removeAttribute("data-density")}_ownerBetween(node,root){for(let p=node.parentElement;p&&p!==root;p=p.parentElement){if(p instanceof ContourBase)return p}return null}ensure(selector,factory,parent){const root=parent||this;if(!root._ensureCache||root._ensureCacheGen!==this._contourRenderGen){root._ensureCache=new Map();root._ensureCacheGen=this._contourRenderGen}const cache=root._ensureCache;const key=root===this?selector:"\u0000"+root+"\u0000"+selector;let node=cache.get(key);if(node===undefined){node=null;for(const candidate of root.querySelectorAll(selector)){if(!this._ownerBetween(candidate,root)){node=candidate;break}}cache.set(key,node)}if(!node){node=factory();if(node&&node.setAttribute&&!node.hasAttribute("part")){const m=String(selector).match(/\.c-[a-z0-9-]+__([a-z0-9-]+)/);if(m)node.setAttribute("part",m[1])}root.appendChild(node);cache.set(key,node)}return node}}export function withBrownout(Base){return class extends Base{static get observed(){const base=(super.observed&&Array.isArray(super.observed))?super.observed:[];const extra=["brownout","brownout-level"];return Array.from(new Set(base.concat(extra)))}brownoutLevel(){return super.brownoutLevel?super.brownoutLevel():(parseInt(this.getAttribute("brownout-level")||this.getAttribute("brownout")||"0",10)||0)}shed(kind,threshold){return this.brownoutLevel()>=(threshold||1)}}}export const simple=(classes)=>class extends ContourBase{render(){classes.forEach((c)=>this.classList.add(c));for(const c of Array.from(this.classList)){if(classes.some((base)=>c.startsWith(base+"--")))this.classList.remove(c)}MODS.forEach((attr)=>{if(this.hasAttribute(attr)){const val=this.getAttribute(attr);classes.forEach((c)=>{const prefix=c.replace("c-","");this.classList.add(`c-${prefix}--${val}`)})}})}};export const CLASS_ONLY=["box","cluster","container","row","scrim","stack"];export function supportsUntilFound(){try{const t=document.createElement("div");t.setAttribute("hidden","until-found");return t.getAttribute("hidden")==="until-found"}catch(e){return false}}export function formatValue(value,format,locale,unit){if(!format)return value;const loc=locale||(typeof navigator!=="undefined"&&navigator.language)||"en";if(format==="date"||format==="time"){try{const opts=format==="time"?{timeStyle:"short"}:undefined;return new Intl.DateTimeFormat(loc,opts).format(new Date(value))}catch(e){return value}}if(format==="relative"){try{const num=Number(value);let seconds=num;if(Number.isNaN(num)){const then=new Date(value).getTime();if(Number.isFinite(then))seconds=(then-Date.now())/1000}const rtf=new Intl.RelativeTimeFormat(loc,{numeric:"auto"});if(Math.abs(seconds)<60)return rtf.format(Math.round(seconds),"second");if(Math.abs(seconds)<3600)return rtf.format(Math.round(seconds/60),"minute");if(Math.abs(seconds)<86400)return rtf.format(Math.round(seconds/3600),"hour");return rtf.format(Math.round(seconds/86400),"day")}catch(e){return value}}let opts={};if(format==="currency")opts={style:"currency",currency:"USD"};else if(format==="percent")opts={style:"percent"};else if(format==="compact")opts={notation:"compact"};else if(format==="unit")opts={style:"unit",unit:unit||"meter"};else if(format!=="number"){try{opts=JSON.parse(format)}catch(e){return value}}try{return new Intl.NumberFormat(loc,opts).format(Number(value))}catch(e){return value}}export function navKey(e,items,{wrap=true,enter=true,homeEnd=false,onKey,onNavigate,rtl}={}){const idx=items.indexOf(document.activeElement);if(idx<0)return;let next=-1;const fwdKey=rtl?"ArrowLeft":"ArrowRight";const revKey=rtl?"ArrowRight":"ArrowLeft";if(e.key===fwdKey||e.key==="ArrowDown")next=wrap?(idx+1)%items.length:Math.min(idx+1,items.length-1);else if(e.key===revKey||e.key==="ArrowUp")next=wrap?(idx-1+items.length)%items.length:Math.max(0,idx-1);else if((homeEnd||wrap)&&e.key==="Home")next=0;else if((homeEnd||wrap)&&e.key==="End")next=items.length-1;if(next>=0&&next!==idx){e.preventDefault();try{items[next].focus()}catch(_){}if(onNavigate)onNavigate(next);if(onKey)onKey(e.key,idx,items[idx])}else if((enter||wrap)&&(e.key==="Enter"||e.key===" ")){e.preventDefault();if(onKey)onKey(e.key,idx,items[idx])}}export function isRtl(el){let node=el;while(node&&node.nodeType===1){const d=node.getAttribute&&node.getAttribute("dir");if(d)return d.toLowerCase()==="rtl";node=node.parentElement}try{return(typeof document!=="undefined"&&(document.documentElement.getAttribute("dir")||"").toLowerCase()==="rtl")}catch(e){return false}}export function haversine(lat1,lon1,lat2,lon2){const R=6371000;const toRad=(d)=>d*Math.PI/180;const dLat=toRad(lat2-lat1);const dLon=toRad(lon2-lon1);const a=Math.sin(dLat/2)**2+Math.cos(toRad(lat1))*Math.cos(toRad(lat2))*Math.sin(dLon/2)**2;return 2*R*Math.asin(Math.sqrt(a))}export function bearing(lat1,lon1,lat2,lon2){const toRad=(d)=>d*Math.PI/180;const toDeg=(r)=>r*180/Math.PI;const dLon=toRad(lon2-lon1);const y=Math.sin(dLon)*Math.cos(toRad(lat2));const x=Math.cos(toRad(lat1))*Math.sin(toRad(lat2))-Math.sin(toRad(lat1))*Math.cos(toRad(lat2))*Math.cos(dLon);return(toDeg(Math.atan2(y,x))+360)%360}export function mercatorResolution(lat,zoom){return 156543.03392*Math.cos(lat*Math.PI/180)/Math.pow(2,zoom)}"use strict";export function arcPath(cx,cy,r,inner,startAngle,endAngle){cx=Number.isFinite(cx)?cx:0;cy=Number.isFinite(cy)?cy:0;r=Number.isFinite(r)&&r>0?r:0;inner=Number.isFinite(inner)&&inner>=0?inner:0;startAngle=Number.isFinite(startAngle)?startAngle:0;endAngle=Number.isFinite(endAngle)?endAngle:0;const largeArc=endAngle-startAngle>Math.PI?1:0;const x1=cx+r*Math.cos(startAngle);const y1=cy+r*Math.sin(startAngle);const x2=cx+r*Math.cos(endAngle);const y2=cy+r*Math.sin(endAngle);if(inner<=0){return`M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} Z`}const ix1=cx+inner*Math.cos(endAngle);const iy1=cy+inner*Math.sin(endAngle);const ix2=cx+inner*Math.cos(startAngle);const iy2=cy+inner*Math.sin(startAngle);return`M ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} L ${ix1} ${iy1} A ${inner} ${inner} 0 ${largeArc} 0 ${ix2} ${iy2} Z`}export function donutSlices(values,opts){opts=opts||{};const cx=opts.cx!=null?opts.cx:100;const cy=opts.cy!=null?opts.cy:100;const r=opts.r!=null?opts.r:90;const inner=opts.inner!=null?opts.inner:55;const gap=opts.gap!=null?opts.gap:0.02;const total=values.reduce((a,b)=>a+(Number(b)||0),0)||1;let angle=-Math.PI/2;const out=[];values.forEach((v,i)=>{const num=Number(v)||0;const frac=num/total;if(!(num>0)){angle+=frac*Math.PI*2;return}const sweep=frac*Math.PI*2-gap;const start=angle+gap/2;const end=start+Math.max(0,sweep);out.push({path:arcPath(cx,cy,r,inner,start,end),value:num,index:i});angle+=frac*Math.PI*2});return out}export function barRects(values,opts){opts=opts||{};const width=opts.width!=null?opts.width:300;const height=opts.height!=null?opts.height:120;const gap=opts.gap!=null?opts.gap:2;const max=opts.max!=null?opts.max:(Math.max.apply(null,values.map((v)=>Number(v)||0))||1);if(!Number.isFinite(max)||max<=0)return values.map(()=>({x:0,y:height,width:0,height:0}));const n=values.length||1;const slot=width/n;const barW=Math.max(1,slot-gap);return values.map((v,i)=>{const h=((Number(v)||0)/max)*height;return{x:i*slot+gap/2,y:height-h,width:barW,height:h}})}export function polylinePoints(values,opts){opts=opts||{};const width=opts.width!=null?opts.width:300;const height=opts.height!=null?opts.height:120;const nums=values.map((v)=>Number(v)||0);if(!nums.length)return"";const max=opts.max!=null?opts.max:Math.max.apply(null,nums);const min=opts.min!=null?opts.min:Math.min.apply(null,nums);const range=(Number.isFinite(max-min)&&(max-min)!==0)?(max-min):1;const n=nums.length||1;return nums.map((v,i)=>{const x=(i/Math.max(1,n-1))*width;const y=height-((v-min)/range)*height;return x.toFixed(2)+","+y.toFixed(2)}).join(" ")}export function smoothPath(values,opts){const pts=polylinePoints(values,opts).split(" ").map((p)=>p.split(",").map(Number));if(!pts.length)return"";let d=`M ${pts[0][0]} ${pts[0][1]}`;for(let i=1;i<pts.length;i++){const prev=pts[i-1];const cur=pts[i];const cpx=(prev[0]+cur[0])/2;d+=` C ${cpx} ${prev[1]}, ${cpx} ${cur[1]}, ${cur[0]} ${cur[1]}`}return d}export function compassNeedle(cx,cy,length,angleDeg,width){angleDeg=angleDeg==null?0:angleDeg;width=width==null?3:width;const a=(angleDeg-90)*Math.PI/180;const tipX=cx+length*Math.cos(a);const tipY=cy+length*Math.sin(a);const tail=length*0.25;const tailX=cx-tail*Math.cos(a);const tailY=cy-tail*Math.sin(a);const perpX=Math.cos(a+Math.PI/2);const perpY=Math.sin(a+Math.PI/2);const b1x=cx+width*perpX;const b1y=cy+width*perpY;const b2x=cx-width*perpX;const b2y=cy-width*perpY;return`M ${tipX.toFixed(2)} ${tipY.toFixed(2)} L ${b1x.toFixed(2)} ${b1y.toFixed(2)} L ${tailX.toFixed(2)} ${tailY.toFixed(2)} L ${b2x.toFixed(2)} ${b2y.toFixed(2)} Z`}export function scaleBarTicks(value,segments){value=Number(value)||0;segments=Math.max(1,Math.round(segments||4));const out=[];for(let i=0;i<=segments;i++){out.push((value/segments)*i)}return out}export const MARKER_SHAPES=["circle","square","triangle","diamond","star"];export function markerStyles(shape){const map={circle:"border-radius:50%",square:"border-radius:0",triangle:"clip-path:polygon(50% 0%,0% 100%,100% 100%)",diamond:"transform:rotate(45deg)",star:"clip-path:polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)",};return map[shape]||""}export function assignMarkers(items){return(items||[]).map((it,i)=>({...it,marker:MARKER_SHAPES[i%MARKER_SHAPES.length]}))}export function marchingSquares(grid,level){const rows=grid.length;const cols=rows?grid[0].length:0;const segments=[];if(!rows||!cols)return segments;const lerp=(a,b,va,vb)=>(vb===va?0.5:(level-va)/(vb-va));for(let y=0;y<rows-1;y++){for(let x=0;x<cols-1;x++){const tl=grid[y][x];const tr=grid[y][x+1];const bl=grid[y+1][x];const br=grid[y+1][x+1];const code=(tl>=level?8:0)|(tr>=level?4:0)|(br>=level?2:0)|(bl>=level?1:0);if(code===0||code===15)continue;const top={x:x+lerp(tl,tr,tl,tr),y};const right={x:x+1,y:y+lerp(tr,br,tr,br)};const bottom={x:x+lerp(bl,br,bl,br),y:y+1};const left={x,y:y+lerp(tl,bl,tl,bl)};let connect;if(code===5){const center=(tl+tr+bl+br)/4;connect=center>=level?"top-bottom":"left-right"}else if(code===10){const center=(tl+tr+bl+br)/4;connect=center>=level?"left-right":"top-bottom"}switch(code){case 1:case 14:segments.push([left,bottom]);break;case 2:case 13:segments.push([bottom,right]);break;case 3:case 12:segments.push([left,right]);break;case 4:case 11:segments.push([top,right]);break;case 6:case 9:segments.push([top,bottom]);break;case 7:case 8:segments.push([left,top]);break;case 5:if(connect==="top-bottom"){segments.push([top,bottom],[left,right])}else{segments.push([top,right],[left,bottom])}break;case 10:if(connect==="left-right"){segments.push([left,right],[top,bottom])}else{segments.push([top,right],[left,bottom])}break}}}return segments}export function contourPaths(grid,levels,width,height){const rows=grid.length;const cols=rows?grid[0].length:0;if(rows<2||cols<2)return[];const sx=width/(cols-1);const sy=height/(rows-1);return(levels||[]).map((level)=>{const segs=marchingSquares(grid,level);let d="";for(const[a,b]of segs){d+=`M ${(a.x * sx).toFixed(2)} ${(a.y * sy).toFixed(2)} L ${(b.x * sx).toFixed(2)} ${(b.y * sy).toFixed(2)} `}return{level,d:d.trim()}})}const WIRED_HOSTS=new WeakMap();export const wcReset=(host)=>{WIRED_HOSTS.delete(host)};const wcClaim=(host,name)=>{let set=WIRED_HOSTS.get(host);if(!set){set=new Set();WIRED_HOSTS.set(host,set)}if(set.has(name))return false;set.add(name);return true};const wcScopes=(host)=>(host.shadowRoot?[host,host.shadowRoot]:[host]);const wcAll=(host,sel)=>{const found=[];for(const scope of wcScopes(host)){for(const el of scope.querySelectorAll(sel))if(!found.includes(el))found.push(el)}return found};const wcOne=(host,sel)=>wcAll(host,sel)[0]||null;const wcSelfOrAll=(host,sel)=>{const found=typeof host.matches==="function"&&host.matches(sel)?[host]:[];for(const el of wcAll(host,sel))if(!found.includes(el))found.push(el);return found};const wcShadowOf=(node)=>{const root=node&&node.getRootNode?node.getRootNode():null;return root&&root.host?root:null};const wcGroup=(host,group,sel)=>{const found=Array.from(group.querySelectorAll(sel));if(wcShadowOf(group)&&wcShadowOf(group).host===host){for(const el of host.querySelectorAll(sel))if(!found.includes(el))found.push(el)}return found};const HEARD=new WeakMap();const wcListen=(host,type,handler)=>{const scoped=(e)=>{let seen=HEARD.get(e);if(!seen){seen=new Set();HEARD.set(e,seen)}if(seen.has(scoped))return;seen.add(scoped);handler(e)};for(const scope of wcScopes(host))scope.addEventListener(type,scoped)};const wcOwned=(host,node)=>!!node&&wcScopes(host).some((scope)=>scope.contains(node));const wcClosest=(host,target,sel)=>(typeof target?.closest==="function"&&wcOwned(host,target))?target.closest(sel):null;const wcEmit=(host,name,detail)=>{host.dispatchEvent(new CustomEvent(name,{detail,bubbles:true,composed:true}))};export function wireTabs(host){if(!wcClaim(host,"tabs"))return;for(const list of wcSelfOrAll(host,".c-tabs__list, .c-code-tabs__list")){const isCode=list.classList.contains("c-code-tabs__list");const panelSel=isCode?".c-code-tabs__panel":".c-tabs__panel";const tabsOf=()=>wcGroup(host,list,"[role='tab']");const activate=(tab,focus)=>{const tabs=tabsOf();if(!tab.id)tab.id=contourId("c-tab");tabs.forEach((t)=>{const selected=t===tab;t.setAttribute("aria-selected",String(selected));t.tabIndex=selected?0:-1;const ctrl=t.getAttribute("aria-controls");if(!ctrl)return;const panel=wcOne(host,"#"+CSS.escape(ctrl))||document.getElementById(ctrl);if(panel){panel.hidden=!selected;if(selected)panel.setAttribute("aria-labelledby",t.id)}});const panels=wcAll(host,panelSel);if(panels.length){const index=tabs.indexOf(tab);panels.forEach((p,i)=>{p.hidden=i!==index})}if(focus)try{tab.focus()}catch(e){}const name=tab.getAttribute("aria-controls")||tab.textContent||"";host.dispatchEvent(new CustomEvent("contour:tab-change",{bubbles:true,composed:true,detail:{index:tabs.indexOf(tab),label:name}}))};const runActivation=(tab,focus)=>{const can=!focus&&typeof document.startViewTransition==="function"&&!(typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);if(can){try{document.startViewTransition(()=>activate(tab,focus));return}catch(e){}}activate(tab,focus)};wcListen(host,"click",(e)=>{const tab=wcClosest(host,e.target,"[role='tab']");if(tab&&tabsOf().includes(tab)){const inner=e.target&&e.target.closest?e.target.closest("button"):null;if(inner&&inner!==tab&&tab.contains(inner))return;runActivation(tab,false)}});wcListen(host,"keydown",(e)=>{let tab=wcClosest(host,e.target,"[role='tab']");if(!tab&&e.target&&e.target.getAttribute&&e.target.getAttribute("role")==="tab"&&wcOwned(host,e.target))tab=e.target;const tabs=tabsOf();const index=tabs.indexOf(tab);if(index<0)return;const vertical=host.getAttribute("orientation")==="vertical";const rtl=isRtl(host);const move=vertical?(rtl?{ArrowDown:index-1,ArrowUp:index+1,Home:tabs.length-1,End:0}:{ArrowDown:index+1,ArrowUp:index-1,Home:0,End:tabs.length-1}):(rtl?{ArrowRight:index-1,ArrowLeft:index+1,Home:tabs.length-1,End:0}:{ArrowRight:index+1,ArrowLeft:index-1,Home:0,End:tabs.length-1});if(!(e.key in move))return;e.preventDefault();const next=tabs[(move[e.key]+tabs.length)%tabs.length];if(next)runActivation(next,true)});const tabs=tabsOf();const persist=host.getAttribute("persist");let restored=null;if(persist==="storage"&&host.id){try{restored=localStorage.getItem("contour-tabs:"+host.id)}catch(e){restored=null}}else if(persist==="url"){try{const params=new URLSearchParams(window.location.search);const v=params.get("c-tabs");if(v!==null)restored=v}catch(e){restored=null}}const marked=tabs.find((t)=>t.getAttribute("aria-selected")==="true");let first=marked||tabs[0];if(restored!==null){const idx=parseInt(restored,10);if(Number.isFinite(idx)&&tabs[idx])first=tabs[idx]}if(first)activate(first,false);if(persist==="storage"&&host.id){host.addEventListener("contour:tab-change",(e)=>{try{localStorage.setItem("contour-tabs:"+host.id,String(e.detail&&e.detail.index))}catch(err){}})}else if(persist==="url"){host.addEventListener("contour:tab-change",(e)=>{try{const url=new URL(window.location.href);url.searchParams.set("c-tabs",String(e.detail&&e.detail.index));window.history.replaceState(null,"",url.toString())}catch(err){}})}}}export function wireSegmented(host){const groups=wcSelfOrAll(host,".c-segmented");const normalize=()=>{const authored=host.getAttribute("value");const chosen=authored!==host._segAuthorValue?authored:null;if(chosen!==null)host._segAuthorValue=authored;let seen=0;for(const g of groups){if(!g.hasAttribute("role"))g.setAttribute("role","group");const label=host.getAttribute("label");if(label&&!g.hasAttribute("aria-label"))g.setAttribute("aria-label",label);const opts=wcGroup(host,g,"button");seen+=opts.length;opts.forEach((b)=>{b.classList.add("c-segmented__option");b.setAttribute("aria-pressed",chosen!==null&&chosen!==undefined?String(b.dataset.value===chosen):(b.getAttribute("aria-pressed")==="true"?"true":"false"))});const chosenOpt=opts.find((b)=>b.getAttribute("aria-pressed")==="true")||opts[0];opts.forEach((b)=>{b.tabIndex=b===chosenOpt?0:-1})}return seen};if(!normalize()){if(!host._segRetryScheduled){host._segRetryScheduled=true;setTimeout(()=>{host._segRetryScheduled=false;normalize()},0)}}if(!wcClaim(host,"segmented"))return;const activate=(btn)=>{const seg=groups.find((g)=>wcGroup(host,g,"button").includes(btn));if(!seg)return;wcGroup(host,seg,"button").forEach((o)=>{const on=o===btn;o.setAttribute("aria-pressed",String(on));o.tabIndex=on?0:-1});wcEmit(host,"contour:change",{value:btn.dataset.value||btn.textContent.trim()})};wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,"button");if(!btn)return;activate(btn)});wcListen(host,"keydown",(e)=>{const btn=wcClosest(host,e.target,"button");if(!btn)return;const seg=groups.find((g)=>wcGroup(host,g,"button").includes(btn));if(!seg)return;const opts=wcGroup(host,seg,"button");navKey(e,opts,{wrap:false,homeEnd:true,rtl:isRtl(host),onNavigate:(i)=>activate(opts[i]),onKey:()=>activate(btn)})})}export function wireCombobox(host){wireComboboxDocDismiss();const input=wcOne(host,".c-combobox__input");const list=wcOne(host,".c-combobox__list");if(!input||!list)return;const optionList=()=>wcAll(host,".c-combobox__option");if(!list.id)list.id=contourId("c-combobox-list");list.setAttribute("role","listbox");input.setAttribute("role","combobox");input.setAttribute("aria-haspopup","listbox");input.setAttribute("aria-controls",list.id);input.setAttribute("aria-expanded",list.hasAttribute("hidden")?"false":"true");if(!input.hasAttribute("aria-autocomplete"))input.setAttribute("aria-autocomplete","list");optionList().forEach((opt,i)=>{if(!opt.id)opt.id=contourId("c-combobox-option");opt.setAttribute("role","option");if(!opt.hasAttribute("aria-selected"))opt.setAttribute("aria-selected","false")});if(!wcClaim(host,"combobox"))return;const liveInput=()=>wcOne(host,".c-combobox__input");const liveList=()=>wcOne(host,".c-combobox__list");let cursor=-1;const mark=(visible)=>{const field=liveInput();visible.forEach((o,i)=>{const on=i===cursor;o.classList.toggle("c-combobox__option--active",on);o.setAttribute("aria-selected",String(on))});if(field){const active=cursor>=0?visible[cursor]:null;if(active)field.setAttribute("aria-activedescendant",active.id);else field.removeAttribute("aria-activedescendant")}};const filter=(query)=>{const q=(query||"").toLowerCase();if(host._comboboxVirtual&&typeof host._renderComboboxWindow==="function"){host._renderComboboxWindow(q,true);cursor=-1;return}optionList().forEach((o)=>{o.hidden=!!(q&&!o.textContent.toLowerCase().includes(q))});cursor=-1};const open=()=>{const l=liveList();if(!l)return;l.removeAttribute("hidden");const field=liveInput();if(field)field.setAttribute("aria-expanded","true")};const close=()=>{const l=liveList();if(l)l.setAttribute("hidden","");const field=liveInput();if(field){field.setAttribute("aria-expanded","false");field.removeAttribute("aria-activedescendant")}cursor=-1;optionList().forEach((o)=>{o.classList.remove("c-combobox__option--active");o.setAttribute("aria-selected","false")})};if(host._comboboxVirtual&&list&&!list._contourVirtualScroll){list._contourVirtualScroll=true;list.addEventListener("scroll",()=>{if(typeof host._renderComboboxWindow==="function")host._renderComboboxWindow(host._comboboxQuery||"")},{passive:true})}const commit=(opt)=>{const field=liveInput();if(!field)return;if(host.hasAttribute("multiple")){const now=opt.getAttribute("aria-selected")==="true";opt.setAttribute("aria-selected",String(!now));opt.classList.toggle("c-combobox__option--selected",!now);const selected=(host.getAttribute("value")||"").split(",").map((v)=>v.trim()).filter(Boolean);const value=host._comboboxVirtual&&host._comboboxFiltered?host._comboboxFiltered.find((item)=>item.index===Number(opt.dataset.optionIndex))?.value:(opt.dataset.optionValue!=null?opt.dataset.optionValue:opt.textContent.trim());const position=selected.indexOf(String(value));if(now&&position>=0)selected.splice(position,1);if(!now&&position<0)selected.push(String(value));host.setAttribute("value",selected.join(","));if(typeof host._syncFormValue==="function")host._syncFormValue();wcEmit(host,"contour:select",{value:selected});field.focus();return}const value=opt.dataset.optionValue!=null?opt.dataset.optionValue:opt.textContent.trim();field.value=opt.textContent;host.setAttribute("value",value);if(typeof host._syncFormValue==="function")host._syncFormValue();wcEmit(host,"contour:select",{value});close();field.focus()};const isField=(target)=>wcClosest(host,target,".c-combobox__input")!==null;wcListen(host,"input",(e)=>{if(!isField(e.target))return;host._comboboxQuery=e.target.value;filter(e.target.value);open();if(typeof host._emitForm==="function")host._emitForm("contour:input")});wcListen(host,"focusin",(e)=>{if(!isField(e.target))return;filter(e.target.value);open()});wcListen(host,"keydown",(e)=>{if(!isField(e.target))return;const visible=optionList().filter((o)=>!o.hidden);if(e.key==="ArrowDown"){e.preventDefault();cursor=Math.min(cursor+1,visible.length-1);mark(visible)}else if(e.key==="ArrowUp"){e.preventDefault();cursor=Math.max(cursor-1,0);mark(visible)}else if(e.key==="Home"){e.preventDefault();cursor=0;mark(visible)}else if(e.key==="End"){e.preventDefault();cursor=Math.max(0,visible.length-1);mark(visible)}else if(e.key==="Enter"||e.key===" "){e.preventDefault();if(cursor>=0&&visible[cursor])commit(visible[cursor])}else if(e.key==="Escape")close()});wcListen(host,"click",(e)=>{const opt=wcClosest(host,e.target,".c-combobox__option");if(opt){commit(opt);return}if(!wcOwned(host,e.target)||!host.contains(e.target))close()})}let _comboboxDocWired=false;function wireComboboxDocDismiss(){if(_comboboxDocWired)return;_comboboxDocWired=true;document.addEventListener("click",(e)=>{for(const host of document.querySelectorAll("contour-combobox, contour-shadow-combobox")){const list=host.shadowRoot?host.shadowRoot.querySelector(".c-combobox__list"):host.querySelector(".c-combobox__list");const input=host.shadowRoot?host.shadowRoot.querySelector(".c-combobox__input"):host.querySelector(".c-combobox__input");if(!list||list.hasAttribute("hidden"))continue;const root=host.shadowRoot||host;if(root.contains(e.target))continue;list.setAttribute("hidden","")}})}const visibleStops=(host)=>wcAll(host,".c-tree__toggle, .c-tree__leaf").filter((el)=>!el.closest(".c-tree__children[hidden]"));export function wireTree(host){const nodes=()=>wcAll(host,".c-tree__node");const rootList=wcSelfOrAll(host,"ul.c-tree")[0];if(rootList&&!rootList.hasAttribute("role"))rootList.setAttribute("role","tree");wcAll(host,".c-tree__children").forEach((ul)=>{if(!ul.hasAttribute("role"))ul.setAttribute("role","group")});const levelOf=(node)=>{let level=1;for(let p=node.parentElement;p;p=p.parentElement)if(p.classList&&p.classList.contains("c-tree__children"))level++;return level};nodes().forEach((node)=>{if(node.getAttribute("role")!=="treeitem")node.setAttribute("role","treeitem");node.setAttribute("aria-level",String(levelOf(node)));const row=node.querySelector(":scope > .c-tree__row");if(row)node.setAttribute("aria-expanded",row.querySelector(":scope > .c-tree__toggle")?.getAttribute("aria-expanded")||"false");else if(node.hasAttribute("aria-expanded"))node.removeAttribute("aria-expanded")});const stops=visibleStops(host);const authored=stops.find((el)=>el.getAttribute("tabindex")==="0");const active=authored||stops.find((el)=>el===document.activeElement)||stops[0];stops.forEach((el)=>el.setAttribute("tabindex",el===active?"0":"-1"));wcAll(host,".c-tree__toggle, .c-tree__leaf").forEach((el)=>{if(!stops.includes(el))el.setAttribute("tabindex","-1")});if(!wcClaim(host,"tree"))return;host._selectedTree=host._selectedTree||new Set();let lastTreeIndex=-1;wcListen(host,"change",(e)=>{const cb=e.target&&e.target.closest?e.target.closest(".c-tree__select"):null;if(!cb||!host.contains(cb))return;const cbs=Array.from(host.querySelectorAll(".c-tree__select"));const idx=cbs.indexOf(cb);const label=(cb.parentElement&&cb.parentElement.textContent||"").trim().slice(0,120);if(e.shiftKey&&lastTreeIndex>=0){const from=Math.min(lastTreeIndex,idx);const to=Math.max(lastTreeIndex,idx);for(let i=from;i<=to;i++){cbs[i].checked=cb.checked;const lbl=(cbs[i].parentElement&&cbs[i].parentElement.textContent||"").trim().slice(0,120);if(cb.checked)host._selectedTree.add(lbl);else host._selectedTree.delete(lbl)}}else if(!e.ctrlKey&&!e.metaKey){if(cb.checked){cbs.forEach((c,i)=>{if(i!==idx&&c.checked){c.checked=false;const lbl=(c.parentElement&&c.parentElement.textContent||"").trim().slice(0,120);host._selectedTree.delete(lbl)}})}if(cb.checked)host._selectedTree.add(label);else host._selectedTree.delete(label)}else{if(cb.checked)host._selectedTree.add(label);else host._selectedTree.delete(label)}lastTreeIndex=idx;wcEmit(host,"contour:select",{labels:Array.from(host._selectedTree)})});wcAll(host,".c-tree__node, .c-tree__leaf").forEach((n)=>{if(!n.hasAttribute("draggable"))n.setAttribute("draggable","true")});let dragLabel=null;wcListen(host,"dragstart",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node)return;dragLabel=(node.textContent||"").trim().slice(0,120);if(e.dataTransfer){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",dragLabel)}catch(err){}}});wcListen(host,"dragover",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node)return;e.preventDefault();if(e.dataTransfer)e.dataTransfer.dropEffect="move"});wcListen(host,"drop",(e)=>{const node=wcClosest(host,e.target,".c-tree__node, .c-tree__leaf");if(!node||!dragLabel)return;e.preventDefault();const toLabel=(node.textContent||"").trim().slice(0,120);if(toLabel&&toLabel!==dragLabel){wcEmit(host,"contour:move",{from:dragLabel,to:toLabel})}dragLabel=null});const persist=host.getAttribute("persist");if(persist==="storage"&&host.id){try{const saved=localStorage.getItem("contour-tree:"+host.id);if(saved!==null){const labels=JSON.parse(saved);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));wcAll(host,".c-tree__row").forEach((row)=>{const currentToggle=row.querySelector(":scope > .c-tree__toggle");if(currentToggle?.getAttribute("aria-expanded")==="true")return;const label=(row.textContent||"").trim().slice(0,120);if(!want.has(label))return;const toggle=row.querySelector(":scope > .c-tree__toggle");if(!toggle)return;const node=row.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;toggle.setAttribute("aria-expanded","true");if(node)node.setAttribute("aria-expanded","true");if(children)children.removeAttribute("hidden")})}}}catch(e){}}else if(persist==="url"){try{const v=new URLSearchParams(window.location.search).get("c-tree");if(v!==null){const labels=JSON.parse(v);if(Array.isArray(labels)){const want=new Set(labels.map((l)=>String(l)));wcAll(host,".c-tree__row").forEach((row)=>{const currentToggle=row.querySelector(":scope > .c-tree__toggle");if(currentToggle?.getAttribute("aria-expanded")==="true")return;const label=(row.textContent||"").trim().slice(0,120);if(!want.has(label))return;const toggle=row.querySelector(":scope > .c-tree__toggle");if(!toggle)return;const node=row.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;toggle.setAttribute("aria-expanded","true");if(node)node.setAttribute("aria-expanded","true");if(children)children.removeAttribute("hidden")})}}}catch(e){}}const toggleNode=(toggle)=>{const wasOpen=toggle.getAttribute("aria-expanded")==="true";toggle.setAttribute("aria-expanded",String(!wasOpen));const row=toggle.closest(".c-tree__row")||toggle.parentElement;const node=toggle.closest(".c-tree__node");const children=node?node.querySelector(":scope > .c-tree__children"):null;if(children){if(wasOpen){if(supportsUntilFound())children.setAttribute("hidden","until-found");else children.hidden=true}else{children.removeAttribute("hidden")}}if(node)node.setAttribute("aria-expanded",String(!wasOpen));wcEmit(host,"contour:toggle",{open:!wasOpen,label:(row?row.textContent:"").trim().slice(0,120)});if(persist==="storage"&&host.id){try{const open=[];wcAll(host,".c-tree__row").forEach((r)=>{const toggle=r.querySelector(":scope > .c-tree__toggle");if(toggle?.getAttribute("aria-expanded")==="true")open.push((r.textContent||"").trim().slice(0,120))});localStorage.setItem("contour-tree:"+host.id,JSON.stringify(open))}catch(e){}}else if(persist==="url"){try{const open=[];wcAll(host,".c-tree__row").forEach((r)=>{const toggle=r.querySelector(":scope > .c-tree__toggle");if(toggle?.getAttribute("aria-expanded")==="true")open.push((r.textContent||"").trim().slice(0,120))});const url=new URL(window.location.href);url.searchParams.set("c-tree",JSON.stringify(open));window.history.replaceState(null,"",url.toString())}catch(e){}}};const branchOf=(el)=>(el.classList&&el.classList.contains("c-tree__toggle")?el:null);const stopsOf=()=>visibleStops(host);const rove=(keep)=>{wcAll(host,".c-tree__toggle, .c-tree__leaf").forEach((el)=>el.setAttribute("tabindex",el===keep?"0":"-1"))};wcListen(host,"click",(e)=>{let toggle=wcClosest(host,e.target,".c-tree__toggle");if(!toggle){const row=wcClosest(host,e.target,".c-tree__row");if(row)toggle=row.querySelector(":scope > .c-tree__toggle")}if(!toggle)return;e.preventDefault();e.stopPropagation();toggleNode(toggle)});wcListen(host,"focusin",(e)=>{if(!wcClosest(host,e.target,".c-tree__toggle, .c-tree__leaf"))return;rove(e.target)});wcListen(host,"keydown",(e)=>{const toggle=wcClosest(host,e.target,".c-tree__toggle, .c-tree__leaf");if(!toggle)return;const items=stopsOf();const idx=items.indexOf(toggle);if(e.key==="Enter"||e.key===" "){if(branchOf(toggle)){e.preventDefault();toggleNode(toggle)}return}if(e.key==="ArrowRight"){const branch=branchOf(toggle);const closed=branch&&branch.getAttribute("aria-expanded")==="false";e.preventDefault();if(closed){toggleNode(branch);rove(toggle)}else{const next=items[idx+1];if(next){next.focus();rove(next)}}return}if(e.key==="ArrowLeft"){const branch=branchOf(toggle);if(branch&&branch.getAttribute("aria-expanded")==="true"){e.preventDefault();toggleNode(branch);rove(toggle)}else{const parent=toggle.closest(".c-tree__children");const owner=parent?parent.closest(".c-tree__node"):null;const up=owner?owner.querySelector(":scope > .c-tree__row > .c-tree__toggle"):null;if(up){e.preventDefault();up.focus();rove(up)}}return}navKey(e,items,{wrap:false,homeEnd:true,onNavigate:(i)=>rove(items[i])})})}export function wireMenu(host){wcAll(host,"[role='menuitem']").forEach((it)=>{if(!it.hasAttribute("tabindex"))it.setAttribute("tabindex",it.getAttribute("aria-disabled")==="true"?"-1":"-1")});const all=()=>wcAll(host,"[role='menuitem']");if(!all().some((it)=>it.getAttribute("tabindex")==="0")&&all().length){const first=all().find((it)=>it.getAttribute("aria-disabled")!=="true");if(first)first.setAttribute("tabindex","0")}if(!wcClaim(host,"menu"))return;const submenusOf=(item)=>item.querySelector(":scope > ul.c-menu, :scope > .c-menu");const closeAllSubmenus=()=>{wcAll(host,"[aria-haspopup='menu']").forEach((it)=>it.setAttribute("aria-expanded","false"))};wcListen(host,"keydown",(e)=>{const its=all().filter((it)=>it.getAttribute("aria-disabled")!=="true");if(!its.length)return;const index=its.indexOf(e.target);const target=index>=0?its[index]:null;const sub=target?submenusOf(target):null;if(target&&target.getAttribute("aria-haspopup")==="menu"&&(e.key==="ArrowRight"||e.key==="Enter"||e.key===" ")){if(sub){e.preventDefault();closeAllSubmenus();target.setAttribute("aria-expanded","true");const firstSub=sub.querySelector("[role='menuitem']");if(firstSub){firstSub.setAttribute("tabindex","0");try{firstSub.focus()}catch(err){}}return}}if(e.key==="ArrowLeft"||e.key==="Escape"){const parent=target?target.closest("ul.c-menu"):null;let ancestor=null;if(target){const ul=target.parentElement&&target.parentElement.tagName==="UL"?target.parentElement:null;let node=target.parentElement;while(node&&node!==host){if(node.getAttribute&&node.getAttribute("aria-haspopup")==="menu"&&node.contains(target)&&node!==target){ancestor=node;break}node=node.parentElement}}if(ancestor){e.preventDefault();ancestor.setAttribute("aria-expanded","false");try{ancestor.focus()}catch(err){}return}if(e.key==="Escape"){closeAllSubmenus()}}navKey(e,its,{wrap:true,homeEnd:true,onKey:()=>{if(e.key==="Enter"||e.key===" "){const idx=its.indexOf(document.activeElement);if(idx>=0&&!(target&&target.getAttribute("aria-haspopup")==="menu")){wcEmit(host,"contour:select",{index:idx,label:its[idx].textContent.trim()});closeAllSubmenus()}}}});if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const ch=e.key.toLowerCase();const match=its.findIndex((it)=>(it.textContent||"").trim().toLowerCase().startsWith(ch));if(match>=0){e.preventDefault();its[match].focus()}}});wcListen(host,"click",(e)=>{const item=wcClosest(host,e.target,"[role='menuitem']");if(!item)return;if(item.getAttribute("aria-disabled")==="true")return;if(item.getAttribute("aria-haspopup")==="menu"){const sub=submenusOf(item);if(sub){const open=item.getAttribute("aria-expanded")==="true";closeAllSubmenus();item.setAttribute("aria-expanded",open?"false":"true");return}}const index=all().indexOf(item);if(index>=0){wcEmit(host,"contour:select",{index,label:item.textContent.trim()});closeAllSubmenus();if(typeof host.hidePopover==="function"){try{host.hidePopover()}catch(e){}}}})}export function wirePagination(host){wcAll(host,".c-pagination__link").forEach((b)=>{if(!b.hasAttribute("tabindex"))b.setAttribute("tabindex","0")});if(!wcClaim(host,"pagination"))return;const activate=(btn)=>{const page=parseInt(btn.textContent,10);if(!Number.isFinite(page))return;wcAll(host,".c-pagination__link").forEach((b)=>{if(parseInt(b.textContent,10)===page)b.setAttribute("aria-current","page");else b.removeAttribute("aria-current")});host.setAttribute("page",String(page));wcEmit(host,"contour:page",{page});if(host.getAttribute("persist")==="storage"&&host.id){try{localStorage.setItem("contour-pagination:"+host.id,String(page))}catch(e){}}else if(host.getAttribute("persist")==="url"){try{const url=new URL(window.location.href);url.searchParams.set("c-pagination",String(page));window.history.replaceState(null,"",url.toString())}catch(e){}}};wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,".c-pagination__link");if(!btn)return;e.preventDefault();const action=btn.getAttribute("data-action");if(action==="prev"||action==="next"){const links=wcAll(host,".c-pagination__link").filter((b)=>!b.getAttribute("data-action"));const cur=links.find((b)=>b.getAttribute("aria-current")==="page");const curPage=cur?(parseInt(cur.textContent,10)||1):1;const page=action==="prev"?Math.max(1,curPage-1):Math.min(links.length,curPage+1);const target=links.find((b)=>parseInt(b.textContent,10)===page);if(target){activate(target);return}}activate(btn)});wcListen(host,"keydown",(e)=>{const btn=wcClosest(host,e.target,".c-pagination__link");if(!btn)return;const links=wcAll(host,".c-pagination__link");const idx=links.indexOf(btn);let next=-1;const rtl=isRtl(host);if(e.key==="ArrowRight")next=rtl?Math.max(idx-1,0):Math.min(idx+1,links.length-1);else if(e.key==="ArrowLeft")next=rtl?Math.min(idx+1,links.length-1):Math.max(idx-1,0);else if(e.key==="Home")next=0;else if(e.key==="End")next=links.length-1;else if(e.key==="Enter"||e.key===" "){e.preventDefault();activate(btn);return}if(next>=0&&next!==idx){e.preventDefault();links[next].focus()}})}export function wireCopy(host){if(!wcClaim(host,"copy"))return;wcListen(host,"click",(e)=>{const btn=wcClosest(host,e.target,".c-code__copy, .c-install__copy");if(!btn)return;const owner=wcClosest(host,btn,".c-code")||wcClosest(host,btn,".c-install")||host;const src=owner.querySelector("code, .c-install__command");const readSource=(el)=>{const lines=el&&el.querySelectorAll?el.querySelectorAll(".c-code__line"):null;if(!lines||!lines.length)return el?el.textContent||"":"";return Array.from(lines).map((l)=>Array.from(l.childNodes).filter((n)=>!(n.classList&&n.classList.contains("c-code__line-number"))).map((n)=>n.textContent).join("")).join("\n")};const text=readSource(src)||(src?"":owner.textContent)||"";const confirm=(ok)=>{const icon=btn.querySelector("use");const originalHref=icon&&icon.getAttribute("href");const originalLabel=btn.getAttribute("aria-label")||btn.title||"";if(ok&&icon)icon.setAttribute("href","#i-check");btn.setAttribute("aria-label",ok?"Copied":"Copy failed");btn.dataset.copied=String(ok);const timer=setTimeout(()=>{if(!btn.isConnected)return;if(icon&&originalHref)icon.setAttribute("href",originalHref);btn.setAttribute("aria-label",originalLabel);delete btn.dataset.copied},1600);onDispose(host,()=>clearTimeout(timer))};const doCopy=async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText){await navigator.clipboard.writeText(text);return true}}catch(e){}try{const ta=document.createElement("textarea");ta.value=text;ta.setAttribute("readonly","");ta.style.position="fixed";ta.style.top="-9999px";ta.style.opacity="0";document.body.append(ta);ta.select();const ok=document.execCommand("copy");ta.remove();return ok}catch(e){return false}};doCopy().then((ok)=>confirm(ok));wcEmit(host,"contour:copy",{text})})}export function wireRemovable(host){if(!wcClaim(host,"removable"))return;wcListen(host,"click",(e)=>{const drop=(node)=>{if(node&&node.parentNode)node.parentNode.removeChild(node)};const tagBtn=wcClosest(host,e.target,".c-tag__remove");if(tagBtn){e.preventDefault();const tag=wcClosest(host,tagBtn,".c-tag");wcEmit(host,"contour:remove",{label:(tag&&tag.getAttribute("label"))||(tag?tag.textContent.trim():"")});drop(tag);return}const pillBtn=wcClosest(host,e.target,".c-filter-pill__remove");if(pillBtn){e.preventDefault();const pill=wcClosest(host,pillBtn,".c-filter-pill");wcEmit(host,"contour:remove",{key:pill&&pill.getAttribute("key"),value:pill&&pill.getAttribute("value")});drop(pill);return}if(wcClosest(host,e.target,"[data-empty-action]")){wcEmit(host,"contour:empty-action",{state:host.getAttribute("state")||"empty"})}const alertClose=wcClosest(host,e.target,".c-alert__close");if(alertClose){e.preventDefault();wcEmit(host,"contour:close",{});if(host.shadowRoot?host.shadowRoot.contains(alertClose):true){try{host.remove()}catch(err){}}return}const calloutClose=wcClosest(host,e.target,".c-callout__close");if(calloutClose){e.preventDefault();wcEmit(host,"contour:close",{});try{host.remove()}catch(err){}return}})}const modalDepth={n:0};let modalSavedOverflow=null;let modalSavedX=0;let modalSavedY=0;const modalInerted=new Set();const modalStack=[];let modalTrapWired=false;function modalFocusables(host){return Array.from(host.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter((el)=>!el.hasAttribute("disabled")&&el.getAttribute("aria-hidden")!=="true")}function modalTrapHandler(e){if(e.key!=="Tab")return;const host=modalStack[modalStack.length-1];if(!host)return;const f=modalFocusables(host);if(!f.length){e.preventDefault();return}const first=f[0];const last=f[f.length-1];const active=document.activeElement;if(e.shiftKey){if(active===first||!host.contains(active)){e.preventDefault();last.focus()}}else{if(active===last){e.preventDefault();first.focus()}}}export function modalContain(host,open){if(open){if(modalDepth.n===0){modalSavedX=window.scrollX;modalSavedY=window.scrollY;modalSavedOverflow=document.documentElement.style.overflow;document.documentElement.style.overflow="hidden"}modalDepth.n+=1;modalStack.push(host);if(modalDepth.n===1&&!modalTrapWired){modalTrapWired=true;document.addEventListener("keydown",modalTrapHandler)}for(let el=host;el&&el!==document.body;el=el.parentElement){for(const sib of el.parentElement.children){if(sib===el||sib.inert||modalInerted.has(sib))continue;sib.inert=true;modalInerted.add(sib)}}}else{const idx=modalStack.lastIndexOf(host);if(idx>=0)modalStack.splice(idx,1);modalDepth.n=Math.max(0,modalDepth.n-1);if(modalDepth.n===0){for(const el of modalInerted)el.inert=false;modalInerted.clear();document.documentElement.style.overflow=modalSavedOverflow||"";window.scrollTo(modalSavedX,modalSavedY);if(modalTrapWired){document.removeEventListener("keydown",modalTrapHandler);modalTrapWired=false}}}}export const STATE_FALLBACK={empty:"No data",loading:"Loading…",error:"Could not load.",};export function stateLabel(host,key){const fallback=STATE_FALLBACK[key]||key;const raw=host&&host.getAttribute?host.getAttribute("labels"):null;if(!raw)return fallback;try{const parsed=JSON.parse(raw);if(parsed&&typeof parsed==="object"&&typeof parsed[key]==="string"&&parsed[key])return parsed[key]}catch(e){}return fallback}const remoteInflight=new Map();const REMOTE_CACHE_MAX=64;const remoteCache=new Map();function cacheResult(src,data){if(remoteCache.size>=REMOTE_CACHE_MAX)remoteCache.delete(remoteCache.keys().next().value);remoteCache.set(src,data)}function setStatus(host,status){host._remoteStatus=status;if(status!=="error")host._remoteError=null;if(status==="loading")host.setAttribute("aria-busy","true");else host.removeAttribute("aria-busy");if(typeof host._setCustomState==="function")host._setCustomState("data-loading",status==="loading")}function emitState(host,name,detail){host.dispatchEvent(new CustomEvent(name,{detail,bubbles:true,composed:true}))}function countOf(data){if(Array.isArray(data))return data.length;if(data&&typeof data==="object")return Object.keys(data).length;return data===null||data===undefined?0:1}function leaveRequest(host){const entry=host._remoteEntry;host._remoteEntry=null;if(!entry)return;entry.hosts.delete(host);if(entry.hosts.size===0&&entry.controller)entry.controller.abort()}export function loadRemote(host,fields){const src=host.getAttribute("src");if(!src){leaveRequest(host);setStatus(host,host._remoteData!==undefined?"ready":"idle");return}remoteRefresh(host);const wanted=typeof fields==="string"?[fields]:fields;if(wanted.every((f)=>host.getAttribute(f)!==null)){leaveRequest(host);setStatus(host,"ready");return}if(!remoteVisible(host)){setStatus(host,"loading");return}const noCache=host.hasAttribute("no-cache");const cacheKey=host.getAttribute("cache-key")||src;if(noCache){if(host._remoteSrc===src&&host._remoteData!==undefined){setStatus(host,"ready");return}}else{const cached=remoteCache.get(cacheKey);if(cached!==undefined){host._remoteSrc=src;host._remoteData=cached;setStatus(host,"ready");return}}if(host._remoteSrc===src&&(host._remoteStatus==="loading"||host._remoteStatus==="error"))return;leaveRequest(host);host._remoteSrc=src;setStatus(host,"loading");let entry=remoteInflight.get(src);if(!entry){entry={hosts:new Set(),controller:new AbortController(),cacheKey};remoteInflight.set(src,entry);entry.promise=startFetch(host,src,entry).then((data)=>{if(remoteInflight.get(src)===entry)remoteInflight.delete(src);cacheResult(src,data);const namedKey=entry.cacheKey;if(namedKey&&namedKey!==src)cacheResult(namedKey,data);for(const h of entry.hosts){h._remoteData=data;h._remoteEntry=null;setStatus(h,"ready");emitState(h,"contour:load",{src,count:countOf(data)})}},(err)=>{if(remoteInflight.get(src)===entry)remoteInflight.delete(src);for(const h of entry.hosts){h._remoteEntry=null;setStatus(h,"error");h._remoteError=err&&err.name==="HttpError"?`Could not load (${err.status})`:STATE_FALLBACK.error;emitState(h,"contour:error",{src,message:h._remoteError,name:err&&err.name,status:err&&err.status,})}}).finally(()=>{for(const h of entry.hosts)if(h.isConnected)h.requestRender();entry.hosts.clear()})}entry.hosts.add(host);host._remoteEntry=entry;if(!host._remoteDisposeRegistered){host._remoteDisposeRegistered=true;onDispose(host,()=>{host._remoteDisposeRegistered=false;leaveRequest(host)})}}export function remoteInvalidate(srcOrKey){remoteCache.delete(srcOrKey)}function startFetch(host,src,entry){const ms=parseInt(host.getAttribute("timeout")||"",10);let timer=null;let signal=entry.controller.signal;if(Number.isFinite(ms)&&ms>0){if(typeof AbortSignal!=="undefined"&&AbortSignal.timeout){signal=AbortSignal.any([signal,AbortSignal.timeout(ms)])}else{timer=setTimeout(()=>entry.controller.abort(),ms)}}onDispose(host,()=>{if(timer)clearTimeout(timer)});return fetch(src,{signal}).then((res)=>{if(timer)clearTimeout(timer);if(!res.ok){const e=new Error(`Could not load (${res.status})`);e.name="HttpError";e.status=res.status;throw e}return res.text()}).then((text)=>{try{return JSON.parse(text)}catch(err){const e=new Error(STATE_FALLBACK.error);e.name="ParseError";e.cause=err;throw e}})}export function remoteData(host,field){const authored=host.getAttribute(field);if(authored!==null)return authored;const data=host._remoteData;if(data===undefined||data===null)return null;if(Array.isArray(data))return JSON.stringify(data);if(typeof data==="object"){const keys=typeof field==="string"?[field]:field;for(const k of keys){if(data[k]===undefined)continue;return typeof data[k]==="string"?data[k]:JSON.stringify(data[k])}return null}return String(data)}export function remoteRefresh(host){const seconds=parseFloat(host.getAttribute("refresh")||"");const want=host.hasAttribute("src")&&Number.isFinite(seconds)&&seconds>0;if(!want){if(host._remoteTimer!==undefined){clearTimeout(host._remoteTimer);host._remoteTimer=undefined}host._remoteLoop=false;return}if(host._remoteLoop)return;host._remoteLoop=true;const tick=()=>{host._remoteTimer=undefined;if(!host.isConnected||!host.hasAttribute("refresh")){host._remoteLoop=false;return}if(document.hidden){host._remoteTimer=setTimeout(tick,1000);return}const src=host.getAttribute("src");const namedKey=host.getAttribute("cache-key");if(namedKey)remoteCache.delete(namedKey);remoteCache.delete(src);host._remoteSrc=null;host._remoteLoop=false;host.requestRender()};host._remoteTimer=setTimeout(tick,Math.max(1000,seconds*1000));onDispose(host,()=>{clearTimeout(host._remoteTimer);host._remoteTimer=undefined;host._remoteLoop=false})}let _sharedLazyIO=null;const _sharedLazyTargets=new Map();export function remoteVisible(host){if(!host.hasAttribute("lazy"))return true;if(typeof IntersectionObserver!=="function")return true;if(host._remoteVisible)return true;if(host._lazyRegistered)return false;if(!_sharedLazyIO){_sharedLazyIO=new IntersectionObserver((records)=>{for(const r of records){const activate=_sharedLazyTargets.get(r.target);if(!activate||!r.isIntersecting)continue;_sharedLazyTargets.delete(r.target);_sharedLazyIO.unobserve(r.target);activate()}},{rootMargin:"200px"})}const activate=()=>{host._remoteVisible=true;host._lazyRegistered=false;host.requestRender()};host._lazyRegistered=true;_sharedLazyTargets.set(host,activate);_sharedLazyIO.observe(host);onDispose(host,()=>{_sharedLazyIO.unobserve(host);_sharedLazyTargets.delete(host);host._lazyRegistered=false});return false}export function watchViewport(host){if(host._contourViewWired)return()=>{};host._contourViewWired=true;const emit=(type)=>host.dispatchEvent(new CustomEvent(type,{bubbles:true,composed:true}));if(typeof IntersectionObserver!=="function"){emit("contour:view-enter");return()=>{}}const io=new IntersectionObserver((records)=>{for(const r of records){if(r.isIntersecting)emit("contour:view-enter");else emit("contour:view-leave")}});io.observe(host);onDispose(host,()=>io.disconnect());return()=>io.disconnect()}function stateNode(block,kind,text){const node=document.createElement("div");node.className="c-"+block+"__"+kind;node.dataset.contourState=kind;node.textContent=text;return node}function skeletonRow(i,total){const node=document.createElement("div");node.className="c-skeleton "+(i===0&&total>1?"c-skeleton--title":"c-skeleton--text");node.dataset.contourState="skeleton";return node}export function renderStates(host,block,opts){const options=opts||{};const loading=host.getAttribute("loading");if(loading!==null||host._remoteStatus==="loading"){host.appendChild(stateNode(block,"loading",loading||stateLabel(host,"loading")));return true}const error=host.getAttribute("error");if(error!==null||host._remoteStatus==="error"){const message=(error!==null&&error!=="")?error:(host._remoteError||stateLabel(host,"error"));const node=stateNode(block,"error",message);if(host.hasAttribute("retry")){const btn=document.createElement("button");btn.type="button";btn.className="c-btn c-btn--ghost c-btn--sm";btn.textContent=host.getAttribute("retry")||"Retry";btn.dataset.action="retry";node.appendChild(btn)}host.appendChild(node);return true}if(host.hasAttribute("skeleton")){const asked=parseInt(host.getAttribute("skeleton")||"3",10);const count=Math.min(options.max||6,Math.max(1,Number.isFinite(asked)?asked:3));for(let i=0;i<count;i++)host.appendChild(skeletonRow(i,count));return true}return false}export function renderEmpty(host,block){host.appendChild(stateNode(block,"empty",host.getAttribute("empty")||stateLabel(host,"empty")))}export function wireStates(host){if(host._contourStatesWired)return;host._contourStatesWired=true;host.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest('[data-action="retry"]'):null;if(!btn||!host.contains(btn))return;e.preventDefault();const src=host.getAttribute("src");const namedKey=host.getAttribute("cache-key");if(namedKey)remoteCache.delete(namedKey);if(src)remoteCache.delete(src);leaveRequest(host);host._remoteSrc=null;host._remoteData=undefined;setStatus(host,"idle");emitState(host,"contour:retry",{src});host.requestRender()})}define("contour-box",simple(["c-box"]));define("contour-cluster",simple(["c-cluster"]));define("contour-container",simple(["c-container"]));define("contour-row",simple(["c-row"]));define("contour-scrim",simple(["c-scrim"]));define("contour-stack",simple(["c-stack"]));let ADOPTED=null;let ADOPTED_KEY="";const adoptedSheets=()=>{let key=document.styleSheets.length+":";for(const sheet of document.styleSheets){let rules=-1;try{rules=sheet.cssRules.length}catch(e){}key+=(sheet.href||"")+"~"+rules+"|"}if(ADOPTED&&key===ADOPTED_KEY)return ADOPTED;ADOPTED_KEY=key;ADOPTED=[];const collect=(sheet,out)=>{let rules;try{rules=sheet.cssRules}catch(e){return}if(!rules)return;for(const r of rules){if(r instanceof CSSImportRule){if(r.styleSheet)collect(r.styleSheet,out)}else{try{out.push(r.cssText)}catch(e){}}}};for(const sheet of document.styleSheets){try{if(sheet.href&&new URL(sheet.href).origin===location.origin){const collected=[];collect(sheet,collected);const built=new CSSStyleSheet();if(collected.length)built.replaceSync(collected.join("\n"));ADOPTED.push(built)}}catch(e){}}return ADOPTED};const _ShadowParent=(typeof HTMLElement!=="undefined")?HTMLElement:Object;class ContourShadow extends _ShadowParent{static get observedAttributes(){return MODS}constructor(){super();let root=this.shadowRoot;if(!root){root=this.attachShadow({mode:"open"});if(this.constructor.contourTemplate){root.appendChild(this.constructor.contourTemplate.content.cloneNode(true))}}const sheets=adoptedSheets();if(sheets.length){try{root.adoptedStyleSheets=sheets}catch(e){}}this._shadowBase=root.firstElementChild?root.firstElementChild.className:""}enhance(root){if(!root)root=this.shadowRoot;if(!root)return;root.querySelectorAll("details").forEach((d)=>{const summary=d.querySelector("summary");if(summary&&!summary.hasAttribute("aria-expanded")){summary.setAttribute("aria-expanded",String(d.open));d.addEventListener("toggle",()=>{summary.setAttribute("aria-expanded",String(d.open))})}});root.querySelectorAll("[data-live]").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite")});root.querySelectorAll(".c-spinner").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite")});root.querySelectorAll(".c-toast, .c-toast-host").forEach((el)=>{if(!el.hasAttribute("role"))el.setAttribute("role","status");if(!el.hasAttribute("aria-live"))el.setAttribute("aria-live","polite");if(!el.hasAttribute("aria-atomic"))el.setAttribute("aria-atomic","true")});root.querySelectorAll("[role='tab']").forEach((tab)=>{const ctrl=tab.getAttribute("aria-controls");if(ctrl){const panel=root.querySelector("#"+CSS.escape(ctrl))||document.getElementById(ctrl);if(panel&&!panel.hasAttribute("aria-labelledby")){if(!tab.id)tab.id=contourId("tab");panel.setAttribute("aria-labelledby",tab.id)}}});root.querySelectorAll("input, textarea, select").forEach((input)=>{if(input.hasAttribute("aria-describedby"))return;const field=input.closest(".c-field");if(field){const hint=field.querySelector(".c-field__hint");if(hint){if(!hint.id)hint.id=contourId("hint");input.setAttribute("aria-describedby",hint.id)}const err=field.querySelector(".c-field__error");if(err){if(!err.id)err.id=contourId("err");const existing=input.getAttribute("aria-describedby")||"";input.setAttribute("aria-describedby",(existing+" "+err.id).trim())}}});root.querySelectorAll(".c-alert").forEach((el)=>{const urgent=el.classList.contains("c-alert--warning")||el.classList.contains("c-alert--danger");const role=urgent?"alert":"status";const live=urgent?"assertive":"polite";if(!el.hasAttribute("role")||el.dataset.contourAutoRole){el.setAttribute("role",role);el.dataset.contourAutoRole=role}if(!el.hasAttribute("aria-live")||el.dataset.contourAutoLive){el.setAttribute("aria-live",live);el.dataset.contourAutoLive=live}});root.querySelectorAll("input[required], textarea[required], select[required]").forEach((el)=>{if(!el.hasAttribute("aria-required"))el.setAttribute("aria-required","true")})}connectedCallback(){this.applyMods();try{this.enhance(this.shadowRoot)}catch(e){}try{wcReset(this);wireTabs(this);wireSegmented(this);wireCombobox(this);wireTree(this);wireMenu(this);wirePagination(this);wireCopy(this);wireRemovable(this)}catch(e){}if(this.shadowRoot&&!this._wiredSlotchange){this._wiredSlotchange=true;this.shadowRoot.addEventListener("slotchange",()=>{try{this.enhance(this.shadowRoot);wireTabs(this);wireSegmented(this);wireCombobox(this);wireTree(this);wireMenu(this);wirePagination(this);wireCopy(this);wireRemovable(this)}catch(e){}})}}attributeChangedCallback(){this.applyMods()}applyMods(){const el=this.shadowRoot.firstElementChild;if(!el||!this._shadowBase)return;const mods=[];for(const attr of MODS){const val=this.getAttribute(attr);if(!val)continue;for(const cls of this._shadowBase.split(/\s+/)){if(cls)mods.push("c-"+cls.replace(/^c-/,"")+"--"+val)}}el.className=(this._shadowBase+" "+mods.join(" ")).trim();if(el.classList.contains("c-alert")){const urgent=el.classList.contains("c-alert--warning")||el.classList.contains("c-alert--danger");const role=urgent?"alert":"status";const live=urgent?"assertive":"polite";if(!el.hasAttribute("role")||el.dataset.contourAutoRole){el.setAttribute("role",role);el.dataset.contourAutoRole=role}if(!el.hasAttribute("aria-live")||el.dataset.contourAutoLive){el.setAttribute("aria-live",live);el.dataset.contourAutoLive=live}}}}const SHADOW_PARTS_PUBLIC={};const SHADOW_MARKUP={};const recordParts=(name,markup)=>{SHADOW_PARTS_PUBLIC[name]=[...markup.matchAll(/part="([^"]+)"/g)].flatMap((m)=>m[1].split(/\s+/)).filter(Boolean)};const shadow=(name,markup)=>{SHADOW_MARKUP[name]=markup;recordParts(name,markup);if(typeof document==="undefined")return;const tpl=document.createElement("template");tpl.innerHTML=markup;const cls=class extends ContourShadow{};cls.contourTemplate=tpl;define(name,cls)};const slotWrapper=(tag,block,part)=>"<"+tag+' class="c-'+block+'" part="'+(part||block)+'"'+(tag==="button"?' type="button"':"")+"><slot></slot></"+tag+">";const SHADOW_SLOTS={div:["accordion","activity","advanced","affordance","affordances","anchor","app","app-body","box","btn-group","chart-grid","catchment","cluster","command","compare","comparison","compass","contour-plot","cta","dash-freshness","dash-kpi-row","dash-shell","dash-toolbar","datamark","delta","draggable","drag-handle","drop-indicator","drop-zone","destructive-hint","docs-shell","drawer","elevation","filter-bar","flow-map","heatmap","hexbin","icon-badge","input-group","instrument","range-scale","resizable","table-wrap","time-range","toast-host","scroll-area","isochrone","landing-features","landing-hero","layer-panel","layer-switch","legend","logos","map-area","map-footer","map-panel","map-slot","measure","metrics","minimap","pager","pagination","panel","plate","price","pricing","progress","prose","pullquote","radio-list","range","readout","recipe","reserved","resize-handle","row","row-action","scale-bar","scrim","segmented","sheet","shortcut-list","shortcut-overlay","shortcut-panel","shortcut-row","showcase","sidebar","skeleton","sparkline","stack","steps","streaming-chart","survey","theme-scope","time-slider","timeline","toast","toolbar","tooltip","tree","version","version-banner"],button:["btn","pressable","scheme-toggle"],span:["avatar","badge","chip","dot","flag","live-badge","mark","pill"],a:["link","linkish"],kbd:["kbd"],label:["check","radio","switch"],select:["select"],nav:["docs-nav"],};const SHADOW_PARTS={"version-banner":"banner","contour-plot":"plot",};for(const[tag,blocks]of Object.entries(SHADOW_SLOTS)){for(const block of blocks){const part=SHADOW_PARTS[block]||block;shadow("contour-shadow-"+block,slotWrapper(tag,block,part))}}shadow("contour-shadow-callout",`<div class="c-callout" part="callout"><div class="c-callout__title" part="title"><slot name="title"></slot></div><div class="c-callout__body" part="body"><slot></slot></div><button class="c-callout__close" part="close" type="button" aria-label="Close">×</button></div>`);shadow("contour-shadow-empty",`<div class="c-empty" part="empty"><div class="c-empty__illustration" part="illustration"><slot name="illustration"></slot></div><div class="c-empty__title" part="title"><slot name="title"></slot></div><div class="c-empty__text" part="body"><slot></slot></div><div><slot name="action"></slot></div></div>`);shadow("contour-shadow-feature",`<div class="c-feature" part="feature"><span class="c-feature__index" part="index"><slot name="index"></slot></span><div class="c-feature__title" part="title"><slot name="title"></slot></div><div class="c-feature__body" part="body"><slot></slot></div></div>`);shadow("contour-shadow-kpi",`<div class="c-kpi" part="kpi"><div class="c-kpi__value" part="value"><slot name="value"></slot></div><div class="c-kpi__label" part="label"><slot name="label"></slot></div><div class="c-kpi__foot" part="foot"><slot name="delta"></slot><slot name="note"></slot></div></div>`);shadow("contour-shadow-stat",`<div class="c-stat" part="stat"><div class="c-stat__value" part="value"><slot name="value"></slot></div><div class="c-stat__label" part="label"><slot name="label"></slot></div><div class="c-stat__delta" part="delta"><slot name="delta"></slot></div></div>`);shadow("contour-shadow-meter",`<div class="c-meter" part="meter"><span class="c-meter__core" part="core"><span class="c-meter__value" part="value"><slot name="value"></slot></span><span class="c-meter__label" part="label"><slot name="label"></slot></span></span></div>`);shadow("contour-shadow-brownout",`<div class="c-brownout" part="brownout" data-level="0"><slot></slot></div>`);shadow("contour-shadow-widget-state",`<div class="c-widget-state" part="widget-state"><slot></slot></div>`);shadow("contour-shadow-donut",`<div class="c-donut" part="donut"><svg class="c-donut__ring" part="ring" viewBox="0 0 32 32"></svg><div class="c-donut__center" part="center"><slot name="value"></slot></div><div class="c-donut__list" part="list"><slot></slot></div></div>`);shadow("contour-shadow-axis",`<div class="c-axis" part="axis"><slot></slot></div>`);shadow("contour-shadow-brush",`<div class="c-brush" part="brush"><div class="c-brush__selection" part="selection"></div></div>`);shadow("contour-shadow-stacked-bar",`<div class="c-stacked-bar" part="bar"><slot></slot></div>`);shadow("contour-shadow-category",`<div class="c-category" part="category" role="listbox"><slot></slot></div>`);shadow("contour-shadow-gauge",`<div class="c-gauge" part="gauge"><svg class="c-gauge__dial" part="dial" aria-hidden="true" viewBox="0 0 100 100"><path class="c-gauge__track" part="track" d="M 10 90 A 40 40 0 0 1 90 90"></path><g class="c-gauge__zones"></g><line class="c-gauge__needle" part="needle" x1="50" y1="50" x2="50" y2="15"></line><circle class="c-gauge__hub" part="hub" cx="50" cy="50" r="4"></circle></svg><div class="c-gauge__value" part="value"><slot name="value"></slot></div><div class="c-gauge__band" part="band"><slot name="band"></slot></div></div>`);shadow("contour-shadow-diff",`<div class="c-diff" part="diff"><div class="c-diff__line c-diff__line--del" part="before"><span class="c-diff__sign">−</span><span><slot name="before"></slot></span></div><div class="c-diff__line c-diff__line--add" part="after"><span class="c-diff__sign">+</span><span><slot name="after"></slot></span></div></div>`);shadow("contour-shadow-do-dont",`<div class="c-do-dont" part="do-dont"><div class="c-do-dont__item c-do-dont__item--do" part="do"><slot name="do"></slot></div><div class="c-do-dont__item c-do-dont__item--dont" part="dont"><slot name="dont"></slot></div></div>`);shadow("contour-shadow-threshold",`<div class="c-threshold" part="threshold"><span class="c-threshold__fill" part="value"></span><span class="c-threshold__target" part="target"></span></div>`);shadow("contour-shadow-coordinate",`<div class="c-coordinate" part="coordinate"><span class="c-coordinate__value" part="value"><slot name="value"></slot></span></div>`);shadow("contour-shadow-install",`<div class="c-install" part="install"><span class="c-install__prompt" part="prompt"><slot name="prompt"></slot></span><span class="c-install__command" part="command"><slot name="command"></slot></span><button class="c-btn c-btn--ghost c-btn--sm c-install__copy" part="copy" type="button" aria-label="Copy command">Copy</button></div>`);shadow("contour-shadow-toc",`<div class="c-toc" part="toc"><div class="c-toc__title" part="title"><slot name="title"></slot></div><nav class="c-toc__list" part="list"><slot></slot></nav></div>`);shadow("contour-shadow-testimonial",`<div class="c-testimonial" part="testimonial"><blockquote class="c-testimonial__quote" part="quote"><slot name="quote"></slot></blockquote><div class="c-testimonial__byline" part="byline"><span class="c-testimonial__name" part="name"><slot name="name"></slot></span><span class="c-testimonial__role" part="role"><slot name="role"></slot></span></div></div>`);shadow("contour-shadow-search-trigger",`<button class="c-search-trigger" part="trigger"><span><slot name="label"></slot></span><kbd class="c-search-trigger__kbd"><slot name="shortcut"></slot></kbd></button>`);shadow("contour-shadow-brand",`<a class="c-brand" part="brand"><span class="c-mark" part="mark"><slot name="mark"></slot></span><span class="c-brand__name" part="name"><slot name="name"></slot></span></a>`);shadow("contour-shadow-section-head",`<div class="c-section-head" part="head"><h2 class="c-section-head__title" part="title"><slot name="title"></slot></h2><p class="c-section-head__desc" part="desc"><slot name="desc"></slot></p></div>`);shadow("contour-shadow-loading",`<div class="c-loading" part="loading"><span class="c-spinner" part="spinner"></span><slot></slot></div>`);shadow("contour-shadow-tabs",`<div class="c-tabs" part="tabs"><div class="c-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-tabs__panels" role="presentation"><slot></slot></div></div>`);shadow("contour-shadow-breadcrumb",`<nav class="c-breadcrumb" part="breadcrumb" aria-label="Breadcrumb"><ol><slot></slot></ol></nav>`);shadow("contour-shadow-menu",`<div class="c-menu" part="menu" role="menu"><slot></slot></div>`);shadow("contour-shadow-combobox",`<div class="c-combobox" part="combobox"><input class="c-combobox__input" part="input" type="text" /><ul class="c-combobox__list" part="list" hidden><slot></slot></ul></div>`);shadow("contour-shadow-table",`<div class="c-table-wrap" part="wrap"><table class="c-table" part="table"><thead><slot name="head"></slot></thead><tbody><slot></slot></tbody></table></div>`);shadow("contour-shadow-chart",`<div class="c-chart" part="chart"><div class="c-chart__plot" part="plot"><slot></slot></div></div>`);shadow("contour-shadow-bivariate",`<div class="c-bivariate" part="bivariate"><div class="c-bivariate__matrix" part="matrix"><slot></slot></div></div>`);shadow("contour-shadow-bivariate-legend",`<div class="c-bivariate-legend" part="legend"><div class="c-bivariate-legend__matrix" part="matrix"><slot></slot></div></div>`);shadow("contour-shadow-expandable",`<details class="c-expandable" part="expandable"><summary class="c-expandable__summary"><slot name="summary"></slot></summary><div class="c-expandable__body" part="body"><slot></slot></div></details>`);shadow("contour-shadow-disclosure",`<details class="c-disclosure" part="disclosure"><summary><slot name="summary"></slot></summary><div class="c-disclosure__body" part="body"><slot></slot></div></details>`);shadow("contour-shadow-faq",`<div class="c-faq" part="faq"><div class="c-faq__question" part="question"><slot name="question"></slot></div><div class="c-faq__answer" part="answer"><slot name="answer"></slot></div></div>`);shadow("contour-shadow-code-tabs",`<div class="c-code-tabs" part="code-tabs"><div class="c-code-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-code-tabs__panels"><slot></slot></div></div>`);shadow("contour-shadow-header",`<header class="c-header" part="header"><div class="container c-header__inner" part="inner"><a class="c-brand" part="brand"><slot name="brand"></slot></a><nav class="c-header__nav" part="nav"><slot name="nav"></slot></nav><div class="c-header__actions" part="actions"><slot name="actions"></slot></div></div></header>`);shadow("contour-shadow-footer",`<footer class="c-footer" part="footer"><div class="container c-footer__grid" part="grid"><div class="c-footer__brand" part="brand"><slot name="brand"></slot></div><div class="c-footer__links" part="links"><slot name="links"></slot></div></div></footer>`);shadow("contour-shadow-container",`<div class="container" part="container"><slot></slot></div>`);shadow("contour-shadow-input",`<input class="c-input" part="input" />`);shadow("contour-shadow-spinner",`<span class="c-spinner" part="spinner" aria-label="Loading"></span>`);shadow("contour-shadow-textarea",`<textarea class="c-textarea" part="textarea"></textarea>`);shadow("contour-shadow-code",`<pre class="c-code" part="code"><code><slot></slot></code><button class="c-code__copy" part="copy" type="button">Copy</button></pre>`);shadow("contour-shadow-card",`<div class="c-card" part="card"> <div class="c-card__title" part="head"><slot name="title">Untitled</slot></div> <div class="c-card__body" part="body"><slot></slot></div> <div class="c-card__foot" part="foot"><slot name="foot"></slot></div> </div>`);shadow("contour-shadow-field",`<div class="c-field" part="field"> <label class="c-field__label" part="label"><slot name="label">Label</slot></label> <slot name="input"></slot> <span class="c-field__hint" part="hint"><slot name="hint"></slot></span> </div>`);shadow("contour-shadow-alert",`<div class="c-alert" part="alert"> <div class="c-alert__title" part="title"><slot name="title"></slot></div> <div class="c-alert__body" part="body"><slot></slot></div> <div class="c-alert__actions" part="actions"><slot name="action"></slot></div> <button class="c-alert__close" part="close" type="button" aria-label="Close">×</button> </div>`);shadow("contour-shadow-tag",`<span class="c-tag" part="tag"><slot></slot><button class="c-tag__remove" part="remove" type="button" aria-label="Remove">×</button></span>`);shadow("contour-shadow-filter-pill",`<span class="c-filter-pill" part="filter-pill"><slot></slot><button class="c-filter-pill__remove" part="remove" type="button" aria-label="Remove filter">×</button></span>`);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\"><use href=\"#i-x\" /></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=(typeof document!=="undefined")?(()=>{const tpl=document.createElement("template");tpl.innerHTML=DIALOG_MARKUP;return tpl})():null;enhance(root){super.enhance(root);if(this._wiredShadowDialog)return;this._wiredShadowDialog=true;const dlg=root.querySelector("dialog");const close=root.querySelector('[part="close"]');if(close)close.addEventListener("click",()=>dlg?.close());if(dlg){let lastFocus=null;dlg.addEventListener("beforetoggle",(e)=>{if(e.newState==="open"){lastFocus=document.activeElement;this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}));const focusable=dlg.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(focusable)try{focusable.focus()}catch(e){}}else if(e.newState==="closed"){this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));if(lastFocus&&typeof lastFocus.focus==="function"){try{lastFocus.focus()}catch(e){}}}});dlg.addEventListener("keydown",(e)=>{if(e.key!=="Tab")return;const focusables=Array.from(dlg.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])"));if(!focusables.length)return;const first=focusables[0];const last=focusables[focusables.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}})}}show(){this.shadowRoot?.querySelector("dialog")?.showModal()}close(){this.shadowRoot?.querySelector("dialog")?.close()}showModal(){this.show()}get open(){return!!this.shadowRoot?.querySelector("dialog")?.open}set open(v){if(v)this.show();else this.close()}get returnValue(){return this.shadowRoot?.querySelector("dialog")?.returnValue??""}set returnValue(v){const d=this.shadowRoot?.querySelector("dialog");if(d)d.returnValue=String(v)}}define("contour-shadow-dialog",ContourShadowDialog);const renderShadowDSD=(tag,attrs="",light="")=>{const markup=SHADOW_MARKUP[tag];if(typeof markup!=="string")return null;const attrStr=attrs?(attrs.startsWith(" ")?attrs:" "+attrs):"";return`<${tag}${attrStr}><template shadowrootmode="open">${markup}</template>${light}</${tag}>`};const FROZEN_SHADOW_MARKUP=Object.freeze({...SHADOW_MARKUP});if(typeof globalThis!=="undefined"){globalThis.ContourShadowTemplates=FROZEN_SHADOW_MARKUP}if(typeof window!=="undefined"){window.ContourElements=Object.freeze(REGISTERED.slice());window.ContourShadowParts=Object.freeze(Object.fromEntries(Object.entries(SHADOW_PARTS_PUBLIC).map(([name,parts])=>[name,Object.freeze([...new Set(parts)])]),));window.ContourEvents=Object.freeze(CONTOUR_EVENTS);if(!window.Contour)window.Contour={};try{window.Contour.shadowTemplates=FROZEN_SHADOW_MARKUP}catch{}}export{SHADOW_MARKUP,renderShadowDSD};class ContourAvatar extends ContourBase{static get observed(){return["name","size","variant","src","status"]}static get properties(){return{name:{attribute:"name"},size:{attribute:"size"},variant:{attribute:"variant"},src:{attribute:"src"},status:{attribute:"status"}}}render(){this.classList.add("c-avatar");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-avatar--"))this.classList.remove(c)});const name=this.getAttribute("name");const size=this.getAttribute("size");if(size)this.classList.add("c-avatar--"+size);const variant=this.getAttribute("variant");if(variant)this.classList.add("c-avatar--"+variant);const oldImg=this.querySelector("img.c-avatar__img");if(oldImg)oldImg.remove();const oldDot=this.querySelector(".c-avatar__status");if(oldDot)oldDot.remove();const src=this.getAttribute("src");if(src){this.textContent="";const img=document.createElement("img");img.className="c-avatar__img";img.src=src;img.alt=name||"";img.loading="lazy";img.decoding="async";this.appendChild(img)}else if(name){const initials=name.split(" ").map((w)=>w[0]).join("").toUpperCase().slice(0,2);if(!this.querySelector("img.c-avatar__img")){}this.textContent=initials}const status=this.getAttribute("status");if(status){const dot=document.createElement("span");dot.className="c-avatar__status c-avatar__status--"+status;dot.setAttribute("aria-hidden","true");this.appendChild(dot)}}}define("contour-avatar",ContourAvatar);class ContourBadgeFull extends ContourBase{static get observed(){return["variant","label","size","removable"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"},size:{attribute:"size"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-badge");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-badge--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-badge--"+variant);const size=this.getAttribute("size");if(size)this.classList.add("c-badge--"+size);const label=this.getAttribute("label");if(label){let textNode=null;for(const n of this.childNodes){if(n.nodeType===3){textNode=n;break}}if(textNode)textNode.nodeValue=label;else this.insertBefore(document.createTextNode(label),this.firstChild)}if(this.hasAttribute("removable")){this.ensure(".c-badge__remove",()=>{const btn=document.createElement("button");btn.className="c-badge__remove";btn.type="button";btn.setAttribute("aria-label","Remove");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-badge__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-badge",ContourBadgeFull);class ContourChipFull extends ContourBase{static get observed(){return["variant","key","value","live"]}static get properties(){return{variant:{attribute:"variant"},key:{attribute:"key"},value:{attribute:"value"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-chip");if(this.hasAttribute("live")&&!this.hasAttribute("role"))this.setAttribute("role","status");else if(!this.hasAttribute("live")&&this.getAttribute("role")==="status"&&this._autoChipRole)this.removeAttribute("role");this._autoChipRole=this.hasAttribute("live");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-chip--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-chip--"+variant);const key=this.getAttribute("key");const value=this.getAttribute("value");if(key){const k=this.ensure(".c-chip__key",()=>{const el=document.createElement("span");el.className="c-chip__key";return el});k.textContent=key}else{const k=this.querySelector(".c-chip__key");if(k)k.remove()}if(value){const v=this.ensure(".c-chip__value",()=>{const el=document.createElement("span");el.className="c-chip__value";return el});v.textContent=value}else{const v=this.querySelector(".c-chip__value");if(v)v.remove()}}}define("contour-chip",ContourChipFull);class ContourTag extends ContourBase{static get observed(){return["label","removable","variant","live"]}static get properties(){return{label:{attribute:"label"},removable:{attribute:"removable",type:Boolean},variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-tag");if(this.hasAttribute("live")&&!this.hasAttribute("role"))this.setAttribute("role","status");else if(!this.hasAttribute("live")&&this.getAttribute("role")==="status"&&this._autoTagRole)this.removeAttribute("role");this._autoTagRole=this.hasAttribute("live");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-tag--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-tag--"+variant);const label=this.getAttribute("label");if(label){let textNode=null;for(const n of this.childNodes){if(n.nodeType===3){textNode=n;break}}if(textNode)textNode.nodeValue=label+" ";else this.insertBefore(document.createTextNode(label+" "),this.firstChild)}if(this.hasAttribute("removable")){this.ensure(".c-tag__remove",()=>{const btn=document.createElement("button");btn.className="c-tag__remove";btn.type="button";btn.setAttribute("aria-label","Remove");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-tag__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-tag",ContourTag);class ContourDot extends ContourBase{static get observed(){return["variant","live"]}static get properties(){return{variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-dot");if(!this.hasAttribute("role"))this.setAttribute("role","img");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","status indicator");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-dot--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-dot--"+variant);if(this.hasAttribute("live"))this.classList.add("c-dot--live");else this.classList.remove("c-dot--live")}}define("contour-dot",ContourDot);class ContourPill extends ContourBase{static get observed(){return["label","live","variant"]}static get properties(){return{label:{attribute:"label"},live:{attribute:"live",type:Boolean},variant:{attribute:"variant"}}}render(){this.classList.add("c-pill");if(this.hasAttribute("live")&&!this.hasAttribute("role"))this.setAttribute("role","status");else if(!this.hasAttribute("live")&&this.getAttribute("role")==="status"&&this._autoPillRole)this.removeAttribute("role");this._autoPillRole=this.hasAttribute("live");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-pill--"))this.classList.remove(c)});const variant=this.getAttribute("variant");if(variant)this.classList.add("c-pill--"+variant);const label=this.getAttribute("label");if(label){this.textContent=label}if(this.hasAttribute("live"))this.classList.add("c-pill--live");else this.classList.remove("c-pill--live")}}define("contour-pill",ContourPill);class ContourKbd extends ContourBase{static get observed(){return["key"]}static get properties(){return{key:{attribute:"key"}}}render(){this.classList.add("c-kbd");const key=this.getAttribute("key");if(key){this.textContent=key}}}define("contour-kbd",ContourKbd);class ContourSpinner extends ContourBase{static get observed(){return["size"]}static get properties(){return{size:{attribute:"size"}}}render(){this.classList.add("c-spinner");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-spinner--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-spinner--"+size);if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Loading")}}define("contour-spinner",ContourSpinner);class ContourSkeleton extends ContourBase{static get observed(){return["size","shimmer"]}static get properties(){return{size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-skeleton--"))this.classList.remove(c)});const size=this.getAttribute("size");if(size)this.classList.add("c-skeleton--"+size);if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true");const shimmer=this.getAttribute("shimmer");if(shimmer==="false"||shimmer==="off")this.classList.add("c-skeleton--static");else this.classList.remove("c-skeleton--static")}}define("contour-skeleton",ContourSkeleton);class ContourTooltip extends ContourBase{static get observed(){return["text","anchor","delay","trigger"]}static get properties(){return{text:{attribute:"text"},anchor:{attribute:"anchor"},delay:{attribute:"delay",type:Number},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-tooltip");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Tooltip");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.hasAttribute("role"))this.setAttribute("role","tooltip");if(!this.id)this.id=contourId("tip");const text=this.getAttribute("text");if(text!==null&&!this.hasChildNodes()){this.textContent=text}}enhance(){if(this._wiredTooltip)return;this._wiredTooltip=true;const anchorSel=this.getAttribute("anchor");if(anchorSel){let trigger=null;if(anchorSel.startsWith("#")){trigger=document.getElementById(anchorSel.slice(1))}else{trigger=document.querySelector(anchorSel)}if(trigger){trigger.setAttribute("popovertarget",this.id||(this.id=contourId("tip")));trigger.setAttribute("aria-describedby",this.id)}}const delayMs=(this.delay&&this.delay>0)?this.delay:0;let showTimer=null;const hasPopover=typeof this.showPopover==="function";const show=()=>{if(showTimer)clearTimeout(showTimer);if(delayMs>0)showTimer=setTimeout(()=>{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");try{requestAnimationFrame(flipIfNeeded)}catch(e){flipIfNeeded()}},delayMs);else{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");try{requestAnimationFrame(flipIfNeeded)}catch(e){flipIfNeeded()}}};const hide=()=>{if(showTimer){clearTimeout(showTimer);showTimer=null}if(hasPopover){try{this.hidePopover()}catch(e){}}else this.classList.remove("is-open")};const triggerMode=this.getAttribute("trigger")||"hover";const trigger=anchorSel?(anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel)):null;const target=trigger||this;const onEnter=()=>{if(triggerMode!=="click")show()};const onLeave=()=>{if(triggerMode!=="click")hide()};const onFocus=()=>{if(triggerMode!=="click")show()};const onBlur=()=>{if(triggerMode!=="click")hide()};const onClick=()=>{if(triggerMode==="click"||triggerMode==="hover"){if(this.matches(":popover-open"))hide();else show()}};const onTouchStart=()=>{if(triggerMode!=="click")show()};const onTouchEnd=()=>{if(triggerMode!=="click"){setTimeout(hide,1500)}};target.addEventListener("mouseenter",onEnter);target.addEventListener("mouseleave",onLeave);target.addEventListener("focus",onFocus);target.addEventListener("blur",onBlur);target.addEventListener("click",onClick);target.addEventListener("touchstart",onTouchStart,{passive:true});target.addEventListener("touchend",onTouchEnd,{passive:true});const flipIfNeeded=()=>{try{const r=this.getBoundingClientRect();if(r.right>window.innerWidth)this.classList.add("c-tooltip--flip-x");else this.classList.remove("c-tooltip--flip-x");if(r.bottom>window.innerHeight)this.classList.add("c-tooltip--flip-y");else this.classList.remove("c-tooltip--flip-y")}catch(e){}};const origShow=show;onDispose(this,()=>{target.removeEventListener("mouseenter",onEnter);target.removeEventListener("mouseleave",onLeave);target.removeEventListener("focus",onFocus);target.removeEventListener("blur",onBlur);target.removeEventListener("click",onClick);target.removeEventListener("touchstart",onTouchStart);target.removeEventListener("touchend",onTouchEnd);if(showTimer)clearTimeout(showTimer)});this.addEventListener("toggle",(e)=>{const t=e.target;if(t&&t===this){this.dispatchEvent(new CustomEvent("contour:toggle",{detail:{open:this.matches(":popover-open")},bubbles:true,composed:true}))}});this.addEventListener("beforetoggle",(e)=>{this.dispatchEvent(new CustomEvent(e.newState==="open"?"contour:show":"contour:hide",{bubbles:true,composed:true}))})}}define("contour-tooltip",ContourTooltip);class ContourProgress extends ContourBase{static get observed(){return["value","label","min","max","paused","pausable"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},min:{attribute:"min"},max:{attribute:"max"},paused:{attribute:"paused",type:Boolean},pausable:{attribute:"pausable",type:Boolean}}}render(){this.classList.add("c-progress");const value=this.getAttribute("value");if(value===null){this.style.removeProperty("--progress");if(this.getAttribute("aria-valuenow")===this._progressAriaValue){this.removeAttribute("aria-valuenow")}this._progressAriaValue=null}else{const num=Number(value);const pct=Number.isFinite(num)?(num<=1&&value.includes(".")?num*100:num):0;const pctStr=Math.max(0,Math.min(100,pct))+"%";this.style.setProperty("--progress",pctStr);const prevVal=this._progressAriaValue;if(!this.hasAttribute("aria-valuenow")||this.getAttribute("aria-valuenow")===prevVal){this.setAttribute("aria-valuenow",String(pct));this._progressAriaValue=String(pct)}}this.ensure(".c-progress__bar",()=>{const el=document.createElement("span");el.className="c-progress__bar";return el});if(!this.hasAttribute("role"))this.setAttribute("role","progressbar");const label=this.getAttribute("label");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label||"Progress");const min=this.getAttribute("min");const max=this.getAttribute("max");const minV=min!==null?Number(min):0;const maxV=max!==null?Number(max):100;if(min!==null)this.setAttribute("aria-valuemin",min);else if(!this.hasAttribute("aria-valuemin"))this.setAttribute("aria-valuemin","0");if(max!==null)this.setAttribute("aria-valuemax",max);else if(!this.hasAttribute("aria-valuemax"))this.setAttribute("aria-valuemax","100");if(this.hasAttribute("aria-valuenow")){const now=Number(this.getAttribute("aria-valuenow"));if(Number.isFinite(now))this.setAttribute("aria-valuenow",String(Math.max(minV,Math.min(maxV,now))))}if(this.hasAttribute("paused"))this.classList.add("c-progress--paused");else Array.from(this.classList).forEach((c)=>{if(c==="c-progress--paused")this.classList.remove(c)});if(this.hasAttribute("pausable")){const paused=this.hasAttribute("paused");const btn=this.ensure(".c-progress__pause",()=>{const el=document.createElement("button");el.className="c-progress__pause";el.type="button";return el});btn.setAttribute("aria-label",paused?"Resume":"Pause");btn.textContent=paused?"▶":"⏸"}else{const btn=this.querySelector(".c-progress__pause");if(btn)btn.remove()}}enhance(){if(this._wiredProgress)return;this._wiredProgress=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-progress__pause"):null;if(!btn||!this.contains(btn))return;e.preventDefault();const paused=!this.hasAttribute("paused");this.toggleAttribute("paused",paused);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{paused}}))})}}define("contour-progress",ContourProgress);class ContourMark extends ContourBase{render(){this.classList.add("c-mark")}}define("contour-mark",ContourMark);class ContourLoading extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-loading");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live","polite");this.ensure(".c-spinner",()=>{const el=document.createElement("span");el.className="c-spinner";el.setAttribute("aria-hidden","true");return el});const label=this.getAttribute("label")||"Loading";let text=this.querySelector("[data-loading-label]");if(!text){text=document.createElement("span");text.className="visually-hidden";text.setAttribute("data-loading-label","");this.appendChild(text)}text.textContent=label;if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label)}}define("contour-loading",ContourLoading);class ContourElevation extends ContourBase{render(){this.classList.add("c-elevation")}}define("contour-elevation",ContourElevation);class ContourVersionBannerFull extends ContourBase{static get observed(){return["message","link","href","dismissible"]}static get properties(){return{message:{attribute:"message"},link:{attribute:"link"},href:{attribute:"href"},dismissible:{attribute:"dismissible",type:Boolean}}}render(){this.classList.add("c-version-banner");if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("message")||"Version banner");Array.from(this.children).forEach((n)=>n.remove());const message=this.getAttribute("message");if(message){const icon=document.createElementNS("http://www.w3.org/2000/svg","svg");icon.setAttribute("aria-hidden","true");icon.innerHTML='<use href="#i-info" />';this.appendChild(icon);const span=document.createElement("span");span.textContent=message;this.appendChild(span)}const link=this.getAttribute("link");const href=this.getAttribute("href");if(link&&href){const a=document.createElement("a");a.className="c-version-banner__link";a.href=safeHref(href);a.textContent=link;this.appendChild(a)}if(this.hasAttribute("dismissible")){const btn=document.createElement("button");btn.className="c-version-banner__dismiss";btn.type="button";btn.setAttribute("aria-label","Dismiss");btn.textContent="×";this.appendChild(btn)}}enhance(){if(this._wiredVersionBanner)return;this._wiredVersionBanner=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-version-banner__dismiss"):null;if(btn&&this.contains(btn)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));this.remove()}})}}define("contour-version-banner",ContourVersionBannerFull);class ContourBanner extends ContourBase{static get observed(){return["message","variant"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"}}}render(){this.classList.add("c-banner");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-banner--"))this.classList.remove(c)});if(variant)this.classList.add("c-banner--"+variant);const message=this.getAttribute("message");if(message){const span=this.ensure(".c-banner__message",()=>{const el=document.createElement("span");el.className="c-banner__message";return el});span.textContent=message}}}define("contour-banner",ContourBanner);class ContourFilterPill extends ContourBase{static get observed(){return["key","value","removable"]}static get properties(){return{key:{attribute:"key"},value:{attribute:"value"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-filter-pill");const key=this.getAttribute("key");const value=this.getAttribute("value");if(key){const k=this.ensure(".c-filter-pill__key",()=>{const el=document.createElement("span");el.className="c-filter-pill__key";return el});k.textContent=key}else{const k=this.querySelector(".c-filter-pill__key");if(k)k.remove()}if(value){const v=this.ensure(".c-filter-pill__value",()=>{const el=document.createElement("span");el.className="c-filter-pill__value";return el});v.textContent=value}else{const v=this.querySelector(".c-filter-pill__value");if(v)v.remove()}if(this.hasAttribute("removable")){this.ensure(".c-filter-pill__remove",()=>{const btn=document.createElement("button");btn.className="c-filter-pill__remove";btn.type="button";btn.setAttribute("aria-label","Remove filter");btn.textContent="×";return btn})}else{const btn=this.querySelector(".c-filter-pill__remove");if(btn)btn.remove()}}enhance(){wireRemovable(this)}}define("contour-filter-pill",ContourFilterPill);class ContourDatamark extends ContourBase{static get observed(){return["value","unit","label"]}static get properties(){return{value:{attribute:"value"},unit:{attribute:"unit"},label:{attribute:"label"}}}render(){this.classList.add("c-datamark");const value=this.getAttribute("value");const unit=this.getAttribute("unit");const label=this.getAttribute("label");const text=value||label;if(text){this.textContent=text;if(unit){const u=document.createElement("span");u.className="u-subtle";u.textContent=" "+unit;this.appendChild(u)}}}}define("contour-datamark",ContourDatamark);class ContourDestructiveHint extends ContourBase{static get observed(){return["text"]}static get properties(){return{text:{attribute:"text"}}}render(){this.classList.add("c-destructive-hint");const text=this.getAttribute("text");if(text)this.textContent=text}}define("contour-destructive-hint",ContourDestructiveHint);class ContourIconBadge extends ContourBase{static get observed(){return["icon"]}static get properties(){return{icon:{attribute:"icon"}}}render(){this.classList.add("c-icon-badge");const icon=this.getAttribute("icon");if(icon){const sanitized=String(icon).replace(/[^a-zA-Z0-9_-]/g,"");if(sanitized&&!sanitized.startsWith("i-")){if(typeof console!=="undefined"&&console.warn){console.warn("ContourIconBadge: icon '"+icon+"' may not exist in the sprite (expected i-* name).")}}const existing=this.querySelector("svg");const svg=existing||document.createElementNS("http://www.w3.org/2000/svg","svg");if(!existing){svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#"+sanitized);svg.appendChild(use);this.appendChild(svg)}else{const use=svg.querySelector("use");if(use)use.setAttribute("href","#"+sanitized)}}else{const svg=this.querySelector("svg");if(svg)svg.remove()}}}define("contour-icon-badge",ContourIconBadge);class ContourLiveBadge extends ContourBase{static get observed(){return["label","state","live"]}static get properties(){return{label:{attribute:"label"},state:{attribute:"state"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-live-badge");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-live-badge--"))this.classList.remove(c)});const state=this.getAttribute("state");if(state){this.classList.add("c-live-badge--"+state)}else if(this.hasAttribute("live")){this.classList.add("c-live-badge--connected")}const label=this.getAttribute("label");if(label&&!this.hasChildNodes())this.textContent=label}}define("contour-live-badge",ContourLiveBadge);class ContourSkeletonGroup extends ContourBase{static get observed(){return["count"]}static get properties(){return{count:{attribute:"count",type:Number}}}render(){this.classList.add("c-skeleton-group");const count=Math.max(1,parseInt(this.getAttribute("count")||"3",10)||3);Array.from(this.querySelectorAll(".c-skeleton")).forEach((n)=>n.remove());for(let i=0;i<count;i++){const sk=document.createElement("div");sk.className="c-skeleton";sk.setAttribute("aria-hidden","true");this.appendChild(sk)}}}define("contour-skeleton-group",ContourSkeletonGroup);class ContourMapPopup extends ContourBase{static get observed(){return["title","content","cluster-count","cluster-expanded","cluster-items","anchor","position","collision"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},"cluster-count":{attribute:"cluster-count",type:Number},"cluster-expanded":{attribute:"cluster-expanded",type:Boolean},"cluster-items":{attribute:"cluster-items"}}}render(){this.classList.add("c-map-popup");this.setAttribute("role","dialog");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("map-popup");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-map-popup__title",()=>{const el=document.createElement("div");el.className="c-map-popup__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-map-popup__body",()=>{const el=document.createElement("div");el.className="c-map-popup__body";return el});c.textContent=content}const clusterCount=Number(this.getAttribute("cluster-count"));if(Number.isFinite(clusterCount)&&clusterCount>1){const badge=this.ensure(".c-map-popup__cluster",()=>{const el=document.createElement("button");el.className="c-map-popup__cluster c-btn c-btn--sm";el.type="button";return el});const expanded=this.hasAttribute("cluster-expanded");badge.textContent=expanded?"Hide locations":`${clusterCount} locations`;badge.setAttribute("aria-expanded",String(expanded));badge.setAttribute("aria-label",expanded?"Hide locations":`Show ${clusterCount} locations`)}else{const badge=this.querySelector(".c-map-popup__cluster");if(badge)badge.remove()}const expanded=this.hasAttribute("cluster-expanded");let items=[];try{items=this.getAttribute("cluster-items")?JSON.parse(this.getAttribute("cluster-items")):[]}catch(e){items=[]}const list=this.querySelector(".c-map-popup__cluster-list");if(expanded&&Array.isArray(items)&&items.length){const ul=list||document.createElement("ul");ul.className="c-map-popup__cluster-list";ul.innerHTML="";items.forEach((it)=>{const li=document.createElement("li");li.className="c-map-popup__cluster-item";li.textContent=typeof it==="string"?it:(it.label||it.name||JSON.stringify(it));ul.appendChild(li)});if(ul.parentNode!==this)this.appendChild(ul)}else if(list){list.remove()}if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",title||"Map popup")}enhance(){if(this._wiredMapPopup)return;this._wiredMapPopup=true;const close=()=>{try{this.hidePopover()}catch(e){}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const keyHandler=(e)=>{if(e.key==="Escape"&&(this.classList.contains("is-open")||this.matches(":popover-open"))){e.preventDefault();close()}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-map-popup__close"):null;if(btn&&this.contains(btn))close();const cluster=e.target&&e.target.closest?e.target.closest(".c-map-popup__cluster"):null;if(cluster&&this.contains(cluster)){const expanded=!this.hasAttribute("cluster-expanded");this.toggleAttribute("cluster-expanded",expanded);this.dispatchEvent(new CustomEvent("contour:cluster-toggle",{bubbles:true,composed:true,detail:{count:Number(this.getAttribute("cluster-count")),expanded}}))}});const anchorSel=this.getAttribute("anchor");let anchorEl=null;if(anchorSel){anchorEl=anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel)}const anchorName="--map-popup-"+this.id;const applyAnchor=()=>{if(anchorEl){anchorEl.style.setProperty("anchor-name",anchorName);this.style.setProperty("position-anchor",anchorName)}};const flipIfNeeded=()=>{try{const r=this.getBoundingClientRect();const flipX=r.right>window.innerWidth||r.left<0;const flipY=r.bottom>window.innerHeight||r.top<0;const flipped=flipX||flipY;this.classList.toggle("c-map-popup--flip-x",flipX&&!flipY);this.classList.toggle("c-map-popup--flip-y",flipY&&!flipX);this.classList.toggle("c-map-popup--flip-both",flipX&&flipY);if(flipped){this.dispatchEvent(new CustomEvent("contour:map-popup-reposition",{bubbles:true,composed:true,detail:{anchor:anchorSel||"",flippedX:flipX,flippedY:flipY,left:Math.round(r.left),top:Math.round(r.top)}}))}}catch(e){}};applyAnchor();this.addEventListener("toggle",(e)=>{if(e.newState==="open"){requestAnimationFrame(()=>{applyAnchor();flipIfNeeded()})}});const onResize=()=>flipIfNeeded();window.addEventListener("resize",onResize);onDispose(this,()=>{window.removeEventListener("resize",onResize);if(anchorEl)anchorEl.style.removeProperty("anchor-name")})}}define("contour-map-popup",ContourMapPopup);class ContourAnimationControls extends ContourBase{static get observed(){return["playing","speed","progress","min","max","caption","show-thumb","show-thumb-caption","loop","step","markers"]}static get properties(){return{playing:{attribute:"playing",type:Boolean},speed:{attribute:"speed"},progress:{attribute:"progress"},min:{attribute:"min"},max:{attribute:"max"},loop:{attribute:"loop",type:Boolean},step:{attribute:"step"},markers:{attribute:"markers"}}}render(){this.classList.add("c-animation-controls");this.setAttribute("role","toolbar");this.setAttribute("aria-label","Animation controls");const playBtn=this.ensure(".c-animation-controls__play",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__play";el.type="button";return el});playBtn.textContent=this.hasAttribute("playing")?"Pause":"Play";playBtn.setAttribute("aria-label",this.hasAttribute("playing")?"Pause":"Play");const speed=this.getAttribute("speed")||"1x";const speedBtn=this.ensure(".c-animation-controls__speed",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__speed";el.type="button";return el});speedBtn.textContent=speed;speedBtn.setAttribute("aria-label","Playback speed "+speed);const loopBtn=this.ensure(".c-animation-controls__loop",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-animation-controls__loop";el.type="button";el.textContent="Loop";return el});loopBtn.setAttribute("aria-pressed",String(this.hasAttribute("loop")));playBtn.tabIndex=0;speedBtn.tabIndex=-1;loopBtn.tabIndex=-1;const scrubber=this.ensure(".c-animation-controls__scrubber",()=>{const el=document.createElement("input");el.className="c-range c-animation-controls__scrubber";el.type="range";return el});if(this.getAttribute("show-thumb")==="false")scrubber.classList.remove("c-animation-controls__scrubber--thumb");else scrubber.classList.add("c-animation-controls__scrubber--thumb");scrubber.min=this.getAttribute("min")||"0";scrubber.max=this.getAttribute("max")||"100";scrubber.step=this.getAttribute("step")||"1";scrubber.value=this.getAttribute("progress")||"0";const min=Number(scrubber.min)||0;const max=Number(scrubber.max)||100;const v=Number(scrubber.value)||min;scrubber.setAttribute("aria-valuenow",String(v));scrubber.setAttribute("aria-valuetext",String(Math.round(v)));scrubber.setAttribute("aria-valuemin",String(min));scrubber.setAttribute("aria-valuemax",String(max));const caption=this.getAttribute("caption");if(caption)scrubber.setAttribute("aria-label",caption);else if(!scrubber.getAttribute("aria-label"))scrubber.setAttribute("aria-label","Playhead");const markersRaw=this.getAttribute("markers");let markers=[];if(markersRaw){try{const p=JSON.parse(markersRaw);markers=Array.isArray(p)?p:[]}catch(e){warnBadJson(this,"markers",e)}}const oldList=this.querySelector("datalist.c-animation-controls__markers");if(markers.length){const dl=this.ensure("datalist.c-animation-controls__markers",()=>{const el=document.createElement("datalist");el.className="c-animation-controls__markers";return el});if(!dl.id)dl.id=this._animMarkersId||(this._animMarkersId=contourId("anim-markers"));dl.innerHTML="";markers.forEach((m)=>{const opt=document.createElement("option");const val=typeof m==="object"&&m!==null?m.value:m;opt.value=String(val);if(typeof m==="object"&&m!==null&&m.label)opt.label=String(m.label);dl.appendChild(opt)});scrubber.setAttribute("list",dl.id)}else{if(oldList)oldList.remove();scrubber.removeAttribute("list")}const showCaption=this.hasAttribute("show-thumb-caption")||this.hasAttribute("show-thumb");if(caption&&showCaption){const cap=this.ensure(".c-animation-controls__caption",()=>{const el=document.createElement("span");el.className="c-animation-controls__caption";return el});cap.textContent=caption}else{const cap=this.querySelector(".c-animation-controls__caption");if(cap)cap.remove()}if(this.hasAttribute("loop")){this.setAttribute("aria-label","Animation controls, loop")}}enhance(){if(this._wiredAnimControls)return;this._wiredAnimControls=true;const SPEEDS=[0.5,1,2,4];const writeProgress=(v)=>{if(!this._animScrubbing)this.setAttribute("progress",String(v))};this.addEventListener("pointerdown",(e)=>{if(e.target&&e.target.closest&&e.target.closest(".c-animation-controls__scrubber"))this._animScrubbing=true},{passive:true});const endScrub=()=>{this._animScrubbing=false};this.addEventListener("pointerup",endScrub,{passive:true});this.addEventListener("pointercancel",endScrub,{passive:true});this.addEventListener("click",(e)=>{const play=e.target&&e.target.closest?e.target.closest(".c-animation-controls__play"):null;if(play&&this.contains(play)){const next=!this.hasAttribute("playing");this.toggleAttribute("playing",next);this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{playing:next}}));return}const speed=e.target&&e.target.closest?e.target.closest(".c-animation-controls__speed"):null;if(speed&&this.contains(speed)){const cur=parseFloat(this.getAttribute("speed")||"1x");const idx=SPEEDS.indexOf(Number.isFinite(cur)?cur:1);const next=SPEEDS[(idx+1)%SPEEDS.length];this.setAttribute("speed",next+"x");this.dispatchEvent(new CustomEvent("contour:speed-change",{bubbles:true,composed:true,detail:{speed:next}}));return}const loop=e.target&&e.target.closest?e.target.closest(".c-animation-controls__loop"):null;if(loop&&this.contains(loop)){const next=!this.hasAttribute("loop");this.toggleAttribute("loop",next);this.dispatchEvent(new CustomEvent("contour:loop-change",{bubbles:true,composed:true,detail:{loop:next}}))}});this.addEventListener("input",(e)=>{const scrubber=e.target&&e.target.closest?e.target.closest(".c-animation-controls__scrubber"):null;if(scrubber&&this.contains(scrubber)){const v=Number(scrubber.value);writeProgress(v);this.dispatchEvent(new CustomEvent("contour:seek",{bubbles:true,composed:true,detail:{progress:v,value:v}}))}});this.addEventListener("change",(e)=>{const scrubber=e.target&&e.target.closest?e.target.closest(".c-animation-controls__scrubber"):null;if(scrubber&&this.contains(scrubber))this.setAttribute("progress",scrubber.value)});this.addEventListener("keydown",(e)=>{if(e.target&&e.target.closest&&e.target.closest(".c-animation-controls__scrubber"))return;const buttons=Array.from(this.querySelectorAll(".c-animation-controls__play, .c-animation-controls__speed, .c-animation-controls__loop"));if(!buttons.includes(e.target))return;navKey(e,buttons,{wrap:true,homeEnd:true,onNavigate:(i)=>{buttons.forEach((b,j)=>{b.tabIndex=j===i?0:-1})},onKey:(k,idx,item)=>{if(k==="Enter"||k===" ")item.click()}})});let timer=null;const speedFactor=()=>{const s=this.getAttribute("speed")||"1x";const n=parseFloat(s);return Number.isFinite(n)&&n>0?n:1};const tick=()=>{const scrubber=this.querySelector(".c-animation-controls__scrubber");if(!scrubber)return;const min=Number(scrubber.min||0);const max=Number(scrubber.max||100);let v=Number(scrubber.value||0)+speedFactor();let ended=false;if(v>max){if(this.hasAttribute("loop"))v=min;else{v=max;stop();ended=true}}scrubber.value=String(v);writeProgress(v);this.dispatchEvent(new CustomEvent("contour:time-change",{bubbles:true,composed:true,detail:{progress:v,value:v}}));if(ended){this.removeAttribute("playing");this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{playing:false}}))}};const start=()=>{if(timer)return;timer=setInterval(tick,100)};const stop=()=>{if(timer){clearInterval(timer);timer=null}};if(this.hasAttribute("playing"))start();const obs=new MutationObserver(()=>{if(this.hasAttribute("playing"))start();else stop()});obs.observe(this,{attributes:true,attributeFilter:["playing"]});onDispose(this,()=>{stop();obs.disconnect()})}}define("contour-animation-controls",ContourAnimationControls);class ContourDropdown extends ContourBase{static get observed(){return["label","items"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"}}}render(){this.classList.add("c-dropdown");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Dropdown");const btn=this.ensure(".c-dropdown__trigger",()=>{const el=document.createElement("button");el.className="c-dropdown__trigger c-btn c-btn--sm";el.type="button";return el});btn.textContent=this.getAttribute("label")||"Menu";btn.setAttribute("aria-haspopup","menu");btn.setAttribute("aria-expanded","false");const menu=this.ensure(".c-dropdown__menu",()=>{const el=document.createElement("div");el.className="c-dropdown__menu c-menu";el.setAttribute("role","menu");el.hidden=true;return el});if(!menu.id)menu.id=(this.id||contourId("dd"))+"-menu";btn.setAttribute("aria-controls",menu.id);const authoredItems=Array.from(this.querySelectorAll(":scope > .c-menu__item"));const items=this.getAttribute("items");if(authoredItems.length){menu.innerHTML="";authoredItems.forEach((it)=>{menu.appendChild(it)})}else if(items){try{const parsed=JSON.parse(items);menu.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("button");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=typeof it==="string"?it:(it.label||it.title||"");menu.appendChild(li)})}catch(e){warnBadJson(this,"attribute",e)}}if(menu.parentNode!==this)this.appendChild(menu);if(btn.parentNode!==this)this.insertBefore(btn,menu)}enhance(){if(this._wiredDropdown)return;this._wiredDropdown=true;const btn=()=>this.querySelector(".c-dropdown__trigger");const menu=()=>this.querySelector(".c-dropdown__menu");this.addEventListener("click",(e)=>{const b=btn();const m=menu();const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&m&&m.contains(item)&&!m.hidden){const idx=Array.from(m.querySelectorAll(".c-menu__item")).indexOf(item);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:idx,value:item.textContent}}));m.hidden=true;if(b){b.setAttribute("aria-expanded","false");try{b.focus()}catch(err){}}return}if(e.target===b||(b&&b.contains(e.target))){if(m){m.hidden=!m.hidden;b.setAttribute("aria-expanded",String(!m.hidden));if(!m.hidden){if(!m.id)m.id=(this.id||contourId("dd"))+"-menu";b.setAttribute("aria-controls",m.id);const first=m.querySelector(".c-menu__item");if(first)try{first.focus()}catch(err){}}}}});const docClick=(e)=>{const m=menu();const b=btn();if(m&&!m.hidden&&!this.contains(e.target)){m.hidden=true;if(b)b.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick));const keyHandler=(e)=>{const m=menu();const b=btn();if(e.key==="Escape"&&m&&!m.hidden){e.preventDefault();m.hidden=true;if(b){b.setAttribute("aria-expanded","false");try{b.focus()}catch(err){}}return}if(!m||m.hidden)return;const items=Array.from(m.querySelectorAll(".c-menu__item"));navKey(e,items,{wrap:true,enter:false,onKey:(k)=>{if(k==="Enter"||k===" ")document.activeElement.click()}})};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-dropdown",ContourDropdown);class ContourAnnotation extends ContourBase{static get observed(){return["label","x","y"]}static get properties(){return{label:{attribute:"label"},x:{attribute:"x"},y:{attribute:"y"}}}render(){this.classList.add("c-annotation");this.setAttribute("role","note");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");const label=this.getAttribute("label");if(label)this.setAttribute("aria-label",label);if(label){const l=this.ensure(".c-annotation__label",()=>{const el=document.createElement("span");el.className="c-annotation__label";return el});l.textContent=label}const x=this.getAttribute("x");const y=this.getAttribute("y");if(x!==null)this.style.setProperty("--annotation-x",x);if(y!==null)this.style.setProperty("--annotation-y",y)}enhance(){if(this._wiredAnnotation)return;this._wiredAnnotation=true;const pct=(v,fallback)=>{const n=parseFloat(v);return Number.isFinite(n)?Math.min(100,Math.max(0,n)):fallback};const write=(x,y,key)=>{this.batch(()=>{this.setAttribute("x",x+"%");this.setAttribute("y",y+"%")});this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:true,composed:true,detail:{delta:key?1:0,key:key||"pointer",value:x+","+y}}))};let drag=null;this.addEventListener("pointerdown",(e)=>{if(e.button!==undefined&&e.button!==0)return;const parent=this.offsetParent||this.parentElement;if(!parent)return;const rect=parent.getBoundingClientRect();drag={px:e.clientX,py:e.clientY,x:pct(this.getAttribute("x"),50),y:pct(this.getAttribute("y"),50),w:rect.width||1,h:rect.height||1};try{this.setPointerCapture(e.pointerId)}catch(err){}try{this.focus()}catch(err){}e.preventDefault()});this.addEventListener("pointermove",(e)=>{if(!drag)return;const x=Math.round((drag.x+((e.clientX-drag.px)/drag.w)*100)*10)/10;const y=Math.round((drag.y+((e.clientY-drag.py)/drag.h)*100)*10)/10;write(Math.min(100,Math.max(0,x)),Math.min(100,Math.max(0,y)))});const endDrag=()=>{if(!drag)return;drag=null;this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:true,composed:true,detail:{value:(this.getAttribute("x")||"")+","+(this.getAttribute("y")||"")}}))};this.addEventListener("pointerup",endDrag);this.addEventListener("pointercancel",endDrag);this.addEventListener("keydown",(e)=>{const step=e.shiftKey?10:1;let dx=0,dy=0;if(e.key==="ArrowLeft")dx=-step;else if(e.key==="ArrowRight")dx=step;else if(e.key==="ArrowUp")dy=-step;else if(e.key==="ArrowDown")dy=step;else return;e.preventDefault();const x=Math.min(100,Math.max(0,pct(this.getAttribute("x"),50)+dx));const y=Math.min(100,Math.max(0,pct(this.getAttribute("y"),50)+dy));write(x,y,e.key);this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:true,composed:true,detail:{value:x+","+y}}))})}}define("contour-annotation",ContourAnnotation);class ContourStyleSwitcher extends ContourBase{static get observed(){return["items","value"]}static get properties(){return{items:{attribute:"items"},value:{attribute:"value"}}}render(){this.classList.add("c-style-switcher");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Style switcher");const items=this.getAttribute("items");const value=this.getAttribute("value");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-style-switcher__option"));if(items&&!authored.length){Array.from(this.querySelectorAll(".c-style-switcher__option")).forEach((n)=>n.remove());try{const parsed=JSON.parse(items);parsed.forEach((it)=>{const name=typeof it==="string"?it:(it.name||it.label||"");const btn=document.createElement("button");btn.className="c-style-switcher__option c-btn c-btn--sm";btn.type="button";btn.textContent=name;btn.dataset.value=name;this.appendChild(btn)})}catch(e){warnBadJson(this,"attribute",e)}}const opts=Array.from(this.querySelectorAll(".c-style-switcher__option"));let active=null;opts.forEach((btn)=>{const v=btn.dataset.value!=null?btn.dataset.value:btn.textContent.trim();const on=v===value;btn.classList.toggle("c-style-switcher__option--active",on);btn.setAttribute("aria-pressed",String(on));btn.tabIndex=-1;if(on&&!active)active=btn});(active||opts[0])?.setAttribute("tabindex","0")}enhance(){if(this._wiredStyleSwitcher)return;this._wiredStyleSwitcher=true;const select=(btn)=>{const v=btn.dataset.value!=null?btn.dataset.value:btn.textContent.trim();this.setAttribute("value",v);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:v}}))};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-style-switcher__option"):null;if(btn&&this.contains(btn))select(btn)});this.addEventListener("keydown",(e)=>{const opts=Array.from(this.querySelectorAll(".c-style-switcher__option"));navKey(e,opts,{onKey:(k)=>{if(k==="Enter"||k===" "){const btn=document.activeElement;if(btn&&btn.classList.contains("c-style-switcher__option"))select(btn)}}})})}}define("contour-style-switcher",ContourStyleSwitcher);class ContourStylePanel extends ContourBase{static get observed(){return["title","layers","layer","single","classification","palette","breaks","opacity","n","colors","property"]}static get properties(){return{title:{attribute:"title"},layers:{attribute:"layers"},classification:{attribute:"classification"},palette:{attribute:"palette"},breaks:{attribute:"breaks"},opacity:{attribute:"opacity"}}}render(){this.classList.add("c-style-panel");if(!this._stylePanelDefault){this._stylePanelDefault={};for(const a of["property","classification","palette","breaks","opacity","n","colors"])this._stylePanelDefault[a]=this.getAttribute(a)}this.setAttribute("role","group");this.setAttribute("aria-label","Style panel");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-style-panel__title",()=>{const el=document.createElement("div");el.className="c-style-panel__title";return el});t.textContent=title}const singleMode=this.hasAttribute("single")||!!this.getAttribute("layer");if(singleMode){const body=this.ensure(".c-style-panel__body",()=>{const el=document.createElement("div");el.className="c-style-panel__body";return el});body.innerHTML="";const uid=contourId("style-panel");const propId=uid+"-property";const policyId=uid+"-policy";const paletteId=uid+"-palette";const nId=uid+"-n";const propLabel=document.createElement("label");propLabel.textContent=labelText(this,"colour-field","Colour field");propLabel.setAttribute("for",propId);body.appendChild(propLabel);const propIn=document.createElement("input");propIn.type="text";propIn.id=propId;propIn.className="c-style-panel__property c-input";propIn.setAttribute("aria-label",labelText(this,"colour-field","Colour field"));const pv=this.getAttribute("property");if(pv)propIn.value=pv;body.appendChild(propIn);const clsLabel=document.createElement("label");clsLabel.textContent=labelText(this,"classification","Classification");clsLabel.setAttribute("for",policyId);body.appendChild(clsLabel);const clsSel=document.createElement("select");clsSel.id=policyId;clsSel.className="c-style-panel__classification c-input";clsSel.setAttribute("aria-label",labelText(this,"classification-method","Classification method"));["equal","quantile","jenks","manual"].forEach((m)=>{const o=document.createElement("option");o.value=m;o.textContent=m;clsSel.appendChild(o)});const cls=this.getAttribute("classification");if(cls)clsSel.value=cls;body.appendChild(clsSel);const palLabel=document.createElement("label");palLabel.textContent=labelText(this,"palette","Palette");palLabel.setAttribute("for",paletteId);body.appendChild(palLabel);const pal=document.createElement("input");pal.type="text";pal.id=paletteId;pal.className="c-style-panel__palette c-input";pal.placeholder=labelText(this,"palette","Palette");pal.setAttribute("aria-label",labelText(this,"palette","Palette"));const palv=this.getAttribute("palette");if(palv)pal.value=palv;body.appendChild(pal);const nLabel=document.createElement("label");nLabel.textContent=labelText(this,"classes","Classes");nLabel.setAttribute("for",nId);body.appendChild(nLabel);const nIn=document.createElement("input");nIn.type="number";nIn.id=nId;nIn.className="c-style-panel__n c-input";nIn.min="2";nIn.max="12";nIn.setAttribute("aria-label",labelText(this,"class-count","Class count"));const nv=this.getAttribute("n");if(nv)nIn.value=nv;else nIn.value="5";body.appendChild(nIn);const op=document.createElement("input");op.type="range";op.className="c-style-panel__opacity";op.setAttribute("aria-label",labelText(this,"opacity","Opacity"));op.min="0";op.max="100";const ov=this.getAttribute("opacity");op.value=ov!=null?ov:"100";body.appendChild(op);const breaksAttr=this.getAttribute("breaks");let breaksArr=null;if(breaksAttr){try{breaksArr=JSON.parse(breaksAttr)}catch(e){breaksArr=breaksAttr.split(",").map((s)=>s.trim())}}if(Array.isArray(breaksArr)&&breaksArr.length){const breaksWrap=document.createElement("div");breaksWrap.className="c-style-panel__breaks";breaksArr.forEach((b,i)=>{const br=document.createElement("div");br.className="break";const span=document.createElement("span");span.textContent=String(b);br.appendChild(span);const inp=document.createElement("input");inp.type="number";inp.className="c-style-panel__breaks c-input";inp.setAttribute("aria-label",labelText(this,"class-lower-bound","Class lower bound"));inp.value=String(b);br.appendChild(inp);breaksWrap.appendChild(br)});body.appendChild(breaksWrap)}const colorsAttr=this.getAttribute("colors");let colors=null;if(colorsAttr){try{colors=JSON.parse(colorsAttr)}catch(e){colors=colorsAttr.split(",").map((s)=>s.trim())}}if(Array.isArray(colors)){const list=document.createElement("div");list.className="c-style-panel__colors";colors.forEach((c,i)=>{const sw=document.createElement("input");sw.type="color";sw.className="c-style-panel__color c-input";sw.setAttribute("aria-label",labelText(this,"colour-for-class","Colour for class")+" "+(i+1));sw.value=c;list.appendChild(sw)});body.appendChild(list)}const actions=document.createElement("div");actions.className="c-style-panel__actions c-btn-group";const applyBtn=document.createElement("button");applyBtn.type="button";applyBtn.className="c-btn c-btn--primary";applyBtn.textContent=labelText(this,"apply","Apply");applyBtn.dataset.action="apply";const revertBtn=document.createElement("button");revertBtn.type="button";revertBtn.className="c-btn";revertBtn.textContent=labelText(this,"revert","Revert");revertBtn.dataset.action="revert";actions.appendChild(applyBtn);actions.appendChild(revertBtn);body.appendChild(actions);return}const layers=this.getAttribute("layers");const body=this.ensure(".c-style-panel__body",()=>{const el=document.createElement("div");el.className="c-style-panel__body";return el});const authoredRows=Array.from(this.querySelectorAll(":scope > .c-style-panel__row"));let parsed=null;if(authoredRows.length){parsed=authoredRows.map((row)=>({name:row.querySelector(".c-style-panel__name")?.textContent||"",color:row.querySelector(".c-style-panel__color")?.value,classification:row.querySelector(".c-style-panel__classification")?.value,palette:row.querySelector(".c-style-panel__palette")?.value,breaks:row.querySelector(".c-style-panel__breaks")?.value,opacity:row.querySelector(".c-style-panel__opacity")?.value,}));authoredRows.forEach((row)=>row.remove())}else if(layers){try{parsed=JSON.parse(layers)}catch(e){parsed=null}}if(parsed){body.innerHTML="";parsed.forEach((l)=>{const row=document.createElement("div");row.className="c-style-panel__row";const name=document.createElement("span");name.className="c-style-panel__name";name.textContent=typeof l==="string"?l:(l.name||l.label||"");row.appendChild(name);const input=document.createElement("input");input.type="color";input.className="c-style-panel__color";input.setAttribute("aria-label","Colour for "+(typeof l==="string"?l:(l.name||l.label||"layer")));if(typeof l==="object"&&l.color)input.value=l.color;row.appendChild(input);const clsSel=document.createElement("select");clsSel.className="c-style-panel__classification";clsSel.setAttribute("aria-label",labelText(this,"classification-method","Classification method"));["equal","quantile","jenks","manual"].forEach((m)=>{const o=document.createElement("option");o.value=m;o.textContent=m;clsSel.appendChild(o)});if(typeof l==="object"&&l.classification)clsSel.value=l.classification;row.appendChild(clsSel);const pal=document.createElement("input");pal.type="text";pal.className="c-style-panel__palette";pal.setAttribute("aria-label","Palette");pal.placeholder="palette";if(typeof l==="object"&&l.palette)pal.value=l.palette;row.appendChild(pal);const breaks=document.createElement("input");breaks.type="text";breaks.className="c-style-panel__breaks";breaks.placeholder="breaks";breaks.setAttribute("aria-label","Class breaks");if(typeof l==="object"&&l.breaks)breaks.value=(Array.isArray(l.breaks)?l.breaks.join(","):l.breaks);row.appendChild(breaks);const op=document.createElement("input");op.type="range";op.className="c-style-panel__opacity";op.setAttribute("aria-label",labelText(this,"opacity","Opacity"));op.min="0";op.max="100";op.value=(typeof l==="object"&&l.opacity!=null)?l.opacity:"100";row.appendChild(op);body.appendChild(row)})}}enhance(){if(this._wiredStylePanel)return;this._wiredStylePanel=true;this.addEventListener("change",(e)=>{const t=e.target;if(!t||!this.contains(t))return;const row=t.closest(".c-style-panel__row");const name=row?(row.querySelector(".c-style-panel__name")?.textContent||""):"";if(t.classList.contains("c-style-panel__color")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:"color"},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__classification")){this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:t.value,layer:name},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__opacity")){this.dispatchEvent(new CustomEvent("contour:layer-opacity",{detail:{name,opacity:Number(t.value)},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__property")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:"property"},bubbles:true,composed:true}))}else if(t.classList.contains("c-style-panel__n")){this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:Number(t.value),layer:name,property:"n"},bubbles:true,composed:true}))}});this.addEventListener("input",(e)=>{const t=e.target;if(!t||!this.contains(t))return;if(t.classList.contains("c-style-panel__color"))t.setAttribute("data-edited","true");if(t.classList.contains("c-style-panel__palette")||t.classList.contains("c-style-panel__breaks")){const row=t.closest(".c-style-panel__row");const name=row?(row.querySelector(".c-style-panel__name")?.textContent||""):"";this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:t.value,layer:name,property:t.classList.contains("c-style-panel__palette")?"palette":"breaks"},bubbles:true,composed:true}))}});this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target.closest("button"):null;if(!t||!this.contains(t))return;if(t.dataset.action==="apply"){const body=this.querySelector(".c-style-panel__body");const payload={applied:true};if(body){const prop=body.querySelector(".c-style-panel__property");const cls=body.querySelector(".c-style-panel__classification");const pal=body.querySelector(".c-style-panel__palette");const n=body.querySelector(".c-style-panel__n");const colors=Array.from(body.querySelectorAll(".c-style-panel__color")).map((c)=>c.value);if(prop)payload.property=prop.value;if(cls)payload.classification=cls.value;if(pal)payload.palette=pal.value;if(n)payload.n=Number(n.value);if(colors.length)payload.colors=colors}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:payload,bubbles:true,composed:true}))}else if(t.dataset.action==="revert"){const def=this._stylePanelDefault||{};this._contourResetting=true;try{for(const a of["property","classification","palette","breaks","opacity","n","colors"]){if(def[a]===null||def[a]===undefined)this.removeAttribute(a);else this.setAttribute(a,def[a])}this.attributeChangedCallback("__rerender__",null,"")}finally{this._contourResetting=false}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{applied:false},bubbles:true,composed:true}))}})}}define("contour-style-panel",ContourStylePanel);class ContourResponsiveContent extends ContourBase{static get observed(){return["breakpoint"]}static get properties(){return{breakpoint:{attribute:"breakpoint"}}}render(){this.classList.add("c-responsive-content");const bp=this.getAttribute("breakpoint")||"md";this.dataset.breakpoint=bp}}define("contour-responsive-content",ContourResponsiveContent);class ContourAvatarGroup extends ContourBase{static get observed(){return["items","max"]}static get properties(){return{items:{attribute:"items"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-avatar-group");const items=this.getAttribute("items");const max=parseInt(this.getAttribute("max")||"4",10)||4;Array.from(this.querySelectorAll(".c-avatar, .c-avatar-group__overflow")).forEach((n)=>n.remove());if(items){try{const parsed=JSON.parse(items);const shown=parsed.slice(0,max);shown.forEach((it)=>{const av=document.createElement("span");av.className="c-avatar";const name=typeof it==="string"?it:(it.name||it.label||"");av.textContent=name.slice(0,2).toUpperCase();if(typeof it==="object"&&it.color){av.style.background=it.color;av.dataset.color=it.color}this.appendChild(av)});if(parsed.length>max){const overflow=document.createElement("span");overflow.className="c-avatar c-avatar-group__overflow";overflow.textContent="+"+(parsed.length-max);this.appendChild(overflow)}}catch(e){warnBadJson(this,"attribute",e)}}}}define("contour-avatar-group",ContourAvatarGroup);class ContourDivider extends ContourBase{static get observed(){return["label","orientation"]}static get properties(){return{label:{attribute:"label"},orientation:{attribute:"orientation"}}}render(){this.classList.add("c-divider");const orientation=this.getAttribute("orientation")||"horizontal";this.classList.add("c-divider--"+orientation);const label=this.getAttribute("label");if(label){const l=this.ensure(".c-divider__label",()=>{const el=document.createElement("span");el.className="c-divider__label";return el});l.textContent=label}}}define("contour-divider",ContourDivider);class ContourStatusLight extends ContourBase{static get observed(){return["status","label"]}static get properties(){return{status:{attribute:"status"},label:{attribute:"label"}}}render(){this.classList.add("c-status-light");const status=this.getAttribute("status")||"neutral";this.classList.add("c-status-light--"+status);if(!this.hasAttribute("role"))this.setAttribute("role","img");const label=this.getAttribute("label");if(label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",label);else if(!label&&!this.hasAttribute("aria-label"))this.setAttribute("aria-label",status);if(label){const l=this.ensure(".c-status-light__label",()=>{const el=document.createElement("span");el.className="c-status-light__label";return el});l.textContent=label}}}define("contour-status-light",ContourStatusLight);class ContourSplitButton extends ContourBase{static get observed(){return["label","menu"]}static get properties(){return{label:{attribute:"label"},menu:{attribute:"menu"}}}render(){this.classList.add("c-split-button");const main=this.ensure(".c-split-button__main",()=>{const el=document.createElement("button");el.className="c-btn c-split-button__main";el.type="button";return el});main.textContent=this.getAttribute("label")||"Action";const toggle=this.ensure(".c-split-button__toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--icon c-split-button__toggle";el.type="button";el.setAttribute("aria-label","More options");el.textContent="▾";return el});const menu=this.ensure(".c-split-button__menu",()=>{const el=document.createElement("div");el.className="c-menu c-split-button__menu";el.setAttribute("role","menu");el.hidden=true;return el});if(!menu.id)menu.id=(this.id||contourId("split"))+"-menu";toggle.setAttribute("aria-haspopup","menu");toggle.setAttribute("aria-controls",menu.id);toggle.setAttribute("aria-expanded",String(!menu.hidden));const items=this.getAttribute("menu");if(items){try{const parsed=JSON.parse(items);menu.innerHTML="";parsed.forEach((it)=>{const li=document.createElement("button");li.className="c-menu__item";li.setAttribute("role","menuitem");li.textContent=typeof it==="string"?it:(it.label||it.title||"");menu.appendChild(li)})}catch(e){warnBadJson(this,"attribute",e)}}if(main.parentNode!==this)this.appendChild(main);if(toggle.parentNode!==this)this.appendChild(toggle);if(menu.parentNode!==this)this.appendChild(menu)}enhance(){if(this._wiredSplitButton)return;this._wiredSplitButton=true;const toggle=()=>this.querySelector(".c-split-button__toggle");const menu=()=>this.querySelector(".c-split-button__menu");const items=()=>Array.from(menu()?.querySelectorAll(".c-menu__item")||[]);const setOpen=(open,focusFirst)=>{const m=menu();const t=toggle();if(!m)return;const was=!m.hidden;m.hidden=!open;if(t)t.setAttribute("aria-expanded",String(open));if(open&&focusFirst){const first=items()[0];if(first)try{first.focus()}catch(e){}}if(was!==open)this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{open}}))};this.addEventListener("click",(e)=>{const main=e.target&&e.target.closest?e.target.closest(".c-split-button__main"):null;if(main&&this.contains(main)){this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true,detail:{label:main.textContent}}));return}const t=toggle();if(e.target===t||(t&&t.contains(e.target))){const m=menu();setOpen(m?m.hidden:false,true);return}const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&this.contains(item)){const index=items().indexOf(item);setOpen(false,false);try{toggle()?.focus()}catch(err){}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent,index}}))}});this.addEventListener("keydown",(e)=>{const t=toggle();const m=menu();const list=items();const onToggle=e.target===t||(t&&t.contains(e.target));const idx=list.indexOf(e.target);if(onToggle&&(e.key==="Enter"||e.key===" "||e.key==="ArrowDown")){e.preventDefault();setOpen(true,true)}else if(onToggle&&e.key==="ArrowUp"){e.preventDefault();setOpen(true,false);const last=list[list.length-1];if(last)try{last.focus()}catch(err){}}else if(idx>=0){if(e.key==="ArrowDown"){e.preventDefault();list[(idx+1)%list.length]?.focus()}else if(e.key==="ArrowUp"){e.preventDefault();list[(idx-1+list.length)%list.length]?.focus()}else if(e.key==="Home"){e.preventDefault();list[0]?.focus()}else if(e.key==="End"){e.preventDefault();list[list.length-1]?.focus()}else if(e.key==="Escape"){e.preventDefault();setOpen(false,false);try{t?.focus()}catch(err){}}}else if(e.key==="Escape"&&m&&!m.hidden){setOpen(false,false);try{t?.focus()}catch(err){}}});const docClick=(e)=>{const m=menu();if(m&&!m.hidden&&!this.contains(e.target))setOpen(false,false)};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick))}}define("contour-split-button",ContourSplitButton);class ContourPaletteEditor extends ContourBase{static get observed(){return["colors"]}static get properties(){return{colors:{attribute:"colors"}}}_palette(){let parsed=[];try{const c=this.getAttribute("colors");parsed=c?JSON.parse(c):[]}catch(e){warnBadJson(this,"colors",e)}if(!Array.isArray(parsed))parsed=[];return parsed.map((c)=>typeof c==="string"?{color:c,name:c}:{color:String(c.color||c.value||"#000000"),name:String(c.name||c.label||c.color||c.value||"color")})}_writePalette(entries){this.setAttribute("colors",JSON.stringify(entries.map((e)=>e.name===e.color?e.color:{color:e.color,name:e.name})))}render(){this.classList.add("c-palette-editor");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Palette editor");const entries=this._palette();Array.from(this.querySelectorAll(".c-palette-editor__swatch, .c-palette-editor__edit, .c-palette-editor__remove, .c-palette-editor__add, .c-palette-editor__contrast")).forEach((n)=>n.remove());entries.forEach((entry,i)=>{const sw=document.createElement("button");sw.className="c-palette-editor__swatch c-swatch"+(this._paletteSelected===i?" is-selected":"");sw.type="button";sw.style.background=safeColor(entry.color);sw.dataset.color=entry.color;sw.dataset.index=String(i);sw.setAttribute("aria-label",entry.name);sw.setAttribute("aria-pressed",String(this._paletteSelected===i));this.appendChild(sw);const edit=document.createElement("input");edit.type="color";edit.className="c-palette-editor__edit";edit.value=/^#[0-9a-f]{6}$/i.test(entry.color)?entry.color:"#000000";edit.dataset.index=String(i);edit.setAttribute("aria-label","Edit "+entry.name);this.appendChild(edit);const rm=document.createElement("button");rm.type="button";rm.className="c-palette-editor__remove";rm.dataset.index=String(i);rm.setAttribute("aria-label","Remove "+entry.name);rm.textContent="×";this.appendChild(rm)});const add=document.createElement("button");add.type="button";add.className="c-palette-editor__add";add.setAttribute("aria-label",labelText(this,"add-color","Add color"));add.textContent="+";this.appendChild(add);const sel=entries[this._paletteSelected];if(sel){const lum=(hex)=>{const m=/^#([0-9a-f]{6})$/i.exec(hex);if(!m)return null;const n=parseInt(m[1],16);const ch=[(n>>16)&255,(n>>8)&255,n&255].map((v)=>{v/=255;return v<=0.03928?v/12.92:Math.pow((v+0.055)/1.055,2.4)});return 0.2126*ch[0]+0.7152*ch[1]+0.0722*ch[2]};const l=lum(sel.color);const out=document.createElement("span");out.className="c-palette-editor__contrast";if(l===null){out.textContent=sel.color}else{const ratio=(a,b)=>(Math.max(a,b)+0.05)/(Math.min(a,b)+0.05);const onWhite=ratio(l,1),onBlack=ratio(l,0);const best=Math.max(onWhite,onBlack);out.textContent=sel.name+": "+onWhite.toFixed(1)+":1 on white, "+onBlack.toFixed(1)+":1 on black — "+(best>=4.5?"AA":"below AA")}this.appendChild(out)}}enhance(){if(this._wiredPaletteEditor)return;this._wiredPaletteEditor=true;this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target:null;if(!t)return;const sw=t.closest(".c-palette-editor__swatch");if(sw&&this.contains(sw)){this._paletteSelected=Number(sw.dataset.index);this.requestRender();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{color:sw.dataset.color}}));return}const rm=t.closest(".c-palette-editor__remove");if(rm&&this.contains(rm)){const entries=this._palette();const i=Number(rm.dataset.index);const[gone]=entries.splice(i,1);if(this._paletteSelected>=entries.length)this._paletteSelected=entries.length-1;this._writePalette(entries);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:gone?gone.color:""}}));return}if(t.closest(".c-palette-editor__add")){const entries=this._palette();const next="#888888";entries.push({color:next,name:next});this._paletteSelected=entries.length-1;this._writePalette(entries);this.dispatchEvent(new CustomEvent("contour:add",{bubbles:true,composed:true,detail:{value:next}}))}});this.addEventListener("change",(e)=>{const edit=e.target&&e.target.closest?e.target.closest(".c-palette-editor__edit"):null;if(!edit||!this.contains(edit))return;const entries=this._palette();const i=Number(edit.dataset.index);if(!entries[i])return;entries[i].color=edit.value;if(entries[i].name===entries[i].color||/^#[0-9a-f]{6}$/i.test(entries[i].name))entries[i].name=edit.value;this._writePalette(entries);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{color:edit.value,values:entries.map((en)=>en.color)}}))});this.addEventListener("keydown",(e)=>{const swatches=Array.from(this.querySelectorAll(".c-palette-editor__swatch"));if(!swatches.includes(e.target))return;navKey(e,swatches,{wrap:true,enter:true,onKey:(k,idx,item)=>{if(k==="Enter"||k===" ")item.click()}})})}}define("contour-palette-editor",ContourPaletteEditor);class ContourDateRange extends ContourBase{static get observed(){return["start","end","label","time","min","max","locale","name","required","disabled"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},label:{attribute:"label"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"},name:{attribute:"name"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return true}render(){this.classList.add("c-date-range");if(this._dateRangeDefaultStart===undefined){this._dateRangeDefaultStart=this.getAttribute("start");this._dateRangeDefaultEnd=this.getAttribute("end")}this.setAttribute("role","group");this.setAttribute("aria-label",this.getAttribute("label")||"Date range");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-date-range__label",()=>{const el=document.createElement("span");el.className="c-date-range__label";return el});l.textContent=label}const start=this.ensure(".c-date-range__start",()=>{const el=document.createElement("input");el.className="c-input c-date-range__start";return el});start.type=this.hasAttribute("time")?"datetime-local":"date";start.value=this.getAttribute("start")||"";start.setAttribute("aria-label",label?label+" — start":"Start date");const end=this.ensure(".c-date-range__end",()=>{const el=document.createElement("input");el.className="c-input c-date-range__end";return el});end.type=start.type;end.value=this.getAttribute("end")||"";end.setAttribute("aria-label",label?label+" — end":"End date");const min=this.getAttribute("min");const max=this.getAttribute("max");[start,end].forEach((input)=>{if(min)input.min=min;else input.removeAttribute("min");if(max)input.max=max;else input.removeAttribute("max");if(this.getAttribute("locale"))input.lang=this.getAttribute("locale");if(this.hasAttribute("disabled"))input.setAttribute("disabled","");else input.removeAttribute("disabled")});if(start.value)end.min=min&&min>start.value?min:start.value;if(end.value)start.max=max&&max<end.value?max:end.value;if(this.hasAttribute("required"))this.setAttribute("aria-required","true");else this.removeAttribute("aria-required");if(this._internals)this._syncFormValue()}enhance(){if(this._wiredDateRange)return;this._wiredDateRange=true;this.addEventListener("change",(e)=>{const t=e.target;if(t&&(t.classList.contains("c-date-range__start")||t.classList.contains("c-date-range__end"))){const s=this.querySelector(".c-date-range__start");const en=this.querySelector(".c-date-range__end");this.batch(()=>{if(s)this.setAttribute("start",s.value);if(en)this.setAttribute("end",en.value)});this._syncFormValue();this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{start:s?.value,end:en?.value}}))}})}_syncFormValue(){if(!this._internals)return;const start=this.querySelector(".c-date-range__start")?.value||"";const end=this.querySelector(".c-date-range__end")?.value||"";const name=this.getAttribute("name");if(name&&(start||end)){const fd=new FormData();if(start)fd.append(name,start);if(end)fd.append(name,end);this._internals.setFormValue(fd)}else{this._internals.setFormValue(null)}const missing=this.hasAttribute("required")&&(!start||!end);const inverted=!!(start&&end&&start>end);if(missing)this._internals.setValidity({valueMissing:true},"Both dates are required.");else if(inverted)this._internals.setValidity({customError:true},"Start must be on or before end.");else this._internals.setValidity({});this._setCustomState("data-invalid",missing||inverted);for(const input of this.querySelectorAll("input"))input.setAttribute("aria-invalid",String(missing||inverted))}formResetCallback(){this._contourResetting=true;try{if(this._dateRangeDefaultStart===null)this.removeAttribute("start");else this.setAttribute("start",this._dateRangeDefaultStart);if(this._dateRangeDefaultEnd===null)this.removeAttribute("end");else this.setAttribute("end",this._dateRangeDefaultEnd);this._syncFormValue()}finally{this._contourResetting=false}}formStateRestoreCallback(state){if(!this._internals||state==null)return;const values=state instanceof FormData?Array.from(state.getAll(this.getAttribute("name"))).map(String):String(state).split(",");this._contourResetting=true;try{this.setAttribute("start",values[0]||"");this.setAttribute("end",values[1]||"");this._syncFormValue()}finally{this._contourResetting=false}}}define("contour-date-range",ContourDateRange);class ContourShortcut extends ContourBase{static get observed(){return["key","label"]}static get properties(){return{key:{attribute:"key"},label:{attribute:"label"}}}render(){this.classList.add("c-shortcut");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"Keyboard shortcut");const key=this.getAttribute("key")||"";const label=this.getAttribute("label")||"";if(key){const k=this.ensure(".c-shortcut__key",()=>{const el=document.createElement("kbd");el.className="c-shortcut__key";return el});k.textContent=key}if(label){const l=this.ensure(".c-shortcut__label",()=>{const el=document.createElement("span");el.className="c-shortcut__label";return el});l.textContent=label}}enhance(){if(this._wiredShortcut)return;this._wiredShortcut=true;const key=this.getAttribute("key");if(key){const handler=(e)=>{if(e.key===key&&(e.metaKey||e.ctrlKey)){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}};document.addEventListener("keydown",handler);onDispose(this,()=>document.removeEventListener("keydown",handler))}}}define("contour-shortcut",ContourShortcut);class ContourPopover extends ContourBase{static get observed(){return["title","content"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"}}}render(){this.classList.add("c-popover");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Popover");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("popover");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-popover__title",()=>{const el=document.createElement("div");el.className="c-popover__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-popover__body",()=>{const el=document.createElement("div");el.className="c-popover__body";return el});c.textContent=content}}enhance(){if(this._wiredPopover)return;this._wiredPopover=true;const close=()=>{try{this.hidePopover()}catch(e){}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const keyHandler=(e)=>{const open=this.classList.contains("is-open")||this.matches(":popover-open");if(!open)return;if(e.key==="Escape"){e.preventDefault();close();return}if(e.key==="Tab"){const focusable=Array.from(this.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!focusable.length){e.preventDefault();return}const first=focusable[0];const last=focusable[focusable.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("contour:show",(e)=>{if(e.target&&e.target!==this&&this.contains(e.target)){this.classList.add("is-parent")}});this.addEventListener("contour:close",(e)=>{if(e.target&&e.target!==this){this.classList.remove("is-parent")}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-popover__close"):null;if(btn&&this.contains(btn))close()})}}define("contour-popover",ContourPopover);class ContourDatePicker extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","range","range-start","range-end","label","disabled","error","help","time","min","max","locale"]}static get properties(){return{value:{attribute:"value"},range:{attribute:"range",type:Boolean},rangeStart:{attribute:"range-start"},rangeEnd:{attribute:"range-end"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"}}}render(){this.classList.add("c-date-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Date picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-date-picker__label",()=>{const el=document.createElement("label");el.className="c-date-picker__label";return el});l.textContent=label}const input=this.ensure(".c-date-picker__input",()=>{const el=document.createElement("input");el.className="c-input c-date-picker__input";return el});const range=this.hasAttribute("range");const type=this.hasAttribute("time")?"datetime-local":"date";const configure=(control,value,name)=>{control.type=type;const next=value||"";if(document.activeElement!==control&&control.value!==next)control.value=next;control.setAttribute("aria-label",name);if(this.hasAttribute("min"))control.min=this.getAttribute("min");else control.removeAttribute("min");if(this.hasAttribute("max"))control.max=this.getAttribute("max");else control.removeAttribute("max");if(this.hasAttribute("locale"))control.lang=this.getAttribute("locale");else control.removeAttribute("lang");if(this.hasAttribute("disabled"))control.setAttribute("disabled","");else control.removeAttribute("disabled")};configure(input,range?this.getAttribute("range-start"):this.getAttribute("value"),range?"Start date":(label||"Date"));let end=this.querySelector(".c-date-picker__end");if(range){end=end||document.createElement("input");end.className="c-input c-date-picker__input c-date-picker__end";configure(end,this.getAttribute("range-end"),"End date");if(end.parentNode!==this)this.appendChild(end)}else if(end)end.remove();if(this.hasAttribute("disabled"))this.classList.add("is-disabled");else this.classList.remove("is-disabled");const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-date-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-date-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-date-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}}_renderCalendar(){const cal=this.querySelector(".c-date-picker__calendar");if(!cal)return;const input=this.querySelector(".c-date-picker__input");const base=(input&&input.value)?new Date(input.value):new Date();const month=this._calMonth||new Date(base.getFullYear(),base.getMonth(),1);this._calMonth=month;const y=month.getFullYear();const m=month.getMonth();const first=new Date(y,m,1);const startDay=first.getDay();const daysInMonth=new Date(y,m+1,0).getDate();cal.innerHTML="";const header=document.createElement("div");header.className="c-date-picker__calendar-header";const prev=document.createElement("button");prev.type="button";prev.className="c-btn c-btn--sm";prev.textContent="‹";prev.setAttribute("aria-label","Previous month");const title=document.createElement("span");title.className="c-date-picker__calendar-title";title.textContent=month.toLocaleString(this.getAttribute("locale")||undefined,{month:"long",year:"numeric"});const next=document.createElement("button");next.type="button";next.className="c-btn c-btn--sm";next.textContent="›";next.setAttribute("aria-label","Next month");header.appendChild(prev);header.appendChild(title);header.appendChild(next);cal.appendChild(header);const grid=document.createElement("div");grid.className="c-date-picker__calendar-grid";grid.setAttribute("role","grid");grid.setAttribute("aria-label",title.textContent);const rowEl=()=>{const row=document.createElement("div");row.className="c-date-picker__calendar-row";row.setAttribute("role","row");grid.appendChild(row);return row};let row=rowEl();let cells=0;const push=(cell)=>{if(cells===7){row=rowEl();cells=0}row.appendChild(cell);cells++};const weekdays=["Su","Mo","Tu","We","Th","Fr","Sa"];const weekdayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];weekdays.forEach((w,i)=>{const h=document.createElement("div");h.className="c-date-picker__calendar-weekday";h.setAttribute("role","columnheader");h.setAttribute("aria-label",weekdayNames[i]);h.textContent=w;push(h)});for(let i=0;i<startDay;i++){const empty=document.createElement("div");empty.className="c-date-picker__calendar-day c-date-picker__calendar-day--empty";empty.setAttribute("role","gridcell");empty.setAttribute("aria-hidden","true");push(empty)}const selected=input?input.value:"";const inMonth=selected&&selected.slice(0,7)===`${y}-${String(m + 1).padStart(2, "0")}`;const stopDay=inMonth?parseInt(selected.slice(8,10),10)||1:1;for(let d=1;d<=daysInMonth;d++){const btn=document.createElement("button");btn.type="button";btn.className="c-date-picker__calendar-day";btn.textContent=String(d);btn.setAttribute("role","gridcell");btn.setAttribute("tabindex",d===stopDay?"0":"-1");btn.setAttribute("aria-label",new Date(y,m,d).toLocaleDateString(this.getAttribute("locale")||undefined,{weekday:"long",day:"numeric",month:"long",year:"numeric"}));const iso=`${y}-${String(m + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`;if(selected&&selected.startsWith(iso)){btn.classList.add("is-selected");btn.setAttribute("aria-selected","true")}btn.addEventListener("click",()=>{if(input){input.value=iso;input.dispatchEvent(new Event("change",{bubbles:true}))}cal.setAttribute("hidden","");const tgl=this.querySelector(".c-date-picker__calendar-toggle");if(tgl)tgl.setAttribute("aria-expanded","false")});push(btn)}cal.appendChild(grid);prev.addEventListener("click",()=>{this._calMonth=new Date(y,m-1,1);this._renderCalendar()});next.addEventListener("click",()=>{this._calMonth=new Date(y,m+1,1);this._renderCalendar()});if(this._internals)this._syncFormValue()}_syncFormValue(){if(!this._internals)return;const start=this.querySelector(".c-date-picker__input");const end=this.querySelector(".c-date-picker__end");if(this.hasAttribute("range")&&end){this._internals.setFormValue((start?start.value:"")+","+end.value)}else{this._internals.setFormValue(start&&start.value?start.value:null)}this._syncValidity(this.hasAttribute("required")&&!(start&&start.value))}enhance(){if(this._wiredDatePicker)return;this._wiredDatePicker=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-date-picker__input")){const end=this.querySelector(".c-date-picker__end");const detail=end?{start:this.querySelector(".c-date-picker__input").value,end:end.value}:{value:t.value};this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail}))}});const toggle=()=>{const cal=this.querySelector(".c-date-picker__calendar");const btn=this.querySelector(".c-date-picker__calendar-toggle");if(!cal)return;const hidden=cal.hasAttribute("hidden");if(hidden){cal.removeAttribute("hidden");if(btn)btn.setAttribute("aria-expanded","true");this._renderCalendar()}else{cal.setAttribute("hidden","");if(btn)btn.setAttribute("aria-expanded","false")}};this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-date-picker__calendar-toggle"):null;if(btn&&this.contains(btn)){e.preventDefault();toggle()}});this.addEventListener("keydown",(e)=>{const cal=this.querySelector(".c-date-picker__calendar");if(!cal||cal.hasAttribute("hidden"))return;const cells=Array.from(cal.querySelectorAll('[role="gridcell"]:not([aria-hidden="true"])'));const i=cells.indexOf(document.activeElement);if(i<0)return;if(e.key==="PageUp"||e.key==="PageDown"){e.preventDefault();const btn=this.querySelector(e.key==="PageUp"?".c-date-picker__calendar-header button:first-child":".c-date-picker__calendar-header button:last-child");if(btn)btn.click();return}let next=-1;if(e.key==="ArrowRight")next=i+1;else if(e.key==="ArrowLeft")next=i-1;else if(e.key==="ArrowDown")next=i+7;else if(e.key==="ArrowUp")next=i-7;else if(e.key==="Home")next=0;else if(e.key==="End")next=cells.length-1;else return;e.preventDefault();if(next<0||next>=cells.length)return;cells.forEach((cell,j)=>cell.setAttribute("tabindex",j===next?"0":"-1"));cells[next].focus()})}}define("contour-date-picker",ContourDatePicker);class ContourRating extends ContourBase{static get observed(){return["value","max","color"]}static get properties(){return{value:{attribute:"value",type:Number},max:{attribute:"max",type:Number},color:{attribute:"color"}}}render(){this.classList.add("c-rating");if(!this.hasAttribute("role"))this.setAttribute("role","radiogroup");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Rating");const max=parseInt(this.getAttribute("max")||"5",10)||5;const value=parseInt(this.getAttribute("value")||"0",10)||0;const color=this.getAttribute("color");Array.from(this.querySelectorAll(".c-rating__star")).forEach((n)=>n.remove());const stop=value>=1&&value<=max?value:1;for(let i=1;i<=max;i++){const star=document.createElement("button");star.className="c-rating__star"+(i<=value?" c-rating__star--filled":"");star.type="button";star.setAttribute("role","radio");star.setAttribute("aria-checked",String(i===value));star.setAttribute("tabindex",String(i===stop?0:-1));star.innerHTML='<span class="c-rating__swatch'+(i<=value?' c-rating__swatch--filled':'')+'" aria-hidden="true"></span>';if(color&&i<=value){const sw=star.firstChild;const safe=safeColor(color);if(sw&&safe){sw.style.backgroundColor=safe;sw.style.borderColor=safe}}star.dataset.value=String(i);star.setAttribute("aria-label",i+" star"+(i>1?"s":""));this.appendChild(star)}}enhance(){if(this._wiredRating)return;this._wiredRating=true;const stars=()=>Array.from(this.querySelectorAll(".c-rating__star"));const select=(v)=>{stars().forEach((st)=>{const on=parseInt(st.dataset.value,10)===v;st.setAttribute("aria-checked",String(on));st.setAttribute("tabindex",on?"0":"-1");st.classList.toggle("c-rating__star--filled",parseInt(st.dataset.value,10)<=v);const sw=st.querySelector(".c-rating__swatch");if(sw)sw.classList.toggle("c-rating__swatch--filled",parseInt(st.dataset.value,10)<=v)});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:v}}))};this.addEventListener("click",(e)=>{const star=e.target&&e.target.closest?e.target.closest(".c-rating__star"):null;if(star&&this.contains(star))select(parseInt(star.dataset.value,10))});this.addEventListener("keydown",(e)=>{const all=stars();if(!all.length)return;navKey(e,all,{wrap:false,homeEnd:true,onNavigate:(i)=>{select(parseInt(all[i].dataset.value,10))},onKey:(key,i)=>{if(key==="Enter"||key===" ")select(parseInt(all[i].dataset.value,10))},})})}}define("contour-rating",ContourRating);class ContourTimePicker extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-time-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Time picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-time-picker__label",()=>{const el=document.createElement("label");el.className="c-time-picker__label";return el});l.textContent=label}const input=this.ensure(".c-time-picker__input",()=>{const el=document.createElement("input");el.className="c-input c-time-picker__input";el.type="time";el.setAttribute("aria-label",this.getAttribute("label")||"Time picker");return el});input.value=this.getAttribute("value")||"";if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-time-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-time-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-time-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}if(this._internals)this._syncFormValue()}enhance(){if(this._wiredTimePicker)return;this._wiredTimePicker=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-time-picker__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}})}}define("contour-time-picker",ContourTimePicker);class ContourColorPicker extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","label","disabled","error","help","alpha","presets"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},alpha:{attribute:"alpha",type:Boolean},presets:{attribute:"presets"}}}render(){this.classList.add("c-color-picker");this.setAttribute("role","group");this.setAttribute("aria-label","Color picker");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-color-picker__label",()=>{const el=document.createElement("label");el.className="c-color-picker__label";return el});l.textContent=label}const input=this.ensure(".c-color-picker__input",()=>{const el=document.createElement("input");el.className="c-color-picker__input";el.type="color";return el});input.value=(this.getAttribute("value")||"#000000").slice(0,7);if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label",label||"Color");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}if(this.hasAttribute("alpha")){const alpha=this.ensure(".c-color-picker__alpha",()=>{const el=document.createElement("input");el.className="c-color-picker__alpha";el.type="range";el.min="0";el.max="1";el.step="0.01";return el});const v=this.getAttribute("value")||"#000000";const a=v.length===9?parseInt(v.slice(7,9),16)/255:1;alpha.value=String(a);alpha.setAttribute("aria-label","Alpha")}else{const a=this.querySelector(".c-color-picker__alpha");if(a)a.remove()}const presetsAttr=this.getAttribute("presets");let presets=[];if(presetsAttr){try{presets=JSON.parse(presetsAttr)}catch(e){presets=[]}}const oldPresets=this.querySelector(".c-color-picker__presets");if(oldPresets)oldPresets.remove();if(Array.isArray(presets)&&presets.length){const wrap=document.createElement("div");wrap.className="c-color-picker__presets";presets.forEach((c)=>{const btn=document.createElement("button");btn.type="button";btn.className="c-color-picker__preset";btn.style.background=c;btn.dataset.color=c;btn.setAttribute("aria-label",labelText(this,"preset","Preset")+" "+c);wrap.appendChild(btn)});this.appendChild(wrap)}if(typeof window!=="undefined"&&"EyeDropper"in window){const ed=this.ensure(".c-color-picker__eyedropper",()=>{const el=document.createElement("button");el.className="c-color-picker__eyedropper";el.type="button";el.textContent=labelText(this,"pick","Pick");el.setAttribute("aria-label",labelText(this,"pick-color","Pick color from screen"));return el});if(this.hasAttribute("disabled"))ed.setAttribute("disabled","");else ed.removeAttribute("disabled")}else{const ed=this.querySelector(".c-color-picker__eyedropper");if(ed)ed.remove()}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-color-picker__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-color-picker__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-color-picker__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}if(this._internals)this._syncFormValue()}enhance(){if(this._wiredColorPicker)return;this._wiredColorPicker=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});this.addEventListener("contour:change",()=>{this._syncFormValue()});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-color-picker__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}if(t&&t.classList.contains("c-color-picker__alpha")){const base=(this.getAttribute("value")||"#000000").slice(0,7);const a=Math.round(parseFloat(t.value)*255).toString(16).padStart(2,"0");const val=base+a;this.setAttribute("value",val);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:val}}))}});this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-color-picker__preset"):null;if(btn&&this.contains(btn)){const c=btn.dataset.color;if(c){this.setAttribute("value",c);const input=this.querySelector(".c-color-picker__input");if(input)input.value=c.slice(0,7);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:c}}))}}const ed=e.target&&e.target.closest?e.target.closest(".c-color-picker__eyedropper"):null;if(ed&&this.contains(ed)&&typeof window!=="undefined"&&"EyeDropper"in window){e.preventDefault();const dropper=new window.EyeDropper();dropper.open().then((r)=>{if(r&&r.sRGBHex){this.setAttribute("value",r.sRGBHex);const input=this.querySelector(".c-color-picker__input");if(input)input.value=r.sRGBHex;this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:r.sRGBHex}}))}}).catch(()=>{})}})}}define("contour-color-picker",ContourColorPicker);class ContourNumberField extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","min","max","step","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},step:{attribute:"step"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-number-field");const label=this.getAttribute("label");if(label){const l=this.ensure(".c-number-field__label",()=>{const el=document.createElement("label");el.className="c-number-field__label";return el});l.textContent=label}const input=this.ensure(".c-number-field__input",()=>{const el=document.createElement("input");el.className="c-input c-number-field__input";el.type="number";el.setAttribute("role","spinbutton");return el});if(this.getAttribute("value")!==null)input.value=this.getAttribute("value");if(this.getAttribute("min")!==null)input.min=this.getAttribute("min");if(this.getAttribute("max")!==null)input.max=this.getAttribute("max");if(this.getAttribute("step")!==null)input.step=this.getAttribute("step");const v=input.value;input.setAttribute("aria-valuenow",v===""?"":v);if(input.min!=="")input.setAttribute("aria-valuemin",input.min);if(input.max!=="")input.setAttribute("aria-valuemax",input.max);if(!input.hasAttribute("aria-label"))input.setAttribute("aria-label",label||"Number");if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-number-field__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-number-field__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-number-field__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const toggle=this.ensure(".c-date-picker__calendar-toggle",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-date-picker__calendar-toggle";el.type="button";el.textContent="📅";el.setAttribute("aria-label","Open calendar");el.setAttribute("aria-expanded","false");return el});let cal=this.querySelector(".c-date-picker__calendar");if(!cal){cal=document.createElement("div");cal.className="c-date-picker__calendar";cal.setAttribute("hidden","");cal.setAttribute("role","dialog");cal.setAttribute("aria-label","Calendar");this.appendChild(cal)}if(this._internals)this._syncFormValue()}enhance(){if(this._wiredNumberField)return;this._wiredNumberField=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-number-field__input")){this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:t.value}}))}});this.addEventListener("keydown",(e)=>{const input=this.querySelector(".c-number-field__input");if(!input||document.activeElement!==input)return;const step=Number(input.step)||1;const min=input.min===""?-Infinity:Number(input.min);const max=input.max===""?Infinity:Number(input.max);let next=null;if(e.key==="ArrowUp")next=(Number(input.value)||0)+step;else if(e.key==="ArrowDown")next=(Number(input.value)||0)-step;else if(e.key==="Home")next=min===-Infinity?0:min;else if(e.key==="End")next=max===Infinity?(Number(input.value)||0):max;if(next!==null){e.preventDefault();next=Math.min(max,Math.max(min,next));input.value=String(next);input.setAttribute("aria-valuenow",String(next));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{value:input.value}}))}})}}define("contour-number-field",ContourNumberField);class ContourHoverCard extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},anchor:{attribute:"anchor"}}}render(){this.classList.add("c-hover-card");if(!this.hasAttribute("role"))this.setAttribute("role","tooltip");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Hover card");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("hover-card");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-hover-card__title",()=>{const el=document.createElement("div");el.className="c-hover-card__title";return el});t.textContent=title}const content=this.getAttribute("content");if(content){const c=this.ensure(".c-hover-card__body",()=>{const el=document.createElement("div");el.className="c-hover-card__body";return el});c.textContent=content}}enhance(){if(this._wiredHoverCard)return;this._wiredHoverCard=true;const anchorSel=this.getAttribute("anchor");if(anchorSel){const trigger=anchorSel.startsWith("#")?document.getElementById(anchorSel.slice(1)):document.querySelector(anchorSel);if(trigger){trigger.setAttribute("popovertarget",this.id);let showTimer=null;const hasPopover=typeof this.showPopover==="function";const show=()=>{if(hasPopover){try{this.showPopover()}catch(e){}}else this.classList.add("is-open");this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))};const hide=()=>{if(showTimer)clearTimeout(showTimer);if(hasPopover){try{this.hidePopover()}catch(e){}}else this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))};const onEnter=()=>{showTimer=setTimeout(show,300)};const onLeave=()=>{hide()};const onFocus=()=>show();const onBlur=()=>{setTimeout(hide,100)};trigger.addEventListener("mouseenter",onEnter);trigger.addEventListener("mouseleave",onLeave);trigger.addEventListener("focus",onFocus);trigger.addEventListener("blur",onBlur);onDispose(this,()=>{if(showTimer){clearTimeout(showTimer);showTimer=null}trigger.removeEventListener("mouseenter",onEnter);trigger.removeEventListener("mouseleave",onLeave);trigger.removeEventListener("focus",onFocus);trigger.removeEventListener("blur",onBlur)})}}const keyHandler=(e)=>{if(e.key==="Escape"&&(this.classList.contains("is-open")||this.matches(":popover-open"))){e.preventDefault();if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-hover-card",ContourHoverCard);class ContourContextMenu extends ContourBase{static get observed(){return["items","trigger"]}static get properties(){return{items:{attribute:"items"},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-context-menu");if(!this.hasAttribute("role"))this.setAttribute("role","menu");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Context menu");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("context-menu");const items=this.getAttribute("items");if(items){try{const parsed=JSON.parse(items);this.innerHTML="";parsed.forEach((it)=>{const btn=document.createElement("button");btn.className="c-menu__item";btn.setAttribute("role","menuitem");btn.textContent=typeof it==="string"?it:(it.label||it.title||"");this.appendChild(btn)})}catch(e){warnBadJson(this,"attribute",e)}}}enhance(){if(this._wiredContextMenu)return;this._wiredContextMenu=true;const openAt=(x,y)=>{if(typeof this.showPopover==="function"){try{this.showPopover()}catch(err){}}else this.classList.add("is-open");if(Number.isFinite(x)&&Number.isFinite(y)){this.style.position="fixed";this.style.left=x+"px";this.style.top=y+"px"}};const triggerSel=this.getAttribute("trigger");if(triggerSel){const trigger=document.querySelector(triggerSel);if(trigger){if(!trigger.hasAttribute("aria-haspopup"))trigger.setAttribute("aria-haspopup","menu");const onCtx=(e)=>{e.preventDefault();openAt(e.clientX,e.clientY)};trigger.addEventListener("contextmenu",onCtx);onDispose(this,()=>trigger.removeEventListener("contextmenu",onCtx))}}this.addEventListener("contextmenu",(e)=>{e.preventDefault();openAt(e.clientX,e.clientY)});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;if(item&&this.contains(item)){this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.textContent.trim()}}));if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open")}});this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-menu__item"));navKey(e,items,{wrap:true,onKey:()=>{if(e.key==="Enter"||e.key===" ")document.activeElement.click()}});if(e.key==="Escape"){e.preventDefault();if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(err){}}this.classList.remove("is-open")}})}}define("contour-context-menu",ContourContextMenu);class ContourFab extends ContourBase{static get observed(){return["label","icon"]}static get properties(){return{label:{attribute:"label"},icon:{attribute:"icon"}}}render(){this.classList.add("c-fab");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");const label=this.getAttribute("label");if(label)this.setAttribute("aria-label",label);const icon=this.getAttribute("icon");if(icon&&!this.querySelector("svg")){const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href",icon.startsWith("#")?icon:"#"+icon);svg.appendChild(use);this.appendChild(svg)}}enhance(){if(this._wiredFab)return;this._wiredFab=true;this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:true,composed:true}))}})}}define("contour-fab",ContourFab);class ContourFileUpload extends ContourBase{static get formAssociated(){return true}static get observed(){return["label","accept","multiple","progress","name"]}static get properties(){return{label:{attribute:"label"},accept:{attribute:"accept"},multiple:{attribute:"multiple",type:Boolean},progress:{attribute:"progress"},name:{attribute:"name"}}}render(){this.classList.add("c-file-upload");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||"File upload");const label=this.getAttribute("label")||"Drop files here or click to browse";const dz=this.ensure(".c-file-upload__dropzone",()=>{const el=document.createElement("div");el.className="c-file-upload__dropzone";el.setAttribute("role","button");el.tabIndex=0;return el});dz.textContent=label;const input=this.ensure(".c-file-upload__input",()=>{const el=document.createElement("input");el.className="c-file-upload__input";el.type="file";el.hidden=true;return el});input.accept=this.getAttribute("accept")||"";input.multiple=this.hasAttribute("multiple");const p=this.getAttribute("progress");if(p!==null){const bar=this.ensure(".c-file-upload__progress",()=>{const el=document.createElement("progress");el.className="c-file-upload__progress";return el});bar.value=Number(p)||0;bar.max=100}else{const bar=this.querySelector(".c-file-upload__progress");if(bar)bar.remove()}const preview=this.ensure(".c-file-upload__preview",()=>{const el=document.createElement("div");el.className="c-file-upload__preview";return el});if(!preview){}if(this._internals)this._syncFormValue()}enhance(){if(this._wiredFileUpload)return;this._wiredFileUpload=true;this._syncFormValue();this.addEventListener("change",()=>{this._syncFormValue()});const dz=()=>this.querySelector(".c-file-upload__dropzone");const input=()=>this.querySelector(".c-file-upload__input");const activate=()=>{const i=input();if(i)i.click()};this.addEventListener("click",(e)=>{const d=dz();if(e.target===d||(d&&d.contains(e.target))){activate()}});this.addEventListener("keydown",(e)=>{const d=dz();if((e.target===d||(d&&d.contains(e.target)))&&(e.key==="Enter"||e.key===" ")){e.preventDefault();activate()}});const renderPreview=(files)=>{const preview=this.querySelector(".c-file-upload__preview");if(!preview)return;this._revokeObjectUrls();preview.innerHTML="";Array.from(files||[]).forEach((f)=>{const item=document.createElement("div");item.className="c-file-upload__preview-item";if(f.type&&f.type.startsWith("image/")){const img=document.createElement("img");img.className="c-file-upload__preview-thumb";img.alt=f.name;img.loading="lazy";img.decoding="async";try{const u=URL.createObjectURL(f);img.src=u;(this._objectUrls||(this._objectUrls=[])).push(u)}catch(e){}item.appendChild(img)}else{const name=document.createElement("span");name.className="c-file-upload__preview-name";name.textContent=f.name;item.appendChild(name)}preview.appendChild(item)})};this.addEventListener("change",(e)=>{const t=e.target;if(t&&t.classList.contains("c-file-upload__input")){renderPreview(t.files);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{files:t.files}}))}});this.addEventListener("dragover",(e)=>{e.preventDefault();this.classList.add("is-dragover")});this.addEventListener("dragleave",()=>this.classList.remove("is-dragover"));this.addEventListener("drop",(e)=>{e.preventDefault();this.classList.remove("is-dragover");const i=input();if(i&&e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){try{i.files=e.dataTransfer.files}catch(err){}renderPreview(e.dataTransfer.files);this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{files:e.dataTransfer.files}}))}})}disconnectedCallback(){super.disconnectedCallback();this._revokeObjectUrls()}_revokeObjectUrls(){if(!this._objectUrls)return;this._objectUrls.forEach((u)=>{try{URL.revokeObjectURL(u)}catch(e){}});this._objectUrls=[]}_syncFormValue(){if(!this._internals)return;const inp=this.querySelector(".c-file-upload__input");if(inp&&inp.files&&inp.files.length){const fd=new FormData();const key=this.getAttribute("name")||"file";Array.from(inp.files).forEach((f)=>fd.append(key,f));this._internals.setFormValue(fd)}else{this._internals.setFormValue(null)}}}define("contour-file-upload",ContourFileUpload);class ContourNotificationCenter extends ContourBase{static get observed(){return["count","items","color"]}static get properties(){return{count:{attribute:"count"},items:{attribute:"items"},color:{attribute:"color"}}}render(){this.classList.add("c-notification-center");this.setAttribute("role","group");const btn=this.ensure(".c-notification-center__trigger",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-notification-center__trigger";el.type="button";el.innerHTML='<span class="c-notification-center__bullet" aria-hidden="true"></span>';el.setAttribute("aria-haspopup","dialog");el.setAttribute("aria-expanded","false");el.setAttribute("aria-label","Notifications");return el});const color=this.getAttribute("color");const bullet=btn.querySelector(".c-notification-center__bullet");if(bullet&&color){bullet.style.background=safeColor(color);bullet.dataset.color=color}const panel=this.ensure(".c-notification-center__panel",()=>{const el=document.createElement("div");el.className="c-notification-center__panel";el.hidden=true;el.setAttribute("role","dialog");el.setAttribute("aria-label","Notifications");return el});panel.hidden=!this._notifOpen;btn.setAttribute("aria-expanded",String(!!this._notifOpen));const authoredItems=Array.from(this.querySelectorAll(":scope > .c-notification-center__item"));const items=this.getAttribute("items");if(authoredItems.length){panel.innerHTML="";const lb=document.createElement("div");lb.setAttribute("role","listbox");lb.setAttribute("aria-label","Notifications");authoredItems.forEach((it)=>{lb.appendChild(it)});panel.appendChild(lb)}else if(items){let parsed=null;try{parsed=JSON.parse(items)}catch(e){warnBadJson(this,"items",e)}panel.innerHTML="";if(!Array.isArray(parsed)){const err=document.createElement("div");err.className="c-notification-center__error";err.setAttribute("role","alert");err.textContent=labelText(this,"error","Could not load notifications");panel.appendChild(err)}else{const lb=document.createElement("div");lb.setAttribute("role","listbox");lb.setAttribute("aria-label","Notifications");const shown=this._notifShown||50;parsed.slice(0,shown).forEach((it)=>{const row=document.createElement("div");row.className="c-notification-center__item"+(it&&it.read?" is-read":"");row.setAttribute("tabindex","-1");row.setAttribute("role","option");row.setAttribute("aria-selected","false");row.dataset.read=it&&it.read?"true":"false";const label=document.createElement("span");label.className="c-notification-center__item-label";label.textContent=typeof it==="string"?it:(it.text||it.title||"");row.appendChild(label);const archive=document.createElement("button");archive.type="button";archive.className="c-notification-center__archive";archive.setAttribute("aria-label",labelText(this,"archive","Archive notification"));archive.textContent="⤓";row.appendChild(archive);const dismiss=document.createElement("button");dismiss.type="button";dismiss.className="c-notification-center__dismiss";dismiss.setAttribute("aria-label",labelText(this,"dismiss","Dismiss notification"));dismiss.textContent="×";row.appendChild(dismiss);lb.appendChild(row)});const firstRow=lb.querySelector(".c-notification-center__item");if(firstRow)firstRow.tabIndex=0;panel.appendChild(lb);if(!parsed.length){const empty=document.createElement("div");empty.className="c-notification-center__empty";empty.textContent=labelText(this,"empty","No notifications");panel.appendChild(empty)}else if(parsed.length>shown){const more=document.createElement("button");more.type="button";more.className="c-btn c-btn--sm c-notification-center__more";more.textContent=labelText(this,"more","Show more")+" ("+(parsed.length-shown)+")";panel.appendChild(more)}}}this._syncNotifBadge()}_syncNotifBadge(){const btn=this.querySelector(".c-notification-center__trigger");if(!btn)return;const rows=Array.from(this.querySelectorAll(".c-notification-center__item"));let unread;if(this._notifInteracted||!this.hasAttribute("count"))unread=rows.filter((r)=>r.dataset.read!=="true").length;else unread=Number(this.getAttribute("count"))||0;let badge=btn.querySelector(".c-notification-center__badge");if(unread>0){if(!badge){badge=document.createElement("span");badge.className="c-notification-center__badge c-badge c-badge--dot";btn.appendChild(badge)}badge.textContent=String(unread)}else if(badge){badge.remove()}}enhance(){if(this._wiredNotifCenter)return;this._wiredNotifCenter=true;const activate=(item)=>{if(item.dataset.read!=="true"){item.dataset.read="true";item.classList.add("is-read");this._notifInteracted=true;this._syncNotifBadge();this.dispatchEvent(new CustomEvent("contour:read",{bubbles:true,composed:true,detail:{label:item.querySelector(".c-notification-center__item-label")?.textContent||item.textContent}}))}for(const r of this.querySelectorAll(".c-notification-center__item"))r.setAttribute("aria-selected",String(r===item));this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{label:item.querySelector(".c-notification-center__item-label")?.textContent||item.textContent}}))};const removeRow=(item,kind)=>{const label=item.querySelector(".c-notification-center__item-label")?.textContent||item.textContent;item.remove();this._notifInteracted=true;this._syncNotifBadge();this.dispatchEvent(new CustomEvent(kind==="archive"?"contour:remove":"contour:dismiss",{bubbles:true,composed:true,detail:{label}}))};this.addEventListener("click",(e)=>{const btn=this.querySelector(".c-notification-center__trigger");const panel=this.querySelector(".c-notification-center__panel");if(btn&&(e.target===btn||btn.contains(e.target))){if(panel){panel.hidden=!panel.hidden;this._notifOpen=!panel.hidden;btn.setAttribute("aria-expanded",String(!panel.hidden));this.dispatchEvent(new CustomEvent(panel.hidden?"contour:close":"contour:open",{bubbles:true,composed:true}))}return}const more=e.target&&e.target.closest?e.target.closest(".c-notification-center__more"):null;if(more&&this.contains(more)){this._notifShown=(this._notifShown||50)+50;this.requestRender();return}const archive=e.target&&e.target.closest?e.target.closest(".c-notification-center__archive"):null;if(archive&&this.contains(archive)){const item=archive.closest(".c-notification-center__item");if(item)removeRow(item,"archive");return}const dismiss=e.target&&e.target.closest?e.target.closest(".c-notification-center__dismiss"):null;if(dismiss&&this.contains(dismiss)){const item=dismiss.closest(".c-notification-center__item");if(item)removeRow(item,"dismiss");return}const item=e.target&&e.target.closest?e.target.closest(".c-notification-center__item"):null;if(item&&this.contains(item))activate(item)});const docClick=(e)=>{const panel=this.querySelector(".c-notification-center__panel");const btn=this.querySelector(".c-notification-center__trigger");if(panel&&!panel.hidden&&!this.contains(e.target)){panel.hidden=true;this._notifOpen=false;if(btn)btn.setAttribute("aria-expanded","false")}};document.addEventListener("click",docClick);onDispose(this,()=>document.removeEventListener("click",docClick));const keyHandler=(e)=>{const panel=this.querySelector(".c-notification-center__panel");const btn=this.querySelector(".c-notification-center__trigger");if(e.key==="Escape"&&panel&&!panel.hidden){panel.hidden=true;this._notifOpen=false;if(btn){btn.setAttribute("aria-expanded","false");try{btn.focus()}catch(err){}}return}if(!panel||panel.hidden)return;const items=Array.from(panel.querySelectorAll(".c-notification-center__item"));if(!items.length)return;if((e.key==="Enter"||e.key===" ")&&items.includes(e.target)){e.preventDefault();activate(e.target);return}if((e.key==="Delete"||e.key==="Backspace")&&items.includes(e.target)){e.preventDefault();const idx=items.indexOf(e.target);removeRow(e.target,"dismiss");const next=items[idx+1]||items[idx-1];if(next&&next.isConnected){try{next.focus()}catch(err){}}return}navKey(e,items,{wrap:true,onNavigate:(i)=>{items.forEach((r,j)=>{r.tabIndex=j===i?0:-1})}})};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler))}}define("contour-notification-center",ContourNotificationCenter);class ContourStepper extends ContourBase{static get observed(){return["steps","current"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"}}}render(){this.classList.add("c-stepper");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Stepper");const steps=this.getAttribute("steps");const current=Number(this.getAttribute("current")||0);const list=this.ensure(".c-stepper__list",()=>{const el=document.createElement("ol");el.className="c-stepper__list";return el});list.innerHTML="";const authoredSteps=Array.from(this.querySelectorAll(":scope > .c-stepper__step"));let parsed=[];if(authoredSteps.length){parsed=authoredSteps.map((el)=>el.textContent.trim());authoredSteps.forEach((el)=>el.remove())}else{try{parsed=steps?JSON.parse(steps):[]}catch(e){parsed=[]}}parsed.forEach((s,i)=>{const li=document.createElement("li");li.className="c-stepper__step"+(i===current?" is-current":"")+(i<current?" is-done":"");if(i===current)li.setAttribute("aria-current","step");li.textContent=typeof s==="string"?s:(s.title||s.label||"");list.appendChild(li)});const nav=this.ensure(".c-stepper__nav",()=>{const el=document.createElement("div");el.className="c-stepper__nav c-btn-group";return el});const prev=this.ensure(".c-stepper__prev",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-stepper__prev";el.type="button";return el});prev.textContent=labelText(this,"prev","Back");const next=this.ensure(".c-stepper__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-stepper__next";el.type="button";return el});next.textContent=labelText(this,"next","Next");if(!nav.contains(prev))nav.appendChild(prev);if(!nav.contains(next))nav.appendChild(next);if(nav.parentNode!==this)this.appendChild(nav)}enhance(){if(this._wiredStepper)return;this._wiredStepper=true;const go=(dir)=>{const list=this.querySelector(".c-stepper__list");const total=list?list.querySelectorAll(".c-stepper__step").length:0;if(!total)return;let cur=Number(this.getAttribute("current")||0);if(dir==="prev")cur=Math.max(0,cur-1);else cur=Math.min(total-1,cur+1);this.setAttribute("current",String(cur));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:dir,index:cur}}))};this.addEventListener("click",(e)=>{const prev=e.target&&e.target.closest?e.target.closest(".c-stepper__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-stepper__next"):null;if(prev&&this.contains(prev)){go("prev");return}if(next&&this.contains(next)){go("next");return}const step=e.target&&e.target.closest?e.target.closest(".c-stepper__step"):null;if(step&&this.contains(step)){const items=Array.from(this.querySelectorAll(".c-stepper__step"));const idx=items.indexOf(step);if(idx>=0&&idx!==Number(this.getAttribute("current")||0)){this.setAttribute("current",String(idx));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:"jump",index:idx}}))}}});this.addEventListener("keydown",(e)=>{if(e.key==="ArrowLeft"){e.preventDefault();go("prev")}else if(e.key==="ArrowRight"){e.preventDefault();go("next")}})}}define("contour-stepper",ContourStepper);class ContourVirtualList extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","item-height","orientation","sticky"]}static get properties(){return{items:{attribute:"items"},"item-height":{attribute:"item-height"},orientation:{attribute:"orientation"},sticky:{attribute:"sticky",type:Boolean}}}_items(){const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_itemHeight(){const h=Number(this.getAttribute("item-height"));if(Number.isFinite(h)&&h>0)return h;return cssLength("--virtual-list-item-height",28)}_autoHeight(){return this.getAttribute("item-height")==="auto"}render(){this.classList.add("c-virtual-list");this.setAttribute("role","list");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Virtual list");const scroller=this.ensure(".c-virtual-list__scroller",()=>{const el=document.createElement("div");el.className="c-virtual-list__scroller";return el});scroller.setAttribute("role","presentation");const horizontal=this.getAttribute("orientation")==="horizontal";scroller.style.overflowX=horizontal?"auto":"hidden";scroller.style.overflowY=horizontal?"hidden":"auto";const inner=this.ensure(".c-virtual-list__inner",()=>{const el=document.createElement("div");el.className="c-virtual-list__inner";el.style.position="relative";return el});if(inner.parentNode!==scroller)scroller.appendChild(inner);this._renderWindow(scroller,inner,horizontal?(scroller.scrollLeft||0):(scroller.scrollTop||0))}_measureHeights(inner,horizontal){const rows=Array.from(inner.querySelectorAll(".c-virtual-list__item"));return rows.map((r)=>horizontal?(r.getBoundingClientRect().width||this._itemHeight()):(r.getBoundingClientRect().height||this._itemHeight()))}_renderWindow(scroller,inner,scrollTop){const items=this._items();const ih=this._itemHeight();const horizontal=this.getAttribute("orientation")==="horizontal";const autoHeight=this._autoHeight();const viewportSize=horizontal?(scroller.clientWidth||320):(scroller.clientHeight||320);const total=items.length;if(this._vlItemCount!==total){this._vlHeights=null;this._vlItemCount=total}let heights=autoHeight?this._vlHeights:null;let cumulative=null;if(autoHeight&&heights&&heights.length===total){cumulative=[0];for(let i=0;i<total;i++)cumulative.push(cumulative[i]+(heights[i]||this._itemHeight()))}const visibleCount=autoHeight&&!cumulative?total:(autoHeight?Math.ceil(viewportSize/this._itemHeight())+6:Math.ceil(viewportSize/ih)+4);let start=0;if(autoHeight&&cumulative){let lo=0,hi=total;while(lo<hi){const mid=(lo+hi)>>1;if(cumulative[mid]<(scrollTop||0))lo=mid+1;else hi=mid}start=Math.max(0,lo-3)}else if(!autoHeight){start=Math.floor((scrollTop||0)/ih)}if(start<0)start=0;const end=autoHeight&&cumulative?Math.min(total,start+visibleCount):Math.min(total,start+visibleCount);if(start>Math.max(0,total-visibleCount)&&!autoHeight)start=Math.max(0,total-visibleCount);const topSpacerSize=autoHeight&&cumulative?cumulative[start]:(autoHeight?0:start*ih);const bottomSpacerSize=autoHeight&&cumulative?Math.max(0,cumulative[total]-cumulative[end]):(autoHeight?0:Math.max(0,(total-end)*ih));inner.style.display=horizontal?"flex":"block";inner.style.width=horizontal&&autoHeight?"max-content":"";inner.style.height=horizontal||autoHeight?"":(total*ih)+"px";inner.innerHTML="";const top=document.createElement("div");top.className="c-virtual-list__spacer c-virtual-list__spacer--top";top.style[horizontal?"width":"height"]=topSpacerSize+"px";inner.appendChild(top);for(let i=start;i<end;i++){const row=document.createElement("div");row.className="c-virtual-list__item";row.setAttribute("role","listitem");row.setAttribute("aria-setsize",String(total));row.setAttribute("aria-posinset",String(i+1));row.setAttribute("tabindex",i===0?"0":"-1");row.textContent=typeof items[i]==="string"?items[i]:(items[i].label||items[i].text||JSON.stringify(items[i]));if(this.hasAttribute("sticky")&&items[i]&&items[i].sticky){row.style.position="sticky";row.style.insetBlockStart="0";row.style.zIndex="1"}if(horizontal&&!autoHeight)row.style.flex="0 0 "+ih+"px";row.dataset.index=String(i);inner.appendChild(row)}const bottom=document.createElement("div");bottom.className="c-virtual-list__spacer c-virtual-list__spacer--bottom";bottom.style[horizontal?"width":"height"]=bottomSpacerSize+"px";inner.appendChild(bottom);if(horizontal&&!autoHeight)inner.style.width=(total*ih)+"px";if(autoHeight&&!this._vlHeights){requestAnimationFrame(()=>{this._vlHeights=this._measureHeights(inner,horizontal);const s=scroller;const i=inner;if(s&&i)this._renderWindow(s,i,s.scrollTop||0)})}}enhance(){if(this._wiredVirtualList)return;this._wiredVirtualList=true;const scroller=()=>this.querySelector(".c-virtual-list__scroller");const inner=()=>this.querySelector(".c-virtual-list__inner");let raf=0;const onScroll=()=>{if(raf)return;raf=requestAnimationFrame(()=>{raf=0;const s=scroller();const i=inner();if(s&&i)this._renderWindow(s,i,this.getAttribute("orientation")==="horizontal"?s.scrollLeft:s.scrollTop)})};const s=scroller();if(s){s.addEventListener("scroll",onScroll,{passive:true});onDispose(this,()=>{s.removeEventListener("scroll",onScroll);if(raf)cancelAnimationFrame(raf)})}this.addEventListener("keydown",(e)=>{const rows=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(!rows.length)return;const horizontal=this.getAttribute("orientation")==="horizontal";const fwd=horizontal?"ArrowRight":"ArrowDown";const back=horizontal?"ArrowLeft":"ArrowUp";const active=document.activeElement;const at=rows.indexOf(active);const scroller=this.querySelector(".c-virtual-list__scroller");const inner=this.querySelector(".c-virtual-list__inner");if((e.key===fwd&&at===rows.length-1)||(e.key===back&&at===0&&Number(active&&active.dataset.index)>0)){e.preventDefault();if(scroller&&inner){const delta=(e.key===fwd?1:-1)*this._itemHeight();if(horizontal)scroller.scrollLeft+=delta;else scroller.scrollTop+=delta;this._renderWindow(scroller,inner,horizontal?scroller.scrollLeft:scroller.scrollTop);const targetIndex=Number(active&&active.dataset.index)+(e.key===fwd?1:-1);requestAnimationFrame(()=>{const next=this.querySelector(`.c-virtual-list__item[data-index="${targetIndex}"]`);if(next){rows.forEach((r)=>r.setAttribute("tabindex","-1"));next.setAttribute("tabindex","0");try{next.focus()}catch(err){}}})}return}navKey(e,rows,{wrap:false,homeEnd:true,onNavigate:(i)=>rows.forEach((r,j)=>r.setAttribute("tabindex",j===i?"0":"-1")),onKey:()=>{if(e.key==="Enter"||e.key===" "){const i=Number(document.activeElement.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i,value:document.activeElement.textContent}}))}}})});this.addEventListener("click",(e)=>{const row=e.target&&e.target.closest?e.target.closest(".c-virtual-list__item"):null;if(!row||!this.contains(row))return;const i=Number(row.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{index:i,value:row.textContent}}))})}}define("contour-virtual-list",ContourVirtualList);class ContourCommandPalette extends ContourBase{static get observed(){return["open","items"]}static get properties(){return{open:{attribute:"open",type:Boolean},items:{attribute:"items"}}}attributeChangedCallback(name,oldValue,newValue){super.attributeChangedCallback(name,oldValue,newValue);if(name==="open"&&this.isConnected&&oldValue!==newValue){if(newValue!==null)this.show();else this.hide()}}_recentsKey(){return"contour-command-palette:"+(this.id||"default")+":recents"}_recents(){try{const r=JSON.parse(localStorage.getItem(this._recentsKey())||"[]");return Array.isArray(r)?r:[]}catch(e){return[]}}_remember(label){try{const r=this._recents().filter((l)=>l!==label);r.unshift(label);localStorage.setItem(this._recentsKey(),JSON.stringify(r.slice(0,5)))}catch(e){}}_cmdRow(label,index,recent){const row=document.createElement("div");row.className="c-command-palette__item";row.setAttribute("role","option");row.id=this.id+"-opt-"+(recent?"r":"")+index;row.textContent=label;row.dataset.index=String(index);row.dataset.label=label;if(recent)row.dataset.recent="true";return row}render(){this.classList.add("c-command-palette");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("aria-modal"))this.setAttribute("aria-modal","true");if(!this.hasAttribute("popover"))this.setAttribute("popover","auto");if(!this.id)this.id=contourId("cmd-palette");const search=this.ensure(".c-command-palette__search",()=>{const el=document.createElement("input");el.className="c-input c-command-palette__search";el.type="search";el.placeholder="Search…";el.setAttribute("aria-label","Search commands");el.setAttribute("role","combobox");el.setAttribute("aria-autocomplete","list");el.setAttribute("aria-expanded","false");return el});const list=this.ensure(".c-command-palette__list",()=>{const el=document.createElement("div");el.className="c-command-palette__list";el.setAttribute("role","listbox");return el});if(!list.id)list.id=this.id+"-list";search.setAttribute("aria-controls",list.id);let parsed=[];const items=this.getAttribute("items");if(items){try{parsed=JSON.parse(items)}catch(e){warnBadJson(this,"items",e)}}if(!Array.isArray(parsed))parsed=[];const labelOf=(it)=>typeof it==="string"?it:(it.label||it.title||"");list.innerHTML="";const q=(this._cmdQuery||"").toLowerCase().trim();const recents=q?[]:this._recents().filter((l)=>parsed.some((it)=>labelOf(it)===l));if(recents.length){const g=document.createElement("div");g.className="c-command-palette__group";g.setAttribute("role","presentation");g.textContent=labelText(this,"recent","Recent");list.appendChild(g);recents.forEach((label)=>list.appendChild(this._cmdRow(label,parsed.findIndex((it)=>labelOf(it)===label),true)))}let lastGroup=null;parsed.forEach((it,i)=>{const g=typeof it==="object"&&it!==null?(it.group||null):null;if(g&&g!==lastGroup){const h=document.createElement("div");h.className="c-command-palette__group";h.setAttribute("role","presentation");h.textContent=g;list.appendChild(h);lastGroup=g}list.appendChild(this._cmdRow(labelOf(it),i,false))});if(this._cmdQuery)search.value=this._cmdQuery;if(this._cmdFilter)this._cmdFilter(this._cmdQuery||"");else if(this._cmdSetActive)this._cmdSetActive(this._cmdCursor||0)}show(){if(this.classList.contains("is-open")||this.matches(":popover-open")){if(!this.hasAttribute("open"))this.setAttribute("open","");return}if(typeof this.showPopover==="function"){try{this.showPopover()}catch(e){}}this.classList.add("is-open");modalContain(this,true);const s=this.querySelector(".c-command-palette__search");if(s){s.setAttribute("aria-expanded","true");try{s.focus()}catch(e){}}if(!this.hasAttribute("open"))this.setAttribute("open","")}hide(){const isOpen=this.classList.contains("is-open")||this.matches(":popover-open");if(!isOpen){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(typeof this.hidePopover==="function"){try{this.hidePopover()}catch(e){}}this.classList.remove("is-open");modalContain(this,false);const s=this.querySelector(".c-command-palette__search");if(s)s.setAttribute("aria-expanded","false");if(this.hasAttribute("open"))this.removeAttribute("open")}toggle(){if(this.classList.contains("is-open")||this.matches(":popover-open"))this.hide();else this.show()}enhance(){if(this._cmdSetActive)this._cmdSetActive(this._cmdCursor||0);if(this._wiredCmdPalette)return;this._wiredCmdPalette=true;const search=()=>this.querySelector(".c-command-palette__search");const list=()=>this.querySelector(".c-command-palette__list");const items=()=>Array.from(this.querySelectorAll(".c-command-palette__item"));const visibleItems=()=>items().filter((it)=>!it.hidden);const setActive=(idx)=>{const vis=visibleItems();if(!vis.length){this._cmdCursor=0;return}this._cmdCursor=Math.max(0,Math.min(idx,vis.length-1));vis.forEach((it,i)=>it.classList.toggle("is-active",i===this._cmdCursor));const active=vis[this._cmdCursor];const s=search();if(s&&active)s.setAttribute("aria-activedescendant",active.id);else if(s)s.removeAttribute("aria-activedescendant")};const filter=(q)=>{const needle=(q||"").toLowerCase().trim();items().forEach((it)=>{const label=(it.dataset.label||it.textContent||"").toLowerCase();it.hidden=needle!==""&&!label.includes(needle)});Array.from(list().querySelectorAll(".c-command-palette__group")).forEach((g)=>{let n=g.nextElementSibling,any=false;while(n&&!n.classList.contains("c-command-palette__group")){if(!n.hidden&&n.classList.contains("c-command-palette__item"))any=true;n=n.nextElementSibling}g.hidden=!any});let empty=list().querySelector(".c-command-palette__empty");const anyVisible=items().some((it)=>!it.hidden);if(!anyVisible){if(!empty){empty=document.createElement("div");empty.className="c-command-palette__empty";empty.setAttribute("role","status");list().appendChild(empty)}empty.textContent=labelText(this,"no-matches","No matches");empty.hidden=false}else if(empty)empty.hidden=true;setActive(0)};const select=(it)=>{if(!it)return;const detail={index:Number(it.dataset.index),label:it.dataset.label||it.textContent};this.value=detail;this._remember(detail.label);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail}));this.hide()};this._cmdSetActive=setActive;this._cmdFilter=filter;this.addEventListener("input",(e)=>{const s=search();if(!s||e.target!==s)return;this._cmdQuery=s.value;filter(s.value)});this.addEventListener("keydown",(e)=>{const s=search();if(!s||e.target!==s)return;const vis=visibleItems();if(e.key==="Escape"){e.preventDefault();this.hide();return}if(!vis.length)return;if(e.key==="ArrowDown"){e.preventDefault();setActive(this._cmdCursor+1)}else if(e.key==="ArrowUp"){e.preventDefault();setActive(this._cmdCursor-1)}else if(e.key==="Home"){e.preventDefault();setActive(0)}else if(e.key==="End"){e.preventDefault();setActive(vis.length-1)}else if(e.key==="Enter"){e.preventDefault();select(vis[this._cmdCursor])}});this.addEventListener("click",(e)=>{const it=e.target&&e.target.closest?e.target.closest(".c-command-palette__item"):null;if(it&&this.contains(it)&&!it.hidden)select(it)});let lastFocus=null;this.addEventListener("beforetoggle",(e)=>{if(e.newState==="open"){lastFocus=document.activeElement;this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))}else if(lastFocus&&typeof lastFocus.focus==="function"){this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}));try{lastFocus.focus()}catch(err){}}});setActive(0)}}define("contour-command-palette",ContourCommandPalette);class ContourBadgeOverflow extends ContourBase{static get observed(){return["count","max"]}static get properties(){return{count:{attribute:"count"},max:{attribute:"max"}}}render(){this.classList.add("c-badge-overflow");const count=Number(this.getAttribute("count")||0);const max=Number(this.getAttribute("max")||3);const extra=Math.max(0,count-max);const existing=this.querySelector(".c-badge-overflow__more");if(existing)existing.remove();if(extra>0){const b=document.createElement("span");b.className="c-badge c-badge-overflow__more";b.textContent="+"+extra;this.appendChild(b)}}}define("contour-badge-overflow",ContourBadgeOverflow);class ContourSideSheet extends ContourBase{static get observed(){return["open","side","title","mode","size"]}static get properties(){return{open:{attribute:"open",type:Boolean},side:{attribute:"side"},title:{attribute:"title"},mode:{attribute:"mode"},size:{attribute:"size"}}}show(){this.setAttribute("open","")}showModal(){this._sheetForceModal=true;this.show()}close(){this.removeAttribute("open")}get open(){return this.hasAttribute("open")}set open(v){if(v)this.show();else this.close()}_modal(){return this._sheetForceModal||(this.getAttribute("mode")||"modal")!=="non-modal"}render(){this.classList.add("c-side-sheet");this.setAttribute("role","dialog");if(this._modal())this.setAttribute("aria-modal","true");else this.removeAttribute("aria-modal");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"Side sheet");for(const c of Array.from(this.classList)){if(/^c-side-sheet--(start|end|sm|md|lg)$/.test(c))this.classList.remove(c)}const side=this.getAttribute("side")==="start"?"start":"end";this.classList.add("c-side-sheet--"+side);const size=this.getAttribute("size");if(size==="sm"||size==="md"||size==="lg")this.classList.add("c-side-sheet--"+size);if(this.hasAttribute("open"))this.classList.add("is-open");else this.classList.remove("is-open");const title=this.getAttribute("title");if(title){const t=this.ensure(".c-side-sheet__title",()=>{const el=document.createElement("div");el.className="c-side-sheet__title";return el});t.textContent=title}}enhance(){if(this._wiredSideSheet)return;this._wiredSideSheet=true;let lastFocus=null;const keyHandler=(e)=>{if(e.key==="Escape"&&this.hasAttribute("open")){e.preventDefault();this.close();return}if(e.key==="Tab"&&this.hasAttribute("open")&&this._modal()){const focusables=Array.from(this.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter((el)=>!el.hasAttribute("disabled"));if(!focusables.length){e.preventDefault();return}const first=focusables[0],last=focusables[focusables.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus()}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus()}}};document.addEventListener("keydown",keyHandler);onDispose(this,()=>document.removeEventListener("keydown",keyHandler));this.addEventListener("click",(e)=>{if(e.target===this)this.close()});let wasOpen=false;const transition=()=>{const isOpen=this.hasAttribute("open");if(isOpen&&!wasOpen){wasOpen=true;lastFocus=document.activeElement;if(this._modal())modalContain(this,true);const first=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(first)try{first.focus()}catch(err){}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:true,composed:true}))}else if(!isOpen&&wasOpen){wasOpen=false;if(this._modal())modalContain(this,false);this._sheetForceModal=false;if(lastFocus&&typeof lastFocus.focus==="function")try{lastFocus.focus()}catch(err){}lastFocus=null;this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}};const obs=new MutationObserver(transition);obs.observe(this,{attributes:true,attributeFilter:["open"]});if(this.hasAttribute("open"))transition();onDispose(this,()=>{obs.disconnect();if(this.hasAttribute("open")&&this._modal())modalContain(this,false)})}}define("contour-side-sheet",ContourSideSheet);class ContourTour extends ContourBase{static get observed(){return["steps","current","open","persist","id"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"},open:{attribute:"open",type:Boolean},persist:{attribute:"persist",type:Boolean}}}_steps(){let parsed=[];try{const s=this.getAttribute("steps");parsed=s?JSON.parse(s):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_current(n){const c=Number(this.getAttribute("current")||0);return Number.isFinite(c)?Math.min(Math.max(0,c),Math.max(0,n-1)):0}_storageKey(){return this.id?"contour-tour:"+this.id:null}_completed(){if(!this.hasAttribute("persist"))return false;const key=this._storageKey();try{return key?localStorage.getItem(key)==="done":false}catch(e){return false}}_markCompleted(){if(!this.hasAttribute("persist"))return;const key=this._storageKey();try{if(key)localStorage.setItem(key,"done")}catch(e){}}show(){this.setAttribute("open","")}close(){if(!this.hasAttribute("open"))return;this.removeAttribute("open");this._markCompleted();this.dispatchEvent(new CustomEvent("contour:close",{bubbles:true,composed:true}))}render(){this.classList.add("c-tour");this.setAttribute("role","dialog");this.setAttribute("aria-label",labelText(this,"tour","Tour"));const parsed=this._steps();if(!this._tourInitialized){this._tourInitialized=true;if(parsed.length&&!this.hasAttribute("open")&&!this._completed())this.setAttribute("open","")}const isOpen=this.hasAttribute("open")&&parsed.length>0;if(isOpen)this.removeAttribute("hidden");else this.setAttribute("hidden","");const current=this._current(parsed.length);const step=parsed[current]||{};const counter=this.ensure(".c-tour__step",()=>{const el=document.createElement("div");el.className="c-tour__step";return el});counter.textContent=labelText(this,"step","Step")+" "+(current+1)+" / "+parsed.length;const tip=this.ensure(".c-tour__tip",()=>{const el=document.createElement("div");el.className="c-tour__tip";return el});tip.textContent=typeof step==="string"?step:(step.text||step.title||"");if(counter.nextSibling!==tip)this.insertBefore(counter,tip);const nav=this.ensure(".c-tour__nav",()=>{const el=document.createElement("div");el.className="c-tour__nav c-btn-group";return el});const back=this.ensure(".c-tour__back",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-tour__back";el.type="button";return el},nav);back.textContent=labelText(this,"back","Back");back.disabled=current===0;const next=this.ensure(".c-tour__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-tour__next";el.type="button";return el},nav);next.textContent=current>=parsed.length-1?labelText(this,"done","Done"):labelText(this,"next","Next");const close=this.ensure(".c-tour__close",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-tour__close";el.type="button";return el},nav);close.textContent=labelText(this,"close","Close");if(nav.firstChild!==back)nav.insertBefore(back,nav.firstChild);if(back.nextSibling!==next)nav.insertBefore(next,back.nextSibling);if(next.nextSibling!==close)nav.insertBefore(close,next.nextSibling);if(this._tourTarget&&this._tourTarget.classList)this._tourTarget.classList.remove("c-tour__target");this._tourTarget=null;const targetSel=isOpen&&typeof step==="object"&&step?step.target:null;if(targetSel){const target=document.querySelector(targetSel);if(target&&target.classList){target.classList.add("c-tour__target");this._tourTarget=target}}if(isOpen)this._positionTour()}_positionTour(){const vw=window.innerWidth,vh=window.innerHeight;const w=this.offsetWidth||280,h=this.offsetHeight||120;const target=this._tourTarget;if(target&&target.getBoundingClientRect){const r=target.getBoundingClientRect();let top=r.bottom+8;if(top+h>vh-8)top=Math.max(8,r.top-h-8);const left=Math.min(Math.max(8,r.left),Math.max(8,vw-w-8));this.style.insetBlockStart=top+"px";this.style.insetInlineStart=left+"px";this.style.insetBlockEnd="auto";this.style.transform=""}else{this.style.insetBlockStart="auto";this.style.insetBlockEnd="1rem";this.style.insetInlineStart="50%";this.style.transform="translateX(-50%)"}}enhance(){if(this._wiredTour)return;this._wiredTour=true;const step=(dir)=>{const parsed=this._steps();if(!parsed.length||!this.hasAttribute("open"))return;const cur=this._current(parsed.length);if(dir==="next"){if(cur>=parsed.length-1){this.close();return}this.setAttribute("current",String(cur+1));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:"next",index:cur+1}}))}else{if(cur===0)return;this.setAttribute("current",String(cur-1));this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{direction:"prev",index:cur-1}}))}};this._tourStep=step;this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target:null;if(!t)return;if(t.closest(".c-tour__next")){step("next");return}if(t.closest(".c-tour__back")){step("prev");return}if(t.closest(".c-tour__close"))this.close()});const keyHandler=(e)=>{if(!this.hasAttribute("open"))return;const tag=e.target&&e.target.tagName;if(tag==="INPUT"||tag==="TEXTAREA"||tag==="SELECT")return;if(e.key==="Escape"){e.preventDefault();this.close()}else if(e.key==="ArrowRight"){e.preventDefault();step("next")}else if(e.key==="ArrowLeft"){e.preventDefault();step("prev")}};document.addEventListener("keydown",keyHandler);const reposition=()=>{if(this.hasAttribute("open"))this._positionTour()};window.addEventListener("scroll",reposition,{passive:true,capture:true});window.addEventListener("resize",reposition,{passive:true});onDispose(this,()=>{document.removeEventListener("keydown",keyHandler);window.removeEventListener("scroll",reposition,{capture:true});window.removeEventListener("resize",reposition);if(this._tourTarget&&this._tourTarget.classList)this._tourTarget.classList.remove("c-tour__target")})}}define("contour-tour",ContourTour);class ContourTagsInput extends ContourBase{static get formAssociated(){return true}static get observed(){return["value","placeholder","disabled","error","help","required","max"]}static get properties(){return{value:{attribute:"value"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},required:{attribute:"required",type:Boolean},max:{attribute:"max"}}}render(){this.classList.add("c-tags-input");if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label","Tags input");const input=this.ensure(".c-tags-input__input",()=>{const el=document.createElement("input");el.className="c-input c-tags-input__input";el.type="text";el.setAttribute("aria-label","Add tag");return el});input.placeholder=this.getAttribute("placeholder")||"Add tag…";if(this.hasAttribute("disabled")){input.setAttribute("disabled","");this.classList.add("is-disabled")}else{input.removeAttribute("disabled");this.classList.remove("is-disabled")}const err=this.getAttribute("error");const help=this.getAttribute("help");let msg=this.querySelector(".c-tags-input__message");if(err||help){if(!msg){msg=document.createElement("div");msg.className="c-tags-input__message";this.appendChild(msg)}msg.textContent=err||help||"";msg.classList.toggle("c-tags-input__message--error",!!err)}else if(msg){msg.remove()}if(err)this.classList.add("is-error");else this.classList.remove("is-error");const tags=this.getAttribute("value");let parsed=[];try{parsed=tags?JSON.parse(tags):[]}catch(e){parsed=tags?tags.split(",").map((s)=>s.trim()).filter(Boolean):[]}Array.from(this.querySelectorAll(".c-tags-input__tag")).forEach((n)=>n.remove());parsed.forEach((t)=>{const chip=document.createElement("span");chip.className="c-tag c-tags-input__tag";chip.textContent=t;const rm=document.createElement("button");rm.className="c-tags-input__remove";rm.type="button";rm.textContent="×";rm.dataset.value=t;chip.appendChild(rm);this.insertBefore(chip,input)});if(this._internals)this._syncFormValue()}enhance(){if(this._wiredTagsInput)return;this._wiredTagsInput=true;this._syncFormValue();this.addEventListener("contour:add",()=>{this._syncFormValue()});this.addEventListener("contour:remove",()=>{this._syncFormValue()});const announce=(msg)=>{let live=this.querySelector(".c-tags-input__live");if(!live){live=document.createElement("span");live.className="c-tags-input__live visually-hidden";live.setAttribute("aria-live","polite");live.setAttribute("aria-atomic","true");this.appendChild(live)}live.textContent=msg};const readTags=()=>{const raw=this.getAttribute("value")||"";let tags=[];try{tags=JSON.parse(raw)}catch(err){tags=raw.split(",").map((s)=>s.trim()).filter(Boolean)}return Array.isArray(tags)?tags.map(String):[]};const addMany=(candidates)=>{if(this.hasAttribute("disabled"))return;const tags=readTags();const max=Number(this.getAttribute("max"));const added=[],dups=[];let limitHit=false;for(const raw of candidates){const v=String(raw).trim();if(!v)continue;if(tags.includes(v)){dups.push(v);continue}if(Number.isFinite(max)&&max>0&&tags.length>=max){limitHit=true;break}tags.push(v);added.push(v)}if(added.length){this.setAttribute("value",JSON.stringify(tags));for(const v of added)this.dispatchEvent(new CustomEvent("contour:add",{bubbles:true,composed:true,detail:{value:v}}))}const parts=[];if(added.length)parts.push("Added "+added.join(", "));if(dups.length)parts.push(dups.join(", ")+" already added");if(limitHit)parts.push("Tag limit reached ("+max+")");if(parts.length)announce(parts.join(". "))};this.addEventListener("keydown",(e)=>{const input=this.querySelector(".c-tags-input__input");if(!input||this.hasAttribute("disabled"))return;if(e.key==="Enter"&&e.target===input){e.preventDefault();const v=input.value;input.value="";addMany([v])}else if(e.key==="Backspace"&&e.target===input&&input.value===""){const tags=readTags();if(tags.length){const removed=tags.pop();this.setAttribute("value",JSON.stringify(tags));announce("Removed "+removed);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:removed}}))}}});this.addEventListener("input",(e)=>{const input=this.querySelector(".c-tags-input__input");if(!input||e.target!==input||this.hasAttribute("disabled"))return;if(input.value.includes(",")){const parts=input.value.split(",");input.value=parts.pop();addMany(parts)}});this.addEventListener("paste",(e)=>{const input=this.querySelector(".c-tags-input__input");if(!input||e.target!==input||this.hasAttribute("disabled"))return;const text=e.clipboardData&&e.clipboardData.getData("text/plain");if(text&&/[,;\n]/.test(text)){e.preventDefault();addMany(text.split(/[,;\n]+/))}});this.addEventListener("click",(e)=>{const rm=e.target&&e.target.closest?e.target.closest(".c-tags-input__remove"):null;if(rm&&this.contains(rm)&&!this.hasAttribute("disabled")){const val=rm.dataset.value;const next=readTags().filter((t)=>t!==val);this.setAttribute("value",JSON.stringify(next));announce("Removed "+val);this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:true,composed:true,detail:{value:val}}))}})}_syncFormValue(){if(!this._internals)return;this._internals.setFormValue(this.getAttribute("value")||"[]");let count=0;try{const p=JSON.parse(this.getAttribute("value")||"[]");count=Array.isArray(p)?p.length:0}catch(err){count=(this.getAttribute("value")||"").split(",").filter((s)=>s.trim()).length}this._syncValidity(this.hasAttribute("required")&&count===0)}}define("contour-tags-input",ContourTagsInput);class ContourSortableList extends ContourBase{static get observed(){return["items","order"]}static get properties(){return{items:{attribute:"items"},order:{attribute:"order"}}}render(){this.classList.add("c-sortable-list");const list=this.ensure(".c-sortable-list__list",()=>{const el=document.createElement("ul");el.className="c-sortable-list__list";return el});const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}if(!Array.isArray(parsed))parsed=[];let sourceOrder=Array.from({length:parsed.length},(_,i)=>i);const orderRaw=this.getAttribute("order");if(orderRaw){try{const order=JSON.parse(orderRaw);if(Array.isArray(order)&&order.length===parsed.length&&order.every((i)=>Number.isInteger(i)&&i>=0&&i<parsed.length)){sourceOrder=order.slice();parsed=order.map((i)=>parsed[i])}}catch(e){}}this._sortableSourceOrder=sourceOrder;this._sortableItems=parsed;list.innerHTML="";parsed.forEach((it,i)=>{const li=document.createElement("li");li.className="c-sortable-list__item";li.setAttribute("draggable","true");li.dataset.index=String(i);const itemLabel=typeof it==="string"?it:(it.label||it.text||"");const handle=document.createElement("span");handle.className="c-sortable-list__handle";handle.textContent="⋮⋮";handle.setAttribute("role","button");handle.setAttribute("aria-label",labelText(this,"reorder","Reorder")+" "+(itemLabel||String(i+1)));handle.setAttribute("data-contour-preserve-key",itemLabel||String(i));handle.tabIndex=0;li.appendChild(handle);const labelEl=document.createElement("span");labelEl.className="c-sortable-list__label";labelEl.textContent=itemLabel;li.appendChild(labelEl);list.appendChild(li)})}enhance(){if(this._wiredSortableList)return;this._wiredSortableList=true;const list=()=>this.querySelector(".c-sortable-list__list");const announce=(msg)=>{let live=this.querySelector(".c-sortable-list__live");if(!live){live=document.createElement("span");live.className="c-sortable-list__live visually-hidden";live.setAttribute("aria-live","polite");live.setAttribute("aria-atomic","true");this.appendChild(live)}live.textContent=msg};const index=(li)=>Array.from(list().children).indexOf(li);const writeBack=(from,to)=>{const n=(this._sortableItems||[]).length;const cur=Array.isArray(this._sortableSourceOrder)&&this._sortableSourceOrder.length===n?this._sortableSourceOrder.slice():Array.from({length:n},(_,i)=>i);const[src]=cur.splice(from,1);cur.splice(to,0,src);this.setAttribute("order",JSON.stringify(cur))};let dragFrom=null;this.addEventListener("dragstart",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li))return;dragFrom=index(li);if(e.dataTransfer){e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",String(dragFrom))}catch(err){}}li.classList.add("is-dragging")});this.addEventListener("dragover",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li)||dragFrom===null)return;e.preventDefault();if(e.dataTransfer)e.dataTransfer.dropEffect="move"});this.addEventListener("drop",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-sortable-list__item"):null;if(!li||!this.contains(li)||dragFrom===null)return;e.preventDefault();const to=index(li);const l=list();const fromLi=l.children[dragFrom];if(fromLi&&dragFrom!==to){if(dragFrom<to)l.insertBefore(fromLi,l.children[to+1]||null);else l.insertBefore(fromLi,l.children[to]);const item=fromLi.querySelector(".c-sortable-list__label");announce((item?item.textContent:"Item")+" moved to position "+(to+1));const from=dragFrom;writeBack(from,to);this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from,to}}))}dragFrom=null;Array.from(l.children).forEach((n)=>n.classList.remove("is-dragging"))});this.addEventListener("dragend",()=>{dragFrom=null;const l=list();if(l)Array.from(l.children).forEach((n)=>n.classList.remove("is-dragging"))});this.addEventListener("keydown",(e)=>{const handle=e.target&&e.target.closest?e.target.closest(".c-sortable-list__handle"):null;if(!handle)return;const li=handle.closest(".c-sortable-list__item");if(!li)return;const l=list();const from=index(li);const moved=(direction,to)=>{const label=li.querySelector(".c-sortable-list__label");announce((label?label.textContent:"Item")+" moved to position "+(to+1));writeBack(from,to);this.dispatchEvent(new CustomEvent("contour:move",{bubbles:true,composed:true,detail:{direction,from,to}}));this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:true,composed:true,detail:{from,to}}))};if(e.key==="ArrowUp"&&li.previousElementSibling){e.preventDefault();l.insertBefore(li,li.previousElementSibling);moved("up",index(li))}else if(e.key==="ArrowDown"&&li.nextElementSibling){e.preventDefault();l.insertBefore(li.nextElementSibling,li);moved("down",index(li))}else if(e.key==="Home"&&from>0){e.preventDefault();l.insertBefore(li,l.firstElementChild);moved("up",0)}else if(e.key==="End"&&from<l.children.length-1){e.preventDefault();l.appendChild(li);moved("down",l.children.length-1)}})}}define("contour-sortable-list",ContourSortableList);class ContourSwatch extends ContourBase{static get observed(){return["color","selected","label"]}static get properties(){return{color:{attribute:"color"},selected:{attribute:"selected",type:Boolean},label:{attribute:"label"}}}render(){this.classList.add("c-swatch");if(!this.hasAttribute("role"))this.setAttribute("role","button");if(this.getAttribute("role")==="button"&&!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("label")||this.getAttribute("color")||"Swatch");const color=this.getAttribute("color")||"#000";this.style.setProperty("--swatch-color",color);if(this.hasAttribute("selected"))this.classList.add("is-selected");else this.classList.remove("is-selected");if(!this.hasAttribute("aria-label")){const label=this.getAttribute("label")||color;this.setAttribute("aria-label",label)}if(!this.querySelector("button")&&!this.querySelector("span")){const span=document.createElement("span");span.className="c-swatch__btn";span.setAttribute("aria-hidden","true");this.appendChild(span)}}enhance(){if(this._wiredSwatch)return;this._wiredSwatch=true;this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:this.getAttribute("color")}}))});this.addEventListener("keydown",(e)=>{if(e.key!=="Enter"&&e.key!==" ")return;e.preventDefault();this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:this.getAttribute("color")}}))})}}define("contour-swatch",ContourSwatch);class ContourCalendar extends ContourBase{static get observed(){return["value","month","year","range","start","end"]}static get properties(){return{value:{attribute:"value"},month:{attribute:"month"},year:{attribute:"year"},range:{attribute:"range",type:Boolean},start:{attribute:"start"},end:{attribute:"end"}}}_attrNum(name,fallback){const raw=this.getAttribute(name);const n=Number(raw);return raw!==null&&Number.isFinite(n)?n:fallback}_ym(){const now=new Date();return{year:this._attrNum("year",now.getFullYear()),month:this._attrNum("month",now.getMonth())}}render(){this.classList.add("c-calendar");const now=new Date();const{year,month}=this._ym();const header=this.ensure(".c-calendar__header",()=>{const el=document.createElement("div");el.className="c-calendar__header";return el});header.innerHTML="";const navBtn=(cls,glyph,label)=>{const b=document.createElement("button");b.type="button";b.className="c-btn c-btn--sm "+cls;b.textContent=glyph;b.setAttribute("aria-label",label);return b};const prevYear=navBtn("c-calendar__prev-year","«","Previous year");const prev=navBtn("c-calendar__prev","‹","Previous month");const title=document.createElement("span");title.className="c-calendar__title";title.textContent=new Date(year,month,1).toLocaleString(undefined,{month:"long",year:"numeric"});const next=navBtn("c-calendar__next","›","Next month");const nextYear=navBtn("c-calendar__next-year","»","Next year");header.append(prevYear,prev,title,next,nextYear);const grid=this.ensure(".c-calendar__grid",()=>{const el=document.createElement("div");el.className="c-calendar__grid";el.setAttribute("role","grid");return el});grid.setAttribute("aria-label",title.textContent);grid.innerHTML="";const first=new Date(year,month,1);const startDay=first.getDay();const daysInMonth=new Date(year,month+1,0).getDate();const isRange=this.hasAttribute("range");const selected=this.getAttribute("value");const rStart=this.getAttribute("start");const rEnd=this.getAttribute("end");let row=null;let col=0;const newRow=()=>{row=document.createElement("div");row.className="c-calendar__row";row.setAttribute("role","row");grid.appendChild(row);col=0};const wdFmt=new Intl.DateTimeFormat(undefined,{weekday:"short"});newRow();for(let i=0;i<7;i++){const wd=document.createElement("div");wd.className="c-calendar__weekday";wd.setAttribute("role","columnheader");wd.textContent=wdFmt.format(new Date(2023,0,1+i));row.appendChild(wd)}newRow();for(let i=0;i<startDay;i++){const empty=document.createElement("div");empty.className="c-calendar__day c-calendar__day--empty";row.appendChild(empty);col++;if(col===7)newRow()}const todayIso=now.getFullYear()+"-"+String(now.getMonth()+1).padStart(2,"0")+"-"+String(now.getDate()).padStart(2,"0");const focusIso=(selected&&selected.startsWith(year+"-"+String(month+1).padStart(2,"0")))?selected:(todayIso.startsWith(year+"-"+String(month+1).padStart(2,"0"))?todayIso:year+"-"+String(month+1).padStart(2,"0")+"-01");for(let d=1;d<=daysInMonth;d++){const cell=document.createElement("button");cell.className="c-calendar__day";cell.type="button";cell.setAttribute("role","gridcell");cell.textContent=String(d);const iso=year+"-"+String(month+1).padStart(2,"0")+"-"+String(d).padStart(2,"0");const isSelected=isRange?(iso===rStart||iso===rEnd):iso===selected;if(isSelected)cell.classList.add("is-selected");if(isRange&&rStart&&rEnd&&iso>rStart&&iso<rEnd)cell.classList.add("is-in-range");cell.setAttribute("aria-selected",String(isSelected));if(iso===todayIso)cell.setAttribute("aria-current","date");cell.setAttribute("tabindex",iso===focusIso?"0":"-1");cell.dataset.value=iso;row.appendChild(cell);col++;if(col===7)newRow()}if(header.parentNode!==this)this.insertBefore(header,grid)}enhance(){if(this._wiredCalendar)return;this._wiredCalendar=true;const navigate=(m,y)=>{this.batch(()=>{this.setAttribute("month",String(m));this.setAttribute("year",String(y))});this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{month:m,year:y}}))};const focusIso=(iso)=>{const cell=this.querySelector('.c-calendar__day[data-value="'+iso+'"]');if(cell){try{cell.focus()}catch(err){}}};this.addEventListener("focusin",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(!cell||!this.contains(cell))return;for(const c of this.querySelectorAll(".c-calendar__day"))c.tabIndex=-1;cell.tabIndex=0});this.addEventListener("click",(e)=>{const t=e.target&&e.target.closest?e.target:null;if(!t)return;const{year,month}=this._ym();if(t.closest(".c-calendar__prev")){const d=new Date(year,month-1,1);navigate(d.getMonth(),d.getFullYear());return}if(t.closest(".c-calendar__next")){const d=new Date(year,month+1,1);navigate(d.getMonth(),d.getFullYear());return}if(t.closest(".c-calendar__prev-year")){navigate(month,year-1);return}if(t.closest(".c-calendar__next-year")){navigate(month,year+1);return}const cell=t.closest(".c-calendar__day");if(cell&&this.contains(cell)&&cell.dataset.value){const iso=cell.dataset.value;if(this.hasAttribute("range")){const start=this.getAttribute("start");const end=this.getAttribute("end");let s,en;if(!start||(start&&end)){s=iso;en=null}else{s=iso<start?iso:start;en=iso<start?start:iso}this.batch(()=>{this.setAttribute("start",s);if(en===null)this.removeAttribute("end");else this.setAttribute("end",en)});this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:iso,range:en?[s,en]:[s]}}))}else{this.setAttribute("value",iso);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{value:iso}}))}}});this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(!cell||!this.contains(cell)||!cell.dataset.value)return;const[y,m,d]=cell.dataset.value.split("-").map(Number);const cur=new Date(y,m-1,d);const{year,month}=this._ym();const daysInMonth=new Date(year,month+1,0).getDate();const isoOf=(dt)=>dt.getFullYear()+"-"+String(dt.getMonth()+1).padStart(2,"0")+"-"+String(dt.getDate()).padStart(2,"0");let target=null;if(e.key==="ArrowRight")target=new Date(y,m-1,d+1);else if(e.key==="ArrowLeft")target=new Date(y,m-1,d-1);else if(e.key==="ArrowDown")target=new Date(y,m-1,d+7);else if(e.key==="ArrowUp")target=new Date(y,m-1,d-7);else if(e.key==="PageUp")target=e.shiftKey?new Date(y-1,m-1,Math.min(d,new Date(y-1,m,0).getDate())):new Date(y,m-2,Math.min(d,new Date(y,m-1,0).getDate()));else if(e.key==="PageDown")target=e.shiftKey?new Date(y+1,m-1,Math.min(d,new Date(y+1,m,0).getDate())):new Date(y,m,Math.min(d,new Date(y,m+1,0).getDate()));else if(e.key==="Home")target=new Date(year,month,1);else if(e.key==="End")target=new Date(year,month,daysInMonth);else return;e.preventDefault();const iso=isoOf(target);if(target.getFullYear()===year&&target.getMonth()===month){focusIso(iso)}else{navigate(target.getMonth(),target.getFullYear());focusIso(iso)}})}}define("contour-calendar",ContourCalendar);class ContourCarousel extends ContourBase{static get observed(){return["items","index","autoplay","paused"]}static get properties(){return{items:{attribute:"items"},index:{attribute:"index"},autoplay:{attribute:"autoplay"},paused:{attribute:"paused",type:Boolean}}}_items(){const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}return Array.isArray(parsed)?parsed:[]}_index(){const i=Number(this.getAttribute("index"));const items=this._items();if(Number.isFinite(i)&&i>=0&&i<items.length)return i;return 0}render(){this.classList.add("c-carousel");this.setAttribute("role","region");this.setAttribute("aria-roledescription","carousel");const track=this.ensure(".c-carousel__track",()=>{const el=document.createElement("div");el.className="c-carousel__track";el.setAttribute("role","group");el.setAttribute("aria-roledescription","slide container");return el});const items=this._items();track.innerHTML="";const idx=this._index();items.forEach((it,i)=>{const slide=document.createElement("div");slide.className="c-carousel__slide"+(i===idx?" is-active":"");slide.setAttribute("role","group");slide.setAttribute("aria-roledescription","slide");slide.setAttribute("aria-label",(i+1)+" of "+items.length);slide.setAttribute("aria-hidden",i===idx?"false":"true");slide.textContent=typeof it==="string"?it:(it.label||it.text||"");slide.dataset.index=String(i);track.appendChild(slide)});const prev=this.ensure(".c-carousel__prev",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__prev";el.type="button";el.textContent="‹";el.setAttribute("aria-label","Previous slide");return el});const next=this.ensure(".c-carousel__next",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__next";el.type="button";el.textContent="›";el.setAttribute("aria-label","Next slide");return el});const status=this.ensure(".c-carousel__status",()=>{const el=document.createElement("span");el.className="c-carousel__status";el.setAttribute("aria-live","polite");return el});status.textContent=(idx+1)+" of "+items.length;const dots=this.ensure(".c-carousel__dots",()=>{const el=document.createElement("div");el.className="c-carousel__dots";el.setAttribute("role","tablist");el.setAttribute("aria-label","Slides");return el});dots.innerHTML="";items.forEach((it,i)=>{const dot=document.createElement("button");dot.type="button";dot.className="c-carousel__dot"+(i===idx?" is-active":"");dot.setAttribute("role","tab");dot.setAttribute("aria-label","Go to slide "+(i+1));dot.setAttribute("aria-selected",i===idx?"true":"false");dot.dataset.index=String(i);dots.appendChild(dot)});const autoplay=Number(this.getAttribute("autoplay"));if(Number.isFinite(autoplay)&&autoplay>0){const paused=this.hasAttribute("paused")||this._reducedMotion();const pp=this.ensure(".c-carousel__pause",()=>{const el=document.createElement("button");el.className="c-btn c-btn--sm c-carousel__pause";el.type="button";return el});pp.textContent=paused?"▶":"⏸";pp.setAttribute("aria-label",paused?"Play slides automatically":"Pause automatic slides");pp.setAttribute("aria-pressed",String(paused))}else{const pp=this.querySelector(".c-carousel__pause");if(pp)pp.remove()}}_reducedMotion(){try{return typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}catch(e){return false}}enhance(){const autoplay=Number(this.getAttribute("autoplay"));const want=Number.isFinite(autoplay)&&autoplay>0&&!this.hasAttribute("paused")&&!this._reducedMotion()&&this._items().length>1;if(want&&!this._carouselTimer){this._carouselTimer=setInterval(()=>{const items=this._items();if(!items.length)return;const idx=(this._index()+1)%items.length;this.setAttribute("index",String(idx));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:idx,direction:"next"}}))},Math.max(500,autoplay))}else if(!want&&this._carouselTimer){clearInterval(this._carouselTimer);this._carouselTimer=null}if(this._wiredCarousel)return;this._wiredCarousel=true;onDispose(this,()=>{if(this._carouselTimer){clearInterval(this._carouselTimer);this._carouselTimer=null}});const go=(dir)=>{const items=this._items();if(!items.length)return;let idx=this._index();if(dir==="prev")idx=(idx-1+items.length)%items.length;else idx=(idx+1)%items.length;this.setAttribute("index",String(idx));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:idx,direction:dir}}))};this.addEventListener("click",(e)=>{const pp=e.target&&e.target.closest?e.target.closest(".c-carousel__pause"):null;if(pp&&this.contains(pp)){if(this._reducedMotion())return;const nowPaused=!this.hasAttribute("paused");this.toggleAttribute("paused",nowPaused);this.dispatchEvent(new CustomEvent(nowPaused?"contour:pause":"contour:play",{bubbles:true,composed:true}));return}const prev=e.target&&e.target.closest?e.target.closest(".c-carousel__prev"):null;const next=e.target&&e.target.closest?e.target.closest(".c-carousel__next"):null;if(prev&&this.contains(prev)){go("prev");return}if(next&&this.contains(next)){go("next");return}const dot=e.target&&e.target.closest?e.target.closest(".c-carousel__dot"):null;if(dot&&this.contains(dot)){const i=Number(dot.dataset.index);if(Number.isFinite(i)&&i!==this._index()){this.setAttribute("index",String(i));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:i,direction:"jump"}}))}}});let startX=null;this.addEventListener("pointerdown",(e)=>{startX=e.clientX});this.addEventListener("pointerup",(e)=>{if(startX===null)return;const dx=e.clientX-startX;startX=null;if(Math.abs(dx)>40){if(dx<0)go("next");else go("prev")}});this.addEventListener("pointercancel",()=>{startX=null});this.addEventListener("keydown",(e)=>{if(e.key==="ArrowLeft"){e.preventDefault();go("prev")}else if(e.key==="ArrowRight"){e.preventDefault();go("next")}else if(e.key==="Home"){e.preventDefault();this.setAttribute("index","0");this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:0,direction:"home"}}))}else if(e.key==="End"){e.preventDefault();const last=this._items().length-1;if(last>=0){this.setAttribute("index",String(last));this.dispatchEvent(new CustomEvent("contour:change",{bubbles:true,composed:true,detail:{index:last,direction:"end"}}))}}})}}define("contour-carousel",ContourCarousel);class ContourDataGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","filter","page-size","resizable","virtual","row-height","loading","error","empty"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page"},filter:{attribute:"filter"},"page-size":{attribute:"page-size"},resizable:{attribute:"resizable",type:Boolean},virtual:{attribute:"virtual",type:Boolean},"row-height":{attribute:"row-height"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}render(){this.classList.add("c-data-grid");if(this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const table=this.ensure(".c-data-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-data-grid__table";el.setAttribute("role","grid");return el});const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(tbody.parentNode!==table)table.appendChild(tbody);tbody.innerHTML="";const tr=document.createElement("tr");const td=document.createElement("td");td.colSpan=1;td.style.textAlign="center";td.style.color="var(--color-text-muted)";if(this.hasAttribute("loading"))td.textContent=this.getAttribute("loading")||"Loading…";else if(this.hasAttribute("error"))td.textContent=this.getAttribute("error")||"Error";else td.textContent=this.getAttribute("empty")||"No data";tr.appendChild(td);tbody.appendChild(tr);let wrap=this.querySelector(".c-data-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-table-wrap c-data-grid__wrap"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap);return}const table=this.ensure(".c-data-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-data-grid__table";el.setAttribute("role","grid");return el});const thead=this.ensure("thead",()=>{const el=document.createElement("thead");return el});const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(thead.parentNode!==table)table.appendChild(thead);if(tbody.parentNode!==table)table.appendChild(tbody);const cols=this.getAttribute("columns");let parsedCols=[];try{parsedCols=cols?JSON.parse(cols):[]}catch(e){parsedCols=[]}if(parsedCols.length&&!thead.querySelector("tr")){const tr=document.createElement("tr");parsedCols.forEach((c)=>{const th=document.createElement("th");th.setAttribute("role","columnheader");th.setAttribute("aria-sort","none");th.setAttribute("tabindex","0");th.textContent=typeof c==="string"?c:(c.label||c.key||"");tr.appendChild(th)});thead.appendChild(tr)}if(this.hasAttribute("resizable")){Array.from(thead.querySelectorAll("th")).forEach((th)=>{th.style.position="relative";th.setAttribute("data-resizable","true")})}const rows=this.getAttribute("rows");let parsedRows=[];try{parsedRows=rows?JSON.parse(rows):[]}catch(e){parsedRows=[]}table.setAttribute("aria-rowcount",String(parsedRows.length));table.setAttribute("aria-colcount",String(parsedCols.length));const filter=this.getAttribute("filter");if(filter){const q=filter.toLowerCase();parsedRows=parsedRows.filter((r)=>JSON.stringify(r).toLowerCase().includes(q))}const page=Number(this.getAttribute("page")||1);const pageSize=Number(this.getAttribute("page-size")||0);if(pageSize>0){const start=(page-1)*pageSize;parsedRows=parsedRows.slice(start,start+pageSize)}this._dgCols=parsedCols;this._dgRows=parsedRows;this._dgFilteredRows=parsedRows;const virtual=this.hasAttribute("virtual")&&!(Number(this.getAttribute("page-size"))>0);if(virtual){this._renderDataGridWindow(0)}else{tbody.innerHTML="";parsedRows.forEach((r)=>{const tr=document.createElement("tr");parsedCols.forEach((c)=>{const key=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","-1");td.textContent=r&&r[key]!=null?r[key]:"";if(!String(td.textContent).trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)})}let wrap=this.querySelector(".c-data-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-table-wrap c-data-grid__wrap"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap);if(!table.querySelector('[tabindex="0"]')){const first=table.querySelector("tbody td, thead th");if(first)first.setAttribute("tabindex","0")}}_rowHeight(){const h=Number(this.getAttribute("row-height"));if(Number.isFinite(h)&&h>0)return h;if(this._measuredRowHeight>0)return this._measuredRowHeight;return cssLength("--data-grid-row-height",32)}_renderDataGridWindow(scrollTop){const table=this.querySelector(".c-data-grid__table");const tbody=table&&table.querySelector("tbody");if(!tbody)return;const cols=this._dgCols||[];const rows=this._dgRows||[];const rh=this._rowHeight();const viewport=400;const visibleCount=Math.ceil(viewport/rh)+6;let start=Math.floor((scrollTop||0)/rh);if(start<0)start=0;if(start>Math.max(0,rows.length-visibleCount))start=Math.max(0,rows.length-visibleCount);const end=Math.min(rows.length,start+visibleCount);tbody.innerHTML="";if(start>0){const sp=document.createElement("tr");const td=document.createElement("td");td.colSpan=Math.max(1,cols.length);td.style.blockSize=(start*rh)+"px";td.style.padding="0";sp.appendChild(td);tbody.appendChild(sp)}for(let i=start;i<end;i++){const r=rows[i];const tr=document.createElement("tr");tr.dataset.index=String(i);cols.forEach((c)=>{const key=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","-1");td.textContent=r&&r[key]!=null?r[key]:"";if(!String(td.textContent).trim())td.setAttribute("aria-label","Empty");tr.appendChild(td)});tbody.appendChild(tr)}if(end<rows.length){const sp=document.createElement("tr");const td=document.createElement("td");td.colSpan=Math.max(1,cols.length);td.style.blockSize=((rows.length-end)*rh)+"px";td.style.padding="0";sp.appendChild(td);tbody.appendChild(sp)}if(!tbody.querySelector('[tabindex="0"]')){const first=tbody.querySelector("tr[data-index] td");if(first)first.setAttribute("tabindex","0")}}enhance(){if(this._wiredDataGrid)return;this._wiredDataGrid=true;const wrap=()=>this.querySelector(".c-data-grid__wrap");const onScroll=()=>{const w=wrap();if(w&&this.hasAttribute("virtual"))this._renderDataGridWindow(w.scrollTop)};this.addEventListener("scroll",(e)=>{const w=e.target&&e.target.classList&&e.target.classList.contains("c-data-grid__wrap")?e.target:null;if(w&&this.hasAttribute("virtual"))this._renderDataGridWindow(w.scrollTop)},true);let sortCol=-1,sortDir="asc";this.addEventListener("keydown",(e)=>{const cell=e.target&&e.target.closest?e.target.closest("[role='gridcell'], [role='columnheader']"):null;if(!cell||!this.contains(cell))return;const row=cell.parentElement;const table=this.querySelector(".c-data-grid__table");if(!table)return;const rows=Array.from(table.querySelectorAll("tr"));const ri=rows.indexOf(row);const ci=Array.from(row.children).indexOf(cell);let target=null;if(e.key==="ArrowRight")target=row.children[ci+1];else if(e.key==="ArrowLeft")target=row.children[ci-1];else if(e.key==="ArrowDown")target=rows[ri+1]&&rows[ri+1].children[ci];else if(e.key==="ArrowUp")target=rows[ri-1]&&rows[ri-1].children[ci];if(target){e.preventDefault();table.querySelectorAll('[tabindex="0"]').forEach((c)=>c.setAttribute("tabindex","-1"));target.setAttribute("tabindex","0");try{target.focus()}catch(err){}}});this.addEventListener("click",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tr"):null;const th=e.target&&e.target.closest?e.target.closest("th"):null;if(tr&&this.contains(tr)&&!th){const idx=Array.from(tr.parentElement.children).indexOf(tr);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{row:idx}}))}if(th&&this.contains(th)){const idx=Array.from(th.parentElement.children).indexOf(th);if(sortCol===idx)sortDir=sortDir==="asc"?"desc":"asc";else{sortCol=idx;sortDir="asc"}const table=this.querySelector(".c-data-grid__table");const tbody=table&&table.querySelector("tbody");const thead=table&&table.querySelector("thead");const cols=this._dgCols||[];const key=cols[idx]?(typeof cols[idx]==="string"?cols[idx]:(cols[idx].key||cols[idx].label||"")):String(idx);const full=(this._dgFilteredRows||[]).slice();full.sort((a,b)=>{const va=a&&a[key]!=null?a[key]:"";const vb=b&&b[key]!=null?b[key]:"";const na=Number(va),nb=Number(vb);const cmp=(!isNaN(na)&&!isNaN(nb))?na-nb:String(va).localeCompare(String(vb));return sortDir==="asc"?cmp:-cmp});this._dgFilteredRows=full;if(tbody){const page=Number(this.getAttribute("page")||1);const pageSize=Number(this.getAttribute("page-size")||0);let pageRows=full;if(pageSize>0){const start=(page-1)*pageSize;pageRows=full.slice(start,start+pageSize)}tbody.innerHTML="";pageRows.forEach((r)=>{const tr=document.createElement("tr");cols.forEach((c)=>{const k=typeof c==="string"?c:(c.key||c.label||"");const td=document.createElement("td");td.setAttribute("role","gridcell");td.setAttribute("tabindex","-1");td.textContent=r&&r[k]!=null?r[k]:"";tr.appendChild(td)});tbody.appendChild(tr)})}if(thead)Array.from(thead.querySelectorAll("th")).forEach((h,i)=>{h.setAttribute("aria-sort",i===idx?(sortDir==="asc"?"ascending":"descending"):"none")});this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:true,composed:true,detail:{column:idx,direction:sortDir}}))}});this.addEventListener("pointerdown",(e)=>{if(!this.hasAttribute("resizable"))return;const th=e.target&&e.target.closest?e.target.closest("th[data-resizable]"):null;if(!th||!this.contains(th)||th.getBoundingClientRect().right-e.clientX>10)return;e.preventDefault();const startX=e.clientX;const startWidth=th.getBoundingClientRect().width;const index=Array.from(th.parentElement.children).indexOf(th);const move=(event)=>{const width=Math.max(48,startWidth+event.clientX-startX);const table=this.querySelector(".c-data-grid__table");if(table)Array.from(table.rows).forEach((row)=>{if(row.children[index])row.children[index].style.inlineSize=width+"px"})};const stop=()=>window.removeEventListener("pointermove",move);window.addEventListener("pointermove",move);window.addEventListener("pointerup",stop,{once:true});onDispose(this,stop)})}}define("contour-data-grid",ContourDataGrid);class ContourTreeGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","expanded","loading","error","empty"]}static get properties(){return{items:{attribute:"items"},expanded:{attribute:"expanded"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}_expandedSet(){const raw=this.getAttribute("expanded");if(!raw)return new Set();try{return new Set(JSON.parse(raw))}catch(e){return new Set([raw])}}render(){this.classList.add("c-tree-grid");const table=this.ensure(".c-tree-grid__table",()=>{const el=document.createElement("table");el.className="c-table c-tree-grid__table";el.setAttribute("role","treegrid");return el});table.setAttribute("aria-label","Tree grid");const tbody=this.ensure("tbody",()=>{const el=document.createElement("tbody");return el});if(tbody.parentNode!==table)table.appendChild(tbody);const items=this.getAttribute("items");let parsed=[];try{parsed=items?JSON.parse(items):[]}catch(e){parsed=[]}const expanded=this._expandedSet();tbody.innerHTML="";const rows=[];const renderNode=(node,depth,path)=>{const tr=document.createElement("tr");tr.setAttribute("role","row");tr.setAttribute("tabindex","0");tr.setAttribute("aria-level",String(depth+1));tr.dataset.path=path;const hasChildren=!!(node&&Array.isArray(node.children)&&node.children.length);if(hasChildren){tr.setAttribute("aria-expanded",expanded.has(path)?"true":"false")}const td=document.createElement("td");td.setAttribute("role","gridcell");td.style.paddingInlineStart=(depth*1.25)+"rem";const label=(node&&(node.label||node.text||node.name))||"";if(hasChildren){const toggle=document.createElement("button");toggle.type="button";toggle.className="c-tree-grid__toggle";toggle.textContent=expanded.has(path)?"▾":"▸";toggle.setAttribute("aria-label",(expanded.has(path)?"Collapse":"Expand")+" "+label);td.appendChild(toggle)}const span=document.createElement("span");span.className="c-tree-grid__label";span.textContent=label;td.appendChild(span);tr.appendChild(td);tbody.appendChild(tr);rows.push(tr);if(hasChildren&&expanded.has(path)){node.children.forEach((c,i)=>renderNode(c,depth+1,path+"."+i))}};parsed.forEach((n,i)=>renderNode(n,0,String(i)));let wrap=this.querySelector(".c-tree-grid__wrap");if(!wrap){wrap=document.createElement("div");wrap.className="c-table-wrap c-tree-grid__wrap"}if(table.parentNode!==wrap)wrap.appendChild(table);if(wrap.parentNode!==this)this.appendChild(wrap)}enhance(){if(this._wiredTreeGrid)return;this._wiredTreeGrid=true;const rows=()=>Array.from(this.querySelectorAll("tr[role='row']"));this.addEventListener("click",(e)=>{const toggle=e.target&&e.target.closest?e.target.closest(".c-tree-grid__toggle"):null;const tr=e.target&&e.target.closest?e.target.closest("tr[role='row']"):null;if(!tr||!this.contains(tr))return;const path=tr.dataset.path;if(toggle){e.preventDefault();const expanded=this._expandedSet();if(expanded.has(path))expanded.delete(path);else expanded.add(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:expanded.has(path)}}))}else{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{path}}))}});this.addEventListener("keydown",(e)=>{const tr=e.target&&e.target.closest?e.target.closest("tr[role='row']"):null;if(!tr||!this.contains(tr))return;const all=rows();const idx=all.indexOf(tr);const path=tr.dataset.path;const hasChildren=tr.getAttribute("aria-expanded")!==null;const expanded=this._expandedSet();if(e.key==="ArrowRight"&&hasChildren&&!expanded.has(path)){e.preventDefault();expanded.add(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:true}}))}else if(e.key==="ArrowLeft"&&hasChildren&&expanded.has(path)){e.preventDefault();expanded.delete(path);this.setAttribute("expanded",JSON.stringify([...expanded]));this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:true,composed:true,detail:{path,expanded:false}}))}else if(e.key==="ArrowDown"){e.preventDefault();if(all[idx+1])try{all[idx+1].focus()}catch(err){}}else if(e.key==="ArrowUp"){e.preventDefault();if(all[idx-1])try{all[idx-1].focus()}catch(err){}}else if(e.key==="Enter"||e.key===" "){e.preventDefault();const toggle=tr.querySelector(".c-tree-grid__toggle");if(toggle)toggle.click()}})}}define("contour-tree-grid",ContourTreeGrid);class ContourPullToRefresh extends ContourBase{static get observed(){return["threshold"]}static get properties(){return{threshold:{attribute:"threshold"}}}render(){this.classList.add("c-pull-to-refresh");if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",labelText(this,"label","Pull to refresh"));const ind=this.ensure(".c-pull-to-refresh__indicator",()=>{const e=document.createElement("div");e.className="c-pull-to-refresh__indicator";return e});ind.innerHTML="";const label=document.createElement("span");label.className="c-pull-to-refresh__label";label.setAttribute("aria-live","polite");label.textContent=this._ptrError?this._ptrError:(this._ptrRefreshing?labelText(this,"refreshing","Refreshing…"):labelText(this,"label","Pull to refresh"));ind.appendChild(label);const btn=document.createElement("button");btn.type="button";btn.className="c-pull-to-refresh__btn";btn.textContent=labelText(this,"refresh","Refresh");ind.appendChild(btn);if(ind.parentNode!==this)this.prepend(ind);this.classList.toggle("is-refreshing",!!this._ptrRefreshing);this.classList.toggle("has-error",!!this._ptrError);this.setAttribute("aria-busy",String(!!this._ptrRefreshing))}complete(){this._ptrRefreshing=false;this._ptrError=null;this.style.removeProperty("--ptr-offset");this.requestRender()}fail(message){this._ptrRefreshing=false;this._ptrError=String(message||labelText(this,"error","Refresh failed"));this.style.removeProperty("--ptr-offset");this.requestRender();this.dispatchEvent(new CustomEvent("contour:error",{bubbles:true,composed:true,detail:{message:this._ptrError}}))}_refresh(){if(this._ptrRefreshing)return;this._ptrRefreshing=true;this._ptrError=null;this.style.removeProperty("--ptr-offset");this.requestRender();this.dispatchEvent(new CustomEvent("contour:refresh",{bubbles:true,composed:true}))}enhance(){if(this._wiredPullToRefresh)return;this._wiredPullToRefresh=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-pull-to-refresh__btn"):null;if(btn&&this.contains(btn))this._refresh()});let startY=0;let pulling=false;let offset=0;this.addEventListener("pointerdown",(e)=>{if(this._ptrRefreshing||this.scrollTop>0)return;if(e.target&&e.target.closest&&e.target.closest(".c-pull-to-refresh__btn"))return;startY=e.clientY;pulling=true;offset=0;try{this.setPointerCapture(e.pointerId)}catch(err){}});this.addEventListener("pointermove",(e)=>{if(!pulling)return;const dy=e.clientY-startY;if(dy>0){offset=Math.min(120,dy*0.6);this.style.setProperty("--ptr-offset",offset+"px")}});const end=()=>{if(!pulling)return;pulling=false;const thr=Number(this.getAttribute("threshold"))||60;if(offset>=thr)this._refresh();else this.style.removeProperty("--ptr-offset");offset=0};this.addEventListener("pointerup",end);this.addEventListener("pointercancel",end)}}define("contour-pull-to-refresh",ContourPullToRefresh);
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,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,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 ContourAvatar extends ContourBase{static get observed(){return["name","size","variant","src","status"]}static get properties(){return{name:{attribute:"name"},size:{attribute:"size"},variant:{attribute:"variant"},src:{attribute:"src"},status:{attribute:"status"}}}render(){this.classList.add("c-avatar"),Array.from(this.classList).forEach(t=>{t.startsWith("c-avatar--")&&this.classList.remove(t)});const t=this.getAttribute("name"),e=this.getAttribute("size");e&&this.classList.add("c-avatar--"+e);const s=this.getAttribute("variant");s&&this.classList.add("c-avatar--"+s);const r=this.querySelector("img.c-avatar__img");r&&r.remove();const i=this.querySelector(".c-avatar__status");i&&i.remove();const a=this.getAttribute("src");if(a){this.textContent="";const e=document.createElement("img");e.className="c-avatar__img",e.src=a,e.alt=t||"",e.loading="lazy",e.decoding="async",e.addEventListener("error",()=>{if(e.remove(),t){const e=t.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2);this.textContent=e}}),this.appendChild(e)}else if(t){const e=t.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2);this.querySelector("img.c-avatar__img"),this.textContent=e}const n=this.getAttribute("status");if(n){const t=document.createElement("span");t.className="c-avatar__status c-avatar__status--"+n,t.setAttribute("aria-hidden","true"),this.appendChild(t)}}}define("contour-avatar",ContourAvatar);class ContourBadgeFull extends ContourBase{static get observed(){return["variant","label","size","removable"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"},size:{attribute:"size"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-badge"),Array.from(this.classList).forEach(t=>{t.startsWith("c-badge--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-badge--"+t);const e=this.getAttribute("size");e&&this.classList.add("c-badge--"+e);const s=this.getAttribute("label");if(s){let t=null;for(const e of this.childNodes)if(3===e.nodeType){t=e;break}t?t.nodeValue=s:this.insertBefore(document.createTextNode(s),this.firstChild)}if(flagOn(this,"removable"))this.ensure(".c-badge__remove",()=>{const t=document.createElement("button");return t.className="c-badge__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove","Remove")),t.textContent="×",t});else{const t=this.querySelector(".c-badge__remove");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-badge",ContourBadgeFull);class ContourChipFull extends ContourBase{static get observed(){return["variant","key","value","live"]}static get properties(){return{variant:{attribute:"variant"},key:{attribute:"key"},value:{attribute:"value"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-chip"),flagOn(this,"live")&&!this.hasAttribute("role")?this.setAttribute("role","status"):!flagOn(this,"live")&&"status"===this.getAttribute("role")&&this._autoChipRole&&this.removeAttribute("role"),this._autoChipRole=flagOn(this,"live"),Array.from(this.classList).forEach(t=>{t.startsWith("c-chip--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-chip--"+t);const e=this.getAttribute("key"),s=this.getAttribute("value");if(e){this.ensure(".c-chip__key",()=>{const t=document.createElement("span");return t.className="c-chip__key",t}).textContent=e}else{const t=this.querySelector(".c-chip__key");t&&t.remove()}if(s){this.ensure(".c-chip__value",()=>{const t=document.createElement("span");return t.className="c-chip__value",t}).textContent=s}else{const t=this.querySelector(".c-chip__value");t&&t.remove()}}}define("contour-chip",ContourChipFull);class ContourTag extends ContourBase{static get observed(){return["label","removable","variant","live"]}static get properties(){return{label:{attribute:"label"},removable:{attribute:"removable",type:Boolean},variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-tag"),flagOn(this,"live")&&!this.hasAttribute("role")?this.setAttribute("role","status"):!flagOn(this,"live")&&"status"===this.getAttribute("role")&&this._autoTagRole&&this.removeAttribute("role"),this._autoTagRole=flagOn(this,"live"),Array.from(this.classList).forEach(t=>{t.startsWith("c-tag--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-tag--"+t);const e=this.getAttribute("label");if(e){let t=null;for(const e of this.childNodes)if(3===e.nodeType){t=e;break}t?t.nodeValue=e+" ":this.insertBefore(document.createTextNode(e+" "),this.firstChild)}if(flagOn(this,"removable"))this.ensure(".c-tag__remove",()=>{const t=document.createElement("button");return t.className="c-tag__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove","Remove")),t.textContent="×",t});else{const t=this.querySelector(".c-tag__remove");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-tag",ContourTag);class ContourDot extends ContourBase{static get observed(){return["variant","live"]}static get properties(){return{variant:{attribute:"variant"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-dot"),this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","status indicator"),Array.from(this.classList).forEach(t=>{t.startsWith("c-dot--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-dot--"+t),flagOn(this,"live")?this.classList.add("c-dot--live"):this.classList.remove("c-dot--live")}}define("contour-dot",ContourDot);class ContourPill extends ContourBase{static get observed(){return["label","live","variant"]}static get properties(){return{label:{attribute:"label"},live:{attribute:"live",type:Boolean},variant:{attribute:"variant"}}}render(){this.classList.add("c-pill"),flagOn(this,"live")&&!this.hasAttribute("role")?this.setAttribute("role","status"):!flagOn(this,"live")&&"status"===this.getAttribute("role")&&this._autoPillRole&&this.removeAttribute("role"),this._autoPillRole=flagOn(this,"live"),Array.from(this.classList).forEach(t=>{t.startsWith("c-pill--")&&this.classList.remove(t)});const t=this.getAttribute("variant");t&&this.classList.add("c-pill--"+t);const e=this.getAttribute("label");e&&(this.textContent=e),flagOn(this,"live")?this.classList.add("c-pill--live"):this.classList.remove("c-pill--live")}}define("contour-pill",ContourPill);class ContourKbd extends ContourBase{static get observed(){return["key"]}static get properties(){return{key:{attribute:"key"}}}render(){this.classList.add("c-kbd");const t=this.getAttribute("key");t&&(this.textContent=t)}}define("contour-kbd",ContourKbd);class ContourSpinner extends ContourBase{static get observed(){return["size"]}static get properties(){return{size:{attribute:"size"}}}render(){this.classList.add("c-spinner"),Array.from(this.classList).forEach(t=>{t.startsWith("c-spinner--")&&this.classList.remove(t)});const t=this.getAttribute("size");t&&this.classList.add("c-spinner--"+t),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"loading","Loading"))}}define("contour-spinner",ContourSpinner);class ContourSkeleton extends ContourBase{static get observed(){return["size","shimmer"]}static get properties(){return{size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton"),Array.from(this.classList).forEach(t=>{t.startsWith("c-skeleton--")&&this.classList.remove(t)});const t=this.getAttribute("size");t&&this.classList.add("c-skeleton--"+t),this.hasAttribute("aria-hidden")||this.setAttribute("aria-hidden","true");const e=this.getAttribute("shimmer");flagOn(this,"shimmer")&&"off"!==e?this.classList.remove("c-skeleton--static"):this.classList.add("c-skeleton--static")}}define("contour-skeleton",ContourSkeleton);class ContourMark extends ContourBase{static get observed(){return["src","icon","label"]}static get properties(){return{src:{attribute:"src"},icon:{attribute:"icon"},label:{attribute:"label"}}}render(){this.classList.add("c-mark");const t=this.getAttribute("src")||this.getAttribute("icon");if(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),setHTML(e,'<use href="'+safeHref(t)+'" />'),this.appendChild(e)}const e=this.getAttribute("label");if(e&&!this.querySelector("[data-mark-label]")){const t=document.createElement("span");t.className="c-mark__label",t.setAttribute("data-mark-label",""),t.textContent=e,this.appendChild(t)}}}define("contour-mark",ContourMark);class ContourLoading extends ContourBase{static get observed(){return["label"]}static get properties(){return{label:{attribute:"label"}}}render(){this.classList.add("c-loading"),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.ensure(".c-spinner",()=>{const t=document.createElement("span");return t.className="c-spinner",t.setAttribute("aria-hidden","true"),t});const t=this.getAttribute("label")||"Loading";let e=this.querySelector("[data-loading-label]");e||(e=document.createElement("span"),e.className="visually-hidden",e.setAttribute("data-loading-label",""),this.appendChild(e)),e.textContent=t,this.hasAttribute("aria-label")||this.setAttribute("aria-label",t)}}define("contour-loading",ContourLoading);class ContourElevation extends ContourBase{render(){this.classList.add("c-elevation")}}define("contour-elevation",ContourElevation);class ContourFilterPill extends ContourBase{static get observed(){return["key","value","removable"]}static get properties(){return{key:{attribute:"key"},value:{attribute:"value"},removable:{attribute:"removable",type:Boolean}}}render(){this.classList.add("c-filter-pill");const t=this.getAttribute("key"),e=this.getAttribute("value");if(t){this.ensure(".c-filter-pill__key",()=>{const t=document.createElement("span");return t.className="c-filter-pill__key",t}).textContent=t}else{const t=this.querySelector(".c-filter-pill__key");t&&t.remove()}if(e){this.ensure(".c-filter-pill__value",()=>{const t=document.createElement("span");return t.className="c-filter-pill__value",t}).textContent=e}else{const t=this.querySelector(".c-filter-pill__value");t&&t.remove()}if(flagOn(this,"removable"))this.ensure(".c-filter-pill__remove",()=>{const t=document.createElement("button");return t.className="c-filter-pill__remove",t.type="button",t.setAttribute("aria-label",labelText(this,"remove-filter","Remove filter")),t.textContent="×",t});else{const t=this.querySelector(".c-filter-pill__remove");t&&t.remove()}}enhance(){wireRemovable(this)}}define("contour-filter-pill",ContourFilterPill);class ContourDatamark extends ContourBase{static get observed(){return["value","unit","label","format","locale"]}static get properties(){return{value:{attribute:"value"},unit:{attribute:"unit"},label:{attribute:"label"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-datamark");const t=this.getAttribute("value"),e=this.getAttribute("unit"),s=this.getAttribute("label"),r=this.getAttribute("format"),i=this.getAttribute("locale"),a=t||s;if(a){const s=t?formatValue(t,r,i,e):a;if(this.textContent=s,e&&t){const t=document.createElement("span");t.className="u-subtle",t.textContent=" "+e,this.appendChild(t)}}}}define("contour-datamark",ContourDatamark);class ContourDestructiveHint extends ContourBase{static get observed(){return["text"]}static get properties(){return{text:{attribute:"text"}}}render(){this.classList.add("c-destructive-hint");const t=this.getAttribute("text");t&&(this.textContent=t)}}define("contour-destructive-hint",ContourDestructiveHint);class ContourIconBadge extends ContourBase{static get observed(){return["icon"]}static get properties(){return{icon:{attribute:"icon"}}}render(){this.classList.add("c-icon-badge");const t=this.getAttribute("icon");if(t){const e=String(t).replace(/[^a-zA-Z0-9_-]/g,"");e&&!e.startsWith("i-")&&"undefined"!=typeof console&&console.warn&&console.warn("ContourIconBadge: icon '"+t+"' may not exist in the sprite (expected i-* name).");const s=this.querySelector("svg"),r=s||document.createElementNS("http://www.w3.org/2000/svg","svg");if(s){const t=r.querySelector("use");t&&t.setAttribute("href","#"+e)}else{r.setAttribute("aria-hidden","true");const t=document.createElementNS("http://www.w3.org/2000/svg","use");t.setAttribute("href","#"+e),r.appendChild(t),this.appendChild(r)}}else{const t=this.querySelector("svg");t&&t.remove()}}}define("contour-icon-badge",ContourIconBadge);class ContourLiveBadge extends ContourBase{static get observed(){return["label","state","live"]}static get properties(){return{label:{attribute:"label"},state:{attribute:"state"},live:{attribute:"live",type:Boolean}}}render(){this.classList.add("c-live-badge"),this.hasAttribute("role")||this.setAttribute("role","status"),Array.from(this.classList).forEach(t=>{t.startsWith("c-live-badge--")&&this.classList.remove(t)});const t=this.getAttribute("state");t?this.classList.add("c-live-badge--"+t):flagOn(this,"live")&&this.classList.add("c-live-badge--connected");const e=this.getAttribute("label");e&&!this.hasChildNodes()&&(this.textContent=e)}}define("contour-live-badge",ContourLiveBadge);class ContourSkeletonGroup extends ContourBase{static get observed(){return["count","size","shimmer"]}static get properties(){return{count:{attribute:"count",type:Number},size:{attribute:"size"},shimmer:{attribute:"shimmer",type:Boolean}}}render(){this.classList.add("c-skeleton-group");const t=Math.max(0,parseInt(this.getAttribute("count")||"3",10)||3),e=this.getAttribute("size"),s=this.getAttribute("shimmer");Array.from(this.querySelectorAll(".c-skeleton")).forEach(t=>t.remove());for(let r=0;r<t;r++){const t=document.createElement("div");t.className="c-skeleton",e&&t.classList.add("c-skeleton--"+e),t.setAttribute("aria-hidden","true"),flagOn(this,"shimmer")&&"off"!==s?t.classList.remove("c-skeleton--static"):t.classList.add("c-skeleton--static"),this.appendChild(t)}}}define("contour-skeleton-group",ContourSkeletonGroup);class ContourAvatarGroup extends ContourBase{static get observed(){return["items","max"]}static get properties(){return{items:{attribute:"items"},max:{attribute:"max",type:Number}}}render(){this.classList.add("c-avatar-group");const t=this.getAttribute("items"),e=parseInt(this.getAttribute("max")||"4",10)||4;if(Array.from(this.querySelectorAll(".c-avatar, .c-avatar-group__overflow")).forEach(t=>t.remove()),t)try{const s=JSON.parse(t);if(s.slice(0,e).forEach(t=>{const e=document.createElement("span");e.className="c-avatar";const s="string"==typeof t?t:t.name||t.label||"";if(e.textContent=s.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2),"object"==typeof t&&t.color){const s=safeColor(t.color);s&&(e.style.background=s,e.dataset.color=s)}this.appendChild(e)}),s.length>e){const t=document.createElement("span");t.className="c-avatar c-avatar-group__overflow";const r=s.length-e;t.textContent="+"+r,t.setAttribute("aria-label","+"+r+" more"),this.appendChild(t)}}catch(t){warnBadJson(this,"attribute",t)}}}define("contour-avatar-group",ContourAvatarGroup);class ContourDivider extends ContourBase{static get observed(){return["label","orientation"]}static get properties(){return{label:{attribute:"label"},orientation:{attribute:"orientation"}}}render(){this.classList.add("c-divider"),this.hasAttribute("role")||this.setAttribute("role","separator");const t=this.getAttribute("orientation")||"horizontal";this.classList.add("c-divider--"+t);const e=this.getAttribute("label");if(e){this.ensure(".c-divider__label",()=>{const t=document.createElement("span");return t.className="c-divider__label",t}).textContent=e}}}define("contour-divider",ContourDivider);class ContourStatusLight extends ContourBase{static get observed(){return["status","label"]}static get properties(){return{status:{attribute:"status"},label:{attribute:"label"}}}render(){this.classList.add("c-status-light");const t=this.getAttribute("status")||"neutral";this.classList.add("c-status-light--"+t),this.hasAttribute("role")||this.setAttribute("role","img");const e=this.getAttribute("label");if(e&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label",e):e||this.hasAttribute("aria-label")||this.setAttribute("aria-label",t),e){this.ensure(".c-status-light__label",()=>{const t=document.createElement("span");return t.className="c-status-light__label",t}).textContent=e}}}define("contour-status-light",ContourStatusLight);class ContourBadgeOverflow extends ContourBase{static get observed(){return["count","max"]}static get properties(){return{count:{attribute:"count"},max:{attribute:"max"}}}render(){this.classList.add("c-badge-overflow");const t=Number(this.getAttribute("count")||0),e=Number(this.getAttribute("max")||3),s=Math.max(0,t-e),r=this.querySelector(".c-badge-overflow__more");if(r&&r.remove(),s>0){const t=document.createElement("span");t.className="c-badge c-badge-overflow__more",t.textContent="+"+s,this.appendChild(t)}}}define("contour-badge-overflow",ContourBadgeOverflow);class ContourTooltip extends ContourBase{static get observed(){return["text","anchor","delay","trigger"]}static get properties(){return{text:{attribute:"text"},anchor:{attribute:"anchor"},delay:{attribute:"delay",type:Number},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-tooltip"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"tooltip","Tooltip")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.hasAttribute("role")||this.setAttribute("role","tooltip"),this.id||(this.id=contourId("tip"));const t=this.getAttribute("text");null===t||this.hasChildNodes()||(this.textContent=t)}enhance(){if(this._wiredTooltip)return;this._wiredTooltip=!0;const t=this.getAttribute("anchor");if(t){let e=null;e=t.startsWith("#")?document.getElementById(t.slice(1)):document.querySelector(t),e&&(e.setAttribute("popovertarget",this.id||(this.id=contourId("tip"))),e.setAttribute("aria-describedby",this.id))}const e=this.delay&&this.delay>0?this.delay:0,s=this.getAttribute("anchor");let r=null;s&&(r=s.startsWith("#")?document.getElementById(s.slice(1)):document.querySelector(s));const i="--tooltip-"+(this.id||(this.id=contourId("tip")));(()=>{r&&(r.style.setProperty("anchor-name",i),this.style.setProperty("position-anchor",i),this.style.setProperty("position-area","top"))})();const a="function"==typeof this.showPopover;let n=null,o=null;const l=()=>{if(a)try{this.showPopover()}catch(t){}else this.classList.add("is-open"),this.style.zIndex="var(--z-tooltip)";try{requestAnimationFrame(w)}catch(t){w()}},c=()=>{if(o&&(clearTimeout(o),o=null),a)try{this.hidePopover()}catch(t){}else this.classList.remove("is-open"),this.style.removeProperty("z-index")},u=()=>{n&&clearTimeout(n),e>0?n=setTimeout(l,e):l()},d=()=>{n&&(clearTimeout(n),n=null),o&&clearTimeout(o),o=setTimeout(c,300)};this.addEventListener("pointerenter",()=>{o&&(clearTimeout(o),o=null)}),this.addEventListener("pointerleave",d),onDispose(this,()=>{r&&r.style.removeProperty("anchor-name")});const h=this.getAttribute("trigger")||"hover",p=s?s.startsWith("#")?document.getElementById(s.slice(1)):document.querySelector(s):null,b=p||this,m=()=>{"click"!==h&&u()},g=()=>{"click"!==h&&d()},v=()=>{"click"!==h&&u()},_=()=>{"click"!==h&&d()},f=t=>{p&&p.hasAttribute("popovertarget")?"click"!==h&&t&&t.preventDefault&&t.preventDefault():"click"!==h&&"hover"!==h||(this.matches(":popover-open")?d():u())},y=()=>{"click"!==h&&u()},A=()=>{"click"!==h&&setTimeout(d,1500)};b.addEventListener("mouseenter",m),b.addEventListener("mouseleave",g),b.addEventListener("focus",v),b.addEventListener("blur",_),b.addEventListener("click",f),b.addEventListener("touchstart",y,{passive:!0}),b.addEventListener("touchend",A,{passive:!0});const w=()=>{try{const t=this.getBoundingClientRect();t.right>window.innerWidth?this.classList.add("c-tooltip--flip-x"):this.classList.remove("c-tooltip--flip-x"),t.bottom>window.innerHeight?this.classList.add("c-tooltip--flip-y"):this.classList.remove("c-tooltip--flip-y")}catch(t){}};onDispose(this,()=>{b.removeEventListener("mouseenter",m),b.removeEventListener("mouseleave",g),b.removeEventListener("focus",v),b.removeEventListener("blur",_),b.removeEventListener("click",f),b.removeEventListener("touchstart",y),b.removeEventListener("touchend",A),n&&clearTimeout(n)}),this.addEventListener("toggle",t=>{const e=t.target;if(e&&e===this){const t=this.matches(":popover-open");wcEmitOverlay(this,t?"contour:open":"contour:close",{open:t})}})}}define("contour-tooltip",ContourTooltip);class ContourProgress extends ContourBase{static get observed(){return["value","label","min","max","paused","pausable"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},min:{attribute:"min"},max:{attribute:"max"},paused:{attribute:"paused",type:Boolean},pausable:{attribute:"pausable",type:Boolean}}}render(){this.classList.add("c-progress");const t=this.getAttribute("value"),e=this.getAttribute("min"),s=this.getAttribute("max"),r=null!==e?Number(e):0,i=null!==s?Number(s):100,a=i-r||1;if(null===t)this.style.removeProperty("--progress"),this.classList.add("c-progress--indeterminate"),this.getAttribute("aria-valuenow")===this._progressAriaValue&&this.removeAttribute("aria-valuenow"),this._progressAriaValue=null;else{this.classList.remove("c-progress--indeterminate");const e=Number(t);let s;s=Number.isFinite(e)?e<=1&&t.includes(".")?100*e:(e-r)/a*100:0,s=Math.max(0,Math.min(100,s)),this.style.setProperty("--progress",s+"%"),this.classList.toggle("c-progress--complete",s>=100);const n=Number.isFinite(e)?Math.max(r,Math.min(i,e)):r,o=this._progressAriaValue;this.hasAttribute("aria-valuenow")&&this.getAttribute("aria-valuenow")!==o||(this.setAttribute("aria-valuenow",String(n)),this._progressAriaValue=String(n))}this.ensure(".c-progress__bar",()=>{const t=document.createElement("span");return t.className="c-progress__bar",t}),this.hasAttribute("role")||this.setAttribute("role","progressbar");const n=this.getAttribute("label");if(this.hasAttribute("aria-label")||this.setAttribute("aria-label",n||"Progress"),null!==e?this.setAttribute("aria-valuemin",e):this.hasAttribute("aria-valuemin")||this.setAttribute("aria-valuemin","0"),null!==s?this.setAttribute("aria-valuemax",s):this.hasAttribute("aria-valuemax")||this.setAttribute("aria-valuemax","100"),this.hasAttribute("aria-valuenow")){const t=Number(this.getAttribute("aria-valuenow"));Number.isFinite(t)&&this.setAttribute("aria-valuenow",String(Math.max(r,Math.min(i,t))))}if(flagOn(this,"paused")?this.classList.add("c-progress--paused"):Array.from(this.classList).forEach(t=>{"c-progress--paused"===t&&this.classList.remove(t)}),flagOn(this,"pausable")){const t=flagOn(this,"paused"),e=this.ensure(".c-progress__pause",()=>{const t=document.createElement("button");return t.className="c-progress__pause",t.type="button",t});e.setAttribute("aria-label",t?"Resume":"Pause"),e.textContent=t?"▶":"⏸"}else{const t=this.querySelector(".c-progress__pause");t&&t.remove()}}enhance(){this._wiredProgress||(this._wiredProgress=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-progress__pause"):null;if(!e||!this.contains(e))return;t.preventDefault();const s=!flagOn(this,"paused");this.toggleAttribute("paused",s),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{paused:s}}))}))}}define("contour-progress",ContourProgress);class ContourVersionBannerFull extends ContourBase{static get observed(){return["message","link","href","dismissible"]}static get properties(){return{message:{attribute:"message"},link:{attribute:"link"},href:{attribute:"href"},dismissible:{attribute:"dismissible",type:Boolean}}}render(){this.classList.add("c-version-banner"),this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("message")||"Version banner"),Array.from(this.children).forEach(t=>t.remove());const t=this.getAttribute("message");if(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),setHTML(e,'<use href="#i-info" />'),this.appendChild(e);const s=document.createElement("span");s.textContent=t,this.appendChild(s)}const e=this.getAttribute("link"),s=this.getAttribute("href");if(e&&s){const t=document.createElement("a");t.className="c-version-banner__link",t.href=safeHref(s),t.textContent=e,this.appendChild(t)}if(flagOn(this,"dismissible")){const t=document.createElement("button");t.className="c-version-banner__dismiss",t.type="button",t.setAttribute("aria-label",labelText(this,"dismiss","Dismiss")),t.textContent="×",this.appendChild(t)}}enhance(){this._wiredVersionBanner||(this._wiredVersionBanner=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-version-banner__dismiss"):null;e&&this.contains(e)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})),this.remove())}))}}define("contour-version-banner",ContourVersionBannerFull);class ContourBanner extends ContourBase{static get observed(){return["message","variant"]}static get properties(){return{message:{attribute:"message"},variant:{attribute:"variant"}}}render(){this.classList.add("c-banner");const t=this.getAttribute("variant");Array.from(this.classList).forEach(t=>{t.startsWith("c-banner--")&&this.classList.remove(t)}),t&&["info","success","warning","danger","error"].includes(t)&&this.classList.add("c-banner--"+t);const e=statusIcon(t);let s=this.querySelector(".c-banner__icon");e?(s||(s=document.createElement("span"),s.className="c-banner__icon"),setHTML(s,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#'+String(e).replace(/[^a-zA-Z0-9_-]/g,"")+'" /></svg>'),this.firstChild!==s&&this.prepend(s)):s&&s.remove();const r=this.getAttribute("message");if(r){this.ensure(".c-banner__message",()=>{const t=document.createElement("span");return t.className="c-banner__message",t}).textContent=r}}}define("contour-banner",ContourBanner);class ContourPullToRefresh extends ContourBase{static get observed(){return["threshold"]}static get properties(){return{threshold:{attribute:"threshold"}}}render(){this.classList.add("c-pull-to-refresh"),this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"label","Pull to refresh"));const t=this.ensure(".c-pull-to-refresh__indicator",()=>{const t=document.createElement("div");return t.className="c-pull-to-refresh__indicator",t});t.innerHTML="";const e=document.createElement("span");e.className="c-pull-to-refresh__label",e.setAttribute("aria-live","polite"),e.textContent=this._ptrError?this._ptrError:this._ptrRefreshing?labelText(this,"refreshing","Refreshing…"):labelText(this,"label","Pull to refresh"),t.appendChild(e);const s=document.createElement("button");s.type="button",s.className="c-pull-to-refresh__btn",s.textContent=labelText(this,"refresh","Refresh"),t.appendChild(s),t.parentNode!==this&&this.prepend(t),this.classList.toggle("is-refreshing",!!this._ptrRefreshing),this.classList.toggle("has-error",!!this._ptrError),this.setAttribute("aria-busy",String(!!this._ptrRefreshing))}complete(){this._ptrRefreshing=!1,this._ptrError=null,this.style.removeProperty("--ptr-offset"),this.requestRender()}fail(t){this._ptrRefreshing=!1,this._ptrError=String(t||labelText(this,"error","Refresh failed")),this.style.removeProperty("--ptr-offset"),this.requestRender(),this.dispatchEvent(new CustomEvent("contour:error",{bubbles:!0,composed:!0,detail:{message:this._ptrError}}))}_refresh(){this._ptrRefreshing||(this._ptrRefreshing=!0,this._ptrError=null,this.style.removeProperty("--ptr-offset"),this.requestRender(),this.dispatchEvent(new CustomEvent("contour:refresh",{bubbles:!0,composed:!0})))}enhance(){if(this._wiredPullToRefresh)return;this._wiredPullToRefresh=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-pull-to-refresh__btn"):null;e&&this.contains(e)&&this._refresh()});let t=0,e=!1,s=0;this.addEventListener("pointerdown",r=>{if(!(this._ptrRefreshing||this.scrollTop>0||r.target&&r.target.closest&&r.target.closest(".c-pull-to-refresh__btn"))){t=r.clientY,e=!0,s=0;try{this.setPointerCapture(r.pointerId)}catch(t){}}}),this.addEventListener("pointermove",r=>{if(!e)return;const i=r.clientY-t;i>0&&(s=Math.min(120,.6*i),this.style.setProperty("--ptr-offset",s+"px"))});const r=()=>{if(!e)return;e=!1;const t=Number(this.getAttribute("threshold"))||60;s>=t?this._refresh():this.style.removeProperty("--ptr-offset"),s=0};this.addEventListener("pointerup",r),this.addEventListener("pointercancel",r)}}function menuPopoverCapable(t){return!!t&&"function"==typeof t.showPopover&&"function"==typeof t.hidePopover}function placeMenu(t,e,s,r){if(!t||!e)return;const i=e.getBoundingClientRect(),a=t.offsetWidth||0,n=t.offsetHeight||0;let o=i.bottom+s;o+n>window.innerHeight&&i.top-s-n>=0&&(o=i.top-s-n);let l=r?i.right-a:i.left;l=Math.max(0,Math.min(l,Math.max(0,window.innerWidth-a))),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.top=o+"px",t.style.left=l+"px"}function armMenuReposition(t,e,s,r,i){disarmMenuReposition(t);const a=()=>{e.hidden||placeMenu(e,s(),r,i)};t._menuReposition=a,window.addEventListener("scroll",a,!0),window.addEventListener("resize",a)}function disarmMenuReposition(t){const e=t._menuReposition;e&&(window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),t._menuReposition=null)}function setMenuOpen(t,e,s,r,i){if(e)if(r){if(e.hidden=!1,menuPopoverCapable(e)){e.style.removeProperty("margin");const r=getComputedStyle(e),a=parseFloat(r.marginBlockStart||r.marginTop)||0;try{e.showPopover()}catch(t){}placeMenu(e,s(),a,i),armMenuReposition(t,e,s,a,i)}}else{if(menuPopoverCapable(e)&&e.matches(":popover-open"))try{e.hidePopover()}catch(t){}disarmMenuReposition(t),e.hidden=!0}}define("contour-pull-to-refresh",ContourPullToRefresh);class ContourDropdown extends ContourBase{static get observed(){return["label","items","empty"]}static get properties(){return{label:{attribute:"label"},items:{attribute:"items"}}}render(){this.classList.add("c-dropdown"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"dropdown","Dropdown"));const t=this.ensure(".c-dropdown__trigger",()=>{const t=document.createElement("button");return t.className="c-dropdown__trigger c-btn c-btn--sm",t.type="button",t});t.textContent=this.getAttribute("label")||"Menu",t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false");const e=this.ensure(".c-dropdown__menu",()=>{const t=document.createElement("div");return t.className="c-dropdown__menu c-menu",t.setAttribute("role","menu"),t.hidden=!0,menuPopoverCapable(t)&&t.setAttribute("popover","manual"),t});e.id||(e.id=(this.id||contourId("dd"))+"-menu"),t.setAttribute("aria-controls",e.id);const s=Array.from(this.querySelectorAll(":scope > .c-menu__item")),r=this.getAttribute("items");if(s.length)e.innerHTML="",s.forEach(t=>{e.appendChild(t)});else if(r){const t=parseArrayAttr(this,"items",warnBadJson);e.innerHTML="",0===t.length?renderEmpty(this,"dropdown"):t.forEach(t=>{const s=document.createElement("button");s.className="c-menu__item",s.type="button",s.setAttribute("role","menuitem"),s.textContent="string"==typeof t?t:t.label||t.title||"",e.appendChild(s)})}e.parentNode!==this&&this.appendChild(e),t.parentNode!==this&&this.insertBefore(t,e)}enhance(){if(this._wiredDropdown)return;this._wiredDropdown=!0;const t=()=>this.querySelector(".c-dropdown__trigger"),e=()=>this.querySelector(".c-dropdown__menu");this.addEventListener("click",s=>{const r=t(),i=e(),a=s.target&&s.target.closest?s.target.closest(".c-menu__item"):null;if(a&&i&&i.contains(a)&&!i.hidden){const e=Array.from(i.querySelectorAll(".c-menu__item")).indexOf(a);if(this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:e,value:a.textContent}})),setMenuOpen(this,i,t,!1,!1),r){r.setAttribute("aria-expanded","false");try{r.focus()}catch(t){}}return}if((s.target===r||r&&r.contains(s.target))&&i){const e=i.hidden;if(setMenuOpen(this,i,t,e,!1),r.setAttribute("aria-expanded",String(e)),e){i.id||(i.id=(this.id||contourId("dd"))+"-menu"),r.setAttribute("aria-controls",i.id);const t=i.querySelector(".c-menu__item");if(t)try{t.focus()}catch(t){}}}});const s=s=>{const r=e(),i=t();!r||r.hidden||this.contains(s.target)||(setMenuOpen(this,r,t,!1,!1),i&&i.setAttribute("aria-expanded","false"))};document.addEventListener("click",s),onDispose(this,()=>document.removeEventListener("click",s)),onDispose(this,()=>disarmMenuReposition(this));const r=s=>{const r=e(),i=t();if("Escape"===s.key&&r&&!r.hidden){if(s.preventDefault(),setMenuOpen(this,r,t,!1,!1),i){i.setAttribute("aria-expanded","false");try{i.focus()}catch(t){}}return}if("ArrowDown"===s.key&&s.target===i&&r&&r.hidden){s.preventDefault(),setMenuOpen(this,r,t,!0,!1),i.setAttribute("aria-expanded","true"),r.id||(r.id=(this.id||contourId("dd"))+"-menu"),i.setAttribute("aria-controls",r.id);const e=r.querySelector(".c-menu__item");if(e)try{e.focus()}catch(t){}return}if(!r||r.hidden)return;const a=Array.from(r.querySelectorAll(".c-menu__item"));if(1===s.key.length&&!s.ctrlKey&&!s.metaKey&&!s.altKey){const t=(this._ddTypeaheadQuery||"")+s.key.toLowerCase();this._ddTypeaheadQuery=t,clearTimeout(this._ddTypeaheadTimer),this._ddTypeaheadTimer=setTimeout(()=>{this._ddTypeaheadQuery=""},800);const e=a.find(e=>e.textContent.toLowerCase().startsWith(t));e&&e.focus()}navKey(s,a,{wrap:!0,enter:!1,onKey:t=>{"Enter"!==t&&" "!==t||document.activeElement.click()}})},i=s=>{const r=e();if(r&&!r.hidden&&!this.contains(s.relatedTarget)){setMenuOpen(this,r,t,!1,!1);const e=t();e&&e.setAttribute("aria-expanded","false")}};this.addEventListener("focusout",i),onDispose(this,()=>this.removeEventListener("focusout",i)),document.addEventListener("keydown",r),onDispose(this,()=>document.removeEventListener("keydown",r))}}define("contour-dropdown",ContourDropdown);class ContourSplitButton extends ContourBase{static get observed(){return["label","menu","empty"]}static get properties(){return{label:{attribute:"label"},menu:{attribute:"menu"}}}render(){this.classList.add("c-split-button");const t=this.ensure(".c-split-button__main",()=>{const t=document.createElement("button");return t.className="c-btn c-split-button__main",t.type="button",t});t.textContent=this.getAttribute("label")||labelText(this,"action","Action");const e=this.ensure(".c-split-button__toggle",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--icon c-split-button__toggle",t.type="button",t.setAttribute("aria-label",labelText(this,"more-options","More options")),t.textContent="▾",t}),s=this.ensure(".c-split-button__menu",()=>{const t=document.createElement("div");return t.className="c-menu c-split-button__menu",t.setAttribute("role","menu"),t.hidden=!0,menuPopoverCapable(t)&&t.setAttribute("popover","manual"),t});s.id||(s.id=(this.id||contourId("split"))+"-menu"),e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-controls",s.id),e.setAttribute("aria-expanded",String(!s.hidden));if(this.getAttribute("menu")){const t=parseArrayAttr(this,"menu",warnBadJson);s.innerHTML="",0===t.length?renderEmpty(this,"split-button"):t.forEach(t=>{const e=document.createElement("button");e.className="c-menu__item",e.type="button",e.setAttribute("role","menuitem"),e.textContent="string"==typeof t?t:t.label||t.title||"",s.appendChild(e)})}t.parentNode!==this&&this.appendChild(t),e.parentNode!==this&&this.appendChild(e),s.parentNode!==this&&this.appendChild(s)}enhance(){if(this._wiredSplitButton)return;this._wiredSplitButton=!0;const t=()=>this.querySelector(".c-split-button__toggle"),e=()=>this.querySelector(".c-split-button__menu"),s=()=>Array.from(e()?.querySelectorAll(".c-menu__item")||[]),r=(r,i)=>{const a=e(),n=t();if(!a)return;const o=!a.hidden;if(setMenuOpen(this,a,t,r,!0),n&&n.setAttribute("aria-expanded",String(r)),r&&i){const t=s()[0];if(t)try{t.focus()}catch(t){}}o!==r&&this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{open:r}}))};onDispose(this,()=>disarmMenuReposition(this)),this.addEventListener("click",i=>{const a=i.target&&i.target.closest?i.target.closest(".c-split-button__main"):null;if(a&&this.contains(a))return void this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0,detail:{label:a.textContent}}));const n=t();if(i.target===n||n&&n.contains(i.target)){const t=e();return void r(!!t&&t.hidden,!0)}const o=i.target&&i.target.closest?i.target.closest(".c-menu__item"):null;if(o&&this.contains(o)){const e=s().indexOf(o);r(!1,!1);try{t()?.focus()}catch(t){}this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{label:o.textContent,index:e}}))}}),this.addEventListener("keydown",i=>{const a=t(),n=e(),o=s(),l=i.target===a||a&&a.contains(i.target),c=o.indexOf(i.target);if(!l||"Enter"!==i.key&&" "!==i.key&&"ArrowDown"!==i.key){if(l&&"ArrowUp"===i.key){i.preventDefault(),r(!0,!1);const t=o[o.length-1];if(t)try{t.focus()}catch(t){}}else if(c>=0){if("ArrowDown"===i.key)i.preventDefault(),o[(c+1)%o.length]?.focus();else if("ArrowUp"===i.key)i.preventDefault(),o[(c-1+o.length)%o.length]?.focus();else if("Home"===i.key)i.preventDefault(),o[0]?.focus();else if("End"===i.key)i.preventDefault(),o[o.length-1]?.focus();else if("Escape"===i.key){i.preventDefault(),r(!1,!1);try{a?.focus()}catch(t){}}}else if("Escape"===i.key&&n&&!n.hidden){r(!1,!1);try{a?.focus()}catch(t){}}}else i.preventDefault(),r(!0,!0);if(1===i.key.length&&!i.ctrlKey&&!i.metaKey&&!i.altKey){const t=(this._sbTypeaheadQuery||"")+i.key.toLowerCase();this._sbTypeaheadQuery=t,clearTimeout(this._sbTypeaheadTimer),this._sbTypeaheadTimer=setTimeout(()=>{this._sbTypeaheadQuery=""},800);const e=o.find(e=>e.textContent.toLowerCase().startsWith(t));e&&e.focus()}});const i=t=>{const s=e();!s||s.hidden||this.contains(t.relatedTarget)||r(!1,!1)};this.addEventListener("focusout",i),onDispose(this,()=>this.removeEventListener("focusout",i));const a=t=>{const s=e();!s||s.hidden||this.contains(t.target)||r(!1,!1)};document.addEventListener("click",a),onDispose(this,()=>document.removeEventListener("click",a))}}define("contour-split-button",ContourSplitButton);class ContourMapPopup extends ContourBase{static get observed(){return["title","content","cluster-count","cluster-expanded","cluster-items","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},"cluster-count":{attribute:"cluster-count",type:Number},"cluster-expanded":{attribute:"cluster-expanded",type:Boolean},"cluster-items":{attribute:"cluster-items"}}}render(){this.classList.add("c-map-popup"),this.setAttribute("role","dialog"),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("map-popup"));const t=this.getAttribute("title");if(t){this.ensure(".c-map-popup__title",()=>{const t=document.createElement("div");return t.className="c-map-popup__title",t}).textContent=t}const e=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-map-popup__title")&&!t.classList.contains("c-map-popup__body"))&&!(3===t.nodeType&&!t.textContent.trim())),s=this.getAttribute("content");if(e.length){const t=this.ensure(".c-map-popup__body",()=>{const t=document.createElement("div");return t.className="c-map-popup__body",t});for(const s of e)t.appendChild(s)}else if(s){this.ensure(".c-map-popup__body",()=>{const t=document.createElement("div");return t.className="c-map-popup__body",t}).textContent=s}const r=Number(this.getAttribute("cluster-count"));if(Number.isFinite(r)&&r>1){const t=this.ensure(".c-map-popup__cluster",()=>{const t=document.createElement("button");return t.className="c-map-popup__cluster c-btn c-btn--sm",t.type="button",t}),e=this.hasAttribute("cluster-expanded");t.textContent=e?"Hide locations":`${r} locations`,t.setAttribute("aria-expanded",String(e)),t.setAttribute("aria-label",e?"Hide locations":`Show ${r} locations`)}else{const t=this.querySelector(".c-map-popup__cluster");t&&t.remove()}const i=this.hasAttribute("cluster-expanded");let a=parseArrayAttr(this,"cluster-items",warnBadJson);const n=this.querySelector(".c-map-popup__cluster-list");if(i&&Array.isArray(a)&&a.length){const t=n||document.createElement("ul");t.className="c-map-popup__cluster-list",setHTML(t,""),a.forEach(e=>{const s=document.createElement("li");s.className="c-map-popup__cluster-item",s.textContent="string"==typeof e?e:e.label||e.name||JSON.stringify(e),t.appendChild(s)}),t.parentNode!==this&&this.appendChild(t)}else n&&n.remove();this.hasAttribute("aria-label")||this.setAttribute("aria-label",t||"Map popup");const o=this.getAttribute("anchor");let l=null;o&&(l=o.startsWith("#")?document.getElementById(o.slice(1)):document.querySelector(o)),this._mapPopupAnchorEl=l;const c="--map-popup-"+this.id;l&&(l.style.setProperty("anchor-name",c),this.style.setProperty("position-anchor",c))}enhance(){if(this._wiredMapPopup)return;this._wiredMapPopup=!0;const t=()=>{try{this.hidePopover()}catch(t){}this.classList.remove("is-open"),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))},e=e=>{"Escape"===e.key&&(this.classList.contains("is-open")||this.matches(":popover-open"))&&(e.preventDefault(),t())};document.addEventListener("keydown",e),onDispose(this,()=>document.removeEventListener("keydown",e)),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-map-popup__close"):null;s&&this.contains(s)&&t();const r=e.target&&e.target.closest?e.target.closest(".c-map-popup__cluster"):null;if(r&&this.contains(r)){const t=!this.hasAttribute("cluster-expanded");this.toggleAttribute("cluster-expanded",t),this.dispatchEvent(new CustomEvent("contour:cluster-toggle",{bubbles:!0,composed:!0,detail:{count:Number(this.getAttribute("cluster-count")),expanded:t}}))}});const s="--map-popup-"+this.id,r=()=>{const t=this._mapPopupAnchorEl;t&&(t.style.setProperty("anchor-name",s),this.style.setProperty("position-anchor",s))},i=()=>{try{const t=this.getBoundingClientRect(),e=t.right>window.innerWidth||t.left<0,s=t.bottom>window.innerHeight||t.top<0,r=e||s;this.classList.toggle("c-map-popup--flip-x",e&&!s),this.classList.toggle("c-map-popup--flip-y",s&&!e),this.classList.toggle("c-map-popup--flip-both",e&&s),r&&this.dispatchEvent(new CustomEvent("contour:map-popup-reposition",{bubbles:!0,composed:!0,detail:{anchor:this.getAttribute("anchor")||"",flippedX:e,flippedY:s,left:Math.round(t.left),top:Math.round(t.top)}}))}catch(t){}};this.addEventListener("toggle",t=>{"open"===t.newState&&requestAnimationFrame(()=>{r(),i()})});const a=()=>i();window.addEventListener("resize",a),onDispose(this,()=>{window.removeEventListener("resize",a),this._mapPopupAnchorEl&&this._mapPopupAnchorEl.style.removeProperty("anchor-name")})}}define("contour-map-popup",ContourMapPopup);class ContourAnimationControls extends ContourBase{static get observed(){return["playing","speed","progress","min","max","caption","show-thumb","show-thumb-caption","loop","step","markers"]}static get properties(){return{playing:{attribute:"playing",type:Boolean},speed:{attribute:"speed"},progress:{attribute:"progress"},min:{attribute:"min"},max:{attribute:"max"},loop:{attribute:"loop",type:Boolean},step:{attribute:"step"},markers:{attribute:"markers"}}}render(){this.classList.add("c-animation-controls"),this.setAttribute("role","toolbar"),this.setAttribute("aria-label",labelText(this,"animation-controls","Animation controls"));const t=this.ensure(".c-animation-controls__play",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-animation-controls__play",t.type="button",t});setHTML(t,this.hasAttribute("playing")?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-pause" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-play" /></svg>'),t.setAttribute("aria-label",this.hasAttribute("playing")?labelText(this,"pause","Pause"):labelText(this,"play","Play"));const e=this.getAttribute("speed")||"1x",s=this.ensure(".c-animation-controls__speed",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-animation-controls__speed",t.type="button",t});s.textContent=e,s.setAttribute("aria-label",labelText(this,"playback-speed","Playback speed")+" "+e);const r=this.ensure(".c-animation-controls__loop",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-animation-controls__loop",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-refresh" /></svg>'),t});r.setAttribute("aria-label",labelText(this,"loop","Loop")),r.setAttribute("aria-pressed",String(this.hasAttribute("loop"))),t.tabIndex=0,s.tabIndex=-1,r.tabIndex=-1;const i=this.ensure(".c-animation-controls__scrubber",()=>{const t=document.createElement("input");return t.className="c-range c-animation-controls__scrubber",t.type="range",t});"false"===this.getAttribute("show-thumb")?i.classList.remove("c-animation-controls__scrubber--thumb"):i.classList.add("c-animation-controls__scrubber--thumb"),i.min=this.getAttribute("min")||"0",i.max=this.getAttribute("max")||"100",i.step=this.getAttribute("step")||"1",i.value=this.getAttribute("progress")||"0";{const t=Number(i.min)||0,e=Number(i.max)||100,s=Number(i.value)||0,r=e===t?0:(s-t)/(e-t)*100;i.style.setProperty("--fill",r+"%")}const a=Number(i.min)||0,n=Number(i.max)||100,o=Number(i.value)||a;i.setAttribute("aria-valuenow",String(o)),i.setAttribute("aria-valuetext",String(Math.round(o))),i.setAttribute("aria-valuemin",String(a)),i.setAttribute("aria-valuemax",String(n));const l=this.getAttribute("caption");l?i.setAttribute("aria-label",l):i.getAttribute("aria-label")||i.setAttribute("aria-label",labelText(this,"playhead","Playhead"));const c=this.getAttribute("markers");let u=[];if(c)try{const t=JSON.parse(c);u=Array.isArray(t)?t:[]}catch(t){warnBadJson(this,"markers",t)}const d=this.querySelector("datalist.c-animation-controls__markers");if(u.length){const t=this.ensure("datalist.c-animation-controls__markers",()=>{const t=document.createElement("datalist");return t.className="c-animation-controls__markers",t});t.id||(t.id=this._animMarkersId||(this._animMarkersId=contourId("anim-markers"))),setHTML(t,""),u.forEach(e=>{const s=document.createElement("option"),r="object"==typeof e&&null!==e?e.value:e;s.value=String(r),"object"==typeof e&&null!==e&&e.label&&(s.label=String(e.label)),t.appendChild(s)}),i.setAttribute("list",t.id)}else d&&d.remove(),i.removeAttribute("list");const h=this.hasAttribute("show-thumb-caption")||this.hasAttribute("show-thumb");if(l&&h){this.ensure(".c-animation-controls__caption",()=>{const t=document.createElement("span");return t.className="c-animation-controls__caption",t}).textContent=l}else{const t=this.querySelector(".c-animation-controls__caption");t&&t.remove()}this.hasAttribute("loop")&&this.setAttribute("aria-label",labelText(this,"animation-controls-loop","Animation controls, loop"))}enhance(){if(this._wiredAnimControls)return;this._wiredAnimControls=!0;const t=[.5,1,2,4],e=t=>{this._animScrubbing||this.setAttribute("progress",String(t))};this.addEventListener("pointerdown",t=>{t.target&&t.target.closest&&t.target.closest(".c-animation-controls__scrubber")&&(this._animScrubbing=!0)},{passive:!0});const s=()=>{this._animScrubbing=!1};this.addEventListener("pointerup",s,{passive:!0}),this.addEventListener("pointercancel",s,{passive:!0}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-animation-controls__play"):null;if(s&&this.contains(s)){const t=!this.hasAttribute("playing");return this.toggleAttribute("playing",t),void this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{playing:t}}))}const r=e.target&&e.target.closest?e.target.closest(".c-animation-controls__speed"):null;if(r&&this.contains(r)){const e=parseFloat(this.getAttribute("speed")||"1x"),s=t.indexOf(Number.isFinite(e)?e:1),r=t[(s+1)%t.length];return this.setAttribute("speed",r+"x"),void this.dispatchEvent(new CustomEvent("contour:speed-change",{bubbles:!0,composed:!0,detail:{speed:r}}))}const i=e.target&&e.target.closest?e.target.closest(".c-animation-controls__loop"):null;if(i&&this.contains(i)){const t=!this.hasAttribute("loop");this.toggleAttribute("loop",t),this.dispatchEvent(new CustomEvent("contour:loop-change",{bubbles:!0,composed:!0,detail:{loop:t}}))}}),this.addEventListener("input",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-animation-controls__scrubber"):null;if(s&&this.contains(s)){const t=Number(s.value),r=Number(s.min)||0,i=Number(s.max)||100,a=i===r?0:(t-r)/(i-r)*100;s.style.setProperty("--fill",a+"%"),e(t),this.dispatchEvent(new CustomEvent("contour:seek",{bubbles:!0,composed:!0,detail:{progress:t,value:t}}))}}),this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-animation-controls__scrubber"):null;e&&this.contains(e)&&this.setAttribute("progress",e.value)}),this.addEventListener("keydown",t=>{if(t.target&&t.target.closest&&t.target.closest(".c-animation-controls__scrubber"))return;const e=Array.from(this.querySelectorAll(".c-animation-controls__play, .c-animation-controls__speed, .c-animation-controls__loop"));e.includes(t.target)&&navKey(t,e,{wrap:!0,homeEnd:!0,onNavigate:t=>{e.forEach((e,s)=>{e.tabIndex=s===t?0:-1})},onKey:(t,e,s)=>{"Enter"!==t&&" "!==t||s.click()}})});let r=null;const i=()=>{const t=this.getAttribute("speed")||"1x",e=parseFloat(t);return Number.isFinite(e)&&e>0?e:1},a=()=>{const t=this.querySelector(".c-animation-controls__scrubber");if(!t)return;const s=Number(t.min||0),r=Number(t.max||100);let a=Number(t.value||0)+i(),n=!1;a>r&&(this.hasAttribute("loop")?a=s:(a=r,o(),n=!0)),t.value=String(a),e(a),this.dispatchEvent(new CustomEvent("contour:time-change",{bubbles:!0,composed:!0,detail:{progress:a,value:a}})),n&&(this.removeAttribute("playing"),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{playing:!1}})))},n=()=>{r||(r=setInterval(a,100))},o=()=>{r&&(clearInterval(r),r=null)};this.hasAttribute("playing")&&n();const l=new MutationObserver(()=>{this.hasAttribute("playing")?n():o()});l.observe(this,{attributes:!0,attributeFilter:["playing"]}),onDispose(this,()=>{o(),l.disconnect()})}}define("contour-animation-controls",ContourAnimationControls);class ContourAnnotation extends ContourBase{static get observed(){return["label","x","y"]}static get properties(){return{label:{attribute:"label"},x:{attribute:"x"},y:{attribute:"y"}}}render(){this.classList.add("c-annotation"),this.setAttribute("role","note"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const t=this.getAttribute("label");if(t&&this.setAttribute("aria-label",t),t){this.ensure(".c-annotation__label",()=>{const t=document.createElement("span");return t.className="c-annotation__label",t}).textContent=t}const e=this.getAttribute("x"),s=this.getAttribute("y");null!==e&&this.style.setProperty("--annotation-x",e),null!==s&&this.style.setProperty("--annotation-y",s)}enhance(){if(this._wiredAnnotation)return;this._wiredAnnotation=!0;const t=(t,e)=>{const s=parseFloat(t);return Number.isFinite(s)?Math.min(100,Math.max(0,s)):e},e=(t,e,s)=>{this.batch(()=>{this.setAttribute("x",t+"%"),this.setAttribute("y",e+"%")}),this.dispatchEvent(new CustomEvent("contour:drag",{bubbles:!0,composed:!0,detail:{delta:s?1:0,key:s||"pointer",value:t+","+e}}))};let s=null;this.addEventListener("pointerdown",e=>{if(void 0!==e.button&&0!==e.button)return;const r=this.offsetParent||this.parentElement;if(!r)return;const i=r.getBoundingClientRect();s={px:e.clientX,py:e.clientY,x:t(this.getAttribute("x"),50),y:t(this.getAttribute("y"),50),w:i.width||1,h:i.height||1};try{this.setPointerCapture(e.pointerId)}catch(t){}try{this.focus()}catch(t){}e.preventDefault()}),this.addEventListener("pointermove",t=>{if(!s)return;const r=Math.round(10*(s.x+(t.clientX-s.px)/s.w*100))/10,i=Math.round(10*(s.y+(t.clientY-s.py)/s.h*100))/10;e(Math.min(100,Math.max(0,r)),Math.min(100,Math.max(0,i)))});const r=()=>{s&&(s=null,this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:!0,composed:!0,detail:{value:(this.getAttribute("x")||"")+","+(this.getAttribute("y")||"")}})))};this.addEventListener("pointerup",r),this.addEventListener("pointercancel",r),this.addEventListener("keydown",s=>{const r=s.shiftKey?10:1;let i=0,a=0;if("ArrowLeft"===s.key)i=-r;else if("ArrowRight"===s.key)i=r;else if("ArrowUp"===s.key)a=-r;else{if("ArrowDown"!==s.key)return;a=r}s.preventDefault();const n=Math.min(100,Math.max(0,t(this.getAttribute("x"),50)+i)),o=Math.min(100,Math.max(0,t(this.getAttribute("y"),50)+a));e(n,o,s.key),this.dispatchEvent(new CustomEvent("contour:dragend",{bubbles:!0,composed:!0,detail:{value:n+","+o}}))})}}define("contour-annotation",ContourAnnotation);class ContourStyleSwitcher extends ContourBase{static get observed(){return["items","value"]}static get properties(){return{items:{attribute:"items"},value:{attribute:"value"}}}render(){this.classList.add("c-style-switcher"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"style-switcher","Style switcher"));const t=this.getAttribute("items"),e=this.getAttribute("value"),s=Array.from(this.children).filter(t=>t.classList&&t.classList.contains("c-style-switcher__option"));if(t&&!s.length){Array.from(this.querySelectorAll(".c-style-switcher__option")).forEach(t=>t.remove());try{JSON.parse(t).forEach(t=>{const e="string"==typeof t?t:t.name||t.label||"",s=document.createElement("button");s.className="c-style-switcher__option c-btn c-btn--sm",s.type="button",s.textContent=e,s.dataset.value=e,this.appendChild(s)})}catch(t){warnBadJson(this,"attribute",t)}}const r=Array.from(this.querySelectorAll(".c-style-switcher__option"));let i=null;r.forEach(t=>{const s=(null!=t.dataset.value?t.dataset.value:t.textContent.trim())===e;t.classList.toggle("c-style-switcher__option--active",s),t.setAttribute("aria-pressed",String(s)),t.tabIndex=-1,s&&!i&&(i=t)}),(i||r[0])?.setAttribute("tabindex","0")}enhance(){if(this._wiredStyleSwitcher)return;this._wiredStyleSwitcher=!0;const t=t=>{const e=null!=t.dataset.value?t.dataset.value:t.textContent.trim();this.setAttribute("value",e),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e}}))};this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-style-switcher__option"):null;s&&this.contains(s)&&t(s)}),this.addEventListener("keydown",e=>{const s=Array.from(this.querySelectorAll(".c-style-switcher__option"));navKey(e,s,{onKey:e=>{if("Enter"===e||" "===e){const e=document.activeElement;e&&e.classList.contains("c-style-switcher__option")&&t(e)}}})})}}define("contour-style-switcher",ContourStyleSwitcher);class ContourStylePanel extends ContourBase{static get observed(){return["title","layers","layer","single","classification","palette","breaks","opacity","n","colors","property"]}static get properties(){return{title:{attribute:"title"},layers:{attribute:"layers"},classification:{attribute:"classification"},palette:{attribute:"palette"},breaks:{attribute:"breaks"},opacity:{attribute:"opacity"}}}render(){if(this.classList.add("c-style-panel"),!this._stylePanelDefault){this._stylePanelDefault={};for(const t of["property","classification","palette","breaks","opacity","n","colors"])this._stylePanelDefault[t]=this.getAttribute(t)}this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"style-panel","Style panel"));const t=this.getAttribute("title");if(t){this.ensure(".c-style-panel__title",()=>{const t=document.createElement("div");return t.className="c-style-panel__title",t}).textContent=t}if(this.hasAttribute("single")||!!this.getAttribute("layer")){const t=this.ensure(".c-style-panel__body",()=>{const t=document.createElement("div");return t.className="c-style-panel__body",t});setHTML(t,"");const e=contourId("style-panel"),s=e+"-property",r=e+"-policy",i=e+"-palette",a=e+"-n",n=document.createElement("label");n.textContent=labelText(this,"colour-field","Colour field"),n.setAttribute("for",s),t.appendChild(n);const o=document.createElement("input");o.type="text",o.id=s,o.className="c-style-panel__property c-input",o.setAttribute("aria-label",labelText(this,"colour-field","Colour field"));const l=this.getAttribute("property");l&&(o.value=l),t.appendChild(o);const c=document.createElement("label");c.textContent=labelText(this,"classification","Classification"),c.setAttribute("for",r),t.appendChild(c);const u=document.createElement("select");u.id=r,u.className="c-style-panel__classification c-input",u.setAttribute("aria-label",labelText(this,"classification-method","Classification method")),["equal","quantile","jenks","manual"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t,u.appendChild(e)});const d=this.getAttribute("classification");d&&(u.value=d),t.appendChild(u);const h=document.createElement("label");h.textContent=labelText(this,"palette","Palette"),h.setAttribute("for",i),t.appendChild(h);const p=document.createElement("input");p.type="text",p.id=i,p.className="c-style-panel__palette c-input",p.placeholder=labelText(this,"palette","Palette"),p.setAttribute("aria-label",labelText(this,"palette","Palette"));const b=this.getAttribute("palette");b&&(p.value=b),t.appendChild(p);const m=document.createElement("label");m.textContent=labelText(this,"classes","Classes"),m.setAttribute("for",a),t.appendChild(m);const g=document.createElement("input");g.type="number",g.id=a,g.className="c-style-panel__n c-input",g.min="2",g.max="12",g.setAttribute("aria-label",labelText(this,"class-count","Class count"));const v=this.getAttribute("n");g.value=v||"5",t.appendChild(g);const _=document.createElement("input");_.type="range",_.className="c-style-panel__opacity",_.setAttribute("aria-label",labelText(this,"opacity","Opacity")),_.min="0",_.max="100";const f=this.getAttribute("opacity");_.value=null!=f?f:"100",t.appendChild(_);const y=this.getAttribute("breaks");let A=null;if(y)try{A=JSON.parse(y)}catch(t){A=y.split(",").map(t=>t.trim())}if(Array.isArray(A)&&A.length){const e=document.createElement("div");e.className="c-style-panel__breaks",A.forEach((t,s)=>{const r=document.createElement("div");r.className="break";const i=document.createElement("span");i.textContent=String(t),r.appendChild(i);const a=document.createElement("input");a.type="number",a.className="c-style-panel__breaks c-input",a.setAttribute("aria-label",labelText(this,"class-lower-bound","Class lower bound")),a.value=String(t),r.appendChild(a),e.appendChild(r)}),t.appendChild(e)}const w=this.getAttribute("colors");let E=null;if(w)try{E=JSON.parse(w)}catch(t){E=w.split(",").map(t=>t.trim())}if(Array.isArray(E)){const e=document.createElement("div");e.className="c-style-panel__colors",E.forEach((t,s)=>{const r=document.createElement("input");r.type="color",r.className="c-style-panel__color c-input",r.setAttribute("aria-label",labelText(this,"colour-for-class","Colour for class")+" "+(s+1)),r.value=t,e.appendChild(r)}),t.appendChild(e)}const x=document.createElement("div");x.className="c-style-panel__actions c-btn-group";const C=document.createElement("button");C.type="button",C.className="c-btn c-btn--primary",C.textContent=labelText(this,"apply","Apply"),C.dataset.action="apply";const S=document.createElement("button");return S.type="button",S.className="c-btn",S.textContent=labelText(this,"revert","Revert"),S.dataset.action="revert",x.appendChild(C),x.appendChild(S),void t.appendChild(x)}const e=this.getAttribute("layers"),s=this.ensure(".c-style-panel__body",()=>{const t=document.createElement("div");return t.className="c-style-panel__body",t}),r=Array.from(this.querySelectorAll(":scope > .c-style-panel__row"));let i=null;if(r.length)i=r.map(t=>({name:t.querySelector(".c-style-panel__name")?.textContent||"",color:t.querySelector(".c-style-panel__color")?.value,classification:t.querySelector(".c-style-panel__classification")?.value,palette:t.querySelector(".c-style-panel__palette")?.value,breaks:t.querySelector(".c-style-panel__breaks")?.value,opacity:t.querySelector(".c-style-panel__opacity")?.value})),r.forEach(t=>t.remove());else if(e)try{i=JSON.parse(e)}catch(t){warnBadJson(this,"layers",t),i=null}i&&(setHTML(s,""),i.forEach(t=>{const e=document.createElement("div");e.className="c-style-panel__row";const r=document.createElement("span");r.className="c-style-panel__name",r.textContent="string"==typeof t?t:t.name||t.label||"",e.appendChild(r);const i=document.createElement("input");i.type="color",i.className="c-style-panel__color",i.setAttribute("aria-label",labelText(this,"colour-for","Colour for")+" "+("string"==typeof t?t:t.name||t.label||labelText(this,"layer","layer"))),"object"==typeof t&&t.color&&(i.value=t.color),e.appendChild(i);const a=document.createElement("select");a.className="c-style-panel__classification",a.setAttribute("aria-label",labelText(this,"classification-method","Classification method")),["equal","quantile","jenks","manual"].forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=t,a.appendChild(e)}),"object"==typeof t&&t.classification&&(a.value=t.classification),e.appendChild(a);const n=document.createElement("input");n.type="text",n.className="c-style-panel__palette",n.setAttribute("aria-label",labelText(this,"palette","Palette")),n.placeholder="palette","object"==typeof t&&t.palette&&(n.value=t.palette),e.appendChild(n);const o=document.createElement("input");o.type="text",o.className="c-style-panel__breaks",o.placeholder="breaks",o.setAttribute("aria-label",labelText(this,"class-breaks","Class breaks")),"object"==typeof t&&t.breaks&&(o.value=Array.isArray(t.breaks)?t.breaks.join(","):t.breaks),e.appendChild(o);const l=document.createElement("input");l.type="range",l.className="c-style-panel__opacity",l.setAttribute("aria-label",labelText(this,"opacity","Opacity")),l.min="0",l.max="100",l.value="object"==typeof t&&null!=t.opacity?t.opacity:"100",e.appendChild(l),s.appendChild(e)}))}enhance(){this._wiredStylePanel||(this._wiredStylePanel=!0,this.addEventListener("change",t=>{const e=t.target;if(!e||!this.contains(e))return;const s=e.closest(".c-style-panel__row"),r=s&&s.querySelector(".c-style-panel__name")?.textContent||"";if(e.classList.contains("c-style-panel__color"))this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:e.value,layer:r,property:"color"},bubbles:!0,composed:!0}));else if(e.classList.contains("c-style-panel__classification"))this.dispatchEvent(new CustomEvent("contour:break-change",{detail:{value:e.value,layer:r},bubbles:!0,composed:!0}));else if(e.classList.contains("c-style-panel__opacity")){const t=r?r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""):"";this.dispatchEvent(new CustomEvent("contour:layer-opacity",{detail:{layerId:t,name:r,opacity:Number(e.value)},bubbles:!0,composed:!0}))}else e.classList.contains("c-style-panel__property")?this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:e.value,layer:r,property:"property"},bubbles:!0,composed:!0})):e.classList.contains("c-style-panel__n")&&this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:Number(e.value),layer:r,property:"n"},bubbles:!0,composed:!0}))}),this.addEventListener("input",t=>{const e=t.target;if(e&&this.contains(e)&&(e.classList.contains("c-style-panel__color")&&e.setAttribute("data-edited","true"),e.classList.contains("c-style-panel__palette")||e.classList.contains("c-style-panel__breaks"))){const t=e.closest(".c-style-panel__row"),s=t&&t.querySelector(".c-style-panel__name")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{value:e.value,layer:s,property:e.classList.contains("c-style-panel__palette")?"palette":"breaks"},bubbles:!0,composed:!0}))}}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest("button"):null;if(e&&this.contains(e))if("apply"===e.dataset.action){const t=this.querySelector(".c-style-panel__body"),e={applied:!0};if(t){const s=t.querySelector(".c-style-panel__property"),r=t.querySelector(".c-style-panel__classification"),i=t.querySelector(".c-style-panel__palette"),a=t.querySelector(".c-style-panel__n"),n=Array.from(t.querySelectorAll(".c-style-panel__color")).map(t=>t.value);s&&(e.property=s.value),r&&(e.classification=r.value),i&&(e.palette=i.value),a&&(e.n=Number(a.value)),n.length&&(e.colors=n)}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:e,bubbles:!0,composed:!0}))}else if("revert"===e.dataset.action){const t=this._stylePanelDefault||{};this._contourResetting=!0;try{for(const e of["property","classification","palette","breaks","opacity","n","colors"])null===t[e]||void 0===t[e]?this.removeAttribute(e):this.setAttribute(e,t[e]);this.attributeChangedCallback("__rerender__",null,"")}finally{this._contourResetting=!1}this.dispatchEvent(new CustomEvent("contour:style-resolved",{detail:{applied:!1},bubbles:!0,composed:!0}))}}))}}define("contour-style-panel",ContourStylePanel);class ContourPopover extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"}}}render(){this.classList.add("c-popover"),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"popover","Popover")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("popover"));const t=this.getAttribute("title");if(t){this.ensure(".c-popover__title",()=>{const t=document.createElement("div");return t.className="c-popover__title",t}).textContent=t}const e=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-popover__title")&&!t.classList.contains("c-popover__body"))&&!(3===t.nodeType&&!t.textContent.trim())),s=this.getAttribute("content");if(e.length){const t=this.ensure(".c-popover__body",()=>{const t=document.createElement("div");return t.className="c-popover__body",t});for(const s of e)t.appendChild(s)}else if(s){this.ensure(".c-popover__body",()=>{const t=document.createElement("div");return t.className="c-popover__body",t}).textContent=s}this._applyPopoverAnchor()}_applyPopoverAnchor(){const t=this.getAttribute("anchor"),e=t?t.startsWith("#")?document.getElementById(t.slice(1)):document.querySelector(t):null;if(this._popoverAnchorEl&&this._popoverAnchorEl!==e&&(this._popoverAnchorEl.style.removeProperty("anchor-name"),this._popoverAnchorEl.removeAttribute("aria-controls"),this._popoverAnchorEl.removeAttribute("aria-expanded")),this._popoverAnchorEl=e||null,e){const t="--popover-"+this.id;e.style.setProperty("anchor-name",t),this.style.setProperty("position-anchor",t),e.setAttribute("aria-controls",this.id),this._popoverAnchorDispose||(this._popoverAnchorDispose=!0,onDispose(this,()=>{this._popoverAnchorEl&&this._popoverAnchorEl.style.removeProperty("anchor-name"),this._popoverAnchorDispose=!1}))}else this.style.removeProperty("position-anchor")}_setPopoverTriggerExpanded(t){const e=this._popoverAnchorEl;e&&(e.setAttribute("aria-controls",this.id),e.setAttribute("aria-expanded",String(!!t)))}enhance(){if(this._wiredPopover)return;this._wiredPopover=!0;const t=()=>{try{this.hidePopover()}catch(t){}this.classList.remove("is-open"),wcEmitOverlay(this,"contour:close",{}),this._setPopoverTriggerExpanded(!1)},e=e=>{if(this.classList.contains("is-open")||this.matches(":popover-open")){if("Escape"===e.key)return e.preventDefault(),void t();if("Tab"===e.key){const t=Array.from(this.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!t.length)return void e.preventDefault();const s=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===s?(e.preventDefault(),r.focus()):e.shiftKey||document.activeElement!==r||(e.preventDefault(),s.focus())}}};document.addEventListener("keydown",e),onDispose(this,()=>document.removeEventListener("keydown",e));const s=()=>{this.classList.add("is-open"),wcEmitOverlay(this,"contour:open",{});const t=this.querySelector('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(t)try{t.focus()}catch(t){}else try{this.focus()}catch(t){}this._setPopoverTriggerExpanded(!0)};this.addEventListener("beforetoggle",t=>{"open"===t.newState&&s()});const r=t=>{t.target&&t.target!==this&&this.contains(t.target)&&this.classList.add("is-parent")};this.addEventListener("contour:open",r),this.addEventListener("contour:show",r),this.addEventListener("contour:close",t=>{t.target&&t.target!==this&&this.classList.remove("is-parent")}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-popover__close"):null;s&&this.contains(s)&&t()})}}define("contour-popover",ContourPopover);class ContourHoverCard extends ContourBase{static get observed(){return["title","content","anchor"]}static get properties(){return{title:{attribute:"title"},content:{attribute:"content"},anchor:{attribute:"anchor"}}}render(){this.classList.add("c-hover-card"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"hover-card","Hover card")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("hover-card"));const t=this.getAttribute("title");if(t){this.ensure(".c-hover-card__title",()=>{const t=document.createElement("div");return t.className="c-hover-card__title",t}).textContent=t}const e=Array.from(this.childNodes).filter(t=>(1!==t.nodeType||!t.classList||!t.classList.contains("c-hover-card__title")&&!t.classList.contains("c-hover-card__body"))&&!(3===t.nodeType&&!t.textContent.trim())),s=this.getAttribute("content");if(e.length){const t=this.ensure(".c-hover-card__body",()=>{const t=document.createElement("div");return t.className="c-hover-card__body",t});for(const s of e)t.appendChild(s)}else if(s){this.ensure(".c-hover-card__body",()=>{const t=document.createElement("div");return t.className="c-hover-card__body",t}).textContent=s}if(!this.hasAttribute("role")){const t=!!this.querySelector("a[href], button, input, select, textarea");this.setAttribute("role",t?"dialog":"tooltip")}"function"==typeof this._wireHoverAnchor&&this._wireHoverAnchor()}enhance(){if(this._wiredHoverCard)return;this._wiredHoverCard=!0;let t=null,e=null;const s="function"==typeof this.showPopover,r=()=>{t&&(clearTimeout(t),t=null),e&&(clearTimeout(e),e=null)},i=t=>{if(r(),s)try{this.showPopover(t?{source:t}:void 0)}catch(t){try{this.showPopover()}catch(t){}}else this.classList.add("is-open");this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}))},a=()=>{if(r(),s)try{this.hidePopover()}catch(t){}else this.classList.remove("is-open");this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))},n=()=>{e&&clearTimeout(e),e=setTimeout(a,300)};this.addEventListener("mouseenter",r),this.addEventListener("mouseleave",n),this.addEventListener("focusin",r),this.addEventListener("focusout",t=>{this.contains(t.relatedTarget)||n()}),this._wireHoverAnchor=()=>{const e=this.getAttribute("anchor")||"";if(this._hoverAnchorSel===e&&this._hoverAnchorCleanup)return;if(this._hoverAnchorCleanup&&(this._hoverAnchorCleanup(),this._hoverAnchorCleanup=null),this._hoverAnchorSel=e,!e)return;const s=e.startsWith("#")?document.getElementById(e.slice(1)):document.querySelector(e);if(!s)return;s.setAttribute("popovertarget",this.id),s.setAttribute("aria-describedby",this.id);const a="--hover-card-"+this.id;s.style.setProperty("anchor-name",a),this.style.setProperty("position-anchor",a);const o=()=>{r(),t=setTimeout(()=>i(s),300)},l=()=>{n()},c=()=>i(s),u=()=>{n()},d=t=>{t&&t.preventDefault&&t.preventDefault()};s.addEventListener("mouseenter",o),s.addEventListener("mouseleave",l),s.addEventListener("focus",c),s.addEventListener("blur",u),s.addEventListener("click",d),this._hoverAnchorCleanup=()=>{s.removeEventListener("mouseenter",o),s.removeEventListener("mouseleave",l),s.removeEventListener("focus",c),s.removeEventListener("blur",u),s.removeEventListener("click",d),s.style.removeProperty("anchor-name"),s.getAttribute("aria-describedby")===this.id&&s.removeAttribute("aria-describedby")}},this._wireHoverAnchor();const o=t=>{"Escape"===t.key&&(this.classList.contains("is-open")||this.matches(":popover-open"))&&(t.preventDefault(),a())};document.addEventListener("keydown",o),onDispose(this,()=>{r(),this._hoverAnchorCleanup&&(this._hoverAnchorCleanup(),this._hoverAnchorCleanup=null),this._hoverAnchorSel=null,document.removeEventListener("keydown",o)})}}define("contour-hover-card",ContourHoverCard);class ContourContextMenu extends ContourBase{static get observed(){return["items","trigger"]}static get properties(){return{items:{attribute:"items"},trigger:{attribute:"trigger"}}}render(){this.classList.add("c-context-menu"),this.hasAttribute("role")||this.setAttribute("role","menu"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"context-menu","Context menu")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("context-menu"));const t=this.getAttribute("items");if(t)try{const e=JSON.parse(t);Array.from(this.querySelectorAll("[data-contour-generated='1']")).forEach(t=>t.remove()),e.forEach(t=>{const e=document.createElement("button");e.className="c-menu__item",e.type="button",e.setAttribute("role","menuitem"),e.dataset.contourGenerated="1",e.textContent="string"==typeof t?t:t.label||t.title||"",this.appendChild(e)})}catch(t){warnBadJson(this,"attribute",t)}}enhance(){if(this._wiredContextMenu)return;this._wiredContextMenu=!0;const t=t=>{if("function"==typeof this.hidePopover)try{this.hidePopover()}catch(t){}if(this.classList.remove("is-open"),t&&this._ctxOpener&&this._ctxOpener.isConnected&&"function"==typeof this._ctxOpener.focus)try{this._ctxOpener.focus()}catch(t){}this._ctxOpener=null},e=(t,e)=>{if(this._ctxOpener=document.activeElement,"function"==typeof this.showPopover)try{this.showPopover()}catch(t){}else this.classList.add("is-open");if(Number.isFinite(t)&&Number.isFinite(e)){this.style.position="fixed",this.style.left=t+"px",this.style.top=e+"px";const s=this.getBoundingClientRect(),r=window.innerWidth||document.documentElement.clientWidth,i=window.innerHeight||document.documentElement.clientHeight,a=Math.max(8,Math.min(t,Math.max(8,r-s.width-8))),n=Math.max(8,Math.min(e,Math.max(8,i-s.height-8)));this.style.left=a+"px",this.style.top=n+"px"}const s=this.querySelector(".c-menu__item:not([disabled])");if(s&&"function"==typeof s.focus)try{s.focus()}catch(t){}},s=this.getAttribute("trigger");if(s){const t=document.querySelector(s);if(t){t.hasAttribute("aria-haspopup")||t.setAttribute("aria-haspopup","menu");const s=t=>{t.preventDefault(),e(t.clientX,t.clientY)};t.addEventListener("contextmenu",s),onDispose(this,()=>t.removeEventListener("contextmenu",s))}}this.addEventListener("contextmenu",t=>{t.preventDefault(),e(t.clientX,t.clientY)}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-menu__item"):null;s&&this.contains(s)&&(this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{label:s.textContent.trim()}})),t(!1))}),this.addEventListener("keydown",e=>{const s=Array.from(this.querySelectorAll(".c-menu__item"));navKey(e,s,{wrap:!0,onKey:()=>{"Enter"!==e.key&&" "!==e.key||document.activeElement.click()}}),"Escape"===e.key&&(e.preventDefault(),t(!0))})}}define("contour-context-menu",ContourContextMenu);class ContourFab extends ContourBase{static get observed(){return["label","icon"]}static get properties(){return{label:{attribute:"label"},icon:{attribute:"icon"}}}render(){this.classList.add("c-fab"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0");const t=this.getAttribute("label");t&&this.setAttribute("aria-label",t);const e=this.getAttribute("icon");if(e&&!this.querySelector("svg")){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("aria-hidden","true"),t.setAttribute("viewBox","0 0 24 24");const s=document.createElementNS("http://www.w3.org/2000/svg","use");s.setAttribute("href",e.startsWith("#")?e:"#"+e),t.appendChild(s),this.appendChild(t)}}enhance(){this._wiredFab||(this._wiredFab=!0,this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0}))}),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0})))}))}}define("contour-fab",ContourFab);class ContourCommandPalette extends ContourBase{static get observed(){return["open","items"]}static get properties(){return{open:{attribute:"open",type:Boolean},items:{attribute:"items"}}}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s),"open"===t&&this.isConnected&&e!==s&&(null!==s?this.show():this.hide())}_recentsKey(){return"contour-command-palette:"+(this.id||"default")+":recents"}_recents(){try{const t=JSON.parse(localStorage.getItem(this._recentsKey())||"[]");return Array.isArray(t)?t:[]}catch(t){return warnBadJson(this,"recents",t),[]}}_remember(t){try{const e=this._recents().filter(e=>e!==t);e.unshift(t),localStorage.setItem(this._recentsKey(),JSON.stringify(e.slice(0,5)))}catch(t){}}_cmdRow(t,e,s){const r=document.createElement("div");return r.className="c-command-palette__item",r.setAttribute("role","option"),r.id=this.id+"-opt-"+(s?"r":"")+e,r.textContent=t,r.dataset.index=String(e),r.dataset.label=t,s&&(r.dataset.recent="true"),r}render(){this.classList.add("c-command-palette"),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-modal")||this.setAttribute("aria-modal","true"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||this.setAttribute("aria-label",labelText(this,"command-palette","Command palette")),this.hasAttribute("popover")||this.setAttribute("popover","auto"),this.id||(this.id=contourId("cmd-palette"));const t=this.ensure(".c-command__input",()=>{const t=document.createElement("div");return t.className="c-command__input",t}),e=this.ensure(".c-command__field",()=>{const t=document.createElement("input");return t.className="c-command__field",t.type="search",t.placeholder=labelText(this,"search","Search…"),t.setAttribute("aria-label",labelText(this,"search-commands","Search commands")),t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded","false"),t}),s=this.hasAttribute("open")||this.classList.contains("is-open")||"function"==typeof this.matches&&this.matches(":popover-open");e.setAttribute("aria-expanded",String(s)),t.contains(e)||t.appendChild(e);const r=this.ensure(".c-command-palette__list",()=>{const t=document.createElement("div");return t.className="c-command-palette__list",t.setAttribute("role","listbox"),t});r.hasAttribute("aria-label")||r.hasAttribute("aria-labelledby")||r.setAttribute("aria-label",labelText(this,"commands","Commands")),r.id||(r.id=this.id+"-list"),e.setAttribute("aria-controls",r.id);let i=[];const a=this.getAttribute("items");if(a)try{i=JSON.parse(a)}catch(t){warnBadJson(this,"items",t)}Array.isArray(i)||(i=[]);const n=t=>"string"==typeof t?t:t.label||t.title||"";setHTML(r,"");const o=(this._cmdQuery||"").toLowerCase().trim()?[]:this._recents().filter(t=>i.some(e=>n(e)===t));if(o.length){const t=document.createElement("div");t.className="c-command-palette__group",t.setAttribute("role","presentation"),t.textContent=labelText(this,"recent","Recent"),r.appendChild(t),o.forEach(t=>r.appendChild(this._cmdRow(t,i.findIndex(e=>n(e)===t),!0)))}let l=null;i.forEach((t,e)=>{const s="object"==typeof t&&null!==t&&t.group||null;if(s&&s!==l){const t=document.createElement("div");t.className="c-command-palette__group",t.setAttribute("role","presentation"),t.textContent=s,r.appendChild(t),l=s}r.appendChild(this._cmdRow(n(t),e,!1))}),this._cmdQuery&&(e.value=this._cmdQuery),this._cmdFilter?this._cmdFilter(this._cmdQuery||""):this._cmdSetActive&&this._cmdSetActive(this._cmdCursor||0)}show(){if(this.classList.contains("is-open")||this.matches(":popover-open"))return void(this.hasAttribute("open")||this.setAttribute("open",""));if("function"==typeof this.showPopover)try{this.showPopover()}catch(t){}this.classList.add("is-open"),modalContain(this,!0);const t=this.querySelector(".c-command__field");if(t){t.setAttribute("aria-expanded","true");try{t.focus()}catch(t){}}this.hasAttribute("open")||this.setAttribute("open","")}hide(){if(!(this.classList.contains("is-open")||this.matches(":popover-open")))return void(this.hasAttribute("open")&&this.removeAttribute("open"));if("function"==typeof this.hidePopover)try{this.hidePopover()}catch(t){}this.classList.remove("is-open"),modalContain(this,!1);const t=this.querySelector(".c-command__field");t&&t.setAttribute("aria-expanded","false"),this.hasAttribute("open")&&this.removeAttribute("open")}toggle(){this.classList.contains("is-open")||this.matches(":popover-open")?this.hide():this.show()}enhance(){if(this._cmdSetActive&&this._cmdSetActive(this._cmdCursor||0),this._wiredCmdPalette)return;this._wiredCmdPalette=!0;const t=()=>this.querySelector(".c-command__field"),e=()=>this.querySelector(".c-command-palette__list"),s=()=>Array.from(this.querySelectorAll(".c-command-palette__item")),r=()=>s().filter(t=>!t.hidden),i=e=>{const s=r();if(!s.length)return void(this._cmdCursor=0);this._cmdCursor=Math.max(0,Math.min(e,s.length-1)),s.forEach((t,e)=>t.classList.toggle("is-active",e===this._cmdCursor));const i=s[this._cmdCursor],a=t();a&&i?a.setAttribute("aria-activedescendant",i.id):a&&a.removeAttribute("aria-activedescendant")},a=t=>{const r=(t||"").toLowerCase().trim();s().forEach(t=>{const e=(t.dataset.label||t.textContent||"").toLowerCase();t.hidden=""!==r&&!e.includes(r)}),Array.from(e().querySelectorAll(".c-command-palette__group")).forEach(t=>{let e=t.nextElementSibling,s=!1;for(;e&&!e.classList.contains("c-command-palette__group");)!e.hidden&&e.classList.contains("c-command-palette__item")&&(s=!0),e=e.nextElementSibling;t.hidden=!s});let a=e().querySelector(".c-command-palette__empty");s().some(t=>!t.hidden)?a&&(a.hidden=!0):(a||(a=document.createElement("div"),a.className="c-command-palette__empty",a.setAttribute("role","status"),e().appendChild(a)),a.textContent=labelText(this,"no-matches","No matches"),a.hidden=!1),i(0)},n=t=>{if(!t)return;const e={index:Number(t.dataset.index),label:t.dataset.label||t.textContent};this.value=e,this._remember(e.label),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:e})),this.hide()};this._cmdSetActive=i,this._cmdFilter=a,this.addEventListener("input",e=>{const s=t();s&&e.target===s&&(this._cmdQuery=s.value,a(s.value))}),this.addEventListener("keydown",e=>{const s=t();if(!s||e.target!==s)return;const a=r();if("Escape"===e.key)return e.preventDefault(),void this.hide();a.length&&("ArrowDown"===e.key?(e.preventDefault(),i(this._cmdCursor+1)):"ArrowUp"===e.key?(e.preventDefault(),i(this._cmdCursor-1)):"Home"===e.key?(e.preventDefault(),i(0)):"End"===e.key?(e.preventDefault(),i(a.length-1)):"Enter"===e.key&&(e.preventDefault(),n(a[this._cmdCursor])))}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-command-palette__item"):null;e&&this.contains(e)&&!e.hidden&&n(e)});let o=null;this.addEventListener("beforetoggle",t=>{if("open"===t.newState)o=document.activeElement,this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}));else if(modalContain(this,!1),o&&"function"==typeof o.focus){this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}));try{o.focus()}catch(t){}}}),onDispose(this,()=>{(this.classList.contains("is-open")||this.matches(":popover-open"))&&modalContain(this,!1)}),i(0)}}define("contour-command-palette",ContourCommandPalette);class ContourSideSheet extends ContourBase{static get observed(){return["open","side","title","mode","size"]}static get properties(){return{open:{attribute:"open",type:Boolean},side:{attribute:"side"},title:{attribute:"title"},mode:{attribute:"mode"},size:{attribute:"size"}}}show(){this.setAttribute("open","")}showModal(){this._sheetForceModal=!0,this.show()}close(){this.removeAttribute("open")}get open(){return this.hasAttribute("open")}set open(t){t?this.show():this.close()}_modal(){return this._sheetForceModal||"non-modal"!==(this.getAttribute("mode")||"modal")}render(){this.classList.add("c-side-sheet"),this.setAttribute("role","dialog"),this._modal()?this.setAttribute("aria-modal","true"):this.removeAttribute("aria-modal"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("title")||"Side sheet");for(const t of Array.from(this.classList))/^c-side-sheet--(start|end|sm|md|lg)$/.test(t)&&this.classList.remove(t);const t="start"===this.getAttribute("side")?"start":"end";this.classList.add("c-side-sheet--"+t);const e=this.getAttribute("size");"sm"!==e&&"md"!==e&&"lg"!==e||this.classList.add("c-side-sheet--"+e),this.hasAttribute("open")?(this.classList.add("is-open"),this.removeAttribute("inert")):(this.classList.remove("is-open"),this.setAttribute("inert",""));const s=this.getAttribute("title");if(s){this.ensure(".c-side-sheet__title",()=>{const t=document.createElement("div");return t.className="c-side-sheet__title",t}).textContent=s}}enhance(){if(this._wiredSideSheet)return;this._wiredSideSheet=!0;let t=null;const e=t=>{if("Escape"===t.key&&this.hasAttribute("open"))return t.preventDefault(),void this.close();if("Tab"===t.key&&this.hasAttribute("open")&&this._modal()){const e=Array.from(this.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")).filter(t=>!t.hasAttribute("disabled"));if(!e.length)return void t.preventDefault();const s=e[0],r=e[e.length-1];t.shiftKey&&document.activeElement===s?(t.preventDefault(),r.focus()):t.shiftKey||document.activeElement!==r||(t.preventDefault(),s.focus())}};document.addEventListener("keydown",e),onDispose(this,()=>document.removeEventListener("keydown",e)),this.addEventListener("click",t=>{t.target===this&&this.close()});let s=!1;const r=()=>{const e=this.hasAttribute("open");if(e&&!s){s=!0,t=document.activeElement,this._modal()&&modalContain(this,!0);const e=this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(e)try{e.focus()}catch(t){}this.dispatchEvent(new CustomEvent("contour:open",{bubbles:!0,composed:!0}))}else if(!e&&s){if(s=!1,this._modal()&&modalContain(this,!1),this._sheetForceModal=!1,t&&"function"==typeof t.focus)try{t.focus()}catch(t){}t=null,this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0}))}},i=new MutationObserver(r);i.observe(this,{attributes:!0,attributeFilter:["open"]}),this.hasAttribute("open")&&r(),onDispose(this,()=>{i.disconnect(),this.hasAttribute("open")&&this._modal()&&modalContain(this,!1)})}}define("contour-side-sheet",ContourSideSheet);class ContourTour extends ContourBase{static get observed(){return["steps","current","open","persist","id"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"},open:{attribute:"open",type:Boolean},persist:{attribute:"persist",type:Boolean}}}_steps(){let t=[];try{const e=this.getAttribute("steps");t=e?JSON.parse(e):[]}catch(e){warnBadJson(this,"steps",e),t=[]}return Array.isArray(t)?t:[]}_current(t){const e=Number(this.getAttribute("current")||0);return Number.isFinite(e)?Math.min(Math.max(0,e),Math.max(0,t-1)):0}_storageKey(){return this.id?"contour-tour:"+this.id:(this.hasAttribute("persist")&&!this._tourWarnedNoId&&(this._tourWarnedNoId=!0,console.warn("[contour-tour] persist requires an id attribute")),null)}_completed(){if(!this.hasAttribute("persist"))return!1;const t=this._storageKey();try{return!!t&&"done"===localStorage.getItem(t)}catch(t){return!1}}_markCompleted(){if(!this.hasAttribute("persist"))return;const t=this._storageKey();try{t&&localStorage.setItem(t,"done")}catch(t){}}show(){this.setAttribute("open","")}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this._markCompleted(),this.dispatchEvent(new CustomEvent("contour:close",{bubbles:!0,composed:!0})))}render(){this.classList.add("c-tour"),this.setAttribute("role","dialog"),this.setAttribute("aria-label",labelText(this,"tour","Tour"));const t=this._steps();this._tourInitialized||(this._tourInitialized=!0,!t.length||this.hasAttribute("open")||this._completed()||this.setAttribute("open",""));const e=this.hasAttribute("open")&&t.length>0;e?this.removeAttribute("hidden"):this.setAttribute("hidden","");const s=this._current(t.length),r=t[s]||{},i=this.ensure(".c-tour__step",()=>{const t=document.createElement("div");return t.className="c-tour__step",t});i.textContent=labelText(this,"step","Step")+" "+(s+1)+" / "+t.length;const a=this.ensure(".c-tour__tip",()=>{const t=document.createElement("div");return t.className="c-tour__tip",t});a.setAttribute("aria-live","polite"),a.textContent="string"==typeof r?r:r.text||r.title||"",i.nextSibling!==a&&this.insertBefore(i,a);const n=this.ensure(".c-tour__nav",()=>{const t=document.createElement("div");return t.className="c-tour__nav c-btn-group",t}),o=this.ensure(".c-tour__back",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-tour__back",t.type="button",t},n);o.textContent=labelText(this,"back","Back"),o.disabled=0===s;const l=this.ensure(".c-tour__next",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-tour__next",t.type="button",t},n);l.textContent=s>=t.length-1?labelText(this,"done","Done"):labelText(this,"next","Next");const c=this.ensure(".c-tour__close",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-tour__close",t.type="button",t},n);c.textContent=labelText(this,"close","Close"),n.firstChild!==o&&n.insertBefore(o,n.firstChild),o.nextSibling!==l&&n.insertBefore(l,o.nextSibling),l.nextSibling!==c&&n.insertBefore(c,l.nextSibling),this._tourTarget&&this._tourTarget.classList&&this._tourTarget.classList.remove("c-tour__target"),this._tourTarget=null;const u=e&&"object"==typeof r&&r?r.target:null;if(u){const t=document.querySelector(u);if(t&&t.classList&&(t.classList.add("c-tour__target"),this._tourTarget=t,"function"==typeof t.scrollIntoView))try{t.scrollIntoView({block:"nearest"})}catch(t){}}e&&this._positionTour(),e?this._tourFocusStep===s&&this._tourOpen||(this._tourFocusStep=s,queueMicrotask(()=>{if(!this.isConnected||!this.hasAttribute("open"))return;const t=this._tourTarget,e=t&&t.isConnected&&"function"==typeof t.focus&&!t.disabled&&t.matches("a[href], button, input, select, textarea, [tabindex]:not([tabindex='-1'])")?t:this.querySelector(".c-tour__next");if(e)try{e.focus({preventScroll:!0})}catch(t){try{e.focus()}catch(t){}}})):this._tourFocusStep=null,this._tourOpen=e}_positionTour(){const t=window.innerWidth,e=window.innerHeight,s=this.offsetWidth||280,r=this.offsetHeight||120,i=this._tourTarget;if(i&&i.getBoundingClientRect){const a=i.getBoundingClientRect();let n=a.bottom+8;n+r>e-8&&(n=Math.max(8,a.top-r-8));const o=Math.min(Math.max(8,a.left),Math.max(8,t-s-8));this.style.insetBlockStart=n+"px",this.style.insetInlineStart=o+"px",this.style.insetBlockEnd="auto",this.style.transform=""}else this.style.insetBlockStart="auto",this.style.insetBlockEnd="1rem",this.style.insetInlineStart="50%",this.style.transform="translateX(-50%)"}enhance(){if(this._wiredTour)return;this._wiredTour=!0;const t=t=>{const e=this._steps();if(!e.length||!this.hasAttribute("open"))return;const s=this._current(e.length);if("next"===t){if(s>=e.length-1)return void this.close();this.setAttribute("current",String(s+1)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:"next",index:s+1}}))}else{if(0===s)return;this.setAttribute("current",String(s-1)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:"prev",index:s-1}}))}};this._tourStep=t,this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target:null;s&&(s.closest(".c-tour__next")?t("next"):s.closest(".c-tour__back")?t("prev"):s.closest(".c-tour__close")&&this.close())});const e=e=>{if(!this.hasAttribute("open"))return;const s=e.target&&e.target.tagName;if("INPUT"===s||"TEXTAREA"===s||"SELECT"===s)return;if("Escape"===e.key)return void this.close();(this.contains(e.target)||this._tourTarget&&(e.target===this._tourTarget||this._tourTarget.contains(e.target)))&&("ArrowRight"===e.key?(e.preventDefault(),t("next")):"ArrowLeft"===e.key&&(e.preventDefault(),t("prev")))};document.addEventListener("keydown",e);const s=()=>{this.hasAttribute("open")&&this._positionTour()};window.addEventListener("scroll",s,{passive:!0,capture:!0}),window.addEventListener("resize",s,{passive:!0}),onDispose(this,()=>{document.removeEventListener("keydown",e),window.removeEventListener("scroll",s,{capture:!0}),window.removeEventListener("resize",s),this._tourTarget&&this._tourTarget.classList&&this._tourTarget.classList.remove("c-tour__target")})}}define("contour-tour",ContourTour);class ContourResponsiveContent extends ContourBase{static get observed(){return["breakpoint"]}static get properties(){return{breakpoint:{attribute:"breakpoint"}}}render(){this.classList.add("c-responsive-content");const t=this.getAttribute("breakpoint")||"md";this.dataset.breakpoint=t}}define("contour-responsive-content",ContourResponsiveContent);class ContourPaletteEditor extends ContourBase{static get observed(){return["colors"]}static get properties(){return{colors:{attribute:"colors"}}}_palette(){let t=[];try{const e=this.getAttribute("colors");t=e?JSON.parse(e):[]}catch(t){warnBadJson(this,"colors",t)}return Array.isArray(t)||(t=[]),t.map(t=>"string"==typeof t?{color:t,name:t}:{color:String(t.color||t.value||"#000000"),name:String(t.name||t.label||t.color||t.value||"color")})}_writePalette(t){this.setAttribute("colors",JSON.stringify(t.map(t=>t.name===t.color?t.color:{color:t.color,name:t.name})))}render(){this.classList.add("c-palette-editor"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"palette-editor","Palette editor"));const t=this._palette();Array.from(this.querySelectorAll(".c-palette-editor__swatch, .c-palette-editor__edit, .c-palette-editor__remove, .c-palette-editor__add, .c-palette-editor__contrast")).forEach(t=>t.remove()),t.forEach((t,e)=>{const s=document.createElement("button");s.className="c-palette-editor__swatch c-swatch"+(this._paletteSelected===e?" is-selected":""),s.type="button",s.style.background=safeColor(t.color),s.dataset.color=t.color,s.dataset.index=String(e),s.setAttribute("aria-label",t.name),s.setAttribute("aria-pressed",String(this._paletteSelected===e)),this.appendChild(s);const r=document.createElement("input");r.type="color",r.className="c-palette-editor__edit",r.value=/^#[0-9a-f]{6}$/i.test(t.color)?t.color:"#000000",r.dataset.index=String(e),r.setAttribute("aria-label",labelText(this,"edit","Edit")+" "+t.name),this.appendChild(r);const i=document.createElement("button");i.type="button",i.className="c-palette-editor__remove",i.dataset.index=String(e),i.setAttribute("aria-label",labelText(this,"remove","Remove")+" "+t.name),i.textContent="×",this.appendChild(i)});const e=document.createElement("button");e.type="button",e.className="c-palette-editor__add",e.setAttribute("aria-label",labelText(this,"add-color","Add color")),e.textContent="+",this.appendChild(e);const s=t[this._paletteSelected];if(s){const t=(t=>{const e=/^#([0-9a-f]{6})$/i.exec(t);if(!e)return null;const s=parseInt(e[1],16),r=[s>>16&255,s>>8&255,255&s].map(t=>(t/=255)<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4));return.2126*r[0]+.7152*r[1]+.0722*r[2]})(s.color),e=document.createElement("span");if(e.className="c-palette-editor__contrast",null===t)e.textContent=s.color;else{const r=(t,e)=>(Math.max(t,e)+.05)/(Math.min(t,e)+.05),i=r(t,1),a=r(t,0),n=Math.max(i,a);e.textContent=s.name+": "+i.toFixed(1)+":1 on white, "+a.toFixed(1)+":1 on black — "+(n>=4.5?"AA":"below AA")}this.appendChild(e)}}enhance(){this._wiredPaletteEditor||(this._wiredPaletteEditor=!0,this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target:null;if(!e)return;const s=e.closest(".c-palette-editor__swatch");if(s&&this.contains(s))return this._paletteSelected=Number(s.dataset.index),this.requestRender(),void this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{color:s.dataset.color}}));const r=e.closest(".c-palette-editor__remove");if(r&&this.contains(r)){const t=this._palette(),e=Number(r.dataset.index),[s]=t.splice(e,1);return this._paletteSelected>=t.length&&(this._paletteSelected=t.length-1),this._writePalette(t),void this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{value:s?s.color:""}}))}if(e.closest(".c-palette-editor__add")){const t=this._palette(),e="#888888";t.push({color:e,name:e}),this._paletteSelected=t.length-1,this._writePalette(t),this.dispatchEvent(new CustomEvent("contour:add",{bubbles:!0,composed:!0,detail:{value:e}}))}}),this.addEventListener("change",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-palette-editor__edit"):null;if(!e||!this.contains(e))return;const s=this._palette(),r=Number(e.dataset.index);s[r]&&(s[r].color=e.value,(s[r].name===s[r].color||/^#[0-9a-f]{6}$/i.test(s[r].name))&&(s[r].name=e.value),this._writePalette(s),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{color:e.value,values:s.map(t=>t.color)}})))}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-palette-editor__swatch"));e.includes(t.target)&&navKey(t,e,{wrap:!0,enter:!0,onKey:(t,e,s)=>{"Enter"!==t&&" "!==t||s.click()}})}))}}define("contour-palette-editor",ContourPaletteEditor);class ContourDateRange extends ContourBase{static get observed(){return["start","end","label","time","min","max","locale","name","required","disabled"]}static get properties(){return{start:{attribute:"start"},end:{attribute:"end"},label:{attribute:"label"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"},name:{attribute:"name"},required:{attribute:"required",type:Boolean},disabled:{attribute:"disabled",type:Boolean}}}static get formAssociated(){return!0}render(){this.classList.add("c-date-range"),void 0===this._dateRangeDefaultStart&&(this._dateRangeDefaultStart=this.getAttribute("start"),this._dateRangeDefaultEnd=this.getAttribute("end")),this.setAttribute("role","group"),this.setAttribute("aria-label",this.getAttribute("label")||"Date range");const t=this.getAttribute("label");if(t){this.ensure(".c-date-range__label",()=>{const t=document.createElement("span");return t.className="c-date-range__label",t}).textContent=t}const e=this.ensure(".c-date-range__start",()=>{const t=document.createElement("input");return t.className="c-input c-date-range__start",t});e.type=this.hasAttribute("time")?"datetime-local":"date",e.value=this.getAttribute("start")||"",e.setAttribute("aria-label",t?t+" — start":"Start date");const s=this.ensure(".c-date-range__end",()=>{const t=document.createElement("input");return t.className="c-input c-date-range__end",t});s.type=e.type,s.value=this.getAttribute("end")||"",s.setAttribute("aria-label",t?t+" — end":"End date");const r=this.getAttribute("min"),i=this.getAttribute("max");[e,s].forEach(t=>{r?t.min=r:t.removeAttribute("min"),i?t.max=i:t.removeAttribute("max"),this.getAttribute("locale")&&(t.lang=this.getAttribute("locale")),this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled")}),e.value&&(s.min=r&&r>e.value?r:e.value),s.value&&(e.max=i&&i<s.value?i:s.value),this.hasAttribute("required")?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required"),this._internals&&this._syncFormValue()}enhance(){this._wiredDateRange||(this._wiredDateRange=!0,this.addEventListener("change",t=>{const e=t.target;if(e&&(e.classList.contains("c-date-range__start")||e.classList.contains("c-date-range__end"))){const t=this.querySelector(".c-date-range__start"),e=this.querySelector(".c-date-range__end");this.batch(()=>{t&&this.setAttribute("start",t.value),e&&this.setAttribute("end",e.value)}),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{start:t?.value,end:e?.value}}))}}))}_syncFormValue(){if(!this._internals)return;const t=this.querySelector(".c-date-range__start")?.value||"",e=this.querySelector(".c-date-range__end")?.value||"",s=this.getAttribute("name");if(s&&(t||e)){const r=new FormData;t&&r.append(s,t),e&&r.append(s,e),this._internals.setFormValue(r)}else this._internals.setFormValue(null);const r=this.hasAttribute("required")&&(!t||!e),i=!!(t&&e&&t>e);r?this._internals.setValidity({valueMissing:!0},"Both dates are required."):i?this._internals.setValidity({customError:!0},"Start must be on or before end."):this._internals.setValidity({}),this._setCustomState("data-invalid",r||i);for(const t of this.querySelectorAll("input"))t.setAttribute("aria-invalid",String(r||i))}formResetCallback(){this._contourResetting=!0;try{null===this._dateRangeDefaultStart?this.removeAttribute("start"):this.setAttribute("start",this._dateRangeDefaultStart),null===this._dateRangeDefaultEnd?this.removeAttribute("end"):this.setAttribute("end",this._dateRangeDefaultEnd),this._syncFormValue()}finally{this._contourResetting=!1}}formStateRestoreCallback(t){if(!this._internals||null==t)return;const e=t instanceof FormData?Array.from(t.getAll(this.getAttribute("name"))).map(String):String(t).split(",");this._contourResetting=!0;try{this.setAttribute("start",e[0]||""),this.setAttribute("end",e[1]||""),this._syncFormValue()}finally{this._contourResetting=!1}}}define("contour-date-range",ContourDateRange);class ContourShortcut extends ContourBase{static get observed(){return["key","label"]}static get properties(){return{key:{attribute:"key"},label:{attribute:"label"}}}render(){this.classList.add("c-shortcut"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"Keyboard shortcut");const t=this.getAttribute("key")||"",e=this.getAttribute("label")||"";if(t){this.ensure(".c-shortcut__key",()=>{const t=document.createElement("kbd");return t.className="c-shortcut__key",t}).textContent=t}if(e){this.ensure(".c-shortcut__label",()=>{const t=document.createElement("span");return t.className="c-shortcut__label",t}).textContent=e}}enhance(){if(this._wiredShortcut)return;this._wiredShortcut=!0;const t=t=>{const e=this.getAttribute("key");e&&t.key===e&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:activate",{bubbles:!0,composed:!0})))};document.addEventListener("keydown",t),onDispose(this,()=>document.removeEventListener("keydown",t))}}define("contour-shortcut",ContourShortcut);class ContourDatePicker extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","range","range-start","range-end","label","disabled","error","help","time","min","max","locale","required","name"]}static get properties(){return{value:{attribute:"value"},range:{attribute:"range",type:Boolean},rangeStart:{attribute:"range-start"},rangeEnd:{attribute:"range-end"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},time:{attribute:"time",type:Boolean},min:{attribute:"min"},max:{attribute:"max"},locale:{attribute:"locale"}}}render(){this.classList.add("c-date-picker"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"date-picker","Date picker"));const t=this.getAttribute("label");if(t){this.ensure(".c-date-picker__label",()=>{const t=document.createElement("label");return t.className="c-date-picker__label",t}).textContent=t}const e=this.keepNode(this.ensure(".c-date-picker__input",()=>{const t=document.createElement("input");return t.className="c-input c-date-picker__input",t})),s=this.hasAttribute("range"),r=this.hasAttribute("time")?"datetime-local":"date",i=(t,e,s)=>{t.type=r;const i=e||"";document.activeElement!==t&&t.value!==i&&(t.value=i),t.setAttribute("aria-label",s),this.hasAttribute("min")?t.min=this.getAttribute("min"):t.removeAttribute("min"),this.hasAttribute("max")?t.max=this.getAttribute("max"):t.removeAttribute("max"),this.hasAttribute("locale")?t.lang=this.getAttribute("locale"):t.removeAttribute("lang"),this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled")};i(e,s?this.getAttribute("range-start"):this.getAttribute("value"),s?"Start date":t||"Date");let a=this.querySelector(".c-date-picker__end");s?(a=this.keepNode(a||document.createElement("input")),a.className="c-input c-date-picker__input c-date-picker__end",i(a,this.getAttribute("range-end"),"End date"),a.parentNode!==this&&this.appendChild(a)):a&&a.remove();const n=this.getAttribute("min"),o=this.getAttribute("max"),l=t=>{if(!n&&!o)return;const e=t.value;if(!e)return;let s=e;n&&s<n&&(s=n),o&&s>o&&(s=o),s!==e&&document.activeElement!==t&&(t.value=s)};l(e),a&&l(a),this.hasAttribute("disabled")?this.classList.add("is-disabled"):this.classList.remove("is-disabled");const c=this.getAttribute("error"),u=this.getAttribute("help");let d=this.querySelector(".c-date-picker__message");c||u?(d||(d=document.createElement("div"),d.className="c-date-picker__message",d.id||(d.id=contourId("c-date-picker-message")),this.appendChild(d)),d.textContent=c||u||"",d.classList.toggle("c-date-picker__message--error",!!c)):d&&d.remove(),c?this.classList.add("is-error"):this.classList.remove("is-error");let h=!!c;this.hasAttribute("range")&&(h=h||this._validateRange());const p=d?d.id:"",b=t=>{h?t.setAttribute("aria-invalid","true"):t.removeAttribute("aria-invalid"),p?t.setAttribute("aria-describedby",p):t.removeAttribute("aria-describedby")};b(e);const m=this.querySelector(".c-date-picker__end");m&&b(m);this.keepNode(this.ensure(".c-date-picker__calendar-toggle",()=>{const t=document.createElement("button");t.className="c-btn c-btn--sm c-date-picker__calendar-toggle",t.type="button",t.setAttribute("aria-label",labelText(this,"open-calendar","Open calendar")),t.setAttribute("aria-expanded","false");const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true");const s=document.createElementNS("http://www.w3.org/2000/svg","use");return s.setAttribute("href","#i-chevron-down"),e.appendChild(s),t.appendChild(e),t}));let g=this.querySelector(".c-date-picker__calendar");g||(g=document.createElement("div"),g.className="c-date-picker__calendar",g.setAttribute("hidden",""),g.setAttribute("role","dialog"),g.setAttribute("aria-label",labelText(this,"calendar","Calendar")),this.appendChild(g)),this.keepNode(g),this._internals&&this._syncFormValue()}_renderCalendar(){const t=this.querySelector(".c-date-picker__calendar");if(!t)return;const e=this.querySelector(".c-date-picker__input"),s=e&&e.value?(t=>{const e=/^(\d{4})-(\d{2})-(\d{2})/.exec(t||"");return e?new Date(Number(e[1]),Number(e[2])-1,Number(e[3])):new Date})(e.value):new Date,r=this._calMonth||new Date(s.getFullYear(),s.getMonth(),1);this._calMonth=r;const i=r.getFullYear(),a=r.getMonth(),n=this.getAttribute("locale")||void 0,o=this._datePickerFirstDayOfWeek(n),l=(new Date(i,a,1).getDay()-o+7)%7,c=new Date(i,a+1,0).getDate();setHTML(t,"");const u=document.createElement("div");u.className="c-date-picker__calendar-header";const d=document.createElement("button");d.type="button",d.className="c-btn c-btn--sm c-btn--icon",setHTML(d,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>'),d.setAttribute("aria-label",labelText(this,"previous-month","Previous month"));const h=document.createElement("span");h.className="c-date-picker__calendar-title",h.textContent=r.toLocaleString(this.getAttribute("locale")||void 0,{month:"long",year:"numeric"});const p=document.createElement("button");p.type="button",p.className="c-btn c-btn--sm c-btn--icon",setHTML(p,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),p.setAttribute("aria-label",labelText(this,"next-month","Next month")),u.appendChild(d),u.appendChild(h),u.appendChild(p),t.appendChild(u);const b=document.createElement("div");b.className="c-date-picker__calendar-grid",b.setAttribute("role","grid"),b.setAttribute("aria-label",h.textContent);const m=()=>{const t=document.createElement("div");return t.className="c-date-picker__calendar-row",t.setAttribute("role","row"),b.appendChild(t),t};let g=m(),v=0;const _=t=>{7===v&&(g=m(),v=0),g.appendChild(t),v++},f=["Su","Mo","Tu","We","Th","Fr","Sa"],y=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];for(let t=0;t<7;t++){const e=(o+t)%7,s=document.createElement("div");s.className="c-date-picker__calendar-weekday",s.setAttribute("role","columnheader");const r=new Date(2026,0,e+1);s.setAttribute("aria-label",r.toLocaleDateString(n,{weekday:"long"})||y[e]),s.textContent=r.toLocaleDateString(n,{weekday:"short"})||f[e],_(s)}for(let t=0;t<l;t++){const t=document.createElement("div");t.className="c-date-picker__calendar-day c-date-picker__calendar-day--empty",t.setAttribute("role","gridcell"),t.setAttribute("aria-hidden","true"),_(t)}const A=e?e.value:"",w=A&&A.slice(0,7)===`${i}-${String(a+1).padStart(2,"0")}`&&parseInt(A.slice(8,10),10)||1,E=this.getAttribute("min"),x=this.getAttribute("max");for(let s=1;s<=c;s++){const r=document.createElement("button");r.type="button",r.className="c-date-picker__calendar-day",r.textContent=String(s),r.setAttribute("role","gridcell"),r.setAttribute("tabindex",s===w?"0":"-1"),r.setAttribute("aria-label",new Date(i,a,s).toLocaleDateString(this.getAttribute("locale")||void 0,{weekday:"long",day:"numeric",month:"long",year:"numeric"}));const n=`${i}-${String(a+1).padStart(2,"0")}-${String(s).padStart(2,"0")}`;A&&A.startsWith(n)&&(r.classList.add("is-selected"),r.setAttribute("aria-selected","true"));const o=E&&n<E||x&&n>x;r.disabled=o,o&&r.setAttribute("aria-disabled","true"),r.setAttribute("tabindex",o?"-1":s===w?"0":"-1"),o?_(r):(r.addEventListener("click",()=>{if(!e)return;if(this.hasAttribute("range")){const t=this.querySelector(".c-date-picker__end");!1!==this._rangeStartNext?(this.setAttribute("range-start",n),this._rangeStartNext=!1):t&&(this.setAttribute("range-end",n),this._rangeStartNext=!0)}else this.setAttribute("value",n);t.setAttribute("hidden","");const s=this.querySelector(".c-date-picker__calendar-toggle");s&&s.setAttribute("aria-expanded","false"),this._validateRange(),this._internals&&this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("value")}}))}),_(r))}t.appendChild(b),d.addEventListener("click",()=>{this._calMonth=new Date(i,a-1,1),this._renderCalendar()}),p.addEventListener("click",()=>{this._calMonth=new Date(i,a+1,1),this._renderCalendar()}),this._internals&&this._syncFormValue()}_syncFormValue(){if(!this._internals)return;const t=this.querySelector(".c-date-picker__input"),e=this.querySelector(".c-date-picker__end");if(this.hasAttribute("range")&&e){const s=t?t.value:"",r=e.value||"",i=this.getAttribute("name");if(i&&(s||r)){const t=new FormData;s&&t.append(i,s),r&&t.append(i,r),this._internals.setFormValue(t)}else this._internals.setFormValue(null)}else this._internals.setFormValue(t&&t.value?t.value:null);this._syncValidity(this.hasAttribute("required")&&!(t&&t.value))}formResetCallback(){const t=()=>{const t=this.querySelector(".c-date-picker__input"),e=this.querySelector(".c-date-picker__end");t&&(t.value=this.getAttribute("range-start")||this.getAttribute("value")||""),e&&(e.value=this.getAttribute("range-end")||""),this._syncFormValue()};t(),"function"==typeof queueMicrotask&&queueMicrotask(t)}_datePickerFirstDayOfWeek(t){return["en-US","en-CA","en-PH","ja-JP","ko-KR","th-TH","ar-SA","he-IL"].includes(String(t||"").toLowerCase())?0:1}_validateRange(){if(!this.hasAttribute("range"))return!1;const t=this.querySelector(".c-date-picker__input"),e=this.querySelector(".c-date-picker__end");if(!t||!e)return!1;const s=!!t.value&&!!e.value&&t.value>e.value;return this.getAttribute("error")||(s?(t.setAttribute("aria-invalid","true"),e.setAttribute("aria-invalid","true")):(t.removeAttribute("aria-invalid"),e.removeAttribute("aria-invalid"))),s}enhance(){if(this._wiredDatePicker)return;this._wiredDatePicker=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;if(e&&e.classList.contains("c-date-picker__input")){const t=this.querySelector(".c-date-picker__end"),s=t?{start:this.querySelector(".c-date-picker__input").value,end:t.value}:{value:e.value};this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:s}))}});const t=()=>{const t=this.querySelector(".c-date-picker__calendar"),e=this.querySelector(".c-date-picker__calendar-toggle");if(!t)return;t.hasAttribute("hidden")?(t.removeAttribute("hidden"),e&&e.setAttribute("aria-expanded","true"),this._renderCalendar()):(t.setAttribute("hidden",""),e&&e.setAttribute("aria-expanded","false"))};this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-date-picker__calendar-toggle"):null;s&&this.contains(s)&&(e.preventDefault(),t());const r=this.querySelector(".c-date-picker__calendar");if(r&&!r.hasAttribute("hidden")&&!r.contains(e.target)&&!s){r.setAttribute("hidden","");const t=this.querySelector(".c-date-picker__calendar-toggle");t&&t.setAttribute("aria-expanded","false")}}),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-date-picker__calendar");if(!e||e.hasAttribute("hidden"))return;if("Escape"===t.key){t.preventDefault(),e.setAttribute("hidden","");const s=this.querySelector(".c-date-picker__calendar-toggle");return void(s&&(s.setAttribute("aria-expanded","false"),s.focus()))}const s=Array.from(e.querySelectorAll('[role="gridcell"]:not([aria-hidden="true"])')),r=s.indexOf(document.activeElement);if(r<0)return;if("PageUp"===t.key||"PageDown"===t.key){t.preventDefault();const e=this.querySelector("PageUp"===t.key?".c-date-picker__calendar-header button:first-child":".c-date-picker__calendar-header button:last-child");return void(e&&e.click())}let i=-1;if("ArrowRight"===t.key)i=r+1;else if("ArrowLeft"===t.key)i=r-1;else if("ArrowDown"===t.key)i=r+7;else if("ArrowUp"===t.key)i=r-7;else if("Home"===t.key)i=0;else{if("End"!==t.key)return;i=s.length-1}t.preventDefault(),i<0||i>=s.length||(s.forEach((t,e)=>t.setAttribute("tabindex",e===i?"0":"-1")),s[i].focus())})}}define("contour-date-picker",ContourDatePicker);class ContourRating extends ContourBase{static get observed(){return["value","max","color","readonly","disabled","name"]}static get properties(){return{value:{attribute:"value",type:Number},max:{attribute:"max",type:Number},color:{attribute:"color"},readonly:{attribute:"readonly",type:Boolean},disabled:{attribute:"disabled",type:Boolean},name:{attribute:"name"}}}static get formAssociated(){return!0}render(){this.classList.add("c-rating"),this.hasAttribute("role")||this.setAttribute("role","radiogroup"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"rating","Rating"));const t=parseInt(this.getAttribute("max")||"5",10)||5,e=parseInt(this.getAttribute("value")||"0",10)||0,s=this.getAttribute("color"),r=flagOn(this,"readonly"),i=flagOn(this,"disabled");Array.from(this.querySelectorAll(".c-rating__star")).forEach(t=>t.remove());const a=e>=1&&e<=t?e:1;for(let n=1;n<=t;n++){const t=document.createElement("button");if(t.className="c-rating__star"+(n<=e?" c-rating__star--filled":""),t.type="button",t.setAttribute("role","radio"),t.setAttribute("aria-checked",String(n===e)),t.setAttribute("aria-label",n+(1===n?" star":" stars")),t.setAttribute("tabindex",String(n===a?0:-1)),(r||i)&&(t.setAttribute("aria-disabled","true"),t.disabled=!0,t.tabIndex=-1),setHTML(t,'<span class="c-rating__swatch'+(n<=e?" c-rating__swatch--filled":"")+'" aria-hidden="true"></span>'),s&&n<=e){const e=t.firstChild,r=safeColor(s);e&&r&&(e.style.backgroundColor=r,e.style.borderColor=r)}t.dataset.value=String(n),t.setAttribute("aria-label",n+" star"+(n>1?"s":"")),this.appendChild(t)}this._internals&&this._syncFormValue()}_syncFormValue(){if(!this._internals)return;const t=this.getAttribute("name"),e=this.getAttribute("value");t&&e?this._internals.setFormValue(e):this._internals.setFormValue(null)}enhance(){if(this._wiredRating)return;this._wiredRating=!0;const t=()=>Array.from(this.querySelectorAll(".c-rating__star")),e=e=>{flagOn(this,"readonly")||flagOn(this,"disabled")||(t().forEach(t=>{const s=parseInt(t.dataset.value,10)===e;t.setAttribute("aria-checked",String(s)),t.setAttribute("tabindex",s?"0":"-1"),t.classList.toggle("c-rating__star--filled",parseInt(t.dataset.value,10)<=e);const r=t.querySelector(".c-rating__swatch");r&&r.classList.toggle("c-rating__swatch--filled",parseInt(t.dataset.value,10)<=e)}),this.setAttribute("value",String(e)),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e}})))};this.addEventListener("click",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-rating__star"):null;s&&this.contains(s)&&e(parseInt(s.dataset.value,10))}),this.addEventListener("keydown",s=>{const r=t();r.length&&navKey(s,r,{wrap:!1,homeEnd:!0,onNavigate:t=>{e(parseInt(r[t].dataset.value,10))},onKey:(t,s)=>{"Enter"!==t&&" "!==t||e(parseInt(r[s].dataset.value,10))}})})}}define("contour-rating",ContourRating);class ContourTimePicker extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-time-picker"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"time-picker","Time picker"));const t=this.getAttribute("label");if(t){this.ensure(".c-time-picker__label",()=>{const t=document.createElement("label");return t.className="c-time-picker__label",t}).textContent=t}const e=this.ensure(".c-time-picker__input",()=>{const t=document.createElement("input");return t.className="c-input c-time-picker__input",t.type="time",t.setAttribute("aria-label",this.getAttribute("label")||"Time picker"),t});e.value=this.getAttribute("value")||"",this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled"));const s=this.getAttribute("error"),r=this.getAttribute("help");let i=this.querySelector(".c-time-picker__message");s||r?(i||(i=document.createElement("div"),i.className="c-time-picker__message",i.id||(i.id=contourId("c-time-picker-message")),this.appendChild(i)),i.textContent=s||r||"",i.classList.toggle("c-time-picker__message--error",!!s)):i&&i.remove(),s?this.classList.add("is-error"):this.classList.remove("is-error");const a=i?i.id:"";s?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"),a?e.setAttribute("aria-describedby",a):e.removeAttribute("aria-describedby"),this._internals&&this._syncFormValue()}enhance(){this._wiredTimePicker||(this._wiredTimePicker=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-time-picker__input")&&this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}))}}define("contour-time-picker",ContourTimePicker);class ContourColorPicker extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","label","disabled","required","error","help","alpha","presets"]}static get properties(){return{value:{attribute:"value"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},required:{attribute:"required",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},alpha:{attribute:"alpha",type:Boolean},presets:{attribute:"presets"}}}render(){this.classList.add("c-color-picker"),this.setAttribute("role","group"),this.setAttribute("aria-label",labelText(this,"color-picker","Color picker"));const t=this.getAttribute("label");if(t){this.ensure(".c-color-picker__label",()=>{const t=document.createElement("label");return t.className="c-color-picker__label",t}).textContent=t}const e=this.ensure(".c-color-picker__input",()=>{const t=document.createElement("input");return t.className="c-color-picker__input",t.type="color",t}),s=this.getAttribute("value")||"",r=/^#?[0-9a-f]{6}([0-9a-f]{2})?$/i.test(s);if(r?(e.value=s.slice(0,7),this.removeAttribute("data-empty")):(e.value="",this.setAttribute("data-empty","")),e.hasAttribute("aria-label")||e.setAttribute("aria-label",t||"Color"),this.hasAttribute("required")?e.setAttribute("required",""):e.removeAttribute("required"),this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled")),this.hasAttribute("alpha")){const t=this.ensure(".c-color-picker__alpha",()=>{const t=document.createElement("input");return t.className="c-color-picker__alpha",t.type="range",t.min="0",t.max="1",t.step="0.01",t}),e=r&&9===s.length?parseInt(s.slice(7,9),16)/255:1;t.value=String(e),t.setAttribute("aria-label",labelText(this,"alpha","Alpha"))}else{const t=this.querySelector(".c-color-picker__alpha");t&&t.remove()}const i=this.getAttribute("presets");let a=[];if(i)try{a=JSON.parse(i)}catch(t){warnBadJson(this,"presets",t),a=[]}const n=this.querySelector(".c-color-picker__presets");if(n&&n.remove(),Array.isArray(a)&&a.length){const t=document.createElement("div");t.className="c-color-picker__presets",a.forEach(e=>{const s=document.createElement("button");s.type="button",s.className="c-color-picker__preset";const r=safeColor(e);r&&(s.style.background=r,s.dataset.color=r,s.setAttribute("aria-label",labelText(this,"preset","Preset")+" "+e),t.appendChild(s))}),this.appendChild(t)}if("undefined"!=typeof window&&"EyeDropper"in window){const t=this.ensure(".c-color-picker__eyedropper",()=>{const t=document.createElement("button");return t.className="c-color-picker__eyedropper",t.type="button",t.textContent=labelText(this,"pick","Pick"),t.setAttribute("aria-label",labelText(this,"pick-color","Pick color from screen")),t});this.hasAttribute("disabled")?t.setAttribute("disabled",""):t.removeAttribute("disabled")}else{const t=this.querySelector(".c-color-picker__eyedropper");t&&t.remove()}const o=this.getAttribute("error"),l=this.getAttribute("help");let c=this.querySelector(".c-color-picker__message");o||l?(c||(c=document.createElement("div"),c.className="c-color-picker__message",c.id||(c.id=contourId("c-color-picker-message")),this.appendChild(c)),c.textContent=o||l||"",c.classList.toggle("c-color-picker__message--error",!!o)):c&&c.remove(),o?this.classList.add("is-error"):this.classList.remove("is-error");const u=c?c.id:"";o?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"),u?e.setAttribute("aria-describedby",u):e.removeAttribute("aria-describedby"),this._internals&&this._syncFormValue()}enhance(){this._wiredColorPicker||(this._wiredColorPicker=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("contour:change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;if(e&&e.classList.contains("c-color-picker__input")){const t=this.getAttribute("value")||"",s=9===t.length?t.slice(7,9):"",r=e.value.slice(0,7)+s;this.setAttribute("value",r),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:r}}))}if(e&&e.classList.contains("c-color-picker__alpha")){const t=(this.getAttribute("value")||"#000000").slice(0,7)+Math.round(255*parseFloat(e.value)).toString(16).padStart(2,"0");this.setAttribute("value",t),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t}}))}}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-color-picker__preset"):null;if(e&&this.contains(e)){const t=e.dataset.color;if(t){this.setAttribute("value",t);const e=this.querySelector(".c-color-picker__input");e&&(e.value=t.slice(0,7)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t}}))}}const s=t.target&&t.target.closest?t.target.closest(".c-color-picker__eyedropper"):null;if(s&&this.contains(s)&&"undefined"!=typeof window&&"EyeDropper"in window){t.preventDefault();(new window.EyeDropper).open().then(t=>{if(t&&t.sRGBHex){this.setAttribute("value",t.sRGBHex);const e=this.querySelector(".c-color-picker__input");e&&(e.value=t.sRGBHex),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:t.sRGBHex}}))}}).catch(()=>{})}}))}}define("contour-color-picker",ContourColorPicker);class ContourNumberField extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","min","max","step","label","disabled","error","help"]}static get properties(){return{value:{attribute:"value"},min:{attribute:"min"},max:{attribute:"max"},step:{attribute:"step"},label:{attribute:"label"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"}}}render(){this.classList.add("c-number-field");const t=this.getAttribute("label");if(t){this.ensure(".c-number-field__label",()=>{const t=document.createElement("label");return t.className="c-number-field__label",t}).textContent=t}const e=this.ensure(".c-number-field__input",()=>{const t=document.createElement("input");return t.className="c-input c-number-field__input",t.type="number",t.setAttribute("role","spinbutton"),t});e.id||(e.id=contourId("nf-input"));const s=this.querySelector(".c-number-field__label");s&&s.setAttribute("for",e.id),null!==this.getAttribute("value")&&(e.value=this.getAttribute("value")),null!==this.getAttribute("min")&&(e.min=this.getAttribute("min")),null!==this.getAttribute("max")&&(e.max=this.getAttribute("max")),null!==this.getAttribute("step")&&(e.step=this.getAttribute("step"));const r=e.value;e.setAttribute("aria-valuenow",""===r?"":r),""!==e.min&&e.setAttribute("aria-valuemin",e.min),""!==e.max&&e.setAttribute("aria-valuemax",e.max),e.hasAttribute("aria-label")||e.setAttribute("aria-label",t||"Number"),this.hasAttribute("disabled")?(e.setAttribute("disabled",""),this.classList.add("is-disabled")):(e.removeAttribute("disabled"),this.classList.remove("is-disabled"));const i=this.getAttribute("error"),a=this.getAttribute("help");let n=this.querySelector(".c-number-field__message");i||a?(n||(n=document.createElement("div"),n.className="c-number-field__message",this.appendChild(n)),n.id||(n.id=contourId("nf-msg")),n.textContent=i||a||"",n.classList.toggle("c-number-field__message--error",!!i),i?n.setAttribute("role","alert"):n.removeAttribute("role"),e.setAttribute("aria-describedby",n.id)):(n&&n.remove(),e.removeAttribute("aria-describedby")),i?(this.classList.add("is-error"),e.setAttribute("aria-invalid","true")):(this.classList.remove("is-error"),e.removeAttribute("aria-invalid")),this._internals&&this._syncFormValue()}enhance(){this._wiredNumberField||(this._wiredNumberField=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()}),this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-number-field__input")&&this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e.value}}))}),this.addEventListener("keydown",t=>{const e=this.querySelector(".c-number-field__input");if(!e||document.activeElement!==e)return;const s=Number(e.step)||1,r=""===e.min?-1/0:Number(e.min),i=""===e.max?1/0:Number(e.max);let a=null;"ArrowUp"===t.key?a=(Number(e.value)||0)+s:"ArrowDown"===t.key?a=(Number(e.value)||0)-s:"Home"===t.key?a=r===-1/0?0:r:"End"===t.key&&(a=i===1/0?Number(e.value)||0:i),null!==a&&(t.preventDefault(),a=Math.min(i,Math.max(r,a)),e.value=String(a),e.setAttribute("aria-valuenow",String(a)),this.setAttribute("value",String(a)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{value:e.value}})))}))}}define("contour-number-field",ContourNumberField);class ContourFileUpload extends ContourBase{static get formAssociated(){return!0}static get observed(){return["label","accept","multiple","progress","name"]}static get properties(){return{label:{attribute:"label"},accept:{attribute:"accept"},multiple:{attribute:"multiple",type:Boolean},progress:{attribute:"progress"},name:{attribute:"name"}}}render(){this.classList.add("c-file-upload"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||"File upload");const t=this.getAttribute("label")||"Drop files here or click to browse";this.ensure(".c-file-upload__dropzone",()=>{const t=document.createElement("div");return t.className="c-file-upload__dropzone",t.setAttribute("role","button"),t.tabIndex=0,t}).textContent=t;const e=this.ensure(".c-file-upload__input",()=>{const t=document.createElement("input");return t.className="c-file-upload__input",t.type="file",t.hidden=!0,t});this.keepNode(e),e.accept=this.getAttribute("accept")||"",e.multiple=this.hasAttribute("multiple");const s=this.getAttribute("progress");if(null!==s){const t=this.ensure(".c-file-upload__progress",()=>{const t=document.createElement("progress");return t.className="c-file-upload__progress",t});t.value=Number(s)||0,t.max=100}else{const t=this.querySelector(".c-file-upload__progress");t&&t.remove()}this.ensure(".c-file-upload__preview",()=>{const t=document.createElement("div");return t.className="c-file-upload__preview",t});this._internals&&this._syncFormValue()}enhance(){if(this._wiredFileUpload)return;this._wiredFileUpload=!0,this._syncFormValue(),this.addEventListener("change",()=>{this._syncFormValue()});const t=()=>this.querySelector(".c-file-upload__dropzone"),e=()=>this.querySelector(".c-file-upload__input"),s=()=>{const t=e();t&&t.click()},r=(t,e)=>{try{const s=new DataTransfer;Array.from(e||[]).forEach(t=>s.items.add(t)),t.files=s.files}catch(t){}};this.addEventListener("click",e=>{const r=t();(e.target===r||r&&r.contains(e.target))&&s()}),this.addEventListener("keydown",e=>{const r=t();!(e.target===r||r&&r.contains(e.target))||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s())});const i=t=>{const e=this.querySelector(".c-file-upload__preview");e&&(this._revokeObjectUrls(),setHTML(e,""),Array.from(t||[]).forEach(t=>{const s=document.createElement("div");if(s.className="c-file-upload__preview-item",t.type&&t.type.startsWith("image/")){const e=document.createElement("img");e.className="c-file-upload__preview-thumb",e.alt=t.name,e.loading="lazy",e.decoding="async";try{const s=URL.createObjectURL(t);e.src=s,(this._objectUrls||(this._objectUrls=[])).push(s)}catch(t){}s.appendChild(e)}else{const e=document.createElement("span");e.className="c-file-upload__preview-name",e.textContent=t.name,s.appendChild(e)}e.appendChild(s)}))};this.addEventListener("change",t=>{const e=t.target;e&&e.classList.contains("c-file-upload__input")&&(i(e.files),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{files:e.files}})))}),this.addEventListener("dragover",t=>{t.preventDefault(),this.classList.add("is-dragover")}),this.addEventListener("dragleave",()=>this.classList.remove("is-dragover")),this.addEventListener("drop",t=>{t.preventDefault(),this.classList.remove("is-dragover");const s=e();if(s&&t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length){const e=this.getAttribute("accept");if(e){const a=e.split(",").map(t=>t.trim().toLowerCase()),n=Array.from(t.dataTransfer.files).filter(t=>{const e=t.name.toLowerCase();return a.some(s=>s.startsWith(".")?e.endsWith(s):s.endsWith("/*")?t.type.toLowerCase().startsWith(s.slice(0,-1)):t.type.toLowerCase()===s)});if(0===n.length)return;r(s,n),i(n),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{files:n}}))}else r(s,t.dataTransfer.files),i(t.dataTransfer.files),this._syncFormValue(),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{files:t.dataTransfer.files}}))}})}disconnectedCallback(){super.disconnectedCallback(),this._revokeObjectUrls()}_revokeObjectUrls(){this._objectUrls&&(this._objectUrls.forEach(t=>{try{URL.revokeObjectURL(t)}catch(t){}}),this._objectUrls=[])}_syncFormValue(){if(!this._internals)return;const t=this.querySelector(".c-file-upload__input");if(t&&t.files&&t.files.length){const e=new FormData,s=this.getAttribute("name")||"file";Array.from(t.files).forEach(t=>e.append(s,t)),this._internals.setFormValue(e)}else this._internals.setFormValue(null)}}define("contour-file-upload",ContourFileUpload);class ContourTagsInput extends ContourBase{static get formAssociated(){return!0}static get observed(){return["value","placeholder","disabled","error","help","required","max"]}static get properties(){return{value:{attribute:"value"},placeholder:{attribute:"placeholder"},disabled:{attribute:"disabled",type:Boolean},error:{attribute:"error"},help:{attribute:"help"},required:{attribute:"required",type:Boolean},max:{attribute:"max"}}}render(){this.classList.add("c-tags-input"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"tags-input","Tags input"));const t=this.ensure(".c-tags-input__input",()=>{const t=document.createElement("input");return t.className="c-input c-tags-input__input",t.type="text",t.setAttribute("aria-label",labelText(this,"add-tag","Add tag")),t});t.placeholder=this.getAttribute("placeholder")||"Add tag…",this.hasAttribute("disabled")?(t.setAttribute("disabled",""),this.classList.add("is-disabled")):(t.removeAttribute("disabled"),this.classList.remove("is-disabled"));const e=this.getAttribute("error"),s=this.getAttribute("help");let r=this.querySelector(".c-tags-input__message");e||s?(r||(r=document.createElement("div"),r.className="c-tags-input__message",this.appendChild(r)),r.id||(r.id=contourId("ti-msg")),r.textContent=e||s||"",r.classList.toggle("c-tags-input__message--error",!!e),e?r.setAttribute("role","alert"):r.removeAttribute("role"),t.setAttribute("aria-describedby",r.id)):(r&&r.remove(),t.removeAttribute("aria-describedby")),e?(this.classList.add("is-error"),t.setAttribute("aria-invalid","true")):(this.classList.remove("is-error"),t.removeAttribute("aria-invalid"));const i=this.getAttribute("value");let a=[];try{a=i?JSON.parse(i):[]}catch(t){a=i?i.split(",").map(t=>t.trim()).filter(Boolean):[]}Array.from(this.querySelectorAll(".c-tags-input__tag")).forEach(t=>t.remove()),a.forEach(e=>{const s=document.createElement("span");s.className="c-tag c-tags-input__tag",s.textContent=e;const r=document.createElement("button");r.className="c-tags-input__remove",r.type="button",r.textContent="×",r.setAttribute("aria-label",labelText(this,"remove","Remove")+" "+e),r.dataset.value=e,s.appendChild(r),this.insertBefore(s,t)}),this._internals&&this._syncFormValue()}enhance(){if(this._wiredTagsInput)return;this._wiredTagsInput=!0,this._syncFormValue(),this.addEventListener("contour:add",()=>{this._syncFormValue()}),this.addEventListener("contour:remove",()=>{this._syncFormValue()});const t=t=>{let e=this.querySelector(".c-tags-input__live");e||(e=document.createElement("span"),e.className="c-tags-input__live visually-hidden",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.appendChild(e)),e.textContent=t},e=()=>{const t=this.getAttribute("value")||"";let e=[];try{e=JSON.parse(t)}catch(s){e=t.split(",").map(t=>t.trim()).filter(Boolean)}return Array.isArray(e)?e.map(String):[]},s=s=>{if(this.hasAttribute("disabled"))return;const r=e(),i=Number(this.getAttribute("max")),a=[],n=[];let o=!1;for(const t of s){const e=String(t).trim();if(e)if(r.includes(e))n.push(e);else{if(Number.isFinite(i)&&i>0&&r.length>=i){o=!0;break}r.push(e),a.push(e)}}if(a.length){this.setAttribute("value",JSON.stringify(r));for(const t of a)this.dispatchEvent(new CustomEvent("contour:add",{bubbles:!0,composed:!0,detail:{value:t}}))}const l=[];a.length&&l.push("Added "+a.join(", ")),n.length&&l.push(n.join(", ")+" already added"),o&&l.push("Tag limit reached ("+i+")"),l.length&&t(l.join(". "))};this.addEventListener("keydown",r=>{const i=this.querySelector(".c-tags-input__input");if(i&&!this.hasAttribute("disabled"))if("Enter"===r.key&&r.target===i){r.preventDefault();const t=i.value;i.value="",s([t])}else if("Backspace"===r.key&&r.target===i&&""===i.value){const s=e();if(s.length){const e=s.pop();this.setAttribute("value",JSON.stringify(s)),t("Removed "+e),this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{value:e}}))}}}),this.addEventListener("input",t=>{const e=this.querySelector(".c-tags-input__input");if(e&&t.target===e&&!this.hasAttribute("disabled")&&e.value.includes(",")){const t=e.value.split(",");e.value=t.pop(),s(t)}}),this.addEventListener("paste",t=>{const e=this.querySelector(".c-tags-input__input");if(!e||t.target!==e||this.hasAttribute("disabled"))return;const r=t.clipboardData&&t.clipboardData.getData("text/plain");r&&/[,;\n]/.test(r)&&(t.preventDefault(),s(r.split(/[,;\n]+/)))}),this.addEventListener("click",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-tags-input__remove"):null;if(r&&this.contains(r)&&!this.hasAttribute("disabled")){const s=r.dataset.value,i=e().filter(t=>t!==s);this.setAttribute("value",JSON.stringify(i)),t("Removed "+s),this.dispatchEvent(new CustomEvent("contour:remove",{bubbles:!0,composed:!0,detail:{value:s}}))}})}_syncFormValue(){if(!this._internals)return;this._internals.setFormValue(this.getAttribute("value")||"[]");let t=0;try{const e=JSON.parse(this.getAttribute("value")||"[]");t=Array.isArray(e)?e.length:0}catch(e){t=(this.getAttribute("value")||"").split(",").filter(t=>t.trim()).length}this._syncValidity(this.hasAttribute("required")&&0===t)}}define("contour-tags-input",ContourTagsInput);class ContourSwatch extends ContourBase{static get observed(){return["color","selected","label"]}static get properties(){return{color:{attribute:"color"},selected:{attribute:"selected",type:Boolean},label:{attribute:"label"}}}render(){this.classList.add("c-swatch"),this.hasAttribute("role")||this.setAttribute("role","button"),"button"!==this.getAttribute("role")||this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.getAttribute("label")||this.getAttribute("color")||"Swatch");const t=safeColor(this.getAttribute("color"))||"var(--color-surface-3)";if(this.style.setProperty("--swatch-color",t),this.hasAttribute("selected")?this.classList.add("is-selected"):this.classList.remove("is-selected"),"button"===this.getAttribute("role")&&this.setAttribute("aria-pressed",String(this.hasAttribute("selected"))),!this.hasAttribute("aria-label")){const e=this.getAttribute("label")||t;this.setAttribute("aria-label",e)}if(!this.querySelector("button")&&!this.querySelector("span")){const t=document.createElement("span");t.className="c-swatch__btn",t.setAttribute("aria-hidden","true"),this.appendChild(t)}}enhance(){this._wiredSwatch||(this._wiredSwatch=!0,this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("color")}}))}),this.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:this.getAttribute("color")}})))}))}}define("contour-swatch",ContourSwatch);class ContourCalendar extends ContourBase{static get observed(){return["value","month","year","range","start","end"]}static get properties(){return{value:{attribute:"value"},month:{attribute:"month"},year:{attribute:"year"},range:{attribute:"range",type:Boolean},start:{attribute:"start"},end:{attribute:"end"}}}_attrNum(t,e){const s=this.getAttribute(t),r=Number(s);return null!==s&&Number.isFinite(r)?r:e}_ym(){const t=new Date;return{year:this._attrNum("year",t.getFullYear()),month:this._attrNum("month",t.getMonth())}}render(){this.classList.add("c-calendar");const t=new Date,{year:e,month:s}=this._ym(),r=this.ensure(".c-calendar__header",()=>{const t=document.createElement("div");return t.className="c-calendar__header",t});setHTML(r,"");const i=(t,e,s)=>{const r=document.createElement("button");return r.type="button",r.className="c-btn c-btn--sm "+t,r.textContent=e,r.setAttribute("aria-label",s),r},a=i("c-calendar__prev-year","","Previous year");setHTML(a,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevrons-left" /></svg>');const n=i("c-calendar__prev","","Previous month");setHTML(n,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>');const o=document.createElement("span");o.className="c-calendar__title",o.textContent=new Date(e,s,1).toLocaleString(void 0,{month:"long",year:"numeric"});const l=i("c-calendar__next","","Next month");setHTML(l,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>');const c=i("c-calendar__next-year","","Next year");setHTML(c,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevrons-right" /></svg>'),r.append(a,n,o,l,c);const u=this.ensure(".c-calendar__grid",()=>{const t=document.createElement("div");return t.className="c-calendar__grid",t.setAttribute("role","grid"),t});u.setAttribute("aria-label",o.textContent),setHTML(u,"");const d=new Date(e,s,1).getDay(),h=new Date(e,s+1,0).getDate(),p=this.hasAttribute("range"),b=this.getAttribute("value"),m=this.getAttribute("start"),g=this.getAttribute("end");let v=null,_=0;const f=()=>{v=document.createElement("div"),v.className="c-calendar__row",v.setAttribute("role","row"),u.appendChild(v),_=0},y=new Intl.DateTimeFormat(void 0,{weekday:"short"});f();for(let t=0;t<7;t++){const e=document.createElement("div");e.className="c-calendar__weekday",e.setAttribute("role","columnheader"),e.textContent=y.format(new Date(2023,0,1+t)),v.appendChild(e)}f();for(let t=0;t<d;t++){const t=document.createElement("div");t.className="c-calendar__day c-calendar__day--empty",v.appendChild(t),_++,7===_&&f()}const A=t.getFullYear()+"-"+String(t.getMonth()+1).padStart(2,"0")+"-"+String(t.getDate()).padStart(2,"0"),w=b&&b.startsWith(e+"-"+String(s+1).padStart(2,"0"))?b:A.startsWith(e+"-"+String(s+1).padStart(2,"0"))?A:e+"-"+String(s+1).padStart(2,"0")+"-01";for(let t=1;t<=h;t++){const r=document.createElement("button");r.className="c-calendar__day",r.type="button",r.setAttribute("role","gridcell"),r.textContent=String(t);const i=e+"-"+String(s+1).padStart(2,"0")+"-"+String(t).padStart(2,"0"),a=p?i===m||i===g:i===b;a&&r.classList.add("is-selected"),p&&m&&g&&i>m&&i<g&&r.classList.add("is-in-range"),r.setAttribute("aria-selected",String(a)),i===A&&r.setAttribute("aria-current","date"),r.setAttribute("tabindex",i===w?"0":"-1"),r.dataset.value=i,v.appendChild(r),_++,7===_&&f()}r.parentNode!==this&&this.insertBefore(r,u)}enhance(){if(this._wiredCalendar)return;this._wiredCalendar=!0;const t=(t,e)=>{this.batch(()=>{this.setAttribute("month",String(t)),this.setAttribute("year",String(e))}),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{month:t,year:e}}))},e=t=>{const e=this.querySelector('.c-calendar__day[data-value="'+t+'"]');if(e)try{e.focus()}catch(t){}};this.addEventListener("focusin",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(e&&this.contains(e)){for(const t of this.querySelectorAll(".c-calendar__day"))t.tabIndex=-1;e.tabIndex=0}}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target:null;if(!s)return;const{year:r,month:i}=this._ym();if(s.closest(".c-calendar__prev")){const e=new Date(r,i-1,1);return void t(e.getMonth(),e.getFullYear())}if(s.closest(".c-calendar__next")){const e=new Date(r,i+1,1);return void t(e.getMonth(),e.getFullYear())}if(s.closest(".c-calendar__prev-year"))return void t(i,r-1);if(s.closest(".c-calendar__next-year"))return void t(i,r+1);const a=s.closest(".c-calendar__day");if(a&&this.contains(a)&&a.dataset.value){const t=a.dataset.value;if(this.hasAttribute("range")){const e=this.getAttribute("start"),s=this.getAttribute("end");let r,i;!e||e&&s?(r=t,i=null):(r=t<e?t:e,i=t<e?e:t),this.batch(()=>{this.setAttribute("start",r),null===i?this.removeAttribute("end"):this.setAttribute("end",i)}),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:t,range:i?[r,i]:[r]}}))}else this.setAttribute("value",t),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{value:t}}))}}),this.addEventListener("keydown",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-calendar__day:not(.c-calendar__day--empty)"):null;if(!r||!this.contains(r)||!r.dataset.value)return;const[i,a,n]=r.dataset.value.split("-").map(Number),{year:o,month:l}=(new Date(i,a-1,n),this._ym()),c=new Date(o,l+1,0).getDate();let u=null;if("ArrowRight"===s.key)u=new Date(i,a-1,n+1);else if("ArrowLeft"===s.key)u=new Date(i,a-1,n-1);else if("ArrowDown"===s.key)u=new Date(i,a-1,n+7);else if("ArrowUp"===s.key)u=new Date(i,a-1,n-7);else if("PageUp"===s.key)u=s.shiftKey?new Date(i-1,a-1,Math.min(n,new Date(i-1,a,0).getDate())):new Date(i,a-2,Math.min(n,new Date(i,a-1,0).getDate()));else if("PageDown"===s.key)u=s.shiftKey?new Date(i+1,a-1,Math.min(n,new Date(i+1,a,0).getDate())):new Date(i,a,Math.min(n,new Date(i,a+1,0).getDate()));else if("Home"===s.key)u=new Date(o,l,1);else{if("End"!==s.key)return;u=new Date(o,l,c)}s.preventDefault();const d=(h=u).getFullYear()+"-"+String(h.getMonth()+1).padStart(2,"0")+"-"+String(h.getDate()).padStart(2,"0");var h;u.getFullYear()===o&&u.getMonth()===l||t(u.getMonth(),u.getFullYear()),e(d)})}}define("contour-calendar",ContourCalendar);class ContourNotificationCenter extends ContourBase{static get observed(){return["count","items","color"]}static get properties(){return{count:{attribute:"count"},items:{attribute:"items"},color:{attribute:"color"}}}render(){this.classList.add("c-notification-center"),this.setAttribute("role","group");const t=this.ensure(".c-notification-center__trigger",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-notification-center__trigger",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-bell" /></svg><span class="c-notification-center__bullet" aria-hidden="true"></span>'),t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-label",labelText(this,"notifications","Notifications")),t}),e=this.getAttribute("color"),s=t.querySelector(".c-notification-center__bullet");s&&e&&(s.style.background=safeColor(e),s.dataset.color=e);const r=this.ensure(".c-notification-center__panel",()=>{const t=document.createElement("div");return t.className="c-notification-center__panel",t.hidden=!0,t.setAttribute("role","dialog"),t.setAttribute("aria-label",labelText(this,"notifications","Notifications")),t});r.hidden=!this._notifOpen,t.setAttribute("aria-expanded",String(!!this._notifOpen));const i=Array.from(this.querySelectorAll(":scope > .c-notification-center__item")),a=this.getAttribute("items");if(i.length){setHTML(r,"");const t=document.createElement("div");t.setAttribute("role","list"),t.setAttribute("aria-label",labelText(this,"notifications","Notifications")),this._notifAuthored||(this._notifAuthored=[]),i.forEach(e=>{t.appendChild(e),this._notifAuthored.push(e)}),r.appendChild(t)}else if(a){let t=null;try{t=JSON.parse(a)}catch(t){warnBadJson(this,"items",t)}if(setHTML(r,""),Array.isArray(t)){const e=document.createElement("div");e.setAttribute("role","list"),e.setAttribute("aria-label",labelText(this,"notifications","Notifications"));const s=this._notifShown||50;t.slice(0,s).forEach(t=>{const s=document.createElement("div");s.className="c-notification-center__item"+(t&&t.read?" is-read":""),s.setAttribute("tabindex","-1"),s.setAttribute("role","listitem"),t&&t.current&&s.setAttribute("aria-current","true"),s.dataset.read=t&&t.read?"true":"false";const r=document.createElement("span");r.className="c-notification-center__item-label",r.textContent="string"==typeof t?t:t.text||t.title||"",s.appendChild(r);const i=document.createElement("button");i.type="button",i.className="c-notification-center__archive",i.setAttribute("aria-label",labelText(this,"archive","Archive notification")),i.textContent="⤓",i.tabIndex=-1,s.appendChild(i);const a=document.createElement("button");a.type="button",a.className="c-notification-center__dismiss",a.setAttribute("aria-label",labelText(this,"dismiss","Dismiss notification")),a.textContent="×",a.tabIndex=-1,s.appendChild(a),e.appendChild(s)});const i=e.querySelector(".c-notification-center__item");if(i&&(i.tabIndex=0),r.appendChild(e),t.length){if(t.length>s){const e=document.createElement("button");e.type="button",e.className="c-btn c-btn--sm c-notification-center__more",e.textContent=labelText(this,"more","Show more")+" ("+(t.length-s)+")",r.appendChild(e)}}else{const t=document.createElement("div");t.className="c-notification-center__empty",t.textContent=labelText(this,"empty","No notifications"),r.appendChild(t)}}else{const t=document.createElement("div");t.className="c-notification-center__error",t.setAttribute("role","alert"),t.textContent=labelText(this,"error","Could not load notifications"),r.appendChild(t)}}this._syncNotifBadge()}_syncNotifBadge(){const t=this.querySelector(".c-notification-center__trigger");if(!t)return;const e=Array.from(this.querySelectorAll(".c-notification-center__item"));let s;s=this._notifInteracted||!this.hasAttribute("count")?e.filter(t=>"true"!==t.dataset.read).length:Number(this.getAttribute("count"))||0;let r=t.querySelector(".c-notification-center__badge");s>0?(r||(r=document.createElement("span"),r.className="c-notification-center__badge c-badge c-badge--dot",t.appendChild(r)),r.textContent=String(s)):r&&r.remove()}enhance(){if(this._wiredNotifCenter)return;this._wiredNotifCenter=!0;const t=t=>{"true"!==t.dataset.read&&(t.dataset.read="true",t.classList.add("is-read"),this._notifInteracted=!0,this._syncNotifBadge(),this.dispatchEvent(new CustomEvent("contour:read",{bubbles:!0,composed:!0,detail:{label:t.querySelector(".c-notification-center__item-label")?.textContent||t.textContent}})));for(const e of this.querySelectorAll(".c-notification-center__item"))e===t?e.setAttribute("aria-current","true"):e.removeAttribute("aria-current");this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{label:t.querySelector(".c-notification-center__item-label")?.textContent||t.textContent}}))},e=(t,e)=>{const s=t.querySelector(".c-notification-center__item-label")?.textContent||t.textContent;t.remove(),this._notifInteracted=!0,this._syncNotifBadge(),this.dispatchEvent(new CustomEvent("archive"===e?"contour:remove":"contour:dismiss",{bubbles:!0,composed:!0,detail:{label:s}}))};this.addEventListener("click",s=>{const r=this.querySelector(".c-notification-center__trigger"),i=this.querySelector(".c-notification-center__panel");if(r&&(s.target===r||r.contains(s.target)))return void(i&&(i.hidden=!i.hidden,this._notifOpen=!i.hidden,r.setAttribute("aria-expanded",String(!i.hidden)),this.dispatchEvent(new CustomEvent(i.hidden?"contour:close":"contour:open",{bubbles:!0,composed:!0}))));const a=s.target&&s.target.closest?s.target.closest(".c-notification-center__more"):null;if(a&&this.contains(a))return this._notifShown=(this._notifShown||50)+50,void this.requestRender();const n=s.target&&s.target.closest?s.target.closest(".c-notification-center__archive"):null;if(n&&this.contains(n)){const t=n.closest(".c-notification-center__item");return void(t&&e(t,"archive"))}const o=s.target&&s.target.closest?s.target.closest(".c-notification-center__dismiss"):null;if(o&&this.contains(o)){const t=o.closest(".c-notification-center__item");return void(t&&e(t,"dismiss"))}const l=s.target&&s.target.closest?s.target.closest(".c-notification-center__item"):null;l&&this.contains(l)&&t(l)});const s=t=>{const e=this.querySelector(".c-notification-center__panel"),s=this.querySelector(".c-notification-center__trigger");!e||e.hidden||this.contains(t.target)||(e.hidden=!0,this._notifOpen=!1,s&&s.setAttribute("aria-expanded","false"))};document.addEventListener("click",s),onDispose(this,()=>document.removeEventListener("click",s));const r=s=>{const r=this.querySelector(".c-notification-center__panel"),i=this.querySelector(".c-notification-center__trigger");if("Escape"===s.key&&r&&!r.hidden){if(r.hidden=!0,this._notifOpen=!1,i){i.setAttribute("aria-expanded","false");try{i.focus()}catch(t){}}return}if(!r||r.hidden)return;const a=Array.from(r.querySelectorAll(".c-notification-center__item"));if(a.length){if(("Enter"===s.key||" "===s.key)&&a.includes(s.target))return s.preventDefault(),void t(s.target);if(("Delete"===s.key||"Backspace"===s.key)&&a.includes(s.target)){s.preventDefault();const t=a.indexOf(s.target);e(s.target,"dismiss");const r=a[t+1]||a[t-1];if(r&&r.isConnected)try{r.focus()}catch(t){}return}navKey(s,a,{wrap:!0,onNavigate:t=>{a.forEach((e,s)=>{e.tabIndex=s===t?0:-1})}})}};document.addEventListener("keydown",r),onDispose(this,()=>document.removeEventListener("keydown",r))}}define("contour-notification-center",ContourNotificationCenter);class ContourStepper extends ContourBase{static get observed(){return["steps","current"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current"}}}render(){this.classList.add("c-stepper"),this.hasAttribute("role")||this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"stepper","Stepper"));const t=this.getAttribute("steps"),e=Number(this.getAttribute("current")||0),s=this.ensure(".c-stepper__list",()=>{const t=document.createElement("ol");return t.className="c-stepper__list",t});setHTML(s,"");const r=Array.from(this.querySelectorAll(":scope > .c-stepper__step"));let i=[];if(r.length)i=r.map(t=>t.textContent.trim()),this._stepperAuthored=i,r.forEach(t=>t.remove());else if(t)try{i=JSON.parse(t)}catch(t){warnBadJson(this,"steps",t),i=this._stepperAuthored||[]}else i=this._stepperAuthored||[];i.forEach((t,r)=>{const i=document.createElement("li");i.className="c-stepper__step"+(r===e?" is-current":"")+(r<e?" is-done":""),r===e&&i.setAttribute("aria-current","step"),i.setAttribute("tabindex",r===e?"0":"-1");const a=document.createElement("span");a.className="c-stepper__marker",a.setAttribute("aria-hidden","true"),r<e?setHTML(a,'<svg viewBox="0 0 24 24"><use href="#i-check" /></svg>'):a.textContent=String(r+1),i.appendChild(a);const n=document.createElement("span");n.className="c-stepper__label",n.textContent="string"==typeof t?t:t.title||t.label||"",i.appendChild(n),s.appendChild(i)});const a=this.ensure(".c-stepper__nav",()=>{const t=document.createElement("div");return t.className="c-stepper__nav c-btn-group",t}),n=this.ensure(".c-stepper__prev",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-stepper__prev",t.type="button",t});n.textContent=labelText(this,"prev","Back"),e<=0?n.setAttribute("disabled",""):n.removeAttribute("disabled");const o=this.ensure(".c-stepper__next",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-stepper__next",t.type="button",t});o.textContent=labelText(this,"next","Next"),e>=i.length-1?o.setAttribute("disabled",""):o.removeAttribute("disabled"),a.contains(n)||a.appendChild(n),a.contains(o)||a.appendChild(o),a.parentNode!==this&&this.appendChild(a)}enhance(){if(this._wiredStepper)return;this._wiredStepper=!0;const t=t=>{const e=this.querySelector(".c-stepper__list"),s=e?e.querySelectorAll(".c-stepper__step").length:0;if(!s)return;let r=Number(this.getAttribute("current")||0);r="prev"===t?Math.max(0,r-1):Math.min(s-1,r+1),this.setAttribute("current",String(r)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:t,index:r}}))};this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest(".c-stepper__prev"):null,r=e.target&&e.target.closest?e.target.closest(".c-stepper__next"):null;if(s&&this.contains(s))return void t("prev");if(r&&this.contains(r))return void t("next");const i=e.target&&e.target.closest?e.target.closest(".c-stepper__step"):null;if(i&&this.contains(i)){const t=Array.from(this.querySelectorAll(".c-stepper__step")).indexOf(i);t>=0&&t!==Number(this.getAttribute("current")||0)&&(this.setAttribute("current",String(t)),this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:!0,composed:!0,detail:{direction:"jump",index:t}})))}}),this.addEventListener("keydown",e=>{"ArrowLeft"===e.key?(e.preventDefault(),t("prev")):"ArrowRight"===e.key&&(e.preventDefault(),t("next"))})}}define("contour-stepper",ContourStepper);class ContourVirtualList extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","item-height","orientation","sticky"]}static get properties(){return{items:{attribute:"items"},"item-height":{attribute:"item-height"},orientation:{attribute:"orientation"},sticky:{attribute:"sticky",type:Boolean}}}_items(){const t=this.getAttribute("items");let e=[];try{e=t?JSON.parse(t):[]}catch(t){warnBadJson(this,"items",t),e=[]}return Array.isArray(e)?e:[]}_itemHeight(){const t=Number(this.getAttribute("item-height"));return Number.isFinite(t)&&t>0?t:cssLength("--virtual-list-item-height",28)}_autoHeight(){return"auto"===this.getAttribute("item-height")}render(){this.classList.add("c-virtual-list"),this.setAttribute("role","list"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",labelText(this,"virtual-list","Virtual list"));const t=this.ensure(".c-virtual-list__scroller",()=>{const t=document.createElement("div");return t.className="c-virtual-list__scroller",t});t.setAttribute("role","presentation");const e="horizontal"===this.getAttribute("orientation");t.style.overflowX=e?"auto":"hidden",t.style.overflowY=e?"hidden":"auto";const s=this.ensure(".c-virtual-list__inner",()=>{const t=document.createElement("div");return t.className="c-virtual-list__inner",t.style.position="relative",t});s.parentNode!==t&&t.appendChild(s),this._renderWindow(t,s,e?t.scrollLeft||0:t.scrollTop||0)}_measureHeights(t,e){return Array.from(t.querySelectorAll(".c-virtual-list__item")).map(t=>e?t.getBoundingClientRect().width||this._itemHeight():t.getBoundingClientRect().height||this._itemHeight())}_renderWindow(t,e,s){const r=this._items(),i=this._itemHeight(),a="horizontal"===this.getAttribute("orientation"),n=this._autoHeight(),o=a?t.clientWidth||320:t.clientHeight||320,l=r.length;this._vlItemCount!==l&&(this._vlHeights=null,this._vlItemCount=l);let c=n?this._vlHeights:null,u=null;if(n&&c&&c.length===l){u=[0];for(let t=0;t<l;t++)u.push(u[t]+(c[t]||this._itemHeight()))}const d=n&&!u?l:n?Math.ceil(o/this._itemHeight())+6:Math.ceil(o/i)+4;let h=0;if(n&&u){let t=0,e=l;for(;t<e;){const r=t+e>>1;u[r]<(s||0)?t=r+1:e=r}h=Math.max(0,t-3)}else n||(h=Math.floor((s||0)/i));h<0&&(h=0);const p=Math.min(l,h+d);h>Math.max(0,l-d)&&!n&&(h=Math.max(0,l-d));const b=n&&u?u[h]:n?0:h*i,m=n&&u?Math.max(0,u[l]-u[p]):n?0:Math.max(0,(l-p)*i);e.style.display=a?"flex":"block",e.style.width=a&&n?"max-content":"",e.style.height=a||n?"":l*i+"px",setHTML(e,"");const g=document.createElement("div");g.className="c-virtual-list__spacer c-virtual-list__spacer--top",g.style[a?"width":"height"]=b+"px",e.appendChild(g);for(let t=h;t<p;t++){const s=document.createElement("div");s.className="c-virtual-list__item",s.setAttribute("role","listitem"),s.setAttribute("aria-setsize",String(l)),s.setAttribute("aria-posinset",String(t+1)),s.setAttribute("tabindex",0===t?"0":"-1"),s.textContent="string"==typeof r[t]?r[t]:r[t].label||r[t].text||JSON.stringify(r[t]),this.hasAttribute("sticky")&&r[t]&&r[t].sticky&&(s.style.position="sticky",s.style.insetBlockStart="0",s.style.zIndex="1"),a&&!n&&(s.style.flex="0 0 "+i+"px"),s.dataset.index=String(t),e.appendChild(s)}const v=document.createElement("div");v.className="c-virtual-list__spacer c-virtual-list__spacer--bottom",v.style[a?"width":"height"]=m+"px",e.appendChild(v),a&&!n&&(e.style.width=l*i+"px"),n&&!this._vlHeights&&requestAnimationFrame(()=>{this._vlHeights=this._measureHeights(e,a);const s=t,r=e;s&&r&&this._renderWindow(s,r,s.scrollTop||0)})}enhance(){if(this._wiredVirtualList)return;this._wiredVirtualList=!0;const t=()=>this.querySelector(".c-virtual-list__scroller"),e=()=>this.querySelector(".c-virtual-list__inner");let s=0;const r=()=>{s||(s=requestAnimationFrame(()=>{s=0;const r=t(),i=e();r&&i&&this._renderWindow(r,i,"horizontal"===this.getAttribute("orientation")?r.scrollLeft:r.scrollTop)}))};this.addEventListener("scroll",r,{passive:!0,capture:!0}),onDispose(this,()=>{this.removeEventListener("scroll",r,{capture:!0}),s&&cancelAnimationFrame(s)}),this.addEventListener("keydown",t=>{const e=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(!e.length)return;const s="horizontal"===this.getAttribute("orientation"),r=s?"ArrowRight":"ArrowDown",i=s?"ArrowLeft":"ArrowUp",a=document.activeElement,n=e.indexOf(a),o=this.querySelector(".c-virtual-list__scroller"),l=this.querySelector(".c-virtual-list__inner");if(t.key===r&&n===e.length-1||t.key===i&&0===n&&Number(a&&a.dataset.index)>0){if(t.preventDefault(),o&&l){const e=(t.key===r?1:-1)*this._itemHeight();s?o.scrollLeft+=e:o.scrollTop+=e,this._renderWindow(o,l,s?o.scrollLeft:o.scrollTop);const i=Number(a&&a.dataset.index)+(t.key===r?1:-1);requestAnimationFrame(()=>{const t=this.querySelector(`.c-virtual-list__item[data-index="${i}"]`),e=Array.from(this.querySelectorAll(".c-virtual-list__item"));if(t){e.forEach(t=>t.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0");try{t.focus()}catch(t){}}})}}else navKey(t,e,{wrap:!1,homeEnd:!0,onNavigate:t=>e.forEach((e,s)=>e.setAttribute("tabindex",s===t?"0":"-1")),onKey:()=>{if("Enter"===t.key||" "===t.key){const t=Number(document.activeElement.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:t,value:document.activeElement.textContent}}))}}})}),this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-virtual-list__item"):null;if(!e||!this.contains(e))return;const s=Number(e.dataset.index);this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{index:s,value:e.textContent}}))})}}define("contour-virtual-list",ContourVirtualList);class ContourSortableList extends ContourBase{static get observed(){return["items","order"]}static get properties(){return{items:{attribute:"items"},order:{attribute:"order"}}}render(){this.classList.add("c-sortable-list");const t=this.ensure(".c-sortable-list__list",()=>{const t=document.createElement("ul");return t.className="c-sortable-list__list",t}),e=this.getAttribute("items");let s=[];try{s=e?JSON.parse(e):[]}catch(t){s=[]}Array.isArray(s)||(s=[]);let r=Array.from({length:s.length},(t,e)=>e);const i=this.getAttribute("order");if(i)try{const t=JSON.parse(i);Array.isArray(t)&&t.length===s.length&&t.every(t=>Number.isInteger(t)&&t>=0&&t<s.length)&&(r=t.slice(),s=t.map(t=>s[t]))}catch(t){}this._sortableSourceOrder=r,this._sortableItems=s,setHTML(t,""),s.forEach((e,s)=>{const r=document.createElement("li");r.className="c-sortable-list__item",r.setAttribute("draggable","true"),r.dataset.index=String(s);const i="string"==typeof e?e:e.label||e.text||"",a=document.createElement("span");a.className="c-sortable-list__handle",a.textContent="⋮⋮",a.setAttribute("role","button"),a.setAttribute("aria-label",labelText(this,"reorder","Reorder")+" "+(i||String(s+1))),a.setAttribute("data-contour-preserve-key",i||String(s)),a.tabIndex=0,r.appendChild(a);const n=document.createElement("span");n.className="c-sortable-list__label",n.textContent=i,r.appendChild(n),t.appendChild(r)})}enhance(){if(this._wiredSortableList)return;this._wiredSortableList=!0;const t=()=>this.querySelector(".c-sortable-list__list"),e=t=>{let e=this.querySelector(".c-sortable-list__live");e||(e=document.createElement("span"),e.className="c-sortable-list__live visually-hidden",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.appendChild(e)),e.textContent=t},s=e=>Array.from(t().children).indexOf(e),r=(t,e)=>{const s=(this._sortableItems||[]).length,r=Array.isArray(this._sortableSourceOrder)&&this._sortableSourceOrder.length===s?this._sortableSourceOrder.slice():Array.from({length:s},(t,e)=>e),[i]=r.splice(t,1);r.splice(e,0,i),this.setAttribute("order",JSON.stringify(r))};let i=null;this.addEventListener("dragstart",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-sortable-list__item"):null;if(e&&this.contains(e)){if(i=s(e),t.dataTransfer){t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",String(i))}catch(t){}}e.classList.add("is-dragging")}}),this.addEventListener("dragover",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-sortable-list__item"):null;e&&this.contains(e)&&null!==i&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"))}),this.addEventListener("drop",a=>{const n=a.target&&a.target.closest?a.target.closest(".c-sortable-list__item"):null;if(!n||!this.contains(n)||null===i)return;a.preventDefault();const o=s(n),l=t(),c=l.children[i];if(c&&i!==o){i<o?l.insertBefore(c,l.children[o+1]||null):l.insertBefore(c,l.children[o]);const t=c.querySelector(".c-sortable-list__label");e((t?t.textContent:"Item")+" moved to position "+(o+1));const s=i;r(s,o),this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:!0,composed:!0,detail:{from:s,to:o}}))}i=null,Array.from(l.children).forEach(t=>t.classList.remove("is-dragging"))}),this.addEventListener("dragend",()=>{i=null;const e=t();e&&Array.from(e.children).forEach(t=>t.classList.remove("is-dragging"))}),this.addEventListener("click",t=>{const s=t.target&&t.target.closest?t.target.closest(".c-sortable-list__handle"):null;if(!s||!this.contains(s))return;const r="true"===s.getAttribute("aria-pressed");s.setAttribute("aria-pressed",String(!r)),s.classList.toggle("is-grabbed",!r);const i=s.closest(".c-sortable-list__item"),a=i&&i.querySelector(".c-sortable-list__label"),n=a?a.textContent:"Item";e(r?`${n} released`:`${n} grabbed; use Up or Down arrows to reorder`)}),this.addEventListener("keydown",i=>{const a=i.target&&i.target.closest?i.target.closest(".c-sortable-list__handle"):null;if(!a)return;if("Enter"===i.key||" "===i.key)return i.preventDefault(),void a.click();const n=a.closest(".c-sortable-list__item");if(!n)return;const o=t(),l=s(n),c=(t,s)=>{const i=n.querySelector(".c-sortable-list__label");e((i?i.textContent:"Item")+" moved to position "+(s+1)),r(l,s),this.dispatchEvent(new CustomEvent("contour:move",{bubbles:!0,composed:!0,detail:{direction:t,from:l,to:s}})),this.dispatchEvent(new CustomEvent("contour:reorder",{bubbles:!0,composed:!0,detail:{from:l,to:s}}))};"ArrowUp"===i.key&&n.previousElementSibling?(i.preventDefault(),o.insertBefore(n,n.previousElementSibling),c("up",s(n))):"ArrowDown"===i.key&&n.nextElementSibling?(i.preventDefault(),o.insertBefore(n.nextElementSibling,n),c("down",s(n))):"Home"===i.key&&l>0?(i.preventDefault(),o.insertBefore(n,o.firstElementChild),c("up",0)):"End"===i.key&&l<o.children.length-1&&(i.preventDefault(),o.appendChild(n),c("down",o.children.length-1))})}}define("contour-sortable-list",ContourSortableList);class ContourCarousel extends ContourBase{static get observed(){return["items","index","autoplay","paused"]}static get properties(){return{items:{attribute:"items"},index:{attribute:"index"},autoplay:{attribute:"autoplay"},paused:{attribute:"paused",type:Boolean}}}_items(){const t=this.getAttribute("items");let e=[];try{e=t?JSON.parse(t):[]}catch(t){e=[]}return Array.isArray(e)?e:[]}_index(){const t=Number(this.getAttribute("index")),e=this._items();return Number.isFinite(t)&&t>=0&&t<e.length?t:0}render(){this.classList.add("c-carousel"),this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),Array.from(this.children).forEach(t=>{t.classList&&t.classList.contains("c-carousel__slide")&&t.parentElement===this&&t.remove()});const t=this.ensure(".c-carousel__track",()=>{const t=document.createElement("div");return t.className="c-carousel__track",t.setAttribute("role","group"),t.setAttribute("aria-roledescription","slide container"),t}),e=this._items();setHTML(t,"");const s=this._index();e.forEach((r,i)=>{const a=document.createElement("div");a.className="c-carousel__slide"+(i===s?" is-active":""),a.setAttribute("role","group"),a.setAttribute("aria-roledescription","slide"),a.setAttribute("aria-label",i+1+" of "+e.length),a.setAttribute("aria-hidden",i===s?"false":"true");const n="object"==typeof r&&r?r.src||r.image||r.video:null;if(n){const t=!("object"!=typeof r||!r)&&("video"===r.type||!!r.video);a.classList.add("c-carousel__slide--media");const e=document.createElement(t?"video":"img");e.src=n,t?(e.controls=!0,r.poster&&(e.poster=r.poster)):e.alt="object"==typeof r&&(r.alt||r.label)||"",a.appendChild(e)}else a.textContent="string"==typeof r?r:r.label||r.text||"";a.dataset.index=String(i),t.appendChild(a)});this.ensure(".c-carousel__prev",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-carousel__prev",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>'),t.setAttribute("aria-label",labelText(this,"previous-slide","Previous slide")),t}),this.ensure(".c-carousel__next",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-carousel__next",t.type="button",setHTML(t,'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>'),t.setAttribute("aria-label",labelText(this,"next-slide","Next slide")),t});const r=this.ensure(".c-carousel__status",()=>{const t=document.createElement("span");return t.className="c-carousel__status",t}),i=Number(this.getAttribute("autoplay")),a=Number.isFinite(i)&&i>0&&!this.hasAttribute("paused")&&!this._reducedMotion();r.setAttribute("aria-live",a?"off":"polite"),r.textContent=e.length?s+1+" of "+e.length:"0 of 0";const n=this.ensure(".c-carousel__dots",()=>{const t=document.createElement("div");return t.className="c-carousel__dots",t.setAttribute("role","group"),t.setAttribute("aria-label",labelText(this,"slide-controls","Slide controls")),t});n.setAttribute("role","group"),n.setAttribute("aria-label",labelText(this,"slide-controls","Slide controls")),setHTML(n,""),e.forEach((t,e)=>{const r=document.createElement("button");r.type="button",r.className="c-carousel__dot"+(e===s?" is-active":""),r.setAttribute("aria-label",labelText(this,"go-to-slide","Go to slide")+" "+(e+1)),r.setAttribute("aria-current",e===s?"true":"false"),r.tabIndex=e===s?0:-1,r.dataset.index=String(e),n.appendChild(r)});const o=i;if(Number.isFinite(o)&&o>0){const t=this.hasAttribute("paused")||this._reducedMotion(),e=this.ensure(".c-carousel__pause",()=>{const t=document.createElement("button");return t.className="c-btn c-btn--sm c-btn--icon c-carousel__pause",t.type="button",t});setHTML(e,t?'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-play" /></svg>':'<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-pause" /></svg>'),e.setAttribute("aria-label",t?labelText(this,"play-slides","Play slides automatically"):labelText(this,"pause-slides","Pause automatic slides")),e.setAttribute("aria-pressed",String(t)),e.disabled=this._reducedMotion()}else{const t=this.querySelector(".c-carousel__pause");t&&t.remove()}}_reducedMotion(){try{return"function"==typeof matchMedia&&matchMedia("(prefers-reduced-motion: reduce)").matches}catch(t){return!1}}enhance(){const t=Number(this.getAttribute("autoplay")),e=Number.isFinite(t)&&t>0&&!this.hasAttribute("paused")&&!this._reducedMotion()&&this._items().length>1;if(e&&!this._carouselTimer?this._carouselTimer=setInterval(()=>{const t=this._items();if(!t.length)return;const e=(this._index()+1)%t.length;this.setAttribute("index",String(e)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:e,direction:"next"}}))},Math.max(500,t)):!e&&this._carouselTimer&&(clearInterval(this._carouselTimer),this._carouselTimer=null),this._wiredCarousel)return;this._wiredCarousel=!0,onDispose(this,()=>{this._carouselTimer&&(clearInterval(this._carouselTimer),this._carouselTimer=null)});const s=t=>{const e=this._items();if(!e.length)return;let s=this._index();s="prev"===t?(s-1+e.length)%e.length:(s+1)%e.length,this.setAttribute("index",String(s)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:s,direction:t}}))};this.addEventListener("click",t=>{const e=t.target&&t.target.closest?t.target.closest(".c-carousel__pause"):null;if(e&&this.contains(e)){if(this._reducedMotion())return;const t=!this.hasAttribute("paused");return this.toggleAttribute("paused",t),void this.dispatchEvent(new CustomEvent(t?"contour:pause":"contour:play",{bubbles:!0,composed:!0}))}const r=t.target&&t.target.closest?t.target.closest(".c-carousel__prev"):null,i=t.target&&t.target.closest?t.target.closest(".c-carousel__next"):null;if(r&&this.contains(r))return void s("prev");if(i&&this.contains(i))return void s("next");const a=t.target&&t.target.closest?t.target.closest(".c-carousel__dot"):null;if(a&&this.contains(a)){const t=Number(a.dataset.index);Number.isFinite(t)&&t!==this._index()&&(this.setAttribute("index",String(t)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:t,direction:"jump"}})))}});let r=null;this.addEventListener("pointerdown",t=>{r=t.clientX}),this.addEventListener("pointerup",t=>{if(null===r)return;const e=t.clientX-r;r=null,Math.abs(e)>40&&s(e<0?"next":"prev")}),this.addEventListener("pointercancel",()=>{r=null}),this.addEventListener("keydown",t=>{if("ArrowLeft"===t.key)t.preventDefault(),s("prev");else if("ArrowRight"===t.key)t.preventDefault(),s("next");else if("Home"===t.key)t.preventDefault(),this.setAttribute("index","0"),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:0,direction:"home"}}));else if("End"===t.key){t.preventDefault();const e=this._items().length-1;e>=0&&(this.setAttribute("index",String(e)),this.dispatchEvent(new CustomEvent("contour:change",{bubbles:!0,composed:!0,detail:{index:e,direction:"end"}})))}})}}define("contour-carousel",ContourCarousel);class ContourDataGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["columns","rows","page","filter","page-size","resizable","virtual","row-height","selected","loading","error","empty"]}static get properties(){return{columns:{attribute:"columns"},rows:{attribute:"rows"},page:{attribute:"page"},filter:{attribute:"filter"},"page-size":{attribute:"page-size"},resizable:{attribute:"resizable",type:Boolean},virtual:{attribute:"virtual",type:Boolean},"row-height":{attribute:"row-height"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}get selected(){return Array.from(this._dgSelectedKeys||[])}set selected(t){this._dgPushedSelection=Array.isArray(t)?t.map(String):[],this._dgSelectionControlled=!0,this.requestRender()}_dgRowKey(t){if(t&&"object"==typeof t&&!Array.isArray(t)){if(void 0!==t.id&&null!==t.id)return String(t.id);if(void 0!==t.key&&null!==t.key)return String(t.key)}const e=this._dgCols||[],s=e.findIndex(t=>t&&"object"==typeof t&&!0===t.key);if(s>=0&&t){const r="string"==typeof e[s].label?e[s].label:"",i=r&&null!=t[r]?String(t[r]):"";if(""!==i)return i}return JSON.stringify(void 0===t?null:t)}_dgReadSelection(){if(this._dgPushedSelection)return void(this._dgSelectedKeys=new Set(this._dgPushedSelection));const t=this.getAttribute("selected");if(null!==t&&t!==this._dgLastSelectedRaw){this._dgLastSelectedRaw=t,this._dgSelectionControlled=!0;try{const e=JSON.parse(t);this._dgSelectedKeys=new Set(Array.isArray(e)?e.map(String):[])}catch(t){this._dgSelectedKeys=new Set}}else this._dgSelectedKeys=this._dgSelectedKeys||new Set}_dgApplySelection(t){if(!t)return;const e=this._dgSelectedKeys||new Set;t.querySelectorAll("tr[data-row-key]").forEach(t=>{t.setAttribute("aria-selected",String(e.has(t.dataset.rowKey)))})}render(){if(this.classList.add("c-data-grid"),this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const t=this.ensure(".c-data-grid__table",()=>{const t=document.createElement("table");return t.className="c-table c-data-grid__table",t.setAttribute("role","grid"),t}),e=this.ensure("tbody",()=>document.createElement("tbody"));e.parentNode!==t&&t.appendChild(e),setHTML(e,"");const s=document.createElement("tr"),r=document.createElement("td");r.colSpan=1,r.style.textAlign="center",r.style.color="var(--color-text-muted)",this.hasAttribute("loading")?r.textContent=this.getAttribute("loading")||"Loading…":this.hasAttribute("error")?r.textContent=this.getAttribute("error")||"Error":r.textContent=this.getAttribute("empty")||"No data",s.appendChild(r),e.appendChild(s);let i=this.querySelector(".c-data-grid__wrap");return i||(i=document.createElement("div"),i.className="c-table-wrap c-data-grid__wrap"),t.parentNode!==i&&i.appendChild(t),void(i.parentNode!==this&&this.appendChild(i))}const t=this.ensure(".c-data-grid__table",()=>{const t=document.createElement("table");return t.className="c-table c-data-grid__table",t.setAttribute("role","grid"),t}),e=this.ensure("thead",()=>document.createElement("thead")),s=this.ensure("tbody",()=>document.createElement("tbody"));e.parentNode!==t&&t.appendChild(e),s.parentNode!==t&&t.appendChild(s);const r=this.getAttribute("columns");let i=[];try{i=r?JSON.parse(r):[]}catch(t){i=[]}if(i.length&&!e.querySelector("tr")){const t=document.createElement("tr");i.forEach(e=>{const s=document.createElement("th");s.setAttribute("role","columnheader"),s.setAttribute("aria-sort","none"),s.setAttribute("tabindex","0"),s.textContent="string"==typeof e?e:e.label||e.key||"",t.appendChild(s)}),e.appendChild(t)}this.hasAttribute("resizable")&&Array.from(e.querySelectorAll("th")).forEach(t=>{t.style.position="relative",t.setAttribute("data-resizable","true")});const a=this.getAttribute("rows");let n=[];try{n=a?JSON.parse(a):[]}catch(t){n=[]}t.setAttribute("aria-rowcount",String(n.length)),t.setAttribute("aria-colcount",String(i.length));const o=this.getAttribute("filter");if(o){const t=o.toLowerCase();n=n.filter(e=>JSON.stringify(e).toLowerCase().includes(t))}if(null!=this._dgSortCol&&this._dgSortCol>=0&&this._dgSortCol<i.length){const t=this._dgSortCol,s=this._dgSortDir||"asc",r=i[t],a=r?"string"==typeof r?r:r.key||r.label||"":String(t);n=n.slice().sort((e,r)=>{const i=Array.isArray(e)?e[t]??"":e&&null!=e[a]?e[a]:"",n=Array.isArray(r)?r[t]??"":r&&null!=r[a]?r[a]:"",o=Number(i),l=Number(n),c=""===i||""===n||isNaN(o)||isNaN(l)?String(i).localeCompare(String(n)):o-l;return"asc"===s?c:-c}),Array.from(e.querySelectorAll("th")).forEach((e,r)=>{e.setAttribute("aria-sort",r===t?"asc"===s?"ascending":"descending":"none")})}this._dgFilteredRows=n;const l=Number(this.getAttribute("page")||1),c=Number(this.getAttribute("page-size")||0);if(c>0){const t=(l-1)*c;n=n.slice(t,t+c)}this._dgCols=i,this._dgRows=n,this._dgReadSelection();if(this.hasAttribute("virtual")&&!(Number(this.getAttribute("page-size"))>0)){const t=this.querySelector(".c-data-grid__wrap");this._renderDataGridWindow(t?t.scrollTop:0)}else{setHTML(s,"");const t=c>0?(l-1)*c:0;n.forEach((e,r)=>{const a=document.createElement("tr");a.dataset.rowKey=this._dgRowKey(e),a.dataset.index=String(t+r),i.forEach((t,s)=>{const r="string"==typeof t?t:t.key||t.label||"",i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1");const n=Array.isArray(e)?e[s]:e?e[r]:void 0;i.textContent=null!=n?n:"",String(i.textContent).trim()||i.setAttribute("aria-label",labelText(this,"empty","Empty")),a.appendChild(i)}),s.appendChild(a)}),this._dgApplySelection(s)}let u=this.querySelector(".c-data-grid__wrap");if(u||(u=document.createElement("div"),u.className="c-table-wrap c-data-grid__wrap"),t.parentNode!==u&&u.appendChild(t),u.parentNode!==this&&this.appendChild(u),!t.querySelector('[tabindex="0"]')){const e=t.querySelector("tbody td, thead th");e&&e.setAttribute("tabindex","0")}}_rowHeight(){const t=Number(this.getAttribute("row-height"));return Number.isFinite(t)&&t>0?t:this._measuredRowHeight>0?this._measuredRowHeight:cssLength("--data-grid-row-height",32)}_renderDataGridWindow(t){const e=this.querySelector(".c-data-grid__table"),s=e&&e.querySelector("tbody");if(!s)return;const r=this._dgCols||[],i=this._dgRows||[],a=this._rowHeight(),n=Math.ceil(400/a)+6;let o=Math.floor((t||0)/a);o<0&&(o=0),o>Math.max(0,i.length-n)&&(o=Math.max(0,i.length-n));const l=Math.min(i.length,o+n);if(setHTML(s,""),o>0){const t=document.createElement("tr"),e=document.createElement("td");e.colSpan=Math.max(1,r.length),e.style.blockSize=o*a+"px",e.style.padding="0",t.appendChild(e),s.appendChild(t)}for(let t=o;t<l;t++){const e=i[t],a=document.createElement("tr");a.dataset.index=String(t),a.dataset.rowKey=this._dgRowKey(e),r.forEach((t,s)=>{const r="string"==typeof t?t:t.key||t.label||"",i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("tabindex","-1");const n=Array.isArray(e)?e[s]:e?e[r]:void 0;i.textContent=null!=n?n:"",String(i.textContent).trim()||i.setAttribute("aria-label",labelText(this,"empty","Empty")),a.appendChild(i)}),s.appendChild(a)}if(l<i.length){const t=document.createElement("tr"),e=document.createElement("td");e.colSpan=Math.max(1,r.length),e.style.blockSize=(i.length-l)*a+"px",e.style.padding="0",t.appendChild(e),s.appendChild(t)}if(!s.querySelector('[tabindex="0"]')){const t=s.querySelector("tr[data-index] td");t&&t.setAttribute("tabindex","0")}this._dgApplySelection(s)}enhance(){if(this._wiredDataGrid)return;this._wiredDataGrid=!0;const t=()=>this.querySelector(".c-data-grid__wrap");this.addEventListener("scroll",t=>{const e=t.target&&t.target.classList&&t.target.classList.contains("c-data-grid__wrap")?t.target:null;e&&this.hasAttribute("virtual")&&this._renderDataGridWindow(e.scrollTop)},!0),this.addEventListener("keydown",t=>{const e=t.target&&t.target.closest?t.target.closest("[role='gridcell'], [role='columnheader']"):null;if(!e||!this.contains(e))return;const s=e.parentElement,r=this.querySelector(".c-data-grid__table");if(!r)return;if(t.altKey&&("ArrowLeft"===t.key||"ArrowRight"===t.key)&&e.hasAttribute("data-resizable")){t.preventDefault();const i=Array.from(s.children).indexOf(e),a=e.getBoundingClientRect().width||100,n=Math.max(48,a+("ArrowRight"===t.key?16:-16));return Array.from(r.rows).forEach(t=>{t.children[i]&&(t.children[i].style.inlineSize=n+"px")}),void this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{column:i,width:n}}))}if("Enter"===t.key||" "===t.key)return t.preventDefault(),void("columnheader"===e.getAttribute("role")?e.click():s&&s.click());const i=Array.from(r.querySelectorAll("tr")),a=i.indexOf(s),n=Array.from(s.children).indexOf(e);let o=null;if("ArrowRight"===t.key?o=s.children[n+1]:"ArrowLeft"===t.key?o=s.children[n-1]:"ArrowDown"===t.key?o=i[a+1]&&i[a+1].children[n]:"ArrowUp"===t.key&&(o=i[a-1]&&i[a-1].children[n]),o){t.preventDefault(),r.querySelectorAll('[tabindex="0"]').forEach(t=>t.setAttribute("tabindex","-1")),o.setAttribute("tabindex","0");try{o.focus()}catch(t){}}}),this.addEventListener("click",e=>{const s=e.target&&e.target.closest?e.target.closest("tr"):null,r=e.target&&e.target.closest?e.target.closest("th"):null;if(s&&this.contains(s)&&!r&&void 0!==s.dataset.rowKey){const t=s.dataset.rowKey,e=Number(s.dataset.index),r=this._dgSelectedKeys||(this._dgSelectedKeys=new Set);r.has(t)?r.delete(t):r.add(t),this._dgApplySelection(s.parentElement),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{row:e,key:t,index:e}}))}if(r&&this.contains(r)){const e=Array.from(r.parentElement.children).indexOf(r);this._dgSortCol===e?this._dgSortDir="asc"===this._dgSortDir?"desc":"asc":(this._dgSortCol=e,this._dgSortDir="asc");const s=this._dgSortDir,i=this.querySelector(".c-data-grid__table"),a=i&&i.querySelector("tbody"),n=i&&i.querySelector("thead"),o=this._dgCols||[],l=o[e]?"string"==typeof o[e]?o[e]:o[e].key||o[e].label||"":String(e),c=(this._dgFilteredRows||[]).slice();if(c.sort((t,r)=>{const i=Array.isArray(t)?t[e]??"":t&&null!=t[l]?t[l]:"",a=Array.isArray(r)?r[e]??"":r&&null!=r[l]?r[l]:"",n=Number(i),o=Number(a),c=""===i||""===a||isNaN(n)||isNaN(o)?String(i).localeCompare(String(a)):n-o;return"asc"===s?c:-c}),this._dgFilteredRows=c,!this.hasAttribute("virtual")||Number(this.getAttribute("page-size"))>0){if(a){const t=Number(this.getAttribute("page")||1),e=Number(this.getAttribute("page-size")||0);let s=c;if(e>0){const r=(t-1)*e;s=c.slice(r,r+e)}setHTML(a,"");const r=e>0?(t-1)*e:0;s.forEach((t,e)=>{const s=document.createElement("tr");s.dataset.rowKey=this._dgRowKey(t),s.dataset.index=String(r+e),o.forEach((e,r)=>{const i="string"==typeof e?e:e.key||e.label||"",a=document.createElement("td");a.setAttribute("role","gridcell"),a.setAttribute("tabindex","-1");const n=Array.isArray(t)?t[r]:t?t[i]:void 0;a.textContent=null!=n?n:"",s.appendChild(a)}),a.appendChild(s)}),this._dgApplySelection(a)}}else{this._dgRows=c;const e=t();this._renderDataGridWindow(e?e.scrollTop:0)}n&&Array.from(n.querySelectorAll("th")).forEach((t,r)=>{t.setAttribute("aria-sort",r===e?"asc"===s?"ascending":"descending":"none")}),this.dispatchEvent(new CustomEvent("contour:sort",{bubbles:!0,composed:!0,detail:{column:e,direction:s}}))}}),this.addEventListener("pointerdown",t=>{if(!this.hasAttribute("resizable"))return;const e=t.target&&t.target.closest?t.target.closest("th[data-resizable]"):null;if(!e||!this.contains(e)||e.getBoundingClientRect().right-t.clientX>10)return;t.preventDefault();const s=t.clientX,r=e.getBoundingClientRect().width,i=Array.from(e.parentElement.children).indexOf(e);let a=r;const n=t=>{a=Math.max(48,r+t.clientX-s);const e=this.querySelector(".c-data-grid__table");e&&Array.from(e.rows).forEach(t=>{t.children[i]&&(t.children[i].style.inlineSize=a+"px")})},o=()=>{window.removeEventListener("pointermove",n),this.dispatchEvent(new CustomEvent("contour:resize",{bubbles:!0,composed:!0,detail:{column:i,width:a}}))};window.addEventListener("pointermove",n),window.addEventListener("pointerup",o,{once:!0}),onDispose(this,o)}),this._dgApplySelection(this.querySelector(".c-data-grid__table tbody"))}}define("contour-data-grid",ContourDataGrid);class ContourTreeGrid extends ContourBase{static get updateMode(){return"keyed"}static get observed(){return["items","rows","expanded","loading","error","empty"]}static get properties(){return{items:{attribute:"items"},rows:{attribute:"rows"},expanded:{attribute:"expanded"},loading:{attribute:"loading"},error:{attribute:"error"},empty:{attribute:"empty"}}}_expandedSet(){const t=this.getAttribute("expanded");if(!t)return new Set;try{return new Set(JSON.parse(t))}catch(e){return new Set([t])}}render(){this.classList.add("c-tree-grid");const t=this.ensure(".c-tree-grid__table",()=>{const t=document.createElement("table");return t.className="c-table c-tree-grid__table",t.setAttribute("role","treegrid"),t});t.setAttribute("aria-label",labelText(this,"tree-grid","Tree grid"));const e=this.ensure("tbody",()=>document.createElement("tbody"));if(e.parentNode!==t&&t.appendChild(e),setHTML(e,""),this.hasAttribute("loading")||this.hasAttribute("error")||this.hasAttribute("empty")){const t=document.createElement("tr"),s=document.createElement("td");s.style.textAlign="center",s.style.color="var(--color-text-muted)",this.hasAttribute("loading")?s.textContent=this.getAttribute("loading")||"Loading…":this.hasAttribute("error")?s.textContent=this.getAttribute("error")||"Error":s.textContent=this.getAttribute("empty")||"No data",t.appendChild(s),e.appendChild(t)}else{const t=this.getAttribute("items")||this.getAttribute("rows");let s=[];try{s=t?JSON.parse(t):[]}catch(t){s=[]}Array.isArray(s)||(s=[]);const r=this._expandedSet(),i=[],a=(t,s,n,o,l)=>{const c=document.createElement("tr");c.setAttribute("role","row"),c.setAttribute("tabindex",0===i.length?"0":"-1"),c.setAttribute("aria-level",String(s+1)),c.setAttribute("aria-posinset",String(o)),c.setAttribute("aria-setsize",String(l)),c.dataset.path=n,this._tgSelectedPath===n&&c.setAttribute("aria-selected","true");const u=!!(t&&Array.isArray(t.children)&&t.children.length);u&&c.setAttribute("aria-expanded",r.has(n)?"true":"false");const d=document.createElement("td");d.setAttribute("role","gridcell"),d.style.setProperty("--tree-depth",String(s));const h=t&&(t.label||t.text||t.name)||"";if(u){const t=document.createElement("button");t.type="button",t.className="c-tree-grid__toggle",t.tabIndex=-1,t.textContent=r.has(n)?"▾":"▸",t.setAttribute("aria-label",(r.has(n)?"Collapse":"Expand")+" "+h),d.appendChild(t)}const p=document.createElement("span");p.className="c-tree-grid__label",p.textContent=h,d.appendChild(p),c.appendChild(d),e.appendChild(c),i.push(c),u&&r.has(n)&&t.children.forEach((e,r)=>a(e,s+1,n+"."+r,r+1,t.children.length))};s.forEach((t,e)=>a(t,0,String(e),e+1,s.length))}let s=this.querySelector(".c-tree-grid__wrap");s||(s=document.createElement("div"),s.className="c-table-wrap c-tree-grid__wrap"),t.parentNode!==s&&s.appendChild(t),s.parentNode!==this&&this.appendChild(s)}enhance(){if(this._wiredTreeGrid)return;this._wiredTreeGrid=!0;const t=()=>Array.from(this.querySelectorAll("tr[role='row']")),e=e=>{if(e){t().forEach(t=>t.setAttribute("tabindex",t===e?"0":"-1"));try{e.focus()}catch(t){}}};this.addEventListener("click",s=>{const r=s.target&&s.target.closest?s.target.closest(".c-tree-grid__toggle"):null,i=s.target&&s.target.closest?s.target.closest("tr[role='row']"):null;if(!i||!this.contains(i))return;const a=i.dataset.path;if(e(i),r){s.preventDefault();const t=this._expandedSet();t.has(a)?t.delete(a):t.add(a),this.setAttribute("expanded",JSON.stringify([...t])),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{path:a,expanded:t.has(a)}}))}else this._tgSelectedPath=a,t().forEach(t=>t.setAttribute("aria-selected",String(t===i))),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{path:a}}))}),this.addEventListener("keydown",s=>{const r=s.target&&s.target.closest?s.target.closest("tr[role='row']"):null;if(!r||!this.contains(r))return;const i=t(),a=i.indexOf(r),n=r.dataset.path||"",o=null!==r.getAttribute("aria-expanded"),l=this._expandedSet();if("ArrowRight"===s.key)s.preventDefault(),o&&!l.has(n)?(l.add(n),this.setAttribute("expanded",JSON.stringify([...l])),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{path:n,expanded:!0}}))):o&&l.has(n)&&i[a+1]&&e(i[a+1]);else if("ArrowLeft"===s.key){if(s.preventDefault(),o&&l.has(n))l.delete(n),this.setAttribute("expanded",JSON.stringify([...l])),this.dispatchEvent(new CustomEvent("contour:toggle",{bubbles:!0,composed:!0,detail:{path:n,expanded:!1}}));else if(n.includes(".")){const t=n.slice(0,n.lastIndexOf(".")),s=i.find(e=>e.dataset.path===t);s&&e(s)}}else if("ArrowDown"===s.key)s.preventDefault(),i[a+1]&&e(i[a+1]);else if("ArrowUp"===s.key)s.preventDefault(),i[a-1]&&e(i[a-1]);else if("Enter"===s.key||" "===s.key){s.preventDefault();const t=r.querySelector(".c-tree-grid__toggle");"Enter"===s.key&&t?t.click():(this._tgSelectedPath=n,i.forEach(t=>t.setAttribute("aria-selected",String(t===r))),this.dispatchEvent(new CustomEvent("contour:select",{bubbles:!0,composed:!0,detail:{path:n}})))}})}}define("contour-tree-grid",ContourTreeGrid);