@adia-ai/web-components 0.6.32 → 0.6.33

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.
@@ -52,7 +52,7 @@ var Sk=Object.defineProperty;var W=(s,t)=>()=>(s&&(t=s(s=0)),t);var Ht=(s,t)=>{f
52
52
  aria-label="Undo" \u2190 explicit accessible name
53
53
  title="Undo" \u2190 auto-mirrored to aria-label + tooltip
54
54
  aria-labelledby="..." \u2190 reference an existing label element
55
- Without an accessible name screen readers announce nothing meaningful.`)))}}static#t=new WeakSet;static#e=new WeakSet;#i=t=>{if(this.disabled){t.stopPropagation();return}if(this.type==="submit"){let e=this.closest("form");e?.requestSubmit&&e.requestSubmit()}else if(this.type==="reset"){let e=this.closest("form");e?.reset&&e.reset()}this.dispatchEvent(new Event("press",{bubbles:!0}))};#s=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.click())};disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}};w("button-ui",Vs);var Ws=class extends A{static properties={text:{type:String,default:"",reflect:!0},href:{type:String,default:"",reflect:!0},target:{type:String,default:"",reflect:!0},rel:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},block:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=t=>{if(this.disabled){t.preventDefault();return}let e={href:this.href,target:this.target},i=new CustomEvent("press",{bubbles:!0,cancelable:!0,detail:e});this.dispatchEvent(i)||t.preventDefault()};#e=t=>{this.disabled&&t.key==="Enter"&&t.preventDefault()};#i(){let t=this.querySelector(":scope > a");t||(t=document.createElement("a"),t.dataset.autostamped="true",this.appendChild(t));let e=[];for(let i of this.childNodes)i!==t&&i.parentNode===this&&e.push(i);for(let i of e)t.appendChild(i);return t}connected(){let t=this.#i();this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e),this.disabled&&this.setAttribute("aria-disabled","true")}render(){let t=this.querySelector(":scope > a");if(!t)return;let e=t.dataset.autostamped==="true";if(e&&(this.href?t.setAttribute("href",this.href):t.removeAttribute("href"),this.target?t.setAttribute("target",this.target):t.removeAttribute("target"),this.rel?t.setAttribute("rel",this.rel):this.target==="_blank"?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel")),this.disabled?(this.setAttribute("aria-disabled","true"),t.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),t.removeAttribute("tabindex")),e){let i=this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:"",n=this.text?`<span>${this.text}</span>`:"";t.innerHTML=`${i}${n}`}}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};w("link-ui",Ws);var z=class s extends A{static formAssociated=!0;static get properties(){return{name:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},pattern:{type:String,default:"",reflect:!0},minlength:{type:Number,default:null,reflect:!0},maxlength:{type:Number,default:null,reflect:!0},throttle:{type:Number,default:0,reflect:!0}}}#t=!1;#e=null;#i=void 0;get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}syncValue(t){t=t??this.value??"",this.internals.setFormValue(t),this.#s(t)}setValid(){this.internals.setValidity({}),this.removeAttribute("aria-invalid"),this.error&&(this.error="")}setInvalid(t,e){this.internals.setValidity({customError:!0},t||"Invalid",e||this),this.setAttribute("aria-invalid","true"),this.error=t||"Invalid"}validate(){let t=this.#s(this.value??"");return t?(this.removeAttribute("aria-invalid"),this.error&&(this.error="")):(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),t}scheduleThrottledInput(t=null){let e=Number(this.throttle)||0,i=()=>new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}});if(e>0){this.#e!=null&&clearTimeout(this.#e),this.#i=this.value,this.#e=setTimeout(()=>{this.#e=null,this.#i=void 0,this.dispatchEvent(i())},e);return}this.dispatchEvent(i())}flushPendingInput(t=null){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}})))}dropPendingInput(){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0)}#s(t){t=t??this.value??"";let e=String(t);if(this.required&&!e.trim())return this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),!1;if(this.pattern&&e)try{if(!new RegExp(`^(?:${this.pattern})$`).test(e))return this.internals.setValidity({patternMismatch:!0},this.getAttribute("data-msg-pattern")||"Please match the requested format.",this),!1}catch{}return this.minlength!=null&&this.minlength>0&&e.length>0&&e.length<this.minlength?(this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-minlength")||`Please use at least ${this.minlength} characters.`,this),!1):this.maxlength!=null&&this.maxlength>0&&e.length>this.maxlength?(this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-maxlength")||`Please use no more than ${this.maxlength} characters.`,this),!1):(this.internals.setValidity({}),!0)}#n=t=>{t.preventDefault(),this.setAttribute("aria-invalid","true"),this.error=this.validationMessage};#r=()=>{this.#t=!0,this.error&&this.validate()};#o=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#n),this.addEventListener("input",this.#r),this.addEventListener("blur",this.#o,!0),this.#a()}#a(){let t=this.constructor;t.labelDeprecated!==!1&&t.properties?.label&&this.hasAttribute("label")&&(s.#l.has(t)||(s.#l.add(t),console.warn(`[AdiaUI] <${this.localName} label="\u2026"> is deprecated \u2014 wrap in <field-ui label="\u2026"> for proper label association. Docs: https://ui-kit.exe.xyz/site/components/field`)))}static#l=new Set;disconnected(){super.disconnected(),this.removeEventListener("invalid",this.#n),this.removeEventListener("input",this.#r),this.removeEventListener("blur",this.#o,!0),this.dropPendingInput()}formResetCallback(){this.#t=!1,this.setValid(),this.onFormReset()}formDisabledCallback(t){this.disabled=t,this.onFormDisabled(t)}formAssociatedCallback(t){this.onFormAssociated(t)}formStateRestoreCallback(t,e){this.onFormStateRestore(t,e)}onFormReset(){}onFormDisabled(t){}onFormAssociated(t){}onFormStateRestore(t,e){}};var Ng=s=>Uc(s)?`<icon-ui name="${s}"></icon-ui>`:s,Ys=class s extends z{static labelDeprecated=!1;static properties={...z.properties,placeholder:{type:String,default:"",reflect:!0},type:{type:String,default:"text",reflect:!0},label:{type:String,default:"",reflect:!0},prefix:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},min:{type:Number,default:null,reflect:!0},max:{type:Number,default:null,reflect:!0},step:{type:Number,default:1,reflect:!0},precision:{type:Number,default:null,reflect:!0},locale:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n="";#r=null;#o=null;#a=".";#l="";#u=null;static#h=0;static#c=400;static#d=60;get#f(){return this.type==="password"}get#p(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#k(t);if(e==="-"||e==="."||e==="-.")return NaN;let i=Number(e);return Number.isFinite(i)?i:NaN}set valueAsNumber(t){if(!Number.isFinite(t)){this.value="";return}this.value=this.#y(t)}connected(){super.connected(),this.setAttribute("role",this.#p?"spinbutton":"textbox");let t=Array.from(this.querySelectorAll(':scope > [slot="leading"]')),e=Array.from(this.querySelectorAll(':scope > [slot="trailing"]'));if(!this.querySelector('[slot="text"]')){let i=this.label?`input-label-${++s.#h}`:"";this.innerHTML=this.#g(i),this.#O(t,e)}this.#t=this.querySelector('[slot="text"]'),this.#e=this.querySelector('[slot="label"]'),this.#i=this.querySelector('[data-step="up"]'),this.#s=this.querySelector('[data-step="down"]'),!this.#f&&this.value&&(this.#t.textContent=this.#p?this.#Q(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#L),this.#t.addEventListener("keydown",this.#A),this.#t.addEventListener("blur",this.#q),this.#t.addEventListener("focus",this.#D),this.#t.addEventListener("paste",this.#W),this.#p&&this.#t.addEventListener("beforeinput",this.#E)),this.#i?.addEventListener("pointerdown",this.#U),this.#s?.addEventListener("pointerdown",this.#_),(this.prefix||this.suffix)&&Pg.then(()=>this.#m())}#g(t){let e=this.prefix?`<span slot="prefix">${Ng(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",n=this.suffix?`<span slot="suffix">${Ng(this.suffix)}</span>`:"",r=t?`aria-labelledby="${t}"`:"";if(this.#f)return`
55
+ Without an accessible name screen readers announce nothing meaningful.`)))}}static#t=new WeakSet;static#e=new WeakSet;#i=t=>{if(this.disabled){t.stopPropagation();return}if(this.type==="submit"){let e=this.closest("form");e?.requestSubmit&&e.requestSubmit()}else if(this.type==="reset"){let e=this.closest("form");e?.reset&&e.reset()}this.dispatchEvent(new Event("press",{bubbles:!0}))};#s=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.click())};disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}};w("button-ui",Vs);var Ws=class extends A{static properties={text:{type:String,default:"",reflect:!0},href:{type:String,default:"",reflect:!0},target:{type:String,default:"",reflect:!0},rel:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},block:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=t=>{if(this.disabled){t.preventDefault();return}let e={href:this.href,target:this.target},i=new CustomEvent("press",{bubbles:!0,cancelable:!0,detail:e});this.dispatchEvent(i)||t.preventDefault()};#e=t=>{this.disabled&&t.key==="Enter"&&t.preventDefault()};#i(){let t=this.querySelector(":scope > a");t||(t=document.createElement("a"),t.dataset.autostamped="true",this.appendChild(t));let e=[];for(let i of this.childNodes)i!==t&&i.parentNode===this&&e.push(i);for(let i of e)t.appendChild(i);return t}connected(){let t=this.#i();this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e),this.disabled&&this.setAttribute("aria-disabled","true")}render(){let t=this.querySelector(":scope > a");if(!t)return;let e=t.dataset.autostamped==="true";if(e&&(this.href?t.setAttribute("href",this.href):t.removeAttribute("href"),this.target?t.setAttribute("target",this.target):t.removeAttribute("target"),this.rel?t.setAttribute("rel",this.rel):this.target==="_blank"?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel")),this.disabled?(this.setAttribute("aria-disabled","true"),t.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),t.removeAttribute("tabindex")),e){let i=this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:"",n=this.text?`<span>${this.text}</span>`:"";t.innerHTML=`${i}${n}`}}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};w("link-ui",Ws);var z=class s extends A{static formAssociated=!0;static get properties(){return{name:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},pattern:{type:String,default:"",reflect:!0},minlength:{type:Number,default:null,reflect:!0},maxlength:{type:Number,default:null,reflect:!0},throttle:{type:Number,default:0,reflect:!0}}}#t=!1;#e=null;#i=void 0;get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}syncValue(t){t=t??this.value??"",this.internals.setFormValue(t),this.#s(t)}setValid(){this.internals.setValidity({}),this.removeAttribute("aria-invalid"),this.error&&(this.error="")}setInvalid(t,e){this.internals.setValidity({customError:!0},t||"Invalid",e||this),this.setAttribute("aria-invalid","true"),this.error=t||"Invalid"}validate(){let t=this.#s(this.value??"");return t?(this.removeAttribute("aria-invalid"),this.error&&(this.error="")):(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),t}scheduleThrottledInput(t=null){let e=Number(this.throttle)||0,i=()=>new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}});if(e>0){this.#e!=null&&clearTimeout(this.#e),this.#i=this.value,this.#e=setTimeout(()=>{this.#e=null,this.#i=void 0,this.dispatchEvent(i())},e);return}this.dispatchEvent(i())}flushPendingInput(t=null){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}})))}dropPendingInput(){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0)}#s(t){t=t??this.value??"";let e=String(t);if(this.required&&!e.trim())return this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),!1;if(this.pattern&&e)try{if(!new RegExp(`^(?:${this.pattern})$`).test(e))return this.internals.setValidity({patternMismatch:!0},this.getAttribute("data-msg-pattern")||"Please match the requested format.",this),!1}catch{}return this.minlength!=null&&this.minlength>0&&e.length>0&&e.length<this.minlength?(this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-minlength")||`Please use at least ${this.minlength} characters.`,this),!1):this.maxlength!=null&&this.maxlength>0&&e.length>this.maxlength?(this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-maxlength")||`Please use no more than ${this.maxlength} characters.`,this),!1):(this.internals.setValidity({}),!0)}#n=t=>{t.preventDefault(),this.setAttribute("aria-invalid","true"),this.error=this.validationMessage};#r=()=>{this.#t=!0,this.error&&this.validate()};#o=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#n),this.addEventListener("input",this.#r),this.addEventListener("blur",this.#o,!0),this.#a()}#a(){let t=this.constructor;t.labelDeprecated!==!1&&t.properties?.label&&this.hasAttribute("label")&&(s.#l.has(t)||(s.#l.add(t),console.warn(`[AdiaUI] <${this.localName} label="\u2026"> is deprecated \u2014 wrap in <field-ui label="\u2026"> for proper label association. Docs: https://ui-kit.exe.xyz/site/components/field`)))}static#l=new Set;disconnected(){super.disconnected(),this.removeEventListener("invalid",this.#n),this.removeEventListener("input",this.#r),this.removeEventListener("blur",this.#o,!0),this.dropPendingInput()}formResetCallback(){this.#t=!1,this.setValid(),this.onFormReset()}formDisabledCallback(t){this.disabled=t,this.onFormDisabled(t)}formAssociatedCallback(t){this.onFormAssociated(t)}formStateRestoreCallback(t,e){this.onFormStateRestore(t,e)}onFormReset(){}onFormDisabled(t){}onFormAssociated(t){}onFormStateRestore(t,e){}};var Ng=s=>Uc(s)?`<icon-ui name="${s}"></icon-ui>`:s,Ys=class s extends z{static labelDeprecated=!1;static properties={...z.properties,placeholder:{type:String,default:"",reflect:!0},type:{type:String,default:"text",reflect:!0},label:{type:String,default:"",reflect:!0},prefix:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},min:{type:Number,default:null,reflect:!0},max:{type:Number,default:null,reflect:!0},step:{type:Number,default:1,reflect:!0},precision:{type:Number,default:null,reflect:!0},locale:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n="";#r=null;#o=null;#a=".";#l="";#u=null;static#h=0;static#c=400;static#d=60;get#f(){return this.type==="password"}get#p(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#k(t);if(e==="-"||e==="."||e==="-.")return NaN;let i=Number(e);return Number.isFinite(i)?i:NaN}set valueAsNumber(t){if(!Number.isFinite(t)){this.value="";return}this.value=this.#y(t)}connected(){super.connected(),this.setAttribute("role",this.#p?"spinbutton":"textbox");let t=Array.from(this.querySelectorAll(':scope > [slot="leading"]')),e=Array.from(this.querySelectorAll(':scope > [slot="trailing"]'));if(!this.querySelector('[slot="text"]')){let i=this.label?`input-label-${++s.#h}`:"";this.innerHTML=this.#g(i),this.#O(t,e)}this.#t=this.querySelector('[slot="text"]'),this.#e=this.querySelector('[slot="label"]'),this.#i=this.querySelector('[data-step="up"]'),this.#s=this.querySelector('[data-step="down"]'),!this.#f&&this.value&&(this.#t.textContent=this.#p?this.#A(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#E),this.#t.addEventListener("keydown",this.#Q),this.#t.addEventListener("blur",this.#q),this.#t.addEventListener("focus",this.#D),this.#t.addEventListener("paste",this.#W),this.#p&&this.#t.addEventListener("beforeinput",this.#T)),this.#i?.addEventListener("pointerdown",this.#U),this.#s?.addEventListener("pointerdown",this.#_),(this.prefix||this.suffix)&&Pg.then(()=>this.#m())}#g(t){let e=this.prefix?`<span slot="prefix">${Ng(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",n=this.suffix?`<span slot="suffix">${Ng(this.suffix)}</span>`:"",r=t?`aria-labelledby="${t}"`:"";if(this.#f)return`
56
56
  <div slot="field">
57
57
  ${e}${i}
58
58
  <input slot="text" type="password" tabindex="0"
@@ -76,7 +76,7 @@ var Sk=Object.defineProperty;var W=(s,t)=>()=>(s&&(t=s(s=0)),t);var Ht=(s,t)=>{f
76
76
  <div slot="field"${this.#p?" data-number":""}>
77
77
  ${e}${i}${o}${n}${a}
78
78
  </div>
79
- `}#O(t,e){let i=this.querySelector(':scope > [slot="field"]');if(i){if(t.length){let n=i.querySelector(':scope > [slot="label"]')||i.querySelector(':scope > [slot="prefix"]');if(n){let r=n;for(let o of t)r.after(o),r=o}else for(let r of t.slice().reverse())i.prepend(r)}if(e.length){let n=i.querySelector(':scope > [slot="controls"]'),r=i.querySelector(':scope > [slot="suffix"]')||i.querySelector(':scope > [slot="text"]');if(r){let o=r;for(let a of e)o.after(a),o=a}else if(n){let o=n.previousElementSibling||n;for(let a of e)o.after(a),o=a}else for(let o of e)i.appendChild(o)}}}#m(){if(this.isConnected)for(let t of["prefix","suffix"]){let e=this[t];if(!e)continue;let i=this.querySelector(`:scope [slot="${t}"]`);if(i&&!i.querySelector(":scope > icon-ui")&&Uc(e)){i.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",e),i.appendChild(n)}}}render(){if(!this.#t)return;let t=this.value??"";if(this.#f)this.#t.placeholder=this.placeholder,this.#t.disabled=this.disabled,this.#t.readOnly=this.readonly,this.#t.value!==t&&(this.#t.value=t);else{this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let e=this.#p&&document.activeElement!==this.#t?this.#Q(t):String(t);this.#t.textContent!==e&&(this.#t.textContent=e,this.#t.toggleAttribute("data-empty",!e))}if(this.#e&&(this.#e.textContent=this.label||""),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#p){let e=this.valueAsNumber;Number.isFinite(e)?(this.setAttribute("aria-valuenow",String(e)),this.setAttribute("aria-valuetext",`${this.#y(e)}${this.suffix?" "+this.suffix:""}`)):(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuetext")),this.min!=null?this.setAttribute("aria-valuemin",String(this.min)):this.removeAttribute("aria-valuemin"),this.max!=null?this.setAttribute("aria-valuemax",String(this.max)):this.removeAttribute("aria-valuemax");let i=this.disabled||this.readonly||this.max!=null&&Number.isFinite(e)&&e>=this.max,n=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!n)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#p&&this.#b(String(t))}validate(){let t=super.validate();if(!this.#p)return t;if(!t)return!1;let e=this.#b(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#b(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#k(e),n=Number(i);return Number.isFinite(n)?this.min!=null&&n<this.min?(this.internals.setValidity({rangeUnderflow:!0},this.getAttribute("data-msg-min")||`Value must be ${this.min} or greater.`,this),!1):this.max!=null&&n>this.max?(this.internals.setValidity({rangeOverflow:!0},this.getAttribute("data-msg-max")||`Value must be ${this.max} or less.`,this),!1):!0:(this.internals.setValidity({badInput:!0},this.getAttribute("data-msg-bad-input")||"Please enter a valid number.",this),!1)}#v(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#S(){return this.locale?this.#u===this.locale?this.#a:(this.#w(),this.#a):"."}#x(){return this.locale?this.#u===this.locale?this.#l:(this.#w(),this.#l):""}#w(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#a=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#a=".",this.#l=""}this.#u=this.locale}#k(t){let e=this.#S(),i=this.#x(),n=String(t);return i&&(n=n.split(i).join("")),e!=="."&&(n=n.replace(new RegExp(`\\${e}`,"g"),".")),n}#y(t){if(!Number.isFinite(t))return"";let e=this.#v();if(this.locale)try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!1}).format(t)}catch{}return e>0?t.toFixed(e):String(Math.round(t))}#$(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#y(t);let e=this.#v();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#y(t)}}#Q(t){let e=String(t??"");if(!e)return"";let i=Number(this.#k(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#y(i):this.#$(i):e}#P(t){let e=this.step||1,i=this.min!=null?this.min:0,n=Math.round((t-i)/e)*e+i,r=Math.max(this.min!=null?this.min:-1/0,Math.min(this.max!=null?this.max:1/0,n));return parseFloat(r.toFixed(10))}#C(t){if(this.disabled||this.readonly)return;let e=(this.step||1)*t,i=Number.isFinite(this.valueAsNumber)?this.valueAsNumber:this.min!=null?this.min:0,n=this.#P(i+e);n!==this.valueAsNumber&&(this.value=this.#y(n),this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#L=()=>{let t;if(this.#f)t=this.#t.value||"";else if(this.#p){let e=this.#t.textContent||"";t=this.#X(e),t!==e&&(this.#t.textContent=t,this.#I())}else t=this.#t.textContent||"";this.value=t,this.#f||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#E=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;let n=this.#t.textContent||"",r=window.getSelection(),o=n.length,a=n.length;if(r&&r.rangeCount&&this.#t.contains(r.anchorNode)){let h=r.getRangeAt(0);o=this.#M(h.startContainer,h.startOffset),a=this.#M(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=n.slice(0,o)+i+n.slice(a);this.#Z(l)||t.preventDefault()};#Z(t){let e=this.#k(t);return e===""||e==="-"||e==="."||e==="-."?e===""||e==="-"||this.min==null||this.min<0:!(!/^-?\d*\.?\d*$/.test(e)||e.startsWith("-")&&this.min!=null&&this.min>=0)}#X(t){let e=this.#S(),i="",n=!1;for(let r=0;r<t.length;r++){let o=t[r];o>="0"&&o<="9"||o==="-"&&i===""&&(this.min==null||this.min<0)?i+=o:o===e&&!n&&(i+=e,n=!0)}return i}#M(t,e){if(!this.#t.contains(t))return 0;let i=0,n=document.createTreeWalker(this.#t,NodeFilter.SHOW_TEXT),r;for(;r=n.nextNode();){if(r===t)return i+e;i+=r.textContent.length}return t===this.#t?e:i}#I(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#A=t=>{if(this.#p){switch(t.key){case"ArrowUp":t.preventDefault(),this.#C(1);return;case"ArrowDown":t.preventDefault(),this.#C(-1);return;case"PageUp":t.preventDefault(),this.#C(10);return;case"PageDown":t.preventDefault(),this.#C(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#N(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#N(this.max));return;case"Escape":t.preventDefault(),this.value=this.#n,this.#t.textContent=this.#Q(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#z(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0}));return}return}t.key==="Enter"&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#D=()=>{if(this.#n=this.value??"",this.#p&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#y(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#q=()=>{this.#p&&this.#z(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#z(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#P(e),n=this.#y(i),r=this.#$(i);this.value!==n&&(this.value=n,this.syncValue(n),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==r&&(this.#t.textContent=r,this.#t.toggleAttribute("data-empty",!r))}#N(t){let e=this.#P(t);e!==this.valueAsNumber&&(this.value=this.#y(e),this.syncValue(this.value),this.#t.textContent=this.value,this.#t.toggleAttribute("data-empty",!this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#W=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#p?this.#X(e):e;document.execCommand("insertText",!1,i)};#U=t=>this.#B(t,1);#_=t=>this.#B(t,-1);#B(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#C(e),this.#Y(),document.addEventListener("pointerup",this.#j,{once:!0}),document.addEventListener("pointercancel",this.#j,{once:!0}),this.#o=window.setTimeout(()=>{this.#o=null,this.#r=window.setInterval(()=>{let i=this.valueAsNumber;this.#C(e),this.valueAsNumber===i&&this.#Y()},s.#d)},s.#c))}#j=()=>this.#Y();#Y(){this.#o!=null&&(window.clearTimeout(this.#o),this.#o=null),this.#r!=null&&(window.clearInterval(this.#r),this.#r=null),document.removeEventListener("pointerup",this.#j),document.removeEventListener("pointercancel",this.#j)}focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#f?this.#t.value="":(this.#t.textContent="",this.#t.setAttribute("data-empty",""))),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#L),this.#t.removeEventListener("keydown",this.#A),this.#t.removeEventListener("blur",this.#q),this.#t.removeEventListener("focus",this.#D),this.#t.removeEventListener("paste",this.#W),this.#t.removeEventListener("beforeinput",this.#E)),this.#i?.removeEventListener("pointerdown",this.#U),this.#s?.removeEventListener("pointerdown",this.#_),this.#Y(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};w("input-ui",Ys);var Us=class extends z{static labelDeprecated=!1;static properties={...z.properties,placeholder:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},rows:{type:Number,default:3,reflect:!0},resize:{type:String,default:"vertical",reflect:!0}};static template=()=>null;#t=null;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
79
+ `}#O(t,e){let i=this.querySelector(':scope > [slot="field"]');if(i){if(t.length){let n=i.querySelector(':scope > [slot="label"]')||i.querySelector(':scope > [slot="prefix"]');if(n){let r=n;for(let o of t)r.after(o),r=o}else for(let r of t.slice().reverse())i.prepend(r)}if(e.length){let n=i.querySelector(':scope > [slot="controls"]'),r=i.querySelector(':scope > [slot="suffix"]')||i.querySelector(':scope > [slot="text"]');if(r){let o=r;for(let a of e)o.after(a),o=a}else if(n){let o=n.previousElementSibling||n;for(let a of e)o.after(a),o=a}else for(let o of e)i.appendChild(o)}}}#m(){if(this.isConnected)for(let t of["prefix","suffix"]){let e=this[t];if(!e)continue;let i=this.querySelector(`:scope [slot="${t}"]`);if(i&&!i.querySelector(":scope > icon-ui")&&Uc(e)){i.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",e),i.appendChild(n)}}}render(){if(!this.#t)return;let t=this.value??"";if(this.#f)this.#t.placeholder=this.placeholder,this.#t.disabled=this.disabled,this.#t.readOnly=this.readonly,this.#t.value!==t&&(this.#t.value=t);else{this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let e=this.#p&&document.activeElement!==this.#t?this.#A(t):String(t);this.#t.textContent!==e&&(this.#t.textContent=e,this.#t.toggleAttribute("data-empty",!e))}if(this.#e&&(this.#e.textContent=this.label||""),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#p){let e=this.valueAsNumber;Number.isFinite(e)?(this.setAttribute("aria-valuenow",String(e)),this.setAttribute("aria-valuetext",`${this.#y(e)}${this.suffix?" "+this.suffix:""}`)):(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuetext")),this.min!=null?this.setAttribute("aria-valuemin",String(this.min)):this.removeAttribute("aria-valuemin"),this.max!=null?this.setAttribute("aria-valuemax",String(this.max)):this.removeAttribute("aria-valuemax");let i=this.disabled||this.readonly||this.max!=null&&Number.isFinite(e)&&e>=this.max,n=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!n)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#p&&this.#b(String(t))}validate(){let t=super.validate();if(!this.#p)return t;if(!t)return!1;let e=this.#b(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#b(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#k(e),n=Number(i);return Number.isFinite(n)?this.min!=null&&n<this.min?(this.internals.setValidity({rangeUnderflow:!0},this.getAttribute("data-msg-min")||`Value must be ${this.min} or greater.`,this),!1):this.max!=null&&n>this.max?(this.internals.setValidity({rangeOverflow:!0},this.getAttribute("data-msg-max")||`Value must be ${this.max} or less.`,this),!1):!0:(this.internals.setValidity({badInput:!0},this.getAttribute("data-msg-bad-input")||"Please enter a valid number.",this),!1)}#x(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#S(){return this.locale?this.#u===this.locale?this.#a:(this.#w(),this.#a):"."}#v(){return this.locale?this.#u===this.locale?this.#l:(this.#w(),this.#l):""}#w(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#a=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#a=".",this.#l=""}this.#u=this.locale}#k(t){let e=this.#S(),i=this.#v(),n=String(t);return i&&(n=n.split(i).join("")),e!=="."&&(n=n.replace(new RegExp(`\\${e}`,"g"),".")),n}#y(t){if(!Number.isFinite(t))return"";let e=this.#x();if(this.locale)try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!1}).format(t)}catch{}return e>0?t.toFixed(e):String(Math.round(t))}#$(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#y(t);let e=this.#x();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#y(t)}}#A(t){let e=String(t??"");if(!e)return"";let i=Number(this.#k(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#y(i):this.#$(i):e}#C(t){let e=this.step||1,i=this.min!=null?this.min:0,n=Math.round((t-i)/e)*e+i,r=Math.max(this.min!=null?this.min:-1/0,Math.min(this.max!=null?this.max:1/0,n));return parseFloat(r.toFixed(10))}#P(t){if(this.disabled||this.readonly)return;let e=(this.step||1)*t,i=Number.isFinite(this.valueAsNumber)?this.valueAsNumber:this.min!=null?this.min:0,n=this.#C(i+e);n!==this.valueAsNumber&&(this.value=this.#y(n),this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#E=()=>{let t;if(this.#f)t=this.#t.value||"";else if(this.#p){let e=this.#t.textContent||"";t=this.#X(e),t!==e&&(this.#t.textContent=t,this.#I())}else t=this.#t.textContent||"";this.value=t,this.#f||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#T=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;let n=this.#t.textContent||"",r=window.getSelection(),o=n.length,a=n.length;if(r&&r.rangeCount&&this.#t.contains(r.anchorNode)){let h=r.getRangeAt(0);o=this.#M(h.startContainer,h.startOffset),a=this.#M(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=n.slice(0,o)+i+n.slice(a);this.#Z(l)||t.preventDefault()};#Z(t){let e=this.#k(t);return e===""||e==="-"||e==="."||e==="-."?e===""||e==="-"||this.min==null||this.min<0:!(!/^-?\d*\.?\d*$/.test(e)||e.startsWith("-")&&this.min!=null&&this.min>=0)}#X(t){let e=this.#S(),i="",n=!1;for(let r=0;r<t.length;r++){let o=t[r];o>="0"&&o<="9"||o==="-"&&i===""&&(this.min==null||this.min<0)?i+=o:o===e&&!n&&(i+=e,n=!0)}return i}#M(t,e){if(!this.#t.contains(t))return 0;let i=0,n=document.createTreeWalker(this.#t,NodeFilter.SHOW_TEXT),r;for(;r=n.nextNode();){if(r===t)return i+e;i+=r.textContent.length}return t===this.#t?e:i}#I(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#Q=t=>{if(this.#p){switch(t.key){case"ArrowUp":t.preventDefault(),this.#P(1);return;case"ArrowDown":t.preventDefault(),this.#P(-1);return;case"PageUp":t.preventDefault(),this.#P(10);return;case"PageDown":t.preventDefault(),this.#P(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#N(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#N(this.max));return;case"Escape":t.preventDefault(),this.value=this.#n,this.#t.textContent=this.#A(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#z(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0}));return}return}t.key==="Enter"&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#D=()=>{if(this.#n=this.value??"",this.#p&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#y(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#q=()=>{this.#p&&this.#z(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#z(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#C(e),n=this.#y(i),r=this.#$(i);this.value!==n&&(this.value=n,this.syncValue(n),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==r&&(this.#t.textContent=r,this.#t.toggleAttribute("data-empty",!r))}#N(t){let e=this.#C(t);e!==this.valueAsNumber&&(this.value=this.#y(e),this.syncValue(this.value),this.#t.textContent=this.value,this.#t.toggleAttribute("data-empty",!this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#W=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#p?this.#X(e):e;document.execCommand("insertText",!1,i)};#U=t=>this.#B(t,1);#_=t=>this.#B(t,-1);#B(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#P(e),this.#Y(),document.addEventListener("pointerup",this.#j,{once:!0}),document.addEventListener("pointercancel",this.#j,{once:!0}),this.#o=window.setTimeout(()=>{this.#o=null,this.#r=window.setInterval(()=>{let i=this.valueAsNumber;this.#P(e),this.valueAsNumber===i&&this.#Y()},s.#d)},s.#c))}#j=()=>this.#Y();#Y(){this.#o!=null&&(window.clearTimeout(this.#o),this.#o=null),this.#r!=null&&(window.clearInterval(this.#r),this.#r=null),document.removeEventListener("pointerup",this.#j),document.removeEventListener("pointercancel",this.#j)}focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#f?this.#t.value="":(this.#t.textContent="",this.#t.setAttribute("data-empty",""))),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#E),this.#t.removeEventListener("keydown",this.#Q),this.#t.removeEventListener("blur",this.#q),this.#t.removeEventListener("focus",this.#D),this.#t.removeEventListener("paste",this.#W),this.#t.removeEventListener("beforeinput",this.#T)),this.#i?.removeEventListener("pointerdown",this.#U),this.#s?.removeEventListener("pointerdown",this.#_),this.#Y(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};w("input-ui",Ys);var Us=class extends z{static labelDeprecated=!1;static properties={...z.properties,placeholder:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},rows:{type:Number,default:3,reflect:!0},resize:{type:String,default:"vertical",reflect:!0}};static template=()=>null;#t=null;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
80
80
  ${this.label?`<label slot="label" label="${this.label}"></label>`:""}
81
81
  <div slot="text" contenteditable="plaintext-only" tabindex="0"
82
82
  ${this.value?"":'data-empty=""'}
@@ -110,7 +110,7 @@ parent-template-re-read pattern that works across frameworks.`);return}let t=thi
110
110
  <icon-ui name="caret-up-down" slot="caret"></icon-ui>
111
111
  </span>
112
112
  ${r}
113
- `,this.hint&&this.setAttribute("aria-describedby",n),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#m),this.#o.removeEventListener("focus",this.#l),this.#o.removeEventListener("click",this.#u)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#m),this.#o.addEventListener("focus",this.#l),this.#o.addEventListener("click",this.#u))),t&&this.appendChild(t)}if(this.#s||(this.#s=this.querySelector('[slot="listbox"]'),this.#s||(this.#s=document.createElement("div"),this.#s.setAttribute("slot","listbox"),this.#s.setAttribute("role","listbox"),this.#s.setAttribute("popover","manual"),this.appendChild(this.#s)),this.#d()),this.#s){let t=this.multiple?new Set(this.value.split(",").map(e=>e.trim()).filter(Boolean)):null;for(let e of this.#s.querySelectorAll('[role="option"]')){let i=e.getAttribute("data-value");(t?t.has(i):i===this.value)?e.setAttribute("aria-selected","true"):e.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#s?.showPopover?.();let t=this.querySelector('[slot="trigger"]')||this;this.#s.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#s.style.width="max-content",this.#n=Tt(t,this.#s,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#a=requestAnimationFrame(()=>{this.#a=null,document.addEventListener("pointerdown",this.#g,{once:!0})})}else this.#n?.(),this.#n=null,this.#s?.hidePopover?.(),this.#a!=null&&(cancelAnimationFrame(this.#a),this.#a=null),document.removeEventListener("pointerdown",this.#g)}#c(){this.#i=[];let t=new Set,e=[];for(let i of this.children)if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&e.push(r.value);this.#i.push(n)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&e.push(i.value)):i.hasAttribute("slot")||t.add(i.tagName.toLowerCase());for(let i of[...this.querySelectorAll("option, optgroup")])i.remove();!this.value&&e.length&&(this.value=this.multiple?e.join(","):e[0]),t.size>0&&!s.#t.has(this)&&(s.#t.add(this),console.warn(`<select-ui>: ignoring unrecognized child element(s) [${[...t].join(", ")}]. Consumer-authored children must be native <option> or <optgroup>, NOT <select-option> or other <*-ui> shapes. Or set element.options = [...] programmatically. (Once-per-element warn; see select.yaml usage: for details.)`))}set options(t){Eo(()=>{this.#i=t,this.#s||(this.#s=this.querySelector('[slot="listbox"]'),this.#s||(this.#s=document.createElement("div"),this.#s.setAttribute("slot","listbox"),this.#s.setAttribute("role","listbox"),this.#s.setAttribute("popover","manual"),this.appendChild(this.#s))),this.#d();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#f())})}get options(){return this.#i}#d(){if(!this.#s)return;this.#s.innerHTML="";let t=e=>{if(e.separator){let r=document.createElement("hr");return r.setAttribute("data-separator",""),r}let i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("data-value",e.value||""),e.icon?i.innerHTML=`<icon-ui name="${Re(e.icon)}"></icon-ui>${Re(e.label)}`:i.textContent=e.label;let n=this.multiple?new Set(this.value.split(",").map(r=>r.trim()).filter(Boolean)):null;return(n?n.has(e.value):e.value===this.value)&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#h),i};for(let e of this.#i)if(e.separator)this.#s.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${Re(e.label)}</strong><span>${Re(e.description||"")}</span></div>`:`<div><strong>${Re(e.label)}</strong><span>${Re(e.description||"")}</span></div>`,this.#s.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${Re(e.label)}</div>`;for(let n of e.options)i.appendChild(t(n));this.#s.appendChild(i)}else this.#s.appendChild(t(e));this.#r&&this.#b()}#f(){return this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#p=t=>{this.disabled||this.#s&&t.composedPath().includes(this.#s)||(this.open=!this.open)};#g=t=>{!this.contains(t.target)&&!(this.#s&&t.composedPath().includes(this.#s))&&(this.open=!1)};#O=t=>{if(t.key==="Escape"){if(this.searchable&&this.#r){this.#r="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#b();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#s?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click();else if(this.searchable&&this.freeText&&this.#r){let i=this.#r;this.value=i,this.#r="",this.open=!1,this.syncValue?.(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}else this.open=!1}else this.open=!0;return}if(t.key===" "&&!this.searchable){if(t.preventDefault(),this.open){let e=this.#s?.querySelector('[role="option"][data-focused]');e?e.click():this.open=!1}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#v(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#v(-1))};#m=t=>{this.#r=t.target.value||"",this.open||(this.open=!0),this.#b()};#b(){if(!this.#s)return;let t=this.#r.toLowerCase(),e=this.#s.querySelectorAll('[role="option"]'),i=!1;for(let r of e){let o=(r.textContent||"").toLowerCase();!t||o.includes(t)?(r.removeAttribute("data-filtered-out"),r.style.display="",i=!0):(r.setAttribute("data-filtered-out",""),r.style.display="none")}for(let r of this.#s.querySelectorAll('[role="group"]')){let o=r.querySelectorAll('[role="option"]:not([data-filtered-out])').length;r.style.display=o?"":"none"}let n=this.#s.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#v(t){if(!this.#s)return;let e=[...this.#s.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#s.querySelector('[role="option"][data-focused]'),n=i?e.indexOf(i):-1,r=e[(n+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),r&&(r.setAttribute("data-focused",""),r.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#p),this.removeEventListener("keydown",this.#O),this.#a!=null&&(cancelAnimationFrame(this.#a),this.#a=null),document.removeEventListener("pointerdown",this.#g),this.#o&&(this.#o.removeEventListener("input",this.#m),this.#o.removeEventListener("focus",this.#l),this.#o.removeEventListener("click",this.#u),this.#o=null),this.#n?.(),this.#n=null,this.#s?.hidePopover?.(),this.#s=null}};w("select-ui",tn);var en=class extends A{static properties={value:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","radio"),this.getAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.setAttribute("aria-checked",this.selected?"true":"false"),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t?.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("aria-hidden","true"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};w("segment-ui",en);var sn=class s extends z{static properties={...z.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#c)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#l(this.#o)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#l(this.#o)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n?.disconnect(),this.#n=null,this.#r&&(this.#r=null),this.removeEventListener("click",this.#h),this.removeEventListener("keydown",this.#c),this.#e=null,this.#i=!1}get#o(){return[...this.querySelectorAll("segment-ui")]}get#a(){return this.#o.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator"));e&&(s.#t.add(this),console.warn(`[segmented-ui] child <${e.tagName.toLowerCase()}> is not <segment-ui> \u2014 bare <segment> tags render text but receive no sliding indicator or aria-checked state. Use <segment-ui>.`))}let t=this.#o;if(t.length){for(let e of t){let n=(e.value||e.getAttribute("value")||"")===this.value;n?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",n?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){let e=t.findIndex(n=>(n.value||n.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e;i&&(this.#e=document.createElement("span"),this.#e.setAttribute("data-indicator",""),this.prepend(this.#e)),this.style.setProperty("--_segment-count",`${t.length}`),i?(this.#e.style.transition="none",this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#e&&(this.#e.style.transition="")})):(this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""))}#u(t){t.disabled||(this.value=t.value,this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#u(e)};#c=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#a,n=i.indexOf(e);if(n<0)return;let r;switch(t.key){case"ArrowRight":case"ArrowDown":r=n<i.length-1?n+1:0;break;case"ArrowLeft":case"ArrowUp":r=n>0?n-1:i.length-1;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}t.preventDefault(),i[r].focus(),this.#u(i[r])}};w("segmented-ui",sn);var nn=class extends z{static labelDeprecated=!1;static properties={...z.properties,value:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:100,reflect:!0},step:{type:Number,default:1,reflect:!0},label:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=0;#n=0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
113
+ `,this.hint&&this.setAttribute("aria-describedby",n),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#m),this.#o.removeEventListener("focus",this.#l),this.#o.removeEventListener("click",this.#u)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#m),this.#o.addEventListener("focus",this.#l),this.#o.addEventListener("click",this.#u))),t&&this.appendChild(t)}if(this.#s||(this.#s=this.querySelector('[slot="listbox"]'),this.#s||(this.#s=document.createElement("div"),this.#s.setAttribute("slot","listbox"),this.#s.setAttribute("role","listbox"),this.#s.setAttribute("popover","manual"),this.appendChild(this.#s)),this.#d()),this.#s){let t=this.multiple?new Set(this.value.split(",").map(e=>e.trim()).filter(Boolean)):null;for(let e of this.#s.querySelectorAll('[role="option"]')){let i=e.getAttribute("data-value");(t?t.has(i):i===this.value)?e.setAttribute("aria-selected","true"):e.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#s?.showPopover?.();let t=this.querySelector('[slot="trigger"]')||this;this.#s.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#s.style.width="max-content",this.#n=Tt(t,this.#s,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#a=requestAnimationFrame(()=>{this.#a=null,document.addEventListener("pointerdown",this.#g,{once:!0})})}else this.#n?.(),this.#n=null,this.#s?.hidePopover?.(),this.#a!=null&&(cancelAnimationFrame(this.#a),this.#a=null),document.removeEventListener("pointerdown",this.#g)}#c(){this.#i=[];let t=new Set,e=[];for(let i of this.children)if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&e.push(r.value);this.#i.push(n)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&e.push(i.value)):i.hasAttribute("slot")||t.add(i.tagName.toLowerCase());for(let i of[...this.querySelectorAll("option, optgroup")])i.remove();!this.value&&e.length&&(this.value=this.multiple?e.join(","):e[0]),t.size>0&&!s.#t.has(this)&&(s.#t.add(this),console.warn(`<select-ui>: ignoring unrecognized child element(s) [${[...t].join(", ")}]. Consumer-authored children must be native <option> or <optgroup>, NOT <select-option> or other <*-ui> shapes. Or set element.options = [...] programmatically. (Once-per-element warn; see select.yaml usage: for details.)`))}set options(t){Eo(()=>{this.#i=t,this.#s||(this.#s=this.querySelector('[slot="listbox"]'),this.#s||(this.#s=document.createElement("div"),this.#s.setAttribute("slot","listbox"),this.#s.setAttribute("role","listbox"),this.#s.setAttribute("popover","manual"),this.appendChild(this.#s))),this.#d();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#f())})}get options(){return this.#i}#d(){if(!this.#s)return;this.#s.innerHTML="";let t=e=>{if(e.separator){let r=document.createElement("hr");return r.setAttribute("data-separator",""),r}let i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("data-value",e.value||""),e.icon?i.innerHTML=`<icon-ui name="${Re(e.icon)}"></icon-ui>${Re(e.label)}`:i.textContent=e.label;let n=this.multiple?new Set(this.value.split(",").map(r=>r.trim()).filter(Boolean)):null;return(n?n.has(e.value):e.value===this.value)&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#h),i};for(let e of this.#i)if(e.separator)this.#s.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${Re(e.label)}</strong><span>${Re(e.description||"")}</span></div>`:`<div><strong>${Re(e.label)}</strong><span>${Re(e.description||"")}</span></div>`,this.#s.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${Re(e.label)}</div>`;for(let n of e.options)i.appendChild(t(n));this.#s.appendChild(i)}else this.#s.appendChild(t(e));this.#r&&this.#b()}#f(){return this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#p=t=>{this.disabled||this.#s&&t.composedPath().includes(this.#s)||(this.open=!this.open)};#g=t=>{!this.contains(t.target)&&!(this.#s&&t.composedPath().includes(this.#s))&&(this.open=!1)};#O=t=>{if(t.key==="Escape"){if(this.searchable&&this.#r){this.#r="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#b();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#s?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click();else if(this.searchable&&this.freeText&&this.#r){let i=this.#r;this.value=i,this.#r="",this.open=!1,this.syncValue?.(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}else this.open=!1}else this.open=!0;return}if(t.key===" "&&!this.searchable){if(t.preventDefault(),this.open){let e=this.#s?.querySelector('[role="option"][data-focused]');e?e.click():this.open=!1}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#x(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#x(-1))};#m=t=>{this.#r=t.target.value||"",this.open||(this.open=!0),this.#b()};#b(){if(!this.#s)return;let t=this.#r.toLowerCase(),e=this.#s.querySelectorAll('[role="option"]'),i=!1;for(let r of e){let o=(r.textContent||"").toLowerCase();!t||o.includes(t)?(r.removeAttribute("data-filtered-out"),r.style.display="",i=!0):(r.setAttribute("data-filtered-out",""),r.style.display="none")}for(let r of this.#s.querySelectorAll('[role="group"]')){let o=r.querySelectorAll('[role="option"]:not([data-filtered-out])').length;r.style.display=o?"":"none"}let n=this.#s.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#x(t){if(!this.#s)return;let e=[...this.#s.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#s.querySelector('[role="option"][data-focused]'),n=i?e.indexOf(i):-1,r=e[(n+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),r&&(r.setAttribute("data-focused",""),r.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#p),this.removeEventListener("keydown",this.#O),this.#a!=null&&(cancelAnimationFrame(this.#a),this.#a=null),document.removeEventListener("pointerdown",this.#g),this.#o&&(this.#o.removeEventListener("input",this.#m),this.#o.removeEventListener("focus",this.#l),this.#o.removeEventListener("click",this.#u),this.#o=null),this.#n?.(),this.#n=null,this.#s?.hidePopover?.(),this.#s=null}};w("select-ui",tn);var en=class extends A{static properties={value:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","radio"),this.getAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.setAttribute("aria-checked",this.selected?"true":"false"),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t?.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("aria-hidden","true"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};w("segment-ui",en);var sn=class s extends z{static properties={...z.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#c)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#l(this.#o)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#l(this.#o)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n?.disconnect(),this.#n=null,this.#r&&(this.#r=null),this.removeEventListener("click",this.#h),this.removeEventListener("keydown",this.#c),this.#e=null,this.#i=!1}get#o(){return[...this.querySelectorAll("segment-ui")]}get#a(){return this.#o.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator"));e&&(s.#t.add(this),console.warn(`[segmented-ui] child <${e.tagName.toLowerCase()}> is not <segment-ui> \u2014 bare <segment> tags render text but receive no sliding indicator or aria-checked state. Use <segment-ui>.`))}let t=this.#o;if(t.length){for(let e of t){let n=(e.value||e.getAttribute("value")||"")===this.value;n?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",n?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){let e=t.findIndex(n=>(n.value||n.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e;i&&(this.#e=document.createElement("span"),this.#e.setAttribute("data-indicator",""),this.prepend(this.#e)),this.style.setProperty("--_segment-count",`${t.length}`),i?(this.#e.style.transition="none",this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#e&&(this.#e.style.transition="")})):(this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""))}#u(t){t.disabled||(this.value=t.value,this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#u(e)};#c=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#a,n=i.indexOf(e);if(n<0)return;let r;switch(t.key){case"ArrowRight":case"ArrowDown":r=n<i.length-1?n+1:0;break;case"ArrowLeft":case"ArrowUp":r=n>0?n-1:i.length-1;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}t.preventDefault(),i[r].focus(),this.#u(i[r])}};w("segmented-ui",sn);var nn=class extends z{static labelDeprecated=!1;static properties={...z.properties,value:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:100,reflect:!0},step:{type:Number,default:1,reflect:!0},label:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=0;#n=0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
114
114
  <span slot="label">${this.label}</span>
115
115
  <span slot="value">${this.#r(this.value)}</span>
116
116
  ${this.suffix?`<span slot="suffix">${this.suffix}</span>`:""}
@@ -140,7 +140,7 @@ parent-template-re-read pattern that works across frameworks.`);return}let t=thi
140
140
  `),this.#e=this.querySelector("section"),this.#i=this.querySelector("chat-input-ui"),this.#i?.addEventListener("submit",this.#n)}disconnected(){this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#i?.removeEventListener("submit",this.#n),this.#e=null,this.#i=null}#n=t=>{if(this.streaming)return;let{text:e,model:i}=t.detail||{};e&&(this.#i.clear(),this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,detail:{text:e,model:i}})))};appendMessage({role:t,content:e="",render:i=!1}){this.#t.push({role:t,content:e});let n=document.createElement("div");n.setAttribute("data-role",t);let r=i?hn(e):Gk(e);if(t==="user")n.innerHTML=`<div slot="bubble">${r}</div>`;else{let o=i?"":'<span slot="cursor"></span>';n.innerHTML=`
141
141
  <span slot="avatar">${t==="assistant"?"AI":t[0].toUpperCase()}</span>
142
142
  <div slot="bubble">${r}${o}</div>
143
- `}return this.#e?.appendChild(n),this.#r(),n}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role==="user")return;e.content+=t;let i=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');if(i){let n=i.querySelector('[slot="cursor"]');n&&n.remove(),i.insertAdjacentText("beforeend",t),i.insertAdjacentHTML("beforeend",'<span slot="cursor"></span>')}this.#r()}startStreaming(){this.streaming=!0,this.#i&&(this.#i.disabled=!0)}stopStreaming(){this.streaming=!1,this.#i&&(this.#i.disabled=!1),this.#e?.querySelector('[data-role]:last-child [slot="cursor"]')?.remove();let t=this.#t[this.#t.length-1];if(t&&t.role==="assistant"&&t.content){let e=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');e&&(e.innerHTML=hn(t.content))}this.#i?.focus()}clear(){this.#t.length=0,this.#e&&(this.#e.innerHTML="")}#r(){let t=this.#e;t&&(this.#s!=null&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.isConnected&&(t.scrollTop=t.scrollHeight)}))}};w("chat-thread-ui",cn);var un=class extends A{#t=!1;#e=!1;#i=null;#s=null;#n=null;#r=null;#o="programmatic";static properties={text:{type:String,default:"",reflect:!0},side:{type:String,default:"right",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"open");if(t?.set){let e=t.set;Object.defineProperty(this,"open",{get:t.get,set:i=>{e.call(this,i),this.#f()},configurable:!0})}}#a=t=>{t.target.closest('[slot="close"]')&&(this.#o="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#o="escape",this.permanent||(this.open=!1)};#u=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#o;this.#o="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#r&&!this.permanent&&(this.#o="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#a);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#u),t.addEventListener("click",this.#h))}disconnected(){this.removeEventListener("press",this.#a),this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#u),this.#r.removeEventListener("click",this.#h)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#n!=null&&(clearTimeout(this.#n),this.#n=null),this.#t=!1,this.#r=null}#c(){let t=getComputedStyle(this).getPropertyValue("--drawer-duration").trim();return parseFloat(t)||200}#d(t,e,i="append"){let n={header:"header",body:"section",footer:"footer"}[t],r=h=>h.getAttribute("slot")===t||n&&!h.getAttribute("slot")&&h.localName===n,o=[...this.children].find(r),a=[...e.children].find(h=>h.getAttribute("slot")===t);o&&a&&o!==a&&a.remove();let l=o||a||(()=>{let h=this.constructor._pp?.[t];if(!h)return null;let c=h.cloneNode(!0);return c.setAttribute("data-stamped",""),c})();return l?(l.getAttribute("slot")!==t&&l.setAttribute("slot",t),l.parentElement!==e&&(i==="prepend"?e.prepend(l):e.appendChild(l)),l):null}render(){let t=this.ensure("dialog");t!==this.#r&&(this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#u),this.#r.removeEventListener("click",this.#h)),this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#u),t.addEventListener("click",this.#h)),this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=this.#d("header",e,"prepend");if(i){let o=i.querySelector(':scope > [slot="heading"][data-stamped]'),a=[...i.children].some(l=>!l.hasAttribute("data-stamped")&&(l.getAttribute("slot")==="heading"||/^h[1-6]$/.test(l.localName)));this.text&&!a?(o||(o=document.createElement("span"),o.setAttribute("slot","heading"),o.setAttribute("data-stamped",""),i.prepend(o)),o.textContent!==this.text&&(o.textContent=this.text)):o&&o.remove()}if(this.permanent)this.drop("close");else{let o=this.ensure("close");i&&o.parentElement!==i&&i.appendChild(o)}let n=[...this.children].filter(o=>o.getAttribute("slot")==="body"||o.localName==="section"&&!o.getAttribute("slot"));if(n.length===0)this.#d("body",e,"append");else for(let o of n)o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o);let r=[...this.children].find(o=>o.getAttribute("slot")==="footer"||!o.getAttribute("slot")&&o.localName==="footer");r&&(r.getAttribute("slot")!=="footer"&&r.setAttribute("slot","footer"),r.parentElement!==e&&e.appendChild(r)),this.#f()}#f(){let t=this.#r;if(t&&t.isConnected)if(this.open&&!t.open){this.#e=!1,this.#i=document.activeElement;try{t.showModal()}catch(e){console.error("[drawer-ui] showModal() failed \u2014 dialog may be detached:",e)}t.offsetHeight,t.setAttribute("data-open",""),this.#n!=null&&clearTimeout(this.#n),this.#n=setTimeout(()=>{this.#n=null,this.dispatchEvent(new CustomEvent("opened",{bubbles:!0}))},this.#c())}else!this.open&&t.open&&!this.#e&&this.#p(t)}#p(t){this.#e=!0,this.#n!=null&&(clearTimeout(this.#n),this.#n=null),t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close()},this.#c())}show(){this.open=!0}hide(){this.open=!1}};w("drawer-ui",un);var dn=class extends A{#t=!1;#e=!1;#i=null;#s=null;#n=null;static properties={text:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};#r=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#o=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#a=()=>{this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0}))};#l=t=>{t.target===this.#n&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#r);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#o),t.addEventListener("close",this.#a),t.addEventListener("click",this.#l))}disconnected(){this.removeEventListener("press",this.#r),this.#n&&(this.#n.removeEventListener("cancel",this.#o),this.#n.removeEventListener("close",this.#a),this.#n.removeEventListener("click",this.#l)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#t=!1,this.#n=null}#u(){let t=getComputedStyle(this).getPropertyValue("--modal-duration").trim();return parseFloat(t)||200}render(){let t=this.ensure("dialog");this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=this.ensure("header");if(i.parentElement!==e&&e.prepend(i),i.setAttribute("text",this.text),this.permanent)this.drop("close");else{let l=this.ensure("close");l.parentElement!==i&&i.appendChild(l)}let n=[...this.children].find(l=>l.getAttribute("slot")==="body"||!l.getAttribute("slot")&&l.localName==="section"),r=[...this.children].filter(l=>!l.getAttribute("slot")&&l.localName!=="section"&&l.localName!=="dialog"&&l.localName!=="footer"),o;n?(n.getAttribute("slot")!=="body"&&n.setAttribute("slot","body"),n.parentElement!==e&&e.appendChild(n),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),o=n):(o=this.ensure("body"),o.setAttribute("data-stamped",""),o.parentElement!==e&&e.appendChild(o));for(let l of r)l!==o&&o.appendChild(l);let a=[...this.children].find(l=>l.getAttribute("slot")==="footer"||!l.getAttribute("slot")&&l.localName==="footer");if(a)a.getAttribute("slot")!=="footer"&&a.setAttribute("slot","footer"),a.parentElement!==e&&e.appendChild(a),e.querySelector(':scope > [slot="footer"][data-stamped]')?.remove();else{let l=this.ensure("footer");l.setAttribute("data-stamped",""),l.parentElement!==e&&e.appendChild(l)}this.open&&!t.open?(this.#e=!1,this.#i=document.activeElement,t.showModal(),t.offsetHeight,t.setAttribute("data-open","")):!this.open&&t.open&&!this.#e&&this.#h(t)}#h(t){this.#e=!0,t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close()},this.#u())}show(){this.open=!0}hide(){this.open=!1}};w("modal-ui",dn);var fn=class extends A{static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>Kt``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},pn=class s extends A{#t=null;#e=!1;#i=null;#s=null;static properties={text:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},action:{type:String,default:"",reflect:!0}};static parts={body:'<div slot="body"></div>'};static template=()=>Kt``;#n=t=>{if(t.target.closest("[data-feed-close]")){this.dismiss();return}if(t.target.closest("[data-feed-action]")){try{this.#r?.()}catch(e){console.warn("[feed-item] action handler threw:",e)}this.dismiss()}};#r=null;#o=null;#a=null;connected(){this.addEventListener("press",this.#n)}#l(){let t=getComputedStyle(this).getPropertyValue("--feed-item-duration").trim();return parseFloat(t)||200}render(){let t=this.ensure("body");if(t.textContent="",this.heading){let h=document.createElement("strong");h.textContent=this.heading,h.style.display="block",t.appendChild(h)}if(this.text){let h=document.createElement("span");h.textContent=this.text,t.appendChild(h)}let e=!this.duration||this.duration<=0,i=this.variant==="danger"||this.variant==="warning",n=e&&!!this.action,r="status";n?r="alertdialog":e&&i&&(r="alert"),this.setAttribute("role",r),this.setAttribute("aria-live",r==="alert"||r==="alertdialog"?"assertive":"polite"),n&&this.setAttribute("aria-modal","false");let o=this.dismissible||e,a=this.querySelector(":scope > [data-feed-close]");o&&!a?(a=document.createElement("button-ui"),a.setAttribute("data-feed-close",""),a.setAttribute("icon","x"),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label","Dismiss"),this.appendChild(a)):!o&&a&&a.remove();let l=this.querySelector(":scope > [data-feed-action]");this.action?(l||(l=document.createElement("button-ui"),l.setAttribute("data-feed-action",""),l.setAttribute("variant","ghost"),l.setAttribute("size","sm"),a&&a.parentElement===this?this.insertBefore(l,a):this.appendChild(l)),l.setAttribute("text",this.action)):l&&l.remove(),n?this.#h():this.#c(),!this.hasAttribute("data-open")&&!this.#e&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("data-open","")})),this.#u()}#u(){this.#t&&clearTimeout(this.#t),this.duration&&this.duration>0&&(this.#t=setTimeout(()=>this.dismiss(),this.duration))}dismiss(){this.#e||(this.#e=!0,this.#t&&(clearTimeout(this.#t),this.#t=null),this.removeAttribute("data-open"),this.setAttribute("data-closing",""),this.#i=setTimeout(()=>{this.#i=null;let t=this.parentElement;this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove(),t?.matches?.("feed-ui")&&Xe.releaseContainerIfEmpty(t)},this.#l()))}update(t){if(!(!t||typeof t!="object")){for(let e of Object.keys(t))e in s.properties&&(this[e]=t[e]);typeof t.onAction=="function"&&(this.#r=t.onAction),this.#u()}}#h(){if(this.#a)return;this.#o=document.activeElement;let t=()=>[...this.querySelectorAll('button, button-ui, [tabindex]:not([tabindex="-1"]), input, [data-feed-action], [data-feed-close]')].filter(e=>!e.hasAttribute("disabled")&&e.offsetParent!==null);this.#a=e=>{if(e.key==="Escape"){e.stopPropagation(),this.dismiss();return}if(e.key!=="Tab")return;let i=t();if(!i.length)return;let n=i[0],r=i[i.length-1],o=document.activeElement;e.shiftKey&&o===n?(e.preventDefault(),r.focus()):!e.shiftKey&&o===r&&(e.preventDefault(),n.focus())},this.addEventListener("keydown",this.#a,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#c(){if(this.#a){this.removeEventListener("keydown",this.#a,!0),this.#a=null;try{this.#o?.focus?.()}catch{}this.#o=null}}disconnected(){this.removeEventListener("press",this.#n),this.#t&&(clearTimeout(this.#t),this.#t=null),this.#i&&(clearTimeout(this.#i),this.#i=null),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#c()}},Xe=class s{static#t=new Map;static get(t="bottom-right"){let e=s.#t.get(t);if(e&&e.isConnected)return e;e=document.createElement("feed-ui"),e.setAttribute("position",t),"popover"in HTMLElement.prototype&&e.setAttribute("popover","manual"),document.body.appendChild(e);try{e.showPopover?.()}catch{}return s.#t.set(t,e),e}static post(t={}){let{text:e="",heading:i="",icon:n="",variant:r="default",duration:o=4e3,position:a="bottom-right",dismissible:l,id:h,action:c="",onAction:u}=t,d=r==="error"?"danger":r,f=s.get(a),p=parseInt(f.getAttribute("max")||"5",10),m=[...f.children].filter(g=>g.tagName==="FEED-ITEM-UI"&&!g.hasAttribute("data-queued")).length,O=document.createElement("feed-item-ui");return h&&O.setAttribute("data-id",h),O.text=e,O.heading=i,O.icon=n,O.variant=d,O.duration=c?0:o,l!=null&&(O.dismissible=!!l),c&&(O.action=c),m>=p&&O.setAttribute("data-queued",""),f.appendChild(O),typeof u=="function"&&O.update({onAction:u}),{id:h??null,dismiss:()=>O.dismiss(),update:g=>O.update(g)}}static clear(t="bottom-right"){let e=s.#t.get(t);if(e)for(let i of[...e.children])i.tagName==="FEED-ITEM-UI"&&i.dismiss?.()}static purge(){for(let t of s.#t.values()){try{t.hidePopover?.()}catch{}t.remove()}s.#t.clear()}static releaseContainerIfEmpty(t){if(!t)return;let e=t.querySelector("feed-item-ui[data-queued]");if(e&&e.removeAttribute("data-queued"),!(t.children.length>0)){try{t.hidePopover?.()}catch{}t.remove();for(let[i,n]of s.#t)n===t&&s.#t.delete(i)}}};w("feed-ui",fn),w("feed-item-ui",pn),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&Xe.post(s.detail)}));var Ji=class extends A{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"info",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},position:{type:String,default:"bottom-right",reflect:!0}};static template=()=>Kt``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,Xe.post({text:this.text,variant:this.variant==="error"?"danger":this.variant,duration:this.duration,position:this.position}),queueMicrotask(()=>{try{this.remove()}catch{}}))}static show(t={}){let{text:e,variant:i="info",duration:n=4e3,position:r="bottom-right"}=t,o=Xe.get(r);return o&&!o.hasAttribute("data-spawned-by")&&o.setAttribute("data-spawned-by","toast"),Xe.post({text:e,variant:i==="error"?"danger":i,duration:n,position:r})}};w("toast-ui",Ji),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&Ji.show(s.detail)}));var Ro=class extends A{static properties={text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","tabpanel")}render(){this.text&&this.setAttribute("aria-label",this.text),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}};customElements.define("tab-ui",Ro);var mn=class extends A{static properties={value:{type:String,default:"",reflect:!0},orientation:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.setAttribute("role","tablist"),this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l),!this.value){let t=this.querySelector("tab-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}}disconnected(){this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null),this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#l),this.#t=null,this.#e=null}get#s(){return[...this.querySelectorAll("tab-ui")]}get#n(){return this.#s.filter(t=>!t.disabled)}render(){let t=this.#s;if(t.length){this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("slot","strip"),this.#t.setAttribute("role","presentation")),this.#t.parentElement!==this&&this.prepend(this.#t),this.reconcile(this.#t,t,e=>e.value||e.getAttribute("value")||"",(e,i,n)=>{let r=e.value||e.getAttribute("value")||"",o=e.text||e.getAttribute("text")||"",a=e.icon||e.getAttribute("icon")||"",l=r===this.value,h=e.disabled||e.hasAttribute("disabled");if(n){if(n.textContent="",a){let u=document.createElement("icon-ui");u.setAttribute("name",a),n.appendChild(u)}return o&&n.appendChild(document.createTextNode(o)),n.setAttribute("aria-selected",String(l)),n.setAttribute("tabindex",l?"0":"-1"),h?n.setAttribute("disabled",""):n.removeAttribute("disabled"),l?n.setAttribute("data-active",""):n.removeAttribute("data-active"),n.dataset.value=r,n}let c=document.createElement("div");if(c.setAttribute("role","tab"),c.setAttribute("slot","tab-button"),c.dataset.value=r,c.setAttribute("aria-selected",String(l)),c.setAttribute("tabindex",l?"0":"-1"),h&&c.setAttribute("disabled",""),l&&c.setAttribute("data-active",""),a){let u=document.createElement("icon-ui");u.setAttribute("name",a),c.appendChild(u)}return o&&c.appendChild(document.createTextNode(o)),c}),this.#r();for(let e of t)(e.value||e.getAttribute("value")||"")===this.value?(e.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):e.setAttribute("hidden","")}}#r(){let t=this.#t?.querySelector('[slot="tab-button"][data-active]');if(!t){this.#e&&(this.#e.style.opacity="0");return}let e=!this.#e;e&&(this.#e=document.createElement("span"),this.#e.setAttribute("slot","indicator"),this.#t.appendChild(this.#e));let i=this.#t.getBoundingClientRect(),n=t.getBoundingClientRect(),r=this.orientation==="vertical",o=()=>{if(r){let a=n.top-i.top;this.#e.style.transform=`translateY(${a}px)`,this.#e.style.height=`${n.height}px`,this.#e.style.width=""}else{let a=n.left-i.left;this.#e.style.transform=`translateX(${a}px)`,this.#e.style.width=`${n.width}px`,this.#e.style.height=""}this.#e.style.opacity="1"};e?(this.#e.style.transition="none",o(),this.#i=requestAnimationFrame(()=>{this.#i=null,this.#e&&(this.#e.style.transition="")})):o()}#o(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#a=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#o(e.dataset.value)};#l=t=>{let e=t.target.closest('[slot="tab-button"]');if(!e||!this.contains(e))return;let i=[...this.#t.querySelectorAll('[slot="tab-button"]:not([disabled])')],n=i.indexOf(e);if(n<0)return;let r=this.orientation==="vertical",o=r?"ArrowDown":"ArrowRight",a=r?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=n<i.length-1?n+1:0;break;case a:l=n>0?n-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;default:return}t.preventDefault(),i[l].focus(),this.#o(i[l].dataset.value)}};w("tabs-ui",mn);var gn=class s extends A{static properties={text:{type:String,default:"",reflect:!0},placement:{type:String,default:"top",reflect:!0},delay:{type:Number,default:400,reflect:!0},follows:{type:String,default:"trigger",reflect:!0},for:{type:String,default:"",reflect:!0},indicator:{type:String,default:"none",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;connected(){this.follows==="pointer"?this.#u():(this.addEventListener("mouseenter",this.#r),this.addEventListener("focusin",this.#r),this.addEventListener("mouseleave",this.#o),this.addEventListener("focusout",this.#o))}disconnected(){this.removeEventListener("mouseenter",this.#r),this.removeEventListener("focusin",this.#r),this.removeEventListener("mouseleave",this.#o),this.removeEventListener("focusout",this.#o),this.#h(),this.#l()}render(){this.#t&&this.follows!=="pointer"&&(this.#t.textContent=this.text),this.#t&&this.follows==="pointer"&&this.#n&&this.#g(this.#n)}#r=()=>{this.text&&(this.#e&&clearTimeout(this.#e),this.#e=setTimeout(()=>this.#a(),this.delay))};#o=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#a(){if(this.#t)return;let t=document.createElement("div"),e=`tooltip-${Date.now()}`;t.id=e,t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.classList.add("tooltip-popup"),t.textContent=this.text,document.body.appendChild(t),this.setAttribute("aria-describedby",e);try{t.showPopover()}catch{}this.#t=t,this.#i=Tt(this,t,{placement:this.placement,gap:6})}#l(){if(this.#e&&(clearTimeout(this.#e),this.#e=null),!!this.#t){this.removeAttribute("aria-describedby"),this.#i?.(),this.#i=null;try{this.#t.hidePopover()}catch{}this.#t.remove(),this.#t=null,this.#n=null}}#u(){if(this.#h(),!this.for)return;let t=this.getRootNode();if(this.#s=t&&t.getElementById?t.getElementById(this.for):document.getElementById(this.for),!this.#s){s._warnedMissing||(s._warnedMissing=new WeakSet),s._warnedMissing.has(this)||(console.warn(`[tooltip-ui] follows="pointer" [for="${this.for}"] did not resolve to an element.`),s._warnedMissing.add(this));return}this.#s.addEventListener("chart-hover",this.#d),this.#s.addEventListener("chart-leave",this.#c)}#h(){this.#s&&(this.#s.removeEventListener("chart-hover",this.#d),this.#s.removeEventListener("chart-leave",this.#c)),this.#s=null}#c=()=>this.#l();#d=t=>{let e=t.detail;if(e){if(this.#n=e,!this.#t){this.#t=this.#f(),this.#p();try{this.#t.showPopover()}catch{}}this.#g(e),this.#O(e.pointerX,e.pointerY)}};#f(){let t=document.createElement("div");return t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.setAttribute("data-follows","pointer"),t.setAttribute("data-indicator",this.indicator||"none"),t.classList.add("tooltip-popup"),document.body.appendChild(t),t}#p(){if(!this.#s||!this.#t)return;let t=this.#s.style;for(let i=0;i<t.length;i++){let n=t[i];n.startsWith("--color-")&&this.#t.style.setProperty(n,t.getPropertyValue(n))}let e=getComputedStyle(this.#s);for(let i=0;i<10;i++){let n=e.getPropertyValue(`--chart-${i}`).trim();n&&this.#t.style.setProperty(`--chart-${i}`,n)}}#g(t){if(!this.#t)return;let{label:e,value:i,pct:n,series:r,slot:o,payload:a}=t,l=this.indicator||"none",h=Array.isArray(a)&&a.length>0?a:[{series:r,label:e,value:i,pct:n,slot:o,hovered:!0}],c=[];e!=null&&c.push(`<span data-tip-role="label">${this.#m(String(e))}</span>`);for(let u of h){let d=u.series??null,f=u.value,p=u.pct,m=u.slot!=null?u.slot:0,O=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let g=f!=null?this.#m(String(f)):"",y=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",v=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${O}"></span>`:"",x=d?`<span data-tip-role="name">${this.#m(d)}</span>`:"",S=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${S}>${v}${x}<span data-tip-role="value">${g}${y}</span></span>`)}this.#t.setAttribute("data-indicator",l),this.#t.setAttribute("aria-live","polite"),this.#t.innerHTML=c.join("")}#O(t,e){if(!this.#t||t==null||e==null)return;let i=12,n=8,r=this.#t;r.style.position="fixed",r.style.left="0",r.style.top="0";let o=r.offsetWidth||0,a=r.offsetHeight||0,l=t-o/2,h=e-a-i;l<n&&(l=n),l+o>window.innerWidth-n&&(l=window.innerWidth-o-n),h<n&&(h=e+i),r.style.left=`${l}px`,r.style.top=`${h}px`}#m(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}};w("tooltip-ui",gn);var Hk={new:{variant:"success",text:"New"},updated:{variant:"info",text:"Updated"},deprecated:{variant:"warning",text:"Deprecated"},removed:{variant:"danger",text:"Removed"},beta:{variant:"accent",text:"Beta"}},On=class extends A{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","status")}render(){if(this.status){let t=Hk[this.status];t&&(this.variant!==t.variant&&(this.variant=t.variant),this.text!==t.text&&(this.text=t.text))}if(this.text&&this.setAttribute("aria-label",this.text),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t&&t.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("size","sm"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};w("badge-ui",On);var bn=class extends A{static properties={separator:{type:String,default:"/",reflect:!0},collapse:{type:Boolean,default:!1,reflect:!0},collapseKeepLeading:{type:Number,default:1,attribute:"collapse-keep-leading",reflect:!0},collapseKeepTrailing:{type:Number,default:2,attribute:"collapse-keep-trailing",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","navigation"),this.setAttribute("aria-label","Breadcrumb")}render(){this.querySelectorAll("[data-sep], [data-overflow]").forEach(l=>l.remove());let t=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-overflow")),e=t.length-1;t.forEach((l,h)=>{l.setAttribute("data-item",""),l.removeAttribute("data-collapsed"),h===e?l.setAttribute("aria-current","page"):l.removeAttribute("aria-current")});let i=Math.max(0,this.collapseKeepLeading|0),n=Math.max(0,this.collapseKeepTrailing|0),r=i+n+1;if(this.collapse&&t.length>=Math.max(r,4)){let l=t.slice(i,t.length-n);l.forEach(c=>c.setAttribute("data-collapsed",""));let h=this.#t(l);i>0?t[i-1].after(h):this.prepend(h)}let a=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-collapsed"));for(let l=0;l<a.length-1;l++){let h=document.createElement("span");h.setAttribute("data-sep",""),h.setAttribute("aria-hidden","true"),h.textContent=this.separator,a[l].after(h)}}#t(t){let e=document.createElement("menu-ui");e.setAttribute("data-overflow",""),e.setAttribute("data-item",""),e.setAttribute("placement","bottom-start");let i=document.createElement("button-ui");i.setAttribute("slot","trigger"),i.setAttribute("text","\u2026"),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("aria-label","Show collapsed crumbs"),e.appendChild(i);for(let n of t){let r=document.createElement("menu-item-ui");r.setAttribute("text",n.textContent.trim()),n.tagName==="A"&&n.hasAttribute("href")&&r.setAttribute("value",n.getAttribute("href")),e.appendChild(r)}return e.addEventListener("action",n=>{let r=n.detail?.value;r&&r!=="#"&&(window.location.href=r)}),e}};w("breadcrumb-ui",bn);var yn=class s extends A{static requiredIcons=["magnifying-glass"];static properties={placeholder:{type:String,default:"Type a command...",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=[];#i=-1;#s=null;#n=null;#r=null;#o=null;#a=!1;#l=new WeakMap;static#u=3;#h=t=>{let e=t.target instanceof Element?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=this.#l.get(e);i&&this.#x(i)};#c=t=>{let e=t.target instanceof Element?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=parseInt(e.dataset.idx);Number.isFinite(i)&&i!==this.#i&&this.#v(i)};connected(){this.#a||(this.#a=!0,this.addEventListener("keydown",this.#y))}render(){this.#s||(this.#d(),this.innerHTML=`
143
+ `}return this.#e?.appendChild(n),this.#r(),n}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role==="user")return;e.content+=t;let i=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');if(i){let n=i.querySelector('[slot="cursor"]');n&&n.remove(),i.insertAdjacentText("beforeend",t),i.insertAdjacentHTML("beforeend",'<span slot="cursor"></span>')}this.#r()}startStreaming(){this.streaming=!0,this.#i&&(this.#i.disabled=!0)}stopStreaming(){this.streaming=!1,this.#i&&(this.#i.disabled=!1),this.#e?.querySelector('[data-role]:last-child [slot="cursor"]')?.remove();let t=this.#t[this.#t.length-1];if(t&&t.role==="assistant"&&t.content){let e=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');e&&(e.innerHTML=hn(t.content))}this.#i?.focus()}clear(){this.#t.length=0,this.#e&&(this.#e.innerHTML="")}#r(){let t=this.#e;t&&(this.#s!=null&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.isConnected&&(t.scrollTop=t.scrollHeight)}))}};w("chat-thread-ui",cn);var un=class extends A{#t=!1;#e=!1;#i=null;#s=null;#n=null;#r=null;#o="programmatic";static properties={text:{type:String,default:"",reflect:!0},side:{type:String,default:"right",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"open");if(t?.set){let e=t.set;Object.defineProperty(this,"open",{get:t.get,set:i=>{e.call(this,i),this.#f()},configurable:!0})}}#a=t=>{t.target.closest('[slot="close"]')&&(this.#o="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#o="escape",this.permanent||(this.open=!1)};#u=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#o;this.#o="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#r&&!this.permanent&&(this.#o="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#a);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#u),t.addEventListener("click",this.#h))}disconnected(){this.removeEventListener("press",this.#a),this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#u),this.#r.removeEventListener("click",this.#h)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#n!=null&&(clearTimeout(this.#n),this.#n=null),this.#t=!1,this.#r=null}#c(){let t=getComputedStyle(this).getPropertyValue("--drawer-duration").trim();return parseFloat(t)||200}#d(t,e,i="append"){let n={header:"header",body:"section",footer:"footer"}[t],r=h=>h.getAttribute("slot")===t||n&&!h.getAttribute("slot")&&h.localName===n,o=[...this.children].find(r),a=[...e.children].find(h=>h.getAttribute("slot")===t);o&&a&&o!==a&&a.remove();let l=o||a||(()=>{let h=this.constructor._pp?.[t];if(!h)return null;let c=h.cloneNode(!0);return c.setAttribute("data-stamped",""),c})();return l?(l.getAttribute("slot")!==t&&l.setAttribute("slot",t),l.parentElement!==e&&(i==="prepend"?e.prepend(l):e.appendChild(l)),l):null}render(){let t=this.ensure("dialog");t!==this.#r&&(this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#u),this.#r.removeEventListener("click",this.#h)),this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#u),t.addEventListener("click",this.#h)),this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=this.#d("header",e,"prepend");if(i){let o=i.querySelector(':scope > [slot="heading"][data-stamped]'),a=[...i.children].some(l=>!l.hasAttribute("data-stamped")&&(l.getAttribute("slot")==="heading"||/^h[1-6]$/.test(l.localName)));this.text&&!a?(o||(o=document.createElement("span"),o.setAttribute("slot","heading"),o.setAttribute("data-stamped",""),i.prepend(o)),o.textContent!==this.text&&(o.textContent=this.text)):o&&o.remove()}if(this.permanent)this.drop("close");else{let o=this.ensure("close");i&&o.parentElement!==i&&i.appendChild(o)}let n=[...this.children].filter(o=>o.getAttribute("slot")==="body"||o.localName==="section"&&!o.getAttribute("slot"));if(n.length===0)this.#d("body",e,"append");else for(let o of n)o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o);let r=[...this.children].find(o=>o.getAttribute("slot")==="footer"||!o.getAttribute("slot")&&o.localName==="footer");r&&(r.getAttribute("slot")!=="footer"&&r.setAttribute("slot","footer"),r.parentElement!==e&&e.appendChild(r)),this.#f()}#f(){let t=this.#r;if(t&&t.isConnected)if(this.open&&!t.open){this.#e=!1,this.#i=document.activeElement;try{t.showModal()}catch(e){console.error("[drawer-ui] showModal() failed \u2014 dialog may be detached:",e)}t.offsetHeight,t.setAttribute("data-open",""),this.#n!=null&&clearTimeout(this.#n),this.#n=setTimeout(()=>{this.#n=null,this.dispatchEvent(new CustomEvent("opened",{bubbles:!0}))},this.#c())}else!this.open&&t.open&&!this.#e&&this.#p(t)}#p(t){this.#e=!0,this.#n!=null&&(clearTimeout(this.#n),this.#n=null),t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close()},this.#c())}show(){this.open=!0}hide(){this.open=!1}};w("drawer-ui",un);var dn=class extends A{#t=!1;#e=!1;#i=null;#s=null;#n=null;static properties={text:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};#r=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#o=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#a=()=>{this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0}))};#l=t=>{t.target===this.#n&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#r);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#o),t.addEventListener("close",this.#a),t.addEventListener("click",this.#l))}disconnected(){this.removeEventListener("press",this.#r),this.#n&&(this.#n.removeEventListener("cancel",this.#o),this.#n.removeEventListener("close",this.#a),this.#n.removeEventListener("click",this.#l)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#t=!1,this.#n=null}#u(){let t=getComputedStyle(this).getPropertyValue("--modal-duration").trim();return parseFloat(t)||200}render(){let t=this.ensure("dialog");this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=this.ensure("header");if(i.parentElement!==e&&e.prepend(i),i.setAttribute("text",this.text),this.permanent)this.drop("close");else{let l=this.ensure("close");l.parentElement!==i&&i.appendChild(l)}let n=[...this.children].find(l=>l.getAttribute("slot")==="body"||!l.getAttribute("slot")&&l.localName==="section"),r=[...this.children].filter(l=>!l.getAttribute("slot")&&l.localName!=="section"&&l.localName!=="dialog"&&l.localName!=="footer"),o;n?(n.getAttribute("slot")!=="body"&&n.setAttribute("slot","body"),n.parentElement!==e&&e.appendChild(n),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),o=n):(o=this.ensure("body"),o.setAttribute("data-stamped",""),o.parentElement!==e&&e.appendChild(o));for(let l of r)l!==o&&o.appendChild(l);let a=[...this.children].find(l=>l.getAttribute("slot")==="footer"||!l.getAttribute("slot")&&l.localName==="footer");if(a)a.getAttribute("slot")!=="footer"&&a.setAttribute("slot","footer"),a.parentElement!==e&&e.appendChild(a),e.querySelector(':scope > [slot="footer"][data-stamped]')?.remove();else{let l=this.ensure("footer");l.setAttribute("data-stamped",""),l.parentElement!==e&&e.appendChild(l)}this.open&&!t.open?(this.#e=!1,this.#i=document.activeElement,t.showModal(),t.offsetHeight,t.setAttribute("data-open","")):!this.open&&t.open&&!this.#e&&this.#h(t)}#h(t){this.#e=!0,t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close()},this.#u())}show(){this.open=!0}hide(){this.open=!1}};w("modal-ui",dn);var fn=class extends A{static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>Kt``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},pn=class s extends A{#t=null;#e=!1;#i=null;#s=null;static properties={text:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},action:{type:String,default:"",reflect:!0}};static parts={body:'<div slot="body"></div>'};static template=()=>Kt``;#n=t=>{if(t.target.closest("[data-feed-close]")){this.dismiss();return}if(t.target.closest("[data-feed-action]")){try{this.#r?.()}catch(e){console.warn("[feed-item] action handler threw:",e)}this.dismiss()}};#r=null;#o=null;#a=null;connected(){this.addEventListener("press",this.#n)}#l(){let t=getComputedStyle(this).getPropertyValue("--feed-item-duration").trim();return parseFloat(t)||200}render(){let t=this.ensure("body");if(t.textContent="",this.heading){let h=document.createElement("strong");h.textContent=this.heading,h.style.display="block",t.appendChild(h)}if(this.text){let h=document.createElement("span");h.textContent=this.text,t.appendChild(h)}let e=!this.duration||this.duration<=0,i=this.variant==="danger"||this.variant==="warning",n=e&&!!this.action,r="status";n?r="alertdialog":e&&i&&(r="alert"),this.setAttribute("role",r),this.setAttribute("aria-live",r==="alert"||r==="alertdialog"?"assertive":"polite"),n&&this.setAttribute("aria-modal","false");let o=this.dismissible||e,a=this.querySelector(":scope > [data-feed-close]");o&&!a?(a=document.createElement("button-ui"),a.setAttribute("data-feed-close",""),a.setAttribute("icon","x"),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label","Dismiss"),this.appendChild(a)):!o&&a&&a.remove();let l=this.querySelector(":scope > [data-feed-action]");this.action?(l||(l=document.createElement("button-ui"),l.setAttribute("data-feed-action",""),l.setAttribute("variant","ghost"),l.setAttribute("size","sm"),a&&a.parentElement===this?this.insertBefore(l,a):this.appendChild(l)),l.setAttribute("text",this.action)):l&&l.remove(),n?this.#h():this.#c(),!this.hasAttribute("data-open")&&!this.#e&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("data-open","")})),this.#u()}#u(){this.#t&&clearTimeout(this.#t),this.duration&&this.duration>0&&(this.#t=setTimeout(()=>this.dismiss(),this.duration))}dismiss(){this.#e||(this.#e=!0,this.#t&&(clearTimeout(this.#t),this.#t=null),this.removeAttribute("data-open"),this.setAttribute("data-closing",""),this.#i=setTimeout(()=>{this.#i=null;let t=this.parentElement;this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove(),t?.matches?.("feed-ui")&&Xe.releaseContainerIfEmpty(t)},this.#l()))}update(t){if(!(!t||typeof t!="object")){for(let e of Object.keys(t))e in s.properties&&(this[e]=t[e]);typeof t.onAction=="function"&&(this.#r=t.onAction),this.#u()}}#h(){if(this.#a)return;this.#o=document.activeElement;let t=()=>[...this.querySelectorAll('button, button-ui, [tabindex]:not([tabindex="-1"]), input, [data-feed-action], [data-feed-close]')].filter(e=>!e.hasAttribute("disabled")&&e.offsetParent!==null);this.#a=e=>{if(e.key==="Escape"){e.stopPropagation(),this.dismiss();return}if(e.key!=="Tab")return;let i=t();if(!i.length)return;let n=i[0],r=i[i.length-1],o=document.activeElement;e.shiftKey&&o===n?(e.preventDefault(),r.focus()):!e.shiftKey&&o===r&&(e.preventDefault(),n.focus())},this.addEventListener("keydown",this.#a,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#c(){if(this.#a){this.removeEventListener("keydown",this.#a,!0),this.#a=null;try{this.#o?.focus?.()}catch{}this.#o=null}}disconnected(){this.removeEventListener("press",this.#n),this.#t&&(clearTimeout(this.#t),this.#t=null),this.#i&&(clearTimeout(this.#i),this.#i=null),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#c()}},Xe=class s{static#t=new Map;static get(t="bottom-right"){let e=s.#t.get(t);if(e&&e.isConnected)return e;e=document.createElement("feed-ui"),e.setAttribute("position",t),"popover"in HTMLElement.prototype&&e.setAttribute("popover","manual"),document.body.appendChild(e);try{e.showPopover?.()}catch{}return s.#t.set(t,e),e}static post(t={}){let{text:e="",heading:i="",icon:n="",variant:r="default",duration:o=4e3,position:a="bottom-right",dismissible:l,id:h,action:c="",onAction:u}=t,d=r==="error"?"danger":r,f=s.get(a),p=parseInt(f.getAttribute("max")||"5",10),m=[...f.children].filter(g=>g.tagName==="FEED-ITEM-UI"&&!g.hasAttribute("data-queued")).length,O=document.createElement("feed-item-ui");return h&&O.setAttribute("data-id",h),O.text=e,O.heading=i,O.icon=n,O.variant=d,O.duration=c?0:o,l!=null&&(O.dismissible=!!l),c&&(O.action=c),m>=p&&O.setAttribute("data-queued",""),f.appendChild(O),typeof u=="function"&&O.update({onAction:u}),{id:h??null,dismiss:()=>O.dismiss(),update:g=>O.update(g)}}static clear(t="bottom-right"){let e=s.#t.get(t);if(e)for(let i of[...e.children])i.tagName==="FEED-ITEM-UI"&&i.dismiss?.()}static purge(){for(let t of s.#t.values()){try{t.hidePopover?.()}catch{}t.remove()}s.#t.clear()}static releaseContainerIfEmpty(t){if(!t)return;let e=t.querySelector("feed-item-ui[data-queued]");if(e&&e.removeAttribute("data-queued"),!(t.children.length>0)){try{t.hidePopover?.()}catch{}t.remove();for(let[i,n]of s.#t)n===t&&s.#t.delete(i)}}};w("feed-ui",fn),w("feed-item-ui",pn),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&Xe.post(s.detail)}));var Ji=class extends A{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"info",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},position:{type:String,default:"bottom-right",reflect:!0}};static template=()=>Kt``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,Xe.post({text:this.text,variant:this.variant==="error"?"danger":this.variant,duration:this.duration,position:this.position}),queueMicrotask(()=>{try{this.remove()}catch{}}))}static show(t={}){let{text:e,variant:i="info",duration:n=4e3,position:r="bottom-right"}=t,o=Xe.get(r);return o&&!o.hasAttribute("data-spawned-by")&&o.setAttribute("data-spawned-by","toast"),Xe.post({text:e,variant:i==="error"?"danger":i,duration:n,position:r})}};w("toast-ui",Ji),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&Ji.show(s.detail)}));var Ro=class extends A{static properties={text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","tabpanel")}render(){this.text&&this.setAttribute("aria-label",this.text),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}};customElements.define("tab-ui",Ro);var mn=class extends A{static properties={value:{type:String,default:"",reflect:!0},orientation:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.setAttribute("role","tablist"),this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l),!this.value){let t=this.querySelector("tab-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}}disconnected(){this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null),this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#l),this.#t=null,this.#e=null}get#s(){return[...this.querySelectorAll("tab-ui")]}get#n(){return this.#s.filter(t=>!t.disabled)}render(){let t=this.#s;if(t.length){this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("slot","strip"),this.#t.setAttribute("role","presentation")),this.#t.parentElement!==this&&this.prepend(this.#t),this.reconcile(this.#t,t,e=>e.value||e.getAttribute("value")||"",(e,i,n)=>{let r=e.value||e.getAttribute("value")||"",o=e.text||e.getAttribute("text")||"",a=e.icon||e.getAttribute("icon")||"",l=r===this.value,h=e.disabled||e.hasAttribute("disabled");if(n){if(n.textContent="",a){let u=document.createElement("icon-ui");u.setAttribute("name",a),n.appendChild(u)}return o&&n.appendChild(document.createTextNode(o)),n.setAttribute("aria-selected",String(l)),n.setAttribute("tabindex",l?"0":"-1"),h?n.setAttribute("disabled",""):n.removeAttribute("disabled"),l?n.setAttribute("data-active",""):n.removeAttribute("data-active"),n.dataset.value=r,n}let c=document.createElement("div");if(c.setAttribute("role","tab"),c.setAttribute("slot","tab-button"),c.dataset.value=r,c.setAttribute("aria-selected",String(l)),c.setAttribute("tabindex",l?"0":"-1"),h&&c.setAttribute("disabled",""),l&&c.setAttribute("data-active",""),a){let u=document.createElement("icon-ui");u.setAttribute("name",a),c.appendChild(u)}return o&&c.appendChild(document.createTextNode(o)),c}),this.#r();for(let e of t)(e.value||e.getAttribute("value")||"")===this.value?(e.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):e.setAttribute("hidden","")}}#r(){let t=this.#t?.querySelector('[slot="tab-button"][data-active]');if(!t){this.#e&&(this.#e.style.opacity="0");return}let e=!this.#e;e&&(this.#e=document.createElement("span"),this.#e.setAttribute("slot","indicator"),this.#t.appendChild(this.#e));let i=this.#t.getBoundingClientRect(),n=t.getBoundingClientRect(),r=this.orientation==="vertical",o=()=>{if(r){let a=n.top-i.top;this.#e.style.transform=`translateY(${a}px)`,this.#e.style.height=`${n.height}px`,this.#e.style.width=""}else{let a=n.left-i.left;this.#e.style.transform=`translateX(${a}px)`,this.#e.style.width=`${n.width}px`,this.#e.style.height=""}this.#e.style.opacity="1"};e?(this.#e.style.transition="none",o(),this.#i=requestAnimationFrame(()=>{this.#i=null,this.#e&&(this.#e.style.transition="")})):o()}#o(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#a=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#o(e.dataset.value)};#l=t=>{let e=t.target.closest('[slot="tab-button"]');if(!e||!this.contains(e))return;let i=[...this.#t.querySelectorAll('[slot="tab-button"]:not([disabled])')],n=i.indexOf(e);if(n<0)return;let r=this.orientation==="vertical",o=r?"ArrowDown":"ArrowRight",a=r?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=n<i.length-1?n+1:0;break;case a:l=n>0?n-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;default:return}t.preventDefault(),i[l].focus(),this.#o(i[l].dataset.value)}};w("tabs-ui",mn);var gn=class s extends A{static properties={text:{type:String,default:"",reflect:!0},placement:{type:String,default:"top",reflect:!0},delay:{type:Number,default:400,reflect:!0},follows:{type:String,default:"trigger",reflect:!0},for:{type:String,default:"",reflect:!0},indicator:{type:String,default:"none",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;connected(){this.follows==="pointer"?this.#u():(this.addEventListener("mouseenter",this.#r),this.addEventListener("focusin",this.#r),this.addEventListener("mouseleave",this.#o),this.addEventListener("focusout",this.#o))}disconnected(){this.removeEventListener("mouseenter",this.#r),this.removeEventListener("focusin",this.#r),this.removeEventListener("mouseleave",this.#o),this.removeEventListener("focusout",this.#o),this.#h(),this.#l()}render(){this.#t&&this.follows!=="pointer"&&(this.#t.textContent=this.text),this.#t&&this.follows==="pointer"&&this.#n&&this.#g(this.#n)}#r=()=>{this.text&&(this.#e&&clearTimeout(this.#e),this.#e=setTimeout(()=>this.#a(),this.delay))};#o=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#a(){if(this.#t)return;let t=document.createElement("div"),e=`tooltip-${Date.now()}`;t.id=e,t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.classList.add("tooltip-popup"),t.textContent=this.text,document.body.appendChild(t),this.setAttribute("aria-describedby",e);try{t.showPopover()}catch{}this.#t=t,this.#i=Tt(this,t,{placement:this.placement,gap:6})}#l(){if(this.#e&&(clearTimeout(this.#e),this.#e=null),!!this.#t){this.removeAttribute("aria-describedby"),this.#i?.(),this.#i=null;try{this.#t.hidePopover()}catch{}this.#t.remove(),this.#t=null,this.#n=null}}#u(){if(this.#h(),!this.for)return;let t=this.getRootNode();if(this.#s=t&&t.getElementById?t.getElementById(this.for):document.getElementById(this.for),!this.#s){s._warnedMissing||(s._warnedMissing=new WeakSet),s._warnedMissing.has(this)||(console.warn(`[tooltip-ui] follows="pointer" [for="${this.for}"] did not resolve to an element.`),s._warnedMissing.add(this));return}this.#s.addEventListener("chart-hover",this.#d),this.#s.addEventListener("chart-leave",this.#c)}#h(){this.#s&&(this.#s.removeEventListener("chart-hover",this.#d),this.#s.removeEventListener("chart-leave",this.#c)),this.#s=null}#c=()=>this.#l();#d=t=>{let e=t.detail;if(e){if(this.#n=e,!this.#t){this.#t=this.#f(),this.#p();try{this.#t.showPopover()}catch{}}this.#g(e),this.#O(e.pointerX,e.pointerY)}};#f(){let t=document.createElement("div");return t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.setAttribute("data-follows","pointer"),t.setAttribute("data-indicator",this.indicator||"none"),t.classList.add("tooltip-popup"),document.body.appendChild(t),t}#p(){if(!this.#s||!this.#t)return;let t=this.#s.style;for(let i=0;i<t.length;i++){let n=t[i];n.startsWith("--color-")&&this.#t.style.setProperty(n,t.getPropertyValue(n))}let e=getComputedStyle(this.#s);for(let i=0;i<10;i++){let n=e.getPropertyValue(`--chart-${i}`).trim();n&&this.#t.style.setProperty(`--chart-${i}`,n)}}#g(t){if(!this.#t)return;let{label:e,value:i,pct:n,series:r,slot:o,payload:a}=t,l=this.indicator||"none",h=Array.isArray(a)&&a.length>0?a:[{series:r,label:e,value:i,pct:n,slot:o,hovered:!0}],c=[];e!=null&&c.push(`<span data-tip-role="label">${this.#m(String(e))}</span>`);for(let u of h){let d=u.series??null,f=u.value,p=u.pct,m=u.slot!=null?u.slot:0,O=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let g=f!=null?this.#m(String(f)):"",y=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",v=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${O}"></span>`:"",x=d?`<span data-tip-role="name">${this.#m(d)}</span>`:"",S=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${S}>${v}${x}<span data-tip-role="value">${g}${y}</span></span>`)}this.#t.setAttribute("data-indicator",l),this.#t.setAttribute("aria-live","polite"),this.#t.innerHTML=c.join("")}#O(t,e){if(!this.#t||t==null||e==null)return;let i=12,n=8,r=this.#t;r.style.position="fixed",r.style.left="0",r.style.top="0";let o=r.offsetWidth||0,a=r.offsetHeight||0,l=t-o/2,h=e-a-i;l<n&&(l=n),l+o>window.innerWidth-n&&(l=window.innerWidth-o-n),h<n&&(h=e+i),r.style.left=`${l}px`,r.style.top=`${h}px`}#m(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}};w("tooltip-ui",gn);var Hk={new:{variant:"success",text:"New"},updated:{variant:"info",text:"Updated"},deprecated:{variant:"warning",text:"Deprecated"},removed:{variant:"danger",text:"Removed"},beta:{variant:"accent",text:"Beta"}},On=class extends A{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","status")}render(){if(this.status){let t=Hk[this.status];t&&(this.variant!==t.variant&&(this.variant=t.variant),this.text!==t.text&&(this.text=t.text))}if(this.text&&this.setAttribute("aria-label",this.text),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t&&t.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("size","sm"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};w("badge-ui",On);var bn=class extends A{static properties={separator:{type:String,default:"/",reflect:!0},collapse:{type:Boolean,default:!1,reflect:!0},collapseKeepLeading:{type:Number,default:1,attribute:"collapse-keep-leading",reflect:!0},collapseKeepTrailing:{type:Number,default:2,attribute:"collapse-keep-trailing",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","navigation"),this.setAttribute("aria-label","Breadcrumb")}render(){this.querySelectorAll("[data-sep], [data-overflow]").forEach(l=>l.remove());let t=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-overflow")),e=t.length-1;t.forEach((l,h)=>{l.setAttribute("data-item",""),l.removeAttribute("data-collapsed"),h===e?l.setAttribute("aria-current","page"):l.removeAttribute("aria-current")});let i=Math.max(0,this.collapseKeepLeading|0),n=Math.max(0,this.collapseKeepTrailing|0),r=i+n+1;if(this.collapse&&t.length>=Math.max(r,4)){let l=t.slice(i,t.length-n);l.forEach(c=>c.setAttribute("data-collapsed",""));let h=this.#t(l);i>0?t[i-1].after(h):this.prepend(h)}let a=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-collapsed"));for(let l=0;l<a.length-1;l++){let h=document.createElement("span");h.setAttribute("data-sep",""),h.setAttribute("aria-hidden","true"),h.textContent=this.separator,a[l].after(h)}}#t(t){let e=document.createElement("menu-ui");e.setAttribute("data-overflow",""),e.setAttribute("data-item",""),e.setAttribute("placement","bottom-start");let i=document.createElement("button-ui");i.setAttribute("slot","trigger"),i.setAttribute("text","\u2026"),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("aria-label","Show collapsed crumbs"),e.appendChild(i);for(let n of t){let r=document.createElement("menu-item-ui");r.setAttribute("text",n.textContent.trim()),n.tagName==="A"&&n.hasAttribute("href")&&r.setAttribute("value",n.getAttribute("href")),e.appendChild(r)}return e.addEventListener("action",n=>{let r=n.detail?.value;r&&r!=="#"&&(window.location.href=r)}),e}};w("breadcrumb-ui",bn);var yn=class s extends A{static requiredIcons=["magnifying-glass"];static properties={placeholder:{type:String,default:"Type a command...",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=[];#i=-1;#s=null;#n=null;#r=null;#o=null;#a=!1;#l=new WeakMap;static#u=3;#h=t=>{let e=t.target instanceof Element?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=this.#l.get(e);i&&this.#v(i)};#c=t=>{let e=t.target instanceof Element?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=parseInt(e.dataset.idx);Number.isFinite(i)&&i!==this.#i&&this.#x(i)};connected(){this.#a||(this.#a=!0,this.addEventListener("keydown",this.#y))}render(){this.#s||(this.#d(),this.innerHTML=`
144
144
  <header>
145
145
  <icon-ui name="magnifying-glass" slot="icon"></icon-ui>
146
146
  <input type="text" placeholder="${this.placeholder}" slot="input" />
@@ -151,29 +151,29 @@ parent-template-re-read pattern that works across frameworks.`);return}let t=thi
151
151
  <span data-hint><kbd>\u21B5</kbd> Select</span>
152
152
  <span data-hint><kbd>\u238B</kbd> Close</span>
153
153
  </footer>
154
- `,this.#s=this.querySelector("input"),this.#n=this.querySelector('[slot="list"]'),this.#o=this.querySelector("footer"),this.#s.addEventListener("input",this.#k),this.#n.addEventListener("click",this.#h),this.#n.addEventListener("pointerover",this.#c),this.#p()),this.open&&(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#s?.focus()}))}get value(){return this.#s?.value||""}set value(t){if(!this.#s)return;let e=t??"";this.#s.value=e,this.#p(e)}focus(){this.#s?.focus()}setItems(t){this.#t=t,this.#p()}#d(){let t=[];for(let e of this.children)if(e.tagName==="OPTGROUP"){let i=e.label,n={label:i,items:[]};for(let r of e.querySelectorAll("option"))n.items.push(this.#f(r,i));t.push(n)}else e.tagName==="OPTION"&&t.push(this.#f(e,""));this.#t=t}#f(t,e=""){return{value:t.value,label:t.textContent.trim(),icon:t.dataset.icon||"",shortcut:t.dataset.shortcut||"",keywords:t.dataset.keywords||"",disabled:t.disabled,category:e}}#p(t=""){if(!this.#n)return;this.#n.innerHTML="",this.#i=-1;let e=t.toLowerCase(),i=this.#t,n=0;if(!e&&this.#e.length){let r=this.#e.map(o=>this.#g(o)).filter(o=>o&&!o.disabled);if(r.length){let o=document.createElement("div");o.setAttribute("data-group",""),o.setAttribute("data-recent",""),o.innerHTML="<div data-group-label>Recent</div>";for(let a of r)o.appendChild(this.#m(a,n)),n++;this.#n.appendChild(o)}}for(let r of i)if(r.items){let o=r.items.filter(l=>this.#b(l,e));if(!o.length)continue;let a=document.createElement("div");a.setAttribute("data-group",""),a.innerHTML=`<div data-group-label>${r.label}</div>`;for(let l of o)a.appendChild(this.#m(l,n)),n++;this.#n.appendChild(a)}else{if(!this.#b(r,e))continue;this.#n.appendChild(this.#m(r,n)),n++}if(!n){let r=document.createElement("div");r.setAttribute("data-empty",""),r.textContent="No results found.",this.#n.appendChild(r)}n>0&&this.#v(0)}#g(t){for(let e of this.#t)if(e.items){let i=e.items.find(n=>n.value===t);if(i)return i}else if(e.value===t)return e;return null}#O(t){t&&(this.#e=[t,...this.#e.filter(e=>e!==t)].slice(0,s.#u))}#m(t,e){let i=document.createElement("div");return i.setAttribute("role","option"),i.setAttribute("data-value",t.value),i.setAttribute("data-idx",e),t.disabled&&i.setAttribute("aria-disabled","true"),i.innerHTML=`
154
+ `,this.#s=this.querySelector("input"),this.#n=this.querySelector('[slot="list"]'),this.#o=this.querySelector("footer"),this.#s.addEventListener("input",this.#k),this.#n.addEventListener("click",this.#h),this.#n.addEventListener("pointerover",this.#c),this.#p()),this.open&&(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#s?.focus()}))}get value(){return this.#s?.value||""}set value(t){if(!this.#s)return;let e=t??"";this.#s.value=e,this.#p(e)}focus(){this.#s?.focus()}setItems(t){this.#t=t,this.#p()}#d(){let t=[];for(let e of this.children)if(e.tagName==="OPTGROUP"){let i=e.label,n={label:i,items:[]};for(let r of e.querySelectorAll("option"))n.items.push(this.#f(r,i));t.push(n)}else e.tagName==="OPTION"&&t.push(this.#f(e,""));this.#t=t}#f(t,e=""){return{value:t.value,label:t.textContent.trim(),icon:t.dataset.icon||"",shortcut:t.dataset.shortcut||"",keywords:t.dataset.keywords||"",disabled:t.disabled,category:e}}#p(t=""){if(!this.#n)return;this.#n.innerHTML="",this.#i=-1;let e=t.toLowerCase(),i=this.#t,n=0;if(!e&&this.#e.length){let r=this.#e.map(o=>this.#g(o)).filter(o=>o&&!o.disabled);if(r.length){let o=document.createElement("div");o.setAttribute("data-group",""),o.setAttribute("data-recent",""),o.innerHTML="<div data-group-label>Recent</div>";for(let a of r)o.appendChild(this.#m(a,n)),n++;this.#n.appendChild(o)}}for(let r of i)if(r.items){let o=r.items.filter(l=>this.#b(l,e));if(!o.length)continue;let a=document.createElement("div");a.setAttribute("data-group",""),a.innerHTML=`<div data-group-label>${r.label}</div>`;for(let l of o)a.appendChild(this.#m(l,n)),n++;this.#n.appendChild(a)}else{if(!this.#b(r,e))continue;this.#n.appendChild(this.#m(r,n)),n++}if(!n){let r=document.createElement("div");r.setAttribute("data-empty",""),r.textContent="No results found.",this.#n.appendChild(r)}n>0&&this.#x(0)}#g(t){for(let e of this.#t)if(e.items){let i=e.items.find(n=>n.value===t);if(i)return i}else if(e.value===t)return e;return null}#O(t){t&&(this.#e=[t,...this.#e.filter(e=>e!==t)].slice(0,s.#u))}#m(t,e){let i=document.createElement("div");return i.setAttribute("role","option"),i.setAttribute("data-value",t.value),i.setAttribute("data-idx",e),t.disabled&&i.setAttribute("aria-disabled","true"),i.innerHTML=`
155
155
  ${t.icon?`<icon-ui name="${t.icon}"></icon-ui>`:""}
156
156
  <span data-text>${t.label}</span>
157
157
  ${t.shortcut?`<span data-shortcut>${t.shortcut}</span>`:""}
158
- `,this.#l.set(i,t),i}#b(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#v(t){let e=this.#n.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#n.querySelector("[data-active]");i&&i.removeAttribute("data-active");let n=[...e].find(r=>parseInt(r.dataset.idx)===t);n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#i=t)}#S(t){let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#n.querySelector("[data-active]"),r=(i?e.indexOf(i):-1)+t;r<0&&(r=e.length-1),r>=e.length&&(r=0),this.#v(parseInt(e[r].dataset.idx))}#x(t){this.#O(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#w(){let t=this.#n.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",r=(this.#l.get(t)||this.#g(e))?.category||"";this.#O(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:r}}))}#k=()=>{this.#p(this.#s.value)};#y=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#S(1);break;case"ArrowUp":t.preventDefault(),this.#S(-1);break;case"Enter":t.preventDefault(),this.#w();break;case"Tab":t.preventDefault(),this.#w();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),this.removeEventListener("keydown",this.#y),this.#s?.removeEventListener("input",this.#k),this.#n?.removeEventListener("click",this.#h),this.#n?.removeEventListener("pointerover",this.#c),this.#s=null,this.#n=null,this.#o=null,this.#a=!1}};w("command-ui",yn);var Xo=.4;function iu(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function su(s,t,e){let i=s+.3963377774*t+.2158037573*e,n=s-.1055613458*t-.0638541728*e,r=s-.0894841775*t-1.291485548*e,o=i*i*i,a=n*n*n,l=r*r*r;return[4.0767416621*o-3.3077115913*a+.2309699292*l,-1.2684380046*o+2.6097574011*a-.3413193965*l,-.0041960863*o-.7034186147*a+1.707614701*l]}function ii(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function nu(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function Vg(s,t,e){let{a:i,b:n}=iu(s,t,e),[r,o,a]=su(s,i,n);return[Math.max(0,Math.min(1,ii(r))),Math.max(0,Math.min(1,ii(o))),Math.max(0,Math.min(1,ii(a)))]}function Kk(s,t,e){let i=n=>Math.round(n*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function vn(s,t,e){let[i,n,r]=Vg(s,t,e);return Kk(i,n,r)}function Jk(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=nu(parseInt(s.slice(0,2),16)/255),e=nu(parseInt(s.slice(2,4),16)/255),i=nu(parseInt(s.slice(4,6),16)/255),n=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*i),r=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*i),o=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*i),a=.2104542553*n+.793617785*r-.0040720468*o,l=1.9779984951*n-2.428592205*r+.4505937099*o,h=.0259040371*n+.7827717662*r-.808675766*o,c=Math.sqrt(l*l+h*h),u=Math.atan2(h,l)*180/Math.PI;return u<0&&(u+=360),{L:a,C:c,H:u}}function Wg(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Io(s,t,e){let{a:i,b:n}=iu(s,t,e),[r,o,a]=su(s,i,n);if(Wg(ii(r),ii(o),ii(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=iu(s,u,e),[p,m,O]=su(s,d,f);Wg(ii(p),ii(m),ii(O))?l=u:h=u}return l}var xn=class s extends z{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#n=NaN;#r=!1;#o=null;#a=!1;#l=null;#u=null;#h=null;#c=null;#d=null;#f=null;#p=null;#g=null;#O=null;#m=null;#b=null;#v=null;#S=[];#x=null;static template=()=>null;#w=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#I("input")};#k=t=>{this.disabled||(this.#o="area",this.#h.setPointerCapture(t.pointerId),this.#Z(t))};#y=t=>{this.#o==="area"&&this.#Z(t)};#$=()=>{this.#o==="area"&&(this.#o=null,this.#I("change"))};#Q=t=>{this.disabled||(this.#o="hue",this.#d.setPointerCapture(t.pointerId),this.#X(t))};#P=t=>{this.#o==="hue"&&this.#X(t)};#C=()=>{this.#o==="hue"&&(this.#o=null,this.#I("change"))};#L=t=>{if(this.disabled)return;let e=t.shiftKey?.05:.01,i=t.shiftKey?.04:.004;switch(t.key){case"ArrowRight":t.preventDefault(),this.#i=Math.min(Xo,this.#i+i);break;case"ArrowLeft":t.preventDefault(),this.#i=Math.max(0,this.#i-i);break;case"ArrowUp":t.preventDefault(),this.#e=Math.min(1,this.#e+e);break;case"ArrowDown":t.preventDefault(),this.#e=Math.max(0,this.#e-e);break;default:return}this.#I("change")};#E=t=>{if(this.disabled)return;let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#s=(this.#s+e)%360;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#s=(this.#s-e+360)%360;break;default:return}this.#I("change")};connected(){if(super.connected(),this.#M(this.value),this.#r)return;this.#r=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#u=this.#l.getContext("2d",{willReadFrequently:!0}),this.#c=document.createElement("div"),this.#c.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#c),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(r,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",r),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#w),t.appendChild(c),c};this.#m=e("H","hue",0,360,1),this.#b=e("C","chroma",0,Xo,.001),this.#v=e("L","lightness",0,1,.001),this.appendChild(t),this.#d=document.createElement("div"),this.#d.setAttribute("data-hue-track",""),this.#d.setAttribute("tabindex","0"),this.#d.setAttribute("role","slider"),this.#d.setAttribute("aria-label","Hue"),this.#f=document.createElement("div"),this.#f.setAttribute("data-hue-thumb",""),this.#d.appendChild(this.#f),this.appendChild(this.#d);let i=document.createElement("div");i.setAttribute("data-output","");let n=r=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",r);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",r),l.setAttribute("aria-label",`Copy ${r}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#D(r,l);return l.addEventListener("click",h),this.#S.push({el:l,handler:h}),o.appendChild(a),o.appendChild(l),i.appendChild(o),a};this.#p=n("oklch"),this.#g=n("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#k),this.#h.addEventListener("pointermove",this.#y),this.#h.addEventListener("pointerup",this.#$),this.#d.addEventListener("pointerdown",this.#Q),this.#d.addEventListener("pointermove",this.#P),this.#d.addEventListener("pointerup",this.#C),this.#h.addEventListener("keydown",this.#L),this.#d.addEventListener("keydown",this.#E),this.#O=new ResizeObserver(()=>this.#q()),this.#O.observe(this.#h)}disconnected(){super.disconnected(),this.#x!=null&&(clearTimeout(this.#x),this.#x=null),this.#O&&(this.#O.disconnect(),this.#O=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#k),this.#h.removeEventListener("pointermove",this.#y),this.#h.removeEventListener("pointerup",this.#$),this.#h.removeEventListener("keydown",this.#L)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#Q),this.#d.removeEventListener("pointermove",this.#P),this.#d.removeEventListener("pointerup",this.#C),this.#d.removeEventListener("keydown",this.#E)),this.#m?.removeEventListener("input",this.#w),this.#b?.removeEventListener("input",this.#w),this.#v?.removeEventListener("input",this.#w);for(let{el:t,handler:e}of this.#S)t.removeEventListener("click",e);this.#S=[],this.#r=!1}#Z(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),n=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*Xo,this.#e=1-n,this.#I("input")}#X(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#I("input")}#M(t){if(t){if(t.startsWith("#")){let e=Jk(t);this.#e=e.L,this.#i=e.C,this.#s=e.H;return}if(t.startsWith("oklch(")){let e=t.match(/oklch\(\s*([\d.]+%?|NaN|none)\s+([\d.]+%?|NaN|none)\s+([\d.]+|NaN|none)/i);if(e){let i=(n,r)=>n==="none"||/^NaN$/i.test(n)?0:r&&n.endsWith("%")||n.endsWith("%")?+n.slice(0,-1)/100:+n;this.#e=i(e[1],!0),this.#i=i(e[2],!1),this.#s=i(e[3],!1);return}s.#t.has(this)||(s.#t.add(this),console.warn(`<color-picker-ui>: could not parse value=${JSON.stringify(t)}. Expected #rrggbb or oklch(L C H) with numeric, NaN, 'none' (CSS L4 powerless), or % channels. Picker is keeping prior state.`))}}}#I(t){let e=[];if(this.#e>this.maxL&&(e.push({axis:"l",requested:this.#e,clamped:this.maxL,reason:"max-l"}),this.#e=this.maxL),this.#e<this.minL&&(e.push({axis:"l",requested:this.#e,clamped:this.minL,reason:"min-l"}),this.#e=this.minL),this.#i>this.maxChroma&&(e.push({axis:"c",requested:this.#i,clamped:this.maxChroma,reason:"max-chroma"}),this.#i=this.maxChroma),Number.isFinite(this.hueDriftMax)){let a=Number.isFinite(this.baseHue)?this.baseHue:Number.isFinite(this.#n)?this.#n:this.#s;Number.isFinite(this.#n)||(this.#n=a);let l=(this.#s-a+540)%360-180,h=this.hueDriftMax;if(l>h){let c=this.#s;this.#s=(a+h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}else if(l<-h){let c=this.#s;this.#s=(a-h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}}let i=Io(this.#e,this.#i,this.#s),n=vn(this.#e,i,this.#s),r=this.#A();this.#a=!0,this.value=this.format==="oklch"?r:n,this.syncValue(),e.length&&this.dispatchEvent(new CustomEvent("constraint-clamp",{bubbles:!0,detail:{clamps:e}}));let o={value:this.value,l:this.#e,c:this.#i,h:this.#s,hex:n,oklch:r};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#A(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#D(t,e){let i=t==="oklch"?this.#A():vn(this.#e,Io(this.#e,this.#i,this.#s),this.#s),n=e.querySelector("icon-ui"),r=o=>{n&&(n.setAttribute("name",o?"check":"warning"),this.#x!=null&&clearTimeout(this.#x),this.#x=setTimeout(()=>{this.#x=null,n.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&r(!0)},()=>{this.isConnected&&r(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),r(document.execCommand("copy")),o.remove()}}#q(){if(!this.#l||!this.#u||!this.#h)return;let t=Math.min(window.devicePixelRatio||1,2)*.5,e=Math.round(this.#h.clientWidth*t),i=Math.round(this.#h.clientHeight*t);if(e<=0||i<=0)return;this.#l.width=e,this.#l.height=i;let n=this.#u.createImageData(e,i),r=n.data,o=this.#s;for(let a=0;a<i;a++){let l=1-a/(i-1);for(let h=0;h<e;h++){let c=h/(e-1)*Xo,u=Io(l,c,o),[d,f,p]=Vg(l,u,o),m=(a*e+h)*4;r[m]=Math.round(d*255),r[m+1]=Math.round(f*255),r[m+2]=Math.round(p*255),r[m+3]=255}}this.#u.putImageData(n,0,0)}render(){if(this.#a?this.#a=!1:this.#M(this.value),this.#q(),this.#c){let r=this.#i/Xo*100,o=(1-this.#e)*100;this.#c.style.left=`${r}%`,this.#c.style.top=`${o}%`,this.#c.style.background=vn(this.#e,Io(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let r=[];for(let o=0;o<=360;o+=30)r.push(vn(.7,.15,o));this.#d.style.background=`linear-gradient(to right, ${r.join(", ")})`,this.#d.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#f&&(this.#f.style.left=`${this.#s/360*100}%`,this.#f.style.background=vn(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#A());let t=this.querySelector('slider-ui[data-channel="hue"]'),e=this.querySelector('slider-ui[data-channel="chroma"]'),i=this.querySelector('slider-ui[data-channel="lightness"]');t&&(t.value=Math.round(this.#s)),e&&(e.value=+this.#i.toFixed(3)),i&&(i.value=+this.#e.toFixed(3)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let n=vn(this.#e,Io(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#A()),this.#g&&(this.#g.textContent=n)}onFormReset(){this.value="#3b82f6"}};w("color-picker-ui",xn);var Sn=class extends z{static get properties(){return{...z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0},maxL:{type:Number,default:1,reflect:!0},minL:{type:Number,default:0,reflect:!0},hueDriftMax:{type:Number,default:NaN,reflect:!0},baseHue:{type:Number,default:NaN,reflect:!0}}}#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;connected(){this.#o(),this.#a(),this.#c(),this.syncValue(this.value)}render(){this.#c(),this.#t&&this.#t.open!==this.open&&(this.#t.open=this.open),this.#i&&(this.#i.format!==this.format&&(this.#i.format=this.format),Object.is(this.#i.maxChroma,this.maxChroma)||(this.#i.maxChroma=this.maxChroma),Object.is(this.#i.maxL,this.maxL)||(this.#i.maxL=this.maxL),Object.is(this.#i.minL,this.minL)||(this.#i.minL=this.minL),Object.is(this.#i.hueDriftMax,this.hueDriftMax)||(this.#i.hueDriftMax=this.hueDriftMax),Object.is(this.#i.baseHue,this.baseHue)||(this.#i.baseHue=this.baseHue)),this.#e&&(this.disabled?this.#e.setAttribute("disabled",""):this.#e.removeAttribute("disabled"))}showPicker(){this.open=!0}hidePicker(){this.open=!1}#o(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-picker-ui[slot="content"]'),this.#s=this.querySelector(".color-input__swatch"),this.#n=this.querySelector(".color-input__value"),this.#t&&this.#e&&this.#i))return;let t=document.createElement("popover-ui");t.setAttribute("trigger","click"),t.setAttribute("placement",this.placement);let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("variant","outline"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-label",this.getAttribute("aria-label")||"Pick a color");let i=document.createElement("span");i.className="color-input__swatch",i.setAttribute("aria-hidden","true");let n=document.createElement("span");n.className="color-input__value",e.append(i,n);let r=document.createElement("color-picker-ui");r.setAttribute("slot","content"),r.setAttribute("format",this.format),r.setAttribute("value",this.value),r.maxChroma=this.maxChroma,r.maxL=this.maxL,r.minL=this.minL,r.hueDriftMax=this.hueDriftMax,r.baseHue=this.baseHue,t.append(e,r),this.append(t),this.#t=t,this.#e=e,this.#i=r,this.#s=i,this.#n=n}#a(){if(this.#r)return;this.#r=!0,this.#i.addEventListener("change",this.#l),this.#i.addEventListener("input",this.#u);let t=()=>{let e=!!this.#t?.open;this.open!==e&&(this.open=e)};this.#t.addEventListener("toggle",t),new MutationObserver(t).observe(this.#t,{attributes:!0,attributeFilter:["open"]})}#l=t=>{this.#h(t.detail,"change")};#u=t=>{this.#h(t.detail,"input")};#h(t,e){if(!t)return;let i=this.format==="oklch"?t.oklch:t.hex;i&&i!==this.value&&(this.value=i,this.syncValue(i)),this.#c(),this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:{value:i??this.value,hex:t.hex,oklch:t.oklch,l:t.l,c:t.c,h:t.h}}))}#c(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#n&&(this.#n.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#l),this.#i?.removeEventListener("input",this.#u),this.#r=!1}};w("color-input-ui",Sn);var ru=0,wn=class extends A{static properties={editable:{type:Boolean,default:!1,reflect:!0},color:{type:String,default:"",reflect:!0},strokeWidth:{type:Number,default:2,reflect:!0,attribute:"stroke-width"},tension:{type:Number,default:.5,reflect:!0},showPorts:{type:Boolean,default:!1,reflect:!0,attribute:"show-ports"},portSize:{type:Number,default:10,attribute:"port-size",reflect:!0},curve:{type:String,default:"bezier",reflect:!0},animated:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=[];#i=new Map;#s=null;#n=null;#r=null;#o=!1;#a=null;#l=null;#u=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",n="left"){let r=`noodle-${++ru}`,o={id:r,from:t,to:e,fromPort:i,toPort:n};return this.#e.push(o),this.#h(),this.dispatchEvent(new CustomEvent("noodle-connect",{bubbles:!0,detail:{...o}})),r}disconnect(t){let e=this.#e.findIndex(n=>n.id===t);if(e===-1)return;let[i]=this.#e.splice(e,1);this.#h(),this.dispatchEvent(new CustomEvent("noodle-disconnect",{bubbles:!0,detail:{...i}}))}setConnections(t){this.#e=t.map(e=>({id:e.id||`noodle-${++ru}`,from:e.from,to:e.to,fromPort:e.fromPort||"right",toPort:e.toPort||"left"})),this.#h()}clear(){this.#e=[],this.#h()}update(){this.#f()}connected(){this.#t=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#t.setAttribute("data-noodle-svg",""),this.prepend(this.#t),this.#s=new ResizeObserver(()=>this.#h()),this.#n=new MutationObserver(()=>{this.#w(),this.#h()}),this.#s.observe(this),this.#c();for(let t of this.#g())this.#s.observe(t);this.#w(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#u?.(),this.#s?.disconnect(),this.#n?.disconnect(),this.#r&&cancelAnimationFrame(this.#r),this.#r=null,this.#k(),this.#t?.remove(),this.#t=null,this.#o=!1}#h(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#f()}))}#c(){this.#n?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#d(){this.#n?.disconnect()}#f(){if(!this.#t)return;this.#d();let t=this.#g();for(let r of t)this.#s.observe(r);this.#y();let e=this.#e.map(r=>{let o=this.#p(r.from),a=this.#p(r.to);if(!o||!a)return null;let l=this.#O(o,r.fromPort),h=this.#O(a,r.toPort);return!l||!h?null:{id:r.id,d:this.#m(l,h,r.fromPort,r.toPort)}}).filter(Boolean),i=new Map;for(let r of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(r.getAttribute("data-noodle-id"),r);let n=new Set(e.map(r=>r.id));for(let[r,o]of i)n.has(r)||o.remove();for(let{id:r,d:o}of e){let a=i.get(r);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",r),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#a&&this.#l){let r=this.#t.querySelector("path[data-noodle-preview]");r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("data-noodle-preview",""),r.style.opacity="0.5",r.style.strokeDasharray="6 3",this.#t.appendChild(r)),r.setAttribute("d",this.#l),r.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#c()}#p(t){return t instanceof HTMLElement?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#g()[t]??null:null}#g(){return[...this.querySelectorAll("[data-noodle-port]")]}#O(t,e){let i=t.getBoundingClientRect(),n=this.getBoundingClientRect(),r=this.offsetWidth&&n.width?n.width/this.offsetWidth:1,o=(i.left-n.left)/r,a=(i.top-n.top)/r,l=i.width/r,h=i.height/r;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#m(t,e,i,n){switch(this.curve){case"step":return this.#S(t,e);case"straight":return this.#x(t,e);default:return this.#b(t,e,i,n)}}#b(t,e,i,n){let r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(r*r+o*o),l=Math.max(50,a*this.tension),h=this.#v(t,i,l),c=this.#v(e,n,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#v(t,e,i){switch(e){case"left":return{x:t.x-i,y:t.y};case"right":return{x:t.x+i,y:t.y};case"top":return{x:t.x,y:t.y-i};case"bottom":return{x:t.x,y:t.y+i};default:return{x:t.x+i,y:t.y}}}#S(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#x(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#w(){this.#d(),this.#k();let t=this.#g();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#$(e,n),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",n),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#Q(a,e,n)),this.appendChild(o),this.#i.set(r,o)}}this.#y(),this.#c()}#k(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#y(){let t=this.#g();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#$(e,n),o=this.#i.get(r);if(!o)continue;let a=this.#O(e,n);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#$(t,e){return t._noodleId||(t._noodleId=`_n${++ru}`),`${t._noodleId}:${e}`}#Q=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n.setPointerCapture(t.pointerId),n.setAttribute("data-noodle-dragging","");let r=this.#O(e,i),o=l=>{if(!this.#a)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#m(r,{x:c,y:u},i,this.#P(r,{x:c,y:u})),this.#h(),this.#C(l.clientX,l.clientY,e),this.dispatchEvent(new CustomEvent("noodle-drag",{bubbles:!0,detail:{from:e,fromPort:i,x:c,y:u}}))},a=l=>{try{n.releasePointerCapture(l.pointerId)}catch{}if(n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#L(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#E(),this.#a=null,this.#l=null,this.#u=null,this.#h()};this.#u=()=>{this.#a=null,n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),this.#E(),this.#l=null,this.#u=null},this.#a={fromEl:e,fromSide:i,startPos:r,pointerId:t.pointerId},this.#l=null,n.addEventListener("pointermove",o),n.addEventListener("pointerup",a)};#P(t,e){let i=e.x-t.x,n=e.y-t.y;return Math.abs(i)>Math.abs(n)?i>0?"left":"right":n>0?"top":"bottom"}#C(t,e,i){this.#E();let n=this.#L(t,e,i);n?.dot&&n.dot.setAttribute("data-noodle-drop-ready","")}#L(t,e,i){let n=this.portSize*2,r=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#g().find(O=>O._noodleId===f);!m||m===i||d<n&&d<o&&(o=d,r={el:m,side:p,dot:l})}return r}#E(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};w("noodles-ui",wn);var Ci={};function me(s,t){Ci[s]=t}function kn(s,t){let e=s.firstElementChild;(!e||e.tagName!=="SPAN")&&(s.replaceChildren(),e=s.appendChild(document.createElement("span"))),e.textContent=t,s.title=t}var ou={basic:(s,t)=>s<t?-1:s>t?1:0,alphanumeric:(s,t)=>String(s??"").localeCompare(String(t??""),void 0,{numeric:!0,sensitivity:"base"}),numeric:(s,t)=>(Number(s)||0)-(Number(t)||0),datetime:(s,t)=>new Date(s||0).getTime()-new Date(t||0).getTime()};me("text",{render(s,t,e){kn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),me("number",{render(s,t,e){kn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),me("currency",{render(s,t,e,i){kn(e,s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:i?.currency||"USD"}).format(s):"")},format(s,t,e){return s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:e?.currency||"USD"}).format(s):""},align:"right",sortFn:"numeric"}),me("percent",{render(s,t,e){kn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var Yg={year:"numeric",month:"short",day:"numeric"};me("date",{render(s,t,e){kn(e,s?new Intl.DateTimeFormat("en-US",Yg).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",Yg).format(new Date(s)):""},align:"left",sortFn:"datetime"});var Ug={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};me("datetime",{render(s,t,e){kn(e,s?new Intl.DateTimeFormat("en-US",Ug).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",Ug).format(new Date(s)):""},align:"left",sortFn:"datetime"}),me("boolean",{render(s,t,e){let i=e.querySelector("check-ui");i||(e.textContent="",i=document.createElement("check-ui"),i.setAttribute("disabled",""),e.appendChild(i)),s?i.setAttribute("checked",""):i.removeAttribute("checked")},format(s){return s?"Yes":"No"},align:"center",sortFn:"basic"}),me("badge",{render(s,t,e,i){let n=e.querySelector("badge-ui");n||(e.textContent="",n=document.createElement("badge-ui"),e.appendChild(n)),n.setAttribute("text",String(s??""));let r=i?.variants||{};n.setAttribute("variant",r[s]||"neutral")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),me("avatar",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("avatar-ui");o.setAttribute("size","sm");let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("avatar-ui"),r=i.querySelector("span");n.setAttribute("text",String(s??"")),r.textContent=String(s??""),e.title=String(s??"")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),me("link",{render(s,t,e,i){let n=e.querySelector("a");n||(e.textContent="",n=document.createElement("a"),n.style.color="var(--table-accent, var(--a-primary))",n.style.textDecoration="none",e.appendChild(n));let r=String(s??""),o=r.includes("@")&&!r.startsWith("http");n.href=o?`mailto:${r}`:r,n.textContent=i?.label??r},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),me("progress",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("progress-ui"),r=i.querySelector("span");n.setAttribute("value",s!=null?String(s):"0"),r.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),me("actions",{render(s,t,e,i){let n=i?.actions||[],r=e.querySelector("row-ui");if(r&&r.children.length!==n.length&&(r.remove(),r=null),!r){e.textContent="",r=document.createElement("row-ui"),r.setAttribute("gap","1");for(let o of n){let a=document.createElement("button-ui");a.setAttribute("icon",o.icon||""),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label",o.label||""),a.addEventListener("click",()=>{a.dispatchEvent(new CustomEvent(o.event,{bubbles:!0,detail:{row:t}}))}),r.appendChild(a)}e.appendChild(r)}},format(){return""},align:"center",sortFn:null});function t1(s,t){if(!t||!s)return;let e=t.split("."),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function si(s,t){return typeof t.accessor=="function"?t.accessor(s):t1(s,t.key)}function rl(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
159
- `)?'"'+t.replace(/"/g,'""')+'"':t}var $n=class extends A{static requiredIcons=["caret-right","caret-up-down","table","arrow-up","arrow-down","funnel-simple","funnel-simple-fill"];static properties={sortable:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},expandable:{type:Boolean,default:!1,reflect:!0},striped:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},density:{type:String,default:"standard",reflect:!0},paginate:{type:Number,default:0,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#n=new Set;#r=null;#o=0;#a=new Set;#l=new Map;#u=null;#h=!1;#c=-1;#d=null;#f=null;set columns(t){this.#t=Array.isArray(t)?t:[],this.#b()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#a.clear(),this.#o=0,this.#b()}get data(){return this.#e}get selected(){return[...this.#a].sort((t,e)=>t-e)}set selected(t){if(this.#a.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#a.add(e);this.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#a.size!==0&&(this.#a.clear(),this.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#o=0,this.#b(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#o=0,this.#b(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}toggleExpand(t){this.#n.has(t)?(this.#n.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#n.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#b()}get expanded(){return[...this.#n]}expandRenderer=null;getState(){return{sort:this.#i.map(t=>({...t})),filters:Object.fromEntries(this.#s),columnWidths:Object.fromEntries(this.#l),hiddenColumns:this.#t.filter(t=>t.hidden).map(t=>t.key),page:this.#o,density:this.density}}setState(t){if(t){if(t.sort&&(this.#i=t.sort),t.filters){this.#s.clear();for(let[e,i]of Object.entries(t.filters))this.#s.set(e,i)}if(t.columnWidths){this.#l.clear();for(let[e,i]of Object.entries(t.columnWidths))this.#l.set(e,i)}if(t.hiddenColumns)for(let e of this.#t)e.hidden=t.hiddenColumns.includes(e.key);t.page!=null&&(this.#o=t.page),t.density&&(this.density=t.density),this.#b()}}#p(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#g(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){this.#O(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#g(),this.#h||(this.#h=!0,this.addEventListener("click",this.#X),this.addEventListener("keydown",this.#z))}disconnected(){this.removeEventListener("click",this.#X),this.removeEventListener("keydown",this.#z),this.#h=!1,this.#q(),this.#m&&(cancelAnimationFrame(this.#m),this.#m=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}#O(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let n={key:i.getAttribute("key")||"",label:i.getAttribute("label")||i.getAttribute("key")||"",type:i.getAttribute("type")||"text",pinned:i.getAttribute("pinned")||null,hidden:i.hasAttribute("hidden"),sortable:i.hasAttribute("sortable"),resizable:i.hasAttribute("resizable"),filterable:i.hasAttribute("filterable"),filterType:i.getAttribute("filter-type")||null},r=i.getAttribute("width");r&&(n.width=Number(r));let o=i.getAttribute("min-width");o&&(n.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(n.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(n.flex=Number(l)),e.push(n),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#m=null;#b(){!this.isConnected||this.#m||(this.#m=requestAnimationFrame(()=>{this.#m=null,this.render(),this.#p()}))}get#v(){return this.#t.filter(t=>!t.hidden)}#S(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#v)this.#l.has(e.key)?t.push(`${this.#l.get(e.key)}px`):e.width?t.push(`${e.width}px`):e.flex?t.push(`minmax(6rem, ${e.flex}fr)`):t.push("minmax(6rem, 1fr)");return t.join(" ")}#x(){let t=this.#e.map((e,i)=>i);if(this.search){let e=this.search.toLowerCase();t=t.filter(i=>{let n=this.#e[i];return this.#v.some(r=>{let o=si(n,r);return o!=null&&String(o).toLowerCase().includes(e)})})}return this.#s.size&&(t=t.filter(e=>{let i=this.#e[e];for(let[n,{op:r,value:o}]of this.#s){let a=this.#t.find(u=>u.key===n),l=si(i,a||{key:n}),h=String(l??"").toLowerCase(),c=String(o).toLowerCase();switch(r){case"contains":if(!h.includes(c))return!1;break;case"equals":if(h!==c)return!1;break;case"startsWith":if(!h.startsWith(c))return!1;break;case"gt":if(Number(l)<=Number(o))return!1;break;case"lt":if(Number(l)>=Number(o))return!1;break;case"gte":if(Number(l)<Number(o))return!1;break;case"lte":if(Number(l)>Number(o))return!1;break;case"between":{let[u,d]=String(o).split(",").map(Number),f=Number(l);if(f<u||f>d)return!1;break}case"select":{if(!c.split(",").map(d=>d.trim()).includes(h))return!1;break}default:if(!h.includes(c))return!1}}return!0})),this.#i.length&&t.sort((e,i)=>{for(let{key:n,dir:r}of this.#i){let o=this.#t.find(u=>u.key===n),a=si(this.#e[e],o||{key:n}),l=si(this.#e[i],o||{key:n}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Ci[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=ou[d]||ou.alphanumeric}if(a==null&&l==null)continue;if(a==null)return 1;if(l==null)return-1;let c=h(a,l);if(c!==0)return r==="asc"?c:-c}return 0}),t}#w(t){if(!this.paginate||this.paginate<=0)return t;let e=this.#o*this.paginate;return t.slice(e,e+this.paginate)}get#k(){if(!this.paginate||this.paginate<=0)return 1;let t=this.#x().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){let t=this.#v;this.style.gridTemplateColumns=this.#S();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#y(e,t),this.#Z();let i=this.querySelector(":scope > [data-body]");i||(i=document.createElement("div"),i.setAttribute("role","rowgroup"),i.setAttribute("data-body",""),e.after(i));let n=this.#x(),r=this.#w(n),o=[];for(let c of r){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#$(c,t);if(u&&this.#Q(u,c,t),this.expandable&&(this.#n.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded")),o.push(d),this.expandable&&this.#n.has(c)){let f=i.querySelector(`:scope > [data-detail-row][data-for="${c}"]`);if(!f&&(f=document.createElement("div"),f.setAttribute("data-detail-row",""),f.dataset.for=c,this.expandRenderer)){let p=this.expandRenderer(this.#e[c],c);p instanceof Node?f.appendChild(p):f.textContent=String(p)}o.push(f)}}let a=[...i.children];for(let c of a)o.includes(c)||c.remove();for(let c=0;c<o.length;c++)i.children[c]!==o[c]&&(i.children[c]?i.insertBefore(o[c],i.children[c]):i.appendChild(o[c]));this.#P(i),this.#C(i,n,t);let l=this.paginate>0&&this.#e.length>0,h=this.querySelector(":scope > [data-footer]");l?(h||(h=document.createElement("div"),h.setAttribute("data-footer",""),this.appendChild(h)),this.#L(h,n.length)):h&&h.remove()}#y(t,e){let i=this.#e.length>0&&this.#a.size===this.#e.length,n=[];if(this.selectable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),r.appendChild(o),n.push(r)}for(let r of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=r.label||r.key,o.appendChild(a),r.sortable!==!1&&this.sortable){o.dataset.sortKey=r.key,o.setAttribute("aria-label",`Sort by ${r.label||r.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===r.key);c?(o.setAttribute("aria-sort",c.dir==="asc"?"ascending":"descending"),h.setAttribute("name",c.dir==="asc"?"arrow-up":"arrow-down")):h.setAttribute("name","caret-up-down"),o.appendChild(h)}if(r.pinned&&o.setAttribute("data-pinned",r.pinned),r.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-resize-handle",""),h.dataset.resizeKey=r.key,o.appendChild(h)}if(r.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=r.key,h.setAttribute("aria-label",`Filter ${r.label||r.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(r.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===r.key){let u=this.#E(r);o.appendChild(u),o.setAttribute("data-filter-open","")}}n.push(o)}for(;t.children.length>n.length;)t.lastChild.remove();for(let r=0;r<n.length;r++)t.children[r]?t.replaceChild(n[r],t.children[r]):t.appendChild(n[r])}#$(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#Q(i,t,e),i}#Q(t,e,i){let n=this.#e[e],r=this.#a.has(e);t.dataset.index=e,r?(t.setAttribute("data-selected",""),t.setAttribute("aria-selected","true")):(t.removeAttribute("data-selected"),t.removeAttribute("aria-selected"));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col","");let l=document.createElement("button");l.setAttribute("data-expand-toggle",""),l.setAttribute("aria-label","Expand row");let h=document.createElement("icon-ui");h.setAttribute("name","caret-right"),h.setAttribute("size","xs"),l.appendChild(h),a.appendChild(l),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-check-col","");let l=document.createElement("check-ui");r&&l.setAttribute("checked",""),l.setAttribute("aria-label",`Select row ${e+1}`),a.appendChild(l),o.push(a)}for(let a of i){let l=document.createElement("div");l.setAttribute("role","gridcell"),l.dataset.key=a.key;let h=si(n,a);if(typeof a.render=="function"){let u=a.render(h,n,l,e);u instanceof Node?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u)}else if(typeof a.format=="function"){let u=a.format(h,n);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Ci[a.type||"text"];if(u?.render)u.render(h,n,l,a.meta);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Ci[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}for(;t.children.length>o.length;)t.lastChild.remove();for(let a=0;a<o.length;a++)t.children[a]?t.replaceChild(o[a],t.children[a]):t.appendChild(o[a])}#P(t){let e=this.querySelector(":scope > [data-empty]"),i=this.querySelector(":scope > [data-loading]");if(this.loading){this.setAttribute("aria-busy","true");let n=this.#v,r=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+n.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<r;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let n=document.createElement("icon-ui");n.setAttribute("name","table");let r=document.createElement("span");r.textContent="No data",e.appendChild(n),e.appendChild(r),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#C(t,e,i){let n=i.some(a=>a.aggregate),r=this.querySelector(":scope > [data-agg-row]");if(!n||this.#e.length===0){r&&r.remove();return}r||(r=document.createElement("div"),r.setAttribute("role","row"),r.setAttribute("data-agg-row",""),t.after(r));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}for(let a of i){let l=document.createElement("div");if(l.setAttribute("role","gridcell"),a.aggregate){let h=e.map(d=>{let f=si(this.#e[d],a);return f!=null?Number(f):NaN}).filter(d=>!isNaN(d)),c;switch(a.aggregate){case"sum":c=h.reduce((d,f)=>d+f,0);break;case"avg":c=h.length?h.reduce((d,f)=>d+f,0)/h.length:0;break;case"min":c=h.length?Math.min(...h):0;break;case"max":c=h.length?Math.max(...h):0;break;case"count":c=e.length;break;default:c=""}let u=Ci[a.type||"text"];typeof c=="number"&&u?.render?u.render(c,{},l,a.meta):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}for(;r.children.length>o.length;)r.lastChild.remove();for(let a=0;a<o.length;a++)r.children[a]?r.replaceChild(o[a],r.children[a]):r.appendChild(o[a])}#L(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",r=>{this.#o=r.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#o}}))}),t.appendChild(i));let n=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#o+1)),i.setAttribute("total",String(n))}#E(t){let e=document.createElement("div");e.setAttribute("data-filter-dropdown","");let i=this.#s.get(t.key);if(t.filter==="select"){let n=[...new Set(this.#e.map(o=>{let a=si(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),r=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of n){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=r.has(o.toLowerCase()),l.addEventListener("change",()=>{let h=[...e.querySelectorAll("input[type=checkbox]:checked")].map(c=>c.value);h.length?this.setFilter(t.key,h.join(","),"select"):this.setFilter(t.key,null)}),a.appendChild(l),a.appendChild(document.createTextNode(` ${o}`)),e.appendChild(a)}}else if(t.filter==="number"){let n=document.createElement("input");n.type="number",n.placeholder="Filter...",n.value=i?.value??"",n.setAttribute("data-filter-input","");let r=document.createElement("select");r.setAttribute("data-filter-op","");for(let[a,l]of[["gte","\u2265"],["lte","\u2264"],["gt",">"],["lt","<"],["equals","="]]){let h=document.createElement("option");h.value=a,h.textContent=l,i?.op===a&&(h.selected=!0),r.appendChild(h)}let o=()=>{n.value?this.setFilter(t.key,n.value,r.value):this.setFilter(t.key,null)};n.addEventListener("input",o),r.addEventListener("change",o),e.appendChild(r),e.appendChild(n)}else{let n=document.createElement("input");n.type="text",n.placeholder=`Filter ${t.label||t.key}...`,n.value=i?.value??"",n.setAttribute("data-filter-input",""),n.addEventListener("input",()=>{n.value?this.setFilter(t.key,n.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(n)}if(i){let n=document.createElement("button");n.textContent="Clear",n.setAttribute("data-filter-clear",""),n.addEventListener("click",()=>{this.setFilter(t.key,null),this.#d=null,this.#b()}),e.appendChild(n)}return this.#f!=null&&cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{if(this.#f=null,!this.isConnected)return;let n=e.querySelector("input");n&&n.focus()}),e}#Z(){let t=this.querySelector(":scope > [data-filter-bar]");if(this.#s.size===0){t&&t.remove();return}if(!t){t=document.createElement("div"),t.setAttribute("data-filter-bar",""),t.setAttribute("role","status");let i=this.querySelector(":scope > [data-header]");i?i.after(t):this.prepend(t)}t.innerHTML="";for(let[i,{op:n,value:r}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=n==="select"?`${r.split(",").length} selected`:r;l.setAttribute("text",`${a}: ${h}`),l.setAttribute("size","xs"),l.setAttribute("data-filter-chip",i);let c=document.createElement("button");c.textContent="\xD7",c.setAttribute("data-chip-dismiss",""),c.addEventListener("click",u=>{u.stopPropagation(),this.setFilter(i,null)}),l.appendChild(c),t.appendChild(l)}let e=document.createElement("button");e.textContent="Clear all",e.setAttribute("data-filter-clear-all",""),e.addEventListener("click",()=>this.clearFilters()),t.appendChild(e)}#X=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#d=this.#d===c?null:c,this.#b();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#b());let n=e.closest("[data-expand-toggle]");if(n&&this.expandable&&this.contains(n)){let c=n.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let r=e.closest("[data-resize-handle]");if(r&&this.contains(r)){this.#I(t,r);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#a.add(u);else this.#a.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#c>=0){let f=Math.min(this.#c,u),p=Math.max(this.#c,u);for(let m=f;m<=p;m++)d?this.#a.add(m):this.#a.delete(m)}else d?this.#a.add(u):this.#a.delete(u);this.#c=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(O=>O.key===d),m=p?si(f,p):void 0;this.dispatchEvent(new CustomEvent("cell-click",{bubbles:!0,detail:{key:d,row:f,value:m,dataIndex:u}})),this.dispatchEvent(new CustomEvent("row-click",{bubbles:!0,detail:{row:f,dataIndex:u}}))}}};#M=null;#I(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,n=this.#t.find(l=>l.key===i);if(!n)return;let r=e.closest('[role="columnheader"]'),o=r?r.getBoundingClientRect().width:100,a=t.clientX;this.setAttribute("data-resizing",""),this.#M={key:i,col:n,startX:a,startWidth:o},document.addEventListener("mousemove",this.#A),document.addEventListener("mouseup",this.#D)}#A=t=>{if(!this.#M)return;let{key:e,col:i,startX:n,startWidth:r}=this.#M,o=t.clientX-n,a=r+o,l=i.minWidth||48,h=i.maxWidth||1/0;a=Math.max(l,Math.min(h,a)),this.#l.set(e,Math.round(a)),this.style.gridTemplateColumns=this.#S()};#D=t=>{if(!this.#M)return;let{key:e}=this.#M;document.removeEventListener("mousemove",this.#A),document.removeEventListener("mouseup",this.#D),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#M=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#q(){document.removeEventListener("mousemove",this.#A),document.removeEventListener("mouseup",this.#D),this.#M=null}#z=t=>{let i=this.#v.length+(this.selectable?1:0),n=this.querySelector(":scope > [data-body]"),r=n?n.children.length:0;this.#u||(this.#u={row:0,col:0});let{row:o,col:a}=this.#u,l=!0;switch(t.key){case"ArrowDown":o=Math.min(o+1,r-1);break;case"ArrowUp":o=Math.max(o-1,-1);break;case"ArrowRight":a=Math.min(a+1,i-1);break;case"ArrowLeft":a=Math.max(a-1,0);break;case"Tab":if(t.shiftKey?(a--,a<0&&(a=i-1,o--)):(a++,a>=i&&(a=0,o++)),o<-1||o>=r){l=!1;break}break;case"Enter":if(o===-1){let c=this.querySelector(":scope > [data-header]")?.children[a];c?.dataset.sortKey&&c.click()}else{let h=this.querySelector("[data-focused]");h&&h.click()}break;default:l=!1}l&&(t.preventDefault(),this.#u={row:o,col:a},this.#N())};#N(){let t=this.querySelector("[data-focused]");if(t&&t.removeAttribute("data-focused"),!this.#u)return;let{row:e,col:i}=this.#u,n;e===-1?n=this.querySelector(":scope > [data-header]")?.children[i]:n=this.querySelector(":scope > [data-body]")?.children[e]?.children[i],n&&(n.setAttribute("data-focused",""),n.scrollIntoView?.({block:"nearest",inline:"nearest"}))}exportCSV(t="export.csv"){let e=this.#v,i=this.#x(),n=e.map(c=>rl(c.label||c.key)),r=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=si(u,d);if(typeof d.format=="function")return rl(d.format(f,u));let p=Ci[d.type||"text"];return p?.format?rl(p.format(f,u,d.meta)):rl(f)})}),o=[n.join(","),...r.map(c=>c.join(","))].join(`
160
- `),a=new Blob([o],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),h=document.createElement("a");h.href=l,h.download=t,h.style.display="none",document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(l)}};w("table-ui",$n);var e1=200;function au(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-empty",""),t.setAttribute("color","subtle"),t.setAttribute("variant","caption"),t.textContent=s,t}function lu(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-head",""),t.setAttribute("variant","kicker"),t.setAttribute("color","subtle"),t.textContent=s,t}var i1=50,Fg=500;function Gg(s,t){if(typeof t?.accessor=="function")return t.accessor(s);let e=t?.key;if(!e||s==null)return;let i=String(e).split("."),n=s;for(let r of i){if(n==null)return;n=n[r]}return n}function s1(s){if(!s)return!1;let t=String(s);return!!(t==="id"||t==="ID"||t==="uuid"||t==="guid"||/[a-z](Id|ID)$/.test(t)||/_id$/i.test(t))}function n1(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(s1(s?.key))return"text";let e=[],i=Math.min(t?.length??0,Fg),n=new Set;for(let r=0;r<i;r++){let o=Gg(t[r],s);if(!(o==null||o==="")&&(e.push(o),n.add(String(o)),n.size>i1))return"text"}return e.length?"select":"text"}function r1(s,t){let e=new Set,i=Math.min(t?.length??0,Fg);for(let n=0;n<i;n++){let r=Gg(t[n],s);r==null||r===""||e.add(String(r))}return[...e].sort((n,r)=>n.localeCompare(r,void 0,{numeric:!0}))}var An=class s extends A{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#n=null;#r=new Set;static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){this.setAttribute("role","toolbar"),this.#o(),this.#h(),this.#a(),this.#O()}disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null);for(let t of this.#r)cancelAnimationFrame(t);this.#r.clear(),this.#b(),this.#u()}render(){this.#a(),this.#O(),this.#f()}#o(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let n=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(n)||s._OPT_OUT_PREFIX_RE.test(n)&&t.push(n)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#a(){let t=this.#l();if(t===this.#t||(this.#u(),!t))return;this.#t=t;let e=()=>this.#y(),i=()=>this.#w();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#l(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#u(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#h(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-title","");let i=document.createElement("span");i.setAttribute("data-heading",""),e.appendChild(i);let n=document.createElement("badge-ui");n.setAttribute("data-count-badge",""),n.setAttribute("size","sm"),n.setAttribute("variant","muted"),n.hidden=!0,e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-controls",""),r.appendChild(this.#d("filter","Filter","funnel-simple")),r.appendChild(this.#d("sort","Sort","arrows-down-up")),r.appendChild(this.#d("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String(e1)),o.addEventListener("search",this.#g);let a=document.createElement("div");a.setAttribute("data-actions","");for(let l of[...this.children])l!==t&&l.getAttribute?.("slot")==="actions"&&a.appendChild(l);t.appendChild(e),t.appendChild(r),t.appendChild(o),t.appendChild(a),this.appendChild(t),this.#f(),this.#p()}#c(t,e){let i=document.createElement("button-ui");return i.setAttribute("data-popover-action",""),i.setAttribute("text",t),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#d(t,e,i){let n=document.createElement("button-ui");return n.setAttribute("data-toolbar-btn",t),n.setAttribute("icon",i),n.setAttribute("text",e),n.setAttribute("variant","outline"),n.setAttribute("size","sm"),n.setAttribute("aria-haspopup","menu"),n.addEventListener("click",r=>{r.stopPropagation(),this.#m(t,n)}),n}#f(){let t=this.querySelector(":scope [data-heading]");if(!t)return;this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0;let e=this.querySelector(":scope [data-count-badge]");if(!e)return;let i=this.count?.toString().trim(),n=this.#t?.data?.length,r=i||(Number.isFinite(n)?String(n):"");r?(e.setAttribute("text",r),e.hidden=!1):e.hidden=!0}#p(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=(i,n)=>{let r=t.querySelector(i);r&&(r.hidden=n)};e('[data-toolbar-btn="filter"]',this.noFilter),e('[data-toolbar-btn="sort"]',this.noSort),e('[data-toolbar-btn="columns"]',this.noColumns),e("[data-search]",this.noSearch)}attributeChanged(t){["no-filter","no-sort","no-columns","no-search"].includes(t)&&this.#p(),t==="placeholder"&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}#g=t=>{let e=t.detail?.value??"";this.#t&&(this.#t.search=e),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#O(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#f()}#m(t,e){if(this.#i?.kind===t){this.#b();return}this.#b();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#x(i),t==="sort"&&this.#k(i),t==="columns"&&this.#$(i),document.body.appendChild(i);try{i.showPopover()}catch{}let n=Tt(e,i,{placement:"bottom-start",gap:4});this.#i={kind:t,btn:e,panel:i,cleanup:n},this.#s||(this.#s=!0,this.#n=requestAnimationFrame(()=>{this.#n=null,!(!this.isConnected||!this.#s)&&(document.addEventListener("pointerdown",this.#v,!0),document.addEventListener("keydown",this.#S,!0))}))}#b(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#v,!0),document.removeEventListener("keydown",this.#S,!0))}}#v=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#b())};#S=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#b(),this.#i?.btn?.focus?.({preventScroll:!0}))};#x(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(au("No filterable columns"));return}let i=e.filters||{};t.appendChild(lu("Filter rows"));let n=document.createElement("div");n.setAttribute("data-popover-list","");let r=e.data||[];for(let o of e.columns){if(o.hidden)continue;let a=document.createElement("field-ui");a.setAttribute("data-filter-row",""),a.setAttribute("inline",""),a.setAttribute("label",o.label||o.key);let l=n1(o,r),h=i[o.key];if(l==="select"){let c=document.createElement("select-ui");c.setAttribute("data-filter-input",""),c.setAttribute("multiple",""),c.setAttribute("placeholder","\u2014");let u=r1(o,r);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";d?e.setFilter(o.key,d,"select"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size","sm"),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;u?e.setFilter(o.key,u,"contains"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}n.appendChild(a)}if(t.appendChild(n),Object.keys(i).length){let o=this.#c("Clear all filters",()=>{e.clearFilters(),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#w()});t.appendChild(o)}}#w(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#x(t.panel))}#k(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(au("No sortable columns"));return}t.appendChild(lu("Sort by"));let i=e.sortState||[],n=new Map(i.map(o=>[o.key,o.dir])),r=document.createElement("div");r.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=n.get(o.key),l=document.createElement("menu-item-ui");l.setAttribute("data-sort-row",""),l.setAttribute("text",o.label||o.key),l.dataset.key=o.key,a&&(l.dataset.active=a);let h=requestAnimationFrame(()=>{if(this.#r.delete(h),!this.isConnected)return;let c=document.createElement("icon-ui");c.setAttribute("data-sort-indicator",""),c.setAttribute("size","xs"),c.setAttribute("name",a==="asc"?"arrow-up":a==="desc"?"arrow-down":"caret-up-down"),l.appendChild(c)});this.#r.add(h),l.addEventListener("click",c=>{let u=e.querySelector(`:scope > [data-header] [data-sort-key="${o.key}"]`);if(!u)return;let d=new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c.shiftKey});u.dispatchEvent(d),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#y()}),r.appendChild(l)}if(t.appendChild(r),i.length){let o=this.#c("Clear sort",()=>{for(let a of[...i]){let l=e.querySelector(`:scope > [data-header] [data-sort-key="${a.key}"]`);if(!l)continue;let h=c=>l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c}));i.length>1?(h(!0),h(!0)):(h(!1),h(!1))}this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#y()});t.appendChild(o)}}#y(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#k(t.panel))}#$(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(au("No columns"));return}t.appendChild(lu("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let n of e.columns){let r=document.createElement("field-ui");r.setAttribute("data-columns-row",""),r.setAttribute("inline",""),r.setAttribute("label",n.label||n.key);let o=document.createElement("check-ui");n.hidden||o.setAttribute("checked",""),o.dataset.key=n.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===n.key?{...l,hidden:!o.hasAttribute("checked")}:{...l});e.columns=a,this.dispatchEvent(new CustomEvent("columns-change",{bubbles:!0,detail:{hiddenColumns:a.filter(l=>l.hidden).map(l=>l.key)}}))}),r.appendChild(o),i.appendChild(r)}t.appendChild(i)}};w("table-toolbar-ui",An);var Qn=class extends A{static properties={orientation:{type:String,default:"vertical",reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll(":scope > timeline-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];e&&e.setAttribute("data-last","")}},Pn=class extends A{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},time:{type:String,default:"",reflect:!0},duration:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},status:{type:String,default:"idle",reflect:!0},spinner:{type:Boolean,default:!1,reflect:!0}};static requiredIcons=["caret-down","caret-right"];static template=()=>null;#t=[];#e=!1;get outcomes(){return this.#t}set outcomes(t){this.#t=Array.isArray(t)?t.slice():[],this.render()}connected(){this.querySelector(':scope > [slot="label"]')||(this.innerHTML=`
158
+ `,this.#l.set(i,t),i}#b(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#x(t){let e=this.#n.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#n.querySelector("[data-active]");i&&i.removeAttribute("data-active");let n=[...e].find(r=>parseInt(r.dataset.idx)===t);n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#i=t)}#S(t){let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#n.querySelector("[data-active]"),r=(i?e.indexOf(i):-1)+t;r<0&&(r=e.length-1),r>=e.length&&(r=0),this.#x(parseInt(e[r].dataset.idx))}#v(t){this.#O(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#w(){let t=this.#n.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",r=(this.#l.get(t)||this.#g(e))?.category||"";this.#O(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:r}}))}#k=()=>{this.#p(this.#s.value)};#y=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#S(1);break;case"ArrowUp":t.preventDefault(),this.#S(-1);break;case"Enter":t.preventDefault(),this.#w();break;case"Tab":t.preventDefault(),this.#w();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),this.removeEventListener("keydown",this.#y),this.#s?.removeEventListener("input",this.#k),this.#n?.removeEventListener("click",this.#h),this.#n?.removeEventListener("pointerover",this.#c),this.#s=null,this.#n=null,this.#o=null,this.#a=!1}};w("command-ui",yn);var Xo=.4;function iu(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function su(s,t,e){let i=s+.3963377774*t+.2158037573*e,n=s-.1055613458*t-.0638541728*e,r=s-.0894841775*t-1.291485548*e,o=i*i*i,a=n*n*n,l=r*r*r;return[4.0767416621*o-3.3077115913*a+.2309699292*l,-1.2684380046*o+2.6097574011*a-.3413193965*l,-.0041960863*o-.7034186147*a+1.707614701*l]}function ii(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function nu(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function Vg(s,t,e){let{a:i,b:n}=iu(s,t,e),[r,o,a]=su(s,i,n);return[Math.max(0,Math.min(1,ii(r))),Math.max(0,Math.min(1,ii(o))),Math.max(0,Math.min(1,ii(a)))]}function Kk(s,t,e){let i=n=>Math.round(n*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function vn(s,t,e){let[i,n,r]=Vg(s,t,e);return Kk(i,n,r)}function Jk(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=nu(parseInt(s.slice(0,2),16)/255),e=nu(parseInt(s.slice(2,4),16)/255),i=nu(parseInt(s.slice(4,6),16)/255),n=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*i),r=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*i),o=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*i),a=.2104542553*n+.793617785*r-.0040720468*o,l=1.9779984951*n-2.428592205*r+.4505937099*o,h=.0259040371*n+.7827717662*r-.808675766*o,c=Math.sqrt(l*l+h*h),u=Math.atan2(h,l)*180/Math.PI;return u<0&&(u+=360),{L:a,C:c,H:u}}function Wg(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Io(s,t,e){let{a:i,b:n}=iu(s,t,e),[r,o,a]=su(s,i,n);if(Wg(ii(r),ii(o),ii(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=iu(s,u,e),[p,m,O]=su(s,d,f);Wg(ii(p),ii(m),ii(O))?l=u:h=u}return l}var xn=class s extends z{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#n=NaN;#r=!1;#o=null;#a=!1;#l=null;#u=null;#h=null;#c=null;#d=null;#f=null;#p=null;#g=null;#O=null;#m=null;#b=null;#x=null;#S=[];#v=null;static template=()=>null;#w=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#I("input")};#k=t=>{this.disabled||(this.#o="area",this.#h.setPointerCapture(t.pointerId),this.#Z(t))};#y=t=>{this.#o==="area"&&this.#Z(t)};#$=()=>{this.#o==="area"&&(this.#o=null,this.#I("change"))};#A=t=>{this.disabled||(this.#o="hue",this.#d.setPointerCapture(t.pointerId),this.#X(t))};#C=t=>{this.#o==="hue"&&this.#X(t)};#P=()=>{this.#o==="hue"&&(this.#o=null,this.#I("change"))};#E=t=>{if(this.disabled)return;let e=t.shiftKey?.05:.01,i=t.shiftKey?.04:.004;switch(t.key){case"ArrowRight":t.preventDefault(),this.#i=Math.min(Xo,this.#i+i);break;case"ArrowLeft":t.preventDefault(),this.#i=Math.max(0,this.#i-i);break;case"ArrowUp":t.preventDefault(),this.#e=Math.min(1,this.#e+e);break;case"ArrowDown":t.preventDefault(),this.#e=Math.max(0,this.#e-e);break;default:return}this.#I("change")};#T=t=>{if(this.disabled)return;let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#s=(this.#s+e)%360;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#s=(this.#s-e+360)%360;break;default:return}this.#I("change")};connected(){if(super.connected(),this.#M(this.value),this.#r)return;this.#r=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#u=this.#l.getContext("2d",{willReadFrequently:!0}),this.#c=document.createElement("div"),this.#c.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#c),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(r,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",r),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#w),t.appendChild(c),c};this.#m=e("H","hue",0,360,1),this.#b=e("C","chroma",0,Xo,.001),this.#x=e("L","lightness",0,1,.001),this.appendChild(t),this.#d=document.createElement("div"),this.#d.setAttribute("data-hue-track",""),this.#d.setAttribute("tabindex","0"),this.#d.setAttribute("role","slider"),this.#d.setAttribute("aria-label","Hue"),this.#f=document.createElement("div"),this.#f.setAttribute("data-hue-thumb",""),this.#d.appendChild(this.#f),this.appendChild(this.#d);let i=document.createElement("div");i.setAttribute("data-output","");let n=r=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",r);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",r),l.setAttribute("aria-label",`Copy ${r}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#D(r,l);return l.addEventListener("click",h),this.#S.push({el:l,handler:h}),o.appendChild(a),o.appendChild(l),i.appendChild(o),a};this.#p=n("oklch"),this.#g=n("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#k),this.#h.addEventListener("pointermove",this.#y),this.#h.addEventListener("pointerup",this.#$),this.#d.addEventListener("pointerdown",this.#A),this.#d.addEventListener("pointermove",this.#C),this.#d.addEventListener("pointerup",this.#P),this.#h.addEventListener("keydown",this.#E),this.#d.addEventListener("keydown",this.#T),this.#O=new ResizeObserver(()=>this.#q()),this.#O.observe(this.#h)}disconnected(){super.disconnected(),this.#v!=null&&(clearTimeout(this.#v),this.#v=null),this.#O&&(this.#O.disconnect(),this.#O=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#k),this.#h.removeEventListener("pointermove",this.#y),this.#h.removeEventListener("pointerup",this.#$),this.#h.removeEventListener("keydown",this.#E)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#A),this.#d.removeEventListener("pointermove",this.#C),this.#d.removeEventListener("pointerup",this.#P),this.#d.removeEventListener("keydown",this.#T)),this.#m?.removeEventListener("input",this.#w),this.#b?.removeEventListener("input",this.#w),this.#x?.removeEventListener("input",this.#w);for(let{el:t,handler:e}of this.#S)t.removeEventListener("click",e);this.#S=[],this.#r=!1}#Z(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),n=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*Xo,this.#e=1-n,this.#I("input")}#X(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#I("input")}#M(t){if(t){if(t.startsWith("#")){let e=Jk(t);this.#e=e.L,this.#i=e.C,this.#s=e.H;return}if(t.startsWith("oklch(")){let e=t.match(/oklch\(\s*([\d.]+%?|NaN|none)\s+([\d.]+%?|NaN|none)\s+([\d.]+|NaN|none)/i);if(e){let i=(n,r)=>n==="none"||/^NaN$/i.test(n)?0:r&&n.endsWith("%")||n.endsWith("%")?+n.slice(0,-1)/100:+n;this.#e=i(e[1],!0),this.#i=i(e[2],!1),this.#s=i(e[3],!1);return}s.#t.has(this)||(s.#t.add(this),console.warn(`<color-picker-ui>: could not parse value=${JSON.stringify(t)}. Expected #rrggbb or oklch(L C H) with numeric, NaN, 'none' (CSS L4 powerless), or % channels. Picker is keeping prior state.`))}}}#I(t){let e=[];if(this.#e>this.maxL&&(e.push({axis:"l",requested:this.#e,clamped:this.maxL,reason:"max-l"}),this.#e=this.maxL),this.#e<this.minL&&(e.push({axis:"l",requested:this.#e,clamped:this.minL,reason:"min-l"}),this.#e=this.minL),this.#i>this.maxChroma&&(e.push({axis:"c",requested:this.#i,clamped:this.maxChroma,reason:"max-chroma"}),this.#i=this.maxChroma),Number.isFinite(this.hueDriftMax)){let a=Number.isFinite(this.baseHue)?this.baseHue:Number.isFinite(this.#n)?this.#n:this.#s;Number.isFinite(this.#n)||(this.#n=a);let l=(this.#s-a+540)%360-180,h=this.hueDriftMax;if(l>h){let c=this.#s;this.#s=(a+h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}else if(l<-h){let c=this.#s;this.#s=(a-h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}}let i=Io(this.#e,this.#i,this.#s),n=vn(this.#e,i,this.#s),r=this.#Q();this.#a=!0,this.value=this.format==="oklch"?r:n,this.syncValue(),e.length&&this.dispatchEvent(new CustomEvent("constraint-clamp",{bubbles:!0,detail:{clamps:e}}));let o={value:this.value,l:this.#e,c:this.#i,h:this.#s,hex:n,oklch:r};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#Q(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#D(t,e){let i=t==="oklch"?this.#Q():vn(this.#e,Io(this.#e,this.#i,this.#s),this.#s),n=e.querySelector("icon-ui"),r=o=>{n&&(n.setAttribute("name",o?"check":"warning"),this.#v!=null&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,n.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&r(!0)},()=>{this.isConnected&&r(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),r(document.execCommand("copy")),o.remove()}}#q(){if(!this.#l||!this.#u||!this.#h)return;let t=Math.min(window.devicePixelRatio||1,2)*.5,e=Math.round(this.#h.clientWidth*t),i=Math.round(this.#h.clientHeight*t);if(e<=0||i<=0)return;this.#l.width=e,this.#l.height=i;let n=this.#u.createImageData(e,i),r=n.data,o=this.#s;for(let a=0;a<i;a++){let l=1-a/(i-1);for(let h=0;h<e;h++){let c=h/(e-1)*Xo,u=Io(l,c,o),[d,f,p]=Vg(l,u,o),m=(a*e+h)*4;r[m]=Math.round(d*255),r[m+1]=Math.round(f*255),r[m+2]=Math.round(p*255),r[m+3]=255}}this.#u.putImageData(n,0,0)}render(){if(this.#a?this.#a=!1:this.#M(this.value),this.#q(),this.#c){let r=this.#i/Xo*100,o=(1-this.#e)*100;this.#c.style.left=`${r}%`,this.#c.style.top=`${o}%`,this.#c.style.background=vn(this.#e,Io(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let r=[];for(let o=0;o<=360;o+=30)r.push(vn(.7,.15,o));this.#d.style.background=`linear-gradient(to right, ${r.join(", ")})`,this.#d.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#f&&(this.#f.style.left=`${this.#s/360*100}%`,this.#f.style.background=vn(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#Q());let t=this.querySelector('slider-ui[data-channel="hue"]'),e=this.querySelector('slider-ui[data-channel="chroma"]'),i=this.querySelector('slider-ui[data-channel="lightness"]');t&&(t.value=Math.round(this.#s)),e&&(e.value=+this.#i.toFixed(3)),i&&(i.value=+this.#e.toFixed(3)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let n=vn(this.#e,Io(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#Q()),this.#g&&(this.#g.textContent=n)}onFormReset(){this.value="#3b82f6"}};w("color-picker-ui",xn);var Sn=class extends z{static get properties(){return{...z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0},maxL:{type:Number,default:1,reflect:!0},minL:{type:Number,default:0,reflect:!0},hueDriftMax:{type:Number,default:NaN,reflect:!0},baseHue:{type:Number,default:NaN,reflect:!0}}}#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;connected(){this.#o(),this.#a(),this.#c(),this.syncValue(this.value)}render(){this.#c(),this.#t&&this.#t.open!==this.open&&(this.#t.open=this.open),this.#i&&(this.#i.format!==this.format&&(this.#i.format=this.format),Object.is(this.#i.maxChroma,this.maxChroma)||(this.#i.maxChroma=this.maxChroma),Object.is(this.#i.maxL,this.maxL)||(this.#i.maxL=this.maxL),Object.is(this.#i.minL,this.minL)||(this.#i.minL=this.minL),Object.is(this.#i.hueDriftMax,this.hueDriftMax)||(this.#i.hueDriftMax=this.hueDriftMax),Object.is(this.#i.baseHue,this.baseHue)||(this.#i.baseHue=this.baseHue)),this.#e&&(this.disabled?this.#e.setAttribute("disabled",""):this.#e.removeAttribute("disabled"))}showPicker(){this.open=!0}hidePicker(){this.open=!1}#o(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-picker-ui[slot="content"]'),this.#s=this.querySelector(".color-input__swatch"),this.#n=this.querySelector(".color-input__value"),this.#t&&this.#e&&this.#i))return;let t=document.createElement("popover-ui");t.setAttribute("trigger","click"),t.setAttribute("placement",this.placement);let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("variant","outline"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-label",this.getAttribute("aria-label")||"Pick a color");let i=document.createElement("span");i.className="color-input__swatch",i.setAttribute("aria-hidden","true");let n=document.createElement("span");n.className="color-input__value",e.append(i,n);let r=document.createElement("color-picker-ui");r.setAttribute("slot","content"),r.setAttribute("format",this.format),r.setAttribute("value",this.value),r.maxChroma=this.maxChroma,r.maxL=this.maxL,r.minL=this.minL,r.hueDriftMax=this.hueDriftMax,r.baseHue=this.baseHue,t.append(e,r),this.append(t),this.#t=t,this.#e=e,this.#i=r,this.#s=i,this.#n=n}#a(){if(this.#r)return;this.#r=!0,this.#i.addEventListener("change",this.#l),this.#i.addEventListener("input",this.#u);let t=()=>{let e=!!this.#t?.open;this.open!==e&&(this.open=e)};this.#t.addEventListener("toggle",t),new MutationObserver(t).observe(this.#t,{attributes:!0,attributeFilter:["open"]})}#l=t=>{this.#h(t.detail,"change")};#u=t=>{this.#h(t.detail,"input")};#h(t,e){if(!t)return;let i=this.format==="oklch"?t.oklch:t.hex;i&&i!==this.value&&(this.value=i,this.syncValue(i)),this.#c(),this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:{value:i??this.value,hex:t.hex,oklch:t.oklch,l:t.l,c:t.c,h:t.h}}))}#c(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#n&&(this.#n.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#l),this.#i?.removeEventListener("input",this.#u),this.#r=!1}};w("color-input-ui",Sn);var ru=0,wn=class extends A{static properties={editable:{type:Boolean,default:!1,reflect:!0},color:{type:String,default:"",reflect:!0},strokeWidth:{type:Number,default:2,reflect:!0,attribute:"stroke-width"},tension:{type:Number,default:.5,reflect:!0},showPorts:{type:Boolean,default:!1,reflect:!0,attribute:"show-ports"},portSize:{type:Number,default:10,attribute:"port-size",reflect:!0},curve:{type:String,default:"bezier",reflect:!0},animated:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=[];#i=new Map;#s=null;#n=null;#r=null;#o=!1;#a=null;#l=null;#u=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",n="left"){let r=`noodle-${++ru}`,o={id:r,from:t,to:e,fromPort:i,toPort:n};return this.#e.push(o),this.#h(),this.dispatchEvent(new CustomEvent("noodle-connect",{bubbles:!0,detail:{...o}})),r}disconnect(t){let e=this.#e.findIndex(n=>n.id===t);if(e===-1)return;let[i]=this.#e.splice(e,1);this.#h(),this.dispatchEvent(new CustomEvent("noodle-disconnect",{bubbles:!0,detail:{...i}}))}setConnections(t){this.#e=t.map(e=>({id:e.id||`noodle-${++ru}`,from:e.from,to:e.to,fromPort:e.fromPort||"right",toPort:e.toPort||"left"})),this.#h()}clear(){this.#e=[],this.#h()}update(){this.#f()}connected(){this.#t=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#t.setAttribute("data-noodle-svg",""),this.prepend(this.#t),this.#s=new ResizeObserver(()=>this.#h()),this.#n=new MutationObserver(()=>{this.#w(),this.#h()}),this.#s.observe(this),this.#c();for(let t of this.#g())this.#s.observe(t);this.#w(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#u?.(),this.#s?.disconnect(),this.#n?.disconnect(),this.#r&&cancelAnimationFrame(this.#r),this.#r=null,this.#k(),this.#t?.remove(),this.#t=null,this.#o=!1}#h(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#f()}))}#c(){this.#n?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#d(){this.#n?.disconnect()}#f(){if(!this.#t)return;this.#d();let t=this.#g();for(let r of t)this.#s.observe(r);this.#y();let e=this.#e.map(r=>{let o=this.#p(r.from),a=this.#p(r.to);if(!o||!a)return null;let l=this.#O(o,r.fromPort),h=this.#O(a,r.toPort);return!l||!h?null:{id:r.id,d:this.#m(l,h,r.fromPort,r.toPort)}}).filter(Boolean),i=new Map;for(let r of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(r.getAttribute("data-noodle-id"),r);let n=new Set(e.map(r=>r.id));for(let[r,o]of i)n.has(r)||o.remove();for(let{id:r,d:o}of e){let a=i.get(r);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",r),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#a&&this.#l){let r=this.#t.querySelector("path[data-noodle-preview]");r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("data-noodle-preview",""),r.style.opacity="0.5",r.style.strokeDasharray="6 3",this.#t.appendChild(r)),r.setAttribute("d",this.#l),r.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#c()}#p(t){return t instanceof HTMLElement?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#g()[t]??null:null}#g(){return[...this.querySelectorAll("[data-noodle-port]")]}#O(t,e){let i=t.getBoundingClientRect(),n=this.getBoundingClientRect(),r=this.offsetWidth&&n.width?n.width/this.offsetWidth:1,o=(i.left-n.left)/r,a=(i.top-n.top)/r,l=i.width/r,h=i.height/r;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#m(t,e,i,n){switch(this.curve){case"step":return this.#S(t,e);case"straight":return this.#v(t,e);default:return this.#b(t,e,i,n)}}#b(t,e,i,n){let r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(r*r+o*o),l=Math.max(50,a*this.tension),h=this.#x(t,i,l),c=this.#x(e,n,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#x(t,e,i){switch(e){case"left":return{x:t.x-i,y:t.y};case"right":return{x:t.x+i,y:t.y};case"top":return{x:t.x,y:t.y-i};case"bottom":return{x:t.x,y:t.y+i};default:return{x:t.x+i,y:t.y}}}#S(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#v(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#w(){this.#d(),this.#k();let t=this.#g();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#$(e,n),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",n),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#A(a,e,n)),this.appendChild(o),this.#i.set(r,o)}}this.#y(),this.#c()}#k(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#y(){let t=this.#g();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#$(e,n),o=this.#i.get(r);if(!o)continue;let a=this.#O(e,n);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#$(t,e){return t._noodleId||(t._noodleId=`_n${++ru}`),`${t._noodleId}:${e}`}#A=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n.setPointerCapture(t.pointerId),n.setAttribute("data-noodle-dragging","");let r=this.#O(e,i),o=l=>{if(!this.#a)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#m(r,{x:c,y:u},i,this.#C(r,{x:c,y:u})),this.#h(),this.#P(l.clientX,l.clientY,e),this.dispatchEvent(new CustomEvent("noodle-drag",{bubbles:!0,detail:{from:e,fromPort:i,x:c,y:u}}))},a=l=>{try{n.releasePointerCapture(l.pointerId)}catch{}if(n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#E(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#T(),this.#a=null,this.#l=null,this.#u=null,this.#h()};this.#u=()=>{this.#a=null,n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),this.#T(),this.#l=null,this.#u=null},this.#a={fromEl:e,fromSide:i,startPos:r,pointerId:t.pointerId},this.#l=null,n.addEventListener("pointermove",o),n.addEventListener("pointerup",a)};#C(t,e){let i=e.x-t.x,n=e.y-t.y;return Math.abs(i)>Math.abs(n)?i>0?"left":"right":n>0?"top":"bottom"}#P(t,e,i){this.#T();let n=this.#E(t,e,i);n?.dot&&n.dot.setAttribute("data-noodle-drop-ready","")}#E(t,e,i){let n=this.portSize*2,r=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#g().find(O=>O._noodleId===f);!m||m===i||d<n&&d<o&&(o=d,r={el:m,side:p,dot:l})}return r}#T(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};w("noodles-ui",wn);var Ci={};function me(s,t){Ci[s]=t}function kn(s,t){let e=s.firstElementChild;(!e||e.tagName!=="SPAN")&&(s.replaceChildren(),e=s.appendChild(document.createElement("span"))),e.textContent=t,s.title=t}var ou={basic:(s,t)=>s<t?-1:s>t?1:0,alphanumeric:(s,t)=>String(s??"").localeCompare(String(t??""),void 0,{numeric:!0,sensitivity:"base"}),numeric:(s,t)=>(Number(s)||0)-(Number(t)||0),datetime:(s,t)=>new Date(s||0).getTime()-new Date(t||0).getTime()};me("text",{render(s,t,e){kn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),me("number",{render(s,t,e){kn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),me("currency",{render(s,t,e,i){kn(e,s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:i?.currency||"USD"}).format(s):"")},format(s,t,e){return s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:e?.currency||"USD"}).format(s):""},align:"right",sortFn:"numeric"}),me("percent",{render(s,t,e){kn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var Yg={year:"numeric",month:"short",day:"numeric"};me("date",{render(s,t,e){kn(e,s?new Intl.DateTimeFormat("en-US",Yg).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",Yg).format(new Date(s)):""},align:"left",sortFn:"datetime"});var Ug={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};me("datetime",{render(s,t,e){kn(e,s?new Intl.DateTimeFormat("en-US",Ug).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",Ug).format(new Date(s)):""},align:"left",sortFn:"datetime"}),me("boolean",{render(s,t,e){let i=e.querySelector("check-ui");i||(e.textContent="",i=document.createElement("check-ui"),i.setAttribute("disabled",""),e.appendChild(i)),s?i.setAttribute("checked",""):i.removeAttribute("checked")},format(s){return s?"Yes":"No"},align:"center",sortFn:"basic"}),me("badge",{render(s,t,e,i){let n=e.querySelector("badge-ui");n||(e.textContent="",n=document.createElement("badge-ui"),e.appendChild(n)),n.setAttribute("text",String(s??""));let r=i?.variants||{};n.setAttribute("variant",r[s]||"neutral")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),me("avatar",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("avatar-ui");o.setAttribute("size","sm");let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("avatar-ui"),r=i.querySelector("span");n.setAttribute("text",String(s??"")),r.textContent=String(s??""),e.title=String(s??"")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),me("link",{render(s,t,e,i){let n=e.querySelector("a");n||(e.textContent="",n=document.createElement("a"),n.style.color="var(--table-accent, var(--a-primary))",n.style.textDecoration="none",e.appendChild(n));let r=String(s??""),o=r.includes("@")&&!r.startsWith("http");n.href=o?`mailto:${r}`:r,n.textContent=i?.label??r},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),me("progress",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("progress-ui"),r=i.querySelector("span");n.setAttribute("value",s!=null?String(s):"0"),r.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),me("actions",{render(s,t,e,i){let n=i?.actions||[],r=e.querySelector("row-ui");if(r&&r.children.length!==n.length&&(r.remove(),r=null),!r){e.textContent="",r=document.createElement("row-ui"),r.setAttribute("gap","1");for(let o of n){let a=document.createElement("button-ui");a.setAttribute("icon",o.icon||""),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label",o.label||""),a.addEventListener("click",()=>{a.dispatchEvent(new CustomEvent(o.event,{bubbles:!0,detail:{row:t}}))}),r.appendChild(a)}e.appendChild(r)}},format(){return""},align:"center",sortFn:null});function t1(s,t){if(!t||!s)return;let e=t.split("."),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function si(s,t){return typeof t.accessor=="function"?t.accessor(s):t1(s,t.key)}function rl(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
159
+ `)?'"'+t.replace(/"/g,'""')+'"':t}var $n=class extends A{static requiredIcons=["caret-right","caret-up-down","table","arrow-up","arrow-down","funnel-simple","funnel-simple-fill"];static properties={sortable:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},expandable:{type:Boolean,default:!1,reflect:!0},striped:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},density:{type:String,default:"standard",reflect:!0},paginate:{type:Number,default:0,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#n=new Set;#r=null;#o=0;#a=new Set;#l=new Map;#u=null;#h=!1;#c=-1;#d=null;#f=null;set columns(t){this.#t=Array.isArray(t)?t:[],this.#b()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#a.clear(),this.#o=0,this.#b()}get data(){return this.#e}get selected(){return[...this.#a].sort((t,e)=>t-e)}set selected(t){if(this.#a.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#a.add(e);this.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#a.size!==0&&(this.#a.clear(),this.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#o=0,this.#b(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#o=0,this.#b(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}toggleExpand(t){this.#n.has(t)?(this.#n.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#n.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#b()}get expanded(){return[...this.#n]}expandRenderer=null;getState(){return{sort:this.#i.map(t=>({...t})),filters:Object.fromEntries(this.#s),columnWidths:Object.fromEntries(this.#l),hiddenColumns:this.#t.filter(t=>t.hidden).map(t=>t.key),page:this.#o,density:this.density}}setState(t){if(t){if(t.sort&&(this.#i=t.sort),t.filters){this.#s.clear();for(let[e,i]of Object.entries(t.filters))this.#s.set(e,i)}if(t.columnWidths){this.#l.clear();for(let[e,i]of Object.entries(t.columnWidths))this.#l.set(e,i)}if(t.hiddenColumns)for(let e of this.#t)e.hidden=t.hiddenColumns.includes(e.key);t.page!=null&&(this.#o=t.page),t.density&&(this.density=t.density),this.#b()}}#p(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#g(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){this.#O(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#g(),this.#h||(this.#h=!0,this.addEventListener("click",this.#X),this.addEventListener("keydown",this.#z))}disconnected(){this.removeEventListener("click",this.#X),this.removeEventListener("keydown",this.#z),this.#h=!1,this.#q(),this.#m&&(cancelAnimationFrame(this.#m),this.#m=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}#O(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let n={key:i.getAttribute("key")||"",label:i.getAttribute("label")||i.getAttribute("key")||"",type:i.getAttribute("type")||"text",pinned:i.getAttribute("pinned")||null,hidden:i.hasAttribute("hidden"),sortable:i.hasAttribute("sortable"),resizable:i.hasAttribute("resizable"),filterable:i.hasAttribute("filterable"),filterType:i.getAttribute("filter-type")||null},r=i.getAttribute("width");r&&(n.width=Number(r));let o=i.getAttribute("min-width");o&&(n.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(n.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(n.flex=Number(l)),e.push(n),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#m=null;#b(){!this.isConnected||this.#m||(this.#m=requestAnimationFrame(()=>{this.#m=null,this.render(),this.#p()}))}get#x(){return this.#t.filter(t=>!t.hidden)}#S(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#x)this.#l.has(e.key)?t.push(`${this.#l.get(e.key)}px`):e.width?t.push(`${e.width}px`):e.flex?t.push(`minmax(6rem, ${e.flex}fr)`):t.push("minmax(6rem, 1fr)");return t.join(" ")}#v(){let t=this.#e.map((e,i)=>i);if(this.search){let e=this.search.toLowerCase();t=t.filter(i=>{let n=this.#e[i];return this.#x.some(r=>{let o=si(n,r);return o!=null&&String(o).toLowerCase().includes(e)})})}return this.#s.size&&(t=t.filter(e=>{let i=this.#e[e];for(let[n,{op:r,value:o}]of this.#s){let a=this.#t.find(u=>u.key===n),l=si(i,a||{key:n}),h=String(l??"").toLowerCase(),c=String(o).toLowerCase();switch(r){case"contains":if(!h.includes(c))return!1;break;case"equals":if(h!==c)return!1;break;case"startsWith":if(!h.startsWith(c))return!1;break;case"gt":if(Number(l)<=Number(o))return!1;break;case"lt":if(Number(l)>=Number(o))return!1;break;case"gte":if(Number(l)<Number(o))return!1;break;case"lte":if(Number(l)>Number(o))return!1;break;case"between":{let[u,d]=String(o).split(",").map(Number),f=Number(l);if(f<u||f>d)return!1;break}case"select":{if(!c.split(",").map(d=>d.trim()).includes(h))return!1;break}default:if(!h.includes(c))return!1}}return!0})),this.#i.length&&t.sort((e,i)=>{for(let{key:n,dir:r}of this.#i){let o=this.#t.find(u=>u.key===n),a=si(this.#e[e],o||{key:n}),l=si(this.#e[i],o||{key:n}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Ci[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=ou[d]||ou.alphanumeric}if(a==null&&l==null)continue;if(a==null)return 1;if(l==null)return-1;let c=h(a,l);if(c!==0)return r==="asc"?c:-c}return 0}),t}#w(t){if(!this.paginate||this.paginate<=0)return t;let e=this.#o*this.paginate;return t.slice(e,e+this.paginate)}get#k(){if(!this.paginate||this.paginate<=0)return 1;let t=this.#v().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#x;this.style.gridTemplateColumns=this.#S();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#y(e,t),this.#Z();let i=this.querySelector(":scope > [data-body]");i||(i=document.createElement("div"),i.setAttribute("role","rowgroup"),i.setAttribute("data-body",""),e.after(i));let n=this.#v(),r=this.#w(n),o=[];for(let c of r){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#$(c,t);if(u&&this.#A(u,c,t),this.expandable&&(this.#n.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded")),o.push(d),this.expandable&&this.#n.has(c)){let f=i.querySelector(`:scope > [data-detail-row][data-for="${c}"]`);if(!f&&(f=document.createElement("div"),f.setAttribute("data-detail-row",""),f.dataset.for=c,this.expandRenderer)){let p=this.expandRenderer(this.#e[c],c);p instanceof Node?f.appendChild(p):f.textContent=String(p)}o.push(f)}}let a=[...i.children];for(let c of a)o.includes(c)||c.remove();for(let c=0;c<o.length;c++)i.children[c]!==o[c]&&(i.children[c]?i.insertBefore(o[c],i.children[c]):i.appendChild(o[c]));this.#C(i),this.#P(i,n,t);let l=this.paginate>0&&this.#e.length>0,h=this.querySelector(":scope > [data-footer]");l?(h||(h=document.createElement("div"),h.setAttribute("data-footer",""),this.appendChild(h)),this.#E(h,n.length)):h&&h.remove()}#y(t,e){let i=this.#e.length>0&&this.#a.size===this.#e.length,n=[];if(this.selectable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),r.appendChild(o),n.push(r)}for(let r of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=r.label||r.key,o.appendChild(a),r.sortable!==!1&&this.sortable){o.dataset.sortKey=r.key,o.setAttribute("aria-label",`Sort by ${r.label||r.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===r.key);c?(o.setAttribute("aria-sort",c.dir==="asc"?"ascending":"descending"),h.setAttribute("name",c.dir==="asc"?"arrow-up":"arrow-down")):h.setAttribute("name","caret-up-down"),o.appendChild(h)}if(r.pinned&&o.setAttribute("data-pinned",r.pinned),r.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-resize-handle",""),h.dataset.resizeKey=r.key,o.appendChild(h)}if(r.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=r.key,h.setAttribute("aria-label",`Filter ${r.label||r.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(r.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===r.key){let u=this.#T(r);o.appendChild(u),o.setAttribute("data-filter-open","")}}n.push(o)}for(;t.children.length>n.length;)t.lastChild.remove();for(let r=0;r<n.length;r++)t.children[r]?t.replaceChild(n[r],t.children[r]):t.appendChild(n[r])}#$(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#A(i,t,e),i}#A(t,e,i){let n=this.#e[e],r=this.#a.has(e);t.dataset.index=e,r?(t.setAttribute("data-selected",""),t.setAttribute("aria-selected","true")):(t.removeAttribute("data-selected"),t.removeAttribute("aria-selected"));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col","");let l=document.createElement("button");l.setAttribute("data-expand-toggle",""),l.setAttribute("aria-label","Expand row");let h=document.createElement("icon-ui");h.setAttribute("name","caret-right"),h.setAttribute("size","xs"),l.appendChild(h),a.appendChild(l),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-check-col","");let l=document.createElement("check-ui");r&&l.setAttribute("checked",""),l.setAttribute("aria-label",`Select row ${e+1}`),a.appendChild(l),o.push(a)}for(let a of i){let l=document.createElement("div");l.setAttribute("role","gridcell"),l.dataset.key=a.key;let h=si(n,a);if(typeof a.render=="function"){let u=a.render(h,n,l,e);u instanceof Node?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u)}else if(typeof a.format=="function"){let u=a.format(h,n);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Ci[a.type||"text"];if(u?.render)u.render(h,n,l,a.meta);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Ci[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}for(;t.children.length>o.length;)t.lastChild.remove();for(let a=0;a<o.length;a++)t.children[a]?t.replaceChild(o[a],t.children[a]):t.appendChild(o[a])}#C(t){let e=this.querySelector(":scope > [data-empty]"),i=this.querySelector(":scope > [data-loading]");if(this.loading){this.setAttribute("aria-busy","true");let n=this.#x,r=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+n.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<r;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let n=document.createElement("icon-ui");n.setAttribute("name","table");let r=document.createElement("span");r.textContent="No data",e.appendChild(n),e.appendChild(r),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#P(t,e,i){let n=i.some(a=>a.aggregate),r=this.querySelector(":scope > [data-agg-row]");if(!n||this.#e.length===0){r&&r.remove();return}r||(r=document.createElement("div"),r.setAttribute("role","row"),r.setAttribute("data-agg-row",""),t.after(r));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}for(let a of i){let l=document.createElement("div");if(l.setAttribute("role","gridcell"),a.aggregate){let h=e.map(d=>{let f=si(this.#e[d],a);return f!=null?Number(f):NaN}).filter(d=>!isNaN(d)),c;switch(a.aggregate){case"sum":c=h.reduce((d,f)=>d+f,0);break;case"avg":c=h.length?h.reduce((d,f)=>d+f,0)/h.length:0;break;case"min":c=h.length?Math.min(...h):0;break;case"max":c=h.length?Math.max(...h):0;break;case"count":c=e.length;break;default:c=""}let u=Ci[a.type||"text"];typeof c=="number"&&u?.render?u.render(c,{},l,a.meta):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}for(;r.children.length>o.length;)r.lastChild.remove();for(let a=0;a<o.length;a++)r.children[a]?r.replaceChild(o[a],r.children[a]):r.appendChild(o[a])}#E(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",r=>{this.#o=r.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#o}}))}),t.appendChild(i));let n=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#o+1)),i.setAttribute("total",String(n))}#T(t){let e=document.createElement("div");e.setAttribute("data-filter-dropdown","");let i=this.#s.get(t.key);if(t.filter==="select"){let n=[...new Set(this.#e.map(o=>{let a=si(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),r=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of n){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=r.has(o.toLowerCase()),l.addEventListener("change",()=>{let h=[...e.querySelectorAll("input[type=checkbox]:checked")].map(c=>c.value);h.length?this.setFilter(t.key,h.join(","),"select"):this.setFilter(t.key,null)}),a.appendChild(l),a.appendChild(document.createTextNode(` ${o}`)),e.appendChild(a)}}else if(t.filter==="number"){let n=document.createElement("input");n.type="number",n.placeholder="Filter...",n.value=i?.value??"",n.setAttribute("data-filter-input","");let r=document.createElement("select");r.setAttribute("data-filter-op","");for(let[a,l]of[["gte","\u2265"],["lte","\u2264"],["gt",">"],["lt","<"],["equals","="]]){let h=document.createElement("option");h.value=a,h.textContent=l,i?.op===a&&(h.selected=!0),r.appendChild(h)}let o=()=>{n.value?this.setFilter(t.key,n.value,r.value):this.setFilter(t.key,null)};n.addEventListener("input",o),r.addEventListener("change",o),e.appendChild(r),e.appendChild(n)}else{let n=document.createElement("input");n.type="text",n.placeholder=`Filter ${t.label||t.key}...`,n.value=i?.value??"",n.setAttribute("data-filter-input",""),n.addEventListener("input",()=>{n.value?this.setFilter(t.key,n.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(n)}if(i){let n=document.createElement("button");n.textContent="Clear",n.setAttribute("data-filter-clear",""),n.addEventListener("click",()=>{this.setFilter(t.key,null),this.#d=null,this.#b()}),e.appendChild(n)}return this.#f!=null&&cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{if(this.#f=null,!this.isConnected)return;let n=e.querySelector("input");n&&n.focus()}),e}#Z(){let t=this.querySelector(":scope > [data-filter-bar]");if(this.#s.size===0){t&&t.remove();return}if(!t){t=document.createElement("div"),t.setAttribute("data-filter-bar",""),t.setAttribute("role","status");let i=this.querySelector(":scope > [data-header]");i?i.after(t):this.prepend(t)}t.innerHTML="";for(let[i,{op:n,value:r}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=n==="select"?`${r.split(",").length} selected`:r;l.setAttribute("text",`${a}: ${h}`),l.setAttribute("size","xs"),l.setAttribute("data-filter-chip",i);let c=document.createElement("button");c.textContent="\xD7",c.setAttribute("data-chip-dismiss",""),c.addEventListener("click",u=>{u.stopPropagation(),this.setFilter(i,null)}),l.appendChild(c),t.appendChild(l)}let e=document.createElement("button");e.textContent="Clear all",e.setAttribute("data-filter-clear-all",""),e.addEventListener("click",()=>this.clearFilters()),t.appendChild(e)}#X=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#d=this.#d===c?null:c,this.#b();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#b());let n=e.closest("[data-expand-toggle]");if(n&&this.expandable&&this.contains(n)){let c=n.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let r=e.closest("[data-resize-handle]");if(r&&this.contains(r)){this.#I(t,r);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#a.add(u);else this.#a.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#c>=0){let f=Math.min(this.#c,u),p=Math.max(this.#c,u);for(let m=f;m<=p;m++)d?this.#a.add(m):this.#a.delete(m)}else d?this.#a.add(u):this.#a.delete(u);this.#c=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(O=>O.key===d),m=p?si(f,p):void 0;this.dispatchEvent(new CustomEvent("cell-click",{bubbles:!0,detail:{key:d,row:f,value:m,dataIndex:u}})),this.dispatchEvent(new CustomEvent("row-click",{bubbles:!0,detail:{row:f,dataIndex:u}}))}}};#M=null;#I(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,n=this.#t.find(l=>l.key===i);if(!n)return;let r=e.closest('[role="columnheader"]'),o=r?r.getBoundingClientRect().width:100,a=t.clientX;this.setAttribute("data-resizing",""),this.#M={key:i,col:n,startX:a,startWidth:o},document.addEventListener("mousemove",this.#Q),document.addEventListener("mouseup",this.#D)}#Q=t=>{if(!this.#M)return;let{key:e,col:i,startX:n,startWidth:r}=this.#M,o=t.clientX-n,a=r+o,l=i.minWidth||48,h=i.maxWidth||1/0;a=Math.max(l,Math.min(h,a)),this.#l.set(e,Math.round(a)),this.style.gridTemplateColumns=this.#S()};#D=t=>{if(!this.#M)return;let{key:e}=this.#M;document.removeEventListener("mousemove",this.#Q),document.removeEventListener("mouseup",this.#D),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#M=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#q(){document.removeEventListener("mousemove",this.#Q),document.removeEventListener("mouseup",this.#D),this.#M=null}#z=t=>{let i=this.#x.length+(this.selectable?1:0),n=this.querySelector(":scope > [data-body]"),r=n?n.children.length:0;this.#u||(this.#u={row:0,col:0});let{row:o,col:a}=this.#u,l=!0;switch(t.key){case"ArrowDown":o=Math.min(o+1,r-1);break;case"ArrowUp":o=Math.max(o-1,-1);break;case"ArrowRight":a=Math.min(a+1,i-1);break;case"ArrowLeft":a=Math.max(a-1,0);break;case"Tab":if(t.shiftKey?(a--,a<0&&(a=i-1,o--)):(a++,a>=i&&(a=0,o++)),o<-1||o>=r){l=!1;break}break;case"Enter":if(o===-1){let c=this.querySelector(":scope > [data-header]")?.children[a];c?.dataset.sortKey&&c.click()}else{let h=this.querySelector("[data-focused]");h&&h.click()}break;default:l=!1}l&&(t.preventDefault(),this.#u={row:o,col:a},this.#N())};#N(){let t=this.querySelector("[data-focused]");if(t&&t.removeAttribute("data-focused"),!this.#u)return;let{row:e,col:i}=this.#u,n;e===-1?n=this.querySelector(":scope > [data-header]")?.children[i]:n=this.querySelector(":scope > [data-body]")?.children[e]?.children[i],n&&(n.setAttribute("data-focused",""),n.scrollIntoView?.({block:"nearest",inline:"nearest"}))}exportCSV(t="export.csv"){let e=this.#x,i=this.#v(),n=e.map(c=>rl(c.label||c.key)),r=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=si(u,d);if(typeof d.format=="function")return rl(d.format(f,u));let p=Ci[d.type||"text"];return p?.format?rl(p.format(f,u,d.meta)):rl(f)})}),o=[n.join(","),...r.map(c=>c.join(","))].join(`
160
+ `),a=new Blob([o],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),h=document.createElement("a");h.href=l,h.download=t,h.style.display="none",document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(l)}};w("table-ui",$n);var e1=200;function au(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-empty",""),t.setAttribute("color","subtle"),t.setAttribute("variant","caption"),t.textContent=s,t}function lu(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-head",""),t.setAttribute("variant","kicker"),t.setAttribute("color","subtle"),t.textContent=s,t}var i1=50,Fg=500;function Gg(s,t){if(typeof t?.accessor=="function")return t.accessor(s);let e=t?.key;if(!e||s==null)return;let i=String(e).split("."),n=s;for(let r of i){if(n==null)return;n=n[r]}return n}function s1(s){if(!s)return!1;let t=String(s);return!!(t==="id"||t==="ID"||t==="uuid"||t==="guid"||/[a-z](Id|ID)$/.test(t)||/_id$/i.test(t))}function n1(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(s1(s?.key))return"text";let e=[],i=Math.min(t?.length??0,Fg),n=new Set;for(let r=0;r<i;r++){let o=Gg(t[r],s);if(!(o==null||o==="")&&(e.push(o),n.add(String(o)),n.size>i1))return"text"}return e.length?"select":"text"}function r1(s,t){let e=new Set,i=Math.min(t?.length??0,Fg);for(let n=0;n<i;n++){let r=Gg(t[n],s);r==null||r===""||e.add(String(r))}return[...e].sort((n,r)=>n.localeCompare(r,void 0,{numeric:!0}))}var An=class s extends A{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#n=null;#r=new Set;static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){this.setAttribute("role","toolbar"),this.#o(),this.#h(),this.#a(),this.#O()}disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null);for(let t of this.#r)cancelAnimationFrame(t);this.#r.clear(),this.#b(),this.#u()}render(){this.#a(),this.#O(),this.#f()}#o(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let n=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(n)||s._OPT_OUT_PREFIX_RE.test(n)&&t.push(n)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#a(){let t=this.#l();if(t===this.#t||(this.#u(),!t))return;this.#t=t;let e=()=>this.#y(),i=()=>this.#w();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#l(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#u(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#h(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-title","");let i=document.createElement("span");i.setAttribute("data-heading",""),e.appendChild(i);let n=document.createElement("badge-ui");n.setAttribute("data-count-badge",""),n.setAttribute("size","sm"),n.setAttribute("variant","muted"),n.hidden=!0,e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-controls",""),r.appendChild(this.#d("filter","Filter","funnel-simple")),r.appendChild(this.#d("sort","Sort","arrows-down-up")),r.appendChild(this.#d("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String(e1)),o.addEventListener("search",this.#g);let a=document.createElement("div");a.setAttribute("data-actions","");for(let l of[...this.children])l!==t&&l.getAttribute?.("slot")==="actions"&&a.appendChild(l);t.appendChild(e),t.appendChild(r),t.appendChild(o),t.appendChild(a),this.appendChild(t),this.#f(),this.#p()}#c(t,e){let i=document.createElement("button-ui");return i.setAttribute("data-popover-action",""),i.setAttribute("text",t),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#d(t,e,i){let n=document.createElement("button-ui");return n.setAttribute("data-toolbar-btn",t),n.setAttribute("icon",i),n.setAttribute("text",e),n.setAttribute("variant","outline"),n.setAttribute("size","sm"),n.setAttribute("aria-haspopup","menu"),n.addEventListener("click",r=>{r.stopPropagation(),this.#m(t,n)}),n}#f(){let t=this.querySelector(":scope [data-heading]");if(!t)return;this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0;let e=this.querySelector(":scope [data-count-badge]");if(!e)return;let i=this.count?.toString().trim(),n=this.#t?.data?.length,r=i||(Number.isFinite(n)?String(n):"");r?(e.setAttribute("text",r),e.hidden=!1):e.hidden=!0}#p(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=(i,n)=>{let r=t.querySelector(i);r&&(r.hidden=n)};e('[data-toolbar-btn="filter"]',this.noFilter),e('[data-toolbar-btn="sort"]',this.noSort),e('[data-toolbar-btn="columns"]',this.noColumns),e("[data-search]",this.noSearch)}attributeChanged(t){["no-filter","no-sort","no-columns","no-search"].includes(t)&&this.#p(),t==="placeholder"&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}#g=t=>{let e=t.detail?.value??"";this.#t&&(this.#t.search=e),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#O(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#f()}#m(t,e){if(this.#i?.kind===t){this.#b();return}this.#b();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#v(i),t==="sort"&&this.#k(i),t==="columns"&&this.#$(i),document.body.appendChild(i);try{i.showPopover()}catch{}let n=Tt(e,i,{placement:"bottom-start",gap:4});this.#i={kind:t,btn:e,panel:i,cleanup:n},this.#s||(this.#s=!0,this.#n=requestAnimationFrame(()=>{this.#n=null,!(!this.isConnected||!this.#s)&&(document.addEventListener("pointerdown",this.#x,!0),document.addEventListener("keydown",this.#S,!0))}))}#b(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#x,!0),document.removeEventListener("keydown",this.#S,!0))}}#x=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#b())};#S=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#b(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(au("No filterable columns"));return}let i=e.filters||{};t.appendChild(lu("Filter rows"));let n=document.createElement("div");n.setAttribute("data-popover-list","");let r=e.data||[];for(let o of e.columns){if(o.hidden)continue;let a=document.createElement("field-ui");a.setAttribute("data-filter-row",""),a.setAttribute("inline",""),a.setAttribute("label",o.label||o.key);let l=n1(o,r),h=i[o.key];if(l==="select"){let c=document.createElement("select-ui");c.setAttribute("data-filter-input",""),c.setAttribute("multiple",""),c.setAttribute("placeholder","\u2014");let u=r1(o,r);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";d?e.setFilter(o.key,d,"select"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size","sm"),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;u?e.setFilter(o.key,u,"contains"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}n.appendChild(a)}if(t.appendChild(n),Object.keys(i).length){let o=this.#c("Clear all filters",()=>{e.clearFilters(),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#w()});t.appendChild(o)}}#w(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#k(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(au("No sortable columns"));return}t.appendChild(lu("Sort by"));let i=e.sortState||[],n=new Map(i.map(o=>[o.key,o.dir])),r=document.createElement("div");r.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=n.get(o.key),l=document.createElement("menu-item-ui");l.setAttribute("data-sort-row",""),l.setAttribute("text",o.label||o.key),l.dataset.key=o.key,a&&(l.dataset.active=a);let h=requestAnimationFrame(()=>{if(this.#r.delete(h),!this.isConnected)return;let c=document.createElement("icon-ui");c.setAttribute("data-sort-indicator",""),c.setAttribute("size","xs"),c.setAttribute("name",a==="asc"?"arrow-up":a==="desc"?"arrow-down":"caret-up-down"),l.appendChild(c)});this.#r.add(h),l.addEventListener("click",c=>{let u=e.querySelector(`:scope > [data-header] [data-sort-key="${o.key}"]`);if(!u)return;let d=new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c.shiftKey});u.dispatchEvent(d),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#y()}),r.appendChild(l)}if(t.appendChild(r),i.length){let o=this.#c("Clear sort",()=>{for(let a of[...i]){let l=e.querySelector(`:scope > [data-header] [data-sort-key="${a.key}"]`);if(!l)continue;let h=c=>l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c}));i.length>1?(h(!0),h(!0)):(h(!1),h(!1))}this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#y()});t.appendChild(o)}}#y(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#k(t.panel))}#$(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(au("No columns"));return}t.appendChild(lu("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let n of e.columns){let r=document.createElement("field-ui");r.setAttribute("data-columns-row",""),r.setAttribute("inline",""),r.setAttribute("label",n.label||n.key);let o=document.createElement("check-ui");n.hidden||o.setAttribute("checked",""),o.dataset.key=n.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===n.key?{...l,hidden:!o.hasAttribute("checked")}:{...l});e.columns=a,this.dispatchEvent(new CustomEvent("columns-change",{bubbles:!0,detail:{hiddenColumns:a.filter(l=>l.hidden).map(l=>l.key)}}))}),r.appendChild(o),i.appendChild(r)}t.appendChild(i)}};w("table-toolbar-ui",An);var Qn=class extends A{static properties={orientation:{type:String,default:"vertical",reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll(":scope > timeline-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];e&&e.setAttribute("data-last","")}},Pn=class extends A{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},time:{type:String,default:"",reflect:!0},duration:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},status:{type:String,default:"idle",reflect:!0},spinner:{type:Boolean,default:!1,reflect:!0}};static requiredIcons=["caret-down","caret-right"];static template=()=>null;#t=[];#e=!1;get outcomes(){return this.#t}set outcomes(t){this.#t=Array.isArray(t)?t.slice():[],this.render()}connected(){this.querySelector(':scope > [slot="label"]')||(this.innerHTML=`
161
161
  <span slot="label"></span>
162
162
  <span slot="description"></span>
163
163
  <span slot="time"></span>
164
164
  `)}render(){let t=this.querySelector(':scope > [slot="label"]'),e=this.querySelector(':scope > [slot="description"]'),i=this.querySelector(':scope > [slot="time"]');if(t&&(t.textContent=this.text),e&&(e.textContent=this.description),i&&(i.textContent=this.duration||this.time),this.icon){let r=this.querySelector(':scope > [slot="icon"]');r||(r=document.createElement("icon-ui"),r.setAttribute("slot","icon"),this.prepend(r)),r.setAttribute("name",this.icon)}else this.querySelector(':scope > [slot="icon"]')?.remove();let n=this.querySelector(':scope > [slot="outcomes"]');if(this.#t.length>0){n||(n=document.createElement("ul"),n.setAttribute("slot","outcomes"),this.appendChild(n)),n.innerHTML="";for(let a of this.#t){let l=document.createElement("li");l.textContent=a,n.appendChild(l)}n.hidden=!this.#e;let r=this.querySelector(":scope > [data-timeline-toggle]");r||(r=document.createElement("button"),r.type="button",r.setAttribute("data-timeline-toggle",""),r.setAttribute("aria-label","Toggle details"),r.addEventListener("click",a=>{a.stopPropagation(),this.#e=!this.#e,this.render(),this.dispatchEvent(new CustomEvent("timeline-toggle",{bubbles:!0,detail:{expanded:this.#e}}))}),this.appendChild(r)),r.innerHTML="";let o=document.createElement("icon-ui");o.setAttribute("name",this.#e?"caret-down":"caret-right"),o.setAttribute("color","muted"),o.setAttribute("size","sm"),r.appendChild(o)}else this.querySelector(":scope > [data-timeline-toggle]")?.remove(),n?.remove()}};w("timeline-ui",Qn),w("timeline-item-ui",Pn);var Cn=class extends A{static properties={step:{type:Number,default:0,reflect:!0},orientation:{type:String,default:"horizontal",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll("stepper-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];e&&e.setAttribute("data-last",""),t.forEach((i,n)=>{i.setAttribute("data-index",n),n<this.step?i.setAttribute("status","completed"):n===this.step?i.setAttribute("status","active"):i.setAttribute("status","idle")})}next(){let t=this.querySelectorAll("stepper-item-ui").length;this.step<t-1&&this.step++}prev(){this.step>0&&this.step--}goTo(t){let e=this.querySelectorAll("stepper-item-ui").length-1;this.step=Math.max(0,Math.min(t,e))}},En=class extends A{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"idle",reflect:!0}};static template=()=>null;connected(){this.querySelector('[slot="label"]')||(this.innerHTML=`
165
165
  <span slot="label"></span>
166
166
  <span slot="description"></span>
167
- `)}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');if(t&&(t.textContent=this.text),e&&(e.textContent=this.description),this.icon){let i=this.querySelector('[slot="icon"]');i||(i=document.createElement("icon-ui"),i.setAttribute("slot","icon"),this.prepend(i)),i.setAttribute("name",this.icon)}else this.querySelector('[slot="icon"]')?.remove()}};w("stepper-ui",Cn),w("stepper-item-ui",En);var Tn=class extends A{static properties={autoplay:{type:Boolean,default:!1,reflect:!0},interval:{type:Number,default:5e3,reflect:!0},noPauseOnHover:{type:Boolean,default:!1,reflect:!0,attribute:"no-pause-on-hover"},loop:{type:Boolean,default:!1,reflect:!0},peek:{type:Boolean,default:!1,reflect:!0},snap:{type:String,default:"start",reflect:!0},gap:{type:String,default:"",reflect:!0},slidesPerView:{type:String,default:"",reflect:!0,attribute:"slides-per-view"},chrome:{type:String,default:"default",reflect:!0},label:{type:String,default:""},counter:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=0;#r=!1;#o=!1;#a=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#n}connected(){if(!this.#t){for(this.#t=document.createElement("div"),this.#t.setAttribute("data-swiper-track","");this.firstChild;)this.#t.appendChild(this.firstChild);this.appendChild(this.#t)}this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.getAttribute("aria-label")||this.setAttribute("aria-label","Carousel"),this.#l(),this.#u(),this.#O(),this.#r||(this.#r=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#w),this.addEventListener("pointerleave",this.#k),this.addEventListener("focusin",this.#y),this.addEventListener("focusout",this.#$)),this.addEventListener("keydown",this.#Q),this.#t.addEventListener("pointerdown",this.#C),this.#t.addEventListener("pointermove",this.#L),this.#t.addEventListener("pointerup",this.#E),this.#t.addEventListener("pointercancel",this.#E),this.#t.addEventListener("click",this.#Z,!0),this.#t.addEventListener("dragstart",this.#X)),this.autoplay&&this.play()}render(){if(this.gap&&this.#t){let e=/^[0-9]+$/.test(this.gap)?`var(--a-space-${this.gap})`:this.gap;this.style.setProperty("--swiper-gap",e)}}disconnected(){this.pause(),this.#i?.disconnect(),this.#i=null,this.#t&&this.#s&&this.#t.removeEventListener("scroll",this.#s),this.#s=null,this.removeEventListener("pointerenter",this.#w),this.removeEventListener("pointerleave",this.#k),this.removeEventListener("focusin",this.#y),this.removeEventListener("focusout",this.#$),this.removeEventListener("keydown",this.#Q),this.#t&&(this.#t.removeEventListener("pointerdown",this.#C),this.#t.removeEventListener("pointermove",this.#L),this.#t.removeEventListener("pointerup",this.#E),this.#t.removeEventListener("pointercancel",this.#E),this.#t.removeEventListener("click",this.#Z,!0),this.#t.removeEventListener("dragstart",this.#X)),this.#a=null,this.#t=null,this.#r=!1}next(){let t=this.#c()-1,e=this.#g(this.#n),i=Math.min(e+1,t);if(i!==e||this.loop){let n=this.loop&&i===e?0:i;this.goTo(this.#p(n))}}prev(){let t=this.#c()-1,e=this.#g(this.#n),i=Math.max(e-1,0);if(i!==e||this.loop){let n=this.loop&&i===e?t:i;this.goTo(this.#p(n))}}goTo(t){let e=this.slides[t];if(!e||!this.#t)return;let i=Math.max(0,this.#d(e));this.#t.scrollTo({left:i,behavior:"smooth"})}play(){this.pause(),!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(this.#e=setInterval(()=>{let t=this.#c()-1,i=this.#g(this.#n)>=t;i&&this.loop?this.goTo(this.#p(0)):i?this.pause():this.next()},this.interval||5e3))}pause(){this.#e&&(clearInterval(this.#e),this.#e=null)}#l(){let t=this.slides;t.forEach((e,i)=>{e.setAttribute("role","group"),e.setAttribute("aria-roledescription","slide"),e.getAttribute("aria-label")||e.setAttribute("aria-label",`${i+1} of ${t.length}`)})}#u(){this.#s=()=>{let t=this.#f();t!==this.#n&&(this.#n=t,this.#x(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{index:t,slide:this.slides[t]}})))},this.#t.addEventListener("scroll",this.#s,{passive:!0}),this.#n=this.#f()}#h(){if(!this.#t)return 1;let t=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:1}#c(){let t=this.slides.length;return t===0?0:this.snap==="center"?t:Math.max(1,t-this.#h()+1)}#d(t){let e=this.#t.clientWidth,i=t.offsetLeft-this.#t.offsetLeft,n=t.offsetWidth;return this.snap==="center"?i+n/2-e/2:this.snap==="end"?i+n-e:i}#f(){if(!this.#t)return 0;let t=this.slides;if(t.length===0)return 0;let e=this.#t.scrollLeft,i=Math.max(0,this.#t.scrollWidth-this.#t.clientWidth),n=0,r=1/0;for(let o=0;o<t.length;o++){let a=Math.max(0,Math.min(i,this.#d(t[o]))),l=Math.abs(e-a);l<r&&(r=l,n=o)}return n}#p(t){if(this.snap!=="end")return t;let e=this.#h();return Math.min(this.slides.length-1,t+e-1)}#g(t){if(this.snap!=="end")return t;let e=this.#h();return Math.max(0,t-e+1)}#O(){this.#o||(this.#o=!0,this.chrome==="toolbar"?this.#b():this.#m(),this.#S(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#S()),this.#i.observe(this)))}#m(){let t=document.createElement("button-ui");t.setAttribute("data-swiper-btn",""),t.setAttribute("data-swiper-prev",""),t.setAttribute("icon","caret-left"),t.setAttribute("variant","ghost"),t.setAttribute("aria-label","Previous slide"),t.addEventListener("press",()=>this.prev());let e=document.createElement("button-ui");e.setAttribute("data-swiper-btn",""),e.setAttribute("data-swiper-next",""),e.setAttribute("icon","caret-right"),e.setAttribute("variant","ghost"),e.setAttribute("aria-label","Next slide"),e.addEventListener("press",()=>this.next()),this.appendChild(t),this.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-dots",""),i.setAttribute("role","tablist"),i.setAttribute("aria-label","Slide indicators"),this.appendChild(i)}#b(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let n=document.createElement("button-ui");n.setAttribute("icon","caret-left"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Previous slide"),n.addEventListener("press",()=>this.prev());let r=document.createElement("button-ui");r.setAttribute("icon","caret-right"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Next slide"),r.addEventListener("press",()=>this.next()),i.appendChild(n),i.appendChild(r),t.appendChild(i),this.insertBefore(t,this.#t);let o=document.createElement("div");o.setAttribute("data-swiper-foot","");let a=document.createElement("span");a.setAttribute("data-swiper-counter",""),o.appendChild(a);let l=document.createElement("div");l.setAttribute("data-swiper-dots",""),l.setAttribute("role","tablist"),l.setAttribute("aria-label","Slide indicators"),o.appendChild(l),this.appendChild(o),this.#v()}#v(){let t=this.querySelector("[data-swiper-counter]");if(!t)return;if(!this.counter){t.textContent="";return}let e=this.#g(this.#n)+1,i=this.#c();t.textContent=`${e} / ${i}`}#S(){let t=this.querySelector("[data-swiper-dots]");if(!t)return;let e=this.#c();if(t.children.length!==e){for(;t.firstChild;)t.removeChild(t.firstChild);for(let i=0;i<e;i++){let n=document.createElement("button");n.setAttribute("role","tab"),n.setAttribute("aria-label",`Page ${i+1}`),n.addEventListener("click",()=>this.goTo(this.#p(i))),t.appendChild(n)}}this.#x()}#x(){if(!this.#o)return;let t=this.querySelector("[data-swiper-dots]");if(t){let e=this.#c()-1,i=Math.min(Math.max(this.#g(this.#n),0),e);[...t.children].forEach((n,r)=>{n.setAttribute("aria-current",r===i?"true":"false")})}this.#v()}#w=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#k=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#y=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#$=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#Q=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#P=5;#C=t=>{t.pointerType!=="touch"&&t.button===0&&(t.target.closest("button, button-ui, a, input, select, textarea")||(this.#a={pointerId:t.pointerId,startX:t.clientX,startScrollLeft:this.#t.scrollLeft,hasMoved:!1},this.#t.style.scrollBehavior="auto",this.#t.setAttribute("data-dragging","")))};#L=t=>{if(!this.#a||t.pointerId!==this.#a.pointerId)return;let e=t.clientX-this.#a.startX;if(Math.abs(e)>=this.#P){if(!this.#a.hasMoved){this.#a.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#a.startScrollLeft-e,t.preventDefault()}};#E=t=>{if(!this.#a||t.pointerId!==this.#a.pointerId)return;let e=this.#a.hasMoved;if(e)try{this.#t.releasePointerCapture(t.pointerId)}catch{}this.#a=null,this.#t.style.scrollBehavior="",this.#t.removeAttribute("data-dragging"),e&&(this.#t.setAttribute("data-just-dragged",""),requestAnimationFrame(()=>this.#t?.removeAttribute("data-just-dragged")))};#Z=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#X=t=>{this.#a&&t.preventDefault()}};w("swiper-ui",Tn);var Ln=class extends z{static labelDeprecated=!1;static properties={...z.properties,label:{type:String,default:"",reflect:!0},accept:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;connected(){super.connected(),this.querySelector("[data-dropzone]")||(this.innerHTML=`
167
+ `)}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');if(t&&(t.textContent=this.text),e&&(e.textContent=this.description),this.icon){let i=this.querySelector('[slot="icon"]');i||(i=document.createElement("icon-ui"),i.setAttribute("slot","icon"),this.prepend(i)),i.setAttribute("name",this.icon)}else this.querySelector('[slot="icon"]')?.remove()}};w("stepper-ui",Cn),w("stepper-item-ui",En);var Tn=class extends A{static properties={autoplay:{type:Boolean,default:!1,reflect:!0},interval:{type:Number,default:5e3,reflect:!0},noPauseOnHover:{type:Boolean,default:!1,reflect:!0,attribute:"no-pause-on-hover"},loop:{type:Boolean,default:!1,reflect:!0},peek:{type:Boolean,default:!1,reflect:!0},snap:{type:String,default:"start",reflect:!0},gap:{type:String,default:"",reflect:!0},slidesPerView:{type:String,default:"",reflect:!0,attribute:"slides-per-view"},chrome:{type:String,default:"default",reflect:!0},label:{type:String,default:""},counter:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=0;#r=!1;#o=!1;#a=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#n}connected(){if(!this.#t){for(this.#t=document.createElement("div"),this.#t.setAttribute("data-swiper-track","");this.firstChild;)this.#t.appendChild(this.firstChild);this.appendChild(this.#t)}this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.getAttribute("aria-label")||this.setAttribute("aria-label","Carousel"),this.#l(),this.#u(),this.#O(),this.#r||(this.#r=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#w),this.addEventListener("pointerleave",this.#k),this.addEventListener("focusin",this.#y),this.addEventListener("focusout",this.#$)),this.addEventListener("keydown",this.#A),this.#t.addEventListener("pointerdown",this.#P),this.#t.addEventListener("pointermove",this.#E),this.#t.addEventListener("pointerup",this.#T),this.#t.addEventListener("pointercancel",this.#T),this.#t.addEventListener("click",this.#Z,!0),this.#t.addEventListener("dragstart",this.#X)),this.autoplay&&this.play()}render(){if(this.gap&&this.#t){let e=/^[0-9]+$/.test(this.gap)?`var(--a-space-${this.gap})`:this.gap;this.style.setProperty("--swiper-gap",e)}}disconnected(){this.pause(),this.#i?.disconnect(),this.#i=null,this.#t&&this.#s&&this.#t.removeEventListener("scroll",this.#s),this.#s=null,this.removeEventListener("pointerenter",this.#w),this.removeEventListener("pointerleave",this.#k),this.removeEventListener("focusin",this.#y),this.removeEventListener("focusout",this.#$),this.removeEventListener("keydown",this.#A),this.#t&&(this.#t.removeEventListener("pointerdown",this.#P),this.#t.removeEventListener("pointermove",this.#E),this.#t.removeEventListener("pointerup",this.#T),this.#t.removeEventListener("pointercancel",this.#T),this.#t.removeEventListener("click",this.#Z,!0),this.#t.removeEventListener("dragstart",this.#X)),this.#a=null,this.#t=null,this.#r=!1}next(){let t=this.#c()-1,e=this.#g(this.#n),i=Math.min(e+1,t);if(i!==e||this.loop){let n=this.loop&&i===e?0:i;this.goTo(this.#p(n))}}prev(){let t=this.#c()-1,e=this.#g(this.#n),i=Math.max(e-1,0);if(i!==e||this.loop){let n=this.loop&&i===e?t:i;this.goTo(this.#p(n))}}goTo(t){let e=this.slides[t];if(!e||!this.#t)return;let i=Math.max(0,this.#d(e));this.#t.scrollTo({left:i,behavior:"smooth"})}play(){this.pause(),!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(this.#e=setInterval(()=>{let t=this.#c()-1,i=this.#g(this.#n)>=t;i&&this.loop?this.goTo(this.#p(0)):i?this.pause():this.next()},this.interval||5e3))}pause(){this.#e&&(clearInterval(this.#e),this.#e=null)}#l(){let t=this.slides;t.forEach((e,i)=>{e.setAttribute("role","group"),e.setAttribute("aria-roledescription","slide"),e.getAttribute("aria-label")||e.setAttribute("aria-label",`${i+1} of ${t.length}`)})}#u(){this.#s=()=>{let t=this.#f();t!==this.#n&&(this.#n=t,this.#v(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{index:t,slide:this.slides[t]}})))},this.#t.addEventListener("scroll",this.#s,{passive:!0}),this.#n=this.#f()}#h(){if(!this.#t)return 1;let t=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:1}#c(){let t=this.slides.length;return t===0?0:this.snap==="center"?t:Math.max(1,t-this.#h()+1)}#d(t){let e=this.#t.clientWidth,i=t.offsetLeft-this.#t.offsetLeft,n=t.offsetWidth;return this.snap==="center"?i+n/2-e/2:this.snap==="end"?i+n-e:i}#f(){if(!this.#t)return 0;let t=this.slides;if(t.length===0)return 0;let e=this.#t.scrollLeft,i=Math.max(0,this.#t.scrollWidth-this.#t.clientWidth),n=0,r=1/0;for(let o=0;o<t.length;o++){let a=Math.max(0,Math.min(i,this.#d(t[o]))),l=Math.abs(e-a);l<r&&(r=l,n=o)}return n}#p(t){if(this.snap!=="end")return t;let e=this.#h();return Math.min(this.slides.length-1,t+e-1)}#g(t){if(this.snap!=="end")return t;let e=this.#h();return Math.max(0,t-e+1)}#O(){this.#o||(this.#o=!0,this.chrome==="toolbar"?this.#b():this.#m(),this.#S(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#S()),this.#i.observe(this)))}#m(){let t=document.createElement("button-ui");t.setAttribute("data-swiper-btn",""),t.setAttribute("data-swiper-prev",""),t.setAttribute("icon","caret-left"),t.setAttribute("variant","ghost"),t.setAttribute("aria-label","Previous slide"),t.addEventListener("press",()=>this.prev());let e=document.createElement("button-ui");e.setAttribute("data-swiper-btn",""),e.setAttribute("data-swiper-next",""),e.setAttribute("icon","caret-right"),e.setAttribute("variant","ghost"),e.setAttribute("aria-label","Next slide"),e.addEventListener("press",()=>this.next()),this.appendChild(t),this.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-dots",""),i.setAttribute("role","tablist"),i.setAttribute("aria-label","Slide indicators"),this.appendChild(i)}#b(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let n=document.createElement("button-ui");n.setAttribute("icon","caret-left"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Previous slide"),n.addEventListener("press",()=>this.prev());let r=document.createElement("button-ui");r.setAttribute("icon","caret-right"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Next slide"),r.addEventListener("press",()=>this.next()),i.appendChild(n),i.appendChild(r),t.appendChild(i),this.insertBefore(t,this.#t);let o=document.createElement("div");o.setAttribute("data-swiper-foot","");let a=document.createElement("span");a.setAttribute("data-swiper-counter",""),o.appendChild(a);let l=document.createElement("div");l.setAttribute("data-swiper-dots",""),l.setAttribute("role","tablist"),l.setAttribute("aria-label","Slide indicators"),o.appendChild(l),this.appendChild(o),this.#x()}#x(){let t=this.querySelector("[data-swiper-counter]");if(!t)return;if(!this.counter){t.textContent="";return}let e=this.#g(this.#n)+1,i=this.#c();t.textContent=`${e} / ${i}`}#S(){let t=this.querySelector("[data-swiper-dots]");if(!t)return;let e=this.#c();if(t.children.length!==e){for(;t.firstChild;)t.removeChild(t.firstChild);for(let i=0;i<e;i++){let n=document.createElement("button");n.setAttribute("role","tab"),n.setAttribute("aria-label",`Page ${i+1}`),n.addEventListener("click",()=>this.goTo(this.#p(i))),t.appendChild(n)}}this.#v()}#v(){if(!this.#o)return;let t=this.querySelector("[data-swiper-dots]");if(t){let e=this.#c()-1,i=Math.min(Math.max(this.#g(this.#n),0),e);[...t.children].forEach((n,r)=>{n.setAttribute("aria-current",r===i?"true":"false")})}this.#x()}#w=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#k=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#y=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#$=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#A=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#C=5;#P=t=>{t.pointerType!=="touch"&&t.button===0&&(t.target.closest("button, button-ui, a, input, select, textarea")||(this.#a={pointerId:t.pointerId,startX:t.clientX,startScrollLeft:this.#t.scrollLeft,hasMoved:!1},this.#t.style.scrollBehavior="auto",this.#t.setAttribute("data-dragging","")))};#E=t=>{if(!this.#a||t.pointerId!==this.#a.pointerId)return;let e=t.clientX-this.#a.startX;if(Math.abs(e)>=this.#C){if(!this.#a.hasMoved){this.#a.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#a.startScrollLeft-e,t.preventDefault()}};#T=t=>{if(!this.#a||t.pointerId!==this.#a.pointerId)return;let e=this.#a.hasMoved;if(e)try{this.#t.releasePointerCapture(t.pointerId)}catch{}this.#a=null,this.#t.style.scrollBehavior="",this.#t.removeAttribute("data-dragging"),e&&(this.#t.setAttribute("data-just-dragged",""),requestAnimationFrame(()=>this.#t?.removeAttribute("data-just-dragged")))};#Z=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#X=t=>{this.#a&&t.preventDefault()}};w("swiper-ui",Tn);var Ln=class extends z{static labelDeprecated=!1;static properties={...z.properties,label:{type:String,default:"",reflect:!0},accept:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;connected(){super.connected(),this.querySelector("[data-dropzone]")||(this.innerHTML=`
168
168
  <div data-dropzone tabindex="0" role="button">Drop files here or click to browse</div>
169
169
  <span hint="${this.hint||""}"></span>
170
170
  <div data-filelist></div>
171
- `),this.#e=this.querySelector("[data-dropzone]"),this.#e&&(this.#e.addEventListener("click",this.#i),this.#e.addEventListener("keydown",this.#s),this.#e.addEventListener("dragover",this.#a),this.#e.addEventListener("dragleave",this.#l),this.#e.addEventListener("drop",this.#u))}render(){let t=this.querySelector("[data-filelist]");if(!this.#e||!t)return;let e=this.querySelector("span[hint]");e&&this.hint&&e.setAttribute("hint",this.hint),t.innerHTML="";for(let i of this.#t){let n=document.createElement("span");n.textContent=i.name,t.appendChild(n)}}get files(){return this.#t}#i=()=>{this.disabled||this.#n()};#s=t=>{this.disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#n())};async#n(){try{if(window.showOpenFilePicker){let t=this.#o(),e={multiple:this.multiple};t.length&&(e.types=t);let i=await window.showOpenFilePicker(e);if(!this.isConnected)return;let n=await Promise.all(i.map(r=>r.getFile()));if(!this.isConnected)return;this.#h(n)}else this.#r()}catch(t){if(t.name!=="AbortError")throw t}}#r(){let t=document.createElement("input");t.type="file",this.accept&&(t.accept=this.accept),this.multiple&&(t.multiple=!0),t.style.display="none",document.body.appendChild(t),t.addEventListener("change",()=>{t.files?.length&&this.#h([...t.files]),t.remove()},{once:!0}),t.addEventListener("cancel",()=>t.remove(),{once:!0}),t.click()}#o(){if(!this.accept)return[];let t={};for(let e of this.accept.split(",")){let i=e.trim();i&&(i.startsWith(".")?(t["application/octet-stream"]=t["application/octet-stream"]||[],t["application/octet-stream"].push(i)):t[i]=t[i]||[])}return Object.keys(t).length?[{accept:t}]:[]}#a=t=>{t.preventDefault(),this.querySelector("[data-dropzone]")?.setAttribute("data-dragover","")};#l=()=>{this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover")};#u=t=>{if(t.preventDefault(),this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover"),this.disabled)return;let e=t.dataTransfer;e?.files?.length&&this.#h([...e.files])};#h(t){this.#t=t;let e=new FormData;for(let i of this.#t)e.append(this.name||"file",i);this.internals.setFormValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,files:this.files}})),this.render()}disconnected(){super.disconnected(),this.#e&&(this.#e.removeEventListener("click",this.#i),this.#e.removeEventListener("keydown",this.#s),this.#e.removeEventListener("dragover",this.#a),this.#e.removeEventListener("dragleave",this.#l),this.#e.removeEventListener("drop",this.#u)),this.#e=null}};w("upload-ui",Ln);var Mn=Bg({name:"draggable",category:"motion-positioning",description:"Pointer drag to reposition",attributes:["data-draggable-dragging"],events:["drag-end"],config:[],setup({host:s}){let t=!1,e=0,i=0,n=0,r=0;function o(){return s.hasAttribute("disabled")}function a(c){if(o())return;t=!0,e=c.clientX,i=c.clientY;let u=getComputedStyle(s),d=u.translate;if(d&&d!=="none"){let f=d.split(/\s+/).map(parseFloat);n=f[0]||0,r=f[1]||0}else{let f=new DOMMatrixReadOnly(u.transform);n=f.m41,r=f.m42}s.setPointerCapture(c.pointerId),s.setAttribute("data-draggable-dragging",""),s.style.touchAction="none"}function l(c){if(!t)return;let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.style.translate=`${f}px ${p}px`}function h(c){if(!t)return;t=!1,s.removeAttribute("data-draggable-dragging");let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.dispatchEvent(new CustomEvent("drag-end",{bubbles:!0,detail:{x:f,y:p}}))}return s.addEventListener("pointerdown",a),s.addEventListener("pointermove",l),s.addEventListener("pointerup",h),()=>{s.removeEventListener("pointerdown",a),s.removeEventListener("pointermove",l),s.removeEventListener("pointerup",h),s.removeAttribute("data-draggable-dragging"),s.style.touchAction=""}}});var Rn=class extends A{static properties={variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"",reflect:!0},elevation:{type:Number,default:1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Mn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Mn),this.#t=!0)}};w("card-ui",Rn);var Xn=class s extends A{static properties={src:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},shape:{type:String,default:"circle",reflect:!0}};get displayName(){return this.text||this.name}static template=()=>null;static#t=!1;#e=null;#i=null;#s=null;connected(){this.setAttribute("role","img"),this.name&&!this.text&&!s.#t&&(s.#t=!0,console.warn('[AdiaUI] <avatar-ui name="\u2026"> is deprecated \u2014 use text="\u2026" instead. Docs: https://ui-kit.exe.xyz/site/components/avatar'))}render(){!this.src&&!this.displayName&&!this.icon||(this.src?(this.#e||(this.#e=document.createElement("img"),this.#e.setAttribute("slot","img"),this.#e.onerror=()=>{this.#e.remove(),this.#e=null,this.#n()}),this.#e.src=this.src,this.#e.alt=this.name||"",this.#e.parentElement||this.appendChild(this.#e),this.#i&&(this.#i.remove(),this.#i=null)):this.icon?(this.#e&&(this.#e.remove(),this.#e=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s)),this.#s.setAttribute("name",this.icon)):(this.#e&&(this.#e.remove(),this.#e=null),this.#s&&(this.#s.remove(),this.#s=null),this.#n()),this.setAttribute("aria-label",this.displayName||this.icon||""))}#n(){if(!this.displayName)return;let t=this.displayName.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","initials"),this.appendChild(this.#i)),this.#i.textContent=t}},In=class extends A{static properties={max:{type:Number,default:5,reflect:!0},size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Avatar group")}render(){let t=[...this.querySelectorAll("avatar-ui")],e=this.max,i=t.length-e;if(this.size)for(let r of t)r.setAttribute("size",this.size);t.forEach((r,o)=>{r.style.display=o<e?"":"none",r.style.zIndex=String(t.length-o)});let n=this.querySelector('[slot="overflow"]');i>0?(n||(n=document.createElement("span"),n.setAttribute("slot","overflow"),this.appendChild(n)),n.textContent=`+${i}`,n.setAttribute("aria-label",`${i} more`),n.style.zIndex="0"):n&&n.remove()}};w("avatar-ui",Xn),w("avatar-group-ui",In);var Zn=class extends A{static properties={value:{type:Number,default:null,reflect:!0},variant:{type:String,default:"bar",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.variant==="bar"&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","track"),this.#e=document.createElement("div"),this.#e.setAttribute("slot","fill"),this.#t.appendChild(this.#e),this.appendChild(this.#t))}render(){let t=this.value==null||this.value<0,e=Math.max(0,Math.min(100,this.value));this.setAttribute("aria-busy",String(t)),t?this.removeAttribute("aria-valuenow"):this.setAttribute("aria-valuenow",String(e)),this.#e&&(this.#e.style.width=t?"100%":`${e}%`)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null}};w("progress-ui",Zn);var Dn=class extends A{static properties={value:{type:Number,default:0,reflect:!0},total:{type:Number,default:0,reflect:!0},caption:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),!this.querySelector(':scope > [slot="caption"]')&&!this.querySelector(':scope > [slot="track"]')?(this.#t=document.createElement("span"),this.#t.setAttribute("slot","caption"),this.appendChild(this.#t),this.#e=document.createElement("div"),this.#e.setAttribute("slot","track"),this.appendChild(this.#e)):(this.#t=this.querySelector(':scope > [slot="caption"]'),this.#e=this.querySelector(':scope > [slot="track"]'))}render(){let t=Math.max(0,this.total|0),e=Math.max(0,Math.min(t,this.value|0));if(this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(e)),this.#t&&!this.#t.dataset.custom&&(this.#t.textContent=this.caption||"",this.#t.toggleAttribute("hidden",!this.caption)),this.#e){let i=this.#e.children.length;for(;this.#e.children.length<t;)this.#e.appendChild(document.createElement("span"));for(;this.#e.children.length>t;)this.#e.lastElementChild.remove();for(let n=0;n<this.#e.children.length;n++)this.#e.children[n].toggleAttribute("data-active",n<e)}}disconnected(){this.#t=null,this.#e=null}};w("step-progress-ui",Dn);var qn=class extends A{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},radius:{type:String,default:"sm",reflect:!0},static:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("aria-hidden","true"),this.#t()}render(){this.#t()}#t(){this.style.width=this.width,this.style.height=this.height}};w("skeleton-ui",qn);var Hg=new Set;function Kg(s,t){Hg.has(s)||(Hg.add(s),console.warn(`[alert-ui] ${t}`))}var Bn=class extends A{static properties={text:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},closable:{type:Boolean,default:!1,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>',content:'<span slot="content"></span>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>'};static template=()=>null;#t(){this.getAttribute("variant")==="error"&&(Kg("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger, muted, neutral]. Mapping to "danger". Fix the source (LLM prompt / corpus pattern) to emit "danger" directly.'),this.setAttribute("variant","danger")),this.hasAttribute("closeable")&&!this.hasAttribute("closable")&&!this.hasAttribute("dismissible")&&(Kg("alias-closeable","attribute [closeable] is a misspelled alias of canonical [closable]. Mapping. Fix the source to use [closable] or [dismissible]."),this.setAttribute("closable",""),this.removeAttribute("closeable")),this.hasAttribute("dismissible")&&!this.hasAttribute("closable")&&this.setAttribute("closable","")}#e=t=>{t.target.closest('[slot="close"]')&&this.#s()};connected(){this.#t(),this.#i(),this.icon&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#e)}disconnected(){this.removeEventListener("press",this.#e)}render(){if(this.icon){let e=this.ensure("leading");e&&e.setAttribute("name",this.icon)}else this.drop("leading");let t=this.ensure("content");if(t){let e=t.hasAttribute("data-alert-auto"),i=t.childNodes.length>0;if(!e&&i){if(this.title||this.description){let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let r=document.createElement("strong");r.textContent=this.title,t.appendChild(r),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#i()}#i(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#s(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};w("alert-ui",Bn);var zn=class extends A{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};w("kbd-ui",zn);var jn=class extends A{static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},removable:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={dismiss:'<button slot="dismiss" type="button" aria-label="Remove"><icon-ui name="x"></icon-ui></button>'};static template=()=>null;#t=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#e=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};connected(){this.setAttribute("role","status"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")),this.removable&&!this.disabled){let t=this.ensure("dismiss");t&&t.parentElement!==this&&this.appendChild(t)}else this.drop("dismiss")}};w("tag-ui",jn);var o1=new Set(["block","dot","square","line","dashed"]),a1=new Set(["sm","md","lg"]),l1=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),h1={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},c1={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function u1(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&l1.has(t)):[]}var ts=null;function d1(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!ts){let u=document.createElement("canvas");u.width=1,u.height=1,ts=u.getContext("2d")}ts.fillStyle="#000",ts.clearRect(0,0,1,1),ts.fillStyle=s,ts.fillRect(0,0,1,1);let[t,e,i]=ts.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let n=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},r=n(t),o=n(e),a=n(i),l=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var Nn=class extends A{static properties={shape:{type:String,default:"square",reflect:!0},size:{type:String,default:"md",reflect:!0},color:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},detail:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},copyable:{type:Boolean,default:!1,reflect:!0},copyValue:{type:String,default:""},selectable:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},autoContrast:{type:Boolean,default:!1,reflect:!0},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#o=null;#a=null;#l=null;#u=null;#h=null;#c=null;connected(){this.#d(),this.#S(),this.#c=new MutationObserver(t=>{let e=!1;for(let i of t){for(let n of i.addedNodes)if(n.nodeType===1){if(n.getAttribute?.("slot")==="chrome"){e=!0;break}if(n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#c.takeRecords())}),this.#c.observe(this,{childList:!0})}render(){this.#d(),this.#p(),this.#g(),this.#m(),this.#b(),this.#v(),this.#O()}#d(){if(this.#r)return;let t=Array.from(this.children).filter(r=>r.getAttribute&&r.getAttribute("slot")==="chrome");for(let r of t)r.remove();let e=Array.from(this.children).filter(r=>r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]'));for(let r of e)r.remove();let i=[];for(let r of Array.from(this.childNodes))(r.nodeType===3&&!r.data||r.nodeType===8)&&i.push(r);for(let r of i)r.remove();let n=Array.from(this.childNodes).filter(r=>!(r.nodeType===1&&r.dataset&&(r.dataset.tile!==void 0||r.dataset.label!==void 0||r.dataset.detail!==void 0||r.dataset.badge!==void 0||r.dataset.copy!==void 0))&&!(r.nodeType===3&&!r.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let r of t)this.appendChild(r);for(let r of e)this.appendChild(r);for(let r of i)this.appendChild(r);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),n.length)for(let r of n)this.#e.appendChild(r);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#n=document.createElement("button"),this.#n.setAttribute("data-copy",""),this.#n.setAttribute("type","button"),this.#n.setAttribute("aria-label","Copy value"),this.#n.setAttribute("hidden",""),this.#n.textContent="\u29C9",this.appendChild(this.#n),this.#r=!0}#f(){if(!this.#t||!this.#s)return;let t=[];for(let e of this.children)if(e!==this.#t){if(e===this.#s)break;e.getAttribute?.("slot")==="chrome"&&t.push(e)}for(let e of Array.from(this.children))e!==this.#t&&e!==this.#s&&e!==this.#e&&e!==this.#i&&e!==this.#n&&e.getAttribute?.("slot")==="chrome"&&this.insertBefore(e,this.#s);for(let e of Array.from(this.children))e===this.#t||e===this.#s||e===this.#e||e===this.#i||e===this.#n||!(e.tagName==="SPAN"&&e.style?.display==="contents")||!e.querySelector?.('[slot="chrome"]')||this.insertBefore(e,this.#s)}#p(){if(!this.#t||!this.#e)return;this.#f();let t=o1.has(this.shape)?this.shape:"square",e=a1.has(this.size)?this.size:"md";t!==this.shape&&this.setAttribute("shape",t),e!==this.size&&this.setAttribute("size",e),this.color&&this.style.setProperty("--swatch-color",this.color),!this.#e.firstChild&&this.label?this.#e.textContent=this.label:this.#e.firstChild?.nodeType===3&&this.label&&(this.#e.textContent=this.label);let i=this.#e.textContent.trim().length>0||this.#e.firstElementChild!=null;this.#e.toggleAttribute("hidden",!i)}#g(){if(!this.#s)return;let t=u1(this.badge);if(t.length===0){this.#s.setAttribute("hidden",""),this.#s.replaceChildren();return}this.#s.removeAttribute("hidden");let e=Array.from(this.#s.children).map(r=>r.dataset.badgeVariant);if(e.length===t.length&&e.every((r,o)=>r===t[o]))return;let n=document.createDocumentFragment();for(let r of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",r),o.setAttribute("role","img"),o.setAttribute("aria-label",c1[r]),o.textContent=h1[r],n.appendChild(o)}this.#s.replaceChildren(n)}#O(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#o=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#o)return;this.#o=t;let e=d1(t);if(e==null){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark");return}let i=e<.62;this.#e.toggleAttribute("data-on-dark",i),this.#e.toggleAttribute("data-on-light",!i)}#m(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#b(){if(!this.#n)return;if(!this.copyable){this.#n.setAttribute("hidden","");return}this.#n.removeAttribute("hidden");let t=this.#w();t?this.#n.setAttribute("aria-label",`Copy ${t}`):this.#n.setAttribute("aria-label","Copy value")}#v(){this.selectable?(this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.setAttribute("aria-pressed",this.selected?"true":"false")):(this.getAttribute("role")==="button"&&this.removeAttribute("role"),this.getAttribute("tabindex")==="0"&&this.removeAttribute("tabindex"),this.removeAttribute("aria-pressed"))}#S(){this.#a=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#n)||this.#x()},this.#l=t=>{this.selectable&&(t.key!=="Enter"&&t.key!==" "||t.target!==this.#n&&(t.preventDefault(),this.#x()))},this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l),this.#u=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#w();e&&this.#k(e)},this.#n.addEventListener("click",this.#u)}#x(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#w(){return this.copyValue?this.copyValue:this.color?this.color:""}async#k(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#y(e)}#y(t){this.#n&&(this.#h!=null&&clearTimeout(this.#h),this.#n.setAttribute("data-copy-state",t?"ok":"fail"),this.#n.textContent=t?"\u2713":"\u26A0",this.#h=setTimeout(()=>{this.#n&&(this.#n.removeAttribute("data-copy-state"),this.#n.textContent="\u29C9",this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#c&&(this.#c.disconnect(),this.#c=null),this.#a&&this.removeEventListener("click",this.#a),this.#l&&this.removeEventListener("keydown",this.#l),this.#n&&this.#u&&this.#n.removeEventListener("click",this.#u),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=!1}};w("swatch-ui",Nn);var Jg={xs:0,sm:480,md:768,lg:1024,xl:1280},es=Object.keys(Jg),hu=Object.values(Jg);function tO(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=es.length-1;t>=0;t--)if(s>=hu[t])return es[t];return"xs"}var Se=Pi(tO());if(typeof window<"u")for(let s=1;s<hu.length;s++)window.matchMedia(`(min-width: ${hu[s]}px)`).addEventListener("change",()=>{Se.value=tO()});function Lt(s,t=Se.value){if(!s)return null;if(!s.includes("@"))return s;let e=null,i=new Map;for(let a of s.trim().split(/\s+/)){let l=a.lastIndexOf("@");l===-1?e=a:i.set(a.slice(l+1),a.slice(0,l))}let n=es.indexOf(t),r=null,o=-1;for(let[a,l]of i){let h=es.indexOf(a);h!==-1&&h<=n&&h>o&&(r=l,o=h)}return r??e}var _n=class extends A{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"stretch",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;render(){let t=this.gap,e=this.align,i=this.justify,r=t?.includes("@")||e?.includes("@")||i?.includes("@")?Se.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",m1(Lt(t,r))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Lt(e,r);this.style.setProperty("--col-align",g1(o)),this.style.textAlign=O1(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",b1(Lt(i,r))):this.style.removeProperty("--col-justify")}},f1={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},p1={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function m1(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function g1(s){return f1[s]??s}function O1(s){return{start:"start",center:"center",end:"end"}[s]??""}function b1(s){return p1[s]??s}w("col-ui",_n);var Vn=class s extends A{static properties={label:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},align:{type:String,default:"start",reflect:!0}};get error(){return this.#O()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=t=>{let e=this.#O();if(!e)return;let i=this.#m(e);i&&(t.preventDefault(),i.focus())};connected(){this.#c(),this.#d(),this.#f(),this.#p(),this.#u(),this.#t?.addEventListener("click",this.#r),this.#n=new MutationObserver(()=>{this.#p(),this.#u(),this.#g(),this.#o()}),this.#n.observe(this,{childList:!0}),this.#o()}disconnected(){this.#n?.disconnect(),this.#n=null,this.#h(),this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#o(),this.#g()}#o(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#a=()=>{this.#o(),this.#g()};#l=null;#u(){let t=this.#O();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#a,!0),t.addEventListener("change",this.#a),t.addEventListener("input",this.#a)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#a,!0),t.removeEventListener("change",this.#a),t.removeEventListener("input",this.#a),this.#l=null)}#c(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#d(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#x("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#f(){if(this.#s=this.querySelector(":scope > [data-field-error]"),this.#s)return;let t=document.createElement("div");t.setAttribute("slot","error"),t.setAttribute("data-field-error",""),t.setAttribute("id",s.#x("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#p(){if(!this.#t)return;let t=this.#O();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#v()),this.#t.setAttribute("for",t.id)}#g(){let t=this.#O();if(!t)return;let e=new Set;this.#i&&!this.#i.hidden&&e.add(this.#i.id),this.#s&&!this.#s.hidden&&e.add(this.#s.id);let n=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(r=>r&&!r.startsWith("field-hint-")&&!r.startsWith("field-err-")),...e].join(" ").trim();n?t.setAttribute("aria-describedby",n):t.removeAttribute("aria-describedby")}#O(){for(let t of this.children)if(!t.hasAttribute("slot"))return t;return null}#m(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#b=0;static#v(){return`field-ctl-${++s.#b}`}static#S=0;static#x(t){return`field-${t}-${++s.#S}`}};w("field-ui",Vn);var Wn=class extends A{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),this.#t=new MutationObserver(t=>{for(let e of t)if(e.type==="childList"&&(this.#i(e.addedNodes)||this.#i(e.removedNodes))){this.#e();return}}),this.#t.observe(this,{childList:!0})}disconnected(){this.#t?.disconnect(),this.#t=null}render(){this.#e()}#e(){let t=this.hasAttribute("inline");for(let e of this.children)e.localName==="field-ui"&&(t?e.hasAttribute("inline")||e.setAttribute("inline",""):e.hasAttribute("inline")&&e.removeAttribute("inline"))}#i(t){for(let e of t)if(e.nodeType===1&&e.localName==="field-ui")return!0;return!1}};w("fields-ui",Wn);var Yn=class extends A{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"center",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},wrapAt:{type:String,default:"",reflect:!0,attribute:"wrap-at"},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Mn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Mn),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,n=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!n?Se.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",x1(Lt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",S1(Lt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",w1(Lt(i,o))):this.style.removeProperty("--row-justify"),n){let a=es.indexOf(o),l=es.indexOf(n);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},y1={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},v1={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function x1(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function S1(s){return y1[s]??s}function w1(s){return v1[s]??s}w("row-ui",Yn);var Un=class extends A{static properties={columns:{type:String,default:"3",reflect:!0},gap:{type:String,default:"md",reflect:!0},columnGap:{type:String,default:"",reflect:!0,attribute:"column-gap"},rowGap:{type:String,default:"",reflect:!0,attribute:"row-gap"}};static template=()=>null;render(){let t=Se.value,e=this.columns;if(e?.includes("@")){let n=Lt(e,t);this.style.gridTemplateColumns=this.#t(n),this.style.gridAutoFlow=n?"row":"",this.style.gridAutoColumns=n?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";let i=this.gap;if(i?.includes("@")){let n=Lt(i,t),r=this.#e(n);this.style.columnGap=r,this.style.rowGap=r}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(12rem, 1fr))":t==="auto-fit"?"repeat(auto-fit, minmax(12rem, 1fr))":t:""}#e(t){return!t||t==="0"?"0":/^\d+$/.test(t)?`var(--a-space-${t})`:`var(--a-gap-${t})`}};w("grid-ui",Un);var Fn=class extends A{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};w("stack-ui",Fn);function is(s,t,e=5){let n=(t-s||1)/e,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*r,h=Math.floor(s/l)*l,c=Math.ceil(t/l)*l,u=[];for(let d=h;d<=c+l*.5;d+=l)u.push(+d.toFixed(10));return u}function eO(s){if(s==null)return"";let t=+s;return Number.isNaN(t)?String(s):Math.abs(t)>=1e6?(t/1e6).toFixed(1).replace(/\.0$/,"")+"M":Math.abs(t)>=1e3?(t/1e3).toFixed(1).replace(/\.0$/,"")+"K":Number.isInteger(t)?String(t):t.toFixed(1)}function Jt(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function mt({label:s,value:t,pct:e,series:i}){let n="";return s!=null&&(n+=` data-tip-label="${Jt(String(s))}"`),t!=null&&(n+=` data-tip-value="${t}"`),e!=null&&(n+=` data-tip-pct="${e}"`),i!=null&&(n+=` data-tip-series="${Jt(String(i))}"`),n}function te(s,t,e){return s+t*Math.cos(e)}function ee(s,t,e){return s+t*Math.sin(e)}function k1(s,t,e,i,n){let r=te(s,e,i),o=ee(t,e,i),a=te(s,e,n),l=ee(t,e,n),h=n-i>Math.PI?1:0;return`M ${s} ${t} L ${r} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function cu(s,t,e,i,n,r,o=0){let a=(e-i)/2,l=r-n,h=Math.max(0,Math.min(o,a)),c=()=>{let pt=te(s,e,n),ut=ee(t,e,n),yt=te(s,e,r),kt=ee(t,e,r),vt=te(s,i,r),zt=ee(t,i,r),jt=te(s,i,n),Qi=ee(t,i,n),Fi=l>Math.PI?1:0;return`M ${pt} ${ut} A ${e} ${e} 0 ${Fi} 1 ${yt} ${kt} L ${vt} ${zt} A ${i} ${i} 0 ${Fi} 0 ${jt} ${Qi} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=n+u,p=r-u,m=n+d,O=r-d,g=p-f>Math.PI?1:0,y=te(s,e,f),v=ee(t,e,f),x=te(s,e,p),S=ee(t,e,p),$=te(s,i,O),k=ee(t,i,O),P=te(s,i,m),T=ee(t,i,m),C=te(s,e-h,n),I=ee(t,e-h,n),X=te(s,i+h,n),N=ee(t,i+h,n),_=te(s,e-h,r),V=ee(t,e-h,r),tt=te(s,i+h,r),rt=ee(t,i+h,r);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${x} ${S} A ${h} ${h} 0 0 1 ${_} ${V} L ${tt} ${rt} A ${h} ${h} 0 0 1 ${$} ${k} A ${i} ${i} 0 ${g} 0 ${P} ${T} A ${h} ${h} 0 0 1 ${X} ${N} L ${C} ${I} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function Zo(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(n=>`${n.x},${n.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let n=0;n<e-1;n++){let r=s[Math.max(n-1,0)],o=s[n],a=s[n+1],l=s[Math.min(n+2,e-1)],h=o.x+(a.x-r.x)*t/3,c=o.y+(a.y-r.y)*t/3,u=a.x-(l.x-o.x)*t/3,d=a.y-(l.y-o.y)*t/3;i+=` C${h},${c} ${u},${d} ${a.x},${a.y}`}return i}function uu(s,t,e=.4){let i=Zo(s,e),n=s[s.length-1],r=s[0];return`${i} L${n.x},${t} L${r.x},${t} Z`}function ol(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,e/2,i));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+r} Q${s},${t} ${s+r},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i} Z`}var iO={std:{ratio:4/3},wide:{ratio:16/9},square:{ratio:1},tall:{ratio:3/4}},Gn=class extends A{static properties={type:{type:String,default:"bar",reflect:!0},heading:{type:String,default:"",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},hideAverage:{type:Boolean,default:!1,reflect:!0,attribute:"hide-average"},color:{type:String,default:"",reflect:!0},hideGrid:{type:Boolean,default:!1,reflect:!0,attribute:"hide-grid"},hideValues:{type:Boolean,default:!1,reflect:!0,attribute:"hide-values"},radius:{type:Number,default:null,reflect:!0},smooth:{type:Number,default:.4,reflect:!0},aspect:{type:String,default:"std",reflect:!0},size:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#n=0;#r=0;#o=new Set;#a(){if(this.radius!=null)return this.radius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}set data(t){!Array.isArray(t)&&!this.#e&&(this.#e=!0,console.warn(`[chart-ui] .data must be an array of plain objects \u2014 received ${t===null?"null":typeof t}. The {labels, datasets} envelope is the Chart.js API, not the chart-ui API.
171
+ `),this.#e=this.querySelector("[data-dropzone]"),this.#e&&(this.#e.addEventListener("click",this.#i),this.#e.addEventListener("keydown",this.#s),this.#e.addEventListener("dragover",this.#a),this.#e.addEventListener("dragleave",this.#l),this.#e.addEventListener("drop",this.#u))}render(){let t=this.querySelector("[data-filelist]");if(!this.#e||!t)return;let e=this.querySelector("span[hint]");e&&this.hint&&e.setAttribute("hint",this.hint),t.innerHTML="";for(let i of this.#t){let n=document.createElement("span");n.textContent=i.name,t.appendChild(n)}}get files(){return this.#t}#i=()=>{this.disabled||this.#n()};#s=t=>{this.disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#n())};async#n(){try{if(window.showOpenFilePicker){let t=this.#o(),e={multiple:this.multiple};t.length&&(e.types=t);let i=await window.showOpenFilePicker(e);if(!this.isConnected)return;let n=await Promise.all(i.map(r=>r.getFile()));if(!this.isConnected)return;this.#h(n)}else this.#r()}catch(t){if(t.name!=="AbortError")throw t}}#r(){let t=document.createElement("input");t.type="file",this.accept&&(t.accept=this.accept),this.multiple&&(t.multiple=!0),t.style.display="none",document.body.appendChild(t),t.addEventListener("change",()=>{t.files?.length&&this.#h([...t.files]),t.remove()},{once:!0}),t.addEventListener("cancel",()=>t.remove(),{once:!0}),t.click()}#o(){if(!this.accept)return[];let t={};for(let e of this.accept.split(",")){let i=e.trim();i&&(i.startsWith(".")?(t["application/octet-stream"]=t["application/octet-stream"]||[],t["application/octet-stream"].push(i)):t[i]=t[i]||[])}return Object.keys(t).length?[{accept:t}]:[]}#a=t=>{t.preventDefault(),this.querySelector("[data-dropzone]")?.setAttribute("data-dragover","")};#l=()=>{this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover")};#u=t=>{if(t.preventDefault(),this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover"),this.disabled)return;let e=t.dataTransfer;e?.files?.length&&this.#h([...e.files])};#h(t){this.#t=t;let e=new FormData;for(let i of this.#t)e.append(this.name||"file",i);this.internals.setFormValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,files:this.files}})),this.render()}disconnected(){super.disconnected(),this.#e&&(this.#e.removeEventListener("click",this.#i),this.#e.removeEventListener("keydown",this.#s),this.#e.removeEventListener("dragover",this.#a),this.#e.removeEventListener("dragleave",this.#l),this.#e.removeEventListener("drop",this.#u)),this.#e=null}};w("upload-ui",Ln);var Mn=Bg({name:"draggable",category:"motion-positioning",description:"Pointer drag to reposition",attributes:["data-draggable-dragging"],events:["drag-end"],config:[],setup({host:s}){let t=!1,e=0,i=0,n=0,r=0;function o(){return s.hasAttribute("disabled")}function a(c){if(o())return;t=!0,e=c.clientX,i=c.clientY;let u=getComputedStyle(s),d=u.translate;if(d&&d!=="none"){let f=d.split(/\s+/).map(parseFloat);n=f[0]||0,r=f[1]||0}else{let f=new DOMMatrixReadOnly(u.transform);n=f.m41,r=f.m42}s.setPointerCapture(c.pointerId),s.setAttribute("data-draggable-dragging",""),s.style.touchAction="none"}function l(c){if(!t)return;let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.style.translate=`${f}px ${p}px`}function h(c){if(!t)return;t=!1,s.removeAttribute("data-draggable-dragging");let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.dispatchEvent(new CustomEvent("drag-end",{bubbles:!0,detail:{x:f,y:p}}))}return s.addEventListener("pointerdown",a),s.addEventListener("pointermove",l),s.addEventListener("pointerup",h),()=>{s.removeEventListener("pointerdown",a),s.removeEventListener("pointermove",l),s.removeEventListener("pointerup",h),s.removeAttribute("data-draggable-dragging"),s.style.touchAction=""}}});var Rn=class extends A{static properties={variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"",reflect:!0},elevation:{type:Number,default:1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Mn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Mn),this.#t=!0)}};w("card-ui",Rn);var Xn=class s extends A{static properties={src:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},shape:{type:String,default:"circle",reflect:!0}};get displayName(){return this.text||this.name}static template=()=>null;static#t=!1;#e=null;#i=null;#s=null;connected(){this.setAttribute("role","img"),this.name&&!this.text&&!s.#t&&(s.#t=!0,console.warn('[AdiaUI] <avatar-ui name="\u2026"> is deprecated \u2014 use text="\u2026" instead. Docs: https://ui-kit.exe.xyz/site/components/avatar'))}render(){!this.src&&!this.displayName&&!this.icon||(this.src?(this.#e||(this.#e=document.createElement("img"),this.#e.setAttribute("slot","img"),this.#e.onerror=()=>{this.#e.remove(),this.#e=null,this.#n()}),this.#e.src=this.src,this.#e.alt=this.name||"",this.#e.parentElement||this.appendChild(this.#e),this.#i&&(this.#i.remove(),this.#i=null)):this.icon?(this.#e&&(this.#e.remove(),this.#e=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s)),this.#s.setAttribute("name",this.icon)):(this.#e&&(this.#e.remove(),this.#e=null),this.#s&&(this.#s.remove(),this.#s=null),this.#n()),this.setAttribute("aria-label",this.displayName||this.icon||""))}#n(){if(!this.displayName)return;let t=this.displayName.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","initials"),this.appendChild(this.#i)),this.#i.textContent=t}},In=class extends A{static properties={max:{type:Number,default:5,reflect:!0},size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Avatar group")}render(){let t=[...this.querySelectorAll("avatar-ui")],e=this.max,i=t.length-e;if(this.size)for(let r of t)r.setAttribute("size",this.size);t.forEach((r,o)=>{r.style.display=o<e?"":"none",r.style.zIndex=String(t.length-o)});let n=this.querySelector('[slot="overflow"]');i>0?(n||(n=document.createElement("span"),n.setAttribute("slot","overflow"),this.appendChild(n)),n.textContent=`+${i}`,n.setAttribute("aria-label",`${i} more`),n.style.zIndex="0"):n&&n.remove()}};w("avatar-ui",Xn),w("avatar-group-ui",In);var Zn=class extends A{static properties={value:{type:Number,default:null,reflect:!0},variant:{type:String,default:"bar",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.variant==="bar"&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","track"),this.#e=document.createElement("div"),this.#e.setAttribute("slot","fill"),this.#t.appendChild(this.#e),this.appendChild(this.#t))}render(){let t=this.value==null||this.value<0,e=Math.max(0,Math.min(100,this.value));this.setAttribute("aria-busy",String(t)),t?this.removeAttribute("aria-valuenow"):this.setAttribute("aria-valuenow",String(e)),this.#e&&(this.#e.style.width=t?"100%":`${e}%`)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null}};w("progress-ui",Zn);var Dn=class extends A{static properties={value:{type:Number,default:0,reflect:!0},total:{type:Number,default:0,reflect:!0},caption:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),!this.querySelector(':scope > [slot="caption"]')&&!this.querySelector(':scope > [slot="track"]')?(this.#t=document.createElement("span"),this.#t.setAttribute("slot","caption"),this.appendChild(this.#t),this.#e=document.createElement("div"),this.#e.setAttribute("slot","track"),this.appendChild(this.#e)):(this.#t=this.querySelector(':scope > [slot="caption"]'),this.#e=this.querySelector(':scope > [slot="track"]'))}render(){let t=Math.max(0,this.total|0),e=Math.max(0,Math.min(t,this.value|0));if(this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(e)),this.#t&&!this.#t.dataset.custom&&(this.#t.textContent=this.caption||"",this.#t.toggleAttribute("hidden",!this.caption)),this.#e){let i=this.#e.children.length;for(;this.#e.children.length<t;)this.#e.appendChild(document.createElement("span"));for(;this.#e.children.length>t;)this.#e.lastElementChild.remove();for(let n=0;n<this.#e.children.length;n++)this.#e.children[n].toggleAttribute("data-active",n<e)}}disconnected(){this.#t=null,this.#e=null}};w("step-progress-ui",Dn);var qn=class extends A{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},radius:{type:String,default:"sm",reflect:!0},static:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("aria-hidden","true"),this.#t()}render(){this.#t()}#t(){this.style.width=this.width,this.style.height=this.height}};w("skeleton-ui",qn);var Hg=new Set;function Kg(s,t){Hg.has(s)||(Hg.add(s),console.warn(`[alert-ui] ${t}`))}var Bn=class extends A{static properties={text:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},closable:{type:Boolean,default:!1,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>',content:'<span slot="content"></span>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>'};static template=()=>null;#t(){this.getAttribute("variant")==="error"&&(Kg("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger, muted, neutral]. Mapping to "danger". Fix the source (LLM prompt / corpus pattern) to emit "danger" directly.'),this.setAttribute("variant","danger")),this.hasAttribute("closeable")&&!this.hasAttribute("closable")&&!this.hasAttribute("dismissible")&&(Kg("alias-closeable","attribute [closeable] is a misspelled alias of canonical [closable]. Mapping. Fix the source to use [closable] or [dismissible]."),this.setAttribute("closable",""),this.removeAttribute("closeable")),this.hasAttribute("dismissible")&&!this.hasAttribute("closable")&&this.setAttribute("closable","")}#e=t=>{t.target.closest('[slot="close"]')&&this.#s()};connected(){this.#t(),this.#i(),this.icon&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#e)}disconnected(){this.removeEventListener("press",this.#e)}render(){if(this.icon){let e=this.ensure("leading");e&&e.setAttribute("name",this.icon)}else this.drop("leading");let t=this.ensure("content");if(t){let e=t.hasAttribute("data-alert-auto"),i=t.childNodes.length>0;if(!e&&i){if(this.title||this.description){let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let r=document.createElement("strong");r.textContent=this.title,t.appendChild(r),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#i()}#i(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#s(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};w("alert-ui",Bn);var zn=class extends A{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};w("kbd-ui",zn);var jn=class extends A{static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},removable:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={dismiss:'<button slot="dismiss" type="button" aria-label="Remove"><icon-ui name="x"></icon-ui></button>'};static template=()=>null;#t=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#e=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};connected(){this.setAttribute("role","status"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")),this.removable&&!this.disabled){let t=this.ensure("dismiss");t&&t.parentElement!==this&&this.appendChild(t)}else this.drop("dismiss")}};w("tag-ui",jn);var o1=new Set(["block","dot","square","line","dashed"]),a1=new Set(["sm","md","lg"]),l1=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),h1={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},c1={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function u1(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&l1.has(t)):[]}var ts=null;function d1(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!ts){let u=document.createElement("canvas");u.width=1,u.height=1,ts=u.getContext("2d")}ts.fillStyle="#000",ts.clearRect(0,0,1,1),ts.fillStyle=s,ts.fillRect(0,0,1,1);let[t,e,i]=ts.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let n=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},r=n(t),o=n(e),a=n(i),l=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var Nn=class extends A{static properties={shape:{type:String,default:"square",reflect:!0},size:{type:String,default:"md",reflect:!0},color:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},detail:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},copyable:{type:Boolean,default:!1,reflect:!0},copyValue:{type:String,default:""},selectable:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},autoContrast:{type:Boolean,default:!1,reflect:!0},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#o=null;#a=null;#l=null;#u=null;#h=null;#c=null;connected(){this.#d(),this.#S(),this.#c=new MutationObserver(t=>{let e=!1;for(let i of t){for(let n of i.addedNodes)if(n.nodeType===1){if(n.getAttribute?.("slot")==="chrome"){e=!0;break}if(n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#c.takeRecords())}),this.#c.observe(this,{childList:!0})}render(){this.#d(),this.#p(),this.#g(),this.#m(),this.#b(),this.#x(),this.#O()}#d(){if(this.#r)return;let t=Array.from(this.children).filter(r=>r.getAttribute&&r.getAttribute("slot")==="chrome");for(let r of t)r.remove();let e=Array.from(this.children).filter(r=>r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]'));for(let r of e)r.remove();let i=[];for(let r of Array.from(this.childNodes))(r.nodeType===3&&!r.data||r.nodeType===8)&&i.push(r);for(let r of i)r.remove();let n=Array.from(this.childNodes).filter(r=>!(r.nodeType===1&&r.dataset&&(r.dataset.tile!==void 0||r.dataset.label!==void 0||r.dataset.detail!==void 0||r.dataset.badge!==void 0||r.dataset.copy!==void 0))&&!(r.nodeType===3&&!r.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let r of t)this.appendChild(r);for(let r of e)this.appendChild(r);for(let r of i)this.appendChild(r);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),n.length)for(let r of n)this.#e.appendChild(r);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#n=document.createElement("button"),this.#n.setAttribute("data-copy",""),this.#n.setAttribute("type","button"),this.#n.setAttribute("aria-label","Copy value"),this.#n.setAttribute("hidden",""),this.#n.textContent="\u29C9",this.appendChild(this.#n),this.#r=!0}#f(){if(!this.#t||!this.#s)return;let t=[];for(let e of this.children)if(e!==this.#t){if(e===this.#s)break;e.getAttribute?.("slot")==="chrome"&&t.push(e)}for(let e of Array.from(this.children))e!==this.#t&&e!==this.#s&&e!==this.#e&&e!==this.#i&&e!==this.#n&&e.getAttribute?.("slot")==="chrome"&&this.insertBefore(e,this.#s);for(let e of Array.from(this.children))e===this.#t||e===this.#s||e===this.#e||e===this.#i||e===this.#n||!(e.tagName==="SPAN"&&e.style?.display==="contents")||!e.querySelector?.('[slot="chrome"]')||this.insertBefore(e,this.#s)}#p(){if(!this.#t||!this.#e)return;this.#f();let t=o1.has(this.shape)?this.shape:"square",e=a1.has(this.size)?this.size:"md";t!==this.shape&&this.setAttribute("shape",t),e!==this.size&&this.setAttribute("size",e),this.color&&this.style.setProperty("--swatch-color",this.color),!this.#e.firstChild&&this.label?this.#e.textContent=this.label:this.#e.firstChild?.nodeType===3&&this.label&&(this.#e.textContent=this.label);let i=this.#e.textContent.trim().length>0||this.#e.firstElementChild!=null;this.#e.toggleAttribute("hidden",!i)}#g(){if(!this.#s)return;let t=u1(this.badge);if(t.length===0){this.#s.setAttribute("hidden",""),this.#s.replaceChildren();return}this.#s.removeAttribute("hidden");let e=Array.from(this.#s.children).map(r=>r.dataset.badgeVariant);if(e.length===t.length&&e.every((r,o)=>r===t[o]))return;let n=document.createDocumentFragment();for(let r of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",r),o.setAttribute("role","img"),o.setAttribute("aria-label",c1[r]),o.textContent=h1[r],n.appendChild(o)}this.#s.replaceChildren(n)}#O(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#o=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#o)return;this.#o=t;let e=d1(t);if(e==null){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark");return}let i=e<.62;this.#e.toggleAttribute("data-on-dark",i),this.#e.toggleAttribute("data-on-light",!i)}#m(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#b(){if(!this.#n)return;if(!this.copyable){this.#n.setAttribute("hidden","");return}this.#n.removeAttribute("hidden");let t=this.#w();t?this.#n.setAttribute("aria-label",`Copy ${t}`):this.#n.setAttribute("aria-label","Copy value")}#x(){this.selectable?(this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.setAttribute("aria-pressed",this.selected?"true":"false")):(this.getAttribute("role")==="button"&&this.removeAttribute("role"),this.getAttribute("tabindex")==="0"&&this.removeAttribute("tabindex"),this.removeAttribute("aria-pressed"))}#S(){this.#a=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#n)||this.#v()},this.#l=t=>{this.selectable&&(t.key!=="Enter"&&t.key!==" "||t.target!==this.#n&&(t.preventDefault(),this.#v()))},this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l),this.#u=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#w();e&&this.#k(e)},this.#n.addEventListener("click",this.#u)}#v(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#w(){return this.copyValue?this.copyValue:this.color?this.color:""}async#k(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#y(e)}#y(t){this.#n&&(this.#h!=null&&clearTimeout(this.#h),this.#n.setAttribute("data-copy-state",t?"ok":"fail"),this.#n.textContent=t?"\u2713":"\u26A0",this.#h=setTimeout(()=>{this.#n&&(this.#n.removeAttribute("data-copy-state"),this.#n.textContent="\u29C9",this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#c&&(this.#c.disconnect(),this.#c=null),this.#a&&this.removeEventListener("click",this.#a),this.#l&&this.removeEventListener("keydown",this.#l),this.#n&&this.#u&&this.#n.removeEventListener("click",this.#u),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=!1}};w("swatch-ui",Nn);var Jg={xs:0,sm:480,md:768,lg:1024,xl:1280},es=Object.keys(Jg),hu=Object.values(Jg);function tO(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=es.length-1;t>=0;t--)if(s>=hu[t])return es[t];return"xs"}var Se=Pi(tO());if(typeof window<"u")for(let s=1;s<hu.length;s++)window.matchMedia(`(min-width: ${hu[s]}px)`).addEventListener("change",()=>{Se.value=tO()});function Lt(s,t=Se.value){if(!s)return null;if(!s.includes("@"))return s;let e=null,i=new Map;for(let a of s.trim().split(/\s+/)){let l=a.lastIndexOf("@");l===-1?e=a:i.set(a.slice(l+1),a.slice(0,l))}let n=es.indexOf(t),r=null,o=-1;for(let[a,l]of i){let h=es.indexOf(a);h!==-1&&h<=n&&h>o&&(r=l,o=h)}return r??e}var _n=class extends A{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"stretch",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;render(){let t=this.gap,e=this.align,i=this.justify,r=t?.includes("@")||e?.includes("@")||i?.includes("@")?Se.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",m1(Lt(t,r))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Lt(e,r);this.style.setProperty("--col-align",g1(o)),this.style.textAlign=O1(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",b1(Lt(i,r))):this.style.removeProperty("--col-justify")}},f1={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},p1={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function m1(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function g1(s){return f1[s]??s}function O1(s){return{start:"start",center:"center",end:"end"}[s]??""}function b1(s){return p1[s]??s}w("col-ui",_n);var Vn=class s extends A{static properties={label:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},align:{type:String,default:"start",reflect:!0}};get error(){return this.#O()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=t=>{let e=this.#O();if(!e)return;let i=this.#m(e);i&&(t.preventDefault(),i.focus())};connected(){this.#c(),this.#d(),this.#f(),this.#p(),this.#u(),this.#t?.addEventListener("click",this.#r),this.#n=new MutationObserver(()=>{this.#p(),this.#u(),this.#g(),this.#o()}),this.#n.observe(this,{childList:!0}),this.#o()}disconnected(){this.#n?.disconnect(),this.#n=null,this.#h(),this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#o(),this.#g()}#o(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#a=()=>{this.#o(),this.#g()};#l=null;#u(){let t=this.#O();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#a,!0),t.addEventListener("change",this.#a),t.addEventListener("input",this.#a)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#a,!0),t.removeEventListener("change",this.#a),t.removeEventListener("input",this.#a),this.#l=null)}#c(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#d(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#v("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#f(){if(this.#s=this.querySelector(":scope > [data-field-error]"),this.#s)return;let t=document.createElement("div");t.setAttribute("slot","error"),t.setAttribute("data-field-error",""),t.setAttribute("id",s.#v("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#p(){if(!this.#t)return;let t=this.#O();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#x()),this.#t.setAttribute("for",t.id)}#g(){let t=this.#O();if(!t)return;let e=new Set;this.#i&&!this.#i.hidden&&e.add(this.#i.id),this.#s&&!this.#s.hidden&&e.add(this.#s.id);let n=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(r=>r&&!r.startsWith("field-hint-")&&!r.startsWith("field-err-")),...e].join(" ").trim();n?t.setAttribute("aria-describedby",n):t.removeAttribute("aria-describedby")}#O(){for(let t of this.children)if(!t.hasAttribute("slot"))return t;return null}#m(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#b=0;static#x(){return`field-ctl-${++s.#b}`}static#S=0;static#v(t){return`field-${t}-${++s.#S}`}};w("field-ui",Vn);var Wn=class extends A{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),this.#t=new MutationObserver(t=>{for(let e of t)if(e.type==="childList"&&(this.#i(e.addedNodes)||this.#i(e.removedNodes))){this.#e();return}}),this.#t.observe(this,{childList:!0})}disconnected(){this.#t?.disconnect(),this.#t=null}render(){this.#e()}#e(){let t=this.hasAttribute("inline");for(let e of this.children)e.localName==="field-ui"&&(t?e.hasAttribute("inline")||e.setAttribute("inline",""):e.hasAttribute("inline")&&e.removeAttribute("inline"))}#i(t){for(let e of t)if(e.nodeType===1&&e.localName==="field-ui")return!0;return!1}};w("fields-ui",Wn);var Yn=class extends A{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"center",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},wrapAt:{type:String,default:"",reflect:!0,attribute:"wrap-at"},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Mn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Mn),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,n=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!n?Se.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",x1(Lt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",S1(Lt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",w1(Lt(i,o))):this.style.removeProperty("--row-justify"),n){let a=es.indexOf(o),l=es.indexOf(n);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},y1={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},v1={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function x1(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function S1(s){return y1[s]??s}function w1(s){return v1[s]??s}w("row-ui",Yn);var Un=class extends A{static properties={columns:{type:String,default:"3",reflect:!0},gap:{type:String,default:"md",reflect:!0},columnGap:{type:String,default:"",reflect:!0,attribute:"column-gap"},rowGap:{type:String,default:"",reflect:!0,attribute:"row-gap"}};static template=()=>null;render(){let t=Se.value,e=this.columns;if(e?.includes("@")){let n=Lt(e,t);this.style.gridTemplateColumns=this.#t(n),this.style.gridAutoFlow=n?"row":"",this.style.gridAutoColumns=n?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";let i=this.gap;if(i?.includes("@")){let n=Lt(i,t),r=this.#e(n);this.style.columnGap=r,this.style.rowGap=r}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(12rem, 1fr))":t==="auto-fit"?"repeat(auto-fit, minmax(12rem, 1fr))":t:""}#e(t){return!t||t==="0"?"0":/^\d+$/.test(t)?`var(--a-space-${t})`:`var(--a-gap-${t})`}};w("grid-ui",Un);var Fn=class extends A{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};w("stack-ui",Fn);function is(s,t,e=5){let n=(t-s||1)/e,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*r,h=Math.floor(s/l)*l,c=Math.ceil(t/l)*l,u=[];for(let d=h;d<=c+l*.5;d+=l)u.push(+d.toFixed(10));return u}function eO(s){if(s==null)return"";let t=+s;return Number.isNaN(t)?String(s):Math.abs(t)>=1e6?(t/1e6).toFixed(1).replace(/\.0$/,"")+"M":Math.abs(t)>=1e3?(t/1e3).toFixed(1).replace(/\.0$/,"")+"K":Number.isInteger(t)?String(t):t.toFixed(1)}function Jt(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function mt({label:s,value:t,pct:e,series:i}){let n="";return s!=null&&(n+=` data-tip-label="${Jt(String(s))}"`),t!=null&&(n+=` data-tip-value="${t}"`),e!=null&&(n+=` data-tip-pct="${e}"`),i!=null&&(n+=` data-tip-series="${Jt(String(i))}"`),n}function te(s,t,e){return s+t*Math.cos(e)}function ee(s,t,e){return s+t*Math.sin(e)}function k1(s,t,e,i,n){let r=te(s,e,i),o=ee(t,e,i),a=te(s,e,n),l=ee(t,e,n),h=n-i>Math.PI?1:0;return`M ${s} ${t} L ${r} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function cu(s,t,e,i,n,r,o=0){let a=(e-i)/2,l=r-n,h=Math.max(0,Math.min(o,a)),c=()=>{let pt=te(s,e,n),ut=ee(t,e,n),yt=te(s,e,r),kt=ee(t,e,r),vt=te(s,i,r),zt=ee(t,i,r),jt=te(s,i,n),Qi=ee(t,i,n),Fi=l>Math.PI?1:0;return`M ${pt} ${ut} A ${e} ${e} 0 ${Fi} 1 ${yt} ${kt} L ${vt} ${zt} A ${i} ${i} 0 ${Fi} 0 ${jt} ${Qi} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=n+u,p=r-u,m=n+d,O=r-d,g=p-f>Math.PI?1:0,y=te(s,e,f),v=ee(t,e,f),x=te(s,e,p),S=ee(t,e,p),$=te(s,i,O),k=ee(t,i,O),P=te(s,i,m),T=ee(t,i,m),C=te(s,e-h,n),I=ee(t,e-h,n),X=te(s,i+h,n),N=ee(t,i+h,n),_=te(s,e-h,r),V=ee(t,e-h,r),tt=te(s,i+h,r),rt=ee(t,i+h,r);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${x} ${S} A ${h} ${h} 0 0 1 ${_} ${V} L ${tt} ${rt} A ${h} ${h} 0 0 1 ${$} ${k} A ${i} ${i} 0 ${g} 0 ${P} ${T} A ${h} ${h} 0 0 1 ${X} ${N} L ${C} ${I} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function Zo(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(n=>`${n.x},${n.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let n=0;n<e-1;n++){let r=s[Math.max(n-1,0)],o=s[n],a=s[n+1],l=s[Math.min(n+2,e-1)],h=o.x+(a.x-r.x)*t/3,c=o.y+(a.y-r.y)*t/3,u=a.x-(l.x-o.x)*t/3,d=a.y-(l.y-o.y)*t/3;i+=` C${h},${c} ${u},${d} ${a.x},${a.y}`}return i}function uu(s,t,e=.4){let i=Zo(s,e),n=s[s.length-1],r=s[0];return`${i} L${n.x},${t} L${r.x},${t} Z`}function ol(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,e/2,i));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+r} Q${s},${t} ${s+r},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i} Z`}var iO={std:{ratio:4/3},wide:{ratio:16/9},square:{ratio:1},tall:{ratio:3/4}},Gn=class extends A{static properties={type:{type:String,default:"bar",reflect:!0},heading:{type:String,default:"",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},hideAverage:{type:Boolean,default:!1,reflect:!0,attribute:"hide-average"},color:{type:String,default:"",reflect:!0},hideGrid:{type:Boolean,default:!1,reflect:!0,attribute:"hide-grid"},hideValues:{type:Boolean,default:!1,reflect:!0,attribute:"hide-values"},radius:{type:Number,default:null,reflect:!0},smooth:{type:Number,default:.4,reflect:!0},aspect:{type:String,default:"std",reflect:!0},size:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#n=0;#r=0;#o=new Set;#a(){if(this.radius!=null)return this.radius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}set data(t){!Array.isArray(t)&&!this.#e&&(this.#e=!0,console.warn(`[chart-ui] .data must be an array of plain objects \u2014 received ${t===null?"null":typeof t}. The {labels, datasets} envelope is the Chart.js API, not the chart-ui API.
172
172
  Correct shape for <chart-ui x="label" y="value">:
173
- [{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#u(),this.#f()}get data(){return this.#t}#l=!1;#u(){if(this.#l)return;let t=this.#h();this.#t.length>t&&(console.warn(`[chart-ui] .data has ${this.#t.length} rows which exceeds the recommended perf budget of ${t}. Consider downsampling at the data layer (e.g., LTTB, bucket aggregation). Override the budget via CSS: chart-ui { --chart-perf-budget: 10000 }.`),this.#l=!0)}#h(){let t=getComputedStyle(this).getPropertyValue("--chart-perf-budget").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:5e3}connected(){if(this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.heading||`${this.type} chart`),this.#t.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}document.addEventListener("toggle",this.#S),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#I),this.addEventListener("focus",this.#X),this.addEventListener("blur",this.#M),this.addEventListener("pointerover",this.#D),this.addEventListener("pointermove",this.#q),this.addEventListener("pointerleave",this.#z),this.addEventListener("pointerdown",this.#N),this.addEventListener("click",this.#U),this.#k(),this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let n=Math.round(e),r=Math.round(i);n===this.#n&&(!this.hasAttribute("resize")||r===this.#r)||(this.#n=n,this.#r=r,!this.#s&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.#f()})))}),this.#i.observe(this)}render(){if(this.loading){let e=this.querySelector("skeleton-ui[data-chart-skel]");e||(e=document.createElement("skeleton-ui"),e.setAttribute("data-chart-skel",""),e.style.cssText="display:block;width:100%;height:100%;min-height:4rem;border-radius:var(--a-radius-md)"),this.innerHTML="",this.appendChild(e);return}let t=this.querySelector("skeleton-ui[data-chart-skel]");t&&t.remove(),this.#f()}#c(){let t=this.clientWidth||300,e=this.clientHeight||0,i=iO[this.aspect]||iO.std,n=this.#t.length||1,r=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(r/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(r,a),c=this.size||(h<150?"sm":h<300?"md":"lg"),u=c==="sm"?9:c==="md"?10:11,d=u,f=c==="sm"?8:c==="md"?9:10,p=this.hideGrid,m=p?0:u*3.2,O=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!O||p?2:u*2.2,left:m},y=r-g.left-g.right,v=Math.max(4,y/n*.6);return{width:r,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:v,plotW:y,n,sizeClass:c}}#d=null;#f(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#d&&(this.#d=t.cloneNode(!0)),this.innerHTML="",this.#d&&this.appendChild(this.#d.cloneNode(!0)),!this.#t.length){this.removeAttribute("data-has-data");return}if(this.setAttribute("data-has-data",""),this.#p(),this.heading){let o=document.createElement("div");o.setAttribute("data-chart-heading",""),o.textContent=this.heading,this.appendChild(o)}let e=document.createElement("div");this.type==="sparkline"&&e.setAttribute("data-sparkline",""),this.appendChild(e);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");e.appendChild(i);let n="",r="";switch(this.type){case"bar":({svg:n,viewBox:r}=this.#H());break;case"line":({svg:n,viewBox:r}=this.#K());break;case"pie":({svg:n,viewBox:r}=this.#J());break;case"donut":({svg:n,viewBox:r}=this.#tt());break;case"radar":({svg:n,viewBox:r}=this.#et());break;case"sparkline":({svg:n,viewBox:r}=this.#it());break;case"segments":({svg:n,viewBox:r}=this.#ut());break;case"area":({svg:n,viewBox:r}=this.#st());break;case"scatter":({svg:n,viewBox:r}=this.#nt());break;case"radial-bar":({svg:n,viewBox:r}=this.#rt());break;case"gauge":({svg:n,viewBox:r}=this.#ot());break;case"funnel":({svg:n,viewBox:r}=this.#at());break;case"treemap":({svg:n,viewBox:r}=this.#lt());break;case"sankey":({svg:n,viewBox:r}=this.#ht());break;case"composed":({svg:n,viewBox:r}=this.#ct());break;case"stacked-bar":({svg:n,viewBox:r}=this.#dt());break;case"grouped-bar":({svg:n,viewBox:r}=this.#ft());break;case"multi-line":({svg:n,viewBox:r}=this.#pt());break;default:({svg:n,viewBox:r}=this.#H());break}if(i.setAttribute("viewBox",r),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=n,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#b()){let o=this.#mt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#p(){let t=this.#T();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#g(t,e){return e?` data-slice="${t}" data-series-key="${Jt(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#O(t,e){return e?` data-slice="${t}" data-series-key="${Jt(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#m=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#S),document.removeEventListener("pointerdown",this.#W),this.removeEventListener("keydown",this.#I),this.removeEventListener("focus",this.#X),this.removeEventListener("blur",this.#M),this.removeEventListener("pointerover",this.#D),this.removeEventListener("pointermove",this.#q),this.removeEventListener("pointerleave",this.#z),this.removeEventListener("pointerdown",this.#N),this.removeEventListener("click",this.#U),this.#F()}#b(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#v(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#S=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:n}=t.detail||{};i&&(n?this.#o.delete(i):this.#o.add(i),this.#f())};#x(t){return!!t&&this.#o.has(t)}#w=!1;#k(){this.#w||(this.aspect&&this.aspect!=="std"&&(console.warn(`[chart-ui] aspect="${this.aspect}" is deprecated. Parents should size the chart directly (width/height on the card or container). The attribute will be removed in a future major.`),this.#w=!0),this.heading&&(console.warn(`[chart-ui] heading="${this.heading}" is deprecated. Place the title in an enclosing card-ui <header><span slot="heading"> instead. The attribute will be removed in a future major.`),this.#w=!0))}#y(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let n=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),`${n||"$"}${eO(e)}`}default:return eO(e)}}#$=-1;#Q(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#P(t){let e=this.#Q();if(!e.length){this.#L();return}this.#$=Math.max(0,Math.min(t,e.length-1)),this.#C(),this.#E()}#C(){let t=this.#Q();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#$];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#L(){this.#$=-1;for(let t of this.#Q())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#E(){let t=this.#Q()[this.#$];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#_(t,i)}#Z(){let t=this.#Q()[this.#$];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#j(t,i)}))}#X=()=>{this.#$===-1&&this.#P(0)};#M=()=>{this.#L(),this.#A&&this.#B()};#I=t=>{let e=this.#Q();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#P(this.#$+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#P(Math.max(0,this.#$-1));break;case"Home":t.preventDefault(),this.#P(0);break;case"End":t.preventDefault(),this.#P(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#Z();break;case"Escape":t.preventDefault(),this.#L(),this.#A&&this.#B();break}};#A=null;#D=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#G(e,t),this.#_(e,t))};#q=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#A&&this.#B(),this.#F();this.#G(e,t),e!==this.#A&&this.#_(e,t)};#z=t=>{t&&t.pointerType==="touch"||(this.#F(),this.#A&&this.#B())};#N=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#A&&this.#B(),this.#F();this.#G(e,t),e!==this.#A&&this.#_(e,t),document.addEventListener("pointerdown",this.#W)};#W=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#F(),this.#A&&this.#B(),document.removeEventListener("pointerdown",this.#W)))};#U=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#j(e,t)}))};#_(t,e){this.#A=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#j(t,e)}))}#B(){this.#A=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#j(t,e){let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=n!=null?Number(n):null,h=r!=null?Number(r):null,c=i??null,u=o??null,d=this.#Y(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#Y(t,e){if(t==null)return null;let i=this.x,n=this.#T();if(!i||n.length===0)return null;let r=this.#t.find(l=>String(l[i]??"")===String(t));if(!r)return null;let o=n.filter(l=>!this.#x(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(r[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#G(t,e){if(this.#v())return;let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset;if(!this.#m){let O=document.createElement("div");O.setAttribute("popover","manual"),O.setAttribute("role","tooltip"),O.classList.add("chart-tooltip-popup"),document.body.appendChild(O),this.#m=O}let a=[];if(o&&a.push(`<span data-tip-role="series">${Jt(o)}</span>`),i&&a.push(`<span data-tip-role="label">${Jt(i)}</span>`),n!==void 0){let O=r!==void 0?` <span data-tip-role="pct">(${r}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#y(n)}${O}</span>`)}this.#m.innerHTML=a.join("");try{this.#m.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#m.offsetWidth||0,f=this.#m.offsetHeight||0,p=c-d/2,m=u-f-l;p<h&&(p=h),p+d>window.innerWidth-h&&(p=window.innerWidth-d-h),m<h&&(m=u+l),this.#m.style.left=`${p}px`,this.#m.style.top=`${m}px`}#F(){if(this.#m){try{this.#m.hidePopover()}catch{}this.#m.remove(),this.#m=null}}#T(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#V(t,e,i,n,r,o){let a=r,l=o?.fontSize||10,h=o?.labelSize||l,c="",u=i;if(o?.sizeClass==="sm"&&i.length>4&&(u=i.filter((d,f)=>f%2===0||f===i.length-1)),!this.hideGrid){let f=i[i.length-1]-i[0]||1;for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<line data-grid x1="${a.left}" y1="${m}" x2="${t-a.right}" y2="${m}"/>`}for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<text data-y-label x="${a.left-4}" y="${m+l*.35}" text-anchor="end" font-size="${l}">${this.#y(p)}</text>`}if(n){let m=(t-a.left-a.right)/n.length,g=n.reduce((x,S)=>Math.max(x,String(S).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=n.length-1;for(let x=0;x<n.length;x++){if(x%y!==0&&x!==v||x!==v&&v-x<y)continue;let S=a.left+m*x+m/2;c+=`<text data-x-label x="${S}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${Jt(n[x])}</text>`}}}return c}#H(){let t=this.#c(),e=this.#t,i=this.#T()[0]||this.y,n=e.map(v=>+(v[i]??0)),r=e.map(v=>v[this.x]??""),o=is(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/e.length,p=f*.6,m=(f-p)/2,O=this.#V(l,h,o,r,c,t),g=!this.hideValues&&t.sizeClass!=="sm",y=!this.hideAverage&&n.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let v=0;v<e.length;v++){let x=n[v],S=a?x/a*u:0,$=c.left+f*v+m,k=c.top+u-S;O+=`<path data-bar${mt({label:r[v],value:x})} d="${ol($,k,p,S,this.#a())}"/>`,g&&(O+=`<text data-value x="${$+p/2}" y="${k-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#y(x)}</text>`)}if(y){let v=n.reduce((S,$)=>S+$,0)/n.length,x=c.top+u-(a?v/a*u:0);O+=`<line data-avg x1="${c.left}" y1="${x}" x2="${l-c.right}" y2="${x}"/>`,O+=`<text data-avg-label x="${l-c.right+2}" y="${x+3}" text-anchor="start" font-size="${t.valueSize}">${this.#y(v)}</text>`,O+=`<line data-hit${mt({label:"Average",value:v})} x1="${c.left}" y1="${x}" x2="${l-c.right}" y2="${x}" stroke="transparent" stroke-width="12"/>`}return{svg:O,viewBox:`0 0 ${l} ${h}`}}#K(){let t=this.#c(),e=this.#t,i=this.#T()[0]||this.y,n=e.map(k=>+(k[i]??0)),r=e.map(k=>k[this.x]??""),o=is(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#V(l,h,o,r,c,t),m=n.map((k,P)=>{let T=c.left+f*P,C=c.top+u-(a?k/a*u:0);return{x:T,y:C,v:k,label:r[P]}}),O=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${uu(m,O,g)}"/>`,p+=`<path data-line d="${Zo(m,g)}"/>`;let y=t.sizeClass==="sm",v=y?1.5:3,x=Math.max(v,10),S=!this.hideValues&&!y,$=!this.hideAverage&&n.length>1&&!y&&!this.hideGrid;for(let k of m)p+=`<circle data-dot cx="${k.x}" cy="${k.y}" r="${v}"/>`,p+=`<circle data-hit${mt({label:k.label,value:k.v})} cx="${k.x}" cy="${k.y}" r="${x}" fill="transparent"/>`,S&&(p+=`<text data-value x="${k.x}" y="${k.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#y(k.v)}</text>`);if($){let k=n.reduce((T,C)=>T+C,0)/n.length,P=c.top+u-(a?k/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${P}" x2="${l-c.right}" y2="${P}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${P+3}" text-anchor="start" font-size="${t.valueSize}">${this.#y(k)}</text>`,p+=`<line data-hit${mt({label:"Average",value:k})} x1="${c.left}" y1="${P}" x2="${l-c.right}" y2="${P}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#J(){let t=this.#t,e=this.#T()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=this.#c(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d="",f=-Math.PI/2;for(let p=0;p<i.length;p++){let m=i[p]/n*Math.PI*2;if(m===0)continue;let O=f+m,g=(i[p]/n*100).toFixed(1),y=` data-slice="${p%10}"${mt({label:r[p],value:i[p],pct:g})}`;Math.abs(m-Math.PI*2)<.001?d+=`<circle${y} cx="${h}" cy="${c}" r="${u}"/>`:d+=`<path${y} d="${k1(h,c,u,f,O)}"/>`,f=O}return this.#R=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#tt(){let t=this.#t,e=this.#T()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=i.reduce((g,y)=>g+y,0)||1,r=t.map(g=>g[this.x]??""),o=this.#c(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d=u*.72,f="",p=-Math.PI/2;for(let g=0;g<i.length;g++){let y=i[g]/n*Math.PI*2;if(y===0)continue;let v=p+y,x=(i[g]/n*100).toFixed(1),S=` data-slice="${g%10}"${mt({label:r[g],value:i[g],pct:x})}`;Math.abs(y-Math.PI*2)<.001?(f+=`<circle${S} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${S} d="M ${h-u} ${c} A ${u} ${u} 0 1 1 ${h+u} ${c} A ${u} ${u} 0 1 1 ${h-u} ${c} Z M ${h-d} ${c} A ${d} ${d} 0 1 0 ${h+d} ${c} A ${d} ${d} 0 1 0 ${h-d} ${c} Z" fill-rule="evenodd"/>`):f+=`<path${S} d="${cu(h,c,u,d,p,v,this.#a())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),O=Math.max(9,Math.round(u*.16));return f+=`<text data-donut-total x="${h}" y="${c}" text-anchor="middle" dominant-baseline="central" font-size="${m}">${this.#y(n)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${O}">Total</text>`,this.#R=t.map((g,y)=>({label:r[y],value:i[y],pct:(i[y]/n*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#et(){let t=this.#t,e=this.#T()[0]||this.y,i=t.map(S=>+(S[e]??0)),n=t.map(S=>S[this.x]??""),r=Math.max(...i)||1,o=t.length,a=this.#c(),{width:l,height:h,fontSize:c}=a,u=l/2,d=h/2,f=c*3.5,p=Math.max(40,Math.min(l,h)/2-f),m="",O=Math.PI*2/o;for(let S=1;S<=3;S++){let $=p*S/3,k="";for(let P=0;P<o;P++){let T=-Math.PI/2+O*P,C=u+$*Math.cos(T),I=d+$*Math.sin(T);k+=(P===0?"M":"L")+` ${C} ${I}`}k+=" Z",m+=`<path data-grid d="${k}"/>`}for(let S=0;S<o;S++){let $=-Math.PI/2+O*S,k=u+p*Math.cos($),P=d+p*Math.sin($);m+=`<line data-grid x1="${u}" y1="${d}" x2="${k}" y2="${P}"/>`}let g="",y=[];for(let S=0;S<o;S++){let $=-Math.PI/2+O*S,k=i[S]/r*p,P=u+k*Math.cos($),T=d+k*Math.sin($);g+=(S===0?"M":"L")+` ${P} ${T}`,y.push({px:P,py:T})}g+=" Z",m+=`<path data-radar-fill d="${g}"/>`,m+=`<path data-radar-line d="${g}"/>`;let v=Math.max(c,10);for(let S=0;S<o;S++){let{px:$,py:k}=y[S];m+=`<circle data-hit${mt({label:n[S],value:i[S]})} cx="${$}" cy="${k}" r="${v}" fill="transparent"/>`}let x=c*1.3;for(let S=0;S<o;S++){let $=-Math.PI/2+O*S,k=u+(p+x)*Math.cos($),P=d+(p+x)*Math.sin($),T=Math.abs(Math.cos($))<.1?"middle":Math.cos($)>0?"start":"end";m+=`<text data-x-label x="${k}" y="${P}" text-anchor="${T}" dominant-baseline="central" font-size="${c}">${Jt(n[S])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#it(){let t=this.#t,e=this.#T()[0]||this.y,i=t.map(y=>+(y[e]??0)),n=Math.max(...i)||1,r=Math.min(...i),o=n-r||1,a=this.clientWidth||120,l=this.clientHeight||32,h=Math.max(40,a),c=Math.max(16,l),u=h/Math.max(i.length-1,1),d=Math.max(2,Math.min(6,c*.1)),f=t.map(y=>y[this.x]??""),p=i.map((y,v)=>({x:u*v,y:c-(y-r)/o*(c-d*2)-d,v:y,label:f[v]})),m=Math.max(0,Math.min(1,this.smooth)),O="";O+=`<path data-area d="${uu(p,c,m)}"/>`,O+=`<path data-line d="${Zo(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)O+=`<circle data-hit${mt({label:y.label,value:y.v})} cx="${y.x}" cy="${y.y}" r="${g}" fill="transparent"/>`;return{svg:O,viewBox:`0 0 ${h} ${c}`}}#st(){return this.#K()}#nt(){let t=this.#c(),e=this.#t,i=this.#T()[0]||this.y,n=e.map(g=>+(g[i]??0)),r=e.map(g=>g[this.x]??""),o=is(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#V(l,h,o,r,c,t),m=t.sizeClass==="sm"?2.5:4,O=Math.max(m*2,10);for(let g=0;g<n.length;g++){let y=c.left+f*g,v=c.top+u-(a?n[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${y}" cy="${v}" r="${m}"/>`,p+=`<circle data-hit${mt({label:r[g],value:n[g]})} cx="${y}" cy="${v}" r="${O}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#rt(){let t=this.#t,e=this.#T()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=t.map(g=>g[this.x]??""),r=Math.max(...i)||1,o=this.#c(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.45),d=u*.3,f=i.length||1,p=(u-d)/f,m=Math.min(2,p*.15),O="";for(let g=0;g<i.length;g++){let y=d+p*g+m/2,v=d+p*(g+1)-m/2,x=(y+v)/2,S=v-y,$=2*Math.PI*x,k=Math.max(0,Math.min(1,i[g]/r))*$;if(O+=`<circle data-radial-track cx="${h}" cy="${c}" r="${x}" fill="none" stroke-width="${S}"/>`,k<=0)continue;let P=(i[g]/r*100).toFixed(1),T=mt({label:n[g],value:i[g],pct:P}),C=Math.abs(k-$)<.5,I=C?"butt":"round",X=C?`${$} 0`:`${k} ${$-k}`;O+=`<circle data-slice="${g%10}"${T} data-radial-bar cx="${h}" cy="${c}" r="${x}" fill="none" stroke-width="${S}" stroke-linecap="${I}" stroke-dasharray="${X}" transform="rotate(-90 ${h} ${c})"/>`}return this.#R=t.map((g,y)=>({label:n[y],key:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:O,viewBox:`0 0 ${a} ${l}`}}#ot(){let t=this.#t,e=this.#T()[0]||this.y,i=t.map(x=>+(x[e]??0)),n=i.reduce((x,S)=>x+S,0)||1,r=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(r,1):n,a=Math.max(0,Math.min(1,r/o)),l=this.#c(),{width:h,height:c}=l,u=h/2,d=c*.68,f=Math.max(40,Math.min(h*.45,c*.6)),p=f*.72,m=(f-p)/2,O="";if(O+=`<path data-radial-track d="${cu(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let x=Math.PI+Math.PI*a,S=mt({label:t[0]?.[this.x]??"Value",value:r,pct:(a*100).toFixed(1)});O+=`<path data-slice="0"${S} data-gauge-fill d="${cu(u,d,f,p,Math.PI,x,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return O+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#y(r)}</text>`,o!==r&&(O+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#y(o)}</text>`),{svg:O,viewBox:`0 0 ${h} ${c}`}}#at(){let t=this.#t,e=this.#T()[0]||this.y,i=t.map(v=>+(v[e]??0)),n=t.map(v=>v[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#c(),{width:l,height:h}=a,c=a.fontSize,u=Math.max(l*.18,80),d=c*.8,f=l-u*2,m=(h-d*2)/r,O=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<r;v++){let x=i[v],S=v<r-1?i[v+1]:i[v],$=x/o*(f/2),k=S/o*(f/2),P=d+m*v+O/2,T=d+m*(v+1)-O/2,C=(x/o*100).toFixed(1),I=mt({label:n[v],value:x,pct:C}),X=`M ${g-$} ${P} L ${g+$} ${P} L ${g+k} ${T} L ${g-k} ${T} Z`;if(y+=`<path data-slice="${v%10}" data-funnel-stage${I} d="${X}"/>`,y+=`<text data-funnel-label x="${u-8}" y="${P+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${Jt(n[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${P+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#y(x)}</text>`,v>0){let N=(i[v]/i[0]*100).toFixed(0);y+=`<text data-funnel-drop x="${l-u+8}" y="${P+m/2+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${N}%</text>`}}return this.#R=t.map((v,x)=>({label:n[x],value:i[x],pct:(i[x]/o*100).toFixed(1),slot:x%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#lt(){let t=this.#t,e=this.#T()[0]||this.y,i=t.map(C=>+(C[e]??0)),n=t.map(C=>C[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#c(),{width:a,height:l,fontSize:h}=o,c=i.reduce((C,I)=>C+I,0)||1,u=Array.from({length:r},(C,I)=>I).sort((C,I)=>i[I]-i[C]),d=[],f=a*l,p=u.map(C=>i[C]/c*f),m=0,O=0,g=a,y=l,v=[],x=0,S=(C,I)=>{if(C.length===0)return 1/0;let X=C.reduce((rt,pt)=>rt+pt,0),N=Math.max(...C),_=Math.min(...C),V=I*I,tt=X*X;return Math.max(V*N/tt,tt/(V*_))},$=(C,I,X,N,_,V)=>{let tt=C.reduce((kt,vt)=>kt+vt,0),rt=_>=V,pt=rt?tt/_:V,ut=rt?_:tt/V,yt=0;for(let kt=0;kt<C.length;kt++){let vt=C[kt]/tt,zt=u[I+kt];if(rt){let jt=vt*_;d.push({i:zt,x:X+yt,y:N,w:jt,h:pt}),yt+=jt}else{let jt=vt*V;d.push({i:zt,x:X,y:N+yt,w:ut,h:jt}),yt+=jt}}return rt?{x:X,y:N+pt,w:_,h:V-pt}:{x:X+ut,y:N,w:_-ut,h:V}},k=p.slice();for(;k.length>0;){v=[k[0]],x=p.length-k.length;let C=Math.min(g,y),I=1;for(;I<k.length;){let N=v.concat(k[I]);if(S(N,C)>S(v,C))break;v=N,I++}let X=$(v,x,m,O,g,y);m=X.x,O=X.y,g=X.w,y=X.h,k=k.slice(v.length)}let P="",T=2;for(let C of d){let I=(i[C.i]/c*100).toFixed(1),X=mt({label:n[C.i],value:i[C.i],pct:I});P+=`<rect data-slice="${C.i%10}" data-treemap-tile${X} x="${C.x+T}" y="${C.y+T}" width="${Math.max(0,C.w-T*2)}" height="${Math.max(0,C.h-T*2)}" rx="${this.#a()}"/>`;let N=C.x+8,_=C.w>h*4,V=_&&C.h>h*2.5,tt=_&&!V&&C.h>h*1.2;if(V)P+=`<text data-treemap-label x="${N}" y="${C.y+h+4}" font-size="${h}" dominant-baseline="hanging">${Jt(n[C.i])}</text>`,P+=`<text data-treemap-value x="${N}" y="${C.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#y(i[C.i])}</text>`;else if(tt){let rt=C.y+C.h/2;P+=`<text data-treemap-label x="${N}" y="${rt}" font-size="${h}" dominant-baseline="central">${Jt(n[C.i])}</text>`}}return this.#R=t.map((C,I)=>({label:n[I],value:i[I],pct:(i[I]/c*100).toFixed(1),slot:I%10})),{svg:P,viewBox:`0 0 ${a} ${l}`}}#ht(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let x of t){let S=x.source??x.from??"",$=x.target??x.to??"",k=+(x.value??x.v??0);e.has(S)||e.set(S,{name:S,flow:0}),i.has($)||i.set($,{name:$,flow:0}),e.get(S).flow+=k,i.get($).flow+=k}let n=this.#c(),{width:r,height:o,fontSize:a}=n,l=Math.max(8,r*.03),h=l+a*5,c=[...e.values()].reduce((x,S)=>x+S.flow,0)||1,u=[...i.values()].reduce((x,S)=>x+S.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),O=o-d*(p.length-1),g=0;for(let x of f){let S=x.flow/c*m;x.y0=g,x.y1=g+S,x.cursor=g,g+=S+d}g=0;for(let x of p){let S=x.flow/u*O;x.y0=g,x.y1=g+S,x.cursor=g,g+=S+d}let y="",v=Math.min(this.#a(),l/2);f.forEach((x,S)=>{y+=`<rect data-sankey-node data-slice="${S%10}" x="${h-l}" y="${x.y0}" width="${l}" height="${x.y1-x.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${h-l-6}" y="${(x.y0+x.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${Jt(x.name)}</text>`}),p.forEach((x,S)=>{y+=`<rect data-sankey-node data-slice="${(f.length+S)%10}" x="${r-h}" y="${x.y0}" width="${l}" height="${x.y1-x.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${r-h+l+6}" y="${(x.y0+x.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${Jt(x.name)}</text>`});for(let x of t){let S=e.get(x.source??x.from??""),$=i.get(x.target??x.to??"");if(!S||!$)continue;let k=+(x.value??x.v??0);if(k<=0)continue;let P=k/c*m,T=k/u*O,C=S.cursor,I=C+P,X=$.cursor,N=X+T;S.cursor+=P,$.cursor+=T;let _=h,V=r-h,tt=(_+V)/2,rt=mt({label:`${S.name} \u2192 ${$.name}`,value:k}),pt=`M ${_} ${C} C ${tt} ${C}, ${tt} ${X}, ${V} ${X} L ${V} ${N} C ${tt} ${N}, ${tt} ${I}, ${_} ${I} Z`;y+=`<path data-sankey-link${rt} d="${pt}"/>`}return{svg:y,viewBox:`0 0 ${r} ${o}`}}#ct(){let t=this.#c(),e=this.#t,i=this.#T(),n=i[0]||"bar",r=i[1]||"line",o=e.map($=>$[this.x]??""),a=e.map($=>+($[n]??0)),l=e.map($=>+($[r]??0)),h=[...a,...l],c=is(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,O=d-p.left-p.right,g=O/e.length,y=g*.6,v=(g-y)/2,x=O/Math.max(e.length-1,1),S=this.#V(d,f,c,o,p,t);if(!this.#x(n))for(let $=0;$<e.length;$++){let k=a[$],P=u?k/u*m:0,T=p.left+g*$+v,C=p.top+m-P;S+=`<path${this.#g(0,n)}${mt({label:o[$],value:k,series:n})} d="${ol(T,C,y,P,this.#a())}"/>`}if(!this.#x(r)){let $=l.map((P,T)=>({x:p.left+g*T+g/2,y:p.top+m-(u?P/u*m:0),v:P,label:o[T]})),k=Math.max(0,Math.min(1,this.smooth));S+=`<path data-line${this.#O(1,r)} d="${Zo($,k)}"/>`;for(let P of $)S+=`<circle data-dot${this.#g(1,r)} cx="${P.x}" cy="${P.y}" r="3"/>`,S+=`<circle data-hit${mt({label:P.label,value:P.v,series:r})} cx="${P.x}" cy="${P.y}" r="10" fill="transparent"/>`}return this.#R=[{label:n,key:n,slot:0},{label:r,key:r,slot:1}],{svg:S,viewBox:`0 0 ${d} ${f}`}}#ut(){let t=this.#t,e=this.#T()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#a(),l/2),c=Math.max(0,parseFloat(o.getPropertyValue("--chart-segments-gap"))||2),u=[],d=0;for(let p=0;p<i.length;p++){let m=p===i.length-1?a:Math.round((d*n+i[p]*a)/n),O=p===i.length-1?a:i.slice(0,p+1).reduce((y,v)=>y+v,0)/n*a,g=p===0?0:i.slice(0,p).reduce((y,v)=>y+v,0)/n*a;u.push({x:g,w:Math.max(0,O-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:O}=u[p];if(O<=0)continue;let g=p===0,y=p===u.length-1,v=Math.max(0,O-(y?0:c)),x=(i[p]/n*100).toFixed(1),S=mt({label:r[p],value:i[p],pct:x}),$=`<title>${Jt(r[p])}: ${i[p]} (${x}%)</title>`;if(g&&y||!g&&!y||h===0)f+=`<rect data-slice="${p%10}"${S} x="${m}" y="0" width="${v}" height="${l}"${(g||y)&&h?` rx="${h}"`:""}>${$}</rect>`;else{let k=h,P=m+v,T;g?T=`M ${m+k} 0 H ${P} V ${l} H ${m+k} A ${k} ${k} 0 0 1 ${m} ${l-k} V ${k} A ${k} ${k} 0 0 1 ${m+k} 0 Z`:T=`M ${m} 0 H ${P-k} A ${k} ${k} 0 0 1 ${P} ${k} V ${l-k} A ${k} ${k} 0 0 1 ${P-k} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${S} d="${T}">${$}</path>`}}return this.#R=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#dt(){let t=this.#t,e=this.#T(),i=t.map(g=>g[this.x]??""),n=t.map(g=>e.reduce((y,v)=>y+ +(g[v]??0),0)),r=is(0,Math.max(...n),5),o=r[r.length-1],a=this.#c(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=f*.6,m=(f-p)/2,O=this.#V(l,h,r,i,c,a);for(let g=0;g<t.length;g++){let y=c.top+u,v=e.length;for(let x=0;x<v;x++){if(this.#x(e[x]))continue;let S=+(t[g][e[x]]??0),$=o?S/o*u:0;if($<=0){y-=$;continue}y-=$;let k=c.left+f*g+m,P=y,T=$,C=x===v-1,I=this.#a(),X=`${this.#g(x%10,e[x])}${mt({label:i[g],value:S,series:e[x]})}`;C?O+=`<path${X} d="${ol(k,P,p,T,I)}"/>`:O+=`<rect${X} x="${k}" y="${P}" width="${p}" height="${T}"/>`}}return this.#R=e.map((g,y)=>({label:g,key:g,slot:y%10})),{svg:O,viewBox:`0 0 ${l} ${h}`}}#ft(){let t=this.#t,e=this.#T(),i=t.map(v=>v[this.x]??""),n=t.flatMap(v=>e.map(x=>+(v[x]??0))),r=is(0,Math.max(...n),5),o=r[r.length-1],a=this.#c(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=3,m=f*.7,O=(m-p*(e.length-1))/e.length,g=(f-m)/2,y=this.#V(l,h,r,i,c,a);for(let v=0;v<t.length;v++)for(let x=0;x<e.length;x++){if(this.#x(e[x]))continue;let S=+(t[v][e[x]]??0),$=o?S/o*u:0,k=c.left+f*v+g+(O+p)*x,P=c.top+u-$;y+=`<path${this.#g(x%10,e[x])}${mt({label:i[v],value:S,series:e[x]})} d="${ol(k,P,O,$,this.#a())}"/>`,this.hideValues||(y+=`<text data-value x="${k+O/2}" y="${P-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#y(S)}</text>`)}return this.#R=e.map((v,x)=>({label:v,key:v,slot:x%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#pt(){let t=this.#t,e=this.#T(),i=t.map(m=>m[this.x]??""),n=t.flatMap(m=>e.map(O=>+(m[O]??0))),r=is(0,Math.max(...n),5),o=r[r.length-1],a=this.#c(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(t.length-1,1),p=this.#V(l,h,r,i,c,a);for(let m=0;m<e.length;m++){if(this.#x(e[m]))continue;let g=t.map(x=>+(x[e[m]]??0)).map((x,S)=>{let $=c.left+f*S,k=c.top+u-(o?x/o*u:0);return{x:$,y:k,v:x,label:i[S]}}),y=c.top+u,v=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area${this.#g(m%10,e[m])} d="${uu(g,y,v)}"/>`,p+=`<path data-line${this.#O(m%10,e[m])} d="${Zo(g,v)}"/>`;for(let x of g)p+=`<circle data-dot${this.#g(m%10,e[m])} cx="${x.x}" cy="${x.y}" r="3"/>`,p+=`<circle data-hit${mt({label:x.label,value:x.v,series:e[m]})} cx="${x.x}" cy="${x.y}" r="10" fill="transparent"/>`}return this.#R=e.map((m,O)=>({label:m,key:m,slot:O%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#R=null;get legendData(){return this.#R?this.#R.map(t=>({...t})):null}#mt(){if(!this.#R||!this.#R.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#R){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let n=document.createElement("span");n.setAttribute("data-legend-dot",""),n.setAttribute("data-slice",String(e.slot)),e.key&&(n.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(n);let r=document.createElement("span");r.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(r),t.appendChild(i)}return t}};w("chart-ui",Gn);var Hn=class s extends A{static properties={for:{type:String,default:"",reflect:!0},items:{type:String,default:"",reflect:!1},shape:{type:String,default:"dot",reflect:!0},position:{type:String,default:"bottom",reflect:!0},static:{type:Boolean,default:!1,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#o()}disconnected(){this.#n()}render(){this.#s(),this.#o()}#s(){if(this.#n(),!this.for)return;let t=this.getRootNode()?.getElementById?.(this.for)||document.getElementById(this.for);if(!t){s._warned||(s._warned=new WeakSet);let e={el:this,id:this.for};s._warned.has(this)||(console.warn(`[chart-legend-ui] [for="${this.for}"] did not resolve to an element.`),s._warned.add(this));return}this.#t=t,this.#e=()=>this.#o(),t.addEventListener("legend-update",this.#e)}#n(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#r(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#o(){let t=this.#r();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",n=e.label??i,r=e.slot!=null?e.slot:0,o=!this.#i.has(i),a=document.createElement("badge-ui");a.setAttribute("data-row",""),a.setAttribute("role",this.static?"listitem":"button"),a.setAttribute("text",n),i&&a.setAttribute("data-key",i),o&&a.setAttribute("data-active",""),this.static||(a.setAttribute("tabindex","0"),a.setAttribute("aria-pressed",o?"true":"false"));let l=this.shape||"dot",h=document.createElement("swatch-ui");h.setAttribute("shape",l),h.setAttribute("size","sm");let c=i?`var(--color-${i}, var(--a-data-${r}))`:`var(--a-data-${r})`;h.style.setProperty("--swatch-color",c),a.appendChild(h),this.static||(a.addEventListener("click",u=>this.#a(u,i)),a.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.#a(u,i))})),this.appendChild(a)}}#a(t,e){if(!e)return;let n=!!this.#i.has(e);n?this.#i.delete(e):this.#i.add(e);let r=t.currentTarget;n?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.setAttribute("aria-pressed",n?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:n,mode:this.onToggle||"hide"}}))}};w("chart-legend-ui",Hn);var $1=120,Kn=class extends A{static properties={placement:{type:String,default:"bottom",reflect:!0},gap:{type:Number,default:4,reflect:!0},open:{type:Boolean,default:!1,reflect:!0},trigger:{type:String,default:"click",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#n=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#d),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#a),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#c),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#c))))}render(){this.open?this.#r():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=Tt(t,e,{placement:this.placement,gap:this.gap}),(this.trigger==="click"||this.trigger==="manual")&&(this.#n=requestAnimationFrame(()=>{this.#n=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#u)}))}}#o(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#u)}#a=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#u=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#c=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},$1)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#o(),this.trigger==="click"&&this.removeEventListener("click",this.#a),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#c),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#c))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};w("popover-ui",Kn);var Jn=class extends A{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.addEventListener("toggle",this.#t)}disconnected(){this.removeEventListener("toggle",this.#t)}#t=t=>{if(this.multiple)return;let e=t.target;if(!e.open)return;let i=this.querySelectorAll("accordion-item-ui");for(let n of i)n!==e&&n.open&&(n.open=!1)}},tr=class extends A{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){if(!this.querySelector('[slot="header"]')){let t=document.createElement("div");t.setAttribute("slot","header");let e=document.createElement("span");e.setAttribute("slot","header-text"),t.appendChild(e);let i=document.createElement("icon-ui");i.setAttribute("name","caret-down"),i.setAttribute("slot","caret"),t.appendChild(i),this.prepend(t)}if(!this.querySelector('[slot="body"]')){let t=document.createElement("div");t.setAttribute("slot","body");let e=[...this.childNodes].filter(i=>i.nodeType===1?!i.hasAttribute("slot"):i.nodeType===3&&i.textContent.trim());for(let i of e)t.appendChild(i);this.appendChild(t)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e))}disconnected(){this.removeEventListener("click",this.#e),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"]');t&&(t.textContent=this.text)}#e=t=>{let e=this.querySelector('[slot="header"]');!e||!e.contains(t.target)||t.target.closest('[slot="action"], [slot="actions"], [data-no-toggle]')||(this.open=!this.open,this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{open:this.open}})))}};w("accordion-ui",Jn),w("accordion-item-ui",tr);var er=class extends A{static properties={label:{type:String,default:"",reflect:!0},vertical:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","separator")}render(){if(this.vertical?this.setAttribute("aria-orientation","vertical"):this.removeAttribute("aria-orientation"),this.label){let t=this.querySelector('[slot="label"]');t||(t=document.createElement("span"),t.setAttribute("slot","label"),this.appendChild(t)),t.textContent=this.label}else{let t=this.querySelector('[slot="label"]');t&&t.remove()}}};w("divider-ui",er);var ir=class extends A{static properties={page:{type:Number,default:1,reflect:!0},total:{type:Number,default:1,reflect:!0},siblings:{type:Number,default:1,reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=!1;connected(){this.#t||(this.#t=document.createElement("nav"),this.#t.setAttribute("slot","nav"),this.#t.setAttribute("aria-label","Pagination"),this.appendChild(this.#t)),this.#e||(this.#e=!0,this.#t.addEventListener("click",this.#r))}disconnected(){this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=!1}render(){if(!this.#t)return;let t=Math.max(1,Math.min(this.page,this.total)),e=Math.max(1,this.total),i=Math.max(0,this.siblings),n=this.#i(t,e,i);this.reconcile(this.#t,n,r=>r.key,(r,o,a)=>a?(this.#n(a,r,t),a):this.#s(r,t))}#i(t,e,i){let n=[];n.push({key:"prev",type:"prev",value:t-1}),n.push({key:"page-1",type:"page",value:1});let r=Math.max(2,t-i),o=Math.min(e-1,t+i);r>2&&n.push({key:"ellipsis-start",type:"ellipsis"});for(let a=r;a<=o;a++)n.push({key:`page-${a}`,type:"page",value:a});return o<e-1&&n.push({key:"ellipsis-end",type:"ellipsis"}),e>1&&n.push({key:`page-${e}`,type:"page",value:e}),n.push({key:"next",type:"next",value:t+1}),n}#s(t,e){if(t.type==="ellipsis"){let n=document.createElement("span");return n.setAttribute("data-ellipsis",""),n.textContent="\u2026",n}let i=document.createElement("button");return i.setAttribute("type","button"),t.type==="prev"?(i.setAttribute("data-prev",""),i.setAttribute("aria-label","Previous page"),i.textContent="\u2039"):t.type==="next"?(i.setAttribute("data-next",""),i.setAttribute("aria-label","Next page"),i.textContent="\u203A"):(i.setAttribute("data-page",""),i.dataset.value=String(t.value),i.textContent=String(t.value),i.setAttribute("aria-label",`Page ${t.value}`)),this.#n(i,t,e),i}#n(t,e,i){e.type!=="ellipsis"&&(e.type==="prev"?i<=1?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0")):e.type==="next"?i>=this.total?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0")):(t.dataset.value=String(e.value),t.textContent=String(e.value),t.setAttribute("aria-label",`Page ${e.value}`),e.value===i?(t.setAttribute("data-active",""),t.setAttribute("aria-current","page")):(t.removeAttribute("data-active"),t.removeAttribute("aria-current"))))}#r=t=>{let e=t.target.closest("[data-prev], [data-next], [data-page]");if(!e||e.hasAttribute("disabled")||!this.#t.contains(e))return;let i;e.hasAttribute("data-prev")?i=this.page-1:e.hasAttribute("data-next")?i=this.page+1:e.hasAttribute("data-page")&&(i=Number(e.dataset.value)),!(i==null||i<1||i>this.total||i===this.page)&&(this.page=i,this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,detail:{page:this.page}})))}};w("pagination-ui",ir);var pM=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),mM={js:"javascript",md:"markdown",yml:"yaml"};function Km(s){if(!s)return"";let t=String(s).toLowerCase();return mM[t]??t}var qr=class s extends A{static formAssociated=!0;static properties={language:{type:String,default:"",reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},text:{type:String,default:"",reflect:!0},lineNumbers:{type:Boolean,default:!1,reflect:!0,attribute:"line-numbers"},editable:{type:Boolean,default:!1,reflect:!0},bare:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=0;#n=!1;#r=null;#o="";#a=null;#l=()=>this.#b();connected(){this.#s+=1,!this.inline&&!this.querySelector(":scope > pre")&&this.#u(),this.#t=this.querySelector(':scope > header [slot="copy"]'),this.#t&&this.#t.addEventListener("click",this.#l);let t=Km(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(pM.has(t)||this.editable)&&this.#c()}disconnected(){this.#s+=1,this.#e!=null&&(clearTimeout(this.#e),this.#e=null),this.#t&&(this.#t.removeEventListener("click",this.#l),this.#t=null),this.#i&&(this.#i.destroy(),this.#i=null)}#u(){let t=this.querySelector(":scope > template"),e=this.text?this.text.trim():t?s.#h(t.innerHTML):(this.textContent||"").trim();if(this.textContent="",!this.bare){let l=document.createElement("header"),h=document.createElement("span");h.setAttribute("slot","label"),h.textContent=this.language||"code",l.appendChild(h);let c=document.createElement("div");c.setAttribute("role","button"),c.setAttribute("tabindex","0"),c.setAttribute("slot","copy"),c.textContent="Copy",l.appendChild(c),this.appendChild(l)}let i=document.createElement("pre"),n=document.createElement("code"),r=Km(this.language),o=this.getAttribute("data-line-states");if(o!=null||r==="diff"){n.setAttribute("data-line-state-mode",""),this.lineNumbers&&n.setAttribute("data-line-numbers","");let l=o?.split(",").map(c=>c.trim())??null;e.split(`
173
+ [{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#u(),this.#f()}get data(){return this.#t}#l=!1;#u(){if(this.#l)return;let t=this.#h();this.#t.length>t&&(console.warn(`[chart-ui] .data has ${this.#t.length} rows which exceeds the recommended perf budget of ${t}. Consider downsampling at the data layer (e.g., LTTB, bucket aggregation). Override the budget via CSS: chart-ui { --chart-perf-budget: 10000 }.`),this.#l=!0)}#h(){let t=getComputedStyle(this).getPropertyValue("--chart-perf-budget").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:5e3}connected(){if(this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.heading||`${this.type} chart`),this.#t.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}document.addEventListener("toggle",this.#S),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#I),this.addEventListener("focus",this.#X),this.addEventListener("blur",this.#M),this.addEventListener("pointerover",this.#D),this.addEventListener("pointermove",this.#q),this.addEventListener("pointerleave",this.#z),this.addEventListener("pointerdown",this.#N),this.addEventListener("click",this.#U),this.#k(),this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let n=Math.round(e),r=Math.round(i);n===this.#n&&(!this.hasAttribute("resize")||r===this.#r)||(this.#n=n,this.#r=r,!this.#s&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.#f()})))}),this.#i.observe(this)}render(){if(this.loading){let e=this.querySelector("skeleton-ui[data-chart-skel]");e||(e=document.createElement("skeleton-ui"),e.setAttribute("data-chart-skel",""),e.style.cssText="display:block;width:100%;height:100%;min-height:4rem;border-radius:var(--a-radius-md)"),this.innerHTML="",this.appendChild(e);return}let t=this.querySelector("skeleton-ui[data-chart-skel]");t&&t.remove(),this.#f()}#c(){let t=this.clientWidth||300,e=this.clientHeight||0,i=iO[this.aspect]||iO.std,n=this.#t.length||1,r=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(r/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(r,a),c=this.size||(h<150?"sm":h<300?"md":"lg"),u=c==="sm"?9:c==="md"?10:11,d=u,f=c==="sm"?8:c==="md"?9:10,p=this.hideGrid,m=p?0:u*3.2,O=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!O||p?2:u*2.2,left:m},y=r-g.left-g.right,v=Math.max(4,y/n*.6);return{width:r,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:v,plotW:y,n,sizeClass:c}}#d=null;#f(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#d&&(this.#d=t.cloneNode(!0)),this.innerHTML="",this.#d&&this.appendChild(this.#d.cloneNode(!0)),!this.#t.length){this.removeAttribute("data-has-data");return}if(this.setAttribute("data-has-data",""),this.#p(),this.heading){let o=document.createElement("div");o.setAttribute("data-chart-heading",""),o.textContent=this.heading,this.appendChild(o)}let e=document.createElement("div");this.type==="sparkline"&&e.setAttribute("data-sparkline",""),this.appendChild(e);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");e.appendChild(i);let n="",r="";switch(this.type){case"bar":({svg:n,viewBox:r}=this.#H());break;case"line":({svg:n,viewBox:r}=this.#K());break;case"pie":({svg:n,viewBox:r}=this.#J());break;case"donut":({svg:n,viewBox:r}=this.#tt());break;case"radar":({svg:n,viewBox:r}=this.#et());break;case"sparkline":({svg:n,viewBox:r}=this.#it());break;case"segments":({svg:n,viewBox:r}=this.#ut());break;case"area":({svg:n,viewBox:r}=this.#st());break;case"scatter":({svg:n,viewBox:r}=this.#nt());break;case"radial-bar":({svg:n,viewBox:r}=this.#rt());break;case"gauge":({svg:n,viewBox:r}=this.#ot());break;case"funnel":({svg:n,viewBox:r}=this.#at());break;case"treemap":({svg:n,viewBox:r}=this.#lt());break;case"sankey":({svg:n,viewBox:r}=this.#ht());break;case"composed":({svg:n,viewBox:r}=this.#ct());break;case"stacked-bar":({svg:n,viewBox:r}=this.#dt());break;case"grouped-bar":({svg:n,viewBox:r}=this.#ft());break;case"multi-line":({svg:n,viewBox:r}=this.#pt());break;default:({svg:n,viewBox:r}=this.#H());break}if(i.setAttribute("viewBox",r),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=n,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#b()){let o=this.#mt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#p(){let t=this.#L();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#g(t,e){return e?` data-slice="${t}" data-series-key="${Jt(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#O(t,e){return e?` data-slice="${t}" data-series-key="${Jt(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#m=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#S),document.removeEventListener("pointerdown",this.#W),this.removeEventListener("keydown",this.#I),this.removeEventListener("focus",this.#X),this.removeEventListener("blur",this.#M),this.removeEventListener("pointerover",this.#D),this.removeEventListener("pointermove",this.#q),this.removeEventListener("pointerleave",this.#z),this.removeEventListener("pointerdown",this.#N),this.removeEventListener("click",this.#U),this.#F()}#b(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#x(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#S=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:n}=t.detail||{};i&&(n?this.#o.delete(i):this.#o.add(i),this.#f())};#v(t){return!!t&&this.#o.has(t)}#w=!1;#k(){this.#w||(this.aspect&&this.aspect!=="std"&&(console.warn(`[chart-ui] aspect="${this.aspect}" is deprecated. Parents should size the chart directly (width/height on the card or container). The attribute will be removed in a future major.`),this.#w=!0),this.heading&&(console.warn(`[chart-ui] heading="${this.heading}" is deprecated. Place the title in an enclosing card-ui <header><span slot="heading"> instead. The attribute will be removed in a future major.`),this.#w=!0))}#y(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let n=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),`${n||"$"}${eO(e)}`}default:return eO(e)}}#$=-1;#A(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#C(t){let e=this.#A();if(!e.length){this.#E();return}this.#$=Math.max(0,Math.min(t,e.length-1)),this.#P(),this.#T()}#P(){let t=this.#A();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#$];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#E(){this.#$=-1;for(let t of this.#A())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#T(){let t=this.#A()[this.#$];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#_(t,i)}#Z(){let t=this.#A()[this.#$];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#j(t,i)}))}#X=()=>{this.#$===-1&&this.#C(0)};#M=()=>{this.#E(),this.#Q&&this.#B()};#I=t=>{let e=this.#A();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#C(this.#$+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#C(Math.max(0,this.#$-1));break;case"Home":t.preventDefault(),this.#C(0);break;case"End":t.preventDefault(),this.#C(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#Z();break;case"Escape":t.preventDefault(),this.#E(),this.#Q&&this.#B();break}};#Q=null;#D=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#G(e,t),this.#_(e,t))};#q=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#Q&&this.#B(),this.#F();this.#G(e,t),e!==this.#Q&&this.#_(e,t)};#z=t=>{t&&t.pointerType==="touch"||(this.#F(),this.#Q&&this.#B())};#N=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#Q&&this.#B(),this.#F();this.#G(e,t),e!==this.#Q&&this.#_(e,t),document.addEventListener("pointerdown",this.#W)};#W=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#F(),this.#Q&&this.#B(),document.removeEventListener("pointerdown",this.#W)))};#U=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#j(e,t)}))};#_(t,e){this.#Q=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#j(t,e)}))}#B(){this.#Q=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#j(t,e){let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=n!=null?Number(n):null,h=r!=null?Number(r):null,c=i??null,u=o??null,d=this.#Y(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#Y(t,e){if(t==null)return null;let i=this.x,n=this.#L();if(!i||n.length===0)return null;let r=this.#t.find(l=>String(l[i]??"")===String(t));if(!r)return null;let o=n.filter(l=>!this.#v(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(r[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#G(t,e){if(this.#x())return;let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset;if(!this.#m){let O=document.createElement("div");O.setAttribute("popover","manual"),O.setAttribute("role","tooltip"),O.classList.add("chart-tooltip-popup"),document.body.appendChild(O),this.#m=O}let a=[];if(o&&a.push(`<span data-tip-role="series">${Jt(o)}</span>`),i&&a.push(`<span data-tip-role="label">${Jt(i)}</span>`),n!==void 0){let O=r!==void 0?` <span data-tip-role="pct">(${r}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#y(n)}${O}</span>`)}this.#m.innerHTML=a.join("");try{this.#m.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#m.offsetWidth||0,f=this.#m.offsetHeight||0,p=c-d/2,m=u-f-l;p<h&&(p=h),p+d>window.innerWidth-h&&(p=window.innerWidth-d-h),m<h&&(m=u+l),this.#m.style.left=`${p}px`,this.#m.style.top=`${m}px`}#F(){if(this.#m){try{this.#m.hidePopover()}catch{}this.#m.remove(),this.#m=null}}#L(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#V(t,e,i,n,r,o){let a=r,l=o?.fontSize||10,h=o?.labelSize||l,c="",u=i;if(o?.sizeClass==="sm"&&i.length>4&&(u=i.filter((d,f)=>f%2===0||f===i.length-1)),!this.hideGrid){let f=i[i.length-1]-i[0]||1;for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<line data-grid x1="${a.left}" y1="${m}" x2="${t-a.right}" y2="${m}"/>`}for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<text data-y-label x="${a.left-4}" y="${m+l*.35}" text-anchor="end" font-size="${l}">${this.#y(p)}</text>`}if(n){let m=(t-a.left-a.right)/n.length,g=n.reduce((x,S)=>Math.max(x,String(S).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=n.length-1;for(let x=0;x<n.length;x++){if(x%y!==0&&x!==v||x!==v&&v-x<y)continue;let S=a.left+m*x+m/2;c+=`<text data-x-label x="${S}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${Jt(n[x])}</text>`}}}return c}#H(){let t=this.#c(),e=this.#t,i=this.#L()[0]||this.y,n=e.map(v=>+(v[i]??0)),r=e.map(v=>v[this.x]??""),o=is(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/e.length,p=f*.6,m=(f-p)/2,O=this.#V(l,h,o,r,c,t),g=!this.hideValues&&t.sizeClass!=="sm",y=!this.hideAverage&&n.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let v=0;v<e.length;v++){let x=n[v],S=a?x/a*u:0,$=c.left+f*v+m,k=c.top+u-S;O+=`<path data-bar${mt({label:r[v],value:x})} d="${ol($,k,p,S,this.#a())}"/>`,g&&(O+=`<text data-value x="${$+p/2}" y="${k-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#y(x)}</text>`)}if(y){let v=n.reduce((S,$)=>S+$,0)/n.length,x=c.top+u-(a?v/a*u:0);O+=`<line data-avg x1="${c.left}" y1="${x}" x2="${l-c.right}" y2="${x}"/>`,O+=`<text data-avg-label x="${l-c.right+2}" y="${x+3}" text-anchor="start" font-size="${t.valueSize}">${this.#y(v)}</text>`,O+=`<line data-hit${mt({label:"Average",value:v})} x1="${c.left}" y1="${x}" x2="${l-c.right}" y2="${x}" stroke="transparent" stroke-width="12"/>`}return{svg:O,viewBox:`0 0 ${l} ${h}`}}#K(){let t=this.#c(),e=this.#t,i=this.#L()[0]||this.y,n=e.map(k=>+(k[i]??0)),r=e.map(k=>k[this.x]??""),o=is(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#V(l,h,o,r,c,t),m=n.map((k,P)=>{let T=c.left+f*P,C=c.top+u-(a?k/a*u:0);return{x:T,y:C,v:k,label:r[P]}}),O=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${uu(m,O,g)}"/>`,p+=`<path data-line d="${Zo(m,g)}"/>`;let y=t.sizeClass==="sm",v=y?1.5:3,x=Math.max(v,10),S=!this.hideValues&&!y,$=!this.hideAverage&&n.length>1&&!y&&!this.hideGrid;for(let k of m)p+=`<circle data-dot cx="${k.x}" cy="${k.y}" r="${v}"/>`,p+=`<circle data-hit${mt({label:k.label,value:k.v})} cx="${k.x}" cy="${k.y}" r="${x}" fill="transparent"/>`,S&&(p+=`<text data-value x="${k.x}" y="${k.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#y(k.v)}</text>`);if($){let k=n.reduce((T,C)=>T+C,0)/n.length,P=c.top+u-(a?k/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${P}" x2="${l-c.right}" y2="${P}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${P+3}" text-anchor="start" font-size="${t.valueSize}">${this.#y(k)}</text>`,p+=`<line data-hit${mt({label:"Average",value:k})} x1="${c.left}" y1="${P}" x2="${l-c.right}" y2="${P}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#J(){let t=this.#t,e=this.#L()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=this.#c(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d="",f=-Math.PI/2;for(let p=0;p<i.length;p++){let m=i[p]/n*Math.PI*2;if(m===0)continue;let O=f+m,g=(i[p]/n*100).toFixed(1),y=` data-slice="${p%10}"${mt({label:r[p],value:i[p],pct:g})}`;Math.abs(m-Math.PI*2)<.001?d+=`<circle${y} cx="${h}" cy="${c}" r="${u}"/>`:d+=`<path${y} d="${k1(h,c,u,f,O)}"/>`,f=O}return this.#R=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#tt(){let t=this.#t,e=this.#L()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=i.reduce((g,y)=>g+y,0)||1,r=t.map(g=>g[this.x]??""),o=this.#c(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d=u*.72,f="",p=-Math.PI/2;for(let g=0;g<i.length;g++){let y=i[g]/n*Math.PI*2;if(y===0)continue;let v=p+y,x=(i[g]/n*100).toFixed(1),S=` data-slice="${g%10}"${mt({label:r[g],value:i[g],pct:x})}`;Math.abs(y-Math.PI*2)<.001?(f+=`<circle${S} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${S} d="M ${h-u} ${c} A ${u} ${u} 0 1 1 ${h+u} ${c} A ${u} ${u} 0 1 1 ${h-u} ${c} Z M ${h-d} ${c} A ${d} ${d} 0 1 0 ${h+d} ${c} A ${d} ${d} 0 1 0 ${h-d} ${c} Z" fill-rule="evenodd"/>`):f+=`<path${S} d="${cu(h,c,u,d,p,v,this.#a())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),O=Math.max(9,Math.round(u*.16));return f+=`<text data-donut-total x="${h}" y="${c}" text-anchor="middle" dominant-baseline="central" font-size="${m}">${this.#y(n)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${O}">Total</text>`,this.#R=t.map((g,y)=>({label:r[y],value:i[y],pct:(i[y]/n*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#et(){let t=this.#t,e=this.#L()[0]||this.y,i=t.map(S=>+(S[e]??0)),n=t.map(S=>S[this.x]??""),r=Math.max(...i)||1,o=t.length,a=this.#c(),{width:l,height:h,fontSize:c}=a,u=l/2,d=h/2,f=c*3.5,p=Math.max(40,Math.min(l,h)/2-f),m="",O=Math.PI*2/o;for(let S=1;S<=3;S++){let $=p*S/3,k="";for(let P=0;P<o;P++){let T=-Math.PI/2+O*P,C=u+$*Math.cos(T),I=d+$*Math.sin(T);k+=(P===0?"M":"L")+` ${C} ${I}`}k+=" Z",m+=`<path data-grid d="${k}"/>`}for(let S=0;S<o;S++){let $=-Math.PI/2+O*S,k=u+p*Math.cos($),P=d+p*Math.sin($);m+=`<line data-grid x1="${u}" y1="${d}" x2="${k}" y2="${P}"/>`}let g="",y=[];for(let S=0;S<o;S++){let $=-Math.PI/2+O*S,k=i[S]/r*p,P=u+k*Math.cos($),T=d+k*Math.sin($);g+=(S===0?"M":"L")+` ${P} ${T}`,y.push({px:P,py:T})}g+=" Z",m+=`<path data-radar-fill d="${g}"/>`,m+=`<path data-radar-line d="${g}"/>`;let v=Math.max(c,10);for(let S=0;S<o;S++){let{px:$,py:k}=y[S];m+=`<circle data-hit${mt({label:n[S],value:i[S]})} cx="${$}" cy="${k}" r="${v}" fill="transparent"/>`}let x=c*1.3;for(let S=0;S<o;S++){let $=-Math.PI/2+O*S,k=u+(p+x)*Math.cos($),P=d+(p+x)*Math.sin($),T=Math.abs(Math.cos($))<.1?"middle":Math.cos($)>0?"start":"end";m+=`<text data-x-label x="${k}" y="${P}" text-anchor="${T}" dominant-baseline="central" font-size="${c}">${Jt(n[S])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#it(){let t=this.#t,e=this.#L()[0]||this.y,i=t.map(y=>+(y[e]??0)),n=Math.max(...i)||1,r=Math.min(...i),o=n-r||1,a=this.clientWidth||120,l=this.clientHeight||32,h=Math.max(40,a),c=Math.max(16,l),u=h/Math.max(i.length-1,1),d=Math.max(2,Math.min(6,c*.1)),f=t.map(y=>y[this.x]??""),p=i.map((y,v)=>({x:u*v,y:c-(y-r)/o*(c-d*2)-d,v:y,label:f[v]})),m=Math.max(0,Math.min(1,this.smooth)),O="";O+=`<path data-area d="${uu(p,c,m)}"/>`,O+=`<path data-line d="${Zo(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)O+=`<circle data-hit${mt({label:y.label,value:y.v})} cx="${y.x}" cy="${y.y}" r="${g}" fill="transparent"/>`;return{svg:O,viewBox:`0 0 ${h} ${c}`}}#st(){return this.#K()}#nt(){let t=this.#c(),e=this.#t,i=this.#L()[0]||this.y,n=e.map(g=>+(g[i]??0)),r=e.map(g=>g[this.x]??""),o=is(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#V(l,h,o,r,c,t),m=t.sizeClass==="sm"?2.5:4,O=Math.max(m*2,10);for(let g=0;g<n.length;g++){let y=c.left+f*g,v=c.top+u-(a?n[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${y}" cy="${v}" r="${m}"/>`,p+=`<circle data-hit${mt({label:r[g],value:n[g]})} cx="${y}" cy="${v}" r="${O}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#rt(){let t=this.#t,e=this.#L()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=t.map(g=>g[this.x]??""),r=Math.max(...i)||1,o=this.#c(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.45),d=u*.3,f=i.length||1,p=(u-d)/f,m=Math.min(2,p*.15),O="";for(let g=0;g<i.length;g++){let y=d+p*g+m/2,v=d+p*(g+1)-m/2,x=(y+v)/2,S=v-y,$=2*Math.PI*x,k=Math.max(0,Math.min(1,i[g]/r))*$;if(O+=`<circle data-radial-track cx="${h}" cy="${c}" r="${x}" fill="none" stroke-width="${S}"/>`,k<=0)continue;let P=(i[g]/r*100).toFixed(1),T=mt({label:n[g],value:i[g],pct:P}),C=Math.abs(k-$)<.5,I=C?"butt":"round",X=C?`${$} 0`:`${k} ${$-k}`;O+=`<circle data-slice="${g%10}"${T} data-radial-bar cx="${h}" cy="${c}" r="${x}" fill="none" stroke-width="${S}" stroke-linecap="${I}" stroke-dasharray="${X}" transform="rotate(-90 ${h} ${c})"/>`}return this.#R=t.map((g,y)=>({label:n[y],key:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:O,viewBox:`0 0 ${a} ${l}`}}#ot(){let t=this.#t,e=this.#L()[0]||this.y,i=t.map(x=>+(x[e]??0)),n=i.reduce((x,S)=>x+S,0)||1,r=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(r,1):n,a=Math.max(0,Math.min(1,r/o)),l=this.#c(),{width:h,height:c}=l,u=h/2,d=c*.68,f=Math.max(40,Math.min(h*.45,c*.6)),p=f*.72,m=(f-p)/2,O="";if(O+=`<path data-radial-track d="${cu(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let x=Math.PI+Math.PI*a,S=mt({label:t[0]?.[this.x]??"Value",value:r,pct:(a*100).toFixed(1)});O+=`<path data-slice="0"${S} data-gauge-fill d="${cu(u,d,f,p,Math.PI,x,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return O+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#y(r)}</text>`,o!==r&&(O+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#y(o)}</text>`),{svg:O,viewBox:`0 0 ${h} ${c}`}}#at(){let t=this.#t,e=this.#L()[0]||this.y,i=t.map(v=>+(v[e]??0)),n=t.map(v=>v[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#c(),{width:l,height:h}=a,c=a.fontSize,u=Math.max(l*.18,80),d=c*.8,f=l-u*2,m=(h-d*2)/r,O=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<r;v++){let x=i[v],S=v<r-1?i[v+1]:i[v],$=x/o*(f/2),k=S/o*(f/2),P=d+m*v+O/2,T=d+m*(v+1)-O/2,C=(x/o*100).toFixed(1),I=mt({label:n[v],value:x,pct:C}),X=`M ${g-$} ${P} L ${g+$} ${P} L ${g+k} ${T} L ${g-k} ${T} Z`;if(y+=`<path data-slice="${v%10}" data-funnel-stage${I} d="${X}"/>`,y+=`<text data-funnel-label x="${u-8}" y="${P+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${Jt(n[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${P+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#y(x)}</text>`,v>0){let N=(i[v]/i[0]*100).toFixed(0);y+=`<text data-funnel-drop x="${l-u+8}" y="${P+m/2+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${N}%</text>`}}return this.#R=t.map((v,x)=>({label:n[x],value:i[x],pct:(i[x]/o*100).toFixed(1),slot:x%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#lt(){let t=this.#t,e=this.#L()[0]||this.y,i=t.map(C=>+(C[e]??0)),n=t.map(C=>C[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#c(),{width:a,height:l,fontSize:h}=o,c=i.reduce((C,I)=>C+I,0)||1,u=Array.from({length:r},(C,I)=>I).sort((C,I)=>i[I]-i[C]),d=[],f=a*l,p=u.map(C=>i[C]/c*f),m=0,O=0,g=a,y=l,v=[],x=0,S=(C,I)=>{if(C.length===0)return 1/0;let X=C.reduce((rt,pt)=>rt+pt,0),N=Math.max(...C),_=Math.min(...C),V=I*I,tt=X*X;return Math.max(V*N/tt,tt/(V*_))},$=(C,I,X,N,_,V)=>{let tt=C.reduce((kt,vt)=>kt+vt,0),rt=_>=V,pt=rt?tt/_:V,ut=rt?_:tt/V,yt=0;for(let kt=0;kt<C.length;kt++){let vt=C[kt]/tt,zt=u[I+kt];if(rt){let jt=vt*_;d.push({i:zt,x:X+yt,y:N,w:jt,h:pt}),yt+=jt}else{let jt=vt*V;d.push({i:zt,x:X,y:N+yt,w:ut,h:jt}),yt+=jt}}return rt?{x:X,y:N+pt,w:_,h:V-pt}:{x:X+ut,y:N,w:_-ut,h:V}},k=p.slice();for(;k.length>0;){v=[k[0]],x=p.length-k.length;let C=Math.min(g,y),I=1;for(;I<k.length;){let N=v.concat(k[I]);if(S(N,C)>S(v,C))break;v=N,I++}let X=$(v,x,m,O,g,y);m=X.x,O=X.y,g=X.w,y=X.h,k=k.slice(v.length)}let P="",T=2;for(let C of d){let I=(i[C.i]/c*100).toFixed(1),X=mt({label:n[C.i],value:i[C.i],pct:I});P+=`<rect data-slice="${C.i%10}" data-treemap-tile${X} x="${C.x+T}" y="${C.y+T}" width="${Math.max(0,C.w-T*2)}" height="${Math.max(0,C.h-T*2)}" rx="${this.#a()}"/>`;let N=C.x+8,_=C.w>h*4,V=_&&C.h>h*2.5,tt=_&&!V&&C.h>h*1.2;if(V)P+=`<text data-treemap-label x="${N}" y="${C.y+h+4}" font-size="${h}" dominant-baseline="hanging">${Jt(n[C.i])}</text>`,P+=`<text data-treemap-value x="${N}" y="${C.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#y(i[C.i])}</text>`;else if(tt){let rt=C.y+C.h/2;P+=`<text data-treemap-label x="${N}" y="${rt}" font-size="${h}" dominant-baseline="central">${Jt(n[C.i])}</text>`}}return this.#R=t.map((C,I)=>({label:n[I],value:i[I],pct:(i[I]/c*100).toFixed(1),slot:I%10})),{svg:P,viewBox:`0 0 ${a} ${l}`}}#ht(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let x of t){let S=x.source??x.from??"",$=x.target??x.to??"",k=+(x.value??x.v??0);e.has(S)||e.set(S,{name:S,flow:0}),i.has($)||i.set($,{name:$,flow:0}),e.get(S).flow+=k,i.get($).flow+=k}let n=this.#c(),{width:r,height:o,fontSize:a}=n,l=Math.max(8,r*.03),h=l+a*5,c=[...e.values()].reduce((x,S)=>x+S.flow,0)||1,u=[...i.values()].reduce((x,S)=>x+S.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),O=o-d*(p.length-1),g=0;for(let x of f){let S=x.flow/c*m;x.y0=g,x.y1=g+S,x.cursor=g,g+=S+d}g=0;for(let x of p){let S=x.flow/u*O;x.y0=g,x.y1=g+S,x.cursor=g,g+=S+d}let y="",v=Math.min(this.#a(),l/2);f.forEach((x,S)=>{y+=`<rect data-sankey-node data-slice="${S%10}" x="${h-l}" y="${x.y0}" width="${l}" height="${x.y1-x.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${h-l-6}" y="${(x.y0+x.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${Jt(x.name)}</text>`}),p.forEach((x,S)=>{y+=`<rect data-sankey-node data-slice="${(f.length+S)%10}" x="${r-h}" y="${x.y0}" width="${l}" height="${x.y1-x.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${r-h+l+6}" y="${(x.y0+x.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${Jt(x.name)}</text>`});for(let x of t){let S=e.get(x.source??x.from??""),$=i.get(x.target??x.to??"");if(!S||!$)continue;let k=+(x.value??x.v??0);if(k<=0)continue;let P=k/c*m,T=k/u*O,C=S.cursor,I=C+P,X=$.cursor,N=X+T;S.cursor+=P,$.cursor+=T;let _=h,V=r-h,tt=(_+V)/2,rt=mt({label:`${S.name} \u2192 ${$.name}`,value:k}),pt=`M ${_} ${C} C ${tt} ${C}, ${tt} ${X}, ${V} ${X} L ${V} ${N} C ${tt} ${N}, ${tt} ${I}, ${_} ${I} Z`;y+=`<path data-sankey-link${rt} d="${pt}"/>`}return{svg:y,viewBox:`0 0 ${r} ${o}`}}#ct(){let t=this.#c(),e=this.#t,i=this.#L(),n=i[0]||"bar",r=i[1]||"line",o=e.map($=>$[this.x]??""),a=e.map($=>+($[n]??0)),l=e.map($=>+($[r]??0)),h=[...a,...l],c=is(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,O=d-p.left-p.right,g=O/e.length,y=g*.6,v=(g-y)/2,x=O/Math.max(e.length-1,1),S=this.#V(d,f,c,o,p,t);if(!this.#v(n))for(let $=0;$<e.length;$++){let k=a[$],P=u?k/u*m:0,T=p.left+g*$+v,C=p.top+m-P;S+=`<path${this.#g(0,n)}${mt({label:o[$],value:k,series:n})} d="${ol(T,C,y,P,this.#a())}"/>`}if(!this.#v(r)){let $=l.map((P,T)=>({x:p.left+g*T+g/2,y:p.top+m-(u?P/u*m:0),v:P,label:o[T]})),k=Math.max(0,Math.min(1,this.smooth));S+=`<path data-line${this.#O(1,r)} d="${Zo($,k)}"/>`;for(let P of $)S+=`<circle data-dot${this.#g(1,r)} cx="${P.x}" cy="${P.y}" r="3"/>`,S+=`<circle data-hit${mt({label:P.label,value:P.v,series:r})} cx="${P.x}" cy="${P.y}" r="10" fill="transparent"/>`}return this.#R=[{label:n,key:n,slot:0},{label:r,key:r,slot:1}],{svg:S,viewBox:`0 0 ${d} ${f}`}}#ut(){let t=this.#t,e=this.#L()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#a(),l/2),c=Math.max(0,parseFloat(o.getPropertyValue("--chart-segments-gap"))||2),u=[],d=0;for(let p=0;p<i.length;p++){let m=p===i.length-1?a:Math.round((d*n+i[p]*a)/n),O=p===i.length-1?a:i.slice(0,p+1).reduce((y,v)=>y+v,0)/n*a,g=p===0?0:i.slice(0,p).reduce((y,v)=>y+v,0)/n*a;u.push({x:g,w:Math.max(0,O-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:O}=u[p];if(O<=0)continue;let g=p===0,y=p===u.length-1,v=Math.max(0,O-(y?0:c)),x=(i[p]/n*100).toFixed(1),S=mt({label:r[p],value:i[p],pct:x}),$=`<title>${Jt(r[p])}: ${i[p]} (${x}%)</title>`;if(g&&y||!g&&!y||h===0)f+=`<rect data-slice="${p%10}"${S} x="${m}" y="0" width="${v}" height="${l}"${(g||y)&&h?` rx="${h}"`:""}>${$}</rect>`;else{let k=h,P=m+v,T;g?T=`M ${m+k} 0 H ${P} V ${l} H ${m+k} A ${k} ${k} 0 0 1 ${m} ${l-k} V ${k} A ${k} ${k} 0 0 1 ${m+k} 0 Z`:T=`M ${m} 0 H ${P-k} A ${k} ${k} 0 0 1 ${P} ${k} V ${l-k} A ${k} ${k} 0 0 1 ${P-k} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${S} d="${T}">${$}</path>`}}return this.#R=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#dt(){let t=this.#t,e=this.#L(),i=t.map(g=>g[this.x]??""),n=t.map(g=>e.reduce((y,v)=>y+ +(g[v]??0),0)),r=is(0,Math.max(...n),5),o=r[r.length-1],a=this.#c(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=f*.6,m=(f-p)/2,O=this.#V(l,h,r,i,c,a);for(let g=0;g<t.length;g++){let y=c.top+u,v=e.length;for(let x=0;x<v;x++){if(this.#v(e[x]))continue;let S=+(t[g][e[x]]??0),$=o?S/o*u:0;if($<=0){y-=$;continue}y-=$;let k=c.left+f*g+m,P=y,T=$,C=x===v-1,I=this.#a(),X=`${this.#g(x%10,e[x])}${mt({label:i[g],value:S,series:e[x]})}`;C?O+=`<path${X} d="${ol(k,P,p,T,I)}"/>`:O+=`<rect${X} x="${k}" y="${P}" width="${p}" height="${T}"/>`}}return this.#R=e.map((g,y)=>({label:g,key:g,slot:y%10})),{svg:O,viewBox:`0 0 ${l} ${h}`}}#ft(){let t=this.#t,e=this.#L(),i=t.map(v=>v[this.x]??""),n=t.flatMap(v=>e.map(x=>+(v[x]??0))),r=is(0,Math.max(...n),5),o=r[r.length-1],a=this.#c(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=3,m=f*.7,O=(m-p*(e.length-1))/e.length,g=(f-m)/2,y=this.#V(l,h,r,i,c,a);for(let v=0;v<t.length;v++)for(let x=0;x<e.length;x++){if(this.#v(e[x]))continue;let S=+(t[v][e[x]]??0),$=o?S/o*u:0,k=c.left+f*v+g+(O+p)*x,P=c.top+u-$;y+=`<path${this.#g(x%10,e[x])}${mt({label:i[v],value:S,series:e[x]})} d="${ol(k,P,O,$,this.#a())}"/>`,this.hideValues||(y+=`<text data-value x="${k+O/2}" y="${P-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#y(S)}</text>`)}return this.#R=e.map((v,x)=>({label:v,key:v,slot:x%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#pt(){let t=this.#t,e=this.#L(),i=t.map(m=>m[this.x]??""),n=t.flatMap(m=>e.map(O=>+(m[O]??0))),r=is(0,Math.max(...n),5),o=r[r.length-1],a=this.#c(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(t.length-1,1),p=this.#V(l,h,r,i,c,a);for(let m=0;m<e.length;m++){if(this.#v(e[m]))continue;let g=t.map(x=>+(x[e[m]]??0)).map((x,S)=>{let $=c.left+f*S,k=c.top+u-(o?x/o*u:0);return{x:$,y:k,v:x,label:i[S]}}),y=c.top+u,v=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area${this.#g(m%10,e[m])} d="${uu(g,y,v)}"/>`,p+=`<path data-line${this.#O(m%10,e[m])} d="${Zo(g,v)}"/>`;for(let x of g)p+=`<circle data-dot${this.#g(m%10,e[m])} cx="${x.x}" cy="${x.y}" r="3"/>`,p+=`<circle data-hit${mt({label:x.label,value:x.v,series:e[m]})} cx="${x.x}" cy="${x.y}" r="10" fill="transparent"/>`}return this.#R=e.map((m,O)=>({label:m,key:m,slot:O%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#R=null;get legendData(){return this.#R?this.#R.map(t=>({...t})):null}#mt(){if(!this.#R||!this.#R.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#R){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let n=document.createElement("span");n.setAttribute("data-legend-dot",""),n.setAttribute("data-slice",String(e.slot)),e.key&&(n.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(n);let r=document.createElement("span");r.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(r),t.appendChild(i)}return t}};w("chart-ui",Gn);var Hn=class s extends A{static properties={for:{type:String,default:"",reflect:!0},items:{type:String,default:"",reflect:!1},shape:{type:String,default:"dot",reflect:!0},position:{type:String,default:"bottom",reflect:!0},static:{type:Boolean,default:!1,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#o()}disconnected(){this.#n()}render(){this.#s(),this.#o()}#s(){if(this.#n(),!this.for)return;let t=this.getRootNode()?.getElementById?.(this.for)||document.getElementById(this.for);if(!t){s._warned||(s._warned=new WeakSet);let e={el:this,id:this.for};s._warned.has(this)||(console.warn(`[chart-legend-ui] [for="${this.for}"] did not resolve to an element.`),s._warned.add(this));return}this.#t=t,this.#e=()=>this.#o(),t.addEventListener("legend-update",this.#e)}#n(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#r(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#o(){let t=this.#r();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",n=e.label??i,r=e.slot!=null?e.slot:0,o=!this.#i.has(i),a=document.createElement("badge-ui");a.setAttribute("data-row",""),a.setAttribute("role",this.static?"listitem":"button"),a.setAttribute("text",n),i&&a.setAttribute("data-key",i),o&&a.setAttribute("data-active",""),this.static||(a.setAttribute("tabindex","0"),a.setAttribute("aria-pressed",o?"true":"false"));let l=this.shape||"dot",h=document.createElement("swatch-ui");h.setAttribute("shape",l),h.setAttribute("size","sm");let c=i?`var(--color-${i}, var(--a-data-${r}))`:`var(--a-data-${r})`;h.style.setProperty("--swatch-color",c),a.appendChild(h),this.static||(a.addEventListener("click",u=>this.#a(u,i)),a.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.#a(u,i))})),this.appendChild(a)}}#a(t,e){if(!e)return;let n=!!this.#i.has(e);n?this.#i.delete(e):this.#i.add(e);let r=t.currentTarget;n?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.setAttribute("aria-pressed",n?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:n,mode:this.onToggle||"hide"}}))}};w("chart-legend-ui",Hn);var $1=120,Kn=class extends A{static properties={placement:{type:String,default:"bottom",reflect:!0},gap:{type:Number,default:4,reflect:!0},open:{type:Boolean,default:!1,reflect:!0},trigger:{type:String,default:"click",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#n=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#d),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#a),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#c),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#c))))}render(){this.open?this.#r():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=Tt(t,e,{placement:this.placement,gap:this.gap}),(this.trigger==="click"||this.trigger==="manual")&&(this.#n=requestAnimationFrame(()=>{this.#n=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#u)}))}}#o(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#u)}#a=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#u=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#c=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},$1)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#o(),this.trigger==="click"&&this.removeEventListener("click",this.#a),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#c),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#c))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};w("popover-ui",Kn);var Jn=class extends A{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.addEventListener("toggle",this.#t)}disconnected(){this.removeEventListener("toggle",this.#t)}#t=t=>{if(this.multiple)return;let e=t.target;if(!e.open)return;let i=this.querySelectorAll("accordion-item-ui");for(let n of i)n!==e&&n.open&&(n.open=!1)}},tr=class extends A{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){if(!this.querySelector('[slot="header"]')){let t=document.createElement("div");t.setAttribute("slot","header");let e=document.createElement("span");e.setAttribute("slot","header-text"),t.appendChild(e);let i=document.createElement("icon-ui");i.setAttribute("name","caret-down"),i.setAttribute("slot","caret"),t.appendChild(i),this.prepend(t)}if(!this.querySelector('[slot="body"]')){let t=document.createElement("div");t.setAttribute("slot","body");let e=[...this.childNodes].filter(i=>i.nodeType===1?!i.hasAttribute("slot"):i.nodeType===3&&i.textContent.trim());for(let i of e)t.appendChild(i);this.appendChild(t)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e))}disconnected(){this.removeEventListener("click",this.#e),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"]');t&&(t.textContent=this.text)}#e=t=>{let e=this.querySelector('[slot="header"]');!e||!e.contains(t.target)||t.target.closest('[slot="action"], [slot="actions"], [data-no-toggle]')||(this.open=!this.open,this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{open:this.open}})))}};w("accordion-ui",Jn),w("accordion-item-ui",tr);var er=class extends A{static properties={label:{type:String,default:"",reflect:!0},vertical:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","separator")}render(){if(this.vertical?this.setAttribute("aria-orientation","vertical"):this.removeAttribute("aria-orientation"),this.label){let t=this.querySelector('[slot="label"]');t||(t=document.createElement("span"),t.setAttribute("slot","label"),this.appendChild(t)),t.textContent=this.label}else{let t=this.querySelector('[slot="label"]');t&&t.remove()}}};w("divider-ui",er);var ir=class extends A{static properties={page:{type:Number,default:1,reflect:!0},total:{type:Number,default:1,reflect:!0},siblings:{type:Number,default:1,reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=!1;connected(){this.#t||(this.#t=document.createElement("nav"),this.#t.setAttribute("slot","nav"),this.#t.setAttribute("aria-label","Pagination"),this.appendChild(this.#t)),this.#e||(this.#e=!0,this.#t.addEventListener("click",this.#r))}disconnected(){this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=!1}render(){if(!this.#t)return;let t=Math.max(1,Math.min(this.page,this.total)),e=Math.max(1,this.total),i=Math.max(0,this.siblings),n=this.#i(t,e,i);this.reconcile(this.#t,n,r=>r.key,(r,o,a)=>a?(this.#n(a,r,t),a):this.#s(r,t))}#i(t,e,i){let n=[];n.push({key:"prev",type:"prev",value:t-1}),n.push({key:"page-1",type:"page",value:1});let r=Math.max(2,t-i),o=Math.min(e-1,t+i);r>2&&n.push({key:"ellipsis-start",type:"ellipsis"});for(let a=r;a<=o;a++)n.push({key:`page-${a}`,type:"page",value:a});return o<e-1&&n.push({key:"ellipsis-end",type:"ellipsis"}),e>1&&n.push({key:`page-${e}`,type:"page",value:e}),n.push({key:"next",type:"next",value:t+1}),n}#s(t,e){if(t.type==="ellipsis"){let n=document.createElement("span");return n.setAttribute("data-ellipsis",""),n.textContent="\u2026",n}let i=document.createElement("button");return i.setAttribute("type","button"),t.type==="prev"?(i.setAttribute("data-prev",""),i.setAttribute("aria-label","Previous page"),i.textContent="\u2039"):t.type==="next"?(i.setAttribute("data-next",""),i.setAttribute("aria-label","Next page"),i.textContent="\u203A"):(i.setAttribute("data-page",""),i.dataset.value=String(t.value),i.textContent=String(t.value),i.setAttribute("aria-label",`Page ${t.value}`)),this.#n(i,t,e),i}#n(t,e,i){e.type!=="ellipsis"&&(e.type==="prev"?i<=1?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0")):e.type==="next"?i>=this.total?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0")):(t.dataset.value=String(e.value),t.textContent=String(e.value),t.setAttribute("aria-label",`Page ${e.value}`),e.value===i?(t.setAttribute("data-active",""),t.setAttribute("aria-current","page")):(t.removeAttribute("data-active"),t.removeAttribute("aria-current"))))}#r=t=>{let e=t.target.closest("[data-prev], [data-next], [data-page]");if(!e||e.hasAttribute("disabled")||!this.#t.contains(e))return;let i;e.hasAttribute("data-prev")?i=this.page-1:e.hasAttribute("data-next")?i=this.page+1:e.hasAttribute("data-page")&&(i=Number(e.dataset.value)),!(i==null||i<1||i>this.total||i===this.page)&&(this.page=i,this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,detail:{page:this.page}})))}};w("pagination-ui",ir);var pM=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),mM={js:"javascript",md:"markdown",yml:"yaml"};function Km(s){if(!s)return"";let t=String(s).toLowerCase();return mM[t]??t}var qr=class s extends A{static formAssociated=!0;static properties={language:{type:String,default:"",reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},text:{type:String,default:"",reflect:!0},lineNumbers:{type:Boolean,default:!1,reflect:!0,attribute:"line-numbers"},editable:{type:Boolean,default:!1,reflect:!0},bare:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=0;#n=!1;#r=null;#o="";#a=null;#l=()=>this.#b();connected(){this.#s+=1,!this.inline&&!this.querySelector(":scope > pre")&&this.#u(),this.#t=this.querySelector(':scope > header [slot="copy"]'),this.#t&&this.#t.addEventListener("click",this.#l);let t=Km(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(pM.has(t)||this.editable)&&this.#c()}disconnected(){this.#s+=1,this.#e!=null&&(clearTimeout(this.#e),this.#e=null),this.#t&&(this.#t.removeEventListener("click",this.#l),this.#t=null),this.#i&&(this.#i.destroy(),this.#i=null)}#u(){let t=this.querySelector(":scope > template"),e=this.text?this.text.trim():t?s.#h(t.innerHTML):(this.textContent||"").trim();if(this.textContent="",!this.bare){let l=document.createElement("header"),h=document.createElement("span");h.setAttribute("slot","label"),h.textContent=this.language||"code",l.appendChild(h);let c=document.createElement("div");c.setAttribute("role","button"),c.setAttribute("tabindex","0"),c.setAttribute("slot","copy"),c.textContent="Copy",l.appendChild(c),this.appendChild(l)}let i=document.createElement("pre"),n=document.createElement("code"),r=Km(this.language),o=this.getAttribute("data-line-states");if(o!=null||r==="diff"){n.setAttribute("data-line-state-mode",""),this.lineNumbers&&n.setAttribute("data-line-numbers","");let l=o?.split(",").map(c=>c.trim())??null;e.split(`
174
174
  `).forEach((c,u)=>{let d="unchanged";if(l&&l[u])d=l[u];else if(r==="diff"){let m=c.charAt(0);m==="+"?d="added":m==="-"&&(d="removed")}let f=document.createElement("span");if(f.setAttribute("data-line-state",d),this.lineNumbers){let m=document.createElement("span");m.setAttribute("data-line-num",""),m.textContent=String(u+1),f.appendChild(m)}let p=document.createElement("span");p.setAttribute("data-line-body",""),p.textContent=c,f.appendChild(p),n.appendChild(f)})}else n.textContent=e;i.appendChild(n),this.appendChild(i)}static#h(t){let e=t.replace(/^\n+|\n+$/g,"");if(!e)return"";let i=e.split(`
175
175
  `),n=i.filter(o=>o.trim().length>0).map(o=>o.match(/^[ \t]*/)[0].length),r=n.length?Math.min(...n):0;return r>0?i.map(o=>o.slice(r)).join(`
176
- `):e}async#c(){if(this.#n||this.#i)return;let t=this.#s,e=Km(this.language);this.#n=!0;try{let i=await Promise.resolve().then(()=>(Hm(),Gm)),n=null;try{n=(await i.importWithTimeout(i.languages[e],`lang-${e}`))?.extension??null}catch(r){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"language",language:e,error:r}}))}if(t!==this.#s||!this.isConnected)return;this.#d(i,n,e)}catch(i){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"core",error:i}})),console.warn("[code-ui] CodeMirror failed to load; staying on static fallback.",i)}finally{this.#n=!1}}#d(t,e,i){let{EditorState:n,EditorView:r,Compartment:o,lineNumbers:a,placeholder:l,syntaxHighlighting:h,history:c,historyKeymap:u,defaultKeymap:d,indentWithTab:f,keymap:p,adiaBaseTheme:m,adiaHighlightStyle:O,lintGutter:g,jsonLinter:y}=t,v=this.querySelector(":scope > pre"),x=v?v.querySelector("code")?.textContent??"":"",S=this.text||x||"";this.#o=S;let $=document.createElement("div");$.setAttribute("data-cm-mount",""),v?v.replaceWith($):this.appendChild($);let k=[m,h(O)];this.editable&&k.push(c(),p.of([{key:"Mod-s",run:P=>(this.#m(P),!0)},...d,...u,f]),r.updateListener.of(P=>{if(!P.docChanged)return;let T=P.state.doc.toString();this.#g(T),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:T}}))}),r.domEventHandlers({focus:(P,T)=>(this.#r=T.state.doc.toString(),!1),blur:(P,T)=>{let C=T.state.doc.toString();return this.#r!==null&&C!==this.#r&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:C}})),this.#r=null,!1}})),this.#a=new o,k.push(this.#a.of(this.#f(r,n))),e&&k.push(e),this.lineNumbers&&k.push(a()),this.placeholder&&k.push(l(this.placeholder)),this.editable&&i==="json"&&k.push(y,g()),this.#i=new r({parent:$,state:n.create({doc:S,extensions:k})}),this.editable&&this.#g(S)}#f(t,e){return this.editable&&!this.disabled&&!this.readonly?[]:[t.editable.of(!1),e.readOnly.of(!0)]}async#p(){if(!this.#i||!this.#a)return;let t=await Promise.resolve().then(()=>(Hm(),Gm));this.#i.dispatch({effects:this.#a.reconfigure(this.#f(t.EditorView,t.EditorState))})}get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}#g(t){this.editable&&(t=t??this.value??"",this.internals.setFormValue(t),this.#O(t))}#O(t){return t=t??"",this.required&&!t.trim()?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),this.setAttribute("aria-invalid","true"),!1):(this.internals.setValidity({}),this.removeAttribute("aria-invalid"),!0)}formResetCallback(){this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:this.#o}}):this.text=this.#o}formDisabledCallback(t){this.disabled=t}formStateRestoreCallback(t,e){typeof t=="string"&&(this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:t}}):this.text=t)}#m(t){this.dispatchEvent(new CustomEvent("save",{bubbles:!0,cancelable:!0,detail:{value:t.state.doc.toString()}}))}get value(){return this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??this.text??""}set value(t){this.text=String(t??"")}#b(){let t=this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??"";t&&navigator.clipboard.writeText(t).then(()=>{let e=this.querySelector(':scope > header [slot="copy"]');if(!e)return;let i=e.textContent;e.textContent="Copied!",this.#e!=null&&clearTimeout(this.#e),this.#e=setTimeout(()=>{this.#e=null,e.textContent=i},1500)})}render(){let t=this.querySelector(':scope > header [slot="label"]');if(t&&this.language&&(t.textContent=this.language),this.#p(),!this.inline&&this.text!=="")if(this.#i){if(this.editable&&this.#i.hasFocus)return;let e=this.#i.state.doc.toString();e!==this.text&&this.#i.dispatch({changes:{from:0,to:e.length,insert:this.text}})}else{let e=this.querySelector(":scope > pre > code");e&&e.textContent!==this.text&&(e.textContent=this.text)}}};w("code-ui",qr);var Br=class extends A{static properties={divider:{type:Boolean,default:!1,reflect:!0},spacing:{type:String,default:"md",reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},selectedKey:{type:String,default:"",reflect:!0,attribute:"selected-key"}};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#r))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#r),this.#t=!1}render(){if(!this.selectable){for(let n of this.#e())n.removeAttribute("aria-selected"),n.removeAttribute("tabindex");return}let t=this.selectedKey||"",e=this.#e(),i=null;for(let n of e){let r=this.#i(n),o=r&&r===t;n.setAttribute("aria-selected",o?"true":"false"),n.setAttribute("tabindex",o?"0":"-1"),o&&(i=n)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#e(){return[...this.children].filter(t=>t.getAttribute&&t.getAttribute("role")==="listitem")}#i(t){return t.id||t.getAttribute("data-key")||""}#s(t,{focus:e=!1}={}){if(!this.selectable||!t)return;let i=this.selectedKey||"";t!==i&&(this.selectedKey=t,this.dispatchEvent(new CustomEvent("selection-change",{detail:{key:t,previousKey:i},bubbles:!0})),e&&[...this.#e()].find(r=>this.#i(r)===t)?.focus?.())}#n=t=>{if(!this.selectable)return;let e=t.target.closest?.('[role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#i(e);i&&this.#s(i)};#r=t=>{if(!this.selectable)return;let e=this.#e();if(!e.length)return;let i=document.activeElement,n=e.indexOf(i);if(n<0)return;let r=n;switch(t.key){case"ArrowDown":r=Math.min(e.length-1,n+1);break;case"ArrowUp":r=Math.max(0,n-1);break;case"Home":r=0;break;case"End":r=e.length-1;break;case"Enter":case" ":{t.preventDefault();let o=this.#i(e[n]);o&&this.#s(o);return}default:return}r!==n&&(t.preventDefault(),e[r]?.focus?.())}},zr=class extends A{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.#s()}#t(t){for(let e of this.children)if(e.matches(t))return e;return null}#e(t){return t.dataset.listStamped="1",t}#i(t){return t?.dataset?.listStamped==="1"}#s(){if(!this.#t('[slot="content"]')){if(this.icon){let t=this.#t('[slot="icon"]')||this.#t("icon-ui");t||(t=this.#e(document.createElement("icon-ui")),t.setAttribute("slot","icon"),this.prepend(t)),t.setAttribute("name",this.icon)}if(this.text){let t=this.#t('[slot="text"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","text"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.text)}if(this.description){let t=this.#t('[slot="description"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","description"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.description)}}}render(){let t=this.#t('[slot="icon"]');if(this.icon)if(t)this.#i(t)&&t.setAttribute("name",this.icon);else{let n=this.#e(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#i(t)&&t.remove();let e=this.#t('[slot="text"]');if(this.text)if(e)this.#i(e)&&(e.textContent=this.text);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","text"),n.textContent=this.text,this.appendChild(n)}else this.#i(e)&&e.remove();let i=this.#t('[slot="description"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","description"),n.textContent=this.description,this.appendChild(n)}else this.#i(i)&&i.remove()}};w("list-ui",Br),w("list-item-ui",zr);var jr=class extends A{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},gap:{type:Number,default:4,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=null;#n=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#d),this.addEventListener("keydown",this.#f))}render(){this.open?this.#o():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){if(this.#e)return this.#e;let t=document.createElement("div");return t.setAttribute("data-menu-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.addEventListener("toggle",this.#b),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#g),this.appendChild(t),this.#e=t,t}#o(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#r(),i=this.querySelectorAll(":scope > menu-item-ui, :scope > menu-divider-ui");for(let n of i)e.appendChild(n);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=Tt(t,e,{placement:this.placement,gap:this.gap}),this.#c&&(this.#c=!1,this.#n=requestAnimationFrame(()=>{this.#n=null,this.#u(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#O),document.addEventListener("keydown",this.#m,!0)})}#a(){this.#t?.(),this.#t=null;let t=this.#e;if(t){t.matches(":popover-open")&&t.hidePopover?.();let e=t.querySelectorAll("menu-item-ui, menu-divider-ui");for(let i of e)this.insertBefore(i,t)}this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#O),document.removeEventListener("keydown",this.#m,!0)}#l(){return Array.from(this.#e?.querySelectorAll("menu-item-ui")??[]).filter(t=>!t.disabled)}#u(t){let e=this.#l();if(!e.length)return;let i=(t+e.length)%e.length,n=e[i];n.setAttribute("tabindex","-1"),n.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#c=!1;#d=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#c=!1,this.open=!this.open)};#f=t=>{let e=this.querySelector('[slot="trigger"]');!e||!(t.target===e||e.contains(t.target))||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#c=!0,this.open=!0)};#p=t=>{let e=t.target.closest("menu-item-ui");!e||e.disabled||(this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.value,text:e.text}})),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0}))};#g=t=>{let e=this.#l();if(!e.length)return;let i=this.#h();switch(t.key){case"ArrowDown":t.preventDefault(),this.#u(i+1);break;case"ArrowUp":t.preventDefault(),this.#u(i-1);break;case"Home":t.preventDefault(),this.#u(0);break;case"End":t.preventDefault(),this.#u(e.length-1);break;case"Enter":case" ":{t.preventDefault(),(e[i]??e[0])?.click();break}}};#O=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#m=t=>{t.key==="Escape"&&this.open?(t.stopPropagation(),t.preventDefault(),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0})):t.key==="Tab"&&this.open&&(this.open=!1)};#b=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#a(),this.#e&&(this.#e.removeEventListener("toggle",this.#b),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#g)),this.#e=null,this.#i=!1}},Nr=class extends A{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","menuitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),this.#s(),this.#n()}#t(t){return t.dataset.menuItemStamped="1",t}#e(t){return t?.dataset?.menuItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}#s(){if(!this.#i('[slot="text"]')){if(this.icon&&!this.#i('[slot="icon"]')){let t=this.#t(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#t(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#n(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let i=this.#t(document.createElement("icon-ui"));i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text),this.#n()}},_r=class extends A{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}};w("menu-ui",jr),w("menu-item-ui",Nr),w("menu-divider-ui",_r);var zw="data-toolbar-spillover",gM="data-toolbar-spillover-menu",jw=8,Rc="data-toolbar-spillover-label";function Nw(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function OM(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function bM(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(Rc)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||OM(e.getAttribute("icon"));i&&(e.setAttribute(Rc,""),e.setAttribute("text",i))}}function yM(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(Rc)&&(e.removeAttribute(Rc),e.removeAttribute("text"))}function _w(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,n=parseFloat(e.marginRight)||0;return t.width+i+n}var Vr=class extends A{static properties={gap:{type:String,default:"sm",reflect:!0},align:{type:String,default:"start",reflect:!0},overflow:{type:String,default:"menu",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#o=!1;#a=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#u(),this.#t=new ResizeObserver(()=>this.#m()),this.#t.observe(this),this.#e=new MutationObserver(()=>{this.#r||this.#m()}),this.#b(),this.#m()}disconnected(){this.#a!=null&&(cancelAnimationFrame(this.#a),this.#a=null),this.#o=!1,this.#t?.disconnect(),this.#e?.disconnect(),this.#c(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}#u(){if(this.#i)return;let t=document.createElement("button-ui");t.setAttribute("icon","dots-three"),t.setAttribute("variant","ghost"),t.setAttribute("size","sm"),t.setAttribute(zw,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(gM,""),e.setAttribute("popover","manual"),e.setAttribute("role","menu"),t.addEventListener("click",this.#d),e.addEventListener("click",this.#f),e.addEventListener("toggle",this.#O),this.appendChild(t),this.appendChild(e),this.#i=t,this.#s=e}#h(){let t=this.#s;!t||t.matches(":popover-open")||(t.showPopover?.(),this.#n?.(),this.#n=Tt(this.#i,t,{placement:"bottom-end",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#p,!0),document.addEventListener("keydown",this.#g,!0)}))}#c(){this.#n?.(),this.#n=null,this.#s?.matches(":popover-open")&&this.#s.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#g,!0)}#d=t=>{t.stopPropagation(),this.#s?.matches(":popover-open")?this.#c():this.#h()};#f=t=>{let e=t.target.closest("button-ui");e&&(e.matches(`[${zw}]`)||queueMicrotask(()=>this.#c()))};#p=t=>{if(this.#i?.contains(t.target)||this.#s?.contains(t.target))return;let e=t.composedPath?.()||[];for(let i of e){if(i===document)break;if(i?.nodeType===1&&i.hasAttribute?.("popover"))return}this.#c()};#g=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#c(),this.#i?.focus?.({preventScroll:!0}))};#O=t=>{t.newState==="closed"&&(this.#n?.(),this.#n=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#g,!0))};#m(){this.#o||(this.#o=!0,this.#a=requestAnimationFrame(()=>{this.#a=null,this.#o=!1,this.isConnected&&this.#S()}))}#b(){this.#e?.observe(this,{childList:!0})}#v(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#S(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#r=!0,this.#v();try{for(;e.firstChild;)yM(e.firstChild),this.insertBefore(e.firstChild,t);let i=0;for(let y of this.children)y===t||y===e||(y.dataset.toolbarOrder==null&&(y.dataset.toolbarOrder=String(i)),i+=1);let n=Array.from(this.children).filter(y=>y!==t&&y!==e).sort((y,v)=>Number(y.dataset.toolbarOrder)-Number(v.dataset.toolbarOrder));for(let y of n)this.insertBefore(y,t);let r=n;for(let y of r)y.hidden=!1;t.hidden=!0;let o=getComputedStyle(this),a=parseFloat(o.paddingLeft)||0,l=parseFloat(o.paddingRight)||0,h=parseFloat(o.columnGap||o.gap)||0,c=this.clientWidth-a-l,u=r.map(y=>_w(y)),d=u.reduce((y,v)=>y+v,0)+Math.max(0,r.length-1)*h,f=d<=c-jw;if(this.overflow==="none"||f)return;t.hidden=!1;let p=_w(t),m=r.length,O=d;for(;m>0&&!(O+h+p<=c-jw);)m-=1,O-=u[m],m>0&&(O-=h);for(;m>0&&Nw(r[m-1]);)m-=1;let g=r.slice(m);for(let y of g){if(Nw(y)){y.hidden=!0;continue}bM(y),e.appendChild(y)}e.firstElementChild||(t.hidden=!0)}finally{this.#r=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#b()})}}}},Wr=class extends A{static template=()=>null;connected(){this.setAttribute("role","group")}};w("toolbar-ui",Vr),w("toolbar-group-ui",Wr);var Yr=class extends A{static properties={variant:{type:String,default:"primary",reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},divider:{type:Boolean,default:!1,reflect:!0},heading:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;connected(){this.setAttribute("role","navigation"),this.heading&&this.setAttribute("aria-label",this.heading),this.addEventListener("click",this.#i),this.variant!=="section"&&(this.#t=new ResizeObserver(()=>this.#e()),this.#t.observe(this))}render(){this.heading?this.setAttribute("aria-label",this.heading):this.removeAttribute("aria-label"),this.variant!=="section"&&this.#e()}#e(){let t=this.collapsed||this.getBoundingClientRect().width<=96;for(let e of this.querySelectorAll(":scope > nav-group-ui")){let i=e.querySelector(':scope > [slot="header"]');i&&(i.title=t?e.text:"")}for(let e of this.querySelectorAll(":scope > nav-item-ui"))e.title=t?e.text:""}get selectedItem(){return this.querySelector("nav-item-ui[selected]")}select(t){let e=this.selectedItem;e&&e!==t&&e.removeAttribute("selected"),t&&(t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("nav-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value}})))}toggle(){this.variant!=="section"&&(this.collapsed=!this.collapsed)}#i=t=>{let e=t.target.closest("nav-item-ui");if(e&&this.contains(e)){if(e.disabled)return;this.select(e),this.#s();return}if(this.variant==="section")return;let i=t.target.closest("nav-group-ui");if(i&&this.contains(i))if(this.collapsed||this.getBoundingClientRect().width<=96)i.showPopover?.();else{let r=i.querySelector(':scope > [slot="header"]');r&&(t.target===r||r.contains(t.target))&&(i.open=!i.open)}};#s(){this.style.pointerEvents="none",requestAnimationFrame(()=>{this.style.pointerEvents=""})}disconnected(){this.removeEventListener("click",this.#i),this.#t?.disconnect(),this.#t=null}};w("nav-ui",Yr);var Ur=class extends A{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},variant:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=t=>{this.collapsible&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!this.open,this.dispatchEvent(new CustomEvent("group-toggle",{bubbles:!0,detail:{text:this.text,open:this.open}})))};connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="header"]')?this.#i=this.querySelector(':scope > [slot="header"]'):(this.#i=document.createElement("div"),this.#i.setAttribute("slot","header"),this.#i.setAttribute("tabindex","0"),this.#i.innerHTML=`
176
+ `):e}async#c(){if(this.#n||this.#i)return;let t=this.#s,e=Km(this.language);this.#n=!0;try{let i=await Promise.resolve().then(()=>(Hm(),Gm)),n=null;try{n=(await i.importWithTimeout(i.languages[e],`lang-${e}`))?.extension??null}catch(r){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"language",language:e,error:r}}))}if(t!==this.#s||!this.isConnected)return;this.#d(i,n,e)}catch(i){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"core",error:i}})),console.warn("[code-ui] CodeMirror failed to load; staying on static fallback.",i)}finally{this.#n=!1}}#d(t,e,i){let{EditorState:n,EditorView:r,Compartment:o,lineNumbers:a,placeholder:l,syntaxHighlighting:h,history:c,historyKeymap:u,defaultKeymap:d,indentWithTab:f,keymap:p,adiaBaseTheme:m,adiaHighlightStyle:O,lintGutter:g,jsonLinter:y}=t,v=this.querySelector(":scope > pre"),x=v?v.querySelector("code")?.textContent??"":"",S=this.text||x||"";this.#o=S;let $=document.createElement("div");$.setAttribute("data-cm-mount",""),v?v.replaceWith($):this.appendChild($);let k=[m,h(O)];this.editable&&k.push(c(),p.of([{key:"Mod-s",run:P=>(this.#m(P),!0)},...d,...u,f]),r.updateListener.of(P=>{if(!P.docChanged)return;let T=P.state.doc.toString();this.#g(T),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:T}}))}),r.domEventHandlers({focus:(P,T)=>(this.#r=T.state.doc.toString(),!1),blur:(P,T)=>{let C=T.state.doc.toString();return this.#r!==null&&C!==this.#r&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:C}})),this.#r=null,!1}})),this.#a=new o,k.push(this.#a.of(this.#f(r,n))),e&&k.push(e),this.lineNumbers&&k.push(a()),this.placeholder&&k.push(l(this.placeholder)),this.editable&&i==="json"&&k.push(y,g()),this.#i=new r({parent:$,state:n.create({doc:S,extensions:k})}),this.editable&&this.#g(S)}#f(t,e){return this.editable&&!this.disabled&&!this.readonly?[]:[t.editable.of(!1),e.readOnly.of(!0)]}async#p(){if(!this.#i||!this.#a)return;let t=await Promise.resolve().then(()=>(Hm(),Gm));this.#i.dispatch({effects:this.#a.reconfigure(this.#f(t.EditorView,t.EditorState))})}get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}#g(t){this.editable&&(t=t??this.value??"",this.internals.setFormValue(t),this.#O(t))}#O(t){return t=t??"",this.required&&!t.trim()?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),this.setAttribute("aria-invalid","true"),!1):(this.internals.setValidity({}),this.removeAttribute("aria-invalid"),!0)}formResetCallback(){this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:this.#o}}):this.text=this.#o}formDisabledCallback(t){this.disabled=t}formStateRestoreCallback(t,e){typeof t=="string"&&(this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:t}}):this.text=t)}#m(t){this.dispatchEvent(new CustomEvent("save",{bubbles:!0,cancelable:!0,detail:{value:t.state.doc.toString()}}))}get value(){return this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??this.text??""}set value(t){this.text=String(t??"")}#b(){let t=this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??"";t&&navigator.clipboard.writeText(t).then(()=>{let e=this.querySelector(':scope > header [slot="copy"]');if(!e)return;let i=e.textContent;e.textContent="Copied!",this.#e!=null&&clearTimeout(this.#e),this.#e=setTimeout(()=>{this.#e=null,e.textContent=i},1500)})}render(){let t=this.querySelector(':scope > header [slot="label"]');if(t&&this.language&&(t.textContent=this.language),this.#p(),!this.inline&&this.text!=="")if(this.#i){if(this.editable&&this.#i.hasFocus)return;let e=this.#i.state.doc.toString();e!==this.text&&this.#i.dispatch({changes:{from:0,to:e.length,insert:this.text}})}else{let e=this.querySelector(":scope > pre > code");e&&e.textContent!==this.text&&(e.textContent=this.text)}}};w("code-ui",qr);var Br=class extends A{static properties={divider:{type:Boolean,default:!1,reflect:!0},spacing:{type:String,default:"md",reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},selectedKey:{type:String,default:"",reflect:!0,attribute:"selected-key"}};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#r))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#r),this.#t=!1}render(){if(!this.selectable){for(let n of this.#e())n.removeAttribute("aria-selected"),n.removeAttribute("tabindex");return}let t=this.selectedKey||"",e=this.#e(),i=null;for(let n of e){let r=this.#i(n),o=r&&r===t;n.setAttribute("aria-selected",o?"true":"false"),n.setAttribute("tabindex",o?"0":"-1"),o&&(i=n)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#e(){return[...this.children].filter(t=>t.getAttribute&&t.getAttribute("role")==="listitem")}#i(t){return t.id||t.getAttribute("data-key")||""}#s(t,{focus:e=!1}={}){if(!this.selectable||!t)return;let i=this.selectedKey||"";t!==i&&(this.selectedKey=t,this.dispatchEvent(new CustomEvent("selection-change",{detail:{key:t,previousKey:i},bubbles:!0})),e&&[...this.#e()].find(r=>this.#i(r)===t)?.focus?.())}#n=t=>{if(!this.selectable)return;let e=t.target.closest?.('[role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#i(e);i&&this.#s(i)};#r=t=>{if(!this.selectable)return;let e=this.#e();if(!e.length)return;let i=document.activeElement,n=e.indexOf(i);if(n<0)return;let r=n;switch(t.key){case"ArrowDown":r=Math.min(e.length-1,n+1);break;case"ArrowUp":r=Math.max(0,n-1);break;case"Home":r=0;break;case"End":r=e.length-1;break;case"Enter":case" ":{t.preventDefault();let o=this.#i(e[n]);o&&this.#s(o);return}default:return}r!==n&&(t.preventDefault(),e[r]?.focus?.())}},zr=class extends A{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.#s()}#t(t){for(let e of this.children)if(e.matches(t))return e;return null}#e(t){return t.dataset.listStamped="1",t}#i(t){return t?.dataset?.listStamped==="1"}#s(){if(!this.#t('[slot="content"]')){if(this.icon){let t=this.#t('[slot="icon"]')||this.#t("icon-ui");t||(t=this.#e(document.createElement("icon-ui")),t.setAttribute("slot","icon"),this.prepend(t)),t.setAttribute("name",this.icon)}if(this.text){let t=this.#t('[slot="text"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","text"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.text)}if(this.description){let t=this.#t('[slot="description"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","description"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.description)}}}render(){let t=this.#t('[slot="icon"]');if(this.icon)if(t)this.#i(t)&&t.setAttribute("name",this.icon);else{let n=this.#e(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#i(t)&&t.remove();let e=this.#t('[slot="text"]');if(this.text)if(e)this.#i(e)&&(e.textContent=this.text);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","text"),n.textContent=this.text,this.appendChild(n)}else this.#i(e)&&e.remove();let i=this.#t('[slot="description"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","description"),n.textContent=this.description,this.appendChild(n)}else this.#i(i)&&i.remove()}};w("list-ui",Br),w("list-item-ui",zr);var jr=class extends A{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},gap:{type:Number,default:4,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=null;#n=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#d),this.addEventListener("keydown",this.#f))}render(){this.open?this.#o():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){if(this.#e)return this.#e;let t=document.createElement("div");return t.setAttribute("data-menu-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.addEventListener("toggle",this.#b),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#g),this.appendChild(t),this.#e=t,t}#o(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#r(),i=this.querySelectorAll(":scope > menu-item-ui, :scope > menu-divider-ui");for(let n of i)e.appendChild(n);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=Tt(t,e,{placement:this.placement,gap:this.gap}),this.#c&&(this.#c=!1,this.#n=requestAnimationFrame(()=>{this.#n=null,this.#u(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#O),document.addEventListener("keydown",this.#m,!0)})}#a(){this.#t?.(),this.#t=null;let t=this.#e;if(t){t.matches(":popover-open")&&t.hidePopover?.();let e=t.querySelectorAll("menu-item-ui, menu-divider-ui");for(let i of e)this.insertBefore(i,t)}this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#O),document.removeEventListener("keydown",this.#m,!0)}#l(){return Array.from(this.#e?.querySelectorAll("menu-item-ui")??[]).filter(t=>!t.disabled)}#u(t){let e=this.#l();if(!e.length)return;let i=(t+e.length)%e.length,n=e[i];n.setAttribute("tabindex","-1"),n.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#c=!1;#d=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#c=!1,this.open=!this.open)};#f=t=>{let e=this.querySelector('[slot="trigger"]');!e||!(t.target===e||e.contains(t.target))||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#c=!0,this.open=!0)};#p=t=>{let e=t.target.closest("menu-item-ui");!e||e.disabled||(this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.value,text:e.text}})),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0}))};#g=t=>{let e=this.#l();if(!e.length)return;let i=this.#h();switch(t.key){case"ArrowDown":t.preventDefault(),this.#u(i+1);break;case"ArrowUp":t.preventDefault(),this.#u(i-1);break;case"Home":t.preventDefault(),this.#u(0);break;case"End":t.preventDefault(),this.#u(e.length-1);break;case"Enter":case" ":{t.preventDefault(),(e[i]??e[0])?.click();break}}};#O=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#m=t=>{t.key==="Escape"&&this.open?(t.stopPropagation(),t.preventDefault(),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0})):t.key==="Tab"&&this.open&&(this.open=!1)};#b=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#a(),this.#e&&(this.#e.removeEventListener("toggle",this.#b),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#g)),this.#e=null,this.#i=!1}},Nr=class extends A{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","menuitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),this.#s(),this.#n()}#t(t){return t.dataset.menuItemStamped="1",t}#e(t){return t?.dataset?.menuItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}#s(){if(!this.#i('[slot="text"]')){if(this.icon&&!this.#i('[slot="icon"]')){let t=this.#t(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#t(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#n(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let i=this.#t(document.createElement("icon-ui"));i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text),this.#n()}},_r=class extends A{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}};w("menu-ui",jr),w("menu-item-ui",Nr),w("menu-divider-ui",_r);var zw="data-toolbar-spillover",gM="data-toolbar-spillover-menu",jw=8,Rc="data-toolbar-spillover-label";function Nw(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function OM(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function bM(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(Rc)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||OM(e.getAttribute("icon"));i&&(e.setAttribute(Rc,""),e.setAttribute("text",i))}}function yM(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(Rc)&&(e.removeAttribute(Rc),e.removeAttribute("text"))}function _w(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,n=parseFloat(e.marginRight)||0;return t.width+i+n}var Vr=class extends A{static properties={gap:{type:String,default:"sm",reflect:!0},align:{type:String,default:"start",reflect:!0},overflow:{type:String,default:"menu",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#o=!1;#a=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#u(),this.#t=new ResizeObserver(()=>this.#m()),this.#t.observe(this),this.#e=new MutationObserver(()=>{this.#r||this.#m()}),this.#b(),this.#m()}disconnected(){this.#a!=null&&(cancelAnimationFrame(this.#a),this.#a=null),this.#o=!1,this.#t?.disconnect(),this.#e?.disconnect(),this.#c(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}#u(){if(this.#i)return;let t=document.createElement("button-ui");t.setAttribute("icon","dots-three"),t.setAttribute("variant","ghost"),t.setAttribute("size","sm"),t.setAttribute(zw,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(gM,""),e.setAttribute("popover","manual"),e.setAttribute("role","menu"),t.addEventListener("click",this.#d),e.addEventListener("click",this.#f),e.addEventListener("toggle",this.#O),this.appendChild(t),this.appendChild(e),this.#i=t,this.#s=e}#h(){let t=this.#s;!t||t.matches(":popover-open")||(t.showPopover?.(),this.#n?.(),this.#n=Tt(this.#i,t,{placement:"bottom-end",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#p,!0),document.addEventListener("keydown",this.#g,!0)}))}#c(){this.#n?.(),this.#n=null,this.#s?.matches(":popover-open")&&this.#s.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#g,!0)}#d=t=>{t.stopPropagation(),this.#s?.matches(":popover-open")?this.#c():this.#h()};#f=t=>{let e=t.target.closest("button-ui");e&&(e.matches(`[${zw}]`)||queueMicrotask(()=>this.#c()))};#p=t=>{if(this.#i?.contains(t.target)||this.#s?.contains(t.target))return;let e=t.composedPath?.()||[];for(let i of e){if(i===document)break;if(i?.nodeType===1&&i.hasAttribute?.("popover"))return}this.#c()};#g=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#c(),this.#i?.focus?.({preventScroll:!0}))};#O=t=>{t.newState==="closed"&&(this.#n?.(),this.#n=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#g,!0))};#m(){this.#o||(this.#o=!0,this.#a=requestAnimationFrame(()=>{this.#a=null,this.#o=!1,this.isConnected&&this.#S()}))}#b(){this.#e?.observe(this,{childList:!0})}#x(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#S(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#r=!0,this.#x();try{for(;e.firstChild;)yM(e.firstChild),this.insertBefore(e.firstChild,t);let i=0;for(let y of this.children)y===t||y===e||(y.dataset.toolbarOrder==null&&(y.dataset.toolbarOrder=String(i)),i+=1);let n=Array.from(this.children).filter(y=>y!==t&&y!==e).sort((y,v)=>Number(y.dataset.toolbarOrder)-Number(v.dataset.toolbarOrder));for(let y of n)this.insertBefore(y,t);let r=n;for(let y of r)y.hidden=!1;t.hidden=!0;let o=getComputedStyle(this),a=parseFloat(o.paddingLeft)||0,l=parseFloat(o.paddingRight)||0,h=parseFloat(o.columnGap||o.gap)||0,c=this.clientWidth-a-l,u=r.map(y=>_w(y)),d=u.reduce((y,v)=>y+v,0)+Math.max(0,r.length-1)*h,f=d<=c-jw;if(this.overflow==="none"||f)return;t.hidden=!1;let p=_w(t),m=r.length,O=d;for(;m>0&&!(O+h+p<=c-jw);)m-=1,O-=u[m],m>0&&(O-=h);for(;m>0&&Nw(r[m-1]);)m-=1;let g=r.slice(m);for(let y of g){if(Nw(y)){y.hidden=!0;continue}bM(y),e.appendChild(y)}e.firstElementChild||(t.hidden=!0)}finally{this.#r=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#b()})}}}},Wr=class extends A{static template=()=>null;connected(){this.setAttribute("role","group")}};w("toolbar-ui",Vr),w("toolbar-group-ui",Wr);var Yr=class extends A{static properties={variant:{type:String,default:"primary",reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},divider:{type:Boolean,default:!1,reflect:!0},heading:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;connected(){this.setAttribute("role","navigation"),this.heading&&this.setAttribute("aria-label",this.heading),this.addEventListener("click",this.#i),this.variant!=="section"&&(this.#t=new ResizeObserver(()=>this.#e()),this.#t.observe(this))}render(){this.heading?this.setAttribute("aria-label",this.heading):this.removeAttribute("aria-label"),this.variant!=="section"&&this.#e()}#e(){let t=this.collapsed||this.getBoundingClientRect().width<=96;for(let e of this.querySelectorAll(":scope > nav-group-ui")){let i=e.querySelector(':scope > [slot="header"]');i&&(i.title=t?e.text:"")}for(let e of this.querySelectorAll(":scope > nav-item-ui"))e.title=t?e.text:""}get selectedItem(){return this.querySelector("nav-item-ui[selected]")}select(t){let e=this.selectedItem;e&&e!==t&&e.removeAttribute("selected"),t&&(t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("nav-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value}})))}toggle(){this.variant!=="section"&&(this.collapsed=!this.collapsed)}#i=t=>{let e=t.target.closest("nav-item-ui");if(e&&this.contains(e)){if(e.disabled)return;this.select(e),this.#s();return}if(this.variant==="section")return;let i=t.target.closest("nav-group-ui");if(i&&this.contains(i))if(this.collapsed||this.getBoundingClientRect().width<=96)i.showPopover?.();else{let r=i.querySelector(':scope > [slot="header"]');r&&(t.target===r||r.contains(t.target))&&(i.open=!i.open)}};#s(){this.style.pointerEvents="none",requestAnimationFrame(()=>{this.style.pointerEvents=""})}disconnected(){this.removeEventListener("click",this.#i),this.#t?.disconnect(),this.#t=null}};w("nav-ui",Yr);var Ur=class extends A{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},variant:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=t=>{this.collapsible&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!this.open,this.dispatchEvent(new CustomEvent("group-toggle",{bubbles:!0,detail:{text:this.text,open:this.open}})))};connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="header"]')?this.#i=this.querySelector(':scope > [slot="header"]'):(this.#i=document.createElement("div"),this.#i.setAttribute("slot","header"),this.#i.setAttribute("tabindex","0"),this.#i.innerHTML=`
177
177
  <span slot="icon">${this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:""}</span>
178
178
  <span slot="text">${this.text}</span>
179
179
  ${this.badge?`<span slot="badge">${this.badge}</span>`:""}
@@ -202,7 +202,7 @@ Correct shape for <chart-ui x="label" y="value">:
202
202
  <text-ui slot="label" data-demo-toggle-label></text-ui>
203
203
  <switch-ui slot="switch" data-demo-toggle-switch></switch-ui>
204
204
  </row-ui>
205
- `};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;connected(){if(this.state)this.state=this.state==="on"?"on":"off";else{let t=this.initial==="on"?"on":"off";this.state=t}this.#t=this.ensure("bar"),this.#e=this.#t.querySelector("[data-demo-toggle-switch]"),this.#i=this.#t.querySelector("[data-demo-toggle-label]"),this.#s||(this.#s=!0,this.#e.addEventListener("change",this.#n))}disconnected(){this.#e&&this.#e.removeEventListener("change",this.#n),this.#t=null,this.#e=null,this.#i=null,this.#s=!1}render(){if(!this.#t)return;let t=this.state==="on";this.#e.checked!==t&&(this.#e.checked=t),this.#i&&(this.#i.textContent=t?this.labelOn:this.labelOff)}toggle(){this.state=this.state==="on"?"off":"on",this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{state:this.state}}))}#n=t=>{t.stopPropagation();let e=this.#e.checked?"on":"off";e!==this.state&&(this.state=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{state:this.state}})))}};w("demo-toggle-ui",co);var uo=class extends A{static properties={src:{type:String,default:"",reflect:!0},markdown:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e="";#i="";connected(){this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-richtext-body",""),this.appendChild(this.#t))}render(){if(this.src&&this.src!==this.#e){this.#e=this.src,this.#i="",this.#s();return}this.markdown&&this.markdown!==this.#i&&(this.#i=this.markdown,this.#e="",this.#t.innerHTML=hn(this.markdown))}async#s(){try{let t=await fetch(this.src);if(!this.isConnected)return;if(!t.ok){this.#t.innerHTML=`<p>Failed to load: ${this.src}</p>`;return}let e=await t.text();if(!this.isConnected)return;this.#t.innerHTML=hn(e)}catch(t){if(!this.isConnected)return;this.#t.innerHTML=`<p>Error: ${t.message}</p>`}}};w("richtext-ui",uo);var fo=class extends A{static properties={pace:{type:Number,default:0,reflect:!0},hideCursor:{type:Boolean,default:!1,reflect:!0,attribute:"hide-cursor"},streaming:{type:Boolean,default:!1,reflect:!0}};#t=null;#e=null;#i="";get tokens(){return this.#t}set tokens(t){this.#t=t,t&&this.#s(t)}static template=()=>null;async#s(t){this.#e?.abort(),this.#e=new AbortController;let e=this.#e.signal;this.#i="",this.textContent="",this.streaming=!0,this.dispatchEvent(new Event("stream-start",{bubbles:!0}));try{for await(let i of t){if(e.aborted)break;if(this.#i+=i,this.pace>0)for(let n of i){if(e.aborted)break;this.textContent+=n,await new Promise(r=>setTimeout(r,this.pace))}else this.textContent=this.#i}}catch(i){e.aborted||this.dispatchEvent(new CustomEvent("stream-error",{bubbles:!0,detail:{error:i}}))}e.aborted||(this.streaming=!1,this.dispatchEvent(new Event("stream-end",{bubbles:!0})))}stop(){this.#e?.abort(),this.streaming=!1}clear(){this.stop(),this.#i="",this.textContent=""}disconnected(){this.stop()}};w("stream-ui",fo);var Et=new Map([["Row","row-ui"],["Column","col-ui"],["List","list-ui"],["ListItem","list-item-ui"],["Grid","grid-ui"],["Stack","stack-ui"],["Block","block-ui"],["Text","text-ui"],["Image","image-ui"],["Icon","icon-ui"],["Divider","divider-ui"],["Badge","badge-ui"],["Avatar","avatar-ui"],["AvatarGroup","avatar-group-ui"],["Progress","progress-ui"],["Skeleton","skeleton-ui"],["Code","code-ui"],["Stat","stat-ui"],["EmptyState","empty-state-ui"],["Input","input-ui"],["TextField","input-ui"],["TextArea","textarea-ui"],["Field","field-ui"],["CheckBox","check-ui"],["Toggle","switch-ui"],["Switch","switch-ui"],["Slider","slider-ui"],["Range","range-ui"],["Rating","rating-ui"],["ChoicePicker","select-ui"],["Select","select-ui"],["Radio","radio-ui"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorPicker","color-picker-ui"],["Upload","upload-ui"],["OtpInput","otp-input-ui"],["Button","button-ui"],["LoadingIndicator","progress-ui"],["ErrorContainer","card-ui"],["Card","card-ui"],["Tabs","tabs-ui"],["Tab","tab-ui"],["Panel","pane-ui"],["Pane","pane-ui"],["Modal","modal-ui"],["Dialog","modal-ui"],["Drawer","drawer-ui"],["Toast","toast-ui"],["Popover","popover-ui"],["Accordion","accordion-ui"],["AccordionItem","accordion-item-ui"],["Alert","alert-ui"],["Tooltip","tooltip-ui"],["Menu","menu-ui"],["Section","section"],["Header","header"],["Footer","footer"],["Stream","stream-ui"],["Table","table-ui"],["Chart","chart-ui"],["Embed","embed-ui"],["Swiper","swiper-ui"],["Slideshow","swiper-ui"],["Carousel","swiper-ui"],["Breadcrumb","breadcrumb-ui"],["Link","link-ui"],["Anchor","link-ui"],["Hyperlink","link-ui"],["NavLink","link-ui"],["Nav","nav-ui"],["NavGroup","nav-group-ui"],["NavItem","nav-item-ui"],["Noodles","noodles-ui"],["Pagination","pagination-ui"],["SegmentedControl","segmented-ui"],["Segment","segment-ui"],["ToggleGroup","toggle-group-ui"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-ui"],["Tag","tag-ui"],["Timeline","timeline-ui"],["TimelineItem","timeline-item-ui"],["button-ui","button-ui"],["card-ui","card-ui"],["text-ui","text-ui"],["input-ui","input-ui"],["text-field-ui","input-ui"],["select-ui","select-ui"],["toggle-ui","switch-ui"],["check-ui","check-ui"],["slider-ui","slider-ui"],["badge-ui","badge-ui"],["avatar-ui","avatar-ui"],["icon-ui","icon-ui"],["image-ui","image-ui"],["divider-ui","divider-ui"],["progress-ui","progress-ui"],["skeleton-ui","skeleton-ui"],["tabs-ui","tabs-ui"],["tab-ui","tab-ui"],["modal-ui","modal-ui"],["dialog-ui","modal-ui"],["drawer-ui","drawer-ui"],["toast-ui","toast-ui"],["popover-ui","popover-ui"],["panel-ui","pane-ui"],["accordion-ui","accordion-ui"],["alert-ui","alert-ui"],["tooltip-ui","tooltip-ui"],["menu-ui","menu-ui"],["table-ui","table-ui"],["chart-ui","chart-ui"],["code-ui","code-ui"],["textarea-ui","textarea-ui"],["radio-ui","radio-ui"],["tag-ui","tag-ui"],["search-ui","search-ui"],["upload-ui","upload-ui"],["breadcrumb-ui","breadcrumb-ui"],["link-ui","link-ui"],["nav-ui","nav-ui"],["noodles-ui","noodles-ui"],["pagination-ui","pagination-ui"],["segmented-control-ui","segmented-ui"],["segment-ui","segment-ui"],["command-ui","command-ui"],["calendar-picker-ui","calendar-picker-ui"],["color-picker-ui","color-picker-ui"],["kbd-ui","kbd-ui"],["toolbar-ui","toolbar-ui"],["otp-input-ui","otp-input-ui"],["embed-ui","embed-ui"],["stream-ui","stream-ui"],["row-ui","row-ui"],["col-ui","col-ui"],["grid-ui","grid-ui"],["stack-ui","stack-ui"],["block-ui","block-ui"],["list-ui","list-ui"],["range-ui","range-ui"],["datetime-ui","calendar-picker-ui"],["timeline-ui","timeline-ui"],["timeline-item-ui","timeline-item-ui"],["avatar-group-ui","avatar-group-ui"],["Keyboard","kbd-ui"],["DatePicker","calendar-picker-ui"],["CommandPalette","command-ui"],["FormContainer","form"],["Sidebar","admin-sidebar"],["Segmented","segmented-ui"],["OTP","otp-input-ui"],["Textarea","textarea-ui"],["RichText","richtext-ui"],["Richtext","richtext-ui"],["DescriptionList","description-list-ui"],["ActionItem","action-item-ui"],["ActionList","action-list-ui"],["Inspector","inspector-ui"],["Heatmap","heatmap-ui"],["ChatThread","chat-thread"],["ChatInput","chat-input-ui"],["OptionCard","option-card-ui"],["Option","option-card-ui"],["AdminCommand","admin-command"],["AdminContent","admin-content"],["AdminPage","admin-page"],["AdminPageBody","admin-page-body"],["AdminPageHeader","admin-page-header"],["AdminScroll","admin-scroll"],["AdminShell","admin-shell"],["AdminSidebar","admin-sidebar"],["AdminStatusbar","admin-statusbar"],["AdminTopbar","admin-topbar"],["ChatComposer","chat-composer"],["ChatEmpty","chat-empty"],["ChatHeader","chat-header"],["ChatShell","chat-shell"],["ChatSidebar","chat-sidebar"],["ChatStatus","chat-status"],["EditorCanvas","editor-canvas"],["EditorCanvasEmpty","editor-canvas-empty"],["EditorShell","editor-shell"],["EditorSidebar","editor-sidebar"],["EditorStatusbar","editor-statusbar"],["EditorToolbar","editor-toolbar"],["GenRoot","gen-root"],["SimpleContent","simple-content"],["SimpleHero","simple-hero"],["SimpleShell","simple-shell"],["ThemePanel","theme-panel"]]);function Xc(s){return Et.get(s)||null}function Fw(s,t){Et.set(s,t)}var Yi=class s{#t;#e;#i=new Map;#s=new Map;#n=new Map;#r=[];#o=null;#a=!1;constructor(t,e=Et,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#a=i}process(t){t&&(this.#a?(this.#r.push(t),this.#o===null&&(this.#o=requestAnimationFrame(()=>this.#l()))):this.#u(t))}#l(){this.#o=null;let t=this.#r.splice(0);for(let e of t)this.#u(e)}#u(t){switch(t.type||t.messageType){case"createSurface":this.#d(t);break;case"updateComponents":this.#f(t);break;case"updateDataModel":this.#k(t);break;case"wireComponents":this.#c(t);break;case"deleteSurface":this.#y(t);break;case"meta":break;default:console.warn("A2UI: unknown message type",t.type)}}#h=null;async#c(t){if(!this.#h){let{WiringEngine:e}=await Promise.resolve().then(()=>(mg(),fk));this.#h=new e({updateDataModel:(i,n,r)=>{this.#k({surfaceId:i,path:n,value:r})},getElement:(i,n)=>this.#i.get(i)?.elements.get(n)||null})}await this.#h.process(t)}async processStream(t){for await(let e of t)this.process(e)}#d({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t))return;let n=document.createElement("div");n.setAttribute("data-a2ui-surface",t),e&&n.setAttribute("data-catalog",e),this.#t.appendChild(n),this.#i.set(t,{root:n,rootId:typeof i=="string"&&i?i:"root",elements:new Map,dataModel:{},bindings:new Map})}#f({surfaceId:t,components:e}){let i=this.#i.get(t);i||(i={root:this.#t,rootId:"root",elements:new Map,dataModel:{},bindings:new Map},this.#i.set(t,i));for(let l of e)if(!(!l.id&&l.id!==0)){if(l.component==="ContextBindings"){i.contextBindings=l;continue}try{let h=i.elements.get(l.id),c=l.component==="Text"?this.#b(l.variant,l):Xc(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-id",l.id),h.setAttribute("data-a2ui-unknown",l.component),h.textContent=`[unknown: ${l.component}]`,i.elements.set(l.id,h),this.#s.set(l.id,h));continue}if(!h)h=document.createElement(c),h.setAttribute("data-a2ui-id",l.id),i.elements.set(l.id,h),this.#s.set(l.id,h);else if(h.localName!==c){let d=document.createElement(c);d.setAttribute("data-a2ui-id",l.id),h.replaceWith(d),h=d,i.elements.set(l.id,h),this.#s.set(l.id,h)}l._surfaceId=t,Object.values(l).some(d=>d&&typeof d=="object"&&d.path)&&i.bindings.set(l.id,l),this.#v(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}let n=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])n.set(h,l.id);l.child&&n.set(l.child,l.id)}let r=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=n.get(u)}return!1};for(let l of e){let h=i.elements.get(l.id);if(h)try{let c=Array.isArray(l.children)?l.children:[];for(let u of c){if(u===l.id||r(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!r(l.id,l.child)){let u=i.elements.get(l.child);u&&u.parentElement!==h&&h.appendChild(u)}}catch(c){console.warn(`A2UI: tree build failed for "${l.id}":`,c.message)}}let o=i.rootId??"root";if(e.find(l=>l.id===o)){let l=i.elements.get(o);l&&l.parentElement!==i.root&&i.root.appendChild(l)}}static#p=new Set(["data","columns","options","itemRenderer","textContent"]);static#g=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui"]);static#O={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};static#m=new Set(["autocomplete","autofocus","autocapitalize","autocorrect","inputmode","enterkeyhint","spellcheck","maxlength","minlength","readonly","novalidate","formnovalidate","formaction","formenctype","formmethod","formtarget","multiple","pattern","placeholder","required","tabindex","accesskey","autoplay","autopictureinpicture","controls","crossorigin","disablepictureinpicture","disableremoteplayback","loop","muted","playsinline","preload","srcset","srcdoc","srclang","sizes","loading","decoding","fetchpriority","ismap","usemap","hreflang","referrerpolicy","download","contenteditable","contextmenu","draggable","dirname","colspan","rowspan","headers","allowfullscreen","allowpaymentrequest","itemid","itemprop","itemref","itemscope","itemtype","nomodule","nonce"]);#b(t,e){return!e?.slot&&s.#O[t]?s.#O[t]:"text-ui"}#v(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#O[e.variant]&&i.add("variant");let n=this.#n.get(e.id),r={};for(let[o,a]of Object.entries(e)){if(i.has(o))continue;let l=a&&typeof a=="object"&&a.path,h=this.#x(a,e._surfaceId);if(r[o]=h,!(n&&Object.is(n[o],h))){if(o==="style"&&typeof h=="string"){t.style.cssText=h;continue}if(s.#p.has(o)&&h!=null){if(o==="textContent"&&!s.#g.has(t.localName)){t.setAttribute("text",String(h));continue}t[o]=h;continue}typeof h=="boolean"?h?t.setAttribute(o,""):t.removeAttribute(o):h!=null?t.setAttribute(this.#S(o),String(h)):l&&t.removeAttribute(this.#S(o))}}if(n)for(let o of Object.keys(n))!(o in r)&&!i.has(o)&&t.removeAttribute(this.#S(o));this.#n.set(e.id,r)}#S(t){return s.#m.has(t.toLowerCase())?t.toLowerCase():t.replace(/([A-Z])/g,"-$1").toLowerCase()}#x(t,e){if(t==null)return null;if(typeof t!="object")return t;if(t.path){let i=e?this.#i.get(e):null;return i?this.#w(i.dataModel,t.path):t.path}return t}#w(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,n)=>i?.[n],t)}#k({surfaceId:t,path:e,value:i}){let n=this.#i.get(t);if(n){if(!e||e==="/")n.dataModel=i??{};else{let r=e.split("/").filter(Boolean),o=n.dataModel;for(let a=0;a<r.length-1;a++)o[r[a]]==null&&(o[r[a]]={}),o=o[r[a]];o[r[r.length-1]]=i}for(let[r,o]of n.bindings){let a=n.elements.get(r);a&&this.#v(a,o)}}}#y({surfaceId:t}){let e=this.#i.get(t);if(e){this.#h?.teardown(t);for(let[i]of e.elements)this.#s.delete(i);e.root.remove(),this.#i.delete(t)}}getSurface(t){return this.#i.get(t)}getElement(t){return this.#s.get(t)}get surfaces(){return[...this.#i.keys()]}reset(){this.#o!==null&&(cancelAnimationFrame(this.#o),this.#o=null),this.#r.length=0;for(let[,t]of this.#i)t.root===this.#t?t.root.innerHTML="":t.root.remove();this.#i.clear(),this.#s.clear(),this.#n.clear()}set batching(t){this.#a=!!t}get batching(){return this.#a}};function zc(s,t={}){let e=s;if(t.catalog){let i=t.catalog instanceof Map?[...t.catalog.keys()]:Object.keys(t.catalog),n=s.includes("?")?"&":"?";e=`${s}${n}a2ui_catalog=${encodeURIComponent(i.join(","))}`}return{[Symbol.asyncIterator](){let i=new EventSource(e),n=[],r=null,o=!1;return i.onmessage=a=>{try{let l=JSON.parse(a.data);if(r){let h=r;r=null,h({value:l,done:!1})}else n.push(l)}catch{console.warn("A2UI SSE: invalid JSON",a.data)}},i.onerror=()=>{if(o=!0,i.close(),r){let a=r;r=null,a({value:void 0,done:!0})}},t.signal&&t.signal.addEventListener("abort",()=>{if(o=!0,i.close(),r){let a=r;r=null,a({value:void 0,done:!0})}}),{next(){return n.length>0?Promise.resolve({value:n.shift(),done:!1}):o?Promise.resolve({value:void 0,done:!0}):new Promise(a=>{r=a})},return(){return o=!0,i.close(),Promise.resolve({value:void 0,done:!0})}}}}}function jc(s,t={}){return{[Symbol.asyncIterator](){let e=new WebSocket(s),i=[],n=null,r=!1;return e.onopen=()=>{if(t.catalog){let o=t.catalog instanceof Map?[...t.catalog.keys()]:Object.keys(t.catalog);e.send(JSON.stringify({type:"a2ui:catalog",supportedTypes:o}))}},e.onmessage=o=>{try{let a=JSON.parse(o.data);if(n){let l=n;n=null,l({value:a,done:!1})}else i.push(a)}catch{console.warn("A2UI WS: invalid JSON",o.data)}},e.onclose=()=>{if(r=!0,n){let o=n;n=null,o({value:void 0,done:!0})}},e.onerror=()=>{r=!0,e.close()},{next(){return i.length>0?Promise.resolve({value:i.shift(),done:!1}):r?Promise.resolve({value:void 0,done:!0}):new Promise(o=>{n=o})},return(){return r=!0,e.close(),Promise.resolve({value:void 0,done:!0})}}}}}function gk(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function Nc(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?jM(s,t):mk(s,t)}function pk(s,t){if(s.result?.content){for(let e of s.result.content)if(e.type==="resource"&&e.resource?.mimeType==="application/json+a2ui")try{let i=JSON.parse(e.resource.text);for(let n of Array.isArray(i)?i:[i])t(n)}catch{}else if(e.type==="text")try{let i=JSON.parse(e.text);i.type&&(i.type.startsWith("create")||i.type.startsWith("update")||i.type.startsWith("delete"))&&t(i)}catch{}}}function jM(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:n}=t,r=new WebSocket(s);if(await new Promise((c,u)=>{r.onopen=c,r.onerror=u,e&&e.addEventListener("abort",()=>{r.close(),u(new DOMException("Aborted","AbortError"))},{once:!0})}),i){let c=i instanceof Map?[...i.keys()]:Object.keys(i);r.send(JSON.stringify({jsonrpc:"2.0",method:"a2ui/catalog",params:{supportedTypes:c}}))}let o=[],a=null,l=!1,h=c=>{if(a){let u=a;a=null,u({value:c,done:!1})}else o.push(c)};for(r.onmessage=c=>{try{let u=JSON.parse(c.data);pk(u,h),u.method==="a2ui/action"&&n&&n(u.params?.name,u.params?.arguments).then(d=>{r.send(JSON.stringify({jsonrpc:"2.0",id:u.id,result:d}))}).catch(d=>{r.send(JSON.stringify({jsonrpc:"2.0",id:u.id,error:{code:-1,message:d.message}}))})}catch{console.warn("A2UI MCP: invalid message",c.data)}},r.onclose=()=>{if(l=!0,a){let c=a;a=null,c({value:void 0,done:!0})}},r.onerror=()=>{l=!0,r.close()},e&&e.addEventListener("abort",()=>{if(l=!0,r.close(),a){let c=a;a=null,c({value:void 0,done:!0})}});!l||o.length>0;)if(o.length>0)yield o.shift();else{if(l)break;{let c=await new Promise(u=>{a=u});if(c.done)break;yield c.value}}}}}function mk(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:n}=t,r=[],o=null,a=!1,l=g=>{if(o){let y=o;o=null,y({value:g,done:!1})}else r.push(g)},h=()=>{if(a=!0,o){let g=o;o=null,g({value:void 0,done:!0})}},c={jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:"a2ui-runtime",version:"0.0.0"}}},u;try{u=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream"},body:JSON.stringify(c),signal:e})}catch(g){console.warn("A2UI MCP HTTP: initialize failed",g);return}if(!u.ok){console.warn(`A2UI MCP HTTP: initialize returned ${u.status}`);return}let d=u.headers.get("mcp-session-id");if(!d){console.warn("A2UI MCP HTTP: server did not return mcp-session-id header");try{await u.text()}catch{}return}try{if((u.headers.get("content-type")||"").includes("text/event-stream")){let y=u.body.getReader(),v=new TextDecoder,x="";for(;;){let{done:S,value:$}=await y.read();if(S||(x+=v.decode($,{stream:!0}),x.includes(`
205
+ `};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;connected(){if(this.state)this.state=this.state==="on"?"on":"off";else{let t=this.initial==="on"?"on":"off";this.state=t}this.#t=this.ensure("bar"),this.#e=this.#t.querySelector("[data-demo-toggle-switch]"),this.#i=this.#t.querySelector("[data-demo-toggle-label]"),this.#s||(this.#s=!0,this.#e.addEventListener("change",this.#n))}disconnected(){this.#e&&this.#e.removeEventListener("change",this.#n),this.#t=null,this.#e=null,this.#i=null,this.#s=!1}render(){if(!this.#t)return;let t=this.state==="on";this.#e.checked!==t&&(this.#e.checked=t),this.#i&&(this.#i.textContent=t?this.labelOn:this.labelOff)}toggle(){this.state=this.state==="on"?"off":"on",this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{state:this.state}}))}#n=t=>{t.stopPropagation();let e=this.#e.checked?"on":"off";e!==this.state&&(this.state=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{state:this.state}})))}};w("demo-toggle-ui",co);var uo=class extends A{static properties={src:{type:String,default:"",reflect:!0},markdown:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e="";#i="";connected(){this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-richtext-body",""),this.appendChild(this.#t))}render(){if(this.src&&this.src!==this.#e){this.#e=this.src,this.#i="",this.#s();return}this.markdown&&this.markdown!==this.#i&&(this.#i=this.markdown,this.#e="",this.#t.innerHTML=hn(this.markdown))}async#s(){try{let t=await fetch(this.src);if(!this.isConnected)return;if(!t.ok){this.#t.innerHTML=`<p>Failed to load: ${this.src}</p>`;return}let e=await t.text();if(!this.isConnected)return;this.#t.innerHTML=hn(e)}catch(t){if(!this.isConnected)return;this.#t.innerHTML=`<p>Error: ${t.message}</p>`}}};w("richtext-ui",uo);var fo=class extends A{static properties={pace:{type:Number,default:0,reflect:!0},hideCursor:{type:Boolean,default:!1,reflect:!0,attribute:"hide-cursor"},streaming:{type:Boolean,default:!1,reflect:!0}};#t=null;#e=null;#i="";get tokens(){return this.#t}set tokens(t){this.#t=t,t&&this.#s(t)}static template=()=>null;async#s(t){this.#e?.abort(),this.#e=new AbortController;let e=this.#e.signal;this.#i="",this.textContent="",this.streaming=!0,this.dispatchEvent(new Event("stream-start",{bubbles:!0}));try{for await(let i of t){if(e.aborted)break;if(this.#i+=i,this.pace>0)for(let n of i){if(e.aborted)break;this.textContent+=n,await new Promise(r=>setTimeout(r,this.pace))}else this.textContent=this.#i}}catch(i){e.aborted||this.dispatchEvent(new CustomEvent("stream-error",{bubbles:!0,detail:{error:i}}))}e.aborted||(this.streaming=!1,this.dispatchEvent(new Event("stream-end",{bubbles:!0})))}stop(){this.#e?.abort(),this.streaming=!1}clear(){this.stop(),this.#i="",this.textContent=""}disconnected(){this.stop()}};w("stream-ui",fo);var Et=new Map([["Row","row-ui"],["Column","col-ui"],["List","list-ui"],["ListItem","list-item-ui"],["Grid","grid-ui"],["Stack","stack-ui"],["Block","block-ui"],["Text","text-ui"],["Image","image-ui"],["Icon","icon-ui"],["Divider","divider-ui"],["Badge","badge-ui"],["Avatar","avatar-ui"],["AvatarGroup","avatar-group-ui"],["Progress","progress-ui"],["Skeleton","skeleton-ui"],["Code","code-ui"],["Stat","stat-ui"],["EmptyState","empty-state-ui"],["Input","input-ui"],["TextField","input-ui"],["TextArea","textarea-ui"],["Field","field-ui"],["CheckBox","check-ui"],["Toggle","switch-ui"],["Switch","switch-ui"],["Slider","slider-ui"],["Range","range-ui"],["Rating","rating-ui"],["ChoicePicker","select-ui"],["Select","select-ui"],["Radio","radio-ui"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorPicker","color-picker-ui"],["Upload","upload-ui"],["OtpInput","otp-input-ui"],["Button","button-ui"],["LoadingIndicator","progress-ui"],["ErrorContainer","card-ui"],["Card","card-ui"],["Tabs","tabs-ui"],["Tab","tab-ui"],["Panel","pane-ui"],["Pane","pane-ui"],["Modal","modal-ui"],["Dialog","modal-ui"],["Drawer","drawer-ui"],["Toast","toast-ui"],["Popover","popover-ui"],["Accordion","accordion-ui"],["AccordionItem","accordion-item-ui"],["Alert","alert-ui"],["Tooltip","tooltip-ui"],["Menu","menu-ui"],["Section","section"],["Header","header"],["Footer","footer"],["Stream","stream-ui"],["Table","table-ui"],["Chart","chart-ui"],["Embed","embed-ui"],["Swiper","swiper-ui"],["Slideshow","swiper-ui"],["Carousel","swiper-ui"],["Breadcrumb","breadcrumb-ui"],["Link","link-ui"],["Anchor","link-ui"],["Hyperlink","link-ui"],["NavLink","link-ui"],["Nav","nav-ui"],["NavGroup","nav-group-ui"],["NavItem","nav-item-ui"],["Noodles","noodles-ui"],["Pagination","pagination-ui"],["SegmentedControl","segmented-ui"],["Segment","segment-ui"],["ToggleGroup","toggle-group-ui"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-ui"],["Tag","tag-ui"],["Timeline","timeline-ui"],["TimelineItem","timeline-item-ui"],["button-ui","button-ui"],["card-ui","card-ui"],["text-ui","text-ui"],["input-ui","input-ui"],["text-field-ui","input-ui"],["select-ui","select-ui"],["toggle-ui","switch-ui"],["check-ui","check-ui"],["slider-ui","slider-ui"],["badge-ui","badge-ui"],["avatar-ui","avatar-ui"],["icon-ui","icon-ui"],["image-ui","image-ui"],["divider-ui","divider-ui"],["progress-ui","progress-ui"],["skeleton-ui","skeleton-ui"],["tabs-ui","tabs-ui"],["tab-ui","tab-ui"],["modal-ui","modal-ui"],["dialog-ui","modal-ui"],["drawer-ui","drawer-ui"],["toast-ui","toast-ui"],["popover-ui","popover-ui"],["panel-ui","pane-ui"],["accordion-ui","accordion-ui"],["alert-ui","alert-ui"],["tooltip-ui","tooltip-ui"],["menu-ui","menu-ui"],["table-ui","table-ui"],["chart-ui","chart-ui"],["code-ui","code-ui"],["textarea-ui","textarea-ui"],["radio-ui","radio-ui"],["tag-ui","tag-ui"],["search-ui","search-ui"],["upload-ui","upload-ui"],["breadcrumb-ui","breadcrumb-ui"],["link-ui","link-ui"],["nav-ui","nav-ui"],["noodles-ui","noodles-ui"],["pagination-ui","pagination-ui"],["segmented-control-ui","segmented-ui"],["segment-ui","segment-ui"],["command-ui","command-ui"],["calendar-picker-ui","calendar-picker-ui"],["color-picker-ui","color-picker-ui"],["kbd-ui","kbd-ui"],["toolbar-ui","toolbar-ui"],["otp-input-ui","otp-input-ui"],["embed-ui","embed-ui"],["stream-ui","stream-ui"],["row-ui","row-ui"],["col-ui","col-ui"],["grid-ui","grid-ui"],["stack-ui","stack-ui"],["block-ui","block-ui"],["list-ui","list-ui"],["range-ui","range-ui"],["datetime-ui","calendar-picker-ui"],["timeline-ui","timeline-ui"],["timeline-item-ui","timeline-item-ui"],["avatar-group-ui","avatar-group-ui"],["Keyboard","kbd-ui"],["DatePicker","calendar-picker-ui"],["CommandPalette","command-ui"],["FormContainer","form"],["Sidebar","admin-sidebar"],["Segmented","segmented-ui"],["OTP","otp-input-ui"],["Textarea","textarea-ui"],["RichText","richtext-ui"],["Richtext","richtext-ui"],["DescriptionList","description-list-ui"],["ActionItem","action-item-ui"],["ActionList","action-list-ui"],["Inspector","inspector-ui"],["Heatmap","heatmap-ui"],["ChatThread","chat-thread"],["ChatInput","chat-input-ui"],["OptionCard","option-card-ui"],["Option","option-card-ui"],["AdminCommand","admin-command"],["AdminContent","admin-content"],["AdminPage","admin-page"],["AdminPageBody","admin-page-body"],["AdminPageHeader","admin-page-header"],["AdminScroll","admin-scroll"],["AdminShell","admin-shell"],["AdminSidebar","admin-sidebar"],["AdminStatusbar","admin-statusbar"],["AdminTopbar","admin-topbar"],["ChatComposer","chat-composer"],["ChatEmpty","chat-empty"],["ChatHeader","chat-header"],["ChatShell","chat-shell"],["ChatSidebar","chat-sidebar"],["ChatStatus","chat-status"],["EditorCanvas","editor-canvas"],["EditorCanvasEmpty","editor-canvas-empty"],["EditorShell","editor-shell"],["EditorSidebar","editor-sidebar"],["EditorStatusbar","editor-statusbar"],["EditorToolbar","editor-toolbar"],["GenRoot","gen-root"],["SimpleContent","simple-content"],["SimpleHero","simple-hero"],["SimpleShell","simple-shell"],["ThemePanel","theme-panel"]]);function Xc(s){return Et.get(s)||null}function Fw(s,t){Et.set(s,t)}var Yi=class s{#t;#e;#i=new Map;#s=new Map;#n=new Map;#r=[];#o=null;#a=!1;constructor(t,e=Et,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#a=i}process(t){t&&(this.#a?(this.#r.push(t),this.#o===null&&(this.#o=requestAnimationFrame(()=>this.#l()))):this.#u(t))}#l(){this.#o=null;let t=this.#r.splice(0);for(let e of t)this.#u(e)}#u(t){switch(t.type||t.messageType){case"createSurface":this.#d(t);break;case"updateComponents":this.#f(t);break;case"updateDataModel":this.#P(t);break;case"wireComponents":this.#c(t);break;case"deleteSurface":this.#E(t);break;case"meta":break;default:console.warn("A2UI: unknown message type",t.type)}}#h=null;async#c(t){if(!this.#h){let{WiringEngine:e}=await Promise.resolve().then(()=>(mg(),fk));this.#h=new e({updateDataModel:(i,n,r)=>{this.#P({surfaceId:i,path:n,value:r})},getElement:(i,n)=>this.#i.get(i)?.elements.get(n)||null})}await this.#h.process(t)}async processStream(t){for await(let e of t)this.process(e)}#d({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t))return;let n=document.createElement("div");n.setAttribute("data-a2ui-surface",t),e&&n.setAttribute("data-catalog",e),this.#t.appendChild(n),this.#i.set(t,{root:n,rootId:typeof i=="string"&&i?i:"root",elements:new Map,dataModel:{},bindings:new Map})}#f({surfaceId:t,components:e}){let i=this.#i.get(t);i||(i={root:this.#t,rootId:"root",elements:new Map,dataModel:{},bindings:new Map},this.#i.set(t,i));for(let l of e)if(!(!l.id&&l.id!==0)){if(l.component==="ContextBindings"){i.contextBindings=l;continue}try{let h=i.elements.get(l.id),c=l.component==="Text"?this.#k(l.variant,l):Xc(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-id",l.id),h.setAttribute("data-a2ui-unknown",l.component),h.textContent=`[unknown: ${l.component}]`,i.elements.set(l.id,h),this.#s.set(l.id,h));continue}if(!h)h=document.createElement(c),h.setAttribute("data-a2ui-id",l.id),i.elements.set(l.id,h),this.#s.set(l.id,h);else if(h.localName!==c){let d=document.createElement(c);d.setAttribute("data-a2ui-id",l.id),h.replaceWith(d),h=d,i.elements.set(l.id,h),this.#s.set(l.id,h)}l._surfaceId=t,Object.values(l).some(d=>d&&typeof d=="object"&&d.path)&&i.bindings.set(l.id,l),this.#y(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#b(e);let n=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])n.set(h,l.id);l.child&&n.set(l.child,l.id)}let r=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=n.get(u)}return!1};for(let l of e){let h=i.elements.get(l.id);if(h)try{let c=Array.isArray(l.children)?l.children:[];for(let u of c){if(u===l.id||r(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!r(l.id,l.child)){let u=i.elements.get(l.child);u&&u.parentElement!==h&&h.appendChild(u)}}catch(c){console.warn(`A2UI: tree build failed for "${l.id}":`,c.message)}}let o=i.rootId??"root";if(e.find(l=>l.id===o)){let l=i.elements.get(o);l&&l.parentElement!==i.root&&i.root.appendChild(l)}}static#p=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#g=new Set(["Header","Section","Footer"]);static#O=new Set(["header","body","footer"]);#m=new Set;#b(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let n=i.component==="Card"||i.component==="ErrorContainer",r=i.component==="Drawer";if(!n&&!r)continue;let o=r?s.#g:s.#p,a=r?"<drawer-ui>":"<card-ui>",l=Array.isArray(i.children)?i.children:[];for(let h of l){let c=e.get(h);if(!c||typeof c.slot=="string"&&s.#O.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#m.has(u)||(this.#m.add(u),console.warn(`A2UI: ${a} (id="${i.id}") body must wrap "${c.component}" (id="${h}") in <Section>. Direct flow children bypass the canonical body slot and lose --card-inset margin. Canonical children: ${[...o].join(", ")}`+(r?', or slot="header|body|footer".':".")))}}}static#x=new Set(["data","columns","options","itemRenderer","textContent"]);static#S=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui"]);static#v={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};static#w=new Set(["autocomplete","autofocus","autocapitalize","autocorrect","inputmode","enterkeyhint","spellcheck","maxlength","minlength","readonly","novalidate","formnovalidate","formaction","formenctype","formmethod","formtarget","multiple","pattern","placeholder","required","tabindex","accesskey","autoplay","autopictureinpicture","controls","crossorigin","disablepictureinpicture","disableremoteplayback","loop","muted","playsinline","preload","srcset","srcdoc","srclang","sizes","loading","decoding","fetchpriority","ismap","usemap","hreflang","referrerpolicy","download","contenteditable","contextmenu","draggable","dirname","colspan","rowspan","headers","allowfullscreen","allowpaymentrequest","itemid","itemprop","itemref","itemscope","itemtype","nomodule","nonce"]);#k(t,e){return!e?.slot&&s.#v[t]?s.#v[t]:"text-ui"}#y(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#v[e.variant]&&i.add("variant");let n=this.#n.get(e.id),r={};for(let[o,a]of Object.entries(e)){if(i.has(o))continue;let l=a&&typeof a=="object"&&a.path,h=this.#A(a,e._surfaceId);if(r[o]=h,!(n&&Object.is(n[o],h))){if(o==="style"&&typeof h=="string"){t.style.cssText=h;continue}if(s.#x.has(o)&&h!=null){if(o==="textContent"&&!s.#S.has(t.localName)){t.setAttribute("text",String(h));continue}t[o]=h;continue}typeof h=="boolean"?h?t.setAttribute(o,""):t.removeAttribute(o):h!=null?t.setAttribute(this.#$(o),String(h)):l&&t.removeAttribute(this.#$(o))}}if(n)for(let o of Object.keys(n))!(o in r)&&!i.has(o)&&t.removeAttribute(this.#$(o));this.#n.set(e.id,r)}#$(t){return s.#w.has(t.toLowerCase())?t.toLowerCase():t.replace(/([A-Z])/g,"-$1").toLowerCase()}#A(t,e){if(t==null)return null;if(typeof t!="object")return t;if(t.path){let i=e?this.#i.get(e):null;return i?this.#C(i.dataModel,t.path):t.path}return t}#C(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,n)=>i?.[n],t)}#P({surfaceId:t,path:e,value:i}){let n=this.#i.get(t);if(n){if(!e||e==="/")n.dataModel=i??{};else{let r=e.split("/").filter(Boolean),o=n.dataModel;for(let a=0;a<r.length-1;a++)o[r[a]]==null&&(o[r[a]]={}),o=o[r[a]];o[r[r.length-1]]=i}for(let[r,o]of n.bindings){let a=n.elements.get(r);a&&this.#y(a,o)}}}#E({surfaceId:t}){let e=this.#i.get(t);if(e){this.#h?.teardown(t);for(let[i]of e.elements)this.#s.delete(i);e.root.remove(),this.#i.delete(t)}}getSurface(t){return this.#i.get(t)}getElement(t){return this.#s.get(t)}get surfaces(){return[...this.#i.keys()]}reset(){this.#o!==null&&(cancelAnimationFrame(this.#o),this.#o=null),this.#r.length=0;for(let[,t]of this.#i)t.root===this.#t?t.root.innerHTML="":t.root.remove();this.#i.clear(),this.#s.clear(),this.#n.clear()}set batching(t){this.#a=!!t}get batching(){return this.#a}};function zc(s,t={}){let e=s;if(t.catalog){let i=t.catalog instanceof Map?[...t.catalog.keys()]:Object.keys(t.catalog),n=s.includes("?")?"&":"?";e=`${s}${n}a2ui_catalog=${encodeURIComponent(i.join(","))}`}return{[Symbol.asyncIterator](){let i=new EventSource(e),n=[],r=null,o=!1;return i.onmessage=a=>{try{let l=JSON.parse(a.data);if(r){let h=r;r=null,h({value:l,done:!1})}else n.push(l)}catch{console.warn("A2UI SSE: invalid JSON",a.data)}},i.onerror=()=>{if(o=!0,i.close(),r){let a=r;r=null,a({value:void 0,done:!0})}},t.signal&&t.signal.addEventListener("abort",()=>{if(o=!0,i.close(),r){let a=r;r=null,a({value:void 0,done:!0})}}),{next(){return n.length>0?Promise.resolve({value:n.shift(),done:!1}):o?Promise.resolve({value:void 0,done:!0}):new Promise(a=>{r=a})},return(){return o=!0,i.close(),Promise.resolve({value:void 0,done:!0})}}}}}function jc(s,t={}){return{[Symbol.asyncIterator](){let e=new WebSocket(s),i=[],n=null,r=!1;return e.onopen=()=>{if(t.catalog){let o=t.catalog instanceof Map?[...t.catalog.keys()]:Object.keys(t.catalog);e.send(JSON.stringify({type:"a2ui:catalog",supportedTypes:o}))}},e.onmessage=o=>{try{let a=JSON.parse(o.data);if(n){let l=n;n=null,l({value:a,done:!1})}else i.push(a)}catch{console.warn("A2UI WS: invalid JSON",o.data)}},e.onclose=()=>{if(r=!0,n){let o=n;n=null,o({value:void 0,done:!0})}},e.onerror=()=>{r=!0,e.close()},{next(){return i.length>0?Promise.resolve({value:i.shift(),done:!1}):r?Promise.resolve({value:void 0,done:!0}):new Promise(o=>{n=o})},return(){return r=!0,e.close(),Promise.resolve({value:void 0,done:!0})}}}}}function gk(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function Nc(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?jM(s,t):mk(s,t)}function pk(s,t){if(s.result?.content){for(let e of s.result.content)if(e.type==="resource"&&e.resource?.mimeType==="application/json+a2ui")try{let i=JSON.parse(e.resource.text);for(let n of Array.isArray(i)?i:[i])t(n)}catch{}else if(e.type==="text")try{let i=JSON.parse(e.text);i.type&&(i.type.startsWith("create")||i.type.startsWith("update")||i.type.startsWith("delete"))&&t(i)}catch{}}}function jM(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:n}=t,r=new WebSocket(s);if(await new Promise((c,u)=>{r.onopen=c,r.onerror=u,e&&e.addEventListener("abort",()=>{r.close(),u(new DOMException("Aborted","AbortError"))},{once:!0})}),i){let c=i instanceof Map?[...i.keys()]:Object.keys(i);r.send(JSON.stringify({jsonrpc:"2.0",method:"a2ui/catalog",params:{supportedTypes:c}}))}let o=[],a=null,l=!1,h=c=>{if(a){let u=a;a=null,u({value:c,done:!1})}else o.push(c)};for(r.onmessage=c=>{try{let u=JSON.parse(c.data);pk(u,h),u.method==="a2ui/action"&&n&&n(u.params?.name,u.params?.arguments).then(d=>{r.send(JSON.stringify({jsonrpc:"2.0",id:u.id,result:d}))}).catch(d=>{r.send(JSON.stringify({jsonrpc:"2.0",id:u.id,error:{code:-1,message:d.message}}))})}catch{console.warn("A2UI MCP: invalid message",c.data)}},r.onclose=()=>{if(l=!0,a){let c=a;a=null,c({value:void 0,done:!0})}},r.onerror=()=>{l=!0,r.close()},e&&e.addEventListener("abort",()=>{if(l=!0,r.close(),a){let c=a;a=null,c({value:void 0,done:!0})}});!l||o.length>0;)if(o.length>0)yield o.shift();else{if(l)break;{let c=await new Promise(u=>{a=u});if(c.done)break;yield c.value}}}}}function mk(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:n}=t,r=[],o=null,a=!1,l=g=>{if(o){let y=o;o=null,y({value:g,done:!1})}else r.push(g)},h=()=>{if(a=!0,o){let g=o;o=null,g({value:void 0,done:!0})}},c={jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:"a2ui-runtime",version:"0.0.0"}}},u;try{u=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream"},body:JSON.stringify(c),signal:e})}catch(g){console.warn("A2UI MCP HTTP: initialize failed",g);return}if(!u.ok){console.warn(`A2UI MCP HTTP: initialize returned ${u.status}`);return}let d=u.headers.get("mcp-session-id");if(!d){console.warn("A2UI MCP HTTP: server did not return mcp-session-id header");try{await u.text()}catch{}return}try{if((u.headers.get("content-type")||"").includes("text/event-stream")){let y=u.body.getReader(),v=new TextDecoder,x="";for(;;){let{done:S,value:$}=await y.read();if(S||(x+=v.decode($,{stream:!0}),x.includes(`
206
206
 
207
207
  `)))break}try{y.cancel()}catch{}}else await u.json().catch(()=>null)}catch{}try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify({jsonrpc:"2.0",method:"notifications/initialized"}),signal:e}).then(g=>g.text()).catch(()=>null)}catch{}if(i){let g=i instanceof Map?[...i.keys()]:Object.keys(i);try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify({jsonrpc:"2.0",method:"a2ui/catalog",params:{supportedTypes:g}}),signal:e}).then(y=>y.text()).catch(()=>null)}catch{}}let f=g=>fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify(g),signal:e}).then(y=>y.text()).catch(()=>null),p=g=>{pk(g,l),g.method==="a2ui/action"&&n&&Promise.resolve().then(()=>n(g.params?.name,g.params?.arguments)).then(y=>f({jsonrpc:"2.0",id:g.id,result:y})).catch(y=>f({jsonrpc:"2.0",id:g.id,error:{code:-1,message:y.message}}))},m;try{m=await fetch(s,{method:"GET",headers:{Accept:"text/event-stream","mcp-session-id":d},signal:e})}catch(g){g?.name!=="AbortError"&&console.warn("A2UI MCP HTTP: GET stream failed",g);return}if(!m.ok||!m.body){console.warn(`A2UI MCP HTTP: GET stream returned ${m.status}`);return}e&&e.addEventListener("abort",h,{once:!0});let O=()=>{try{fetch(s,{method:"DELETE",headers:{"mcp-session-id":d}}).catch(()=>null)}catch{}};for((async()=>{let g=m.body.getReader(),y=new TextDecoder,v="";try{for(;!a;){let{done:x,value:S}=await g.read();if(x)break;v+=y.decode(S,{stream:!0});let $;for(;($=v.indexOf(`
208
208
 
@@ -227,12 +227,12 @@ Correct shape for <chart-ui x="label" y="value">:
227
227
  <span data-reasoning-time>${r}s</span>
228
228
  <icon-ui name="${this.collapsed?"caret-right":"caret-up"}" color="muted" data-reasoning-chevron></icon-ui>
229
229
  </span>
230
- `,this.#o.hidden=this.collapsed,this.#r.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#o.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#b(),this.#o.appendChild(a)),a.appendChild(this.#v(l))):(a=null,this.#o.appendChild(this.#S(l)))}#b(){let t=document.createElement("timeline-ui");return t.setAttribute("size","sm"),t}#v(t){let e=document.createElement("timeline-item-ui");e.setAttribute("text",t.label||""),t.status==="done"&&e.setAttribute("status","completed"),t.status==="error"&&e.setAttribute("status","error"),t.status==="active"&&(e.setAttribute("status","active"),e.setAttribute("spinner",""));let i=t.durationLabel||(t.duration!=null?_M(t.duration):"");return i&&e.setAttribute("duration",i),t.outcomes?.length&&(e.outcomes=t.outcomes),e.dataset.stepId=t.id||"",e}#S(t){switch(t.kind){case"thought":return this.#x(t);case"plan":return this.#w(t);case"iteration":return this.#k(t);default:return document.createTextNode("")}}#x(t){let e=document.createElement("div");e.setAttribute("data-reasoning-thought","");let i=document.createElement("span");return i.setAttribute("data-reasoning-thought-text",""),i.textContent=t.text||"",e.appendChild(i),e}#w(t){let e=document.createElement("div");e.setAttribute("data-reasoning-plan","");let i=document.createElement("div");i.setAttribute("data-reasoning-plan-label",""),i.textContent="Plan",e.appendChild(i);let n=document.createElement("ol");n.setAttribute("data-reasoning-plan-list","");for(let r of t.items||[]){let o=document.createElement("li");o.textContent=r,n.appendChild(o)}return e.appendChild(n),e}#k(t){let e=document.createElement("div");e.setAttribute("data-reasoning-iteration",""),t.status==="active"&&e.setAttribute("data-active",""),t.status==="done"&&e.setAttribute("data-done",""),t.status==="error"&&e.setAttribute("data-error","");let i=document.createElement("div");i.setAttribute("data-reasoning-iter-header","");let n=t.status==="done"?'<icon-ui name="check-circle" color="success" size="sm"></icon-ui>':t.status==="error"?'<icon-ui name="warning" color="danger" size="sm"></icon-ui>':"<span data-reasoning-spinner data-small></span>";if(i.innerHTML=`
230
+ `,this.#o.hidden=this.collapsed,this.#r.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#o.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#b(),this.#o.appendChild(a)),a.appendChild(this.#x(l))):(a=null,this.#o.appendChild(this.#S(l)))}#b(){let t=document.createElement("timeline-ui");return t.setAttribute("size","sm"),t}#x(t){let e=document.createElement("timeline-item-ui");e.setAttribute("text",t.label||""),t.status==="done"&&e.setAttribute("status","completed"),t.status==="error"&&e.setAttribute("status","error"),t.status==="active"&&(e.setAttribute("status","active"),e.setAttribute("spinner",""));let i=t.durationLabel||(t.duration!=null?_M(t.duration):"");return i&&e.setAttribute("duration",i),t.outcomes?.length&&(e.outcomes=t.outcomes),e.dataset.stepId=t.id||"",e}#S(t){switch(t.kind){case"thought":return this.#v(t);case"plan":return this.#w(t);case"iteration":return this.#k(t);default:return document.createTextNode("")}}#v(t){let e=document.createElement("div");e.setAttribute("data-reasoning-thought","");let i=document.createElement("span");return i.setAttribute("data-reasoning-thought-text",""),i.textContent=t.text||"",e.appendChild(i),e}#w(t){let e=document.createElement("div");e.setAttribute("data-reasoning-plan","");let i=document.createElement("div");i.setAttribute("data-reasoning-plan-label",""),i.textContent="Plan",e.appendChild(i);let n=document.createElement("ol");n.setAttribute("data-reasoning-plan-list","");for(let r of t.items||[]){let o=document.createElement("li");o.textContent=r,n.appendChild(o)}return e.appendChild(n),e}#k(t){let e=document.createElement("div");e.setAttribute("data-reasoning-iteration",""),t.status==="active"&&e.setAttribute("data-active",""),t.status==="done"&&e.setAttribute("data-done",""),t.status==="error"&&e.setAttribute("data-error","");let i=document.createElement("div");i.setAttribute("data-reasoning-iter-header","");let n=t.status==="done"?'<icon-ui name="check-circle" color="success" size="sm"></icon-ui>':t.status==="error"?'<icon-ui name="warning" color="danger" size="sm"></icon-ui>':"<span data-reasoning-spinner data-small></span>";if(i.innerHTML=`
231
231
  ${n}
232
232
  <span data-reasoning-iter-n>#${t.n}</span>
233
233
  <span data-reasoning-iter-label>${gg(t.label||"")}</span>
234
234
  ${t.summary?`<span data-reasoning-iter-summary>${gg(t.summary)}</span>`:""}
235
- `,e.appendChild(i),t.steps?.length){let r=this.#b();for(let o of t.steps)r.appendChild(this.#v(o));e.appendChild(r)}return e}#y(){if(this.status==="done"||this.status==="error")return;let t=Math.round((Date.now()-this.#i)/1e3),e=this.#r?.querySelector("[data-reasoning-time]");e&&(e.textContent=t+"s");let i=t+"s";for(let n of this.querySelectorAll("timeline-item-ui[active]:not([completed])"))n.dataset._frozenDuration||n.setAttribute("duration",i)}};w("agent-reasoning-ui",$o);var Ua=class extends A{static requiredIcons=["caret-right","circle-fill"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=null;get pills(){return this.#t}set pills(t){this.#t=Array.isArray(t)?t.slice():[],this.#o()}get metrics(){return this.#e}set metrics(t){this.#e=Array.isArray(t)?t.slice():[],this.#o()}get feedback(){return this.#i}set feedback(t){this.#i=Array.isArray(t)?t.slice():[],this.#o()}connected(){this.#r()}disconnected(){this.#s?.removeEventListener("toggle",this.#n),this.#s=null}#n=()=>{this.collapsed=!this.#s.hasAttribute("open"),this.dispatchEvent(new CustomEvent("trace-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}}))};#r(){this.innerHTML="",this.#s=document.createElement("details"),this.#s.setAttribute("data-trace-root",""),this.collapsed||this.#s.setAttribute("open",""),this.#s.addEventListener("toggle",this.#n),this.appendChild(this.#s),this.#o()}#o(){if(!this.#s)return;let t=this.#t.length?this.#t.map(a=>this.#h(a)).join("<span data-trace-sep>\xB7</span>"):`<span>${Ui(this.label||"Trace")}</span>`,e=this.#e.some(a=>a.aux!=null&&String(a.aux).trim()!==""),i=this.#e.some(a=>this.#a(a)),n=this.#e.length?`
235
+ `,e.appendChild(i),t.steps?.length){let r=this.#b();for(let o of t.steps)r.appendChild(this.#x(o));e.appendChild(r)}return e}#y(){if(this.status==="done"||this.status==="error")return;let t=Math.round((Date.now()-this.#i)/1e3),e=this.#r?.querySelector("[data-reasoning-time]");e&&(e.textContent=t+"s");let i=t+"s";for(let n of this.querySelectorAll("timeline-item-ui[active]:not([completed])"))n.dataset._frozenDuration||n.setAttribute("duration",i)}};w("agent-reasoning-ui",$o);var Ua=class extends A{static requiredIcons=["caret-right","circle-fill"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=null;get pills(){return this.#t}set pills(t){this.#t=Array.isArray(t)?t.slice():[],this.#o()}get metrics(){return this.#e}set metrics(t){this.#e=Array.isArray(t)?t.slice():[],this.#o()}get feedback(){return this.#i}set feedback(t){this.#i=Array.isArray(t)?t.slice():[],this.#o()}connected(){this.#r()}disconnected(){this.#s?.removeEventListener("toggle",this.#n),this.#s=null}#n=()=>{this.collapsed=!this.#s.hasAttribute("open"),this.dispatchEvent(new CustomEvent("trace-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}}))};#r(){this.innerHTML="",this.#s=document.createElement("details"),this.#s.setAttribute("data-trace-root",""),this.collapsed||this.#s.setAttribute("open",""),this.#s.addEventListener("toggle",this.#n),this.appendChild(this.#s),this.#o()}#o(){if(!this.#s)return;let t=this.#t.length?this.#t.map(a=>this.#h(a)).join("<span data-trace-sep>\xB7</span>"):`<span>${Ui(this.label||"Trace")}</span>`,e=this.#e.some(a=>a.aux!=null&&String(a.aux).trim()!==""),i=this.#e.some(a=>this.#a(a)),n=this.#e.length?`
236
236
  <div data-trace-headers>
237
237
  <span data-trace-header>Stage</span>
238
238
  <span data-trace-header>Score</span>