contour-ds 1.7.2 → 1.8.1

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 (109) hide show
  1. package/README.md +80 -11
  2. package/dist/agent-rules.json +16 -0
  3. package/dist/build-manifest.json +181 -104
  4. package/dist/contour-wc-content.esm.js +5125 -0
  5. package/dist/contour-wc-content.esm.min.js +1 -0
  6. package/dist/contour-wc-dashboard.esm.js +8654 -0
  7. package/dist/contour-wc-dashboard.esm.min.js +1 -0
  8. package/dist/contour-wc-data.esm.js +8260 -0
  9. package/dist/contour-wc-data.esm.min.js +1 -0
  10. package/dist/contour-wc-docs.esm.js +4305 -0
  11. package/dist/contour-wc-docs.esm.min.js +1 -0
  12. package/dist/contour-wc-feedback.esm.js +4917 -0
  13. package/dist/contour-wc-feedback.esm.min.js +1 -0
  14. package/dist/contour-wc-forms.esm.js +5688 -0
  15. package/dist/contour-wc-forms.esm.min.js +1 -0
  16. package/dist/contour-wc-interaction.esm.js +4580 -0
  17. package/dist/contour-wc-interaction.esm.min.js +1 -0
  18. package/dist/contour-wc-layout.esm.js +4174 -0
  19. package/dist/contour-wc-layout.esm.min.js +1 -0
  20. package/dist/contour-wc-map.esm.js +5205 -0
  21. package/dist/contour-wc-map.esm.min.js +1 -0
  22. package/dist/contour-wc-misc.esm.js +4264 -0
  23. package/dist/contour-wc-misc.esm.min.js +1 -0
  24. package/dist/contour-wc-navigation.esm.js +5844 -0
  25. package/dist/contour-wc-navigation.esm.min.js +1 -0
  26. package/dist/contour-wc-ui.esm.js +9009 -0
  27. package/dist/contour-wc-ui.esm.min.js +1 -0
  28. package/dist/contour-wc.esm.js +6109 -1641
  29. package/dist/contour-wc.esm.min.js +1 -1
  30. package/dist/contour-wc.js +6108 -1641
  31. package/dist/contour-wc.min.js +1 -1
  32. package/dist/contour.code-snippets +4512 -0
  33. package/dist/contour.components.json +2597 -799
  34. package/dist/contour.css +5275 -4050
  35. package/dist/contour.d.ts +560 -1085
  36. package/dist/contour.esm.js +7 -0
  37. package/dist/contour.esm.min.js +1 -1
  38. package/dist/contour.html-data.json +10311 -0
  39. package/dist/contour.js +7 -0
  40. package/dist/contour.min.css +1 -1
  41. package/dist/contour.min.js +1 -1
  42. package/dist/contour.react.d.ts +420 -0
  43. package/dist/contour.single.html +17 -0
  44. package/dist/contour.single.min.css +1 -0
  45. package/dist/contour.tokens.json +940 -902
  46. package/dist/contour.vue.d.ts +418 -0
  47. package/dist/contour.web-types.json +10703 -0
  48. package/dist/custom-elements.json +30708 -0
  49. package/dist/docs/actions.md +3 -2
  50. package/dist/docs/affordances.md +23 -9
  51. package/dist/docs/apireference.md +1 -1
  52. package/dist/docs/colour.md +1 -1
  53. package/dist/docs/componentindex.md +6 -2
  54. package/dist/docs/data.md +7 -2
  55. package/dist/docs/docs.md +9 -2
  56. package/dist/docs/feedback.md +1 -1
  57. package/dist/docs/field.md +1 -1
  58. package/dist/docs/forms.md +1 -1
  59. package/dist/docs/index.json +22 -20
  60. package/dist/docs/install.md +1 -1
  61. package/dist/docs/landing.md +1 -1
  62. package/dist/docs/mapengine.md +19 -2
  63. package/dist/docs/motion.md +1 -1
  64. package/dist/docs/navigation.md +1 -1
  65. package/dist/docs/overlays.md +1 -1
  66. package/dist/docs/overview.md +1 -1
  67. package/dist/docs/patterns.md +2 -2
  68. package/dist/docs/playground.md +22 -2
  69. package/dist/docs/principles.md +1 -1
  70. package/dist/docs/recipes.md +13 -8
  71. package/dist/docs/space.md +1 -1
  72. package/dist/docs/status.md +14 -2
  73. package/dist/docs/surfaces.md +1 -1
  74. package/dist/docs/theming.md +1 -1
  75. package/dist/docs/type.md +1 -1
  76. package/dist/docs/webcomponents.md +17 -3
  77. package/dist/registry/items/contour-core.json +2 -2
  78. package/dist/registry/items/contour-data.json +2 -2
  79. package/dist/registry/items/contour-docs.json +2 -2
  80. package/dist/registry/items/contour-landing.json +2 -2
  81. package/dist/registry/registry.json +8 -8
  82. package/dist/surfaces/contour-core.min.css +1 -1
  83. package/dist/surfaces/contour-data.min.css +1 -1
  84. package/dist/surfaces/contour-docs.min.css +1 -1
  85. package/dist/surfaces/contour-landing.min.css +1 -1
  86. package/dist/wc/behaviours.mjs +45 -57
  87. package/dist/wc/content.mjs +263 -63
  88. package/dist/wc/core.mjs +390 -71
  89. package/dist/wc/dashboard.mjs +220 -13
  90. package/dist/wc/data.mjs +1075 -460
  91. package/dist/wc/docs.mjs +105 -12
  92. package/dist/wc/feedback.mjs +63 -14
  93. package/dist/wc/forms.mjs +733 -104
  94. package/dist/wc/index.mjs +9 -2
  95. package/dist/wc/interaction.mjs +182 -28
  96. package/dist/wc/layout.mjs +95 -25
  97. package/dist/wc/map.mjs +185 -118
  98. package/dist/wc/misc.mjs +124 -24
  99. package/dist/wc/navigation.mjs +384 -115
  100. package/dist/wc/shadow.mjs +94 -18
  101. package/dist/wc/states.mjs +21 -3
  102. package/dist/wc/svg.mjs +104 -0
  103. package/dist/wc/ui.mjs +1988 -476
  104. package/integrations/README.md +2 -0
  105. package/integrations/ai/CLAUDE.md +3 -3
  106. package/integrations/frameworks/README.md +235 -0
  107. package/integrations/native/style-dictionary.config.json +1 -1
  108. package/integrations/tailwind/contour-theme.css +5 -6
  109. package/package.json +53 -24
@@ -0,0 +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};const splitCodeLines=(code)=>{const lines=[];let line=null;const add=(n)=>{if(!line){line=document.createElement("span");line.className="c-code__line";lines.push(line)}line.appendChild(n)};Array.from(code.childNodes).forEach((n)=>{if(n.nodeType!==3){add(n);return}String(n.textContent||"").split("\n").forEach((p,i)=>{if(i)line=null;if(p)add(document.createTextNode(p))})});const last=lines[lines.length-1];if(last&&!last.textContent&&lines.length>1)lines.pop();if(!lines.length)return;const frag=document.createDocumentFragment();lines.forEach((l,i)=>{const num=document.createElement("span");num.className="c-code__line-number";num.setAttribute("aria-hidden","true");num.textContent=String(i+1);l.prepend(num);frag.appendChild(l)});code.textContent="";code.appendChild(frag)};const joinCodeLines=(code)=>{const frag=document.createDocumentFragment();Array.from(code.querySelectorAll(".c-code__line")).forEach((l)=>{Array.from(l.childNodes).forEach((n)=>{if(n.classList&&n.classList.contains("c-code__line-number"))return;frag.appendChild(n)});frag.appendChild(document.createTextNode("\n"))});code.textContent="";code.appendChild(frag)};class ContourCard extends ContourBase{static get observed(){return["title","variant","heading"]}static get properties(){return{title:{attribute:"title"},variant:{attribute:"variant"}}}render(){this.classList.add("c-card");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-card--"))this.classList.remove(c)});if(variant)this.classList.add("c-card--"+variant);const title=this.getAttribute("title");if(title){const h=this.ensure(".c-card__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-card__title";return el});if(h.parentNode===this&&this.firstChild!==h)this.prepend(h);h.textContent=title}else{const h=this.querySelector(".c-card__title");if(h)h.remove()}}}define("contour-card",ContourCard);class ContourFeature extends ContourBase{static get observed(){return["index","title","body","heading"]}static get properties(){return{index:{attribute:"index"},title:{attribute:"title"},body:{attribute:"body"}}}render(){this.classList.add("c-feature");const index=this.getAttribute("index");const title=this.getAttribute("title");const body=this.getAttribute("body");if(index){const x=this.ensure(".c-feature__index",()=>{const el=document.createElement("span");el.className="c-feature__index";return el});x.textContent=index}else{const x=this.querySelector(".c-feature__index");if(x)x.remove()}if(title){const t=this.ensure(".c-feature__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-feature__title";return el});t.textContent=title}else{const t=this.querySelector(".c-feature__title");if(t)t.remove()}if(body){const b=this.ensure(".c-feature__body",()=>{const el=document.createElement("p");el.className="c-feature__body";return el});b.textContent=body}else{const b=this.querySelector(".c-feature__body");if(b)b.remove()}}}define("contour-feature",ContourFeature);class ContourSteps extends ContourBase{static get observed(){return["steps","current","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading"]}static get properties(){return{steps:{attribute:"steps"},current:{attribute:"current",type:Number},src:{attribute:"src"}}}render(){this.classList.add("c-steps");let list=this.querySelector(".c-steps__list");if(!list){list=document.createElement("ol");list.className="c-steps__list";list.setAttribute("aria-label",this.getAttribute("aria-label")||"Steps");this.appendChild(list)}wireStates(this);loadRemote(this,"steps");if(renderStates(this,"steps"))return;const steps=remoteData(this,"steps");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-steps__item"));if(steps&&!authored.length){Array.from(list.querySelectorAll(".c-steps__item")).forEach((n)=>n.remove());try{const parsed=JSON.parse(steps);parsed.forEach((st,i)=>{const item=document.createElement("li");item.className="c-steps__item";item.tabIndex=-1;const title=typeof st==="string"?st:st.title;const body=typeof st==="string"?"":st.body;if(title){const h=document.createElement(headingTag(this,"h3"));h.className="c-steps__title";h.textContent=title;item.appendChild(h)}if(body){const p=document.createElement("p");p.className="c-steps__body";p.textContent=body;item.appendChild(p)}list.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!steps&&!authored.length){renderEmpty(this,"steps")}const attrCurrent=this.getAttribute("current");const current=(this._current!=null)?this._current:(attrCurrent!=null?parseInt(attrCurrent,10):NaN);const items=Array.from(this.querySelectorAll(".c-steps__item"));items.forEach((it,i)=>{if(Number.isFinite(current)&&i===current)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=(Number.isFinite(current)&&i===current)?0:-1});if(items.length&&!Number.isFinite(current)){items[0].tabIndex=0}}enhance(){if(!this._wiredSteps){this._wiredSteps=true;this.addEventListener("keydown",(e)=>{const items=Array.from(this.querySelectorAll(".c-steps__item"));if(!items.length)return;navKey(e,items,{wrap:false,homeEnd:true,rtl:isRtl(this),onNavigate:(i)=>{this._current=i;items.forEach((it,j)=>{it.setAttribute("aria-current",j===i?"step":"");it.tabIndex=j===i?0:-1});const title=items[i].querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-change",{bubbles:true,composed:true,detail:{index:i,title}}))},onKey:()=>{if(e.key==="Enter"||e.key===" "){const idx=items.indexOf(document.activeElement);const title=document.activeElement.querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:true,composed:true,detail:{index:idx,title}}))}}})});this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-steps__item"):null;if(!item||!this.contains(item))return;const items=Array.from(this.querySelectorAll(".c-steps__item"));const idx=items.indexOf(item);if(idx<0)return;this._current=idx;items.forEach((it,i)=>{if(i===idx)it.setAttribute("aria-current","step");else it.removeAttribute("aria-current");it.tabIndex=i===idx?0:-1});const title=item.querySelector(".c-steps__title")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:step-activate",{bubbles:true,composed:true,detail:{index:idx,title}}))})}}}define("contour-steps",ContourSteps);class ContourLink extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-link");const href=this.getAttribute("href");const label=this.getAttribute("label");const prevLink=this.querySelector("a");if(prevLink)prevLink.remove();if(href&&label){const a=document.createElement("a");a.href=safeHref(href);a.textContent=label;const ariaLabel=this.getAttribute("aria-label");if(ariaLabel)a.setAttribute("aria-label",ariaLabel);this.appendChild(a)}}}define("contour-link",ContourLink);class ContourBrand extends ContourBase{static get observed(){return["name","tag"]}static get properties(){return{name:{attribute:"name"},tag:{attribute:"tag"}}}render(){this.classList.add("c-brand");const name=this.getAttribute("name");const tag=this.getAttribute("tag");if(name){const n=this.ensure(".c-brand__name",()=>{const el=document.createElement("span");el.className="c-brand__name";return el});n.textContent=name}else{const n=this.querySelector(".c-brand__name");if(n)n.remove()}if(tag){const t=this.ensure(".c-brand__tag",()=>{const el=document.createElement("span");el.className="c-brand__tag";return el});t.textContent=tag}else{const t=this.querySelector(".c-brand__tag");if(t)t.remove()}}}define("contour-brand",ContourBrand);class ContourSectionHead extends ContourBase{static get observed(){return["title","desc","heading"]}static get properties(){return{title:{attribute:"title"},desc:{attribute:"desc"}}}render(){this.classList.add("c-section-head");const title=this.getAttribute("title");const desc=this.getAttribute("desc");if(!this.querySelector(".c-icon-badge")){const badge=document.createElement("div");badge.className="c-icon-badge";const svg=document.createElementNS("http://www.w3.org/2000/svg","svg");svg.setAttribute("aria-hidden","true");const use=document.createElementNS("http://www.w3.org/2000/svg","use");use.setAttribute("href","#i-crosshair");svg.appendChild(use);badge.replaceChildren(svg);this.prepend(badge)}let content=this.querySelector(":scope > div:not(.c-icon-badge)");if(!content){content=document.createElement("div");this.appendChild(content)}if(title){const t=this.ensure(".c-section-head__title",()=>{const el=document.createElement(headingTag(this,"h2"));el.className="c-section-head__title";return el});t.textContent=title;if(t.parentNode!==content)content.appendChild(t)}else{const t=this.querySelector(".c-section-head__title");if(t)t.remove()}if(desc){const d=this.ensure(".c-section-head__desc",()=>{const el=document.createElement("p");el.className="c-section-head__desc";return el});d.textContent=desc;if(d.parentNode!==content)content.appendChild(d)}else{const d=this.querySelector(".c-section-head__desc");if(d)d.remove()}}}define("contour-section-head",ContourSectionHead);class ContourDiff extends ContourBase{static get observed(){return["before","after"]}static get properties(){return{before:{attribute:"before"},after:{attribute:"after"}}}render(){this.classList.add("c-diff");this.setAttribute("role","group");this.setAttribute("aria-label","Diff");Array.from(this.querySelectorAll(".c-diff__line")).forEach((n)=>n.remove());const line=(kind,sign,text)=>{const el=document.createElement("div");el.className=kind?`c-diff__line c-diff__line--${kind}`:"c-diff__line";el.setAttribute("role","listitem");el.setAttribute("tabindex","0");const s=document.createElement("span");s.className="c-diff__sign";s.textContent=sign;const code=document.createElement("span");code.textContent=text;el.append(s,code);return el};const before=this.getAttribute("before");const after=this.getAttribute("after");if(before)this.appendChild(line("del","−",before));if(after)this.appendChild(line("add","+",after))}enhance(){if(this._wiredDiff)return;this._wiredDiff=true;this.addEventListener("click",(e)=>{const line=e.target&&e.target.closest?e.target.closest(".c-diff__line"):null;if(line&&this.contains(line)){const kind=line.classList.contains("c-diff__line--add")?"add":line.classList.contains("c-diff__line--del")?"del":"context";const text=line.querySelector("span:last-child")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:diff-activate",{bubbles:true,composed:true,detail:{kind,text}}))}});this.addEventListener("keydown",(e)=>{const line=e.target&&e.target.closest?e.target.closest(".c-diff__line"):null;if(!line||!this.contains(line))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();line.click()}})}}define("contour-diff",ContourDiff);class ContourDoDont extends ContourBase{static get observed(){return["do","dont"]}static get properties(){return{do:{attribute:"do"},dont:{attribute:"dont"}}}render(){this.classList.add("c-do-dont");this.setAttribute("role","group");this.setAttribute("aria-label","Do and don't");Array.from(this.querySelectorAll(".c-do-dont__item")).forEach((n)=>n.remove());const item=(kind,word,text)=>{const el=document.createElement("div");el.className=`c-do-dont__item c-do-dont__item--${kind}`;el.setAttribute("role","listitem");const label=document.createElement("p");label.className="c-do-dont__label";label.textContent=word;const body=document.createElement("p");body.className="u-muted";body.textContent=text;el.append(label,body);return el};const doText=this.getAttribute("do");const dontText=this.getAttribute("dont");if(doText)this.appendChild(item("do","Do",doText));if(dontText)this.appendChild(item("dont","Don't",dontText))}enhance(){if(this._wiredDoDont)return;this._wiredDoDont=true;this.addEventListener("click",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-do-dont__item"):null;if(item&&this.contains(item)){const kind=item.classList.contains("c-do-dont__item--do")?"do":"dont";const text=item.querySelector(".u-muted")?.textContent||"";this.dispatchEvent(new CustomEvent("contour:do-dont-activate",{bubbles:true,composed:true,detail:{kind,text}}))}});Array.from(this.querySelectorAll(".c-do-dont__item")).forEach((it)=>{if(!it.hasAttribute("tabindex"))it.setAttribute("tabindex","0");if(!it.hasAttribute("role"))it.setAttribute("role","button")});this.addEventListener("keydown",(e)=>{const item=e.target&&e.target.closest?e.target.closest(".c-do-dont__item"):null;if(!item||!this.contains(item))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();item.click()}})}}define("contour-do-dont",ContourDoDont);class ContourFlag extends ContourBase{static get observed(){return["variant","label"]}static get properties(){return{variant:{attribute:"variant"},label:{attribute:"label"}}}render(){this.classList.add("c-flag");const variant=this.getAttribute("variant");Array.from(this.classList).forEach((c)=>{if(c.startsWith("c-flag--"))this.classList.remove(c)});if(variant)this.classList.add("c-flag--"+variant);const label=this.getAttribute("label");if(label){this.textContent=label}}}define("contour-flag",ContourFlag);class ContourInstallFull extends ContourBase{static get observed(){return["command","prompt","copyable"]}static get properties(){return{command:{attribute:"command"},prompt:{attribute:"prompt"},copyable:{attribute:"copyable"}}}render(){this.classList.add("c-install");const prompt=this.getAttribute("prompt")||"$";const command=this.getAttribute("command")||"";if(command){const p=this.ensure(".c-install__prompt",()=>{const el=document.createElement("span");el.className="c-install__prompt";return el});p.textContent=prompt;const c=this.ensure(".c-install__command",()=>{const el=document.createElement("span");el.className="c-install__command";return el});c.textContent=command;if(this.hasAttribute("copyable")){this.ensure(".c-install__copy",()=>{const btn=document.createElement("button");btn.className="c-btn c-btn--ghost c-btn--sm c-install__copy";btn.type="button";btn.setAttribute("aria-label",labelText(this,"copy-command","Copy command"));btn.textContent=labelText(this,"copy","Copy");return btn})}else{const btn=this.querySelector(".c-install__copy");if(btn)btn.remove()}}}enhance(){wireCopy(this)}}define("contour-install",ContourInstallFull);class ContourTestimonialFull extends ContourBase{static get observed(){return["quote","name","role"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"},role:{attribute:"role"}}}render(){this.classList.add("c-testimonial");const quote=this.getAttribute("quote");if(quote){const q=this.ensure(".c-testimonial__quote",()=>{const el=document.createElement("blockquote");el.className="c-testimonial__quote";return el});q.textContent=quote}else{const q=this.querySelector(".c-testimonial__quote");if(q)q.remove()}const name=this.getAttribute("name");const role=this.getAttribute("role");if(name){const by=this.ensure(".c-testimonial__byline",()=>{const el=document.createElement("figcaption");el.className="c-testimonial__byline";return el});const n=by.querySelector(".c-testimonial__name")||(()=>{const el=document.createElement("cite");el.className="c-testimonial__name";by.appendChild(el);return el})();n.className="c-testimonial__name";n.textContent=name;if(role){const r=by.querySelector(".c-testimonial__role")||(()=>{const el=document.createElement("span");el.className="c-testimonial__role";by.appendChild(el);return el})();r.className="c-testimonial__role";r.textContent=role}else{const r=by.querySelector(".c-testimonial__role");if(r)r.remove()}}else{const by=this.querySelector(".c-testimonial__byline");if(by)by.remove()}}}define("contour-testimonial",ContourTestimonialFull);class ContourShowcaseFull extends ContourBase{static get observed(){return["title","text","media","reverse","items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton","heading"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},media:{attribute:"media"},reverse:{attribute:"reverse"},items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-showcase");this.setAttribute("role","list");if(this.hasAttribute("reverse"))this.classList.add("c-showcase--reverse");else this.classList.remove("c-showcase--reverse");const title=this.getAttribute("title");if(title)this.setAttribute("aria-label",title);else this.removeAttribute("aria-label");this.setAttribute("role","region");wireStates(this);loadRemote(this,"items");if(renderStates(this,"showcase"))return;const items=remoteData(this,"items");const text=this.getAttribute("text");const media=this.getAttribute("media");if(media){const m=this.ensure(".c-showcase__media",()=>{const el=document.createElement("figure");el.className="c-showcase__media";return el});if(/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(media.trim())){let img=m.querySelector("img");if(!img){img=document.createElement("img");m.appendChild(img)}img.src=media.trim();img.alt=title||""}else{m.innerHTML=sanitizeHtml(media)}if(title){let cap=m.querySelector(".c-showcase__caption");if(!cap){cap=document.createElement("figcaption");cap.className="c-showcase__caption";m.appendChild(cap)}cap.textContent=title}}else{const m=this.querySelector(".c-showcase__media");if(m)m.remove()}if(title){const t=this.ensure(".c-showcase__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-showcase__title";return el});t.textContent=title}else{const t=this.querySelector(".c-showcase__title");if(t)t.remove()}if(text){const p=this.ensure(".c-showcase__text",()=>{const el=document.createElement("p");el.className="c-showcase__text";return el});p.textContent=text}else{const p=this.querySelector(".c-showcase__text");if(p)p.remove()}const ul=this.querySelector(".c-showcase__list");const authored=ul?Array.from(ul.children).filter((n)=>n.tagName==="LI"):[];if(items&&!authored.length){try{const parsed=JSON.parse(items);const l=this.ensure(".c-showcase__list",()=>{const el=document.createElement("ul");el.className="c-showcase__list";return el});l.replaceChildren();parsed.forEach((it)=>{const li=document.createElement("li");li.textContent=typeof it==="string"?it:(it.label||it.title||"");l.appendChild(li)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&!authored.length&&!title&&!text&&!media){renderEmpty(this,"showcase")}else if(!items&&ul){ul.remove()}}enhance(){if(this._wiredShowcase)return;this._wiredShowcase=true;this.addEventListener("click",(e)=>{const media=e.target&&e.target.closest?e.target.closest(".c-showcase__media"):null;if(media&&this.contains(media)){const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:showcase-activate",{bubbles:true,composed:true,detail:{title}}))}});this.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){const media=this.querySelector(".c-showcase__media");if(media){e.preventDefault();const title=this.getAttribute("title")||"";this.dispatchEvent(new CustomEvent("contour:showcase-activate",{bubbles:true,composed:true,detail:{title}}))}}})}}define("contour-showcase",ContourShowcaseFull);class ContourPricingFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-pricing")}}define("contour-pricing",ContourPricingFull);class ContourRecipeFull extends ContourBase{static get observed(){return["title","body","canvas","heading","url","tags","head","index"]}static get properties(){return{title:{attribute:"title"},body:{attribute:"body"},canvas:{attribute:"canvas"},url:{attribute:"url"},tags:{attribute:"tags"},head:{attribute:"head"},index:{attribute:"index"}}}render(){this.classList.add("c-recipe");const url=this.getAttribute("url");let frame=this.querySelector(".c-recipe__frame");if(url){if(!frame){frame=document.createElement("div");frame.className="c-recipe__frame";const bar=document.createElement("div");bar.className="c-recipe__frame-bar";for(let i=0;i<3;i++){const dot=document.createElement("span");dot.className="c-recipe__frame-dot";bar.appendChild(dot)}const urlEl=document.createElement("span");urlEl.className="c-recipe__frame-url";bar.appendChild(urlEl);frame.appendChild(bar);this.prepend(frame)}const urlEl=frame.querySelector(".c-recipe__frame-url");if(urlEl)urlEl.textContent=url}else if(frame){frame.remove()}const head=this.getAttribute("head");if(head){const h=this.ensure(".c-recipe__head",()=>{const el=document.createElement("div");el.className="c-recipe__head";return el});h.textContent=head}else{const h=this.querySelector(".c-recipe__head");if(h)h.remove()}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-recipe__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-recipe__title";return el});t.textContent=title}else{const t=this.querySelector(".c-recipe__title");if(t)t.remove()}const index=this.getAttribute("index");if(index){const idx=this.ensure(".c-recipe__index",()=>{const el=document.createElement("span");el.className="c-recipe__index";return el});idx.textContent=index}else{const idx=this.querySelector(".c-recipe__index");if(idx)idx.remove()}const body=this.getAttribute("body");if(body){const b=this.ensure(".c-recipe__desc",()=>{const el=document.createElement("p");el.className="c-recipe__desc";return el});b.textContent=body}else{const b=this.querySelector(".c-recipe__desc");if(b)b.remove()}const tags=this.getAttribute("tags");if(tags){const t=this.ensure(".c-recipe__tags",()=>{const el=document.createElement("div");el.className="c-recipe__tags";return el});t.innerHTML="";tags.split(",").map((s)=>s.trim()).filter(Boolean).forEach((tag)=>{const span=document.createElement("span");span.textContent=tag;t.appendChild(span)})}else{const t=this.querySelector(".c-recipe__tags");if(t)t.remove()}const canvas=this.getAttribute("canvas");if(canvas){const c=this.ensure(".c-recipe__canvas",()=>{const el=document.createElement("div");el.className="c-recipe__canvas";return el});if(/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(canvas.trim())){let img=c.querySelector("img");if(!img){img=document.createElement("img");c.appendChild(img)}img.src=canvas.trim();img.alt=""}else{c.innerHTML=sanitizeHtml(canvas)}}else{const c=this.querySelector(".c-recipe__canvas");if(c)c.remove()}}}define("contour-recipe",ContourRecipeFull);class ContourLogosFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-logos");if(!this.querySelector(".c-logos__item")){for(const name of["Cartolab","Nordwand"]){const span=document.createElement("span");span.className="c-logos__item";span.textContent=name;this.appendChild(span)}}}}define("contour-logos",ContourLogosFull);class ContourLandingFeaturesFull extends ContourBase{static get observed(){return["items","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{items:{attribute:"items"},src:{attribute:"src"}}}render(){this.classList.add("c-landing-features");wireStates(this);loadRemote(this,"items");if(renderStates(this,"landing-features"))return;const items=remoteData(this,"items");const authored=Array.from(this.children).filter((n)=>n.classList&&n.classList.contains("c-landing-features__item"));if(items&&!authored.length){try{const parsed=JSON.parse(items);this.querySelectorAll(".c-landing-features__item").forEach((el)=>el.remove());parsed.forEach((it)=>{const item=document.createElement("div");item.className="c-landing-features__item";if(it.icon){const ic=document.createElement("span");ic.className="c-landing-features__icon";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","#"+String(it.icon).replace(/[^a-zA-Z0-9_-]/g,""));svg.appendChild(use);ic.appendChild(svg);item.appendChild(ic)}if(it.title){const t=document.createElement("span");t.className="c-landing-features__title";t.textContent=it.title;item.appendChild(t)}if(it.text){const tx=document.createElement("p");tx.className="c-landing-features__text";tx.textContent=it.text;item.appendChild(tx)}this.appendChild(item)})}catch(e){warnBadJson(this,"attribute",e)}}else if(!items&&!authored.length){this.querySelectorAll(".c-landing-features__item").forEach((el)=>el.remove());renderEmpty(this,"landing-features")}}}define("contour-landing-features",ContourLandingFeaturesFull);class ContourLandingHeroFull extends ContourBase{static get observed(){return["actions","title","text","heading","preview"]}static get properties(){return{actions:{attribute:"actions"},title:{attribute:"title"},text:{attribute:"text"},preview:{attribute:"preview"}}}render(){this.classList.add("c-landing-hero");const preview=this.getAttribute("preview");let pv=this.querySelector(".c-landing-hero__preview");if(preview){if(!pv){pv=document.createElement("div");pv.className="c-landing-hero__preview";const bar=document.createElement("div");bar.className="c-landing-hero__preview-bar";for(let i=0;i<3;i++){const dot=document.createElement("span");dot.className="c-landing-hero__preview-dot";bar.appendChild(dot)}const body=document.createElement("div");body.className="c-landing-hero__preview-body";pv.appendChild(bar);pv.appendChild(body);this.appendChild(pv)}const body=pv.querySelector(".c-landing-hero__preview-body");if(body){if(/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(preview.trim())){body.innerHTML="";const img=document.createElement("img");img.src=preview.trim();img.alt="";body.appendChild(img)}else{body.innerHTML=sanitizeHtml(preview)}}}else if(pv){pv.remove()}const title=this.getAttribute("title");if(title){const t=this.ensure(".c-landing-hero__title",()=>{const el=document.createElement(headingTag(this,"h2"));el.className="c-landing-hero__title";return el});t.textContent=title}const text=this.getAttribute("text");if(text){const t=this.ensure(".c-landing-hero__text",()=>{const el=document.createElement("p");el.className="c-landing-hero__text";return el});t.textContent=text}const actions=this.getAttribute("actions");const a=this.querySelector(".c-landing-hero__actions");const authored=a?Array.from(a.children):[];if(actions&&!authored.length){const el=this.ensure(".c-landing-hero__actions",()=>{const e=document.createElement("div");e.className="c-landing-hero__actions";return e});try{const parsed=JSON.parse(actions);if(Array.isArray(parsed)){el.replaceChildren();parsed.forEach((act)=>{const btn=document.createElement(act.href?"a":"button");btn.className="c-btn"+(act.primary?" c-btn--primary":"");if(act.href)btn.href=safeHref(act.href);else btn.type="button";btn.textContent=act.label||act.text||"";el.appendChild(btn)})}else{el.innerHTML=sanitizeHtml(actions)}}catch(_){el.innerHTML=sanitizeHtml(actions)}}else if(!actions&&a&&!authored.length){a.remove()}}}define("contour-landing-hero",ContourLandingHeroFull);class ContourLinkishFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-linkish")}}define("contour-linkish",ContourLinkishFull);class ContourPriceFull extends ContourBase{static get observed(){return["value","format","locale"]}static get properties(){return{value:{attribute:"value"},format:{attribute:"format"},locale:{attribute:"locale"}}}render(){this.classList.add("c-price");const value=this.getAttribute("value");if(value)this.textContent=formatValue(value,this.getAttribute("format"),this.getAttribute("locale"))}}define("contour-price",ContourPriceFull);class ContourProseFull extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-prose")}}define("contour-prose",ContourProseFull);class ContourPanel extends ContourBase{static get observed(){return["title","subtitle","status","heading","collapsible","collapsed","flush"]}static get properties(){return{title:{attribute:"title"},subtitle:{attribute:"subtitle"},status:{attribute:"status"},collapsible:{attribute:"collapsible",type:Boolean},collapsed:{attribute:"collapsed",type:Boolean},flush:{attribute:"flush",type:Boolean}}}render(){this.classList.add("c-panel");if(!this.hasAttribute("role"))this.setAttribute("role","region");if(!this.hasAttribute("aria-label"))this.setAttribute("aria-label",this.getAttribute("title")||"Panel");const title=this.getAttribute("title");const subtitle=this.getAttribute("subtitle");const status=this.getAttribute("status");if(title){const h=this.ensure(".c-panel__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-panel__title";return el});if(h.parentNode===this&&this.firstChild!==h)this.prepend(h);h.textContent=title}else{const h=this.querySelector(".c-panel__title");if(h)h.remove()}if(subtitle){const sub=this.ensure(".c-panel__subtitle",()=>{const el=document.createElement("p");el.className="c-panel__subtitle";return el});sub.textContent=subtitle}else{const sub=this.querySelector(".c-panel__subtitle");if(sub)sub.remove()}if(status){const st=this.ensure(".c-panel__status",()=>{const el=document.createElement("span");el.className="c-panel__status";return el});Array.from(st.classList).forEach((c)=>{if(c.startsWith("c-panel__status--"))st.classList.remove(c)});if(status==="error"||status==="live")st.classList.add("c-panel__status--"+status);st.textContent=status}else{const st=this.querySelector(".c-panel__status");if(st)st.remove()}if(this.hasAttribute("collapsible")){let btn=this.querySelector(".c-panel__collapse");if(!btn){btn=document.createElement("button");btn.type="button";btn.className="c-panel__collapse c-btn c-btn--ghost c-btn--sm";btn.setAttribute("aria-label","Toggle panel");btn.textContent="▾";this.appendChild(btn)}if(this.hasAttribute("collapsed")){this.classList.add("c-panel--collapsed");btn.setAttribute("aria-expanded","false");btn.textContent="▸"}else{this.classList.remove("c-panel--collapsed");btn.setAttribute("aria-expanded","true");btn.textContent="▾"}}else{const btn=this.querySelector(".c-panel__collapse");if(btn)btn.remove();this.classList.remove("c-panel--collapsed")}const body=this.ensure(".c-panel__body",()=>{const el=document.createElement("div");el.className="c-panel__body";return el});body.classList.toggle("c-panel__body--flush",this.hasAttribute("flush"));const head=this.querySelector(".c-panel__head");Array.from(this.childNodes).forEach((n)=>{if(n===body||n===head)return;if(n.nodeType===1&&(n.classList.contains("c-panel__title")||n.classList.contains("c-panel__subtitle")||n.classList.contains("c-panel__status")))return;body.appendChild(n)});if(!body.parentNode)this.appendChild(body);if(head&&head.parentNode===this&&body.parentNode===this&&head.compareDocumentPosition(body)&Node.DOCUMENT_POSITION_PRECEDING){this.insertBefore(body,head.nextSibling)}}enhance(){if(this._wiredPanel)return;this._wiredPanel=true;this.addEventListener("click",(e)=>{const btn=e.target&&e.target.closest?e.target.closest(".c-panel__collapse"):null;if(!btn||!this.contains(btn))return;e.preventDefault();this.toggleAttribute("collapsed");this.dispatchEvent(new CustomEvent("contour:collapse",{bubbles:true,composed:true,detail:{collapsed:this.hasAttribute("collapsed")}}))})}}define("contour-panel",ContourPanel);class ContourCta extends ContourBase{static get observed(){return["title","text","actions","heading"]}static get properties(){return{title:{attribute:"title"},text:{attribute:"text"},actions:{attribute:"actions"}}}render(){this.classList.add("c-cta");const title=this.getAttribute("title");const text=this.getAttribute("text");if(title){const t=this.ensure(".c-cta__title",()=>{const el=document.createElement(headingTag(this,"h3"));el.className="c-cta__title";return el});t.textContent=title}else{const t=this.querySelector(".c-cta__title");if(t)t.remove()}if(text){const p=this.ensure(".c-cta__text",()=>{const el=document.createElement("p");el.className="c-cta__text";return el});p.textContent=text}else{const p=this.querySelector(".c-cta__text");if(p)p.remove()}const actions=this.getAttribute("actions");const prevWrap=this.querySelector(".c-cta__actions");if(prevWrap)prevWrap.remove();if(actions){try{const parsed=JSON.parse(actions);const wrap=document.createElement("div");wrap.className="c-cta__actions";parsed.forEach((a)=>{const btn=document.createElement("button");btn.className="c-btn c-btn--primary";btn.type="button";btn.textContent=typeof a==="string"?a:(a.label||a);wrap.appendChild(btn)});this.appendChild(wrap)}catch(e){warnBadJson(this,"attribute",e)}}}}define("contour-cta",ContourCta);class ContourCode extends ContourBase{static get observed(){return["title","copyable","numbered"]}static get properties(){return{title:{attribute:"title"},copyable:{attribute:"copyable",type:Boolean},numbered:{attribute:"numbered",type:Boolean}}}render(){this.classList.add("c-code");const title=this.getAttribute("title");if(title){const head=this.ensure(".c-code__head",()=>{const el=document.createElement("div");el.className="c-code__head";return el});if(head.parentNode===this&&this.firstChild!==head)this.prepend(head);const t=head.querySelector(".c-code__title")||(()=>{const el=document.createElement("div");el.className="c-code__title";head.appendChild(el);return el})();t.textContent=title}else{const head=this.querySelector(".c-code__head");if(head)head.remove();const t=this.querySelector(".c-code__title");if(t)t.remove()}if(this.hasAttribute("copyable")){this.ensure(".c-code__copy",()=>{const btn=document.createElement("button");btn.className="c-code__copy";btn.type="button";btn.textContent=labelText(this,"copy","Copy");return btn})}else{const btn=this.querySelector(".c-code__copy");if(btn)btn.remove()}const pre=this.ensure("pre",()=>{const el=document.createElement("pre");return el});Array.from(this.childNodes).forEach((n)=>{if(n===pre||(n.nodeType===1&&(n.classList.contains("c-code__head")||n.classList.contains("c-code__copy"))))return;pre.appendChild(n)});if(!pre.querySelector("code")){const code=document.createElement("code");while(pre.firstChild)code.appendChild(pre.firstChild);pre.appendChild(code)}if(pre.parentNode!==this)this.appendChild(pre);const head=this.querySelector(".c-code__head");if(head&&head.parentNode===this&&pre.parentNode===this&&head.compareDocumentPosition(pre)&Node.DOCUMENT_POSITION_PRECEDING){this.insertBefore(pre,head.nextSibling)}const numbered=this.hasAttribute("numbered");this.classList.toggle("c-code--numbered",numbered);const codeEl=pre.querySelector("code");if(codeEl){const split=codeEl.dataset.contourLines==="1";if(numbered&&!split){splitCodeLines(codeEl);codeEl.dataset.contourLines="1"}else if(!numbered&&split){joinCodeLines(codeEl);delete codeEl.dataset.contourLines}}}enhance(){wireCopy(this)}}define("contour-code",ContourCode);class ContourPlate extends ContourBase{static get observed(){return[]}render(){this.classList.add("c-plate")}}define("contour-plate",ContourPlate);class ContourPullquote extends ContourBase{static get observed(){return["quote","name"]}static get properties(){return{quote:{attribute:"quote"},name:{attribute:"name"}}}render(){this.classList.add("c-pullquote");const quote=this.getAttribute("quote");if(quote){Array.from(this.childNodes).forEach((n)=>{if(n.nodeType===3)n.remove()});const cite=this.querySelector("cite");this.insertBefore(document.createTextNode(quote),cite)}const name=this.getAttribute("name");if(name){const by=this.ensure("cite",()=>{const el=document.createElement("cite");this.appendChild(el);return el});by.textContent=name}else{const by=this.querySelector("cite");if(by)by.remove()}}}define("contour-pullquote",ContourPullquote);class ContourAnchor extends ContourBase{static get observed(){return["href","label"]}static get properties(){return{href:{attribute:"href"},label:{attribute:"label"}}}render(){this.classList.add("c-anchor");const href=this.getAttribute("href");const label=this.getAttribute("label");const prevAnchor=this.querySelector("a");if(prevAnchor)prevAnchor.remove();if(href&&label){const a=document.createElement("a");a.href=safeHref(href);a.textContent=label;const ariaLabel=this.getAttribute("aria-label");if(ariaLabel)a.setAttribute("aria-label",ariaLabel);this.appendChild(a)}}}define("contour-anchor",ContourAnchor);class ContourGeocoder extends ContourBase{static get observed(){return["placeholder","value","results","empty","loading","error","retry","src","lazy","refresh","timeout","skeleton"]}static get properties(){return{placeholder:{attribute:"placeholder"},value:{attribute:"value"},results:{attribute:"results"},src:{attribute:"src"}}}render(){this.classList.add("c-geocoder");wireStates(this);loadRemote(this,["results"]);if(renderStates(this,"geocoder"))return;let inp=this.querySelector(".c-geocoder__input");if(!inp){inp=document.createElement("input");inp.type="search";inp.className="c-geocoder__input";if(!inp.hasAttribute("aria-label"))inp.setAttribute("aria-label",this.getAttribute("placeholder")||"Search location");this.appendChild(inp)}const ph=this.getAttribute("placeholder");if(ph)inp.setAttribute("placeholder",ph);const val=this.getAttribute("value");if(val!==null&&inp.value!==val)inp.value=val;Array.from(this.querySelectorAll(".c-geocoder__result")).forEach((n)=>n.remove());let results=[];const rAttr=this.getAttribute("results");if(rAttr){try{results=JSON.parse(rAttr)}catch(e){results=[]}}const remote=remoteData(this,"results");if(Array.isArray(remote))results=remote;if(Array.isArray(results)&&results.length){const list=document.createElement("ul");list.className="c-geocoder__list";list.setAttribute("role","listbox");results.forEach((r,idx)=>{const li=document.createElement("li");li.className="c-geocoder__result";li.setAttribute("role","option");li.setAttribute("tabindex",idx===0?"0":"-1");li.textContent=(typeof r==="object")?(r.label||r.name||""):String(r);if(typeof r==="object"){if(r.lat!=null)li.dataset.lat=String(r.lat);if(r.lon!=null)li.dataset.lon=String(r.lon)}list.appendChild(li)});this.appendChild(list)}else if(!this.hasAttribute("loading")&&!this.hasAttribute("error")){renderEmpty(this,"geocoder")}}enhance(){if(this._wiredGeocoder)return;this._wiredGeocoder=true;const inp=this.querySelector(".c-geocoder__input");if(inp){let timer=null;inp.addEventListener("input",()=>{if(timer)clearTimeout(timer);timer=setTimeout(()=>{this.dispatchEvent(new CustomEvent("contour:search",{bubbles:true,composed:true,detail:{query:inp.value}}))},200)});inp.addEventListener("keydown",(e)=>{if(e.key==="Enter"){e.preventDefault();this.dispatchEvent(new CustomEvent("contour:search",{bubbles:true,composed:true,detail:{query:inp.value}}))}})}this.addEventListener("click",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-geocoder__result"):null;if(!li||!this.contains(li))return;const result={label:li.textContent.trim(),lat:li.dataset.lat,lon:li.dataset.lon};this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{result}}))});this.addEventListener("keydown",(e)=>{const li=e.target&&e.target.closest?e.target.closest(".c-geocoder__result"):null;if(!li||!this.contains(li))return;if(e.key==="Enter"||e.key===" "){e.preventDefault();const result={label:li.textContent.trim(),lat:li.dataset.lat,lon:li.dataset.lon};this.dispatchEvent(new CustomEvent("contour:select",{bubbles:true,composed:true,detail:{result}}))}})}}define("contour-geocoder",ContourGeocoder);