@adia-ai/web-modules 0.7.2 → 0.7.4

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.
@@ -7,7 +7,7 @@ var LE=Object.defineProperty;var B=(s,t)=>()=>(s&&(t=s(s=0)),t);var Yt=(s,t)=>{f
7
7
  `+c+" Compute the full attr value as a single expression and interpolate the whole.")}continue}let a=+o[1],l=n.name;l[0]==="@"?(r.removeAttribute(l),e[a]={t:"e",n:r,name:l.slice(1),c:void 0,_fx:null}):l[0]==="."?(r.removeAttribute(l),e[a]={t:"p",n:r,name:NO(r,l.slice(1)),c:void 0,_fx:null,_resolved:!1}):l[0]==="?"?(r.removeAttribute(l),console.warn(`[template] Lit-style boolean attribute "${l}=" is not supported.
8
8
  Element: <${r.tagName.toLowerCase()}>
9
9
  Use .${l.slice(1)}=\${value} (property binding) instead \u2014 the primitive reflects the property to the DOM attribute for you.
10
- See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),e[a]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):e[a]={t:"a",n:r,name:l,c:void 0,_fx:null}}return e}function Oh(s){for(let t of s)t&&t._fx&&(t._fx(),t._fx=null)}function Pd(s){if(s.n.nodeType===1&&s.n[$d])return s.n;let t=document.createElement("span");return t.style.display="contents",t.setAttribute("role","presentation"),t[$d]=!0,s.n.replaceWith(t),s.n=t,t}function Qd(s,t){if(t!==s.c){if(s.t==="n")if(t!=null&&t._directive)t._commit(Pd(s));else if(zO(t))er(t,Pd(s));else if(Array.isArray(t)){let e=Pd(s);e.replaceChildren();for(let i of t)if(zO(i)){let r=document.createElement("span");r.style.display="contents",r.setAttribute("role","presentation"),e.appendChild(r),er(i,r)}else e.appendChild(document.createTextNode(i??""))}else if(t instanceof Node)s.n.replaceWith(t),s.n=t;else if(s.n[$d]){let e=document.createTextNode(t??"");s.n.replaceWith(e),s.n=e}else s.n.textContent=t??"";else if(s.t==="a")t==null||t===!1?s.n.removeAttribute(s.name):s.n.setAttribute(s.name,t===!0?"":t);else if(s.t==="p"){if(!s._resolved){let e=NO(s.n,s.name);e!==s.name&&(s.name=e),s._resolved=!0}s.n[s.name]=t}else s.t==="e"&&(_O(s.c)&&s.n.removeEventListener(s.name,s.c),_O(t)&&s.n.addEventListener(s.name,t));s.c=t}}function VE(s,t){for(let e=0;e<s.length;e++){let i=s[e];if(!i)continue;let r=t[e],n=i.t!=="e"&&typeof r=="function",o=!n&&i.t!=="e"&&Cd(r);if(i._fx&&!n&&!o&&(i._fx(),i._fx=null),n){i._fx||(i._fx=as(()=>Qd(i,r())));continue}if(o){i._fx||(i._fx=as(()=>Qd(i,r.value)));continue}Qd(i,r)}}function WE(s,t,e){return{_directive:!0,_commit(i){let r=i[ir]||new Map,n=new Map,o=[];for(let l=0;l<s.length;l++){let h=t(s[l],l);if(n.has(h))continue;o.push(h);let c=e(s[l],l);if(r.has(h)){let u=r.get(h);er(c,u),n.set(h,u)}else{let u=document.createElement("span");u.style.display="contents",u.setAttribute("role","presentation"),er(c,u),n.set(h,u)}}for(let[l,h]of r)n.has(l)||(h._i&&Oh(h._i.p),h.remove());let a=null;for(let l=o.length-1;l>=0;l--){let h=n.get(o[l]);(h.nextSibling!==a||h.parentNode!==i)&&i.insertBefore(h,a),a=h}i[ir]=n}}}var $d,ir,qO,XO,bh,wa,ZO,zO,_O,Td=B(()=>{"use strict";Ct();[$d,ir]=[Symbol(),Symbol()];qO=new WeakMap;XO={classname:"className",innertext:"innerText",innerhtml:"innerHTML",outerhtml:"outerHTML",textcontent:"textContent",tabindex:"tabIndex",arialabel:"ariaLabel",ariadescribedby:"ariaDescribedBy",arialabelledby:"ariaLabelledBy",ariarole:"role",contenteditable:"contentEditable",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",colspan:"colSpan",rowspan:"rowSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",usemap:"useMap",ismap:"isMap",accesskey:"accessKey",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",defaultselected:"defaultSelected"};bh="http://www.w3.org/2000/svg",wa="http://www.w3.org/1998/Math/MathML",ZO="http://www.w3.org/1999/xhtml";zO=s=>s!=null&&typeof s=="object"&&s.strings,_O=s=>typeof s=="function"||s!=null&&typeof s.handleEvent=="function"});function VO(s){if(!s.name)throw new Error("Trait requires a name");if(!s.setup)throw new Error(`Trait "${s.name}" requires a setup function`);if(!s.category)throw new Error(`Trait "${s.name}" requires a category`);if(!jO.has(s.category))throw new Error(`Trait "${s.name}" has unknown category "${s.category}". Known: ${[...jO].join(", ")}`);if(!s.description)throw new Error(`Trait "${s.name}" requires a description`);let t=Object.freeze({name:s.name,category:s.category,description:s.description,attributes:Object.freeze(s.attributes||[]),events:Object.freeze(s.events||[]),config:Object.freeze(s.config||[])});function e(){let i=null;return{schema:t,connect(r,n){i=s.setup({host:r,...n||{}})},disconnect(r){i&&(i(),i=null);for(let n of t.attributes)r.hasAttribute(n)&&(console.warn(`Trait "${t.name}": attribute "${n}" still present after disconnect`),r.removeAttribute(n))}}}return e.schema=t,yh.set(s.name,e),e}function WO(s){return yh.get(s)||null}function Zq(s){return yh.get(s)?.schema||null}function Bq(){return[...yh.keys()]}var yh,jO,Ld=B(()=>{"use strict";yh=new Map,jO=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"])});function UE(s,t){s[ka]=new Map,s[Md]=new Map;for(let[e,i]of Object.entries(t)){let r=i.attribute??e.toLowerCase(),n=i.type??String,o=qi(i.default??void 0);s[Md].set(e,o),Object.defineProperty(s,e,{get(){return o.value},set(a){let l=o.peek();Object.is(l,a)||(s[ka].set(e,l),o.value=a,i.reflect&&FE(s,r,a,n))},configurable:!0})}}function FE(s,t,e,i){i===Boolean?e?s.setAttribute(t,""):s.removeAttribute(t):e==null?s.removeAttribute(t):s.setAttribute(t,String(e))}function HE(s){if(Object.hasOwn(s,"_sa"))return;s._sa=!0;let t=s.styles;if(!t)return;let e=Array.isArray(t)?t:[t];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...e.filter(i=>!document.adoptedStyleSheets.includes(i))]}function UO(s){if(Object.hasOwn(s,"_pp"))return;s._pp={};let t=s.parts;if(t)for(let[e,i]of Object.entries(t)){let r=document.createElement("template");r.innerHTML=i,s._pp[e]=r.content.firstElementChild}}var Md,ka,YE,x,$=B(()=>{"use strict";Ct();Td();Ct();Td();Ld();Md=Symbol(),ka=Symbol();YE=(s,t)=>t===Boolean?s!==null:t===Number?s===null?null:+s:s;x=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let t=Object.entries(this.properties).map(([e,i])=>i.attribute??e.toLowerCase());return t.includes("traits")?t:[...t,"traits"]}#t=[];#e=[];#i=[];#s=null;#r=null;#n=null;#a=qi(0);constructor(){super(),this.internals=this.attachInternals(),UE(this,this.constructor.properties)}connectedCallback(){let t=this.constructor;t._tag||(t._tag=this.localName),HE(t),UO(t),F(()=>this.connected()),this.#t.push(as(()=>{for(let i of this[Md].values())i.value;this.#a.value;let e=t.template(this);if(e&&er(e,this),this.render(),this[ka].size){let i=new Map(this[ka]);this[ka].clear(),this.updated(i)}},{host:this.localName,onError:this.onError?e=>this.onError(e):null})),this.#n||(this.#n=new Set);for(let e of t.traits)this.#l(e);this.#c(),this.#s&&this.#o()}disconnectedCallback(){this._i&&Oh(this._i.p);for(let t of this.#t)t();this.#t.length=0;for(let t of this.#i)t.value=void 0;this.#i.length=0;for(let t of this.#e)t.disconnect(this);this.#e.length=0,this.#n?.clear(),this.#r?.(),this.#r=null,this.#s?.disconnect?.(this),this.disconnected()}#o(){let t=this.#s;t.connect?.(this),this.#r=t.subscribe?.(()=>{this.#a.value++})}get controller(){return this.#s}set controller(t){this.#r?.(),this.#r=null,this.#s?.disconnect?.(this),this.#s=t,t&&this.isConnected&&this.#o()}#l(t,{declarative:e=!1}={}){this.#n.add(t);let i=t();i.connect(this,{host:this,signal:qi,computed:Ed,effect:as}),e&&(i._declarative=!0),this.#e.push(i)}addTrait(t){return this.#n||(this.#n=new Set),this.#n.has(t)?this:(this.#l(t),this)}#c(){let t=this.getAttribute("traits");if(t)for(let e of t.split(/\s+/).filter(Boolean)){let i=WO(e);if(!i){console.warn(`<${this.localName}> traits="${e}" \u2014 trait not found. Did you forget to import it?`);continue}this.#n.has(i)||this.#l(i,{declarative:!0})}}#h(){if(!this.#n)return;let t=[];for(let e of this.#e)if(e._declarative){e.disconnect(this);for(let i of this.#n)if(i.schema?.name&&e.schema?.name===i.schema.name){this.#n.delete(i);break}}else t.push(e);this.#e.length=0,this.#e.push(...t),this.#c()}attributeChangedCallback(t,e,i){if(t==="traits"){this.isConnected&&this.#h();return}for(let[r,n]of Object.entries(this.constructor.properties))if((n.attribute??r.toLowerCase())===t){this[r]=YE(i,n.type??String);break}}static template=()=>null;static create(t={}){let e=this._tag??customElements.getName?.(this);if(!e)throw new Error("Component not registered");let i=document.createElement(e);for(let[r,n]of Object.entries(t))i[r]=n;return i}signal(t){let e=qi(t);return this.#i.push(e),e}ensure(t){for(let n of this.children)if(n.getAttribute("slot")===t)return n;let e=this.#u(t);if(e)return e;UO(this.constructor);let i=this.constructor._pp?.[t];if(!i)return null;let r=i.cloneNode(!0);return r._uiPart=!0,this.appendChild(r),r}drop(t){for(let i of this.children)if(i.getAttribute("slot")===t){i.remove();return}let e=this.#u(t);e&&e.remove()}#u(t){for(let e of this.querySelectorAll(`[slot="${t}"]`)){let i=e.parentElement,r=!0;for(;i&&i!==this;){if(i.localName.includes("-")){r=!1;break}i=i.parentElement}if(r&&i===this)return e}return null}reconcile(t,e,i,r){let n=t[ir]||new Map,o=new Map,a=[];for(let h=0;h<e.length;h++){let c=e[h],u=i(c,h);if(o.has(u))continue;let d=n.get(u);d?r(c,h,d):d=r(c,h,null),o.set(u,d),a.push(u)}for(let[h,c]of n)o.has(h)||c.remove();let l=null;for(let h=a.length-1;h>=0;h--){let c=o.get(a[h]);(c.nextSibling!==l||c.parentNode!==t)&&t.insertBefore(c,l),l=c}t[ir]=o}connected(){}render(){}disconnected(){}updated(t){}}});function vy(s,t,e,i){switch(s){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function La(s,t,e,i){for(var r;s.from==s.to||(e<1?s.from>=t:s.from>t)||(e>-1?s.to<=t:s.to<t);){let o=!i&&s instanceof le&&s.index<0?null:s.parent;if(!o)return s;s=o}let n=i?0:tt.IgnoreOverlays;if(i)for(let o=s,a=o.parent;a;o=a,a=o.parent)o instanceof le&&o.index<0&&((r=a.enter(t,e,n))===null||r===void 0?void 0:r.from)!=o.from&&(s=a);for(;;){let o=s.enter(t,e,n);if(!o)return s;s=o}}function xy(s,t,e,i){let r=s.cursor(),n=[];if(!r.firstChild())return n;if(e!=null){for(let o=!1;!o;)if(o=r.type.is(e),!r.nextSibling())return n}for(;;){if(i!=null&&r.type.is(i))return n;if(r.type.is(t)&&n.push(r.node),!r.nextSibling())return i==null?n:[]}}function Kd(s,t,e=t.length-1){for(let i=s;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}function Sy(s){if(!s.length)return null;let t=0,e=s[0];for(let n=1;n<s.length;n++){let o=s[n];(o.from>e.from||o.to<e.to)&&(e=o,t=n)}let i=e instanceof le&&e.index<0?null:e.parent,r=s.slice();return i?r[t]=i:r.splice(t,1),new tf(r,e)}function o$(s,t,e){let i=s.resolveInner(t,e),r=null;for(let n=i instanceof le?i:i.context.parent;n;n=n.parent)if(n.index<0){let o=n.parent;(r||(r=[i])).push(o.resolve(t,e)),n=o}else{let o=fi.get(n.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let a=new le(o.tree,o.overlay[0].from+n.from,-1,n);(r||(r=[i])).push(La(a,t,e,!1))}}return r?Sy(r):i}function ef(s){return s.children.some(t=>t instanceof pi||!t.type.isAnonymous||ef(t))}function a$(s){var t;let{buffer:e,nodeSet:i,maxBufferLength:r=1024,reused:n=[],minRepeatType:o=i.types.length}=s,a=Array.isArray(e)?new Gd(e,e.length):e,l=i.types,h=0,c=0;function u(k,E,A,C,T,Q){let{id:D,start:R,end:_,size:V}=a,U=c,J=h;if(V<0)if(a.next(),V==-1){let xt=n[D];A.push(xt),C.push(R-k);return}else if(V==-3){h=D;return}else if(V==-4){c=D;return}else throw new RangeError(`Unrecognized record size: ${V}`);let rt=l[D],ut,ot,bt=R-k;if(_-R<=r&&(ot=b(a.pos-E,T))){let xt=new Uint16Array(ot.size-ot.skip),Ot=a.pos-ot.size,Et=xt.length;for(;a.pos>Ot;)Et=g(ot.start,xt,Et);ut=new pi(xt,_-ot.start,i),bt=ot.start-k}else{let xt=a.pos-V;a.next();let Ot=[],Et=[],Tt=D>=o?D:-1,Ft=0,rs=_;for(;a.pos>xt;)Tt>=0&&a.id==Tt&&a.size>=0?(a.end<=rs-r&&(p(Ot,Et,R,Ft,a.end,rs,Tt,U,J),Ft=Ot.length,rs=a.end),a.next()):Q>2500?d(R,xt,Ot,Et):u(R,xt,Ot,Et,Tt,Q+1);if(Tt>=0&&Ft>0&&Ft<Ot.length&&p(Ot,Et,R,Ft,R,rs,Tt,U,J),Ot.reverse(),Et.reverse(),Tt>-1&&Ft>0){let wO=f(rt,J);ut=sf(rt,Ot,Et,0,Ot.length,0,_-R,wO,wO)}else ut=m(rt,Ot,Et,_-R,U-_,J)}A.push(ut),C.push(bt)}function d(k,E,A,C){let T=[],Q=0,D=-1;for(;a.pos>E;){let{id:R,start:_,end:V,size:U}=a;if(U>4)a.next();else{if(D>-1&&_<D)break;D<0&&(D=V-r),T.push(R,_,V),Q++,a.next()}}if(Q){let R=new Uint16Array(Q*4),_=T[T.length-2];for(let V=T.length-3,U=0;V>=0;V-=3)R[U++]=T[V],R[U++]=T[V+1]-_,R[U++]=T[V+2]-_,R[U++]=U;A.push(new pi(R,T[2]-_,i)),C.push(_-k)}}function f(k,E){return(A,C,T)=>{let Q=0,D=A.length-1,R,_;if(D>=0&&(R=A[D])instanceof Y){if(!D&&R.type==k&&R.length==T)return R;(_=R.prop(z.lookAhead))&&(Q=C[D]+R.length+_)}return m(k,A,C,T,Q,E)}}function p(k,E,A,C,T,Q,D,R,_){let V=[],U=[];for(;k.length>C;)V.push(k.pop()),U.push(E.pop()+A-T);k.push(m(i.types[D],V,U,Q-T,R-Q,_)),E.push(T-A)}function m(k,E,A,C,T,Q,D){if(Q){let R=[z.contextHash,Q];D=D?[R].concat(D):[R]}if(T>25){let R=[z.lookAhead,T];D=D?[R].concat(D):[R]}return new Y(k,E,A,C,D)}function b(k,E){let A=a.fork(),C=0,T=0,Q=0,D=A.end-r,R={size:0,start:0,skip:0};t:for(let _=A.pos-k;A.pos>_;){let V=A.size;if(A.id==E&&V>=0){R.size=C,R.start=T,R.skip=Q,Q+=4,C+=4,A.next();continue}let U=A.pos-V;if(V<0||U<_||A.start<D)break;let J=A.id>=o?4:0,rt=A.start;for(A.next();A.pos>U;){if(A.size<0)if(A.size==-3||A.size==-4)J+=4;else break t;else A.id>=o&&(J+=4);A.next()}T=rt,C+=V,Q+=J}return(E<0||C==k)&&(R.size=C,R.start=T,R.skip=Q),R.size>4?R:void 0}function g(k,E,A){let{id:C,start:T,end:Q,size:D}=a;if(a.next(),D>=0&&C<o){let R=A;if(D>4){let _=a.pos-(D-4);for(;a.pos>_;)A=g(k,E,A)}E[--A]=R,E[--A]=Q-k,E[--A]=T-k,E[--A]=C}else D==-3?h=C:D==-4&&(c=C);return A}let y=[],v=[];for(;a.pos>0;)u(s.start||0,s.bufferStart||0,y,v,-1,0);let w=(t=s.length)!==null&&t!==void 0?t:y.length?v[0]+y[0].length:0;return new Y(l[s.topID],y.reverse(),v.reverse(),w)}function $h(s,t){if(!s.isAnonymous||t instanceof pi||t.type!=s)return 1;let e=wy.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=s||!(i instanceof Y)){e=1;break}e+=$h(s,i)}wy.set(t,e)}return e}function sf(s,t,e,i,r,n,o,a,l){let h=0;for(let p=i;p<r;p++)h+=$h(s,t[p]);let c=Math.ceil(h*1.5/8),u=[],d=[];function f(p,m,b,g,y){for(let v=b;v<g;){let w=v,k=m[v],E=$h(s,p[v]);for(v++;v<g;v++){let A=$h(s,p[v]);if(E+A>=c)break;E+=A}if(v==w+1){if(E>c){let A=p[w];f(A.children,A.positions,0,A.children.length,m[w]+y);continue}u.push(p[w])}else{let A=m[v-1]+p[v-1].length-k;u.push(sf(s,p,m,w,v,k,A,null,l))}d.push(k+y-n)}}return f(t,e,i,r,0),(a||l)(u,d,o)}function ms(s){return(t,e,i,r)=>new af(t,s,e,i,r)}function ky(s){if(!s.length||s.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(s))}function l$(s,t,e){for(let i of s){if(i.from>=e)break;if(i.to>t)return i.from<=t&&i.to>=e?2:1}return 0}function Ay(s,t,e,i,r,n){if(t<e){let o=s.buffer[t+1];i.push(s.slice(t,e,o)),r.push(o-n)}}function h$(s){let{node:t}=s,e=[],i=t.context.buffer;do e.push(s.index),s.parent();while(!s.tree);let r=s.tree,n=r.children.indexOf(i),o=r.children[n],a=o.buffer,l=[n];function h(c,u,d,f,p,m){let b=e[m],g=[],y=[];Ay(o,c,b,g,y,f);let v=a[b+1],w=a[b+2];l.push(g.length);let k=m?h(b+4,a[b+3],o.set.types[a[b]],v,w-v,m-1):t.toTree();return g.push(k),y.push(v-f),Ay(o,a[b+3],u,g,y,f),new Y(d,g,y,p)}r.children[n]=h(0,a.length,dt.none,0,o.length,e.length-1);for(let c of l){let u=s.tree.children[c],d=s.tree.positions[c];s.yield(new le(u,d+s.from,c,s._tree))}}function Ey(s,t){let e=null,i=t;for(let r=1,n=0;r<s.length;r++){let o=s[r-1].to,a=s[r].from;for(;n<i.length;n++){let l=i[n];if(l.from>=a)break;l.to<=o||(e||(i=e=t.slice()),l.from<o?(e[n]=new ae(l.from,o),l.to>a&&e.splice(n+1,0,new ae(a,l.to))):l.to>a?e[n--]=new ae(a,l.to):e.splice(n--,1))}}return i}function c$(s,t,e,i){let r=0,n=0,o=!1,a=!1,l=-1e9,h=[];for(;;){let c=r==s.length?1e9:o?s[r].to:s[r].from,u=n==t.length?1e9:a?t[n].to:t[n].from;if(o!=a){let d=Math.max(l,e),f=Math.min(c,u,i);d<f&&h.push(new ae(d,f))}if(l=Math.min(c,u),l==1e9)break;c==l&&(o?(o=!1,r++):o=!0),u==l&&(a?(a=!1,n++):a=!0)}return h}function Cy(s,t){let e=[];for(let{pos:i,mount:r,frag:n}of s){let o=i+(r.overlay?r.overlay[0].from:0),a=o+r.tree.length,l=Math.max(n.from,o),h=Math.min(n.to,a);if(r.overlay){let c=r.overlay.map(d=>new ae(d.from+i,d.to+i)),u=c$(t,c,l,h);for(let d=0,f=l;;d++){let p=d==u.length,m=p?h:u[d].from;if(m>f&&e.push(new Fe(f,m,r.tree,-o,n.from>=f||n.openStart,n.to<=m||n.openEnd)),p)break;f=u[d].to}}else e.push(new Fe(l,h,r.tree,-o,n.from>=o||n.openStart,n.to<=a||n.openEnd))}return e}var hf,r$,ae,z,fi,n$,dt,Ye,Eh,yy,tt,Y,Gd,pi,Ch,le,Jd,ds,tf,fs,wy,ps,Fe,He,rf,Ph,nf,of,af,Qh,lf,Be=B(()=>{hf=1024,r$=0,ae=class{constructor(t,e){this.from=t,this.to=e}},z=class{constructor(t={}){this.id=r$++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=dt.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}};z.closedBy=new z({deserialize:s=>s.split(" ")}),z.openedBy=new z({deserialize:s=>s.split(" ")}),z.group=new z({deserialize:s=>s.split(" ")}),z.isolate=new z({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}}),z.contextHash=new z({perNode:!0}),z.lookAhead=new z({perNode:!0}),z.mounted=new z({perNode:!0});fi=class{constructor(t,e,i,r=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=r}static get(t){return t&&t.props&&t.props[z.mounted.id]}},n$=Object.create(null),dt=class s{constructor(t,e,i,r=0){this.name=t,this.props=e,this.id=i,this.flags=r}static define(t){let e=t.props&&t.props.length?Object.create(null):n$,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),r=new s(t.name||"",e,t.id,i);if(t.props){for(let n of t.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[n[0].id]=n[1]}}return r}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(z.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let r of i.split(" "))e[r]=t[i];return i=>{for(let r=i.prop(z.group),n=-1;n<(r?r.length:0);n++){let o=e[n<0?i.name:r[n]];if(o)return o}}}};dt.none=new dt("",Object.create(null),0,8);Ye=class s{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let r=null;for(let n of t){let o=n(i);if(o){r||(r=Object.assign({},i.props));let a=o[1],l=o[0];l.combine&&l.id in r&&(a=l.combine(r[l.id],a)),r[l.id]=a}}e.push(r?new dt(i.name,r,i.id,i.flags):i)}return new s(e)}},Eh=new WeakMap,yy=new WeakMap;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(tt||(tt={}));Y=class s{constructor(t,e,i,r,n){if(this.type=t,this.children=e,this.positions=i,this.length=r,this.props=null,n&&n.length){this.props=Object.create(null);for(let[o,a]of n)this.props[typeof o=="number"?o:o.id]=a}}toString(){let t=fi.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let r=i.toString();r&&(e&&(e+=","),e+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new fs(this.topNode,t)}cursorAt(t,e=0,i=0){let r=Eh.get(this)||this.topNode,n=new fs(r);return n.moveTo(t,e),Eh.set(this,n._tree),n}get topNode(){return new le(this,0,0,null)}resolve(t,e=0){let i=La(Eh.get(this)||this.topNode,t,e,!1);return Eh.set(this,i),i}resolveInner(t,e=0){let i=La(yy.get(this)||this.topNode,t,e,!0);return yy.set(this,i),i}resolveStack(t,e=0){return o$(this,t,e)}iterate(t){let{enter:e,leave:i,from:r=0,to:n=this.length}=t,o=t.mode||0,a=(o&tt.IncludeAnonymous)>0;for(let l=this.cursor(o|tt.IncludeAnonymous);;){let h=!1;if(l.from<=n&&l.to>=r&&(!a&&l.type.isAnonymous||e(l)!==!1)){if(l.firstChild())continue;h=!0}for(;h&&i&&(a||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;h=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:sf(dt.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,r)=>new s(this.type,e,i,r,this.propValues),t.makeTree||((e,i,r)=>new s(dt.none,e,i,r)))}static build(t){return a$(t)}};Y.empty=new Y(dt.none,[],[],0);Gd=class s{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new s(this.buffer,this.index)}},pi=class s{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return dt.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],r=this.set.types[e],n=r.name;if(/\W/.test(n)&&!r.isError&&(n=JSON.stringify(n)),t+=4,i==t)return n;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return n+"("+o.join(",")+")"}findChild(t,e,i,r,n){let{buffer:o}=this,a=-1;for(let l=t;l!=e&&!(vy(n,r,o[l+1],o[l+2])&&(a=l,i>0));l=o[l+3]);return a}slice(t,e,i){let r=this.buffer,n=new Uint16Array(e-t),o=0;for(let a=t,l=0;a<e;){n[l++]=r[a++],n[l++]=r[a++]-i;let h=n[l++]=r[a++]-i;n[l++]=r[a++]-t,o=Math.max(o,h)}return new s(n,o,this.set)}};Ch=class{cursor(t=0){return new fs(this,t)}getChild(t,e=null,i=null){let r=xy(this,t,e,i);return r.length?r[0]:null}getChildren(t,e=null,i=null){return xy(this,t,e,i)}resolve(t,e=0){return La(this,t,e,!1)}resolveInner(t,e=0){return La(this,t,e,!0)}matchContext(t){return Kd(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let r=e.lastChild;if(!r||r.to!=e.to)break;r.type.isError&&r.from==r.to?(i=e,e=r.prevSibling):e=r}return i}get node(){return this}get next(){return this.parent}},le=class s extends Ch{constructor(t,e,i,r){super(),this._tree=t,this.from=e,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,r,n=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,h=e>0?a.length:-1;t!=h;t+=e){let c=a[t],u=l[t]+o.from,d;if(!(!(n&tt.EnterBracketed&&c instanceof Y&&(d=fi.get(c))&&!d.overlay&&d.bracketed&&i>=u&&i<=u+c.length)&&!vy(r,i,u,u+c.length))){if(c instanceof pi){if(n&tt.ExcludeBuffers)continue;let f=c.findChild(0,c.buffer.length,e,i-u,r);if(f>-1)return new ds(new Jd(o,c,t,u),null,f)}else if(n&tt.IncludeAnonymous||!c.type.isAnonymous||ef(c)){let f;if(!(n&tt.IgnoreMounts)&&(f=fi.get(c))&&!f.overlay)return new s(f.tree,u,t,o);let p=new s(c,u,t,o);return n&tt.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(e<0?c.children.length-1:0,e,i,r,n)}}}if(n&tt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let r;if(!(i&tt.IgnoreOverlays)&&(r=fi.get(this._tree))&&r.overlay){let n=t-this.from,o=i&tt.EnterBracketed&&r.bracketed;for(let{from:a,to:l}of r.overlay)if((e>0||o?a<=n:a<n)&&(e<0||o?l>=n:l>n))return new s(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};Jd=class{constructor(t,e,i,r){this.parent=t,this.buffer=e,this.index=i,this.start=r}},ds=class s extends Ch{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new s(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&tt.ExcludeBuffers)return null;let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new s(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new s(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new s(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,r=this.index+4,n=i.buffer[this.index+3];if(n>r){let o=i.buffer[this.index+1];t.push(i.slice(r,n,o)),e.push(0)}return new Y(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};tf=class{constructor(t,e){this.heads=t,this.node=e}get next(){return Sy(this.heads)}};fs=class{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~tt.EnterBracketed,t instanceof le)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:r}=this.buffer;return this.type=e||r.set.types[r.buffer[t]],this.from=i+r.buffer[t+1],this.to=i+r.buffer[t+2],!0}yield(t){return t?t instanceof le?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:r}=this.buffer,n=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.buffer.start,i);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&tt.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&tt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&tt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(e.findChild(r,this.index,-1,0,4))}else{let r=e.buffer[this.index+3];if(r<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:r}=this;if(r){if(t>0){if(this.index<r.buffer.buffer.length)return!1}else for(let n=0;n<this.index;n++)if(r.buffer.buffer[n+3]<this.index)return!1;({index:e,parent:i}=r)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let n=e+t,o=t<0?-1:i._tree.children.length;n!=o;n+=t){let a=i._tree.children[n];if(this.mode&tt.IncludeAnonymous||a instanceof pi||!a.type.isAnonymous||ef(a))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let r=this.index,n=this.stack.length;n>=0;){for(let o=t;o;o=o._parent)if(o.index==r){if(r==this.index)return o;e=o,i=n+1;break t}r=this.stack[--n]}for(let r=i;r<this.stack.length;r++)e=new ds(this.buffer,e,this.stack[r]);return this.bufferNode=new ds(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let r=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&e&&e(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(t){if(!this.buffer)return Kd(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let r=t.length-1,n=this.stack.length-1;r>=0;n--){if(n<0)return Kd(this._tree,t,r);let o=i[e.buffer[this.stack[n]]];if(!o.isAnonymous){if(t[r]&&t[r]!=o.name)return!1;r--}}return!0}};wy=new WeakMap;ps=class{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let r=this.map.get(t);r||this.map.set(t,r=new Map),r.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof ds?this.setBuffer(t.context.buffer,t.index,e):t instanceof le&&this.map.set(t.tree,e)}get(t){return t instanceof ds?this.getBuffer(t.context.buffer,t.index):t instanceof le?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}},Fe=class s{constructor(t,e,i,r,n=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=r,this.open=(n?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let r=[new s(0,t.length,t,0,!1,i)];for(let n of e)n.to>t.length&&r.push(n);return r}static applyChanges(t,e,i=128){if(!e.length)return t;let r=[],n=1,o=t.length?t[0]:null;for(let a=0,l=0,h=0;;a++){let c=a<e.length?e[a]:null,u=c?c.fromA:1e9;if(u-l>=i)for(;o&&o.from<u;){let d=o;if(l>=d.from||u<=d.to||h){let f=Math.max(d.from,l)-h,p=Math.min(d.to,u)-h;d=f>=p?null:new s(f,p,d.tree,d.offset+h,a>0,!!c)}if(d&&r.push(d),o.to>u)break;o=n<t.length?t[n++]:null}if(!c)break;l=c.toA,h=c.toA-c.toB}return r}},He=class{startParse(t,e,i){return typeof t=="string"&&(t=new rf(t)),i=i?i.length?i.map(r=>new ae(r.from,r.to)):[new ae(0,0)]:[new ae(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let r=this.startParse(t,e,i);for(;;){let n=r.advance();if(n)return n}}},rf=class{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}};Ph=class{constructor(t,e,i,r,n,o){this.parser=t,this.parse=e,this.overlay=i,this.bracketed=r,this.target=n,this.from=o}};nf=class{constructor(t,e,i,r,n,o,a,l){this.parser=t,this.predicate=e,this.mounts=i,this.index=r,this.start=n,this.bracketed=o,this.target=a,this.prev=l,this.depth=0,this.ranges=[]}},of=new z({perNode:!0}),af=class{constructor(t,e,i,r,n){this.nest=e,this.input=i,this.fragments=r,this.ranges=n,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new Y(i.type,i.children,i.positions,i.length,i.propValues.concat([[of,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[z.mounted.id]=new fi(e,t.overlay,t.parser,t.bracketed),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new lf(this.fragments),e=null,i=null,r=new fs(new le(this.baseTree,this.ranges[0].from,0,null),tt.IncludeAnonymous|tt.IgnoreMounts);t:for(let n,o;;){let a=!0,l;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)a=!1;else if(t.hasNode(r)){if(e){let h=e.mounts.find(c=>c.frag.from<=r.from&&c.frag.to>=r.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let u=c.from+h.pos,d=c.to+h.pos;u>=r.from&&d<=r.to&&!e.ranges.some(f=>f.from<d&&f.to>u)&&e.ranges.push({from:u,to:d})}}a=!1}else if(i&&(o=l$(i.ranges,r.from,r.to)))a=o!=2;else if(!r.type.isAnonymous&&(n=this.nest(r,this.input))&&(r.from<r.to||!n.overlay)){r.tree||(h$(r),e&&e.depth++,i&&i.depth++);let h=t.findMounts(r.from,n.parser);if(typeof n.overlay=="function")e=new nf(n.parser,n.overlay,h,this.inner.length,r.from,!!n.bracketed,r.tree,e);else{let c=Ey(this.ranges,n.overlay||(r.from<r.to?[new ae(r.from,r.to)]:[]));c.length&&ky(c),(c.length||!n.overlay)&&this.inner.push(new Ph(n.parser,c.length?n.parser.startParse(this.input,Cy(h,c),c):n.parser.startParse(""),n.overlay?n.overlay.map(u=>new ae(u.from-r.from,u.to-r.from)):null,!!n.bracketed,r.tree,c.length?c[0].from:r.from)),n.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):a=!1}}else if(e&&(l=e.predicate(r))&&(l===!0&&(l=new ae(r.from,r.to)),l.from<l.to)){let h=e.ranges.length-1;h>=0&&e.ranges[h].to==l.from?e.ranges[h]={from:e.ranges[h].from,to:l.to}:e.ranges.push(l)}if(a&&r.firstChild())e&&e.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break t;if(e&&!--e.depth){let h=Ey(this.ranges,e.ranges);h.length&&(ky(h),this.inner.splice(e.index,0,new Ph(e.parser,e.parser.startParse(this.input,Cy(e.mounts,h),h),e.ranges.map(c=>new ae(c.from-e.start,c.to-e.start)),e.bracketed,e.target,h[0].from))),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}};Qh=class{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(tt.IncludeAnonymous|tt.IgnoreMounts)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from<i;)if(!(e.to>=t&&e.enter(i,1,tt.IgnoreOverlays|tt.ExcludeBuffers)))if(e.to<=t)e.next(!1)||(this.done=!0);else break}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof Y)e=e.children[0];else break}return!1}},lf=class{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(e=i.tree.prop(of))!==null&&e!==void 0?e:i.to,this.inner=new Qh(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(of))!==null&&t!==void 0?t:e.to,this.inner=new Qh(e.tree,-e.offset)}}findMounts(t,e){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let n=this.inner.cursor.node;n;n=n.parent){let o=(i=n.tree)===null||i===void 0?void 0:i.prop(z.mounted);if(o&&o.parser==e)for(let a=this.fragI;a<this.fragments.length;a++){let l=this.fragments[a];if(l.from>=n.to)break;l.tree==this.curFrag.tree&&r.push({frag:l,pos:n.from-l.offset,mount:o})}}}return r}}});function Ma(s,t=Uint16Array){if(typeof s!="string")return s;let e=null;for(let i=0,r=0;i<s.length;){let n=0;for(;;){let o=s.charCodeAt(i++),a=!1;if(o==126){n=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),n+=l,a)break;n*=46}e?e[r++]=n:e=new t(n)}return e}function Py(s,t,e,i,r,n){let o=0,a=1<<i,{dialect:l}=e.p.parser;t:for(;(a&s[o])!=0;){let h=s[o+1];for(let f=o+3;f<h;f+=2)if((s[f+1]&a)>0){let p=s[f];if(l.allows(p)&&(t.token.value==-1||t.token.value==p||u$(p,t.token.value,r,n))){t.acceptToken(p);break}}let c=t.next,u=0,d=s[o+2];if(t.next<0&&d>u&&s[h+d*3-3]==65535){o=s[h+d*3-1];continue t}for(;u<d;){let f=u+d>>1,p=h+f+(f<<1),m=s[p],b=s[p+1]||65536;if(c<m)d=f;else if(c>=b)u=f+1;else{o=s[p+2],t.advance();continue t}}break}}function Qy(s,t,e){for(let i=t,r;(r=s[i])!=65535;i++)if(r==e)return i-t;return-1}function u$(s,t,e,i){let r=Qy(e,i,t);return r<0||Qy(e,i,s)<r}function Ty(s,t,e){let i=s.cursor(tt.IncludeAnonymous);for(i.moveTo(t);;)if(!(e<0?i.childBefore(t):i.childAfter(t)))for(;;){if((e<0?i.to<t:i.from>t)&&!i.type.isError)return e<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(s.length,Math.max(i.from+1,t+25));if(e<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return e<0?0:s.length}}function Ly(s,t){for(let e=0;e<t.length;e++){let i=t[e];if(i.pos==s.pos&&i.sameState(s)){t[e].score<s.score&&(t[e]=s);return}}t.push(s)}function mi(s,t){return s[t]|s[t+1]<<16}function d$(s){let t=null;for(let e of s){let i=e.p.stoppedAt;(e.pos==e.p.stream.end||i!=null&&e.pos>i)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function My(s){if(s.external){let t=s.extend?1:0;return(e,i)=>s.external(e,i)<<1|t}return s.get}var Th,Lh,cf,uf,An,$y,Mh,Ni,gi,ft,xe,df,ff,pf,mf,gf,bf,bi,Ht,gs=B(()=>{Be();Th=class s{constructor(t,e,i,r,n,o,a,l,h,c=0,u){this.p=t,this.stack=e,this.state=i,this.reducePos=r,this.pos=n,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=h,this.lookAhead=c,this.parent=u}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let r=t.parser.context;return new s(t,[],e,i,i,0,[],0,r?new Lh(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,r=t&65535,{parser:n}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=n.dynamicPrecedence(r);if(a&&(this.score+=a),i==0){r<n.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(n.getGoto(this.state,r,!0),this.reducePos),r<n.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(i-1)*3-(t&262144?6:0),h=l?this.stack[l-2]:this.p.ranges[0].from;r<n.minRepeatTerm&&h==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-h;c>=2e3&&!(!((e=this.p.parser.nodeSet.types[r])===null||e===void 0)&&e.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=c));let u=l?this.stack[l-1]:0,d=this.bufferBase+this.buffer.length-u;if(r<n.minRepeatTerm||t&131072){let f=n.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,h,f,d+4,!0)}if(t&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=n.getGoto(f,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,h)}storeNode(t,e,i,r=4,n=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(e==i)return;if(this.buffer[o-2]>=e){this.buffer[o-2]=i;return}}}if(!n||this.pos==i)this.buffer.push(t,e,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=t,this.buffer[o+1]=e,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(t,e,i,r){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let n=t,{parser:o}=this.p;this.pos=r;let a=o.stateFlag(n,1);!a&&(r>i||e<=o.maxNode)&&(this.reducePos=r),this.pushState(n,a?i:Math.min(i,this.reducePos)),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,r,4)}else this.pos=r,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,r,4)}apply(t,e,i,r){t&65536?this.reduce(t):this.shift(t,e,i,r)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let r=this.pos;this.reducePos=this.pos=r+t.length,this.pushState(e,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&t.buffer[e-4]==0&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),r=t.bufferBase+e;for(;t&&r==t.bufferBase;)t=t.parent;return new s(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new cf(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(i==0)return!1;if((i&65536)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let r=[];for(let n=0,o;n<e.length;n+=2)(o=e[n+1])!=this.state&&this.p.parser.hasAction(o,t)&&r.push(e[n],o);if(this.stack.length<120)for(let n=0;r.length<8&&n<e.length;n+=2){let o=e[n+1];r.some((a,l)=>l&1&&a==o)||r.push(e[n],o)}e=r}let i=[];for(let r=0;r<e.length&&i.length<4;r+=2){let n=e[r+1];if(n==this.state)continue;let o=this.split();o.pushState(n,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(e[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let i=e>>19,r=e&65535,n=this.stack.length-i*3;if(n<0||t.getGoto(this.stack[n],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;e=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(r,n)=>{if(!e.includes(r))return e.push(r),t.allActions(r,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-n;if(a>1){let l=o&65535,h=this.stack.length-a*3;if(h>=0&&t.getGoto(this.stack[h],l,!1)>=0)return a<<19|65536|l}}else{let a=i(o,n+1);if(a!=null)return a}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new Lh(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},Lh=class{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}},cf=class{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=r}},uf=class s{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new s(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new s(this.stack,this.pos,this.index)}};An=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},$y=new An,Mh=class{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=$y,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,r=this.rangeIndex,n=this.pos+t;for(;n<i.from;){if(!r)return null;let o=this.ranges[--r];n-=i.from-o.to,i=o}for(;e<0?n>i.to:n>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];n+=o.from-i.to,i=o}return n}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,r;if(e>=0&&e<this.chunk.length)i=this.pos+t,r=this.chunk.charCodeAt(e);else{let n=this.resolveOffset(t,1);if(n==null)return-1;if(i=n,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=i;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=$y,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let r of this.ranges){if(r.from>=e)break;r.to>t&&(i+=this.input.read(Math.max(r.from,t),Math.min(r.to,e)))}return i}},Ni=class{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;Py(this.data,t,e,this.id,i.data,i.tokenPrecTable)}};Ni.prototype.contextual=Ni.prototype.fallback=Ni.prototype.extend=!1;gi=class{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data=typeof t=="string"?Ma(t):t}token(t,e){let i=t.pos,r=0;for(;;){let n=t.next<0,o=t.resolveOffset(1,1);if(Py(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,o==null)break;t.reset(o,t.token)}r&&(t.reset(i,t.token),t.acceptToken(this.elseToken,r))}};gi.prototype.contextual=Ni.prototype.fallback=Ni.prototype.extend=!1;ft=class{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}};xe=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),df=null;ff=class{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?Ty(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?Ty(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],r=this.index[e];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let n=i.children[r],o=this.start[e]+i.positions[r];if(o>t)return this.nextStart=o,null;if(n instanceof Y){if(o==t){if(o<this.safeFrom)return null;let a=o+n.length;if(a<=this.safeTo){let l=n.prop(z.lookAhead);if(!l||a+l<this.fragment.to)return n}}this.index[e]++,o+n.length>=Math.max(this.safeFrom,t)&&(this.trees.push(n),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+n.length}}},pf=class{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new An)}getActions(t){let e=0,i=null,{parser:r}=t.p,{tokenizers:n}=r,o=r.stateSlot(t.state,3),a=t.curContext?t.curContext.hash:0,l=0;for(let h=0;h<n.length;h++){if((1<<h&o)==0)continue;let c=n[h],u=this.tokens[h];if(!(i&&!c.fallback)&&((c.contextual||u.start!=t.pos||u.mask!=o||u.context!=a)&&(this.updateCachedToken(u,c,t),u.mask=o,u.context=a),u.lookAhead>u.end+25&&(l=Math.max(u.lookAhead,l)),u.value!=0)){let d=e;if(u.extended>-1&&(e=this.addActions(t,u.extended,u.end,e)),e=this.addActions(t,u.value,u.end,e),!c.extend&&(i=u,e>d))break}}for(;this.actions.length>e;)this.actions.pop();return l&&t.setLookAhead(l),!i&&t.pos==this.stream.end&&(i=new An,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new An,{pos:i,p:r}=t;return e.start=i,e.end=Math.min(i+1,r.stream.end),e.value=i==r.stream.end?r.parser.eofTerm:0,e}updateCachedToken(t,e,i){let r=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(r,t),i),t.value>-1){let{parser:n}=i.p;for(let o=0;o<n.specialized.length;o++)if(n.specialized[o]==t.value){let a=n.specializers[o](this.stream.read(t.start,t.end),i);if(a>=0&&i.p.parser.dialect.allows(a>>1)){(a&1)==0?t.value=a>>1:t.extended=a>>1;break}}}else t.value=0,t.end=this.stream.clipPos(r+1)}putAction(t,e,i,r){for(let n=0;n<r;n+=3)if(this.actions[n]==t)return r;return this.actions[r++]=t,this.actions[r++]=e,this.actions[r++]=i,r}addActions(t,e,i,r){let{state:n}=t,{parser:o}=t.p,{data:a}=o;for(let l=0;l<2;l++)for(let h=o.stateSlot(n,l?2:1);;h+=3){if(a[h]==65535)if(a[h+1]==1)h=mi(a,h+2);else{r==0&&a[h+1]==2&&(r=this.putAction(mi(a,h+2),e,i,r));break}a[h]==e&&(r=this.putAction(mi(a,h+1),e,i,r))}return r}},mf=class{constructor(t,e,i,r){this.parser=t,this.input=e,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Mh(e,r),this.tokens=new pf(t,this.stream),this.topTerm=t.top[1];let{from:n}=r[0];this.stacks=[Th.start(this,t.top[0],n)],this.fragments=i.length&&this.stream.end-n>t.bufferLength*4?new ff(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,i=this.stacks=[],r,n;if(this.bigReductionCount>300&&t.length==1){let[o]=t;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<t.length;o++){let a=t[o];for(;;){if(this.tokens.mainToken=null,a.pos>e)i.push(a);else{if(this.advanceStack(a,i,t))continue;{r||(r=[],n=[]),r.push(a);let l=this.tokens.getMainToken(a);n.push(l.value,l.end)}}break}}if(!i.length){let o=r&&d$(r);if(o)return xe&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw xe&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,n,i);if(o)return xe&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((a,l)=>l.score-a.score);i.length>o;)i.pop();i.some(a=>a.reducePos>e)&&this.recovering--}else if(i.length>1){t:for(let o=0;o<i.length-1;o++){let a=i[o];for(let l=o+1;l<i.length;l++){let h=i[l];if(a.sameState(h)||a.buffer.length>500&&h.buffer.length>500)if((a.score-h.score||a.buffer.length-h.buffer.length)>0)i.splice(l--,1);else{i.splice(o--,1);continue t}}}i.length>12&&(i.sort((o,a)=>a.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let r=t.pos,{parser:n}=this,o=xe?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let h=t.curContext&&t.curContext.tracker.strict,c=h?t.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let d=this.parser.nodeSet.types[u.type.id]==u.type?n.getGoto(t.state,u.type.id):-1;if(d>-1&&u.length&&(!h||(u.prop(z.contextHash)||0)==c))return t.useNode(u,d),xe&&console.log(o+this.stackID(t)+` (via reuse of ${n.getName(u.type.id)})`),!0;if(!(u instanceof Y)||u.children.length==0||u.positions[0]>0)break;let f=u.children[0];if(f instanceof Y&&u.positions[0]==0)u=f;else break}}let a=n.stateSlot(t.state,4);if(a>0)return t.reduce(a),xe&&console.log(o+this.stackID(t)+` (via always-reduce ${n.getName(a&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let l=this.tokens.getActions(t);for(let h=0;h<l.length;){let c=l[h++],u=l[h++],d=l[h++],f=h==l.length||!i,p=f?t:t.split(),m=this.tokens.mainToken;if(p.apply(c,u,m?m.start:p.pos,d),xe&&console.log(o+this.stackID(p)+` (via ${(c&65536)==0?"shift":`reduce of ${n.getName(c&65535)}`} for ${n.getName(u)} @ ${r}${p==t?"":", split"})`),f)return!0;p.pos>r?e.push(p):i.push(p)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return Ly(t,e),!0}}runRecovery(t,e,i){let r=null,n=!1;for(let o=0;o<t.length;o++){let a=t[o],l=e[o<<1],h=e[(o<<1)+1],c=xe?this.stackID(a)+" -> ":"";if(a.deadEnd&&(n||(n=!0,a.restart(),xe&&console.log(c+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let u=a.split(),d=c;for(let f=0;f<10&&u.forceReduce()&&(xe&&console.log(d+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));f++)xe&&(d=this.stackID(u)+" -> ");for(let f of a.recoverByInsert(l))xe&&console.log(c+this.stackID(f)+" (via recover-insert)"),this.advanceFully(f,i);this.stream.end>a.pos?(h==a.pos&&(h++,l=0),a.recoverByDelete(l,h),xe&&console.log(c+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),Ly(a,i)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(t){return t.close(),Y.build({buffer:uf.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(df||(df=new WeakMap)).get(t);return e||df.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}};gf=class{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||this.disabled[t]==0}},bf=s=>s,bi=class{constructor(t){this.start=t.start,this.shift=t.shift||bf,this.reduce=t.reduce||bf,this.reuse=t.reuse||bf,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}},Ht=class s extends He{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let a=0;a<t.repeatNodeCount;a++)e.push("");let i=Object.keys(t.topRules).map(a=>t.topRules[a][1]),r=[];for(let a=0;a<e.length;a++)r.push([]);function n(a,l,h){r[a].push([l,l.deserialize(String(h))])}if(t.nodeProps)for(let a of t.nodeProps){let l=a[0];typeof l=="string"&&(l=z[l]);for(let h=1;h<a.length;){let c=a[h++];if(c>=0)n(c,l,a[h++]);else{let u=a[h+-c];for(let d=-c;d>0;d--)n(a[h++],l,u);h++}}}this.nodeSet=new Ye(e.map((a,l)=>dt.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:i.indexOf(l)>-1,error:l==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(l)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=1024;let o=Ma(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(My),this.states=Ma(t.states,Uint32Array),this.data=Ma(t.stateData),this.goto=Ma(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(a=>typeof a=="number"?new Ni(o,a):a),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let r=new mf(this,t,e,i);for(let n of this.wrappers)r=n(r,t,e,i);return r}getGoto(t,e,i=!1){let r=this.goto;if(e>=r[0])return-1;for(let n=r[e+1];;){let o=r[n++],a=o&1,l=r[n++];if(a&&i)return l;for(let h=n+(o>>1);n<h;n++)if(r[n]==t)return l;if(a)return-1}}hasAction(t,e){let i=this.data;for(let r=0;r<2;r++)for(let n=this.stateSlot(t,r?2:1),o;;n+=3){if((o=i[n])==65535)if(i[n+1]==1)o=i[n=mi(i,n+2)];else{if(i[n+1]==2)return mi(i,n+2);break}if(o==e||o==0)return mi(i,n+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,i=>i==e?!0:null)}allActions(t,e){let i=this.stateSlot(t,4),r=i?e(i):void 0;for(let n=this.stateSlot(t,1);r==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=mi(this.data,n+2);else break;r=e(mi(this.data,n+1))}return r}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=mi(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];e.some((n,o)=>o&1&&n==r)||e.push(this.data[i],r)}}return e}configure(t){let e=Object.assign(Object.create(s.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(i=>{let r=t.tokenizers.find(n=>n.from==i);return r?r.to:i})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,r)=>{let n=t.specializers.find(a=>a.from==i.external);if(!n)return i;let o=Object.assign(Object.assign({},i),{external:n.to});return e.specializers[r]=My(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let n of t.split(" ")){let o=e.indexOf(n);o>=0&&(i[o]=!0)}let r=null;for(let n=0;n<e.length;n++)if(!i[n])for(let o=this.dialects[e[n]],a;(a=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[a]=1;return new gf(t,i,r)}static deserialize(t){return new s(t)}}});function m$(s,t){return s.length==t.length&&s.every((e,i)=>e==t[i])}function g$(s){let t=[[]];for(let e=0;e<s.length;e++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(s[e]));return t.sort((e,i)=>i.length-e.length)}function Lt(s){let t=Object.create(null);for(let e in s){let i=s[e];Array.isArray(i)||(i=[i]);for(let r of e.split(" "))if(r){let n=[],o=2,a=r;for(let u=0;;){if(a=="..."&&u>0&&u+3==r.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!d)throw new RangeError("Invalid path: "+r);if(n.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),u+=d[0].length,u==r.length)break;let f=r[u++];if(u==r.length&&f=="!"){o=0;break}if(f!="/")throw new RangeError("Invalid path: "+r);a=r.slice(u)}let l=n.length-1,h=n[l];if(!h)throw new RangeError("Invalid path: "+r);let c=new bs(i,o,l>0?n.slice(0,l):null);t[h]=c.sort(t[h])}}return Ry.add(t)}function Xh(s,t){let e=Object.create(null);for(let n of s)if(!Array.isArray(n.tag))e[n.tag.id]=n.class;else for(let o of n.tag)e[o.id]=n.class;let{scope:i,all:r=null}=t||{};return{style:n=>{let o=r;for(let a of n)for(let l of a.set){let h=e[l.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function b$(s,t){let e=null;for(let i of s){let r=i.style(t);r&&(e=e?e+" "+r:r)}return e}function Nh(s,t,e,i=0,r=s.length){let n=new Of(i,Array.isArray(t)?t:[t],e);n.highlightRange(s.cursor(),i,r,"",n.highlighters),n.flush(r)}function O$(s,t,e,i,r,n=0,o=s.length){let a=n;function l(h,c){if(!(h<=a)){for(let u=s.slice(a,h),d=0;;){let f=u.indexOf(`
10
+ See USAGE.md \xA7 Template parser \u2014 invariants + unsupported syntaxes.`),e[a]={t:"n",n:document.createTextNode(""),c:void 0,_fx:null}):e[a]={t:"a",n:r,name:l,c:void 0,_fx:null}}return e}function Oh(s){for(let t of s)t&&t._fx&&(t._fx(),t._fx=null)}function Pd(s){if(s.n.nodeType===1&&s.n[$d])return s.n;let t=document.createElement("span");return t.style.display="contents",t.setAttribute("role","presentation"),t[$d]=!0,s.n.replaceWith(t),s.n=t,t}function Qd(s,t){if(t!==s.c){if(s.t==="n")if(t!=null&&t._directive)t._commit(Pd(s));else if(zO(t))er(t,Pd(s));else if(Array.isArray(t)){let e=Pd(s);e.replaceChildren();for(let i of t)if(zO(i)){let r=document.createElement("span");r.style.display="contents",r.setAttribute("role","presentation"),e.appendChild(r),er(i,r)}else e.appendChild(document.createTextNode(i??""))}else if(t instanceof Node)s.n.replaceWith(t),s.n=t;else if(s.n[$d]){let e=document.createTextNode(t??"");s.n.replaceWith(e),s.n=e}else s.n.textContent=t??"";else if(s.t==="a")t==null||t===!1?s.n.removeAttribute(s.name):s.n.setAttribute(s.name,t===!0?"":t);else if(s.t==="p"){if(!s._resolved){let e=NO(s.n,s.name);e!==s.name&&(s.name=e),s._resolved=!0}s.n[s.name]=t}else s.t==="e"&&(_O(s.c)&&s.n.removeEventListener(s.name,s.c),_O(t)&&s.n.addEventListener(s.name,t));s.c=t}}function VE(s,t){for(let e=0;e<s.length;e++){let i=s[e];if(!i)continue;let r=t[e],n=i.t!=="e"&&typeof r=="function",o=!n&&i.t!=="e"&&Cd(r);if(i._fx&&!n&&!o&&(i._fx(),i._fx=null),n){i._fx||(i._fx=as(()=>Qd(i,r())));continue}if(o){i._fx||(i._fx=as(()=>Qd(i,r.value)));continue}Qd(i,r)}}function WE(s,t,e){return{_directive:!0,_commit(i){let r=i[ir]||new Map,n=new Map,o=[];for(let l=0;l<s.length;l++){let h=t(s[l],l);if(n.has(h))continue;o.push(h);let c=e(s[l],l);if(r.has(h)){let u=r.get(h);er(c,u),n.set(h,u)}else{let u=document.createElement("span");u.style.display="contents",u.setAttribute("role","presentation"),er(c,u),n.set(h,u)}}for(let[l,h]of r)n.has(l)||(h._i&&Oh(h._i.p),h.remove());let a=null;for(let l=o.length-1;l>=0;l--){let h=n.get(o[l]);(h.nextSibling!==a||h.parentNode!==i)&&i.insertBefore(h,a),a=h}i[ir]=n}}}var $d,ir,qO,XO,bh,wa,ZO,zO,_O,Td=B(()=>{"use strict";Ct();[$d,ir]=[Symbol(),Symbol()];qO=new WeakMap;XO={classname:"className",innertext:"innerText",innerhtml:"innerHTML",outerhtml:"outerHTML",textcontent:"textContent",tabindex:"tabIndex",arialabel:"ariaLabel",ariadescribedby:"ariaDescribedBy",arialabelledby:"ariaLabelledBy",ariarole:"role",contenteditable:"contentEditable",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",colspan:"colSpan",rowspan:"rowSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",usemap:"useMap",ismap:"isMap",accesskey:"accessKey",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",defaultselected:"defaultSelected"};bh="http://www.w3.org/2000/svg",wa="http://www.w3.org/1998/Math/MathML",ZO="http://www.w3.org/1999/xhtml";zO=s=>s!=null&&typeof s=="object"&&s.strings,_O=s=>typeof s=="function"||s!=null&&typeof s.handleEvent=="function"});function VO(s){if(!s.name)throw new Error("Trait requires a name");if(!s.setup)throw new Error(`Trait "${s.name}" requires a setup function`);if(!s.category)throw new Error(`Trait "${s.name}" requires a category`);if(!jO.has(s.category))throw new Error(`Trait "${s.name}" has unknown category "${s.category}". Known: ${[...jO].join(", ")}`);if(!s.description)throw new Error(`Trait "${s.name}" requires a description`);let t=Object.freeze({name:s.name,category:s.category,description:s.description,attributes:Object.freeze(s.attributes||[]),events:Object.freeze(s.events||[]),config:Object.freeze(s.config||[])});function e(){let i=null;return{schema:t,connect(r,n){i=s.setup({host:r,...n||{}})},disconnect(r){i&&(i(),i=null);for(let n of t.attributes)r.hasAttribute(n)&&(console.warn(`Trait "${t.name}": attribute "${n}" still present after disconnect`),r.removeAttribute(n))}}}return e.schema=t,yh.set(s.name,e),e}function WO(s){return yh.get(s)||null}function Zq(s){return yh.get(s)?.schema||null}function Bq(){return[...yh.keys()]}var yh,jO,Ld=B(()=>{"use strict";yh=new Map,jO=new Set(["input-interaction","keyboard-navigation","forms-data","layout-measurement","motion-positioning","animation-feedback","visual-dynamics","interaction-delight","audio-haptics-sensory"])});function UE(s,t){s[ka]=new Map,s[Md]=new Map;for(let[e,i]of Object.entries(t)){let r=i.attribute??e.toLowerCase(),n=i.type??String,o=qi(i.default??void 0);s[Md].set(e,o),Object.defineProperty(s,e,{get(){return o.value},set(a){let l=o.peek();Object.is(l,a)||(s[ka].set(e,l),o.value=a,i.reflect&&FE(s,r,a,n))},configurable:!0})}}function FE(s,t,e,i){i===Boolean?e?s.setAttribute(t,""):s.removeAttribute(t):e==null?s.removeAttribute(t):s.setAttribute(t,String(e))}function HE(s){if(Object.hasOwn(s,"_sa"))return;s._sa=!0;let t=s.styles;if(!t)return;let e=Array.isArray(t)?t:[t];document.adoptedStyleSheets=[...document.adoptedStyleSheets,...e.filter(i=>!document.adoptedStyleSheets.includes(i))]}function UO(s){if(Object.hasOwn(s,"_pp"))return;s._pp={};let t=s.parts;if(t)for(let[e,i]of Object.entries(t)){let r=document.createElement("template");r.innerHTML=i,s._pp[e]=r.content.firstElementChild}}var Md,ka,YE,x,$=B(()=>{"use strict";Ct();Td();Ct();Td();Ld();Md=Symbol(),ka=Symbol();YE=(s,t)=>t===Boolean?s!==null:t===Number?s===null?null:+s:s;x=class extends HTMLElement{static get properties(){return{}}static get traits(){return[]}static get observedAttributes(){let t=Object.entries(this.properties).map(([e,i])=>i.attribute??e.toLowerCase());return t.includes("traits")?t:[...t,"traits"]}#t=[];#e=[];#i=[];#s=null;#r=null;#n=null;#a=qi(0);constructor(){super(),this.internals=this.attachInternals(),UE(this,this.constructor.properties)}connectedCallback(){let t=this.constructor;t._tag||(t._tag=this.localName),HE(t),UO(t),F(()=>this.connected()),this.#t.push(as(()=>{for(let i of this[Md].values())i.value;this.#a.value;let e=t.template(this);if(e&&er(e,this),this.render(),this[ka].size){let i=new Map(this[ka]);this[ka].clear(),this.updated(i)}},{host:this.localName,onError:this.onError?e=>this.onError(e):null})),this.#n||(this.#n=new Set);for(let e of t.traits)this.#l(e);this.#c(),this.#s&&this.#o()}disconnectedCallback(){this._i&&Oh(this._i.p);for(let t of this.#t)t();this.#t.length=0;for(let t of this.#i)t.value=void 0;this.#i.length=0;for(let t of this.#e)t.disconnect(this);this.#e.length=0,this.#n?.clear(),this.#r?.(),this.#r=null,this.#s?.disconnect?.(this),this.disconnected()}#o(){let t=this.#s;t.connect?.(this),this.#r=t.subscribe?.(()=>{this.#a.value++})}get controller(){return this.#s}set controller(t){this.#r?.(),this.#r=null,this.#s?.disconnect?.(this),this.#s=t,t&&this.isConnected&&this.#o()}#l(t,{declarative:e=!1}={}){this.#n.add(t);let i=t();i.connect(this,{host:this,signal:qi,computed:Ed,effect:as}),e&&(i._declarative=!0),this.#e.push(i)}addTrait(t){return this.#n||(this.#n=new Set),this.#n.has(t)?this:(this.#l(t),this)}#c(){let t=this.getAttribute("traits");if(t)for(let e of t.split(/\s+/).filter(Boolean)){let i=WO(e);if(!i){console.warn(`<${this.localName}> traits="${e}" \u2014 trait not found. Did you forget to import it?`);continue}this.#n.has(i)||this.#l(i,{declarative:!0})}}#h(){if(!this.#n)return;let t=[];for(let e of this.#e)if(e._declarative){e.disconnect(this);for(let i of this.#n)if(i.schema?.name&&e.schema?.name===i.schema.name){this.#n.delete(i);break}}else t.push(e);this.#e.length=0,this.#e.push(...t),this.#c()}attributeChangedCallback(t,e,i){if(t==="traits"){this.isConnected&&this.#h();return}for(let[r,n]of Object.entries(this.constructor.properties))if((n.attribute??r.toLowerCase())===t){this[r]=YE(i,n.type??String);break}}static template=()=>null;static create(t={}){let e=this._tag??customElements.getName?.(this);if(!e)throw new Error("Component not registered");let i=document.createElement(e);for(let[r,n]of Object.entries(t))i[r]=n;return i}signal(t){let e=qi(t);return this.#i.push(e),e}ensure(t){for(let n of this.children)if(n.getAttribute("slot")===t)return n;let e=this.#d(t);if(e)return e;UO(this.constructor);let i=this.constructor._pp?.[t];if(!i)return null;let r=i.cloneNode(!0);return r._uiPart=!0,this.appendChild(r),r}drop(t){for(let i of this.children)if(i.getAttribute("slot")===t){i.remove();return}let e=this.#d(t);e&&e.remove()}#d(t){for(let e of this.querySelectorAll(`[slot="${t}"]`)){let i=e.parentElement,r=!0;for(;i&&i!==this;){if(i.localName.includes("-")){r=!1;break}i=i.parentElement}if(r&&i===this)return e}return null}reconcile(t,e,i,r){let n=t[ir]||new Map,o=new Map,a=[];for(let h=0;h<e.length;h++){let c=e[h],u=i(c,h);if(o.has(u))continue;let d=n.get(u);d?r(c,h,d):d=r(c,h,null),o.set(u,d),a.push(u)}for(let[h,c]of n)o.has(h)||c.remove();let l=null;for(let h=a.length-1;h>=0;h--){let c=o.get(a[h]);(c.nextSibling!==l||c.parentNode!==t)&&t.insertBefore(c,l),l=c}t[ir]=o}connected(){}render(){}disconnected(){}updated(t){}}});function vy(s,t,e,i){switch(s){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function La(s,t,e,i){for(var r;s.from==s.to||(e<1?s.from>=t:s.from>t)||(e>-1?s.to<=t:s.to<t);){let o=!i&&s instanceof le&&s.index<0?null:s.parent;if(!o)return s;s=o}let n=i?0:tt.IgnoreOverlays;if(i)for(let o=s,a=o.parent;a;o=a,a=o.parent)o instanceof le&&o.index<0&&((r=a.enter(t,e,n))===null||r===void 0?void 0:r.from)!=o.from&&(s=a);for(;;){let o=s.enter(t,e,n);if(!o)return s;s=o}}function xy(s,t,e,i){let r=s.cursor(),n=[];if(!r.firstChild())return n;if(e!=null){for(let o=!1;!o;)if(o=r.type.is(e),!r.nextSibling())return n}for(;;){if(i!=null&&r.type.is(i))return n;if(r.type.is(t)&&n.push(r.node),!r.nextSibling())return i==null?n:[]}}function Kd(s,t,e=t.length-1){for(let i=s;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}function Sy(s){if(!s.length)return null;let t=0,e=s[0];for(let n=1;n<s.length;n++){let o=s[n];(o.from>e.from||o.to<e.to)&&(e=o,t=n)}let i=e instanceof le&&e.index<0?null:e.parent,r=s.slice();return i?r[t]=i:r.splice(t,1),new tf(r,e)}function o$(s,t,e){let i=s.resolveInner(t,e),r=null;for(let n=i instanceof le?i:i.context.parent;n;n=n.parent)if(n.index<0){let o=n.parent;(r||(r=[i])).push(o.resolve(t,e)),n=o}else{let o=fi.get(n.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let a=new le(o.tree,o.overlay[0].from+n.from,-1,n);(r||(r=[i])).push(La(a,t,e,!1))}}return r?Sy(r):i}function ef(s){return s.children.some(t=>t instanceof pi||!t.type.isAnonymous||ef(t))}function a$(s){var t;let{buffer:e,nodeSet:i,maxBufferLength:r=1024,reused:n=[],minRepeatType:o=i.types.length}=s,a=Array.isArray(e)?new Gd(e,e.length):e,l=i.types,h=0,c=0;function u(k,E,A,C,T,Q){let{id:D,start:R,end:_,size:V}=a,U=c,J=h;if(V<0)if(a.next(),V==-1){let xt=n[D];A.push(xt),C.push(R-k);return}else if(V==-3){h=D;return}else if(V==-4){c=D;return}else throw new RangeError(`Unrecognized record size: ${V}`);let rt=l[D],ut,ot,bt=R-k;if(_-R<=r&&(ot=b(a.pos-E,T))){let xt=new Uint16Array(ot.size-ot.skip),Ot=a.pos-ot.size,Et=xt.length;for(;a.pos>Ot;)Et=g(ot.start,xt,Et);ut=new pi(xt,_-ot.start,i),bt=ot.start-k}else{let xt=a.pos-V;a.next();let Ot=[],Et=[],Tt=D>=o?D:-1,Ft=0,rs=_;for(;a.pos>xt;)Tt>=0&&a.id==Tt&&a.size>=0?(a.end<=rs-r&&(p(Ot,Et,R,Ft,a.end,rs,Tt,U,J),Ft=Ot.length,rs=a.end),a.next()):Q>2500?d(R,xt,Ot,Et):u(R,xt,Ot,Et,Tt,Q+1);if(Tt>=0&&Ft>0&&Ft<Ot.length&&p(Ot,Et,R,Ft,R,rs,Tt,U,J),Ot.reverse(),Et.reverse(),Tt>-1&&Ft>0){let wO=f(rt,J);ut=sf(rt,Ot,Et,0,Ot.length,0,_-R,wO,wO)}else ut=m(rt,Ot,Et,_-R,U-_,J)}A.push(ut),C.push(bt)}function d(k,E,A,C){let T=[],Q=0,D=-1;for(;a.pos>E;){let{id:R,start:_,end:V,size:U}=a;if(U>4)a.next();else{if(D>-1&&_<D)break;D<0&&(D=V-r),T.push(R,_,V),Q++,a.next()}}if(Q){let R=new Uint16Array(Q*4),_=T[T.length-2];for(let V=T.length-3,U=0;V>=0;V-=3)R[U++]=T[V],R[U++]=T[V+1]-_,R[U++]=T[V+2]-_,R[U++]=U;A.push(new pi(R,T[2]-_,i)),C.push(_-k)}}function f(k,E){return(A,C,T)=>{let Q=0,D=A.length-1,R,_;if(D>=0&&(R=A[D])instanceof Y){if(!D&&R.type==k&&R.length==T)return R;(_=R.prop(z.lookAhead))&&(Q=C[D]+R.length+_)}return m(k,A,C,T,Q,E)}}function p(k,E,A,C,T,Q,D,R,_){let V=[],U=[];for(;k.length>C;)V.push(k.pop()),U.push(E.pop()+A-T);k.push(m(i.types[D],V,U,Q-T,R-Q,_)),E.push(T-A)}function m(k,E,A,C,T,Q,D){if(Q){let R=[z.contextHash,Q];D=D?[R].concat(D):[R]}if(T>25){let R=[z.lookAhead,T];D=D?[R].concat(D):[R]}return new Y(k,E,A,C,D)}function b(k,E){let A=a.fork(),C=0,T=0,Q=0,D=A.end-r,R={size:0,start:0,skip:0};t:for(let _=A.pos-k;A.pos>_;){let V=A.size;if(A.id==E&&V>=0){R.size=C,R.start=T,R.skip=Q,Q+=4,C+=4,A.next();continue}let U=A.pos-V;if(V<0||U<_||A.start<D)break;let J=A.id>=o?4:0,rt=A.start;for(A.next();A.pos>U;){if(A.size<0)if(A.size==-3||A.size==-4)J+=4;else break t;else A.id>=o&&(J+=4);A.next()}T=rt,C+=V,Q+=J}return(E<0||C==k)&&(R.size=C,R.start=T,R.skip=Q),R.size>4?R:void 0}function g(k,E,A){let{id:C,start:T,end:Q,size:D}=a;if(a.next(),D>=0&&C<o){let R=A;if(D>4){let _=a.pos-(D-4);for(;a.pos>_;)A=g(k,E,A)}E[--A]=R,E[--A]=Q-k,E[--A]=T-k,E[--A]=C}else D==-3?h=C:D==-4&&(c=C);return A}let y=[],v=[];for(;a.pos>0;)u(s.start||0,s.bufferStart||0,y,v,-1,0);let w=(t=s.length)!==null&&t!==void 0?t:y.length?v[0]+y[0].length:0;return new Y(l[s.topID],y.reverse(),v.reverse(),w)}function $h(s,t){if(!s.isAnonymous||t instanceof pi||t.type!=s)return 1;let e=wy.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=s||!(i instanceof Y)){e=1;break}e+=$h(s,i)}wy.set(t,e)}return e}function sf(s,t,e,i,r,n,o,a,l){let h=0;for(let p=i;p<r;p++)h+=$h(s,t[p]);let c=Math.ceil(h*1.5/8),u=[],d=[];function f(p,m,b,g,y){for(let v=b;v<g;){let w=v,k=m[v],E=$h(s,p[v]);for(v++;v<g;v++){let A=$h(s,p[v]);if(E+A>=c)break;E+=A}if(v==w+1){if(E>c){let A=p[w];f(A.children,A.positions,0,A.children.length,m[w]+y);continue}u.push(p[w])}else{let A=m[v-1]+p[v-1].length-k;u.push(sf(s,p,m,w,v,k,A,null,l))}d.push(k+y-n)}}return f(t,e,i,r,0),(a||l)(u,d,o)}function ms(s){return(t,e,i,r)=>new af(t,s,e,i,r)}function ky(s){if(!s.length||s.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(s))}function l$(s,t,e){for(let i of s){if(i.from>=e)break;if(i.to>t)return i.from<=t&&i.to>=e?2:1}return 0}function Ay(s,t,e,i,r,n){if(t<e){let o=s.buffer[t+1];i.push(s.slice(t,e,o)),r.push(o-n)}}function h$(s){let{node:t}=s,e=[],i=t.context.buffer;do e.push(s.index),s.parent();while(!s.tree);let r=s.tree,n=r.children.indexOf(i),o=r.children[n],a=o.buffer,l=[n];function h(c,u,d,f,p,m){let b=e[m],g=[],y=[];Ay(o,c,b,g,y,f);let v=a[b+1],w=a[b+2];l.push(g.length);let k=m?h(b+4,a[b+3],o.set.types[a[b]],v,w-v,m-1):t.toTree();return g.push(k),y.push(v-f),Ay(o,a[b+3],u,g,y,f),new Y(d,g,y,p)}r.children[n]=h(0,a.length,dt.none,0,o.length,e.length-1);for(let c of l){let u=s.tree.children[c],d=s.tree.positions[c];s.yield(new le(u,d+s.from,c,s._tree))}}function Ey(s,t){let e=null,i=t;for(let r=1,n=0;r<s.length;r++){let o=s[r-1].to,a=s[r].from;for(;n<i.length;n++){let l=i[n];if(l.from>=a)break;l.to<=o||(e||(i=e=t.slice()),l.from<o?(e[n]=new ae(l.from,o),l.to>a&&e.splice(n+1,0,new ae(a,l.to))):l.to>a?e[n--]=new ae(a,l.to):e.splice(n--,1))}}return i}function c$(s,t,e,i){let r=0,n=0,o=!1,a=!1,l=-1e9,h=[];for(;;){let c=r==s.length?1e9:o?s[r].to:s[r].from,u=n==t.length?1e9:a?t[n].to:t[n].from;if(o!=a){let d=Math.max(l,e),f=Math.min(c,u,i);d<f&&h.push(new ae(d,f))}if(l=Math.min(c,u),l==1e9)break;c==l&&(o?(o=!1,r++):o=!0),u==l&&(a?(a=!1,n++):a=!0)}return h}function Cy(s,t){let e=[];for(let{pos:i,mount:r,frag:n}of s){let o=i+(r.overlay?r.overlay[0].from:0),a=o+r.tree.length,l=Math.max(n.from,o),h=Math.min(n.to,a);if(r.overlay){let c=r.overlay.map(d=>new ae(d.from+i,d.to+i)),u=c$(t,c,l,h);for(let d=0,f=l;;d++){let p=d==u.length,m=p?h:u[d].from;if(m>f&&e.push(new Fe(f,m,r.tree,-o,n.from>=f||n.openStart,n.to<=m||n.openEnd)),p)break;f=u[d].to}}else e.push(new Fe(l,h,r.tree,-o,n.from>=o||n.openStart,n.to<=a||n.openEnd))}return e}var hf,r$,ae,z,fi,n$,dt,Ye,Eh,yy,tt,Y,Gd,pi,Ch,le,Jd,ds,tf,fs,wy,ps,Fe,He,rf,Ph,nf,of,af,Qh,lf,Be=B(()=>{hf=1024,r$=0,ae=class{constructor(t,e){this.from=t,this.to=e}},z=class{constructor(t={}){this.id=r$++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=dt.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}};z.closedBy=new z({deserialize:s=>s.split(" ")}),z.openedBy=new z({deserialize:s=>s.split(" ")}),z.group=new z({deserialize:s=>s.split(" ")}),z.isolate=new z({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}}),z.contextHash=new z({perNode:!0}),z.lookAhead=new z({perNode:!0}),z.mounted=new z({perNode:!0});fi=class{constructor(t,e,i,r=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=r}static get(t){return t&&t.props&&t.props[z.mounted.id]}},n$=Object.create(null),dt=class s{constructor(t,e,i,r=0){this.name=t,this.props=e,this.id=i,this.flags=r}static define(t){let e=t.props&&t.props.length?Object.create(null):n$,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),r=new s(t.name||"",e,t.id,i);if(t.props){for(let n of t.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[n[0].id]=n[1]}}return r}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(z.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let r of i.split(" "))e[r]=t[i];return i=>{for(let r=i.prop(z.group),n=-1;n<(r?r.length:0);n++){let o=e[n<0?i.name:r[n]];if(o)return o}}}};dt.none=new dt("",Object.create(null),0,8);Ye=class s{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let r=null;for(let n of t){let o=n(i);if(o){r||(r=Object.assign({},i.props));let a=o[1],l=o[0];l.combine&&l.id in r&&(a=l.combine(r[l.id],a)),r[l.id]=a}}e.push(r?new dt(i.name,r,i.id,i.flags):i)}return new s(e)}},Eh=new WeakMap,yy=new WeakMap;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(tt||(tt={}));Y=class s{constructor(t,e,i,r,n){if(this.type=t,this.children=e,this.positions=i,this.length=r,this.props=null,n&&n.length){this.props=Object.create(null);for(let[o,a]of n)this.props[typeof o=="number"?o:o.id]=a}}toString(){let t=fi.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let r=i.toString();r&&(e&&(e+=","),e+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new fs(this.topNode,t)}cursorAt(t,e=0,i=0){let r=Eh.get(this)||this.topNode,n=new fs(r);return n.moveTo(t,e),Eh.set(this,n._tree),n}get topNode(){return new le(this,0,0,null)}resolve(t,e=0){let i=La(Eh.get(this)||this.topNode,t,e,!1);return Eh.set(this,i),i}resolveInner(t,e=0){let i=La(yy.get(this)||this.topNode,t,e,!0);return yy.set(this,i),i}resolveStack(t,e=0){return o$(this,t,e)}iterate(t){let{enter:e,leave:i,from:r=0,to:n=this.length}=t,o=t.mode||0,a=(o&tt.IncludeAnonymous)>0;for(let l=this.cursor(o|tt.IncludeAnonymous);;){let h=!1;if(l.from<=n&&l.to>=r&&(!a&&l.type.isAnonymous||e(l)!==!1)){if(l.firstChild())continue;h=!0}for(;h&&i&&(a||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;h=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:sf(dt.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,r)=>new s(this.type,e,i,r,this.propValues),t.makeTree||((e,i,r)=>new s(dt.none,e,i,r)))}static build(t){return a$(t)}};Y.empty=new Y(dt.none,[],[],0);Gd=class s{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new s(this.buffer,this.index)}},pi=class s{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return dt.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],r=this.set.types[e],n=r.name;if(/\W/.test(n)&&!r.isError&&(n=JSON.stringify(n)),t+=4,i==t)return n;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return n+"("+o.join(",")+")"}findChild(t,e,i,r,n){let{buffer:o}=this,a=-1;for(let l=t;l!=e&&!(vy(n,r,o[l+1],o[l+2])&&(a=l,i>0));l=o[l+3]);return a}slice(t,e,i){let r=this.buffer,n=new Uint16Array(e-t),o=0;for(let a=t,l=0;a<e;){n[l++]=r[a++],n[l++]=r[a++]-i;let h=n[l++]=r[a++]-i;n[l++]=r[a++]-t,o=Math.max(o,h)}return new s(n,o,this.set)}};Ch=class{cursor(t=0){return new fs(this,t)}getChild(t,e=null,i=null){let r=xy(this,t,e,i);return r.length?r[0]:null}getChildren(t,e=null,i=null){return xy(this,t,e,i)}resolve(t,e=0){return La(this,t,e,!1)}resolveInner(t,e=0){return La(this,t,e,!0)}matchContext(t){return Kd(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let r=e.lastChild;if(!r||r.to!=e.to)break;r.type.isError&&r.from==r.to?(i=e,e=r.prevSibling):e=r}return i}get node(){return this}get next(){return this.parent}},le=class s extends Ch{constructor(t,e,i,r){super(),this._tree=t,this.from=e,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,r,n=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,h=e>0?a.length:-1;t!=h;t+=e){let c=a[t],u=l[t]+o.from,d;if(!(!(n&tt.EnterBracketed&&c instanceof Y&&(d=fi.get(c))&&!d.overlay&&d.bracketed&&i>=u&&i<=u+c.length)&&!vy(r,i,u,u+c.length))){if(c instanceof pi){if(n&tt.ExcludeBuffers)continue;let f=c.findChild(0,c.buffer.length,e,i-u,r);if(f>-1)return new ds(new Jd(o,c,t,u),null,f)}else if(n&tt.IncludeAnonymous||!c.type.isAnonymous||ef(c)){let f;if(!(n&tt.IgnoreMounts)&&(f=fi.get(c))&&!f.overlay)return new s(f.tree,u,t,o);let p=new s(c,u,t,o);return n&tt.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(e<0?c.children.length-1:0,e,i,r,n)}}}if(n&tt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let r;if(!(i&tt.IgnoreOverlays)&&(r=fi.get(this._tree))&&r.overlay){let n=t-this.from,o=i&tt.EnterBracketed&&r.bracketed;for(let{from:a,to:l}of r.overlay)if((e>0||o?a<=n:a<n)&&(e<0||o?l>=n:l>n))return new s(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};Jd=class{constructor(t,e,i,r){this.parent=t,this.buffer=e,this.index=i,this.start=r}},ds=class s extends Ch{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new s(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&tt.ExcludeBuffers)return null;let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new s(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new s(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new s(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,r=this.index+4,n=i.buffer[this.index+3];if(n>r){let o=i.buffer[this.index+1];t.push(i.slice(r,n,o)),e.push(0)}return new Y(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};tf=class{constructor(t,e){this.heads=t,this.node=e}get next(){return Sy(this.heads)}};fs=class{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~tt.EnterBracketed,t instanceof le)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:r}=this.buffer;return this.type=e||r.set.types[r.buffer[t]],this.from=i+r.buffer[t+1],this.to=i+r.buffer[t+2],!0}yield(t){return t?t instanceof le?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:r}=this.buffer,n=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.buffer.start,i);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&tt.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&tt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&tt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(e.findChild(r,this.index,-1,0,4))}else{let r=e.buffer[this.index+3];if(r<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:r}=this;if(r){if(t>0){if(this.index<r.buffer.buffer.length)return!1}else for(let n=0;n<this.index;n++)if(r.buffer.buffer[n+3]<this.index)return!1;({index:e,parent:i}=r)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let n=e+t,o=t<0?-1:i._tree.children.length;n!=o;n+=t){let a=i._tree.children[n];if(this.mode&tt.IncludeAnonymous||a instanceof pi||!a.type.isAnonymous||ef(a))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let r=this.index,n=this.stack.length;n>=0;){for(let o=t;o;o=o._parent)if(o.index==r){if(r==this.index)return o;e=o,i=n+1;break t}r=this.stack[--n]}for(let r=i;r<this.stack.length;r++)e=new ds(this.buffer,e,this.stack[r]);return this.bufferNode=new ds(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let r=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&e&&e(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(t){if(!this.buffer)return Kd(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let r=t.length-1,n=this.stack.length-1;r>=0;n--){if(n<0)return Kd(this._tree,t,r);let o=i[e.buffer[this.stack[n]]];if(!o.isAnonymous){if(t[r]&&t[r]!=o.name)return!1;r--}}return!0}};wy=new WeakMap;ps=class{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let r=this.map.get(t);r||this.map.set(t,r=new Map),r.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof ds?this.setBuffer(t.context.buffer,t.index,e):t instanceof le&&this.map.set(t.tree,e)}get(t){return t instanceof ds?this.getBuffer(t.context.buffer,t.index):t instanceof le?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}},Fe=class s{constructor(t,e,i,r,n=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=r,this.open=(n?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let r=[new s(0,t.length,t,0,!1,i)];for(let n of e)n.to>t.length&&r.push(n);return r}static applyChanges(t,e,i=128){if(!e.length)return t;let r=[],n=1,o=t.length?t[0]:null;for(let a=0,l=0,h=0;;a++){let c=a<e.length?e[a]:null,u=c?c.fromA:1e9;if(u-l>=i)for(;o&&o.from<u;){let d=o;if(l>=d.from||u<=d.to||h){let f=Math.max(d.from,l)-h,p=Math.min(d.to,u)-h;d=f>=p?null:new s(f,p,d.tree,d.offset+h,a>0,!!c)}if(d&&r.push(d),o.to>u)break;o=n<t.length?t[n++]:null}if(!c)break;l=c.toA,h=c.toA-c.toB}return r}},He=class{startParse(t,e,i){return typeof t=="string"&&(t=new rf(t)),i=i?i.length?i.map(r=>new ae(r.from,r.to)):[new ae(0,0)]:[new ae(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let r=this.startParse(t,e,i);for(;;){let n=r.advance();if(n)return n}}},rf=class{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}};Ph=class{constructor(t,e,i,r,n,o){this.parser=t,this.parse=e,this.overlay=i,this.bracketed=r,this.target=n,this.from=o}};nf=class{constructor(t,e,i,r,n,o,a,l){this.parser=t,this.predicate=e,this.mounts=i,this.index=r,this.start=n,this.bracketed=o,this.target=a,this.prev=l,this.depth=0,this.ranges=[]}},of=new z({perNode:!0}),af=class{constructor(t,e,i,r,n){this.nest=e,this.input=i,this.fragments=r,this.ranges=n,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new Y(i.type,i.children,i.positions,i.length,i.propValues.concat([[of,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[z.mounted.id]=new fi(e,t.overlay,t.parser,t.bracketed),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new lf(this.fragments),e=null,i=null,r=new fs(new le(this.baseTree,this.ranges[0].from,0,null),tt.IncludeAnonymous|tt.IgnoreMounts);t:for(let n,o;;){let a=!0,l;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)a=!1;else if(t.hasNode(r)){if(e){let h=e.mounts.find(c=>c.frag.from<=r.from&&c.frag.to>=r.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let u=c.from+h.pos,d=c.to+h.pos;u>=r.from&&d<=r.to&&!e.ranges.some(f=>f.from<d&&f.to>u)&&e.ranges.push({from:u,to:d})}}a=!1}else if(i&&(o=l$(i.ranges,r.from,r.to)))a=o!=2;else if(!r.type.isAnonymous&&(n=this.nest(r,this.input))&&(r.from<r.to||!n.overlay)){r.tree||(h$(r),e&&e.depth++,i&&i.depth++);let h=t.findMounts(r.from,n.parser);if(typeof n.overlay=="function")e=new nf(n.parser,n.overlay,h,this.inner.length,r.from,!!n.bracketed,r.tree,e);else{let c=Ey(this.ranges,n.overlay||(r.from<r.to?[new ae(r.from,r.to)]:[]));c.length&&ky(c),(c.length||!n.overlay)&&this.inner.push(new Ph(n.parser,c.length?n.parser.startParse(this.input,Cy(h,c),c):n.parser.startParse(""),n.overlay?n.overlay.map(u=>new ae(u.from-r.from,u.to-r.from)):null,!!n.bracketed,r.tree,c.length?c[0].from:r.from)),n.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):a=!1}}else if(e&&(l=e.predicate(r))&&(l===!0&&(l=new ae(r.from,r.to)),l.from<l.to)){let h=e.ranges.length-1;h>=0&&e.ranges[h].to==l.from?e.ranges[h]={from:e.ranges[h].from,to:l.to}:e.ranges.push(l)}if(a&&r.firstChild())e&&e.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break t;if(e&&!--e.depth){let h=Ey(this.ranges,e.ranges);h.length&&(ky(h),this.inner.splice(e.index,0,new Ph(e.parser,e.parser.startParse(this.input,Cy(e.mounts,h),h),e.ranges.map(c=>new ae(c.from-e.start,c.to-e.start)),e.bracketed,e.target,h[0].from))),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}};Qh=class{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(tt.IncludeAnonymous|tt.IgnoreMounts)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from<i;)if(!(e.to>=t&&e.enter(i,1,tt.IgnoreOverlays|tt.ExcludeBuffers)))if(e.to<=t)e.next(!1)||(this.done=!0);else break}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof Y)e=e.children[0];else break}return!1}},lf=class{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(e=i.tree.prop(of))!==null&&e!==void 0?e:i.to,this.inner=new Qh(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(of))!==null&&t!==void 0?t:e.to,this.inner=new Qh(e.tree,-e.offset)}}findMounts(t,e){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let n=this.inner.cursor.node;n;n=n.parent){let o=(i=n.tree)===null||i===void 0?void 0:i.prop(z.mounted);if(o&&o.parser==e)for(let a=this.fragI;a<this.fragments.length;a++){let l=this.fragments[a];if(l.from>=n.to)break;l.tree==this.curFrag.tree&&r.push({frag:l,pos:n.from-l.offset,mount:o})}}}return r}}});function Ma(s,t=Uint16Array){if(typeof s!="string")return s;let e=null;for(let i=0,r=0;i<s.length;){let n=0;for(;;){let o=s.charCodeAt(i++),a=!1;if(o==126){n=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),n+=l,a)break;n*=46}e?e[r++]=n:e=new t(n)}return e}function Py(s,t,e,i,r,n){let o=0,a=1<<i,{dialect:l}=e.p.parser;t:for(;(a&s[o])!=0;){let h=s[o+1];for(let f=o+3;f<h;f+=2)if((s[f+1]&a)>0){let p=s[f];if(l.allows(p)&&(t.token.value==-1||t.token.value==p||u$(p,t.token.value,r,n))){t.acceptToken(p);break}}let c=t.next,u=0,d=s[o+2];if(t.next<0&&d>u&&s[h+d*3-3]==65535){o=s[h+d*3-1];continue t}for(;u<d;){let f=u+d>>1,p=h+f+(f<<1),m=s[p],b=s[p+1]||65536;if(c<m)d=f;else if(c>=b)u=f+1;else{o=s[p+2],t.advance();continue t}}break}}function Qy(s,t,e){for(let i=t,r;(r=s[i])!=65535;i++)if(r==e)return i-t;return-1}function u$(s,t,e,i){let r=Qy(e,i,t);return r<0||Qy(e,i,s)<r}function Ty(s,t,e){let i=s.cursor(tt.IncludeAnonymous);for(i.moveTo(t);;)if(!(e<0?i.childBefore(t):i.childAfter(t)))for(;;){if((e<0?i.to<t:i.from>t)&&!i.type.isError)return e<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(s.length,Math.max(i.from+1,t+25));if(e<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return e<0?0:s.length}}function Ly(s,t){for(let e=0;e<t.length;e++){let i=t[e];if(i.pos==s.pos&&i.sameState(s)){t[e].score<s.score&&(t[e]=s);return}}t.push(s)}function mi(s,t){return s[t]|s[t+1]<<16}function d$(s){let t=null;for(let e of s){let i=e.p.stoppedAt;(e.pos==e.p.stream.end||i!=null&&e.pos>i)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function My(s){if(s.external){let t=s.extend?1:0;return(e,i)=>s.external(e,i)<<1|t}return s.get}var Th,Lh,cf,uf,An,$y,Mh,Ni,gi,ft,xe,df,ff,pf,mf,gf,bf,bi,Ht,gs=B(()=>{Be();Th=class s{constructor(t,e,i,r,n,o,a,l,h,c=0,u){this.p=t,this.stack=e,this.state=i,this.reducePos=r,this.pos=n,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=h,this.lookAhead=c,this.parent=u}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let r=t.parser.context;return new s(t,[],e,i,i,0,[],0,r?new Lh(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,r=t&65535,{parser:n}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=n.dynamicPrecedence(r);if(a&&(this.score+=a),i==0){r<n.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(n.getGoto(this.state,r,!0),this.reducePos),r<n.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(i-1)*3-(t&262144?6:0),h=l?this.stack[l-2]:this.p.ranges[0].from;r<n.minRepeatTerm&&h==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-h;c>=2e3&&!(!((e=this.p.parser.nodeSet.types[r])===null||e===void 0)&&e.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=c));let u=l?this.stack[l-1]:0,d=this.bufferBase+this.buffer.length-u;if(r<n.minRepeatTerm||t&131072){let f=n.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,h,f,d+4,!0)}if(t&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=n.getGoto(f,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,h)}storeNode(t,e,i,r=4,n=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(e==i)return;if(this.buffer[o-2]>=e){this.buffer[o-2]=i;return}}}if(!n||this.pos==i)this.buffer.push(t,e,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=t,this.buffer[o+1]=e,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(t,e,i,r){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let n=t,{parser:o}=this.p;this.pos=r;let a=o.stateFlag(n,1);!a&&(r>i||e<=o.maxNode)&&(this.reducePos=r),this.pushState(n,a?i:Math.min(i,this.reducePos)),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,r,4)}else this.pos=r,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,r,4)}apply(t,e,i,r){t&65536?this.reduce(t):this.shift(t,e,i,r)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let r=this.pos;this.reducePos=this.pos=r+t.length,this.pushState(e,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&t.buffer[e-4]==0&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),r=t.bufferBase+e;for(;t&&r==t.bufferBase;)t=t.parent;return new s(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new cf(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(i==0)return!1;if((i&65536)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let r=[];for(let n=0,o;n<e.length;n+=2)(o=e[n+1])!=this.state&&this.p.parser.hasAction(o,t)&&r.push(e[n],o);if(this.stack.length<120)for(let n=0;r.length<8&&n<e.length;n+=2){let o=e[n+1];r.some((a,l)=>l&1&&a==o)||r.push(e[n],o)}e=r}let i=[];for(let r=0;r<e.length&&i.length<4;r+=2){let n=e[r+1];if(n==this.state)continue;let o=this.split();o.pushState(n,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(e[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let i=e>>19,r=e&65535,n=this.stack.length-i*3;if(n<0||t.getGoto(this.stack[n],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;e=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(r,n)=>{if(!e.includes(r))return e.push(r),t.allActions(r,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-n;if(a>1){let l=o&65535,h=this.stack.length-a*3;if(h>=0&&t.getGoto(this.stack[h],l,!1)>=0)return a<<19|65536|l}}else{let a=i(o,n+1);if(a!=null)return a}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new Lh(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},Lh=class{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}},cf=class{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=r}},uf=class s{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new s(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new s(this.stack,this.pos,this.index)}};An=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},$y=new An,Mh=class{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=$y,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,r=this.rangeIndex,n=this.pos+t;for(;n<i.from;){if(!r)return null;let o=this.ranges[--r];n-=i.from-o.to,i=o}for(;e<0?n>i.to:n>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];n+=o.from-i.to,i=o}return n}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,r;if(e>=0&&e<this.chunk.length)i=this.pos+t,r=this.chunk.charCodeAt(e);else{let n=this.resolveOffset(t,1);if(n==null)return-1;if(i=n,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=i;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=$y,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let r of this.ranges){if(r.from>=e)break;r.to>t&&(i+=this.input.read(Math.max(r.from,t),Math.min(r.to,e)))}return i}},Ni=class{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;Py(this.data,t,e,this.id,i.data,i.tokenPrecTable)}};Ni.prototype.contextual=Ni.prototype.fallback=Ni.prototype.extend=!1;gi=class{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data=typeof t=="string"?Ma(t):t}token(t,e){let i=t.pos,r=0;for(;;){let n=t.next<0,o=t.resolveOffset(1,1);if(Py(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,o==null)break;t.reset(o,t.token)}r&&(t.reset(i,t.token),t.acceptToken(this.elseToken,r))}};gi.prototype.contextual=Ni.prototype.fallback=Ni.prototype.extend=!1;ft=class{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}};xe=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),df=null;ff=class{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?Ty(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?Ty(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],r=this.index[e];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let n=i.children[r],o=this.start[e]+i.positions[r];if(o>t)return this.nextStart=o,null;if(n instanceof Y){if(o==t){if(o<this.safeFrom)return null;let a=o+n.length;if(a<=this.safeTo){let l=n.prop(z.lookAhead);if(!l||a+l<this.fragment.to)return n}}this.index[e]++,o+n.length>=Math.max(this.safeFrom,t)&&(this.trees.push(n),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+n.length}}},pf=class{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new An)}getActions(t){let e=0,i=null,{parser:r}=t.p,{tokenizers:n}=r,o=r.stateSlot(t.state,3),a=t.curContext?t.curContext.hash:0,l=0;for(let h=0;h<n.length;h++){if((1<<h&o)==0)continue;let c=n[h],u=this.tokens[h];if(!(i&&!c.fallback)&&((c.contextual||u.start!=t.pos||u.mask!=o||u.context!=a)&&(this.updateCachedToken(u,c,t),u.mask=o,u.context=a),u.lookAhead>u.end+25&&(l=Math.max(u.lookAhead,l)),u.value!=0)){let d=e;if(u.extended>-1&&(e=this.addActions(t,u.extended,u.end,e)),e=this.addActions(t,u.value,u.end,e),!c.extend&&(i=u,e>d))break}}for(;this.actions.length>e;)this.actions.pop();return l&&t.setLookAhead(l),!i&&t.pos==this.stream.end&&(i=new An,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new An,{pos:i,p:r}=t;return e.start=i,e.end=Math.min(i+1,r.stream.end),e.value=i==r.stream.end?r.parser.eofTerm:0,e}updateCachedToken(t,e,i){let r=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(r,t),i),t.value>-1){let{parser:n}=i.p;for(let o=0;o<n.specialized.length;o++)if(n.specialized[o]==t.value){let a=n.specializers[o](this.stream.read(t.start,t.end),i);if(a>=0&&i.p.parser.dialect.allows(a>>1)){(a&1)==0?t.value=a>>1:t.extended=a>>1;break}}}else t.value=0,t.end=this.stream.clipPos(r+1)}putAction(t,e,i,r){for(let n=0;n<r;n+=3)if(this.actions[n]==t)return r;return this.actions[r++]=t,this.actions[r++]=e,this.actions[r++]=i,r}addActions(t,e,i,r){let{state:n}=t,{parser:o}=t.p,{data:a}=o;for(let l=0;l<2;l++)for(let h=o.stateSlot(n,l?2:1);;h+=3){if(a[h]==65535)if(a[h+1]==1)h=mi(a,h+2);else{r==0&&a[h+1]==2&&(r=this.putAction(mi(a,h+2),e,i,r));break}a[h]==e&&(r=this.putAction(mi(a,h+1),e,i,r))}return r}},mf=class{constructor(t,e,i,r){this.parser=t,this.input=e,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Mh(e,r),this.tokens=new pf(t,this.stream),this.topTerm=t.top[1];let{from:n}=r[0];this.stacks=[Th.start(this,t.top[0],n)],this.fragments=i.length&&this.stream.end-n>t.bufferLength*4?new ff(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,i=this.stacks=[],r,n;if(this.bigReductionCount>300&&t.length==1){let[o]=t;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<t.length;o++){let a=t[o];for(;;){if(this.tokens.mainToken=null,a.pos>e)i.push(a);else{if(this.advanceStack(a,i,t))continue;{r||(r=[],n=[]),r.push(a);let l=this.tokens.getMainToken(a);n.push(l.value,l.end)}}break}}if(!i.length){let o=r&&d$(r);if(o)return xe&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw xe&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,n,i);if(o)return xe&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((a,l)=>l.score-a.score);i.length>o;)i.pop();i.some(a=>a.reducePos>e)&&this.recovering--}else if(i.length>1){t:for(let o=0;o<i.length-1;o++){let a=i[o];for(let l=o+1;l<i.length;l++){let h=i[l];if(a.sameState(h)||a.buffer.length>500&&h.buffer.length>500)if((a.score-h.score||a.buffer.length-h.buffer.length)>0)i.splice(l--,1);else{i.splice(o--,1);continue t}}}i.length>12&&(i.sort((o,a)=>a.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let r=t.pos,{parser:n}=this,o=xe?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let h=t.curContext&&t.curContext.tracker.strict,c=h?t.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let d=this.parser.nodeSet.types[u.type.id]==u.type?n.getGoto(t.state,u.type.id):-1;if(d>-1&&u.length&&(!h||(u.prop(z.contextHash)||0)==c))return t.useNode(u,d),xe&&console.log(o+this.stackID(t)+` (via reuse of ${n.getName(u.type.id)})`),!0;if(!(u instanceof Y)||u.children.length==0||u.positions[0]>0)break;let f=u.children[0];if(f instanceof Y&&u.positions[0]==0)u=f;else break}}let a=n.stateSlot(t.state,4);if(a>0)return t.reduce(a),xe&&console.log(o+this.stackID(t)+` (via always-reduce ${n.getName(a&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let l=this.tokens.getActions(t);for(let h=0;h<l.length;){let c=l[h++],u=l[h++],d=l[h++],f=h==l.length||!i,p=f?t:t.split(),m=this.tokens.mainToken;if(p.apply(c,u,m?m.start:p.pos,d),xe&&console.log(o+this.stackID(p)+` (via ${(c&65536)==0?"shift":`reduce of ${n.getName(c&65535)}`} for ${n.getName(u)} @ ${r}${p==t?"":", split"})`),f)return!0;p.pos>r?e.push(p):i.push(p)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return Ly(t,e),!0}}runRecovery(t,e,i){let r=null,n=!1;for(let o=0;o<t.length;o++){let a=t[o],l=e[o<<1],h=e[(o<<1)+1],c=xe?this.stackID(a)+" -> ":"";if(a.deadEnd&&(n||(n=!0,a.restart(),xe&&console.log(c+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let u=a.split(),d=c;for(let f=0;f<10&&u.forceReduce()&&(xe&&console.log(d+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));f++)xe&&(d=this.stackID(u)+" -> ");for(let f of a.recoverByInsert(l))xe&&console.log(c+this.stackID(f)+" (via recover-insert)"),this.advanceFully(f,i);this.stream.end>a.pos?(h==a.pos&&(h++,l=0),a.recoverByDelete(l,h),xe&&console.log(c+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),Ly(a,i)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(t){return t.close(),Y.build({buffer:uf.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(df||(df=new WeakMap)).get(t);return e||df.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}};gf=class{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||this.disabled[t]==0}},bf=s=>s,bi=class{constructor(t){this.start=t.start,this.shift=t.shift||bf,this.reduce=t.reduce||bf,this.reuse=t.reuse||bf,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}},Ht=class s extends He{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let a=0;a<t.repeatNodeCount;a++)e.push("");let i=Object.keys(t.topRules).map(a=>t.topRules[a][1]),r=[];for(let a=0;a<e.length;a++)r.push([]);function n(a,l,h){r[a].push([l,l.deserialize(String(h))])}if(t.nodeProps)for(let a of t.nodeProps){let l=a[0];typeof l=="string"&&(l=z[l]);for(let h=1;h<a.length;){let c=a[h++];if(c>=0)n(c,l,a[h++]);else{let u=a[h+-c];for(let d=-c;d>0;d--)n(a[h++],l,u);h++}}}this.nodeSet=new Ye(e.map((a,l)=>dt.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:i.indexOf(l)>-1,error:l==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(l)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=1024;let o=Ma(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(My),this.states=Ma(t.states,Uint32Array),this.data=Ma(t.stateData),this.goto=Ma(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(a=>typeof a=="number"?new Ni(o,a):a),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let r=new mf(this,t,e,i);for(let n of this.wrappers)r=n(r,t,e,i);return r}getGoto(t,e,i=!1){let r=this.goto;if(e>=r[0])return-1;for(let n=r[e+1];;){let o=r[n++],a=o&1,l=r[n++];if(a&&i)return l;for(let h=n+(o>>1);n<h;n++)if(r[n]==t)return l;if(a)return-1}}hasAction(t,e){let i=this.data;for(let r=0;r<2;r++)for(let n=this.stateSlot(t,r?2:1),o;;n+=3){if((o=i[n])==65535)if(i[n+1]==1)o=i[n=mi(i,n+2)];else{if(i[n+1]==2)return mi(i,n+2);break}if(o==e||o==0)return mi(i,n+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,i=>i==e?!0:null)}allActions(t,e){let i=this.stateSlot(t,4),r=i?e(i):void 0;for(let n=this.stateSlot(t,1);r==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=mi(this.data,n+2);else break;r=e(mi(this.data,n+1))}return r}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=mi(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];e.some((n,o)=>o&1&&n==r)||e.push(this.data[i],r)}}return e}configure(t){let e=Object.assign(Object.create(s.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(i=>{let r=t.tokenizers.find(n=>n.from==i);return r?r.to:i})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,r)=>{let n=t.specializers.find(a=>a.from==i.external);if(!n)return i;let o=Object.assign(Object.assign({},i),{external:n.to});return e.specializers[r]=My(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let n of t.split(" ")){let o=e.indexOf(n);o>=0&&(i[o]=!0)}let r=null;for(let n=0;n<e.length;n++)if(!i[n])for(let o=this.dialects[e[n]],a;(a=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[a]=1;return new gf(t,i,r)}static deserialize(t){return new s(t)}}});function m$(s,t){return s.length==t.length&&s.every((e,i)=>e==t[i])}function g$(s){let t=[[]];for(let e=0;e<s.length;e++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(s[e]));return t.sort((e,i)=>i.length-e.length)}function Lt(s){let t=Object.create(null);for(let e in s){let i=s[e];Array.isArray(i)||(i=[i]);for(let r of e.split(" "))if(r){let n=[],o=2,a=r;for(let u=0;;){if(a=="..."&&u>0&&u+3==r.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!d)throw new RangeError("Invalid path: "+r);if(n.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),u+=d[0].length,u==r.length)break;let f=r[u++];if(u==r.length&&f=="!"){o=0;break}if(f!="/")throw new RangeError("Invalid path: "+r);a=r.slice(u)}let l=n.length-1,h=n[l];if(!h)throw new RangeError("Invalid path: "+r);let c=new bs(i,o,l>0?n.slice(0,l):null);t[h]=c.sort(t[h])}}return Ry.add(t)}function Xh(s,t){let e=Object.create(null);for(let n of s)if(!Array.isArray(n.tag))e[n.tag.id]=n.class;else for(let o of n.tag)e[o.id]=n.class;let{scope:i,all:r=null}=t||{};return{style:n=>{let o=r;for(let a of n)for(let l of a.set){let h=e[l.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function b$(s,t){let e=null;for(let i of s){let r=i.style(t);r&&(e=e?e+" "+r:r)}return e}function Nh(s,t,e,i=0,r=s.length){let n=new Of(i,Array.isArray(t)?t:[t],e);n.highlightRange(s.cursor(),i,r,"",n.highlighters),n.flush(r)}function O$(s,t,e,i,r,n=0,o=s.length){let a=n;function l(h,c){if(!(h<=a)){for(let u=s.slice(a,h),d=0;;){let f=u.indexOf(`
11
11
  `,d),p=f<0?u.length:f;if(p>d&&i(u.slice(d,p),c),f<0)break;r(),d=f+1}a=h}}Nh(t,e,(h,c,u)=>{l(h,""),l(c,u)},n,o),l(o,"")}function Iy(s){let t=s.type.prop(Ry);for(;t&&t.context&&!s.matchContext(t.context);)t=t.next;return t||null}var f$,he,p$,Rh,Ry,bs,Of,q,Ih,Zi,Dy,qy,Bi,Dh,yf,Ge,Os,Ke,Je,vf,Ra,qh,O,y$,ti=B(()=>{Be();f$=0,he=class s{constructor(t,e,i,r){this.name=t,this.set=e,this.base=i,this.modified=r,this.id=f$++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i=typeof t=="string"?t:"?";if(t instanceof s&&(e=t),e?.base)throw new Error("Can not derive from a modified tag");let r=new s(i,[],null,[]);if(r.set.push(r),e)for(let n of e.set)r.set.push(n);return r}static defineModifier(t){let e=new Rh(t);return i=>i.modified.indexOf(e)>-1?i:Rh.get(i.base||i,i.modified.concat(e).sort((r,n)=>r.id-n.id))}},p$=0,Rh=class s{constructor(t){this.name=t,this.instances=[],this.id=p$++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(a=>a.base==t&&m$(e,a.modified));if(i)return i;let r=[],n=new he(t.name,r,t,e);for(let a of e)a.instances.push(n);let o=g$(e);for(let a of t.set)if(!a.modified.length)for(let l of o)r.push(s.get(a,l));return n}};Ry=new z({combine(s,t){let e,i,r;for(;s||t;){if(!s||t&&s.depth>=t.depth?(r=t,t=t.next):(r=s,s=s.next),e&&e.mode==r.mode&&!r.context&&!e.context)continue;let n=new bs(r.tags,r.mode,r.context);e?e.next=n:i=n,e=n}return i}}),bs=class{constructor(t,e,i,r){this.tags=t,this.mode=e,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}};bs.empty=new bs([],2,null);Of=class{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,r,n){let{type:o,from:a,to:l}=t;if(a>=i||l<=e)return;o.isTop&&(n=this.highlighters.filter(f=>!f.scope||f.scope(o)));let h=r,c=Iy(t)||bs.empty,u=b$(n,c.tags);if(u&&(h&&(h+=" "),h+=u,c.mode==1&&(r+=(r?" ":"")+u)),this.startSpan(Math.max(e,a),h),c.opaque)return;let d=t.tree&&t.tree.prop(z.mounted);if(d&&d.overlay){let f=t.node.enter(d.overlay[0].from+a,1),p=this.highlighters.filter(b=>!b.scope||b.scope(d.tree.type)),m=t.firstChild();for(let b=0,g=a;;b++){let y=b<d.overlay.length?d.overlay[b]:null,v=y?y.from+a:l,w=Math.max(e,g),k=Math.min(i,v);if(w<k&&m)for(;t.from<k&&(this.highlightRange(t,w,k,r,n),this.startSpan(Math.min(k,t.to),h),!(t.to>=v||!t.nextSibling())););if(!y||v>i)break;g=y.to+a,g>e&&(this.highlightRange(f.cursor(),Math.max(e,y.from+a),Math.min(i,g),"",p),this.startSpan(Math.min(i,g),h))}m&&t.parent()}else if(t.firstChild()){d&&(r="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,r,n),this.startSpan(Math.min(i,t.to),h)}while(t.nextSibling());t.parent()}}};q=he.define,Ih=q(),Zi=q(),Dy=q(Zi),qy=q(Zi),Bi=q(),Dh=q(Bi),yf=q(Bi),Ge=q(),Os=q(Ge),Ke=q(),Je=q(),vf=q(),Ra=q(vf),qh=q(),O={comment:Ih,lineComment:q(Ih),blockComment:q(Ih),docComment:q(Ih),name:Zi,variableName:q(Zi),typeName:Dy,tagName:q(Dy),propertyName:qy,attributeName:q(qy),className:q(Zi),labelName:q(Zi),namespace:q(Zi),macroName:q(Zi),literal:Bi,string:Dh,docString:q(Dh),character:q(Dh),attributeValue:q(Dh),number:yf,integer:q(yf),float:q(yf),bool:q(Bi),regexp:q(Bi),escape:q(Bi),color:q(Bi),url:q(Bi),keyword:Ke,self:q(Ke),null:q(Ke),atom:q(Ke),unit:q(Ke),modifier:q(Ke),operatorKeyword:q(Ke),controlKeyword:q(Ke),definitionKeyword:q(Ke),moduleKeyword:q(Ke),operator:Je,derefOperator:q(Je),arithmeticOperator:q(Je),logicOperator:q(Je),bitwiseOperator:q(Je),compareOperator:q(Je),updateOperator:q(Je),definitionOperator:q(Je),typeOperator:q(Je),controlOperator:q(Je),punctuation:vf,separator:q(vf),bracket:Ra,angleBracket:q(Ra),squareBracket:q(Ra),paren:q(Ra),brace:q(Ra),content:Ge,heading:Os,heading1:q(Os),heading2:q(Os),heading3:q(Os),heading4:q(Os),heading5:q(Os),heading6:q(Os),contentSeparator:q(Ge),list:q(Ge),quote:q(Ge),emphasis:q(Ge),strong:q(Ge),link:q(Ge),monospace:q(Ge),strikethrough:q(Ge),inserted:q(),deleted:q(),changed:q(),invalid:q(),meta:qh,documentMeta:q(qh),annotation:q(qh),processingInstruction:q(qh),definition:he.defineModifier("definition"),constant:he.defineModifier("constant"),function:he.defineModifier("function"),standard:he.defineModifier("standard"),local:he.defineModifier("local"),special:he.defineModifier("special")};for(let s in O){let t=O[s];t instanceof he&&(t.name=s)}y$=Xh([{tag:O.link,class:"tok-link"},{tag:O.heading,class:"tok-heading"},{tag:O.emphasis,class:"tok-emphasis"},{tag:O.strong,class:"tok-strong"},{tag:O.keyword,class:"tok-keyword"},{tag:O.atom,class:"tok-atom"},{tag:O.bool,class:"tok-bool"},{tag:O.url,class:"tok-url"},{tag:O.labelName,class:"tok-labelName"},{tag:O.inserted,class:"tok-inserted"},{tag:O.deleted,class:"tok-deleted"},{tag:O.literal,class:"tok-literal"},{tag:O.string,class:"tok-string"},{tag:O.number,class:"tok-number"},{tag:[O.regexp,O.escape,O.special(O.string)],class:"tok-string2"},{tag:O.variableName,class:"tok-variableName"},{tag:O.local(O.variableName),class:"tok-variableName tok-local"},{tag:O.definition(O.variableName),class:"tok-variableName tok-definition"},{tag:O.special(O.variableName),class:"tok-variableName2"},{tag:O.definition(O.propertyName),class:"tok-propertyName tok-definition"},{tag:O.typeName,class:"tok-typeName"},{tag:O.namespace,class:"tok-namespace"},{tag:O.className,class:"tok-className"},{tag:O.macroName,class:"tok-macroName"},{tag:O.propertyName,class:"tok-propertyName"},{tag:O.operator,class:"tok-operator"},{tag:O.comment,class:"tok-comment"},{tag:O.meta,class:"tok-meta"},{tag:O.invalid,class:"tok-invalid"},{tag:O.punctuation,class:"tok-punctuation"}])});var v$,xf,Xy=B(()=>{gs();ti();v$=Lt({String:O.string,Number:O.number,"True False":O.bool,PropertyName:O.propertyName,Null:O.null,", :":O.separator,"[ ]":O.squareBracket,"{ }":O.brace}),xf=Ht.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"\u26A0 JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[v$],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0})});function x$(s){if(s<768)return!1;for(let t=0,e=Ia.length;;){let i=t+e>>1;if(s<Ia[i])e=i;else if(s>=Sf[i])t=i+1;else return!0;if(t==e)return!1}}function Ny(s){return s>=127462&&s<=127487}function cj(s){for(let t=0;t<Ia.length;t++)if(Sf[t]>s)return Ia[t]<=s;return!1}function Vy(s,t,e=!0,i=!0){return(e?By:S$)(s,t,i)}function By(s,t,e){if(t==s.length)return t;t&&zy(s.charCodeAt(t))&&_y(s.charCodeAt(t-1))&&t--;let i=wf(s,t);for(t+=jy(i);t<s.length;){let r=wf(s,t);if(i==Zy||r==Zy||e&&x$(r))t+=jy(r),i=r;else if(Ny(r)){let n=0,o=t-2;for(;o>=0&&Ny(wf(s,o));)n++,o-=2;if(n%2==0)break;t+=2}else break}return t}function S$(s,t,e){for(;t>0;){let i=By(s,t-2,e);if(i<t)return i;t--}return 0}function wf(s,t){let e=s.charCodeAt(t);if(!_y(e)||t+1==s.length)return e;let i=s.charCodeAt(t+1);return zy(i)?(e-55296<<10)+(i-56320)+65536:e}function zy(s){return s>=56320&&s<57344}function _y(s){return s>=55296&&s<56320}function jy(s){return s<65536?1:2}var Ia,Sf,Zy,Wy=B(()=>{Ia=[],Sf=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<s.length;t++)(t%2?Sf:Ia).push(e=e+s[t])})();Zy=8205});function w$(s){let t=-1;for(let e of s)t+=e.length+1;return t}function Zh(s,t,e=0,i=1e9){for(let r=0,n=0,o=!0;n<s.length&&r<=i;n++){let a=s[n],l=r+a.length;l>=e&&(l>i&&(a=a.slice(0,i-r)),r<e&&(a=a.slice(e-r)),o?(t[t.length-1]+=a,o=!1):t.push(a)),r=l+1}return t}function Uy(s,t,e){return Zh(s,[""],t,e)}function Cn(s,t,e){return t=Math.max(0,Math.min(s.length,t)),[t,Math.max(t,Math.min(s.length,e))]}function kt(s,t,e=!0,i=!0){return Vy(s,t,e,i)}function k$(s){return s>=56320&&s<57344}function A$(s){return s>=55296&&s<56320}function zt(s,t){let e=s.charCodeAt(t);if(!A$(e)||t+1==s.length)return e;let i=s.charCodeAt(t+1);return k$(i)?(e-55296<<10)+(i-56320)+65536:e}function Jh(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}function $e(s){return s<65536?1:2}function Zt(s,t,e,i=!1){if(t==0&&e<=0)return;let r=s.length-2;r>=0&&e<=0&&e==s[r+1]?s[r]+=t:r>=0&&t==0&&s[r]==0?s[r+1]+=e:i?(s[r]+=t,s[r+1]+=e):s.push(t,e)}function zi(s,t,e){if(e.length==0)return;let i=t.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(e);else{for(;s.length<i;)s.push(K.empty);s.push(e)}}function Af(s,t,e){let i=s.inserted;for(let r=0,n=0,o=0;o<s.sections.length;){let a=s.sections[o++],l=s.sections[o++];if(l<0)r+=a,n+=a;else{let h=r,c=n,u=K.empty;for(;h+=a,c+=l,l&&i&&(u=u.append(i[o-2>>1])),!(e||o==s.sections.length||s.sections[o+1]<0);)a=s.sections[o++],l=s.sections[o++];t(r,h,n,c,u),r=h,n=c}}}function Ef(s,t,e,i=!1){let r=[],n=i?[]:null,o=new vs(s),a=new vs(t);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let h=Math.min(o.len,a.len);Zt(r,h,-1),o.forward(h),a.forward(h)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!e))){let h=a.len;for(Zt(r,a.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&l<o.i&&o.len<=c&&(Zt(r,0,o.ins),n&&zi(n,r,o.text),l=o.i),o.forward(c),h-=c}a.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(a.ins==-1){let u=Math.min(c,a.len);h+=u,c-=u,a.forward(u)}else if(a.ins==0&&a.len<c)c-=a.len,a.next();else break;Zt(r,h,l<o.i?o.ins:0),n&&l<o.i&&zi(n,r,o.text),l=o.i,o.forward(o.len-c)}else{if(o.done&&a.done)return n?Bt.createSet(r,n):ei.create(r);throw new Error("Mismatched change set lengths")}}}function Fy(s,t,e=!1){let i=[],r=e?[]:null,n=new vs(s),o=new vs(t);for(let a=!1;;){if(n.done&&o.done)return r?Bt.createSet(i,r):ei.create(i);if(n.ins==0)Zt(i,n.len,0,a),n.next();else if(o.len==0&&!o.done)Zt(i,0,o.ins,a),r&&zi(r,i,o.text),o.next();else{if(n.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(n.len2,o.len),h=i.length;if(n.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Zt(i,l,c,a),r&&c&&zi(r,i,o.text)}else o.ins==-1?(Zt(i,n.off?0:n.len,l,a),r&&zi(r,i,n.textBit(l))):(Zt(i,n.off?0:n.len,o.off?0:o.ins,a),r&&!o.off&&zi(r,i,o.text));a=(n.ins>l||o.ins>=0&&o.len>l)&&(a||i.length>h),n.forward2(l),o.forward(l)}}}}function Yy(s,t){for(let e of s.ranges)if(e.to>t)throw new RangeError("Selection points outside of document")}function $f(s,t){return s==t||s.length==t.length&&s.every((e,i)=>e===t[i])}function Hy(s,t,e){if(s.length!=t.length)return!1;for(let i=0;i<s.length;i++)if(!e(s[i],t[i]))return!1;return!0}function Pf(s,t){let e=!1;for(let i of t)Xa(s,i)&1&&(e=!0);return e}function E$(s,t,e){let i=e.map(l=>s[l.id]),r=e.map(l=>l.type),n=i.filter(l=>!(l&1)),o=s[t.id]>>1;function a(l){let h=[];for(let c=0;c<i.length;c++){let u=Uh(l,i[c]);if(r[c]==2)for(let d of u)h.push(d);else h.push(u)}return t.combine(h)}return{create(l){for(let h of i)Xa(l,h);return l.values[o]=a(l),1},update(l,h){if(!Pf(l,n))return 0;let c=a(l);return t.compare(c,l.values[o])?0:(l.values[o]=c,1)},reconfigure(l,h){let c=Pf(l,i),u=h.config.facets[t.id],d=h.facet(t);if(u&&!c&&$f(e,u))return l.values[o]=d,0;let f=a(l);return t.compare(f,d)?(l.values[o]=d,0):(l.values[o]=f,1)}}}function Da(s){return t=>new Vh(t,s)}function C$(s,t,e){let i=[[],[],[],[],[]],r=new Map;function n(o,a){let l=r.get(o);if(l!=null){if(l<=a)return;let h=i[l].indexOf(o);h>-1&&i[l].splice(h,1),o instanceof qa&&e.delete(o.compartment)}if(r.set(o,a),Array.isArray(o))for(let h of o)n(h,a);else if(o instanceof qa){if(e.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=t.get(o.compartment)||o.inner;e.set(o.compartment,h),n(h,a)}else if(o instanceof Vh)n(o.inner,o.prec);else if(o instanceof mt)i[a].push(o),o.provides&&n(o.provides,a);else if(o instanceof $n)i[a].push(o),o.facet.extensions&&n(o.facet.extensions,Ss.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);n(h,a)}}return n(s,Ss.default),i.reduce((o,a)=>o.concat(a))}function Xa(s,t){if(t&1)return 2;let e=t>>1,i=s.status[e];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[e]=4;let r=s.computeSlot(s,s.config.dynamicSlots[e]);return s.status[e]=2|r}function Uh(s,t){return t&1?s.config.staticValues[t>>1]:s.values[t>>1]}function $$(s,t){let e=[];for(let i=0,r=0;;){let n,o;if(i<s.length&&(r==t.length||t[r]>=s[i]))n=s[i++],o=s[i++];else if(r<t.length)n=t[r++],o=t[r++];else return e;!e.length||e[e.length-1]<n?e.push(n,o):e[e.length-1]<o&&(e[e.length-1]=o)}}function sv(s,t,e){var i;let r,n,o;return e?(r=t.changes,n=Bt.empty(t.changes.length),o=s.changes.compose(t.changes)):(r=t.changes.map(s.changes),n=s.changes.mapDesc(t.changes,!0),o=s.changes.compose(r)),{changes:o,selection:t.selection?t.selection.map(n):(i=s.selection)===null||i===void 0?void 0:i.map(r),effects:W.mapEffects(s.effects,r).concat(W.mapEffects(t.effects,n)),annotations:s.annotations.length?s.annotations.concat(t.annotations):t.annotations,scrollIntoView:s.scrollIntoView||t.scrollIntoView}}function Tf(s,t,e){let i=t.selection,r=Pn(t.annotations);return t.userEvent&&(r=r.concat(yt.userEvent.of(t.userEvent))),{changes:t.changes instanceof Bt?t.changes:Bt.of(t.changes||[],e,s.facet(Ky)),selection:i&&(i instanceof P?i:P.single(i.anchor,i.head)),effects:Pn(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}function rv(s,t,e){let i=Tf(s,t.length?t[0]:{},s.doc.length);t.length&&t[0].filter===!1&&(e=!1);for(let n=1;n<t.length;n++){t[n].filter===!1&&(e=!1);let o=!!t[n].sequential;i=sv(i,Tf(s,t[n],o?i.changes.newLength:s.doc.length),o)}let r=yt.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Q$(e?P$(r):r)}function P$(s){let t=s.startState,e=!0;for(let r of t.facet(Jy)){let n=r(s);if(n===!1){e=!1;break}Array.isArray(n)&&(e=e===!0?n:$$(e,n))}if(e!==!0){let r,n;if(e===!1)n=s.changes.invertedDesc,r=Bt.empty(t.doc.length);else{let o=s.changes.filter(e);r=o.changes,n=o.filtered.mapDesc(o.changes).invertedDesc}s=yt.create(t,r,s.selection&&s.selection.map(n),W.mapEffects(s.effects,n),s.annotations,s.scrollIntoView)}let i=t.facet(tv);for(let r=i.length-1;r>=0;r--){let n=i[r](s);n instanceof yt?s=n:Array.isArray(n)&&n.length==1&&n[0]instanceof yt?s=n[0]:s=rv(t,Pn(n),!1)}return s}function Q$(s){let t=s.startState,e=t.facet(ev),i=s;for(let r=e.length-1;r>=0;r--){let n=e[r](s);n&&Object.keys(n).length&&(i=sv(i,Tf(t,n,s.changes.newLength),!0))}return i==s?s:yt.create(t,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}function Pn(s){return s==null?T$:Array.isArray(s)?s:[s]}function M$(s){if(Lf)return Lf.test(s);for(let t=0;t<s.length;t++){let e=s[t];if(/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||L$.test(e)))return!0}return!1}function R$(s){return t=>{if(!/\S/.test(t))return pt.Space;if(M$(t))return pt.Word;for(let e=0;e<s.length;e++)if(t.indexOf(s[e])>-1)return pt.Word;return pt.Other}}function Kt(s,t,e={}){let i={};for(let r of s)for(let n of Object.keys(r)){let o=r[n],a=i[n];if(a===void 0)i[n]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(e,n))i[n]=e[n](a,o);else throw new Error("Config merge conflict for field "+n)}for(let r in t)i[r]===void 0&&(i[r]=t[r]);return i}function Mf(s,t){return s==t||s.constructor==t.constructor&&s.eq(t)}function Rf(s,t){return s.from-t.from||s.value.startSide-t.value.startSide}function I$(s){if(s.length>1)for(let t=s[0],e=1;e<s.length;e++){let i=s[e];if(Rf(t,i)>0)return s.slice().sort(Rf);t=i}return s}function nv(s,t,e){let i=new Map;for(let n of s)for(let o=0;o<n.chunk.length;o++)n.chunk[o].maxPoint<=0&&i.set(n.chunk[o],n.chunkPos[o]);let r=new Set;for(let n of t)for(let o=0;o<n.chunk.length;o++){let a=i.get(n.chunk[o]);a!=null&&(e?e.mapPos(a):a)==n.chunkPos[o]&&!e?.touchesRange(a,a+n.chunk[o].length)&&r.add(n.chunk[o])}return r}function Df(s,t){for(let e=s[t];;){let i=(t<<1)+1;if(i>=s.length)break;let r=s[i];if(i+1<s.length&&r.compare(s[i+1])>=0&&(r=s[i+1],i++),e.compare(r)<0)break;s[i]=e,s[t]=r,t=i}}function ov(s,t,e,i,r,n){s.goto(t),e.goto(i);let o=i+r,a=i,l=i-t,h=!!n.boundChange;for(let c=!1;;){let u=s.to+l-e.to,d=u||s.endSide-e.endSide,f=d<0?s.to+l:e.to,p=Math.min(f,o);if(s.point||e.point?(s.point&&e.point&&Mf(s.point,e.point)&&qf(s.activeForPoint(s.to),e.activeForPoint(e.to))||n.comparePoint(a,p,s.point,e.point),c=!1):(c&&n.boundChange(a),p>a&&!qf(s.active,e.active)&&n.compareRange(a,p,s.active,e.active),h&&p<o&&(u||s.openEnd(f)!=e.openEnd(f))&&(c=!0)),f>o)break;a=f,d<=0&&s.next(),d>=0&&e.next()}}function qf(s,t){if(s.length!=t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!=t[e]&&!Mf(s[e],t[e]))return!1;return!0}function Gh(s,t){for(let e=t,i=s.length-1;e<i;e++)s[e]=s[e+1];s.pop()}function Kh(s,t,e){for(let i=s.length-1;i>=t;i--)s[i+1]=s[i];s[t]=e}function av(s,t){let e=-1,i=1e9;for(let r=0;r<t.length;r++)(t[r]-i||s[r].endSide-s[e].endSide)<0&&(e=r,i=t[r]);return e}function _t(s,t,e=s.length){let i=0;for(let r=0;r<e&&r<s.length;)s.charCodeAt(r)==9?(i+=t-i%t,r++):(i++,r=kt(s,r));return i}function Za(s,t,e,i){for(let r=0,n=0;;){if(n>=t)return r;if(r==s.length)break;n+=s.charCodeAt(r)==9?e-n%e:1,r=kt(s,r)}return i===!0?-1:s.length}var K,Se,En,ys,Bh,zh,_h,kf,wt,ei,Bt,vs,xs,P,Cf,X,$n,jh,mt,Ss,ce,Vh,_i,qa,Wh,Gy,Qf,Ky,Jy,tv,ev,iv,Gt,Fh,Yh,W,yt,T$,pt,L$,Lf,nt,we,Qn,If,H,ke,Hh,Na,ws,ii=B(()=>{Wy();K=class s{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=Cn(this,t,e);let r=[];return this.decompose(0,t,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(e,this.length,r,1),En.from(r,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Cn(this,t,e);let i=[];return this.decompose(t,e,i,0),En.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),r=new ys(this),n=new ys(t);for(let o=e,a=e;;){if(r.next(o),n.next(o),o=0,r.lineBreak!=n.lineBreak||r.done!=n.done||r.value!=n.value)return!1;if(a+=r.value.length,r.done||a>=i)return!0}}iter(t=1){return new ys(this,t)}iterRange(t,e=this.length){return new Bh(this,t,e)}iterLines(t,e){let i;if(t==null)i=this.iter();else{e==null&&(e=this.lines+1);let r=this.line(t).from;i=this.iterRange(r,Math.max(r,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new zh(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?s.empty:t.length<=32?new Se(t):En.from(Se.split(t,[]))}},Se=class s extends K{constructor(t,e=w$(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,r){for(let n=0;;n++){let o=this.text[n],a=r+o.length;if((e?i:a)>=t)return new _h(r,a,i,o);r=a+1,i++}}decompose(t,e,i,r){let n=t<=0&&e>=this.length?this:new s(Uy(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(r&1){let o=i.pop(),a=Zh(n.text,o.text.slice(),0,n.length);if(a.length<=32)i.push(new s(a,o.length+n.length));else{let l=a.length>>1;i.push(new s(a.slice(0,l)),new s(a.slice(l)))}}else i.push(n)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);[t,e]=Cn(this,t,e);let r=Zh(this.text,Zh(i.text,Uy(this.text,0,t)),e),n=this.length+i.length-(e-t);return r.length<=32?new s(r,n):En.from(s.split(r,[]),n)}sliceString(t,e=this.length,i=`
12
12
  `){[t,e]=Cn(this,t,e);let r="";for(let n=0,o=0;n<=e&&o<this.text.length;o++){let a=this.text[o],l=n+a.length;n>t&&o&&(r+=i),t<l&&e>n&&(r+=a.slice(Math.max(0,t-n),e-n)),n=l+1}return r}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],r=-1;for(let n of t)i.push(n),r+=n.length+1,i.length==32&&(e.push(new s(i,r)),i=[],r=-1);return r>-1&&e.push(new s(i,r)),e}},En=class s extends K{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,e,i,r){for(let n=0;;n++){let o=this.children[n],a=r+o.length,l=i+o.lines-1;if((e?l:a)>=t)return o.lineInner(t,e,i,r);r=a+1,i=l+1}}decompose(t,e,i,r){for(let n=0,o=0;o<=e&&n<this.children.length;n++){let a=this.children[n],l=o+a.length;if(t<=l&&e>=o){let h=r&((o<=t?1:0)|(l>=e?2:0));o>=t&&l<=e&&!h?i.push(a):a.decompose(t-o,e-o,i,h)}o=l+1}}replace(t,e,i){if([t,e]=Cn(this,t,e),i.lines<this.lines)for(let r=0,n=0;r<this.children.length;r++){let o=this.children[r],a=n+o.length;if(t>=n&&e<=a){let l=o.replace(t-n,e-n,i),h=this.lines-o.lines+l.lines;if(l.lines<h>>4&&l.lines>h>>6){let c=this.children.slice();return c[r]=l,new s(c,this.length-(e-t)+i.length)}return super.replace(n,a,l)}n=a+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i=`
13
13
  `){[t,e]=Cn(this,t,e);let r="";for(let n=0,o=0;n<this.children.length&&o<=e;n++){let a=this.children[n],l=o+a.length;o>t&&n&&(r+=i),t<l&&e>o&&(r+=a.sliceString(t-o,e-o,i)),o=l+1}return r}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof s))return 0;let i=0,[r,n,o,a]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;r+=e,n+=e){if(r==o||n==a)return i;let l=this.children[r],h=t.children[n];if(l!=h)return i+l.scanIdentical(h,e);i+=l.length+1}}static from(t,e=t.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let f of t)i+=f.lines;if(i<32){let f=[];for(let p of t)p.flatten(f);return new Se(f,e)}let r=Math.max(32,i>>5),n=r<<1,o=r>>1,a=[],l=0,h=-1,c=[];function u(f){let p;if(f.lines>n&&f instanceof s)for(let m of f.children)u(m);else f.lines>o&&(l>o||!l)?(d(),a.push(f)):f instanceof Se&&l&&(p=c[c.length-1])instanceof Se&&f.lines+p.lines<=32?(l+=f.lines,h+=f.length+1,c[c.length-1]=new Se(p.text.concat(f.text),p.length+1+f.length)):(l+f.lines>r&&d(),l+=f.lines,h+=f.length+1,c.push(f))}function d(){l!=0&&(a.push(c.length==1?c[0]:s.from(c,h)),h=-1,l=c.length=0)}for(let f of t)u(f);return d(),a.length==1?a[0]:new s(a,e)}};K.empty=new Se([""],0);ys=class{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof Se?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],n=this.offsets[i],o=n>>1,a=r instanceof Se?r.text.length:r.children.length;if(o==(e>0?a:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((n&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=`
@@ -38,7 +38,7 @@ var LE=Object.defineProperty;var B=(s,t)=>()=>(s&&(t=s(s=0)),t);var Yt=(s,t)=>{f
38
38
  `?"":e;else{let r=e.indexOf(`
39
39
  `);i=r<0?e:e.slice(0,r)}return t+i.length>this.to?i.slice(0,this.to-t):i}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(t,e,i=0){this.block=mu.create(t,i,this.lineStart+e,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(t,e,i=0){this.startContext(this.parser.getNodeType(t),e,i)}addNode(t,e,i){typeof t=="number"&&(t=new Y(this.parser.nodeSet.types[t],to,to,(i??this.prevLineEnd())-e)),this.block.addChild(t,e-this.block.from)}addElement(t){this.block.addChild(t.toTree(this.parser.nodeSet),t.from-this.block.from)}addLeafElement(t,e){this.addNode(this.buffer.writeElements(Cg(e.children,t.marks),-e.from).finish(e.type,e.to-e.from),e.from)}finishContext(){let t=this.stack.pop(),e=this.stack[this.stack.length-1];e.addChild(t.toTree(this.parser.nodeSet),t.from-e.from),this.block=e}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(t){return this.ranges.length>1?Pw(this.ranges,0,t.topNode,this.ranges[0].from,this.reusePlaceholders):t}finishLeaf(t){for(let i of t.parsers)if(i.finish(this,t))return;let e=Cg(this.parser.parseInline(t.content,t.start),t.marks);this.addNode(this.buffer.writeElements(e,-t.start).finish(L.Paragraph,t.content.length),t.start)}elt(t,e,i,r){return typeof t=="string"?et(this.parser.getNodeType(t),e,i,r):new Su(t,e)}get buffer(){return new xu(this.parser.nodeSet)}};io=class s extends He{constructor(t,e,i,r,n,o,a,l,h){super(),this.nodeSet=t,this.blockParsers=e,this.leafBlockParsers=i,this.blockNames=r,this.endLeafBlock=n,this.skipContextMarkup=o,this.inlineParsers=a,this.inlineNames=l,this.wrappers=h,this.nodeTypes=Object.create(null);for(let c of t.types)this.nodeTypes[c.name]=c.id}createParse(t,e,i){let r=new yu(this,t,e,i);for(let n of this.wrappers)r=n(r,t,e,i);return r}configure(t){let e=Ag(t);if(!e)return this;let{nodeSet:i,skipContextMarkup:r}=this,n=this.blockParsers.slice(),o=this.leafBlockParsers.slice(),a=this.blockNames.slice(),l=this.inlineParsers.slice(),h=this.inlineNames.slice(),c=this.endLeafBlock.slice(),u=this.wrappers;if(Pl(e.defineNodes)){r=Object.assign({},r);let d=i.types.slice(),f;for(let p of e.defineNodes){let{name:m,block:b,composite:g,style:y}=typeof p=="string"?{name:p}:p;if(d.some(k=>k.name==m))continue;g&&(r[d.length]=(k,E,A)=>g(E,A,k.value));let v=d.length,w=g?["Block","BlockContext"]:b?v>=L.ATXHeading1&&v<=L.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;d.push(dt.define({id:v,name:m,props:w&&[[z.group,w]]})),y&&(f||(f={}),Array.isArray(y)||y instanceof he?f[m]=y:Object.assign(f,y))}i=new Ye(d),f&&(i=i.extend(Lt(f)))}if(Pl(e.props)&&(i=i.extend(...e.props)),Pl(e.remove))for(let d of e.remove){let f=this.blockNames.indexOf(d),p=this.inlineNames.indexOf(d);f>-1&&(n[f]=o[f]=void 0),p>-1&&(l[p]=void 0)}if(Pl(e.parseBlock))for(let d of e.parseBlock){let f=a.indexOf(d.name);if(f>-1)n[f]=d.parse,o[f]=d.leaf;else{let p=d.before?vu(a,d.before):d.after?vu(a,d.after)+1:a.length-1;n.splice(p,0,d.parse),o.splice(p,0,d.leaf),a.splice(p,0,d.name)}d.endLeaf&&c.push(d.endLeaf)}if(Pl(e.parseInline))for(let d of e.parseInline){let f=h.indexOf(d.name);if(f>-1)l[f]=d.parse;else{let p=d.before?vu(h,d.before):d.after?vu(h,d.after)+1:h.length-1;l.splice(p,0,d.parse),h.splice(p,0,d.name)}}return e.wrap&&(u=u.concat(e.wrap)),new s(i,n,o,a,c,r,l,h,u)}getNodeType(t){let e=this.nodeTypes[t];if(e==null)throw new RangeError(`Unknown node type '${t}'`);return e}parseInline(t,e){let i=new eo(this,t,e);t:for(let r=e;r<i.end;){let n=i.char(r);for(let o of this.inlineParsers)if(o){let a=o(i,n,r);if(a>=0){r=a;continue t}}r++}return i.resolveMarkers(0)}};Qw=[dt.none];for(let s=1,t;t=L[s];s++)Qw[s]=dt.define({id:s,name:t,props:s>=L.Escape?[]:[[z.group,s in bw?["Block","BlockContext"]:["Block","LeafBlock"]]],top:t=="Document"});to=[],xu=class{constructor(t){this.nodeSet=t,this.content=[],this.nodes=[]}write(t,e,i,r=0){return this.content.push(t,e,i,4+r*4),this}writeElements(t,e=0){for(let i of t)i.writeTo(this,e);return this}finish(t,e){return Y.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:t,length:e})}},Ki=class{constructor(t,e,i,r=to){this.type=t,this.from=e,this.to=i,this.children=r}writeTo(t,e){let i=t.content.length;t.writeElements(this.children,e),t.content.push(this.type,this.from+e,this.to+e,t.content.length+4-i)}toTree(t){return new xu(t).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}},Su=class{constructor(t,e){this.tree=t,this.from=e}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return to}writeTo(t,e){t.nodes.push(this.tree),t.content.push(t.nodes.length-1,this.from+e,this.to+e,-1)}toTree(){return this.tree}};Tw={resolve:"Emphasis",mark:"EmphasisMark"},Lw={resolve:"Emphasis",mark:"EmphasisMark"},Zs={},wu={},se=class{constructor(t,e,i,r){this.type=t,this.from=e,this.to=i,this.side=r}},Mw="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",Ql=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{Ql=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}Eg={Escape(s,t,e){if(t!=92||e==s.end-1)return-1;let i=s.char(e+1);for(let r=0;r<Mw.length;r++)if(Mw.charCodeAt(r)==i)return s.append(et(L.Escape,e,e+2));return-1},Entity(s,t,e){if(t!=38)return-1;let i=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(s.slice(e+1,e+31));return i?s.append(et(L.Entity,e,e+1+i[0].length)):-1},InlineCode(s,t,e){if(t!=96||e&&s.char(e-1)==96)return-1;let i=e+1;for(;i<s.end&&s.char(i)==96;)i++;let r=i-e,n=0;for(;i<s.end;i++)if(s.char(i)==96){if(n++,n==r&&s.char(i+1)!=96)return s.append(et(L.InlineCode,e,i+1,[et(L.CodeMark,e,e+r),et(L.CodeMark,i+1-r,i+1)]))}else n=0;return-1},HTMLTag(s,t,e){if(t!=60||e==s.end-1)return-1;let i=s.slice(e+1,s.end),r=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(i);if(r)return s.append(et(L.Autolink,e,e+1+r[0].length,[et(L.LinkMark,e,e+1),et(L.URL,e+1,e+r[0].length),et(L.LinkMark,e+r[0].length,e+1+r[0].length)]));let n=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(i);if(n)return s.append(et(L.Comment,e,e+1+n[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return s.append(et(L.ProcessingInstruction,e,e+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return a?s.append(et(L.HTMLTag,e,e+1+a[0].length)):-1},Emphasis(s,t,e){if(t!=95&&t!=42)return-1;let i=e+1;for(;s.char(i)==t;)i++;let r=s.slice(e-1,e),n=s.slice(i,i+1),o=Ql.test(r),a=Ql.test(n),l=/\s|^$/.test(r),h=/\s|^$/.test(n),c=!h&&(!a||l||o),u=!l&&(!o||h||a),d=c&&(t==42||!u||o),f=u&&(t==42||!c||a);return s.append(new se(t==95?Tw:Lw,e,i,(d?1:0)|(f?2:0)))},HardBreak(s,t,e){if(t==92&&s.char(e+1)==10)return s.append(et(L.HardBreak,e,e+2));if(t==32){let i=e+1;for(;s.char(i)==32;)i++;if(s.char(i)==10&&i>=e+2)return s.append(et(L.HardBreak,e,i+1))}return-1},Link(s,t,e){return t==91?s.append(new se(Zs,e,e+1,1)):-1},Image(s,t,e){return t==33&&s.char(e+1)==91?s.append(new se(wu,e,e+2,1)):-1},LinkEnd(s,t,e){if(t!=93)return-1;for(let i=s.parts.length-1;i>=0;i--){let r=s.parts[i];if(r instanceof se&&(r.type==Zs||r.type==wu)){if(!r.side||s.skipSpace(r.to)==e&&!/[(\[]/.test(s.slice(e+1,e+2)))return s.parts[i]=null,-1;let n=s.takeContent(i),o=s.parts[i]=_2(s,n,r.type==Zs?L.Link:L.Image,r.from,e+1);if(r.type==Zs)for(let a=0;a<i;a++){let l=s.parts[a];l instanceof se&&l.type==Zs&&(l.side=0)}return o.to}}return-1}};eo=class{constructor(t,e,i){this.parser=t,this.text=e,this.offset=i,this.parts=[]}char(t){return t>=this.end?-1:this.text.charCodeAt(t-this.offset)}get end(){return this.offset+this.text.length}slice(t,e){return this.text.slice(t-this.offset,e-this.offset)}append(t){return this.parts.push(t),t.to}addDelimiter(t,e,i,r,n){return this.append(new se(t,e,i,(r?1:0)|(n?2:0)))}get hasOpenLink(){for(let t=this.parts.length-1;t>=0;t--){let e=this.parts[t];if(e instanceof se&&(e.type==Zs||e.type==wu))return!0}return!1}addElement(t){return this.append(t)}resolveMarkers(t){for(let i=t;i<this.parts.length;i++){let r=this.parts[i];if(!(r instanceof se&&r.type.resolve&&r.side&2))continue;let n=r.type==Tw||r.type==Lw,o=r.to-r.from,a,l=i-1;for(;l>=t;l--){let m=this.parts[l];if(m instanceof se&&m.side&1&&m.type==r.type&&!(n&&(r.side&1||m.side&2)&&(m.to-m.from+o)%3==0&&((m.to-m.from)%3||o%3))){a=m;break}}if(!a)continue;let h=r.type.resolve,c=[],u=a.from,d=r.to;if(n){let m=Math.min(2,a.to-a.from,o);u=a.to-m,d=r.from+m,h=m==1?"Emphasis":"StrongEmphasis"}a.type.mark&&c.push(this.elt(a.type.mark,u,a.to));for(let m=l+1;m<i;m++)this.parts[m]instanceof Ki&&c.push(this.parts[m]),this.parts[m]=null;r.type.mark&&c.push(this.elt(r.type.mark,r.from,d));let f=this.elt(h,u,d,c);this.parts[l]=n&&a.from!=u?new se(a.type,a.from,u,a.side):null,(this.parts[i]=n&&r.to!=d?new se(r.type,d,r.to,r.side):null)?this.parts.splice(i,0,f):this.parts[i]=f}let e=[];for(let i=t;i<this.parts.length;i++){let r=this.parts[i];r instanceof Ki&&e.push(r)}return e}findOpeningDelimiter(t){for(let e=this.parts.length-1;e>=0;e--){let i=this.parts[e];if(i instanceof se&&i.type==t&&i.side&1)return e}return null}takeContent(t){let e=this.resolveMarkers(t);return this.parts.length=t,e}getDelimiterAt(t){let e=this.parts[t];return e instanceof se?e:null}skipSpace(t){return $l(this.text,t-this.offset)+this.offset}elt(t,e,i,r){return typeof t=="string"?et(this.parser.getNodeType(t),e,i,r):new Su(t,e)}};eo.linkStart=Zs,eo.imageStart=wu;j2=[L.CodeBlock,L.ListItem,L.OrderedList,L.BulletList],$g=class{constructor(t,e){this.fragments=t,this.input=e,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,t.length&&(this.fragment=t[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(t,e){for(;this.fragment&&this.fragment.to<=t;)this.nextFragment();if(!this.fragment||this.fragment.from>(t?t-1:0))return!1;if(this.fragmentEnd<0){let n=this.fragment.to;for(;n>0&&this.input.read(n-1,n)!=`
40
40
  `;)n--;this.fragmentEnd=n?n-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let r=t+this.fragment.offset;for(;i.to<=r;)if(!i.parent())return!1;for(;;){if(i.from>=r)return this.fragment.from<=e;if(!i.childAfter(r))return!1}}matches(t){let e=this.cursor.tree;return e&&e.prop(z.contextHash)==t}takeNodes(t){let e=this.cursor,i=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),n=t.absoluteLineStart,o=n,a=t.block.children.length,l=o,h=a;for(;;){if(e.to-i>r){if(e.type.isAnonymous&&e.firstChild())continue;break}let c=qw(e.from-i,t.ranges);if(e.to-i<=t.ranges[t.rangeI].to)t.addNode(e.tree,c);else{let u=new Y(t.parser.nodeSet.types[L.Paragraph],[],[],0,t.block.hashProp);t.reusePlaceholders.set(u,e.tree),t.addNode(u,c)}if(e.type.is("Block")&&(j2.indexOf(e.type.id)<0?(o=e.to-i,a=t.block.children.length):(o=l,a=h),l=e.to-i,h=t.block.children.length),!e.nextSibling())break}for(;t.block.children.length>a;)t.block.children.pop(),t.block.positions.pop();return o-n}};V2=Lt({"Blockquote/...":O.quote,HorizontalRule:O.contentSeparator,"ATXHeading1/... SetextHeading1/...":O.heading1,"ATXHeading2/... SetextHeading2/...":O.heading2,"ATXHeading3/...":O.heading3,"ATXHeading4/...":O.heading4,"ATXHeading5/...":O.heading5,"ATXHeading6/...":O.heading6,"Comment CommentBlock":O.comment,Escape:O.escape,Entity:O.character,"Emphasis/...":O.emphasis,"StrongEmphasis/...":O.strong,"Link/... Image/...":O.link,"OrderedList/... BulletList/...":O.list,"BlockQuote/...":O.quote,"InlineCode CodeText":O.monospace,"URL Autolink":O.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":O.processingInstruction,"CodeInfo LinkLabel":O.labelName,LinkTitle:O.string,Paragraph:O.content}),Qg=new io(new Ye(Qw).extend(V2),Object.keys(Ou).map(s=>Ou[s]),Object.keys(Ou).map(s=>$w[s]),Object.keys(Ou),B2,bw,Object.keys(Eg).map(s=>Eg[s]),Object.keys(Eg),[]);U2={resolve:"Strikethrough",mark:"StrikethroughMark"},Xw={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":O.strikethrough}},{name:"StrikethroughMark",style:O.processingInstruction}],parseInline:[{name:"Strikethrough",parse(s,t,e){if(t!=126||s.char(e+1)!=126||s.char(e+2)==126)return-1;let i=s.slice(e-1,e),r=s.slice(e+2,e+3),n=/\s|^$/.test(i),o=/\s|^$/.test(r),a=Ql.test(i),l=Ql.test(r);return s.addDelimiter(U2,e,e+2,!o&&(!l||n||a),!n&&(!a||o||l))},after:"Emphasis"}]};Zw=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,ku=class{constructor(){this.rows=null}nextLine(t,e,i){if(this.rows==null){this.rows=!1;let r;if((e.next==45||e.next==58||e.next==124)&&Zw.test(r=e.text.slice(e.pos))){let n=[];Tl(t,i.content,0,n,i.start)==Tl(t,r,e.pos)&&(this.rows=[t.elt("TableHeader",i.start,i.start+i.content.length,n),t.elt("TableDelimiter",t.lineStart+e.pos,t.lineStart+e.text.length)])}}else if(this.rows){let r=[];Tl(t,e.text,e.pos,r,t.lineStart),this.rows.push(t.elt("TableRow",t.lineStart+e.pos,t.lineStart+e.text.length,r))}return!1}finish(t,e){return this.rows?(t.addLeafElement(e,t.elt("Table",e.start,e.start+e.content.length,this.rows)),!0):!1}},Bw={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":O.heading}},"TableRow",{name:"TableCell",style:O.content},{name:"TableDelimiter",style:O.processingInstruction}],parseBlock:[{name:"Table",leaf(s,t){return Nw(t.content,0)?new ku:null},endLeaf(s,t,e){if(e.parsers.some(r=>r instanceof ku)||!Nw(t.text,t.basePos))return!1;let i=s.peekLine();return Zw.test(i)&&Tl(s,t.text,t.basePos)==Tl(s,i,t.basePos)},before:"SetextHeading"}]},Pg=class{nextLine(){return!1}finish(t,e){return t.addLeafElement(e,t.elt("Task",e.start,e.start+e.content.length,[t.elt("TaskMarker",e.start,e.start+3),...t.parser.parseInline(e.content.slice(3),e.start+3)])),!0}},zw={defineNodes:[{name:"Task",block:!0,style:O.list},{name:"TaskMarker",style:O.atom}],parseBlock:[{name:"TaskList",leaf(s,t){return/^\[[ xX]\][ \t]/.test(t.content)&&s.parentType().name=="ListItem"?new Pg:null},after:"SetextHeading"}]},_w=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,jw=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,F2=/[\w-]+\.[\w-]+($|\/)/,Vw=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,Ww=/\/[a-zA-Z\d@.]+/gy;Yw={parseInline:[{name:"Autolink",parse(s,t,e){let i=e-s.offset;if(i&&/\w/.test(s.text[i-1]))return-1;_w.lastIndex=i;let r=_w.exec(s.text),n=-1;if(!r)return-1;if(r[1]||r[2]){if(n=Y2(s.text,i+r[0].length),n>-1&&s.hasOpenLink){let o=/([^\[\]]|\[[^\]]*\])*/.exec(s.text.slice(i,n));n=i+o[0].length}}else r[3]?n=Fw(s.text,i):(n=Fw(s.text,i+r[0].length),n>-1&&r[0]=="xmpp:"&&(Ww.lastIndex=n,r=Ww.exec(s.text),r&&(n=r.index+r[0].length)));return n<0?-1:(s.addElement(s.elt("URL",e,n+s.offset)),n+s.offset)}}]},Lg=[Bw,zw,Xw,Yw];Mg={defineNodes:[{name:"Superscript",style:O.special(O.content)},{name:"SuperscriptMark",style:O.processingInstruction}],parseInline:[{name:"Superscript",parse:Hw(94,"Superscript","SuperscriptMark")}]},Rg={defineNodes:[{name:"Subscript",style:O.special(O.content)},{name:"SubscriptMark",style:O.processingInstruction}],parseInline:[{name:"Subscript",parse:Hw(126,"Subscript","SubscriptMark")}]},Ig={defineNodes:[{name:"Emoji",style:O.character}],parseInline:[{name:"Emoji",parse(s,t,e){let i;return t!=58||!(i=/^[a-zA-Z_0-9]+:/.exec(s.slice(e+1,s.end)))?-1:s.addElement(s.elt("Emoji",e,e+1+i[0].length))}}]}});var ak={};Yt(ak,{commonmarkLanguage:()=>Bg,deleteMarkupBackward:()=>jg,insertNewlineContinueMarkup:()=>_g,insertNewlineContinueMarkupCommand:()=>zg,markdown:()=>ok,markdownKeymap:()=>Vg,markdownLanguage:()=>so,pasteURLAsLink:()=>Wg});function Dg(s){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(s.name);return t?+t[1]:void 0}function H2(s){return s.name=="OrderedList"||s.name=="BulletList"}function G2(s,t){let e=s;for(;;){let i=e.nextSibling,r;if(!i||(r=Dg(i.type))!=null&&r<=t)break;e=i}return e.to}function qg(s){return new Qt(Kw,s,[],"markdown")}function tR(s,t){return e=>{if(e&&s){let i=null;if(e=/\S*/.exec(e)[0],typeof s=="function"?i=s(e):i=Un.matchLanguageName(s,e,!0),i instanceof Un)return i.support?i.support.language.parser:Yi.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}function ek(s,t){let e=[],i=[];for(let r=s;r;r=r.parent){if(r.name=="FencedCode")return i;(r.name=="ListItem"||r.name=="Blockquote")&&e.push(r)}for(let r=e.length-1;r>=0;r--){let n=e[r],o,a=t.lineAt(n.from),l=n.from-a.from;if(n.name=="Blockquote"&&(o=/^ *>( ?)/.exec(a.text.slice(l))))i.push(new Ll(n,l,l+o[0].length,"",o[1],">",null));else if(n.name=="ListItem"&&n.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(a.text.slice(l)))){let h=o[3],c=o[0].length;h.length>=4&&(h=h.slice(0,h.length-4),c-=4),i.push(new Ll(n.parent,l,l+c,o[1],h,o[2],n))}else if(n.name=="ListItem"&&n.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(a.text.slice(l)))){let h=o[4],c=o[0].length;h.length>4&&(h=h.slice(0,h.length-4),c-=4);let u=o[2];o[3]&&(u+=o[3].replace(/[xX]/," ")),i.push(new Ll(n.parent,l,l+c,o[1],h,u,n))}}return i}function ik(s,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(s.from,s.from+10))}function Xg(s,t,e,i=0){for(let r=-1,n=s;;){if(n.name=="ListItem"){let a=ik(n,t),l=+a[2];if(r>=0){if(l!=r+1)return;e.push({from:n.from+a[1].length,to:n.from+a[0].length,insert:String(r+2+i)})}r=l}let o=n.nextSibling;if(!o)break;n=o}}function Ng(s,t){let e=/^[ \t]*/.exec(s)[0].length;if(!e||t.facet($i)!=" ")return s;let i=_t(s,4,e),r="";for(let n=i;n>0;)n>=4?(r+=" ",n-=4):(r+=" ",n--);return r+s.slice(e)}function sk(s){return s.name=="QuoteMark"||s.name=="ListMark"}function eR(s,t){if(s.name!="OrderedList"&&s.name!="BulletList")return!1;let e=s.firstChild,i=s.getChild("ListItem","ListItem");if(!i)return!1;let r=t.lineAt(e.to),n=t.lineAt(i.from),o=/^[\s>]*$/.test(r.text);return r.number+(o?0:1)<n.number}function rk(s,t,e){let i="";for(let r=0,n=s.length-2;r<=n;r++)i+=s[r].blank(r<n?_t(e.text,4,s[r+1].from)-i.length:null,r<n);return Ng(i,t)}function iR(s,t){let e=s.resolveInner(t,-1),i=t;sk(e)&&(i=e.from,e=e.parent);for(let r;r=e.childBefore(i);)if(sk(r))i=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")e=r.lastChild,i=e.to;else break;return e}function ok(s={}){let{codeLanguages:t,defaultCodeLanguage:e,addKeymap:i=!0,base:{parser:r}=Bg,completeHTMLTags:n=!0,pasteURLAsLink:o=!0,htmlTagLanguage:a=nk}=s;if(!(r instanceof io))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=s.extensions?[s.extensions]:[],h=[a.support,K2],c;o&&h.push(Wg),e instanceof vt?(h.push(e.support),c=e.language):e&&(c=e);let u=t||c?tR(t,c):void 0;l.push(Tg({codeParser:u,htmlParser:a.language.parser})),i&&h.push(ce.high(ni.of(Vg)));let d=qg(r.configure(l));return n&&h.push(d.data.of({autocomplete:sR})),new vt(d,h)}function sR(s){let{state:t,pos:e}=s,i=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(e-25,e));if(!i)return null;let r=G(t).resolveInner(e,-1);for(;r&&!r.type.isTop;){if(r.name=="CodeBlock"||r.name=="FencedCode"||r.name=="ProcessingInstructionBlock"||r.name=="CommentBlock"||r.name=="Link"||r.name=="Image")return null;r=r.parent}return{from:e-i[0].length,to:e,options:rR(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}function rR(){if(Zg)return Zg;let s=fu(new Xs(nt.create({extensions:nk}),0,!0));return Zg=s?s.options:[]}var Kw,Jw,tk,K2,Bg,J2,so,Ll,zg,_g,jg,Vg,nk,Zg,nR,Wg,lk=B(()=>{ii();Si();li();ig();Gw();gg();Be();Kw=Ms({commentTokens:{block:{open:"<!--",close:"-->"}}}),Jw=new z,tk=Qg.configure({props:[ie.add(s=>!s.is("Block")||s.is("Document")||Dg(s)!=null||H2(s)?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),Jw.add(Dg),ee.add({Document:()=>null}),oi.add({Document:Kw})]});K2=Fc.of((s,t,e)=>{for(let i=G(s).resolveInner(e,-1);i&&!(i.from<t);i=i.parent){let r=i.type.prop(Jw);if(r==null)continue;let n=G2(i,r);if(n>e)return{from:e,to:n}}return null});Bg=qg(tk),J2=tk.configure([Lg,Rg,Mg,Ig,{props:[ie.add({Table:(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}]),so=qg(J2);Ll=class{constructor(t,e,i,r,n,o,a){this.node=t,this.from=e,this.to=i,this.spaceBefore=r,this.spaceAfter=n,this.type=o,this.item=a}blank(t,e=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(t!=null){for(;i.length<t;)i+=" ";return i}else{for(let r=this.to-this.from-i.length-this.spaceAfter.length;r>0;r--)i+=" ";return i+(e?this.spaceAfter:"")}}marker(t,e){let i=this.node.name=="OrderedList"?String(+ik(this.item,t)[2]+e):"";return this.spaceBefore+i+this.type+this.spaceAfter}};zg=(s={})=>({state:t,dispatch:e})=>{let i=G(t),{doc:r}=t,n=null,o=t.changeByRange(a=>{if(!a.empty||!so.isActiveAt(t,a.from,-1)&&!so.isActiveAt(t,a.from,1))return n={range:a};let l=a.from,h=r.lineAt(l),c=ek(i.resolveInner(l,-1),r);for(;c.length&&c[c.length-1].from>l-h.from;)c.pop();if(!c.length)return n={range:a};let u=c[c.length-1];if(u.to-u.spaceAfter.length>l-h.from)return n={range:a};let d=l>=u.to-u.spaceAfter.length&&!/\S/.test(h.text.slice(u.to));if(u.item&&d){let g=u.node.firstChild,y=u.node.getChild("ListItem","ListItem");if(g.to>=l||y&&y.to<l||h.from>0&&!/[^\s>]/.test(r.lineAt(h.from-1).text)||s.nonTightLists===!1){let v=c.length>1?c[c.length-2]:null,w,k="";v&&v.item?(w=h.from+v.from,k=v.marker(r,1)):w=h.from+(v?v.to:0);let E=[{from:w,to:l,insert:k}];return u.node.name=="OrderedList"&&Xg(u.item,r,E,-2),v&&v.node.name=="OrderedList"&&Xg(v.item,r,E),{range:P.cursor(w+k.length),changes:E}}else{let v=rk(c,t,h);return{range:P.cursor(l+v.length+1),changes:{from:h.from,insert:v+t.lineBreak}}}}if(u.node.name=="Blockquote"&&d&&h.from){let g=r.lineAt(h.from-1),y=/>\s*$/.exec(g.text);if(y&&y.index==u.from){let v=t.changes([{from:g.from+y.index,to:g.to},{from:h.from+u.from,to:h.to}]);return{range:a.map(v),changes:v}}}let f=[];u.node.name=="OrderedList"&&Xg(u.item,r,f);let p=u.item&&u.item.from<h.from,m="";if(!p||/^[\s\d.)\-+*>]*/.exec(h.text)[0].length>=u.to)for(let g=0,y=c.length-1;g<=y;g++)m+=g==y&&!p?c[g].marker(r,1):c[g].blank(g<y?_t(h.text,4,c[g+1].from)-m.length:null);let b=l;for(;b>h.from&&/\s/.test(h.text.charAt(b-h.from-1));)b--;return m=Ng(m,t),eR(u.node,t.doc)&&(m=rk(c,t,h)+t.lineBreak+m),f.push({from:b,to:l,insert:t.lineBreak+m}),{range:P.cursor(b+m.length+1),changes:f}});return n?!1:(e(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},_g=zg();jg=({state:s,dispatch:t})=>{let e=G(s),i=null,r=s.changeByRange(n=>{let o=n.from,{doc:a}=s;if(n.empty&&so.isActiveAt(s,n.from)){let l=a.lineAt(o),h=ek(iR(e,o),a);if(h.length){let c=h[h.length-1],u=c.to-c.spaceAfter.length+(c.spaceAfter?1:0);if(o-l.from>u&&!/\S/.test(l.text.slice(u,o-l.from)))return{range:P.cursor(l.from+u),changes:{from:l.from+u,to:o}};if(o-l.from==u&&(!c.item||l.from<=c.item.from||!/\S/.test(l.text.slice(0,c.to)))){let d=l.from+c.from;if(c.item&&c.node.from<c.item.from&&/\S/.test(l.text.slice(c.from,c.to))){let f=c.blank(_t(l.text,4,c.to)-_t(l.text,4,c.from));return d==l.from&&(f=Ng(f,s)),{range:P.cursor(d+f.length),changes:{from:d,to:l.from+c.to,insert:f}}}if(d<o)return{range:P.cursor(d),changes:{from:d,to:o}}}}}return i={range:n}});return i?!1:(t(s.update(r,{scrollIntoView:!0,userEvent:"delete"})),!0)},Vg=[{key:"Enter",run:_g},{key:"Backspace",run:jg}],nk=pu({matchClosingTags:!1});Zg=null;nR=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Wg=I.domEventHandlers({paste:(s,t)=>{var e;let{main:i}=t.state.selection;if(i.empty)return!1;let r=(e=s.clipboardData)===null||e===void 0?void 0:e.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!so.isActiveAt(t.state,i.from,1)))return!1;let n=G(t.state),o=!1;return n.iterate({from:i.from,to:i.to,enter:a=>{(a.from>i.from||nR.test(a.name))&&(o=!0)},leave:a=>{a.to<i.to&&(o=!0)}}),o?!1:(t.dispatch({changes:[{from:i.from,insert:"["},{from:i.to,insert:`](${r})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}})});function Rl(s,t){for(let e=0,i=t-s.pos-1;;i--,e++){let r=s.peek(i);if(Mi(r)||r==-1)return e}}function Hg(s){return s==32||s==9}function Mi(s){return s==10||s==13}function pk(s){return Hg(s)||Mi(s)}function Bs(s){return s<0||pk(s)}function no(s,t,e=0){return s.peek(e)==t&&s.peek(e+1)==t&&s.peek(e+2)==t&&Bs(s.peek(e+3))}function CR(s){return s>32&&s<127&&s!=34&&s!=37&&s!=44&&s!=60&&s!=62&&s!=92&&s!=94&&s!=96&&s!=123&&s!=124&&s!=125}function mk(s){return s>=48&&s<=57||s>=97&&s<=102||s>=65&&s<=70}function gk(s,t){return s.next==37?(s.advance(),mk(s.next)&&s.advance(),mk(s.next)&&s.advance(),!0):CR(s.next)||t&&s.next==44?(s.advance(),!0):!1}function bk(s){if(s.advance(),s.next==60){for(s.advance();;)if(!gk(s,!0)){s.next==62&&s.advance();break}}else for(;gk(s,!1););}function Gg(s){for(s.advance();!Bs(s.next)&&Au(s.next)!="f";)s.advance()}function Kg(s,t){let e=s.next,i=!1,r=s.pos;for(s.advance();;){let n=s.next;if(n<0)break;if(s.advance(),n==e)if(n==39)if(s.next==39)s.advance();else break;else break;else if(n==92&&e==34)s.next>=0&&s.advance();else if(Mi(n)){if(t)return!1;i=!0}else if(t&&s.pos>=r+1024)return!1}return!i}function $R(s){for(let t=[],e=s.pos+1024;;)if(s.next==91||s.next==123)t.push(s.next),s.advance();else if(s.next==39||s.next==34){if(!Kg(s,!0))return!1}else if(s.next==93||s.next==125){if(t[t.length-1]!=s.next-2)return!1;if(t.pop(),s.advance(),!t.length)return!0}else{if(s.next<0||s.pos>e||Mi(s.next))return!1;s.advance()}}function Au(s){return s<33?"u":s>125?"s":PR[s-33]}function Jg(s,t){let e=Au(s);return e!="u"&&!(t&&e=="f")}function Ok(s,t,e,i){if(Au(s.next)=="s"||(s.next==63||s.next==58||s.next==45)&&Jg(s.peek(1),e))s.advance();else return!1;let r=s.pos;for(;;){let n=s.next,o=0,a=i+1;for(;pk(n);){if(Mi(n)){if(t)return!1;a=0}else a++;n=s.peek(++o)}if(!(n>=0&&(n==58?Jg(s.peek(o+1),e):n==35?s.peek(o-1)!=32:Jg(n,e)))||!e&&a<=i||a==0&&!e&&(no(s,45,o)||no(s,46,o)))break;if(t&&Au(n)=="f")return!1;for(let h=o;h>=0;h--)s.advance();if(t&&s.pos>r+1024)return!1}return!0}var ro,hk,oR,aR,ck,lR,uk,hR,cR,dk,uR,dR,fR,pR,mR,gR,fk,bR,OR,yR,vR,xR,SR,wR,Ug,Fg,Ml,Yg,Li,kR,AR,ER,PR,QR,TR,LR,tb,yk=B(()=>{gs();ti();ro=63,hk=64,oR=1,aR=2,ck=3,lR=4,uk=5,hR=6,cR=7,dk=65,uR=66,dR=8,fR=9,pR=10,mR=11,gR=12,fk=13,bR=19,OR=20,yR=29,vR=33,xR=34,SR=47,wR=0,Ug=1,Fg=2,Ml=3,Yg=4,Li=class{constructor(t,e,i){this.parent=t,this.depth=e,this.type=i,this.hash=(t?t.hash+t.hash<<8:0)+e+(e<<4)+i}};Li.top=new Li(null,-1,wR);kR=new bi({start:Li.top,reduce(s,t){return s.type==Ml&&(t==OR||t==xR)?s.parent:s},shift(s,t,e,i){if(t==ck)return new Li(s,Rl(i,i.pos),Ug);if(t==dk||t==uk)return new Li(s,Rl(i,i.pos),Fg);if(t==ro)return s.parent;if(t==bR||t==vR)return new Li(s,0,Ml);if(t==fk&&s.type==Yg)return s.parent;if(t==SR){let r=/[1-9]/.exec(i.read(i.pos,e.pos));if(r)return new Li(s,s.depth+ +r[0],Yg)}return s},hash(s){return s.hash}});AR=new ft((s,t)=>{if(s.next==-1&&t.canShift(hk))return s.acceptToken(hk);let e=s.peek(-1);if((Mi(e)||e<0)&&t.context.type!=Ml){if(no(s,45))if(t.canShift(ro))s.acceptToken(ro);else return s.acceptToken(oR,3);if(no(s,46))if(t.canShift(ro))s.acceptToken(ro);else return s.acceptToken(aR,3);let i=0;for(;s.next==32;)i++,s.advance();(i<t.context.depth||i==t.context.depth&&t.context.type==Ug&&(s.next!=45||!Bs(s.peek(1))))&&s.next!=-1&&!Mi(s.next)&&s.next!=35&&s.acceptToken(ro,-i)}},{contextual:!0}),ER=new ft((s,t)=>{if(t.context.type==Ml){s.next==63&&(s.advance(),Bs(s.next)&&s.acceptToken(cR));return}if(s.next==45)s.advance(),Bs(s.next)&&s.acceptToken(t.context.type==Ug&&t.context.depth==Rl(s,s.pos-1)?lR:ck);else if(s.next==63)s.advance(),Bs(s.next)&&s.acceptToken(t.context.type==Fg&&t.context.depth==Rl(s,s.pos-1)?hR:uk);else{let e=s.pos;for(;;)if(Hg(s.next)){if(s.pos==e)return;s.advance()}else if(s.next==33)bk(s);else if(s.next==38)Gg(s);else if(s.next==42){Gg(s);break}else if(s.next==39||s.next==34){if(Kg(s,!0))break;return}else if(s.next==91||s.next==123){if(!$R(s))return;break}else{Ok(s,!0,!1,0);break}for(;Hg(s.next);)s.advance();if(s.next==58){if(s.pos==e&&t.canShift(yR))return;let i=s.peek(1);Bs(i)&&s.acceptTokenTo(t.context.type==Fg&&t.context.depth==Rl(s,e)?uR:dk,e)}}},{contextual:!0});PR="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";QR=new ft((s,t)=>{if(s.next==33)bk(s),s.acceptToken(gR);else if(s.next==38||s.next==42){let e=s.next==38?pR:mR;Gg(s),s.acceptToken(e)}else s.next==39||s.next==34?(Kg(s,!1),s.acceptToken(fR)):Ok(s,!1,t.context.type==Ml,t.context.depth)&&s.acceptToken(dR)}),TR=new ft((s,t)=>{let e=t.context.type==Yg?t.context.depth:-1,i=s.pos;t:for(;;){let r=0,n=s.next;for(;n==32;)n=s.peek(++r);if(!r&&(no(s,45,r)||no(s,46,r))||!Mi(n)&&(e<0&&(e=Math.max(t.context.depth+1,r)),r<e))break;for(;;){if(s.next<0)break t;let o=Mi(s.next);if(s.advance(),o)continue t;i=s.pos}}s.acceptTokenTo(fk,i)}),LR=Lt({DirectiveName:O.keyword,DirectiveContent:O.attributeValue,"DirectiveEnd DocEnd":O.meta,QuotedLiteral:O.string,BlockLiteralHeader:O.special(O.string),BlockLiteralContent:O.content,Literal:O.content,"Key/Literal Key/QuotedLiteral":O.definition(O.propertyName),"Anchor Alias":O.labelName,Tag:O.typeName,Comment:O.lineComment,": , -":O.separator,"?":O.punctuation,"[ ]":O.squareBracket,"{ }":O.brace}),tb=Ht.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"\u26A0 DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:kR,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[LR],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[AR,ER,QR,TR,0,1],topRules:{Stream:[0,15]},tokenPrec:0})});var Sk={};Yt(Sk,{yaml:()=>vk,yamlFrontmatter:()=>xk,yamlLanguage:()=>Eu});function vk(){return new vt(Eu)}function xk(s){let{language:t,support:e}=s.content instanceof vt?s.content:{language:s.content,support:[]};return new vt(RR.configure({wrap:ms(i=>i.name=="FrontmatterContent"?{parser:Eu.parser}:i.name=="Body"?{parser:t.parser}:null)}),e)}var MR,Eu,RR,wk=B(()=>{yk();li();Be();ti();gs();MR=Ht.deserialize({version:14,states:"!vOQOPOOO]OPO'#C_OhOPO'#C^OOOO'#Cc'#CcOpOPO'#CaQOOOOOO{OPOOOOOO'#Cb'#CbO!WOPO'#C`O!`OPO,58xOOOO-E6a-E6aOOOO-E6`-E6`OOOO'#C_'#C_OOOO1G.d1G.d",stateData:"!h~OXPOYROWTP~OWVXXRXYRX~OYVOXSP~OXROYROWTX~OXROYROWTP~OYVOXSX~OX[O~OXY~",goto:"vWPPX[beioRUOQQOR]XRXQTTOUQWQRZWSSOURYS",nodeNames:"\u26A0 Document Frontmatter DashLine FrontmatterContent Body",maxTerm:10,skippedNodes:[0],repeatNodeCount:2,tokenData:"$z~RXOYnYZ!^Z]n]^!^^}n}!O!i!O;'Sn;'S;=`!c<%lOn~qXOYnYZ!^Z]n]^!^^;'Sn;'S;=`!c<%l~n~On~~!^~!cOY~~!fP;=`<%ln~!lZOYnYZ!^Z]n]^!^^}n}!O#_!O;'Sn;'S;=`!c<%l~n~On~~!^~#bZOYnYZ!^Z]n]^!^^}n}!O$T!O;'Sn;'S;=`!c<%l~n~On~~!^~$WXOYnYZ$sZ]n]^$s^;'Sn;'S;=`!c<%l~n~On~~$s~$zOX~Y~",tokenizers:[0],topRules:{Document:[0,1]},tokenPrec:67}),Eu=pe.define({name:"yaml",parser:tb.configure({props:[ee.add({Stream:s=>{for(let t=s.node.resolve(s.pos,-1);t&&t.to>=s.pos;t=t.parent){if(t.name=="BlockLiteralContent"&&t.from<t.to)return s.baseIndentFor(t);if(t.name=="BlockLiteral")return s.baseIndentFor(t)+s.unit;if(t.name=="BlockSequence"||t.name=="BlockMapping")return s.column(t.firstChild.from,1);if(t.name=="QuotedLiteral")return null;if(t.name=="Literal"){let e=s.column(t.from,1);if(e==s.lineIndent(t.from,1))return e;if(t.to>s.pos)return null}}return null},FlowMapping:Yn({closing:"}"}),FlowSequence:Yn({closing:"]"})}),ie.add({"FlowMapping FlowSequence":Pi,"Item Pair BlockLiteral":(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});RR=pe.define({name:"yaml-frontmatter",parser:MR.configure({props:[Lt({DashLine:O.meta})]})})});function zs(s,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let r=s(t,e);return r?(i(e.update(r)),!0):!1}}function eb(s,t){let e=s.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}function NR(s,{open:t,close:e},i,r){let n=s.sliceDoc(i-Il,i),o=s.sliceDoc(r,r+Il),a=/\s*$/.exec(n)[0].length,l=/^\s*/.exec(o)[0].length,h=n.length-a;if(n.slice(h-t.length,h)==t&&o.slice(l,l+e.length)==e)return{open:{pos:i-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let c,u;r-i<=2*Il?c=u=s.sliceDoc(i,r):(c=s.sliceDoc(i,i+Il),u=s.sliceDoc(r-Il,r));let d=/^\s*/.exec(c)[0].length,f=/\s*$/.exec(u)[0].length,p=u.length-f-e.length;return c.slice(d,d+t.length)==t&&u.slice(p,p+e.length)==e?{open:{pos:i+d+t.length,margin:/\s/.test(c.charAt(d+t.length))?1:0},close:{pos:r-f-e.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function ZR(s){let t=[];for(let e of s.selection.ranges){let i=s.doc.lineAt(e.from),r=e.to<=i.to?i:s.doc.lineAt(e.to);r.from>i.from&&r.from==e.to&&(r=e.to==i.to+1?i:s.doc.lineAt(e.to-1));let n=t.length-1;n>=0&&t[n].to>i.from?t[n].to=r.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return t}function Cu(s,t,e=t.selection.ranges){let i=e.map(n=>eb(t,n.from).block);if(!i.every(n=>n))return null;let r=e.map((n,o)=>NR(t,i[o],n.from,n.to));if(s!=2&&!r.every(n=>n))return{changes:t.changes(e.map((n,o)=>r[o]?[]:[{from:n.from,insert:i[o].open+" "},{from:n.to,insert:" "+i[o].close}]))};if(s!=1&&r.some(n=>n)){let n=[];for(let o=0,a;o<r.length;o++)if(a=r[o]){let l=i[o],{open:h,close:c}=a;n.push({from:h.pos-l.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+l.close.length})}return{changes:n}}return null}function ib(s,t,e=t.selection.ranges){let i=[],r=-1;t:for(let{from:n,to:o}of e){let a=i.length,l=1e9,h;for(let c=n;c<=o;){let u=t.doc.lineAt(c);if(h==null&&(h=eb(t,u.from).line,!h))continue t;if(u.from>r&&(n==o||o>u.from)){r=u.from;let d=/^\s*/.exec(u.text)[0].length,f=d==u.length,p=u.text.slice(d,d+h.length)==h?d:-1;d<u.text.length&&d<l&&(l=d),i.push({line:u,comment:p,token:h,indent:d,empty:f,single:!1})}c=u.to+1}if(l<1e9)for(let c=a;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=l);i.length==a+1&&(i[a].single=!0)}if(s!=2&&i.some(n=>n.comment<0&&(!n.empty||n.single))){let n=[];for(let{line:a,token:l,indent:h,empty:c,single:u}of i)(u||!c)&&n.push({from:a.from+h,insert:l+" "});let o=t.changes(n);return{changes:o,selection:t.selection.map(o,1)}}else if(s!=1&&i.some(n=>n.comment>=0)){let n=[];for(let{line:o,comment:a,token:l}of i)if(a>=0){let h=o.from+a,c=h+l.length;o.text[c-o.from]==" "&&c++,n.push({from:h,to:c})}return{changes:n}}return null}function zu(s={}){return[$u,Qk.of(s),I.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?rb:t.inputType=="historyRedo"?Qu:null;return i?(t.preventDefault(),i(e)):!1}})]}function Pu(s,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let r=e.field($u,!1);if(!r)return!1;let n=r.pop(s,e,t);return n?(i(n),!0):!1}}function Mk(s){return function(t){let e=t.field($u,!1);if(!e)return 0;let i=s==0?e.done:e.undone;return i.length-(i.length&&!i[0].changes?1:0)}}function Tu(s,t,e,i){let r=t+1>e+20?t-e-1:0,n=s.slice(r,t);return n.push(i),n}function jR(s,t){let e=[],i=!1;return s.iterChangedRanges((r,n)=>e.push(r,n)),t.iterChangedRanges((r,n,o,a)=>{for(let l=0;l<e.length;){let h=e[l++],c=e[l++];a>=h&&o<=c&&(i=!0)}}),i}function VR(s,t){return s.ranges.length==t.ranges.length&&s.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function Rk(s,t){return s.length?t.length?s.concat(t):s:t}function Ik(s,t){if(s.length){let e=s[s.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-WR));return i.length&&i[i.length-1].eq(t)?s:(i.push(t),Tu(s,s.length-1,1e9,e.setSelAfter(i)))}else return[_e.selection([t])]}function UR(s){let t=s[s.length-1],e=s.slice();return e[s.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function nb(s,t){if(!s.length)return s;let e=s.length,i=De;for(;e;){let r=FR(s[e-1],t,i);if(r.changes&&!r.changes.empty||r.effects.length){let n=s.slice(0,e);return n[e-1]=r,n}else t=r.mapped,e--,i=r.selectionsAfter}return i.length?[_e.selection(i)]:De}function FR(s,t,e){let i=Rk(s.selectionsAfter.length?s.selectionsAfter.map(a=>a.map(t)):De,e);if(!s.changes)return _e.selection(i);let r=s.changes.map(t),n=t.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(n):n;return new _e(r,W.mapEffects(s.effects,t),o,s.startSelection.map(n),i)}function oo(s,t){return P.create(s.ranges.map(t),s.mainIndex)}function je(s,t){return s.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function ge({state:s,dispatch:t},e){let i=oo(s.selection,e);return i.eq(s.selection,!0)?!1:(t(je(s,i)),!0)}function js(s,t){return P.cursor(t?s.to:s.from)}function Lu(s,t){return ge(s,e=>e.empty?s.moveByChar(e,t):js(e,t))}function Vt(s){return s.textDirectionAt(s.state.selection.main.head)==st.LTR}function lb(s,t,e){let i=t.head,r=s.doc.lineAt(i);return i==(e?r.to:r.from)?i=e?Math.min(s.doc.length,r.to+1):Math.max(0,r.from-1):i=r.from+kt(r.text,i-r.from,e),P.cursor(i,e?-1:1)}function Dk(s,t){return ge(s,e=>e.empty?lb(s.state,e,t):js(e,t))}function Mu(s,t){return ge(s,e=>e.empty?s.moveByGroup(e,t):js(e,t))}function hb(s,t,e){let i=s.state.charCategorizer(t),r=i(e),n=r!=pt.Space;return o=>{let a=i(o);return a!=pt.Space?n&&a==r:(n=!1,!0)}}function Zk(s,t,e){let i=s.state.charCategorizer(t.from),r=pt.Space,n=t.from,o=0,a=!1,l=!1,h=!1,c=d=>{if(a)return!1;n+=e?d.length:-d.length;let f=i(d),p;if(f==pt.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(f=-1),r==pt.Space&&(r=f),r!=f)return!1;if(r==pt.Word)if(d.toLowerCase()==d){if(!e&&l)return!1;h=!0}else if(h){if(e)return!1;a=!0}else{if(l&&e&&i(p=s.state.sliceDoc(n,n+1))==pt.Word&&p.toLowerCase()==p)return!1;l=!0}return o++,!0},u=s.moveByChar(t,e,d=>(c(d),c));if(Nk&&r==pt.Word&&u.from==t.from+o*(e?1:-1)){let d=Math.min(t.head,u.head),f=Math.max(t.head,u.head),p=s.state.sliceDoc(d,f);if(p.length>1&&/[\u4E00-\uffff]/.test(p)){let m=Array.from(Nk.segment(p));if(m.length>1)return e?P.cursor(t.head+m[1].index,-1):P.cursor(u.head+m[m.length-1].index,1)}}return u}function Bk(s,t){return ge(s,e=>e.empty?Zk(s,e,t):js(e,t))}function nI(s,t,e){if(t.type.prop(e))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(s.sliceDoc(t.from,t.to)))||t.firstChild}function Ru(s,t,e){let i=G(s).resolveInner(t.head),r=e?z.closedBy:z.openedBy;for(let l=t.head;;){let h=e?i.childAfter(l):i.childBefore(l);if(!h)break;nI(s,h,r)?i=h:l=e?h.to:h.from}let n=i.type.prop(r),o,a;return n&&(o=e?Re(s,i.from,1):Re(s,i.to,-1))&&o.matched?a=e?o.end.to:o.end.from:a=e?i.to:i.from,P.cursor(a,e?-1:1)}function jk(s,t){return ge(s,e=>{if(!e.empty)return js(e,t);let i=s.moveVertically(e,t);return i.head!=e.head?i:s.moveToLineBoundary(e,t)})}function Vk(s){let t=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,e=0,i=0,r;if(t){for(let n of s.state.facet(I.scrollMargins)){let o=n(s);o?.top&&(e=Math.max(o?.top,e)),o?.bottom&&(i=Math.max(o?.bottom,i))}r=s.scrollDOM.clientHeight-e-i}else r=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:i,selfScroll:t,height:Math.max(s.defaultLineHeight,r-5)}}function Wk(s,t){let e=Vk(s),{state:i}=s,r=oo(i.selection,o=>o.empty?s.moveVertically(o,t,e.height):js(o,t));if(r.eq(i.selection))return!1;let n;if(e.selfScroll){let o=s.coordsAtPos(i.selection.main.head),a=s.scrollDOM.getBoundingClientRect(),l=a.top+e.marginTop,h=a.bottom-e.marginBottom;o&&o.top>l&&o.bottom<h&&(n=I.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-l}))}return s.dispatch(je(i,r),{effects:n}),!0}function Ji(s,t,e){let i=s.lineBlockAt(t.head),r=s.moveToLineBoundary(t,e);if(r.head==t.head&&r.head!=(e?i.to:i.from)&&(r=s.moveToLineBoundary(t,e,!1)),!e&&r.head==i.from&&i.length){let n=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(r=P.cursor(i.from+n))}return r}function Jk(s,t,e){let i=!1,r=oo(s.selection,n=>{let o=Re(s,n.head,-1)||Re(s,n.head,1)||n.head>0&&Re(s,n.head-1,1)||n.head<s.doc.length&&Re(s,n.head+1,-1);if(!o||!o.end)return n;i=!0;let a=o.start.from==n.head?o.end.to:o.end.from;return e?P.range(n.anchor,a):P.cursor(a)});return i?(t(je(s,r)),!0):!1}function Wt(s,t){let e=oo(s.state.selection,i=>{let r=t(i);return P.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return e.eq(s.state.selection)?!1:(s.dispatch(je(s.state,e)),!0)}function Du(s,t){return Wt(s,e=>s.moveByChar(e,t))}function qu(s,t){return Wt(s,e=>s.moveByGroup(e,t))}function sA(s,t){return Wt(s,e=>Zk(s,e,t))}function oA(s,t){return Wt(s,e=>s.moveVertically(e,t))}function aA(s,t){return Wt(s,e=>s.moveVertically(e,t,Vk(s).height))}function bA(s,t){let{state:e}=s,i=e.selection,r=e.selection.ranges.slice();for(let n of e.selection.ranges){let o=e.doc.lineAt(n.head);if(t?o.to<s.state.doc.length:o.from>0)for(let a=n;;){let l=s.moveVertically(a,t);if(l.head<o.from||l.head>o.to){r.some(h=>h.head==l.head)||r.push(l);break}else{if(l.head==a.head)break;a=l}}}return r.length==i.ranges.length?!1:(s.dispatch(je(e,P.create(r,r.length-1))),!0)}function Vs(s,t){if(s.state.readOnly)return!1;let e="delete.selection",{state:i}=s,r=i.changeByRange(n=>{let{from:o,to:a}=n;if(o==a){let l=t(n);l<o?(e="delete.backward",l=Xu(s,l,!1)):l>o&&(e="delete.forward",l=Xu(s,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=Xu(s,o,!1),a=Xu(s,a,!0);return o==a?{range:n}:{changes:{from:o,to:a},range:P.cursor(o,o<n.head?-1:1)}});return r.changes.empty?!1:(s.dispatch(i.update(r,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?I.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Xu(s,t,e){if(s instanceof I)for(let i of s.state.facet(I.atomicRanges).map(r=>r(s)))i.between(t,t,(r,n)=>{r<t&&n>t&&(t=e?n:r)});return t}function Zu(s){let t=[],e=-1;for(let i of s.selection.ranges){let r=s.doc.lineAt(i.from),n=s.doc.lineAt(i.to);if(!i.empty&&i.to==n.from&&(n=s.doc.lineAt(i.to-1)),e>=r.number){let o=t[t.length-1];o.to=n.to,o.ranges.push(i)}else t.push({from:r.from,to:n.to,ranges:[i]});e=n.number+1}return t}function $A(s,t,e){if(s.readOnly)return!1;let i=[],r=[];for(let n of Zu(s)){if(e?n.to==s.doc.length:n.from==0)continue;let o=s.doc.lineAt(e?n.to+1:n.from-1),a=o.length+1;if(e){i.push({from:n.to,to:o.to},{from:n.from,insert:o.text+s.lineBreak});for(let l of n.ranges)r.push(P.range(Math.min(s.doc.length,l.anchor+a),Math.min(s.doc.length,l.head+a)))}else{i.push({from:o.from,to:n.from},{from:n.to,insert:s.lineBreak+o.text});for(let l of n.ranges)r.push(P.range(l.anchor-a,l.head-a))}}return i.length?(t(s.update({changes:i,scrollIntoView:!0,selection:P.create(r,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}function TA(s,t,e){if(s.readOnly)return!1;let i=[];for(let n of Zu(s))e?i.push({from:n.from,insert:s.doc.slice(n.from,n.to)+s.lineBreak}):i.push({from:n.to,insert:s.lineBreak+s.doc.slice(n.from,n.to)});let r=s.changes(i);return t(s.update({changes:r,selection:s.selection.map(r,e?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}function SI(s,t){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=G(s).resolveInner(t),i=e.childBefore(t),r=e.childAfter(t),n;return i&&r&&i.to<=t&&r.from>=t&&(n=i.type.prop(z.closedBy))&&n.indexOf(r.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(r.from).from&&!/\S/.test(s.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}function DA(s){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(r=>{let{from:n,to:o}=r,a=t.doc.lineAt(n),l=!s&&n==o&&SI(t,n);s&&(n=o=(o<=a.to?a:t.doc.lineAt(o)).to);let h=new Ai(t,{simulateBreak:n,simulateDoubleBreak:!!l}),c=Fn(h,n);for(c==null&&(c=_t(/^\s*/.exec(t.doc.lineAt(n).text)[0],t.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:n,to:o}=l:n>a.from&&n<a.from+100&&!/\S/.test(a.text.slice(0,n))&&(n=a.from);let u=["",Hi(t,c)];return l&&u.push(Hi(t,h.lineIndent(a.from,-1))),{changes:{from:n,to:o,insert:K.of(u)},range:P.cursor(n+1+u[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Cb(s,t){let e=-1;return s.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let a=s.doc.lineAt(o);a.number>e&&(i.empty||i.to>a.from)&&(t(a,r,i),e=a.number),o=a.to+1}let n=s.changes(r);return{changes:r,range:P.range(n.mapPos(i.anchor,1),n.mapPos(i.head,1))}})}var kk,Ak,IR,DR,Ek,qR,XR,Ck,Il,sb,$k,Pk,Qk,$u,BR,rb,Qu,Tk,Lk,zR,_R,_e,De,WR,YR,_s,_u,ob,ab,HR,GR,KR,JR,qk,Xk,tI,eI,iI,Nk,sI,rI,zk,_k,cb,ub,db,Iu,Uk,Fk,Yk,Hk,Gk,Kk,tA,oI,fb,pb,aI,lI,hI,cI,eA,iA,uI,dI,fI,pI,mI,rA,nA,mb,gb,bb,Ob,lA,hA,cA,uA,dA,fA,yb,vb,xb,Sb,pA,mA,gA,OA,yA,vA,wb,Nu,gI,kb,xA,Ab,SA,bI,wA,OI,kA,AA,yI,EA,CA,PA,QA,LA,MA,RA,vI,xI,Eb,IA,qA,Bu,$b,XA,wI,kI,NA,ZA,ju,Vu,BA=B(()=>{ii();Si();li();Be();kk=s=>{let{state:t}=s,e=t.doc.lineAt(t.selection.main.from),i=eb(s.state,e.from);return i.line?Ak(s):i.block?Ck(s):!1};Ak=zs(ib,0),IR=zs(ib,1),DR=zs(ib,2),Ek=zs(Cu,0),qR=zs(Cu,1),XR=zs(Cu,2),Ck=zs((s,t)=>Cu(s,t,ZR(t)),0);Il=50;sb=Gt.define(),$k=Gt.define(),Pk=X.define(),Qk=X.define({combine(s){return Kt(s,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,r)=>t(i,r)||e(i,r)})}}),$u=mt.define({create(){return _s.empty},update(s,t){let e=t.state.facet(Qk),i=t.annotation(sb);if(i){let l=_e.fromTransaction(t,i.selection),h=i.side,c=h==0?s.undone:s.done;return l?c=Tu(c,c.length,e.minDepth,l):c=Ik(c,t.startState.selection),new _s(h==0?i.rest:c,h==0?c:i.rest)}let r=t.annotation($k);if((r=="full"||r=="before")&&(s=s.isolate()),t.annotation(yt.addToHistory)===!1)return t.changes.empty?s:s.addMapping(t.changes.desc);let n=_e.fromTransaction(t),o=t.annotation(yt.time),a=t.annotation(yt.userEvent);return n?s=s.addChanges(n,o,a,e,t):t.selection&&(s=s.addSelection(t.startState.selection,o,a,e.newGroupDelay)),(r=="full"||r=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(t=>t.toJSON()),undone:s.undone.map(t=>t.toJSON())}},fromJSON(s){return new _s(s.done.map(_e.fromJSON),s.undone.map(_e.fromJSON))}});BR=$u;rb=Pu(0,!1),Qu=Pu(1,!1),Tk=Pu(0,!0),Lk=Pu(1,!0);zR=Mk(0),_R=Mk(1),_e=class s{constructor(t,e,i,r,n){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=r,this.selectionsAfter=n}setSelAfter(t){return new s(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(e=this.mapped)===null||e===void 0?void 0:e.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(t){return new s(t.changes&&Bt.fromJSON(t.changes),[],t.mapped&&ei.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,e){let i=De;for(let r of t.startState.facet(Pk)){let n=r(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new s(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,De)}static selection(t){return new s(void 0,De,void 0,void 0,t)}};De=[],WR=200;YR=/^(input\.type|delete)($|\.)/,_s=class s{constructor(t,e,i=0,r=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new s(this.done,this.undone):this}addChanges(t,e,i,r,n){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!i||YR.test(i))&&(!a.selectionsAfter.length&&e-this.prevTime<r.newGroupDelay&&r.joinToEvent(n,jR(a.changes,t.changes))||i=="input.type.compose")?o=Tu(o,o.length-1,r.minDepth,new _e(t.changes.compose(a.changes),Rk(W.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,De)):o=Tu(o,o.length,r.minDepth,t),new s(o,De,e,i)}addSelection(t,e,i,r){let n=this.done.length?this.done[this.done.length-1].selectionsAfter:De;return n.length>0&&e-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&VR(n[n.length-1],t)?this:new s(Ik(this.done,t),this.undone,e,i)}addMapping(t){return new s(nb(this.done,t),nb(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let r=t==0?this.done:this.undone;if(r.length==0)return null;let n=r[r.length-1],o=n.selectionsAfter[0]||(n.startSelection?n.startSelection.map(n.changes.invertedDesc,1):e.selection);if(i&&n.selectionsAfter.length)return e.update({selection:n.selectionsAfter[n.selectionsAfter.length-1],annotations:sb.of({side:t,rest:UR(r),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(n.changes){let a=r.length==1?De:r.slice(0,r.length-1);return n.mapped&&(a=nb(a,n.mapped)),e.update({changes:n.changes,selection:n.startSelection,effects:n.effects,annotations:sb.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};_s.empty=new _s(De,De);_u=[{key:"Mod-z",run:rb,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Qu,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Qu,preventDefault:!0},{key:"Mod-u",run:Tk,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Lk,preventDefault:!0}];ob=s=>Lu(s,!Vt(s)),ab=s=>Lu(s,Vt(s)),HR=s=>Lu(s,!0),GR=s=>Lu(s,!1);KR=s=>Dk(s,!0),JR=s=>Dk(s,!1);qk=s=>Mu(s,!Vt(s)),Xk=s=>Mu(s,Vt(s)),tI=s=>Mu(s,!0),eI=s=>Mu(s,!1);iI=s=>ge(s,t=>t.empty?s.moveByChar(t,!0,e=>hb(s,t.head,e)):js(t,!0)),Nk=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;sI=s=>Bk(s,!0),rI=s=>Bk(s,!1);zk=s=>ge(s,t=>Ru(s.state,t,!Vt(s))),_k=s=>ge(s,t=>Ru(s.state,t,Vt(s)));cb=s=>jk(s,!1),ub=s=>jk(s,!0);db=s=>Wk(s,!1),Iu=s=>Wk(s,!0);Uk=s=>ge(s,t=>Ji(s,t,!0)),Fk=s=>ge(s,t=>Ji(s,t,!1)),Yk=s=>ge(s,t=>Ji(s,t,!Vt(s))),Hk=s=>ge(s,t=>Ji(s,t,Vt(s))),Gk=s=>ge(s,t=>P.cursor(s.lineBlockAt(t.head).from,1)),Kk=s=>ge(s,t=>P.cursor(s.lineBlockAt(t.head).to,-1));tA=({state:s,dispatch:t})=>Jk(s,t,!1),oI=({state:s,dispatch:t})=>Jk(s,t,!0);fb=s=>Du(s,!Vt(s)),pb=s=>Du(s,Vt(s)),aI=s=>Du(s,!0),lI=s=>Du(s,!1),hI=s=>Wt(s,t=>lb(s.state,t,!0)),cI=s=>Wt(s,t=>lb(s.state,t,!1));eA=s=>qu(s,!Vt(s)),iA=s=>qu(s,Vt(s)),uI=s=>qu(s,!0),dI=s=>qu(s,!1),fI=s=>Wt(s,t=>s.moveByChar(t,!0,e=>hb(s,t.head,e)));pI=s=>sA(s,!0),mI=s=>sA(s,!1),rA=s=>Wt(s,t=>Ru(s.state,t,!Vt(s))),nA=s=>Wt(s,t=>Ru(s.state,t,Vt(s)));mb=s=>oA(s,!1),gb=s=>oA(s,!0);bb=s=>aA(s,!1),Ob=s=>aA(s,!0),lA=s=>Wt(s,t=>Ji(s,t,!0)),hA=s=>Wt(s,t=>Ji(s,t,!1)),cA=s=>Wt(s,t=>Ji(s,t,!Vt(s))),uA=s=>Wt(s,t=>Ji(s,t,Vt(s))),dA=s=>Wt(s,t=>P.cursor(s.lineBlockAt(t.head).from)),fA=s=>Wt(s,t=>P.cursor(s.lineBlockAt(t.head).to)),yb=({state:s,dispatch:t})=>(t(je(s,{anchor:0})),!0),vb=({state:s,dispatch:t})=>(t(je(s,{anchor:s.doc.length})),!0),xb=({state:s,dispatch:t})=>(t(je(s,{anchor:s.selection.main.anchor,head:0})),!0),Sb=({state:s,dispatch:t})=>(t(je(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),pA=({state:s,dispatch:t})=>(t(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),mA=({state:s,dispatch:t})=>{let e=Zu(s).map(({from:i,to:r})=>P.range(i,Math.min(r+1,s.doc.length)));return t(s.update({selection:P.create(e),userEvent:"select"})),!0},gA=({state:s,dispatch:t})=>{let e=oo(s.selection,i=>{let r=G(s),n=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=n.node.from&&o.node.to<=n.node.to&&(n=o)}for(let o=n;o;o=o.next){let{node:a}=o;if((a.from<i.from&&a.to>=i.to||a.to>i.to&&a.from<=i.from)&&o.next)return P.range(a.to,a.from)}return i});return e.eq(s.selection)?!1:(t(je(s,e)),!0)};OA=s=>bA(s,!1),yA=s=>bA(s,!0),vA=({state:s,dispatch:t})=>{let e=s.selection,i=null;return e.ranges.length>1?i=P.create([e.main]):e.main.empty||(i=P.create([P.cursor(e.main.head)])),i?(t(je(s,i)),!0):!1};wb=(s,t,e)=>Vs(s,i=>{let r=i.from,{state:n}=s,o=n.doc.lineAt(r),a,l;if(e&&!t&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,r-o.from))){if(a[a.length-1]==" ")return r-1;let h=_t(a,n.tabSize),c=h%Ei(n)||Ei(n);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)r--;l=r}else l=kt(o.text,r-o.from,t,t)+o.from,l==r&&o.number!=(t?n.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,r-o.from))&&(l=kt(o.text,l-o.from,!1,!1)+o.from);return l}),Nu=s=>wb(s,!1,!0),gI=s=>wb(s,!1,!1),kb=s=>wb(s,!0,!1),xA=(s,t)=>Vs(s,e=>{let i=e.head,{state:r}=s,n=r.doc.lineAt(i),o=r.charCategorizer(i);for(let a=null;;){if(i==(t?n.to:n.from)){i==e.head&&n.number!=(t?r.doc.lines:1)&&(i+=t?1:-1);break}let l=kt(n.text,i-n.from,t)+n.from,h=n.text.slice(Math.min(i,l)-n.from,Math.max(i,l)-n.from),c=o(h);if(a!=null&&c!=a)break;(h!=" "||i!=e.head)&&(a=c),i=l}return i}),Ab=s=>xA(s,!1),SA=s=>xA(s,!0),bI=s=>Vs(s,t=>s.moveByChar(t,!0,e=>hb(s,t.head,e)).head),wA=s=>Vs(s,t=>{let e=s.lineBlockAt(t.head).to;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),OI=s=>Vs(s,t=>{let e=s.lineBlockAt(t.head).from;return t.head>e?e:Math.max(0,t.head-1)}),kA=s=>Vs(s,t=>{let e=s.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),AA=s=>Vs(s,t=>{let e=s.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),yI=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=[];for(let i=0,r="",n=s.doc.iter();;){if(n.next(),n.lineBreak||n.done){let o=r.search(/\s+$/);if(o>-1&&e.push({from:i-(r.length-o),to:i}),n.done)break;r=""}else r=n.value;i+=n.value.length}return e.length?(t(s.update({changes:e,userEvent:"delete"})),!0):!1},EA=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:K.of(["",""])},range:P.cursor(i.from)}));return t(s.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},CA=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>{if(!i.empty||i.from==0||i.from==s.doc.length)return{range:i};let r=i.from,n=s.doc.lineAt(r),o=r==n.from?r-1:kt(n.text,r-n.from,!1)+n.from,a=r==n.to?r+1:kt(n.text,r-n.from,!0)+n.from;return{changes:{from:o,to:a,insert:s.doc.slice(r,a).append(s.doc.slice(o,r))},range:P.cursor(a)}});return e.changes.empty?!1:(t(s.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};PA=({state:s,dispatch:t})=>$A(s,t,!1),QA=({state:s,dispatch:t})=>$A(s,t,!0);LA=({state:s,dispatch:t})=>TA(s,t,!1),MA=({state:s,dispatch:t})=>TA(s,t,!0),RA=s=>{if(s.state.readOnly)return!1;let{state:t}=s,e=t.changes(Zu(t).map(({from:r,to:n})=>(r>0?r--:n<t.doc.length&&n++,{from:r,to:n}))),i=oo(t.selection,r=>{let n;if(s.lineWrapping){let o=s.lineBlockAt(r.head),a=s.coordsAtPos(r.head,r.assoc||1);a&&(n=o.bottom+s.documentTop-a.bottom+s.defaultLineHeight/2)}return s.moveVertically(r,!0,n)}).map(e);return s.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0},vI=({state:s,dispatch:t})=>(t(s.update(s.replaceSelection(s.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),xI=({state:s,dispatch:t})=>(t(s.update(s.changeByRange(e=>{let i=/^\s*/.exec(s.doc.lineAt(e.from).text)[0];return{changes:{from:e.from,to:e.to,insert:s.lineBreak+i},range:P.cursor(e.from+i.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);Eb=DA(!1),IA=DA(!0);qA=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=Object.create(null),i=new Ai(s,{overrideIndentation:n=>{let o=e[n];return o??-1}}),r=Cb(s,(n,o,a)=>{let l=Fn(i,n.from);if(l==null)return;/\S/.test(n.text)||(l=0);let h=/^\s*/.exec(n.text)[0],c=Hi(s,l);(h!=c||a.from<n.from+h.length)&&(e[n.from]=l,o.push({from:n.from,to:n.from+h.length,insert:c}))});return r.changes.empty||t(s.update(r,{userEvent:"indent"})),!0},Bu=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Cb(s,(e,i)=>{i.push({from:e.from,insert:s.facet($i)})}),{userEvent:"input.indent"})),!0),$b=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Cb(s,(e,i)=>{let r=/^\s*/.exec(e.text)[0];if(!r)return;let n=_t(r,s.tabSize),o=0,a=Hi(s,Math.max(0,n-Ei(s)));for(;o<r.length&&o<a.length&&r.charCodeAt(o)==a.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+r.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),XA=s=>(s.setTabFocusMode(),!0),wI=s=>(s.setTabFocusMode(2e3),!0),kI=({state:s,dispatch:t})=>s.selection.ranges.some(e=>!e.empty)?Bu({state:s,dispatch:t}):(t(s.update(s.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),NA=[{key:"Ctrl-b",run:ob,shift:fb,preventDefault:!0},{key:"Ctrl-f",run:ab,shift:pb},{key:"Ctrl-p",run:cb,shift:mb},{key:"Ctrl-n",run:ub,shift:gb},{key:"Ctrl-a",run:Gk,shift:dA},{key:"Ctrl-e",run:Kk,shift:fA},{key:"Ctrl-d",run:kb},{key:"Ctrl-h",run:Nu},{key:"Ctrl-k",run:wA},{key:"Ctrl-Alt-h",run:Ab},{key:"Ctrl-o",run:EA},{key:"Ctrl-t",run:CA},{key:"Ctrl-v",run:Iu}],ZA=[{key:"ArrowLeft",run:ob,shift:fb,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:qk,shift:eA,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Yk,shift:cA,preventDefault:!0},{key:"ArrowRight",run:ab,shift:pb,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Xk,shift:iA,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Hk,shift:uA,preventDefault:!0},{key:"ArrowUp",run:cb,shift:mb,preventDefault:!0},{mac:"Cmd-ArrowUp",run:yb,shift:xb},{mac:"Ctrl-ArrowUp",run:db,shift:bb},{key:"ArrowDown",run:ub,shift:gb,preventDefault:!0},{mac:"Cmd-ArrowDown",run:vb,shift:Sb},{mac:"Ctrl-ArrowDown",run:Iu,shift:Ob},{key:"PageUp",run:db,shift:bb},{key:"PageDown",run:Iu,shift:Ob},{key:"Home",run:Fk,shift:hA,preventDefault:!0},{key:"Mod-Home",run:yb,shift:xb},{key:"End",run:Uk,shift:lA,preventDefault:!0},{key:"Mod-End",run:vb,shift:Sb},{key:"Enter",run:Eb,shift:Eb},{key:"Mod-a",run:pA},{key:"Backspace",run:Nu,shift:Nu,preventDefault:!0},{key:"Delete",run:kb,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ab,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:SA,preventDefault:!0},{mac:"Mod-Backspace",run:kA,preventDefault:!0},{mac:"Mod-Delete",run:AA,preventDefault:!0}].concat(NA.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),ju=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:zk,shift:rA},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:_k,shift:nA},{key:"Alt-ArrowUp",run:PA},{key:"Shift-Alt-ArrowUp",run:LA},{key:"Alt-ArrowDown",run:QA},{key:"Shift-Alt-ArrowDown",run:MA},{key:"Mod-Alt-ArrowUp",run:OA},{key:"Mod-Alt-ArrowDown",run:yA},{key:"Escape",run:vA},{key:"Mod-Enter",run:IA},{key:"Alt-l",mac:"Ctrl-l",run:mA},{key:"Mod-i",run:gA,preventDefault:!0},{key:"Mod-[",run:$b},{key:"Mod-]",run:Bu},{key:"Mod-Alt-\\",run:qA},{key:"Shift-Mod-k",run:RA},{key:"Shift-Mod-\\",run:tA},{key:"Mod-/",run:kk},{key:"Alt-A",run:Ek},{key:"Ctrl-m",mac:"Shift-Alt-m",run:XA}].concat(ZA),Vu={key:"Tab",run:Bu,shift:$b}});function ts(s,t=null,e=0){let i=null;return s.between(e,1e9,(r,n,{spec:o})=>{if(!(t&&o.diagnostics.indexOf(t)<0))if(!i)i=new Wu(r,n,t||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Wu(i.from,n,i.diagnostic)}}),i}function zA(s,t){let e=t.pos,i=t.end||e,r=s.state.facet(hi).hideOn(s,e,i);if(r!=null)return r;let n=s.startState.doc.lineAt(t.pos);return!!(s.effects.some(o=>o.is(Dl))||s.changes.touchesRange(n.from,Math.max(n.to,i)))}function _A(s,t){return s.field(Ut,!1)?t:t.concat(W.appendConfig.of(e1))}function jA(s,t){return{effects:_A(s,[Dl.of(t)])}}function AI(s){let t=s.field(Ut,!1);return t?t.diagnostics.size:0}function CI(s,t,e){let{diagnostics:i}=s.state.field(Ut),r,n=-1,o=-1;i.between(t-(e<0?1:0),t+(e>0?1:0),(l,h,{spec:c})=>{if(t>=l&&t<=h&&(l==h||(t>l||e>0)&&(t<h||e<0)))return r=c.diagnostics,n=l,o=h,!1});let a=s.state.facet(hi).tooltipFilter;return r&&a&&(r=a(r,s.state)),r?{pos:n,end:o,above:s.state.doc.lineAt(n).to<o,create(){return{dom:WA(s,r)}}}:null}function WA(s,t){return $t("ul",{class:"cm-tooltip-lint"},t.map(e=>KA(s,e,!1)))}function QI(s,t,e){let i=[],r=-1;for(let n of s)n.then(o=>{i.push(o),clearTimeout(r),i.length==s.length?t(i):r=setTimeout(()=>t(i),200)},e)}function HA(s,t){return s?t?(e,i)=>t(s(e,i),i):s:t}function Xl(s,t={}){return[hi.of({source:s,config:t}),YA,e1]}function TI(s){let t=s.plugin(YA);t&&t.force()}function GA(s){let t=[];if(s)t:for(let{name:e}of s){for(let i=0;i<e.length;i++){let r=e[i];if(/[a-zA-Z]/.test(r)&&!t.some(n=>n.toLowerCase()==r.toLowerCase())){t.push(r);continue t}}t.push("")}return t}function KA(s,t,e){var i;let r=e?GA(t.actions):[];return $t("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},$t("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(s):t.message),(i=t.actions)===null||i===void 0?void 0:i.map((n,o)=>{let a=!1,l=f=>{if(f.preventDefault(),a)return;a=!0;let p=ts(s.state.field(Ut).diagnostics,t);p&&n.apply(s,p.from,p.to)},{name:h}=n,c=r[o]?h.indexOf(r[o]):-1,u=c<0?h:[h.slice(0,c),$t("u",h.slice(c,c+1)),h.slice(c+1)],d=n.markClass?" "+n.markClass:"";return $t("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},u)}),t.source&&$t("div",{class:"cm-diagnosticSource"},t.source))}function Fu(s,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(s)}</svg>')`}function Yu(s){return Fu(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${s}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}function MI(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function JA(s){let t="hint",e=1;for(let i of s){let r=MI(i.severity);r>e&&(e=r,t=i.severity)}return t}function RI(s,t){let e=i=>{let r=t.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientX<r.right+10&&i.clientY>r.top-10&&i.clientY<r.bottom+10)){for(let n=i.target;n;n=n.parentNode)if(n.nodeType==1&&n.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",e),s.state.field(t1)&&s.dispatch({effects:Mb.of(null)})}};window.addEventListener("mousemove",e)}function II(s,t,e){function i(){let o=s.elementAtHeight(t.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:Mb.of({pos:o.from,above:!1,clip:!1,create(){return{dom:WA(s,e),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,RI(s,t)}let{hoverTime:r}=s.state.facet(Gu),n=setTimeout(i,r);t.onmouseout=()=>{clearTimeout(n),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(n),n=setTimeout(i,r)}}function DI(s,t){let e=Object.create(null);for(let r of t){let n=s.lineAt(r.from);(e[n.from]||(e[n.from]=[])).push(r)}let i=[];for(let r in e)i.push(new Hu(e[r]).range(+r));return H.of(i,!0)}function Ku(s={}){return[Gu.of(s),Lb,qI,XI,t1]}function NI(s,t){let e=s.field(Ut,!1);if(e&&e.diagnostics.size){let i=[],r=[],n=-1;for(let o=H.iter([e.diagnostics]);;o.next()){for(let a=0;a<i.length;a++)(!o.value||o.value.spec.diagnostics.indexOf(i[a])<0)&&(t(i[a],r[a],n),i.splice(a,1),r.splice(a--,1));if(!o.value)break;for(let a of o.value.spec.diagnostics)i.indexOf(a)<0&&(i.push(a),r.push(o.from));n=o.to}}}var Wu,Ws,Dl,Pb,VA,Ut,EI,UA,Qb,FA,$I,PI,YA,hi,Tb,Uu,ql,LI,Hu,qI,Lb,Mb,t1,XI,e1,Gu,i1=B(()=>{Si();ii();Bf();Wu=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},Ws=class s{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let r=i.facet(hi).markerFilter;r&&(t=r(t,i));let n=t.slice().sort((f,p)=>f.from-p.from||f.to-p.to),o=new ke,a=[],l=0,h=i.doc.iter(),c=0,u=i.doc.length;for(let f=0;;){let p=f==n.length?null:n[f];if(!p&&!a.length)break;let m,b;if(a.length)m=l,b=a.reduce((v,w)=>Math.min(v,w.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>u)break;b=p.to,a.push(p),f++}for(;f<n.length;){let v=n[f];if(v.from==m&&(v.to>v.from||v.to==m))a.push(v),f++,b=Math.min(v.to,b);else{b=Math.min(v.from,b);break}}b=Math.min(b,u);let g=!1;if(a.some(v=>v.from==m&&(v.to==b||b==u))&&(g=m==b,!g&&b-m<10)){let v=m-(c+h.value.length);v>0&&(h.next(v),c=m);for(let w=m;;){if(w>=b){g=!0;break}if(!h.lineBreak&&c+h.value.length>w)break;w=c+h.value.length,c+=h.value.length,h.next()}}let y=JA(a);if(g)o.add(m,m,j.widget({widget:new Tb(y),diagnostics:a.slice()}));else{let v=a.reduce((w,k)=>k.markClass?w+" "+k.markClass:w,"");o.add(m,b,j.mark({class:"cm-lintRange cm-lintRange-"+y+v,diagnostics:a.slice(),inclusiveEnd:a.some(w=>w.to>b)}))}if(l=b,l==u)break;for(let v=0;v<a.length;v++)a[v].to<=l&&a.splice(v--,1)}let d=o.finish();return new s(d,e,ts(d))}};Dl=W.define(),Pb=W.define(),VA=W.define(),Ut=mt.define({create(){return new Ws(j.none,null,null)},update(s,t){if(t.docChanged&&s.diagnostics.size){let e=s.diagnostics.map(t.changes),i=null,r=s.panel;if(s.selected){let n=t.changes.mapPos(s.selected.from,1);i=ts(e,s.selected.diagnostic,n)||ts(e,null,n)}!e.size&&r&&t.state.facet(hi).autoPanel&&(r=null),s=new Ws(e,r,i)}for(let e of t.effects)if(e.is(Dl)){let i=t.state.facet(hi).autoPanel?e.value.length?ql.open:null:s.panel;s=Ws.init(e.value,i,t.state)}else e.is(Pb)?s=new Ws(s.diagnostics,e.value?ql.open:null,s.selected):e.is(VA)&&(s=new Ws(s.diagnostics,s.panel,e.value));return s},provide:s=>[jn.from(s,t=>t.panel),I.decorations.from(s,t=>t.diagnostics)]});EI=j.mark({class:"cm-lintRange cm-lintRange-active"});UA=s=>{let t=s.state.field(Ut,!1);(!t||!t.panel)&&s.dispatch({effects:_A(s.state,[Pb.of(!0)])});let e=Dc(s,ql.open);return e&&e.dom.querySelector(".cm-panel-lint ul").focus(),!0},Qb=s=>{let t=s.state.field(Ut,!1);return!t||!t.panel?!1:(s.dispatch({effects:Pb.of(!1)}),!0)},FA=s=>{let t=s.state.field(Ut,!1);if(!t)return!1;let e=s.state.selection.main,i=ts(t.diagnostics,null,e.to+1);return!i&&(i=ts(t.diagnostics,null,0),!i||i.from==e.from&&i.to==e.to)?!1:(s.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},$I=s=>{let{state:t}=s,e=t.field(Ut,!1);if(!e)return!1;let i=t.selection.main,r,n,o,a;return e.diagnostics.between(0,t.doc.length,(l,h)=>{h<i.to&&(r==null||r<l)&&(r=l,n=h),(o==null||l>o)&&(o=l,a=h)}),o==null||r==null&&o==i.from?!1:(s.dispatch({selection:{anchor:r??o,head:n??a},scrollIntoView:!0}),!0)},PI=[{key:"Mod-Shift-m",run:UA,preventDefault:!0},{key:"F8",run:FA}],YA=ht.fromClass(class{constructor(s){this.view=s,this.timeout=-1,this.set=!0;let{delay:t}=s.state.facet(hi);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let s=Date.now();if(s<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-s);else{this.set=!1;let{state:t}=this.view,{sources:e}=t.facet(hi);e.length&&QI(e.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==t.doc&&this.view.dispatch(jA(this.view.state,i.reduce((r,n)=>r.concat(n))))},i=>{Pt(this.view.state,i)})}}update(s){let t=s.state.facet(hi);(s.docChanged||t!=s.startState.facet(hi)||t.needsRefresh&&t.needsRefresh(s))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});hi=X.define({combine(s){return{sources:s.map(t=>t.source).filter(t=>t!=null),...Kt(s.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:HA,tooltipFilter:HA,needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e,hideOn:(t,e)=>t?e?(i,r,n)=>t(i,r,n)||e(i,r,n):t:e,autoPanel:(t,e)=>t||e})}}});Tb=class extends qt{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return $t("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},Uu=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=KA(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},ql=class s{constructor(t){this.view=t,this.items=[];let e=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)Qb(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],o=GA(n.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==r.keyCode){let l=ts(this.view.state.field(Ut).diagnostics,n);l&&n.actions[a].apply(t,l.from,l.to)}}else return;r.preventDefault()}},i=r=>{for(let n=0;n<this.items.length;n++)this.items[n].dom.contains(r.target)&&this.moveSelection(n)};this.list=$t("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:i}),this.dom=$t("div",{class:"cm-panel-lint"},this.list,$t("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Qb(this.view)},"\xD7")),this.update()}get selectedIndex(){let t=this.view.state.field(Ut).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(Ut),i=0,r=!1,n=null,o=new Set;for(t.between(0,this.view.state.doc.length,(a,l,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let u=-1,d;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==c){u=f;break}u<0?(d=new Uu(this.view,c),this.items.splice(i,0,d),r=!0):(d=this.items[u],u>i&&(this.items.splice(i,u-i),r=!0)),e&&d.diagnostic==e.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),n=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Uu(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),n?(this.list.setAttribute("aria-activedescendant",n.id),this.view.requestMeasure({key:this,read:()=>({sel:n.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let h=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/h:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let t=this.list.firstChild;function e(){let i=t;t=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=this.view.state.field(Ut),i=ts(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:VA.of(i)})}static open(t){return new s(t)}};LI=I.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Yu("#d11")},".cm-lintRange-warning":{backgroundImage:Yu("orange")},".cm-lintRange-info":{backgroundImage:Yu("#999")},".cm-lintRange-hint":{backgroundImage:Yu("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});Hu=class extends te{constructor(t){super(),this.diagnostics=t,this.severity=JA(t)}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=t.state.facet(Gu).tooltipFilter;return r&&(i=r(i,t.state)),i.length&&(e.onmouseover=()=>II(t,e,i)),e}};qI=cl({class:"cm-gutter-lint",markers:s=>s.state.field(Lb),widgetMarker:(s,t,e)=>{let i=[];return s.state.field(Lb).between(e.from,e.to,(r,n,o)=>{r>e.from&&r<e.to&&i.push(...o.diagnostics)}),i.length?new Hu(i):null}}),Lb=mt.define({create(){return H.empty},update(s,t){s=s.map(t.changes);let e=t.state.facet(Gu).markerFilter;for(let i of t.effects)if(i.is(Dl)){let r=i.value;e&&(r=e(r||[],t.state)),s=DI(t.state.doc,r.slice(0))}return s}}),Mb=W.define(),t1=mt.define({create(){return null},update(s,t){return s&&t.docChanged&&(s=zA(t,s)?null:{...s,pos:t.changes.mapPos(s.pos)}),t.effects.reduce((e,i)=>i.is(Mb)?i.value:e,s)},provide:s=>Ts.from(s)}),XI=I.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Fu('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Fu('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Fu('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),e1=[Ut,I.decorations.compute([Ut],s=>{let{selected:t,panel:e}=s.field(Ut);return!t||!e||t.from==t.to?j.none:j.set([EI.range(t.from,t.to)])}),tm(CI,{hideOn:zA}),LI],Gu=X.define({combine(s){return Kt(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}})});var Ib={};Yt(Ib,{Compartment:()=>_i,EditorSelection:()=>P,EditorState:()=>nt,EditorView:()=>I,HighlightStyle:()=>Ci,LOAD_TIMEOUT_MS:()=>Rb,LanguageSupport:()=>vt,StateEffect:()=>W,adiaBaseTheme:()=>ZI,adiaHighlightStyle:()=>BI,defaultHighlightStyle:()=>Gc,defaultKeymap:()=>ju,drawSelection:()=>qc,highlightActiveLine:()=>Xc,highlightActiveLineGutter:()=>zc,history:()=>zu,historyKeymap:()=>_u,importWithTimeout:()=>_I,indentWithTab:()=>Vu,jsonLinter:()=>jI,keymap:()=>ni,languages:()=>zI,lineNumbers:()=>Bc,lintGutter:()=>Ku,linter:()=>Xl,placeholder:()=>Nc,syntaxHighlighting:()=>Hc});function _I(s,t){return Promise.race([s(),new Promise((e,i)=>setTimeout(()=>i(new Error(`code-editor: ${t} load timed out after ${Rb}ms`)),Rb))])}function VI(s,t){let e=t.length,i=s.match(/at position (\d+)/);if(i){let o=Math.min(e,Number(i[1]));return{from:o,to:Math.min(e,o+1)}}let r=s.match(/line (\d+) column (\d+)/);if(r){let o=Number(r[1]),a=Number(r[2]),l=0,h=1;for(let u=0;u<t.length&&h<o;u++)t[u]===`
41
- `&&(h++,l=u+1);let c=Math.min(e,l+Math.max(0,a-1));return{from:c,to:Math.min(e,c+1)}}let n=Math.max(0,e);return{from:Math.max(0,n-1),to:n}}var ZI,BI,zI,Rb,jI,Db=B(()=>{"use strict";ii();Si();BA();li();i1();ti();ZI=I.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{padding:"0",caretColor:"inherit"},".cm-focused":{outline:"none"}}),BI=Ci.define([{tag:[O.comment,O.lineComment,O.blockComment,O.docComment],class:"tok-comment"},{tag:[O.keyword,O.controlKeyword,O.modifier,O.operatorKeyword],class:"tok-keyword"},{tag:[O.string,O.character,O.regexp,O.escape,O.special(O.string)],class:"tok-string"},{tag:[O.number,O.integer,O.float],class:"tok-number"},{tag:[O.bool,O.null,O.atom],class:"tok-boolean"},{tag:[O.operator,O.logicOperator,O.arithmeticOperator,O.compareOperator,O.updateOperator,O.definitionOperator],class:"tok-operator"},{tag:[O.punctuation,O.bracket,O.paren,O.brace,O.squareBracket,O.angleBracket,O.separator],class:"tok-punctuation"},{tag:[O.function(O.variableName),O.function(O.propertyName),O.macroName],class:"tok-function"},{tag:[O.variableName,O.local(O.variableName),O.self],class:"tok-variable"},{tag:[O.typeName,O.className,O.namespace],class:"tok-type"},{tag:[O.propertyName,O.labelName,O.definition(O.variableName)],class:"tok-property"},{tag:[O.tagName,O.heading,O.contentSeparator],class:"tok-tag"},{tag:[O.attributeName,O.attributeValue],class:"tok-attribute"},{tag:[O.url,O.link],class:"tok-url"},{tag:[O.invalid,O.deleted],class:"tok-invalid"}]),zI={json:()=>Promise.resolve().then(()=>(qx(),Dx)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(gg(),mw)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(hg(),sw)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Rm(),fS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(lk(),ak)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(wk(),Sk)).then(s=>({extension:s.yaml()}))},Rb=1e4;jI=Xl(s=>{let t=s.state.doc.toString();if(t.trim()==="")return[];try{return JSON.parse(t),[]}catch(e){let i=e instanceof Error?e.message:String(e),{from:r,to:n}=VI(i,t);return[{from:r,to:n,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function id(s){return Xt.get(s)||null}function v1(s,t){Xt.set(s,t)}var Xt,Wb=B(()=>{"use strict";Xt=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"],["ProgressRow","progress-row-ui"],["DateRangePicker","date-range-picker-ui"],["DatetimePicker","datetime-picker-ui"],["CalendarGrid","calendar-grid-ui"],["CalendarPicker","calendar-picker-ui"],["Combobox","combobox-ui"],["Skeleton","skeleton-ui"],["Stepper","stepper-ui"],["StepperItem","stepper-item-ui"],["Tour","tour-ui"],["TourStep","tour-step-ui"],["IntegrationCard","integration-card-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"],["ColDef","col-def"],["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 x1(s,t){if(!t||t==="/")return s;let e=t.replace(/^\//,"").split("/"),i=s;for(let r of e){if(i==null)return;i=i[r]}return i}function xD(s,t,e){if(!t||t==="/")return;let i=t.replace(/^\//,"").split("/"),r=s;for(let n=0;n<i.length-1;n++){let o=i[n];r[o]==null&&(r[o]={}),r=r[o]}r[i[i.length-1]]=e}var sd,Jo,Ub=B(()=>{"use strict";sd={provider:0,controller:1,source:2,action:3,lifecycle:4},Jo=class{surfaceId;#t=new Map;#e={};#i={};#s=new Map;#r;#n;constructor(t,e,i){this.surfaceId=t,this.#r=e,this.#n=i}get context(){return{surfaceId:this.surfaceId,getElement:t=>this.#n.get(t)||null,getRootElement:()=>this.#r,getModel:t=>t?x1(this.#e,t):this.#e,setModel:(t,e)=>this.#a(t,e),getDockable:(t,e)=>this.#l(t,e),listDockables:t=>this.#c(t),emit:t=>this.#h(t),getParam:t=>this.#i[t],watchModel:(t,e)=>this.#o(t,e)}}dock(t){this.#t.has(t.id)&&this.undock(t.id);let e=t.dock(this.context);this.#t.set(t.id,{dockable:t,cleanup:typeof e=="function"?e:null})}dockAll(t){let e=[...t].sort((i,r)=>(sd[i.kind]??9)-(sd[r.kind]??9));for(let i of e)this.dock(i)}undock(t){let e=this.#t.get(t);e&&(e.cleanup?.(),e.dockable.undock(),this.#t.delete(t))}undockAll(){let t=[...this.#t.entries()].sort((e,i)=>(sd[i[1].dockable.kind]??9)-(sd[e[1].dockable.kind]??9));for(let[e]of t)this.undock(e)}undockMany(t){for(let e of t)this.undock(e)}setInitialModel(t){Object.assign(this.#e,t)}setParams(t){Object.assign(this.#i,t)}updateElements(t){this.#n=t}#a(t,e){xD(this.#e,t,e);for(let[i,r]of this.#s)if(t===i||t.startsWith(i+"/"))for(let n of r)n(x1(this.#e,i))}#o(t,e){return this.#s.has(t)||this.#s.set(t,new Set),this.#s.get(t).add(e),()=>{let i=this.#s.get(t);i?.delete(e),i?.size===0&&this.#s.delete(t)}}#l(t,e){let i=this.#t.get(e);return i&&i.dockable.kind===t?i.dockable:null}#c(t){let e=[];for(let{dockable:i}of this.#t.values())(!t||i.kind===t)&&e.push(i);return e}#h(t){let e=t.target?this.#n.get(t.target):this.#r;e&&e.dispatchEvent(new CustomEvent(t.event,{bubbles:!0,detail:t}))}}});var be,Ys=B(()=>{"use strict";be=class{get kind(){throw new Error("Dockable subclass must define kind")}get id(){throw new Error("Dockable subclass must define id")}dock(t){throw new Error("Dockable subclass must implement dock()")}undock(){}}});var ta,Fb=B(()=>{"use strict";Ys();ta=class extends be{kind="controller";id;type;hostId;config;bind;controller=null;#t;constructor(t,e){super(),this.id=t.id,this.type=t.type,this.hostId=t.host,this.config=t.config||{},this.bind=t.bind||null,this.#t=e}async dock(t){let e=t.getElement(this.hostId);if(!e){console.warn(`ControllerDock: host element "${this.hostId}" not found`);return}let i=await this.#t(this.type);if(!i){console.warn(`ControllerDock: unknown controller type "${this.type}"`);return}this.controller=new i(this.config),this.controller.connect(e);let r=[];if(this.bind)for(let[n,o]of Object.entries(this.bind)){if(this.controller.subscribe){let l=this.controller.subscribe(n,h=>{t.setModel(o,h)});l&&r.push(l)}let a=t.getModel(o);a!==void 0&&this.controller.setState&&this.controller.setState(n,a)}return e.controller=this.controller,()=>{e.controller=null,r.forEach(n=>n())}}undock(){this.controller&&(this.controller.disconnect?.(),this.controller=null)}}});var ea,Yb=B(()=>{"use strict";Ys();ea=class extends be{kind="source";id;uri;path;refresh;#t;#e=null;constructor(t,e){super(),this.id=t.id,this.uri=t.uri,this.path=t.path,this.refresh=t.refresh||"once",this.#t=e}dock(t){if(this.#e=t,this.#i(t),this.refresh==="on-focus"){let e=()=>this.#i(t);return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)}if(this.refresh.startsWith("interval:")){let e=parseInt(this.refresh.split(":")[1],10);if(e>0){let i=setInterval(()=>this.#i(t),e);return()=>clearInterval(i)}}if(this.refresh==="stream"){let e=this.#s(t);try{let i=new EventSource(e);return i.onmessage=r=>{try{t.setModel(this.path,JSON.parse(r.data))}catch{}},()=>i.close()}catch{console.warn(`DataSourceDock: stream failed for ${e}`)}}}undock(){this.#e=null}refetch(){this.#e&&this.#i(this.#e)}async#i(t){let e=this.#s(t);try{let i=await this.#t(e,t);i!==void 0&&t.setModel(this.path,i)}catch(i){console.warn(`DataSourceDock: fetch failed for ${e}`,i)}}#s(t){return this.uri.replace(/\{(\w+)\}/g,(e,i)=>t.getParam(i)??t.getModel("/"+i)??"")}}});var rd,ia,Hb=B(()=>{"use strict";Ys();rd={press:"click",submit:"submit",input:"input",change:"change",select:"select",toggle:"change",dismiss:"close",navigate:"click",mount:"connectedCallback",unmount:"disconnectedCallback",focus:"focusin",blur:"focusout",drag:"dragstart",drop:"drop"},ia=class extends be{kind="action";id;event;handler;config;onSuccess;onError;#t;constructor(t,e){super(),this.event=t.event,this.handler=t.handler,this.config=t.config||{},this.onSuccess=t.onSuccess||null,this.onError=t.onError||null,this.#t=e,this.id=`action:${this.event.event}:${this.event.target||"root"}:${this.handler}`}dock(t){let e=this.event.target?t.getElement(this.event.target):t.getRootElement();if(!e){console.warn(`ActionDock: target "${this.event.target}" not found`);return}let i=rd[this.event.event]||this.event.event,r=this.#t(this.handler);if(!r){console.warn(`ActionDock: unknown handler "${this.handler}"`);return}let n=async o=>{if(this.event.condition){let a=t.getModel(this.event.condition.path);if("equals"in this.event.condition&&a!==this.event.condition.equals||"notEquals"in this.event.condition&&a===this.event.condition.notEquals||"exists"in this.event.condition&&this.event.condition.exists&&a==null)return}try{let a=await r(this.config,t,o);if(this.onSuccess)for(let l of this.onSuccess){let h=this.#t(l.handler);h&&await h(l.config||{},t,a)}}catch(a){if(this.onError)for(let l of this.onError){let h=this.#t(l.handler);h&&await h(l.config||{},t,a)}else console.error(`ActionDock: handler "${this.handler}" failed`,a)}};if(this.event.debounce>0){let o=n,a;n=(...l)=>{clearTimeout(a),a=setTimeout(()=>o(...l),this.event.debounce)}}if(this.event.throttle>0){let o=n,a=0;n=(...l)=>{let h=Date.now();h-a>=this.event.throttle&&(a=h,o(...l))}}return e.addEventListener(i,n),()=>e.removeEventListener(i,n)}undock(){}}});var sa,Gb=B(()=>{"use strict";Ys();sa=class extends be{kind="provider";id;hostId;value;constructor(t){super(),this.id=`provider:${t.name}`,this.hostId=t.host||null,this.value=t.value??null}dock(t){let e=this.hostId?t.getElement(this.hostId):t.getRootElement();if(!e){console.warn(`ProviderDock: host "${this.hostId}" not found`);return}let i=document.createElement("a2ui-provider");return i.setAttribute("name",this.id.replace("provider:","")),i.value=this.value,e.parentNode?.insertBefore(i,e),i.appendChild(e),()=>{i.parentNode&&(i.parentNode.insertBefore(e,i),i.remove())}}undock(){}}});var ra,Kb=B(()=>{"use strict";Ys();ra=class extends be{kind="lifecycle";id="lifecycle";onMount;onUnmount;onModelChange;#t;#e=null;constructor(t,e){super(),this.onMount=t.onMount||[],this.onUnmount=t.onUnmount||[],this.onModelChange=t.onModelChange||[],this.#t=e}dock(t){this.#e=t;for(let i of this.onMount)this.#i(i,t);let e=this.onModelChange.map(i=>{let r=()=>this.#i(i,t);if(i.debounce>0){let n=r,o;r=()=>{clearTimeout(o),o=setTimeout(n,i.debounce)}}return t.watchModel(i.path,r)});return()=>e.forEach(i=>i())}undock(){if(this.#e){for(let t of this.onUnmount)this.#i(t,this.#e);this.#e=null}}async#i(t,e){let i=this.#t(t.handler);if(i)try{await i(t.config||{},e)}catch(r){console.warn(`LifecycleDock: ${t.handler} failed`,r)}}}});var S1,Oe,Hs=B(()=>{"use strict";S1=new WeakSet,Oe=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!S1.has(e)&&e!==s&&(S1.add(e),e.schema||console.warn(`AdiaUI: ${e.name} extends BaseController without static schema`),this.getState===s.prototype.getState&&console.error(`AdiaUI: ${e.schema?.name??e.name} must implement getState()`)),this.#t&&this.#t!==t&&console.warn(`AdiaUI: ${e.schema?.name??e.name} already connected to a different host`),this.#t=t,this.onConnect(t),this.reflect()}disconnect(t){let e=t??this.#t;e&&(this.onDisconnect(e),this.#t=null)}subscribe(t){return this.#e.add(t),()=>this.#e.delete(t)}notify(){this.reflect();for(let t of this.#e)t()}onConnect(t){}onDisconnect(t){}reflect(){}getState(){throw new Error(`${this.constructor.schema?.name??this.constructor.name}: getState() not implemented`)}}});var w1={};Yt(w1,{FormController:()=>Jb});var Jb,k1=B(()=>{"use strict";Hs();Jb=class extends Oe{static schema=Object.freeze({name:"form",state:{values:"object",errors:"object",dirty:"boolean",valid:"boolean"},commands:["set","validate","reset","setInitial"],attributes:["data-form-valid","data-form-invalid","data-form-dirty"]});#t={};#e={};#i={};#s={};constructor(t={}){super(),this.#t={...t},this.#e={...t}}onDisconnect(t){t.removeAttribute("data-form-valid"),t.removeAttribute("data-form-invalid"),t.removeAttribute("data-form-dirty")}getState(){let t=Object.keys(this.#e).some(i=>this.#e[i]!==this.#t[i]),e=Object.keys(this.#i).length===0;return{values:{...this.#e},errors:{...this.#i},dirty:t,valid:e}}reflect(){if(!this.host)return;let{dirty:t,valid:e}=this.getState();e?(this.host.setAttribute("data-form-valid",""),this.host.removeAttribute("data-form-invalid")):(this.host.setAttribute("data-form-invalid",""),this.host.removeAttribute("data-form-valid")),t?this.host.setAttribute("data-form-dirty",""):this.host.removeAttribute("data-form-dirty")}#r(t){let e=this.#s[t];if(!e){delete this.#i[t];return}let i=e(this.#e[t]);i===!0||i==null?delete this.#i[t]:this.#i[t]=typeof i=="string"?i:"Invalid"}commands={set:(t,e)=>{this.#e[t]=e,this.#r(t),this.notify()},validate:(t,e)=>{this.#s[t]=e,this.#r(t),this.notify()},reset:()=>{this.#e={...this.#t},this.#i={};for(let t of Object.keys(this.#s))this.#r(t);this.notify()},setInitial:t=>{this.#t={...t}}}}});var A1={};Yt(A1,{DataStreamController:()=>tO});var tO,E1=B(()=>{"use strict";Hs();tO=class extends Oe{static schema=Object.freeze({name:"data-stream",state:{data:"array",status:"string",error:"string"},commands:["push","pushMany","connect","poll","consume","stop","clear"],attributes:["data-stream-status"]});#t=[];#e;#i="idle";#s=null;#r=null;#n=0;#a=1;#o=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:r=[]}={}){super(),this.#e=t,this.#n=e,this.#a=Math.max(1,Math.round(i)),this.#t=r.slice(-t)}getState(){return{data:this.#t,status:this.#i,error:this.#s}}reflect(){this.host&&this.host.setAttribute("data-stream-status",this.#i)}onDisconnect(){this.commands.stop()}#c(t){this.#l++,!(this.#a>1&&this.#l%this.#a!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u())}#h(t){if(this.#a>1){let e=[];for(let i of t)this.#l++,this.#l%this.#a===0&&e.push(i);this.#t.push(...e)}else this.#t.push(...t);this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u()}#u(){if(this.#n<=0){this.notify();return}this.#o===null&&(this.#o=setTimeout(()=>{this.#o=null,this.notify()},this.#n))}#d(t,e=null){this.#i=t,this.#s=e,this.notify()}commands={push:t=>{this.#c(t)},pushMany:t=>{this.#h(t)},connect:(t,e)=>{this.commands.stop(),this.#r=new AbortController,t==="sse"?this.#f(e):t==="ws"?this.#p(e):this.#d("error",`Unknown stream type: ${t}`)},poll:(t,e=2e3)=>{this.commands.stop(),this.#r=new AbortController,this.#m(t,e)},consume:t=>{this.commands.stop(),this.#r=new AbortController,this.#g(t)},stop:()=>{this.#r&&(this.#r.abort(),this.#r=null),this.#o!==null&&(clearTimeout(this.#o),this.#o=null),(this.#i==="streaming"||this.#i==="connecting")&&this.#d("stopped")},clear:()=>{this.#t=[],this.notify()}};#f(t){this.#d("connecting");let e=new EventSource(t),i=this.#r.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=r=>{try{let n=JSON.parse(r.data);this.#c(n)}catch{}},e.onerror=()=>{i.aborted||(this.#d("error","SSE connection lost"),e.close())}}#p(t){this.#d("connecting");let e=new WebSocket(t),i=this.#r.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=r=>{try{let n=JSON.parse(r.data);Array.isArray(n)?this.#h(n):this.#c(n)}catch{}},e.onerror=()=>{i.aborted||this.#d("error","WebSocket error")},e.onclose=()=>{i.aborted||this.#d("stopped")}}async#m(t,e){this.#d("streaming");let i=this.#r.signal;for(;!i.aborted;){try{let n=await(await fetch(t,{signal:i})).json();Array.isArray(n)?this.#h(n):this.#c(n)}catch(r){if(i.aborted)break;this.#d("error",r.message);break}await new Promise(r=>setTimeout(r,e))}}async#g(t){this.#d("streaming");let e=this.#r.signal;try{for await(let i of t){if(e.aborted)break;Array.isArray(i)?this.#h(i):this.#c(i)}e.aborted||this.#d("idle")}catch(i){e.aborted||this.#d("error",i.message)}}}});var C1={};Yt(C1,{SelectionController:()=>eO});var eO,$1=B(()=>{"use strict";Hs();eO=class extends Oe{static schema=Object.freeze({name:"selection",state:{selected:"Set",multiple:"boolean"},commands:["select","deselect","toggle","clear","selectAll"],attributes:["data-selection-active","data-selection-selected"]});#t=new Set;#e=!1;constructor({multiple:t=!1,initial:e=[]}={}){super(),this.#e=t;for(let i of e)this.#t.add(String(i))}onConnect(t){t.setAttribute("data-selection-active","")}onDisconnect(t){this.#i(t),t.removeAttribute("data-selection-active")}getState(){return{selected:new Set(this.#t),multiple:this.#e}}reflect(){if(!this.host)return;let t=this.host.querySelectorAll("[data-selection-key]");for(let e of t){let i=e.getAttribute("data-selection-key");this.#t.has(i)?e.setAttribute("data-selection-selected",""):e.removeAttribute("data-selection-selected")}}#i(t){let e=t.querySelectorAll("[data-selection-selected]");for(let i of e)i.removeAttribute("data-selection-selected")}commands={select:t=>{t=String(t),this.#e||this.#t.clear(),this.#t.add(t),this.notify()},deselect:t=>{this.#t.delete(String(t)),this.notify()},toggle:t=>{t=String(t),this.#t.has(t)?this.#t.delete(t):(this.#e||this.#t.clear(),this.#t.add(t)),this.notify()},clear:()=>{this.#t.clear(),this.notify()},selectAll:t=>{if(this.#e){for(let e of t)this.#t.add(String(e));this.notify()}}}}});var P1={};Yt(P1,{ToggleController:()=>iO});var iO,Q1=B(()=>{"use strict";Hs();iO=class extends Oe{static schema=Object.freeze({name:"toggle",state:{on:"boolean"},commands:["toggle","set"],attributes:["data-toggle-on"]});#t=!1;constructor(t=!1){super(),this.#t=t}getState(){return{on:this.#t}}onDisconnect(t){t.removeAttribute("data-toggle-on")}reflect(){this.host&&(this.#t?this.host.setAttribute("data-toggle-on",""):this.host.removeAttribute("data-toggle-on"))}commands={toggle:()=>{this.#t=!this.#t,this.notify()},set:t=>{this.#t=!!t,this.notify()}}}});var T1={};Yt(T1,{AccordionController:()=>sO});var sO,L1=B(()=>{"use strict";Hs();sO=class extends Oe{static schema=Object.freeze({name:"accordion",state:{expanded:"Set",multiple:"boolean"},commands:["toggle","expand","collapse","collapseAll","expandAll"],attributes:["data-accordion-expanded"]});#t=new Set;#e=!1;constructor({multiple:t=!1,initial:e=[]}={}){super(),this.#e=t;for(let i of e)this.#t.add(String(i))}onDisconnect(t){let e=t.querySelectorAll("[data-accordion-expanded]");for(let i of e)i.removeAttribute("data-accordion-expanded")}getState(){return{expanded:new Set(this.#t),multiple:this.#e}}reflect(){if(!this.host)return;let t=this.host.querySelectorAll("[data-accordion-key]");for(let e of t){let i=e.getAttribute("data-accordion-key");this.#t.has(i)?e.setAttribute("data-accordion-expanded",""):e.removeAttribute("data-accordion-expanded")}}commands={toggle:t=>{t=String(t),this.#t.has(t)?this.#t.delete(t):(this.#e||this.#t.clear(),this.#t.add(t)),this.notify()},expand:t=>{t=String(t),this.#e||this.#t.clear(),this.#t.add(t),this.notify()},collapse:t=>{this.#t.delete(String(t)),this.notify()},collapseAll:()=>{this.#t.clear(),this.notify()},expandAll:t=>{if(this.#e){for(let e of t)this.#t.add(String(e));this.notify()}}}}});var M1={};Yt(M1,{StateMachineController:()=>rO});var rO,R1=B(()=>{"use strict";Hs();rO=class extends Oe{static schema={name:"state-machine",state:{current:"string",history:"string[]"},commands:["send","transition","reset"],attributes:["data-state"],config:{initial:"string",states:"object"}};#t="";#e="";#i={};#s=[];onConnect(t){let e=this.config||{};this.#e=e.initial||t.dataset?.initial||Object.keys(e.states||{})[0]||"",this.#i=this._validateStates(e.states||{}),this.#t=this.#e,this.#s=this.#t?[this.#t]:[],this.#t&&this._emit("stateEntered",{state:this.#t,initial:!0})}getState(){return{current:this.#t,history:[...this.#s]}}reflect(){this.host&&(this.#t?this.host.setAttribute("data-state",this.#t):this.host.removeAttribute("data-state"))}commands={send:t=>{if(!t||!this.#t)return;let i=(this.#i[this.#t]?.on||{})[t];i&&this._moveTo(i,{event:t})},transition:t=>{!t||!(t in this.#i)||this._moveTo(t,{forced:!0})},reset:()=>{this.#e&&this._moveTo(this.#e,{reset:!0})}};_moveTo(t,e){if(t===this.#t)return;let i=this.#t;i&&this._emit("stateExited",{state:i,target:t,...e}),this.#t=t,this.#s.push(t),this.notify(),this._emit("stateEntered",{state:t,from:i,...e})}_emit(t,e){this.host&&this.host.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}_validateStates(t){let e={},i=Object.keys(t);for(let r of i){let n=t[r]||{},o={};for(let[a,l]of Object.entries(n.on||{})){if(typeof l!="string"||!(l in t)){console.warn(`[state-machine] state "${r}" transition "${a}" \u2192 "${l}" \u2014 target not declared`);continue}o[a]=l}e[r]={on:o}}return e}}});function I1(s,t){Di.controllers.set(s,t)}function D1(s,t){Di.handlers.set(s,t)}function q1(s,t){Di.resolvers.set(s,t)}async function nd(s){let t=Di.controllers.get(s);return t?t():null}function od(s){return Di.handlers.get(s)||null}async function Bl(s,t={}){let e=s;for(let[o,a]of Object.entries(t))e=e.replace(`{${o}}`,encodeURIComponent(a));let i=e.indexOf("://");if(i===-1)throw new Error(`Invalid URI: ${s}`);let r=e.slice(0,i),n=Di.resolvers.get(r);if(!n)throw new Error(`No resolver for scheme "${r}"`);return n(e,t)}async function SD(s){let{action:t,params:e}=s,i=nO(t.body,s),r=t.uri;for(let[c,u]of Object.entries(e))r=r.replace(`{${c}}`,encodeURIComponent(u));let n=r.indexOf("://"),o=n>-1?r.slice(0,n):"api",a=Di.resolvers.get(o),l=r.replace(/^\w+:\/\//,"/api/"),h=await fetch(l,{method:t.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!h.ok){let c=await h.text().catch(()=>"Request failed");throw new Error(c)}return h.json().catch(()=>({}))}async function wD(s){let{action:t}=s,e=nO(t.value,s);s.updateModel(t.path,e)}async function kD(s){let{action:t,params:e}=s,i=t.navigate||t.path||"";for(let[r,n]of Object.entries(e))i=i.replace(`{${r}}`,encodeURIComponent(n));i==="back"?history.back():i&&(location.hash=i)}async function AD(){history.back()}async function ED(s){let{action:t,controllers:e}=s,i=e[t.controllerId];if(!i?.commands?.[t.command]){console.warn(`Wiring: controller "${t.controllerId}" or command "${t.command}" not found`);return}return i.commands[t.command](t.args)}async function CD(s){let{action:t,source:e}=s,i=nO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function $D(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function PD(s){let{action:t}=s,e=typeof t=="string"?t:t.message||t.notify;document.dispatchEvent(new CustomEvent("a2ui-notify",{bubbles:!0,detail:{message:e,variant:t.variant||"info"}}))}function nO(s,t){if(s){if(typeof s!="object")return s;switch(s.from){case"event-detail":return s.key?t.event?.detail?.[s.key]:t.event?.detail;case"event-target":return s.key?t.source?.[s.key]:t.source?.value;case"model":return QD(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}function QD(s,t){if(!t||!s)return;let e=t.split("/").filter(Boolean),i=s;for(let r of e){if(i==null||typeof i!="object")return;i=i[r]}return i}async function TD(s,t){let e=s.replace(/^resource:\/\//,"/api/"),i=await fetch(e);if(!i.ok)throw new Error(`Resource fetch failed: ${i.status}`);return i.json()}async function LD(s,t){let e=s.replace(/^api:\/\//,"https://"),i=await fetch(e);if(!i.ok)throw new Error(`API fetch failed: ${i.status}`);return i.json()}async function MD(s,t){return{_source:s,_mock:!0}}var Di,oO=B(()=>{"use strict";Di={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(k1(),w1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(E1(),A1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>($1(),C1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(Q1(),P1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(L1(),T1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(R1(),M1))).StateMachineController]]),handlers:new Map([["submit-resource",SD],["update-model",wD],["navigate",kD],["navigate-back",AD],["controller-command",ED],["emit-event",CD],["refresh-source",$D],["notify",PD]]),resolvers:new Map([["resource",TD],["api",LD],["mock",MD]])}});function RD(s){return async(t,e,i)=>{let r={action:t,event:i instanceof Event?i:null,source:i instanceof Event?i.target:null,dataModel:e.getModel(),updateModel:(n,o)=>e.setModel(n,o),controllers:Object.fromEntries(e.listDockables("controller").map(n=>[n.id,n.controller])),params:{},resolveData:Bl};return s(r)}}function ID(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=od(t);if(!e)return null;let i=RD(e);return s.set(t,i),i}}function DD(){return async s=>nd(s)}function qD(){return async(s,t)=>Bl(s,{})}function ad(s){let t=[],e=ID(),i=DD(),r=qD();if(s.data?.sources)for(let o of s.data.sources)t.push(new ea(o,r));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new ta(o,i));if(s.actions)for(let o of s.actions)t.push(new ia(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new sa(a))}s.lifecycle&&t.push(new ra(s.lifecycle,e));let n=s.state?.model||null;return{dockables:t,initialModel:n}}var aO=B(()=>{"use strict";Fb();Yb();Hb();Gb();Kb();oO()});var X1={};Yt(X1,{WiringEngine:()=>zl});var zl,lO=B(()=>{"use strict";Ub();aO();zl=class{#t=new Map;#e;#i;constructor({updateDataModel:t,getElement:e}){this.#e=t,this.#i=e}async process(t){let{surfaceId:e}=t;if(!e)return;let i=this.#t.get(e);i||(i=this.#s(e),this.#t.set(e,i));try{t.data?.params&&i.setParams(this.#r(t.data.params));let{dockables:r,initialModel:n}=ad(t);n&&i.setInitialModel(n),t.undock&&i.undockMany(t.undock);for(let o of r)await i.dock(o)}catch(r){console.warn(`Wiring: error processing wireComponents for "${e}":`,r.message)}}teardown(t){let e=this.#t.get(t);e&&(e.undockAll(),this.#t.delete(t))}teardownAll(){for(let t of this.#t.keys())this.teardown(t)}getSurface(t){return this.#t.get(t)||null}getSurfaceState(t){let e=this.#t.get(t);if(!e)return null;let i=e.context.listDockables();return{surfaceId:t,controllerCount:i.filter(r=>r.kind==="controller").length,sourceCount:i.filter(r=>r.kind==="source").length,actionCount:i.filter(r=>r.kind==="action").length,providerCount:i.filter(r=>r.kind==="provider").length,hasLifecycle:i.some(r=>r.kind==="lifecycle"),totalDocked:i.length}}#s(t){let e={get:h=>this.#i(t,h),has:h=>!!this.#i(t,h)},i=this.#i(t,"root")||document.createElement("div"),r=new Proxy(new Map,{get(h,c){return c==="get"?u=>e.get(u):c==="has"?u=>e.has(u):h[c]}}),n=new Jo(t,i,r),o=n.context,a=o.setModel,l=this.#e;return Object.defineProperty(n,"context",{get(){return{...o,setModel(c,u){a(c,u),l(t,c,u)}}}}),n}#r(t){let e={};for(let[i,r]of Object.entries(t))switch(r.from){case"route":{let o=location.hash.slice(1).match(new RegExp(`${r.key}/([^/]+)`));o&&(e[i]=o[1]);break}case"query":{let o=new URL(location.href).searchParams.get(r.key);o&&(e[i]=o);break}case"literal":e[i]=r.value;break;default:typeof r=="string"&&(e[i]=r)}return e}}});var is,N1=B(()=>{"use strict";Wb();is=class s{#t;#e;#i=new Map;#s=new Map;#r=new Map;#n=[];#a=null;#o=!1;constructor(t,e=Xt,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#o=i}process(t){t&&(this.#o?(this.#n.push(t),this.#a===null&&(this.#a=requestAnimationFrame(()=>this.#l()))):this.#c(t))}#l(){this.#a=null;let t=this.#n.splice(0);for(let e of t)this.#c(e)}#c(t){switch(t.type||t.messageType){case"createSurface":this.#d(t);break;case"updateComponents":this.#f(t);break;case"updateDataModel":this.#T(t);break;case"wireComponents":this.#u(t);break;case"deleteSurface":this.#Q(t);break;case"updateStyles":this.#I(t);break;case"removeStyles":this.#$(t);break;case"meta":break;default:console.warn("A2UI: unknown message type",t.type)}}#h=null;async#u(t){if(!this.#h){let{WiringEngine:e}=await Promise.resolve().then(()=>(lO(),X1));this.#h=new e({updateDataModel:(i,r,n)=>{this.#T({surfaceId:i,path:r,value:n})},getElement:(i,r)=>this.#i.get(i)?.elements.get(r)||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 r=document.createElement("div");r.setAttribute("data-a2ui-surface",t),e&&r.setAttribute("data-catalog",e),this.#t.appendChild(r),this.#i.set(t,{root:r,rootId:typeof i=="string"&&i?i:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets: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,adoptedSheets:new Map},this.#i.set(t,i),this.#t&&typeof this.#t.setAttribute=="function"&&this.#t.setAttribute("data-a2ui-surface",t));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.#x(l.variant,l):id(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.#k(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#O(e);let r=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])r.set(h,l.id);l.child&&r.set(l.child,l.id)}let n=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=r.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||n(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!n(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#m=new Set(["Header","Section","Footer"]);static#g=new Set(["header","body","footer"]);#b=new Set;#O(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let r=i.component==="Card"||i.component==="ErrorContainer",n=i.component==="Drawer";if(!r&&!n)continue;let o=n?s.#m:s.#p,a=n?"<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.#g.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#b.has(u)||(this.#b.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(", ")}`+(n?', or slot="header|body|footer".':".")))}}}static#y=new Set(["data","columns","options","itemRenderer","textContent"]);static#w=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#S=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"]);#x(t,e){return!e?.slot&&s.#v[t]?s.#v[t]:"text-ui"}#k(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 r=this.#r.get(e.id),n={};for(let[o,a]of Object.entries(e)){if(i.has(o))continue;let l=a&&typeof a=="object"&&a.path,h=this.#C(a,e._surfaceId);if(n[o]=h,!(r&&Object.is(r[o],h))){if(o==="style"&&typeof h=="string"){t.style.cssText=h;continue}if(s.#y.has(o)&&h!=null){if(o==="textContent"&&!s.#w.has(t.localName)){t.setAttribute("text",String(h));continue}let c=h;if(typeof c=="string"&&(c.startsWith("[")||c.startsWith("{")))try{c=JSON.parse(c)}catch{}t[o]=c;continue}typeof h=="boolean"?h?t.setAttribute(o,""):t.removeAttribute(o):h!=null?t.setAttribute(this.#A(o),String(h)):l&&t.removeAttribute(this.#A(o))}}if(r)for(let o of Object.keys(r))!(o in n)&&!i.has(o)&&t.removeAttribute(this.#A(o));this.#r.set(e.id,n)}#A(t){return s.#S.has(t.toLowerCase())?t.toLowerCase():t.replace(/([A-Z])/g,"-$1").toLowerCase()}#C(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.#E(i.dataModel,t.path):t.path}return t}#E(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,r)=>i?.[r],t)}#T({surfaceId:t,path:e,value:i}){let r=this.#i.get(t);if(r){if(!e||e==="/")r.dataModel=i??{};else{let n=e.split("/").filter(Boolean),o=r.dataModel;for(let a=0;a<n.length-1;a++)o[n[a]]==null&&(o[n[a]]={}),o=o[n[a]];o[n[n.length-1]]=i}for(let[n,o]of r.bindings){let a=r.elements.get(n);a&&this.#k(a,o)}}}#Q({surfaceId:t}){let e=this.#i.get(t);if(e){this.#h?.teardown(t);for(let[i]of e.elements)this.#s.delete(i);if(e.adoptedSheets&&e.adoptedSheets.size>0){let i=new Set;for(let r of e.adoptedSheets.values())i.add(r.sheet);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(r=>!i.has(r)),e.adoptedSheets.clear()}e.root.remove(),this.#i.delete(t)}}static#P=new Set(["root","html","body"]);#I({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#R(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#R(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: css must be a string"});return}let r=this.#i.get(t);if(!r){this.#R(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let n=this.#M(i,t);if(n.rejected){this.#R(r.root,"styles-rejected",{surfaceId:t,styleId:e,reason:n.reason});return}let o=r.adoptedSheets.get(e);o&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet)),document.adoptedStyleSheets=[...document.adoptedStyleSheets,n.sheet],r.adoptedSheets.set(e,{sheet:n.sheet,ruleCount:n.sheet.cssRules.length,appliedAt:typeof performance<"u"?performance.now():Date.now()}),this.#R(r.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:n.sheet.cssRules.length,validationWarnings:n.warnings})}#$({surfaceId:t,styleId:e}){let i=this.#i.get(t);if(!i)return;let r=i.adoptedSheets.get(e);r&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(n=>n!==r.sheet),i.adoptedSheets.delete(e),this.#R(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#M(t,e){let i=[];if(/^\s*@import\b/im.test(t))return{rejected:!0,reason:"forbidden-import"};if(/^\s*@charset\b/im.test(t))return{rejected:!0,reason:"forbidden-charset"};let r=new CSSStyleSheet;try{r.replaceSync(t)}catch(l){return{rejected:!0,reason:"parse-error: "+(l?.message||String(l))}}for(let l of r.cssRules){let h=this.#L(l);if(h)return{rejected:!0,reason:h}}if(/url\s*\(\s*["']?\s*(?:https?:|\/\/)/i.test(t))return{rejected:!0,reason:"external-url"};for(let l of r.cssRules)if(l.constructor?.name==="CSSPropertyRule"||l.cssText?.startsWith("@property")){let h=l.cssText.match(/@property\s+(--[\w-]+)/);h&&i.push({kind:"property-registered-globally",name:h[1]})}let n=this.#X(r,e),o=this.#q(r,e),a=new CSSStyleSheet;try{a.replaceSync(o)}catch(l){return{rejected:!0,reason:"scope-wrap-failed: "+(l?.message||String(l))}}return n.length>0&&i.push({kind:"animations-namespaced",count:n.length}),{rejected:!1,sheet:a,warnings:i}}#L(t){let e=t.cssText||"";if(/^@import\b/i.test(e))return"forbidden-import";if(/^@charset\b/i.test(e))return"forbidden-charset";if(/^@scope\b/i.test(e))return"forbidden-scope-directive";if(t.selectorText){let i=this.#D(t.selectorText);for(let r of i){let n=r.trim().replace(/^:scope\s*/,"");if(n.startsWith(":root"))return"forbidden-root-selector";let o=n.match(/^([a-zA-Z*][\w-]*)/);if(!o)continue;let a=o[1].toLowerCase();if(s.#P.has(a))return`forbidden-${a}-selector`}}return null}#D(t){let e=[],i=0,r=0;for(let n=0;n<t.length;n++){let o=t[n];o==="("?i++:o===")"?i--:o===","&&i===0&&(e.push(t.slice(r,n)),r=n+1)}return e.push(t.slice(r)),e}#X(t,e){let i=[],r=String(e).replace(/[^a-zA-Z0-9_-]/g,"_");for(let o=0;o<t.cssRules.length;o++){let a=t.cssRules[o];if(a.constructor?.name==="CSSKeyframesRule"||a.cssText?.startsWith("@keyframes")){let l=a.name;if(!l)continue;let h=`${r}_${l}`;try{a.name=h}catch{let c=a.cssText.replace(/@keyframes\s+[\w-]+/,`@keyframes ${h}`);t.deleteRule(o),t.insertRule(c,o)}i.push({from:l,to:h})}}if(i.length===0)return i;let n=new Map(i.map(o=>[o.from,o.to]));for(let o of t.cssRules)if(o.style)for(let a of["animation","animation-name"]){let l=o.style.getPropertyValue(a);if(!l)continue;let h=l.replace(/\b([\w-]+)\b/g,c=>n.has(c)?n.get(c):c);h!==l&&o.style.setProperty(a,h)}return i}#q(t,e){let i=[];for(let n of t.cssRules)i.push(n.cssText);return`@scope ([data-a2ui-surface="${String(e).replace(/"/g,'\\"')}"]) {
41
+ `&&(h++,l=u+1);let c=Math.min(e,l+Math.max(0,a-1));return{from:c,to:Math.min(e,c+1)}}let n=Math.max(0,e);return{from:Math.max(0,n-1),to:n}}var ZI,BI,zI,Rb,jI,Db=B(()=>{"use strict";ii();Si();BA();li();i1();ti();ZI=I.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{padding:"0",caretColor:"inherit"},".cm-focused":{outline:"none"}}),BI=Ci.define([{tag:[O.comment,O.lineComment,O.blockComment,O.docComment],class:"tok-comment"},{tag:[O.keyword,O.controlKeyword,O.modifier,O.operatorKeyword],class:"tok-keyword"},{tag:[O.string,O.character,O.regexp,O.escape,O.special(O.string)],class:"tok-string"},{tag:[O.number,O.integer,O.float],class:"tok-number"},{tag:[O.bool,O.null,O.atom],class:"tok-boolean"},{tag:[O.operator,O.logicOperator,O.arithmeticOperator,O.compareOperator,O.updateOperator,O.definitionOperator],class:"tok-operator"},{tag:[O.punctuation,O.bracket,O.paren,O.brace,O.squareBracket,O.angleBracket,O.separator],class:"tok-punctuation"},{tag:[O.function(O.variableName),O.function(O.propertyName),O.macroName],class:"tok-function"},{tag:[O.variableName,O.local(O.variableName),O.self],class:"tok-variable"},{tag:[O.typeName,O.className,O.namespace],class:"tok-type"},{tag:[O.propertyName,O.labelName,O.definition(O.variableName)],class:"tok-property"},{tag:[O.tagName,O.heading,O.contentSeparator],class:"tok-tag"},{tag:[O.attributeName,O.attributeValue],class:"tok-attribute"},{tag:[O.url,O.link],class:"tok-url"},{tag:[O.invalid,O.deleted],class:"tok-invalid"}]),zI={json:()=>Promise.resolve().then(()=>(qx(),Dx)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(gg(),mw)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(hg(),sw)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Rm(),fS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(lk(),ak)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(wk(),Sk)).then(s=>({extension:s.yaml()}))},Rb=1e4;jI=Xl(s=>{let t=s.state.doc.toString();if(t.trim()==="")return[];try{return JSON.parse(t),[]}catch(e){let i=e instanceof Error?e.message:String(e),{from:r,to:n}=VI(i,t);return[{from:r,to:n,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function id(s){return Xt.get(s)||null}function v1(s,t){Xt.set(s,t)}var Xt,Wb=B(()=>{"use strict";Xt=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"],["ProgressRow","progress-row-ui"],["DateRangePicker","date-range-picker-ui"],["DatetimePicker","datetime-picker-ui"],["CalendarGrid","calendar-grid-ui"],["CalendarPicker","calendar-picker-ui"],["Combobox","combobox-ui"],["Skeleton","skeleton-ui"],["Stepper","stepper-ui"],["StepperItem","stepper-item-ui"],["Tour","tour-ui"],["TourStep","tour-step-ui"],["IntegrationCard","integration-card-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"],["ColDef","col-def"],["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 x1(s,t){if(!t||t==="/")return s;let e=t.replace(/^\//,"").split("/"),i=s;for(let r of e){if(i==null)return;i=i[r]}return i}function xD(s,t,e){if(!t||t==="/")return;let i=t.replace(/^\//,"").split("/"),r=s;for(let n=0;n<i.length-1;n++){let o=i[n];r[o]==null&&(r[o]={}),r=r[o]}r[i[i.length-1]]=e}var sd,Jo,Ub=B(()=>{"use strict";sd={provider:0,controller:1,source:2,action:3,lifecycle:4},Jo=class{surfaceId;#t=new Map;#e={};#i={};#s=new Map;#r;#n;constructor(t,e,i){this.surfaceId=t,this.#r=e,this.#n=i}get context(){return{surfaceId:this.surfaceId,getElement:t=>this.#n.get(t)||null,getRootElement:()=>this.#r,getModel:t=>t?x1(this.#e,t):this.#e,setModel:(t,e)=>this.#a(t,e),getDockable:(t,e)=>this.#l(t,e),listDockables:t=>this.#c(t),emit:t=>this.#h(t),getParam:t=>this.#i[t],watchModel:(t,e)=>this.#o(t,e)}}dock(t){this.#t.has(t.id)&&this.undock(t.id);let e=t.dock(this.context);this.#t.set(t.id,{dockable:t,cleanup:typeof e=="function"?e:null})}dockAll(t){let e=[...t].sort((i,r)=>(sd[i.kind]??9)-(sd[r.kind]??9));for(let i of e)this.dock(i)}undock(t){let e=this.#t.get(t);e&&(e.cleanup?.(),e.dockable.undock(),this.#t.delete(t))}undockAll(){let t=[...this.#t.entries()].sort((e,i)=>(sd[i[1].dockable.kind]??9)-(sd[e[1].dockable.kind]??9));for(let[e]of t)this.undock(e)}undockMany(t){for(let e of t)this.undock(e)}setInitialModel(t){Object.assign(this.#e,t)}setParams(t){Object.assign(this.#i,t)}updateElements(t){this.#n=t}#a(t,e){xD(this.#e,t,e);for(let[i,r]of this.#s)if(t===i||t.startsWith(i+"/"))for(let n of r)n(x1(this.#e,i))}#o(t,e){return this.#s.has(t)||this.#s.set(t,new Set),this.#s.get(t).add(e),()=>{let i=this.#s.get(t);i?.delete(e),i?.size===0&&this.#s.delete(t)}}#l(t,e){let i=this.#t.get(e);return i&&i.dockable.kind===t?i.dockable:null}#c(t){let e=[];for(let{dockable:i}of this.#t.values())(!t||i.kind===t)&&e.push(i);return e}#h(t){let e=t.target?this.#n.get(t.target):this.#r;e&&e.dispatchEvent(new CustomEvent(t.event,{bubbles:!0,detail:t}))}}});var be,Ys=B(()=>{"use strict";be=class{get kind(){throw new Error("Dockable subclass must define kind")}get id(){throw new Error("Dockable subclass must define id")}dock(t){throw new Error("Dockable subclass must implement dock()")}undock(){}}});var ta,Fb=B(()=>{"use strict";Ys();ta=class extends be{kind="controller";id;type;hostId;config;bind;controller=null;#t;constructor(t,e){super(),this.id=t.id,this.type=t.type,this.hostId=t.host,this.config=t.config||{},this.bind=t.bind||null,this.#t=e}async dock(t){let e=t.getElement(this.hostId);if(!e){console.warn(`ControllerDock: host element "${this.hostId}" not found`);return}let i=await this.#t(this.type);if(!i){console.warn(`ControllerDock: unknown controller type "${this.type}"`);return}this.controller=new i(this.config),this.controller.connect(e);let r=[];if(this.bind)for(let[n,o]of Object.entries(this.bind)){if(this.controller.subscribe){let l=this.controller.subscribe(n,h=>{t.setModel(o,h)});l&&r.push(l)}let a=t.getModel(o);a!==void 0&&this.controller.setState&&this.controller.setState(n,a)}return e.controller=this.controller,()=>{e.controller=null,r.forEach(n=>n())}}undock(){this.controller&&(this.controller.disconnect?.(),this.controller=null)}}});var ea,Yb=B(()=>{"use strict";Ys();ea=class extends be{kind="source";id;uri;path;refresh;#t;#e=null;constructor(t,e){super(),this.id=t.id,this.uri=t.uri,this.path=t.path,this.refresh=t.refresh||"once",this.#t=e}dock(t){if(this.#e=t,this.#i(t),this.refresh==="on-focus"){let e=()=>this.#i(t);return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)}if(this.refresh.startsWith("interval:")){let e=parseInt(this.refresh.split(":")[1],10);if(e>0){let i=setInterval(()=>this.#i(t),e);return()=>clearInterval(i)}}if(this.refresh==="stream"){let e=this.#s(t);try{let i=new EventSource(e);return i.onmessage=r=>{try{t.setModel(this.path,JSON.parse(r.data))}catch{}},()=>i.close()}catch{console.warn(`DataSourceDock: stream failed for ${e}`)}}}undock(){this.#e=null}refetch(){this.#e&&this.#i(this.#e)}async#i(t){let e=this.#s(t);try{let i=await this.#t(e,t);i!==void 0&&t.setModel(this.path,i)}catch(i){console.warn(`DataSourceDock: fetch failed for ${e}`,i)}}#s(t){return this.uri.replace(/\{(\w+)\}/g,(e,i)=>t.getParam(i)??t.getModel("/"+i)??"")}}});var rd,ia,Hb=B(()=>{"use strict";Ys();rd={press:"click",submit:"submit",input:"input",change:"change",select:"select",toggle:"change",dismiss:"close",navigate:"click",mount:"connectedCallback",unmount:"disconnectedCallback",focus:"focusin",blur:"focusout",drag:"dragstart",drop:"drop"},ia=class extends be{kind="action";id;event;handler;config;onSuccess;onError;#t;constructor(t,e){super(),this.event=t.event,this.handler=t.handler,this.config=t.config||{},this.onSuccess=t.onSuccess||null,this.onError=t.onError||null,this.#t=e,this.id=`action:${this.event.event}:${this.event.target||"root"}:${this.handler}`}dock(t){let e=this.event.target?t.getElement(this.event.target):t.getRootElement();if(!e){console.warn(`ActionDock: target "${this.event.target}" not found`);return}let i=rd[this.event.event]||this.event.event,r=this.#t(this.handler);if(!r){console.warn(`ActionDock: unknown handler "${this.handler}"`);return}let n=async o=>{if(this.event.condition){let a=t.getModel(this.event.condition.path);if("equals"in this.event.condition&&a!==this.event.condition.equals||"notEquals"in this.event.condition&&a===this.event.condition.notEquals||"exists"in this.event.condition&&this.event.condition.exists&&a==null)return}try{let a=await r(this.config,t,o);if(this.onSuccess)for(let l of this.onSuccess){let h=this.#t(l.handler);h&&await h(l.config||{},t,a)}}catch(a){if(this.onError)for(let l of this.onError){let h=this.#t(l.handler);h&&await h(l.config||{},t,a)}else console.error(`ActionDock: handler "${this.handler}" failed`,a)}};if(this.event.debounce>0){let o=n,a;n=(...l)=>{clearTimeout(a),a=setTimeout(()=>o(...l),this.event.debounce)}}if(this.event.throttle>0){let o=n,a=0;n=(...l)=>{let h=Date.now();h-a>=this.event.throttle&&(a=h,o(...l))}}return e.addEventListener(i,n),()=>e.removeEventListener(i,n)}undock(){}}});var sa,Gb=B(()=>{"use strict";Ys();sa=class extends be{kind="provider";id;hostId;value;constructor(t){super(),this.id=`provider:${t.name}`,this.hostId=t.host||null,this.value=t.value??null}dock(t){let e=this.hostId?t.getElement(this.hostId):t.getRootElement();if(!e){console.warn(`ProviderDock: host "${this.hostId}" not found`);return}let i=document.createElement("a2ui-provider");return i.setAttribute("name",this.id.replace("provider:","")),i.value=this.value,e.parentNode?.insertBefore(i,e),i.appendChild(e),()=>{i.parentNode&&(i.parentNode.insertBefore(e,i),i.remove())}}undock(){}}});var ra,Kb=B(()=>{"use strict";Ys();ra=class extends be{kind="lifecycle";id="lifecycle";onMount;onUnmount;onModelChange;#t;#e=null;constructor(t,e){super(),this.onMount=t.onMount||[],this.onUnmount=t.onUnmount||[],this.onModelChange=t.onModelChange||[],this.#t=e}dock(t){this.#e=t;for(let i of this.onMount)this.#i(i,t);let e=this.onModelChange.map(i=>{let r=()=>this.#i(i,t);if(i.debounce>0){let n=r,o;r=()=>{clearTimeout(o),o=setTimeout(n,i.debounce)}}return t.watchModel(i.path,r)});return()=>e.forEach(i=>i())}undock(){if(this.#e){for(let t of this.onUnmount)this.#i(t,this.#e);this.#e=null}}async#i(t,e){let i=this.#t(t.handler);if(i)try{await i(t.config||{},e)}catch(r){console.warn(`LifecycleDock: ${t.handler} failed`,r)}}}});var S1,Oe,Hs=B(()=>{"use strict";S1=new WeakSet,Oe=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!S1.has(e)&&e!==s&&(S1.add(e),e.schema||console.warn(`AdiaUI: ${e.name} extends BaseController without static schema`),this.getState===s.prototype.getState&&console.error(`AdiaUI: ${e.schema?.name??e.name} must implement getState()`)),this.#t&&this.#t!==t&&console.warn(`AdiaUI: ${e.schema?.name??e.name} already connected to a different host`),this.#t=t,this.onConnect(t),this.reflect()}disconnect(t){let e=t??this.#t;e&&(this.onDisconnect(e),this.#t=null)}subscribe(t){return this.#e.add(t),()=>this.#e.delete(t)}notify(){this.reflect();for(let t of this.#e)t()}onConnect(t){}onDisconnect(t){}reflect(){}getState(){throw new Error(`${this.constructor.schema?.name??this.constructor.name}: getState() not implemented`)}}});var w1={};Yt(w1,{FormController:()=>Jb});var Jb,k1=B(()=>{"use strict";Hs();Jb=class extends Oe{static schema=Object.freeze({name:"form",state:{values:"object",errors:"object",dirty:"boolean",valid:"boolean"},commands:["set","validate","reset","setInitial"],attributes:["data-form-valid","data-form-invalid","data-form-dirty"]});#t={};#e={};#i={};#s={};constructor(t={}){super(),this.#t={...t},this.#e={...t}}onDisconnect(t){t.removeAttribute("data-form-valid"),t.removeAttribute("data-form-invalid"),t.removeAttribute("data-form-dirty")}getState(){let t=Object.keys(this.#e).some(i=>this.#e[i]!==this.#t[i]),e=Object.keys(this.#i).length===0;return{values:{...this.#e},errors:{...this.#i},dirty:t,valid:e}}reflect(){if(!this.host)return;let{dirty:t,valid:e}=this.getState();e?(this.host.setAttribute("data-form-valid",""),this.host.removeAttribute("data-form-invalid")):(this.host.setAttribute("data-form-invalid",""),this.host.removeAttribute("data-form-valid")),t?this.host.setAttribute("data-form-dirty",""):this.host.removeAttribute("data-form-dirty")}#r(t){let e=this.#s[t];if(!e){delete this.#i[t];return}let i=e(this.#e[t]);i===!0||i==null?delete this.#i[t]:this.#i[t]=typeof i=="string"?i:"Invalid"}commands={set:(t,e)=>{this.#e[t]=e,this.#r(t),this.notify()},validate:(t,e)=>{this.#s[t]=e,this.#r(t),this.notify()},reset:()=>{this.#e={...this.#t},this.#i={};for(let t of Object.keys(this.#s))this.#r(t);this.notify()},setInitial:t=>{this.#t={...t}}}}});var A1={};Yt(A1,{DataStreamController:()=>tO});var tO,E1=B(()=>{"use strict";Hs();tO=class extends Oe{static schema=Object.freeze({name:"data-stream",state:{data:"array",status:"string",error:"string"},commands:["push","pushMany","connect","poll","consume","stop","clear"],attributes:["data-stream-status"]});#t=[];#e;#i="idle";#s=null;#r=null;#n=0;#a=1;#o=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:r=[]}={}){super(),this.#e=t,this.#n=e,this.#a=Math.max(1,Math.round(i)),this.#t=r.slice(-t)}getState(){return{data:this.#t,status:this.#i,error:this.#s}}reflect(){this.host&&this.host.setAttribute("data-stream-status",this.#i)}onDisconnect(){this.commands.stop()}#c(t){this.#l++,!(this.#a>1&&this.#l%this.#a!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#d())}#h(t){if(this.#a>1){let e=[];for(let i of t)this.#l++,this.#l%this.#a===0&&e.push(i);this.#t.push(...e)}else this.#t.push(...t);this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#d()}#d(){if(this.#n<=0){this.notify();return}this.#o===null&&(this.#o=setTimeout(()=>{this.#o=null,this.notify()},this.#n))}#u(t,e=null){this.#i=t,this.#s=e,this.notify()}commands={push:t=>{this.#c(t)},pushMany:t=>{this.#h(t)},connect:(t,e)=>{this.commands.stop(),this.#r=new AbortController,t==="sse"?this.#f(e):t==="ws"?this.#p(e):this.#u("error",`Unknown stream type: ${t}`)},poll:(t,e=2e3)=>{this.commands.stop(),this.#r=new AbortController,this.#m(t,e)},consume:t=>{this.commands.stop(),this.#r=new AbortController,this.#g(t)},stop:()=>{this.#r&&(this.#r.abort(),this.#r=null),this.#o!==null&&(clearTimeout(this.#o),this.#o=null),(this.#i==="streaming"||this.#i==="connecting")&&this.#u("stopped")},clear:()=>{this.#t=[],this.notify()}};#f(t){this.#u("connecting");let e=new EventSource(t),i=this.#r.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#u("streaming"),e.onmessage=r=>{try{let n=JSON.parse(r.data);this.#c(n)}catch{}},e.onerror=()=>{i.aborted||(this.#u("error","SSE connection lost"),e.close())}}#p(t){this.#u("connecting");let e=new WebSocket(t),i=this.#r.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#u("streaming"),e.onmessage=r=>{try{let n=JSON.parse(r.data);Array.isArray(n)?this.#h(n):this.#c(n)}catch{}},e.onerror=()=>{i.aborted||this.#u("error","WebSocket error")},e.onclose=()=>{i.aborted||this.#u("stopped")}}async#m(t,e){this.#u("streaming");let i=this.#r.signal;for(;!i.aborted;){try{let n=await(await fetch(t,{signal:i})).json();Array.isArray(n)?this.#h(n):this.#c(n)}catch(r){if(i.aborted)break;this.#u("error",r.message);break}await new Promise(r=>setTimeout(r,e))}}async#g(t){this.#u("streaming");let e=this.#r.signal;try{for await(let i of t){if(e.aborted)break;Array.isArray(i)?this.#h(i):this.#c(i)}e.aborted||this.#u("idle")}catch(i){e.aborted||this.#u("error",i.message)}}}});var C1={};Yt(C1,{SelectionController:()=>eO});var eO,$1=B(()=>{"use strict";Hs();eO=class extends Oe{static schema=Object.freeze({name:"selection",state:{selected:"Set",multiple:"boolean"},commands:["select","deselect","toggle","clear","selectAll"],attributes:["data-selection-active","data-selection-selected"]});#t=new Set;#e=!1;constructor({multiple:t=!1,initial:e=[]}={}){super(),this.#e=t;for(let i of e)this.#t.add(String(i))}onConnect(t){t.setAttribute("data-selection-active","")}onDisconnect(t){this.#i(t),t.removeAttribute("data-selection-active")}getState(){return{selected:new Set(this.#t),multiple:this.#e}}reflect(){if(!this.host)return;let t=this.host.querySelectorAll("[data-selection-key]");for(let e of t){let i=e.getAttribute("data-selection-key");this.#t.has(i)?e.setAttribute("data-selection-selected",""):e.removeAttribute("data-selection-selected")}}#i(t){let e=t.querySelectorAll("[data-selection-selected]");for(let i of e)i.removeAttribute("data-selection-selected")}commands={select:t=>{t=String(t),this.#e||this.#t.clear(),this.#t.add(t),this.notify()},deselect:t=>{this.#t.delete(String(t)),this.notify()},toggle:t=>{t=String(t),this.#t.has(t)?this.#t.delete(t):(this.#e||this.#t.clear(),this.#t.add(t)),this.notify()},clear:()=>{this.#t.clear(),this.notify()},selectAll:t=>{if(this.#e){for(let e of t)this.#t.add(String(e));this.notify()}}}}});var P1={};Yt(P1,{ToggleController:()=>iO});var iO,Q1=B(()=>{"use strict";Hs();iO=class extends Oe{static schema=Object.freeze({name:"toggle",state:{on:"boolean"},commands:["toggle","set"],attributes:["data-toggle-on"]});#t=!1;constructor(t=!1){super(),this.#t=t}getState(){return{on:this.#t}}onDisconnect(t){t.removeAttribute("data-toggle-on")}reflect(){this.host&&(this.#t?this.host.setAttribute("data-toggle-on",""):this.host.removeAttribute("data-toggle-on"))}commands={toggle:()=>{this.#t=!this.#t,this.notify()},set:t=>{this.#t=!!t,this.notify()}}}});var T1={};Yt(T1,{AccordionController:()=>sO});var sO,L1=B(()=>{"use strict";Hs();sO=class extends Oe{static schema=Object.freeze({name:"accordion",state:{expanded:"Set",multiple:"boolean"},commands:["toggle","expand","collapse","collapseAll","expandAll"],attributes:["data-accordion-expanded"]});#t=new Set;#e=!1;constructor({multiple:t=!1,initial:e=[]}={}){super(),this.#e=t;for(let i of e)this.#t.add(String(i))}onDisconnect(t){let e=t.querySelectorAll("[data-accordion-expanded]");for(let i of e)i.removeAttribute("data-accordion-expanded")}getState(){return{expanded:new Set(this.#t),multiple:this.#e}}reflect(){if(!this.host)return;let t=this.host.querySelectorAll("[data-accordion-key]");for(let e of t){let i=e.getAttribute("data-accordion-key");this.#t.has(i)?e.setAttribute("data-accordion-expanded",""):e.removeAttribute("data-accordion-expanded")}}commands={toggle:t=>{t=String(t),this.#t.has(t)?this.#t.delete(t):(this.#e||this.#t.clear(),this.#t.add(t)),this.notify()},expand:t=>{t=String(t),this.#e||this.#t.clear(),this.#t.add(t),this.notify()},collapse:t=>{this.#t.delete(String(t)),this.notify()},collapseAll:()=>{this.#t.clear(),this.notify()},expandAll:t=>{if(this.#e){for(let e of t)this.#t.add(String(e));this.notify()}}}}});var M1={};Yt(M1,{StateMachineController:()=>rO});var rO,R1=B(()=>{"use strict";Hs();rO=class extends Oe{static schema={name:"state-machine",state:{current:"string",history:"string[]"},commands:["send","transition","reset"],attributes:["data-state"],config:{initial:"string",states:"object"}};#t="";#e="";#i={};#s=[];onConnect(t){let e=this.config||{};this.#e=e.initial||t.dataset?.initial||Object.keys(e.states||{})[0]||"",this.#i=this._validateStates(e.states||{}),this.#t=this.#e,this.#s=this.#t?[this.#t]:[],this.#t&&this._emit("stateEntered",{state:this.#t,initial:!0})}getState(){return{current:this.#t,history:[...this.#s]}}reflect(){this.host&&(this.#t?this.host.setAttribute("data-state",this.#t):this.host.removeAttribute("data-state"))}commands={send:t=>{if(!t||!this.#t)return;let i=(this.#i[this.#t]?.on||{})[t];i&&this._moveTo(i,{event:t})},transition:t=>{!t||!(t in this.#i)||this._moveTo(t,{forced:!0})},reset:()=>{this.#e&&this._moveTo(this.#e,{reset:!0})}};_moveTo(t,e){if(t===this.#t)return;let i=this.#t;i&&this._emit("stateExited",{state:i,target:t,...e}),this.#t=t,this.#s.push(t),this.notify(),this._emit("stateEntered",{state:t,from:i,...e})}_emit(t,e){this.host&&this.host.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}_validateStates(t){let e={},i=Object.keys(t);for(let r of i){let n=t[r]||{},o={};for(let[a,l]of Object.entries(n.on||{})){if(typeof l!="string"||!(l in t)){console.warn(`[state-machine] state "${r}" transition "${a}" \u2192 "${l}" \u2014 target not declared`);continue}o[a]=l}e[r]={on:o}}return e}}});function I1(s,t){Di.controllers.set(s,t)}function D1(s,t){Di.handlers.set(s,t)}function q1(s,t){Di.resolvers.set(s,t)}async function nd(s){let t=Di.controllers.get(s);return t?t():null}function od(s){return Di.handlers.get(s)||null}async function Bl(s,t={}){let e=s;for(let[o,a]of Object.entries(t))e=e.replace(`{${o}}`,encodeURIComponent(a));let i=e.indexOf("://");if(i===-1)throw new Error(`Invalid URI: ${s}`);let r=e.slice(0,i),n=Di.resolvers.get(r);if(!n)throw new Error(`No resolver for scheme "${r}"`);return n(e,t)}async function SD(s){let{action:t,params:e}=s,i=nO(t.body,s),r=t.uri;for(let[c,u]of Object.entries(e))r=r.replace(`{${c}}`,encodeURIComponent(u));let n=r.indexOf("://"),o=n>-1?r.slice(0,n):"api",a=Di.resolvers.get(o),l=r.replace(/^\w+:\/\//,"/api/"),h=await fetch(l,{method:t.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!h.ok){let c=await h.text().catch(()=>"Request failed");throw new Error(c)}return h.json().catch(()=>({}))}async function wD(s){let{action:t}=s,e=nO(t.value,s);s.updateModel(t.path,e)}async function kD(s){let{action:t,params:e}=s,i=t.navigate||t.path||"";for(let[r,n]of Object.entries(e))i=i.replace(`{${r}}`,encodeURIComponent(n));i==="back"?history.back():i&&(location.hash=i)}async function AD(){history.back()}async function ED(s){let{action:t,controllers:e}=s,i=e[t.controllerId];if(!i?.commands?.[t.command]){console.warn(`Wiring: controller "${t.controllerId}" or command "${t.command}" not found`);return}return i.commands[t.command](t.args)}async function CD(s){let{action:t,source:e}=s,i=nO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function $D(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function PD(s){let{action:t}=s,e=typeof t=="string"?t:t.message||t.notify;document.dispatchEvent(new CustomEvent("a2ui-notify",{bubbles:!0,detail:{message:e,variant:t.variant||"info"}}))}function nO(s,t){if(s){if(typeof s!="object")return s;switch(s.from){case"event-detail":return s.key?t.event?.detail?.[s.key]:t.event?.detail;case"event-target":return s.key?t.source?.[s.key]:t.source?.value;case"model":return QD(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}function QD(s,t){if(!t||!s)return;let e=t.split("/").filter(Boolean),i=s;for(let r of e){if(i==null||typeof i!="object")return;i=i[r]}return i}async function TD(s,t){let e=s.replace(/^resource:\/\//,"/api/"),i=await fetch(e);if(!i.ok)throw new Error(`Resource fetch failed: ${i.status}`);return i.json()}async function LD(s,t){let e=s.replace(/^api:\/\//,"https://"),i=await fetch(e);if(!i.ok)throw new Error(`API fetch failed: ${i.status}`);return i.json()}async function MD(s,t){return{_source:s,_mock:!0}}var Di,oO=B(()=>{"use strict";Di={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(k1(),w1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(E1(),A1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>($1(),C1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(Q1(),P1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(L1(),T1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(R1(),M1))).StateMachineController]]),handlers:new Map([["submit-resource",SD],["update-model",wD],["navigate",kD],["navigate-back",AD],["controller-command",ED],["emit-event",CD],["refresh-source",$D],["notify",PD]]),resolvers:new Map([["resource",TD],["api",LD],["mock",MD]])}});function RD(s){return async(t,e,i)=>{let r={action:t,event:i instanceof Event?i:null,source:i instanceof Event?i.target:null,dataModel:e.getModel(),updateModel:(n,o)=>e.setModel(n,o),controllers:Object.fromEntries(e.listDockables("controller").map(n=>[n.id,n.controller])),params:{},resolveData:Bl};return s(r)}}function ID(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=od(t);if(!e)return null;let i=RD(e);return s.set(t,i),i}}function DD(){return async s=>nd(s)}function qD(){return async(s,t)=>Bl(s,{})}function ad(s){let t=[],e=ID(),i=DD(),r=qD();if(s.data?.sources)for(let o of s.data.sources)t.push(new ea(o,r));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new ta(o,i));if(s.actions)for(let o of s.actions)t.push(new ia(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new sa(a))}s.lifecycle&&t.push(new ra(s.lifecycle,e));let n=s.state?.model||null;return{dockables:t,initialModel:n}}var aO=B(()=>{"use strict";Fb();Yb();Hb();Gb();Kb();oO()});var X1={};Yt(X1,{WiringEngine:()=>zl});var zl,lO=B(()=>{"use strict";Ub();aO();zl=class{#t=new Map;#e;#i;constructor({updateDataModel:t,getElement:e}){this.#e=t,this.#i=e}async process(t){let{surfaceId:e}=t;if(!e)return;let i=this.#t.get(e);i||(i=this.#s(e),this.#t.set(e,i));try{t.data?.params&&i.setParams(this.#r(t.data.params));let{dockables:r,initialModel:n}=ad(t);n&&i.setInitialModel(n),t.undock&&i.undockMany(t.undock);for(let o of r)await i.dock(o)}catch(r){console.warn(`Wiring: error processing wireComponents for "${e}":`,r.message)}}teardown(t){let e=this.#t.get(t);e&&(e.undockAll(),this.#t.delete(t))}teardownAll(){for(let t of this.#t.keys())this.teardown(t)}getSurface(t){return this.#t.get(t)||null}getSurfaceState(t){let e=this.#t.get(t);if(!e)return null;let i=e.context.listDockables();return{surfaceId:t,controllerCount:i.filter(r=>r.kind==="controller").length,sourceCount:i.filter(r=>r.kind==="source").length,actionCount:i.filter(r=>r.kind==="action").length,providerCount:i.filter(r=>r.kind==="provider").length,hasLifecycle:i.some(r=>r.kind==="lifecycle"),totalDocked:i.length}}#s(t){let e={get:h=>this.#i(t,h),has:h=>!!this.#i(t,h)},i=this.#i(t,"root")||document.createElement("div"),r=new Proxy(new Map,{get(h,c){return c==="get"?u=>e.get(u):c==="has"?u=>e.has(u):h[c]}}),n=new Jo(t,i,r),o=n.context,a=o.setModel,l=this.#e;return Object.defineProperty(n,"context",{get(){return{...o,setModel(c,u){a(c,u),l(t,c,u)}}}}),n}#r(t){let e={};for(let[i,r]of Object.entries(t))switch(r.from){case"route":{let o=location.hash.slice(1).match(new RegExp(`${r.key}/([^/]+)`));o&&(e[i]=o[1]);break}case"query":{let o=new URL(location.href).searchParams.get(r.key);o&&(e[i]=o);break}case"literal":e[i]=r.value;break;default:typeof r=="string"&&(e[i]=r)}return e}}});var is,N1=B(()=>{"use strict";Wb();is=class s{#t;#e;#i=new Map;#s=new Map;#r=new Map;#n=[];#a=null;#o=!1;constructor(t,e=Xt,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#o=i}process(t){t&&(this.#o?(this.#n.push(t),this.#a===null&&(this.#a=requestAnimationFrame(()=>this.#l()))):this.#c(t))}#l(){this.#a=null;let t=this.#n.splice(0);for(let e of t)this.#c(e)}#c(t){switch(t.type||t.messageType){case"createSurface":this.#u(t);break;case"updateComponents":this.#f(t);break;case"updateDataModel":this.#T(t);break;case"wireComponents":this.#d(t);break;case"deleteSurface":this.#Q(t);break;case"updateStyles":this.#I(t);break;case"removeStyles":this.#$(t);break;case"meta":break;default:console.warn("A2UI: unknown message type",t.type)}}#h=null;async#d(t){if(!this.#h){let{WiringEngine:e}=await Promise.resolve().then(()=>(lO(),X1));this.#h=new e({updateDataModel:(i,r,n)=>{this.#T({surfaceId:i,path:r,value:n})},getElement:(i,r)=>this.#i.get(i)?.elements.get(r)||null})}await this.#h.process(t)}async processStream(t){for await(let e of t)this.process(e)}#u({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t))return;let r=document.createElement("div");r.setAttribute("data-a2ui-surface",t),e&&r.setAttribute("data-catalog",e),this.#t.appendChild(r),this.#i.set(t,{root:r,rootId:typeof i=="string"&&i?i:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets: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,adoptedSheets:new Map},this.#i.set(t,i),this.#t&&typeof this.#t.setAttribute=="function"&&this.#t.setAttribute("data-a2ui-surface",t));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.#x(l.variant,l):id(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.#k(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#y(e);let r=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])r.set(h,l.id);l.child&&r.set(l.child,l.id)}let n=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=r.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||n(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!n(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#m=new Set(["Header","Section","Footer"]);static#g=new Set(["header","body","footer"]);#b=new Set;#y(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let r=i.component==="Card"||i.component==="ErrorContainer",n=i.component==="Drawer";if(!r&&!n)continue;let o=n?s.#m:s.#p,a=n?"<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.#g.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#b.has(u)||(this.#b.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(", ")}`+(n?', or slot="header|body|footer".':".")))}}}static#O=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"]);#x(t,e){return!e?.slot&&s.#v[t]?s.#v[t]:"text-ui"}#k(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 r=this.#r.get(e.id),n={};for(let[o,a]of Object.entries(e)){if(i.has(o))continue;let l=a&&typeof a=="object"&&a.path,h=this.#C(a,e._surfaceId);if(n[o]=h,!(r&&Object.is(r[o],h))){if(o==="style"&&typeof h=="string"){t.style.cssText=h;continue}if(s.#O.has(o)&&h!=null){if(o==="textContent"&&!s.#S.has(t.localName)){t.setAttribute("text",String(h));continue}let c=h;if(typeof c=="string"&&(c.startsWith("[")||c.startsWith("{")))try{c=JSON.parse(c)}catch{}t[o]=c;continue}typeof h=="boolean"?h?t.setAttribute(o,""):t.removeAttribute(o):h!=null?t.setAttribute(this.#A(o),String(h)):l&&t.removeAttribute(this.#A(o))}}if(r)for(let o of Object.keys(r))!(o in n)&&!i.has(o)&&t.removeAttribute(this.#A(o));this.#r.set(e.id,n)}#A(t){return s.#w.has(t.toLowerCase())?t.toLowerCase():t.replace(/([A-Z])/g,"-$1").toLowerCase()}#C(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.#E(i.dataModel,t.path):t.path}return t}#E(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,r)=>i?.[r],t)}#T({surfaceId:t,path:e,value:i}){let r=this.#i.get(t);if(r){if(!e||e==="/")r.dataModel=i??{};else{let n=e.split("/").filter(Boolean),o=r.dataModel;for(let a=0;a<n.length-1;a++)o[n[a]]==null&&(o[n[a]]={}),o=o[n[a]];o[n[n.length-1]]=i}for(let[n,o]of r.bindings){let a=r.elements.get(n);a&&this.#k(a,o)}}}#Q({surfaceId:t}){let e=this.#i.get(t);if(e){this.#h?.teardown(t);for(let[i]of e.elements)this.#s.delete(i);if(e.adoptedSheets&&e.adoptedSheets.size>0){let i=new Set;for(let r of e.adoptedSheets.values())i.add(r.sheet);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(r=>!i.has(r)),e.adoptedSheets.clear()}e.root.remove(),this.#i.delete(t)}}static#P=new Set(["root","html","body"]);#I({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#R(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#R(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: css must be a string"});return}let r=this.#i.get(t);if(!r){this.#R(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let n=this.#M(i,t);if(n.rejected){this.#R(r.root,"styles-rejected",{surfaceId:t,styleId:e,reason:n.reason});return}let o=r.adoptedSheets.get(e);o&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet)),document.adoptedStyleSheets=[...document.adoptedStyleSheets,n.sheet],r.adoptedSheets.set(e,{sheet:n.sheet,ruleCount:n.sheet.cssRules.length,appliedAt:typeof performance<"u"?performance.now():Date.now()}),this.#R(r.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:n.sheet.cssRules.length,validationWarnings:n.warnings})}#$({surfaceId:t,styleId:e}){let i=this.#i.get(t);if(!i)return;let r=i.adoptedSheets.get(e);r&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(n=>n!==r.sheet),i.adoptedSheets.delete(e),this.#R(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#M(t,e){let i=[];if(/^\s*@import\b/im.test(t))return{rejected:!0,reason:"forbidden-import"};if(/^\s*@charset\b/im.test(t))return{rejected:!0,reason:"forbidden-charset"};let r=new CSSStyleSheet;try{r.replaceSync(t)}catch(l){return{rejected:!0,reason:"parse-error: "+(l?.message||String(l))}}for(let l of r.cssRules){let h=this.#L(l);if(h)return{rejected:!0,reason:h}}if(/url\s*\(\s*["']?\s*(?:https?:|\/\/)/i.test(t))return{rejected:!0,reason:"external-url"};for(let l of r.cssRules)if(l.constructor?.name==="CSSPropertyRule"||l.cssText?.startsWith("@property")){let h=l.cssText.match(/@property\s+(--[\w-]+)/);h&&i.push({kind:"property-registered-globally",name:h[1]})}let n=this.#X(r,e),o=this.#q(r,e),a=new CSSStyleSheet;try{a.replaceSync(o)}catch(l){return{rejected:!0,reason:"scope-wrap-failed: "+(l?.message||String(l))}}return n.length>0&&i.push({kind:"animations-namespaced",count:n.length}),{rejected:!1,sheet:a,warnings:i}}#L(t){let e=t.cssText||"";if(/^@import\b/i.test(e))return"forbidden-import";if(/^@charset\b/i.test(e))return"forbidden-charset";if(/^@scope\b/i.test(e))return"forbidden-scope-directive";if(t.selectorText){let i=this.#D(t.selectorText);for(let r of i){let n=r.trim().replace(/^:scope\s*/,"");if(n.startsWith(":root"))return"forbidden-root-selector";let o=n.match(/^([a-zA-Z*][\w-]*)/);if(!o)continue;let a=o[1].toLowerCase();if(s.#P.has(a))return`forbidden-${a}-selector`}}return null}#D(t){let e=[],i=0,r=0;for(let n=0;n<t.length;n++){let o=t[n];o==="("?i++:o===")"?i--:o===","&&i===0&&(e.push(t.slice(r,n)),r=n+1)}return e.push(t.slice(r)),e}#X(t,e){let i=[],r=String(e).replace(/[^a-zA-Z0-9_-]/g,"_");for(let o=0;o<t.cssRules.length;o++){let a=t.cssRules[o];if(a.constructor?.name==="CSSKeyframesRule"||a.cssText?.startsWith("@keyframes")){let l=a.name;if(!l)continue;let h=`${r}_${l}`;try{a.name=h}catch{let c=a.cssText.replace(/@keyframes\s+[\w-]+/,`@keyframes ${h}`);t.deleteRule(o),t.insertRule(c,o)}i.push({from:l,to:h})}}if(i.length===0)return i;let n=new Map(i.map(o=>[o.from,o.to]));for(let o of t.cssRules)if(o.style)for(let a of["animation","animation-name"]){let l=o.style.getPropertyValue(a);if(!l)continue;let h=l.replace(/\b([\w-]+)\b/g,c=>n.has(c)?n.get(c):c);h!==l&&o.style.setProperty(a,h)}return i}#q(t,e){let i=[];for(let n of t.cssRules)i.push(n.cssText);return`@scope ([data-a2ui-surface="${String(e).replace(/"/g,'\\"')}"]) {
42
42
  ${i.join(`
43
43
  `)}
44
44
  }`}#R(t,e,i){let r=t||this.#t;if(!(!r||typeof CustomEvent>"u"))try{r.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,composed:!1}))}catch{}}getSurface(t){return this.#i.get(t)}getElement(t){return this.#s.get(t)}get surfaces(){return[...this.#i.keys()]}getStylesheets(t){return this.#i.get(t)?.adoptedSheets??new Map}reset(){this.#a!==null&&(cancelAnimationFrame(this.#a),this.#a=null),this.#n.length=0;let t=new Set;for(let[,e]of this.#i)if(e.adoptedSheets)for(let i of e.adoptedSheets.values())t.add(i.sheet);t.size>0&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>!t.has(e)));for(let[,e]of this.#i)e.root===this.#t?e.root.innerHTML="":e.root.remove();this.#i.clear(),this.#s.clear(),this.#r.clear()}set batching(t){this.#o=!!t}get batching(){return this.#o}}});function ld(s,t={}){let e=s;if(t.catalog){let i=t.catalog instanceof Map?[...t.catalog.keys()]:Object.keys(t.catalog),r=s.includes("?")?"&":"?";e=`${s}${r}a2ui_catalog=${encodeURIComponent(i.join(","))}`}return{[Symbol.asyncIterator](){let i=new EventSource(e),r=[],n=null,o=!1;return i.onmessage=a=>{try{let l=JSON.parse(a.data);if(n){let h=n;n=null,h({value:l,done:!1})}else r.push(l)}catch{console.warn("A2UI SSE: invalid JSON",a.data)}},i.onerror=()=>{if(o=!0,i.close(),n){let a=n;n=null,a({value:void 0,done:!0})}},t.signal&&t.signal.addEventListener("abort",()=>{if(o=!0,i.close(),n){let a=n;n=null,a({value:void 0,done:!0})}}),{next(){return r.length>0?Promise.resolve({value:r.shift(),done:!1}):o?Promise.resolve({value:void 0,done:!0}):new Promise(a=>{n=a})},return(){return o=!0,i.close(),Promise.resolve({value:void 0,done:!0})}}}}}function hd(s,t={}){return{[Symbol.asyncIterator](){let e=new WebSocket(s),i=[],r=null,n=!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(r){let l=r;r=null,l({value:a,done:!1})}else i.push(a)}catch{console.warn("A2UI WS: invalid JSON",o.data)}},e.onclose=()=>{if(n=!0,r){let o=r;r=null,o({value:void 0,done:!0})}},e.onerror=()=>{n=!0,e.close()},{next(){return i.length>0?Promise.resolve({value:i.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise(o=>{r=o})},return(){return n=!0,e.close(),Promise.resolve({value:void 0,done:!0})}}}}}function z1(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function cd(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?XD(s,t):B1(s,t)}function Z1(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 r of Array.isArray(i)?i:[i])t(r)}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 XD(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:r}=t,n=new WebSocket(s);if(await new Promise((c,u)=>{n.onopen=c,n.onerror=u,e&&e.addEventListener("abort",()=>{n.close(),u(new DOMException("Aborted","AbortError"))},{once:!0})}),i){let c=i instanceof Map?[...i.keys()]:Object.keys(i);n.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(n.onmessage=c=>{try{let u=JSON.parse(c.data);Z1(u,h),u.method==="a2ui/action"&&r&&r(u.params?.name,u.params?.arguments).then(d=>{n.send(JSON.stringify({jsonrpc:"2.0",id:u.id,result:d}))}).catch(d=>{n.send(JSON.stringify({jsonrpc:"2.0",id:u.id,error:{code:-1,message:d.message}}))})}catch{console.warn("A2UI MCP: invalid message",c.data)}},n.onclose=()=>{if(l=!0,a){let c=a;a=null,c({value:void 0,done:!0})}},n.onerror=()=>{l=!0,n.close()},e&&e.addEventListener("abort",()=>{if(l=!0,n.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 B1(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:r}=t,n=[],o=null,a=!1,l=g=>{if(o){let y=o;o=null,y({value:g,done:!1})}else n.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,w="";for(;;){let{done:k,value:E}=await y.read();if(k||(w+=v.decode(E,{stream:!0}),w.includes(`
@@ -65,7 +65,7 @@ ${i.join(`
65
65
  aria-label="Undo" \u2190 explicit accessible name
66
66
  title="Undo" \u2190 auto-mirrored to aria-label + tooltip
67
67
  aria-labelledby="..." \u2190 reference an existing label element
68
- 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)}};S("button-ui",rr);$();var nr=class extends x{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>`:"",r=this.text?`<span>${this.text}</span>`:"";t.innerHTML=`${i}${r}`}}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("link-ui",nr);$();var M=class s extends x{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)}#r=t=>{t.preventDefault(),this.setAttribute("aria-invalid","true"),this.error=this.validationMessage};#n=()=>{this.#t=!0,this.error&&this.validate()};#a=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#r),this.addEventListener("input",this.#n),this.addEventListener("blur",this.#a,!0),this.#o()}#o(){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.#r),this.removeEventListener("input",this.#n),this.removeEventListener("blur",this.#a,!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 HO=s=>ph(s)?`<icon-ui name="${s}"></icon-ui>`:s,or=class s extends M{static labelDeprecated=!1;static properties={...M.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;#r="";#n=null;#a=null;#o=".";#l="";#c=null;static#h=0;static#u=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.#A(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.#m(i),this.#g(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.#E(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#P),this.#t.addEventListener("keydown",this.#X),this.#t.addEventListener("blur",this.#R),this.#t.addEventListener("focus",this.#q),this.#t.addEventListener("paste",this.#j),this.#p&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#B),this.#s?.addEventListener("pointerdown",this.#H),(this.prefix||this.suffix)&&MO.then(()=>this.#b())}#m(t){let e=this.prefix?`<span slot="prefix">${HO(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",r=this.suffix?`<span slot="suffix">${HO(this.suffix)}</span>`:"",n=t?`aria-labelledby="${t}"`:"";if(this.#f)return`
68
+ 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)}};S("button-ui",rr);$();var nr=class extends x{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>`:"",r=this.text?`<span>${this.text}</span>`:"";t.innerHTML=`${i}${r}`}}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("link-ui",nr);$();var M=class s extends x{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)}#r=t=>{t.preventDefault(),this.setAttribute("aria-invalid","true"),this.error=this.validationMessage};#n=()=>{this.#t=!0,this.error&&this.validate()};#a=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#r),this.addEventListener("input",this.#n),this.addEventListener("blur",this.#a,!0),this.#o()}#o(){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.#r),this.removeEventListener("input",this.#n),this.removeEventListener("blur",this.#a,!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 HO=s=>ph(s)?`<icon-ui name="${s}"></icon-ui>`:s,or=class s extends M{static labelDeprecated=!1;static properties={...M.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;#r="";#n=null;#a=null;#o=".";#l="";#c=null;static#h=0;static#d=400;static#u=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.#A(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.#m(i),this.#g(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.#E(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#P),this.#t.addEventListener("keydown",this.#X),this.#t.addEventListener("blur",this.#R),this.#t.addEventListener("focus",this.#q),this.#t.addEventListener("paste",this.#j),this.#p&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#B),this.#s?.addEventListener("pointerdown",this.#H),(this.prefix||this.suffix)&&MO.then(()=>this.#b())}#m(t){let e=this.prefix?`<span slot="prefix">${HO(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",r=this.suffix?`<span slot="suffix">${HO(this.suffix)}</span>`:"",n=t?`aria-labelledby="${t}"`:"";if(this.#f)return`
69
69
  <div slot="field">
70
70
  ${e}${i}
71
71
  <input slot="text" type="password" tabindex="0"
@@ -89,16 +89,16 @@ ${i.join(`
89
89
  <div slot="field"${this.#p?" data-number":""}>
90
90
  ${e}${i}${o}${r}${a}
91
91
  </div>
92
- `}#g(t,e){let i=this.querySelector(':scope > [slot="field"]');if(i){if(t.length){let r=i.querySelector(':scope > [slot="label"]')||i.querySelector(':scope > [slot="prefix"]');if(r){let n=r;for(let o of t)n.after(o),n=o}else for(let n of t.slice().reverse())i.prepend(n)}if(e.length){let r=i.querySelector(':scope > [slot="controls"]'),n=i.querySelector(':scope > [slot="suffix"]')||i.querySelector(':scope > [slot="text"]');if(n){let o=n;for(let a of e)o.after(a),o=a}else if(r){let o=r.previousElementSibling||r;for(let a of e)o.after(a),o=a}else for(let o of e)i.appendChild(o)}}}#b(){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")&&ph(e)){i.replaceChildren();let r=document.createElement("icon-ui");r.setAttribute("name",e),i.appendChild(r)}}}#O(){for(let t of["prefix","suffix"]){let e=this.querySelector(`:scope > [slot="field"] > [slot="${t}"]`);if(!e)continue;let i=this[t]||"",r=e.querySelector(":scope > icon-ui");if(i&&ph(i))if(r)r.getAttribute("name")!==i&&r.setAttribute("name",i);else{e.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",i),e.appendChild(n)}else r&&e.replaceChildren(),e.textContent!==i&&(e.textContent=i)}}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.#E(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.#O(),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.#A(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,r=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!r)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#p&&this.#y(String(t))}validate(){let t=super.validate();if(!this.#p)return t;if(!t)return!1;let e=this.#y(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#y(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#k(e),r=Number(i);return Number.isFinite(r)?this.min!=null&&r<this.min?(this.internals.setValidity({rangeUnderflow:!0},this.getAttribute("data-msg-min")||`Value must be ${this.min} or greater.`,this),!1):this.max!=null&&r>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)}#w(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#v(){return this.locale?this.#c===this.locale?this.#o:(this.#x(),this.#o):"."}#S(){return this.locale?this.#c===this.locale?this.#l:(this.#x(),this.#l):""}#x(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#o=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#o=".",this.#l=""}this.#c=this.locale}#k(t){let e=this.#v(),i=this.#S(),r=String(t);return i&&(r=r.split(i).join("")),e!=="."&&(r=r.replace(new RegExp(`\\${e}`,"g"),".")),r}#A(t){if(!Number.isFinite(t))return"";let e=this.#w();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))}#C(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#A(t);let e=this.#w();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#A(t)}}#E(t){let e=String(t??"");if(!e)return"";let i=Number(this.#k(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#A(i):this.#C(i):e}#T(t){let e=this.step||1,i=this.min!=null?this.min:0,r=Math.round((t-i)/e)*e+i,n=Math.max(this.min!=null?this.min:-1/0,Math.min(this.max!=null?this.max:1/0,r));return parseFloat(n.toFixed(10))}#Q(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,r=this.#T(i+e);r!==this.valueAsNumber&&(this.value=this.#A(r),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}})))}#P=()=>{let t;if(this.#f)t=this.#t.value||"";else if(this.#p){let e=this.#t.textContent||"";t=this.#M(e),t!==e&&(this.#t.textContent=t,this.#D())}else t=this.#t.textContent||"";this.value=t,this.#f||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#I=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;let r=this.#t.textContent||"",n=window.getSelection(),o=r.length,a=r.length;if(n&&n.rangeCount&&this.#t.contains(n.anchorNode)){let h=n.getRangeAt(0);o=this.#L(h.startContainer,h.startOffset),a=this.#L(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=r.slice(0,o)+i+r.slice(a);this.#$(l)||t.preventDefault()};#$(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)}#M(t){let e=this.#v(),i="",r=!1;for(let n=0;n<t.length;n++){let o=t[n];o>="0"&&o<="9"||o==="-"&&i===""&&(this.min==null||this.min<0)?i+=o:o===e&&!r&&(i+=e,r=!0)}return i}#L(t,e){if(!this.#t.contains(t))return 0;let i=0,r=document.createTreeWalker(this.#t,NodeFilter.SHOW_TEXT),n;for(;n=r.nextNode();){if(n===t)return i+e;i+=n.textContent.length}return t===this.#t?e:i}#D(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#X=t=>{if(this.#p){switch(t.key){case"ArrowUp":t.preventDefault(),this.#Q(1);return;case"ArrowDown":t.preventDefault(),this.#Q(-1);return;case"PageUp":t.preventDefault(),this.#Q(10);return;case"PageDown":t.preventDefault(),this.#Q(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#Z(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#Z(this.max));return;case"Escape":t.preventDefault(),this.value=this.#r,this.#t.textContent=this.#E(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#_(),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})))};#q=()=>{if(this.#r=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.#A(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#R=()=>{this.#p&&this.#_(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#_(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#T(e),r=this.#A(i),n=this.#C(i);this.value!==r&&(this.value=r,this.syncValue(r),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==n&&(this.#t.textContent=n,this.#t.toggleAttribute("data-empty",!n))}#Z(t){let e=this.#T(t);e!==this.valueAsNumber&&(this.value=this.#A(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}})))}#j=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#p?this.#M(e):e;document.execCommand("insertText",!1,i)};#B=t=>this.#F(t,1);#H=t=>this.#F(t,-1);#F(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#Q(e),this.#N(),document.addEventListener("pointerup",this.#V,{once:!0}),document.addEventListener("pointercancel",this.#V,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#n=window.setInterval(()=>{let i=this.valueAsNumber;this.#Q(e),this.valueAsNumber===i&&this.#N()},s.#d)},s.#u))}#V=()=>this.#N();#N(){this.#a!=null&&(window.clearTimeout(this.#a),this.#a=null),this.#n!=null&&(window.clearInterval(this.#n),this.#n=null),document.removeEventListener("pointerup",this.#V),document.removeEventListener("pointercancel",this.#V)}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.#P),this.#t.removeEventListener("keydown",this.#X),this.#t.removeEventListener("blur",this.#R),this.#t.removeEventListener("focus",this.#q),this.#t.removeEventListener("paste",this.#j),this.#t.removeEventListener("beforeinput",this.#I)),this.#i?.removeEventListener("pointerdown",this.#B),this.#s?.removeEventListener("pointerdown",this.#H),this.#N(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};S("input-ui",or);var ar=class extends M{static labelDeprecated=!1;static properties={...M.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=`
92
+ `}#g(t,e){let i=this.querySelector(':scope > [slot="field"]');if(i){if(t.length){let r=i.querySelector(':scope > [slot="label"]')||i.querySelector(':scope > [slot="prefix"]');if(r){let n=r;for(let o of t)n.after(o),n=o}else for(let n of t.slice().reverse())i.prepend(n)}if(e.length){let r=i.querySelector(':scope > [slot="controls"]'),n=i.querySelector(':scope > [slot="suffix"]')||i.querySelector(':scope > [slot="text"]');if(n){let o=n;for(let a of e)o.after(a),o=a}else if(r){let o=r.previousElementSibling||r;for(let a of e)o.after(a),o=a}else for(let o of e)i.appendChild(o)}}}#b(){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")&&ph(e)){i.replaceChildren();let r=document.createElement("icon-ui");r.setAttribute("name",e),i.appendChild(r)}}}#y(){for(let t of["prefix","suffix"]){let e=this.querySelector(`:scope > [slot="field"] > [slot="${t}"]`);if(!e)continue;let i=this[t]||"",r=e.querySelector(":scope > icon-ui");if(i&&ph(i))if(r)r.getAttribute("name")!==i&&r.setAttribute("name",i);else{e.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",i),e.appendChild(n)}else r&&e.replaceChildren(),e.textContent!==i&&(e.textContent=i)}}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.#E(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.#y(),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.#A(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,r=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!r)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#p&&this.#O(String(t))}validate(){let t=super.validate();if(!this.#p)return t;if(!t)return!1;let e=this.#O(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#O(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#k(e),r=Number(i);return Number.isFinite(r)?this.min!=null&&r<this.min?(this.internals.setValidity({rangeUnderflow:!0},this.getAttribute("data-msg-min")||`Value must be ${this.min} or greater.`,this),!1):this.max!=null&&r>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)}#S(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#v(){return this.locale?this.#c===this.locale?this.#o:(this.#x(),this.#o):"."}#w(){return this.locale?this.#c===this.locale?this.#l:(this.#x(),this.#l):""}#x(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#o=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#o=".",this.#l=""}this.#c=this.locale}#k(t){let e=this.#v(),i=this.#w(),r=String(t);return i&&(r=r.split(i).join("")),e!=="."&&(r=r.replace(new RegExp(`\\${e}`,"g"),".")),r}#A(t){if(!Number.isFinite(t))return"";let e=this.#S();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))}#C(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#A(t);let e=this.#S();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#A(t)}}#E(t){let e=String(t??"");if(!e)return"";let i=Number(this.#k(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#A(i):this.#C(i):e}#T(t){let e=this.step||1,i=this.min!=null?this.min:0,r=Math.round((t-i)/e)*e+i,n=Math.max(this.min!=null?this.min:-1/0,Math.min(this.max!=null?this.max:1/0,r));return parseFloat(n.toFixed(10))}#Q(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,r=this.#T(i+e);r!==this.valueAsNumber&&(this.value=this.#A(r),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}})))}#P=()=>{let t;if(this.#f)t=this.#t.value||"";else if(this.#p){let e=this.#t.textContent||"";t=this.#M(e),t!==e&&(this.#t.textContent=t,this.#D())}else t=this.#t.textContent||"";this.value=t,this.#f||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#I=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;let r=this.#t.textContent||"",n=window.getSelection(),o=r.length,a=r.length;if(n&&n.rangeCount&&this.#t.contains(n.anchorNode)){let h=n.getRangeAt(0);o=this.#L(h.startContainer,h.startOffset),a=this.#L(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=r.slice(0,o)+i+r.slice(a);this.#$(l)||t.preventDefault()};#$(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)}#M(t){let e=this.#v(),i="",r=!1;for(let n=0;n<t.length;n++){let o=t[n];o>="0"&&o<="9"||o==="-"&&i===""&&(this.min==null||this.min<0)?i+=o:o===e&&!r&&(i+=e,r=!0)}return i}#L(t,e){if(!this.#t.contains(t))return 0;let i=0,r=document.createTreeWalker(this.#t,NodeFilter.SHOW_TEXT),n;for(;n=r.nextNode();){if(n===t)return i+e;i+=n.textContent.length}return t===this.#t?e:i}#D(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#X=t=>{if(this.#p){switch(t.key){case"ArrowUp":t.preventDefault(),this.#Q(1);return;case"ArrowDown":t.preventDefault(),this.#Q(-1);return;case"PageUp":t.preventDefault(),this.#Q(10);return;case"PageDown":t.preventDefault(),this.#Q(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#Z(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#Z(this.max));return;case"Escape":t.preventDefault(),this.value=this.#r,this.#t.textContent=this.#E(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#_(),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})))};#q=()=>{if(this.#r=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.#A(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#R=()=>{this.#p&&this.#_(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#_(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#T(e),r=this.#A(i),n=this.#C(i);this.value!==r&&(this.value=r,this.syncValue(r),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==n&&(this.#t.textContent=n,this.#t.toggleAttribute("data-empty",!n))}#Z(t){let e=this.#T(t);e!==this.valueAsNumber&&(this.value=this.#A(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}})))}#j=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#p?this.#M(e):e;document.execCommand("insertText",!1,i)};#B=t=>this.#F(t,1);#H=t=>this.#F(t,-1);#F(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#Q(e),this.#N(),document.addEventListener("pointerup",this.#V,{once:!0}),document.addEventListener("pointercancel",this.#V,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#n=window.setInterval(()=>{let i=this.valueAsNumber;this.#Q(e),this.valueAsNumber===i&&this.#N()},s.#u)},s.#d))}#V=()=>this.#N();#N(){this.#a!=null&&(window.clearTimeout(this.#a),this.#a=null),this.#n!=null&&(window.clearInterval(this.#n),this.#n=null),document.removeEventListener("pointerup",this.#V),document.removeEventListener("pointercancel",this.#V)}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.#P),this.#t.removeEventListener("keydown",this.#X),this.#t.removeEventListener("blur",this.#R),this.#t.removeEventListener("focus",this.#q),this.#t.removeEventListener("paste",this.#j),this.#t.removeEventListener("beforeinput",this.#I)),this.#i?.removeEventListener("pointerdown",this.#B),this.#s?.removeEventListener("pointerdown",this.#H),this.#N(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};S("input-ui",or);var ar=class extends M{static labelDeprecated=!1;static properties={...M.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=`
93
93
  ${this.label?`<label slot="label" label="${this.label}"></label>`:""}
94
94
  <div slot="text" contenteditable="plaintext-only" tabindex="0"
95
95
  ${this.value?"":'data-empty=""'}
96
96
  data-placeholder="${this.placeholder}"></div>
97
- `),this.#t=this.querySelector('[slot="text"]'),this.value&&(this.#t.textContent=this.value),this.#t&&(this.#t.addEventListener("input",this.#e),this.#t.addEventListener("keydown",this.#i),this.#t.addEventListener("blur",this.#s),this.#t.addEventListener("paste",this.#r))}render(){if(!this.#t)return;this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let t=this.value||"";this.#t.textContent!==t&&(this.#t.textContent=t,this.#t.toggleAttribute("data-empty",!t));let e=this.querySelector('[slot="label"]');e&&this.label&&e.setAttribute("label",this.label),this.setAttribute("aria-label",this.label||this.placeholder||"")}#e=()=>{let t=this.#t.textContent||"";this.value=t,this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#i=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.flushPendingInput(),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#s=()=>{this.flushPendingInput(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#r=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,e)};focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(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.#i),this.#t.removeEventListener("blur",this.#s),this.#t.removeEventListener("paste",this.#r)),this.#t=null}};S("textarea-ui",ar);$();var lr=class extends M{static labelDeprecated=!1;static properties={...M.properties,checked:{type:Boolean,default:!1,reflect:!0},indeterminate:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>it`<span slot="box"></span>`;connected(){super.connected(),this.setAttribute("role","checkbox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){this.indeterminate?this.setAttribute("aria-checked","mixed"):this.setAttribute("aria-checked",String(this.checked)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.label&&this.setAttribute("aria-label",this.label),this.syncValue(this.checked?this.value||"on":"")}#t=()=>{this.disabled||(this.checked=!this.checked,this.indeterminate=!1,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}})))};#e=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#t())};disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("check-ui",lr);$();var hr=class extends M{static labelDeprecated=!1;static properties={...M.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>it`<span slot="dot"></span>`;connected(){super.connected(),this.setAttribute("role","radio"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){this.setAttribute("aria-checked",String(this.checked)),this.label&&this.setAttribute("aria-label",this.label),this.checked&&this.syncValue(this.value||"on")}#t=()=>{if(this.disabled||this.checked)return;let t=this.closest('fieldset, [role="radiogroup"]')||this.parentElement;if(t)for(let e of t.querySelectorAll(`radio-ui[name="${this.name}"]`))e!==this&&e.checked&&(e.checked=!1);this.checked=!0,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}}))};#e=t=>{if((t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#t()),t.key==="ArrowDown"||t.key==="ArrowRight"){t.preventDefault();let e=this.#i(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#i(-1);e&&(e.focus(),e.click())}};#i(t){let i=[...(this.closest('fieldset, [role="radiogroup"]')||this.parentElement)?.querySelectorAll(`radio-ui[name="${this.name}"]`)||[]],r=i.indexOf(this);return i[(r+t+i.length)%i.length]||null}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("radio-ui",hr);var cr=class extends M{static properties={...M.properties,checked:{type:Boolean,default:!1,reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},layout:{type:String,default:"default",reflect:!0}};static template=()=>null;connected(){super.connected(),this.setAttribute("role","radio"),this.setAttribute("tabindex","0"),this.#t(),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}render(){this.setAttribute("aria-checked",String(this.checked)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let t=this.querySelector(':scope > [slot="heading"]');t&&t.dataset.fromAttr==="true"&&(t.textContent=this.heading||"");let e=this.querySelector(':scope > [slot="description"]');e&&e.dataset.fromAttr==="true"&&(e.textContent=this.description||"");let i=this.querySelector(':scope > [slot="icon"]');i&&i.dataset.fromAttr==="true"&&i.setAttribute("name",this.icon||""),this.checked?this.syncValue(this.value||"on"):this.syncValue("")}#t(){if(this.heading&&!this.querySelector(':scope > [slot="heading"]')){let t=document.createElement("span");t.setAttribute("slot","heading"),t.dataset.fromAttr="true",t.textContent=this.heading,this.appendChild(t)}if(this.description&&!this.querySelector(':scope > [slot="description"]')){let t=document.createElement("span");t.setAttribute("slot","description"),t.dataset.fromAttr="true",t.textContent=this.description,this.appendChild(t)}if(this.icon&&!this.querySelector(':scope > [slot="icon"]')){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.dataset.fromAttr="true",t.setAttribute("name",this.icon),this.appendChild(t)}}#e=()=>{if(this.disabled||this.readonly||this.checked)return;let t=this.#s();if(t)for(let e of t.querySelectorAll(`option-card-ui[name="${this.name}"]`))e!==this&&e.checked&&(e.checked=!1);this.checked=!0,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}}))};#i=t=>{if(t.target===this){if(t.key===" "||t.key==="Enter"){t.preventDefault(),this.#e();return}if(t.key==="ArrowDown"||t.key==="ArrowRight"){t.preventDefault();let e=this.#r(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#r(-1);e&&(e.focus(),e.click())}}};#s(){return this.closest('fieldset, [role="radiogroup"]')||this.parentElement}#r(t){let i=[...this.#s()?.querySelectorAll(`option-card-ui[name="${this.name}"]`)||[]],r=i.indexOf(this);return r<0?null:i[(r+t+i.length)%i.length]||null}};S("option-card-ui",cr);$();var Ue=Object.freeze({AVAILABLE:"available",CONNECTED:"connected",ERROR:"error",PENDING:"pending",COMING_SOON:"coming-soon"}),GO=Object.freeze({available:{event:"press",emits:"connect",label:"Connect",variant:"primary",icon:""},connected:{event:"press",emits:"configure",label:"Configure",variant:"outline",icon:""},error:{event:"press",emits:"retry",label:"Retry",variant:"outline",icon:"arrow-clockwise"},pending:{event:"press",emits:"",label:"Connecting\u2026",variant:"outline",icon:""}}),KE=Object.freeze({connected:{variant:"success",text:"Connected",icon:"check"},error:{variant:"danger",text:"Error",icon:"warning-circle"},pending:{variant:"info",text:"Connecting\u2026",icon:""},"coming-soon":{variant:"muted",text:"Coming soon",icon:""}}),JE=Object.freeze({slack:"chat-circle",github:"git-branch",gitlab:"git-branch",linear:"kanban",stripe:"credit-card",zapier:"lightning",figma:"figma-logo",notion:"notion-logo",webhook:"lightning",discord:"discord-logo",google:"google-logo"}),tC="plug",ur=class extends x{static requiredIcons=["check","warning-circle","arrow-clockwise"];static properties={provider:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!1},logo:{type:String,default:"",reflect:!1},description:{type:String,default:"",reflect:!1},status:{type:String,default:"available",reflect:!0},"error-message":{type:String,default:"",attribute:"error-message"},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={body:'<div slot="body" data-integration-card-body></div>',logo:'<div slot="logo" data-integration-card-logo></div>',heading:'<div slot="heading" data-integration-card-heading></div>',desc:'<p slot="description" data-integration-card-description></p>',error:'<p slot="error" data-integration-card-error></p>',status:'<badge-ui slot="status" data-integration-card-status></badge-ui>',footer:'<footer slot="footer" data-integration-card-footer></footer>',button:'<button-ui slot="action" data-integration-card-action></button-ui>'};static template=()=>null;#t="";#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;connected(){this.setAttribute("role","group"),this.#e=this.ensure("body"),this.#i=this.ensure("logo"),this.#s=this.ensure("heading"),this.#r=this.ensure("desc"),this.#a=this.ensure("status"),this.#o=this.ensure("footer"),this.#i.parentElement!==this.#e&&this.#e.appendChild(this.#i),this.#s.parentElement!==this.#e&&this.#e.appendChild(this.#s),this.#a.parentElement!==this.#e&&this.#e.appendChild(this.#a),this.#s.id?this.#t=this.#s.id:(this.#t=`integration-card-heading-${Math.random().toString(36).slice(2,9)}`,this.#s.id=this.#t),this.setAttribute("aria-labelledby",this.#t),this.addEventListener("press",this.#m),this.addEventListener("action",this.#g)}disconnected(){this.removeEventListener("press",this.#m),this.removeEventListener("action",this.#g),this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=null}render(){if(!this.#s)return;let t=this.#c();this.name&&this.#s.textContent!==this.name&&(this.#s.textContent=this.name),this.#h()?this.#r.parentElement===this&&this.#r.remove():(this.#r.parentElement||this.appendChild(this.#r),this.description?(this.#r.textContent!==this.description&&(this.#r.textContent=this.description),this.#r.hidden=!1):(this.#r.textContent="",this.#r.hidden=!0)),this.#u(),this.#d(t),this.#f(t),this.#p(t)}#c(){let t=(this.status||"").trim()||Ue.AVAILABLE;return Object.values(Ue).includes(t)?t:Ue.AVAILABLE}#h(){for(let t of this.children)if(t!==this.#e&&t!==this.#r&&t!==this.#n&&t!==this.#o&&!(t.getAttribute&&t.getAttribute("slot")==="actions")&&!(t.dataset&&(t.dataset.integrationCardBody!==void 0||t.dataset.integrationCardDescription!==void 0||t.dataset.integrationCardError!==void 0||t.dataset.integrationCardFooter!==void 0)))return!0;return!1}#u(){if(!this.#i)return;let t=(this.logo||"").trim();if(t.startsWith("{{p:"))return;let e=(this.provider||"").trim().toLowerCase(),i=t||JE[e]||(e?tC:"");if(!i){this.#i.replaceChildren(),this.#i.hidden=!0;return}if(this.#i.hidden=!1,i.includes("/")){let o=this.#i.querySelector(":scope > img");if(o&&o.getAttribute("src")===i){o.setAttribute("alt",`${this.name||this.provider||"Integration"} logo`);return}this.#i.replaceChildren(),o=document.createElement("img"),o.setAttribute("src",i),o.setAttribute("alt",`${this.name||this.provider||"Integration"} logo`),o.setAttribute("data-integration-logo",""),o.setAttribute("loading","lazy"),o.setAttribute("decoding","async"),this.#i.appendChild(o);return}let n=this.#i.querySelector(":scope > icon-ui");n&&n.getAttribute("name")===i||(this.#i.replaceChildren(),n=document.createElement("icon-ui"),n.setAttribute("name",i),n.setAttribute("aria-hidden","true"),this.#i.appendChild(n))}#d(t){if(!this.#a)return;let e=KE[t];if(!e){this.#a.hidden=!0,this.#a.removeAttribute("aria-label");return}this.#a.hidden=!1,this.#a.setAttribute("variant",e.variant),this.#a.setAttribute("text",e.text),this.#a.setAttribute("size","sm"),e.icon?this.#a.setAttribute("icon",e.icon):this.#a.removeAttribute("icon"),this.#a.setAttribute("aria-label",e.text)}#f(t){let e=(this["error-message"]||this.getAttribute("error-message")||"").trim();t===Ue.ERROR&&e?(this.#n||(this.#n=this.ensure("error")),this.#n.parentElement||(this.#r?.parentElement===this?this.#r.after(this.#n):this.#o?.parentElement===this?this.insertBefore(this.#n,this.#o):this.appendChild(this.#n)),this.#n.textContent!==e&&(this.#n.textContent=e),this.#n.hidden=!1,this.#n.setAttribute("role","status")):this.#n&&(this.#n.hidden=!0,this.#n.textContent="")}#p(t){if(t===Ue.COMING_SOON){this.drop("button"),this.#l=null;return}let e=GO[t];if(!e){this.drop("button"),this.#l=null;return}this.#l||(this.#l=this.ensure("button")),this.#l.parentElement!==this.#o&&this.#o.insertBefore(this.#l,this.#o.firstChild),this.#l.setAttribute("text",e.label),this.#l.setAttribute("variant",e.variant),this.#l.setAttribute("size","sm"),e.icon?this.#l.setAttribute("icon",e.icon):this.#l.removeAttribute("icon"),t===Ue.CONNECTED?this.#l.setAttribute("aria-pressed","true"):t===Ue.AVAILABLE?this.#l.setAttribute("aria-pressed","false"):this.#l.removeAttribute("aria-pressed");let i={available:"Connect to",connected:"Configure",error:"Retry connecting",pending:"Connecting to"}[t]||e.label,r=this.name||this.provider||"integration";this.#l.setAttribute("aria-label",`${i} ${r}`),t===Ue.PENDING||this.disabled?this.#l.setAttribute("disabled",""):this.#l.removeAttribute("disabled")}#m=t=>{if(!this.#l||t.target!==this.#l&&!t.composedPath?.().includes(this.#l))return;if(this.disabled){t.stopPropagation();return}let e=this.#c();if(e===Ue.PENDING||e===Ue.COMING_SOON){t.stopPropagation();return}let i=GO[e];!i||!i.emits||this.dispatchEvent(new CustomEvent(i.emits,{bubbles:!0,detail:{provider:this.provider}}))};#g=t=>{let e=t.detail?.action||t.target?.getAttribute?.("action");if(e&&(e==="disconnect"||e==="reauth"||e==="re-authenticate")){let i=e==="disconnect"?"disconnect":"reauth";this.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:{provider:this.provider}}))}}};S("integration-card-ui",ur);$();var dr=class s extends M{static labelDeprecated=!1;static properties={...M.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0}};static#t=0;static template=t=>{let e=t.hint?`switch-hint-${++s.#t}`:"";return e?t.setAttribute("aria-describedby",e):t.removeAttribute("aria-describedby"),it`
97
+ `),this.#t=this.querySelector('[slot="text"]'),this.value&&(this.#t.textContent=this.value),this.#t&&(this.#t.addEventListener("input",this.#e),this.#t.addEventListener("keydown",this.#i),this.#t.addEventListener("blur",this.#s),this.#t.addEventListener("paste",this.#r))}render(){if(!this.#t)return;this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let t=this.value||"";this.#t.textContent!==t&&(this.#t.textContent=t,this.#t.toggleAttribute("data-empty",!t));let e=this.querySelector('[slot="label"]');e&&this.label&&e.setAttribute("label",this.label),this.setAttribute("aria-label",this.label||this.placeholder||"")}#e=()=>{let t=this.#t.textContent||"";this.value=t,this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#i=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.flushPendingInput(),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#s=()=>{this.flushPendingInput(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#r=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,e)};focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(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.#i),this.#t.removeEventListener("blur",this.#s),this.#t.removeEventListener("paste",this.#r)),this.#t=null}};S("textarea-ui",ar);$();var lr=class extends M{static labelDeprecated=!1;static properties={...M.properties,checked:{type:Boolean,default:!1,reflect:!0},indeterminate:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>it`<span slot="box"></span>`;connected(){super.connected(),this.setAttribute("role","checkbox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){this.indeterminate?this.setAttribute("aria-checked","mixed"):this.setAttribute("aria-checked",String(this.checked)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.label&&this.setAttribute("aria-label",this.label),this.syncValue(this.checked?this.value||"on":"")}#t=()=>{this.disabled||(this.checked=!this.checked,this.indeterminate=!1,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}})))};#e=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#t())};disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("check-ui",lr);$();var hr=class extends M{static labelDeprecated=!1;static properties={...M.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>it`<span slot="dot"></span>`;connected(){super.connected(),this.setAttribute("role","radio"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){this.setAttribute("aria-checked",String(this.checked)),this.label&&this.setAttribute("aria-label",this.label),this.checked&&this.syncValue(this.value||"on")}#t=()=>{if(this.disabled||this.checked)return;let t=this.closest('fieldset, [role="radiogroup"]')||this.parentElement;if(t)for(let e of t.querySelectorAll(`radio-ui[name="${this.name}"]`))e!==this&&e.checked&&(e.checked=!1);this.checked=!0,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}}))};#e=t=>{if((t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#t()),t.key==="ArrowDown"||t.key==="ArrowRight"){t.preventDefault();let e=this.#i(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#i(-1);e&&(e.focus(),e.click())}};#i(t){let i=[...(this.closest('fieldset, [role="radiogroup"]')||this.parentElement)?.querySelectorAll(`radio-ui[name="${this.name}"]`)||[]],r=i.indexOf(this);return i[(r+t+i.length)%i.length]||null}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("radio-ui",hr);var cr=class extends M{static properties={...M.properties,checked:{type:Boolean,default:!1,reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},layout:{type:String,default:"default",reflect:!0}};static template=()=>null;connected(){super.connected(),this.setAttribute("role","radio"),this.setAttribute("tabindex","0"),this.#t(),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}render(){this.setAttribute("aria-checked",String(this.checked)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let t=this.querySelector(':scope > [slot="heading"]');t&&t.dataset.fromAttr==="true"&&(t.textContent=this.heading||"");let e=this.querySelector(':scope > [slot="description"]');e&&e.dataset.fromAttr==="true"&&(e.textContent=this.description||"");let i=this.querySelector(':scope > [slot="icon"]');i&&i.dataset.fromAttr==="true"&&i.setAttribute("name",this.icon||""),this.checked?this.syncValue(this.value||"on"):this.syncValue("")}#t(){if(this.heading&&!this.querySelector(':scope > [slot="heading"]')){let t=document.createElement("span");t.setAttribute("slot","heading"),t.dataset.fromAttr="true",t.textContent=this.heading,this.appendChild(t)}if(this.description&&!this.querySelector(':scope > [slot="description"]')){let t=document.createElement("span");t.setAttribute("slot","description"),t.dataset.fromAttr="true",t.textContent=this.description,this.appendChild(t)}if(this.icon&&!this.querySelector(':scope > [slot="icon"]')){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.dataset.fromAttr="true",t.setAttribute("name",this.icon),this.appendChild(t)}}#e=()=>{if(this.disabled||this.readonly||this.checked)return;let t=this.#s();if(t)for(let e of t.querySelectorAll(`option-card-ui[name="${this.name}"]`))e!==this&&e.checked&&(e.checked=!1);this.checked=!0,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}}))};#i=t=>{if(t.target===this){if(t.key===" "||t.key==="Enter"){t.preventDefault(),this.#e();return}if(t.key==="ArrowDown"||t.key==="ArrowRight"){t.preventDefault();let e=this.#r(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#r(-1);e&&(e.focus(),e.click())}}};#s(){return this.closest('fieldset, [role="radiogroup"]')||this.parentElement}#r(t){let i=[...this.#s()?.querySelectorAll(`option-card-ui[name="${this.name}"]`)||[]],r=i.indexOf(this);return r<0?null:i[(r+t+i.length)%i.length]||null}};S("option-card-ui",cr);$();var Ue=Object.freeze({AVAILABLE:"available",CONNECTED:"connected",ERROR:"error",PENDING:"pending",COMING_SOON:"coming-soon"}),GO=Object.freeze({available:{event:"press",emits:"connect",label:"Connect",variant:"primary",icon:""},connected:{event:"press",emits:"configure",label:"Configure",variant:"outline",icon:""},error:{event:"press",emits:"retry",label:"Retry",variant:"outline",icon:"arrow-clockwise"},pending:{event:"press",emits:"",label:"Connecting\u2026",variant:"outline",icon:""}}),KE=Object.freeze({connected:{variant:"success",text:"Connected",icon:"check"},error:{variant:"danger",text:"Error",icon:"warning-circle"},pending:{variant:"info",text:"Connecting\u2026",icon:""},"coming-soon":{variant:"muted",text:"Coming soon",icon:""}}),JE=Object.freeze({slack:"chat-circle",github:"git-branch",gitlab:"git-branch",linear:"kanban",stripe:"credit-card",zapier:"lightning",figma:"figma-logo",notion:"notion-logo",webhook:"lightning",discord:"discord-logo",google:"google-logo"}),tC="plug",ur=class extends x{static requiredIcons=["check","warning-circle","arrow-clockwise"];static properties={provider:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!1},logo:{type:String,default:"",reflect:!1},description:{type:String,default:"",reflect:!1},status:{type:String,default:"available",reflect:!0},"error-message":{type:String,default:"",attribute:"error-message"},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={body:'<div slot="body" data-integration-card-body></div>',logo:'<div slot="logo" data-integration-card-logo></div>',heading:'<div slot="heading" data-integration-card-heading></div>',desc:'<p slot="description" data-integration-card-description></p>',error:'<p slot="error" data-integration-card-error></p>',status:'<badge-ui slot="status" data-integration-card-status></badge-ui>',footer:'<footer slot="footer" data-integration-card-footer></footer>',button:'<button-ui slot="action" data-integration-card-action></button-ui>'};static template=()=>null;#t="";#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;connected(){this.setAttribute("role","group"),this.#e=this.ensure("body"),this.#i=this.ensure("logo"),this.#s=this.ensure("heading"),this.#r=this.ensure("desc"),this.#a=this.ensure("status"),this.#o=this.ensure("footer"),this.#i.parentElement!==this.#e&&this.#e.appendChild(this.#i),this.#s.parentElement!==this.#e&&this.#e.appendChild(this.#s),this.#a.parentElement!==this.#e&&this.#e.appendChild(this.#a),this.#s.id?this.#t=this.#s.id:(this.#t=`integration-card-heading-${Math.random().toString(36).slice(2,9)}`,this.#s.id=this.#t),this.setAttribute("aria-labelledby",this.#t),this.addEventListener("press",this.#m),this.addEventListener("action",this.#g)}disconnected(){this.removeEventListener("press",this.#m),this.removeEventListener("action",this.#g),this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=null}render(){if(!this.#s)return;let t=this.#c();this.name&&this.#s.textContent!==this.name&&(this.#s.textContent=this.name),this.#h()?this.#r.parentElement===this&&this.#r.remove():(this.#r.parentElement||this.appendChild(this.#r),this.description?(this.#r.textContent!==this.description&&(this.#r.textContent=this.description),this.#r.hidden=!1):(this.#r.textContent="",this.#r.hidden=!0)),this.#d(),this.#u(t),this.#f(t),this.#p(t)}#c(){let t=(this.status||"").trim()||Ue.AVAILABLE;return Object.values(Ue).includes(t)?t:Ue.AVAILABLE}#h(){for(let t of this.children)if(t!==this.#e&&t!==this.#r&&t!==this.#n&&t!==this.#o&&!(t.getAttribute&&t.getAttribute("slot")==="actions")&&!(t.dataset&&(t.dataset.integrationCardBody!==void 0||t.dataset.integrationCardDescription!==void 0||t.dataset.integrationCardError!==void 0||t.dataset.integrationCardFooter!==void 0)))return!0;return!1}#d(){if(!this.#i)return;let t=(this.logo||"").trim();if(t.startsWith("{{p:"))return;let e=(this.provider||"").trim().toLowerCase(),i=t||JE[e]||(e?tC:"");if(!i){this.#i.replaceChildren(),this.#i.hidden=!0;return}if(this.#i.hidden=!1,i.includes("/")){let o=this.#i.querySelector(":scope > img");if(o&&o.getAttribute("src")===i){o.setAttribute("alt",`${this.name||this.provider||"Integration"} logo`);return}this.#i.replaceChildren(),o=document.createElement("img"),o.setAttribute("src",i),o.setAttribute("alt",`${this.name||this.provider||"Integration"} logo`),o.setAttribute("data-integration-logo",""),o.setAttribute("loading","lazy"),o.setAttribute("decoding","async"),this.#i.appendChild(o);return}let n=this.#i.querySelector(":scope > icon-ui");n&&n.getAttribute("name")===i||(this.#i.replaceChildren(),n=document.createElement("icon-ui"),n.setAttribute("name",i),n.setAttribute("aria-hidden","true"),this.#i.appendChild(n))}#u(t){if(!this.#a)return;let e=KE[t];if(!e){this.#a.hidden=!0,this.#a.removeAttribute("aria-label");return}this.#a.hidden=!1,this.#a.setAttribute("variant",e.variant),this.#a.setAttribute("text",e.text),this.#a.setAttribute("size","sm"),e.icon?this.#a.setAttribute("icon",e.icon):this.#a.removeAttribute("icon"),this.#a.setAttribute("aria-label",e.text)}#f(t){let e=(this["error-message"]||this.getAttribute("error-message")||"").trim();t===Ue.ERROR&&e?(this.#n||(this.#n=this.ensure("error")),this.#n.parentElement||(this.#r?.parentElement===this?this.#r.after(this.#n):this.#o?.parentElement===this?this.insertBefore(this.#n,this.#o):this.appendChild(this.#n)),this.#n.textContent!==e&&(this.#n.textContent=e),this.#n.hidden=!1,this.#n.setAttribute("role","status")):this.#n&&(this.#n.hidden=!0,this.#n.textContent="")}#p(t){if(t===Ue.COMING_SOON){this.drop("button"),this.#l=null;return}let e=GO[t];if(!e){this.drop("button"),this.#l=null;return}this.#l||(this.#l=this.ensure("button")),this.#l.parentElement!==this.#o&&this.#o.insertBefore(this.#l,this.#o.firstChild),this.#l.setAttribute("text",e.label),this.#l.setAttribute("variant",e.variant),this.#l.setAttribute("size","sm"),e.icon?this.#l.setAttribute("icon",e.icon):this.#l.removeAttribute("icon"),t===Ue.CONNECTED?this.#l.setAttribute("aria-pressed","true"):t===Ue.AVAILABLE?this.#l.setAttribute("aria-pressed","false"):this.#l.removeAttribute("aria-pressed");let i={available:"Connect to",connected:"Configure",error:"Retry connecting",pending:"Connecting to"}[t]||e.label,r=this.name||this.provider||"integration";this.#l.setAttribute("aria-label",`${i} ${r}`),t===Ue.PENDING||this.disabled?this.#l.setAttribute("disabled",""):this.#l.removeAttribute("disabled")}#m=t=>{if(!this.#l||t.target!==this.#l&&!t.composedPath?.().includes(this.#l))return;if(this.disabled){t.stopPropagation();return}let e=this.#c();if(e===Ue.PENDING||e===Ue.COMING_SOON){t.stopPropagation();return}let i=GO[e];!i||!i.emits||this.dispatchEvent(new CustomEvent(i.emits,{bubbles:!0,detail:{provider:this.provider}}))};#g=t=>{let e=t.detail?.action||t.target?.getAttribute?.("action");if(e&&(e==="disconnect"||e==="reauth"||e==="re-authenticate")){let i=e==="disconnect"?"disconnect":"reauth";this.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:{provider:this.provider}}))}}};S("integration-card-ui",ur);$();var dr=class s extends M{static labelDeprecated=!1;static properties={...M.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0}};static#t=0;static template=t=>{let e=t.hint?`switch-hint-${++s.#t}`:"";return e?t.setAttribute("aria-describedby",e):t.removeAttribute("aria-describedby"),it`
98
98
  <span slot="track"><span slot="thumb"></span></span>
99
99
  ${t.label?it`<span slot="label">${t.label}</span>`:null}
100
100
  ${t.hint?it`<span slot="hint" id=${e}>${t.hint}</span>`:null}
101
- `};connected(){super.connected(),this.setAttribute("role","switch"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}render(){this.setAttribute("aria-checked",String(this.checked)),this.syncValue(this.checked?this.value||"on":"")}#e=()=>{this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}})))};#i=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#e())};disconnected(){super.disconnected(),this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}};S("switch-ui",dr);var fr=class s extends M{static labelDeprecated=!1;static properties={...M.properties,value:{type:Number,default:50,reflect:!0},dual:{type:Boolean,default:!1,reflect:!0},lowerValue:{type:Number,default:0,reflect:!0,attribute:"lower-value"},upperValue:{type:Number,default:100,reflect:!0,attribute:"upper-value"},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;static#t=0;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=null;#o=0;#l=NaN;#c=NaN;#h(t){let e=this.max-this.min;return e>0?(t-this.min)/e:0}#u(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}connected(){super.connected();let t=this.dual;if(this.setAttribute("role",t?"group":"slider"),this.setAttribute("tabindex","0"),t?(this.removeAttribute("aria-valuemin"),this.removeAttribute("aria-valuemax")):(this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max)),this.label&&this.setAttribute("aria-label",this.label),!this.querySelector('[slot="track"]')){let e=this.hint?`slider-hint-${++s.#t}`:"",i=this.label?`${this.label} lower bound`:"Lower bound",r=this.label?`${this.label} upper bound`:"Upper bound",n=t?`<span slot="value-lower">${this.#u(this.lowerValue)}</span><span slot="value-sep" aria-hidden="true">\u2013</span><span slot="value-upper">${this.#u(this.upperValue)}</span>`:`<span slot="value">${this.#u(this.value)}</span>`,o=t?`<div slot="thumb" data-thumb="lower" tabindex="0" role="slider" aria-label="${i}" aria-valuemin="${this.min}" aria-valuemax="${this.max}"></div><div slot="thumb" data-thumb="upper" tabindex="0" role="slider" aria-label="${r}" aria-valuemin="${this.min}" aria-valuemax="${this.max}"></div>`:'<div slot="thumb" tabindex="0"></div>';this.innerHTML=`
101
+ `};connected(){super.connected(),this.setAttribute("role","switch"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}render(){this.setAttribute("aria-checked",String(this.checked)),this.syncValue(this.checked?this.value||"on":"")}#e=()=>{this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}})))};#i=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#e())};disconnected(){super.disconnected(),this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}};S("switch-ui",dr);var fr=class s extends M{static labelDeprecated=!1;static properties={...M.properties,value:{type:Number,default:50,reflect:!0},dual:{type:Boolean,default:!1,reflect:!0},lowerValue:{type:Number,default:0,reflect:!0,attribute:"lower-value"},upperValue:{type:Number,default:100,reflect:!0,attribute:"upper-value"},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;static#t=0;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=null;#o=0;#l=NaN;#c=NaN;#h(t){let e=this.max-this.min;return e>0?(t-this.min)/e:0}#d(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}connected(){super.connected();let t=this.dual;if(this.setAttribute("role",t?"group":"slider"),this.setAttribute("tabindex","0"),t?(this.removeAttribute("aria-valuemin"),this.removeAttribute("aria-valuemax")):(this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max)),this.label&&this.setAttribute("aria-label",this.label),!this.querySelector('[slot="track"]')){let e=this.hint?`slider-hint-${++s.#t}`:"",i=this.label?`${this.label} lower bound`:"Lower bound",r=this.label?`${this.label} upper bound`:"Upper bound",n=t?`<span slot="value-lower">${this.#d(this.lowerValue)}</span><span slot="value-sep" aria-hidden="true">\u2013</span><span slot="value-upper">${this.#d(this.upperValue)}</span>`:`<span slot="value">${this.#d(this.value)}</span>`,o=t?`<div slot="thumb" data-thumb="lower" tabindex="0" role="slider" aria-label="${i}" aria-valuemin="${this.min}" aria-valuemax="${this.max}"></div><div slot="thumb" data-thumb="upper" tabindex="0" role="slider" aria-label="${r}" aria-valuemin="${this.min}" aria-valuemax="${this.max}"></div>`:'<div slot="thumb" tabindex="0"></div>';this.innerHTML=`
102
102
  <div slot="header">
103
103
  ${this.label?`<span slot="label">${this.label}</span>`:""}
104
104
  <span slot="readout">
@@ -111,12 +111,12 @@ ${i.join(`
111
111
  ${o}
112
112
  </div>
113
113
  ${this.hint?`<span slot="hint" id="${e}">${this.hint}</span>`:""}
114
- `,this.hint&&this.setAttribute("aria-describedby",e)}this.#e=this.querySelector('[slot="track"]'),t?(this.#s=this.querySelector('[slot="thumb"][data-thumb="lower"]'),this.#r=this.querySelector('[slot="thumb"][data-thumb="upper"]'),this.#s?.addEventListener("pointerdown",this.#y),this.#r?.addEventListener("pointerdown",this.#y)):(this.#i=this.querySelector('[slot="thumb"]'),this.#i?.addEventListener("pointerdown",this.#y)),this.#e?.addEventListener("click",this.#S),this.addEventListener("keydown",this.#x)}render(){if(!this.#e)return;if(typeof this.value=="function"||typeof this.lowerValue=="function"||typeof this.upperValue=="function"){console.warn(`[slider-ui] .value / .lowerValue / .upperValue received a function. Did you mean:
114
+ `,this.hint&&this.setAttribute("aria-describedby",e)}this.#e=this.querySelector('[slot="track"]'),t?(this.#s=this.querySelector('[slot="thumb"][data-thumb="lower"]'),this.#r=this.querySelector('[slot="thumb"][data-thumb="upper"]'),this.#s?.addEventListener("pointerdown",this.#O),this.#r?.addEventListener("pointerdown",this.#O)):(this.#i=this.querySelector('[slot="thumb"]'),this.#i?.addEventListener("pointerdown",this.#O)),this.#e?.addEventListener("click",this.#w),this.addEventListener("keydown",this.#x)}render(){if(!this.#e)return;if(typeof this.value=="function"||typeof this.lowerValue=="function"||typeof this.upperValue=="function"){console.warn(`[slider-ui] .value / .lowerValue / .upperValue received a function. Did you mean:
115
115
  .value=\${fn()} \u2190 call the function to get the current value
116
116
  .value=\${signal.value} \u2190 read the signal's current value
117
117
  Functions are not auto-invoked at render time; the slider reads
118
118
  .value synchronously. See USAGE.md "Reactive binding" for the
119
- parent-template-re-read pattern that works across frameworks.`);return}if(this.dual){if(this.lowerValue>this.upperValue){let a=!Number.isNaN(this.#l)&&this.lowerValue!==this.#l;!Number.isNaN(this.#c)&&this.upperValue!==this.#c&&!a?this.upperValue=this.lowerValue:this.lowerValue=this.upperValue}this.#l=this.lowerValue,this.#c=this.upperValue;let i=this.#h(this.lowerValue),r=this.#h(this.upperValue);this.style.setProperty("--slider-pct-lower",String(i)),this.style.setProperty("--slider-pct-upper",String(r));let n=this.querySelector('[slot="value-lower"]'),o=this.querySelector('[slot="value-upper"]');n&&(n.textContent=this.#u(this.lowerValue)),o&&(o.textContent=this.#u(this.upperValue)),this.#s&&(this.#s.setAttribute("aria-valuenow",this.lowerValue),this.#s.setAttribute("aria-valuetext",`${this.#u(this.lowerValue)}${this.suffix?" "+this.suffix:""}`)),this.#r&&(this.#r.setAttribute("aria-valuenow",this.upperValue),this.#r.setAttribute("aria-valuetext",`${this.#u(this.upperValue)}${this.suffix?" "+this.suffix:""}`)),this.syncValue(`${this.lowerValue},${this.upperValue}`)}else{let i=this.#h(this.value);this.style.setProperty("--slider-pct",String(i));let r=this.querySelector('[slot="value"]');r&&(r.textContent=this.#u(this.value)),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.#u(this.value)}${this.suffix?" "+this.suffix:""}`),this.syncValue(String(this.value))}let t=this.querySelector('[slot="label"]');if(t)t.textContent=this.label;else if(this.label){let i=this.querySelector('[slot="header"]');if(i){let r=document.createElement("span");r.slot="label",r.textContent=this.label,i.prepend(r)}}this.label&&this.setAttribute("aria-label",this.label);let e=this.querySelector('[slot="suffix"]');e&&(e.textContent=this.suffix)}#d(t,e=null){let i=this.#i||this.#s||this.#r;if(!this.#e||!i)return this.min;let r=this.#e.getBoundingClientRect(),n=i.getBoundingClientRect().width,o=r.width,a,l;if(this.dual?(a=o-2*n,l=e==="upper"?1.5*n:.5*n):(a=o-n,l=.5*n),a<=0)return this.min;let h=t-r.left,c=Math.max(0,Math.min(1,(h-l)/a)),u=this.min+c*(this.max-this.min);return this.#p(u)}#f(t){if(!this.#e)return 0;let e=this.#i||this.#s||this.#r;if(!e)return 0;let i=this.#e.getBoundingClientRect(),r=e.getBoundingClientRect().width,n=i.width;if(this.dual){let o=n-2*r,a=t==="upper"?this.#h(this.upperValue):this.#h(this.lowerValue),l=t==="upper"?1.5*r:.5*r;return i.left+l+a*o}else return i.left+.5*r+this.#h(this.value)*(n-r)}#p(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#m(t){t!==this.value&&(this.value=t,this.scheduleThrottledInput())}#g(t){let e=Math.min(Math.max(t,this.min),this.upperValue);e!==this.lowerValue&&(this.lowerValue=e,this.scheduleThrottledInput())}#b(t){let e=Math.max(Math.min(t,this.max),this.lowerValue);e!==this.upperValue&&(this.upperValue=e,this.scheduleThrottledInput())}#O(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#y=t=>{if(this.disabled)return;t.preventDefault(),this.#n=!0,this.setAttribute("data-dragging","");let e;if(this.dual){let i=t.currentTarget?.dataset?.thumb;this.#a=i==="upper"?"upper":"lower",e=this.#a==="lower"?this.#s:this.#r,e?.setAttribute("data-active","")}else e=this.#i;if(this.#e&&e){let i=this.dual?this.#a:null;this.#o=t.clientX-this.#f(i)}else this.#o=0;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.#w),e.addEventListener("pointerup",this.#v)};#w=t=>{if(!this.#n)return;let e=t.clientX-this.#o;if(this.dual){let i=this.#d(e,this.#a);this.#a==="lower"?this.#g(i):this.#b(i)}else this.#m(this.#d(e))};#v=t=>{this.#n=!1,this.#o=0,this.removeAttribute("data-dragging");let e=this.dual?this.#a==="lower"?this.#s:this.#r:this.#i;e?.releasePointerCapture(t.pointerId),e?.removeEventListener("pointermove",this.#w),e?.removeEventListener("pointerup",this.#v),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#O(),this.#a=null};#S=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#r)return;let e=Math.abs(t.clientX-this.#f("lower")),i=Math.abs(t.clientX-this.#f("upper"));e<=i?this.#g(this.#d(t.clientX,"lower")):this.#b(this.#d(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#d(t.clientX))}this.flushPendingInput(),this.#O()}};#x=t=>{if(this.disabled)return;let e=0,i=null;switch(t.key){case"ArrowRight":case"ArrowUp":e=this.step;break;case"ArrowLeft":case"ArrowDown":e=-this.step;break;case"Home":i=this.min;break;case"End":i=this.max;break;case"PageUp":e=this.step*10;break;case"PageDown":e=-this.step*10;break;default:return}if(t.preventDefault(),this.dual){let n=this.ownerDocument?.activeElement===this.#r?"upper":"lower",o=n==="lower"?this.lowerValue:this.upperValue,a=i!==null?i:o+e;a=this.#p(a),n==="lower"?this.#g(a):this.#b(a)}else{let r=i!==null?i:this.value+e;this.#m(this.#p(r))}this.flushPendingInput(),this.#O()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#y),this.#s?.removeEventListener("pointerdown",this.#y),this.#r?.removeEventListener("pointerdown",this.#y),this.#e?.removeEventListener("click",this.#S),this.removeEventListener("keydown",this.#x),this.#e=null,this.#i=null,this.#s=null,this.#r=null}};S("slider-ui",fr);var eC=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,iC=0;function ct(s,t,e={}){let{placement:i="bottom-start",gap:r=4,matchWidth:n=!1}=e;return eC?sC(s,t,{placement:i,gap:r,matchWidth:n}):oC(s,t,{placement:i,gap:r,matchWidth:n})}function sC(s,t,{placement:e,gap:i,matchWidth:r}){let n=`--a-anchor-${++iC}`,o=s.style.anchorName,a={position:t.style.position,positionAnchor:t.style.positionAnchor,positionArea:t.style.positionArea,positionTryFallbacks:t.style.positionTryFallbacks,margin:t.style.margin,width:t.style.width,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,overflowY:t.style.overflowY,top:t.style.top,left:t.style.left};return s.style.anchorName=n,t.style.position="fixed",t.style.positionAnchor=n,t.style.positionArea=nC(e),t.style.margin=rC(e,i),t.style.positionTryFallbacks="flip-block, flip-inline, flip-block flip-inline",t.style.width=r?`anchor-size(${n} width)`:"max-content",t.style.maxWidth="min(calc(100vw - 1rem), var(--popover-max-width, 32rem))",t.style.maxHeight="calc(100vh - 3rem)",t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName=o;for(let[l,h]of Object.entries(a))t.style[l]=h}}function rC(s,t){return s.startsWith("bottom")?`${t}px 0 0 0`:s.startsWith("top")?`0 0 ${t}px 0`:s.startsWith("left")?`0 ${t}px 0 0`:s.startsWith("right")?`0 0 0 ${t}px`:`${t}px`}function nC(s){switch(s){case"bottom":return"bottom span-all";case"bottom-start":return"bottom span-right";case"bottom-end":return"bottom span-left";case"top":return"top span-all";case"top-start":return"top span-right";case"top-end":return"top span-left";case"left":return"left span-all";case"left-start":return"left span-bottom";case"left-end":return"left span-top";case"right":return"right span-all";case"right-start":return"right span-bottom";case"right-end":return"right span-top";default:return"bottom span-right"}}function oC(s,t,{placement:e,gap:i,matchWidth:r}){function n(){if(!s||!t)return;let a=s.getBoundingClientRect(),l=t.getBoundingClientRect(),h=window.innerWidth,c=window.innerHeight,u=e;u.startsWith("bottom")&&a.bottom+i+l.height>c&&a.top-i-l.height>0?u=u.replace("bottom","top"):u.startsWith("top")&&a.top-i-l.height<0&&a.bottom+i+l.height<c&&(u=u.replace("top","bottom"));let d,f;u.startsWith("top")?d=a.top-l.height-i:u.startsWith("bottom")?d=a.bottom+i:u.startsWith("left")?(f=a.left-l.width-i,u==="left-start"?d=a.top:u==="left-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2):u.startsWith("right")&&(f=a.right+i,u==="right-start"?d=a.top:u==="right-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2),f===void 0&&(u.endsWith("-start")?f=a.left:u.endsWith("-end")?f=a.right-l.width:f=a.left+(a.width-l.width)/2),f+l.width>h-i&&(f=a.right-l.width),f<i&&(f=a.left),d=Math.max(i,Math.min(d,c-l.height-i)),f=Math.max(i,Math.min(f,h-l.width-i)),t.style.position="fixed",t.style.top=`${d}px`,t.style.left=`${f}px`,r&&(t.style.width=`${a.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{n(),t.style.opacity=""});let o=aC(s);for(let a of o)a.addEventListener("scroll",n,{passive:!0});return window.addEventListener("resize",n,{passive:!0}),()=>{for(let a of o)a.removeEventListener("scroll",n);window.removeEventListener("resize",n)}}function aC(s){let t=[document],e=s?.parentElement;for(;e;){let i=getComputedStyle(e);/auto|scroll/.test(i.overflow+i.overflowX+i.overflowY)&&t.push(e),e=e.parentElement}return t}Ct();function Dt(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var pr=class s extends M{static labelDeprecated=!1;static requiredIcons=["caret-up-down","check","x","magnifying-glass"];static#t=new WeakSet;static properties={...M.properties,placeholder:{type:String,default:"Select...",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},searchable:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},divider:{type:Boolean,default:!1,reflect:!0},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:0,reflect:!0},selectAll:{type:Boolean,default:!1,reflect:!0,attribute:"select-all"},clearable:{type:Boolean,default:!1,reflect:!0}};static#e=0;static template=()=>null;#i=[];#s=!1;#r=null;#n=null;#a="";#o=null;#l=null;#c=()=>{this.disabled||(this.open=!0)};#h=t=>{t.stopPropagation(),this.disabled||(this.open=!0)};#u=t=>{let e=t.currentTarget;t.stopPropagation();let i=e.__adiaOption;if(i&&!i.disabled){if(i.action){this.open=!1,this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{action:i.action}}));return}if(this.multiple){this.toggle(i.value);return}this.value=i.value,this.open=!1,this.#a="",this.syncValue(i.value),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}};syncValue(t){if(!this.multiple)return super.syncValue(t);let e=t??this.value??"";this.internals.setFormValue(e);let i=String(e).split(",").map(r=>r.trim()).filter(Boolean);if(this.min>0&&i.length<this.min){this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please select at least ${this.min}.`,this);return}if(this.max>0&&i.length>this.max){this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-max")||`Please select no more than ${this.max}.`,this);return}if(this.required&&i.length===0){this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this);return}this.internals.setValidity({})}#d(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#f(t){let e=new Set,i=[];for(let r of t){if(r==null||r==="")continue;let n=String(r);e.has(n)||(e.add(n),i.push(n))}return i.join(",")}toggle(t){if(!this.multiple){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}let e=this.#d(),i=e.indexOf(String(t)),r=e.slice(),n=[],o=[];if(i>=0)e.splice(i,1),o=[String(t)];else{if(this.max>0&&e.length>=this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:r,reason:"max"}}));return}e.push(String(t)),n=[String(t)]}let a=this.#f(e);this.value=a,this.syncValue(a),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e,added:n,removed:o}}))}selectAllOptions(){if(!this.multiple)return;let t=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null),e=this.#f(t.map(o=>o.value));if(e===this.value)return;let i=this.#d();this.value=e,this.syncValue(e),this.render();let r=this.#d(),n=r.filter(o=>!i.includes(o));this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:n,removed:[]}}))}clear(){if(!this.multiple){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:""}}));return}let t=this.#d();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#p(){let t=this.#d();if(t.length===0)return;let e=t.pop(),i=this.#f(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#m=t=>{if(!this.multiple)return;let e=t.target;if(!e||e.tagName!=="TAG-UI")return;let i=e.dataset.chipValue;if(!i)return;t.stopPropagation();let r=this.#d().filter(o=>o!==i),n=this.#f(r);this.value=n,this.syncValue(n),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:[],removed:[i]}}))};#g=t=>{t.stopPropagation(),!this.disabled&&(this.open=!0)};#b=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#O=t=>{if(t.stopPropagation(),this.disabled||this.readonly)return;let i=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null).map(o=>String(o.value)),r=new Set(this.#d());i.length>0&&i.every(o=>r.has(o))?this.clear():this.selectAllOptions()};#y=!1;#w(){let t="Select...",e=this.hasAttribute("aria-label")&&!this.#y,i=!!this.label||this.hasAttribute("aria-labelledby");!e&&!i&&this.placeholder&&this.placeholder!==t?(this.setAttribute("aria-label",this.placeholder),this.#y=!0):this.#y&&(this.removeAttribute("aria-label"),this.#y=!1)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#T),this.addEventListener("keydown",this.#P),this.addEventListener("remove",this.#m),this.#i.length===0&&this.#v()}render(){if(this.multiple?this.setAttribute("data-multi-chips",""):this.removeAttribute("data-multi-chips"),this.#w(),this.querySelector('[slot="trigger"]')){let e=this.querySelector('[slot="display"]');if(e&&!this.multiple)e.tagName==="INPUT"?this.#a||(e.value=this.#E()===this.placeholder?"":this.#E()):e.textContent=this.#E();else if(e&&this.multiple){let i=this.#d().length>0;e.tagName==="INPUT"?(e.placeholder=i?"":this.placeholder||"",this.#a||(e.value="")):e.textContent=i?"":this.placeholder||""}}else{this.#s=!0;let e=this.#r;e?.parentNode===this&&this.removeChild(e);let i=this.avatar?`<img slot="leading" data-select-leading src="${Dt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${Dt(this.icon)}"></icon-ui>`:"",r=this.searchable?`<input slot="display" type="text" role="combobox" aria-autocomplete="list" autocomplete="off" placeholder="${Dt(this.placeholder||"")}" value="${Dt(this.#E()===this.placeholder?"":this.#E())}" />`:`<span slot="display">${Dt(this.#E())}</span>`,n=this.hint?`select-hint-${++s.#e}`:"",o=this.hint?`<span slot="hint" id="${n}">${Dt(this.hint)}</span>`:"";this.innerHTML=`
119
+ parent-template-re-read pattern that works across frameworks.`);return}if(this.dual){if(this.lowerValue>this.upperValue){let a=!Number.isNaN(this.#l)&&this.lowerValue!==this.#l;!Number.isNaN(this.#c)&&this.upperValue!==this.#c&&!a?this.upperValue=this.lowerValue:this.lowerValue=this.upperValue}this.#l=this.lowerValue,this.#c=this.upperValue;let i=this.#h(this.lowerValue),r=this.#h(this.upperValue);this.style.setProperty("--slider-pct-lower",String(i)),this.style.setProperty("--slider-pct-upper",String(r));let n=this.querySelector('[slot="value-lower"]'),o=this.querySelector('[slot="value-upper"]');n&&(n.textContent=this.#d(this.lowerValue)),o&&(o.textContent=this.#d(this.upperValue)),this.#s&&(this.#s.setAttribute("aria-valuenow",this.lowerValue),this.#s.setAttribute("aria-valuetext",`${this.#d(this.lowerValue)}${this.suffix?" "+this.suffix:""}`)),this.#r&&(this.#r.setAttribute("aria-valuenow",this.upperValue),this.#r.setAttribute("aria-valuetext",`${this.#d(this.upperValue)}${this.suffix?" "+this.suffix:""}`)),this.syncValue(`${this.lowerValue},${this.upperValue}`)}else{let i=this.#h(this.value);this.style.setProperty("--slider-pct",String(i));let r=this.querySelector('[slot="value"]');r&&(r.textContent=this.#d(this.value)),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.#d(this.value)}${this.suffix?" "+this.suffix:""}`),this.syncValue(String(this.value))}let t=this.querySelector('[slot="label"]');if(t)t.textContent=this.label;else if(this.label){let i=this.querySelector('[slot="header"]');if(i){let r=document.createElement("span");r.slot="label",r.textContent=this.label,i.prepend(r)}}this.label&&this.setAttribute("aria-label",this.label);let e=this.querySelector('[slot="suffix"]');e&&(e.textContent=this.suffix)}#u(t,e=null){let i=this.#i||this.#s||this.#r;if(!this.#e||!i)return this.min;let r=this.#e.getBoundingClientRect(),n=i.getBoundingClientRect().width,o=r.width,a,l;if(this.dual?(a=o-2*n,l=e==="upper"?1.5*n:.5*n):(a=o-n,l=.5*n),a<=0)return this.min;let h=t-r.left,c=Math.max(0,Math.min(1,(h-l)/a)),u=this.min+c*(this.max-this.min);return this.#p(u)}#f(t){if(!this.#e)return 0;let e=this.#i||this.#s||this.#r;if(!e)return 0;let i=this.#e.getBoundingClientRect(),r=e.getBoundingClientRect().width,n=i.width;if(this.dual){let o=n-2*r,a=t==="upper"?this.#h(this.upperValue):this.#h(this.lowerValue),l=t==="upper"?1.5*r:.5*r;return i.left+l+a*o}else return i.left+.5*r+this.#h(this.value)*(n-r)}#p(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#m(t){t!==this.value&&(this.value=t,this.scheduleThrottledInput())}#g(t){let e=Math.min(Math.max(t,this.min),this.upperValue);e!==this.lowerValue&&(this.lowerValue=e,this.scheduleThrottledInput())}#b(t){let e=Math.max(Math.min(t,this.max),this.lowerValue);e!==this.upperValue&&(this.upperValue=e,this.scheduleThrottledInput())}#y(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#O=t=>{if(this.disabled)return;t.preventDefault(),this.#n=!0,this.setAttribute("data-dragging","");let e;if(this.dual){let i=t.currentTarget?.dataset?.thumb;this.#a=i==="upper"?"upper":"lower",e=this.#a==="lower"?this.#s:this.#r,e?.setAttribute("data-active","")}else e=this.#i;if(this.#e&&e){let i=this.dual?this.#a:null;this.#o=t.clientX-this.#f(i)}else this.#o=0;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.#S),e.addEventListener("pointerup",this.#v)};#S=t=>{if(!this.#n)return;let e=t.clientX-this.#o;if(this.dual){let i=this.#u(e,this.#a);this.#a==="lower"?this.#g(i):this.#b(i)}else this.#m(this.#u(e))};#v=t=>{this.#n=!1,this.#o=0,this.removeAttribute("data-dragging");let e=this.dual?this.#a==="lower"?this.#s:this.#r:this.#i;e?.releasePointerCapture(t.pointerId),e?.removeEventListener("pointermove",this.#S),e?.removeEventListener("pointerup",this.#v),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#y(),this.#a=null};#w=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#r)return;let e=Math.abs(t.clientX-this.#f("lower")),i=Math.abs(t.clientX-this.#f("upper"));e<=i?this.#g(this.#u(t.clientX,"lower")):this.#b(this.#u(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#u(t.clientX))}this.flushPendingInput(),this.#y()}};#x=t=>{if(this.disabled)return;let e=0,i=null;switch(t.key){case"ArrowRight":case"ArrowUp":e=this.step;break;case"ArrowLeft":case"ArrowDown":e=-this.step;break;case"Home":i=this.min;break;case"End":i=this.max;break;case"PageUp":e=this.step*10;break;case"PageDown":e=-this.step*10;break;default:return}if(t.preventDefault(),this.dual){let n=this.ownerDocument?.activeElement===this.#r?"upper":"lower",o=n==="lower"?this.lowerValue:this.upperValue,a=i!==null?i:o+e;a=this.#p(a),n==="lower"?this.#g(a):this.#b(a)}else{let r=i!==null?i:this.value+e;this.#m(this.#p(r))}this.flushPendingInput(),this.#y()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#O),this.#s?.removeEventListener("pointerdown",this.#O),this.#r?.removeEventListener("pointerdown",this.#O),this.#e?.removeEventListener("click",this.#w),this.removeEventListener("keydown",this.#x),this.#e=null,this.#i=null,this.#s=null,this.#r=null}};S("slider-ui",fr);var eC=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,iC=0;function ct(s,t,e={}){let{placement:i="bottom-start",gap:r=4,matchWidth:n=!1}=e;return eC?sC(s,t,{placement:i,gap:r,matchWidth:n}):oC(s,t,{placement:i,gap:r,matchWidth:n})}function sC(s,t,{placement:e,gap:i,matchWidth:r}){let n=`--a-anchor-${++iC}`,o=s.style.anchorName,a={position:t.style.position,positionAnchor:t.style.positionAnchor,positionArea:t.style.positionArea,positionTryFallbacks:t.style.positionTryFallbacks,margin:t.style.margin,width:t.style.width,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,overflowY:t.style.overflowY,top:t.style.top,left:t.style.left};return s.style.anchorName=n,t.style.position="fixed",t.style.positionAnchor=n,t.style.positionArea=nC(e),t.style.margin=rC(e,i),t.style.positionTryFallbacks="flip-block, flip-inline, flip-block flip-inline",t.style.width=r?`anchor-size(${n} width)`:"max-content",t.style.maxWidth="min(calc(100vw - 1rem), var(--popover-max-width, 32rem))",t.style.maxHeight="calc(100vh - 3rem)",t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName=o;for(let[l,h]of Object.entries(a))t.style[l]=h}}function rC(s,t){return s.startsWith("bottom")?`${t}px 0 0 0`:s.startsWith("top")?`0 0 ${t}px 0`:s.startsWith("left")?`0 ${t}px 0 0`:s.startsWith("right")?`0 0 0 ${t}px`:`${t}px`}function nC(s){switch(s){case"bottom":return"bottom span-all";case"bottom-start":return"bottom span-right";case"bottom-end":return"bottom span-left";case"top":return"top span-all";case"top-start":return"top span-right";case"top-end":return"top span-left";case"left":return"left span-all";case"left-start":return"left span-bottom";case"left-end":return"left span-top";case"right":return"right span-all";case"right-start":return"right span-bottom";case"right-end":return"right span-top";default:return"bottom span-right"}}function oC(s,t,{placement:e,gap:i,matchWidth:r}){function n(){if(!s||!t)return;let a=s.getBoundingClientRect(),l=t.getBoundingClientRect(),h=window.innerWidth,c=window.innerHeight,u=e;u.startsWith("bottom")&&a.bottom+i+l.height>c&&a.top-i-l.height>0?u=u.replace("bottom","top"):u.startsWith("top")&&a.top-i-l.height<0&&a.bottom+i+l.height<c&&(u=u.replace("top","bottom"));let d,f;u.startsWith("top")?d=a.top-l.height-i:u.startsWith("bottom")?d=a.bottom+i:u.startsWith("left")?(f=a.left-l.width-i,u==="left-start"?d=a.top:u==="left-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2):u.startsWith("right")&&(f=a.right+i,u==="right-start"?d=a.top:u==="right-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2),f===void 0&&(u.endsWith("-start")?f=a.left:u.endsWith("-end")?f=a.right-l.width:f=a.left+(a.width-l.width)/2),f+l.width>h-i&&(f=a.right-l.width),f<i&&(f=a.left),d=Math.max(i,Math.min(d,c-l.height-i)),f=Math.max(i,Math.min(f,h-l.width-i)),t.style.position="fixed",t.style.top=`${d}px`,t.style.left=`${f}px`,r&&(t.style.width=`${a.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{n(),t.style.opacity=""});let o=aC(s);for(let a of o)a.addEventListener("scroll",n,{passive:!0});return window.addEventListener("resize",n,{passive:!0}),()=>{for(let a of o)a.removeEventListener("scroll",n);window.removeEventListener("resize",n)}}function aC(s){let t=[document],e=s?.parentElement;for(;e;){let i=getComputedStyle(e);/auto|scroll/.test(i.overflow+i.overflowX+i.overflowY)&&t.push(e),e=e.parentElement}return t}Ct();function Dt(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var pr=class s extends M{static labelDeprecated=!1;static requiredIcons=["caret-up-down","check","x","magnifying-glass"];static#t=new WeakSet;static properties={...M.properties,placeholder:{type:String,default:"Select...",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},searchable:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},divider:{type:Boolean,default:!1,reflect:!0},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:0,reflect:!0},selectAll:{type:Boolean,default:!1,reflect:!0,attribute:"select-all"},clearable:{type:Boolean,default:!1,reflect:!0}};static#e=0;static template=()=>null;#i=[];#s=!1;#r=null;#n=null;#a="";#o=null;#l=null;#c=()=>{this.disabled||(this.open=!0)};#h=t=>{t.stopPropagation(),this.disabled||(this.open=!0)};#d=t=>{let e=t.currentTarget;t.stopPropagation();let i=e.__adiaOption;if(i&&!i.disabled){if(i.action){this.open=!1,this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{action:i.action}}));return}if(this.multiple){this.toggle(i.value);return}this.value=i.value,this.open=!1,this.#a="",this.syncValue(i.value),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}};syncValue(t){if(!this.multiple)return super.syncValue(t);let e=t??this.value??"";this.internals.setFormValue(e);let i=String(e).split(",").map(r=>r.trim()).filter(Boolean);if(this.min>0&&i.length<this.min){this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please select at least ${this.min}.`,this);return}if(this.max>0&&i.length>this.max){this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-max")||`Please select no more than ${this.max}.`,this);return}if(this.required&&i.length===0){this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this);return}this.internals.setValidity({})}#u(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#f(t){let e=new Set,i=[];for(let r of t){if(r==null||r==="")continue;let n=String(r);e.has(n)||(e.add(n),i.push(n))}return i.join(",")}toggle(t){if(!this.multiple){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}let e=this.#u(),i=e.indexOf(String(t)),r=e.slice(),n=[],o=[];if(i>=0)e.splice(i,1),o=[String(t)];else{if(this.max>0&&e.length>=this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:r,reason:"max"}}));return}e.push(String(t)),n=[String(t)]}let a=this.#f(e);this.value=a,this.syncValue(a),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e,added:n,removed:o}}))}selectAllOptions(){if(!this.multiple)return;let t=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null),e=this.#f(t.map(o=>o.value));if(e===this.value)return;let i=this.#u();this.value=e,this.syncValue(e),this.render();let r=this.#u(),n=r.filter(o=>!i.includes(o));this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:n,removed:[]}}))}clear(){if(!this.multiple){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:""}}));return}let t=this.#u();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#p(){let t=this.#u();if(t.length===0)return;let e=t.pop(),i=this.#f(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#m=t=>{if(!this.multiple)return;let e=t.target;if(!e||e.tagName!=="TAG-UI")return;let i=e.dataset.chipValue;if(!i)return;t.stopPropagation();let r=this.#u().filter(o=>o!==i),n=this.#f(r);this.value=n,this.syncValue(n),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:[],removed:[i]}}))};#g=t=>{t.stopPropagation(),!this.disabled&&(this.open=!0)};#b=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#y=t=>{if(t.stopPropagation(),this.disabled||this.readonly)return;let i=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null).map(o=>String(o.value)),r=new Set(this.#u());i.length>0&&i.every(o=>r.has(o))?this.clear():this.selectAllOptions()};#O=!1;#S(){let t="Select...",e=this.hasAttribute("aria-label")&&!this.#O,i=!!this.label||this.hasAttribute("aria-labelledby");!e&&!i&&this.placeholder&&this.placeholder!==t?(this.setAttribute("aria-label",this.placeholder),this.#O=!0):this.#O&&(this.removeAttribute("aria-label"),this.#O=!1)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#T),this.addEventListener("keydown",this.#P),this.addEventListener("remove",this.#m),this.#i.length===0&&this.#v()}render(){if(this.multiple?this.setAttribute("data-multi-chips",""):this.removeAttribute("data-multi-chips"),this.#S(),this.querySelector('[slot="trigger"]')){let e=this.querySelector('[slot="display"]');if(e&&!this.multiple)e.tagName==="INPUT"?this.#a||(e.value=this.#E()===this.placeholder?"":this.#E()):e.textContent=this.#E();else if(e&&this.multiple){let i=this.#u().length>0;e.tagName==="INPUT"?(e.placeholder=i?"":this.placeholder||"",this.#a||(e.value="")):e.textContent=i?"":this.placeholder||""}}else{this.#s=!0;let e=this.#r;e?.parentNode===this&&this.removeChild(e);let i=this.avatar?`<img slot="leading" data-select-leading src="${Dt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${Dt(this.icon)}"></icon-ui>`:"",r=this.searchable?`<input slot="display" type="text" role="combobox" aria-autocomplete="list" autocomplete="off" placeholder="${Dt(this.placeholder||"")}" value="${Dt(this.#E()===this.placeholder?"":this.#E())}" />`:`<span slot="display">${Dt(this.#E())}</span>`,n=this.hint?`select-hint-${++s.#e}`:"",o=this.hint?`<span slot="hint" id="${n}">${Dt(this.hint)}</span>`:"";this.innerHTML=`
120
120
  <span slot="trigger">
121
121
  ${i}
122
122
  <span data-chips></span>
@@ -127,7 +127,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
127
127
  <icon-ui name="caret-up-down" slot="caret"></icon-ui>
128
128
  </span>
129
129
  ${o}
130
- `,this.hint&&this.setAttribute("aria-describedby",n);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#b),a.addEventListener("click",this.#b)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#I),this.#o.removeEventListener("focus",this.#c),this.#o.removeEventListener("click",this.#h)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#I),this.#o.addEventListener("focus",this.#c),this.#o.addEventListener("click",this.#h))),e&&this.appendChild(e)}this.#x(),this.multiple&&this.#C();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#d().length>0&&!this.disabled&&!this.readonly?t.removeAttribute("hidden"):t.setAttribute("hidden","")),this.#r||(this.#r=this.querySelector('[slot="listbox"]'),this.#r||(this.#r=document.createElement("div"),this.#r.setAttribute("slot","listbox"),this.#r.setAttribute("role","listbox"),this.#r.setAttribute("popover","manual"),this.appendChild(this.#r)),this.#k()),this.#r){let e=this.multiple?new Set(this.value.split(",").map(i=>i.trim()).filter(Boolean)):null;for(let i of this.#r.querySelectorAll('[role="option"]')){let r=i.getAttribute("data-value");(e?e.has(r):r===this.value)?i.setAttribute("aria-selected","true"):i.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#r?.showPopover?.();let e=this.querySelector('[slot="trigger"]')||this;this.#r.style.minWidth=`${e.getBoundingClientRect().width}px`,this.#r.style.width="max-content",this.#n=ct(e,this.#r,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#Q,{once:!0})})}else this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q)}#v(){this.#i=[];let t=new Set,e=[];for(let i of this.children)if(i.tagName==="OPTGROUP"){let r={label:i.label||i.getAttribute("label")||"",options:[]};for(let n of i.querySelectorAll("option"))r.options.push({value:n.value,label:n.textContent.trim(),disabled:n.disabled,icon:n.getAttribute("icon")||"",avatar:n.getAttribute("avatar")||""}),n.hasAttribute("selected")&&e.push(n.value);this.#i.push(r)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled,icon:i.getAttribute("icon")||"",avatar:i.getAttribute("avatar")||""}),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){F(()=>{this.#i=t,this.#r||(this.#r=this.querySelector('[slot="listbox"]'),this.#r||(this.#r=document.createElement("div"),this.#r.setAttribute("slot","listbox"),this.#r.setAttribute("role","listbox"),this.#r.setAttribute("popover","manual"),this.appendChild(this.#r))),this.#k();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#E())})}get options(){return this.#i}static#S(t){return t?t.avatar?`<img data-option-avatar src="${Dt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Dt(t.icon)}"></icon-ui>`:"":""}#x(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(c=>c.options||[c]).find(c=>!c.header&&!c.separator&&c.value===this.value),r=i&&i.avatar||this.avatar||"",n=i&&i.icon||this.icon||"",o=t.querySelector(":scope > [data-select-leading]"),a="";if(r?a=`<img slot="leading" data-select-leading src="${Dt(r)}" alt="" />`:n&&(a=`<icon-ui slot="leading" data-select-leading name="${Dt(n)}"></icon-ui>`),!a){o?.remove();return}let l=document.createElement("template");l.innerHTML=a;let h=l.content.firstElementChild;o?o.tagName===h.tagName?h.tagName==="IMG"?o.getAttribute("src")!==h.getAttribute("src")&&o.setAttribute("src",h.getAttribute("src")):o.getAttribute("name")!==h.getAttribute("name")&&o.setAttribute("name",h.getAttribute("name")):o.replaceWith(h):t.insertBefore(h,t.firstChild)}#k(){if(!this.#r)return;if(this.#r.innerHTML="",this.multiple?this.#r.setAttribute("aria-multiselectable","true"):this.#r.removeAttribute("aria-multiselectable"),this.multiple&&this.selectAll){let e=document.createElement("div");e.setAttribute("data-select-all","");let i=document.createElement("button");i.type="button",i.dataset.selectAllBtn="",i.textContent=this.#A()?"Clear":"Select all",i.addEventListener("click",this.#O),e.appendChild(i),this.#r.appendChild(e)}let t=e=>{if(e.separator){let a=document.createElement("hr");return a.setAttribute("data-separator",""),a}let i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("data-value",e.value||"");let r=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,n=r?r.has(e.value):e.value===this.value,o=s.#S(e);if(this.multiple){i.setAttribute("data-multi-option","");let a=document.createElement("span");a.setAttribute("data-checkbox",""),a.innerHTML='<icon-ui name="check" aria-hidden="true"></icon-ui>',i.appendChild(a);let l=document.createElement("span");l.setAttribute("data-option-label",""),o?l.innerHTML=`${o}${Dt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else o?i.innerHTML=`${o}${Dt(e.label)}`:i.textContent=e.label;return n&&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.#u),i};for(let e of this.#i)if(e.separator)this.#r.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>${Dt(e.label)}</strong><span>${Dt(e.description||"")}</span></div>`:`<div><strong>${Dt(e.label)}</strong><span>${Dt(e.description||"")}</span></div>`,this.#r.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${Dt(e.label)}</div>`;for(let r of e.options)i.appendChild(t(r));this.#r.appendChild(i)}else this.#r.appendChild(t(e));if(this.#i.length===0){let e=document.createElement("div");e.setAttribute("data-empty",""),e.textContent="No options",this.#r.appendChild(e)}this.#a&&this.#$()}#A(){if(!this.multiple)return!1;let t=this.#i.flatMap(i=>i.options||[i]).filter(i=>!i.disabled&&!i.separator&&!i.header&&i.value!=null);if(t.length===0)return!1;let e=new Set(this.#d());return t.every(i=>e.has(String(i.value)))}#C(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;let e=this.#d(),i=Number(this.maxChips)||0,r=i>0&&e.length>i?e.slice(0,i):e,n=i>0&&e.length>i?e.length-i:0,o=this.#i.flatMap(l=>l.options||[l]).filter(l=>!l.separator&&!l.header&&l.value!=null),a=l=>{let h=o.find(c=>String(c.value)===String(l));return h?h.label:String(l)};for(;t.firstChild;)t.removeChild(t.firstChild);for(let l of r){let h=document.createElement("tag-ui");h.setAttribute("size","sm"),!this.disabled&&!this.readonly&&h.setAttribute("removable",""),h.dataset.chipValue=String(l),h.setAttribute("text",a(l)),t.appendChild(h)}if(n>0){let l=document.createElement("button");l.type="button",l.dataset.more="",l.textContent=`+${n} more`,l.addEventListener("click",this.#g),t.appendChild(l)}}#E(){return this.multiple?this.value?"":this.placeholder:this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#T=t=>{this.disabled||this.#r&&t.composedPath().includes(this.#r)||(this.open=!this.open)};#Q=t=>{!this.contains(t.target)&&!(this.#r&&t.composedPath().includes(this.#r))&&(this.open=!1)};#P=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.tagName==="INPUT"&&e.getAttribute("slot")==="display",r=!this.#a||this.#a.length===0;if((!i||r)&&this.#d().length>0){t.preventDefault(),this.#p();return}}if(t.key==="Escape"){if(this.searchable&&this.#a){this.#a="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#$();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#r?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click(),this.multiple&&(this.open=!1);else if(this.searchable&&this.freeText&&this.#a){let i=this.#a;this.value=i,this.#a="",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.#r?.querySelector('[role="option"][data-focused]');e?e.click():this.multiple||(this.open=!1)}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#M(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#M(-1))};#I=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#$()};#$(){if(!this.#r)return;let t=this.#a.toLowerCase(),e=this.#r.querySelectorAll('[role="option"]'),i=!1;for(let n of e){let o=(n.textContent||"").toLowerCase();!t||o.includes(t)?(n.removeAttribute("data-filtered-out"),n.style.display="",i=!0):(n.setAttribute("data-filtered-out",""),n.style.display="none")}for(let n of this.#r.querySelectorAll('[role="group"]')){let o=n.querySelectorAll('[role="option"]:not([data-filtered-out])').length;n.style.display=o?"":"none"}let r=this.#r.querySelector('[role="option"][data-focused]');r&&r.hasAttribute("data-filtered-out")&&r.removeAttribute("data-focused")}#M(t){if(!this.#r)return;let e=[...this.#r.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#r.querySelector('[role="option"][data-focused]'),r=i?e.indexOf(i):-1,n=e[(r+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),n&&(n.setAttribute("data-focused",""),n.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#T),this.removeEventListener("keydown",this.#P),this.removeEventListener("remove",this.#m),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q),this.#o&&(this.#o.removeEventListener("input",this.#I),this.#o.removeEventListener("focus",this.#c),this.#o.removeEventListener("click",this.#h),this.#o=null),this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#r=null}};S("select-ui",pr);$();var mr=class extends x{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()}};S("segment-ui",mr);var gr=class s extends M{static properties={...M.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#r=null;#n=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#u)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#r=new ResizeObserver(()=>this.#l(this.#a)),this.#r.observe(this)),document.fonts?.ready&&(this.#n=document.fonts.ready.then(()=>{this.#n=null,this.#l(this.#a)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#r?.disconnect(),this.#r=null,this.#n&&(this.#n=null),this.removeEventListener("click",this.#h),this.removeEventListener("keydown",this.#u),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator")&&!(i.tagName==="SPAN"&&i.style.display==="contents"));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.#a;if(t.length){for(let e of t){let r=(e.value||e.getAttribute("value")||"")===this.value;r?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",r?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){let e=t.findIndex(r=>(r.value||r.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e||!this.contains(this.#e);if(i){for(let r of this.querySelectorAll(":scope > [data-indicator]"))r.remove();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",""))}#c(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.#c(e)};#u=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#o,r=i.indexOf(e);if(r<0)return;let n;switch(t.key){case"ArrowRight":case"ArrowDown":n=r<i.length-1?r+1:0;break;case"ArrowLeft":case"ArrowUp":n=r>0?r-1:i.length-1;break;case"Home":n=0;break;case"End":n=i.length-1;break;default:return}t.preventDefault(),i[n].focus(),this.#c(i[n])}};S("segmented-ui",gr);var br=class extends M{static labelDeprecated=!1;static properties={...M.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;#r=0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
130
+ `,this.hint&&this.setAttribute("aria-describedby",n);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#b),a.addEventListener("click",this.#b)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#I),this.#o.removeEventListener("focus",this.#c),this.#o.removeEventListener("click",this.#h)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#I),this.#o.addEventListener("focus",this.#c),this.#o.addEventListener("click",this.#h))),e&&this.appendChild(e)}this.#x(),this.multiple&&this.#C();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#u().length>0&&!this.disabled&&!this.readonly?t.removeAttribute("hidden"):t.setAttribute("hidden","")),this.#r||(this.#r=this.querySelector('[slot="listbox"]'),this.#r||(this.#r=document.createElement("div"),this.#r.setAttribute("slot","listbox"),this.#r.setAttribute("role","listbox"),this.#r.setAttribute("popover","manual"),this.appendChild(this.#r)),this.#k()),this.#r){let e=this.multiple?new Set(this.value.split(",").map(i=>i.trim()).filter(Boolean)):null;for(let i of this.#r.querySelectorAll('[role="option"]')){let r=i.getAttribute("data-value");(e?e.has(r):r===this.value)?i.setAttribute("aria-selected","true"):i.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#r?.showPopover?.();let e=this.querySelector('[slot="trigger"]')||this;this.#r.style.minWidth=`${e.getBoundingClientRect().width}px`,this.#r.style.width="max-content",this.#n=ct(e,this.#r,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#Q,{once:!0})})}else this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q)}#v(){this.#i=[];let t=new Set,e=[];for(let i of this.children)if(i.tagName==="OPTGROUP"){let r={label:i.label||i.getAttribute("label")||"",options:[]};for(let n of i.querySelectorAll("option"))r.options.push({value:n.value,label:n.textContent.trim(),disabled:n.disabled,icon:n.getAttribute("icon")||"",avatar:n.getAttribute("avatar")||""}),n.hasAttribute("selected")&&e.push(n.value);this.#i.push(r)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled,icon:i.getAttribute("icon")||"",avatar:i.getAttribute("avatar")||""}),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){F(()=>{this.#i=t,this.#r||(this.#r=this.querySelector('[slot="listbox"]'),this.#r||(this.#r=document.createElement("div"),this.#r.setAttribute("slot","listbox"),this.#r.setAttribute("role","listbox"),this.#r.setAttribute("popover","manual"),this.appendChild(this.#r))),this.#k();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#E())})}get options(){return this.#i}static#w(t){return t?t.avatar?`<img data-option-avatar src="${Dt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Dt(t.icon)}"></icon-ui>`:"":""}#x(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(c=>c.options||[c]).find(c=>!c.header&&!c.separator&&c.value===this.value),r=i&&i.avatar||this.avatar||"",n=i&&i.icon||this.icon||"",o=t.querySelector(":scope > [data-select-leading]"),a="";if(r?a=`<img slot="leading" data-select-leading src="${Dt(r)}" alt="" />`:n&&(a=`<icon-ui slot="leading" data-select-leading name="${Dt(n)}"></icon-ui>`),!a){o?.remove();return}let l=document.createElement("template");l.innerHTML=a;let h=l.content.firstElementChild;o?o.tagName===h.tagName?h.tagName==="IMG"?o.getAttribute("src")!==h.getAttribute("src")&&o.setAttribute("src",h.getAttribute("src")):o.getAttribute("name")!==h.getAttribute("name")&&o.setAttribute("name",h.getAttribute("name")):o.replaceWith(h):t.insertBefore(h,t.firstChild)}#k(){if(!this.#r)return;if(this.#r.innerHTML="",this.multiple?this.#r.setAttribute("aria-multiselectable","true"):this.#r.removeAttribute("aria-multiselectable"),this.multiple&&this.selectAll){let e=document.createElement("div");e.setAttribute("data-select-all","");let i=document.createElement("button");i.type="button",i.dataset.selectAllBtn="",i.textContent=this.#A()?"Clear":"Select all",i.addEventListener("click",this.#y),e.appendChild(i),this.#r.appendChild(e)}let t=e=>{if(e.separator){let a=document.createElement("hr");return a.setAttribute("data-separator",""),a}let i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("data-value",e.value||"");let r=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,n=r?r.has(e.value):e.value===this.value,o=s.#w(e);if(this.multiple){i.setAttribute("data-multi-option","");let a=document.createElement("span");a.setAttribute("data-checkbox",""),a.innerHTML='<icon-ui name="check" aria-hidden="true"></icon-ui>',i.appendChild(a);let l=document.createElement("span");l.setAttribute("data-option-label",""),o?l.innerHTML=`${o}${Dt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else o?i.innerHTML=`${o}${Dt(e.label)}`:i.textContent=e.label;return n&&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.#d),i};for(let e of this.#i)if(e.separator)this.#r.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>${Dt(e.label)}</strong><span>${Dt(e.description||"")}</span></div>`:`<div><strong>${Dt(e.label)}</strong><span>${Dt(e.description||"")}</span></div>`,this.#r.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${Dt(e.label)}</div>`;for(let r of e.options)i.appendChild(t(r));this.#r.appendChild(i)}else this.#r.appendChild(t(e));if(this.#i.length===0){let e=document.createElement("div");e.setAttribute("data-empty",""),e.textContent="No options",this.#r.appendChild(e)}this.#a&&this.#$()}#A(){if(!this.multiple)return!1;let t=this.#i.flatMap(i=>i.options||[i]).filter(i=>!i.disabled&&!i.separator&&!i.header&&i.value!=null);if(t.length===0)return!1;let e=new Set(this.#u());return t.every(i=>e.has(String(i.value)))}#C(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;let e=this.#u(),i=Number(this.maxChips)||0,r=i>0&&e.length>i?e.slice(0,i):e,n=i>0&&e.length>i?e.length-i:0,o=this.#i.flatMap(l=>l.options||[l]).filter(l=>!l.separator&&!l.header&&l.value!=null),a=l=>{let h=o.find(c=>String(c.value)===String(l));return h?h.label:String(l)};for(;t.firstChild;)t.removeChild(t.firstChild);for(let l of r){let h=document.createElement("tag-ui");h.setAttribute("size","sm"),!this.disabled&&!this.readonly&&h.setAttribute("removable",""),h.dataset.chipValue=String(l),h.setAttribute("text",a(l)),t.appendChild(h)}if(n>0){let l=document.createElement("button");l.type="button",l.dataset.more="",l.textContent=`+${n} more`,l.addEventListener("click",this.#g),t.appendChild(l)}}#E(){return this.multiple?this.value?"":this.placeholder:this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#T=t=>{this.disabled||this.#r&&t.composedPath().includes(this.#r)||(this.open=!this.open)};#Q=t=>{!this.contains(t.target)&&!(this.#r&&t.composedPath().includes(this.#r))&&(this.open=!1)};#P=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.tagName==="INPUT"&&e.getAttribute("slot")==="display",r=!this.#a||this.#a.length===0;if((!i||r)&&this.#u().length>0){t.preventDefault(),this.#p();return}}if(t.key==="Escape"){if(this.searchable&&this.#a){this.#a="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#$();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#r?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click(),this.multiple&&(this.open=!1);else if(this.searchable&&this.freeText&&this.#a){let i=this.#a;this.value=i,this.#a="",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.#r?.querySelector('[role="option"][data-focused]');e?e.click():this.multiple||(this.open=!1)}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#M(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#M(-1))};#I=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#$()};#$(){if(!this.#r)return;let t=this.#a.toLowerCase(),e=this.#r.querySelectorAll('[role="option"]'),i=!1;for(let n of e){let o=(n.textContent||"").toLowerCase();!t||o.includes(t)?(n.removeAttribute("data-filtered-out"),n.style.display="",i=!0):(n.setAttribute("data-filtered-out",""),n.style.display="none")}for(let n of this.#r.querySelectorAll('[role="group"]')){let o=n.querySelectorAll('[role="option"]:not([data-filtered-out])').length;n.style.display=o?"":"none"}let r=this.#r.querySelector('[role="option"][data-focused]');r&&r.hasAttribute("data-filtered-out")&&r.removeAttribute("data-focused")}#M(t){if(!this.#r)return;let e=[...this.#r.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#r.querySelector('[role="option"][data-focused]'),r=i?e.indexOf(i):-1,n=e[(r+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),n&&(n.setAttribute("data-focused",""),n.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#T),this.removeEventListener("keydown",this.#P),this.removeEventListener("remove",this.#m),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q),this.#o&&(this.#o.removeEventListener("input",this.#I),this.#o.removeEventListener("focus",this.#c),this.#o.removeEventListener("click",this.#h),this.#o=null),this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#r=null}};S("select-ui",pr);$();var mr=class extends x{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()}};S("segment-ui",mr);var gr=class s extends M{static properties={...M.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#r=null;#n=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#d)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#r=new ResizeObserver(()=>this.#l(this.#a)),this.#r.observe(this)),document.fonts?.ready&&(this.#n=document.fonts.ready.then(()=>{this.#n=null,this.#l(this.#a)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#r?.disconnect(),this.#r=null,this.#n&&(this.#n=null),this.removeEventListener("click",this.#h),this.removeEventListener("keydown",this.#d),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator")&&!(i.tagName==="SPAN"&&i.style.display==="contents"));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.#a;if(t.length){for(let e of t){let r=(e.value||e.getAttribute("value")||"")===this.value;r?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",r?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){let e=t.findIndex(r=>(r.value||r.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e||!this.contains(this.#e);if(i){for(let r of this.querySelectorAll(":scope > [data-indicator]"))r.remove();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",""))}#c(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.#c(e)};#d=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#o,r=i.indexOf(e);if(r<0)return;let n;switch(t.key){case"ArrowRight":case"ArrowDown":n=r<i.length-1?r+1:0;break;case"ArrowLeft":case"ArrowUp":n=r>0?r-1:i.length-1;break;case"Home":n=0;break;case"End":n=i.length-1;break;default:return}t.preventDefault(),i[n].focus(),this.#c(i[n])}};S("segmented-ui",gr);var br=class extends M{static labelDeprecated=!1;static properties={...M.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;#r=0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
131
131
  <span slot="label">${this.label}</span>
132
132
  <span slot="value">${this.#n(this.value)}</span>
133
133
  ${this.suffix?`<span slot="suffix">${this.suffix}</span>`:""}
@@ -136,13 +136,13 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
136
136
  <div slot="layer" data-layer="base">${t}</div>
137
137
  <div slot="layer" data-layer="fill" aria-hidden="true">${t}</div>
138
138
  </div>
139
- `}this.#t=this.querySelector('[slot="field"]'),this.#e=this.querySelector('[data-layer="base"] [slot="value"]'),this.#t&&this.#t.addEventListener("pointerdown",this.#c),this.addEventListener("keydown",this.#d)}render(){if(!this.#t)return;let t=this.#n(this.value);this.#e&&(this.#e.textContent=t);let e=this.querySelector('[data-layer="fill"] [slot="value"]');e&&(e.textContent=t);let i=this.max-this.min,r=i>0?(this.value-this.min)/i*100:0;this.style.setProperty("--range-fill-pct",`${r}%`),this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.value}${this.suffix?" "+this.suffix:""}`),this.setAttribute("aria-label",this.label||""),this.syncValue(String(this.value))}#n(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}#a(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#o(t){let e=this.#a(t);e!==this.value&&(this.value=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})))}#l(t){let e=this.#t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-e.left)/e.width));return this.#a(this.min+i*(this.max-this.min))}#c=t=>{this.disabled||(t.preventDefault(),this.#o(this.#l(t.clientX)),this.#i=!0,this.#s=t.clientX,this.#r=this.value,this.setAttribute("data-dragging",""),this.#t.setPointerCapture(t.pointerId),this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#u))};#h=t=>{if(!this.#i)return;let e=t.clientX-this.#s,i=this.#t.getBoundingClientRect().width,r=this.max-this.min,n=e/i*r;this.#o(this.#r+n)};#u=t=>{this.#i=!1,this.removeAttribute("data-dragging"),this.#t.releasePointerCapture(t.pointerId),this.#t.removeEventListener("pointermove",this.#h),this.#t.removeEventListener("pointerup",this.#u),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#d=t=>{if(this.disabled)return;let e=this.value;switch(t.key){case"ArrowRight":case"ArrowUp":e+=this.step;break;case"ArrowLeft":case"ArrowDown":e-=this.step;break;case"Home":e=this.min;break;case"End":e=this.max;break;case"PageUp":e+=this.step*10;break;case"PageDown":e-=this.step*10;break;default:return}t.preventDefault(),this.#o(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};disconnected(){super.disconnected(),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#t?.removeEventListener("pointerup",this.#u),this.removeEventListener("keydown",this.#d),this.#t=null,this.#e=null}};S("range-ui",br);$();var Or=class extends x{static requiredIcons=["caret-right"];static template=()=>null;connected(){this.setAttribute("role","tree"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}get selectedItem(){return this.querySelector("tree-item-ui[selected]")}select(t,e=null){let i=this.selectedItem;i&&i!==t&&i.removeAttribute("selected"),t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("tree-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value,ctrlKey:!!e?.ctrlKey,metaKey:!!e?.metaKey,shiftKey:!!e?.shiftKey}}))}#t(t){if(!t)return null;if(t instanceof Element)return t.matches?.("tree-item-ui")?t:null;if(typeof t=="string"){let e=t.replace(/"/g,'\\"');return this.querySelector(`tree-item-ui[value="${e}"]`)||this.querySelector(`tree-item-ui[text="${e}"]`)||null}return null}expand(t){let e=this.#t(t);e&&e.hasChildren&&!e.open&&(e.open=!0)}collapse(t){let e=this.#t(t);e&&e.open&&(e.open=!1)}expandAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.hasChildren&&!t.open&&(t.open=!0)}collapseAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.open&&(t.open=!1)}expandTo(t){let e=this.#t(t);if(!e)return;let i=e.parentElement?.closest("tree-item-ui");for(;i;)i.hasChildren&&!i.open&&(i.open=!0),i=i.parentElement?.closest("tree-item-ui");e.querySelector(':scope > [slot="row"]')?.scrollIntoView?.({block:"nearest",inline:"nearest"})}#e=t=>{let e=t.target.closest("tree-item-ui");if(!e||!this.contains(e)||t.target.closest('[slot="actions"] *'))return;let i=e.querySelector(':scope > [slot="row"]');!i||!(t.target===i||i.contains(t.target))||(this.select(e,t),e.hasChildren&&(e.open=!e.open))};#i=t=>{let e=t.target.closest("tree-item-ui");if(e)switch(t.key){case"ArrowRight":if(t.preventDefault(),e.hasChildren&&!e.open)e.open=!0;else{let i=e.querySelector(":scope > tree-item-ui");i&&i.querySelector('[slot="row"]')?.focus()}break;case"ArrowLeft":if(t.preventDefault(),e.hasChildren&&e.open)e.open=!1;else{let i=e.parentElement?.closest("tree-item-ui");i&&i.querySelector(':scope > [slot="row"]')?.focus()}break;case"ArrowDown":{t.preventDefault();let i=this.#s(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"ArrowUp":{t.preventDefault();let i=this.#r(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"Enter":case" ":t.preventDefault(),this.select(e,t);break}};#s(t){if(t.open&&t.hasChildren)return t.querySelector(":scope > tree-item-ui");let e=t;for(;e;){let i=e.nextElementSibling;if(i&&i.matches("tree-item-ui"))return i;e=e.parentElement?.closest("tree-item-ui")}return null}#r(t){let e=t.previousElementSibling;if(e&&e.matches("tree-item-ui")){let r=e;for(;r.open&&r.hasChildren;){let n=r.querySelectorAll(":scope > tree-item-ui");r=n[n.length-1]}return r}return t.parentElement?.closest("tree-item-ui")||null}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}},yr=class extends x{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},badge:{type:String,default:"",reflect:!0}};static template=()=>null;get hasChildren(){return this.querySelector(":scope > tree-item-ui")!==null}get depth(){let t=0,e=this.parentElement;for(;e;)e.matches("tree-item-ui")&&t++,e=e.parentElement;return t}connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="row"]')||this.#t();let t=this.querySelector(':scope > [slot="row"]');t&&(t.setAttribute("role","treeitem"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"))}#t(){let t=document.createElement("div");t.setAttribute("slot","row"),t.setAttribute("tabindex","0");let e=this.querySelector(':scope > [slot="caret"]');if(e)t.appendChild(e);else{let o=document.createElement("icon-ui");o.setAttribute("slot","caret"),o.setAttribute("name","caret-right"),t.appendChild(o)}if(this.icon){let o=document.createElement("icon-ui");o.setAttribute("name",this.icon),o.setAttribute("slot","icon"),t.appendChild(o)}let i=document.createElement("span");i.setAttribute("slot","text"),i.textContent=this.text,t.appendChild(i);let r=document.createElement("span");r.setAttribute("slot","badge"),this.badge&&(r.textContent=this.badge),t.appendChild(r);let n=this.querySelectorAll(':scope > [slot="actions"]');if(n.length)for(let o of n)t.appendChild(o);else{let o=document.createElement("span");o.setAttribute("slot","actions"),t.appendChild(o)}this.prepend(t)}render(){let t=this.querySelector(':scope > [slot="row"]');if(!t)return;t.style.paddingInlineStart=`${this.depth*16+4}px`,this.hasChildren?t.setAttribute("aria-expanded",String(this.open)):t.removeAttribute("aria-expanded"),this.selected?t.setAttribute("aria-selected","true"):t.removeAttribute("aria-selected");let e=t.querySelector('[slot="text"]');e&&this.text&&(e.textContent=this.text);let i=t.querySelector('[slot="badge"]');i&&(i.textContent=this.badge||"")}};S("tree-ui",Or),S("tree-item-ui",yr);$();var vr=class extends x{static requiredIcons=["caret-right"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},minWidth:{type:Number,default:200,attribute:"min-width",reflect:!0},maxWidth:{type:Number,default:9999,attribute:"max-width",reflect:!0},side:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=0;#s=0;#r=null;#n="";#a=!1;connected(){this.#a||(this.#a=!0,this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l)),this.resizable&&!this.querySelector('[slot="resize"]')&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","resize"),this.appendChild(this.#t)),(this.#t||this.resizable)&&(this.#t=this.#t||this.querySelector('[slot="resize"]'),this.#t?.addEventListener("pointerdown",this.#c))}render(){let t=this.querySelector(":scope > header");if(t&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-expanded",String(!this.collapsed)),!t.querySelector('[slot="caret"]'))){let e=document.createElement("icon-ui");e.setAttribute("slot","caret"),e.setAttribute("name","caret-right"),t.append(e)}}toggle(){this.collapsed=!this.collapsed,this.dispatchEvent(new Event("toggle",{bubbles:!0}))}#o=t=>{let e=this.querySelector(":scope > header");e&&(t.target===e||e.contains(t.target))&&this.toggle()};#l=t=>{t.target===this.querySelector(":scope > header")&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.toggle())};#c=t=>{if(t.isPrimary){t.preventDefault(),this.#e=!0,this.#i=t.clientX,this.#s=this.getBoundingClientRect().width,this.#r=t.pointerId,this.setAttribute("data-resizing","");try{this.#t.setPointerCapture(t.pointerId)}catch{}this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#u,{once:!0}),this.#t.addEventListener("pointercancel",this.#u,{once:!0}),this.#n=document.documentElement.style.cursor,document.documentElement.style.cursor="col-resize"}};#h=t=>{if(!this.#e)return;let e=this.side==="trailing"?-1:1,i=(t.clientX-this.#i)*e,r=Math.max(this.minWidth,Math.min(this.maxWidth,this.#s+i));this.style.width=`${r}px`};#u=()=>{if(this.#e){this.#e=!1,this.removeAttribute("data-resizing");try{this.#t?.releasePointerCapture(this.#r)}catch{}this.#r=null,this.#t?.removeEventListener("pointermove",this.#h),document.documentElement.style.cursor=this.#n}};disconnected(){this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#l),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#e&&(document.documentElement.style.cursor=this.#n),this.#a=!1}};S("pane-ui",vr);$();var xr=class extends x{static properties={scroll:{type:Boolean,default:!1,reflect:!0},maxWidth:{type:String,default:"",attribute:"max-width",reflect:!0},padding:{type:String,default:"",reflect:!0},stickyHeader:{type:Boolean,default:!1,attribute:"sticky-header",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.stickyHeader&&this.#i()}disconnected(){this.#s()}render(){this.stickyHeader&&!this.#t&&this.#i(),!this.stickyHeader&&this.#t&&this.#s()}#i(){let t=this.querySelector(":scope > :is(header, header-ui)");t&&(this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-page-sentinel",""),this.#t.style.cssText="height: 0; width: 0; pointer-events: none;",t.insertAdjacentElement("beforebegin",this.#t)),this.#e||(this.#e=new IntersectionObserver(e=>{this.toggleAttribute("data-header-stuck",!e[0].isIntersecting)},{threshold:0})),this.#e.observe(this.#t))}#s(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null,this.removeAttribute("data-header-stuck")}};S("page-ui",xr);$();var Ea=class extends x{static properties={disabled:{type:Boolean,default:!1,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Type a message...",reflect:!0},model:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=[];#n=[];#a=null;#o=null;#l=null;#c=()=>this.#o?.click();#h=()=>{this.#o?.files?.length&&this.#m(this.#o.files),this.#o&&(this.#o.value="")};get value(){return this.#t?.value?.trim()??""}get attachments(){return[...this.#n]}set models(t){this.#r=t||[],this.#i&&(this.#i.options=this.#r,this.model&&(this.#i.value=this.model))}get models(){return this.#r}connected(){this.querySelector('[slot="toolbar"]')||(this.innerHTML=`
139
+ `}this.#t=this.querySelector('[slot="field"]'),this.#e=this.querySelector('[data-layer="base"] [slot="value"]'),this.#t&&this.#t.addEventListener("pointerdown",this.#c),this.addEventListener("keydown",this.#u)}render(){if(!this.#t)return;let t=this.#n(this.value);this.#e&&(this.#e.textContent=t);let e=this.querySelector('[data-layer="fill"] [slot="value"]');e&&(e.textContent=t);let i=this.max-this.min,r=i>0?(this.value-this.min)/i*100:0;this.style.setProperty("--range-fill-pct",`${r}%`),this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.value}${this.suffix?" "+this.suffix:""}`),this.setAttribute("aria-label",this.label||""),this.syncValue(String(this.value))}#n(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}#a(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#o(t){let e=this.#a(t);e!==this.value&&(this.value=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})))}#l(t){let e=this.#t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-e.left)/e.width));return this.#a(this.min+i*(this.max-this.min))}#c=t=>{this.disabled||(t.preventDefault(),this.#o(this.#l(t.clientX)),this.#i=!0,this.#s=t.clientX,this.#r=this.value,this.setAttribute("data-dragging",""),this.#t.setPointerCapture(t.pointerId),this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#d))};#h=t=>{if(!this.#i)return;let e=t.clientX-this.#s,i=this.#t.getBoundingClientRect().width,r=this.max-this.min,n=e/i*r;this.#o(this.#r+n)};#d=t=>{this.#i=!1,this.removeAttribute("data-dragging"),this.#t.releasePointerCapture(t.pointerId),this.#t.removeEventListener("pointermove",this.#h),this.#t.removeEventListener("pointerup",this.#d),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#u=t=>{if(this.disabled)return;let e=this.value;switch(t.key){case"ArrowRight":case"ArrowUp":e+=this.step;break;case"ArrowLeft":case"ArrowDown":e-=this.step;break;case"Home":e=this.min;break;case"End":e=this.max;break;case"PageUp":e+=this.step*10;break;case"PageDown":e-=this.step*10;break;default:return}t.preventDefault(),this.#o(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};disconnected(){super.disconnected(),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#t?.removeEventListener("pointerup",this.#d),this.removeEventListener("keydown",this.#u),this.#t=null,this.#e=null}};S("range-ui",br);$();var Or=class extends x{static requiredIcons=["caret-right"];static template=()=>null;connected(){this.setAttribute("role","tree"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}get selectedItem(){return this.querySelector("tree-item-ui[selected]")}select(t,e=null){let i=this.selectedItem;i&&i!==t&&i.removeAttribute("selected"),t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("tree-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value,ctrlKey:!!e?.ctrlKey,metaKey:!!e?.metaKey,shiftKey:!!e?.shiftKey}}))}#t(t){if(!t)return null;if(t instanceof Element)return t.matches?.("tree-item-ui")?t:null;if(typeof t=="string"){let e=t.replace(/"/g,'\\"');return this.querySelector(`tree-item-ui[value="${e}"]`)||this.querySelector(`tree-item-ui[text="${e}"]`)||null}return null}expand(t){let e=this.#t(t);e&&e.hasChildren&&!e.open&&(e.open=!0)}collapse(t){let e=this.#t(t);e&&e.open&&(e.open=!1)}expandAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.hasChildren&&!t.open&&(t.open=!0)}collapseAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.open&&(t.open=!1)}expandTo(t){let e=this.#t(t);if(!e)return;let i=e.parentElement?.closest("tree-item-ui");for(;i;)i.hasChildren&&!i.open&&(i.open=!0),i=i.parentElement?.closest("tree-item-ui");e.querySelector(':scope > [slot="row"]')?.scrollIntoView?.({block:"nearest",inline:"nearest"})}#e=t=>{let e=t.target.closest("tree-item-ui");if(!e||!this.contains(e)||t.target.closest('[slot="actions"] *'))return;let i=e.querySelector(':scope > [slot="row"]');!i||!(t.target===i||i.contains(t.target))||(this.select(e,t),e.hasChildren&&(e.open=!e.open))};#i=t=>{let e=t.target.closest("tree-item-ui");if(e)switch(t.key){case"ArrowRight":if(t.preventDefault(),e.hasChildren&&!e.open)e.open=!0;else{let i=e.querySelector(":scope > tree-item-ui");i&&i.querySelector('[slot="row"]')?.focus()}break;case"ArrowLeft":if(t.preventDefault(),e.hasChildren&&e.open)e.open=!1;else{let i=e.parentElement?.closest("tree-item-ui");i&&i.querySelector(':scope > [slot="row"]')?.focus()}break;case"ArrowDown":{t.preventDefault();let i=this.#s(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"ArrowUp":{t.preventDefault();let i=this.#r(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"Enter":case" ":t.preventDefault(),this.select(e,t);break}};#s(t){if(t.open&&t.hasChildren)return t.querySelector(":scope > tree-item-ui");let e=t;for(;e;){let i=e.nextElementSibling;if(i&&i.matches("tree-item-ui"))return i;e=e.parentElement?.closest("tree-item-ui")}return null}#r(t){let e=t.previousElementSibling;if(e&&e.matches("tree-item-ui")){let r=e;for(;r.open&&r.hasChildren;){let n=r.querySelectorAll(":scope > tree-item-ui");r=n[n.length-1]}return r}return t.parentElement?.closest("tree-item-ui")||null}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}},yr=class extends x{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},badge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;get hasChildren(){return this.querySelector(":scope > tree-item-ui")!==null}get depth(){let t=0,e=this.parentElement;for(;e;)e.matches("tree-item-ui")&&t++,e=e.parentElement;return t}connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="row"]')||this.#i();let t=this.querySelector(':scope > [slot="row"]');t&&(t.setAttribute("role","treeitem"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","0")),this.#r(),this.#t=new MutationObserver(()=>this.#r()),this.#t.observe(this,{childList:!0,subtree:!0})}#i(){let t=document.createElement("div");t.setAttribute("slot","row"),t.setAttribute("tabindex","0");let e=this.#s("caret")[0];if(e)t.appendChild(e);else{let o=document.createElement("icon-ui");o.setAttribute("slot","caret"),o.setAttribute("name","caret-right"),o.dataset.treeCaretDefault="1",t.appendChild(o)}if(this.icon){let o=document.createElement("icon-ui");o.setAttribute("name",this.icon),o.setAttribute("slot","icon"),t.appendChild(o)}let i=document.createElement("span");i.setAttribute("slot","text"),i.textContent=this.text,t.appendChild(i);let r=document.createElement("span");r.setAttribute("slot","badge"),this.badge&&(r.textContent=this.badge),t.appendChild(r);let n=document.createElement("span");n.setAttribute("slot","actions"),n.dataset.treeActionsPlaceholder="1",t.appendChild(n),this.prepend(t)}render(){let t=this.querySelector(':scope > [slot="row"]');if(!t)return;t.style.paddingInlineStart=`${this.depth*16+4}px`,this.hasChildren?t.setAttribute("aria-expanded",String(this.open)):t.removeAttribute("aria-expanded"),this.selected?t.setAttribute("aria-selected","true"):t.removeAttribute("aria-selected");let e=t.querySelector('[slot="text"]');e&&this.text&&(e.textContent=this.text);let i=t.querySelector('[slot="badge"]');i&&(i.textContent=this.badge||"")}#s(t){let e=[],i=r=>{for(let n of r.children)if(!n.matches("tree-item-ui")){if(n.getAttribute("slot")===t){e.push(n);continue}(n.matches('[role="presentation"]')||n.style?.display==="contents")&&i(n)}};return i(this),e}#r(){if(this.#e)return;let t=this.querySelector(':scope > [slot="row"]');if(t){this.#e=!0;try{let e=this.#s("actions").filter(r=>!r.dataset.treeActionsPlaceholder&&r.parentElement!==t);if(e.length){t.querySelector(':scope > [slot="actions"][data-tree-actions-placeholder]')?.remove();for(let r of e)t.appendChild(r)}let i=this.#s("caret").find(r=>!r.dataset.treeCaretDefault&&r.parentElement!==t);i&&(t.querySelector(':scope > [slot="caret"][data-tree-caret-default]')?.remove(),t.prepend(i))}finally{this.#t?.takeRecords(),this.#e=!1}}}disconnected(){this.#t?.disconnect(),this.#t=null}};S("tree-ui",Or),S("tree-item-ui",yr);$();var vr=class extends x{static requiredIcons=["caret-right"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},minWidth:{type:Number,default:200,attribute:"min-width",reflect:!0},maxWidth:{type:Number,default:9999,attribute:"max-width",reflect:!0},side:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=0;#s=0;#r=null;#n="";#a=!1;connected(){this.#a||(this.#a=!0,this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l)),this.resizable&&!this.querySelector('[slot="resize"]')&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","resize"),this.appendChild(this.#t)),(this.#t||this.resizable)&&(this.#t=this.#t||this.querySelector('[slot="resize"]'),this.#t?.addEventListener("pointerdown",this.#c))}render(){let t=this.querySelector(":scope > header");if(t&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-expanded",String(!this.collapsed)),!t.querySelector('[slot="caret"]'))){let e=document.createElement("icon-ui");e.setAttribute("slot","caret"),e.setAttribute("name","caret-right"),t.append(e)}}toggle(){this.collapsed=!this.collapsed,this.dispatchEvent(new Event("toggle",{bubbles:!0}))}#o=t=>{let e=this.querySelector(":scope > header");e&&(t.target===e||e.contains(t.target))&&this.toggle()};#l=t=>{t.target===this.querySelector(":scope > header")&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.toggle())};#c=t=>{if(t.isPrimary){t.preventDefault(),this.#e=!0,this.#i=t.clientX,this.#s=this.getBoundingClientRect().width,this.#r=t.pointerId,this.setAttribute("data-resizing","");try{this.#t.setPointerCapture(t.pointerId)}catch{}this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#d,{once:!0}),this.#t.addEventListener("pointercancel",this.#d,{once:!0}),this.#n=document.documentElement.style.cursor,document.documentElement.style.cursor="col-resize"}};#h=t=>{if(!this.#e)return;let e=this.side==="trailing"?-1:1,i=(t.clientX-this.#i)*e,r=Math.max(this.minWidth,Math.min(this.maxWidth,this.#s+i));this.style.width=`${r}px`};#d=()=>{if(this.#e){this.#e=!1,this.removeAttribute("data-resizing");try{this.#t?.releasePointerCapture(this.#r)}catch{}this.#r=null,this.#t?.removeEventListener("pointermove",this.#h),document.documentElement.style.cursor=this.#n}};disconnected(){this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#l),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#e&&(document.documentElement.style.cursor=this.#n),this.#a=!1}};S("pane-ui",vr);$();var xr=class extends x{static properties={scroll:{type:Boolean,default:!1,reflect:!0},maxWidth:{type:String,default:"",attribute:"max-width",reflect:!0},padding:{type:String,default:"",reflect:!0},stickyHeader:{type:Boolean,default:!1,attribute:"sticky-header",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.stickyHeader&&this.#i()}disconnected(){this.#s()}render(){this.stickyHeader&&!this.#t&&this.#i(),!this.stickyHeader&&this.#t&&this.#s()}#i(){let t=this.querySelector(":scope > :is(header, header-ui)");t&&(this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-page-sentinel",""),this.#t.style.cssText="height: 0; width: 0; pointer-events: none;",t.insertAdjacentElement("beforebegin",this.#t)),this.#e||(this.#e=new IntersectionObserver(e=>{this.toggleAttribute("data-header-stuck",!e[0].isIntersecting)},{threshold:0})),this.#e.observe(this.#t))}#s(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null,this.removeAttribute("data-header-stuck")}};S("page-ui",xr);$();var Ea=class extends x{static properties={disabled:{type:Boolean,default:!1,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Type a message...",reflect:!0},model:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=[];#n=[];#a=null;#o=null;#l=null;#c=()=>this.#o?.click();#h=()=>{this.#o?.files?.length&&this.#m(this.#o.files),this.#o&&(this.#o.value="")};get value(){return this.#t?.value?.trim()??""}get attachments(){return[...this.#n]}set models(t){this.#r=t||[],this.#i&&(this.#i.options=this.#r,this.model&&(this.#i.value=this.model))}get models(){return this.#r}connected(){this.querySelector('[slot="toolbar"]')||(this.innerHTML=`
140
140
  <textarea-ui placeholder="${this.placeholder}" rows="1"></textarea-ui>
141
141
  <div slot="toolbar">
142
142
  <select-ui slot="model" placeholder="Model" aria-label="Select model" divider></select-ui>
143
143
  <button-ui icon="paper-plane-right" variant="ghost" slot="send" aria-label="Send message"></button-ui>
144
144
  </div>
145
- `),this.#t=this.querySelector("textarea-ui"),this.#e=this.querySelector('[slot="send"]'),this.#i=this.querySelector('[slot="model"]'),this.#e&&!this.#e.hasAttribute("aria-label")&&this.#e.setAttribute("aria-label","Send message"),this.#i&&!this.#i.hasAttribute("aria-label")&&this.#i.setAttribute("aria-label","Select model"),this.#r.length&&this.#i&&(this.#i.options=this.#r,this.model&&(this.#i.value=this.model));let t=this.querySelector('[slot="toolbar"]');if(t&&!t.querySelector('[slot="attach"]')){this.#o=document.createElement("input"),this.#o.type="file",this.#o.accept="image/*",this.#o.multiple=!0,this.#o.style.display="none",this.appendChild(this.#o),this.#s=document.createElement("button-ui"),this.#s.setAttribute("icon","image"),this.#s.setAttribute("variant","ghost"),this.#s.setAttribute("slot","attach"),this.#s.setAttribute("size","sm"),this.#s.setAttribute("aria-label","Attach image");let e=t.querySelector('[slot="send"]');t.insertBefore(this.#s,e),this.#s.addEventListener("press",this.#c),this.#o.addEventListener("change",this.#h)}this.#a=document.createElement("div"),this.#a.setAttribute("slot","preview"),this.#a.hidden=!0,this.insertBefore(this.#a,this.querySelector('[slot="toolbar"]')),this.addEventListener("paste",this.#p),this.#e?.addEventListener("press",this.#f),this.#t?.addEventListener("submit",this.#f),this.#i?.addEventListener("change",this.#d),this.addEventListener("pointerdown",this.#u)}render(){this.#t&&(this.#t.disabled=this.disabled,this.#t.placeholder=this.placeholder),this.#e&&(this.#e.disabled=this.disabled||this.loading),this.#i&&this.model&&this.#i.value!==this.model&&(this.#i.value=this.model)}#u=t=>{t.target.closest("button-ui, select-ui, input-ui, a")||(this.#l=requestAnimationFrame(()=>{this.#l=null,this.#t?.focus()}))};#d=()=>{this.model=this.#i?.value||""};#f=()=>{if(this.disabled||this.loading)return;let t=this.value;!t&&!this.#n.length||this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,detail:{text:t,model:this.model,attachments:this.attachments}}))};#p=t=>{let e=t.clipboardData?.items;if(!e)return;let i=[...e].filter(n=>n.type.startsWith("image/"));if(i.length===0)return;t.preventDefault();let r=i.map(n=>n.getAsFile()).filter(Boolean);r.length&&this.#m(r)};#m(t){for(let e of t){let i=new FileReader;i.onload=()=>{this.#n.push({type:"image",dataUrl:i.result,name:e.name}),this.#b()},i.readAsDataURL(e)}}#g(t){this.#n.splice(t,1),this.#b()}#b(){this.#a&&(this.#a.innerHTML="",this.#a.hidden=this.#n.length===0,this.#n.forEach((t,e)=>{let i=document.createElement("div");i.setAttribute("data-preview-item","");let r=document.createElement("img");r.src=t.dataUrl,r.alt=t.name||"attachment";let n=document.createElement("button");n.textContent="\xD7",n.setAttribute("data-preview-remove",""),n.addEventListener("click",()=>this.#g(e)),i.appendChild(r),i.appendChild(n),this.#a.appendChild(i)}))}clear(){this.#t?.clear(),this.#n=[],this.#a&&(this.#a.innerHTML="",this.#a.hidden=!0)}focus(){this.#t?.focus()}disconnected(){this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.removeEventListener("paste",this.#p),this.#e?.removeEventListener("press",this.#f),this.#t?.removeEventListener("submit",this.#f),this.#i?.removeEventListener("change",this.#d),this.#s?.removeEventListener("press",this.#c),this.#o?.removeEventListener("change",this.#h),this.removeEventListener("pointerdown",this.#u),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#a=null,this.#o=null}};customElements.define("chat-input-ui",Ea);var lC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},KO=s=>s.replace(/[&<>"]/g,t=>lC[t]);function ci(s){let t=s.split(`
145
+ `),this.#t=this.querySelector("textarea-ui"),this.#e=this.querySelector('[slot="send"]'),this.#i=this.querySelector('[slot="model"]'),this.#e&&!this.#e.hasAttribute("aria-label")&&this.#e.setAttribute("aria-label","Send message"),this.#i&&!this.#i.hasAttribute("aria-label")&&this.#i.setAttribute("aria-label","Select model"),this.#r.length&&this.#i&&(this.#i.options=this.#r,this.model&&(this.#i.value=this.model));let t=this.querySelector('[slot="toolbar"]');if(t&&!t.querySelector('[slot="attach"]')){this.#o=document.createElement("input"),this.#o.type="file",this.#o.accept="image/*",this.#o.multiple=!0,this.#o.style.display="none",this.appendChild(this.#o),this.#s=document.createElement("button-ui"),this.#s.setAttribute("icon","image"),this.#s.setAttribute("variant","ghost"),this.#s.setAttribute("slot","attach"),this.#s.setAttribute("size","sm"),this.#s.setAttribute("aria-label","Attach image");let e=t.querySelector('[slot="send"]');t.insertBefore(this.#s,e),this.#s.addEventListener("press",this.#c),this.#o.addEventListener("change",this.#h)}this.#a=document.createElement("div"),this.#a.setAttribute("slot","preview"),this.#a.hidden=!0,this.insertBefore(this.#a,this.querySelector('[slot="toolbar"]')),this.addEventListener("paste",this.#p),this.#e?.addEventListener("press",this.#f),this.#t?.addEventListener("submit",this.#f),this.#i?.addEventListener("change",this.#u),this.addEventListener("pointerdown",this.#d)}render(){this.#t&&(this.#t.disabled=this.disabled,this.#t.placeholder=this.placeholder),this.#e&&(this.#e.disabled=this.disabled||this.loading),this.#i&&this.model&&this.#i.value!==this.model&&(this.#i.value=this.model)}#d=t=>{t.target.closest("button-ui, select-ui, input-ui, a")||(this.#l=requestAnimationFrame(()=>{this.#l=null,this.#t?.focus()}))};#u=()=>{this.model=this.#i?.value||""};#f=()=>{if(this.disabled||this.loading)return;let t=this.value;!t&&!this.#n.length||this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,detail:{text:t,model:this.model,attachments:this.attachments}}))};#p=t=>{let e=t.clipboardData?.items;if(!e)return;let i=[...e].filter(n=>n.type.startsWith("image/"));if(i.length===0)return;t.preventDefault();let r=i.map(n=>n.getAsFile()).filter(Boolean);r.length&&this.#m(r)};#m(t){for(let e of t){let i=new FileReader;i.onload=()=>{this.#n.push({type:"image",dataUrl:i.result,name:e.name}),this.#b()},i.readAsDataURL(e)}}#g(t){this.#n.splice(t,1),this.#b()}#b(){this.#a&&(this.#a.innerHTML="",this.#a.hidden=this.#n.length===0,this.#n.forEach((t,e)=>{let i=document.createElement("div");i.setAttribute("data-preview-item","");let r=document.createElement("img");r.src=t.dataUrl,r.alt=t.name||"attachment";let n=document.createElement("button");n.textContent="\xD7",n.setAttribute("data-preview-remove",""),n.addEventListener("click",()=>this.#g(e)),i.appendChild(r),i.appendChild(n),this.#a.appendChild(i)}))}clear(){this.#t?.clear(),this.#n=[],this.#a&&(this.#a.innerHTML="",this.#a.hidden=!0)}focus(){this.#t?.focus()}disconnected(){this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.removeEventListener("paste",this.#p),this.#e?.removeEventListener("press",this.#f),this.#t?.removeEventListener("submit",this.#f),this.#i?.removeEventListener("change",this.#u),this.#s?.removeEventListener("press",this.#c),this.#o?.removeEventListener("change",this.#h),this.removeEventListener("pointerdown",this.#d),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#a=null,this.#o=null}};customElements.define("chat-input-ui",Ea);var lC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},KO=s=>s.replace(/[&<>"]/g,t=>lC[t]);function ci(s){let t=s.split(`
146
146
  `),e=[],i=0;for(;i<t.length;){let r=t[i],n=r.match(/^```(\w*)/);if(n){let l=n[1],h=[];for(i++;i<t.length&&!t[i].startsWith("```");)h.push(KO(t[i])),i++;i++;let c=h.join(`
147
147
  `);e.push(l?`<code-ui language="${l}">${c}</code-ui>`:`<pre><code>${c}</code></pre>`);continue}if(!r.trim()){i++;continue}let o=r.match(/^(#{1,6})\s+(.+)/);if(o){let l=o[1].length;e.push(`<h${l}>${vh(o[2])}</h${l}>`),i++;continue}if(/^[-*]\s/.test(r)){let l=[];for(;i<t.length&&/^[-*]\s/.test(t[i]);)l.push(`<li>${vh(t[i].replace(/^[-*]\s/,""))}</li>`),i++;e.push(`<ul>${l.join("")}</ul>`);continue}if(/^\d+\.\s/.test(r)){let l=[];for(;i<t.length&&/^\d+\.\s/.test(t[i]);)l.push(`<li>${vh(t[i].replace(/^\d+\.\s/,""))}</li>`),i++;e.push(`<ol>${l.join("")}</ol>`);continue}let a=[];for(;i<t.length&&t[i].trim()&&!/^```|^#{1,6}\s|^[-*]\s|^\d+\.\s/.test(t[i]);)a.push(t[i]),i++;e.push(`<p>${vh(a.join(" "))}</p>`)}return e.join(`
148
148
  `)}function vh(s){return KO(s).replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/_(.+?)_/g,"<em>$1</em>").replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>')}$();function hC(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Sr=class extends x{static properties={streaming:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;#i=null;#s=null;get messages(){return[...this.#t]}connected(){!this.querySelector("header")&&!this.querySelector("section")&&(this.innerHTML=`
@@ -157,7 +157,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
157
157
  `),this.#e=this.querySelector("section"),this.#i=this.querySelector("chat-input-ui"),this.#i?.addEventListener("submit",this.#r)}disconnected(){this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#i?.removeEventListener("submit",this.#r),this.#e=null,this.#i=null}#r=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 r=document.createElement("div");r.setAttribute("data-role",t);let n=i?ci(e):hC(e);if(t==="user")r.innerHTML=`<div slot="bubble">${n}</div>`;else{let o=i?"":'<span slot="cursor"></span>';r.innerHTML=`
158
158
  <span slot="avatar">${t==="assistant"?"AI":t[0].toUpperCase()}</span>
159
159
  <div slot="bubble">${n}${o}</div>
160
- `}return this.#e?.appendChild(r),this.#n(),r}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 r=i.querySelector('[slot="cursor"]');r&&r.remove(),i.insertAdjacentText("beforeend",t),i.insertAdjacentHTML("beforeend",'<span slot="cursor"></span>')}this.#n()}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=ci(t.content))}this.#i?.focus()}clear(){this.#t.length=0,this.#e&&(this.#e.innerHTML="")}#n(){let t=this.#e;t&&(this.#s!=null&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.isConnected&&(t.scrollTop=t.scrollHeight)}))}};S("chat-thread-ui",Sr);$();var wr=class extends x{#t=!1;#e=!1;#i=null;#s=null;#r=null;#n=null;#a="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})}}#o=t=>{t.target.closest('[slot="close"]')&&(this.#a="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#a="escape",this.permanent||(this.open=!1)};#c=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#a;this.#a="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#n&&!this.permanent&&(this.#a="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#o);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h))}disconnected(){this.removeEventListener("press",this.#o),this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#h)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#r!=null&&(clearTimeout(this.#r),this.#r=null),this.#t=!1,this.#n=null}#u(){let t=getComputedStyle(this).getPropertyValue("--drawer-duration").trim();return parseFloat(t)||200}#d(t,e,i="append"){let r={header:"header",body:"section",footer:"footer"}[t],n=h=>h.getAttribute("slot")===t||r&&!h.getAttribute("slot")&&h.localName===r,o=[...this.children].find(n),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.#n&&(this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#h)),this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),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 r=[...this.children].filter(o=>o.getAttribute("slot")==="body"||o.localName==="section"&&!o.getAttribute("slot"));if(r.length===0)this.#d("body",e,"append");else for(let o of r)o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o);let n=[...this.children].find(o=>o.getAttribute("slot")==="footer"||!o.getAttribute("slot")&&o.localName==="footer");n&&(n.getAttribute("slot")!=="footer"&&n.setAttribute("slot","footer"),n.parentElement!==e&&e.appendChild(n)),this.#f()}#f(){let t=this.#n;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.#r!=null&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.dispatchEvent(new CustomEvent("opened",{bubbles:!0}))},this.#u())}else!this.open&&t.open&&!this.#e&&this.#p(t)}#p(t){this.#e=!0,this.#r!=null&&(clearTimeout(this.#r),this.#r=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.#u())}show(){this.open=!0}hide(){this.open=!1}};S("drawer-ui",wr);$();var kr=class extends x{#t=!1;#e=!1;#i=null;#s=null;#r=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>'};#n=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#a=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#o=()=>{this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0}))};#l=t=>{t.target===this.#r&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#n);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#r=t,t.addEventListener("cancel",this.#a),t.addEventListener("close",this.#o),t.addEventListener("click",this.#l))}disconnected(){this.removeEventListener("press",this.#n),this.#r&&(this.#r.removeEventListener("cancel",this.#a),this.#r.removeEventListener("close",this.#o),this.#r.removeEventListener("click",this.#l)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#t=!1,this.#r=null}#c(){let t=getComputedStyle(this),e=t.getPropertyValue("--modal-duration").trim()||t.getPropertyValue("--modal-duration-default").trim();return parseFloat(e)||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),this.text?i.setAttribute("text",this.text):i.removeAttribute("text"),this.permanent)this.drop("close");else{let l=this.ensure("close");l.parentElement!==i&&i.appendChild(l)}let r=[...this.children].find(l=>l.getAttribute("slot")==="body"||!l.getAttribute("slot")&&l.localName==="section"),n=[...this.children].filter(l=>!l.getAttribute("slot")&&l.localName!=="section"&&l.localName!=="dialog"&&l.localName!=="footer"),o;r?(r.getAttribute("slot")!=="body"&&r.setAttribute("slot","body"),r.parentElement!==e&&e.appendChild(r),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),o=r):(o=this.ensure("body"),o.setAttribute("data-stamped",""),o.parentElement!==e&&e.appendChild(o));for(let l of n)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.#c())}show(){this.open=!0}hide(){this.open=!1}};S("modal-ui",kr);$();var Ar=class extends x{static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>it``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},Er=class s extends x{#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=()=>it``;#r=t=>{if(t.target.closest("[data-feed-close]")){this.dismiss();return}if(t.target.closest("[data-feed-action]")){try{this.#n?.()}catch(e){console.warn("[feed-item] action handler threw:",e)}this.dismiss()}};#n=null;#a=null;#o=null;connected(){this.addEventListener("press",this.#r)}#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",r=e&&!!this.action,n="status";r?n="alertdialog":e&&i&&(n="alert"),this.setAttribute("role",n),this.setAttribute("aria-live",n==="alert"||n==="alertdialog"?"assertive":"polite"),r&&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(),r?this.#h():this.#u(),!this.hasAttribute("data-open")&&!this.#e&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("data-open","")})),this.#c()}#c(){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")&&Ze.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.#n=t.onAction),this.#c()}}#h(){if(this.#o)return;this.#a=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.#o=e=>{if(e.key==="Escape"){e.stopPropagation(),this.dismiss();return}if(e.key!=="Tab")return;let i=t();if(!i.length)return;let r=i[0],n=i[i.length-1],o=document.activeElement;e.shiftKey&&o===r?(e.preventDefault(),n.focus()):!e.shiftKey&&o===n&&(e.preventDefault(),r.focus())},this.addEventListener("keydown",this.#o,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#u(){if(this.#o){this.removeEventListener("keydown",this.#o,!0),this.#o=null;try{this.#a?.focus?.()}catch{}this.#a=null}}disconnected(){this.removeEventListener("press",this.#r),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.#u()}},Ze=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:r="",variant:n="default",duration:o=4e3,position:a="bottom-right",dismissible:l,id:h,action:c="",onAction:u}=t,d=n==="error"?"danger":n,f=s.get(a),p=parseInt(f.getAttribute("max")||"5",10),m=[...f.children].filter(y=>y.tagName==="FEED-ITEM-UI"&&!y.hasAttribute("data-queued")).length,b=document.createElement("feed-item-ui");h&&b.setAttribute("data-id",h),b.text=e,b.heading=i,b.icon=r,b.variant=d;let g="duration"in t;return b.duration=c&&!g?0:o,l!=null&&(b.dismissible=!!l),c&&(b.action=c),m>=p&&b.setAttribute("data-queued",""),f.appendChild(b),typeof u=="function"&&b.update({onAction:u}),{id:h??null,dismiss:()=>b.dismiss(),update:y=>b.update(y)}}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,r]of s.#t)r===t&&s.#t.delete(i)}}};S("feed-ui",Ar),S("feed-item-ui",Er),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&Ze.post(s.detail)}));$();var ls=class extends x{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=()=>it``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,Ze.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",position:r="bottom-right",action:n,onAction:o}=t,a=Ze.get(r);a&&!a.hasAttribute("data-spawned-by")&&a.setAttribute("data-spawned-by","toast");let l={text:e,variant:i==="error"?"danger":i,position:r};return"duration"in t&&(l.duration=t.duration),"dismissible"in t&&(l.dismissible=!!t.dismissible),n&&(l.action=n),typeof o=="function"&&(l.onAction=o),Ze.post(l)}};S("toast-ui",ls),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&ls.show(s.detail)}));$();var Ca=class extends x{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",Ca);$();var Cr=class extends x{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.#o),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.#o),this.removeEventListener("keydown",this.#l),this.#t=null,this.#e=null}get#s(){return[...this.querySelectorAll("tab-ui")]}get#r(){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,r)=>{let n=e.value||e.getAttribute("value")||"",o=e.text||e.getAttribute("text")||"",a=e.icon||e.getAttribute("icon")||"",l=n===this.value,h=e.disabled||e.hasAttribute("disabled");if(r){if(r.textContent="",a){let u=document.createElement("icon-ui");u.setAttribute("name",a),r.appendChild(u)}return o&&r.appendChild(document.createTextNode(o)),r.setAttribute("aria-selected",String(l)),r.setAttribute("tabindex",l?"0":"-1"),h?r.setAttribute("disabled",""):r.removeAttribute("disabled"),l?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.dataset.value=n,r}let c=document.createElement("div");if(c.setAttribute("role","tab"),c.setAttribute("slot","tab-button"),c.dataset.value=n,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.#n();for(let e of t)(e.value||e.getAttribute("value")||"")===this.value?(e.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):e.setAttribute("hidden","")}}#n(){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(),r=t.getBoundingClientRect(),n=this.orientation==="vertical",o=()=>{if(n){let a=r.top-i.top;this.#e.style.transform=`translateY(${a}px)`,this.#e.style.height=`${r.height}px`,this.#e.style.width=""}else{let a=r.left-i.left;this.#e.style.transform=`translateX(${a}px)`,this.#e.style.width=`${r.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()}#a(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#o=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#a(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])')],r=i.indexOf(e);if(r<0)return;let n=this.orientation==="vertical",o=n?"ArrowDown":"ArrowRight",a=n?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=r<i.length-1?r+1:0;break;case a:l=r>0?r-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.#a(i[l].dataset.value)}};S("tabs-ui",Cr);$();var $r=class s extends x{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;#r=null;connected(){this.follows==="pointer"?this.#c():(this.addEventListener("mouseenter",this.#n),this.addEventListener("focusin",this.#n),this.addEventListener("mouseleave",this.#a),this.addEventListener("focusout",this.#a))}disconnected(){this.removeEventListener("mouseenter",this.#n),this.removeEventListener("focusin",this.#n),this.removeEventListener("mouseleave",this.#a),this.removeEventListener("focusout",this.#a),this.#h(),this.#l()}render(){this.#t&&this.follows!=="pointer"&&(this.#t.textContent=this.text),this.#t&&this.follows==="pointer"&&this.#r&&this.#m(this.#r)}#n=()=>{this.text&&(this.#e&&clearTimeout(this.#e),this.#e=setTimeout(()=>this.#o(),this.delay))};#a=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#o(){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=ct(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.#r=null}}#c(){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.#u)}#h(){this.#s&&(this.#s.removeEventListener("chart-hover",this.#d),this.#s.removeEventListener("chart-leave",this.#u)),this.#s=null}#u=()=>this.#l();#d=t=>{let e=t.detail;if(e){if(this.#r=e,!this.#t){this.#t=this.#f(),this.#p();try{this.#t.showPopover()}catch{}}this.#m(e),this.#g(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 r=t[i];r.startsWith("--color-")&&this.#t.style.setProperty(r,t.getPropertyValue(r))}let e=getComputedStyle(this.#s);for(let i=0;i<10;i++){let r=e.getPropertyValue(`--chart-${i}`).trim();r&&this.#t.style.setProperty(`--chart-${i}`,r)}}#m(t){if(!this.#t)return;let{label:e,value:i,pct:r,series:n,slot:o,payload:a}=t,l=this.indicator||"none",h=Array.isArray(a)&&a.length>0?a:[{series:n,label:e,value:i,pct:r,slot:o,hovered:!0}],c=[];e!=null&&c.push(`<span data-tip-role="label">${this.#b(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,b=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let g=f!=null?this.#b(String(f)):"",y=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",v=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${b}"></span>`:"",w=d?`<span data-tip-role="name">${this.#b(d)}</span>`:"",k=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${k}>${v}${w}<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("")}#g(t,e){if(!this.#t||t==null||e==null)return;let i=12,r=8,n=this.#t;n.style.position="fixed",n.style.left="0",n.style.top="0";let o=n.offsetWidth||0,a=n.offsetHeight||0,l=t-o/2,h=e-a-i;l<r&&(l=r),l+o>window.innerWidth-r&&(l=window.innerWidth-o-r),h<r&&(h=e+i),n.style.left=`${l}px`,n.style.top=`${h}px`}#b(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}};S("tooltip-ui",$r);$();var cC={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"}},Pr=class extends x{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=cC[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()}};S("badge-ui",Pr);$();var Qr=class extends x{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),r=Math.max(0,this.collapseKeepTrailing|0),n=i+r+1;if(this.collapse&&t.length>=Math.max(n,4)){let l=t.slice(i,t.length-r);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 r of t){let n=document.createElement("menu-item-ui");n.setAttribute("text",r.textContent.trim()),r.tagName==="A"&&r.hasAttribute("href")&&n.setAttribute("value",r.getAttribute("href")),e.appendChild(n)}return e.addEventListener("action",r=>{let n=r.detail?.value;n&&n!=="#"&&(window.location.href=n)}),e}};S("breadcrumb-ui",Qr);$();var Tr=class s extends x{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;#r=null;#n=null;#a=null;#o=!1;#l=new WeakMap;static#c=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)};#u=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.#y(i)};connected(){this.#o||(this.#o=!0,this.addEventListener("keydown",this.#k))}render(){this.#s||(this.#d(),this.innerHTML=`
160
+ `}return this.#e?.appendChild(r),this.#n(),r}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 r=i.querySelector('[slot="cursor"]');r&&r.remove(),i.insertAdjacentText("beforeend",t),i.insertAdjacentHTML("beforeend",'<span slot="cursor"></span>')}this.#n()}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=ci(t.content))}this.#i?.focus()}clear(){this.#t.length=0,this.#e&&(this.#e.innerHTML="")}#n(){let t=this.#e;t&&(this.#s!=null&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.isConnected&&(t.scrollTop=t.scrollHeight)}))}};S("chat-thread-ui",Sr);$();var wr=class extends x{#t=!1;#e=!1;#i=null;#s=null;#r=null;#n=null;#a="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})}}#o=t=>{t.target.closest('[slot="close"]')&&(this.#a="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#a="escape",this.permanent||(this.open=!1)};#c=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#a;this.#a="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#n&&!this.permanent&&(this.#a="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#o);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h))}disconnected(){this.removeEventListener("press",this.#o),this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#h)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#r!=null&&(clearTimeout(this.#r),this.#r=null),this.#t=!1,this.#n=null}#d(){let t=getComputedStyle(this).getPropertyValue("--drawer-duration").trim();return parseFloat(t)||200}#u(t,e,i="append"){let r={header:"header",body:"section",footer:"footer"}[t],n=h=>h.getAttribute("slot")===t||r&&!h.getAttribute("slot")&&h.localName===r,o=[...this.children].find(n),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.#n&&(this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#h)),this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),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.#u("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 r=[...this.children].filter(o=>o.getAttribute("slot")==="body"||o.localName==="section"&&!o.getAttribute("slot"));if(r.length===0)this.#u("body",e,"append");else for(let o of r)o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o);let n=[...this.children].find(o=>o.getAttribute("slot")==="footer"||!o.getAttribute("slot")&&o.localName==="footer");n&&(n.getAttribute("slot")!=="footer"&&n.setAttribute("slot","footer"),n.parentElement!==e&&e.appendChild(n)),this.#f()}#f(){let t=this.#n;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.#r!=null&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.dispatchEvent(new CustomEvent("opened",{bubbles:!0}))},this.#d())}else!this.open&&t.open&&!this.#e&&this.#p(t)}#p(t){this.#e=!0,this.#r!=null&&(clearTimeout(this.#r),this.#r=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.#d())}show(){this.open=!0}hide(){this.open=!1}};S("drawer-ui",wr);$();var kr=class extends x{#t=!1;#e=!1;#i=null;#s=null;#r=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>'};#n=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#a=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#o=()=>{this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0}))};#l=t=>{t.target===this.#r&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#n);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#r=t,t.addEventListener("cancel",this.#a),t.addEventListener("close",this.#o),t.addEventListener("click",this.#l))}disconnected(){this.removeEventListener("press",this.#n),this.#r&&(this.#r.removeEventListener("cancel",this.#a),this.#r.removeEventListener("close",this.#o),this.#r.removeEventListener("click",this.#l)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#t=!1,this.#r=null}#c(){let e=getComputedStyle(this).getPropertyValue("--modal-duration").trim();return parseFloat(e)||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),this.text?i.setAttribute("text",this.text):i.removeAttribute("text"),this.permanent)this.drop("close");else{let l=this.ensure("close");l.parentElement!==i&&i.appendChild(l)}let r=[...this.children].find(l=>l.getAttribute("slot")==="body"||!l.getAttribute("slot")&&l.localName==="section"),n=[...this.children].filter(l=>!l.getAttribute("slot")&&l.localName!=="section"&&l.localName!=="dialog"&&l.localName!=="footer"),o;r?(r.getAttribute("slot")!=="body"&&r.setAttribute("slot","body"),r.parentElement!==e&&e.appendChild(r),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),o=r):(o=this.ensure("body"),o.setAttribute("data-stamped",""),o.parentElement!==e&&e.appendChild(o));for(let l of n)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.#c())}show(){this.open=!0}hide(){this.open=!1}};S("modal-ui",kr);$();var Ar=class extends x{static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>it``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},Er=class s extends x{#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=()=>it``;#r=t=>{if(t.target.closest("[data-feed-close]")){this.dismiss();return}if(t.target.closest("[data-feed-action]")){try{this.#n?.()}catch(e){console.warn("[feed-item] action handler threw:",e)}this.dismiss()}};#n=null;#a=null;#o=null;connected(){this.addEventListener("press",this.#r)}#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",r=e&&!!this.action,n="status";r?n="alertdialog":e&&i&&(n="alert"),this.setAttribute("role",n),this.setAttribute("aria-live",n==="alert"||n==="alertdialog"?"assertive":"polite"),r&&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(),r?this.#h():this.#d(),!this.hasAttribute("data-open")&&!this.#e&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("data-open","")})),this.#c()}#c(){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")&&Ze.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.#n=t.onAction),this.#c()}}#h(){if(this.#o)return;this.#a=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.#o=e=>{if(e.key==="Escape"){e.stopPropagation(),this.dismiss();return}if(e.key!=="Tab")return;let i=t();if(!i.length)return;let r=i[0],n=i[i.length-1],o=document.activeElement;e.shiftKey&&o===r?(e.preventDefault(),n.focus()):!e.shiftKey&&o===n&&(e.preventDefault(),r.focus())},this.addEventListener("keydown",this.#o,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#d(){if(this.#o){this.removeEventListener("keydown",this.#o,!0),this.#o=null;try{this.#a?.focus?.()}catch{}this.#a=null}}disconnected(){this.removeEventListener("press",this.#r),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.#d()}},Ze=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:r="",variant:n="default",duration:o=4e3,position:a="bottom-right",dismissible:l,id:h,action:c="",onAction:u}=t,d=n==="error"?"danger":n,f=s.get(a),p=parseInt(f.getAttribute("max")||"5",10),m=[...f.children].filter(y=>y.tagName==="FEED-ITEM-UI"&&!y.hasAttribute("data-queued")).length,b=document.createElement("feed-item-ui");h&&b.setAttribute("data-id",h),b.text=e,b.heading=i,b.icon=r,b.variant=d;let g="duration"in t;return b.duration=c&&!g?0:o,l!=null&&(b.dismissible=!!l),c&&(b.action=c),m>=p&&b.setAttribute("data-queued",""),f.appendChild(b),typeof u=="function"&&b.update({onAction:u}),{id:h??null,dismiss:()=>b.dismiss(),update:y=>b.update(y)}}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,r]of s.#t)r===t&&s.#t.delete(i)}}};S("feed-ui",Ar),S("feed-item-ui",Er),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&Ze.post(s.detail)}));$();var ls=class extends x{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=()=>it``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,Ze.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",position:r="bottom-right",action:n,onAction:o}=t,a=Ze.get(r);a&&!a.hasAttribute("data-spawned-by")&&a.setAttribute("data-spawned-by","toast");let l={text:e,variant:i==="error"?"danger":i,position:r};return"duration"in t&&(l.duration=t.duration),"dismissible"in t&&(l.dismissible=!!t.dismissible),n&&(l.action=n),typeof o=="function"&&(l.onAction=o),Ze.post(l)}};S("toast-ui",ls),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&ls.show(s.detail)}));$();var Ca=class extends x{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",Ca);$();var Cr=class extends x{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.#o),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.#o),this.removeEventListener("keydown",this.#l),this.#t=null,this.#e=null}get#s(){return[...this.querySelectorAll("tab-ui")]}get#r(){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,r)=>{let n=e.value||e.getAttribute("value")||"",o=e.text||e.getAttribute("text")||"",a=e.icon||e.getAttribute("icon")||"",l=n===this.value,h=e.disabled||e.hasAttribute("disabled");if(r){if(r.textContent="",a){let u=document.createElement("icon-ui");u.setAttribute("name",a),r.appendChild(u)}return o&&r.appendChild(document.createTextNode(o)),r.setAttribute("aria-selected",String(l)),r.setAttribute("tabindex",l?"0":"-1"),h?r.setAttribute("disabled",""):r.removeAttribute("disabled"),l?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.dataset.value=n,r}let c=document.createElement("div");if(c.setAttribute("role","tab"),c.setAttribute("slot","tab-button"),c.dataset.value=n,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.#n();for(let e of t)(e.value||e.getAttribute("value")||"")===this.value?(e.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):e.setAttribute("hidden","")}}#n(){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(),r=t.getBoundingClientRect(),n=this.orientation==="vertical",o=()=>{if(n){let a=r.top-i.top;this.#e.style.transform=`translateY(${a}px)`,this.#e.style.height=`${r.height}px`,this.#e.style.width=""}else{let a=r.left-i.left;this.#e.style.transform=`translateX(${a}px)`,this.#e.style.width=`${r.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()}#a(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#o=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#a(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])')],r=i.indexOf(e);if(r<0)return;let n=this.orientation==="vertical",o=n?"ArrowDown":"ArrowRight",a=n?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=r<i.length-1?r+1:0;break;case a:l=r>0?r-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.#a(i[l].dataset.value)}};S("tabs-ui",Cr);$();var $r=class s extends x{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;#r=null;connected(){this.follows==="pointer"?this.#c():(this.addEventListener("mouseenter",this.#n),this.addEventListener("focusin",this.#n),this.addEventListener("mouseleave",this.#a),this.addEventListener("focusout",this.#a))}disconnected(){this.removeEventListener("mouseenter",this.#n),this.removeEventListener("focusin",this.#n),this.removeEventListener("mouseleave",this.#a),this.removeEventListener("focusout",this.#a),this.#h(),this.#l()}render(){this.#t&&this.follows!=="pointer"&&(this.#t.textContent=this.text),this.#t&&this.follows==="pointer"&&this.#r&&this.#m(this.#r)}#n=()=>{this.text&&(this.#e&&clearTimeout(this.#e),this.#e=setTimeout(()=>this.#o(),this.delay))};#a=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#o(){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=ct(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.#r=null}}#c(){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.#u),this.#s.addEventListener("chart-leave",this.#d)}#h(){this.#s&&(this.#s.removeEventListener("chart-hover",this.#u),this.#s.removeEventListener("chart-leave",this.#d)),this.#s=null}#d=()=>this.#l();#u=t=>{let e=t.detail;if(e){if(this.#r=e,!this.#t){this.#t=this.#f(),this.#p();try{this.#t.showPopover()}catch{}}this.#m(e),this.#g(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 r=t[i];r.startsWith("--color-")&&this.#t.style.setProperty(r,t.getPropertyValue(r))}let e=getComputedStyle(this.#s);for(let i=0;i<10;i++){let r=e.getPropertyValue(`--chart-${i}`).trim();r&&this.#t.style.setProperty(`--chart-${i}`,r)}}#m(t){if(!this.#t)return;let{label:e,value:i,pct:r,series:n,slot:o,payload:a}=t,l=this.indicator||"none",h=Array.isArray(a)&&a.length>0?a:[{series:n,label:e,value:i,pct:r,slot:o,hovered:!0}],c=[];e!=null&&c.push(`<span data-tip-role="label">${this.#b(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,b=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let g=f!=null?this.#b(String(f)):"",y=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",v=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${b}"></span>`:"",w=d?`<span data-tip-role="name">${this.#b(d)}</span>`:"",k=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${k}>${v}${w}<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("")}#g(t,e){if(!this.#t||t==null||e==null)return;let i=12,r=8,n=this.#t;n.style.position="fixed",n.style.left="0",n.style.top="0";let o=n.offsetWidth||0,a=n.offsetHeight||0,l=t-o/2,h=e-a-i;l<r&&(l=r),l+o>window.innerWidth-r&&(l=window.innerWidth-o-r),h<r&&(h=e+i),n.style.left=`${l}px`,n.style.top=`${h}px`}#b(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}};S("tooltip-ui",$r);$();var cC={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"}},Pr=class extends x{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=cC[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()}};S("badge-ui",Pr);$();var Qr=class extends x{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),r=Math.max(0,this.collapseKeepTrailing|0),n=i+r+1;if(this.collapse&&t.length>=Math.max(n,4)){let l=t.slice(i,t.length-r);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 r of t){let n=document.createElement("menu-item-ui");n.setAttribute("text",r.textContent.trim()),r.tagName==="A"&&r.hasAttribute("href")&&n.setAttribute("value",r.getAttribute("href")),e.appendChild(n)}return e.addEventListener("action",r=>{let n=r.detail?.value;n&&n!=="#"&&(window.location.href=n)}),e}};S("breadcrumb-ui",Qr);$();var Tr=class s extends x{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;#r=null;#n=null;#a=null;#o=!1;#l=new WeakMap;static#c=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)};#d=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.#O(i)};connected(){this.#o||(this.#o=!0,this.addEventListener("keydown",this.#k))}render(){this.#s||(this.#u(),this.innerHTML=`
161
161
  <header>
162
162
  <icon-ui name="magnifying-glass" slot="icon"></icon-ui>
163
163
  <input type="text" placeholder="${this.placeholder}" slot="input" />
@@ -168,26 +168,26 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
168
168
  <span data-hint><kbd>\u21B5</kbd> Select</span>
169
169
  <span data-hint><kbd>\u238B</kbd> Close</span>
170
170
  </footer>
171
- `,this.#s=this.querySelector("input"),this.#r=this.querySelector('[slot="list"]'),this.#a=this.querySelector("footer"),this.#s.addEventListener("input",this.#x),this.#r.addEventListener("click",this.#h),this.#r.addEventListener("pointerover",this.#u),this.#p()),this.open&&(this.#n=requestAnimationFrame(()=>{this.#n=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,r={label:i,items:[]};for(let n of e.querySelectorAll("option"))r.items.push(this.#f(n,i));t.push(r)}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.#r)return;this.#r.innerHTML="",this.#i=-1;let e=t.toLowerCase(),i=this.#t,r=0;if(!e&&this.#e.length){let n=this.#e.map(o=>this.#m(o)).filter(o=>o&&!o.disabled);if(n.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 n)o.appendChild(this.#b(a,r)),r++;this.#r.appendChild(o)}}for(let n of i)if(n.items){let o=n.items.filter(l=>this.#O(l,e));if(!o.length)continue;let a=document.createElement("div");a.setAttribute("data-group",""),a.innerHTML=`<div data-group-label>${n.label}</div>`;for(let l of o)a.appendChild(this.#b(l,r)),r++;this.#r.appendChild(a)}else{if(!this.#O(n,e))continue;this.#r.appendChild(this.#b(n,r)),r++}if(!r){let n=document.createElement("div");n.setAttribute("data-empty",""),n.textContent="No results found.",this.#r.appendChild(n)}r>0&&this.#y(0)}#m(t){for(let e of this.#t)if(e.items){let i=e.items.find(r=>r.value===t);if(i)return i}else if(e.value===t)return e;return null}#g(t){t&&(this.#e=[t,...this.#e.filter(e=>e!==t)].slice(0,s.#c))}#b(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=`
171
+ `,this.#s=this.querySelector("input"),this.#r=this.querySelector('[slot="list"]'),this.#a=this.querySelector("footer"),this.#s.addEventListener("input",this.#x),this.#r.addEventListener("click",this.#h),this.#r.addEventListener("pointerover",this.#d),this.#p()),this.open&&(this.#n=requestAnimationFrame(()=>{this.#n=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()}#u(){let t=[];for(let e of this.children)if(e.tagName==="OPTGROUP"){let i=e.label,r={label:i,items:[]};for(let n of e.querySelectorAll("option"))r.items.push(this.#f(n,i));t.push(r)}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.#r)return;this.#r.innerHTML="",this.#i=-1;let e=t.toLowerCase(),i=this.#t,r=0;if(!e&&this.#e.length){let n=this.#e.map(o=>this.#m(o)).filter(o=>o&&!o.disabled);if(n.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 n)o.appendChild(this.#b(a,r)),r++;this.#r.appendChild(o)}}for(let n of i)if(n.items){let o=n.items.filter(l=>this.#y(l,e));if(!o.length)continue;let a=document.createElement("div");a.setAttribute("data-group",""),a.innerHTML=`<div data-group-label>${n.label}</div>`;for(let l of o)a.appendChild(this.#b(l,r)),r++;this.#r.appendChild(a)}else{if(!this.#y(n,e))continue;this.#r.appendChild(this.#b(n,r)),r++}if(!r){let n=document.createElement("div");n.setAttribute("data-empty",""),n.textContent="No results found.",this.#r.appendChild(n)}r>0&&this.#O(0)}#m(t){for(let e of this.#t)if(e.items){let i=e.items.find(r=>r.value===t);if(i)return i}else if(e.value===t)return e;return null}#g(t){t&&(this.#e=[t,...this.#e.filter(e=>e!==t)].slice(0,s.#c))}#b(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=`
172
172
  ${t.icon?`<icon-ui name="${t.icon}"></icon-ui>`:""}
173
173
  <span data-text>${t.label}</span>
174
174
  ${t.shortcut?`<span data-shortcut>${t.shortcut}</span>`:""}
175
- `,this.#l.set(i,t),i}#O(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#y(t){let e=this.#r.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#r.querySelector("[data-active]");i&&i.removeAttribute("data-active");let r=[...e].find(n=>parseInt(n.dataset.idx)===t);r&&(r.setAttribute("data-active",""),r.scrollIntoView({block:"nearest"}),this.#i=t)}#w(t){let e=[...this.#r.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#r.querySelector("[data-active]"),n=(i?e.indexOf(i):-1)+t;n<0&&(n=e.length-1),n>=e.length&&(n=0),this.#y(parseInt(e[n].dataset.idx))}#v(t){this.#g(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#S(){let t=this.#r.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",n=(this.#l.get(t)||this.#m(e))?.category||"";this.#g(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:n}}))}#x=()=>{this.#p(this.#s.value)};#k=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#w(1);break;case"ArrowUp":t.preventDefault(),this.#w(-1);break;case"Enter":t.preventDefault(),this.#S();break;case"Tab":t.preventDefault(),this.#S();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),this.removeEventListener("keydown",this.#k),this.#s?.removeEventListener("input",this.#x),this.#r?.removeEventListener("click",this.#h),this.#r?.removeEventListener("pointerover",this.#u),this.#s=null,this.#r=null,this.#a=null,this.#o=!1}};S("command-ui",Tr);var $a=.4;function qd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function Xd(s,t,e){let i=s+.3963377774*t+.2158037573*e,r=s-.1055613458*t-.0638541728*e,n=s-.0894841775*t-1.291485548*e,o=i*i*i,a=r*r*r,l=n*n*n;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 ui(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function Nd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function JO(s,t,e){let{a:i,b:r}=qd(s,t,e),[n,o,a]=Xd(s,i,r);return[Math.max(0,Math.min(1,ui(n))),Math.max(0,Math.min(1,ui(o))),Math.max(0,Math.min(1,ui(a)))]}function uC(s,t,e){let i=r=>Math.round(r*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Lr(s,t,e){let[i,r,n]=JO(s,t,e);return uC(i,r,n)}function dC(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=Nd(parseInt(s.slice(0,2),16)/255),e=Nd(parseInt(s.slice(2,4),16)/255),i=Nd(parseInt(s.slice(4,6),16)/255),r=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*i),n=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*i),o=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*i),a=.2104542553*r+.793617785*n-.0040720468*o,l=1.9779984951*r-2.428592205*n+.4505937099*o,h=.0259040371*r+.7827717662*n-.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 ty(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Pa(s,t,e){let{a:i,b:r}=qd(s,t,e),[n,o,a]=Xd(s,i,r);if(ty(ui(n),ui(o),ui(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=qd(s,u,e),[p,m,b]=Xd(s,d,f);ty(ui(p),ui(m),ui(b))?l=u:h=u}return l}var Mr=class s extends M{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...M.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;#r=NaN;#n=!1;#a=null;#o=!1;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=null;#g=null;#b=null;#O=null;#y=null;#w=[];#v=null;static template=()=>null;#S=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.#L("input")};#x=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#I(t))};#k=t=>{this.#a==="area"&&this.#I(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#L("change"))};#C=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#$(t))};#E=t=>{this.#a==="hue"&&this.#$(t)};#T=()=>{this.#a==="hue"&&(this.#a=null,this.#L("change"))};#Q=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($a,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.#L("change")};#P=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.#L("change")};connected(){if(super.connected(),this.#M(this.value),this.#n)return;this.#n=!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.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#u=document.createElement("div"),this.#u.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#u),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(n,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",n),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#S),t.appendChild(c),c};this.#b=e("H","hue",0,360,1),this.#O=e("C","chroma",0,$a,.001),this.#y=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 r=n=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",n);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",n),l.setAttribute("aria-label",`Copy ${n}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#X(n,l);return l.addEventListener("click",h),this.#w.push({el:l,handler:h}),o.appendChild(a),o.appendChild(l),i.appendChild(o),a};this.#p=r("oklch"),this.#m=r("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#x),this.#h.addEventListener("pointermove",this.#k),this.#h.addEventListener("pointerup",this.#A),this.#d.addEventListener("pointerdown",this.#C),this.#d.addEventListener("pointermove",this.#E),this.#d.addEventListener("pointerup",this.#T),this.#h.addEventListener("keydown",this.#Q),this.#d.addEventListener("keydown",this.#P),this.#g=new ResizeObserver(()=>this.#q()),this.#g.observe(this.#h)}disconnected(){super.disconnected(),this.#v!=null&&(clearTimeout(this.#v),this.#v=null),this.#g&&(this.#g.disconnect(),this.#g=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#x),this.#h.removeEventListener("pointermove",this.#k),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#Q)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#C),this.#d.removeEventListener("pointermove",this.#E),this.#d.removeEventListener("pointerup",this.#T),this.#d.removeEventListener("keydown",this.#P)),this.#b?.removeEventListener("input",this.#S),this.#O?.removeEventListener("input",this.#S),this.#y?.removeEventListener("input",this.#S);for(let{el:t,handler:e}of this.#w)t.removeEventListener("click",e);this.#w=[],this.#n=!1}#I(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),r=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*$a,this.#e=1-r,this.#L("input")}#$(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#L("input")}#M(t){if(t){if(t.startsWith("#")){let e=dC(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=(r,n)=>r==="none"||/^NaN$/i.test(r)?0:n&&r.endsWith("%")||r.endsWith("%")?+r.slice(0,-1)/100:+r;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.`))}}}#L(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.#r)?this.#r:this.#s;Number.isFinite(this.#r)||(this.#r=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=Pa(this.#e,this.#i,this.#s),r=Lr(this.#e,i,this.#s),n=this.#D();this.#o=!0,this.value=this.format==="oklch"?n:r,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:r,oklch:n};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#D(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#X(t,e){let i=t==="oklch"?this.#D():Lr(this.#e,Pa(this.#e,this.#i,this.#s),this.#s),r=e.querySelector("icon-ui"),n=o=>{r&&(r.setAttribute("name",o?"check":"warning"),this.#v!=null&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,r.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&n(!0)},()=>{this.isConnected&&n(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),n(document.execCommand("copy")),o.remove()}}#q(){if(!this.#l||!this.#c||!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 r=this.#c.createImageData(e,i),n=r.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)*$a,u=Pa(l,c,o),[d,f,p]=JO(l,u,o),m=(a*e+h)*4;n[m]=Math.round(d*255),n[m+1]=Math.round(f*255),n[m+2]=Math.round(p*255),n[m+3]=255}}this.#c.putImageData(r,0,0)}render(){if(this.#o?this.#o=!1:this.#M(this.value),this.#q(),this.#u){let n=this.#i/$a*100,o=(1-this.#e)*100;this.#u.style.left=`${n}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Lr(this.#e,Pa(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let n=[];for(let o=0;o<=360;o+=30)n.push(Lr(.7,.15,o));this.#d.style.background=`linear-gradient(to right, ${n.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=Lr(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#D());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 r=Lr(this.#e,Pa(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#D()),this.#m&&(this.#m.textContent=r)}onFormReset(){this.value="#3b82f6"}};S("color-picker-ui",Mr);var Rr=class extends M{static get properties(){return{...M.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",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;#r=null;#n=!1;#a=null;connected(){this.#o(),this.#l(),this.#d(),this.syncValue(this.value)}render(){this.#d(),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.#r=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 r=document.createElement("span");r.className="color-input__value",e.append(i,r);let n=document.createElement("color-picker-ui");n.setAttribute("slot","content"),n.setAttribute("format",this.format),n.setAttribute("value",this.value),n.maxChroma=this.maxChroma,n.maxL=this.maxL,n.minL=this.minL,n.hueDriftMax=this.hueDriftMax,n.baseHue=this.baseHue,t.append(e,n),this.append(t),this.#t=t,this.#e=e,this.#i=n,this.#s=i,this.#r=r}#l(){if(this.#n)return;this.#n=!0,this.#i.addEventListener("change",this.#c),this.#i.addEventListener("input",this.#h);let t=()=>{let e=!!this.#t?.open;this.open!==e&&(this.open=e)};this.#t.addEventListener("toggle",t),this.#a=new MutationObserver(t),this.#a.observe(this.#t,{attributes:!0,attributeFilter:["open"]})}#c=t=>{this.#u(t.detail,"change")};#h=t=>{this.#u(t.detail,"input")};#u(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.#d(),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}}))}#d(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#r&&(this.#r.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#c),this.#i?.removeEventListener("input",this.#h),this.#a?.disconnect(),this.#a=null,this.#n=!1}};S("color-input-ui",Rr);$();var Zd=0,Ir=class extends x{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;#r=null;#n=null;#a=!1;#o=null;#l=null;#c=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",r="left"){let n=`noodle-${++Zd}`,o={id:n,from:t,to:e,fromPort:i,toPort:r};return this.#e.push(o),this.#h(),this.dispatchEvent(new CustomEvent("noodle-connect",{bubbles:!0,detail:{...o}})),n}disconnect(t){let e=this.#e.findIndex(r=>r.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-${++Zd}`,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.#r=new MutationObserver(()=>{this.#S(),this.#h()}),this.#s.observe(this),this.#u();for(let t of this.#m())this.#s.observe(t);this.#S(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#c?.(),this.#s?.disconnect(),this.#r?.disconnect(),this.#n&&cancelAnimationFrame(this.#n),this.#n=null,this.#x(),this.#t?.remove(),this.#t=null,this.#a=!1}#h(){this.#n||(this.#n=requestAnimationFrame(()=>{this.#n=null,this.#f()}))}#u(){this.#r?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#d(){this.#r?.disconnect()}#f(){if(!this.#t)return;this.#d();let t=this.#m();for(let n of t)this.#s.observe(n);this.#k();let e=this.#e.map(n=>{let o=this.#p(n.from),a=this.#p(n.to);if(!o||!a)return null;let l=this.#g(o,n.fromPort),h=this.#g(a,n.toPort);return!l||!h?null:{id:n.id,d:this.#b(l,h,n.fromPort,n.toPort)}}).filter(Boolean),i=new Map;for(let n of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(n.getAttribute("data-noodle-id"),n);let r=new Set(e.map(n=>n.id));for(let[n,o]of i)r.has(n)||o.remove();for(let{id:n,d:o}of e){let a=i.get(n);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",n),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#o&&this.#l){let n=this.#t.querySelector("path[data-noodle-preview]");n||(n=document.createElementNS("http://www.w3.org/2000/svg","path"),n.setAttribute("data-noodle-preview",""),n.style.opacity="0.5",n.style.strokeDasharray="6 3",this.#t.appendChild(n)),n.setAttribute("d",this.#l),n.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#u()}#p(t){return t instanceof HTMLElement?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#g(t,e){let i=t.getBoundingClientRect(),r=this.getBoundingClientRect(),n=this.offsetWidth&&r.width?r.width/this.offsetWidth:1,o=(i.left-r.left)/n,a=(i.top-r.top)/n,l=i.width/n,h=i.height/n;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}}}#b(t,e,i,r){switch(this.curve){case"step":return this.#w(t,e);case"straight":return this.#v(t,e);default:return this.#O(t,e,i,r)}}#O(t,e,i,r){let n=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(n*n+o*o),l=Math.max(50,a*this.tension),h=this.#y(t,i,l),c=this.#y(e,r,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#y(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}}}#w(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}`}#S(){this.#d(),this.#x();let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let r of i){let n=this.#A(e,r),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",r),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#C(a,e,r)),this.appendChild(o),this.#i.set(n,o)}}this.#k(),this.#u()}#x(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#k(){let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let r of i){let n=this.#A(e,r),o=this.#i.get(n);if(!o)continue;let a=this.#g(e,r);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#A(t,e){return t._noodleId||(t._noodleId=`_n${++Zd}`),`${t._noodleId}:${e}`}#C=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let r=t.currentTarget;r.setPointerCapture(t.pointerId),r.setAttribute("data-noodle-dragging","");let n=this.#g(e,i),o=l=>{if(!this.#o)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#b(n,{x:c,y:u},i,this.#E(n,{x:c,y:u})),this.#h(),this.#T(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{r.releasePointerCapture(l.pointerId)}catch{}if(r.removeAttribute("data-noodle-dragging"),r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#Q(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#P(),this.#o=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#o=null,r.removeAttribute("data-noodle-dragging"),r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",a),this.#P(),this.#l=null,this.#c=null},this.#o={fromEl:e,fromSide:i,startPos:n,pointerId:t.pointerId},this.#l=null,r.addEventListener("pointermove",o),r.addEventListener("pointerup",a)};#E(t,e){let i=e.x-t.x,r=e.y-t.y;return Math.abs(i)>Math.abs(r)?i>0?"left":"right":r>0?"top":"bottom"}#T(t,e,i){this.#P();let r=this.#Q(t,e,i);r?.dot&&r.dot.setAttribute("data-noodle-drop-ready","")}#Q(t,e,i){let r=this.portSize*2,n=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.#m().find(b=>b._noodleId===f);!m||m===i||d<r&&d<o&&(o=d,n={el:m,side:p,dot:l})}return n}#P(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};S("noodles-ui",Ir);var Xi={};function ve(s,t){Xi[s]=t}function Dr(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 Bd={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()};ve("text",{render(s,t,e){Dr(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("number",{render(s,t,e){Dr(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),ve("currency",{render(s,t,e,i){Dr(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"}),ve("percent",{render(s,t,e){Dr(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var ey={year:"numeric",month:"short",day:"numeric"};ve("date",{render(s,t,e){Dr(e,s?new Intl.DateTimeFormat("en-US",ey).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",ey).format(new Date(s)):""},align:"left",sortFn:"datetime"});var iy={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};ve("datetime",{render(s,t,e){Dr(e,s?new Intl.DateTimeFormat("en-US",iy).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",iy).format(new Date(s)):""},align:"left",sortFn:"datetime"}),ve("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"}),ve("badge",{render(s,t,e,i){let r=e.querySelector("badge-ui");r||(e.textContent="",r=document.createElement("badge-ui"),e.appendChild(r)),r.setAttribute("text",String(s??""));let n=i?.variants||{};r.setAttribute("variant",n[s]||"neutral")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("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 r=i.querySelector("avatar-ui"),n=i.querySelector("span");r.setAttribute("text",String(s??"")),n.textContent=String(s??""),e.title=String(s??"")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("link",{render(s,t,e,i){let r=e.querySelector("a");r||(e.textContent="",r=document.createElement("a"),r.style.color="var(--table-accent, var(--a-primary))",r.style.textDecoration="none",e.appendChild(r));let n=String(s??""),o=n.includes("@")&&!n.startsWith("http");r.href=o?`mailto:${n}`:n,r.textContent=i?.label??n},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("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 r=i.querySelector("progress-ui"),n=i.querySelector("span");r.setAttribute("value",s!=null?String(s):"0"),n.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),ve("actions",{render(s,t,e,i){let r=i?.actions||[],n=e.querySelector("row-ui");if(n&&n.children.length!==r.length&&(n.remove(),n=null),!n){e.textContent="",n=document.createElement("row-ui"),n.setAttribute("gap","1");for(let o of r){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}}))}),n.appendChild(a)}e.appendChild(n)}},format(){return""},align:"center",sortFn:null});$();function fC(s,t){if(!t||!s)return;let e=t.split("."),i=s;for(let r of e){if(i==null)return;i=i[r]}return i}function di(s,t){return typeof t.accessor=="function"?t.accessor(s):fC(s,t.key)}function xh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
176
- `)?'"'+t.replace(/"/g,'""')+'"':t}var qr=class extends x{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;#r=new Set;#n=null;#a=0;#o=new Set;#l=new Map;#c=null;#h=!1;#u=-1;#d=null;#f=null;set columns(t){this.#t=Array.isArray(t)?t:[],this.#O()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#a=0,this.#O()}get data(){return this.#e}get selected(){return[...this.#o].sort((t,e)=>t-e)}set selected(t){if(this.#o.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#o.add(e);this.#O(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#O(),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.#a=0,this.#O(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#a=0,this.#O(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}toggleExpand(t){this.#r.has(t)?(this.#r.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#r.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#O()}get expanded(){return[...this.#r]}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.#a,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.#a=t.page),t.density&&(this.density=t.density),this.#O()}}#p(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#m(){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.#g(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#m(),this.#h||(this.#h=!0,this.addEventListener("click",this.#M),this.addEventListener("keydown",this.#_),this.addEventListener("pointerdown",this.#$))}disconnected(){this.removeEventListener("click",this.#M),this.removeEventListener("keydown",this.#_),this.removeEventListener("pointerdown",this.#$),this.#h=!1,this.#R(),this.#b&&(cancelAnimationFrame(this.#b),this.#b=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}#g(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let r={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},n=i.getAttribute("width");n&&(r.width=Number(n));let o=i.getAttribute("min-width");o&&(r.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(r.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(r.flex=Number(l)),e.push(r),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#b=null;#O(){!this.isConnected||this.#b||(this.#b=requestAnimationFrame(()=>{this.#b=null,this.render(),this.#p()}))}get#y(){return this.#t.filter(t=>!t.hidden)}#w(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#y)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 r=this.#e[i];return this.#y.some(n=>{let o=di(r,n);return o!=null&&String(o).toLowerCase().includes(e)})})}return this.#s.size&&(t=t.filter(e=>{let i=this.#e[e];for(let[r,{op:n,value:o}]of this.#s){let a=this.#t.find(u=>u.key===r),l=di(i,a||{key:r}),h=String(l??"").toLowerCase(),c=String(o).toLowerCase();switch(n){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:r,dir:n}of this.#i){let o=this.#t.find(u=>u.key===r),a=di(this.#e[e],o||{key:r}),l=di(this.#e[i],o||{key:r}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Xi[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Bd[d]||Bd.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 n==="asc"?c:-c}return 0}),t}#S(t){if(!this.paginate||this.paginate<=0)return t;let e=this.#a*this.paginate;return t.slice(e,e+this.paginate)}get#x(){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.#y;this.style.gridTemplateColumns=this.#w();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#k(e,t),this.#I();let i=this.querySelector(":scope > [data-body]");i||(i=document.createElement("div"),i.setAttribute("role","rowgroup"),i.setAttribute("data-body",""),e.after(i));let r=this.#v(),n=this.#S(r),o=[];for(let c of n){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#A(c,t);if(u&&this.#C(u,c,t),this.expandable&&(this.#r.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded")),o.push(d),this.expandable&&this.#r.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.#E(i),this.#T(i,r,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.#Q(h,r.length)):h&&h.remove()}#k(t,e){let i=this.#e.length>0&&this.#o.size===this.#e.length,r=[];if(this.selectable){let n=document.createElement("div");n.setAttribute("role","columnheader"),n.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),n.appendChild(o),r.push(n)}for(let n of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=n.label||n.key,o.appendChild(a),n.sortable!==!1&&this.sortable){o.dataset.sortKey=n.key,o.setAttribute("aria-label",`Sort by ${n.label||n.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===n.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(n.pinned&&o.setAttribute("data-pinned",n.pinned),n.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-resize-handle",""),h.dataset.resizeKey=n.key,o.appendChild(h)}if(n.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=n.key,h.setAttribute("aria-label",`Filter ${n.label||n.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(n.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===n.key){let u=this.#P(n);o.appendChild(u),o.setAttribute("data-filter-open","")}}r.push(o)}for(;t.children.length>r.length;)t.lastChild.remove();for(let n=0;n<r.length;n++)t.children[n]?t.replaceChild(r[n],t.children[n]):t.appendChild(r[n])}#A(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#C(i,t,e),i}#C(t,e,i){let r=this.#e[e],n=this.#o.has(e);t.dataset.index=e,n?(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");n&&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=di(r,a);if(typeof a.render=="function"){let u=a.render(h,r,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,r);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Xi[a.type||"text"];if(u?.render)u.render(h,r,l,a.meta);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Xi[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])}#E(t){let e=this.querySelector(":scope > [data-empty]"),i=this.querySelector(":scope > [data-loading]");if(this.loading){this.setAttribute("aria-busy","true");let r=this.#y,n=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+r.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<n;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 r=document.createElement("icon-ui");r.setAttribute("name","table");let n=document.createElement("span");n.textContent="No data",e.appendChild(r),e.appendChild(n),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#T(t,e,i){let r=i.some(a=>a.aggregate),n=this.querySelector(":scope > [data-agg-row]");if(!r||this.#e.length===0){n&&n.remove();return}n||(n=document.createElement("div"),n.setAttribute("role","row"),n.setAttribute("data-agg-row",""),t.after(n));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=di(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=Xi[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(;n.children.length>o.length;)n.lastChild.remove();for(let a=0;a<o.length;a++)n.children[a]?n.replaceChild(o[a],n.children[a]):n.appendChild(o[a])}#Q(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",n=>{this.#a=n.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))}),t.appendChild(i));let r=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#a+1)),i.setAttribute("total",String(r))}#P(t){let e=document.createElement("div");e.setAttribute("data-filter-dropdown","");let i=this.#s.get(t.key);if(t.filter==="select"){let r=[...new Set(this.#e.map(o=>{let a=di(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),n=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of r){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=n.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 r=document.createElement("input");r.type="number",r.placeholder="Filter...",r.value=i?.value??"",r.setAttribute("data-filter-input","");let n=document.createElement("select");n.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),n.appendChild(h)}let o=()=>{r.value?this.setFilter(t.key,r.value,n.value):this.setFilter(t.key,null)};r.addEventListener("input",o),n.addEventListener("change",o),e.appendChild(n),e.appendChild(r)}else{let r=document.createElement("input");r.type="text",r.placeholder=`Filter ${t.label||t.key}...`,r.value=i?.value??"",r.setAttribute("data-filter-input",""),r.addEventListener("input",()=>{r.value?this.setFilter(t.key,r.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(r)}if(i){let r=document.createElement("button");r.textContent="Clear",r.setAttribute("data-filter-clear",""),r.addEventListener("click",()=>{this.setFilter(t.key,null),this.#d=null,this.#O()}),e.appendChild(r)}return this.#f!=null&&cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{if(this.#f=null,!this.isConnected)return;let r=e.querySelector("input");r&&r.focus()}),e}#I(){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:r,value:n}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=r==="select"?`${n.split(",").length} selected`:n;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)}#$=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#D(t,e))};#M=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.#O();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#O());let r=e.closest("[data-expand-toggle]");if(r&&this.expandable&&this.contains(r)){let c=r.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let n=e.closest("[data-resize-handle]");if(n&&this.contains(n)){this.#D(t,n);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.#o.add(u);else this.#o.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.#u>=0){let f=Math.min(this.#u,u),p=Math.max(this.#u,u);for(let m=f;m<=p;m++)d?this.#o.add(m):this.#o.delete(m)}else d?this.#o.add(u):this.#o.delete(u);this.#u=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(b=>b.key===d),m=p?di(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}}))}}};#L=null;#D(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,r=this.#t.find(l=>l.key===i);if(!r)return;let n=e.closest('[role="columnheader"]'),o=n?n.getBoundingClientRect().width:100,a=t.clientX;this.setAttribute("data-resizing",""),this.#L={key:i,col:r,startX:a,startWidth:o},document.addEventListener("pointermove",this.#X),document.addEventListener("pointerup",this.#q)}#X=t=>{if(!this.#L)return;let{key:e,col:i,startX:r,startWidth:n}=this.#L,o=t.clientX-r,a=n+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.#w()};#q=t=>{if(!this.#L)return;let{key:e}=this.#L;document.removeEventListener("pointermove",this.#X),document.removeEventListener("pointerup",this.#q),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#L=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#R(){document.removeEventListener("pointermove",this.#X),document.removeEventListener("pointerup",this.#q),this.#L=null}#_=t=>{let i=this.#y.length+(this.selectable?1:0),r=this.querySelector(":scope > [data-body]"),n=r?r.children.length:0;this.#c||(this.#c={row:0,col:0});let{row:o,col:a}=this.#c,l=!0;switch(t.key){case"ArrowDown":o=Math.min(o+1,n-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>=n){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.#c={row:o,col:a},this.#Z())};#Z(){let t=this.querySelector("[data-focused]");if(t&&t.removeAttribute("data-focused"),!this.#c)return;let{row:e,col:i}=this.#c,r;e===-1?r=this.querySelector(":scope > [data-header]")?.children[i]:r=this.querySelector(":scope > [data-body]")?.children[e]?.children[i],r&&(r.setAttribute("data-focused",""),r.scrollIntoView?.({block:"nearest",inline:"nearest"}))}exportCSV(t="export.csv"){let e=this.#y,i=this.#v(),r=e.map(c=>xh(c.label||c.key)),n=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=di(u,d);if(typeof d.format=="function")return xh(d.format(f,u));let p=Xi[d.type||"text"];return p?.format?xh(p.format(f,u,d.meta)):xh(f)})}),o=[r.join(","),...n.map(c=>c.join(","))].join(`
177
- `),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)}};S("table-ui",qr);$();var pC=200;function zd(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 _d(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 mC=50,sy=500;function ry(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("."),r=s;for(let n of i){if(r==null)return;r=r[n]}return r}function gC(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 bC(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(gC(s?.key))return"text";let e=[],i=Math.min(t?.length??0,sy),r=new Set;for(let n=0;n<i;n++){let o=ry(t[n],s);if(!(o==null||o==="")&&(e.push(o),r.add(String(o)),r.size>mC))return"text"}return e.length?"select":"text"}function OC(s,t){let e=new Set,i=Math.min(t?.length??0,sy);for(let r=0;r<i;r++){let n=ry(t[r],s);n==null||n===""||e.add(String(n))}return[...e].sort((r,n)=>r.localeCompare(n,void 0,{numeric:!0}))}var Xr=class s extends x{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;#r=null;#n=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.#a(),this.#h(),this.#o(),this.#g()}disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null);for(let t of this.#n)cancelAnimationFrame(t);this.#n.clear(),this.#O(),this.#c()}render(){this.#o(),this.#g(),this.#f()}#a(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let r=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(r)||s._OPT_OUT_PREFIX_RE.test(r)&&t.push(r)}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.`)}#o(){let t=this.#l();if(t===this.#t||(this.#c(),!t))return;this.#t=t;let e=()=>this.#k(),i=()=>this.#S();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}#c(){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 r=document.createElement("badge-ui");r.setAttribute("data-count-badge",""),r.setAttribute("size","sm"),r.setAttribute("variant","muted"),r.hidden=!0,e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-controls",""),n.appendChild(this.#d("filter","Filter","funnel-simple")),n.appendChild(this.#d("sort","Sort","arrows-down-up")),n.appendChild(this.#d("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("size","sm"),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String(pC)),o.addEventListener("search",this.#m);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(n),t.appendChild(o),t.appendChild(a),this.appendChild(t),this.#f(),this.#p()}#u(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 r=document.createElement("button-ui");return r.setAttribute("data-toolbar-btn",t),r.setAttribute("icon",i),r.setAttribute("text",e),r.setAttribute("variant","outline"),r.setAttribute("size","sm"),r.setAttribute("aria-haspopup","menu"),r.addEventListener("click",n=>{n.stopPropagation(),this.#b(t,r)}),r}#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(),r=this.#t?.data?.length,n=i||(Number.isFinite(r)?String(r):"");n?(e.setAttribute("text",n),e.hidden=!1):e.hidden=!0}#p(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=(i,r)=>{let n=t.querySelector(i);n&&(n.hidden=r)};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)}#m=t=>{let e=t.detail?.value??"";this.#t&&(this.#t.search=e),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#g(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#f()}#b(t,e){if(this.#i?.kind===t){this.#O();return}this.#O();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.#x(i),t==="columns"&&this.#A(i),document.body.appendChild(i);try{i.showPopover()}catch{}let r=ct(e,i,{placement:"bottom",gap:4});this.#i={kind:t,btn:e,panel:i,cleanup:r},this.#s||(this.#s=!0,this.#r=requestAnimationFrame(()=>{this.#r=null,!(!this.isConnected||!this.#s)&&(document.addEventListener("pointerdown",this.#y,!0),document.addEventListener("keydown",this.#w,!0))}))}#O(){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.#y,!0),document.removeEventListener("keydown",this.#w,!0))}}#y=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#O())};#w=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#O(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(zd("No filterable columns"));return}let i=e.filters||{};t.appendChild(_d("Filter rows"));let r=document.createElement("div");r.setAttribute("data-popover-list","");let n=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=bC(o,n),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=OC(o,n);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)}r.appendChild(a)}if(t.appendChild(r),Object.keys(i).length){let o=this.#u("Clear all filters",()=>{e.clearFilters(),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#S()});t.appendChild(o)}}#S(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#x(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(zd("No sortable columns"));return}t.appendChild(_d("Sort by"));let i=e.sortState||[],r=new Map(i.map(o=>[o.key,o.dir])),n=document.createElement("div");n.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=r.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.#n.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.#n.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.#k()}),n.appendChild(l)}if(t.appendChild(n),i.length){let o=this.#u("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.#k()});t.appendChild(o)}}#k(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#x(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(zd("No columns"));return}t.appendChild(_d("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let r of e.columns){let n=document.createElement("field-ui");n.setAttribute("data-columns-row",""),n.setAttribute("inline",""),n.setAttribute("label",r.label||r.key);let o=document.createElement("check-ui");r.hidden||o.setAttribute("checked",""),o.dataset.key=r.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===r.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)}}))}),n.appendChild(o),i.appendChild(n)}t.appendChild(i)}};S("table-toolbar-ui",Xr);$();var Nr=class extends x{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","")}},Zr=class extends x{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=`
175
+ `,this.#l.set(i,t),i}#y(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#O(t){let e=this.#r.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#r.querySelector("[data-active]");i&&i.removeAttribute("data-active");let r=[...e].find(n=>parseInt(n.dataset.idx)===t);r&&(r.setAttribute("data-active",""),r.scrollIntoView({block:"nearest"}),this.#i=t)}#S(t){let e=[...this.#r.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#r.querySelector("[data-active]"),n=(i?e.indexOf(i):-1)+t;n<0&&(n=e.length-1),n>=e.length&&(n=0),this.#O(parseInt(e[n].dataset.idx))}#v(t){this.#g(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#w(){let t=this.#r.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",n=(this.#l.get(t)||this.#m(e))?.category||"";this.#g(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:n}}))}#x=()=>{this.#p(this.#s.value)};#k=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.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),this.removeEventListener("keydown",this.#k),this.#s?.removeEventListener("input",this.#x),this.#r?.removeEventListener("click",this.#h),this.#r?.removeEventListener("pointerover",this.#d),this.#s=null,this.#r=null,this.#a=null,this.#o=!1}};S("command-ui",Tr);var $a=.4;function qd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function Xd(s,t,e){let i=s+.3963377774*t+.2158037573*e,r=s-.1055613458*t-.0638541728*e,n=s-.0894841775*t-1.291485548*e,o=i*i*i,a=r*r*r,l=n*n*n;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 ui(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function Nd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function JO(s,t,e){let{a:i,b:r}=qd(s,t,e),[n,o,a]=Xd(s,i,r);return[Math.max(0,Math.min(1,ui(n))),Math.max(0,Math.min(1,ui(o))),Math.max(0,Math.min(1,ui(a)))]}function uC(s,t,e){let i=r=>Math.round(r*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Lr(s,t,e){let[i,r,n]=JO(s,t,e);return uC(i,r,n)}function dC(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=Nd(parseInt(s.slice(0,2),16)/255),e=Nd(parseInt(s.slice(2,4),16)/255),i=Nd(parseInt(s.slice(4,6),16)/255),r=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*i),n=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*i),o=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*i),a=.2104542553*r+.793617785*n-.0040720468*o,l=1.9779984951*r-2.428592205*n+.4505937099*o,h=.0259040371*r+.7827717662*n-.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 ty(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Pa(s,t,e){let{a:i,b:r}=qd(s,t,e),[n,o,a]=Xd(s,i,r);if(ty(ui(n),ui(o),ui(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=qd(s,u,e),[p,m,b]=Xd(s,d,f);ty(ui(p),ui(m),ui(b))?l=u:h=u}return l}var Mr=class s extends M{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...M.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;#r=NaN;#n=!1;#a=null;#o=!1;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m=null;#g=null;#b=null;#y=null;#O=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.#L("input")};#x=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#I(t))};#k=t=>{this.#a==="area"&&this.#I(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#L("change"))};#C=t=>{this.disabled||(this.#a="hue",this.#u.setPointerCapture(t.pointerId),this.#$(t))};#E=t=>{this.#a==="hue"&&this.#$(t)};#T=()=>{this.#a==="hue"&&(this.#a=null,this.#L("change"))};#Q=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($a,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.#L("change")};#P=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.#L("change")};connected(){if(super.connected(),this.#M(this.value),this.#n)return;this.#n=!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.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#d=document.createElement("div"),this.#d.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#d),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(n,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",n),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#w),t.appendChild(c),c};this.#b=e("H","hue",0,360,1),this.#y=e("C","chroma",0,$a,.001),this.#O=e("L","lightness",0,1,.001),this.appendChild(t),this.#u=document.createElement("div"),this.#u.setAttribute("data-hue-track",""),this.#u.setAttribute("tabindex","0"),this.#u.setAttribute("role","slider"),this.#u.setAttribute("aria-label","Hue"),this.#f=document.createElement("div"),this.#f.setAttribute("data-hue-thumb",""),this.#u.appendChild(this.#f),this.appendChild(this.#u);let i=document.createElement("div");i.setAttribute("data-output","");let r=n=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",n);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",n),l.setAttribute("aria-label",`Copy ${n}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#X(n,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=r("oklch"),this.#m=r("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#x),this.#h.addEventListener("pointermove",this.#k),this.#h.addEventListener("pointerup",this.#A),this.#u.addEventListener("pointerdown",this.#C),this.#u.addEventListener("pointermove",this.#E),this.#u.addEventListener("pointerup",this.#T),this.#h.addEventListener("keydown",this.#Q),this.#u.addEventListener("keydown",this.#P),this.#g=new ResizeObserver(()=>this.#q()),this.#g.observe(this.#h)}disconnected(){super.disconnected(),this.#v!=null&&(clearTimeout(this.#v),this.#v=null),this.#g&&(this.#g.disconnect(),this.#g=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#x),this.#h.removeEventListener("pointermove",this.#k),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#Q)),this.#u&&(this.#u.removeEventListener("pointerdown",this.#C),this.#u.removeEventListener("pointermove",this.#E),this.#u.removeEventListener("pointerup",this.#T),this.#u.removeEventListener("keydown",this.#P)),this.#b?.removeEventListener("input",this.#w),this.#y?.removeEventListener("input",this.#w),this.#O?.removeEventListener("input",this.#w);for(let{el:t,handler:e}of this.#S)t.removeEventListener("click",e);this.#S=[],this.#n=!1}#I(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),r=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*$a,this.#e=1-r,this.#L("input")}#$(t){let e=this.#u.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#L("input")}#M(t){if(t){if(t.startsWith("#")){let e=dC(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=(r,n)=>r==="none"||/^NaN$/i.test(r)?0:n&&r.endsWith("%")||r.endsWith("%")?+r.slice(0,-1)/100:+r;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.`))}}}#L(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.#r)?this.#r:this.#s;Number.isFinite(this.#r)||(this.#r=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=Pa(this.#e,this.#i,this.#s),r=Lr(this.#e,i,this.#s),n=this.#D();this.#o=!0,this.value=this.format==="oklch"?n:r,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:r,oklch:n};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#D(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#X(t,e){let i=t==="oklch"?this.#D():Lr(this.#e,Pa(this.#e,this.#i,this.#s),this.#s),r=e.querySelector("icon-ui"),n=o=>{r&&(r.setAttribute("name",o?"check":"warning"),this.#v!=null&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,r.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&n(!0)},()=>{this.isConnected&&n(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),n(document.execCommand("copy")),o.remove()}}#q(){if(!this.#l||!this.#c||!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 r=this.#c.createImageData(e,i),n=r.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)*$a,u=Pa(l,c,o),[d,f,p]=JO(l,u,o),m=(a*e+h)*4;n[m]=Math.round(d*255),n[m+1]=Math.round(f*255),n[m+2]=Math.round(p*255),n[m+3]=255}}this.#c.putImageData(r,0,0)}render(){if(this.#o?this.#o=!1:this.#M(this.value),this.#q(),this.#d){let n=this.#i/$a*100,o=(1-this.#e)*100;this.#d.style.left=`${n}%`,this.#d.style.top=`${o}%`,this.#d.style.background=Lr(this.#e,Pa(this.#e,this.#i,this.#s),this.#s)}if(this.#u){let n=[];for(let o=0;o<=360;o+=30)n.push(Lr(.7,.15,o));this.#u.style.background=`linear-gradient(to right, ${n.join(", ")})`,this.#u.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#f&&(this.#f.style.left=`${this.#s/360*100}%`,this.#f.style.background=Lr(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#D());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 r=Lr(this.#e,Pa(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#D()),this.#m&&(this.#m.textContent=r)}onFormReset(){this.value="#3b82f6"}};S("color-picker-ui",Mr);var Rr=class extends M{static get properties(){return{...M.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",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;#r=null;#n=!1;#a=null;connected(){this.#o(),this.#l(),this.#u(),this.syncValue(this.value)}render(){this.#u(),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.#r=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 r=document.createElement("span");r.className="color-input__value",e.append(i,r);let n=document.createElement("color-picker-ui");n.setAttribute("slot","content"),n.setAttribute("format",this.format),n.setAttribute("value",this.value),n.maxChroma=this.maxChroma,n.maxL=this.maxL,n.minL=this.minL,n.hueDriftMax=this.hueDriftMax,n.baseHue=this.baseHue,t.append(e,n),this.append(t),this.#t=t,this.#e=e,this.#i=n,this.#s=i,this.#r=r}#l(){if(this.#n)return;this.#n=!0,this.#i.addEventListener("change",this.#c),this.#i.addEventListener("input",this.#h);let t=()=>{let e=!!this.#t?.open;this.open!==e&&(this.open=e)};this.#t.addEventListener("toggle",t),this.#a=new MutationObserver(t),this.#a.observe(this.#t,{attributes:!0,attributeFilter:["open"]})}#c=t=>{this.#d(t.detail,"change")};#h=t=>{this.#d(t.detail,"input")};#d(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.#u(),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}}))}#u(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#r&&(this.#r.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#c),this.#i?.removeEventListener("input",this.#h),this.#a?.disconnect(),this.#a=null,this.#n=!1}};S("color-input-ui",Rr);$();var Zd=0,Ir=class extends x{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;#r=null;#n=null;#a=!1;#o=null;#l=null;#c=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",r="left"){let n=`noodle-${++Zd}`,o={id:n,from:t,to:e,fromPort:i,toPort:r};return this.#e.push(o),this.#h(),this.dispatchEvent(new CustomEvent("noodle-connect",{bubbles:!0,detail:{...o}})),n}disconnect(t){let e=this.#e.findIndex(r=>r.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-${++Zd}`,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.#r=new MutationObserver(()=>{this.#w(),this.#h()}),this.#s.observe(this),this.#d();for(let t of this.#m())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.#c?.(),this.#s?.disconnect(),this.#r?.disconnect(),this.#n&&cancelAnimationFrame(this.#n),this.#n=null,this.#x(),this.#t?.remove(),this.#t=null,this.#a=!1}#h(){this.#n||(this.#n=requestAnimationFrame(()=>{this.#n=null,this.#f()}))}#d(){this.#r?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#u(){this.#r?.disconnect()}#f(){if(!this.#t)return;this.#u();let t=this.#m();for(let n of t)this.#s.observe(n);this.#k();let e=this.#e.map(n=>{let o=this.#p(n.from),a=this.#p(n.to);if(!o||!a)return null;let l=this.#g(o,n.fromPort),h=this.#g(a,n.toPort);return!l||!h?null:{id:n.id,d:this.#b(l,h,n.fromPort,n.toPort)}}).filter(Boolean),i=new Map;for(let n of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(n.getAttribute("data-noodle-id"),n);let r=new Set(e.map(n=>n.id));for(let[n,o]of i)r.has(n)||o.remove();for(let{id:n,d:o}of e){let a=i.get(n);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",n),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#o&&this.#l){let n=this.#t.querySelector("path[data-noodle-preview]");n||(n=document.createElementNS("http://www.w3.org/2000/svg","path"),n.setAttribute("data-noodle-preview",""),n.style.opacity="0.5",n.style.strokeDasharray="6 3",this.#t.appendChild(n)),n.setAttribute("d",this.#l),n.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#d()}#p(t){return t instanceof HTMLElement?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#g(t,e){let i=t.getBoundingClientRect(),r=this.getBoundingClientRect(),n=this.offsetWidth&&r.width?r.width/this.offsetWidth:1,o=(i.left-r.left)/n,a=(i.top-r.top)/n,l=i.width/n,h=i.height/n;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}}}#b(t,e,i,r){switch(this.curve){case"step":return this.#S(t,e);case"straight":return this.#v(t,e);default:return this.#y(t,e,i,r)}}#y(t,e,i,r){let n=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(n*n+o*o),l=Math.max(50,a*this.tension),h=this.#O(t,i,l),c=this.#O(e,r,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#O(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.#u(),this.#x();let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let r of i){let n=this.#A(e,r),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",r),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#C(a,e,r)),this.appendChild(o),this.#i.set(n,o)}}this.#k(),this.#d()}#x(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#k(){let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let r of i){let n=this.#A(e,r),o=this.#i.get(n);if(!o)continue;let a=this.#g(e,r);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#A(t,e){return t._noodleId||(t._noodleId=`_n${++Zd}`),`${t._noodleId}:${e}`}#C=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let r=t.currentTarget;r.setPointerCapture(t.pointerId),r.setAttribute("data-noodle-dragging","");let n=this.#g(e,i),o=l=>{if(!this.#o)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#b(n,{x:c,y:u},i,this.#E(n,{x:c,y:u})),this.#h(),this.#T(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{r.releasePointerCapture(l.pointerId)}catch{}if(r.removeAttribute("data-noodle-dragging"),r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#Q(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#P(),this.#o=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#o=null,r.removeAttribute("data-noodle-dragging"),r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",a),this.#P(),this.#l=null,this.#c=null},this.#o={fromEl:e,fromSide:i,startPos:n,pointerId:t.pointerId},this.#l=null,r.addEventListener("pointermove",o),r.addEventListener("pointerup",a)};#E(t,e){let i=e.x-t.x,r=e.y-t.y;return Math.abs(i)>Math.abs(r)?i>0?"left":"right":r>0?"top":"bottom"}#T(t,e,i){this.#P();let r=this.#Q(t,e,i);r?.dot&&r.dot.setAttribute("data-noodle-drop-ready","")}#Q(t,e,i){let r=this.portSize*2,n=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.#m().find(b=>b._noodleId===f);!m||m===i||d<r&&d<o&&(o=d,n={el:m,side:p,dot:l})}return n}#P(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};S("noodles-ui",Ir);var Xi={};function ve(s,t){Xi[s]=t}function Dr(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 Bd={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()};ve("text",{render(s,t,e){Dr(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("number",{render(s,t,e){Dr(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),ve("currency",{render(s,t,e,i){Dr(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"}),ve("percent",{render(s,t,e){Dr(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var ey={year:"numeric",month:"short",day:"numeric"};ve("date",{render(s,t,e){Dr(e,s?new Intl.DateTimeFormat("en-US",ey).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",ey).format(new Date(s)):""},align:"left",sortFn:"datetime"});var iy={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};ve("datetime",{render(s,t,e){Dr(e,s?new Intl.DateTimeFormat("en-US",iy).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",iy).format(new Date(s)):""},align:"left",sortFn:"datetime"}),ve("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"}),ve("badge",{render(s,t,e,i){let r=e.querySelector("badge-ui");r||(e.textContent="",r=document.createElement("badge-ui"),e.appendChild(r)),r.setAttribute("text",String(s??""));let n=i?.variants||{};r.setAttribute("variant",n[s]||"neutral")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("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 r=i.querySelector("avatar-ui"),n=i.querySelector("span");r.setAttribute("text",String(s??"")),n.textContent=String(s??""),e.title=String(s??"")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("link",{render(s,t,e,i){let r=e.querySelector("a");r||(e.textContent="",r=document.createElement("a"),r.style.color="var(--table-accent, var(--a-primary))",r.style.textDecoration="none",e.appendChild(r));let n=String(s??""),o=n.includes("@")&&!n.startsWith("http");r.href=o?`mailto:${n}`:n,r.textContent=i?.label??n},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("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 r=i.querySelector("progress-ui"),n=i.querySelector("span");r.setAttribute("value",s!=null?String(s):"0"),n.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),ve("actions",{render(s,t,e,i){let r=i?.actions||[],n=e.querySelector("row-ui");if(n&&n.children.length!==r.length&&(n.remove(),n=null),!n){e.textContent="",n=document.createElement("row-ui"),n.setAttribute("gap","1");for(let o of r){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}}))}),n.appendChild(a)}e.appendChild(n)}},format(){return""},align:"center",sortFn:null});$();function fC(s,t){if(!t||!s)return;let e=t.split("."),i=s;for(let r of e){if(i==null)return;i=i[r]}return i}function di(s,t){return typeof t.accessor=="function"?t.accessor(s):fC(s,t.key)}function xh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
176
+ `)?'"'+t.replace(/"/g,'""')+'"':t}var qr=class extends x{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;#r=new Set;#n=null;#a=0;#o=new Set;#l=new Map;#c=null;#h=!1;#d=-1;#u=null;#f=null;set columns(t){this.#t=Array.isArray(t)?t:[],this.#y()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#a=0,this.#y()}get data(){return this.#e}get selected(){return[...this.#o].sort((t,e)=>t-e)}set selected(t){if(this.#o.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#o.add(e);this.#y(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#y(),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.#a=0,this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#u=null,this.#a=0,this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}toggleExpand(t){this.#r.has(t)?(this.#r.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#r.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#y()}get expanded(){return[...this.#r]}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.#a,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.#a=t.page),t.density&&(this.density=t.density),this.#y()}}#p(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#m(){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.#g(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#m(),this.#h||(this.#h=!0,this.addEventListener("click",this.#M),this.addEventListener("keydown",this.#_),this.addEventListener("pointerdown",this.#$))}disconnected(){this.removeEventListener("click",this.#M),this.removeEventListener("keydown",this.#_),this.removeEventListener("pointerdown",this.#$),this.#h=!1,this.#R(),this.#b&&(cancelAnimationFrame(this.#b),this.#b=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}#g(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let r={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},n=i.getAttribute("width");n&&(r.width=Number(n));let o=i.getAttribute("min-width");o&&(r.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(r.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(r.flex=Number(l)),e.push(r),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#b=null;#y(){!this.isConnected||this.#b||(this.#b=requestAnimationFrame(()=>{this.#b=null,this.render(),this.#p()}))}get#O(){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.#O)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 r=this.#e[i];return this.#O.some(n=>{let o=di(r,n);return o!=null&&String(o).toLowerCase().includes(e)})})}return this.#s.size&&(t=t.filter(e=>{let i=this.#e[e];for(let[r,{op:n,value:o}]of this.#s){let a=this.#t.find(u=>u.key===r),l=di(i,a||{key:r}),h=String(l??"").toLowerCase(),c=String(o).toLowerCase();switch(n){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:r,dir:n}of this.#i){let o=this.#t.find(u=>u.key===r),a=di(this.#e[e],o||{key:r}),l=di(this.#e[i],o||{key:r}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Xi[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Bd[d]||Bd.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 n==="asc"?c:-c}return 0}),t}#w(t){if(!this.paginate||this.paginate<=0)return t;let e=this.#a*this.paginate;return t.slice(e,e+this.paginate)}get#x(){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.#O;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.#k(e,t),this.#I();let i=this.querySelector(":scope > [data-body]");i||(i=document.createElement("div"),i.setAttribute("role","rowgroup"),i.setAttribute("data-body",""),e.after(i));let r=this.#v(),n=this.#w(r),o=[];for(let c of n){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#A(c,t);if(u&&this.#C(u,c,t),this.expandable&&(this.#r.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded")),o.push(d),this.expandable&&this.#r.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.#E(i),this.#T(i,r,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.#Q(h,r.length)):h&&h.remove()}#k(t,e){let i=this.#e.length>0&&this.#o.size===this.#e.length,r=[];if(this.selectable){let n=document.createElement("div");n.setAttribute("role","columnheader"),n.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),n.appendChild(o),r.push(n)}for(let n of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=n.label||n.key,o.appendChild(a),n.sortable!==!1&&this.sortable){o.dataset.sortKey=n.key,o.setAttribute("aria-label",`Sort by ${n.label||n.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===n.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(n.pinned&&o.setAttribute("data-pinned",n.pinned),n.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-resize-handle",""),h.dataset.resizeKey=n.key,o.appendChild(h)}if(n.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=n.key,h.setAttribute("aria-label",`Filter ${n.label||n.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(n.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#u===n.key){let u=this.#P(n);o.appendChild(u),o.setAttribute("data-filter-open","")}}r.push(o)}for(;t.children.length>r.length;)t.lastChild.remove();for(let n=0;n<r.length;n++)t.children[n]?t.replaceChild(r[n],t.children[n]):t.appendChild(r[n])}#A(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#C(i,t,e),i}#C(t,e,i){let r=this.#e[e],n=this.#o.has(e);t.dataset.index=e,n?(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");n&&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=di(r,a);if(typeof a.render=="function"){let u=a.render(h,r,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,r);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Xi[a.type||"text"];if(u?.render)u.render(h,r,l,a.meta);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Xi[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])}#E(t){let e=this.querySelector(":scope > [data-empty]"),i=this.querySelector(":scope > [data-loading]");if(this.loading){this.setAttribute("aria-busy","true");let r=this.#O,n=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+r.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<n;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 r=document.createElement("icon-ui");r.setAttribute("name","table");let n=document.createElement("span");n.textContent="No data",e.appendChild(r),e.appendChild(n),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#T(t,e,i){let r=i.some(a=>a.aggregate),n=this.querySelector(":scope > [data-agg-row]");if(!r||this.#e.length===0){n&&n.remove();return}n||(n=document.createElement("div"),n.setAttribute("role","row"),n.setAttribute("data-agg-row",""),t.after(n));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=di(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=Xi[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(;n.children.length>o.length;)n.lastChild.remove();for(let a=0;a<o.length;a++)n.children[a]?n.replaceChild(o[a],n.children[a]):n.appendChild(o[a])}#Q(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",n=>{this.#a=n.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))}),t.appendChild(i));let r=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#a+1)),i.setAttribute("total",String(r))}#P(t){let e=document.createElement("div");e.setAttribute("data-filter-dropdown","");let i=this.#s.get(t.key);if(t.filter==="select"){let r=[...new Set(this.#e.map(o=>{let a=di(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),n=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of r){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=n.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 r=document.createElement("input");r.type="number",r.placeholder="Filter...",r.value=i?.value??"",r.setAttribute("data-filter-input","");let n=document.createElement("select");n.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),n.appendChild(h)}let o=()=>{r.value?this.setFilter(t.key,r.value,n.value):this.setFilter(t.key,null)};r.addEventListener("input",o),n.addEventListener("change",o),e.appendChild(n),e.appendChild(r)}else{let r=document.createElement("input");r.type="text",r.placeholder=`Filter ${t.label||t.key}...`,r.value=i?.value??"",r.setAttribute("data-filter-input",""),r.addEventListener("input",()=>{r.value?this.setFilter(t.key,r.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(r)}if(i){let r=document.createElement("button");r.textContent="Clear",r.setAttribute("data-filter-clear",""),r.addEventListener("click",()=>{this.setFilter(t.key,null),this.#u=null,this.#y()}),e.appendChild(r)}return this.#f!=null&&cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{if(this.#f=null,!this.isConnected)return;let r=e.querySelector("input");r&&r.focus()}),e}#I(){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:r,value:n}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=r==="select"?`${n.split(",").length} selected`:n;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)}#$=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#D(t,e))};#M=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#u=this.#u===c?null:c,this.#y();return}this.#u&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#u=null,this.#y());let r=e.closest("[data-expand-toggle]");if(r&&this.expandable&&this.contains(r)){let c=r.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let n=e.closest("[data-resize-handle]");if(n&&this.contains(n)){this.#D(t,n);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.#o.add(u);else this.#o.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.#d>=0){let f=Math.min(this.#d,u),p=Math.max(this.#d,u);for(let m=f;m<=p;m++)d?this.#o.add(m):this.#o.delete(m)}else d?this.#o.add(u):this.#o.delete(u);this.#d=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(b=>b.key===d),m=p?di(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}}))}}};#L=null;#D(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,r=this.#t.find(l=>l.key===i);if(!r)return;let n=e.closest('[role="columnheader"]'),o=n?n.getBoundingClientRect().width:100,a=t.clientX;this.setAttribute("data-resizing",""),this.#L={key:i,col:r,startX:a,startWidth:o},document.addEventListener("pointermove",this.#X),document.addEventListener("pointerup",this.#q)}#X=t=>{if(!this.#L)return;let{key:e,col:i,startX:r,startWidth:n}=this.#L,o=t.clientX-r,a=n+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()};#q=t=>{if(!this.#L)return;let{key:e}=this.#L;document.removeEventListener("pointermove",this.#X),document.removeEventListener("pointerup",this.#q),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#L=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#R(){document.removeEventListener("pointermove",this.#X),document.removeEventListener("pointerup",this.#q),this.#L=null}#_=t=>{let i=this.#O.length+(this.selectable?1:0),r=this.querySelector(":scope > [data-body]"),n=r?r.children.length:0;this.#c||(this.#c={row:0,col:0});let{row:o,col:a}=this.#c,l=!0;switch(t.key){case"ArrowDown":o=Math.min(o+1,n-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>=n){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.#c={row:o,col:a},this.#Z())};#Z(){let t=this.querySelector("[data-focused]");if(t&&t.removeAttribute("data-focused"),!this.#c)return;let{row:e,col:i}=this.#c,r;e===-1?r=this.querySelector(":scope > [data-header]")?.children[i]:r=this.querySelector(":scope > [data-body]")?.children[e]?.children[i],r&&(r.setAttribute("data-focused",""),r.scrollIntoView?.({block:"nearest",inline:"nearest"}))}exportCSV(t="export.csv"){let e=this.#O,i=this.#v(),r=e.map(c=>xh(c.label||c.key)),n=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=di(u,d);if(typeof d.format=="function")return xh(d.format(f,u));let p=Xi[d.type||"text"];return p?.format?xh(p.format(f,u,d.meta)):xh(f)})}),o=[r.join(","),...n.map(c=>c.join(","))].join(`
177
+ `),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)}};S("table-ui",qr);$();var pC=200;function zd(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 _d(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 mC=50,sy=500;function ry(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("."),r=s;for(let n of i){if(r==null)return;r=r[n]}return r}function gC(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 bC(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(gC(s?.key))return"text";let e=[],i=Math.min(t?.length??0,sy),r=new Set;for(let n=0;n<i;n++){let o=ry(t[n],s);if(!(o==null||o==="")&&(e.push(o),r.add(String(o)),r.size>mC))return"text"}return e.length?"select":"text"}function OC(s,t){let e=new Set,i=Math.min(t?.length??0,sy);for(let r=0;r<i;r++){let n=ry(t[r],s);n==null||n===""||e.add(String(n))}return[...e].sort((r,n)=>r.localeCompare(n,void 0,{numeric:!0}))}var Xr=class s extends x{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;#r=null;#n=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.#a(),this.#h(),this.#o(),this.#g()}disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null);for(let t of this.#n)cancelAnimationFrame(t);this.#n.clear(),this.#y(),this.#c()}render(){this.#o(),this.#g(),this.#f()}#a(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let r=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(r)||s._OPT_OUT_PREFIX_RE.test(r)&&t.push(r)}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.`)}#o(){let t=this.#l();if(t===this.#t||(this.#c(),!t))return;this.#t=t;let e=()=>this.#k(),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}#c(){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 r=document.createElement("badge-ui");r.setAttribute("data-count-badge",""),r.setAttribute("size","sm"),r.setAttribute("variant","muted"),r.hidden=!0,e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-controls",""),n.appendChild(this.#u("filter","Filter","funnel-simple")),n.appendChild(this.#u("sort","Sort","arrows-down-up")),n.appendChild(this.#u("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("size","sm"),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String(pC)),o.addEventListener("search",this.#m);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(n),t.appendChild(o),t.appendChild(a),this.appendChild(t),this.#f(),this.#p()}#d(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}#u(t,e,i){let r=document.createElement("button-ui");return r.setAttribute("data-toolbar-btn",t),r.setAttribute("icon",i),r.setAttribute("text",e),r.setAttribute("variant","outline"),r.setAttribute("size","sm"),r.setAttribute("aria-haspopup","menu"),r.addEventListener("click",n=>{n.stopPropagation(),this.#b(t,r)}),r}#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(),r=this.#t?.data?.length,n=i||(Number.isFinite(r)?String(r):"");n?(e.setAttribute("text",n),e.hidden=!1):e.hidden=!0}#p(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=(i,r)=>{let n=t.querySelector(i);n&&(n.hidden=r)};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)}#m=t=>{let e=t.detail?.value??"";this.#t&&(this.#t.search=e),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#g(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#f()}#b(t,e){if(this.#i?.kind===t){this.#y();return}this.#y();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.#x(i),t==="columns"&&this.#A(i),document.body.appendChild(i);try{i.showPopover()}catch{}let r=ct(e,i,{placement:"bottom",gap:4});this.#i={kind:t,btn:e,panel:i,cleanup:r},this.#s||(this.#s=!0,this.#r=requestAnimationFrame(()=>{this.#r=null,!(!this.isConnected||!this.#s)&&(document.addEventListener("pointerdown",this.#O,!0),document.addEventListener("keydown",this.#S,!0))}))}#y(){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.#O,!0),document.removeEventListener("keydown",this.#S,!0))}}#O=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#y())};#S=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(zd("No filterable columns"));return}let i=e.filters||{};t.appendChild(_d("Filter rows"));let r=document.createElement("div");r.setAttribute("data-popover-list","");let n=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=bC(o,n),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=OC(o,n);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)}r.appendChild(a)}if(t.appendChild(r),Object.keys(i).length){let o=this.#d("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))}#x(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(zd("No sortable columns"));return}t.appendChild(_d("Sort by"));let i=e.sortState||[],r=new Map(i.map(o=>[o.key,o.dir])),n=document.createElement("div");n.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=r.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.#n.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.#n.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.#k()}),n.appendChild(l)}if(t.appendChild(n),i.length){let o=this.#d("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.#k()});t.appendChild(o)}}#k(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#x(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(zd("No columns"));return}t.appendChild(_d("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let r of e.columns){let n=document.createElement("field-ui");n.setAttribute("data-columns-row",""),n.setAttribute("inline",""),n.setAttribute("label",r.label||r.key);let o=document.createElement("check-ui");r.hidden||o.setAttribute("checked",""),o.dataset.key=r.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===r.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)}}))}),n.appendChild(o),i.appendChild(n)}t.appendChild(i)}};S("table-toolbar-ui",Xr);$();var Nr=class extends x{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","")}},Zr=class extends x{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=`
178
178
  <span slot="label"></span>
179
179
  <span slot="description"></span>
180
180
  <span slot="time"></span>
181
181
  `)}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 n=this.querySelector(':scope > [slot="icon"]');n||(n=document.createElement("icon-ui"),n.setAttribute("slot","icon"),this.prepend(n)),n.setAttribute("name",this.icon)}else this.querySelector(':scope > [slot="icon"]')?.remove();let r=this.querySelector(':scope > [slot="outcomes"]');if(this.#t.length>0){r||(r=document.createElement("ul"),r.setAttribute("slot","outcomes"),this.appendChild(r)),r.innerHTML="";for(let a of this.#t){let l=document.createElement("li");l.textContent=a,r.appendChild(l)}r.hidden=!this.#e;let n=this.querySelector(":scope > [data-timeline-toggle]");n||(n=document.createElement("button"),n.type="button",n.setAttribute("data-timeline-toggle",""),n.setAttribute("aria-label","Toggle details"),n.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(n)),n.innerHTML="";let o=document.createElement("icon-ui");o.setAttribute("name",this.#e?"caret-down":"caret-right"),o.setAttribute("color","muted"),o.setAttribute("size","sm"),n.appendChild(o)}else this.querySelector(":scope > [data-timeline-toggle]")?.remove(),r?.remove()}};S("timeline-ui",Nr),S("timeline-item-ui",Zr);$();var Br=class extends x{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,r)=>{i.setAttribute("data-index",r),r<this.step?i.setAttribute("status","completed"):r===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))}},zr=class extends x{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=`
182
182
  <span slot="label"></span>
183
183
  <span slot="description"></span>
184
- `)}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()}};S("stepper-ui",Br),S("stepper-item-ui",zr);$();var _r=class extends x{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;#r=0;#n=!1;#a=!1;#o=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#r}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.#c(),this.#g(),this.#n||(this.#n=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#S),this.addEventListener("pointerleave",this.#x),this.addEventListener("focusin",this.#k),this.addEventListener("focusout",this.#A)),this.addEventListener("keydown",this.#C),this.#t.addEventListener("pointerdown",this.#T),this.#t.addEventListener("pointermove",this.#Q),this.#t.addEventListener("pointerup",this.#P),this.#t.addEventListener("pointercancel",this.#P),this.#t.addEventListener("click",this.#I,!0),this.#t.addEventListener("dragstart",this.#$)),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.#S),this.removeEventListener("pointerleave",this.#x),this.removeEventListener("focusin",this.#k),this.removeEventListener("focusout",this.#A),this.removeEventListener("keydown",this.#C),this.#t&&(this.#t.removeEventListener("pointerdown",this.#T),this.#t.removeEventListener("pointermove",this.#Q),this.#t.removeEventListener("pointerup",this.#P),this.#t.removeEventListener("pointercancel",this.#P),this.#t.removeEventListener("click",this.#I,!0),this.#t.removeEventListener("dragstart",this.#$)),this.#o=null,this.#t=null,this.#n=!1}next(){let t=this.#u()-1,e=this.#m(this.#r),i=Math.min(e+1,t);if(i!==e||this.loop){let r=this.loop&&i===e?0:i;this.goTo(this.#p(r))}}prev(){let t=this.#u()-1,e=this.#m(this.#r),i=Math.max(e-1,0);if(i!==e||this.loop){let r=this.loop&&i===e?t:i;this.goTo(this.#p(r))}}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.#u()-1,i=this.#m(this.#r)>=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}`)})}#c(){this.#s=()=>{let t=this.#f();t!==this.#r&&(this.#r=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.#r=this.#f()}#h(){if(!this.#t)return 1;let t=getComputedStyle(this.#t),e=t.getPropertyValue("--swiper-columns").trim()||t.getPropertyValue("--swiper-columns-default").trim(),i=parseInt(e,10);return Number.isFinite(i)&&i>0?i:1}#u(){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,r=t.offsetWidth;return this.snap==="center"?i+r/2-e/2:this.snap==="end"?i+r-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),r=0,n=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<n&&(n=l,r=o)}return r}#p(t){if(this.snap!=="end")return t;let e=this.#h();return Math.min(this.slides.length-1,t+e-1)}#m(t){if(this.snap!=="end")return t;let e=this.#h();return Math.max(0,t-e+1)}#g(){this.#a||(this.#a=!0,this.chrome==="toolbar"?this.#O():this.#b(),this.#w(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#w()),this.#i.observe(this)))}#b(){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)}#O(){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 r=document.createElement("button-ui");r.setAttribute("icon","caret-left"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Previous slide"),r.addEventListener("press",()=>this.prev());let n=document.createElement("button-ui");n.setAttribute("icon","caret-right"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Next slide"),n.addEventListener("press",()=>this.next()),i.appendChild(r),i.appendChild(n),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.#y()}#y(){let t=this.querySelector("[data-swiper-counter]");if(!t)return;if(!this.counter){t.textContent="";return}let e=this.#m(this.#r)+1,i=this.#u();t.textContent=`${e} / ${i}`}#w(){let t=this.querySelector("[data-swiper-dots]");if(!t)return;let e=this.#u();if(t.children.length!==e){for(;t.firstChild;)t.removeChild(t.firstChild);for(let i=0;i<e;i++){let r=document.createElement("button");r.setAttribute("role","tab"),r.setAttribute("aria-label",`Page ${i+1}`),r.addEventListener("click",()=>this.goTo(this.#p(i))),t.appendChild(r)}}this.#v()}#v(){if(!this.#a)return;let t=this.querySelector("[data-swiper-dots]");if(t){let e=this.#u()-1,i=Math.min(Math.max(this.#m(this.#r),0),e);[...t.children].forEach((r,n)=>{r.setAttribute("aria-current",n===i?"true":"false")})}this.#y()}#S=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#x=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#k=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#A=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#C=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#E=5;#T=t=>{t.pointerType!=="touch"&&t.button===0&&(t.target.closest("button, button-ui, a, input, select, textarea")||(this.#o={pointerId:t.pointerId,startX:t.clientX,startScrollLeft:this.#t.scrollLeft,hasMoved:!1},this.#t.style.scrollBehavior="auto",this.#t.setAttribute("data-dragging","")))};#Q=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=t.clientX-this.#o.startX;if(Math.abs(e)>=this.#E){if(!this.#o.hasMoved){this.#o.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#o.startScrollLeft-e,t.preventDefault()}};#P=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=this.#o.hasMoved;if(e)try{this.#t.releasePointerCapture(t.pointerId)}catch{}this.#o=null,this.#t.style.scrollBehavior="",this.#t.removeAttribute("data-dragging"),e&&(this.#t.setAttribute("data-just-dragged",""),requestAnimationFrame(()=>this.#t?.removeAttribute("data-just-dragged")))};#I=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#$=t=>{this.#o&&t.preventDefault()}};S("swiper-ui",_r);var jr=class extends M{static labelDeprecated=!1;static properties={...M.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=`
184
+ `)}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()}};S("stepper-ui",Br),S("stepper-item-ui",zr);$();var _r=class extends x{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;#r=0;#n=!1;#a=!1;#o=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#r}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.#c(),this.#g(),this.#n||(this.#n=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#w),this.addEventListener("pointerleave",this.#x),this.addEventListener("focusin",this.#k),this.addEventListener("focusout",this.#A)),this.addEventListener("keydown",this.#C),this.#t.addEventListener("pointerdown",this.#T),this.#t.addEventListener("pointermove",this.#Q),this.#t.addEventListener("pointerup",this.#P),this.#t.addEventListener("pointercancel",this.#P),this.#t.addEventListener("click",this.#I,!0),this.#t.addEventListener("dragstart",this.#$)),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.#x),this.removeEventListener("focusin",this.#k),this.removeEventListener("focusout",this.#A),this.removeEventListener("keydown",this.#C),this.#t&&(this.#t.removeEventListener("pointerdown",this.#T),this.#t.removeEventListener("pointermove",this.#Q),this.#t.removeEventListener("pointerup",this.#P),this.#t.removeEventListener("pointercancel",this.#P),this.#t.removeEventListener("click",this.#I,!0),this.#t.removeEventListener("dragstart",this.#$)),this.#o=null,this.#t=null,this.#n=!1}next(){let t=this.#d()-1,e=this.#m(this.#r),i=Math.min(e+1,t);if(i!==e||this.loop){let r=this.loop&&i===e?0:i;this.goTo(this.#p(r))}}prev(){let t=this.#d()-1,e=this.#m(this.#r),i=Math.max(e-1,0);if(i!==e||this.loop){let r=this.loop&&i===e?t:i;this.goTo(this.#p(r))}}goTo(t){let e=this.slides[t];if(!e||!this.#t)return;let i=Math.max(0,this.#u(e));this.#t.scrollTo({left:i,behavior:"smooth"})}play(){this.pause(),!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(this.#e=setInterval(()=>{let t=this.#d()-1,i=this.#m(this.#r)>=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}`)})}#c(){this.#s=()=>{let t=this.#f();t!==this.#r&&(this.#r=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.#r=this.#f()}#h(){if(!this.#t)return 1;let e=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").trim(),i=parseInt(e,10);return Number.isFinite(i)&&i>0?i:1}#d(){let t=this.slides.length;return t===0?0:this.snap==="center"?t:Math.max(1,t-this.#h()+1)}#u(t){let e=this.#t.clientWidth,i=t.offsetLeft-this.#t.offsetLeft,r=t.offsetWidth;return this.snap==="center"?i+r/2-e/2:this.snap==="end"?i+r-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),r=0,n=1/0;for(let o=0;o<t.length;o++){let a=Math.max(0,Math.min(i,this.#u(t[o]))),l=Math.abs(e-a);l<n&&(n=l,r=o)}return r}#p(t){if(this.snap!=="end")return t;let e=this.#h();return Math.min(this.slides.length-1,t+e-1)}#m(t){if(this.snap!=="end")return t;let e=this.#h();return Math.max(0,t-e+1)}#g(){this.#a||(this.#a=!0,this.chrome==="toolbar"?this.#y():this.#b(),this.#S(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#S()),this.#i.observe(this)))}#b(){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)}#y(){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 r=document.createElement("button-ui");r.setAttribute("icon","caret-left"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Previous slide"),r.addEventListener("press",()=>this.prev());let n=document.createElement("button-ui");n.setAttribute("icon","caret-right"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Next slide"),n.addEventListener("press",()=>this.next()),i.appendChild(r),i.appendChild(n),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.#O()}#O(){let t=this.querySelector("[data-swiper-counter]");if(!t)return;if(!this.counter){t.textContent="";return}let e=this.#m(this.#r)+1,i=this.#d();t.textContent=`${e} / ${i}`}#S(){let t=this.querySelector("[data-swiper-dots]");if(!t)return;let e=this.#d();if(t.children.length!==e){for(;t.firstChild;)t.removeChild(t.firstChild);for(let i=0;i<e;i++){let r=document.createElement("button");r.setAttribute("role","tab"),r.setAttribute("aria-label",`Page ${i+1}`),r.addEventListener("click",()=>this.goTo(this.#p(i))),t.appendChild(r)}}this.#v()}#v(){if(!this.#a)return;let t=this.querySelector("[data-swiper-dots]");if(t){let e=this.#d()-1,i=Math.min(Math.max(this.#m(this.#r),0),e);[...t.children].forEach((r,n)=>{r.setAttribute("aria-current",n===i?"true":"false")})}this.#O()}#w=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#x=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#k=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#A=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#C=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#E=5;#T=t=>{t.pointerType!=="touch"&&t.button===0&&(t.target.closest("button, button-ui, a, input, select, textarea")||(this.#o={pointerId:t.pointerId,startX:t.clientX,startScrollLeft:this.#t.scrollLeft,hasMoved:!1},this.#t.style.scrollBehavior="auto",this.#t.setAttribute("data-dragging","")))};#Q=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=t.clientX-this.#o.startX;if(Math.abs(e)>=this.#E){if(!this.#o.hasMoved){this.#o.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#o.startScrollLeft-e,t.preventDefault()}};#P=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=this.#o.hasMoved;if(e)try{this.#t.releasePointerCapture(t.pointerId)}catch{}this.#o=null,this.#t.style.scrollBehavior="",this.#t.removeAttribute("data-dragging"),e&&(this.#t.setAttribute("data-just-dragged",""),requestAnimationFrame(()=>this.#t?.removeAttribute("data-just-dragged")))};#I=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#$=t=>{this.#o&&t.preventDefault()}};S("swiper-ui",_r);var jr=class extends M{static labelDeprecated=!1;static properties={...M.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=`
185
185
  <div data-dropzone tabindex="0" role="button">Drop files here or click to browse</div>
186
186
  <span hint="${this.hint||""}"></span>
187
187
  <div data-filelist></div>
188
- `),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.#o),this.#e.addEventListener("dragleave",this.#l),this.#e.addEventListener("drop",this.#c))}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 r=document.createElement("span");r.textContent=i.name,t.appendChild(r)}}get files(){return this.#t}#i=()=>{this.disabled||this.#r()};#s=t=>{this.disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#r())};async#r(){try{if(window.showOpenFilePicker){let t=this.#a(),e={multiple:this.multiple};t.length&&(e.types=t);let i=await window.showOpenFilePicker(e);if(!this.isConnected)return;let r=await Promise.all(i.map(n=>n.getFile()));if(!this.isConnected)return;this.#h(r)}else this.#n()}catch(t){if(t.name!=="AbortError")throw t}}#n(){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()}#a(){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}]:[]}#o=t=>{t.preventDefault(),this.querySelector("[data-dropzone]")?.setAttribute("data-dragover","")};#l=()=>{this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover")};#c=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.#o),this.#e.removeEventListener("dragleave",this.#l),this.#e.removeEventListener("drop",this.#c)),this.#e=null}};S("upload-ui",jr);Ld();var Vr=VO({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,r=0,n=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);r=f[0]||0,n=f[1]||0}else{let f=new DOMMatrixReadOnly(u.transform);r=f.m41,n=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=r+u,p=n+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=r+u,p=n+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 Wr=class extends x{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(Vr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Vr),this.#t=!0)}};S("card-ui",Wr);$();var Ur=class extends x{static properties={src:{type:String,default:"",reflect:!0},text:{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}static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","img")}render(){!this.src&&!this.displayName&&!this.icon||(this.src?(this.#t||(this.#t=document.createElement("img"),this.#t.setAttribute("slot","img"),this.#t.onerror=()=>{this.#t.remove(),this.#t=null,this.#s()}),this.#t.src=this.src,this.#t.alt=this.displayName||"",this.#t.parentElement||this.appendChild(this.#t),this.#e&&(this.#e.remove(),this.#e=null)):this.icon?(this.#t&&(this.#t.remove(),this.#t=null),this.#e&&(this.#e.remove(),this.#e=null),this.#i||(this.#i=document.createElement("icon-ui"),this.#i.setAttribute("slot","icon"),this.appendChild(this.#i)),this.#i.setAttribute("name",this.icon)):(this.#t&&(this.#t.remove(),this.#t=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s()),this.setAttribute("aria-label",this.displayName||this.icon||""))}#s(){if(!this.displayName)return;let t=this.displayName.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","initials"),this.appendChild(this.#e)),this.#e.textContent=t}},Fr=class extends x{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 n of t)n.setAttribute("size",this.size);t.forEach((n,o)=>{n.style.display=o<e?"":"none",n.style.zIndex=String(t.length-o)});let r=this.querySelector('[slot="overflow"]');i>0?(r||(r=document.createElement("span"),r.setAttribute("slot","overflow"),this.appendChild(r)),r.textContent=`+${i}`,r.setAttribute("aria-label",`${i} more`),r.style.zIndex="0"):r&&r.remove()}};S("avatar-ui",Ur),S("avatar-group-ui",Fr);$();var Yr=class extends x{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}};S("progress-ui",Yr);$();var Hr=class extends x{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 r=0;r<this.#e.children.length;r++)this.#e.children[r].toggleAttribute("data-active",r<e)}}disconnected(){this.#t=null,this.#e=null}};S("step-progress-ui",Hr);$();var Gr=class extends x{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}};S("skeleton-ui",Gr);$();var Kr=class extends x{static properties={size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"arc",reflect:!0},tone:{type:String,default:"current",reflect:!0},paused:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"Loading",reflect:!1}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-busy")||this.setAttribute("aria-busy","true"),this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}render(){this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}#t(){let t=this.variant==="dots",e=this.querySelectorAll(":scope > [data-spinner-dot]");if(t){if(e.length===3)return;e.forEach(r=>r.remove());let i=document.createDocumentFragment();for(let r=1;r<=3;r++){let n=document.createElement("span");n.setAttribute("data-spinner-dot",String(r)),n.setAttribute("aria-hidden","true"),i.appendChild(n)}this.appendChild(i)}else e.length&&e.forEach(i=>i.remove())}};S("spinner-ui",Kr);$();var Jr=class extends x{static properties={active:{type:Boolean,default:!1,reflect:!0},delay:{type:Number,default:200,reflect:!0},label:{type:String,default:"Loading\u2026",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"active");if(t?.set){let e=t.set;Object.defineProperty(this,"active",{get:t.get,set:i=>{let r=!!t.get.call(this);e.call(this,i),!!i!==r&&this.#s(!!i)},configurable:!0})}}connected(){this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.setAttribute("aria-label",this.label||"Loading"),this.#t=this.parentElement,this.active&&this.#s(!0)}disconnected(){this.#a(),this.#i&&this.#n(),this.#t=null}render(){let t=this.label||"Loading";this.setAttribute("aria-label",t);let e=this.querySelector(":scope > spinner-ui[data-loading-overlay-auto]");e&&e.getAttribute("label")!==t&&e.setAttribute("label",t),this.children.length===0&&this.#o()}#s(t){if(this.#a(),t){let e=Math.max(0,Number(this.delay)||0);e===0?this.#r():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#r()},e)}else this.#i&&this.#n()}#r(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#n(){let t=this.#t||this.parentElement;t&&t.getAttribute("aria-busy")==="true"&&t.removeAttribute("aria-busy"),this.#i=!1}#a(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}#o(){let t=document.createElement("spinner-ui");t.setAttribute("size","lg"),t.setAttribute("tone","subtle"),t.setAttribute("label",this.label||"Loading"),t.setAttribute("data-loading-overlay-auto",""),this.appendChild(t)}};S("loading-overlay-ui",Jr);$();var ny=new Set;function oy(s,t){ny.has(s)||(ny.add(s),console.warn(`[alert-ui] ${t}`))}var tn=class s extends x{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},pattern:{type:String,default:"",reflect:!0},amount:{type:Number,default:0,reflect:!0},currency:{type:String,default:"USD",reflect:!0},dueAt:{type:String,default:"",reflect:!0,attribute:"due-at"},cardLast4:{type:String,default:"",reflect:!0,attribute:"card-last4"},reason:{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#t={declined:"x-circle",expired:"clock",insufficient:"wallet",network:"wifi-slash"};static template=()=>null;#e(){this.getAttribute("variant")==="error"&&(oy("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")&&(oy("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","")}#i=t=>{if(t.target.closest('[slot="close"]')){this.#h();return}if(this.pattern==="dunning"){let e=t.target.closest("[data-dunning-action]");if(e&&this.contains(e)){let i=e.getAttribute("data-dunning-action")||"";this.dispatchEvent(new CustomEvent("dunning-action",{bubbles:!0,composed:!0,detail:{action:i,amount:this.amount,currency:this.currency,dueAt:this.dueAt}}))}}};connected(){this.#e(),this.#c(),(this.icon||this.pattern==="dunning"&&this.reason)&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#i)}disconnected(){this.removeEventListener("press",this.#i)}render(){if(this.pattern==="dunning"){this.#s(),this.#c();return}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 r=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",r)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let n=document.createElement("strong");n.textContent=this.title,t.appendChild(n),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let r=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",r)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#c()}#s(){let t=this.icon||s.#t[this.reason]||"x-circle",e=this.ensure("leading");e&&e.setAttribute("name",t);let i=this.ensure("content");if(!i)return;i.setAttribute("data-alert-auto","dunning"),i.replaceChildren();let r=this.title||this.#r();if(r){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=r,i.appendChild(l)}let n=this.#n(),o=this.#o();if(n||o){if(i.appendChild(document.createTextNode(" ")),n){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=n,i.appendChild(l)}if(n&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[r,n,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#r(){switch(this.reason){case"expired":return"Card expired";case"insufficient":return"Insufficient funds";case"network":return"Network error";case"declined":return"Payment failed";default:return this.variant==="warning"?"Payment due soon":"Payment failed"}}#n(){if(!this.amount&&this.amount!==0||this.amount===0)return"";try{let t=this.getAttribute("lang")||this.lang||void 0;return new Intl.NumberFormat(t,{style:"currency",currency:this.currency||"USD"}).format(this.amount)}catch{return`${this.currency||""} ${this.amount}`.trim()}}#a(){if(!this.dueAt)return"";let t=/^\d{4}-\d{2}-\d{2}$/.test(this.dueAt)?new Date(`${this.dueAt}T00:00:00`):new Date(this.dueAt);if(Number.isNaN(t.getTime()))return"";try{let e=this.getAttribute("lang")||this.lang||void 0;return new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}).format(t)}catch{return t.toDateString()}}#o(){let t=[];this.cardLast4&&t.push(`Card ending ${this.cardLast4}`),this.reason&&this.reason!=="declined"&&t.push(this.#l());let e=this.#a();if(e){let i=this.variant==="warning"?"due":"failed";t.push(`${i} ${e}`)}return t.join(" \xB7 ")}#l(){switch(this.reason){case"expired":return"expired";case"insufficient":return"insufficient funds";case"network":return"network error";case"declined":return"declined";default:return""}}#c(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#h(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};S("alert-ui",tn);$();var yC={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},en=class extends x{static properties={text:{type:String,default:"",reflect:!1},variant:{type:String,default:"default",reflect:!0},icon:{type:String,default:"",reflect:!0},live:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>'};static requiredIcons=["info","check-circle","warning","x-circle"];static template=()=>null;#t(t){return!!(t&&(t._uiPart||t.hasAttribute("data-im-auto")))}connected(){}render(){this.live?this.setAttribute("aria-live",this.live):this.hasAttribute("aria-live")&&this.removeAttribute("aria-live"),this.#e();let t=this.icon||yC[this.variant]||"",e=this.querySelector(':scope > [slot="leading"]');if(!(e&&!this.#t(e)))if(t){let i=this.ensure("leading");i&&(i.setAttribute("data-im-auto",""),i.getAttribute("name")!==t&&i.setAttribute("name",t))}else this.drop("leading")}#e(){let t=this.querySelector(":scope > [data-im-text]");if(Array.from(this.childNodes).some(i=>i===t?!1:i.nodeType===Node.ELEMENT_NODE?!(i.getAttribute&&i.getAttribute("slot")==="leading"):!!(i.nodeType===Node.TEXT_NODE&&i.textContent.trim()))){t&&t.remove();return}this.text?(t||(t=document.createElement("span"),t.setAttribute("data-im-text",""),this.appendChild(t)),t.textContent!==this.text&&(t.textContent=this.text)):t&&t.remove()}};S("inline-message-ui",en);$();var sn=class extends x{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};S("kbd-ui",sn);$();var rn=class extends x{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" weight="bold"></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")}};S("tag-ui",rn);$();var vC=new Set(["block","dot","square","line","dashed"]),xC=new Set(["sm","md","lg"]),SC=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),wC={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},kC={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function AC(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&SC.has(t)):[]}var hs=null;function EC(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!hs){let u=document.createElement("canvas");u.width=1,u.height=1,hs=u.getContext("2d")}hs.fillStyle="#000",hs.clearRect(0,0,1,1),hs.fillStyle=s,hs.fillRect(0,0,1,1);let[t,e,i]=hs.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let r=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},n=r(t),o=r(e),a=r(i),l=Math.cbrt(.4122214708*n+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*n+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*n+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var nn=class extends x{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;#r=null;#n=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;connected(){this.#d(),this.#w(),this.#u=new MutationObserver(t=>{let e=!1;for(let i of t){for(let r of i.addedNodes)if(r.nodeType===1){if(r.getAttribute?.("slot")==="chrome"){e=!0;break}if(r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#u.takeRecords())}),this.#u.observe(this,{childList:!0})}render(){this.#d(),this.#p(),this.#m(),this.#b(),this.#O(),this.#y(),this.#g()}#d(){if(this.#n)return;let t=Array.from(this.children).filter(n=>n.getAttribute&&n.getAttribute("slot")==="chrome");for(let n of t)n.remove();let e=Array.from(this.children).filter(n=>n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]'));for(let n of e)n.remove();let i=[];for(let n of Array.from(this.childNodes))(n.nodeType===3&&!n.data||n.nodeType===8)&&i.push(n);for(let n of i)n.remove();let r=Array.from(this.childNodes).filter(n=>!(n.nodeType===1&&n.dataset&&(n.dataset.tile!==void 0||n.dataset.label!==void 0||n.dataset.detail!==void 0||n.dataset.badge!==void 0||n.dataset.copy!==void 0))&&!(n.nodeType===3&&!n.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 n of t)this.appendChild(n);for(let n of e)this.appendChild(n);for(let n of i)this.appendChild(n);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",""),r.length)for(let n of r)this.#e.appendChild(n);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#r=document.createElement("button"),this.#r.setAttribute("data-copy",""),this.#r.setAttribute("type","button"),this.#r.setAttribute("aria-label","Copy value"),this.#r.setAttribute("hidden",""),this.#r.textContent="\u29C9",this.appendChild(this.#r),this.#n=!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.#r&&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.#r||!(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=vC.has(this.shape)?this.shape:"square",e=xC.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)}#m(){if(!this.#s)return;let t=AC(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(n=>n.dataset.badgeVariant);if(e.length===t.length&&e.every((n,o)=>n===t[o]))return;let r=document.createDocumentFragment();for(let n of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",n),o.setAttribute("role","img"),o.setAttribute("aria-label",kC[n]),o.textContent=wC[n],r.appendChild(o)}this.#s.replaceChildren(r)}#g(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#a=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#a)return;this.#a=t;let e=EC(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)}#b(){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)}#O(){if(!this.#r)return;if(!this.copyable){this.#r.setAttribute("hidden","");return}this.#r.removeAttribute("hidden");let t=this.#S();t?this.#r.setAttribute("aria-label",`Copy ${t}`):this.#r.setAttribute("aria-label","Copy value")}#y(){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"))}#w(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#r)||this.#v()},this.#l=t=>{this.selectable&&(t.key!=="Enter"&&t.key!==" "||t.target!==this.#r&&(t.preventDefault(),this.#v()))},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#S();e&&this.#x(e)},this.#r.addEventListener("click",this.#c)}#v(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#S(){return this.copyValue?this.copyValue:this.color?this.color:""}async#x(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#k(e)}#k(t){this.#r&&(this.#h!=null&&clearTimeout(this.#h),this.#r.setAttribute("data-copy-state",t?"ok":"fail"),this.#r.textContent=t?"\u2713":"\u26A0",this.#h=setTimeout(()=>{this.#r&&(this.#r.removeAttribute("data-copy-state"),this.#r.textContent="\u29C9",this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#u&&(this.#u.disconnect(),this.#u=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#r&&this.#c&&this.#r.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=!1}};S("swatch-ui",nn);Ct();var ay={xs:0,sm:480,md:768,lg:1024,xl:1280},cs=Object.keys(ay),jd=Object.values(ay);function ly(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=cs.length-1;t>=0;t--)if(s>=jd[t])return cs[t];return"xs"}var Ce=qi(ly());if(typeof window<"u")for(let s=1;s<jd.length;s++)window.matchMedia(`(min-width: ${jd[s]}px)`).addEventListener("change",()=>{Ce.value=ly()});function Nt(s,t=Ce.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 r=cs.indexOf(t),n=null,o=-1;for(let[a,l]of i){let h=cs.indexOf(a);h!==-1&&h<=r&&h>o&&(n=l,o=h)}return n??e}$();var on=class extends x{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,n=t?.includes("@")||e?.includes("@")||i?.includes("@")?Ce.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",PC(Nt(t,n))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Nt(e,n);this.style.setProperty("--col-align",QC(o)),this.style.textAlign=TC(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",LC(Nt(i,n))):this.style.removeProperty("--col-justify")}},CC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},$C={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function PC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function QC(s){return CC[s]??s}function TC(s){return{start:"start",center:"center",end:"end"}[s]??""}function LC(s){return $C[s]??s}S("col-ui",on);$();var an=class s extends x{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.#g()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=t=>{let e=this.#g();if(!e)return;let i=this.#b(e);i&&(t.preventDefault(),i.focus())};connected(){this.#u(),this.#d(),this.#f(),this.#p(),this.#c(),this.#t?.addEventListener("click",this.#n),this.#r=new MutationObserver(()=>{this.#p(),this.#c(),this.#m(),this.#a()}),this.#r.observe(this,{childList:!0}),this.#a()}disconnected(){this.#r?.disconnect(),this.#r=null,this.#h(),this.#t?.removeEventListener("click",this.#n),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.#a(),this.#m()}#a(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#o=()=>{this.#a(),this.#m()};#l=null;#c(){let t=this.#g();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#u(){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.#g();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#y()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#g();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 r=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(n=>n&&!n.startsWith("field-hint-")&&!n.startsWith("field-err-")),...e].join(" ").trim();r?t.setAttribute("aria-describedby",r):t.removeAttribute("aria-describedby")}#g(){for(let t of this.children)if(!t.hasAttribute("slot"))return t;return null}#b(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#O=0;static#y(){return`field-ctl-${++s.#O}`}static#w=0;static#v(t){return`field-${t}-${++s.#w}`}};S("field-ui",an);$();var ln=class extends x{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}};S("fields-ui",ln);$();var hn=class extends x{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(Vr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Vr),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,r=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!r?Ce.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",IC(Nt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",DC(Nt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",qC(Nt(i,o))):this.style.removeProperty("--row-justify"),r){let a=cs.indexOf(o),l=cs.indexOf(r);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},MC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},RC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function IC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function DC(s){return MC[s]??s}function qC(s){return RC[s]??s}S("row-ui",hn);$();var cn=class extends x{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"},minColumnWidth:{type:String,default:"",reflect:!0,attribute:"min-column-width"}};static template=()=>null;render(){let t=Ce.value,e=this.columns;if(e?.includes("@")){let r=Nt(e,t);this.style.gridTemplateColumns=this.#t(r),this.style.gridAutoFlow=r?"row":"",this.style.gridAutoColumns=r?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";this.minColumnWidth?this.style.setProperty("--grid-min-col",this.minColumnWidth):this.style.removeProperty("--grid-min-col");let i=this.gap;if(i?.includes("@")){let r=Nt(i,t),n=this.#e(r);this.style.columnGap=n,this.style.rowGap=n}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(var(--grid-min-col, 12rem), 1fr))":t==="auto-fit"?"repeat(auto-fit, minmax(var(--grid-min-col, 12rem), 1fr))":t:""}#e(t){return!t||t==="0"?"0":/^\d+$/.test(t)?`var(--a-space-${t})`:`var(--a-gap-${t})`}};S("grid-ui",cn);$();var un=class extends x{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};S("stack-ui",un);$();function us(s,t,e=5){let r=(t-s||1)/e,n=Math.pow(10,Math.floor(Math.log10(r))),o=r/n,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*n,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 hy(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 re(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function St({label:s,value:t,pct:e,series:i}){let r="";return s!=null&&(r+=` data-tip-label="${re(String(s))}"`),t!=null&&(r+=` data-tip-value="${t}"`),e!=null&&(r+=` data-tip-pct="${e}"`),i!=null&&(r+=` data-tip-series="${re(String(i))}"`),r}function ne(s,t,e){return s+t*Math.cos(e)}function oe(s,t,e){return s+t*Math.sin(e)}function XC(s,t,e,i,r){let n=ne(s,e,i),o=oe(t,e,i),a=ne(s,e,r),l=oe(t,e,r),h=r-i>Math.PI?1:0;return`M ${s} ${t} L ${n} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function Vd(s,t,e,i,r,n,o=0){let a=(e-i)/2,l=n-r,h=Math.max(0,Math.min(o,a)),c=()=>{let ut=ne(s,e,r),ot=oe(t,e,r),bt=ne(s,e,n),xt=oe(t,e,n),Ot=ne(s,i,n),Et=oe(t,i,n),Tt=ne(s,i,r),Ft=oe(t,i,r),rs=l>Math.PI?1:0;return`M ${ut} ${ot} A ${e} ${e} 0 ${rs} 1 ${bt} ${xt} L ${Ot} ${Et} A ${i} ${i} 0 ${rs} 0 ${Tt} ${Ft} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=r+u,p=n-u,m=r+d,b=n-d,g=p-f>Math.PI?1:0,y=ne(s,e,f),v=oe(t,e,f),w=ne(s,e,p),k=oe(t,e,p),E=ne(s,i,b),A=oe(t,i,b),C=ne(s,i,m),T=oe(t,i,m),Q=ne(s,e-h,r),D=oe(t,e-h,r),R=ne(s,i+h,r),_=oe(t,i+h,r),V=ne(s,e-h,n),U=oe(t,e-h,n),J=ne(s,i+h,n),rt=oe(t,i+h,n);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${w} ${k} A ${h} ${h} 0 0 1 ${V} ${U} L ${J} ${rt} A ${h} ${h} 0 0 1 ${E} ${A} A ${i} ${i} 0 ${g} 0 ${C} ${T} A ${h} ${h} 0 0 1 ${R} ${_} L ${Q} ${D} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function Qa(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(r=>`${r.x},${r.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let r=0;r<e-1;r++){let n=s[Math.max(r-1,0)],o=s[r],a=s[r+1],l=s[Math.min(r+2,e-1)],h=o.x+(a.x-n.x)*t/3,c=o.y+(a.y-n.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 Wd(s,t,e=.4){let i=Qa(s,e),r=s[s.length-1],n=s[0];return`${i} L${r.x},${t} L${n.x},${t} Z`}function Sh(s,t,e,i,r=0){if(i<=0||e<=0)return"";let n=Math.max(0,Math.min(r,e/2,i));return n===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+n} Q${s},${t} ${s+n},${t} H${s+e-n} Q${s+e},${t} ${s+e},${t+n} V${t+i} Z`}var NC={std:{ratio:4/3}},dn=class extends x{static properties={type:{type:String,default:"bar",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},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;#r=0;#n=0;#a=new Set;#o(){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.
188
+ `),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.#o),this.#e.addEventListener("dragleave",this.#l),this.#e.addEventListener("drop",this.#c))}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 r=document.createElement("span");r.textContent=i.name,t.appendChild(r)}}get files(){return this.#t}#i=()=>{this.disabled||this.#r()};#s=t=>{this.disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#r())};async#r(){try{if(window.showOpenFilePicker){let t=this.#a(),e={multiple:this.multiple};t.length&&(e.types=t);let i=await window.showOpenFilePicker(e);if(!this.isConnected)return;let r=await Promise.all(i.map(n=>n.getFile()));if(!this.isConnected)return;this.#h(r)}else this.#n()}catch(t){if(t.name!=="AbortError")throw t}}#n(){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()}#a(){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}]:[]}#o=t=>{t.preventDefault(),this.querySelector("[data-dropzone]")?.setAttribute("data-dragover","")};#l=()=>{this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover")};#c=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.#o),this.#e.removeEventListener("dragleave",this.#l),this.#e.removeEventListener("drop",this.#c)),this.#e=null}};S("upload-ui",jr);Ld();var Vr=VO({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,r=0,n=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);r=f[0]||0,n=f[1]||0}else{let f=new DOMMatrixReadOnly(u.transform);r=f.m41,n=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=r+u,p=n+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=r+u,p=n+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 Wr=class extends x{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(Vr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Vr),this.#t=!0)}};S("card-ui",Wr);$();var Ur=class extends x{static properties={src:{type:String,default:"",reflect:!0},text:{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}static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","img")}render(){!this.src&&!this.displayName&&!this.icon||(this.src?(this.#t||(this.#t=document.createElement("img"),this.#t.setAttribute("slot","img"),this.#t.onerror=()=>{this.#t.remove(),this.#t=null,this.#s()}),this.#t.src=this.src,this.#t.alt=this.displayName||"",this.#t.parentElement||this.appendChild(this.#t),this.#e&&(this.#e.remove(),this.#e=null)):this.icon?(this.#t&&(this.#t.remove(),this.#t=null),this.#e&&(this.#e.remove(),this.#e=null),this.#i||(this.#i=document.createElement("icon-ui"),this.#i.setAttribute("slot","icon"),this.appendChild(this.#i)),this.#i.setAttribute("name",this.icon)):(this.#t&&(this.#t.remove(),this.#t=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s()),this.setAttribute("aria-label",this.displayName||this.icon||""))}#s(){if(!this.displayName)return;let t=this.displayName.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","initials"),this.appendChild(this.#e)),this.#e.textContent=t}},Fr=class extends x{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 n of t)n.setAttribute("size",this.size);t.forEach((n,o)=>{n.style.display=o<e?"":"none",n.style.zIndex=String(t.length-o)});let r=this.querySelector('[slot="overflow"]');i>0?(r||(r=document.createElement("span"),r.setAttribute("slot","overflow"),this.appendChild(r)),r.textContent=`+${i}`,r.setAttribute("aria-label",`${i} more`),r.style.zIndex="0"):r&&r.remove()}};S("avatar-ui",Ur),S("avatar-group-ui",Fr);$();var Yr=class extends x{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}};S("progress-ui",Yr);$();var Hr=class extends x{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 r=0;r<this.#e.children.length;r++)this.#e.children[r].toggleAttribute("data-active",r<e)}}disconnected(){this.#t=null,this.#e=null}};S("step-progress-ui",Hr);$();var Gr=class extends x{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}};S("skeleton-ui",Gr);$();var Kr=class extends x{static properties={size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"arc",reflect:!0},tone:{type:String,default:"current",reflect:!0},paused:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"Loading",reflect:!1}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-busy")||this.setAttribute("aria-busy","true"),this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}render(){this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}#t(){let t=this.variant==="dots",e=this.querySelectorAll(":scope > [data-spinner-dot]");if(t){if(e.length===3)return;e.forEach(r=>r.remove());let i=document.createDocumentFragment();for(let r=1;r<=3;r++){let n=document.createElement("span");n.setAttribute("data-spinner-dot",String(r)),n.setAttribute("aria-hidden","true"),i.appendChild(n)}this.appendChild(i)}else e.length&&e.forEach(i=>i.remove())}};S("spinner-ui",Kr);$();var Jr=class extends x{static properties={active:{type:Boolean,default:!1,reflect:!0},delay:{type:Number,default:200,reflect:!0},label:{type:String,default:"Loading\u2026",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"active");if(t?.set){let e=t.set;Object.defineProperty(this,"active",{get:t.get,set:i=>{let r=!!t.get.call(this);e.call(this,i),!!i!==r&&this.#s(!!i)},configurable:!0})}}connected(){this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.setAttribute("aria-label",this.label||"Loading"),this.#t=this.parentElement,this.active&&this.#s(!0)}disconnected(){this.#a(),this.#i&&this.#n(),this.#t=null}render(){let t=this.label||"Loading";this.setAttribute("aria-label",t);let e=this.querySelector(":scope > spinner-ui[data-loading-overlay-auto]");e&&e.getAttribute("label")!==t&&e.setAttribute("label",t),this.children.length===0&&this.#o()}#s(t){if(this.#a(),t){let e=Math.max(0,Number(this.delay)||0);e===0?this.#r():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#r()},e)}else this.#i&&this.#n()}#r(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#n(){let t=this.#t||this.parentElement;t&&t.getAttribute("aria-busy")==="true"&&t.removeAttribute("aria-busy"),this.#i=!1}#a(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}#o(){let t=document.createElement("spinner-ui");t.setAttribute("size","lg"),t.setAttribute("tone","subtle"),t.setAttribute("label",this.label||"Loading"),t.setAttribute("data-loading-overlay-auto",""),this.appendChild(t)}};S("loading-overlay-ui",Jr);$();var ny=new Set;function oy(s,t){ny.has(s)||(ny.add(s),console.warn(`[alert-ui] ${t}`))}var tn=class s extends x{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},pattern:{type:String,default:"",reflect:!0},amount:{type:Number,default:0,reflect:!0},currency:{type:String,default:"USD",reflect:!0},dueAt:{type:String,default:"",reflect:!0,attribute:"due-at"},cardLast4:{type:String,default:"",reflect:!0,attribute:"card-last4"},reason:{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#t={declined:"x-circle",expired:"clock",insufficient:"wallet",network:"wifi-slash"};static template=()=>null;#e(){this.getAttribute("variant")==="error"&&(oy("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")&&(oy("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","")}#i=t=>{if(t.target.closest('[slot="close"]')){this.#h();return}if(this.pattern==="dunning"){let e=t.target.closest("[data-dunning-action]");if(e&&this.contains(e)){let i=e.getAttribute("data-dunning-action")||"";this.dispatchEvent(new CustomEvent("dunning-action",{bubbles:!0,composed:!0,detail:{action:i,amount:this.amount,currency:this.currency,dueAt:this.dueAt}}))}}};connected(){this.#e(),this.#c(),(this.icon||this.pattern==="dunning"&&this.reason)&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#i)}disconnected(){this.removeEventListener("press",this.#i)}render(){if(this.pattern==="dunning"){this.#s(),this.#c();return}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 r=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",r)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let n=document.createElement("strong");n.textContent=this.title,t.appendChild(n),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let r=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",r)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#c()}#s(){let t=this.icon||s.#t[this.reason]||"x-circle",e=this.ensure("leading");e&&e.setAttribute("name",t);let i=this.ensure("content");if(!i)return;i.setAttribute("data-alert-auto","dunning"),i.replaceChildren();let r=this.title||this.#r();if(r){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=r,i.appendChild(l)}let n=this.#n(),o=this.#o();if(n||o){if(i.appendChild(document.createTextNode(" ")),n){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=n,i.appendChild(l)}if(n&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[r,n,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#r(){switch(this.reason){case"expired":return"Card expired";case"insufficient":return"Insufficient funds";case"network":return"Network error";case"declined":return"Payment failed";default:return this.variant==="warning"?"Payment due soon":"Payment failed"}}#n(){if(!this.amount&&this.amount!==0||this.amount===0)return"";try{let t=this.getAttribute("lang")||this.lang||void 0;return new Intl.NumberFormat(t,{style:"currency",currency:this.currency||"USD"}).format(this.amount)}catch{return`${this.currency||""} ${this.amount}`.trim()}}#a(){if(!this.dueAt)return"";let t=/^\d{4}-\d{2}-\d{2}$/.test(this.dueAt)?new Date(`${this.dueAt}T00:00:00`):new Date(this.dueAt);if(Number.isNaN(t.getTime()))return"";try{let e=this.getAttribute("lang")||this.lang||void 0;return new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}).format(t)}catch{return t.toDateString()}}#o(){let t=[];this.cardLast4&&t.push(`Card ending ${this.cardLast4}`),this.reason&&this.reason!=="declined"&&t.push(this.#l());let e=this.#a();if(e){let i=this.variant==="warning"?"due":"failed";t.push(`${i} ${e}`)}return t.join(" \xB7 ")}#l(){switch(this.reason){case"expired":return"expired";case"insufficient":return"insufficient funds";case"network":return"network error";case"declined":return"declined";default:return""}}#c(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#h(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};S("alert-ui",tn);$();var yC={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},en=class extends x{static properties={text:{type:String,default:"",reflect:!1},variant:{type:String,default:"default",reflect:!0},icon:{type:String,default:"",reflect:!0},live:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>'};static requiredIcons=["info","check-circle","warning","x-circle"];static template=()=>null;#t(t){return!!(t&&(t._uiPart||t.hasAttribute("data-im-auto")))}connected(){}render(){this.live?this.setAttribute("aria-live",this.live):this.hasAttribute("aria-live")&&this.removeAttribute("aria-live"),this.#e();let t=this.icon||yC[this.variant]||"",e=this.querySelector(':scope > [slot="leading"]');if(!(e&&!this.#t(e)))if(t){let i=this.ensure("leading");i&&(i.setAttribute("data-im-auto",""),i.getAttribute("name")!==t&&i.setAttribute("name",t))}else this.drop("leading")}#e(){let t=this.querySelector(":scope > [data-im-text]");if(Array.from(this.childNodes).some(i=>i===t?!1:i.nodeType===Node.ELEMENT_NODE?!(i.getAttribute&&i.getAttribute("slot")==="leading"):!!(i.nodeType===Node.TEXT_NODE&&i.textContent.trim()))){t&&t.remove();return}this.text?(t||(t=document.createElement("span"),t.setAttribute("data-im-text",""),this.appendChild(t)),t.textContent!==this.text&&(t.textContent=this.text)):t&&t.remove()}};S("inline-message-ui",en);$();var sn=class extends x{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};S("kbd-ui",sn);$();var rn=class extends x{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" weight="bold"></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")}};S("tag-ui",rn);$();var vC=new Set(["block","dot","square","line","dashed"]),xC=new Set(["sm","md","lg"]),SC=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),wC={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},kC={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function AC(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&SC.has(t)):[]}var hs=null;function EC(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!hs){let u=document.createElement("canvas");u.width=1,u.height=1,hs=u.getContext("2d")}hs.fillStyle="#000",hs.clearRect(0,0,1,1),hs.fillStyle=s,hs.fillRect(0,0,1,1);let[t,e,i]=hs.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let r=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},n=r(t),o=r(e),a=r(i),l=Math.cbrt(.4122214708*n+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*n+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*n+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var nn=class extends x{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;#r=null;#n=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;connected(){this.#u(),this.#S(),this.#d=new MutationObserver(t=>{let e=!1;for(let i of t){for(let r of i.addedNodes)if(r.nodeType===1){if(r.getAttribute?.("slot")==="chrome"){e=!0;break}if(r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#d.takeRecords())}),this.#d.observe(this,{childList:!0})}render(){this.#u(),this.#p(),this.#m(),this.#b(),this.#y(),this.#O(),this.#g()}#u(){if(this.#n)return;let t=Array.from(this.children).filter(n=>n.getAttribute&&n.getAttribute("slot")==="chrome");for(let n of t)n.remove();let e=Array.from(this.children).filter(n=>n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]'));for(let n of e)n.remove();let i=[];for(let n of Array.from(this.childNodes))(n.nodeType===3&&!n.data||n.nodeType===8)&&i.push(n);for(let n of i)n.remove();let r=Array.from(this.childNodes).filter(n=>!(n.nodeType===1&&n.dataset&&(n.dataset.tile!==void 0||n.dataset.label!==void 0||n.dataset.detail!==void 0||n.dataset.badge!==void 0||n.dataset.copy!==void 0))&&!(n.nodeType===3&&!n.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 n of t)this.appendChild(n);for(let n of e)this.appendChild(n);for(let n of i)this.appendChild(n);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",""),r.length)for(let n of r)this.#e.appendChild(n);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#r=document.createElement("button"),this.#r.setAttribute("data-copy",""),this.#r.setAttribute("type","button"),this.#r.setAttribute("aria-label","Copy value"),this.#r.setAttribute("hidden",""),this.#r.textContent="\u29C9",this.appendChild(this.#r),this.#n=!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.#r&&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.#r||!(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=vC.has(this.shape)?this.shape:"square",e=xC.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)}#m(){if(!this.#s)return;let t=AC(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(n=>n.dataset.badgeVariant);if(e.length===t.length&&e.every((n,o)=>n===t[o]))return;let r=document.createDocumentFragment();for(let n of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",n),o.setAttribute("role","img"),o.setAttribute("aria-label",kC[n]),o.textContent=wC[n],r.appendChild(o)}this.#s.replaceChildren(r)}#g(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#a=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#a)return;this.#a=t;let e=EC(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)}#b(){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)}#y(){if(!this.#r)return;if(!this.copyable){this.#r.setAttribute("hidden","");return}this.#r.removeAttribute("hidden");let t=this.#w();t?this.#r.setAttribute("aria-label",`Copy ${t}`):this.#r.setAttribute("aria-label","Copy value")}#O(){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.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#r)||this.#v()},this.#l=t=>{this.selectable&&(t.key!=="Enter"&&t.key!==" "||t.target!==this.#r&&(t.preventDefault(),this.#v()))},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#w();e&&this.#x(e)},this.#r.addEventListener("click",this.#c)}#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#x(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#k(e)}#k(t){this.#r&&(this.#h!=null&&clearTimeout(this.#h),this.#r.setAttribute("data-copy-state",t?"ok":"fail"),this.#r.textContent=t?"\u2713":"\u26A0",this.#h=setTimeout(()=>{this.#r&&(this.#r.removeAttribute("data-copy-state"),this.#r.textContent="\u29C9",this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#d&&(this.#d.disconnect(),this.#d=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#r&&this.#c&&this.#r.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=!1}};S("swatch-ui",nn);Ct();var ay={xs:0,sm:480,md:768,lg:1024,xl:1280},cs=Object.keys(ay),jd=Object.values(ay);function ly(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=cs.length-1;t>=0;t--)if(s>=jd[t])return cs[t];return"xs"}var Ce=qi(ly());if(typeof window<"u")for(let s=1;s<jd.length;s++)window.matchMedia(`(min-width: ${jd[s]}px)`).addEventListener("change",()=>{Ce.value=ly()});function Nt(s,t=Ce.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 r=cs.indexOf(t),n=null,o=-1;for(let[a,l]of i){let h=cs.indexOf(a);h!==-1&&h<=r&&h>o&&(n=l,o=h)}return n??e}$();var on=class extends x{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,n=t?.includes("@")||e?.includes("@")||i?.includes("@")?Ce.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",PC(Nt(t,n))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Nt(e,n);this.style.setProperty("--col-align",QC(o)),this.style.textAlign=TC(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",LC(Nt(i,n))):this.style.removeProperty("--col-justify")}},CC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},$C={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function PC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function QC(s){return CC[s]??s}function TC(s){return{start:"start",center:"center",end:"end"}[s]??""}function LC(s){return $C[s]??s}S("col-ui",on);$();var an=class s extends x{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.#g()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=t=>{let e=this.#g();if(!e)return;let i=this.#b(e);i&&(t.preventDefault(),i.focus())};connected(){this.#d(),this.#u(),this.#f(),this.#p(),this.#c(),this.#t?.addEventListener("click",this.#n),this.#r=new MutationObserver(()=>{this.#p(),this.#c(),this.#m(),this.#a()}),this.#r.observe(this,{childList:!0}),this.#a()}disconnected(){this.#r?.disconnect(),this.#r=null,this.#h(),this.#t?.removeEventListener("click",this.#n),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.#a(),this.#m()}#a(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#o=()=>{this.#a(),this.#m()};#l=null;#c(){let t=this.#g();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#d(){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}}#u(){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.#g();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#O()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#g();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 r=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(n=>n&&!n.startsWith("field-hint-")&&!n.startsWith("field-err-")),...e].join(" ").trim();r?t.setAttribute("aria-describedby",r):t.removeAttribute("aria-describedby")}#g(){for(let t of this.children)if(!t.hasAttribute("slot"))return t;return null}#b(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#y=0;static#O(){return`field-ctl-${++s.#y}`}static#S=0;static#v(t){return`field-${t}-${++s.#S}`}};S("field-ui",an);$();var ln=class extends x{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}};S("fields-ui",ln);$();var hn=class extends x{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(Vr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Vr),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,r=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!r?Ce.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",IC(Nt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",DC(Nt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",qC(Nt(i,o))):this.style.removeProperty("--row-justify"),r){let a=cs.indexOf(o),l=cs.indexOf(r);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},MC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},RC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function IC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function DC(s){return MC[s]??s}function qC(s){return RC[s]??s}S("row-ui",hn);$();var cn=class extends x{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"},minColumnWidth:{type:String,default:"",reflect:!0,attribute:"min-column-width"}};static template=()=>null;render(){let t=Ce.value,e=this.columns;if(e?.includes("@")){let r=Nt(e,t);this.style.gridTemplateColumns=this.#t(r),this.style.gridAutoFlow=r?"row":"",this.style.gridAutoColumns=r?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";this.minColumnWidth?this.style.setProperty("--grid-min-col",this.minColumnWidth):this.style.removeProperty("--grid-min-col");let i=this.gap;if(i?.includes("@")){let r=Nt(i,t),n=this.#e(r);this.style.columnGap=n,this.style.rowGap=n}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(var(--grid-min-col, 12rem), 1fr))":t==="auto-fit"?"repeat(auto-fit, minmax(var(--grid-min-col, 12rem), 1fr))":t:""}#e(t){return!t||t==="0"?"0":/^\d+$/.test(t)?`var(--a-space-${t})`:`var(--a-gap-${t})`}};S("grid-ui",cn);$();var un=class extends x{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};S("stack-ui",un);$();function us(s,t,e=5){let r=(t-s||1)/e,n=Math.pow(10,Math.floor(Math.log10(r))),o=r/n,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*n,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 hy(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 re(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function St({label:s,value:t,pct:e,series:i}){let r="";return s!=null&&(r+=` data-tip-label="${re(String(s))}"`),t!=null&&(r+=` data-tip-value="${t}"`),e!=null&&(r+=` data-tip-pct="${e}"`),i!=null&&(r+=` data-tip-series="${re(String(i))}"`),r}function ne(s,t,e){return s+t*Math.cos(e)}function oe(s,t,e){return s+t*Math.sin(e)}function XC(s,t,e,i,r){let n=ne(s,e,i),o=oe(t,e,i),a=ne(s,e,r),l=oe(t,e,r),h=r-i>Math.PI?1:0;return`M ${s} ${t} L ${n} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function Vd(s,t,e,i,r,n,o=0){let a=(e-i)/2,l=n-r,h=Math.max(0,Math.min(o,a)),c=()=>{let ut=ne(s,e,r),ot=oe(t,e,r),bt=ne(s,e,n),xt=oe(t,e,n),Ot=ne(s,i,n),Et=oe(t,i,n),Tt=ne(s,i,r),Ft=oe(t,i,r),rs=l>Math.PI?1:0;return`M ${ut} ${ot} A ${e} ${e} 0 ${rs} 1 ${bt} ${xt} L ${Ot} ${Et} A ${i} ${i} 0 ${rs} 0 ${Tt} ${Ft} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=r+u,p=n-u,m=r+d,b=n-d,g=p-f>Math.PI?1:0,y=ne(s,e,f),v=oe(t,e,f),w=ne(s,e,p),k=oe(t,e,p),E=ne(s,i,b),A=oe(t,i,b),C=ne(s,i,m),T=oe(t,i,m),Q=ne(s,e-h,r),D=oe(t,e-h,r),R=ne(s,i+h,r),_=oe(t,i+h,r),V=ne(s,e-h,n),U=oe(t,e-h,n),J=ne(s,i+h,n),rt=oe(t,i+h,n);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${w} ${k} A ${h} ${h} 0 0 1 ${V} ${U} L ${J} ${rt} A ${h} ${h} 0 0 1 ${E} ${A} A ${i} ${i} 0 ${g} 0 ${C} ${T} A ${h} ${h} 0 0 1 ${R} ${_} L ${Q} ${D} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function Qa(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(r=>`${r.x},${r.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let r=0;r<e-1;r++){let n=s[Math.max(r-1,0)],o=s[r],a=s[r+1],l=s[Math.min(r+2,e-1)],h=o.x+(a.x-n.x)*t/3,c=o.y+(a.y-n.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 Wd(s,t,e=.4){let i=Qa(s,e),r=s[s.length-1],n=s[0];return`${i} L${r.x},${t} L${n.x},${t} Z`}function Sh(s,t,e,i,r=0){if(i<=0||e<=0)return"";let n=Math.max(0,Math.min(r,e/2,i));return n===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+n} Q${s},${t} ${s+n},${t} H${s+e-n} Q${s+e},${t} ${s+e},${t+n} V${t+i} Z`}var NC={std:{ratio:4/3}},dn=class extends x{static properties={type:{type:String,default:"bar",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},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;#r=0;#n=0;#a=new Set;#o(){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.
189
189
  Correct shape for <chart-ui x="label" y="value">:
190
- [{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#c(),this.#f()}get data(){return this.#t}#l=!1;#c(){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.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.#w),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#$),this.addEventListener("focus",this.#P),this.addEventListener("blur",this.#I),this.addEventListener("pointerover",this.#L),this.addEventListener("pointermove",this.#D),this.addEventListener("pointerleave",this.#X),this.addEventListener("pointerdown",this.#q),this.addEventListener("click",this.#_),this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let r=Math.round(e),n=Math.round(i);r===this.#r&&(!this.hasAttribute("resize")||n===this.#n)||(this.#r=r,this.#n=n,!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()}#u(){let t=this.clientWidth||300,e=this.clientHeight||0,i=NC.std,r=this.#t.length||1,n=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(n/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(n,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,b=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!b||p?2:u*2.2,left:m},y=n-g.left-g.right,v=Math.max(4,y/r*.6);return{width:n,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:v,plotW:y,n:r,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}this.setAttribute("data-has-data",""),this.#p();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 r="",n="";switch(this.type){case"bar":({svg:r,viewBox:n}=this.#G());break;case"line":({svg:r,viewBox:n}=this.#J());break;case"pie":({svg:r,viewBox:n}=this.#K());break;case"donut":({svg:r,viewBox:n}=this.#tt());break;case"radar":({svg:r,viewBox:n}=this.#et());break;case"sparkline":({svg:r,viewBox:n}=this.#it());break;case"segments":({svg:r,viewBox:n}=this.#ht());break;case"area":({svg:r,viewBox:n}=this.#st());break;case"scatter":({svg:r,viewBox:n}=this.#Y());break;case"radial-bar":({svg:r,viewBox:n}=this.#U());break;case"gauge":({svg:r,viewBox:n}=this.#rt());break;case"funnel":({svg:r,viewBox:n}=this.#nt());break;case"treemap":({svg:r,viewBox:n}=this.#ot());break;case"sankey":({svg:r,viewBox:n}=this.#at());break;case"composed":({svg:r,viewBox:n}=this.#lt());break;case"stacked-bar":({svg:r,viewBox:n}=this.#ct());break;case"grouped-bar":({svg:r,viewBox:n}=this.#ut());break;case"multi-line":({svg:r,viewBox:n}=this.#dt());break;default:({svg:r,viewBox:n}=this.#G());break}if(i.setAttribute("viewBox",n),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=r,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#O()){let o=this.#ft();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#p(){let t=this.#N();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#m(t,e){return e?` data-slice="${t}" data-series-key="${re(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g(t,e){return e?` data-slice="${t}" data-series-key="${re(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#b=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#w),document.removeEventListener("pointerdown",this.#R),this.removeEventListener("keydown",this.#$),this.removeEventListener("focus",this.#P),this.removeEventListener("blur",this.#I),this.removeEventListener("pointerover",this.#L),this.removeEventListener("pointermove",this.#D),this.removeEventListener("pointerleave",this.#X),this.removeEventListener("pointerdown",this.#q),this.removeEventListener("click",this.#_),this.#V()}#O(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#y(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#w=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:r}=t.detail||{};i&&(r?this.#a.delete(i):this.#a.add(i),this.#f())};#v(t){return!!t&&this.#a.has(t)}#S(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 r=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),`${r||"$"}${hy(e)}`}default:return hy(e)}}#x=-1;#k(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#A(t){let e=this.#k();if(!e.length){this.#E();return}this.#x=Math.max(0,Math.min(t,e.length-1)),this.#C(),this.#T()}#C(){let t=this.#k();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#x];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#E(){this.#x=-1;for(let t of this.#k())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#T(){let t=this.#k()[this.#x];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#Z(t,i)}#Q(){let t=this.#k()[this.#x];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.#B(t,i)}))}#P=()=>{this.#x===-1&&this.#A(0)};#I=()=>{this.#E(),this.#M&&this.#j()};#$=t=>{let e=this.#k();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#A(this.#x+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#A(Math.max(0,this.#x-1));break;case"Home":t.preventDefault(),this.#A(0);break;case"End":t.preventDefault(),this.#A(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#Q();break;case"Escape":t.preventDefault(),this.#E(),this.#M&&this.#j();break}};#M=null;#L=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#F(e,t),this.#Z(e,t))};#D=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#M&&this.#j(),this.#V();this.#F(e,t),e!==this.#M&&this.#Z(e,t)};#X=t=>{t&&t.pointerType==="touch"||(this.#V(),this.#M&&this.#j())};#q=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#M&&this.#j(),this.#V();this.#F(e,t),e!==this.#M&&this.#Z(e,t),document.addEventListener("pointerdown",this.#R)};#R=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#V(),this.#M&&this.#j(),document.removeEventListener("pointerdown",this.#R)))};#_=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#B(e,t)}))};#Z(t,e){this.#M=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#B(t,e)}))}#j(){this.#M=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#B(t,e){let{tipLabel:i,tipValue:r,tipPct:n,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=r!=null?Number(r):null,h=n!=null?Number(n):null,c=i??null,u=o??null,d=this.#H(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:r??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:r??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#H(t,e){if(t==null)return null;let i=this.x,r=this.#N();if(!i||r.length===0)return null;let n=this.#t.find(l=>String(l[i]??"")===String(t));if(!n)return null;let o=r.filter(l=>!this.#v(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(n[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#F(t,e){if(this.#y())return;let{tipLabel:i,tipValue:r,tipPct:n,tipSeries:o}=t.dataset;if(!this.#b){let b=document.createElement("div");b.setAttribute("popover","manual"),b.setAttribute("role","tooltip"),b.classList.add("chart-tooltip-popup"),document.body.appendChild(b),this.#b=b}let a=[];if(o&&a.push(`<span data-tip-role="series">${re(o)}</span>`),i&&a.push(`<span data-tip-role="label">${re(i)}</span>`),r!==void 0){let b=n!==void 0?` <span data-tip-role="pct">(${n}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#S(r)}${b}</span>`)}this.#b.innerHTML=a.join("");try{this.#b.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#b.offsetWidth||0,f=this.#b.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.#b.style.left=`${p}px`,this.#b.style.top=`${m}px`}#V(){if(this.#b){try{this.#b.hidePopover()}catch{}this.#b.remove(),this.#b=null}}#N(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#W(t,e,i,r,n,o){let a=n,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.#S(p)}</text>`}if(r){let m=(t-a.left-a.right)/r.length,g=r.reduce((w,k)=>Math.max(w,String(k).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=r.length-1;for(let w=0;w<r.length;w++){if(w%y!==0&&w!==v||w!==v&&v-w<y)continue;let k=a.left+m*w+m/2;c+=`<text data-x-label x="${k}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${re(r[w])}</text>`}}}return c}#G(){let t=this.#u(),e=this.#t,i=this.#N()[0]||this.y,r=e.map(v=>+(v[i]??0)),n=e.map(v=>v[this.x]??""),o=us(0,Math.max(...r),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,b=this.#W(l,h,o,n,c,t),g=!this.hideValues&&t.sizeClass!=="sm",y=!this.hideAverage&&r.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let v=0;v<e.length;v++){let w=r[v],k=a?w/a*u:0,E=c.left+f*v+m,A=c.top+u-k;b+=`<path data-bar${St({label:n[v],value:w})} d="${Sh(E,A,p,k,this.#o())}"/>`,g&&(b+=`<text data-value x="${E+p/2}" y="${A-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#S(w)}</text>`)}if(y){let v=r.reduce((k,E)=>k+E,0)/r.length,w=c.top+u-(a?v/a*u:0);b+=`<line data-avg x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}"/>`,b+=`<text data-avg-label x="${l-c.right+2}" y="${w+3}" text-anchor="start" font-size="${t.valueSize}">${this.#S(v)}</text>`,b+=`<line data-hit${St({label:"Average",value:v})} x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}" stroke="transparent" stroke-width="12"/>`}return{svg:b,viewBox:`0 0 ${l} ${h}`}}#J(){let t=this.#u(),e=this.#t,i=this.#N()[0]||this.y,r=e.map(A=>+(A[i]??0)),n=e.map(A=>A[this.x]??""),o=us(0,Math.max(...r),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.#W(l,h,o,n,c,t),m=r.map((A,C)=>{let T=c.left+f*C,Q=c.top+u-(a?A/a*u:0);return{x:T,y:Q,v:A,label:n[C]}}),b=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${Wd(m,b,g)}"/>`,p+=`<path data-line d="${Qa(m,g)}"/>`;let y=t.sizeClass==="sm",v=y?1.5:3,w=Math.max(v,10),k=!this.hideValues&&!y,E=!this.hideAverage&&r.length>1&&!y&&!this.hideGrid;for(let A of m)p+=`<circle data-dot cx="${A.x}" cy="${A.y}" r="${v}"/>`,p+=`<circle data-hit${St({label:A.label,value:A.v})} cx="${A.x}" cy="${A.y}" r="${w}" fill="transparent"/>`,k&&(p+=`<text data-value x="${A.x}" y="${A.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#S(A.v)}</text>`);if(E){let A=r.reduce((T,Q)=>T+Q,0)/r.length,C=c.top+u-(a?A/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${C}" x2="${l-c.right}" y2="${C}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${C+3}" text-anchor="start" font-size="${t.valueSize}">${this.#S(A)}</text>`,p+=`<line data-hit${St({label:"Average",value:A})} x1="${c.left}" y1="${C}" x2="${l-c.right}" y2="${C}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#K(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(p=>+(p[e]??0)),r=i.reduce((p,m)=>p+m,0)||1,n=t.map(p=>p[this.x]??""),o=this.#u(),{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]/r*Math.PI*2;if(m===0)continue;let b=f+m,g=(i[p]/r*100).toFixed(1),y=` data-slice="${p%10}"${St({label:n[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="${XC(h,c,u,f,b)}"/>`,f=b}return this.#z=t.map((p,m)=>({label:n[m],value:i[m],pct:(i[m]/r*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#tt(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(g=>+(g[e]??0)),r=i.reduce((g,y)=>g+y,0)||1,n=t.map(g=>g[this.x]??""),o=this.#u(),{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]/r*Math.PI*2;if(y===0)continue;let v=p+y,w=(i[g]/r*100).toFixed(1),k=` data-slice="${g%10}"${St({label:n[g],value:i[g],pct:w})}`;Math.abs(y-Math.PI*2)<.001?(f+=`<circle${k} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${k} 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${k} d="${Vd(h,c,u,d,p,v,this.#o())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),b=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.#S(r)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${b}">Total</text>`,this.#z=t.map((g,y)=>({label:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#et(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(k=>+(k[e]??0)),r=t.map(k=>k[this.x]??""),n=Math.max(...i)||1,o=t.length,a=this.#u(),{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="",b=Math.PI*2/o;for(let k=1;k<=3;k++){let E=p*k/3,A="";for(let C=0;C<o;C++){let T=-Math.PI/2+b*C,Q=u+E*Math.cos(T),D=d+E*Math.sin(T);A+=(C===0?"M":"L")+` ${Q} ${D}`}A+=" Z",m+=`<path data-grid d="${A}"/>`}for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=u+p*Math.cos(E),C=d+p*Math.sin(E);m+=`<line data-grid x1="${u}" y1="${d}" x2="${A}" y2="${C}"/>`}let g="",y=[];for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=i[k]/n*p,C=u+A*Math.cos(E),T=d+A*Math.sin(E);g+=(k===0?"M":"L")+` ${C} ${T}`,y.push({px:C,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 k=0;k<o;k++){let{px:E,py:A}=y[k];m+=`<circle data-hit${St({label:r[k],value:i[k]})} cx="${E}" cy="${A}" r="${v}" fill="transparent"/>`}let w=c*1.3;for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=u+(p+w)*Math.cos(E),C=d+(p+w)*Math.sin(E),T=Math.abs(Math.cos(E))<.1?"middle":Math.cos(E)>0?"start":"end";m+=`<text data-x-label x="${A}" y="${C}" text-anchor="${T}" dominant-baseline="central" font-size="${c}">${re(r[k])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#it(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(y=>+(y[e]??0)),r=Math.max(...i)||1,n=Math.min(...i),o=r-n||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-n)/o*(c-d*2)-d,v:y,label:f[v]})),m=Math.max(0,Math.min(1,this.smooth)),b="";b+=`<path data-area d="${Wd(p,c,m)}"/>`,b+=`<path data-line d="${Qa(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)b+=`<circle data-hit${St({label:y.label,value:y.v})} cx="${y.x}" cy="${y.y}" r="${g}" fill="transparent"/>`;return{svg:b,viewBox:`0 0 ${h} ${c}`}}#st(){return this.#J()}#Y(){let t=this.#u(),e=this.#t,i=this.#N()[0]||this.y,r=e.map(g=>+(g[i]??0)),n=e.map(g=>g[this.x]??""),o=us(0,Math.max(...r),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.#W(l,h,o,n,c,t),m=t.sizeClass==="sm"?2.5:4,b=Math.max(m*2,10);for(let g=0;g<r.length;g++){let y=c.left+f*g,v=c.top+u-(a?r[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${y}" cy="${v}" r="${m}"/>`,p+=`<circle data-hit${St({label:n[g],value:r[g]})} cx="${y}" cy="${v}" r="${b}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#U(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(g=>+(g[e]??0)),r=t.map(g=>g[this.x]??""),n=Math.max(...i)||1,o=this.#u(),{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),b="";for(let g=0;g<i.length;g++){let y=d+p*g+m/2,v=d+p*(g+1)-m/2,w=(y+v)/2,k=v-y,E=2*Math.PI*w,A=Math.max(0,Math.min(1,i[g]/n))*E;if(b+=`<circle data-radial-track cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${k}"/>`,A<=0)continue;let C=(i[g]/n*100).toFixed(1),T=St({label:r[g],value:i[g],pct:C}),Q=Math.abs(A-E)<.5,D=Q?"butt":"round",R=Q?`${E} 0`:`${A} ${E-A}`;b+=`<circle data-slice="${g%10}"${T} data-radial-bar cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${k}" stroke-linecap="${D}" stroke-dasharray="${R}" transform="rotate(-90 ${h} ${c})"/>`}return this.#z=t.map((g,y)=>({label:r[y],key:r[y],value:i[y],pct:(i[y]/n*100).toFixed(1),slot:y%10})),{svg:b,viewBox:`0 0 ${a} ${l}`}}#rt(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(w=>+(w[e]??0)),r=i.reduce((w,k)=>w+k,0)||1,n=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(n,1):r,a=Math.max(0,Math.min(1,n/o)),l=this.#u(),{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,b="";if(b+=`<path data-radial-track d="${Vd(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let w=Math.PI+Math.PI*a,k=St({label:t[0]?.[this.x]??"Value",value:n,pct:(a*100).toFixed(1)});b+=`<path data-slice="0"${k} data-gauge-fill d="${Vd(u,d,f,p,Math.PI,w,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return b+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#S(n)}</text>`,o!==n&&(b+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#S(o)}</text>`),{svg:b,viewBox:`0 0 ${h} ${c}`}}#nt(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(v=>+(v[e]??0)),r=t.map(v=>v[this.x]??""),n=i.length;if(n===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#u(),{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)/n,b=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<n;v++){let w=i[v],k=v<n-1?i[v+1]:i[v],E=w/o*(f/2),A=k/o*(f/2),C=d+m*v+b/2,T=d+m*(v+1)-b/2,Q=(w/o*100).toFixed(1),D=St({label:r[v],value:w,pct:Q}),R=`M ${g-E} ${C} L ${g+E} ${C} L ${g+A} ${T} L ${g-A} ${T} Z`;if(y+=`<path data-slice="${v%10}" data-funnel-stage${D} d="${R}"/>`,y+=`<text data-funnel-label x="${u-8}" y="${C+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${re(r[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${C+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#S(w)}</text>`,v>0){let _=(i[v]/i[0]*100).toFixed(0);y+=`<text data-funnel-drop x="${l-u+8}" y="${C+m/2+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${_}%</text>`}}return this.#z=t.map((v,w)=>({label:r[w],value:i[w],pct:(i[w]/o*100).toFixed(1),slot:w%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#ot(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(Q=>+(Q[e]??0)),r=t.map(Q=>Q[this.x]??""),n=i.length;if(n===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#u(),{width:a,height:l,fontSize:h}=o,c=i.reduce((Q,D)=>Q+D,0)||1,u=Array.from({length:n},(Q,D)=>D).sort((Q,D)=>i[D]-i[Q]),d=[],f=a*l,p=u.map(Q=>i[Q]/c*f),m=0,b=0,g=a,y=l,v=[],w=0,k=(Q,D)=>{if(Q.length===0)return 1/0;let R=Q.reduce((rt,ut)=>rt+ut,0),_=Math.max(...Q),V=Math.min(...Q),U=D*D,J=R*R;return Math.max(U*_/J,J/(U*V))},E=(Q,D,R,_,V,U)=>{let J=Q.reduce((xt,Ot)=>xt+Ot,0),rt=V>=U,ut=rt?J/V:U,ot=rt?V:J/U,bt=0;for(let xt=0;xt<Q.length;xt++){let Ot=Q[xt]/J,Et=u[D+xt];if(rt){let Tt=Ot*V;d.push({i:Et,x:R+bt,y:_,w:Tt,h:ut}),bt+=Tt}else{let Tt=Ot*U;d.push({i:Et,x:R,y:_+bt,w:ot,h:Tt}),bt+=Tt}}return rt?{x:R,y:_+ut,w:V,h:U-ut}:{x:R+ot,y:_,w:V-ot,h:U}},A=p.slice();for(;A.length>0;){v=[A[0]],w=p.length-A.length;let Q=Math.min(g,y),D=1;for(;D<A.length;){let _=v.concat(A[D]);if(k(_,Q)>k(v,Q))break;v=_,D++}let R=E(v,w,m,b,g,y);m=R.x,b=R.y,g=R.w,y=R.h,A=A.slice(v.length)}let C="",T=2;for(let Q of d){let D=(i[Q.i]/c*100).toFixed(1),R=St({label:r[Q.i],value:i[Q.i],pct:D});C+=`<rect data-slice="${Q.i%10}" data-treemap-tile${R} x="${Q.x+T}" y="${Q.y+T}" width="${Math.max(0,Q.w-T*2)}" height="${Math.max(0,Q.h-T*2)}" rx="${this.#o()}"/>`;let _=Q.x+8,V=Q.w>h*4,U=V&&Q.h>h*2.5,J=V&&!U&&Q.h>h*1.2;if(U)C+=`<text data-treemap-label x="${_}" y="${Q.y+h+4}" font-size="${h}" dominant-baseline="hanging">${re(r[Q.i])}</text>`,C+=`<text data-treemap-value x="${_}" y="${Q.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#S(i[Q.i])}</text>`;else if(J){let rt=Q.y+Q.h/2;C+=`<text data-treemap-label x="${_}" y="${rt}" font-size="${h}" dominant-baseline="central">${re(r[Q.i])}</text>`}}return this.#z=t.map((Q,D)=>({label:r[D],value:i[D],pct:(i[D]/c*100).toFixed(1),slot:D%10})),{svg:C,viewBox:`0 0 ${a} ${l}`}}#at(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let w of t){let k=w.source??w.from??"",E=w.target??w.to??"",A=+(w.value??w.v??0);e.has(k)||e.set(k,{name:k,flow:0}),i.has(E)||i.set(E,{name:E,flow:0}),e.get(k).flow+=A,i.get(E).flow+=A}let r=this.#u(),{width:n,height:o,fontSize:a}=r,l=Math.max(8,n*.03),h=l+a*5,c=[...e.values()].reduce((w,k)=>w+k.flow,0)||1,u=[...i.values()].reduce((w,k)=>w+k.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),b=o-d*(p.length-1),g=0;for(let w of f){let k=w.flow/c*m;w.y0=g,w.y1=g+k,w.cursor=g,g+=k+d}g=0;for(let w of p){let k=w.flow/u*b;w.y0=g,w.y1=g+k,w.cursor=g,g+=k+d}let y="",v=Math.min(this.#o(),l/2);f.forEach((w,k)=>{y+=`<rect data-sankey-node data-slice="${k%10}" x="${h-l}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${h-l-6}" y="${(w.y0+w.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${re(w.name)}</text>`}),p.forEach((w,k)=>{y+=`<rect data-sankey-node data-slice="${(f.length+k)%10}" x="${n-h}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${n-h+l+6}" y="${(w.y0+w.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${re(w.name)}</text>`});for(let w of t){let k=e.get(w.source??w.from??""),E=i.get(w.target??w.to??"");if(!k||!E)continue;let A=+(w.value??w.v??0);if(A<=0)continue;let C=A/c*m,T=A/u*b,Q=k.cursor,D=Q+C,R=E.cursor,_=R+T;k.cursor+=C,E.cursor+=T;let V=h,U=n-h,J=(V+U)/2,rt=St({label:`${k.name} \u2192 ${E.name}`,value:A}),ut=`M ${V} ${Q} C ${J} ${Q}, ${J} ${R}, ${U} ${R} L ${U} ${_} C ${J} ${_}, ${J} ${D}, ${V} ${D} Z`;y+=`<path data-sankey-link${rt} d="${ut}"/>`}return{svg:y,viewBox:`0 0 ${n} ${o}`}}#lt(){let t=this.#u(),e=this.#t,i=this.#N(),r=i[0]||"bar",n=i[1]||"line",o=e.map(E=>E[this.x]??""),a=e.map(E=>+(E[r]??0)),l=e.map(E=>+(E[n]??0)),h=[...a,...l],c=us(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,b=d-p.left-p.right,g=b/e.length,y=g*.6,v=(g-y)/2,w=b/Math.max(e.length-1,1),k=this.#W(d,f,c,o,p,t);if(!this.#v(r))for(let E=0;E<e.length;E++){let A=a[E],C=u?A/u*m:0,T=p.left+g*E+v,Q=p.top+m-C;k+=`<path${this.#m(0,r)}${St({label:o[E],value:A,series:r})} d="${Sh(T,Q,y,C,this.#o())}"/>`}if(!this.#v(n)){let E=l.map((C,T)=>({x:p.left+g*T+g/2,y:p.top+m-(u?C/u*m:0),v:C,label:o[T]})),A=Math.max(0,Math.min(1,this.smooth));k+=`<path data-line${this.#g(1,n)} d="${Qa(E,A)}"/>`;for(let C of E)k+=`<circle data-dot${this.#m(1,n)} cx="${C.x}" cy="${C.y}" r="3"/>`,k+=`<circle data-hit${St({label:C.label,value:C.v,series:n})} cx="${C.x}" cy="${C.y}" r="10" fill="transparent"/>`}return this.#z=[{label:r,key:r,slot:0},{label:n,key:n,slot:1}],{svg:k,viewBox:`0 0 ${d} ${f}`}}#ht(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(p=>+(p[e]??0)),r=i.reduce((p,m)=>p+m,0)||1,n=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#o(),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*r+i[p]*a)/r),b=p===i.length-1?a:i.slice(0,p+1).reduce((y,v)=>y+v,0)/r*a,g=p===0?0:i.slice(0,p).reduce((y,v)=>y+v,0)/r*a;u.push({x:g,w:Math.max(0,b-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:b}=u[p];if(b<=0)continue;let g=p===0,y=p===u.length-1,v=Math.max(0,b-(y?0:c)),w=(i[p]/r*100).toFixed(1),k=St({label:n[p],value:i[p],pct:w}),E=`<title>${re(n[p])}: ${i[p]} (${w}%)</title>`;if(g&&y||!g&&!y||h===0)f+=`<rect data-slice="${p%10}"${k} x="${m}" y="0" width="${v}" height="${l}"${(g||y)&&h?` rx="${h}"`:""}>${E}</rect>`;else{let A=h,C=m+v,T;g?T=`M ${m+A} 0 H ${C} V ${l} H ${m+A} A ${A} ${A} 0 0 1 ${m} ${l-A} V ${A} A ${A} ${A} 0 0 1 ${m+A} 0 Z`:T=`M ${m} 0 H ${C-A} A ${A} ${A} 0 0 1 ${C} ${A} V ${l-A} A ${A} ${A} 0 0 1 ${C-A} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${k} d="${T}">${E}</path>`}}return this.#z=t.map((p,m)=>({label:n[m],value:i[m],pct:(i[m]/r*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#ct(){let t=this.#t,e=this.#N(),i=t.map(g=>g[this.x]??""),r=t.map(g=>e.reduce((y,v)=>y+ +(g[v]??0),0)),n=us(0,Math.max(...r),5),o=n[n.length-1],a=this.#u(),{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,b=this.#W(l,h,n,i,c,a);for(let g=0;g<t.length;g++){let y=c.top+u,v=e.length;for(let w=0;w<v;w++){if(this.#v(e[w]))continue;let k=+(t[g][e[w]]??0),E=o?k/o*u:0;if(E<=0){y-=E;continue}y-=E;let A=c.left+f*g+m,C=y,T=E,Q=w===v-1,D=this.#o(),R=`${this.#m(w%10,e[w])}${St({label:i[g],value:k,series:e[w]})}`;Q?b+=`<path${R} d="${Sh(A,C,p,T,D)}"/>`:b+=`<rect${R} x="${A}" y="${C}" width="${p}" height="${T}"/>`}}return this.#z=e.map((g,y)=>({label:g,key:g,slot:y%10})),{svg:b,viewBox:`0 0 ${l} ${h}`}}#ut(){let t=this.#t,e=this.#N(),i=t.map(v=>v[this.x]??""),r=t.flatMap(v=>e.map(w=>+(v[w]??0))),n=us(0,Math.max(...r),5),o=n[n.length-1],a=this.#u(),{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,b=(m-p*(e.length-1))/e.length,g=(f-m)/2,y=this.#W(l,h,n,i,c,a);for(let v=0;v<t.length;v++)for(let w=0;w<e.length;w++){if(this.#v(e[w]))continue;let k=+(t[v][e[w]]??0),E=o?k/o*u:0,A=c.left+f*v+g+(b+p)*w,C=c.top+u-E;y+=`<path${this.#m(w%10,e[w])}${St({label:i[v],value:k,series:e[w]})} d="${Sh(A,C,b,E,this.#o())}"/>`,this.hideValues||(y+=`<text data-value x="${A+b/2}" y="${C-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#S(k)}</text>`)}return this.#z=e.map((v,w)=>({label:v,key:v,slot:w%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#dt(){let t=this.#t,e=this.#N(),i=t.map(m=>m[this.x]??""),r=t.flatMap(m=>e.map(b=>+(m[b]??0))),n=us(0,Math.max(...r),5),o=n[n.length-1],a=this.#u(),{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.#W(l,h,n,i,c,a);for(let m=0;m<e.length;m++){if(this.#v(e[m]))continue;let g=t.map(w=>+(w[e[m]]??0)).map((w,k)=>{let E=c.left+f*k,A=c.top+u-(o?w/o*u:0);return{x:E,y:A,v:w,label:i[k]}}),y=c.top+u,v=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area${this.#m(m%10,e[m])} d="${Wd(g,y,v)}"/>`,p+=`<path data-line${this.#g(m%10,e[m])} d="${Qa(g,v)}"/>`;for(let w of g)p+=`<circle data-dot${this.#m(m%10,e[m])} cx="${w.x}" cy="${w.y}" r="3"/>`,p+=`<circle data-hit${St({label:w.label,value:w.v,series:e[m]})} cx="${w.x}" cy="${w.y}" r="10" fill="transparent"/>`}return this.#z=e.map((m,b)=>({label:m,key:m,slot:b%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#z=null;get legendData(){return this.#z?this.#z.map(t=>({...t})):null}#ft(){if(!this.#z||!this.#z.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#z){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let r=document.createElement("span");r.setAttribute("data-legend-dot",""),r.setAttribute("data-slice",String(e.slot)),e.key&&(r.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(r);let n=document.createElement("span");n.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(n),t.appendChild(i)}return t}};S("chart-ui",dn);$();var fn=class s extends x{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.#a()}disconnected(){this.#r()}render(){this.#s(),this.#a()}#s(){if(this.#r(),!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.#a(),t.addEventListener("legend-update",this.#e)}#r(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#n(){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:[]}#a(){let t=this.#n();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",r=e.label??i,n=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",r),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-${n}))`:`var(--a-data-${n})`;h.style.setProperty("--swatch-color",c),a.appendChild(h),this.static||(a.addEventListener("click",u=>this.#o(u,i)),a.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.#o(u,i))})),this.appendChild(a)}}#o(t,e){if(!e)return;let r=!!this.#i.has(e);r?this.#i.delete(e):this.#i.add(e);let n=t.currentTarget;r?n.setAttribute("data-active",""):n.removeAttribute("data-active"),n.setAttribute("aria-pressed",r?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:r,mode:this.onToggle||"hide"}}))}};S("chart-legend-ui",fn);$();var ZC=120,pn=class extends x{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;#r=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.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#u),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#u))))}render(){this.open?this.#n():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#n(){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=ct(t,e,{placement:this.placement,gap:this.gap}),(this.trigger==="click"||this.trigger==="manual")&&(this.#r=requestAnimationFrame(()=>{this.#r=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#c)}))}}#a(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#o=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)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#u=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},ZC)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#a(),this.trigger==="click"&&this.removeEventListener("click",this.#o),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#u),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#u))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};S("popover-ui",pn);$();var mn=class extends x{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 r of i)r!==e&&r.open&&(r.open=!1)}},gn=class extends x{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}})))}};S("accordion-ui",mn),S("accordion-item-ui",gn);$();var bn=class extends x{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()}}};S("divider-ui",bn);$();var On=class extends x{static properties={cite:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","blockquote")}render(){let t=this.querySelector('[slot="cite"]:not([data-cite-stamped])'),e=this.querySelector('[slot="cite"][data-cite-stamped]');if(t){e?.remove();return}if(this.cite)if(e)e.textContent=this.cite;else{let i=document.createElement("span");i.setAttribute("slot","cite"),i.setAttribute("data-cite-stamped",""),i.textContent=this.cite,this.appendChild(i)}else e&&e.remove()}};S("blockquote-ui",On);$();var Ud=[{limit:60,unit:"second",divisor:1},{limit:3600,unit:"minute",divisor:60},{limit:3600*24,unit:"hour",divisor:3600},{limit:3600*24*7,unit:"day",divisor:3600*24},{limit:3600*24*30,unit:"week",divisor:3600*24*7},{limit:3600*24*365,unit:"month",divisor:3600*24*30},{limit:1/0,unit:"year",divisor:3600*24*365}],yn=class extends x{static properties={datetime:{type:String,default:"",reflect:!0},timeStyle:{type:String,default:"long",reflect:!0,attribute:"time-style"},numeric:{type:String,default:"auto",reflect:!0},locale:{type:String,default:"",reflect:!0},updateInterval:{type:Number,default:60,reflect:!0,attribute:"update-interval"}};static template=()=>null;#t=null;#e(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#i(){if(!this.datetime)return"";let t=new Date(this.datetime);if(Number.isNaN(t.getTime()))return"";let e=(t.getTime()-Date.now())/1e3,i=Math.abs(e),r=Ud.find(o=>i<=o.limit)||Ud[Ud.length-1],n=Math.round(e/r.divisor);try{return new Intl.RelativeTimeFormat(this.#e(),{style:this.timeStyle,numeric:this.numeric}).format(n,r.unit)}catch{let o=e<0,a=Math.abs(n);return o?`${a} ${r.unit}${a===1?"":"s"} ago`:`in ${a} ${r.unit}${a===1?"":"s"}`}}#s(){if(!this.datetime)return"";let t=new Date(this.datetime);if(Number.isNaN(t.getTime()))return"";try{return new Intl.DateTimeFormat(this.#e(),{dateStyle:"full",timeStyle:"long"}).format(t)}catch{return t.toString()}}connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","time"),this.#r()}render(){let t=this.#i();this.textContent=t,t&&!this.hasAttribute("data-suppress-title")&&this.setAttribute("title",this.#s()),this.datetime&&this.setAttribute("datetime",this.datetime),this.#r()}#r(){this.#n();let t=Number(this.updateInterval);!Number.isFinite(t)||t<=0||(this.#t=setInterval(()=>{this.textContent=this.#i()},t*1e3))}#n(){this.#t!=null&&(clearInterval(this.#t),this.#t=null)}disconnected(){super.disconnected(),this.#n()}};S("relative-time-ui",yn);$();var vn=class extends x{static properties={value:{type:Number,default:0,reflect:!0},numberStyle:{type:String,default:"decimal",reflect:!0,attribute:"number-style"},currency:{type:String,default:"",reflect:!0},unit:{type:String,default:"",reflect:!0},notation:{type:String,default:"standard",reflect:!0},compactDisplay:{type:String,default:"short",reflect:!0,attribute:"compact-display"},minimumFractionDigits:{type:Number,default:0,reflect:!0,attribute:"minimum-fraction-digits"},maximumFractionDigits:{type:Number,default:2,reflect:!0,attribute:"maximum-fraction-digits"},locale:{type:String,default:"",reflect:!0},signDisplay:{type:String,default:"auto",reflect:!0,attribute:"sign-display"}};static template=()=>null;#t(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#e(){let t=Number(this.value);if(!Number.isFinite(t)||this.numberStyle==="currency"&&!this.currency||this.numberStyle==="unit"&&!this.unit)return"";let e={style:this.numberStyle,notation:this.notation,signDisplay:this.signDisplay};this.numberStyle==="currency"&&(e.currency=this.currency),this.numberStyle==="unit"&&(e.unit=this.unit),this.notation==="compact"&&(e.compactDisplay=this.compactDisplay),Number.isFinite(this.minimumFractionDigits)&&(e.minimumFractionDigits=this.minimumFractionDigits),Number.isFinite(this.maximumFractionDigits)&&(e.maximumFractionDigits=this.maximumFractionDigits);try{return new Intl.NumberFormat(this.#t(),e).format(t)}catch{return String(t)}}connected(){super.connected()}render(){let t=this.#e();this.textContent=t,t&&Number.isFinite(Number(this.value))?this.setAttribute("aria-label",`${t} (raw: ${this.value})`):this.removeAttribute("aria-label")}};S("number-format-ui",vn);$();var Fd=["Weak","Fair","Good","Strong"];function BC(s){if(!s)return-1;let t=0;s.length>=8&&t++,s.length>=12&&t++,s.length>=16&&t++;let e=[/[a-z]/.test(s),/[A-Z]/.test(s),/[0-9]/.test(s),/[^a-zA-Z0-9]/.test(s)].filter(Boolean).length;return e>=2&&t++,e>=3&&t++,e===4&&t++,/(.)\1{2,}/.test(s)&&t--,s.length<8&&(t=Math.min(t,0)),Math.max(0,Math.min(3,t))}var xn=class extends x{static properties={value:{type:String,default:""},minScore:{type:Number,default:2,reflect:!0,attribute:"min-score"},showLabel:{type:Boolean,default:!0,reflect:!0,attribute:"show-label"}};static template=()=>null;#t=-2;connected(){super.connected(),this.querySelector('[slot="bar"]')||(this.innerHTML=`
190
+ [{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#c(),this.#f()}get data(){return this.#t}#l=!1;#c(){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.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.#$),this.addEventListener("focus",this.#P),this.addEventListener("blur",this.#I),this.addEventListener("pointerover",this.#L),this.addEventListener("pointermove",this.#D),this.addEventListener("pointerleave",this.#X),this.addEventListener("pointerdown",this.#q),this.addEventListener("click",this.#_),this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let r=Math.round(e),n=Math.round(i);r===this.#r&&(!this.hasAttribute("resize")||n===this.#n)||(this.#r=r,this.#n=n,!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()}#d(){let t=this.clientWidth||300,e=this.clientHeight||0,i=NC.std,r=this.#t.length||1,n=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(n/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(n,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,b=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!b||p?2:u*2.2,left:m},y=n-g.left-g.right,v=Math.max(4,y/r*.6);return{width:n,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:v,plotW:y,n:r,sizeClass:c}}#u=null;#f(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#u&&(this.#u=t.cloneNode(!0)),this.innerHTML="",this.#u&&this.appendChild(this.#u.cloneNode(!0)),!this.#t.length){this.removeAttribute("data-has-data");return}this.setAttribute("data-has-data",""),this.#p();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 r="",n="";switch(this.type){case"bar":({svg:r,viewBox:n}=this.#G());break;case"line":({svg:r,viewBox:n}=this.#J());break;case"pie":({svg:r,viewBox:n}=this.#K());break;case"donut":({svg:r,viewBox:n}=this.#tt());break;case"radar":({svg:r,viewBox:n}=this.#et());break;case"sparkline":({svg:r,viewBox:n}=this.#it());break;case"segments":({svg:r,viewBox:n}=this.#ht());break;case"area":({svg:r,viewBox:n}=this.#st());break;case"scatter":({svg:r,viewBox:n}=this.#Y());break;case"radial-bar":({svg:r,viewBox:n}=this.#U());break;case"gauge":({svg:r,viewBox:n}=this.#rt());break;case"funnel":({svg:r,viewBox:n}=this.#nt());break;case"treemap":({svg:r,viewBox:n}=this.#ot());break;case"sankey":({svg:r,viewBox:n}=this.#at());break;case"composed":({svg:r,viewBox:n}=this.#lt());break;case"stacked-bar":({svg:r,viewBox:n}=this.#ct());break;case"grouped-bar":({svg:r,viewBox:n}=this.#ut());break;case"multi-line":({svg:r,viewBox:n}=this.#dt());break;default:({svg:r,viewBox:n}=this.#G());break}if(i.setAttribute("viewBox",n),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=r,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#y()){let o=this.#ft();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#p(){let t=this.#N();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#m(t,e){return e?` data-slice="${t}" data-series-key="${re(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g(t,e){return e?` data-slice="${t}" data-series-key="${re(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#b=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.#R),this.removeEventListener("keydown",this.#$),this.removeEventListener("focus",this.#P),this.removeEventListener("blur",this.#I),this.removeEventListener("pointerover",this.#L),this.removeEventListener("pointermove",this.#D),this.removeEventListener("pointerleave",this.#X),this.removeEventListener("pointerdown",this.#q),this.removeEventListener("click",this.#_),this.#V()}#y(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#O(){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:r}=t.detail||{};i&&(r?this.#a.delete(i):this.#a.add(i),this.#f())};#v(t){return!!t&&this.#a.has(t)}#w(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 r=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),`${r||"$"}${hy(e)}`}default:return hy(e)}}#x=-1;#k(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#A(t){let e=this.#k();if(!e.length){this.#E();return}this.#x=Math.max(0,Math.min(t,e.length-1)),this.#C(),this.#T()}#C(){let t=this.#k();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#x];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#E(){this.#x=-1;for(let t of this.#k())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#T(){let t=this.#k()[this.#x];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#Z(t,i)}#Q(){let t=this.#k()[this.#x];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.#B(t,i)}))}#P=()=>{this.#x===-1&&this.#A(0)};#I=()=>{this.#E(),this.#M&&this.#j()};#$=t=>{let e=this.#k();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#A(this.#x+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#A(Math.max(0,this.#x-1));break;case"Home":t.preventDefault(),this.#A(0);break;case"End":t.preventDefault(),this.#A(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#Q();break;case"Escape":t.preventDefault(),this.#E(),this.#M&&this.#j();break}};#M=null;#L=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#F(e,t),this.#Z(e,t))};#D=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#M&&this.#j(),this.#V();this.#F(e,t),e!==this.#M&&this.#Z(e,t)};#X=t=>{t&&t.pointerType==="touch"||(this.#V(),this.#M&&this.#j())};#q=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#M&&this.#j(),this.#V();this.#F(e,t),e!==this.#M&&this.#Z(e,t),document.addEventListener("pointerdown",this.#R)};#R=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#V(),this.#M&&this.#j(),document.removeEventListener("pointerdown",this.#R)))};#_=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#B(e,t)}))};#Z(t,e){this.#M=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#B(t,e)}))}#j(){this.#M=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#B(t,e){let{tipLabel:i,tipValue:r,tipPct:n,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=r!=null?Number(r):null,h=n!=null?Number(n):null,c=i??null,u=o??null,d=this.#H(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:r??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:r??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#H(t,e){if(t==null)return null;let i=this.x,r=this.#N();if(!i||r.length===0)return null;let n=this.#t.find(l=>String(l[i]??"")===String(t));if(!n)return null;let o=r.filter(l=>!this.#v(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(n[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#F(t,e){if(this.#O())return;let{tipLabel:i,tipValue:r,tipPct:n,tipSeries:o}=t.dataset;if(!this.#b){let b=document.createElement("div");b.setAttribute("popover","manual"),b.setAttribute("role","tooltip"),b.classList.add("chart-tooltip-popup"),document.body.appendChild(b),this.#b=b}let a=[];if(o&&a.push(`<span data-tip-role="series">${re(o)}</span>`),i&&a.push(`<span data-tip-role="label">${re(i)}</span>`),r!==void 0){let b=n!==void 0?` <span data-tip-role="pct">(${n}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#w(r)}${b}</span>`)}this.#b.innerHTML=a.join("");try{this.#b.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#b.offsetWidth||0,f=this.#b.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.#b.style.left=`${p}px`,this.#b.style.top=`${m}px`}#V(){if(this.#b){try{this.#b.hidePopover()}catch{}this.#b.remove(),this.#b=null}}#N(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#W(t,e,i,r,n,o){let a=n,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.#w(p)}</text>`}if(r){let m=(t-a.left-a.right)/r.length,g=r.reduce((w,k)=>Math.max(w,String(k).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=r.length-1;for(let w=0;w<r.length;w++){if(w%y!==0&&w!==v||w!==v&&v-w<y)continue;let k=a.left+m*w+m/2;c+=`<text data-x-label x="${k}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${re(r[w])}</text>`}}}return c}#G(){let t=this.#d(),e=this.#t,i=this.#N()[0]||this.y,r=e.map(v=>+(v[i]??0)),n=e.map(v=>v[this.x]??""),o=us(0,Math.max(...r),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,b=this.#W(l,h,o,n,c,t),g=!this.hideValues&&t.sizeClass!=="sm",y=!this.hideAverage&&r.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let v=0;v<e.length;v++){let w=r[v],k=a?w/a*u:0,E=c.left+f*v+m,A=c.top+u-k;b+=`<path data-bar${St({label:n[v],value:w})} d="${Sh(E,A,p,k,this.#o())}"/>`,g&&(b+=`<text data-value x="${E+p/2}" y="${A-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#w(w)}</text>`)}if(y){let v=r.reduce((k,E)=>k+E,0)/r.length,w=c.top+u-(a?v/a*u:0);b+=`<line data-avg x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}"/>`,b+=`<text data-avg-label x="${l-c.right+2}" y="${w+3}" text-anchor="start" font-size="${t.valueSize}">${this.#w(v)}</text>`,b+=`<line data-hit${St({label:"Average",value:v})} x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}" stroke="transparent" stroke-width="12"/>`}return{svg:b,viewBox:`0 0 ${l} ${h}`}}#J(){let t=this.#d(),e=this.#t,i=this.#N()[0]||this.y,r=e.map(A=>+(A[i]??0)),n=e.map(A=>A[this.x]??""),o=us(0,Math.max(...r),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.#W(l,h,o,n,c,t),m=r.map((A,C)=>{let T=c.left+f*C,Q=c.top+u-(a?A/a*u:0);return{x:T,y:Q,v:A,label:n[C]}}),b=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${Wd(m,b,g)}"/>`,p+=`<path data-line d="${Qa(m,g)}"/>`;let y=t.sizeClass==="sm",v=y?1.5:3,w=Math.max(v,10),k=!this.hideValues&&!y,E=!this.hideAverage&&r.length>1&&!y&&!this.hideGrid;for(let A of m)p+=`<circle data-dot cx="${A.x}" cy="${A.y}" r="${v}"/>`,p+=`<circle data-hit${St({label:A.label,value:A.v})} cx="${A.x}" cy="${A.y}" r="${w}" fill="transparent"/>`,k&&(p+=`<text data-value x="${A.x}" y="${A.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#w(A.v)}</text>`);if(E){let A=r.reduce((T,Q)=>T+Q,0)/r.length,C=c.top+u-(a?A/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${C}" x2="${l-c.right}" y2="${C}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${C+3}" text-anchor="start" font-size="${t.valueSize}">${this.#w(A)}</text>`,p+=`<line data-hit${St({label:"Average",value:A})} x1="${c.left}" y1="${C}" x2="${l-c.right}" y2="${C}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#K(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(p=>+(p[e]??0)),r=i.reduce((p,m)=>p+m,0)||1,n=t.map(p=>p[this.x]??""),o=this.#d(),{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]/r*Math.PI*2;if(m===0)continue;let b=f+m,g=(i[p]/r*100).toFixed(1),y=` data-slice="${p%10}"${St({label:n[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="${XC(h,c,u,f,b)}"/>`,f=b}return this.#z=t.map((p,m)=>({label:n[m],value:i[m],pct:(i[m]/r*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#tt(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(g=>+(g[e]??0)),r=i.reduce((g,y)=>g+y,0)||1,n=t.map(g=>g[this.x]??""),o=this.#d(),{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]/r*Math.PI*2;if(y===0)continue;let v=p+y,w=(i[g]/r*100).toFixed(1),k=` data-slice="${g%10}"${St({label:n[g],value:i[g],pct:w})}`;Math.abs(y-Math.PI*2)<.001?(f+=`<circle${k} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${k} 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${k} d="${Vd(h,c,u,d,p,v,this.#o())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),b=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.#w(r)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${b}">Total</text>`,this.#z=t.map((g,y)=>({label:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#et(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(k=>+(k[e]??0)),r=t.map(k=>k[this.x]??""),n=Math.max(...i)||1,o=t.length,a=this.#d(),{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="",b=Math.PI*2/o;for(let k=1;k<=3;k++){let E=p*k/3,A="";for(let C=0;C<o;C++){let T=-Math.PI/2+b*C,Q=u+E*Math.cos(T),D=d+E*Math.sin(T);A+=(C===0?"M":"L")+` ${Q} ${D}`}A+=" Z",m+=`<path data-grid d="${A}"/>`}for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=u+p*Math.cos(E),C=d+p*Math.sin(E);m+=`<line data-grid x1="${u}" y1="${d}" x2="${A}" y2="${C}"/>`}let g="",y=[];for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=i[k]/n*p,C=u+A*Math.cos(E),T=d+A*Math.sin(E);g+=(k===0?"M":"L")+` ${C} ${T}`,y.push({px:C,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 k=0;k<o;k++){let{px:E,py:A}=y[k];m+=`<circle data-hit${St({label:r[k],value:i[k]})} cx="${E}" cy="${A}" r="${v}" fill="transparent"/>`}let w=c*1.3;for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=u+(p+w)*Math.cos(E),C=d+(p+w)*Math.sin(E),T=Math.abs(Math.cos(E))<.1?"middle":Math.cos(E)>0?"start":"end";m+=`<text data-x-label x="${A}" y="${C}" text-anchor="${T}" dominant-baseline="central" font-size="${c}">${re(r[k])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#it(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(y=>+(y[e]??0)),r=Math.max(...i)||1,n=Math.min(...i),o=r-n||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-n)/o*(c-d*2)-d,v:y,label:f[v]})),m=Math.max(0,Math.min(1,this.smooth)),b="";b+=`<path data-area d="${Wd(p,c,m)}"/>`,b+=`<path data-line d="${Qa(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)b+=`<circle data-hit${St({label:y.label,value:y.v})} cx="${y.x}" cy="${y.y}" r="${g}" fill="transparent"/>`;return{svg:b,viewBox:`0 0 ${h} ${c}`}}#st(){return this.#J()}#Y(){let t=this.#d(),e=this.#t,i=this.#N()[0]||this.y,r=e.map(g=>+(g[i]??0)),n=e.map(g=>g[this.x]??""),o=us(0,Math.max(...r),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.#W(l,h,o,n,c,t),m=t.sizeClass==="sm"?2.5:4,b=Math.max(m*2,10);for(let g=0;g<r.length;g++){let y=c.left+f*g,v=c.top+u-(a?r[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${y}" cy="${v}" r="${m}"/>`,p+=`<circle data-hit${St({label:n[g],value:r[g]})} cx="${y}" cy="${v}" r="${b}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#U(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(g=>+(g[e]??0)),r=t.map(g=>g[this.x]??""),n=Math.max(...i)||1,o=this.#d(),{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),b="";for(let g=0;g<i.length;g++){let y=d+p*g+m/2,v=d+p*(g+1)-m/2,w=(y+v)/2,k=v-y,E=2*Math.PI*w,A=Math.max(0,Math.min(1,i[g]/n))*E;if(b+=`<circle data-radial-track cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${k}"/>`,A<=0)continue;let C=(i[g]/n*100).toFixed(1),T=St({label:r[g],value:i[g],pct:C}),Q=Math.abs(A-E)<.5,D=Q?"butt":"round",R=Q?`${E} 0`:`${A} ${E-A}`;b+=`<circle data-slice="${g%10}"${T} data-radial-bar cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${k}" stroke-linecap="${D}" stroke-dasharray="${R}" transform="rotate(-90 ${h} ${c})"/>`}return this.#z=t.map((g,y)=>({label:r[y],key:r[y],value:i[y],pct:(i[y]/n*100).toFixed(1),slot:y%10})),{svg:b,viewBox:`0 0 ${a} ${l}`}}#rt(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(w=>+(w[e]??0)),r=i.reduce((w,k)=>w+k,0)||1,n=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(n,1):r,a=Math.max(0,Math.min(1,n/o)),l=this.#d(),{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,b="";if(b+=`<path data-radial-track d="${Vd(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let w=Math.PI+Math.PI*a,k=St({label:t[0]?.[this.x]??"Value",value:n,pct:(a*100).toFixed(1)});b+=`<path data-slice="0"${k} data-gauge-fill d="${Vd(u,d,f,p,Math.PI,w,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return b+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#w(n)}</text>`,o!==n&&(b+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#w(o)}</text>`),{svg:b,viewBox:`0 0 ${h} ${c}`}}#nt(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(v=>+(v[e]??0)),r=t.map(v=>v[this.x]??""),n=i.length;if(n===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#d(),{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)/n,b=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<n;v++){let w=i[v],k=v<n-1?i[v+1]:i[v],E=w/o*(f/2),A=k/o*(f/2),C=d+m*v+b/2,T=d+m*(v+1)-b/2,Q=(w/o*100).toFixed(1),D=St({label:r[v],value:w,pct:Q}),R=`M ${g-E} ${C} L ${g+E} ${C} L ${g+A} ${T} L ${g-A} ${T} Z`;if(y+=`<path data-slice="${v%10}" data-funnel-stage${D} d="${R}"/>`,y+=`<text data-funnel-label x="${u-8}" y="${C+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${re(r[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${C+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#w(w)}</text>`,v>0){let _=(i[v]/i[0]*100).toFixed(0);y+=`<text data-funnel-drop x="${l-u+8}" y="${C+m/2+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${_}%</text>`}}return this.#z=t.map((v,w)=>({label:r[w],value:i[w],pct:(i[w]/o*100).toFixed(1),slot:w%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#ot(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(Q=>+(Q[e]??0)),r=t.map(Q=>Q[this.x]??""),n=i.length;if(n===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#d(),{width:a,height:l,fontSize:h}=o,c=i.reduce((Q,D)=>Q+D,0)||1,u=Array.from({length:n},(Q,D)=>D).sort((Q,D)=>i[D]-i[Q]),d=[],f=a*l,p=u.map(Q=>i[Q]/c*f),m=0,b=0,g=a,y=l,v=[],w=0,k=(Q,D)=>{if(Q.length===0)return 1/0;let R=Q.reduce((rt,ut)=>rt+ut,0),_=Math.max(...Q),V=Math.min(...Q),U=D*D,J=R*R;return Math.max(U*_/J,J/(U*V))},E=(Q,D,R,_,V,U)=>{let J=Q.reduce((xt,Ot)=>xt+Ot,0),rt=V>=U,ut=rt?J/V:U,ot=rt?V:J/U,bt=0;for(let xt=0;xt<Q.length;xt++){let Ot=Q[xt]/J,Et=u[D+xt];if(rt){let Tt=Ot*V;d.push({i:Et,x:R+bt,y:_,w:Tt,h:ut}),bt+=Tt}else{let Tt=Ot*U;d.push({i:Et,x:R,y:_+bt,w:ot,h:Tt}),bt+=Tt}}return rt?{x:R,y:_+ut,w:V,h:U-ut}:{x:R+ot,y:_,w:V-ot,h:U}},A=p.slice();for(;A.length>0;){v=[A[0]],w=p.length-A.length;let Q=Math.min(g,y),D=1;for(;D<A.length;){let _=v.concat(A[D]);if(k(_,Q)>k(v,Q))break;v=_,D++}let R=E(v,w,m,b,g,y);m=R.x,b=R.y,g=R.w,y=R.h,A=A.slice(v.length)}let C="",T=2;for(let Q of d){let D=(i[Q.i]/c*100).toFixed(1),R=St({label:r[Q.i],value:i[Q.i],pct:D});C+=`<rect data-slice="${Q.i%10}" data-treemap-tile${R} x="${Q.x+T}" y="${Q.y+T}" width="${Math.max(0,Q.w-T*2)}" height="${Math.max(0,Q.h-T*2)}" rx="${this.#o()}"/>`;let _=Q.x+8,V=Q.w>h*4,U=V&&Q.h>h*2.5,J=V&&!U&&Q.h>h*1.2;if(U)C+=`<text data-treemap-label x="${_}" y="${Q.y+h+4}" font-size="${h}" dominant-baseline="hanging">${re(r[Q.i])}</text>`,C+=`<text data-treemap-value x="${_}" y="${Q.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#w(i[Q.i])}</text>`;else if(J){let rt=Q.y+Q.h/2;C+=`<text data-treemap-label x="${_}" y="${rt}" font-size="${h}" dominant-baseline="central">${re(r[Q.i])}</text>`}}return this.#z=t.map((Q,D)=>({label:r[D],value:i[D],pct:(i[D]/c*100).toFixed(1),slot:D%10})),{svg:C,viewBox:`0 0 ${a} ${l}`}}#at(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let w of t){let k=w.source??w.from??"",E=w.target??w.to??"",A=+(w.value??w.v??0);e.has(k)||e.set(k,{name:k,flow:0}),i.has(E)||i.set(E,{name:E,flow:0}),e.get(k).flow+=A,i.get(E).flow+=A}let r=this.#d(),{width:n,height:o,fontSize:a}=r,l=Math.max(8,n*.03),h=l+a*5,c=[...e.values()].reduce((w,k)=>w+k.flow,0)||1,u=[...i.values()].reduce((w,k)=>w+k.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),b=o-d*(p.length-1),g=0;for(let w of f){let k=w.flow/c*m;w.y0=g,w.y1=g+k,w.cursor=g,g+=k+d}g=0;for(let w of p){let k=w.flow/u*b;w.y0=g,w.y1=g+k,w.cursor=g,g+=k+d}let y="",v=Math.min(this.#o(),l/2);f.forEach((w,k)=>{y+=`<rect data-sankey-node data-slice="${k%10}" x="${h-l}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${h-l-6}" y="${(w.y0+w.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${re(w.name)}</text>`}),p.forEach((w,k)=>{y+=`<rect data-sankey-node data-slice="${(f.length+k)%10}" x="${n-h}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${n-h+l+6}" y="${(w.y0+w.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${re(w.name)}</text>`});for(let w of t){let k=e.get(w.source??w.from??""),E=i.get(w.target??w.to??"");if(!k||!E)continue;let A=+(w.value??w.v??0);if(A<=0)continue;let C=A/c*m,T=A/u*b,Q=k.cursor,D=Q+C,R=E.cursor,_=R+T;k.cursor+=C,E.cursor+=T;let V=h,U=n-h,J=(V+U)/2,rt=St({label:`${k.name} \u2192 ${E.name}`,value:A}),ut=`M ${V} ${Q} C ${J} ${Q}, ${J} ${R}, ${U} ${R} L ${U} ${_} C ${J} ${_}, ${J} ${D}, ${V} ${D} Z`;y+=`<path data-sankey-link${rt} d="${ut}"/>`}return{svg:y,viewBox:`0 0 ${n} ${o}`}}#lt(){let t=this.#d(),e=this.#t,i=this.#N(),r=i[0]||"bar",n=i[1]||"line",o=e.map(E=>E[this.x]??""),a=e.map(E=>+(E[r]??0)),l=e.map(E=>+(E[n]??0)),h=[...a,...l],c=us(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,b=d-p.left-p.right,g=b/e.length,y=g*.6,v=(g-y)/2,w=b/Math.max(e.length-1,1),k=this.#W(d,f,c,o,p,t);if(!this.#v(r))for(let E=0;E<e.length;E++){let A=a[E],C=u?A/u*m:0,T=p.left+g*E+v,Q=p.top+m-C;k+=`<path${this.#m(0,r)}${St({label:o[E],value:A,series:r})} d="${Sh(T,Q,y,C,this.#o())}"/>`}if(!this.#v(n)){let E=l.map((C,T)=>({x:p.left+g*T+g/2,y:p.top+m-(u?C/u*m:0),v:C,label:o[T]})),A=Math.max(0,Math.min(1,this.smooth));k+=`<path data-line${this.#g(1,n)} d="${Qa(E,A)}"/>`;for(let C of E)k+=`<circle data-dot${this.#m(1,n)} cx="${C.x}" cy="${C.y}" r="3"/>`,k+=`<circle data-hit${St({label:C.label,value:C.v,series:n})} cx="${C.x}" cy="${C.y}" r="10" fill="transparent"/>`}return this.#z=[{label:r,key:r,slot:0},{label:n,key:n,slot:1}],{svg:k,viewBox:`0 0 ${d} ${f}`}}#ht(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(p=>+(p[e]??0)),r=i.reduce((p,m)=>p+m,0)||1,n=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#o(),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*r+i[p]*a)/r),b=p===i.length-1?a:i.slice(0,p+1).reduce((y,v)=>y+v,0)/r*a,g=p===0?0:i.slice(0,p).reduce((y,v)=>y+v,0)/r*a;u.push({x:g,w:Math.max(0,b-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:b}=u[p];if(b<=0)continue;let g=p===0,y=p===u.length-1,v=Math.max(0,b-(y?0:c)),w=(i[p]/r*100).toFixed(1),k=St({label:n[p],value:i[p],pct:w}),E=`<title>${re(n[p])}: ${i[p]} (${w}%)</title>`;if(g&&y||!g&&!y||h===0)f+=`<rect data-slice="${p%10}"${k} x="${m}" y="0" width="${v}" height="${l}"${(g||y)&&h?` rx="${h}"`:""}>${E}</rect>`;else{let A=h,C=m+v,T;g?T=`M ${m+A} 0 H ${C} V ${l} H ${m+A} A ${A} ${A} 0 0 1 ${m} ${l-A} V ${A} A ${A} ${A} 0 0 1 ${m+A} 0 Z`:T=`M ${m} 0 H ${C-A} A ${A} ${A} 0 0 1 ${C} ${A} V ${l-A} A ${A} ${A} 0 0 1 ${C-A} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${k} d="${T}">${E}</path>`}}return this.#z=t.map((p,m)=>({label:n[m],value:i[m],pct:(i[m]/r*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#ct(){let t=this.#t,e=this.#N(),i=t.map(g=>g[this.x]??""),r=t.map(g=>e.reduce((y,v)=>y+ +(g[v]??0),0)),n=us(0,Math.max(...r),5),o=n[n.length-1],a=this.#d(),{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,b=this.#W(l,h,n,i,c,a);for(let g=0;g<t.length;g++){let y=c.top+u,v=e.length;for(let w=0;w<v;w++){if(this.#v(e[w]))continue;let k=+(t[g][e[w]]??0),E=o?k/o*u:0;if(E<=0){y-=E;continue}y-=E;let A=c.left+f*g+m,C=y,T=E,Q=w===v-1,D=this.#o(),R=`${this.#m(w%10,e[w])}${St({label:i[g],value:k,series:e[w]})}`;Q?b+=`<path${R} d="${Sh(A,C,p,T,D)}"/>`:b+=`<rect${R} x="${A}" y="${C}" width="${p}" height="${T}"/>`}}return this.#z=e.map((g,y)=>({label:g,key:g,slot:y%10})),{svg:b,viewBox:`0 0 ${l} ${h}`}}#ut(){let t=this.#t,e=this.#N(),i=t.map(v=>v[this.x]??""),r=t.flatMap(v=>e.map(w=>+(v[w]??0))),n=us(0,Math.max(...r),5),o=n[n.length-1],a=this.#d(),{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,b=(m-p*(e.length-1))/e.length,g=(f-m)/2,y=this.#W(l,h,n,i,c,a);for(let v=0;v<t.length;v++)for(let w=0;w<e.length;w++){if(this.#v(e[w]))continue;let k=+(t[v][e[w]]??0),E=o?k/o*u:0,A=c.left+f*v+g+(b+p)*w,C=c.top+u-E;y+=`<path${this.#m(w%10,e[w])}${St({label:i[v],value:k,series:e[w]})} d="${Sh(A,C,b,E,this.#o())}"/>`,this.hideValues||(y+=`<text data-value x="${A+b/2}" y="${C-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#w(k)}</text>`)}return this.#z=e.map((v,w)=>({label:v,key:v,slot:w%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#dt(){let t=this.#t,e=this.#N(),i=t.map(m=>m[this.x]??""),r=t.flatMap(m=>e.map(b=>+(m[b]??0))),n=us(0,Math.max(...r),5),o=n[n.length-1],a=this.#d(),{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.#W(l,h,n,i,c,a);for(let m=0;m<e.length;m++){if(this.#v(e[m]))continue;let g=t.map(w=>+(w[e[m]]??0)).map((w,k)=>{let E=c.left+f*k,A=c.top+u-(o?w/o*u:0);return{x:E,y:A,v:w,label:i[k]}}),y=c.top+u,v=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area${this.#m(m%10,e[m])} d="${Wd(g,y,v)}"/>`,p+=`<path data-line${this.#g(m%10,e[m])} d="${Qa(g,v)}"/>`;for(let w of g)p+=`<circle data-dot${this.#m(m%10,e[m])} cx="${w.x}" cy="${w.y}" r="3"/>`,p+=`<circle data-hit${St({label:w.label,value:w.v,series:e[m]})} cx="${w.x}" cy="${w.y}" r="10" fill="transparent"/>`}return this.#z=e.map((m,b)=>({label:m,key:m,slot:b%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#z=null;get legendData(){return this.#z?this.#z.map(t=>({...t})):null}#ft(){if(!this.#z||!this.#z.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#z){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let r=document.createElement("span");r.setAttribute("data-legend-dot",""),r.setAttribute("data-slice",String(e.slot)),e.key&&(r.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(r);let n=document.createElement("span");n.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(n),t.appendChild(i)}return t}};S("chart-ui",dn);$();var fn=class s extends x{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.#a()}disconnected(){this.#r()}render(){this.#s(),this.#a()}#s(){if(this.#r(),!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.#a(),t.addEventListener("legend-update",this.#e)}#r(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#n(){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:[]}#a(){let t=this.#n();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",r=e.label??i,n=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",r),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-${n}))`:`var(--a-data-${n})`;h.style.setProperty("--swatch-color",c),a.appendChild(h),this.static||(a.addEventListener("click",u=>this.#o(u,i)),a.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.#o(u,i))})),this.appendChild(a)}}#o(t,e){if(!e)return;let r=!!this.#i.has(e);r?this.#i.delete(e):this.#i.add(e);let n=t.currentTarget;r?n.setAttribute("data-active",""):n.removeAttribute("data-active"),n.setAttribute("aria-pressed",r?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:r,mode:this.onToggle||"hide"}}))}};S("chart-legend-ui",fn);$();var ZC=120,pn=class extends x{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;#r=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#u),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#d),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#d))))}render(){this.open?this.#n():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#n(){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=ct(t,e,{placement:this.placement,gap:this.gap}),(this.trigger==="click"||this.trigger==="manual")&&(this.#r=requestAnimationFrame(()=>{this.#r=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#c)}))}}#a(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#o=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)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#d=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},ZC)};#u=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#a(),this.trigger==="click"&&this.removeEventListener("click",this.#o),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#d),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#d))),this.#s?.removeEventListener("toggle",this.#u),this.#s=null,this.#e=!1}};S("popover-ui",pn);$();var mn=class extends x{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 r of i)r!==e&&r.open&&(r.open=!1)}},gn=class extends x{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}})))}};S("accordion-ui",mn),S("accordion-item-ui",gn);$();var bn=class extends x{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()}}};S("divider-ui",bn);$();var On=class extends x{static properties={cite:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","blockquote")}render(){let t=this.querySelector('[slot="cite"]:not([data-cite-stamped])'),e=this.querySelector('[slot="cite"][data-cite-stamped]');if(t){e?.remove();return}if(this.cite)if(e)e.textContent=this.cite;else{let i=document.createElement("span");i.setAttribute("slot","cite"),i.setAttribute("data-cite-stamped",""),i.textContent=this.cite,this.appendChild(i)}else e&&e.remove()}};S("blockquote-ui",On);$();var Ud=[{limit:60,unit:"second",divisor:1},{limit:3600,unit:"minute",divisor:60},{limit:3600*24,unit:"hour",divisor:3600},{limit:3600*24*7,unit:"day",divisor:3600*24},{limit:3600*24*30,unit:"week",divisor:3600*24*7},{limit:3600*24*365,unit:"month",divisor:3600*24*30},{limit:1/0,unit:"year",divisor:3600*24*365}],yn=class extends x{static properties={datetime:{type:String,default:"",reflect:!0},timeStyle:{type:String,default:"long",reflect:!0,attribute:"time-style"},numeric:{type:String,default:"auto",reflect:!0},locale:{type:String,default:"",reflect:!0},updateInterval:{type:Number,default:60,reflect:!0,attribute:"update-interval"}};static template=()=>null;#t=null;#e(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#i(){if(!this.datetime)return"";let t=new Date(this.datetime);if(Number.isNaN(t.getTime()))return"";let e=(t.getTime()-Date.now())/1e3,i=Math.abs(e),r=Ud.find(o=>i<=o.limit)||Ud[Ud.length-1],n=Math.round(e/r.divisor);try{return new Intl.RelativeTimeFormat(this.#e(),{style:this.timeStyle,numeric:this.numeric}).format(n,r.unit)}catch{let o=e<0,a=Math.abs(n);return o?`${a} ${r.unit}${a===1?"":"s"} ago`:`in ${a} ${r.unit}${a===1?"":"s"}`}}#s(){if(!this.datetime)return"";let t=new Date(this.datetime);if(Number.isNaN(t.getTime()))return"";try{return new Intl.DateTimeFormat(this.#e(),{dateStyle:"full",timeStyle:"long"}).format(t)}catch{return t.toString()}}connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","time"),this.#r()}render(){let t=this.#i();this.textContent=t,t&&!this.hasAttribute("data-suppress-title")&&this.setAttribute("title",this.#s()),this.datetime&&this.setAttribute("datetime",this.datetime),this.#r()}#r(){this.#n();let t=Number(this.updateInterval);!Number.isFinite(t)||t<=0||(this.#t=setInterval(()=>{this.textContent=this.#i()},t*1e3))}#n(){this.#t!=null&&(clearInterval(this.#t),this.#t=null)}disconnected(){super.disconnected(),this.#n()}};S("relative-time-ui",yn);$();var vn=class extends x{static properties={value:{type:Number,default:0,reflect:!0},numberStyle:{type:String,default:"decimal",reflect:!0,attribute:"number-style"},currency:{type:String,default:"",reflect:!0},unit:{type:String,default:"",reflect:!0},notation:{type:String,default:"standard",reflect:!0},compactDisplay:{type:String,default:"short",reflect:!0,attribute:"compact-display"},minimumFractionDigits:{type:Number,default:0,reflect:!0,attribute:"minimum-fraction-digits"},maximumFractionDigits:{type:Number,default:2,reflect:!0,attribute:"maximum-fraction-digits"},locale:{type:String,default:"",reflect:!0},signDisplay:{type:String,default:"auto",reflect:!0,attribute:"sign-display"}};static template=()=>null;#t(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#e(){let t=Number(this.value);if(!Number.isFinite(t)||this.numberStyle==="currency"&&!this.currency||this.numberStyle==="unit"&&!this.unit)return"";let e={style:this.numberStyle,notation:this.notation,signDisplay:this.signDisplay};this.numberStyle==="currency"&&(e.currency=this.currency),this.numberStyle==="unit"&&(e.unit=this.unit),this.notation==="compact"&&(e.compactDisplay=this.compactDisplay),Number.isFinite(this.minimumFractionDigits)&&(e.minimumFractionDigits=this.minimumFractionDigits),Number.isFinite(this.maximumFractionDigits)&&(e.maximumFractionDigits=this.maximumFractionDigits);try{return new Intl.NumberFormat(this.#t(),e).format(t)}catch{return String(t)}}connected(){super.connected()}render(){let t=this.#e();this.textContent=t,t&&Number.isFinite(Number(this.value))?this.setAttribute("aria-label",`${t} (raw: ${this.value})`):this.removeAttribute("aria-label")}};S("number-format-ui",vn);$();var Fd=["Weak","Fair","Good","Strong"];function BC(s){if(!s)return-1;let t=0;s.length>=8&&t++,s.length>=12&&t++,s.length>=16&&t++;let e=[/[a-z]/.test(s),/[A-Z]/.test(s),/[0-9]/.test(s),/[^a-zA-Z0-9]/.test(s)].filter(Boolean).length;return e>=2&&t++,e>=3&&t++,e===4&&t++,/(.)\1{2,}/.test(s)&&t--,s.length<8&&(t=Math.min(t,0)),Math.max(0,Math.min(3,t))}var xn=class extends x{static properties={value:{type:String,default:""},minScore:{type:Number,default:2,reflect:!0,attribute:"min-score"},showLabel:{type:Boolean,default:!0,reflect:!0,attribute:"show-label"}};static template=()=>null;#t=-2;connected(){super.connected(),this.querySelector('[slot="bar"]')||(this.innerHTML=`
191
191
  <div slot="bar" aria-hidden="true">
192
192
  <div slot="segment" data-i="0"></div>
193
193
  <div slot="segment" data-i="1"></div>
@@ -195,15 +195,15 @@ Correct shape for <chart-ui x="label" y="value">:
195
195
  <div slot="segment" data-i="3"></div>
196
196
  </div>
197
197
  <span slot="label" aria-live="polite"></span>
198
- `),this.setAttribute("role","meter"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","3")}render(){let t=BC(this.value);t<0?(this.removeAttribute("data-score"),this.removeAttribute("aria-valuenow"),this.setAttribute("aria-valuetext","Empty")):(this.setAttribute("data-score",String(t)),this.setAttribute("aria-valuenow",String(t)),this.setAttribute("aria-valuetext",Fd[t])),this.querySelectorAll('[slot="segment"]').forEach((r,n)=>{t>=0&&n<=t?r.setAttribute("data-lit",""):r.removeAttribute("data-lit")});let i=this.querySelector('[slot="label"]');i&&(i.textContent=t>=0&&this.showLabel!==!1?Fd[t]:""),t!==this.#t&&(this.#t=t,this.dispatchEvent(new CustomEvent("score-change",{bubbles:!0,detail:{score:t,label:t>=0?Fd[t]:"",satisfied:t>=this.minScore}})))}};S("password-strength-ui",xn);$();function zC(s){return(s||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section"}var Sn=class extends x{static properties={target:{type:String,default:"",reflect:!0},headings:{type:String,default:"h2,h3",reflect:!0},offset:{type:Number,default:80,reflect:!0},label:{type:String,default:"Table of contents",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s="";#r=!1;#n(){if(this.target){let t=this.ownerDocument?.querySelector(this.target)||document.querySelector(this.target);return t||null}return this.parentElement}#a(){let t=this.#n();if(!t)return[];let e=(this.headings||"h2,h3").trim();return Array.from(t.querySelectorAll(e)).filter(r=>!this.contains(r))}#o(t){let e=this.ownerDocument||document;for(let i of t){if(i.id)continue;let r=zC(i.textContent),n=r,o=1;for(;e.getElementById(n)&&e.getElementById(n)!==i;)n=`${r}-${o++}`;i.id=n}}#l(t){if(t.length===0)return[];let e=t.map(r=>{let n=/^h([1-6])$/i.exec(r.tagName);return n?parseInt(n[1],10):6}),i=Math.min(...e);return e.map(r=>r-i)}#c(){let t=this.#a();this.#o(t);let e=this.#l(t),i=t.map((a,l)=>`${a.id}:${e[l]}`).join("|");if(i===this.#s&&this.querySelector("nav")){this.#h(t);return}this.#s=i;let r=this.querySelector("nav[data-stamped]");if(r&&r.remove(),t.length===0){this.removeAttribute("aria-label");return}let n=document.createElement("nav");n.setAttribute("data-stamped",""),n.setAttribute("aria-label",this.label||"Table of contents");let o=document.createElement("ul");t.forEach((a,l)=>{let h=document.createElement("li"),c=document.createElement("a");c.setAttribute("href",`#${a.id}`),c.setAttribute("data-target-id",a.id),c.setAttribute("data-depth",String(e[l])),c.textContent=(a.textContent||"").trim(),h.appendChild(c),o.appendChild(h)}),n.appendChild(o),this.appendChild(n),this.#h(t)}#h(t){if(this.#t?.disconnect(),typeof IntersectionObserver>"u"||t.length===0)return;let e=Number.isFinite(this.offset)?this.offset:80;this.#t=new IntersectionObserver(i=>{let r=i.filter(n=>n.isIntersecting).sort((n,o)=>n.boundingClientRect.top-o.boundingClientRect.top);r.length!==0&&this.#u(r[0].target.id)},{rootMargin:`-${e}px 0px -50% 0px`,threshold:0}),t.forEach(i=>this.#t.observe(i))}#u(t){t!==this.#e&&(this.#e=t,this.querySelectorAll("a[data-target-id]").forEach(e=>{e.dataset.targetId===t?e.setAttribute("data-active",""):e.removeAttribute("data-active")}),this.dispatchEvent(new CustomEvent("section-change",{bubbles:!0,detail:{activeId:t}})))}connected(){super.connected(),this.setAttribute("role","navigation"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.label||"Table of contents"),this.#r||(this.#r=!0,queueMicrotask(()=>{this.#r=!1,this.#c()}))}render(){(this.#s||this.querySelector("nav[data-stamped]"))&&this.#c()}disconnected(){super.disconnected(),this.#t?.disconnect(),this.#t=null}};S("toc-ui",Sn);var Ta=new Uint8Array(512),wh=new Uint8Array(256);(function(){let t=1;for(let e=0;e<255;e++)Ta[e]=t,wh[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)Ta[e]=Ta[e-255]})();function kh(s,t){return s===0||t===0?0:Ta[(wh[s]+wh[t])%255]}function cy(s){let t=new Array(s).fill(0);t[s-1]=1;let e=1;for(let i=0;i<s;i++){for(let r=0;r<t.length;r++)t[r]=kh(t[r],e),r+1<t.length&&(t[r]^=t[r+1]);e=kh(e,2)}return t}function uy(s,t){let e=cy(t),i=new Array(t).fill(0);for(let r of s){let n=r^i[0];if(i.shift(),i.push(0),n!==0)for(let o=0;o<e.length;o++)i[o]^=kh(e[o],n)}return i}var Yd={L:[[7,1,19,0,0],[10,1,34,0,0],[15,1,55,0,0],[20,1,80,0,0],[26,1,108,0,0],[18,2,68,0,0],[20,2,78,0,0],[24,2,97,0,0],[30,2,116,0,0],[18,2,68,2,69]],M:[[10,1,16,0,0],[16,1,28,0,0],[26,1,44,0,0],[18,2,32,0,0],[24,2,43,0,0],[16,4,27,0,0],[18,4,31,0,0],[22,2,38,2,39],[22,3,36,2,37],[26,4,43,1,44]],Q:[[13,1,13,0,0],[22,1,22,0,0],[18,2,17,0,0],[26,2,24,0,0],[18,2,15,2,16],[24,4,19,0,0],[18,2,14,4,15],[22,4,18,2,19],[20,4,16,4,17],[24,6,19,2,20]],H:[[17,1,9,0,0],[28,1,16,0,0],[22,2,13,0,0],[16,4,9,0,0],[22,2,11,2,12],[28,4,15,0,0],[26,4,13,1,14],[26,4,14,2,15],[24,4,12,4,13],[28,6,15,2,16]]};function dy(s,t){let[,e,i,r,n]=Yd[t][s-1];return e*i+r*n}function fy(s,t){for(let e=1;e<=10;e++){let i=dy(e,t),r=4+(e<10?8:16),n=Math.floor((i*8-r)/8);if(s<=n)return e}return-1}var _C=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]];function py(s){let t=[];for(let e=0;e<s.length;e++){let i=s.charCodeAt(e);if(i<128)t.push(i);else if(i<2048)t.push(192|i>>6,128|i&63);else if(i<55296||i>=57344)t.push(224|i>>12,128|i>>6&63,128|i&63);else{e++;let r=s.charCodeAt(e);i=65536+((i&1023)<<10|r&1023),t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63)}}return t}function my(s,t,e){let r=dy(t,e)*8,n=[];Ah(n,4,4);let o=t<10?8:16;Ah(n,s.length,o);for(let u of s)Ah(n,u,8);let a=r-n.length,l=Math.min(4,a);for(let u=0;u<l;u++)n.push(0);for(;n.length%8!==0&&n.length<r;)n.push(0);let h=[236,17],c=0;for(;n.length<r;)Ah(n,h[c%2],8),c++;return jC(n)}function Ah(s,t,e){for(let i=e-1;i>=0;i--)s.push(t>>i&1)}function jC(s){let t=[];for(let e=0;e<s.length;e+=8){let i=0;for(let r=0;r<8;r++)i=i<<1|(s[e+r]||0);t.push(i)}return t}function gy(s,t,e){let[i,r,n,o,a]=Yd[e][t-1],l=[],h=0;for(let f=0;f<r;f++)l.push(s.slice(h,h+n)),h+=n;for(let f=0;f<o;f++)l.push(s.slice(h,h+a)),h+=a;let c=l.map(f=>uy(f,i)),u=[],d=Math.max(n,a||0);for(let f=0;f<d;f++)for(let p of l)f<p.length&&u.push(p[f]);for(let f=0;f<i;f++)for(let p of c)u.push(p[f]);return u}function VC(s){let t=s*4+17,e=Array.from({length:t},()=>new Uint8Array(t)),i=Array.from({length:t},()=>new Uint8Array(t));return{matrix:e,reserved:i,size:t}}function Hd(s,t,e,i){for(let r=-1;r<=7;r++)for(let n=-1;n<=7;n++){let o=e+r,a=i+n;if(!(o<0||o>=s.length||a<0||a>=s.length))if(t[o][a]=1,r>=0&&r<=6&&n>=0&&n<=6){let l=r===0||r===6||n===0||n===6,h=r>=2&&r<=4&&n>=2&&n<=4;s[o][a]=l||h?1:0}else s[o][a]=0}}function WC(s,t,e,i){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++){let o=e+r,a=i+n;if(o<0||o>=s.length||a<0||a>=s.length)continue;t[o][a]=1;let l=Math.abs(r)===2||Math.abs(n)===2,h=r===0&&n===0;s[o][a]=l||h?1:0}}function UC(s,t){let e=s.length;for(let i=8;i<e-8;i++){let r=i%2===0?1:0;s[6][i]=r,s[i][6]=r,t[6][i]=1,t[i][6]=1}}function FC(s){let t=s.length;for(let e=0;e<=8;e++)s[8][e]=1,s[e][8]=1;for(let e=t-8;e<t;e++)s[8][e]=1;for(let e=t-7;e<t;e++)s[e][8]=1}function YC(s,t,e){let i=s.length;Hd(s,t,0,0),Hd(s,t,0,i-7),Hd(s,t,i-7,0);let r=_C[e-1];for(let n of r)for(let o of r)n===6&&o===6||n===6&&o===i-7||n===i-7&&o===6||WC(s,t,n,o);UC(s,t),s[i-8][8]=1,t[i-8][8]=1,FC(t)}function HC(s,t,e){let i=s.length,r=[];for(let a of e)for(let l=7;l>=0;l--)r.push(a>>l&1);let n=0,o=!0;for(let a=i-1;a>=1;a-=2){a===6&&(a=5);for(let l=0;l<i;l++){let h=o?i-1-l:l;for(let c=0;c<2;c++){let u=a-c;!t[h][u]&&n<r.length&&(s[h][u]=r[n++])}}o=!o}}function GC(s,t,e){switch(s){case 0:return(t+e)%2===0;case 1:return t%2===0;case 2:return e%3===0;case 3:return(t+e)%3===0;case 4:return(Math.floor(t/2)+Math.floor(e/3))%2===0;case 5:return t*e%2+t*e%3===0;case 6:return(t*e%2+t*e%3)%2===0;case 7:return((t+e)%2+t*e%3)%2===0}return!1}function KC(s,t,e){let i=s.length;for(let r=0;r<i;r++)for(let n=0;n<i;n++)!t[r][n]&&GC(e,r,n)&&(s[r][n]^=1)}function JC(s,t){let i={L:1,M:0,Q:3,H:2}[s]<<3|t,r=i<<10,n=1335;for(let o=14;o>=10;o--)r&1<<o&&(r^=n<<o-10);return(i<<10|r)^21522}function t$(s,t,e){let i=JC(t,e),r=s.length;for(let n=0;n<=5;n++)s[n][8]=i>>n&1;s[7][8]=i>>6&1,s[8][8]=i>>7&1,s[8][7]=i>>8&1;for(let n=9;n<=14;n++)s[8][14-n]=i>>n&1;for(let n=0;n<=7;n++)s[8][r-1-n]=i>>n&1;for(let n=8;n<=14;n++)s[r-15+n][8]=i>>n&1}function e$(s){let t=s<<12,e=7973;for(let i=17;i>=12;i--)t&1<<i&&(t^=e<<i-12);return s<<12|t}function i$(s,t,e){if(t<7)return;let i=e$(t),r=s.length;for(let n=0;n<18;n++){let o=i>>n&1,a=Math.floor(n/3),l=n%3+r-11;s[a][l]=o,s[l][a]=o,e&&(e[a][l]=1,e[l][a]=1)}}function s$(s){let t=s.length,e=0;for(let l=0;l<t;l++){let h=1;for(let c=1;c<t;c++)s[l][c]===s[l][c-1]?(h++,h===5?e+=3:h>5&&e++):h=1}for(let l=0;l<t;l++){let h=1;for(let c=1;c<t;c++)s[c][l]===s[c-1][l]?(h++,h===5?e+=3:h>5&&e++):h=1}for(let l=0;l<t-1;l++)for(let h=0;h<t-1;h++){let c=s[l][h];s[l][h+1]===c&&s[l+1][h]===c&&s[l+1][h+1]===c&&(e+=3)}let i=[1,0,1,1,1,0,1];for(let l=0;l<t;l++)for(let h=0;h<=t-11;h++){let c=!0;for(let u=0;u<7;u++)if(s[l][h+u]!==i[u]){c=!1;break}if(c){let u=h+7<=t-4&&s[l][h+7]===0&&s[l][h+8]===0&&s[l][h+9]===0&&s[l][h+10]===0,d=h>=4&&s[l][h-1]===0&&s[l][h-2]===0&&s[l][h-3]===0&&s[l][h-4]===0;(u||d)&&(e+=40)}}for(let l=0;l<t;l++)for(let h=0;h<=t-11;h++){let c=!0;for(let u=0;u<7;u++)if(s[h+u][l]!==i[u]){c=!1;break}if(c){let u=h+7<=t-4&&s[h+7][l]===0&&s[h+8][l]===0&&s[h+9][l]===0&&s[h+10][l]===0,d=h>=4&&s[h-1][l]===0&&s[h-2][l]===0&&s[h-3][l]===0&&s[h-4][l]===0;(u||d)&&(e+=40)}}let r=0;for(let l=0;l<t;l++)for(let h=0;h<t;h++)s[l][h]&&r++;let n=t*t,o=r*100/n,a=Math.floor(Math.abs(o-50)/5);return e+=a*10,e}var __={rsGenerator:cy,rsEncode:uy,gfMul:kh,EXP:Ta,LOG:wh,buildDataBits:my,interleaveCodewords:gy,utf8Encode:py,selectVersion:fy};function by(s,t={}){let e=t.errorCorrection||"M";if(!Yd[e])throw new Error(`Unknown error-correction level: ${e}. Expected L/M/Q/H.`);let i=py(s),r=t.version||fy(i.length,e);if(r<1||r>10)throw new Error(`QR encoder supports versions 1-10 only; data length ${i.length} bytes exceeds capacity at ECC=${e}.`);let n=my(i,r,e),o=gy(n,r,e),a=null,l=1/0;for(let h=0;h<8;h++){let{matrix:c,reserved:u,size:d}=VC(r);YC(c,u,r),i$(c,r,u),HC(c,u,o),KC(c,u,h),t$(c,e,h);let f=s$(c);f<l&&(l=f,a={matrix:c,size:d,version:r,mask:h,ecc:e})}return a}function Oy(s,t={}){let e=s.length,i=t.cellSize||8,r=t.margin!=null?t.margin:4,n=t.color||"#000",o=t.background||"#fff",a=(e+r*2)*i,l=[];for(let h=0;h<e;h++)for(let c=0;c<e;c++)if(s[h][c]){let u=(c+r)*i,d=(h+r)*i;l.push(`<rect x="${u}" y="${d}" width="${i}" height="${i}"/>`)}return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} ${a}" width="${a}" height="${a}" shape-rendering="crispEdges">
198
+ `),this.setAttribute("role","meter"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","3")}render(){let t=BC(this.value);t<0?(this.removeAttribute("data-score"),this.removeAttribute("aria-valuenow"),this.setAttribute("aria-valuetext","Empty")):(this.setAttribute("data-score",String(t)),this.setAttribute("aria-valuenow",String(t)),this.setAttribute("aria-valuetext",Fd[t])),this.querySelectorAll('[slot="segment"]').forEach((r,n)=>{t>=0&&n<=t?r.setAttribute("data-lit",""):r.removeAttribute("data-lit")});let i=this.querySelector('[slot="label"]');i&&(i.textContent=t>=0&&this.showLabel!==!1?Fd[t]:""),t!==this.#t&&(this.#t=t,this.dispatchEvent(new CustomEvent("score-change",{bubbles:!0,detail:{score:t,label:t>=0?Fd[t]:"",satisfied:t>=this.minScore}})))}};S("password-strength-ui",xn);$();function zC(s){return(s||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section"}var Sn=class extends x{static properties={target:{type:String,default:"",reflect:!0},headings:{type:String,default:"h2,h3",reflect:!0},offset:{type:Number,default:80,reflect:!0},label:{type:String,default:"Table of contents",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s="";#r=!1;#n(){if(this.target){let t=this.ownerDocument?.querySelector(this.target)||document.querySelector(this.target);return t||null}return this.parentElement}#a(){let t=this.#n();if(!t)return[];let e=(this.headings||"h2,h3").trim();return Array.from(t.querySelectorAll(e)).filter(r=>!this.contains(r))}#o(t){let e=this.ownerDocument||document;for(let i of t){if(i.id)continue;let r=zC(i.textContent),n=r,o=1;for(;e.getElementById(n)&&e.getElementById(n)!==i;)n=`${r}-${o++}`;i.id=n}}#l(t){if(t.length===0)return[];let e=t.map(r=>{let n=/^h([1-6])$/i.exec(r.tagName);return n?parseInt(n[1],10):6}),i=Math.min(...e);return e.map(r=>r-i)}#c(){let t=this.#a();this.#o(t);let e=this.#l(t),i=t.map((a,l)=>`${a.id}:${e[l]}`).join("|");if(i===this.#s&&this.querySelector("nav")){this.#h(t);return}this.#s=i;let r=this.querySelector("nav[data-stamped]");if(r&&r.remove(),t.length===0){this.removeAttribute("aria-label");return}let n=document.createElement("nav");n.setAttribute("data-stamped",""),n.setAttribute("aria-label",this.label||"Table of contents");let o=document.createElement("ul");t.forEach((a,l)=>{let h=document.createElement("li"),c=document.createElement("a");c.setAttribute("href",`#${a.id}`),c.setAttribute("data-target-id",a.id),c.setAttribute("data-depth",String(e[l])),c.textContent=(a.textContent||"").trim(),h.appendChild(c),o.appendChild(h)}),n.appendChild(o),this.appendChild(n),this.#h(t)}#h(t){if(this.#t?.disconnect(),typeof IntersectionObserver>"u"||t.length===0)return;let e=Number.isFinite(this.offset)?this.offset:80;this.#t=new IntersectionObserver(i=>{let r=i.filter(n=>n.isIntersecting).sort((n,o)=>n.boundingClientRect.top-o.boundingClientRect.top);r.length!==0&&this.#d(r[0].target.id)},{rootMargin:`-${e}px 0px -50% 0px`,threshold:0}),t.forEach(i=>this.#t.observe(i))}#d(t){t!==this.#e&&(this.#e=t,this.querySelectorAll("a[data-target-id]").forEach(e=>{e.dataset.targetId===t?e.setAttribute("data-active",""):e.removeAttribute("data-active")}),this.dispatchEvent(new CustomEvent("section-change",{bubbles:!0,detail:{activeId:t}})))}connected(){super.connected(),this.setAttribute("role","navigation"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.label||"Table of contents"),this.#r||(this.#r=!0,queueMicrotask(()=>{this.#r=!1,this.#c()}))}render(){(this.#s||this.querySelector("nav[data-stamped]"))&&this.#c()}disconnected(){super.disconnected(),this.#t?.disconnect(),this.#t=null}};S("toc-ui",Sn);var Ta=new Uint8Array(512),wh=new Uint8Array(256);(function(){let t=1;for(let e=0;e<255;e++)Ta[e]=t,wh[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)Ta[e]=Ta[e-255]})();function kh(s,t){return s===0||t===0?0:Ta[(wh[s]+wh[t])%255]}function cy(s){let t=new Array(s).fill(0);t[s-1]=1;let e=1;for(let i=0;i<s;i++){for(let r=0;r<t.length;r++)t[r]=kh(t[r],e),r+1<t.length&&(t[r]^=t[r+1]);e=kh(e,2)}return t}function uy(s,t){let e=cy(t),i=new Array(t).fill(0);for(let r of s){let n=r^i[0];if(i.shift(),i.push(0),n!==0)for(let o=0;o<e.length;o++)i[o]^=kh(e[o],n)}return i}var Yd={L:[[7,1,19,0,0],[10,1,34,0,0],[15,1,55,0,0],[20,1,80,0,0],[26,1,108,0,0],[18,2,68,0,0],[20,2,78,0,0],[24,2,97,0,0],[30,2,116,0,0],[18,2,68,2,69]],M:[[10,1,16,0,0],[16,1,28,0,0],[26,1,44,0,0],[18,2,32,0,0],[24,2,43,0,0],[16,4,27,0,0],[18,4,31,0,0],[22,2,38,2,39],[22,3,36,2,37],[26,4,43,1,44]],Q:[[13,1,13,0,0],[22,1,22,0,0],[18,2,17,0,0],[26,2,24,0,0],[18,2,15,2,16],[24,4,19,0,0],[18,2,14,4,15],[22,4,18,2,19],[20,4,16,4,17],[24,6,19,2,20]],H:[[17,1,9,0,0],[28,1,16,0,0],[22,2,13,0,0],[16,4,9,0,0],[22,2,11,2,12],[28,4,15,0,0],[26,4,13,1,14],[26,4,14,2,15],[24,4,12,4,13],[28,6,15,2,16]]};function dy(s,t){let[,e,i,r,n]=Yd[t][s-1];return e*i+r*n}function fy(s,t){for(let e=1;e<=10;e++){let i=dy(e,t),r=4+(e<10?8:16),n=Math.floor((i*8-r)/8);if(s<=n)return e}return-1}var _C=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]];function py(s){let t=[];for(let e=0;e<s.length;e++){let i=s.charCodeAt(e);if(i<128)t.push(i);else if(i<2048)t.push(192|i>>6,128|i&63);else if(i<55296||i>=57344)t.push(224|i>>12,128|i>>6&63,128|i&63);else{e++;let r=s.charCodeAt(e);i=65536+((i&1023)<<10|r&1023),t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63)}}return t}function my(s,t,e){let r=dy(t,e)*8,n=[];Ah(n,4,4);let o=t<10?8:16;Ah(n,s.length,o);for(let u of s)Ah(n,u,8);let a=r-n.length,l=Math.min(4,a);for(let u=0;u<l;u++)n.push(0);for(;n.length%8!==0&&n.length<r;)n.push(0);let h=[236,17],c=0;for(;n.length<r;)Ah(n,h[c%2],8),c++;return jC(n)}function Ah(s,t,e){for(let i=e-1;i>=0;i--)s.push(t>>i&1)}function jC(s){let t=[];for(let e=0;e<s.length;e+=8){let i=0;for(let r=0;r<8;r++)i=i<<1|(s[e+r]||0);t.push(i)}return t}function gy(s,t,e){let[i,r,n,o,a]=Yd[e][t-1],l=[],h=0;for(let f=0;f<r;f++)l.push(s.slice(h,h+n)),h+=n;for(let f=0;f<o;f++)l.push(s.slice(h,h+a)),h+=a;let c=l.map(f=>uy(f,i)),u=[],d=Math.max(n,a||0);for(let f=0;f<d;f++)for(let p of l)f<p.length&&u.push(p[f]);for(let f=0;f<i;f++)for(let p of c)u.push(p[f]);return u}function VC(s){let t=s*4+17,e=Array.from({length:t},()=>new Uint8Array(t)),i=Array.from({length:t},()=>new Uint8Array(t));return{matrix:e,reserved:i,size:t}}function Hd(s,t,e,i){for(let r=-1;r<=7;r++)for(let n=-1;n<=7;n++){let o=e+r,a=i+n;if(!(o<0||o>=s.length||a<0||a>=s.length))if(t[o][a]=1,r>=0&&r<=6&&n>=0&&n<=6){let l=r===0||r===6||n===0||n===6,h=r>=2&&r<=4&&n>=2&&n<=4;s[o][a]=l||h?1:0}else s[o][a]=0}}function WC(s,t,e,i){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++){let o=e+r,a=i+n;if(o<0||o>=s.length||a<0||a>=s.length)continue;t[o][a]=1;let l=Math.abs(r)===2||Math.abs(n)===2,h=r===0&&n===0;s[o][a]=l||h?1:0}}function UC(s,t){let e=s.length;for(let i=8;i<e-8;i++){let r=i%2===0?1:0;s[6][i]=r,s[i][6]=r,t[6][i]=1,t[i][6]=1}}function FC(s){let t=s.length;for(let e=0;e<=8;e++)s[8][e]=1,s[e][8]=1;for(let e=t-8;e<t;e++)s[8][e]=1;for(let e=t-7;e<t;e++)s[e][8]=1}function YC(s,t,e){let i=s.length;Hd(s,t,0,0),Hd(s,t,0,i-7),Hd(s,t,i-7,0);let r=_C[e-1];for(let n of r)for(let o of r)n===6&&o===6||n===6&&o===i-7||n===i-7&&o===6||WC(s,t,n,o);UC(s,t),s[i-8][8]=1,t[i-8][8]=1,FC(t)}function HC(s,t,e){let i=s.length,r=[];for(let a of e)for(let l=7;l>=0;l--)r.push(a>>l&1);let n=0,o=!0;for(let a=i-1;a>=1;a-=2){a===6&&(a=5);for(let l=0;l<i;l++){let h=o?i-1-l:l;for(let c=0;c<2;c++){let u=a-c;!t[h][u]&&n<r.length&&(s[h][u]=r[n++])}}o=!o}}function GC(s,t,e){switch(s){case 0:return(t+e)%2===0;case 1:return t%2===0;case 2:return e%3===0;case 3:return(t+e)%3===0;case 4:return(Math.floor(t/2)+Math.floor(e/3))%2===0;case 5:return t*e%2+t*e%3===0;case 6:return(t*e%2+t*e%3)%2===0;case 7:return((t+e)%2+t*e%3)%2===0}return!1}function KC(s,t,e){let i=s.length;for(let r=0;r<i;r++)for(let n=0;n<i;n++)!t[r][n]&&GC(e,r,n)&&(s[r][n]^=1)}function JC(s,t){let i={L:1,M:0,Q:3,H:2}[s]<<3|t,r=i<<10,n=1335;for(let o=14;o>=10;o--)r&1<<o&&(r^=n<<o-10);return(i<<10|r)^21522}function t$(s,t,e){let i=JC(t,e),r=s.length;for(let n=0;n<=5;n++)s[n][8]=i>>n&1;s[7][8]=i>>6&1,s[8][8]=i>>7&1,s[8][7]=i>>8&1;for(let n=9;n<=14;n++)s[8][14-n]=i>>n&1;for(let n=0;n<=7;n++)s[8][r-1-n]=i>>n&1;for(let n=8;n<=14;n++)s[r-15+n][8]=i>>n&1}function e$(s){let t=s<<12,e=7973;for(let i=17;i>=12;i--)t&1<<i&&(t^=e<<i-12);return s<<12|t}function i$(s,t,e){if(t<7)return;let i=e$(t),r=s.length;for(let n=0;n<18;n++){let o=i>>n&1,a=Math.floor(n/3),l=n%3+r-11;s[a][l]=o,s[l][a]=o,e&&(e[a][l]=1,e[l][a]=1)}}function s$(s){let t=s.length,e=0;for(let l=0;l<t;l++){let h=1;for(let c=1;c<t;c++)s[l][c]===s[l][c-1]?(h++,h===5?e+=3:h>5&&e++):h=1}for(let l=0;l<t;l++){let h=1;for(let c=1;c<t;c++)s[c][l]===s[c-1][l]?(h++,h===5?e+=3:h>5&&e++):h=1}for(let l=0;l<t-1;l++)for(let h=0;h<t-1;h++){let c=s[l][h];s[l][h+1]===c&&s[l+1][h]===c&&s[l+1][h+1]===c&&(e+=3)}let i=[1,0,1,1,1,0,1];for(let l=0;l<t;l++)for(let h=0;h<=t-11;h++){let c=!0;for(let u=0;u<7;u++)if(s[l][h+u]!==i[u]){c=!1;break}if(c){let u=h+7<=t-4&&s[l][h+7]===0&&s[l][h+8]===0&&s[l][h+9]===0&&s[l][h+10]===0,d=h>=4&&s[l][h-1]===0&&s[l][h-2]===0&&s[l][h-3]===0&&s[l][h-4]===0;(u||d)&&(e+=40)}}for(let l=0;l<t;l++)for(let h=0;h<=t-11;h++){let c=!0;for(let u=0;u<7;u++)if(s[h+u][l]!==i[u]){c=!1;break}if(c){let u=h+7<=t-4&&s[h+7][l]===0&&s[h+8][l]===0&&s[h+9][l]===0&&s[h+10][l]===0,d=h>=4&&s[h-1][l]===0&&s[h-2][l]===0&&s[h-3][l]===0&&s[h-4][l]===0;(u||d)&&(e+=40)}}let r=0;for(let l=0;l<t;l++)for(let h=0;h<t;h++)s[l][h]&&r++;let n=t*t,o=r*100/n,a=Math.floor(Math.abs(o-50)/5);return e+=a*10,e}var __={rsGenerator:cy,rsEncode:uy,gfMul:kh,EXP:Ta,LOG:wh,buildDataBits:my,interleaveCodewords:gy,utf8Encode:py,selectVersion:fy};function by(s,t={}){let e=t.errorCorrection||"M";if(!Yd[e])throw new Error(`Unknown error-correction level: ${e}. Expected L/M/Q/H.`);let i=py(s),r=t.version||fy(i.length,e);if(r<1||r>10)throw new Error(`QR encoder supports versions 1-10 only; data length ${i.length} bytes exceeds capacity at ECC=${e}.`);let n=my(i,r,e),o=gy(n,r,e),a=null,l=1/0;for(let h=0;h<8;h++){let{matrix:c,reserved:u,size:d}=VC(r);YC(c,u,r),i$(c,r,u),HC(c,u,o),KC(c,u,h),t$(c,e,h);let f=s$(c);f<l&&(l=f,a={matrix:c,size:d,version:r,mask:h,ecc:e})}return a}function Oy(s,t={}){let e=s.length,i=t.cellSize||8,r=t.margin!=null?t.margin:4,n=t.color||"#000",o=t.background||"#fff",a=(e+r*2)*i,l=[];for(let h=0;h<e;h++)for(let c=0;c<e;c++)if(s[h][c]){let u=(c+r)*i,d=(h+r)*i;l.push(`<rect x="${u}" y="${d}" width="${i}" height="${i}"/>`)}return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} ${a}" width="${a}" height="${a}" shape-rendering="crispEdges">
199
199
  <rect width="100%" height="100%" fill="${o}"/>
200
200
  <g fill="${n}">${l.join("")}</g>
201
- </svg>`}$();var wn=class extends x{static properties={value:{type:String,default:"",reflect:!0},matrix:{type:String,default:"",reflect:!0},size:{type:Number,default:200,reflect:!0},errorCorrection:{type:String,default:"M",reflect:!0,attribute:"error-correction"},margin:{type:Number,default:4,reflect:!0},color:{type:String,default:"",reflect:!0},background:{type:String,default:"",reflect:!0},label:{type:String,default:"QR code",reflect:!0}};static template=()=>null;#t="";#e(t){if(!t)return null;try{let e=JSON.parse(t);return!Array.isArray(e)||e.length===0||!Array.isArray(e[0])?null:e.map(i=>i.map(r=>r?1:0))}catch(e){return console.warn("[qr-code-ui] invalid [matrix] JSON:",e.message),null}}#i(){let t=this.#e(this.matrix);if(t)return this.removeAttribute("data-error"),t;if(!this.value)return this.removeAttribute("data-error"),null;try{let e=by(this.value,{errorCorrection:this.errorCorrection||"M"});return this.removeAttribute("data-error"),e.matrix}catch(e){return this.setAttribute("data-error",""),console.warn(`[qr-code-ui] encode failed for value (${this.value?.length||0} chars at ECC=${this.errorCorrection}): ${e.message}. Lower ECC, shorten input, or supply a precomputed [matrix].`),null}}connected(){super.connected(),this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.label||"QR code")}render(){let t=`${this.value}|${this.matrix}|${this.size}|${this.errorCorrection}|${this.margin}|${this.color}|${this.background}`;if(t===this.#t&&this.querySelector("svg"))return;this.#t=t,this.label&&this.setAttribute("aria-label",this.label);let e=this.#i();if(!e){this.innerHTML="";return}let i=Oy(e,{cellSize:8,margin:Number.isFinite(this.margin)?this.margin:4,color:this.color||"#000000",background:this.background||"#ffffff"});this.innerHTML=i;let r=this.querySelector("svg");r&&Number.isFinite(this.size)&&(r.setAttribute("width",String(this.size)),r.setAttribute("height",String(this.size)))}};S("qr-code-ui",wn);$();var kn=class extends x{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},size:{type:String,default:"md",reflect:!0}};static requiredIcons=["caret-left","caret-right"];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("press",this.#a))}disconnected(){this.#t?.removeEventListener("press",this.#a),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),r=this.#i(t,e,i);this.reconcile(this.#t,r,n=>n.key,(n,o,a)=>a?(this.#n(a,n,t),a):this.#r(n,t))}#i(t,e,i){let r=[];r.push({key:"prev",type:"prev",value:t-1});let n=2*i+5;if(e<=n)for(let o=1;o<=e;o++)r.push({key:`page-${o}`,type:"page",value:o});else{let o=t<=i+3,a=t>=e-i-2;if(o){let l=n-2;for(let h=1;h<=l;h++)r.push({key:`page-${h}`,type:"page",value:h});r.push({key:"ellipsis-end",type:"ellipsis"}),r.push({key:`page-${e}`,type:"page",value:e})}else if(a){r.push({key:"page-1",type:"page",value:1}),r.push({key:"ellipsis-start",type:"ellipsis"});let l=e-n+3;for(let h=l;h<=e;h++)r.push({key:`page-${h}`,type:"page",value:h})}else{r.push({key:"page-1",type:"page",value:1}),r.push({key:"ellipsis-start",type:"ellipsis"});for(let l=t-i;l<=t+i;l++)r.push({key:`page-${l}`,type:"page",value:l});r.push({key:"ellipsis-end",type:"ellipsis"}),r.push({key:`page-${e}`,type:"page",value:e})}}return r.push({key:"next",type:"next",value:t+1}),r}#s(){return this.variant==="button"?"outline":"ghost"}#r(t,e){if(t.type==="ellipsis"){let r=document.createElement("span");return r.setAttribute("data-ellipsis",""),r.textContent="\u2026",r}let i=document.createElement("button-ui");return i.setAttribute("size",this.size),t.type==="prev"?(i.setAttribute("data-prev",""),i.setAttribute("icon","caret-left"),i.setAttribute("aria-label","Previous page")):t.type==="next"?(i.setAttribute("data-next",""),i.setAttribute("icon","caret-right"),i.setAttribute("aria-label","Next page")):(i.setAttribute("data-page",""),i.dataset.value=String(t.value),i.setAttribute("text",String(t.value)),i.setAttribute("aria-label",`Page ${t.value}`)),this.#n(i,t,e),i}#n(t,e,i){e.type!=="ellipsis"&&(t.setAttribute("size",this.size),e.type==="prev"?(t.setAttribute("variant",this.#s()),i<=1?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0"))):e.type==="next"?(t.setAttribute("variant",this.#s()),i>=this.total?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0"))):(t.dataset.value=String(e.value),t.setAttribute("text",String(e.value)),t.setAttribute("aria-label",`Page ${e.value}`),e.value===i?(t.setAttribute("variant","primary"),t.setAttribute("data-active",""),t.setAttribute("aria-current","page")):(t.setAttribute("variant",this.#s()),t.removeAttribute("data-active"),t.removeAttribute("aria-current"))))}#a=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}})))}};S("pagination-ui",kn);$();var WI=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),UI={js:"javascript",md:"markdown",yml:"yaml"};function qb(s){if(!s)return"";let t=String(s).toLowerCase();return UI[t]??t}var ao=class s extends x{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;#r=!1;#n=null;#a="";#o=null;#l=()=>this.#O();connected(){this.#s+=1,!this.inline&&!this.querySelector(":scope > pre")&&this.#c(),this.#t=this.querySelector(':scope > header [slot="copy"]'),this.#t&&this.#t.addEventListener("click",this.#l);let t=qb(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(WI.has(t)||this.editable)&&this.#u()}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)}#c(){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"),r=document.createElement("code"),n=qb(this.language),o=this.getAttribute("data-line-states");if(o!=null||n==="diff"){r.setAttribute("data-line-state-mode",""),this.lineNumbers&&r.setAttribute("data-line-numbers","");let l=o?.split(",").map(c=>c.trim())??null;e.split(`
201
+ </svg>`}$();var wn=class extends x{static properties={value:{type:String,default:"",reflect:!0},matrix:{type:String,default:"",reflect:!0},size:{type:Number,default:200,reflect:!0},errorCorrection:{type:String,default:"M",reflect:!0,attribute:"error-correction"},margin:{type:Number,default:4,reflect:!0},color:{type:String,default:"",reflect:!0},background:{type:String,default:"",reflect:!0},label:{type:String,default:"QR code",reflect:!0}};static template=()=>null;#t="";#e(t){if(!t)return null;try{let e=JSON.parse(t);return!Array.isArray(e)||e.length===0||!Array.isArray(e[0])?null:e.map(i=>i.map(r=>r?1:0))}catch(e){return console.warn("[qr-code-ui] invalid [matrix] JSON:",e.message),null}}#i(){let t=this.#e(this.matrix);if(t)return this.removeAttribute("data-error"),t;if(!this.value)return this.removeAttribute("data-error"),null;try{let e=by(this.value,{errorCorrection:this.errorCorrection||"M"});return this.removeAttribute("data-error"),e.matrix}catch(e){return this.setAttribute("data-error",""),console.warn(`[qr-code-ui] encode failed for value (${this.value?.length||0} chars at ECC=${this.errorCorrection}): ${e.message}. Lower ECC, shorten input, or supply a precomputed [matrix].`),null}}connected(){super.connected(),this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.label||"QR code")}render(){let t=`${this.value}|${this.matrix}|${this.size}|${this.errorCorrection}|${this.margin}|${this.color}|${this.background}`;if(t===this.#t&&this.querySelector("svg"))return;this.#t=t,this.label&&this.setAttribute("aria-label",this.label);let e=this.#i();if(!e){this.innerHTML="";return}let i=Oy(e,{cellSize:8,margin:Number.isFinite(this.margin)?this.margin:4,color:this.color||"#000000",background:this.background||"#ffffff"});this.innerHTML=i;let r=this.querySelector("svg");r&&Number.isFinite(this.size)&&(r.setAttribute("width",String(this.size)),r.setAttribute("height",String(this.size)))}};S("qr-code-ui",wn);$();var kn=class extends x{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},size:{type:String,default:"md",reflect:!0}};static requiredIcons=["caret-left","caret-right"];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("press",this.#a))}disconnected(){this.#t?.removeEventListener("press",this.#a),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),r=this.#i(t,e,i);this.reconcile(this.#t,r,n=>n.key,(n,o,a)=>a?(this.#n(a,n,t),a):this.#r(n,t))}#i(t,e,i){let r=[];r.push({key:"prev",type:"prev",value:t-1});let n=2*i+5;if(e<=n)for(let o=1;o<=e;o++)r.push({key:`page-${o}`,type:"page",value:o});else{let o=t<=i+3,a=t>=e-i-2;if(o){let l=n-2;for(let h=1;h<=l;h++)r.push({key:`page-${h}`,type:"page",value:h});r.push({key:"ellipsis-end",type:"ellipsis"}),r.push({key:`page-${e}`,type:"page",value:e})}else if(a){r.push({key:"page-1",type:"page",value:1}),r.push({key:"ellipsis-start",type:"ellipsis"});let l=e-n+3;for(let h=l;h<=e;h++)r.push({key:`page-${h}`,type:"page",value:h})}else{r.push({key:"page-1",type:"page",value:1}),r.push({key:"ellipsis-start",type:"ellipsis"});for(let l=t-i;l<=t+i;l++)r.push({key:`page-${l}`,type:"page",value:l});r.push({key:"ellipsis-end",type:"ellipsis"}),r.push({key:`page-${e}`,type:"page",value:e})}}return r.push({key:"next",type:"next",value:t+1}),r}#s(){return this.variant==="button"?"outline":"ghost"}#r(t,e){if(t.type==="ellipsis"){let r=document.createElement("span");return r.setAttribute("data-ellipsis",""),r.textContent="\u2026",r}let i=document.createElement("button-ui");return i.setAttribute("size",this.size),t.type==="prev"?(i.setAttribute("data-prev",""),i.setAttribute("icon","caret-left"),i.setAttribute("aria-label","Previous page")):t.type==="next"?(i.setAttribute("data-next",""),i.setAttribute("icon","caret-right"),i.setAttribute("aria-label","Next page")):(i.setAttribute("data-page",""),i.dataset.value=String(t.value),i.setAttribute("text",String(t.value)),i.setAttribute("aria-label",`Page ${t.value}`)),this.#n(i,t,e),i}#n(t,e,i){e.type!=="ellipsis"&&(t.setAttribute("size",this.size),e.type==="prev"?(t.setAttribute("variant",this.#s()),i<=1?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0"))):e.type==="next"?(t.setAttribute("variant",this.#s()),i>=this.total?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0"))):(t.dataset.value=String(e.value),t.setAttribute("text",String(e.value)),t.setAttribute("aria-label",`Page ${e.value}`),e.value===i?(t.setAttribute("variant","primary"),t.setAttribute("data-active",""),t.setAttribute("aria-current","page")):(t.setAttribute("variant",this.#s()),t.removeAttribute("data-active"),t.removeAttribute("aria-current"))))}#a=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}})))}};S("pagination-ui",kn);$();var WI=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),UI={js:"javascript",md:"markdown",yml:"yaml"};function qb(s){if(!s)return"";let t=String(s).toLowerCase();return UI[t]??t}var ao=class s extends x{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;#r=!1;#n=null;#a="";#o=null;#l=()=>this.#y();connected(){this.#s+=1,!this.inline&&!this.querySelector(":scope > pre")&&this.#c(),this.#t=this.querySelector(':scope > header [slot="copy"]'),this.#t&&this.#t.addEventListener("click",this.#l);let t=qb(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(WI.has(t)||this.editable)&&this.#d()}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)}#c(){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"),r=document.createElement("code"),n=qb(this.language),o=this.getAttribute("data-line-states");if(o!=null||n==="diff"){r.setAttribute("data-line-state-mode",""),this.lineNumbers&&r.setAttribute("data-line-numbers","");let l=o?.split(",").map(c=>c.trim())??null;e.split(`
202
202
  `).forEach((c,u)=>{let d="unchanged";if(l&&l[u])d=l[u];else if(n==="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),r.appendChild(f)})}else r.textContent=e;i.appendChild(r),this.appendChild(i)}static#h(t){let e=t.replace(/^\n+|\n+$/g,"");if(!e)return"";let i=e.split(`
203
203
  `),r=i.filter(o=>o.trim().length>0).map(o=>o.match(/^[ \t]*/)[0].length),n=r.length?Math.min(...r):0;return n>0?i.map(o=>o.slice(n)).join(`
204
- `):e}async#u(){if(this.#r||this.#i)return;let t=this.#s,e=qb(this.language);this.#r=!0;try{let i=await Promise.resolve().then(()=>(Db(),Ib)),r=null;try{r=(await i.importWithTimeout(i.languages[e],`lang-${e}`))?.extension??null}catch(n){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"language",language:e,error:n}}))}if(t!==this.#s||!this.isConnected)return;this.#d(i,r,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.#r=!1}}#d(t,e,i){let{EditorState:r,EditorView:n,Compartment:o,lineNumbers:a,placeholder:l,syntaxHighlighting:h,history:c,historyKeymap:u,defaultKeymap:d,indentWithTab:f,keymap:p,adiaBaseTheme:m,adiaHighlightStyle:b,lintGutter:g,jsonLinter:y}=t,v=this.querySelector(":scope > pre"),w=v?v.querySelector("code")?.textContent??"":"",k=this.text||w||"";this.#a=k;let E=document.createElement("div");E.setAttribute("data-cm-mount",""),v?v.replaceWith(E):this.appendChild(E);let A=[m,h(b)];this.editable&&A.push(c(),p.of([{key:"Mod-s",run:C=>(this.#b(C),!0)},...d,...u,f]),n.updateListener.of(C=>{if(!C.docChanged)return;let T=C.state.doc.toString();this.#m(T),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:T}}))}),n.domEventHandlers({focus:(C,T)=>(this.#n=T.state.doc.toString(),!1),blur:(C,T)=>{let Q=T.state.doc.toString();return this.#n!==null&&Q!==this.#n&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:Q}})),this.#n=null,!1}})),this.#o=new o,A.push(this.#o.of(this.#f(n,r))),e&&A.push(e),this.lineNumbers&&A.push(a()),this.placeholder&&A.push(l(this.placeholder)),this.editable&&i==="json"&&A.push(y,g()),this.#i=new n({parent:E,state:r.create({doc:k,extensions:A})}),this.editable&&this.#m(k)}#f(t,e){return this.editable&&!this.disabled&&!this.readonly?[]:[t.editable.of(!1),e.readOnly.of(!0)]}async#p(){if(!this.#i||!this.#o)return;let t=await Promise.resolve().then(()=>(Db(),Ib));this.#i.dispatch({effects:this.#o.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()}#m(t){this.editable&&(t=t??this.value??"",this.internals.setFormValue(t),this.#g(t))}#g(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.#a}}):this.text=this.#a}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)}#b(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??"")}#O(){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)}}};S("code-ui",ao);$();function s1(s){let t=s.replace(/=""(?=[\s/>])/g,"").replace(/\t/g," ").split(`
204
+ `):e}async#d(){if(this.#r||this.#i)return;let t=this.#s,e=qb(this.language);this.#r=!0;try{let i=await Promise.resolve().then(()=>(Db(),Ib)),r=null;try{r=(await i.importWithTimeout(i.languages[e],`lang-${e}`))?.extension??null}catch(n){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"language",language:e,error:n}}))}if(t!==this.#s||!this.isConnected)return;this.#u(i,r,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.#r=!1}}#u(t,e,i){let{EditorState:r,EditorView:n,Compartment:o,lineNumbers:a,placeholder:l,syntaxHighlighting:h,history:c,historyKeymap:u,defaultKeymap:d,indentWithTab:f,keymap:p,adiaBaseTheme:m,adiaHighlightStyle:b,lintGutter:g,jsonLinter:y}=t,v=this.querySelector(":scope > pre"),w=v?v.querySelector("code")?.textContent??"":"",k=this.text||w||"";this.#a=k;let E=document.createElement("div");E.setAttribute("data-cm-mount",""),v?v.replaceWith(E):this.appendChild(E);let A=[m,h(b)];this.editable&&A.push(c(),p.of([{key:"Mod-s",run:C=>(this.#b(C),!0)},...d,...u,f]),n.updateListener.of(C=>{if(!C.docChanged)return;let T=C.state.doc.toString();this.#m(T),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:T}}))}),n.domEventHandlers({focus:(C,T)=>(this.#n=T.state.doc.toString(),!1),blur:(C,T)=>{let Q=T.state.doc.toString();return this.#n!==null&&Q!==this.#n&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:Q}})),this.#n=null,!1}})),this.#o=new o,A.push(this.#o.of(this.#f(n,r))),e&&A.push(e),this.lineNumbers&&A.push(a()),this.placeholder&&A.push(l(this.placeholder)),this.editable&&i==="json"&&A.push(y,g()),this.#i=new n({parent:E,state:r.create({doc:k,extensions:A})}),this.editable&&this.#m(k)}#f(t,e){return this.editable&&!this.disabled&&!this.readonly?[]:[t.editable.of(!1),e.readOnly.of(!0)]}async#p(){if(!this.#i||!this.#o)return;let t=await Promise.resolve().then(()=>(Db(),Ib));this.#i.dispatch({effects:this.#o.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()}#m(t){this.editable&&(t=t??this.value??"",this.internals.setFormValue(t),this.#g(t))}#g(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.#a}}):this.text=this.#a}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)}#b(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??"")}#y(){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)}}};S("code-ui",ao);$();function s1(s){let t=s.replace(/=""(?=[\s/>])/g,"").replace(/\t/g," ").split(`
205
205
  `);for(;t.length&&t[0].trim()==="";)t.shift();for(;t.length&&t[t.length-1].trim()==="";)t.pop();let e=o=>o.match(/^ */)[0].length,i=t.slice(1).filter(o=>o.trim()),r=(i.length?i:t.filter(o=>o.trim())).map(e),n=r.length?Math.min(...r):0;return t.map(o=>o.slice(Math.min(n,e(o)))).join(`
206
- `)}var lo=class extends x{static properties={layout:{type:String,default:"",reflect:!0},codeFirst:{type:Boolean,default:!1,reflect:!0,attribute:"code-first"},language:{type:String,default:"html",reflect:!0},rows:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e(t,e,i){let r=document.createElement("div");r.setAttribute("data-preview-render",""),r.innerHTML=t;let n=document.createElement("div");n.setAttribute("data-preview-code","");let o=document.createElement("code-ui");return o.setAttribute("language",e),o.textContent=t.replace(/\s+data-chunk(?:-[a-z]+)?="[^"]*"/g,""),n.appendChild(o),i?[n,r]:[r,n]}connected(){if(this.querySelector(":scope > [data-preview-render], :scope > [data-preview-row]"))return;!this.hasAttribute("rows")&&!this.hasAttribute("layout")&&this.setAttribute("layout","split");let t=this.getAttribute("language")||"html",e=this.hasAttribute("code-first");if(this.hasAttribute("rows")){let r=[...this.children],n=[];for(let o of r){let a=o.getAttribute("data-preview-label");a!=null&&o.removeAttribute("data-preview-label");let l=o.hasAttribute("data-preview-unwrap");l&&o.removeAttribute("data-preview-unwrap");let h=s1(l?o.innerHTML:o.outerHTML),c=document.createElement("div");c.setAttribute("data-preview-row","");let u=this.#e(h,t,e);a&&u.find(f=>f.hasAttribute("data-preview-render"))?.setAttribute("data-preview-label",a),c.append(...u),n.push(c)}if(n.length){this.replaceChildren(...n),this.#r();return}}let i=s1(this.innerHTML);this.replaceChildren(...this.#e(i,t,e)),this.#r()}#i=()=>{if(this.hasAttribute("rows"))for(let t of this.querySelectorAll(":scope > [data-preview-row]")){let e=t.querySelector(":scope > [data-preview-render]");e&&e.scrollWidth>e.clientWidth+4&&t.setAttribute("data-stack","")}else if(this.getAttribute("layout")==="split"){let t=this.querySelector(":scope > [data-preview-render]");t&&t.scrollWidth>t.clientWidth+4&&this.setAttribute("layout","stack")}};#s=()=>requestAnimationFrame(this.#i);#r(){this.#s(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(this.#s),this.#t.observe(this))}disconnected(){this.#t?.disconnect()}};S("preview-ui",lo);$();var ho=class extends x{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.#r),this.addEventListener("keydown",this.#n))}disconnected(){this.removeEventListener("click",this.#r),this.removeEventListener("keydown",this.#n),this.#t=!1}render(){if(!this.selectable){for(let r of this.#e())r.removeAttribute("aria-selected"),r.removeAttribute("tabindex");return}let t=this.selectedKey||"",e=this.#e(),i=null;for(let r of e){let n=this.#i(r),o=n&&n===t;r.setAttribute("aria-selected",o?"true":"false"),r.setAttribute("tabindex",o?"0":"-1"),o&&(i=r)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#e(){return[...this.children].filter(t=>t.tagName==="LIST-ITEM-UI"||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(n=>this.#i(n)===t)?.focus?.())}#r=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)};#n=t=>{if(!this.selectable)return;let e=this.#e();if(!e.length)return;let i=document.activeElement,r=e.indexOf(i);if(r<0)return;let n=r;switch(t.key){case"ArrowDown":n=Math.min(e.length-1,r+1);break;case"ArrowUp":n=Math.max(0,r-1);break;case"Home":n=0;break;case"End":n=e.length-1;break;case"Enter":case" ":{t.preventDefault();let o=this.#i(e[r]);o&&this.#s(o);return}default:return}n!==r&&(t.preventDefault(),e[n]?.focus?.())}},co=class extends x{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 r=this.#e(document.createElement("icon-ui"));r.setAttribute("slot","icon"),r.setAttribute("name",this.icon),this.prepend(r)}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 r=this.#e(document.createElement("span"));r.setAttribute("slot","text"),r.textContent=this.text,this.appendChild(r)}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 r=this.#e(document.createElement("span"));r.setAttribute("slot","description"),r.textContent=this.description,this.appendChild(r)}else this.#i(i)&&i.remove()}};S("list-ui",ho),S("list-item-ui",co);$();var uo=class extends x{static properties={items:{type:Array,default:[],reflect:!1},itemSize:{type:Number,default:0,reflect:!0,attribute:"item-size"},itemSizeRem:{type:Number,default:0,reflect:!0,attribute:"item-size-rem"},estimatedSize:{type:Number,default:48,reflect:!0,attribute:"estimated-size"},overscan:{type:Number,default:3,reflect:!0},direction:{type:String,default:"vertical",reflect:!0},pinBottom:{type:Boolean,default:!1,reflect:!0,attribute:"pin-bottom"},startIndex:{type:Number,default:0,reflect:!1,attribute:"start-index"},loading:{type:Boolean,default:!1,reflect:!0}};static parts={phantom:"<div data-phantom></div>",window:"<div data-window></div>",sentinelTop:'<div data-sentinel="top"></div>',sentinelBottom:'<div data-sentinel="bottom"></div>'};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=(t,e)=>t&&typeof t=="object"&&"id"in t?t.id:e;#a=new Map;#o=new Map;#l=1e5;#c=-1;#h=-1;#u=0;#d=!0;#f=null;#p=null;#m=()=>{this.#P();let t=this.#A();this.#u=t,this.#d=this.#E()};#g=t=>{let e=t.target.closest?.("[data-row]");if(!e||e.parentElement!==this.#e)return;let i=Number(e.dataset.index);if(!Number.isInteger(i)||i<0)return;let r=this.items?.[i];r!=null&&this.dispatchEvent(new CustomEvent("item-click",{detail:{item:r,index:i},bubbles:!0}))};#b=t=>{if(t.target!==this)return;let e=this.#w()||this.estimatedSize||48,i=this.#k(),r=0;switch(t.key){case"ArrowDown":r=+e;break;case"ArrowUp":r=-e;break;case"PageDown":r=+i;break;case"PageUp":r=-i;break;case" ":r=+i;break;case"Home":t.preventDefault(),this.scrollToTop();return;case"End":t.preventDefault(),this.scrollToBottom();return;default:return}t.preventDefault();let n=this.#A();this.#C(n+r)};#O=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let r=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:r},bubbles:!0}))}else if(i==="bottom"){let r=this.items||[],n=this.#h>=0?this.#h:r.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:n},bubbles:!0}))}}};#y=t=>{if(this.itemSize>0)return;let e=!1;for(let i of t){let r=i.target;if(!r||r.parentElement!==this.#e)continue;let n=Number(r.dataset.index);if(!Number.isInteger(n))continue;let o=this.direction==="horizontal"?i.contentRect.width:i.contentRect.height,a=Math.max(1,Math.round(o));this.#o.get(n)!==a&&(this.#o.set(n,a),this.dispatchEvent(new CustomEvent("measure",{detail:{index:n,height:a},bubbles:!0})),e=!0)}e&&(this.#X(),this.#T(),this.#P())};connected(){this.setAttribute("role",this.getAttribute("role")||"list"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t=this.ensure("phantom"),this.#e=this.ensure("window"),this.#i=this.ensure("sentinelTop"),this.#s=this.ensure("sentinelBottom"),typeof IntersectionObserver<"u"&&(this.#p=new IntersectionObserver(this.#O,{root:this,rootMargin:"0px",threshold:0}),this.#p.observe(this.#i),this.#p.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#f=new ResizeObserver(this.#y)),this.addEventListener("scroll",this.#m,{passive:!0}),this.addEventListener("click",this.#g),this.addEventListener("keydown",this.#b),this.startIndex>0&&queueMicrotask(()=>this.scrollToIndex(this.startIndex))}disconnected(){this.removeEventListener("scroll",this.#m),this.removeEventListener("click",this.#g),this.removeEventListener("keydown",this.#b),this.#p?.disconnect(),this.#p=null,this.#f?.disconnect(),this.#f=null,this.#a.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#d||this.#E());t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.setAttribute("aria-rowcount",String(t.length)),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.#T(),this.#P(),e&&this.scrollToBottom(),this.#d=this.#E()}set renderRow(t){this.#r=typeof t=="function"?t:null,this.#a.clear(),this.#P()}get renderRow(){return this.#r}set keyFn(t){this.#n=typeof t=="function"?t:((e,i)=>i),this.#a.clear(),this.#P()}get keyFn(){return this.#n}scrollToIndex(t,{behavior:e="auto",align:i="start"}={}){let r=this.items||[];if(!r.length)return;let n=Math.max(0,Math.min(r.length-1,t|0)),o=this.#S(n),a=this.#k(),l=this.#v(n),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#C(Math.max(0,h),e)}scrollToTop(){this.#C(0)}scrollToBottom(){let t=this.#x();this.#C(Math.max(0,t))}getVisibleRange(){return{startIndex:this.#c,endIndex:this.#h}}invalidateMeasurements(t=0){if(t<=0)this.#o.clear();else for(let e of[...this.#o.keys()])e>=t&&this.#o.delete(e);this.#T(),this.#P()}#w(){if(this.itemSize>0)return this.itemSize;if(this.itemSizeRem>0){let t=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return this.itemSizeRem*t}return 0}#v(t){let e=this.#w();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#S(t){let e=this.#w();if(e>0)return t*e;let i=0;for(let r=0;r<t;r++)i+=this.#v(r);return i}#x(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#w();if(i>0)return e*i;let r=0,n=this.estimatedSize||48;for(let o=0;o<e;o++)r+=this.#o.get(o)??n;return r}#k(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#A(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#C(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#E(){let t=this.#A(),e=this.#k(),i=this.#x();return t+e>=i-1}#T(){if(!this.#t)return;let t=this.#x();this.direction==="horizontal"?(this.#t.style.width=`${t}px`,this.#t.style.height="1px"):(this.#t.style.height=`${t}px`,this.#t.style.width="1px")}#Q(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#k(),r=this.#A(),n=this.#w(),o,a;if(n>0)o=Math.floor(r/n),a=Math.ceil((r+i)/n);else{let h=this.estimatedSize||48,c=0;o=0;for(let d=0;d<e;d++){let f=this.#o.get(d)??h;if(c+f>r){o=d;break}c+=f}a=o;let u=0;for(let d=o;d<e;d++){let f=this.#o.get(d)??h;if(u+=f,a=d+1,u>=i)break}}let l=Math.max(0,this.overscan|0);return o=Math.max(0,o-l),a=Math.min(e,a+l),{start:o,end:a}}#P(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=t.length,{start:i,end:r}=this.#Q(),n=this.#S(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${n}px)`:this.#e.style.transform=`translateY(${n}px)`,this.loading?this.#$(r-i):this.#I(t,i,r),(i!==this.#c||r!==this.#h)&&(this.#c=i,this.#h=r,this.dispatchEvent(new CustomEvent("range-change",{detail:{startIndex:i,endIndex:r,items:t.slice(i,r)},bubbles:!0})))}#I(t,e,i){if(!this.#e)return;let r=new Set,n=this.#r??this.#L();for(let l=e;l<i;l++){let h=t[l],c=this.#n(h,l);r.add(c);let u=this.#a.get(c);u?(u.dataset.index=String(l),u.setAttribute("aria-rowindex",String(l+1))):(u=this.#M(h,l,n),this.#a.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#n(h,l),u=this.#a.get(c);u&&o.push(u)}for(let[l,h]of this.#a)r.has(l)||(this.#f?.unobserve(h),h.parentElement===this.#e&&h.remove(),this.#a.delete(l));let a=this.#e.firstChild;for(let l of o)l!==a&&this.#e.insertBefore(l,a),a=l.nextSibling;for(;a;){let l=a.nextSibling;a.remove(),a=l}if(this.itemSize<=0&&this.itemSizeRem<=0&&this.#f)for(let l of o)this.#f.observe(l)}#$(t){if(!this.#e)return;this.#e.replaceChildren(),this.#a.clear();let e=Math.max(1,Math.min(20,t|0||5)),i=this.querySelector(':scope > template[slot="loading"]');for(let r=0;r<e;r++){let n=document.createElement("div");if(n.setAttribute("data-row",""),n.setAttribute("data-skeleton-row",""),n.dataset.index=String(r),i?.content)n.appendChild(i.content.cloneNode(!0));else{let o=document.createElement("skeleton-ui");n.appendChild(o)}this.#e.appendChild(n)}}#M(t,e,i){let r=document.createElement("div");r.setAttribute("data-row",""),r.setAttribute("role","listitem"),r.dataset.index=String(e),r.setAttribute("aria-rowindex",String(e+1));let n=null;if(typeof i=="function")try{n=i(t,e)}catch(o){console.warn("[list-window-ui] render() threw:",o)}if(n instanceof Node)r.appendChild(n);else if(n!=null)r.textContent=String(n);else if(t!=null&&typeof t=="object"&&"text"in t){let o=document.createElement("list-item-ui");o.setAttribute("text",String(t.text)),"description"in t&&o.setAttribute("description",String(t.description)),"icon"in t&&o.setAttribute("icon",String(t.icon)),r.appendChild(o)}else t!=null&&(r.textContent=String(t));return r}#L(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#D==null&&(this.#D=t.innerHTML);let e=this.#D;return(i,r)=>{let n=e.replace(/\$\{item\.([a-zA-Z0-9_]+)\}/g,(a,l)=>{let h=i&&typeof i=="object"?i[l]:"";return h==null?"":FI(String(h))}),o=document.createElement("template");return o.innerHTML=n,o.content.cloneNode(!0)}}#D=null;#X(){if(this.#o.size<=this.#l)return;let t=this.#o.size-this.#l,e=0;for(let i of this.#o.keys())if(this.#o.delete(i),++e>=t)break}};function FI(s){return s.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}S("list-window-ui",uo);$();var fo=class extends x{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;#r=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#d),this.addEventListener("keydown",this.#f))}render(){this.open?this.#a():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#n(){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.#O),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#a(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#n(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui");for(let r of i)e.contains(r)||e.appendChild(r);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=ct(t,e,{placement:this.placement,gap:this.gap}),this.#u&&(this.#u=!1,this.#r=requestAnimationFrame(()=>{this.#r=null,this.#c(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#g),document.addEventListener("keydown",this.#b,!0)})}#o(){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.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),document.removeEventListener("pointerdown",this.#g),document.removeEventListener("keydown",this.#b,!0)}#l(){return Array.from(this.#e?.querySelectorAll("menu-item-ui")??[]).filter(t=>!t.disabled)}#c(t){let e=this.#l();if(!e.length)return;let i=(t+e.length)%e.length,r=e[i];r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#u=!1;#d=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#u=!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.#u=!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}))};#m=t=>{let e=this.#l();if(!e.length)return;let i=this.#h();switch(t.key){case"ArrowDown":t.preventDefault(),this.#c(i+1);break;case"ArrowUp":t.preventDefault(),this.#c(i-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(),(e[i]??e[0])?.click();break}}};#g=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#b=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)};#O=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#O),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},po=class extends x{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.closest('[role="menu"], [role="menubar"]')?(this.setAttribute("role","menuitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")):(this.removeAttribute("role"),this.removeAttribute("tabindex")),this.#s(),this.#r()}#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)}}}#r(){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.#r()}},mo=class extends x{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}};S("menu-ui",fo),S("menu-item-ui",po),S("menu-divider-ui",mo);$();var r1=500,go=class extends x{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:r1,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#r=null;#n=null;#a=null;#o=null;connected(){super.connected(),this.#l()}disconnected(){super.disconnected(),this.#c(),this.#w(),this.#t?.remove(),this.#t=null}openAt(t,e,i=null){if(i??=this.#s[0]??null,!!i){if(this.#n=i,t==null||e==null){let r=i.getBoundingClientRect();t=r.left+r.width/2,e=r.top+r.height/2}this.#O(t,e)}}close(t="manual"){this.#y(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#u),t.addEventListener("touchstart",this.#d,{passive:!0}),t.addEventListener("touchend",this.#f),t.addEventListener("touchcancel",this.#f),t.addEventListener("keydown",this.#p)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#u),t.removeEventListener("touchstart",this.#d),t.removeEventListener("touchend",this.#f),t.removeEventListener("touchcancel",this.#f),t.removeEventListener("keydown",this.#p);this.#s=[]}#h(){if(this.for)try{return[...document.querySelectorAll(this.for)]}catch(t){return console.warn(`[context-menu-ui] invalid [for] selector: ${this.for}`,t),[]}for(let t of this.children){let e=t.tagName.toLowerCase();if(e!=="menu-item-ui"&&e!=="menu-divider-ui")return[t]}return[]}#u=t=>{t.defaultPrevented||this.#m()&&(t.preventDefault(),this.#n=t.currentTarget,this.#O(t.clientX,t.clientY))};#d=t=>{if(!this.#m())return;let e=t.touches[0];e&&(this.#r=setTimeout(()=>{this.#n=t.currentTarget,this.#O(e.clientX,e.clientY)},this.longPressMs??r1))};#f=()=>{this.#r&&clearTimeout(this.#r),this.#r=null};#p=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#m())return;t.preventDefault(),this.#n=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#m(){return[...this.children].some(t=>t.tagName.toLowerCase()==="menu-item-ui")}#g(){if(this.#t)return this.#t;let t=document.createElement("div");return t.setAttribute("data-context-menu-surface",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.setAttribute("aria-label",this.getAttribute("aria-label")||"Context menu"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#x),document.body.appendChild(t),this.#t=t,t}#b(t,e){if(!this.#e){let i=document.createElement("div");i.setAttribute("data-context-menu-anchor",""),i.style.cssText="position:fixed;width:1px;height:1px;pointer-events:none;opacity:0;",document.body.appendChild(i),this.#e=i}return this.#e.style.left=`${t}px`,this.#e.style.top=`${e}px`,this.#e}#O(t,e){let i=this.#g();i.replaceChildren();for(let o of[...this.children]){let a=o.tagName.toLowerCase();(a==="menu-item-ui"||a==="menu-divider-ui")&&i.appendChild(o.cloneNode(!0))}try{i.showPopover()}catch{}let r=this.#b(t,e);this.#i?.(),this.#i=ct(r,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#v();let n=i.querySelector("menu-item-ui:not([disabled])");queueMicrotask(()=>n?.focus?.()),this.dispatchEvent(new CustomEvent("context-menu-open",{bubbles:!0,detail:{target:this.#n,x:t,y:e}}))}#y(t="manual"){if(this.open){this.open=!1,this.#w(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#n?.focus?.()}catch{}}}#w(){this.#S(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#v(){this.#a=t=>{this.#t?.contains(t.target)||this.#y("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#S(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#x=t=>{let e=t.target.closest("menu-item-ui");if(!e||e.hasAttribute("disabled"))return;let i=e.getAttribute("value")||"",r=e.getAttribute("text")||e.textContent.trim();this.dispatchEvent(new CustomEvent("context-menu-select",{bubbles:!0,detail:{value:i,text:r}})),this.#y("select")}};S("context-menu-ui",go);$();var bo=class extends x{static properties={};static template=()=>null};S("visually-hidden-ui",bo);$();var Oo=class extends x{static properties={target:{type:String,default:"#main",reflect:!0},text:{type:String,default:"Skip to main content",reflect:!0}};static template=({target:t,text:e})=>it`<a href="${t}" data-skip-link>${e}</a>`;connected(){super.connected(),this.addEventListener("click",this.#t)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t)}#t=t=>{if(!t.target.closest("[data-skip-link]"))return;let i=this.target.replace(/^#/,""),r=document.getElementById(i);r&&queueMicrotask(()=>{r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus({preventScroll:!1})})}};S("skip-nav-ui",Oo);$();var yo=class extends x{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};S("mark-ui",yo);var vo=class extends M{static properties={...M.properties,placeholder:{type:String,default:"Click to edit",reflect:!0},editing:{type:Boolean,default:!1,reflect:!0},commit:{type:String,default:"blur",reflect:!0}};static template=()=>null;#t="";#e=!1;#i=!1;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","textbox"),!this.hasAttribute("tabindex")&&!this.disabled&&this.setAttribute("tabindex","0"),this.value&&this.textContent.trim()===""?this.textContent=this.value:!this.value&&this.textContent.trim()&&(this.value=this.textContent.trim(),this.syncValue()),this.#e||(this.#e=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#r),this.addEventListener("focus",this.#n),this.addEventListener("blur",this.#a))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#r),this.removeEventListener("focus",this.#n),this.removeEventListener("blur",this.#a),this.#e=!1}startEdit(){this.editing||this.disabled||this.readonly||(this.#t=this.value||"",this.editing=!0,this.setAttribute("contenteditable","plaintext-only"),this.dispatchEvent(new CustomEvent("edit-start",{bubbles:!0})),queueMicrotask(()=>{this.focus(),this.#o()}))}commitEdit(){if(!this.editing)return;let t=(this.textContent||"").trim(),e=this.#t;this.editing=!1,this.removeAttribute("contenteditable"),this.textContent!==t&&(this.textContent=t),t!==e&&(this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,oldValue:e}}))),this.dispatchEvent(new CustomEvent("edit-end",{bubbles:!0,detail:{committed:!0}}))}cancelEdit(){this.editing&&(this.editing=!1,this.removeAttribute("contenteditable"),this.textContent=this.#t,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0})),this.dispatchEvent(new CustomEvent("edit-end",{bubbles:!0,detail:{committed:!1}})))}#s=t=>{this.disabled||this.readonly||this.editing||(t.preventDefault(),this.startEdit())};#r=t=>{if(this.editing)t.key==="Enter"?(t.preventDefault(),this.#i=!0,this.commitEdit(),this.blur()):t.key==="Escape"&&(t.preventDefault(),this.#i=!0,this.cancelEdit(),this.blur());else if(t.key==="Enter"||t.key===" "){if(this.disabled||this.readonly)return;t.preventDefault(),this.startEdit()}};#n=()=>{};#a=()=>{if(this.editing){if(this.#i){this.#i=!1;return}this.commit==="blur"?this.commitEdit():this.commit==="enter"&&this.cancelEdit()}};#o(){let t=document.createRange();t.selectNodeContents(this);let e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(t))}};S("inline-edit-ui",vo);$();var xo=class extends x{static properties={active:{type:Boolean,default:!1,reflect:!0},step:{type:Number,default:0,reflect:!1},autoStart:{type:Boolean,default:!1,reflect:!0,attribute:"auto-start"},storageKey:{type:String,default:"",reflect:!0,attribute:"storage-key"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){super.connected(),this.autoStart&&!this.#o()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#a.length){console.warn("[tour-ui] start() called with no <tour-step> children \u2014 nothing to render.");return}this.step=0,this.active=!0,this.#c(),this.#u(),this.dispatchEvent(new CustomEvent("tour-start",{bubbles:!0,detail:{step:0}}))}}next(){if(!this.active)return;let t=this.#a.length;if(this.step>=t-1){this.finish();return}let e=this.step;this.step=e+1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:e,to:this.step,totalSteps:t}}))}previous(){if(!this.active||this.step<=0)return;let t=this.step;this.step=t-1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:t,to:this.step,totalSteps:this.#a.length}}))}skip(){if(!this.active)return;let t=this.#a.length,e=this.step;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-skip",{bubbles:!0,detail:{step:e,totalSteps:t}}))}finish(){if(!this.active)return;let t=this.#a.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#a(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#o(){if(!this.storageKey)return!1;try{return localStorage.getItem(this.storageKey)==="done"}catch{return!1}}#l(){if(this.storageKey)try{localStorage.setItem(this.storageKey,"done")}catch{}}#c(){if(!this.#t){let t=document.createElement("div");t.setAttribute("data-tour-spotlight",""),t.setAttribute("aria-hidden","true"),document.body.appendChild(t),this.#t=t}if(!this.#e){let t=document.createElement("div");t.setAttribute("data-tour-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#p),document.body.appendChild(t),this.#e=t}this.#s=()=>this.#f(),this.#r=()=>this.#f(),window.addEventListener("resize",this.#s),window.addEventListener("scroll",this.#r,!0),this.#n=t=>{this.active&&(t.key==="Escape"?(t.preventDefault(),this.skip()):t.key==="ArrowRight"?(t.preventDefault(),this.next()):t.key==="ArrowLeft"&&(t.preventDefault(),this.previous()))},document.addEventListener("keydown",this.#n)}#h(){this.#i?.(),this.#i=null,this.#s&&window.removeEventListener("resize",this.#s),this.#r&&window.removeEventListener("scroll",this.#r,!0),this.#n&&document.removeEventListener("keydown",this.#n),this.#s=this.#r=this.#n=null;try{this.#e?.hidePopover?.()}catch{}this.#e?.removeEventListener("click",this.#p),this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null}#u(){let t=this.#a[this.step];if(!t)return;let e=this.#a.length,i=this.step===e-1,r=this.step===0,n=t.getAttribute("title")||"",o=t.getAttribute("placement")||"bottom",a=t.getAttribute("target")||"",l=a?document.querySelector(a):null;this.#d=l,this.#f();let h=`${this.step+1} of ${e}`,c=t.innerHTML;this.#e.innerHTML=`
206
+ `)}var lo=class extends x{static properties={layout:{type:String,default:"",reflect:!0},codeFirst:{type:Boolean,default:!1,reflect:!0,attribute:"code-first"},language:{type:String,default:"html",reflect:!0},rows:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e(t,e,i){let r=document.createElement("div");r.setAttribute("data-preview-render",""),r.innerHTML=t;let n=document.createElement("div");n.setAttribute("data-preview-code","");let o=document.createElement("code-ui");return o.setAttribute("language",e),o.textContent=t.replace(/\s+data-chunk(?:-[a-z]+)?="[^"]*"/g,""),n.appendChild(o),i?[n,r]:[r,n]}connected(){if(this.querySelector(":scope > [data-preview-render], :scope > [data-preview-row]"))return;!this.hasAttribute("rows")&&!this.hasAttribute("layout")&&this.setAttribute("layout","split");let t=this.getAttribute("language")||"html",e=this.hasAttribute("code-first");if(this.hasAttribute("rows")){let r=[...this.children],n=[];for(let o of r){let a=o.getAttribute("data-preview-label");a!=null&&o.removeAttribute("data-preview-label");let l=o.hasAttribute("data-preview-unwrap");l&&o.removeAttribute("data-preview-unwrap");let h=s1(l?o.innerHTML:o.outerHTML),c=document.createElement("div");c.setAttribute("data-preview-row","");let u=this.#e(h,t,e);a&&u.find(f=>f.hasAttribute("data-preview-render"))?.setAttribute("data-preview-label",a),c.append(...u),n.push(c)}if(n.length){this.replaceChildren(...n),this.#r();return}}let i=s1(this.innerHTML);this.replaceChildren(...this.#e(i,t,e)),this.#r()}#i=()=>{if(this.hasAttribute("rows"))for(let t of this.querySelectorAll(":scope > [data-preview-row]")){let e=t.querySelector(":scope > [data-preview-render]");e&&e.scrollWidth>e.clientWidth+4&&t.setAttribute("data-stack","")}else if(this.getAttribute("layout")==="split"){let t=this.querySelector(":scope > [data-preview-render]");t&&t.scrollWidth>t.clientWidth+4&&this.setAttribute("layout","stack")}};#s=()=>requestAnimationFrame(this.#i);#r(){this.#s(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(this.#s),this.#t.observe(this))}disconnected(){this.#t?.disconnect()}};S("preview-ui",lo);$();var ho=class extends x{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.#r),this.addEventListener("keydown",this.#n))}disconnected(){this.removeEventListener("click",this.#r),this.removeEventListener("keydown",this.#n),this.#t=!1}render(){if(!this.selectable){for(let r of this.#e())r.removeAttribute("aria-selected"),r.removeAttribute("tabindex");return}let t=this.selectedKey||"",e=this.#e(),i=null;for(let r of e){let n=this.#i(r),o=n&&n===t;r.setAttribute("aria-selected",o?"true":"false"),r.setAttribute("tabindex",o?"0":"-1"),o&&(i=r)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#e(){return[...this.children].filter(t=>t.tagName==="LIST-ITEM-UI"||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(n=>this.#i(n)===t)?.focus?.())}#r=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)};#n=t=>{if(!this.selectable)return;let e=this.#e();if(!e.length)return;let i=document.activeElement,r=e.indexOf(i);if(r<0)return;let n=r;switch(t.key){case"ArrowDown":n=Math.min(e.length-1,r+1);break;case"ArrowUp":n=Math.max(0,r-1);break;case"Home":n=0;break;case"End":n=e.length-1;break;case"Enter":case" ":{t.preventDefault();let o=this.#i(e[r]);o&&this.#s(o);return}default:return}n!==r&&(t.preventDefault(),e[n]?.focus?.())}},co=class extends x{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 r=this.#e(document.createElement("icon-ui"));r.setAttribute("slot","icon"),r.setAttribute("name",this.icon),this.prepend(r)}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 r=this.#e(document.createElement("span"));r.setAttribute("slot","text"),r.textContent=this.text,this.appendChild(r)}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 r=this.#e(document.createElement("span"));r.setAttribute("slot","description"),r.textContent=this.description,this.appendChild(r)}else this.#i(i)&&i.remove()}};S("list-ui",ho),S("list-item-ui",co);$();var uo=class extends x{static properties={items:{type:Array,default:[],reflect:!1},itemSize:{type:Number,default:0,reflect:!0,attribute:"item-size"},itemSizeRem:{type:Number,default:0,reflect:!0,attribute:"item-size-rem"},estimatedSize:{type:Number,default:48,reflect:!0,attribute:"estimated-size"},overscan:{type:Number,default:3,reflect:!0},direction:{type:String,default:"vertical",reflect:!0},pinBottom:{type:Boolean,default:!1,reflect:!0,attribute:"pin-bottom"},startIndex:{type:Number,default:0,reflect:!1,attribute:"start-index"},loading:{type:Boolean,default:!1,reflect:!0}};static parts={phantom:"<div data-phantom></div>",window:"<div data-window></div>",sentinelTop:'<div data-sentinel="top"></div>',sentinelBottom:'<div data-sentinel="bottom"></div>'};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=(t,e)=>t&&typeof t=="object"&&"id"in t?t.id:e;#a=new Map;#o=new Map;#l=1e5;#c=-1;#h=-1;#d=0;#u=!0;#f=null;#p=null;#m=()=>{this.#P();let t=this.#A();this.#d=t,this.#u=this.#E()};#g=t=>{let e=t.target.closest?.("[data-row]");if(!e||e.parentElement!==this.#e)return;let i=Number(e.dataset.index);if(!Number.isInteger(i)||i<0)return;let r=this.items?.[i];r!=null&&this.dispatchEvent(new CustomEvent("item-click",{detail:{item:r,index:i},bubbles:!0}))};#b=t=>{if(t.target!==this)return;let e=this.#S()||this.estimatedSize||48,i=this.#k(),r=0;switch(t.key){case"ArrowDown":r=+e;break;case"ArrowUp":r=-e;break;case"PageDown":r=+i;break;case"PageUp":r=-i;break;case" ":r=+i;break;case"Home":t.preventDefault(),this.scrollToTop();return;case"End":t.preventDefault(),this.scrollToBottom();return;default:return}t.preventDefault();let n=this.#A();this.#C(n+r)};#y=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let r=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:r},bubbles:!0}))}else if(i==="bottom"){let r=this.items||[],n=this.#h>=0?this.#h:r.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:n},bubbles:!0}))}}};#O=t=>{if(this.itemSize>0)return;let e=!1;for(let i of t){let r=i.target;if(!r||r.parentElement!==this.#e)continue;let n=Number(r.dataset.index);if(!Number.isInteger(n))continue;let o=this.direction==="horizontal"?i.contentRect.width:i.contentRect.height,a=Math.max(1,Math.round(o));this.#o.get(n)!==a&&(this.#o.set(n,a),this.dispatchEvent(new CustomEvent("measure",{detail:{index:n,height:a},bubbles:!0})),e=!0)}e&&(this.#X(),this.#T(),this.#P())};connected(){this.setAttribute("role",this.getAttribute("role")||"list"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t=this.ensure("phantom"),this.#e=this.ensure("window"),this.#i=this.ensure("sentinelTop"),this.#s=this.ensure("sentinelBottom"),typeof IntersectionObserver<"u"&&(this.#p=new IntersectionObserver(this.#y,{root:this,rootMargin:"0px",threshold:0}),this.#p.observe(this.#i),this.#p.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#f=new ResizeObserver(this.#O)),this.addEventListener("scroll",this.#m,{passive:!0}),this.addEventListener("click",this.#g),this.addEventListener("keydown",this.#b),this.startIndex>0&&queueMicrotask(()=>this.scrollToIndex(this.startIndex))}disconnected(){this.removeEventListener("scroll",this.#m),this.removeEventListener("click",this.#g),this.removeEventListener("keydown",this.#b),this.#p?.disconnect(),this.#p=null,this.#f?.disconnect(),this.#f=null,this.#a.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#u||this.#E());t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.setAttribute("aria-rowcount",String(t.length)),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.#T(),this.#P(),e&&this.scrollToBottom(),this.#u=this.#E()}set renderRow(t){this.#r=typeof t=="function"?t:null,this.#a.clear(),this.#P()}get renderRow(){return this.#r}set keyFn(t){this.#n=typeof t=="function"?t:((e,i)=>i),this.#a.clear(),this.#P()}get keyFn(){return this.#n}scrollToIndex(t,{behavior:e="auto",align:i="start"}={}){let r=this.items||[];if(!r.length)return;let n=Math.max(0,Math.min(r.length-1,t|0)),o=this.#w(n),a=this.#k(),l=this.#v(n),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#C(Math.max(0,h),e)}scrollToTop(){this.#C(0)}scrollToBottom(){let t=this.#x();this.#C(Math.max(0,t))}getVisibleRange(){return{startIndex:this.#c,endIndex:this.#h}}invalidateMeasurements(t=0){if(t<=0)this.#o.clear();else for(let e of[...this.#o.keys()])e>=t&&this.#o.delete(e);this.#T(),this.#P()}#S(){if(this.itemSize>0)return this.itemSize;if(this.itemSizeRem>0){let t=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return this.itemSizeRem*t}return 0}#v(t){let e=this.#S();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#w(t){let e=this.#S();if(e>0)return t*e;let i=0;for(let r=0;r<t;r++)i+=this.#v(r);return i}#x(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#S();if(i>0)return e*i;let r=0,n=this.estimatedSize||48;for(let o=0;o<e;o++)r+=this.#o.get(o)??n;return r}#k(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#A(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#C(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#E(){let t=this.#A(),e=this.#k(),i=this.#x();return t+e>=i-1}#T(){if(!this.#t)return;let t=this.#x();this.direction==="horizontal"?(this.#t.style.width=`${t}px`,this.#t.style.height="1px"):(this.#t.style.height=`${t}px`,this.#t.style.width="1px")}#Q(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#k(),r=this.#A(),n=this.#S(),o,a;if(n>0)o=Math.floor(r/n),a=Math.ceil((r+i)/n);else{let h=this.estimatedSize||48,c=0;o=0;for(let d=0;d<e;d++){let f=this.#o.get(d)??h;if(c+f>r){o=d;break}c+=f}a=o;let u=0;for(let d=o;d<e;d++){let f=this.#o.get(d)??h;if(u+=f,a=d+1,u>=i)break}}let l=Math.max(0,this.overscan|0);return o=Math.max(0,o-l),a=Math.min(e,a+l),{start:o,end:a}}#P(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=t.length,{start:i,end:r}=this.#Q(),n=this.#w(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${n}px)`:this.#e.style.transform=`translateY(${n}px)`,this.loading?this.#$(r-i):this.#I(t,i,r),(i!==this.#c||r!==this.#h)&&(this.#c=i,this.#h=r,this.dispatchEvent(new CustomEvent("range-change",{detail:{startIndex:i,endIndex:r,items:t.slice(i,r)},bubbles:!0})))}#I(t,e,i){if(!this.#e)return;let r=new Set,n=this.#r??this.#L();for(let l=e;l<i;l++){let h=t[l],c=this.#n(h,l);r.add(c);let u=this.#a.get(c);u?(u.dataset.index=String(l),u.setAttribute("aria-rowindex",String(l+1))):(u=this.#M(h,l,n),this.#a.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#n(h,l),u=this.#a.get(c);u&&o.push(u)}for(let[l,h]of this.#a)r.has(l)||(this.#f?.unobserve(h),h.parentElement===this.#e&&h.remove(),this.#a.delete(l));let a=this.#e.firstChild;for(let l of o)l!==a&&this.#e.insertBefore(l,a),a=l.nextSibling;for(;a;){let l=a.nextSibling;a.remove(),a=l}if(this.itemSize<=0&&this.itemSizeRem<=0&&this.#f)for(let l of o)this.#f.observe(l)}#$(t){if(!this.#e)return;this.#e.replaceChildren(),this.#a.clear();let e=Math.max(1,Math.min(20,t|0||5)),i=this.querySelector(':scope > template[slot="loading"]');for(let r=0;r<e;r++){let n=document.createElement("div");if(n.setAttribute("data-row",""),n.setAttribute("data-skeleton-row",""),n.dataset.index=String(r),i?.content)n.appendChild(i.content.cloneNode(!0));else{let o=document.createElement("skeleton-ui");n.appendChild(o)}this.#e.appendChild(n)}}#M(t,e,i){let r=document.createElement("div");r.setAttribute("data-row",""),r.setAttribute("role","listitem"),r.dataset.index=String(e),r.setAttribute("aria-rowindex",String(e+1));let n=null;if(typeof i=="function")try{n=i(t,e)}catch(o){console.warn("[list-window-ui] render() threw:",o)}if(n instanceof Node)r.appendChild(n);else if(n!=null)r.textContent=String(n);else if(t!=null&&typeof t=="object"&&"text"in t){let o=document.createElement("list-item-ui");o.setAttribute("text",String(t.text)),"description"in t&&o.setAttribute("description",String(t.description)),"icon"in t&&o.setAttribute("icon",String(t.icon)),r.appendChild(o)}else t!=null&&(r.textContent=String(t));return r}#L(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#D==null&&(this.#D=t.innerHTML);let e=this.#D;return(i,r)=>{let n=e.replace(/\$\{item\.([a-zA-Z0-9_]+)\}/g,(a,l)=>{let h=i&&typeof i=="object"?i[l]:"";return h==null?"":FI(String(h))}),o=document.createElement("template");return o.innerHTML=n,o.content.cloneNode(!0)}}#D=null;#X(){if(this.#o.size<=this.#l)return;let t=this.#o.size-this.#l,e=0;for(let i of this.#o.keys())if(this.#o.delete(i),++e>=t)break}};function FI(s){return s.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}S("list-window-ui",uo);$();var fo=class extends x{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;#r=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#u),this.addEventListener("keydown",this.#f))}render(){this.open?this.#a():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#n(){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.#y),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#a(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#n(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui");for(let r of i)e.contains(r)||e.appendChild(r);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=ct(t,e,{placement:this.placement,gap:this.gap}),this.#d&&(this.#d=!1,this.#r=requestAnimationFrame(()=>{this.#r=null,this.#c(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#g),document.addEventListener("keydown",this.#b,!0)})}#o(){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.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),document.removeEventListener("pointerdown",this.#g),document.removeEventListener("keydown",this.#b,!0)}#l(){return Array.from(this.#e?.querySelectorAll("menu-item-ui")??[]).filter(t=>!t.disabled)}#c(t){let e=this.#l();if(!e.length)return;let i=(t+e.length)%e.length,r=e[i];r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#d=!1;#u=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#d=!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.#d=!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}))};#m=t=>{let e=this.#l();if(!e.length)return;let i=this.#h();switch(t.key){case"ArrowDown":t.preventDefault(),this.#c(i+1);break;case"ArrowUp":t.preventDefault(),this.#c(i-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(),(e[i]??e[0])?.click();break}}};#g=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#b=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)};#y=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#y),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},po=class extends x{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.closest('[role="menu"], [role="menubar"]')?(this.setAttribute("role","menuitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")):(this.removeAttribute("role"),this.removeAttribute("tabindex")),this.#s(),this.#r()}#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)}}}#r(){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.#r()}},mo=class extends x{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}};S("menu-ui",fo),S("menu-item-ui",po),S("menu-divider-ui",mo);$();var r1=500,go=class extends x{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:r1,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#r=null;#n=null;#a=null;#o=null;connected(){super.connected(),this.#l()}disconnected(){super.disconnected(),this.#c(),this.#S(),this.#t?.remove(),this.#t=null}openAt(t,e,i=null){if(i??=this.#s[0]??null,!!i){if(this.#n=i,t==null||e==null){let r=i.getBoundingClientRect();t=r.left+r.width/2,e=r.top+r.height/2}this.#y(t,e)}}close(t="manual"){this.#O(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#d),t.addEventListener("touchstart",this.#u,{passive:!0}),t.addEventListener("touchend",this.#f),t.addEventListener("touchcancel",this.#f),t.addEventListener("keydown",this.#p)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#d),t.removeEventListener("touchstart",this.#u),t.removeEventListener("touchend",this.#f),t.removeEventListener("touchcancel",this.#f),t.removeEventListener("keydown",this.#p);this.#s=[]}#h(){if(this.for)try{return[...document.querySelectorAll(this.for)]}catch(t){return console.warn(`[context-menu-ui] invalid [for] selector: ${this.for}`,t),[]}for(let t of this.children){let e=t.tagName.toLowerCase();if(e!=="menu-item-ui"&&e!=="menu-divider-ui")return[t]}return[]}#d=t=>{t.defaultPrevented||this.#m()&&(t.preventDefault(),this.#n=t.currentTarget,this.#y(t.clientX,t.clientY))};#u=t=>{if(!this.#m())return;let e=t.touches[0];e&&(this.#r=setTimeout(()=>{this.#n=t.currentTarget,this.#y(e.clientX,e.clientY)},this.longPressMs??r1))};#f=()=>{this.#r&&clearTimeout(this.#r),this.#r=null};#p=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#m())return;t.preventDefault(),this.#n=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#m(){return[...this.children].some(t=>t.tagName.toLowerCase()==="menu-item-ui")}#g(){if(this.#t)return this.#t;let t=document.createElement("div");return t.setAttribute("data-context-menu-surface",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.setAttribute("aria-label",this.getAttribute("aria-label")||"Context menu"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#x),document.body.appendChild(t),this.#t=t,t}#b(t,e){if(!this.#e){let i=document.createElement("div");i.setAttribute("data-context-menu-anchor",""),i.style.cssText="position:fixed;width:1px;height:1px;pointer-events:none;opacity:0;",document.body.appendChild(i),this.#e=i}return this.#e.style.left=`${t}px`,this.#e.style.top=`${e}px`,this.#e}#y(t,e){let i=this.#g();i.replaceChildren();for(let o of[...this.children]){let a=o.tagName.toLowerCase();(a==="menu-item-ui"||a==="menu-divider-ui")&&i.appendChild(o.cloneNode(!0))}try{i.showPopover()}catch{}let r=this.#b(t,e);this.#i?.(),this.#i=ct(r,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#v();let n=i.querySelector("menu-item-ui:not([disabled])");queueMicrotask(()=>n?.focus?.()),this.dispatchEvent(new CustomEvent("context-menu-open",{bubbles:!0,detail:{target:this.#n,x:t,y:e}}))}#O(t="manual"){if(this.open){this.open=!1,this.#S(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#n?.focus?.()}catch{}}}#S(){this.#w(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#v(){this.#a=t=>{this.#t?.contains(t.target)||this.#O("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#O("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#w(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#x=t=>{let e=t.target.closest("menu-item-ui");if(!e||e.hasAttribute("disabled"))return;let i=e.getAttribute("value")||"",r=e.getAttribute("text")||e.textContent.trim();this.dispatchEvent(new CustomEvent("context-menu-select",{bubbles:!0,detail:{value:i,text:r}})),this.#O("select")}};S("context-menu-ui",go);$();var bo=class extends x{static properties={};static template=()=>null};S("visually-hidden-ui",bo);$();var Oo=class extends x{static properties={target:{type:String,default:"#main",reflect:!0},text:{type:String,default:"Skip to main content",reflect:!0}};static template=({target:t,text:e})=>it`<a href="${t}" data-skip-link>${e}</a>`;connected(){super.connected(),this.addEventListener("click",this.#t)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t)}#t=t=>{if(!t.target.closest("[data-skip-link]"))return;let i=this.target.replace(/^#/,""),r=document.getElementById(i);r&&queueMicrotask(()=>{r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus({preventScroll:!1})})}};S("skip-nav-ui",Oo);$();var yo=class extends x{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};S("mark-ui",yo);var vo=class extends M{static properties={...M.properties,placeholder:{type:String,default:"Click to edit",reflect:!0},editing:{type:Boolean,default:!1,reflect:!0},commit:{type:String,default:"blur",reflect:!0}};static template=()=>null;#t="";#e=!1;#i=!1;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","textbox"),!this.hasAttribute("tabindex")&&!this.disabled&&this.setAttribute("tabindex","0"),this.value&&this.textContent.trim()===""?this.textContent=this.value:!this.value&&this.textContent.trim()&&(this.value=this.textContent.trim(),this.syncValue()),this.#e||(this.#e=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#r),this.addEventListener("focus",this.#n),this.addEventListener("blur",this.#a))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#r),this.removeEventListener("focus",this.#n),this.removeEventListener("blur",this.#a),this.#e=!1}startEdit(){this.editing||this.disabled||this.readonly||(this.#t=this.value||"",this.editing=!0,this.setAttribute("contenteditable","plaintext-only"),this.dispatchEvent(new CustomEvent("edit-start",{bubbles:!0})),queueMicrotask(()=>{this.focus(),this.#o()}))}commitEdit(){if(!this.editing)return;let t=(this.textContent||"").trim(),e=this.#t;this.editing=!1,this.removeAttribute("contenteditable"),this.textContent!==t&&(this.textContent=t),t!==e&&(this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,oldValue:e}}))),this.dispatchEvent(new CustomEvent("edit-end",{bubbles:!0,detail:{committed:!0}}))}cancelEdit(){this.editing&&(this.editing=!1,this.removeAttribute("contenteditable"),this.textContent=this.#t,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0})),this.dispatchEvent(new CustomEvent("edit-end",{bubbles:!0,detail:{committed:!1}})))}#s=t=>{this.disabled||this.readonly||this.editing||(t.preventDefault(),this.startEdit())};#r=t=>{if(this.editing)t.key==="Enter"?(t.preventDefault(),this.#i=!0,this.commitEdit(),this.blur()):t.key==="Escape"&&(t.preventDefault(),this.#i=!0,this.cancelEdit(),this.blur());else if(t.key==="Enter"||t.key===" "){if(this.disabled||this.readonly)return;t.preventDefault(),this.startEdit()}};#n=()=>{};#a=()=>{if(this.editing){if(this.#i){this.#i=!1;return}this.commit==="blur"?this.commitEdit():this.commit==="enter"&&this.cancelEdit()}};#o(){let t=document.createRange();t.selectNodeContents(this);let e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(t))}};S("inline-edit-ui",vo);$();var xo=class extends x{static properties={active:{type:Boolean,default:!1,reflect:!0},step:{type:Number,default:0,reflect:!1},autoStart:{type:Boolean,default:!1,reflect:!0,attribute:"auto-start"},storageKey:{type:String,default:"",reflect:!0,attribute:"storage-key"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){super.connected(),this.autoStart&&!this.#o()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#a.length){console.warn("[tour-ui] start() called with no <tour-step> children \u2014 nothing to render.");return}this.step=0,this.active=!0,this.#c(),this.#d(),this.dispatchEvent(new CustomEvent("tour-start",{bubbles:!0,detail:{step:0}}))}}next(){if(!this.active)return;let t=this.#a.length;if(this.step>=t-1){this.finish();return}let e=this.step;this.step=e+1,this.#d(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:e,to:this.step,totalSteps:t}}))}previous(){if(!this.active||this.step<=0)return;let t=this.step;this.step=t-1,this.#d(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:t,to:this.step,totalSteps:this.#a.length}}))}skip(){if(!this.active)return;let t=this.#a.length,e=this.step;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-skip",{bubbles:!0,detail:{step:e,totalSteps:t}}))}finish(){if(!this.active)return;let t=this.#a.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#a(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#o(){if(!this.storageKey)return!1;try{return localStorage.getItem(this.storageKey)==="done"}catch{return!1}}#l(){if(this.storageKey)try{localStorage.setItem(this.storageKey,"done")}catch{}}#c(){if(!this.#t){let t=document.createElement("div");t.setAttribute("data-tour-spotlight",""),t.setAttribute("aria-hidden","true"),document.body.appendChild(t),this.#t=t}if(!this.#e){let t=document.createElement("div");t.setAttribute("data-tour-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#p),document.body.appendChild(t),this.#e=t}this.#s=()=>this.#f(),this.#r=()=>this.#f(),window.addEventListener("resize",this.#s),window.addEventListener("scroll",this.#r,!0),this.#n=t=>{this.active&&(t.key==="Escape"?(t.preventDefault(),this.skip()):t.key==="ArrowRight"?(t.preventDefault(),this.next()):t.key==="ArrowLeft"&&(t.preventDefault(),this.previous()))},document.addEventListener("keydown",this.#n)}#h(){this.#i?.(),this.#i=null,this.#s&&window.removeEventListener("resize",this.#s),this.#r&&window.removeEventListener("scroll",this.#r,!0),this.#n&&document.removeEventListener("keydown",this.#n),this.#s=this.#r=this.#n=null;try{this.#e?.hidePopover?.()}catch{}this.#e?.removeEventListener("click",this.#p),this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null}#d(){let t=this.#a[this.step];if(!t)return;let e=this.#a.length,i=this.step===e-1,r=this.step===0,n=t.getAttribute("title")||"",o=t.getAttribute("placement")||"bottom",a=t.getAttribute("target")||"",l=a?document.querySelector(a):null;this.#u=l,this.#f();let h=`${this.step+1} of ${e}`,c=t.innerHTML;this.#e.innerHTML=`
207
207
  <div data-tour-header>
208
208
  <span data-tour-indicator>${h}</span>
209
209
  <span></span>
@@ -217,7 +217,7 @@ Correct shape for <chart-ui x="label" y="value">:
217
217
  <button-ui data-tour-next variant="primary" size="sm" text="${i?"Done":"Next \u2192"}"></button-ui>
218
218
  </div>
219
219
  </div>
220
- `;try{this.#e.showPopover()}catch{}this.#i?.(),l?this.#i=ct(l,this.#e,{placement:o,gap:12}):(this.#e.style.position="fixed",this.#e.style.top="50%",this.#e.style.left="50%",this.#e.style.transform="translate(-50%, -50%)"),queueMicrotask(()=>this.#e?.focus?.())}#d=null;#f(){if(!this.#t)return;let t=this.#d;if(!t){this.#t.setAttribute("data-tour-no-target","");return}this.#t.removeAttribute("data-tour-no-target");let e=t.getBoundingClientRect(),i=getComputedStyle(this),r=parseFloat(i.getPropertyValue("--tour-spotlight-padding"))||8,n=Math.max(0,e.top-r),o=Math.max(0,e.left-r),a=e.width+r*2,l=e.height+r*2;this.#t.style.top=`${n}px`,this.#t.style.left=`${o}px`,this.#t.style.width=`${a}px`,this.#t.style.height=`${l}px`}#p=t=>{let e=t.target;if(!(!e||!e.closest)){if(e.closest("[data-tour-skip]")){this.skip();return}if(e.closest("[data-tour-previous]")){this.previous();return}if(e.closest("[data-tour-next]")){this.next();return}}}},So=class extends x{static properties={target:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null};function YI(s){return String(s??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}S("tour-ui",xo),S("tour-step-ui",So);$();var n1="data-toolbar-spillover",HI="data-toolbar-spillover-menu",o1=8,Ju="data-toolbar-spillover-label";function a1(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function GI(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function KI(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(Ju)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||GI(e.getAttribute("icon"));i&&(e.setAttribute(Ju,""),e.setAttribute("text",i))}}function JI(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(Ju)&&(e.removeAttribute(Ju),e.removeAttribute("text"))}function l1(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,r=parseFloat(e.marginRight)||0;return t.width+i+r}var wo=class extends x{static properties={gap:{type:String,default:"sm",reflect:!0},align:{type:String,default:"start",reflect:!0},overflow:{type:String,default:"menu",reflect:!0},bordered:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=!1;#o=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#c(),this.#t=new ResizeObserver(()=>this.#b()),this.#t.observe(this),this.#e=new MutationObserver(()=>{this.#n||this.#b()}),this.#O(),this.#b()}disconnected(){this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.#a=!1,this.#t?.disconnect(),this.#e?.disconnect(),this.#u(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}#c(){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(n1,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(HI,""),e.setAttribute("popover","manual"),e.setAttribute("role","menu"),t.addEventListener("click",this.#d),e.addEventListener("click",this.#f),e.addEventListener("toggle",this.#g),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.#r?.(),this.#r=ct(this.#i,t,{placement:"bottom-end",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#p,!0),document.addEventListener("keydown",this.#m,!0)}))}#u(){this.#r?.(),this.#r=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.#m,!0)}#d=t=>{t.stopPropagation(),this.#s?.matches(":popover-open")?this.#u():this.#h()};#f=t=>{let e=t.target.closest("button-ui");e&&(e.matches(`[${n1}]`)||queueMicrotask(()=>this.#u()))};#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.#u()};#m=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#u(),this.#i?.focus?.({preventScroll:!0}))};#g=t=>{t.newState==="closed"&&(this.#r?.(),this.#r=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0))};#b(){this.#a||(this.#a=!0,this.#o=requestAnimationFrame(()=>{this.#o=null,this.#a=!1,this.isConnected&&this.#w()}))}#O(){this.#e?.observe(this,{childList:!0})}#y(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#w(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#n=!0,this.#y();try{for(;e.firstChild;)JI(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 r=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 r)this.insertBefore(y,t);let n=r;for(let y of n)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=n.map(y=>l1(y)),d=u.reduce((y,v)=>y+v,0)+Math.max(0,n.length-1)*h,f=d<=c-o1;if(this.overflow==="none"||f)return;t.hidden=!1;let p=l1(t),m=n.length,b=d;for(;m>0&&!(b+h+p<=c-o1);)m-=1,b-=u[m],m>0&&(b-=h);for(;m>0&&a1(n[m-1]);)m-=1;let g=n.slice(m);for(let y of g){if(a1(y)){y.hidden=!0;continue}KI(y),e.appendChild(y)}e.firstElementChild||(t.hidden=!0)}finally{this.#n=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#O()})}}}},ko=class extends x{static template=()=>null;connected(){this.setAttribute("role","group")}};S("toolbar-ui",wo),S("toolbar-group-ui",ko);$();var Ao=class extends x{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 n=i.querySelector(':scope > [slot="header"]');n&&(t.target===n||n.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}};S("nav-ui",Ao);$();var Eo=class extends x{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=`
220
+ `;try{this.#e.showPopover()}catch{}this.#i?.(),l?this.#i=ct(l,this.#e,{placement:o,gap:12}):(this.#e.style.position="fixed",this.#e.style.top="50%",this.#e.style.left="50%",this.#e.style.transform="translate(-50%, -50%)"),queueMicrotask(()=>this.#e?.focus?.())}#u=null;#f(){if(!this.#t)return;let t=this.#u;if(!t){this.#t.setAttribute("data-tour-no-target","");return}this.#t.removeAttribute("data-tour-no-target");let e=t.getBoundingClientRect(),i=getComputedStyle(this),r=parseFloat(i.getPropertyValue("--tour-spotlight-padding"))||8,n=Math.max(0,e.top-r),o=Math.max(0,e.left-r),a=e.width+r*2,l=e.height+r*2;this.#t.style.top=`${n}px`,this.#t.style.left=`${o}px`,this.#t.style.width=`${a}px`,this.#t.style.height=`${l}px`}#p=t=>{let e=t.target;if(!(!e||!e.closest)){if(e.closest("[data-tour-skip]")){this.skip();return}if(e.closest("[data-tour-previous]")){this.previous();return}if(e.closest("[data-tour-next]")){this.next();return}}}},So=class extends x{static properties={target:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null};function YI(s){return String(s??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}S("tour-ui",xo),S("tour-step-ui",So);$();var n1="data-toolbar-spillover",HI="data-toolbar-spillover-menu",o1=8,Ju="data-toolbar-spillover-label";function a1(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function GI(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function KI(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(Ju)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||GI(e.getAttribute("icon"));i&&(e.setAttribute(Ju,""),e.setAttribute("text",i))}}function JI(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(Ju)&&(e.removeAttribute(Ju),e.removeAttribute("text"))}function l1(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,r=parseFloat(e.marginRight)||0;return t.width+i+r}var wo=class extends x{static properties={gap:{type:String,default:"sm",reflect:!0},align:{type:String,default:"start",reflect:!0},overflow:{type:String,default:"menu",reflect:!0},bordered:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=!1;#o=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#c(),this.#t=new ResizeObserver(()=>this.#b()),this.#t.observe(this),this.#e=new MutationObserver(()=>{this.#n||this.#b()}),this.#y(),this.#b()}disconnected(){this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.#a=!1,this.#t?.disconnect(),this.#e?.disconnect(),this.#d(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}#c(){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(n1,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(HI,""),e.setAttribute("popover","manual"),e.setAttribute("role","menu"),t.addEventListener("click",this.#u),e.addEventListener("click",this.#f),e.addEventListener("toggle",this.#g),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.#r?.(),this.#r=ct(this.#i,t,{placement:"bottom-end",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#p,!0),document.addEventListener("keydown",this.#m,!0)}))}#d(){this.#r?.(),this.#r=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.#m,!0)}#u=t=>{t.stopPropagation(),this.#s?.matches(":popover-open")?this.#d():this.#h()};#f=t=>{let e=t.target.closest("button-ui");e&&(e.matches(`[${n1}]`)||queueMicrotask(()=>this.#d()))};#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.#d()};#m=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#d(),this.#i?.focus?.({preventScroll:!0}))};#g=t=>{t.newState==="closed"&&(this.#r?.(),this.#r=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0))};#b(){this.#a||(this.#a=!0,this.#o=requestAnimationFrame(()=>{this.#o=null,this.#a=!1,this.isConnected&&this.#S()}))}#y(){this.#e?.observe(this,{childList:!0})}#O(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#S(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#n=!0,this.#O();try{for(;e.firstChild;)JI(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 r=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 r)this.insertBefore(y,t);let n=r;for(let y of n)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=n.map(y=>l1(y)),d=u.reduce((y,v)=>y+v,0)+Math.max(0,n.length-1)*h,f=d<=c-o1;if(this.overflow==="none"||f)return;t.hidden=!1;let p=l1(t),m=n.length,b=d;for(;m>0&&!(b+h+p<=c-o1);)m-=1,b-=u[m],m>0&&(b-=h);for(;m>0&&a1(n[m-1]);)m-=1;let g=n.slice(m);for(let y of g){if(a1(y)){y.hidden=!0;continue}KI(y),e.appendChild(y)}e.firstElementChild||(t.hidden=!0)}finally{this.#n=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#y()})}}}},ko=class extends x{static template=()=>null;connected(){this.setAttribute("role","group")}};S("toolbar-ui",wo),S("toolbar-group-ui",ko);$();var Ao=class extends x{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 n=i.querySelector(':scope > [slot="header"]');n&&(t.target===n||n.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}};S("nav-ui",Ao);$();var Eo=class extends x{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=`
221
221
  <span slot="icon">${this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:""}</span>
222
222
  <span slot="text">${this.text}</span>
223
223
  ${this.badge?`<span slot="badge">${this.badge}</span>`:""}
@@ -226,14 +226,14 @@ Correct shape for <chart-ui x="label" y="value">:
226
226
  <span slot="icon">${this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:""}</span>
227
227
  <span slot="text">${this.text}</span>
228
228
  ${this.badge?`<span slot="badge">${this.badge}</span>`:""}
229
- `),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){let t=this.querySelector('[slot="text"]');t&&(t.textContent=this.text),this.setAttribute("tabindex",this.disabled?"-1":"0"),this.selected?this.setAttribute("aria-current","page"):this.removeAttribute("aria-current")}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("nav-item-ui",Co);var $o=class extends M{static properties={...M.properties,length:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=[];#e=t=>{let e=this.#t.indexOf(t.currentTarget);e<0||this.#o(t,e)};#i=t=>{let e=this.#t.indexOf(t.currentTarget);e<0||this.#l(t,e)};#s=t=>{this.#c(t)};connected(){super.connected(),this.setAttribute("role","group"),this.setAttribute("aria-label","One-time password"),this.#r(),this.#n()}#r(){let t=this.length||6;this.innerHTML="",this.#t=[];for(let e=0;e<t;e++){let i=document.createElement("input");i.type="text",i.maxLength=1,i.inputMode="numeric",i.autocomplete="one-time-code",i.setAttribute("slot","digit"),i.setAttribute("aria-label",`Digit ${e+1}`),this.appendChild(i),this.#t.push(i)}}#n(){for(let t of this.#t)t.addEventListener("input",this.#e),t.addEventListener("keydown",this.#i),t.addEventListener("paste",this.#s)}#a(){for(let t of this.#t)t.removeEventListener("input",this.#e),t.removeEventListener("keydown",this.#i),t.removeEventListener("paste",this.#s)}render(){if(!this.#t.length)return;let t=this.disabled;for(let e of this.#t)e.disabled=t}#o(t,e){let i=this.#t[e];i.value=i.value.replace(/\D/g,"").slice(0,1),this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),i.value&&e<this.#t.length-1&&this.#t[e+1].focus(),this.#u()}#l(t,e){t.key==="Backspace"&&!this.#t[e].value&&e>0&&(this.#t[e-1].focus(),this.#t[e-1].value="",this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#c(t){t.preventDefault();let e=(t.clipboardData?.getData("text/plain")||"").replace(/\D/g,"");for(let r=0;r<this.#t.length;r++)this.#t[r].value=e[r]||"";this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));let i=this.#t.findIndex(r=>!r.value);i>=0?this.#t[i].focus():this.#t[this.#t.length-1].focus(),this.#u()}#h(){let t=this.#t.map(e=>e.value).join("");this.value=t,this.syncValue(t)}#u(){let t=this.#t.map(e=>e.value).join("");t.length===this.#t.length&&this.dispatchEvent(new CustomEvent("complete",{bubbles:!0,detail:{value:t}}))}focus(){let t=this.#t.findIndex(e=>!e.value);this.#t[t>=0?t:0]?.focus()}clear(){for(let t of this.#t)t.value="";this.value="",this.syncValue(""),this.#t[0]?.focus()}disconnected(){super.disconnected(),this.#a(),this.#t=[]}};S("otp-input-ui",$o);$();var Po=class extends x{static properties={src:{type:String,default:"",reflect:!0},alt:{type:String,default:"",reflect:!0},width:{type:String,default:"",reflect:!0},height:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},fit:{type:String,default:"cover",reflect:!0},radius:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},fallback:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.#e=this.querySelector(':scope > [slot="skeleton"]'),this.#e||(this.#e=document.createElement("skeleton-ui"),this.#e.setAttribute("slot","skeleton"),this.#e.setAttribute("width","100%"),this.#e.setAttribute("height","100%"),this.appendChild(this.#e)),this.#t=this.querySelector(':scope > [slot="image"]'),this.#t||(this.#t=document.createElement("img"),this.#t.setAttribute("slot","image"),this.#t.loading="lazy",this.appendChild(this.#t)),this.#t.addEventListener("load",this.#s),this.#t.addEventListener("error",this.#r),this.#i()}render(){this.#t&&(this.#t.getAttribute("src")!==this.src&&(this.removeAttribute("data-loaded"),this.removeAttribute("data-error"),this.#t.src=this.src||""),this.#t.alt=this.alt||"",this.#i())}#i(){this.width&&(this.style.width=this.width),this.height&&(this.style.height=this.height)}#s=()=>{this.setAttribute("data-loaded",""),this.removeAttribute("data-error")};#r=()=>{this.fallback&&this.#t.src!==this.fallback?this.#t.src=this.fallback:this.setAttribute("data-error","")};disconnected(){this.#t&&(this.#t.removeEventListener("load",this.#s),this.#t.removeEventListener("error",this.#r)),this.#t=null,this.#e=null}};S("image-ui",Po);var Qo=class extends M{static properties={...M.properties,placeholder:{type:String,default:"Search...",reflect:!0},debounce:{type:Number,default:300,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(super.connected(),this.setAttribute("role","search"),!this.querySelector("input-ui")){let t=this.getAttribute("size");this.innerHTML=`<input-ui
229
+ `),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){let t=this.querySelector('[slot="text"]');t&&(t.textContent=this.text),this.setAttribute("tabindex",this.disabled?"-1":"0"),this.selected?this.setAttribute("aria-current","page"):this.removeAttribute("aria-current")}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("nav-item-ui",Co);var $o=class extends M{static properties={...M.properties,length:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=[];#e=t=>{let e=this.#t.indexOf(t.currentTarget);e<0||this.#o(t,e)};#i=t=>{let e=this.#t.indexOf(t.currentTarget);e<0||this.#l(t,e)};#s=t=>{this.#c(t)};connected(){super.connected(),this.setAttribute("role","group"),this.setAttribute("aria-label","One-time password"),this.#r(),this.#n()}#r(){let t=this.length||6;this.innerHTML="",this.#t=[];for(let e=0;e<t;e++){let i=document.createElement("input");i.type="text",i.maxLength=1,i.inputMode="numeric",i.autocomplete="one-time-code",i.setAttribute("slot","digit"),i.setAttribute("aria-label",`Digit ${e+1}`),this.appendChild(i),this.#t.push(i)}}#n(){for(let t of this.#t)t.addEventListener("input",this.#e),t.addEventListener("keydown",this.#i),t.addEventListener("paste",this.#s)}#a(){for(let t of this.#t)t.removeEventListener("input",this.#e),t.removeEventListener("keydown",this.#i),t.removeEventListener("paste",this.#s)}render(){if(!this.#t.length)return;let t=this.disabled;for(let e of this.#t)e.disabled=t}#o(t,e){let i=this.#t[e];i.value=i.value.replace(/\D/g,"").slice(0,1),this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),i.value&&e<this.#t.length-1&&this.#t[e+1].focus(),this.#d()}#l(t,e){t.key==="Backspace"&&!this.#t[e].value&&e>0&&(this.#t[e-1].focus(),this.#t[e-1].value="",this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#c(t){t.preventDefault();let e=(t.clipboardData?.getData("text/plain")||"").replace(/\D/g,"");for(let r=0;r<this.#t.length;r++)this.#t[r].value=e[r]||"";this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));let i=this.#t.findIndex(r=>!r.value);i>=0?this.#t[i].focus():this.#t[this.#t.length-1].focus(),this.#d()}#h(){let t=this.#t.map(e=>e.value).join("");this.value=t,this.syncValue(t)}#d(){let t=this.#t.map(e=>e.value).join("");t.length===this.#t.length&&this.dispatchEvent(new CustomEvent("complete",{bubbles:!0,detail:{value:t}}))}focus(){let t=this.#t.findIndex(e=>!e.value);this.#t[t>=0?t:0]?.focus()}clear(){for(let t of this.#t)t.value="";this.value="",this.syncValue(""),this.#t[0]?.focus()}disconnected(){super.disconnected(),this.#a(),this.#t=[]}};S("otp-input-ui",$o);$();var Po=class extends x{static properties={src:{type:String,default:"",reflect:!0},alt:{type:String,default:"",reflect:!0},width:{type:String,default:"",reflect:!0},height:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},fit:{type:String,default:"cover",reflect:!0},radius:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},fallback:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.#e=this.querySelector(':scope > [slot="skeleton"]'),this.#e||(this.#e=document.createElement("skeleton-ui"),this.#e.setAttribute("slot","skeleton"),this.#e.setAttribute("width","100%"),this.#e.setAttribute("height","100%"),this.appendChild(this.#e)),this.#t=this.querySelector(':scope > [slot="image"]'),this.#t||(this.#t=document.createElement("img"),this.#t.setAttribute("slot","image"),this.#t.loading="lazy",this.appendChild(this.#t)),this.#t.addEventListener("load",this.#s),this.#t.addEventListener("error",this.#r),this.#i()}render(){this.#t&&(this.#t.getAttribute("src")!==this.src&&(this.removeAttribute("data-loaded"),this.removeAttribute("data-error"),this.#t.src=this.src||""),this.#t.alt=this.alt||"",this.#i())}#i(){this.width&&(this.style.width=this.width),this.height&&(this.style.height=this.height)}#s=()=>{this.setAttribute("data-loaded",""),this.removeAttribute("data-error")};#r=()=>{this.fallback&&this.#t.src!==this.fallback?this.#t.src=this.fallback:this.setAttribute("data-error","")};disconnected(){this.#t&&(this.#t.removeEventListener("load",this.#s),this.#t.removeEventListener("error",this.#r)),this.#t=null,this.#e=null}};S("image-ui",Po);var Qo=class extends M{static properties={...M.properties,placeholder:{type:String,default:"Search...",reflect:!0},debounce:{type:Number,default:300,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(super.connected(),this.setAttribute("role","search"),!this.querySelector("input-ui")){let t=this.getAttribute("size");this.innerHTML=`<input-ui
230
230
  type="search"
231
231
  prefix="magnifying-glass"
232
232
  suffix="x-circle"
233
233
  placeholder="${this.placeholder}"
234
234
  ${this.disabled?"disabled":""}
235
235
  ${t?`size="${t}"`:""}
236
- ></input-ui>`}this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#r),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#n)))}render(){this.#t&&(this.#t.setAttribute("placeholder",this.placeholder),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"),this.setAttribute("value",this.value||""))}#s=()=>{this.value=this.#t.value,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}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#r=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#n()};#n=()=>{clearTimeout(this.#i),this.value="",this.#t&&(this.#t.value=""),this.syncValue(""),this.setAttribute("value",""),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:""}})),this.#t?.focus()};focus(){this.#t?.focus()}clear(){this.#n()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#r)),this.#e&&this.#e.removeEventListener("click",this.#n),this.#t=null,this.#e=null}};S("search-ui",Qo);Ct();function Us(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function tD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var eD=0,To=class extends M{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle","check"];static properties={...M.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},creatable:{type:Boolean,default:!1,reflect:!0},clearable:{type:Boolean,default:!1,reflect:!0},filterMode:{type:String,default:"substring",reflect:!0,attribute:"filter-mode"},loading:{type:Boolean,default:!1,reflect:!0},maxOptions:{type:Number,default:100,reflect:!0,attribute:"max-options"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#r=!1;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=`combobox-${++eD}`;#g=()=>this.#X();#b=t=>this.#q(t);#O=()=>this.#R();#y=t=>this.#_(t);#w=t=>this.#H(t);#v=t=>this.#F(t);#S=t=>this.#J(t);#x=t=>this.#tt(t);#k=t=>this.#et(t);connected(){super.connected(),this.#t.length===0&&this.#Q(),this.#e=this.value||"",this.#A(),this.#$(),this.#U()}disconnected(){super.disconnected(),this.#T(),this.#f?.(),this.#f=null,this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#k),this.#o?.hidePopover?.(),this.#o=null,this.#n=null,this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#u=null,this.#d=null}render(){this.#n&&(this.#n.setAttribute("aria-expanded",String(this.open)),this.disabled||this.readonly?this.#n.contentEditable="false":this.#n.contentEditable="plaintext-only",this.#a&&(this.#a.textContent=this.label||"",this.#a.style.display=this.label?"":"none"),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#u&&(this.#u.style.display=this.clearable&&this.value?"":"none"),this.#c&&(this.#c.style.display=this.loading?"":"none"),this.open?this.#st():this.#Y())}#A(){if(this.querySelector(":scope > [data-field]")){this.#C(),this.#E();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,r=Array.from(this.querySelectorAll(':scope > [slot="prefix"]')),n=Array.from(this.querySelectorAll(':scope > [slot="suffix"]')),o=Array.from(this.querySelectorAll(':scope > [slot="empty"]')),a=Array.from(this.querySelectorAll(':scope > [slot="loading"]')),l=Array.from(this.querySelectorAll(':scope > [slot="footer"]'));this.innerHTML=`
236
+ ></input-ui>`}this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#r),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#n)))}render(){this.#t&&(this.#t.setAttribute("placeholder",this.placeholder),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"),this.setAttribute("value",this.value||""))}#s=()=>{this.value=this.#t.value,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}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#r=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#n()};#n=()=>{clearTimeout(this.#i),this.value="",this.#t&&(this.#t.value=""),this.syncValue(""),this.setAttribute("value",""),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:""}})),this.#t?.focus()};focus(){this.#t?.focus()}clear(){this.#n()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#r)),this.#e&&this.#e.removeEventListener("click",this.#n),this.#t=null,this.#e=null}};S("search-ui",Qo);Ct();function Us(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function tD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var eD=0,To=class extends M{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle","check"];static properties={...M.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},creatable:{type:Boolean,default:!1,reflect:!0},clearable:{type:Boolean,default:!1,reflect:!0},filterMode:{type:String,default:"substring",reflect:!0,attribute:"filter-mode"},loading:{type:Boolean,default:!1,reflect:!0},maxOptions:{type:Number,default:100,reflect:!0,attribute:"max-options"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#r=!1;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m=`combobox-${++eD}`;#g=()=>this.#X();#b=t=>this.#q(t);#y=()=>this.#R();#O=t=>this.#_(t);#S=t=>this.#H(t);#v=t=>this.#F(t);#w=t=>this.#J(t);#x=t=>this.#tt(t);#k=t=>this.#et(t);connected(){super.connected(),this.#t.length===0&&this.#Q(),this.#e=this.value||"",this.#A(),this.#$(),this.#U()}disconnected(){super.disconnected(),this.#T(),this.#f?.(),this.#f=null,this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#k),this.#o?.hidePopover?.(),this.#o=null,this.#n=null,this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#d=null,this.#u=null}render(){this.#n&&(this.#n.setAttribute("aria-expanded",String(this.open)),this.disabled||this.readonly?this.#n.contentEditable="false":this.#n.contentEditable="plaintext-only",this.#a&&(this.#a.textContent=this.label||"",this.#a.style.display=this.label?"":"none"),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#d&&(this.#d.style.display=this.clearable&&this.value?"":"none"),this.#c&&(this.#c.style.display=this.loading?"":"none"),this.open?this.#st():this.#Y())}#A(){if(this.querySelector(":scope > [data-field]")){this.#C(),this.#E();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,r=Array.from(this.querySelectorAll(':scope > [slot="prefix"]')),n=Array.from(this.querySelectorAll(':scope > [slot="suffix"]')),o=Array.from(this.querySelectorAll(':scope > [slot="empty"]')),a=Array.from(this.querySelectorAll(':scope > [slot="loading"]')),l=Array.from(this.querySelectorAll(':scope > [slot="footer"]'));this.innerHTML=`
237
237
  <span data-label id="${t}"${this.label?"":' style="display:none"'}>${Us(this.label||"")}</span>
238
238
  <div data-field>
239
239
  <span data-prefix></span>
@@ -260,8 +260,8 @@ Correct shape for <chart-ui x="label" y="value">:
260
260
  <div data-empty>No matches</div>
261
261
  <div data-footer></div>
262
262
  </div>
263
- `,this.#C(),r.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...r),n.length&&this.#d.replaceChildren(...n),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#E()}#C(){this.#n=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#u=this.querySelector(":scope > [data-field] > [data-clear]"),this.#d=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#E(){this.#n&&(this.#n.addEventListener("input",this.#g),this.#n.addEventListener("keydown",this.#b),this.#n.addEventListener("focus",this.#O),this.#n.addEventListener("blur",this.#y)),this.#u&&this.#u.addEventListener("click",this.#S),this.#d&&this.#d.addEventListener("click",this.#x)}#T(){this.#n&&(this.#n.removeEventListener("input",this.#g),this.#n.removeEventListener("keydown",this.#b),this.#n.removeEventListener("focus",this.#O),this.#n.removeEventListener("blur",this.#y)),this.#u&&this.#u.removeEventListener("click",this.#S),this.#d&&this.#d.removeEventListener("click",this.#x)}#Q(){let t=[],e="";for(let i of Array.from(this.children))if(i.tagName==="OPTGROUP"){let r={label:i.label||i.getAttribute("label")||"",options:[]};for(let n of i.querySelectorAll("option"))r.options.push({value:n.value,label:n.textContent.trim(),disabled:n.disabled}),n.hasAttribute("selected")&&!e&&(e=n.value);t.push(r)}else i.tagName==="OPTION"&&(t.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&!e&&(e=i.value));for(let i of[...this.querySelectorAll(":scope > option, :scope > optgroup")])i.remove();this.#t=t,!this.value&&e&&(this.value=e)}set options(t){F(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#$(),this.#U()})}get options(){return this.#t}#P(){let t=[];for(let e of this.#t)if(e&&Array.isArray(e.options))for(let i of e.options)t.push(i);else e&&t.push(e);return t}#I(t){return this.#P().find(e=>e.value===t)||null}#$(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#P(),i=this.#D(e).slice(0,Number(this.maxOptions)||100),r=0,n=a=>{r+=1;let l=document.createElement("div");return l.setAttribute("role","option"),l.setAttribute("id",`${this.#m}-opt-${r}`),l.dataset.value=a.value??"",a.disabled&&l.setAttribute("aria-disabled","true"),a.value===this.value&&l.setAttribute("aria-selected","true"),l.innerHTML=this.#M(a.label??a.value),l.addEventListener("click",this.#w),l.addEventListener("mouseenter",this.#v),l};if(this.#t.some(a=>a&&Array.isArray(a.options)))for(let a of this.#t)if(a&&Array.isArray(a.options)){let l=this.#D(a.options);if(!l.length)continue;let h=document.createElement("div");h.setAttribute("role","group");let c=document.createElement("div");c.setAttribute("data-group-label",""),c.textContent=a.label||"",h.appendChild(c);for(let u of l)h.appendChild(n(u));t.appendChild(h)}else a&&this.#L(a)&&t.appendChild(n(a));else for(let a of i)t.appendChild(n(a));let o=t.querySelectorAll('[role="option"]').length;this.#l&&(this.#l.style.display=o||this.loading?"none":""),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant")}#M(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Us(e);let i=this.#i,r=new RegExp(tD(i),"i"),n=e.match(r);if(!n)return Us(e);let o=n.index??0,a=o+n[0].length;return Us(e.slice(0,o))+"<mark>"+Us(e.slice(o,a))+"</mark>"+Us(e.slice(a))}#L(t){if(!this.#i)return!0;let e=this.#i.toLowerCase(),i=String(t.label??t.value??"").toLowerCase();switch(this.filterMode){case"prefix":return i.startsWith(e);case"fuzzy":{let r=0;for(let n of e){if(r=i.indexOf(n,r),r===-1)return!1;r+=1}return!0}default:return i.includes(e)}}#D(t){return this.#i?t.filter(e=>this.#L(e)):t.slice()}#X(){if(this.#r)return;let t=this.#n.textContent||"";this.#i=t.trim(),this.#n.toggleAttribute("data-empty",!t),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#$();let e=this.#Z();this.#i&&e.length&&this.#B(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#q(t){let e=t.key;if(e==="ArrowDown"){t.preventDefault(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}))),this.#j(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#j(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#B(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#Z();this.#B(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#V();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#it("escape"));return}if(e==="Tab"){this.#N();return}if(e==="Backspace"){let i=!(this.#n.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#K("keyboard"));return}}#R(){}#_(t){!this.freeText&&this.#i&&!this.value&&(this.#U(),this.#i="")}#Z(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#j(t){let e=this.#Z();if(!e.length)return;if(this.#s<0){this.#B(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#B(i)}#B(t){let e=this.#Z();if(!e.length){this.#s=-1,this.#n?.removeAttribute("aria-activedescendant");return}for(let n of e)n.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),r=e[i];r&&(r.setAttribute("data-active",""),r.scrollIntoView({block:"nearest"}),this.#s=i,this.#n?.setAttribute("aria-activedescendant",r.id))}#H(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#W(i,"click")}#F(t){let e=t.currentTarget,r=this.#Z().indexOf(e);r>=0&&this.#B(r)}#V(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#Z(),e=this.#s>=0?t[this.#s]:null;if(e){this.#W(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(!i){this.#Y("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#G(i,"keyboard");return}if(this.freeText){this.#G(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#U(),this.#i="",this.#$()}#N(){if(!this.open)return;let t=this.#Z(),e=this.#s>=0?t[this.#s]:null;if(e){this.#W(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#I(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#G(i,"keyboard");return}this.#U(),this.#i="",this.#Y("blur")}#W(t,e){if(this.readonly){this.#Y("select");return}let i=this.#I(t);F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#U(),this.#$(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:i,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#G(t,e){if(this.readonly){this.#Y("select");return}F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#U(),this.#$(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:null,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#J(t){t.preventDefault(),t.stopPropagation(),this.#K("click"),this.#n?.focus()}#K(t){F(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#U(),this.#$(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#K("programmatic")}#tt(t){t.preventDefault(),t.stopPropagation(),!this.disabled&&(this.open?(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}}))):(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"click"}})),this.#n?.focus()))}#et(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#U(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#it(t){this.#U(),this.#i="",this.#$(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#st(){if(!this.#o)return;this.#o.showPopover?.();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=ct(t,this.#o,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#p!=null&&cancelAnimationFrame(this.#p),this.#p=requestAnimationFrame(()=>{this.#p=null,document.addEventListener("pointerdown",this.#k)});let e=this.#Z();if(!e.length)return;let i=e.findIndex(r=>r.dataset.value===this.value);this.#B(i>=0?i:0)}#Y(t){this.#o&&(this.#f?.(),this.#f=null,this.#o.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#k),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant"))}#U(){if(!this.#n)return;let t=this.#I(this.value),e=t?t.label??t.value??"":this.value||"";(this.#n.textContent||"")!==e&&(this.#r=!0,this.#n.textContent=e,this.#r=!1),this.#n.toggleAttribute("data-empty",!e)}open$(){this.open=!0}close$(){this.open=!1}focus(){this.#n?.focus()}selectOption(t){return this.#I(t)?(this.#W(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};S("combobox-ui",To);Ct();var iD=0;function sD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Lo=class extends M{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=M.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
264
- `,reflect:!0,attribute:"paste-split"},max:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},minLength:{type:Number,default:1,reflect:!0,attribute:"min-length"},maxLength:{type:Number,default:0,reflect:!0,attribute:"max-length"},unique:{type:Boolean,default:!0,reflect:!0},transform:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0}}}static get observedAttributes(){let t=super.observedAttributes;return t.includes("value")?t:[...t,"value"]}attributeChangedCallback(t,e,i){if(t==="value"){if(i!=null&&e!==i){let r=this.#B(i);r&&(this.value=r)}return}super.attributeChangedCallback(t,e,i)}static template=()=>null;#t=[];#e=[];#i=null;#s=-1;#r=!1;#n=0;#a=null;#o=null;#l=null;#c=null;#h=`tags-input-${++iD}`;#u=()=>this.#A();#d=t=>this.#C(t);#f=t=>this.#E(t);#p=t=>this.#T(t);#m=t=>this.#Q(t);#g=t=>this.#P(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#B(this.getAttribute("value"));t&&(this.#t=t)}this.#b(),this.#v(),this.#x(),this.#k()}disconnected(){super.disconnected(),this.#w(),this.#a=null,this.#o=null,this.#l=null,this.#c=null}render(){this.#o&&(this.disabled||this.readonly?this.#o.contentEditable="false":this.#o.contentEditable="plaintext-only",this.#o.setAttribute("data-placeholder",this.placeholder||""),this.#e.length?(this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","listbox"),this.setAttribute("aria-expanded",String(!!this.hasAttribute("suggesting")))):(this.setAttribute("role","group"),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded")),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.placeholder||"Tags"))}set value(t){F(()=>{let e=Array.isArray(t)?t.map(r=>String(r??"")):typeof t=="string"?this.#B(t)||[]:[],i=this.#t.slice();this.#t=e,this.#v(),this.#x(),this.#k(),this.#X(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){F(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#S(),this.render()})}get suggestions(){return this.#e.slice()}set validateFn(t){this.#i=typeof t=="function"?t:null}get validateFn(){return this.#i}addToken(t){return this.#$(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#D(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#v(),this.#x(),this.#k(),this.#X(t,[],"programmatic")}focus(){this.#o?.focus()}#b(){if(this.querySelector(":scope > [data-chip-list]")){this.#O(),this.#y();return}let t=`${this.#h}-suggestions`,e=`${this.#h}-input`;this.innerHTML=`
263
+ `,this.#C(),r.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...r),n.length&&this.#u.replaceChildren(...n),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#E()}#C(){this.#n=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#d=this.querySelector(":scope > [data-field] > [data-clear]"),this.#u=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#E(){this.#n&&(this.#n.addEventListener("input",this.#g),this.#n.addEventListener("keydown",this.#b),this.#n.addEventListener("focus",this.#y),this.#n.addEventListener("blur",this.#O)),this.#d&&this.#d.addEventListener("click",this.#w),this.#u&&this.#u.addEventListener("click",this.#x)}#T(){this.#n&&(this.#n.removeEventListener("input",this.#g),this.#n.removeEventListener("keydown",this.#b),this.#n.removeEventListener("focus",this.#y),this.#n.removeEventListener("blur",this.#O)),this.#d&&this.#d.removeEventListener("click",this.#w),this.#u&&this.#u.removeEventListener("click",this.#x)}#Q(){let t=[],e="";for(let i of Array.from(this.children))if(i.tagName==="OPTGROUP"){let r={label:i.label||i.getAttribute("label")||"",options:[]};for(let n of i.querySelectorAll("option"))r.options.push({value:n.value,label:n.textContent.trim(),disabled:n.disabled}),n.hasAttribute("selected")&&!e&&(e=n.value);t.push(r)}else i.tagName==="OPTION"&&(t.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&!e&&(e=i.value));for(let i of[...this.querySelectorAll(":scope > option, :scope > optgroup")])i.remove();this.#t=t,!this.value&&e&&(this.value=e)}set options(t){F(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#$(),this.#U()})}get options(){return this.#t}#P(){let t=[];for(let e of this.#t)if(e&&Array.isArray(e.options))for(let i of e.options)t.push(i);else e&&t.push(e);return t}#I(t){return this.#P().find(e=>e.value===t)||null}#$(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#P(),i=this.#D(e).slice(0,Number(this.maxOptions)||100),r=0,n=a=>{r+=1;let l=document.createElement("div");return l.setAttribute("role","option"),l.setAttribute("id",`${this.#m}-opt-${r}`),l.dataset.value=a.value??"",a.disabled&&l.setAttribute("aria-disabled","true"),a.value===this.value&&l.setAttribute("aria-selected","true"),l.innerHTML=this.#M(a.label??a.value),l.addEventListener("click",this.#S),l.addEventListener("mouseenter",this.#v),l};if(this.#t.some(a=>a&&Array.isArray(a.options)))for(let a of this.#t)if(a&&Array.isArray(a.options)){let l=this.#D(a.options);if(!l.length)continue;let h=document.createElement("div");h.setAttribute("role","group");let c=document.createElement("div");c.setAttribute("data-group-label",""),c.textContent=a.label||"",h.appendChild(c);for(let u of l)h.appendChild(n(u));t.appendChild(h)}else a&&this.#L(a)&&t.appendChild(n(a));else for(let a of i)t.appendChild(n(a));let o=t.querySelectorAll('[role="option"]').length;this.#l&&(this.#l.style.display=o||this.loading?"none":""),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant")}#M(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Us(e);let i=this.#i,r=new RegExp(tD(i),"i"),n=e.match(r);if(!n)return Us(e);let o=n.index??0,a=o+n[0].length;return Us(e.slice(0,o))+"<mark>"+Us(e.slice(o,a))+"</mark>"+Us(e.slice(a))}#L(t){if(!this.#i)return!0;let e=this.#i.toLowerCase(),i=String(t.label??t.value??"").toLowerCase();switch(this.filterMode){case"prefix":return i.startsWith(e);case"fuzzy":{let r=0;for(let n of e){if(r=i.indexOf(n,r),r===-1)return!1;r+=1}return!0}default:return i.includes(e)}}#D(t){return this.#i?t.filter(e=>this.#L(e)):t.slice()}#X(){if(this.#r)return;let t=this.#n.textContent||"";this.#i=t.trim(),this.#n.toggleAttribute("data-empty",!t),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#$();let e=this.#Z();this.#i&&e.length&&this.#B(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#q(t){let e=t.key;if(e==="ArrowDown"){t.preventDefault(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}))),this.#j(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#j(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#B(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#Z();this.#B(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#V();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#it("escape"));return}if(e==="Tab"){this.#N();return}if(e==="Backspace"){let i=!(this.#n.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#K("keyboard"));return}}#R(){}#_(t){!this.freeText&&this.#i&&!this.value&&(this.#U(),this.#i="")}#Z(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#j(t){let e=this.#Z();if(!e.length)return;if(this.#s<0){this.#B(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#B(i)}#B(t){let e=this.#Z();if(!e.length){this.#s=-1,this.#n?.removeAttribute("aria-activedescendant");return}for(let n of e)n.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),r=e[i];r&&(r.setAttribute("data-active",""),r.scrollIntoView({block:"nearest"}),this.#s=i,this.#n?.setAttribute("aria-activedescendant",r.id))}#H(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#W(i,"click")}#F(t){let e=t.currentTarget,r=this.#Z().indexOf(e);r>=0&&this.#B(r)}#V(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#Z(),e=this.#s>=0?t[this.#s]:null;if(e){this.#W(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(!i){this.#Y("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#G(i,"keyboard");return}if(this.freeText){this.#G(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#U(),this.#i="",this.#$()}#N(){if(!this.open)return;let t=this.#Z(),e=this.#s>=0?t[this.#s]:null;if(e){this.#W(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#I(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#G(i,"keyboard");return}this.#U(),this.#i="",this.#Y("blur")}#W(t,e){if(this.readonly){this.#Y("select");return}let i=this.#I(t);F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#U(),this.#$(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:i,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#G(t,e){if(this.readonly){this.#Y("select");return}F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#U(),this.#$(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:null,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#J(t){t.preventDefault(),t.stopPropagation(),this.#K("click"),this.#n?.focus()}#K(t){F(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#U(),this.#$(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#K("programmatic")}#tt(t){t.preventDefault(),t.stopPropagation(),!this.disabled&&(this.open?(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}}))):(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"click"}})),this.#n?.focus()))}#et(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#U(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#it(t){this.#U(),this.#i="",this.#$(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#st(){if(!this.#o)return;this.#o.showPopover?.();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=ct(t,this.#o,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#p!=null&&cancelAnimationFrame(this.#p),this.#p=requestAnimationFrame(()=>{this.#p=null,document.addEventListener("pointerdown",this.#k)});let e=this.#Z();if(!e.length)return;let i=e.findIndex(r=>r.dataset.value===this.value);this.#B(i>=0?i:0)}#Y(t){this.#o&&(this.#f?.(),this.#f=null,this.#o.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#k),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant"))}#U(){if(!this.#n)return;let t=this.#I(this.value),e=t?t.label??t.value??"":this.value||"";(this.#n.textContent||"")!==e&&(this.#r=!0,this.#n.textContent=e,this.#r=!1),this.#n.toggleAttribute("data-empty",!e)}open$(){this.open=!0}close$(){this.open=!1}focus(){this.#n?.focus()}selectOption(t){return this.#I(t)?(this.#W(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};S("combobox-ui",To);Ct();var iD=0;function sD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Lo=class extends M{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=M.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
264
+ `,reflect:!0,attribute:"paste-split"},max:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},minLength:{type:Number,default:1,reflect:!0,attribute:"min-length"},maxLength:{type:Number,default:0,reflect:!0,attribute:"max-length"},unique:{type:Boolean,default:!0,reflect:!0},transform:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0}}}static get observedAttributes(){let t=super.observedAttributes;return t.includes("value")?t:[...t,"value"]}attributeChangedCallback(t,e,i){if(t==="value"){if(i!=null&&e!==i){let r=this.#B(i);r&&(this.value=r)}return}super.attributeChangedCallback(t,e,i)}static template=()=>null;#t=[];#e=[];#i=null;#s=-1;#r=!1;#n=0;#a=null;#o=null;#l=null;#c=null;#h=`tags-input-${++iD}`;#d=()=>this.#A();#u=t=>this.#C(t);#f=t=>this.#E(t);#p=t=>this.#T(t);#m=t=>this.#Q(t);#g=t=>this.#P(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#B(this.getAttribute("value"));t&&(this.#t=t)}this.#b(),this.#v(),this.#x(),this.#k()}disconnected(){super.disconnected(),this.#S(),this.#a=null,this.#o=null,this.#l=null,this.#c=null}render(){this.#o&&(this.disabled||this.readonly?this.#o.contentEditable="false":this.#o.contentEditable="plaintext-only",this.#o.setAttribute("data-placeholder",this.placeholder||""),this.#e.length?(this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","listbox"),this.setAttribute("aria-expanded",String(!!this.hasAttribute("suggesting")))):(this.setAttribute("role","group"),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded")),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.placeholder||"Tags"))}set value(t){F(()=>{let e=Array.isArray(t)?t.map(r=>String(r??"")):typeof t=="string"?this.#B(t)||[]:[],i=this.#t.slice();this.#t=e,this.#v(),this.#x(),this.#k(),this.#X(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){F(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#w(),this.render()})}get suggestions(){return this.#e.slice()}set validateFn(t){this.#i=typeof t=="function"?t:null}get validateFn(){return this.#i}addToken(t){return this.#$(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#D(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#v(),this.#x(),this.#k(),this.#X(t,[],"programmatic")}focus(){this.#o?.focus()}#b(){if(this.querySelector(":scope > [data-chip-list]")){this.#y(),this.#O();return}let t=`${this.#h}-suggestions`,e=`${this.#h}-input`;this.innerHTML=`
265
265
  <div data-chip-list role="list" aria-label="Tags"></div>
266
266
  <span data-inline-input
267
267
  id="${e}"
@@ -277,11 +277,11 @@ Correct shape for <chart-ui x="label" y="value">:
277
277
  <icon-ui name="circle-notch"></icon-ui>
278
278
  </span>
279
279
  <div data-suggestions id="${t}" role="listbox" hidden></div>
280
- `,this.#O(),this.#y()}#O(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#y(){this.#o&&(this.#o.addEventListener("input",this.#u),this.#o.addEventListener("keydown",this.#d),this.#o.addEventListener("paste",this.#f)),this.#a&&this.#a.addEventListener("remove",this.#p),this.#l&&this.#l.addEventListener("click",this.#g),this.addEventListener("mousedown",this.#m)}#w(){this.#o&&(this.#o.removeEventListener("input",this.#u),this.#o.removeEventListener("keydown",this.#d),this.#o.removeEventListener("paste",this.#f)),this.#a&&this.#a.removeEventListener("remove",this.#p),this.#l&&this.#l.removeEventListener("click",this.#g),this.removeEventListener("mousedown",this.#m)}#v(){if(!this.#a)return;let t=Array.from(this.#a.querySelectorAll(":scope > tag-ui"));for(let e=0;e<this.#t.length;e++){let i=this.#t[e],r=t[e];r||(r=document.createElement("tag-ui"),r.setAttribute("role","listitem"),this.#a.appendChild(r)),r.setAttribute("text",i),this.readonly||this.disabled?r.removeAttribute("removable"):r.setAttribute("removable",""),r.setAttribute("data-index",String(e))}for(let e=this.#t.length;e<t.length;e++)t[e].remove()}#S(){if(!this.#l)return;let t=this.#o?(this.#o.textContent||"").trim().toLowerCase():"",e=this.#e.filter(r=>!this.#t.includes(r)).filter(r=>!t||r.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((r,n)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${n}`),o.dataset.value=r,o.textContent=r,this.#l.appendChild(o)});let i=this.#e.length>0&&e.length>0&&this.hasAttribute("editing");this.#l.hidden=!i,this.toggleAttribute("suggesting",i),i?this.setAttribute("aria-expanded","true"):this.removeAttribute("aria-expanded"),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant");for(let r of this.#l.children)r.removeAttribute("data-active")}#x(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.#o.toggleAttribute("data-empty",t),this.toggleAttribute("editing",!t)}#k(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#A(){if(this.#r)return;let t=this.#o.textContent||"";if(this.delimiter&&this.delimiter!=="enter"&&t.includes(this.delimiter)){let e=t.split(this.delimiter),i=e.pop(),r=!1;for(let n of e)n.length&&this.#$(n,"delimiter")&&(r=!0);this.#r=!0,this.#o.textContent=i||"",this.#r=!1,this.#_(),this.#x(),this.#S(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#x(),this.#S(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#C(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#o&&this.#o.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let r=this.#l?.children[this.#s];if(r){this.#$(r.dataset.value||"","suggestion");return}}i&&this.#$(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#D(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#j())}#E(t){if(this.disabled||this.readonly)return;let e=t.clipboardData?.getData("text/plain")||"";if(!e||!this.pasteSplit)return;t.preventDefault();let i=new RegExp(`[${sD(this.pasteSplit)}]+`),r=e.split(i).map(o=>o.trim()).filter(Boolean);if(r.length===0)return;if(r.length===1){document.execCommand("insertText",!1,r[0]),this.#x(),this.#S();return}let n="";for(let o=0;o<r.length;o++){let a=r[o];!this.#$(a,"paste")&&o===r.length-1&&(n=a)}n&&(this.#r=!0,this.#o.textContent=n,this.#r=!1,this.#_(),this.#x(),this.#S())}#T(t){let e=t.target.closest("tag-ui[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#D(i,"chip-click"))}#Q(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#o&&(t.preventDefault(),this.#o?.focus(),this.#_())}#P(t){let e=t.target.closest('[role="option"]');e&&this.#$(e.dataset.value||"","suggestion")}#I(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#$(t,e){if(this.disabled||this.readonly)return!1;let i=this.#I(t.trim());if(!i)return this.#R(),!1;if(i.length<this.minLength)return this.#q(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#q(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#R(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#q(i,"max"),!1;let r=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(r))return this.#q(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#M(i,o,e),!1;if(o===!1)return this.#q(i,"validator"),!1}catch{return this.#q(i,"validator"),!1}return this.#L(i,e),!0}#M(t,e,i){let r=++this.#n;this.setAttribute("validating",""),this.#c&&(this.#c.hidden=!1),e.then(n=>{if(!(r!==this.#n||!this.isConnected)){if(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),n===!1){this.#q(t,"validator");return}this.#L(t,i)}},()=>{r!==this.#n||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#q(t,"validator"))})}#L(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#R(),this.#x(),this.#k(),this.#X(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#D(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),r=i.slice();r.splice(t,1),this.#t=r,this.#v(),this.#x(),this.#k(),this.#X(i,r,e),e!=="programmatic"&&this.#o?.focus()}#X(t,e,i){let r=new Set(t),n=new Set(e),o=e.filter(l=>!r.has(l)),a=t.filter(l=>!n.has(l));o.length===0&&a.length===0||this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e.slice(),added:o,removed:a,source:i}}))}#q(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#R(){this.#o&&(this.#r=!0,this.#o.textContent="",this.#r=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#S())}#_(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#Z(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let r of e)r.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#o?.setAttribute("aria-activedescendant",i.id)}#j(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#B(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(r=>String(r??""))}catch{}return e.includes(",")?(this.#q(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#B(t);if(e){this.value=e;return}}super.syncValue(t)}};S("tags-input-ui",Lo);$();var Nl=class extends x{static properties={value:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},change:{type:String,default:"",reflect:!0},trend:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},bleed:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="icon"]'),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.textContent=this.change,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};customElements.define("stat-ui",Nl);$();var Mo=class extends x{static properties={label:{type:String,default:"",reflect:!0},value:{type:Number,default:null,reflect:!0},meta:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","group"),this.#t=this.querySelector(':scope > [slot="label"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","label"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="meta"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","meta"),this.appendChild(this.#e)),this.#i=this.querySelector(":scope > progress-ui"),this.#i||(this.#i=document.createElement("progress-ui"),this.value!=null&&this.value>=0&&this.#i.setAttribute("value",String(this.value)),this.appendChild(this.#i))}disconnected(){this.#t=null,this.#e=null,this.#i=null}render(){this.#t&&(this.#t.textContent=this.label,this.#t.hidden=!this.label,this.#e.textContent=this.meta,this.#e.hidden=!this.meta,this.value!=null&&this.value>=0?this.#i.setAttribute("value",String(this.value)):this.#i.removeAttribute("value"),this.label?this.setAttribute("aria-label",this.meta?`${this.label}, ${this.meta}`:this.label):this.removeAttribute("aria-label"))}};S("progress-row-ui",Mo);$();var Ro=class extends x{static properties={};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),r=i?e.indexOf(i):-1,n=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),n(r+1);break;case"ArrowUp":t.preventDefault(),n(r-1);break;case"Home":t.preventDefault(),n(0);break;case"End":t.preventDefault(),n(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},Io=class extends x{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","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t(),this.#e()}#t(){if(!this.querySelector('[slot="text"]')){if(this.icon){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#e(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.querySelector('[slot="icon"]');if(this.icon)if(t)t.setAttribute("name",this.icon);else{let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else t&&t.remove();let e=this.querySelector('[slot="text"]');e&&(e.textContent=this.text),this.#e()}};S("action-list-ui",Ro),S("action-item-ui",Io);$();var Do=class extends x{static properties={icon:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"",reflect:!0},minimal:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s(t){return t.dataset.emptyStateStamped="1",t}#r(t){return t?.dataset?.emptyStateStamped==="1"}connected(){this.#t=this.querySelector(':scope > [slot="icon"]'),this.#t||(this.#t=this.#s(document.createElement("icon-ui")),this.#t.setAttribute("slot","icon"),this.minimal||this.#t.setAttribute("size","lg"),this.insertBefore(this.#t,this.firstChild)),this.#e=this.querySelector(':scope > [slot="heading"]'),this.#e||(this.#e=this.#s(document.createElement("span")),this.#e.setAttribute("slot","heading"),this.insertBefore(this.#e,this.querySelector('[slot="action"]'))),this.#i=this.querySelector(':scope > [slot="description"]'),this.#i||(this.#i=this.#s(document.createElement("span")),this.#i.setAttribute("slot","description"),this.insertBefore(this.#i,this.querySelector('[slot="action"]')))}render(){this.#t&&(this.#r(this.#t)&&(this.icon?(this.#t.setAttribute("name",this.icon),this.#t.hidden=!1):this.#t.hidden=!0),this.#r(this.#e)&&(this.heading?(this.#e.textContent=this.heading,this.#e.hidden=!1):this.#e.hidden=!0),this.#r(this.#i)&&(this.description?(this.#i.textContent=this.description,this.#i.hidden=!1):this.#i.hidden=!0))}disconnected(){this.#t=null,this.#e=null,this.#i=null}};S("empty-state-ui",Do);$();var rD=["S","M","T","W","T","F","S"],nD=["January","February","March","April","May","June","July","August","September","October","November","December"];function h1(s){return String(s).padStart(2,"0")}function Xb(s,t,e){return`${s}-${h1(t+1)}-${h1(e)}`}function Ri(s){if(!s)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s).trim());return t?new Date(+t[1],+t[2]-1,+t[3]):null}function td(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var qo=class extends x{static requiredIcons=["caret-left","caret-right"];static properties={value:{type:String,default:"",reflect:!0},month:{type:String,default:"",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},rangeStart:{type:String,default:"",reflect:!0,attribute:"range-start"},rangeEnd:{type:String,default:"",reflect:!0,attribute:"range-end"}};static template=()=>null;#t=new Date().getFullYear();#e=new Date().getMonth();#i=null;#s=!1;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Calendar");let t=Ri(this.value);if(t)this.#t=t.getFullYear(),this.#e=t.getMonth();else{let e=/^(\d{4})-(\d{2})$/.exec(String(this.month||"").trim());e&&(this.#t=+e[1],this.#e=+e[2]-1)}this.#s||(this.#s=!0,this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#o),this.#s=!1}render(){let t=Ri(this.value);t&&(t.getFullYear()!==this.#t||t.getMonth()!==this.#e)&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#r()}navigate(t){for(this.#e+=t;this.#e>11;)this.#e-=12,this.#t++;for(;this.#e<0;)this.#e+=12,this.#t--;this.#i=null,this.#r()}focusDay(t){let e=new Date(this.#t,this.#e+1,0).getDate();t<1||t>e||(this.#i=t,this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.())}#r(){let t=this.#t,e=this.#e,i=new Date,r=Ri(this.value),n=Ri(this.min),o=Ri(this.max),a=Ri(this.rangeStart),l=Ri(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
280
+ `,this.#y(),this.#O()}#y(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#O(){this.#o&&(this.#o.addEventListener("input",this.#d),this.#o.addEventListener("keydown",this.#u),this.#o.addEventListener("paste",this.#f)),this.#a&&this.#a.addEventListener("remove",this.#p),this.#l&&this.#l.addEventListener("click",this.#g),this.addEventListener("mousedown",this.#m)}#S(){this.#o&&(this.#o.removeEventListener("input",this.#d),this.#o.removeEventListener("keydown",this.#u),this.#o.removeEventListener("paste",this.#f)),this.#a&&this.#a.removeEventListener("remove",this.#p),this.#l&&this.#l.removeEventListener("click",this.#g),this.removeEventListener("mousedown",this.#m)}#v(){if(!this.#a)return;let t=Array.from(this.#a.querySelectorAll(":scope > tag-ui"));for(let e=0;e<this.#t.length;e++){let i=this.#t[e],r=t[e];r||(r=document.createElement("tag-ui"),r.setAttribute("role","listitem"),this.#a.appendChild(r)),r.setAttribute("text",i),this.readonly||this.disabled?r.removeAttribute("removable"):r.setAttribute("removable",""),r.setAttribute("data-index",String(e))}for(let e=this.#t.length;e<t.length;e++)t[e].remove()}#w(){if(!this.#l)return;let t=this.#o?(this.#o.textContent||"").trim().toLowerCase():"",e=this.#e.filter(r=>!this.#t.includes(r)).filter(r=>!t||r.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((r,n)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${n}`),o.dataset.value=r,o.textContent=r,this.#l.appendChild(o)});let i=this.#e.length>0&&e.length>0&&this.hasAttribute("editing");this.#l.hidden=!i,this.toggleAttribute("suggesting",i),i?this.setAttribute("aria-expanded","true"):this.removeAttribute("aria-expanded"),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant");for(let r of this.#l.children)r.removeAttribute("data-active")}#x(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.#o.toggleAttribute("data-empty",t),this.toggleAttribute("editing",!t)}#k(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#A(){if(this.#r)return;let t=this.#o.textContent||"";if(this.delimiter&&this.delimiter!=="enter"&&t.includes(this.delimiter)){let e=t.split(this.delimiter),i=e.pop(),r=!1;for(let n of e)n.length&&this.#$(n,"delimiter")&&(r=!0);this.#r=!0,this.#o.textContent=i||"",this.#r=!1,this.#_(),this.#x(),this.#w(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#x(),this.#w(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#C(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#o&&this.#o.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let r=this.#l?.children[this.#s];if(r){this.#$(r.dataset.value||"","suggestion");return}}i&&this.#$(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#D(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#j())}#E(t){if(this.disabled||this.readonly)return;let e=t.clipboardData?.getData("text/plain")||"";if(!e||!this.pasteSplit)return;t.preventDefault();let i=new RegExp(`[${sD(this.pasteSplit)}]+`),r=e.split(i).map(o=>o.trim()).filter(Boolean);if(r.length===0)return;if(r.length===1){document.execCommand("insertText",!1,r[0]),this.#x(),this.#w();return}let n="";for(let o=0;o<r.length;o++){let a=r[o];!this.#$(a,"paste")&&o===r.length-1&&(n=a)}n&&(this.#r=!0,this.#o.textContent=n,this.#r=!1,this.#_(),this.#x(),this.#w())}#T(t){let e=t.target.closest("tag-ui[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#D(i,"chip-click"))}#Q(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#o&&(t.preventDefault(),this.#o?.focus(),this.#_())}#P(t){let e=t.target.closest('[role="option"]');e&&this.#$(e.dataset.value||"","suggestion")}#I(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#$(t,e){if(this.disabled||this.readonly)return!1;let i=this.#I(t.trim());if(!i)return this.#R(),!1;if(i.length<this.minLength)return this.#q(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#q(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#R(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#q(i,"max"),!1;let r=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(r))return this.#q(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#M(i,o,e),!1;if(o===!1)return this.#q(i,"validator"),!1}catch{return this.#q(i,"validator"),!1}return this.#L(i,e),!0}#M(t,e,i){let r=++this.#n;this.setAttribute("validating",""),this.#c&&(this.#c.hidden=!1),e.then(n=>{if(!(r!==this.#n||!this.isConnected)){if(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),n===!1){this.#q(t,"validator");return}this.#L(t,i)}},()=>{r!==this.#n||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#q(t,"validator"))})}#L(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#R(),this.#x(),this.#k(),this.#X(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#D(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),r=i.slice();r.splice(t,1),this.#t=r,this.#v(),this.#x(),this.#k(),this.#X(i,r,e),e!=="programmatic"&&this.#o?.focus()}#X(t,e,i){let r=new Set(t),n=new Set(e),o=e.filter(l=>!r.has(l)),a=t.filter(l=>!n.has(l));o.length===0&&a.length===0||this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e.slice(),added:o,removed:a,source:i}}))}#q(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#R(){this.#o&&(this.#r=!0,this.#o.textContent="",this.#r=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#w())}#_(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#Z(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let r of e)r.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#o?.setAttribute("aria-activedescendant",i.id)}#j(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#B(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(r=>String(r??""))}catch{}return e.includes(",")?(this.#q(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#B(t);if(e){this.value=e;return}}super.syncValue(t)}};S("tags-input-ui",Lo);$();var Nl=class extends x{static properties={value:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},change:{type:String,default:"",reflect:!0},trend:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},bleed:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="icon"]'),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.textContent=this.change,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};customElements.define("stat-ui",Nl);$();var Mo=class extends x{static properties={label:{type:String,default:"",reflect:!0},value:{type:Number,default:null,reflect:!0},meta:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","group"),this.#t=this.querySelector(':scope > [slot="label"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","label"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="meta"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","meta"),this.appendChild(this.#e)),this.#i=this.querySelector(":scope > progress-ui"),this.#i||(this.#i=document.createElement("progress-ui"),this.value!=null&&this.value>=0&&this.#i.setAttribute("value",String(this.value)),this.appendChild(this.#i))}disconnected(){this.#t=null,this.#e=null,this.#i=null}render(){this.#t&&(this.#t.textContent=this.label,this.#t.hidden=!this.label,this.#e.textContent=this.meta,this.#e.hidden=!this.meta,this.value!=null&&this.value>=0?this.#i.setAttribute("value",String(this.value)):this.#i.removeAttribute("value"),this.label?this.setAttribute("aria-label",this.meta?`${this.label}, ${this.meta}`:this.label):this.removeAttribute("aria-label"))}};S("progress-row-ui",Mo);$();var Ro=class extends x{static properties={};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),r=i?e.indexOf(i):-1,n=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),n(r+1);break;case"ArrowUp":t.preventDefault(),n(r-1);break;case"Home":t.preventDefault(),n(0);break;case"End":t.preventDefault(),n(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},Io=class extends x{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","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t(),this.#e()}#t(){if(!this.querySelector('[slot="text"]')){if(this.icon){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#e(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.querySelector('[slot="icon"]');if(this.icon)if(t)t.setAttribute("name",this.icon);else{let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else t&&t.remove();let e=this.querySelector('[slot="text"]');e&&(e.textContent=this.text),this.#e()}};S("action-list-ui",Ro),S("action-item-ui",Io);$();var Do=class extends x{static properties={icon:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"",reflect:!0},minimal:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s(t){return t.dataset.emptyStateStamped="1",t}#r(t){return t?.dataset?.emptyStateStamped==="1"}connected(){this.#t=this.querySelector(':scope > [slot="icon"]'),this.#t||(this.#t=this.#s(document.createElement("icon-ui")),this.#t.setAttribute("slot","icon"),this.minimal||this.#t.setAttribute("size","lg"),this.insertBefore(this.#t,this.firstChild)),this.#e=this.querySelector(':scope > [slot="heading"]'),this.#e||(this.#e=this.#s(document.createElement("span")),this.#e.setAttribute("slot","heading"),this.insertBefore(this.#e,this.querySelector('[slot="action"]'))),this.#i=this.querySelector(':scope > [slot="description"]'),this.#i||(this.#i=this.#s(document.createElement("span")),this.#i.setAttribute("slot","description"),this.insertBefore(this.#i,this.querySelector('[slot="action"]')))}render(){this.#t&&(this.#r(this.#t)&&(this.icon?(this.#t.setAttribute("name",this.icon),this.#t.hidden=!1):this.#t.hidden=!0),this.#r(this.#e)&&(this.heading?(this.#e.textContent=this.heading,this.#e.hidden=!1):this.#e.hidden=!0),this.#r(this.#i)&&(this.description?(this.#i.textContent=this.description,this.#i.hidden=!1):this.#i.hidden=!0))}disconnected(){this.#t=null,this.#e=null,this.#i=null}};S("empty-state-ui",Do);$();var rD=["S","M","T","W","T","F","S"],nD=["January","February","March","April","May","June","July","August","September","October","November","December"];function h1(s){return String(s).padStart(2,"0")}function Xb(s,t,e){return`${s}-${h1(t+1)}-${h1(e)}`}function Ri(s){if(!s)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s).trim());return t?new Date(+t[1],+t[2]-1,+t[3]):null}function td(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var qo=class extends x{static requiredIcons=["caret-left","caret-right"];static properties={value:{type:String,default:"",reflect:!0},month:{type:String,default:"",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},rangeStart:{type:String,default:"",reflect:!0,attribute:"range-start"},rangeEnd:{type:String,default:"",reflect:!0,attribute:"range-end"}};static template=()=>null;#t=new Date().getFullYear();#e=new Date().getMonth();#i=null;#s=!1;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Calendar");let t=Ri(this.value);if(t)this.#t=t.getFullYear(),this.#e=t.getMonth();else{let e=/^(\d{4})-(\d{2})$/.exec(String(this.month||"").trim());e&&(this.#t=+e[1],this.#e=+e[2]-1)}this.#s||(this.#s=!0,this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#o),this.#s=!1}render(){let t=Ri(this.value);t&&(t.getFullYear()!==this.#t||t.getMonth()!==this.#e)&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#r()}navigate(t){for(this.#e+=t;this.#e>11;)this.#e-=12,this.#t++;for(;this.#e<0;)this.#e+=12,this.#t--;this.#i=null,this.#r()}focusDay(t){let e=new Date(this.#t,this.#e+1,0).getDate();t<1||t>e||(this.#i=t,this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.())}#r(){let t=this.#t,e=this.#e,i=new Date,r=Ri(this.value),n=Ri(this.min),o=Ri(this.max),a=Ri(this.rangeStart),l=Ri(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
281
281
  <button data-cal-prev type="button" aria-label="Previous month" tabindex="-1"><icon-ui name="caret-left"></icon-ui></button>
282
282
  <span data-cal-title>${nD[e]} ${t}</span>
283
283
  <button data-cal-next type="button" aria-label="Next month" tabindex="-1"><icon-ui name="caret-right"></icon-ui></button>
284
- </div>`;u+=`<div data-cal-weekdays>${rD.map(g=>`<span>${g}</span>`).join("")}</div>`;let d=new Date(t,e,1).getDay(),f=new Date(t,e+1,0).getDate(),p=new Date(t,e,0).getDate();u+="<div data-cal-grid>";for(let g=d-1;g>=0;g--){let y=p-g;u+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${y}</button>`}for(let g=1;g<=f;g++){let y=new Date(t,e,g),v=Xb(t,e,g),w=td(y,i),k=r&&td(y,r),E=n&&y<n||o&&y>o,A=this.#i===g,C=!!(h&&c&&y>h&&y<c),T=!!(h&&td(y,h)),Q=!!(c&&td(y,c)),D=['type="button"',"data-cal-day",`data-date="${v}"`,w?"data-today":"",k?"data-selected":"",C?"data-in-range":"",T?"data-range-start":"",Q?"data-range-end":"",E?"disabled":"",A?"data-focused":"",`tabindex="${A?"0":"-1"}"`].filter(Boolean).join(" ");u+=`<button ${D}>${g}</button>`}let b=(7-(d+f)%7)%7;for(let g=1;g<=b;g++)u+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${g}</button>`;u+="</div>",this.innerHTML=u}#n(t){this.disabled||this.readonly||(this.value=t,this.#r(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t}})))}#a=t=>{if(this.disabled)return;let e=t.target instanceof Element?t.target:null;if(!e)return;if(e.closest("[data-cal-prev]")){t.stopPropagation(),this.navigate(-1);return}if(e.closest("[data-cal-next]")){t.stopPropagation(),this.navigate(1);return}let n=e.closest("[data-cal-day][data-date]:not([disabled])");n&&(t.stopPropagation(),this.#n(n.dataset.date))};#o=t=>{if(this.disabled)return;if(t.key==="Enter"||t.key===" "){if(this.#i){t.preventDefault();let i=Xb(this.#t,this.#e,this.#i),r=new Date(this.#t,this.#e,this.#i),n=Ri(this.min),o=Ri(this.max);(!n||r>=n)&&(!o||r<=o)&&this.#n(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#t,this.#e+1,0).getDate(),r=(this.#i||1)+e[t.key];if(r<1){this.navigate(-1);let o=new Date(this.#t,this.#e+1,0).getDate();this.#i=o+r}else r>i?(this.navigate(1),this.#i=r-i):this.#i=r;this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{focusDate:Xb(this.#t,this.#e,this.#i)}}));return}if(t.key==="PageUp"){t.preventDefault(),this.navigate(-1);return}if(t.key==="PageDown"){t.preventDefault(),this.navigate(1);return}if(t.key==="Home"){t.preventDefault(),this.#i=1,this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}if(t.key==="End"){t.preventDefault(),this.#i=new Date(this.#t,this.#e+1,0).getDate(),this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}}};S("calendar-grid-ui",qo);var oD=["S","M","T","W","T","F","S"],aD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c1=["January","February","March","April","May","June","July","August","September","October","November","December"];function u1(s,t,e){return`${s}-${String(t+1).padStart(2,"0")}-${String(e).padStart(2,"0")}`}function es(s){if(!s)return null;let[t,e,i]=s.split("-").map(Number);return isNaN(t)||isNaN(e)||isNaN(i)?null:new Date(t,e-1,i)}function d1(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Xo=class extends M{static labelDeprecated=!1;static requiredIcons=["calendar","caret-left","caret-right"];static properties={...M.properties,label:{type:String,default:"",reflect:!0},placeholder:{type:String,default:"Select date...",reflect:!0},format:{type:String,default:"short",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=new Date().getFullYear();#r=new Date().getMonth();#n=null;#a=!1;#o=null;#l=t=>{let e=t.target instanceof Element?t.target:null;if(!e)return;if(e.closest("[data-cal-prev]")){t.stopPropagation(),this.#u(-1);return}if(e.closest("[data-cal-next]")){t.stopPropagation(),this.#u(1);return}let n=e.closest("[data-cal-day][data-date]:not([disabled])");n&&(t.stopPropagation(),this.#d(n.dataset.date))};connected(){super.connected(),this.setAttribute("role","group"),this.addEventListener("click",this.#f),this.addEventListener("keydown",this.#m);let t=es(this.value);t&&(this.#s=t.getFullYear(),this.#r=t.getMonth())}render(){if(!this.querySelector('[slot="trigger"]'))this.innerHTML=`
284
+ </div>`;u+=`<div data-cal-weekdays>${rD.map(g=>`<span>${g}</span>`).join("")}</div>`;let d=new Date(t,e,1).getDay(),f=new Date(t,e+1,0).getDate(),p=new Date(t,e,0).getDate();u+="<div data-cal-grid>";for(let g=d-1;g>=0;g--){let y=p-g;u+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${y}</button>`}for(let g=1;g<=f;g++){let y=new Date(t,e,g),v=Xb(t,e,g),w=td(y,i),k=r&&td(y,r),E=n&&y<n||o&&y>o,A=this.#i===g,C=!!(h&&c&&y>h&&y<c),T=!!(h&&td(y,h)),Q=!!(c&&td(y,c)),D=['type="button"',"data-cal-day",`data-date="${v}"`,w?"data-today":"",k?"data-selected":"",C?"data-in-range":"",T?"data-range-start":"",Q?"data-range-end":"",E?"disabled":"",A?"data-focused":"",`tabindex="${A?"0":"-1"}"`].filter(Boolean).join(" ");u+=`<button ${D}>${g}</button>`}let b=(7-(d+f)%7)%7;for(let g=1;g<=b;g++)u+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${g}</button>`;u+="</div>",this.innerHTML=u}#n(t){this.disabled||this.readonly||(this.value=t,this.#r(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t}})))}#a=t=>{if(this.disabled)return;let e=t.target instanceof Element?t.target:null;if(!e)return;if(e.closest("[data-cal-prev]")){t.stopPropagation(),this.navigate(-1);return}if(e.closest("[data-cal-next]")){t.stopPropagation(),this.navigate(1);return}let n=e.closest("[data-cal-day][data-date]:not([disabled])");n&&(t.stopPropagation(),this.#n(n.dataset.date))};#o=t=>{if(this.disabled)return;if(t.key==="Enter"||t.key===" "){if(this.#i){t.preventDefault();let i=Xb(this.#t,this.#e,this.#i),r=new Date(this.#t,this.#e,this.#i),n=Ri(this.min),o=Ri(this.max);(!n||r>=n)&&(!o||r<=o)&&this.#n(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#t,this.#e+1,0).getDate(),r=(this.#i||1)+e[t.key];if(r<1){this.navigate(-1);let o=new Date(this.#t,this.#e+1,0).getDate();this.#i=o+r}else r>i?(this.navigate(1),this.#i=r-i):this.#i=r;this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{focusDate:Xb(this.#t,this.#e,this.#i)}}));return}if(t.key==="PageUp"){t.preventDefault(),this.navigate(-1);return}if(t.key==="PageDown"){t.preventDefault(),this.navigate(1);return}if(t.key==="Home"){t.preventDefault(),this.#i=1,this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}if(t.key==="End"){t.preventDefault(),this.#i=new Date(this.#t,this.#e+1,0).getDate(),this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}}};S("calendar-grid-ui",qo);var oD=["S","M","T","W","T","F","S"],aD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c1=["January","February","March","April","May","June","July","August","September","October","November","December"];function u1(s,t,e){return`${s}-${String(t+1).padStart(2,"0")}-${String(e).padStart(2,"0")}`}function es(s){if(!s)return null;let[t,e,i]=s.split("-").map(Number);return isNaN(t)||isNaN(e)||isNaN(i)?null:new Date(t,e-1,i)}function d1(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Xo=class extends M{static labelDeprecated=!1;static requiredIcons=["calendar","caret-left","caret-right"];static properties={...M.properties,label:{type:String,default:"",reflect:!0},placeholder:{type:String,default:"Select date...",reflect:!0},format:{type:String,default:"short",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=new Date().getFullYear();#r=new Date().getMonth();#n=null;#a=!1;#o=null;#l=t=>{let e=t.target instanceof Element?t.target:null;if(!e)return;if(e.closest("[data-cal-prev]")){t.stopPropagation(),this.#d(-1);return}if(e.closest("[data-cal-next]")){t.stopPropagation(),this.#d(1);return}let n=e.closest("[data-cal-day][data-date]:not([disabled])");n&&(t.stopPropagation(),this.#u(n.dataset.date))};connected(){super.connected(),this.setAttribute("role","group"),this.addEventListener("click",this.#f),this.addEventListener("keydown",this.#m);let t=es(this.value);t&&(this.#s=t.getFullYear(),this.#r=t.getMonth())}render(){if(!this.querySelector('[slot="trigger"]'))this.innerHTML=`
285
285
  <span slot="trigger">
286
286
  <span slot="display">${this.#c()}</span>
287
287
  <icon-ui name="calendar" slot="caret"></icon-ui>
@@ -290,18 +290,18 @@ Correct shape for <chart-ui x="label" y="value">:
290
290
  <button data-cal-prev type="button" aria-label="Previous month"><icon-ui name="caret-left"></icon-ui></button>
291
291
  <span data-cal-title>${c1[e]} ${t}</span>
292
292
  <button data-cal-next type="button" aria-label="Next month"><icon-ui name="caret-right"></icon-ui></button>
293
- </div>`;a+=`<div data-cal-weekdays>${oD.map(f=>`<span>${f}</span>`).join("")}</div>`;let l=new Date(t,e,1).getDay(),h=new Date(t,e+1,0).getDate(),c=new Date(t,e,0).getDate();a+="<div data-cal-grid>";for(let f=l-1;f>=0;f--){let p=c-f;a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${p}</button>`}for(let f=1;f<=h;f++){let p=new Date(t,e,f),m=u1(t,e,f),b=d1(p,i),g=r&&d1(p,r),y=n&&p<n||o&&p>o,v=this.#n===f,w=['type="button"',"data-cal-day",`data-date="${m}"`,b?"data-today":"",g?"data-selected":"",y?"disabled":"",v?"data-focused":"",`tabindex="${v?"0":"-1"}"`].filter(Boolean).join(" ");a+=`<button ${w}>${f}</button>`}let d=(7-(l+h)%7)%7;for(let f=1;f<=d;f++)a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${f}</button>`;a+="</div>",this.#t.innerHTML=a}#u(t){this.#r+=t,this.#r>11&&(this.#r=0,this.#s++),this.#r<0&&(this.#r=11,this.#s--),this.#n=null,this.#h()}#d(t){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.open&&this.#h()}#f=t=>{if(!this.disabled&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!this.open,this.open)){let e=es(this.value);if(e)this.#s=e.getFullYear(),this.#r=e.getMonth(),this.#n=e.getDate();else{let i=new Date;this.#s=i.getFullYear(),this.#r=i.getMonth(),this.#n=i.getDate()}}};#p=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!1)};#m=t=>{if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!0);return}if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.#n){let i=u1(this.#s,this.#r,this.#n),r=new Date(this.#s,this.#r,this.#n),n=es(this.min),o=es(this.max);(!n||r>=n)&&(!o||r<=o)&&this.#d(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#s,this.#r+1,0).getDate(),r=(this.#n||1)+e[t.key];if(r<1){this.#u(-1);let o=new Date(this.#s,this.#r+1,0).getDate();this.#n=o+r}else r>i?(this.#u(1),this.#n=r-i):this.#n=r;this.#h(),this.#t?.querySelector("[data-focused]")?.focus()}};disconnected(){super.disconnected(),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.removeEventListener("click",this.#f),this.removeEventListener("keydown",this.#m),document.removeEventListener("pointerdown",this.#p),this.#t&&this.#a&&this.#t.removeEventListener("click",this.#l),this.#a=!1,this.#i?.(),this.#i=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null}};S("calendar-picker-ui",Xo);Ct();var lD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],hD=["January","February","March","April","May","June","July","August","September","October","November","December"];function Nb(s){return String(s).padStart(2,"0")}function Ve(s){return s?`${s.getFullYear()}-${Nb(s.getMonth()+1)}-${Nb(s.getDate())}`:""}function Zb(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}function We(s){if(s==null)return null;if(typeof s=="object")return!s.from||!s.to?null:{from:String(s.from),to:String(s.to)};if(typeof s!="string"||!s.trim())return null;try{let t=JSON.parse(s);if(t&&t.from&&t.to)return{from:String(t.from),to:String(t.to)}}catch{}return null}function f1(s){return s?s.from<=s.to:!1}function p1(s,t){let e=Zb(s);if(!e)return"";switch(t){case"long":return`${hD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${lD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function cD(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=Ve(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),Ve(l)},r=Ve(new Date(t.getFullYear(),t.getMonth(),1)),n=Ve(new Date(t.getFullYear(),t.getMonth()+1,0)),o=Ve(new Date(t.getFullYear(),0,1));return[{label:"Today",range:{from:e,to:e}},{label:"Last 7 days",range:{from:i(6),to:e}},{label:"Last 30 days",range:{from:i(29),to:e}},{label:"This month",range:{from:r,to:n}},{label:"Year to date",range:{from:o,to:e}}]}function uD(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var No=class extends M{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down","arrow-right"];static get properties(){return{...M.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#r=!1;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;get rangeValue(){return We(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return We(this.compareValue)}set rangeCompareValue(t){t==null?this.compareValue="":this.compareValue=JSON.stringify({from:String(t.from),to:String(t.to)})}get presets(){return Array.isArray(this.#t)?this.#t:cD()}set presets(t){F(()=>{this.#t=Array.isArray(t)?t.slice():null,this.isConnected&&this.#p()})}open$(){this.open=!0}close$(){this.open=!1}openPopover(){this.disabled||this.readonly||this.open||(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.comparison&&(this.compareValue=""),this.#e=null,this.syncValue("")}applyPreset(t){let e=this.presets.find(i=>i.label===t);return!e||!e.range?!1:(this.#k(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=We(e);if(this.comparison&&this.name){let r=new FormData;i&&r.append(this.name,e),We(this.compareValue)&&r.append(`${this.name}-compare`,this.compareValue),this.internals.setFormValue(r)}else this.internals.setFormValue(i?e:"");this.#u(i)}#u(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date range.",this),!1):t&&!f1(t)?(this.internals.setValidity({rangeUnderflow:!0},"End date must be on or after start date.",this),!1):t&&this.min&&t.from<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable date is ${this.min}.`,this),!1):t&&this.max&&t.to>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable date is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#s||(this.#s=!0,this.#d(),this.#n.addEventListener("click",this.#g),this.#n.addEventListener("keydown",this.#b,!0),this.#a.addEventListener("click",this.#O),this.#a.addEventListener("keydown",this.#y),this.#l.addEventListener("change",this.#v),this.#c.addEventListener("change",this.#S)),this.syncValue()}disconnected(){super.disconnected(),this.#n&&(this.#n.removeEventListener("click",this.#g),this.#n.removeEventListener("keydown",this.#b,!0)),this.#a&&(this.#a.removeEventListener("click",this.#O),this.#a.removeEventListener("keydown",this.#y),this.#a.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#v),this.#c&&this.#c.removeEventListener("change",this.#S),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#w),this.#h?.(),this.#h=null,this.#s=!1,this.#r=!1,this.#n=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null}#d(){if(this.#n=this.ensure("trigger"),this.#a=this.ensure("popover"),this.id&&this.#a.setAttribute("aria-labelledby",this.id),!this.#a.querySelector(":scope > [data-calendar-area]")){let r=this.constructor._pp.calArea.cloneNode(!0);this.#a.appendChild(r)}let t=this.querySelector(':scope > [slot="presets"]');if(t&&t.parentElement!==this.#a)this.#a.appendChild(t),this.#o=t;else if(!this.noPresets&&!t){if(!this.#a.querySelector(":scope > [data-preset-rail]")){let r=this.constructor._pp.presets.cloneNode(!0);this.#a.insertBefore(r,this.#a.querySelector(":scope > [data-calendar-area]"))}this.#o=this.#a.querySelector(":scope > [data-preset-rail]")}let e=this.#a.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let r=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(r)}if(!e.querySelector(":scope > [data-cal-to]")){let r=this.constructor._pp.calTo.cloneNode(!0),n=We(this.value)?.from,o,a;if(n){let[l,h]=n.split("-").map(Number);o=l,a=h-1}else{let l=new Date;o=l.getFullYear(),a=l.getMonth()}a+=1,a>11&&(a=0,o+=1),r.setAttribute("month",`${o}-${Nb(a+1)}`),e.appendChild(r)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=this.querySelector(':scope > [slot="footer"]');i&&i.parentElement!==this.#a&&this.#a.appendChild(i)}render(){if(!this.#n)return;let t=this.#f();this.#n.setAttribute("text",t),this.#n.toggleAttribute("data-has-value",t!==this.placeholder),this.#n.toggleAttribute("disabled",this.disabled),this.#n.setAttribute("aria-haspopup","dialog"),this.#n.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let e=We(this.value),i=this.#e,r=i?.from||e?.from||"",n=i?.to||e?.to||"",o=a=>{r?a.setAttribute("range-start",r):a.removeAttribute("range-start"),n?a.setAttribute("range-end",n):a.removeAttribute("range-end")};this.#l&&(this.min&&this.#l.setAttribute("min",this.min),this.max&&this.#l.setAttribute("max",this.max),this.#l.value=i?.from||e?.from||"",o(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=i?.to||e?.to||"",o(this.#c)),this.querySelector(':scope > [slot="presets"]')||(this.noPresets?(this.#o?.remove(),this.#o=null):(this.#o||this.#d(),this.#p())),this.#a&&(this.open&&!this.#r?!this.disabled&&!this.readonly?(this.#r=!0,this.#a.showPopover?.(),this.#h?.(),this.#h=ct(this.#n,this.#a,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#x),document.addEventListener("keydown",this.#w),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#r&&(this.#r=!1,this.#h?.(),this.#h=null,this.#a.hidePopover?.(),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#w),this.#n?.focus?.()))}#f(){let t=We(this.value);if(!t)return this.placeholder;let e=p1(t.from,this.format),i=p1(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#p(){if(this.#o){this.#o.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#o.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#o.appendChild(t);for(let e of uD()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#o.appendChild(i)}}}}#m=!1;#g=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#m;this.#m=!1,this.open?this.closePopover("outside"):(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#b=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#O=t=>{if(this.readonly){let r=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),n=t.target.closest("[data-cal-day]");if(r||n){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let r=We(this.value);if(!r)return;let n=this.#A(i.dataset.comparisonPresetLabel,r);n&&(this.rangeCompareValue=n);return}};#y=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#C();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#w=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#l?.value||"";if(!e)return;let i=We(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.from=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));let r=this.#e.to||i?.to||null;r&&this.#k({from:e,to:r})};#S=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#c?.value||"";if(!e)return;let i=We(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from||i?.from||null,to:e}}}));let r=this.#e.from||i?.from||null;r&&this.#k({from:r,to:e})};#x=t=>{this.open&&(this.contains(t.target)||this.#a&&t.composedPath?.().includes(this.#a)||this.closePopover("outside"))};#k(t,e={}){if(!t||!t.from||!t.to)return;if(!f1(t)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"reversed"}}));return}if(this.min&&t.from<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"below-min"}}));return}if(this.max&&t.to>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"above-max"}}));return}let i=JSON.stringify({from:t.from,to:t.to});this.value=i,this.#e=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:{from:t.from,to:t.to},compareValue:We(this.compareValue),presetLabel:e.presetLabel||null}}))}#A(t,e){let i=Zb(e.from),r=Zb(e.to);if(!i||!r)return null;let n=Math.round((r-i)/864e5)+1;switch(t){case"Previous period":{let o=new Date(i);o.setDate(o.getDate()-1);let a=new Date(o);return a.setDate(a.getDate()-(n-1)),{from:Ve(a),to:Ve(o)}}case"Same period last year":{let o=new Date(i);o.setFullYear(o.getFullYear()-1);let a=new Date(r);return a.setFullYear(a.getFullYear()-1),{from:Ve(o),to:Ve(a)}}case"Same period last month":{let o=new Date(i);o.setMonth(o.getMonth()-1);let a=new Date(r);return a.setMonth(a.getMonth()-1),{from:Ve(o),to:Ve(a)}}default:return null}}#C(){if(!this.#a)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#a.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};S("date-range-picker-ui",No);var m1=23,g1=12,VF=1,b1=59,O1=59,dD=["hour","minute"];function Zl(s){if(!s)return null;let t=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(String(s).trim());if(!t)return null;let e=Number(t[1]),i=Number(t[2]),r=t[3]!=null?Number(t[3]):0;return!Number.isFinite(e)||e<0||e>23||!Number.isFinite(i)||i<0||i>59||!Number.isFinite(r)||r<0||r>59?null:{h:e,m:i,s:r}}function Bb({h:s,m:t,s:e},i){let r=n=>String(n).padStart(2,"0");return i==="second"?`${r(s)}:${r(t)}:${r(e)}`:`${r(s)}:${r(t)}`}function Zo({h:s,m:t,s:e}){return s*3600+t*60+e}function fD(s){try{let t=s||document?.documentElement?.lang||void 0,i=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions(),r=i.hourCycle||(i.hour12?"h12":"h23");return r==="h11"||r==="h12"?"h12":"h23"}catch{return"h23"}}var zo=class extends M{static labelDeprecated=!1;static properties={...M.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#r(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:fD(this.locale)}get#n(){return this.#r==="h12"}get#a(){return this.precision==="second"}get#o(){return`${this.#r}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#b),this.addEventListener("focusin",this.#O),this.addEventListener("focusout",this.#y)}render(){this.#i&&this.#i!==this.#o&&this.#l(),this.#u(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#b),this.removeEventListener("focusin",this.#O),this.removeEventListener("focusout",this.#y),this.#t=null,this.#e=[],this.#s=null}clear(){this.value="",this.syncValue(""),this.#u()}stepUp(t,e=1){this.#f(t,1*(e|0||1))}stepDown(t,e=1){this.#f(t,-1*(e|0||1))}#l(){let t=this.#r,e=this.#a,i=this.#n,r=[...dD];e&&r.push("second"),i&&r.push("meridiem"),this.#e=r;let n=this.querySelector(':scope > [slot="prefix"]'),o=this.querySelector(':scope > [slot="suffix"]'),a=(c,u,d)=>`<span data-segment="${c}" role="spinbutton" tabindex="0"
293
+ </div>`;a+=`<div data-cal-weekdays>${oD.map(f=>`<span>${f}</span>`).join("")}</div>`;let l=new Date(t,e,1).getDay(),h=new Date(t,e+1,0).getDate(),c=new Date(t,e,0).getDate();a+="<div data-cal-grid>";for(let f=l-1;f>=0;f--){let p=c-f;a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${p}</button>`}for(let f=1;f<=h;f++){let p=new Date(t,e,f),m=u1(t,e,f),b=d1(p,i),g=r&&d1(p,r),y=n&&p<n||o&&p>o,v=this.#n===f,w=['type="button"',"data-cal-day",`data-date="${m}"`,b?"data-today":"",g?"data-selected":"",y?"disabled":"",v?"data-focused":"",`tabindex="${v?"0":"-1"}"`].filter(Boolean).join(" ");a+=`<button ${w}>${f}</button>`}let d=(7-(l+h)%7)%7;for(let f=1;f<=d;f++)a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${f}</button>`;a+="</div>",this.#t.innerHTML=a}#d(t){this.#r+=t,this.#r>11&&(this.#r=0,this.#s++),this.#r<0&&(this.#r=11,this.#s--),this.#n=null,this.#h()}#u(t){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.open&&this.#h()}#f=t=>{if(!this.disabled&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!this.open,this.open)){let e=es(this.value);if(e)this.#s=e.getFullYear(),this.#r=e.getMonth(),this.#n=e.getDate();else{let i=new Date;this.#s=i.getFullYear(),this.#r=i.getMonth(),this.#n=i.getDate()}}};#p=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!1)};#m=t=>{if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!0);return}if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.#n){let i=u1(this.#s,this.#r,this.#n),r=new Date(this.#s,this.#r,this.#n),n=es(this.min),o=es(this.max);(!n||r>=n)&&(!o||r<=o)&&this.#u(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#s,this.#r+1,0).getDate(),r=(this.#n||1)+e[t.key];if(r<1){this.#d(-1);let o=new Date(this.#s,this.#r+1,0).getDate();this.#n=o+r}else r>i?(this.#d(1),this.#n=r-i):this.#n=r;this.#h(),this.#t?.querySelector("[data-focused]")?.focus()}};disconnected(){super.disconnected(),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.removeEventListener("click",this.#f),this.removeEventListener("keydown",this.#m),document.removeEventListener("pointerdown",this.#p),this.#t&&this.#a&&this.#t.removeEventListener("click",this.#l),this.#a=!1,this.#i?.(),this.#i=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null}};S("calendar-picker-ui",Xo);Ct();var lD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],hD=["January","February","March","April","May","June","July","August","September","October","November","December"];function Nb(s){return String(s).padStart(2,"0")}function Ve(s){return s?`${s.getFullYear()}-${Nb(s.getMonth()+1)}-${Nb(s.getDate())}`:""}function Zb(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}function We(s){if(s==null)return null;if(typeof s=="object")return!s.from||!s.to?null:{from:String(s.from),to:String(s.to)};if(typeof s!="string"||!s.trim())return null;try{let t=JSON.parse(s);if(t&&t.from&&t.to)return{from:String(t.from),to:String(t.to)}}catch{}return null}function f1(s){return s?s.from<=s.to:!1}function p1(s,t){let e=Zb(s);if(!e)return"";switch(t){case"long":return`${hD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${lD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function cD(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=Ve(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),Ve(l)},r=Ve(new Date(t.getFullYear(),t.getMonth(),1)),n=Ve(new Date(t.getFullYear(),t.getMonth()+1,0)),o=Ve(new Date(t.getFullYear(),0,1));return[{label:"Today",range:{from:e,to:e}},{label:"Last 7 days",range:{from:i(6),to:e}},{label:"Last 30 days",range:{from:i(29),to:e}},{label:"This month",range:{from:r,to:n}},{label:"Year to date",range:{from:o,to:e}}]}function uD(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var No=class extends M{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down","arrow-right"];static get properties(){return{...M.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#r=!1;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;get rangeValue(){return We(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return We(this.compareValue)}set rangeCompareValue(t){t==null?this.compareValue="":this.compareValue=JSON.stringify({from:String(t.from),to:String(t.to)})}get presets(){return Array.isArray(this.#t)?this.#t:cD()}set presets(t){F(()=>{this.#t=Array.isArray(t)?t.slice():null,this.isConnected&&this.#p()})}open$(){this.open=!0}close$(){this.open=!1}openPopover(){this.disabled||this.readonly||this.open||(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.comparison&&(this.compareValue=""),this.#e=null,this.syncValue("")}applyPreset(t){let e=this.presets.find(i=>i.label===t);return!e||!e.range?!1:(this.#k(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=We(e);if(this.comparison&&this.name){let r=new FormData;i&&r.append(this.name,e),We(this.compareValue)&&r.append(`${this.name}-compare`,this.compareValue),this.internals.setFormValue(r)}else this.internals.setFormValue(i?e:"");this.#d(i)}#d(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date range.",this),!1):t&&!f1(t)?(this.internals.setValidity({rangeUnderflow:!0},"End date must be on or after start date.",this),!1):t&&this.min&&t.from<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable date is ${this.min}.`,this),!1):t&&this.max&&t.to>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable date is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#s||(this.#s=!0,this.#u(),this.#n.addEventListener("click",this.#g),this.#n.addEventListener("keydown",this.#b,!0),this.#a.addEventListener("click",this.#y),this.#a.addEventListener("keydown",this.#O),this.#l.addEventListener("change",this.#v),this.#c.addEventListener("change",this.#w)),this.syncValue()}disconnected(){super.disconnected(),this.#n&&(this.#n.removeEventListener("click",this.#g),this.#n.removeEventListener("keydown",this.#b,!0)),this.#a&&(this.#a.removeEventListener("click",this.#y),this.#a.removeEventListener("keydown",this.#O),this.#a.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#v),this.#c&&this.#c.removeEventListener("change",this.#w),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#S),this.#h?.(),this.#h=null,this.#s=!1,this.#r=!1,this.#n=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null}#u(){if(this.#n=this.ensure("trigger"),this.#a=this.ensure("popover"),this.id&&this.#a.setAttribute("aria-labelledby",this.id),!this.#a.querySelector(":scope > [data-calendar-area]")){let r=this.constructor._pp.calArea.cloneNode(!0);this.#a.appendChild(r)}let t=this.querySelector(':scope > [slot="presets"]');if(t&&t.parentElement!==this.#a)this.#a.appendChild(t),this.#o=t;else if(!this.noPresets&&!t){if(!this.#a.querySelector(":scope > [data-preset-rail]")){let r=this.constructor._pp.presets.cloneNode(!0);this.#a.insertBefore(r,this.#a.querySelector(":scope > [data-calendar-area]"))}this.#o=this.#a.querySelector(":scope > [data-preset-rail]")}let e=this.#a.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let r=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(r)}if(!e.querySelector(":scope > [data-cal-to]")){let r=this.constructor._pp.calTo.cloneNode(!0),n=We(this.value)?.from,o,a;if(n){let[l,h]=n.split("-").map(Number);o=l,a=h-1}else{let l=new Date;o=l.getFullYear(),a=l.getMonth()}a+=1,a>11&&(a=0,o+=1),r.setAttribute("month",`${o}-${Nb(a+1)}`),e.appendChild(r)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=this.querySelector(':scope > [slot="footer"]');i&&i.parentElement!==this.#a&&this.#a.appendChild(i)}render(){if(!this.#n)return;let t=this.#f();this.#n.setAttribute("text",t),this.#n.toggleAttribute("data-has-value",t!==this.placeholder),this.#n.toggleAttribute("disabled",this.disabled),this.#n.setAttribute("aria-haspopup","dialog"),this.#n.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let e=We(this.value),i=this.#e,r=i?.from||e?.from||"",n=i?.to||e?.to||"",o=a=>{r?a.setAttribute("range-start",r):a.removeAttribute("range-start"),n?a.setAttribute("range-end",n):a.removeAttribute("range-end")};this.#l&&(this.min&&this.#l.setAttribute("min",this.min),this.max&&this.#l.setAttribute("max",this.max),this.#l.value=i?.from||e?.from||"",o(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=i?.to||e?.to||"",o(this.#c)),this.querySelector(':scope > [slot="presets"]')||(this.noPresets?(this.#o?.remove(),this.#o=null):(this.#o||this.#u(),this.#p())),this.#a&&(this.open&&!this.#r?!this.disabled&&!this.readonly?(this.#r=!0,this.#a.showPopover?.(),this.#h?.(),this.#h=ct(this.#n,this.#a,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#x),document.addEventListener("keydown",this.#S),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#r&&(this.#r=!1,this.#h?.(),this.#h=null,this.#a.hidePopover?.(),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#S),this.#n?.focus?.()))}#f(){let t=We(this.value);if(!t)return this.placeholder;let e=p1(t.from,this.format),i=p1(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#p(){if(this.#o){this.#o.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#o.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#o.appendChild(t);for(let e of uD()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#o.appendChild(i)}}}}#m=!1;#g=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#m;this.#m=!1,this.open?this.closePopover("outside"):(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#b=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#y=t=>{if(this.readonly){let r=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),n=t.target.closest("[data-cal-day]");if(r||n){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let r=We(this.value);if(!r)return;let n=this.#A(i.dataset.comparisonPresetLabel,r);n&&(this.rangeCompareValue=n);return}};#O=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#C();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#S=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#l?.value||"";if(!e)return;let i=We(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.from=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));let r=this.#e.to||i?.to||null;r&&this.#k({from:e,to:r})};#w=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#c?.value||"";if(!e)return;let i=We(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from||i?.from||null,to:e}}}));let r=this.#e.from||i?.from||null;r&&this.#k({from:r,to:e})};#x=t=>{this.open&&(this.contains(t.target)||this.#a&&t.composedPath?.().includes(this.#a)||this.closePopover("outside"))};#k(t,e={}){if(!t||!t.from||!t.to)return;if(!f1(t)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"reversed"}}));return}if(this.min&&t.from<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"below-min"}}));return}if(this.max&&t.to>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"above-max"}}));return}let i=JSON.stringify({from:t.from,to:t.to});this.value=i,this.#e=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:{from:t.from,to:t.to},compareValue:We(this.compareValue),presetLabel:e.presetLabel||null}}))}#A(t,e){let i=Zb(e.from),r=Zb(e.to);if(!i||!r)return null;let n=Math.round((r-i)/864e5)+1;switch(t){case"Previous period":{let o=new Date(i);o.setDate(o.getDate()-1);let a=new Date(o);return a.setDate(a.getDate()-(n-1)),{from:Ve(a),to:Ve(o)}}case"Same period last year":{let o=new Date(i);o.setFullYear(o.getFullYear()-1);let a=new Date(r);return a.setFullYear(a.getFullYear()-1),{from:Ve(o),to:Ve(a)}}case"Same period last month":{let o=new Date(i);o.setMonth(o.getMonth()-1);let a=new Date(r);return a.setMonth(a.getMonth()-1),{from:Ve(o),to:Ve(a)}}default:return null}}#C(){if(!this.#a)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#a.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};S("date-range-picker-ui",No);var m1=23,g1=12,VF=1,b1=59,O1=59,dD=["hour","minute"];function Zl(s){if(!s)return null;let t=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(String(s).trim());if(!t)return null;let e=Number(t[1]),i=Number(t[2]),r=t[3]!=null?Number(t[3]):0;return!Number.isFinite(e)||e<0||e>23||!Number.isFinite(i)||i<0||i>59||!Number.isFinite(r)||r<0||r>59?null:{h:e,m:i,s:r}}function Bb({h:s,m:t,s:e},i){let r=n=>String(n).padStart(2,"0");return i==="second"?`${r(s)}:${r(t)}:${r(e)}`:`${r(s)}:${r(t)}`}function Zo({h:s,m:t,s:e}){return s*3600+t*60+e}function fD(s){try{let t=s||document?.documentElement?.lang||void 0,i=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions(),r=i.hourCycle||(i.hour12?"h12":"h23");return r==="h11"||r==="h12"?"h12":"h23"}catch{return"h23"}}var zo=class extends M{static labelDeprecated=!1;static properties={...M.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#r(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:fD(this.locale)}get#n(){return this.#r==="h12"}get#a(){return this.precision==="second"}get#o(){return`${this.#r}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#b),this.addEventListener("focusin",this.#y),this.addEventListener("focusout",this.#O)}render(){this.#i&&this.#i!==this.#o&&this.#l(),this.#d(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#b),this.removeEventListener("focusin",this.#y),this.removeEventListener("focusout",this.#O),this.#t=null,this.#e=[],this.#s=null}clear(){this.value="",this.syncValue(""),this.#d()}stepUp(t,e=1){this.#f(t,1*(e|0||1))}stepDown(t,e=1){this.#f(t,-1*(e|0||1))}#l(){let t=this.#r,e=this.#a,i=this.#n,r=[...dD];e&&r.push("second"),i&&r.push("meridiem"),this.#e=r;let n=this.querySelector(':scope > [slot="prefix"]'),o=this.querySelector(':scope > [slot="suffix"]'),a=(c,u,d)=>`<span data-segment="${c}" role="spinbutton" tabindex="0"
294
294
  aria-label="${u}" aria-valuemin="0" aria-valuemax="${d}"
295
295
  aria-valuenow=""></span>`,l='<span data-separator aria-hidden="true">:</span>',h="";h+=a("hour","Hours",i?g1:m1),h+=l,h+=a("minute","Minutes",b1),e&&(h+=l,h+=a("second","Seconds",O1)),i&&(h+=`<span data-segment="meridiem" role="spinbutton" tabindex="0"
296
296
  aria-label="AM/PM" aria-valuemin="0" aria-valuemax="1"
297
- aria-valuenow="" data-meridiem></span>`),this.innerHTML=h,n&&this.insertBefore(n,this.firstChild),o&&this.appendChild(o),this.#t={};for(let c of r){let u=this.querySelector(`[data-segment="${c}"]`);u&&(this.#t[c]=u)}for(let c of r){let u=this.#t[c];u&&(u.contentEditable="plaintext-only",u.addEventListener("beforeinput",this.#w),u.addEventListener("input",this.#v),u.addEventListener("blur",this.#S),u.addEventListener("focus",this.#x))}this.#i=this.#o}#c(){if(!this.#t)return;let t=!(this.disabled||this.readonly);for(let e of this.#e){let i=this.#t[e];i&&(i.contentEditable=t?"plaintext-only":"false")}}#h(){let t=Zl(this.value);return t||null}#u(){if(!this.#t)return;let t=this.#h(),e=this.#r;if(!t){for(let a of this.#e){let l=this.#t[a];l&&(document.activeElement===l&&l.textContent!==""||(l.textContent="",l.setAttribute("aria-valuenow",""),l.setAttribute("aria-valuetext",this.placeholder)))}return}let i=this.#n?t.h%12||12:t.h,r={hour:zb(i),minute:zb(t.m),second:zb(t.s),meridiem:e==="h12"?t.h>=12?"PM":"AM":""},n={hour:String(i),minute:String(t.m),second:String(t.s),meridiem:e==="h12"?t.h>=12?"1":"0":""},o={hour:`${i} hour${i===1?"":"s"}`,minute:`${t.m} minute${t.m===1?"":"s"}`,second:`${t.s} second${t.s===1?"":"s"}`,meridiem:e==="h12"?t.h>=12?"PM":"AM":""};for(let a of this.#e){let l=this.#t[a];l&&document.activeElement!==l&&(l.textContent=r[a],l.setAttribute("aria-valuenow",n[a]),l.setAttribute("aria-valuetext",o[a]))}}#d(t){if(!this.#t)return;let e=this.#r,i={};for(let d of this.#e)i[d]=(this.#t[d]?.textContent||"").trim();if(!i.hour&&!i.minute){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",segment:t||null}}));return}let r=_b(i.hour,0,e==="h12"?g1:m1),n=_b(i.minute,0,b1),o=this.#a?_b(i.second,0,O1):0;if(r==null||n==null||o==null){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"parse"}}));return}if(e==="h12"){let f=String(i.meridiem||"").trim().toUpperCase()==="PM";r===12?r=f?12:0:f&&(r+=12)}let a={h:r,m:n,s:o},l=Zo(a),h=Zl(this.min),c=Zl(this.max);if(h&&l<Zo(h)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(c&&l>Zo(c)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let u=Bb(a,this.precision);if(u===this.value){this.#u();return}this.value=u,this.syncValue(u),this.#u(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:u,segment:t||null}}))}#f(t,e){if(this.disabled||this.readonly||!this.#t?.[t])return;let i=this.#r,r=Math.max(1,this.step|0),n=this.#h();if(n||(n={h:0,m:0,s:0}),t==="hour")n.h=Bo(n.h+e,0,24);else if(t==="minute"){let c=Math.max(1,Math.floor(r/60))*e;for(n.m=n.m+c;n.m<0;)n.m+=60,n.h=Bo(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=Bo(n.h+1,0,24)}else if(t==="second"){let c=Math.max(1,r)*e;for(n.s=n.s+c;n.s<0;)n.s+=60,n.m-=1;for(;n.s>59;)n.s-=60,n.m+=1;for(;n.m<0;)n.m+=60,n.h=Bo(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=Bo(n.h+1,0,24)}else t==="meridiem"&&(n.h=Bo(n.h+12,0,24));let o=Zo(n),a=Zl(this.min),l=Zl(this.max);if(a&&o<Zo(a)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(l&&o>Zo(l)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let h=Bb(n,this.precision);this.value=h,this.syncValue(h),this.#u(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:h}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:h,segment:t}}))}#p(t,e){if(this.disabled||this.readonly)return;let i=this.#r,r=this.#h()||{h:0,m:0,s:0};t==="hour"?r.h=e==="min"?0:23:t==="minute"?r.m=e==="min"?0:59:t==="second"?r.s=e==="min"?0:59:t==="meridiem"&&(r.h=e==="min"?r.h%12:r.h%12+12);let n=Bb(r,this.precision);this.value=n,this.syncValue(n),this.#u(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,segment:t}}))}#m(t,e){let i=this.#e.indexOf(t);if(i<0)return;let r=i+e;if(r<0||r>=this.#e.length)return;this.#t?.[this.#e[r]]?.focus()}#g(t){if(!(t instanceof Element))return null;let e=t.closest("[data-segment]");return!e||!this.contains(e)?null:e.getAttribute("data-segment")}#b=t=>{if(this.disabled)return;let e=this.#g(t.target);if(e)switch(t.key){case"ArrowUp":t.preventDefault(),this.#f(e,1);return;case"ArrowDown":t.preventDefault(),this.#f(e,-1);return;case"PageUp":t.preventDefault(),this.#f(e,10);return;case"PageDown":t.preventDefault(),this.#f(e,-10);return;case"Home":t.preventDefault(),this.#p(e,"min");return;case"End":t.preventDefault(),this.#p(e,"max");return;case"ArrowLeft":t.preventDefault(),this.#m(e,-1);return;case"ArrowRight":t.preventDefault(),this.#m(e,1);return;case"Enter":t.preventDefault(),this.#d(e);return}};#O=t=>{let e=this.#g(t.target);e&&(this.#s=e,this.setAttribute("editing",""),this.setAttribute("segment",e))};#y=t=>{queueMicrotask(()=>{let e=document.activeElement;(!e||!this.contains(e))&&(this.removeAttribute("editing"),this.removeAttribute("segment"),this.#s=null)})};#w=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;if(this.#g(t.target)==="meridiem"){if(!/^[apmAPM]$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault();return}if(!/^\d$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault()};#v=t=>{let e=this.#g(t.target);if(!e)return;let i=(t.target.textContent||"").trim();if(this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),e==="meridiem"){let r=i.toUpperCase();(r==="AM"||r==="PM")&&(t.target.textContent=r,this.#d(e));return}if(i.length<2){let r=parseInt(t.target.getAttribute("aria-valuemax")||"0",10),n=parseInt(i,10);Number.isNaN(n)||n*10>r&&(this.#d(e),this.#m(e,1))}else this.#d(e),this.#m(e,1)};#S=t=>{let e=this.#g(t.target);e&&this.#d(e)};#x=t=>{let e=t.target;e instanceof HTMLElement&&requestAnimationFrame(()=>{if(document.activeElement!==e)return;let i=window.getSelection?.();if(!i)return;let r=document.createRange();r.selectNodeContents(e),i.removeAllRanges(),i.addRange(r)})};onFormReset(){this.value="",this.#u()}};function zb(s){return String(s).padStart(2,"0")}function _b(s,t,e){if(s===""||s==null)return null;let i=Number(s);return!Number.isFinite(i)||!Number.isInteger(i)||i<t||i>e?null:i}function Bo(s,t,e){let i=s-t,r=e-t;return i=(i%r+r)%r,i+t}S("time-picker-ui",zo);Ct();var pD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],mD=["January","February","March","April","May","June","July","August","September","October","November","December"];function jb(s){return String(s).padStart(2,"0")}function Fs(s){if(!s)return null;let t=String(s).trim(),e=/^(\d{4}-\d{2}-\d{2})[T ](\d{1,2}:\d{2}(?::\d{2})?)$/.exec(t);return e?{date:e[1],time:e[2]}:null}function ed(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let r=jb(Number(i[1])),n=i[2],o=i[3]||"00";return e==="second"?`${s}T${r}:${n}:${o}`:`${s}T${r}:${n}`}function gD(s,t){let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s||"");if(!e)return"";let i=+e[1],r=+e[2]-1,n=+e[3];switch(t){case"long":return`${mD[r]} ${n}, ${i}`;case"iso":return s;default:return`${pD[r]} ${n}, ${i}`}}function bD(s,t,e){let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(s||"");if(!i)return"";let r=+i[1],n=i[2],o=i[3],a,l="";if(e==="h12"){let c=r>=12,u=r%12||12;a=jb(u),l=c?" PM":" AM"}else a=jb(r);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${n}${h}${l}`}var _o=class extends M{static labelDeprecated=!0;static requiredIcons=["calendar","clock","caret-down"];static get properties(){return{...M.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select date and time",reflect:!1},format:{type:String,default:"short",reflect:!0},locale:{type:String,default:"",reflect:!1},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date and time picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date and time picker"></div>',calPane:'<calendar-grid-ui data-cal-pane aria-label="Date"></calendar-grid-ui>',divider:"<divider-ui data-pane-divider vertical></divider-ui>",timePane:"<time-picker-ui data-time-pane></time-picker-ui>"};static template=()=>null;#t=null;#e=null;#i=!1;#s=!1;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=!1;get datetimeValue(){return Fs(this.value)}set datetimeValue(t){F(()=>{t==null?this.value="":typeof t=="string"?this.value=t:t.date&&t.time?this.value=ed(t.date,t.time,this.precision):this.value=""})}openPopover(){this.disabled||this.readonly||this.open||(this.#e=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.#t=null,this.syncValue("")}syncValue(t){let e=t??this.value??"";this.internals.setFormValue(e),this.#u(e)}#u(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date and time.",this),!1):t?Fs(t)?this.min&&t<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable datetime is ${this.min}.`,this),!1):this.max&&t>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable datetime is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0):(this.internals.setValidity({badInput:!0},"Invalid date or time format.",this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#i||(this.#i=!0,this.#d(),this.#r.addEventListener("click",this.#p),this.#r.addEventListener("keydown",this.#m,!0),this.#n.addEventListener("click",this.#g),this.#n.addEventListener("keydown",this.#b),this.#a.addEventListener("change",this.#y),this.#o.addEventListener("change",this.#w),this.#o.addEventListener("input",this.#v),this.#o.addEventListener("invalid",this.#S)),this.syncValue()}disconnected(){super.disconnected(),this.#r&&(this.#r.removeEventListener("click",this.#p),this.#r.removeEventListener("keydown",this.#m,!0)),this.#n&&(this.#n.removeEventListener("click",this.#g),this.#n.removeEventListener("keydown",this.#b),this.#n.hidePopover?.()),this.#a&&this.#a.removeEventListener("change",this.#y),this.#o&&(this.#o.removeEventListener("change",this.#w),this.#o.removeEventListener("input",this.#v),this.#o.removeEventListener("invalid",this.#S)),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#O),this.#c?.(),this.#c=null,this.#i=!1,this.#s=!1,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=null,this.#t=null}#d(){if(this.#r=this.ensure("trigger"),this.#n=this.ensure("popover"),this.id&&this.#n.setAttribute("aria-labelledby",this.id),!this.#n.querySelector(":scope > [data-cal-pane]")){let e=this.constructor._pp.calPane.cloneNode(!0);this.#n.appendChild(e)}if(!this.#n.querySelector(":scope > [data-pane-divider]")){let e=this.constructor._pp.divider.cloneNode(!0);this.#n.appendChild(e)}if(!this.#n.querySelector(":scope > [data-time-pane]")){let e=this.constructor._pp.timePane.cloneNode(!0);this.#n.appendChild(e)}this.#a=this.#n.querySelector(":scope > [data-cal-pane]"),this.#l=this.#n.querySelector(":scope > [data-pane-divider]"),this.#o=this.#n.querySelector(":scope > [data-time-pane]");let t=this.querySelector(':scope > [slot="footer"]');t&&t.parentElement!==this.#n&&this.#n.appendChild(t)}render(){if(!this.#r)return;(!this.#a||!this.#o||!this.#a.isConnected)&&this.#d(),this.#r.setAttribute("text",this.#f()),this.#r.toggleAttribute("data-has-value",this.#f()!==this.placeholder),this.#r.toggleAttribute("disabled",this.disabled),this.#r.setAttribute("aria-haspopup","dialog"),this.#r.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let t=Fs(this.value),e=this.#t,i=e?.date??t?.date??"",r=e?.time??t?.time??"";if(this.#a){let n=this.min?this.min.slice(0,10):"",o=this.max?this.max.slice(0,10):"";n?this.#a.setAttribute("min",n):this.#a.removeAttribute("min"),o?this.#a.setAttribute("max",o):this.#a.removeAttribute("max"),this.#a.value!==i&&(this.#a.value=i),this.#a.toggleAttribute("disabled",!!this.disabled),this.#a.toggleAttribute("readonly",!!this.readonly)}if(this.#o){this.#o.setAttribute("precision",this.precision),this.#o.setAttribute("step",String(this.step)),this.hourcycle?this.#o.setAttribute("hour-cycle",this.hourcycle):this.#o.removeAttribute("hour-cycle"),this.locale?this.#o.setAttribute("locale",this.locale):this.#o.removeAttribute("locale");let n=this.min?this.min.slice(11):"",o=this.max?this.max.slice(11):"";n&&i===this.min.slice(0,10)?this.#o.setAttribute("min",n):this.#o.removeAttribute("min"),o&&i===this.max.slice(0,10)?this.#o.setAttribute("max",o):this.#o.removeAttribute("max"),this.#o.value!==r&&(this.#o.value=r),this.#o.toggleAttribute("disabled",!!this.disabled),this.#o.toggleAttribute("readonly",!!this.readonly)}this.#n&&(this.open&&!this.#s?!this.disabled&&!this.readonly?(this.#s=!0,this.#n.showPopover?.(),this.#c?.(),this.#c=ct(this.#r,this.#n,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#x),document.addEventListener("keydown",this.#O),queueMicrotask(()=>{if(!this.open)return;this.#a?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#s&&(this.#s=!1,this.#c?.(),this.#c=null,this.#n.hidePopover?.(),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#O),this.#r?.focus?.()))}#f(){let t=Fs(this.value);if(!t)return this.placeholder;let e=gD(t.date,this.format),i=bD(t.time,this.precision,this.hourcycle);return!e||!i?this.placeholder:`${e} ${i}`}#p=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#h;this.#h=!1,this.open?this.closePopover("outside"):(this.#e=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#m=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#h=!0}};#g=t=>{let e=t.target.closest("[data-action]");if(e&&this.contains(e)){let i=e.dataset.action;i==="apply"?(this.#A("click"),this.closePopover("apply")):i==="cancel"&&(this.#t=null,this.closePopover("cancel"))}};#b=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#C();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#O=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#y=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#a?.value||"";if(!e)return;this.#t||(this.#t={date:"",time:""}),this.#t.date=e;let i=Fs(this.value),r=this.#t.time||i?.time||"",n=r?ed(e,r,this.precision):`${e}T`;this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:n}})),r?this.#k({date:e,time:r}):queueMicrotask(()=>{if(!this.open)return;this.#o?.querySelector?.('[data-segment="hour"]')?.focus?.()})};#w=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#o?.value||"";if(!e)return;this.#t||(this.#t={date:"",time:""}),this.#t.time=e;let i=Fs(this.value),r=this.#t.date||i?.date||"";r?this.#k({date:r,time:e}):this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:`T${e}`}}))};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"",i=Fs(this.value),r=this.#t?.date||i?.date||"",n=r&&e?ed(r,e,this.precision):e?`T${e}`:"";this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:n}}))};#S=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:t.detail?.reason||"pane"}}))};#x=t=>{this.open&&(this.contains(t.target)||this.#n&&t.composedPath?.().includes(this.#n)||this.closePopover("outside"))};#k(t,e="click"){if(!t||!t.date||!t.time)return;let i=ed(t.date,t.time,this.precision);if(!i){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"parse"}}));return}if(this.min&&i<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"below-min"}}));return}if(this.max&&i>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"above-max"}}));return}this.value=i,this.#t=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:i,source:e}}))}#A(t="click"){let e=this.#a?.value||"",i=this.#o?.value||"";!e||!i||this.#k({date:e,time:i},t)}#C(){if(!this.#n)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","time-picker-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])","[data-segment]",'[tabindex="0"]'].join(",");return Array.from(this.#n.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};S("datetime-picker-ui",_o);$();var jo=class extends x{static properties={src:{type:String,default:"",reflect:!0},height:{type:String,default:"400",reflect:!0},width:{type:String,default:"100%",reflect:!0},aspect:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;connected(){this.#t||(this.#t=document.createElement("iframe"),this.#t.setAttribute("sandbox","allow-scripts allow-same-origin"),this.#t.setAttribute("loading","lazy"),this.#t.setAttribute("allowfullscreen",""),this.appendChild(this.#t))}render(){this.#t&&(this.src&&(this.#t.src=this.src),this.aspect?(this.style.aspectRatio=this.aspect,this.#t.style.width="100%",this.#t.style.height="100%",this.style.width=this.width,this.style.height=""):(this.style.aspectRatio="",this.#t.style.width="100%",this.#t.style.height=this.height.match(/^\d+$/)?`${this.height}px`:this.height,this.style.width=this.width,this.style.height=""))}disconnected(){this.#t=null}};S("embed-ui",jo);$();var OD={none:"0",xs:"var(--a-space-1)",sm:"var(--a-space-2)",md:"var(--a-space-4)",lg:"var(--a-space-6)",xl:"var(--a-space-10)"};function y1(s){return OD[s]??(/^\d+$/.test(s??"")?`var(--a-space-${s})`:s??"")}var Vo=class extends x{static properties={padding:{type:String,default:"md",reflect:!0},margin:{type:String,default:"none",reflect:!0}};static template=()=>null;render(){let t=this.padding,e=this.margin,r=t?.includes("@")||e?.includes("@")?Ce.value:"";t?.includes("@")?this.style.setProperty("--block-padding",y1(Nt(t,r))):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",y1(Nt(e,r))):this.style.removeProperty("--block-margin")}};S("block-ui",Vo);$();var yD={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function vD(s){return yD[s]??s}var Wo=class extends x{static properties={variant:{type:String,default:"body",reflect:!0},strong:{type:Boolean,default:!1,reflect:!0},truncate:{type:Boolean,default:!1,reflect:!0},lines:{type:Number,default:0,reflect:!0},size:{type:String,default:"",reflect:!0},color:{type:String,default:"",reflect:!0},weight:{type:String,default:"",reflect:!0},"text-align":{type:String,default:"",reflect:!0}};static template=()=>null;render(){this.lines>0?this.style.setProperty("--_text-lines",String(this.lines)):this.style.removeProperty("--_text-lines");let t=this.size;if(t?.includes("@")){let e=Ce.value;this.style.setProperty("--text-size",vD(Nt(t,e)))}else this.style.removeProperty("--text-size")}};S("text-ui",Wo);$();var Uo=class extends x{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}};static template=()=>null;#t=!1;connected(){this.setAttribute("role","button"),this.setAttribute("tabindex","0")}render(){this.#t||(this.#t=!0,this.#e()),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}#e(){let t="";this.icon&&(t+=`<icon-ui name="${this.icon}"></icon-ui>`),this.text&&(t+=`<span data-text>${this.text}</span>`),this.innerHTML=t}disconnected(){this.#t=!1}},Fo=class extends x{static properties={value:{type:String,default:"",reflect:!0},single:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;get#e(){return new Set(this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[])}connected(){this.#t||(this.#t=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#r)),this.setAttribute("role","group")}render(){let t=this.#e;for(let e of this.querySelectorAll("toggle-option-ui")){let i=e.value||e.getAttribute("value")||"";t.has(i)?(e.setAttribute("data-selected",""),e.setAttribute("aria-pressed","true")):(e.removeAttribute("data-selected"),e.setAttribute("aria-pressed","false"))}}#i(t){if(t.disabled)return;let e=t.value||t.getAttribute("value")||"";if(!e)return;let i=this.#e;this.single?i.has(e)?i.clear():(i.clear(),i.add(e)):i.has(e)?i.delete(e):i.add(e),this.value=[...i].join(","),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}#s=t=>{let e=t.target.closest("toggle-option-ui");e&&this.contains(e)&&this.#i(e)};#r=t=>{if(t.key==="Enter"||t.key===" "){t.preventDefault();let e=t.target.closest("toggle-option-ui");e&&this.contains(e)&&this.#i(e)}};disconnected(){this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#r),this.#t=!1}};S("toggle-option-ui",Uo),S("toggle-group-ui",Fo);$();var Ii="light",qe="dark",Vb="auto",Yo=class extends x{static properties={scheme:{type:String,default:Vb,reflect:!0},target:{type:String,default:":root",reflect:!0},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},iconLight:{type:String,default:"sun",reflect:!0,attribute:"icon-light"},iconDark:{type:String,default:"moon",reflect:!0,attribute:"icon-dark"},labelLight:{type:String,default:"Switch to dark mode",reflect:!0,attribute:"label-light"},labelDark:{type:String,default:"Switch to light mode",reflect:!0,attribute:"label-dark"},size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"ghost",reflect:!0},color:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=!1;#n=!1;connected(){this.#r||(this.#a(),this.#r=!0),this.#o()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="scheme"&&this.isConnected&&this.#r&&!this.#n&&e!==i&&this.#o()}disconnected(){this.#t&&this.#s&&this.#t.removeEventListener("press",this.#s),this.#g()}toggle(){this.#n=!0;let t=this.activeScheme===qe?Ii:qe;this.#l(t,"programmatic")}setScheme(t){if(this.#n=!0,t===Vb){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Ii||t===qe)&&this.#l(t,"programmatic")}#a(){let t=document.createElement("button-ui");t.setAttribute("part","button"),t.setAttribute("variant",this.variant||"ghost"),t.setAttribute("size",this.size||"md"),this.color&&t.setAttribute("color",this.color),this.disabled&&t.setAttribute("disabled",""),this.appendChild(t),this.#t=t,this.#s=e=>{if(e.stopPropagation(),this.disabled)return;this.#n=!0;let i=this.activeScheme===qe?Ii:qe;this.#l(i,"press")},t.addEventListener("press",this.#s)}#o(){let t=null;if(this.persist)try{let e=localStorage.getItem(`${this.storagePrefix}scheme`);(e===Ii||e===qe)&&(t=e)}catch{}if(t===null){let e=this.scheme||Vb;(e===Ii||e===qe)&&(t=e)}t===Ii||t===qe?(this.#d(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Ii&&t!==qe)){if(this.#d(t),this.activeScheme=t,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,t)}catch{}this.#g(),this.#c(),this.#h(e)}}#c(){if(!this.#t)return;let t=this.activeScheme===qe,e=t?this.iconDark:this.iconLight,i=t?this.labelDark:this.labelLight;this.#t.getAttribute("icon")!==e&&this.#t.setAttribute("icon",e),this.#t.setAttribute("aria-label",i),this.#t.setAttribute("title",i),this.#t.getAttribute("variant")!==this.variant&&this.#t.setAttribute("variant",this.variant||"ghost"),this.#t.getAttribute("size")!==this.size&&this.#t.setAttribute("size",this.size||"md"),this.color?this.#t.setAttribute("color",this.color):this.#t.removeAttribute("color"),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled")}render(){this.#c()}#h(t){this.dispatchEvent(new CustomEvent("scheme-change",{bubbles:!0,detail:{scheme:this.activeScheme,source:t}}))}#u(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}#d(t){let e=this.#u();e.style.setProperty("color-scheme",t),e.setAttribute("data-scheme",t)}#f(){let t=this.#u();if(t.style.removeProperty("color-scheme"),t.removeAttribute("data-scheme"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}}#p(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return qe}catch{}return Ii}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?qe:Ii;t!==this.activeScheme&&(this.activeScheme=t,this.#c(),this.#h("media"))},this.#e.addEventListener("change",this.#i)}catch{}}#g(){if(this.#e&&this.#i)try{this.#e.removeEventListener("change",this.#i)}catch{}this.#e=null,this.#i=null}};S("toggle-scheme-ui",Yo);$();var Ho=class extends x{static properties={labelOn:{type:String,default:"On",attribute:"label-on",reflect:!0},labelOff:{type:String,default:"Off",attribute:"label-off",reflect:!0},initial:{type:String,default:"off",reflect:!0},state:{type:String,default:"",reflect:!0}};static parts={bar:`
297
+ aria-valuenow="" data-meridiem></span>`),this.innerHTML=h,n&&this.insertBefore(n,this.firstChild),o&&this.appendChild(o),this.#t={};for(let c of r){let u=this.querySelector(`[data-segment="${c}"]`);u&&(this.#t[c]=u)}for(let c of r){let u=this.#t[c];u&&(u.contentEditable="plaintext-only",u.addEventListener("beforeinput",this.#S),u.addEventListener("input",this.#v),u.addEventListener("blur",this.#w),u.addEventListener("focus",this.#x))}this.#i=this.#o}#c(){if(!this.#t)return;let t=!(this.disabled||this.readonly);for(let e of this.#e){let i=this.#t[e];i&&(i.contentEditable=t?"plaintext-only":"false")}}#h(){let t=Zl(this.value);return t||null}#d(){if(!this.#t)return;let t=this.#h(),e=this.#r;if(!t){for(let a of this.#e){let l=this.#t[a];l&&(document.activeElement===l&&l.textContent!==""||(l.textContent="",l.setAttribute("aria-valuenow",""),l.setAttribute("aria-valuetext",this.placeholder)))}return}let i=this.#n?t.h%12||12:t.h,r={hour:zb(i),minute:zb(t.m),second:zb(t.s),meridiem:e==="h12"?t.h>=12?"PM":"AM":""},n={hour:String(i),minute:String(t.m),second:String(t.s),meridiem:e==="h12"?t.h>=12?"1":"0":""},o={hour:`${i} hour${i===1?"":"s"}`,minute:`${t.m} minute${t.m===1?"":"s"}`,second:`${t.s} second${t.s===1?"":"s"}`,meridiem:e==="h12"?t.h>=12?"PM":"AM":""};for(let a of this.#e){let l=this.#t[a];l&&document.activeElement!==l&&(l.textContent=r[a],l.setAttribute("aria-valuenow",n[a]),l.setAttribute("aria-valuetext",o[a]))}}#u(t){if(!this.#t)return;let e=this.#r,i={};for(let d of this.#e)i[d]=(this.#t[d]?.textContent||"").trim();if(!i.hour&&!i.minute){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",segment:t||null}}));return}let r=_b(i.hour,0,e==="h12"?g1:m1),n=_b(i.minute,0,b1),o=this.#a?_b(i.second,0,O1):0;if(r==null||n==null||o==null){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"parse"}}));return}if(e==="h12"){let f=String(i.meridiem||"").trim().toUpperCase()==="PM";r===12?r=f?12:0:f&&(r+=12)}let a={h:r,m:n,s:o},l=Zo(a),h=Zl(this.min),c=Zl(this.max);if(h&&l<Zo(h)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(c&&l>Zo(c)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let u=Bb(a,this.precision);if(u===this.value){this.#d();return}this.value=u,this.syncValue(u),this.#d(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:u,segment:t||null}}))}#f(t,e){if(this.disabled||this.readonly||!this.#t?.[t])return;let i=this.#r,r=Math.max(1,this.step|0),n=this.#h();if(n||(n={h:0,m:0,s:0}),t==="hour")n.h=Bo(n.h+e,0,24);else if(t==="minute"){let c=Math.max(1,Math.floor(r/60))*e;for(n.m=n.m+c;n.m<0;)n.m+=60,n.h=Bo(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=Bo(n.h+1,0,24)}else if(t==="second"){let c=Math.max(1,r)*e;for(n.s=n.s+c;n.s<0;)n.s+=60,n.m-=1;for(;n.s>59;)n.s-=60,n.m+=1;for(;n.m<0;)n.m+=60,n.h=Bo(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=Bo(n.h+1,0,24)}else t==="meridiem"&&(n.h=Bo(n.h+12,0,24));let o=Zo(n),a=Zl(this.min),l=Zl(this.max);if(a&&o<Zo(a)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(l&&o>Zo(l)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let h=Bb(n,this.precision);this.value=h,this.syncValue(h),this.#d(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:h}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:h,segment:t}}))}#p(t,e){if(this.disabled||this.readonly)return;let i=this.#r,r=this.#h()||{h:0,m:0,s:0};t==="hour"?r.h=e==="min"?0:23:t==="minute"?r.m=e==="min"?0:59:t==="second"?r.s=e==="min"?0:59:t==="meridiem"&&(r.h=e==="min"?r.h%12:r.h%12+12);let n=Bb(r,this.precision);this.value=n,this.syncValue(n),this.#d(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,segment:t}}))}#m(t,e){let i=this.#e.indexOf(t);if(i<0)return;let r=i+e;if(r<0||r>=this.#e.length)return;this.#t?.[this.#e[r]]?.focus()}#g(t){if(!(t instanceof Element))return null;let e=t.closest("[data-segment]");return!e||!this.contains(e)?null:e.getAttribute("data-segment")}#b=t=>{if(this.disabled)return;let e=this.#g(t.target);if(e)switch(t.key){case"ArrowUp":t.preventDefault(),this.#f(e,1);return;case"ArrowDown":t.preventDefault(),this.#f(e,-1);return;case"PageUp":t.preventDefault(),this.#f(e,10);return;case"PageDown":t.preventDefault(),this.#f(e,-10);return;case"Home":t.preventDefault(),this.#p(e,"min");return;case"End":t.preventDefault(),this.#p(e,"max");return;case"ArrowLeft":t.preventDefault(),this.#m(e,-1);return;case"ArrowRight":t.preventDefault(),this.#m(e,1);return;case"Enter":t.preventDefault(),this.#u(e);return}};#y=t=>{let e=this.#g(t.target);e&&(this.#s=e,this.setAttribute("editing",""),this.setAttribute("segment",e))};#O=t=>{queueMicrotask(()=>{let e=document.activeElement;(!e||!this.contains(e))&&(this.removeAttribute("editing"),this.removeAttribute("segment"),this.#s=null)})};#S=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;if(this.#g(t.target)==="meridiem"){if(!/^[apmAPM]$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault();return}if(!/^\d$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault()};#v=t=>{let e=this.#g(t.target);if(!e)return;let i=(t.target.textContent||"").trim();if(this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),e==="meridiem"){let r=i.toUpperCase();(r==="AM"||r==="PM")&&(t.target.textContent=r,this.#u(e));return}if(i.length<2){let r=parseInt(t.target.getAttribute("aria-valuemax")||"0",10),n=parseInt(i,10);Number.isNaN(n)||n*10>r&&(this.#u(e),this.#m(e,1))}else this.#u(e),this.#m(e,1)};#w=t=>{let e=this.#g(t.target);e&&this.#u(e)};#x=t=>{let e=t.target;e instanceof HTMLElement&&requestAnimationFrame(()=>{if(document.activeElement!==e)return;let i=window.getSelection?.();if(!i)return;let r=document.createRange();r.selectNodeContents(e),i.removeAllRanges(),i.addRange(r)})};onFormReset(){this.value="",this.#d()}};function zb(s){return String(s).padStart(2,"0")}function _b(s,t,e){if(s===""||s==null)return null;let i=Number(s);return!Number.isFinite(i)||!Number.isInteger(i)||i<t||i>e?null:i}function Bo(s,t,e){let i=s-t,r=e-t;return i=(i%r+r)%r,i+t}S("time-picker-ui",zo);Ct();var pD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],mD=["January","February","March","April","May","June","July","August","September","October","November","December"];function jb(s){return String(s).padStart(2,"0")}function Fs(s){if(!s)return null;let t=String(s).trim(),e=/^(\d{4}-\d{2}-\d{2})[T ](\d{1,2}:\d{2}(?::\d{2})?)$/.exec(t);return e?{date:e[1],time:e[2]}:null}function ed(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let r=jb(Number(i[1])),n=i[2],o=i[3]||"00";return e==="second"?`${s}T${r}:${n}:${o}`:`${s}T${r}:${n}`}function gD(s,t){let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s||"");if(!e)return"";let i=+e[1],r=+e[2]-1,n=+e[3];switch(t){case"long":return`${mD[r]} ${n}, ${i}`;case"iso":return s;default:return`${pD[r]} ${n}, ${i}`}}function bD(s,t,e){let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(s||"");if(!i)return"";let r=+i[1],n=i[2],o=i[3],a,l="";if(e==="h12"){let c=r>=12,u=r%12||12;a=jb(u),l=c?" PM":" AM"}else a=jb(r);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${n}${h}${l}`}var _o=class extends M{static labelDeprecated=!0;static requiredIcons=["calendar","clock","caret-down"];static get properties(){return{...M.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select date and time",reflect:!1},format:{type:String,default:"short",reflect:!0},locale:{type:String,default:"",reflect:!1},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date and time picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date and time picker"></div>',calPane:'<calendar-grid-ui data-cal-pane aria-label="Date"></calendar-grid-ui>',divider:"<divider-ui data-pane-divider vertical></divider-ui>",timePane:"<time-picker-ui data-time-pane></time-picker-ui>"};static template=()=>null;#t=null;#e=null;#i=!1;#s=!1;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=!1;get datetimeValue(){return Fs(this.value)}set datetimeValue(t){F(()=>{t==null?this.value="":typeof t=="string"?this.value=t:t.date&&t.time?this.value=ed(t.date,t.time,this.precision):this.value=""})}openPopover(){this.disabled||this.readonly||this.open||(this.#e=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.#t=null,this.syncValue("")}syncValue(t){let e=t??this.value??"";this.internals.setFormValue(e),this.#d(e)}#d(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date and time.",this),!1):t?Fs(t)?this.min&&t<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable datetime is ${this.min}.`,this),!1):this.max&&t>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable datetime is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0):(this.internals.setValidity({badInput:!0},"Invalid date or time format.",this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#i||(this.#i=!0,this.#u(),this.#r.addEventListener("click",this.#p),this.#r.addEventListener("keydown",this.#m,!0),this.#n.addEventListener("click",this.#g),this.#n.addEventListener("keydown",this.#b),this.#a.addEventListener("change",this.#O),this.#o.addEventListener("change",this.#S),this.#o.addEventListener("input",this.#v),this.#o.addEventListener("invalid",this.#w)),this.syncValue()}disconnected(){super.disconnected(),this.#r&&(this.#r.removeEventListener("click",this.#p),this.#r.removeEventListener("keydown",this.#m,!0)),this.#n&&(this.#n.removeEventListener("click",this.#g),this.#n.removeEventListener("keydown",this.#b),this.#n.hidePopover?.()),this.#a&&this.#a.removeEventListener("change",this.#O),this.#o&&(this.#o.removeEventListener("change",this.#S),this.#o.removeEventListener("input",this.#v),this.#o.removeEventListener("invalid",this.#w)),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#y),this.#c?.(),this.#c=null,this.#i=!1,this.#s=!1,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=null,this.#t=null}#u(){if(this.#r=this.ensure("trigger"),this.#n=this.ensure("popover"),this.id&&this.#n.setAttribute("aria-labelledby",this.id),!this.#n.querySelector(":scope > [data-cal-pane]")){let e=this.constructor._pp.calPane.cloneNode(!0);this.#n.appendChild(e)}if(!this.#n.querySelector(":scope > [data-pane-divider]")){let e=this.constructor._pp.divider.cloneNode(!0);this.#n.appendChild(e)}if(!this.#n.querySelector(":scope > [data-time-pane]")){let e=this.constructor._pp.timePane.cloneNode(!0);this.#n.appendChild(e)}this.#a=this.#n.querySelector(":scope > [data-cal-pane]"),this.#l=this.#n.querySelector(":scope > [data-pane-divider]"),this.#o=this.#n.querySelector(":scope > [data-time-pane]");let t=this.querySelector(':scope > [slot="footer"]');t&&t.parentElement!==this.#n&&this.#n.appendChild(t)}render(){if(!this.#r)return;(!this.#a||!this.#o||!this.#a.isConnected)&&this.#u(),this.#r.setAttribute("text",this.#f()),this.#r.toggleAttribute("data-has-value",this.#f()!==this.placeholder),this.#r.toggleAttribute("disabled",this.disabled),this.#r.setAttribute("aria-haspopup","dialog"),this.#r.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let t=Fs(this.value),e=this.#t,i=e?.date??t?.date??"",r=e?.time??t?.time??"";if(this.#a){let n=this.min?this.min.slice(0,10):"",o=this.max?this.max.slice(0,10):"";n?this.#a.setAttribute("min",n):this.#a.removeAttribute("min"),o?this.#a.setAttribute("max",o):this.#a.removeAttribute("max"),this.#a.value!==i&&(this.#a.value=i),this.#a.toggleAttribute("disabled",!!this.disabled),this.#a.toggleAttribute("readonly",!!this.readonly)}if(this.#o){this.#o.setAttribute("precision",this.precision),this.#o.setAttribute("step",String(this.step)),this.hourcycle?this.#o.setAttribute("hour-cycle",this.hourcycle):this.#o.removeAttribute("hour-cycle"),this.locale?this.#o.setAttribute("locale",this.locale):this.#o.removeAttribute("locale");let n=this.min?this.min.slice(11):"",o=this.max?this.max.slice(11):"";n&&i===this.min.slice(0,10)?this.#o.setAttribute("min",n):this.#o.removeAttribute("min"),o&&i===this.max.slice(0,10)?this.#o.setAttribute("max",o):this.#o.removeAttribute("max"),this.#o.value!==r&&(this.#o.value=r),this.#o.toggleAttribute("disabled",!!this.disabled),this.#o.toggleAttribute("readonly",!!this.readonly)}this.#n&&(this.open&&!this.#s?!this.disabled&&!this.readonly?(this.#s=!0,this.#n.showPopover?.(),this.#c?.(),this.#c=ct(this.#r,this.#n,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#x),document.addEventListener("keydown",this.#y),queueMicrotask(()=>{if(!this.open)return;this.#a?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#s&&(this.#s=!1,this.#c?.(),this.#c=null,this.#n.hidePopover?.(),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#y),this.#r?.focus?.()))}#f(){let t=Fs(this.value);if(!t)return this.placeholder;let e=gD(t.date,this.format),i=bD(t.time,this.precision,this.hourcycle);return!e||!i?this.placeholder:`${e} ${i}`}#p=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#h;this.#h=!1,this.open?this.closePopover("outside"):(this.#e=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#m=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#h=!0}};#g=t=>{let e=t.target.closest("[data-action]");if(e&&this.contains(e)){let i=e.dataset.action;i==="apply"?(this.#A("click"),this.closePopover("apply")):i==="cancel"&&(this.#t=null,this.closePopover("cancel"))}};#b=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#C();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#y=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#O=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#a?.value||"";if(!e)return;this.#t||(this.#t={date:"",time:""}),this.#t.date=e;let i=Fs(this.value),r=this.#t.time||i?.time||"",n=r?ed(e,r,this.precision):`${e}T`;this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:n}})),r?this.#k({date:e,time:r}):queueMicrotask(()=>{if(!this.open)return;this.#o?.querySelector?.('[data-segment="hour"]')?.focus?.()})};#S=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#o?.value||"";if(!e)return;this.#t||(this.#t={date:"",time:""}),this.#t.time=e;let i=Fs(this.value),r=this.#t.date||i?.date||"";r?this.#k({date:r,time:e}):this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:`T${e}`}}))};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"",i=Fs(this.value),r=this.#t?.date||i?.date||"",n=r&&e?ed(r,e,this.precision):e?`T${e}`:"";this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:n}}))};#w=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:t.detail?.reason||"pane"}}))};#x=t=>{this.open&&(this.contains(t.target)||this.#n&&t.composedPath?.().includes(this.#n)||this.closePopover("outside"))};#k(t,e="click"){if(!t||!t.date||!t.time)return;let i=ed(t.date,t.time,this.precision);if(!i){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"parse"}}));return}if(this.min&&i<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"below-min"}}));return}if(this.max&&i>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"above-max"}}));return}this.value=i,this.#t=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:i,source:e}}))}#A(t="click"){let e=this.#a?.value||"",i=this.#o?.value||"";!e||!i||this.#k({date:e,time:i},t)}#C(){if(!this.#n)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","time-picker-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])","[data-segment]",'[tabindex="0"]'].join(",");return Array.from(this.#n.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};S("datetime-picker-ui",_o);$();var jo=class extends x{static properties={src:{type:String,default:"",reflect:!0},height:{type:String,default:"400",reflect:!0},width:{type:String,default:"100%",reflect:!0},aspect:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;connected(){this.#t||(this.#t=document.createElement("iframe"),this.#t.setAttribute("sandbox","allow-scripts allow-same-origin"),this.#t.setAttribute("loading","lazy"),this.#t.setAttribute("allowfullscreen",""),this.appendChild(this.#t))}render(){this.#t&&(this.src&&(this.#t.src=this.src),this.aspect?(this.style.aspectRatio=this.aspect,this.#t.style.width="100%",this.#t.style.height="100%",this.style.width=this.width,this.style.height=""):(this.style.aspectRatio="",this.#t.style.width="100%",this.#t.style.height=this.height.match(/^\d+$/)?`${this.height}px`:this.height,this.style.width=this.width,this.style.height=""))}disconnected(){this.#t=null}};S("embed-ui",jo);$();var OD={none:"0",xs:"var(--a-space-1)",sm:"var(--a-space-2)",md:"var(--a-space-4)",lg:"var(--a-space-6)",xl:"var(--a-space-10)"};function y1(s){return OD[s]??(/^\d+$/.test(s??"")?`var(--a-space-${s})`:s??"")}var Vo=class extends x{static properties={padding:{type:String,default:"md",reflect:!0},margin:{type:String,default:"none",reflect:!0}};static template=()=>null;render(){let t=this.padding,e=this.margin,r=t?.includes("@")||e?.includes("@")?Ce.value:"";t?.includes("@")?this.style.setProperty("--block-padding",y1(Nt(t,r))):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",y1(Nt(e,r))):this.style.removeProperty("--block-margin")}};S("block-ui",Vo);$();var yD={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function vD(s){return yD[s]??s}var Wo=class extends x{static properties={variant:{type:String,default:"body",reflect:!0},strong:{type:Boolean,default:!1,reflect:!0},truncate:{type:Boolean,default:!1,reflect:!0},lines:{type:Number,default:0,reflect:!0},size:{type:String,default:"",reflect:!0},color:{type:String,default:"",reflect:!0},weight:{type:String,default:"",reflect:!0},"text-align":{type:String,default:"",reflect:!0}};static template=()=>null;render(){this.lines>0?this.style.setProperty("--_text-lines",String(this.lines)):this.style.removeProperty("--_text-lines");let t=this.size;if(t?.includes("@")){let e=Ce.value;this.style.setProperty("--text-size",vD(Nt(t,e)))}else this.style.removeProperty("--text-size")}};S("text-ui",Wo);$();var Uo=class extends x{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}};static template=()=>null;#t=!1;connected(){this.setAttribute("role","button"),this.setAttribute("tabindex","0")}render(){this.#t||(this.#t=!0,this.#e()),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}#e(){let t="";this.icon&&(t+=`<icon-ui name="${this.icon}"></icon-ui>`),this.text&&(t+=`<span data-text>${this.text}</span>`),this.innerHTML=t}disconnected(){this.#t=!1}},Fo=class extends x{static properties={value:{type:String,default:"",reflect:!0},single:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;get#e(){return new Set(this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[])}connected(){this.#t||(this.#t=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#r)),this.setAttribute("role","group")}render(){let t=this.#e;for(let e of this.querySelectorAll("toggle-option-ui")){let i=e.value||e.getAttribute("value")||"";t.has(i)?(e.setAttribute("data-selected",""),e.setAttribute("aria-pressed","true")):(e.removeAttribute("data-selected"),e.setAttribute("aria-pressed","false"))}}#i(t){if(t.disabled)return;let e=t.value||t.getAttribute("value")||"";if(!e)return;let i=this.#e;this.single?i.has(e)?i.clear():(i.clear(),i.add(e)):i.has(e)?i.delete(e):i.add(e),this.value=[...i].join(","),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}#s=t=>{let e=t.target.closest("toggle-option-ui");e&&this.contains(e)&&this.#i(e)};#r=t=>{if(t.key==="Enter"||t.key===" "){t.preventDefault();let e=t.target.closest("toggle-option-ui");e&&this.contains(e)&&this.#i(e)}};disconnected(){this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#r),this.#t=!1}};S("toggle-option-ui",Uo),S("toggle-group-ui",Fo);$();var Ii="light",qe="dark",Vb="auto",Yo=class extends x{static properties={scheme:{type:String,default:Vb,reflect:!0},target:{type:String,default:":root",reflect:!0},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},iconLight:{type:String,default:"sun",reflect:!0,attribute:"icon-light"},iconDark:{type:String,default:"moon",reflect:!0,attribute:"icon-dark"},labelLight:{type:String,default:"Switch to dark mode",reflect:!0,attribute:"label-light"},labelDark:{type:String,default:"Switch to light mode",reflect:!0,attribute:"label-dark"},size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"ghost",reflect:!0},color:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=!1;#n=!1;connected(){this.#r||(this.#a(),this.#r=!0),this.#o()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="scheme"&&this.isConnected&&this.#r&&!this.#n&&e!==i&&this.#o()}disconnected(){this.#t&&this.#s&&this.#t.removeEventListener("press",this.#s),this.#g()}toggle(){this.#n=!0;let t=this.activeScheme===qe?Ii:qe;this.#l(t,"programmatic")}setScheme(t){if(this.#n=!0,t===Vb){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Ii||t===qe)&&this.#l(t,"programmatic")}#a(){let t=document.createElement("button-ui");t.setAttribute("part","button"),t.setAttribute("variant",this.variant||"ghost"),t.setAttribute("size",this.size||"md"),this.color&&t.setAttribute("color",this.color),this.disabled&&t.setAttribute("disabled",""),this.appendChild(t),this.#t=t,this.#s=e=>{if(e.stopPropagation(),this.disabled)return;this.#n=!0;let i=this.activeScheme===qe?Ii:qe;this.#l(i,"press")},t.addEventListener("press",this.#s)}#o(){let t=null;if(this.persist)try{let e=localStorage.getItem(`${this.storagePrefix}scheme`);(e===Ii||e===qe)&&(t=e)}catch{}if(t===null){let e=this.scheme||Vb;(e===Ii||e===qe)&&(t=e)}t===Ii||t===qe?(this.#u(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Ii&&t!==qe)){if(this.#u(t),this.activeScheme=t,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,t)}catch{}this.#g(),this.#c(),this.#h(e)}}#c(){if(!this.#t)return;let t=this.activeScheme===qe,e=t?this.iconDark:this.iconLight,i=t?this.labelDark:this.labelLight;this.#t.getAttribute("icon")!==e&&this.#t.setAttribute("icon",e),this.#t.setAttribute("aria-label",i),this.#t.setAttribute("title",i),this.#t.getAttribute("variant")!==this.variant&&this.#t.setAttribute("variant",this.variant||"ghost"),this.#t.getAttribute("size")!==this.size&&this.#t.setAttribute("size",this.size||"md"),this.color?this.#t.setAttribute("color",this.color):this.#t.removeAttribute("color"),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled")}render(){this.#c()}#h(t){this.dispatchEvent(new CustomEvent("scheme-change",{bubbles:!0,detail:{scheme:this.activeScheme,source:t}}))}#d(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}#u(t){let e=this.#d();e.style.setProperty("color-scheme",t),e.setAttribute("data-scheme",t)}#f(){let t=this.#d();if(t.style.removeProperty("color-scheme"),t.removeAttribute("data-scheme"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}}#p(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return qe}catch{}return Ii}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?qe:Ii;t!==this.activeScheme&&(this.activeScheme=t,this.#c(),this.#h("media"))},this.#e.addEventListener("change",this.#i)}catch{}}#g(){if(this.#e&&this.#i)try{this.#e.removeEventListener("change",this.#i)}catch{}this.#e=null,this.#i=null}};S("toggle-scheme-ui",Yo);$();var Ho=class extends x{static properties={labelOn:{type:String,default:"On",attribute:"label-on",reflect:!0},labelOff:{type:String,default:"Off",attribute:"label-off",reflect:!0},initial:{type:String,default:"off",reflect:!0},state:{type:String,default:"",reflect:!0}};static parts={bar:`
298
298
  <row-ui slot="bar" gap="3" align="center" data-demo-toggle-bar>
299
299
  <text-ui slot="label" data-demo-toggle-label></text-ui>
300
300
  <switch-ui slot="switch" data-demo-toggle-switch></switch-ui>
301
301
  </row-ui>
302
- `};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.#r))}disconnected(){this.#e&&this.#e.removeEventListener("change",this.#r),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}}))}#r=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}})))}};S("demo-toggle-ui",Ho);$();var Go=class extends x{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=ci(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=ci(e)}catch(t){if(!this.isConnected)return;this.#t.innerHTML=`<p>Error: ${t.message}</p>`}}};S("richtext-ui",Go);$();var Ko=class extends x{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 r of i){if(e.aborted)break;this.textContent+=r,await new Promise(n=>setTimeout(n,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()}};S("stream-ui",Ko);$();var fd=class s extends x{static properties={theme:{type:String,default:"",reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=[];#r=-1;static MAX_HISTORY=10;#n=null;static#a=!1;#o=t=>{t.target.closest("input, textarea, [contenteditable]")||!this.contains(document.activeElement)&&(document.activeElement,document.body)};#l=t=>{this.#e?.contains(t.target)&&this.#m("click",t.target)};#c=t=>{this.#e?.contains(t.target)&&this.#m("change",t.target)};#h=t=>{this.#e?.contains(t.target)&&this.#m("input",t.target)};#u=t=>{this.dispatchEvent(new CustomEvent("canvas-interaction",{bubbles:!0,detail:{type:"retry",targetTag:"button-ui",targetId:"retry",value:"",...t.detail}}))};connected(){document.addEventListener("keydown",this.#o),this.addEventListener("click",this.#l),this.addEventListener("change",this.#c),this.addEventListener("input",this.#h),this.addEventListener("a2ui-retry",this.#u),this.#d()}disconnected(){document.removeEventListener("keydown",this.#o),this.removeEventListener("click",this.#l),this.removeEventListener("change",this.#c),this.removeEventListener("input",this.#h),this.removeEventListener("a2ui-retry",this.#u),this.#e=null,this.#i=null,this.#t=!1}#d(){return this.#n?this.#n:customElements.get("a2ui-root")?(this.#n=Promise.resolve(!0),this.#n):(this.#n=Promise.resolve().then(()=>(cO(),V1)).then(()=>customElements.whenDefined("a2ui-root")).then(()=>!0).catch(t=>(s.#a||(s.#a=!0,console.warn("[canvas-ui] A2UI renderer <a2ui-root> could not be loaded \u2014 install @adia-ai/web-modules to render generated UI in <canvas-ui>. Apps that use only primitives (and never <canvas-ui>) can ignore this.",t)),!1)),this.#n)}#f(t){if(this.#e&&typeof this.#e.process=="function"){t(this.#e);return}this.#d().then(e=>{e&&this.#e&&typeof this.#e.process=="function"&&t(this.#e)})}render(){if(!this.#t){if(this.#t=!0,this.#i=document.createElement("div"),this.#i.setAttribute("data-canvas-surface",""),this.#e=document.createElement("a2ui-root"),this.theme){let t=document.createElement("theme-ui");t.setAttribute("preset",this.theme),t.appendChild(this.#e),this.#i.appendChild(t)}else this.#i.appendChild(this.#e);this.appendChild(this.#i)}}process(t){this.#f(e=>e.process(t))}processAll(t){this.#f(e=>{for(let i of t)e.process(i)})}reset(){this.#f(t=>t.reset())}getHTML(){return this.#e?.innerHTML??""}pushVersion(t){this.#r<this.#s.length-1&&(this.#s=this.#s.slice(0,this.#r+1)),this.#s.push(t?[...t]:[]),this.#s.length>s.MAX_HISTORY&&this.#s.shift(),this.#r=this.#s.length-1}back(){return this.#r<=0?!1:(this.#r--,this.#p(),!0)}forward(){return this.#r>=this.#s.length-1?!1:(this.#r++,this.#p(),!0)}get historyLength(){return this.#s.length}get historyIndex(){return this.#r}#p(){let t=this.#s[this.#r];this.#f(e=>{if(e.reset(),t)for(let i of t)e.process(i)})}#m(t,e){this.dispatchEvent(new CustomEvent("canvas-interaction",{bubbles:!0,detail:{type:t,targetTag:e.localName,targetId:e.id||"",value:e.value??e.getAttribute("text")??""}}))}};customElements.define("canvas-ui",fd);$();hO();var oa=class extends x{static properties={value:{type:String,default:"surface",reflect:!0}};static template=()=>null;#t=null;#e={};connected(){let t=this.textContent?.trim()||"";this.innerHTML="",this.#s(t)}disconnected(){this.#t?.removeEventListener("change",this.#i),this.#t=null,this.#e={}}render(){this.#t&&this.#t.getAttribute("value")!==this.value&&this.#t.setAttribute("value",this.value)}#i=t=>{t.detail?.value&&t.detail.value!==this.value&&(this.value=t.detail.value)};#s(t){let e=[...Xt.entries()].map(([i,r])=>`${i} \u2192 <${r}>`).join(`
302
+ `};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.#r))}disconnected(){this.#e&&this.#e.removeEventListener("change",this.#r),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}}))}#r=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}})))}};S("demo-toggle-ui",Ho);$();var Go=class extends x{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=ci(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=ci(e)}catch(t){if(!this.isConnected)return;this.#t.innerHTML=`<p>Error: ${t.message}</p>`}}};S("richtext-ui",Go);$();var Ko=class extends x{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 r of i){if(e.aborted)break;this.textContent+=r,await new Promise(n=>setTimeout(n,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()}};S("stream-ui",Ko);$();var fd=class s extends x{static properties={theme:{type:String,default:"",reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=[];#r=-1;static MAX_HISTORY=10;#n=null;static#a=!1;#o=t=>{t.target.closest("input, textarea, [contenteditable]")||!this.contains(document.activeElement)&&(document.activeElement,document.body)};#l=t=>{this.#e?.contains(t.target)&&this.#m("click",t.target)};#c=t=>{this.#e?.contains(t.target)&&this.#m("change",t.target)};#h=t=>{this.#e?.contains(t.target)&&this.#m("input",t.target)};#d=t=>{this.dispatchEvent(new CustomEvent("canvas-interaction",{bubbles:!0,detail:{type:"retry",targetTag:"button-ui",targetId:"retry",value:"",...t.detail}}))};connected(){document.addEventListener("keydown",this.#o),this.addEventListener("click",this.#l),this.addEventListener("change",this.#c),this.addEventListener("input",this.#h),this.addEventListener("a2ui-retry",this.#d),this.#u()}disconnected(){document.removeEventListener("keydown",this.#o),this.removeEventListener("click",this.#l),this.removeEventListener("change",this.#c),this.removeEventListener("input",this.#h),this.removeEventListener("a2ui-retry",this.#d),this.#e=null,this.#i=null,this.#t=!1}#u(){return this.#n?this.#n:customElements.get("a2ui-root")?(this.#n=Promise.resolve(!0),this.#n):(this.#n=Promise.resolve().then(()=>(cO(),V1)).then(()=>customElements.whenDefined("a2ui-root")).then(()=>!0).catch(t=>(s.#a||(s.#a=!0,console.warn("[canvas-ui] A2UI renderer <a2ui-root> could not be loaded \u2014 install @adia-ai/web-modules to render generated UI in <canvas-ui>. Apps that use only primitives (and never <canvas-ui>) can ignore this.",t)),!1)),this.#n)}#f(t){if(this.#e&&typeof this.#e.process=="function"){t(this.#e);return}this.#u().then(e=>{e&&this.#e&&typeof this.#e.process=="function"&&t(this.#e)})}render(){if(!this.#t){if(this.#t=!0,this.#i=document.createElement("div"),this.#i.setAttribute("data-canvas-surface",""),this.#e=document.createElement("a2ui-root"),this.theme){let t=document.createElement("theme-ui");t.setAttribute("preset",this.theme),t.appendChild(this.#e),this.#i.appendChild(t)}else this.#i.appendChild(this.#e);this.appendChild(this.#i)}}process(t){this.#f(e=>e.process(t))}processAll(t){this.#f(e=>{for(let i of t)e.process(i)})}reset(){this.#f(t=>t.reset())}getHTML(){return this.#e?.innerHTML??""}pushVersion(t){this.#r<this.#s.length-1&&(this.#s=this.#s.slice(0,this.#r+1)),this.#s.push(t?[...t]:[]),this.#s.length>s.MAX_HISTORY&&this.#s.shift(),this.#r=this.#s.length-1}back(){return this.#r<=0?!1:(this.#r--,this.#p(),!0)}forward(){return this.#r>=this.#s.length-1?!1:(this.#r++,this.#p(),!0)}get historyLength(){return this.#s.length}get historyIndex(){return this.#r}#p(){let t=this.#s[this.#r];this.#f(e=>{if(e.reset(),t)for(let i of t)e.process(i)})}#m(t,e){this.dispatchEvent(new CustomEvent("canvas-interaction",{bubbles:!0,detail:{type:t,targetTag:e.localName,targetId:e.id||"",value:e.value??e.getAttribute("text")??""}}))}};customElements.define("canvas-ui",fd);$();hO();var oa=class extends x{static properties={value:{type:String,default:"surface",reflect:!0}};static template=()=>null;#t=null;#e={};connected(){let t=this.textContent?.trim()||"";this.innerHTML="",this.#s(t)}disconnected(){this.#t?.removeEventListener("change",this.#i),this.#t=null,this.#e={}}render(){this.#t&&this.#t.getAttribute("value")!==this.value&&this.#t.setAttribute("value",this.value)}#i=t=>{t.detail?.value&&t.detail.value!==this.value&&(this.value=t.detail.value)};#s(t){let e=[...Xt.entries()].map(([i,r])=>`${i} \u2192 <${r}>`).join(`
303
303
  `);this.#t=document.createElement("tabs-ui"),this.#t.setAttribute("value",this.value||"surface"),this.#t.addEventListener("change",this.#i),this.#r("catalog",`Catalog (${Xt.size})`,e),this.#r("surface","Surface",t||"{}",{language:"json"}),this.#r("messages","Messages","(no messages)"),this.#r("code","Code","(empty)",{language:"html",lineNumbers:!0}),this.appendChild(this.#t)}#r(t,e,i,r={}){let n=document.createElement("tab-ui");n.setAttribute("value",t),n.setAttribute("text",e);let o=document.createElement("code-ui");r.language&&o.setAttribute("language",r.language),r.lineNumbers&&o.setAttribute("line-numbers",""),o.setAttribute("text",i),n.appendChild(o),this.#t.appendChild(n),this.#e[t]=o}update(t,e){if(this.#e.surface&&this.#e.surface.setAttribute("text",JSON.stringify(t,null,2)),this.#e.messages){let r=Array.isArray(e)&&e.length?e.map((n,o)=>`${o+1}. ${n.type||n.messageType||"unknown"}${n.surfaceId?` [${n.surfaceId}]`:""}`).join(`
304
- `):"(no messages)";this.#e.messages.setAttribute("text",r)}let i=this.#t?.querySelector('tab-ui[value="messages"]');if(i){let r=Array.isArray(e)?e.length:0;i.setAttribute("text",`Messages (${r})`)}}setHTML(t){this.#e.code&&this.#e.code.setAttribute("text",t||"(empty)")}};S("inspector-ui",oa);$();var W1={interpret:"Interpreting",analyze:"Analyzing",plan:"Planning",generate:"Generating",validate:"Validating",render:"Rendering"},aa=class extends x{static properties={stage:{type:String,default:"",reflect:!0},message:{type:String,default:"",reflect:!0},status:{type:String,default:"idle",reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h="";#u="";connected(){this.setAttribute("role","status"),this.setAttribute("aria-label","Pipeline status")}render(){this.#e||(this.#e=!0,this.#d()),this.#f()}#d(){this.#i=document.createElement("div"),this.#i.setAttribute("data-pipeline-status",""),this.#s=document.createElement("div"),this.#s.setAttribute("data-pipeline-current",""),this.#r=document.createElement("span"),this.#r.setAttribute("data-pipeline-dot",""),this.#n=document.createElement("span"),this.#n.setAttribute("data-pipeline-label",""),this.#a=document.createElement("span"),this.#a.setAttribute("data-pipeline-msg",""),this.#s.append(this.#r,this.#n,this.#a),this.#o=document.createElement("details"),this.#o.setAttribute("data-pipeline-history",""),this.#o.hidden=!0,this.#l=document.createElement("summary"),this.#o.appendChild(this.#l),this.#c=document.createElement("ol"),this.#c.setAttribute("data-pipeline-log",""),this.#o.appendChild(this.#c),this.#i.append(this.#s,this.#o),this.appendChild(this.#i)}#f(){let{stage:t,message:e}=this;if(this.status==="completed"){this.#h&&this.#h!==this.#t[this.#t.length-1]?.stage&&this.#p(this.#h,this.#u),this.#r.setAttribute("data-pipeline-dot","complete"),this.#n.textContent="Complete",this.#a.textContent="",this.#m();return}t&&t!==this.#h&&this.#h&&this.#p(this.#h,this.#u);let i=W1[t]||t;this.#r.setAttribute("data-pipeline-dot","active"),this.#r.setAttribute("data-stage",t),this.#n.textContent=i,this.#a.textContent=e?`\u2014 ${e}`:"",this.#h=t,this.#u=e,this.#m()}#p(t,e){this.#t.push({stage:t,message:e,timestamp:Date.now()})}#m(){if(this.#t.length===0){this.#o.hidden=!0;return}this.#o.hidden=!1,this.#l.textContent=`${this.#t.length} step${this.#t.length>1?"s":""} completed`,this.#c.innerHTML="";for(let t of this.#t){let e=document.createElement("li"),i=document.createElement("span");i.setAttribute("data-pipeline-dot","complete");let r=document.createElement("span"),n=W1[t.stage]||t.stage;r.textContent=t.message?`${n} \u2014 ${t.message}`:n,e.append(i,r),this.#c.appendChild(e)}this.status==="completed"&&this.#o.removeAttribute("open")}disconnected(){this.#i=null,this.#s=null,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null,this.#e=!1}};S("pipeline-status-ui",aa);var la=class extends M{static properties={...M.properties,value:{type:Number,default:0,reflect:!0},max:{type:Number,default:5,reflect:!0},icon:{type:String,default:"star",reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},allowHalf:{type:Boolean,default:!1,reflect:!0,attribute:"allow-half"},size:{type:String,default:"md",reflect:!0}};static template=()=>null;#t=null;connected(){super.connected(),this.setAttribute("role","slider"),this.setAttribute("aria-orientation","horizontal"),this.setAttribute("aria-valuemin","0"),this.hasAttribute("tabindex")||this.setAttribute("tabindex",this.readonly?"-1":"0"),this.addEventListener("pointermove",this.#i),this.addEventListener("pointerleave",this.#s),this.addEventListener("click",this.#r),this.addEventListener("keydown",this.#n)}render(){let t=Number(this.max)||5,e=this.#t??(Number(this.value)||0),i=Array.from({length:t},(r,n)=>{let o=n+1;return`
304
+ `):"(no messages)";this.#e.messages.setAttribute("text",r)}let i=this.#t?.querySelector('tab-ui[value="messages"]');if(i){let r=Array.isArray(e)?e.length:0;i.setAttribute("text",`Messages (${r})`)}}setHTML(t){this.#e.code&&this.#e.code.setAttribute("text",t||"(empty)")}};S("inspector-ui",oa);$();var W1={interpret:"Interpreting",analyze:"Analyzing",plan:"Planning",generate:"Generating",validate:"Validating",render:"Rendering"},aa=class extends x{static properties={stage:{type:String,default:"",reflect:!0},message:{type:String,default:"",reflect:!0},status:{type:String,default:"idle",reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h="";#d="";connected(){this.setAttribute("role","status"),this.setAttribute("aria-label","Pipeline status")}render(){this.#e||(this.#e=!0,this.#u()),this.#f()}#u(){this.#i=document.createElement("div"),this.#i.setAttribute("data-pipeline-status",""),this.#s=document.createElement("div"),this.#s.setAttribute("data-pipeline-current",""),this.#r=document.createElement("span"),this.#r.setAttribute("data-pipeline-dot",""),this.#n=document.createElement("span"),this.#n.setAttribute("data-pipeline-label",""),this.#a=document.createElement("span"),this.#a.setAttribute("data-pipeline-msg",""),this.#s.append(this.#r,this.#n,this.#a),this.#o=document.createElement("details"),this.#o.setAttribute("data-pipeline-history",""),this.#o.hidden=!0,this.#l=document.createElement("summary"),this.#o.appendChild(this.#l),this.#c=document.createElement("ol"),this.#c.setAttribute("data-pipeline-log",""),this.#o.appendChild(this.#c),this.#i.append(this.#s,this.#o),this.appendChild(this.#i)}#f(){let{stage:t,message:e}=this;if(this.status==="completed"){this.#h&&this.#h!==this.#t[this.#t.length-1]?.stage&&this.#p(this.#h,this.#d),this.#r.setAttribute("data-pipeline-dot","complete"),this.#n.textContent="Complete",this.#a.textContent="",this.#m();return}t&&t!==this.#h&&this.#h&&this.#p(this.#h,this.#d);let i=W1[t]||t;this.#r.setAttribute("data-pipeline-dot","active"),this.#r.setAttribute("data-stage",t),this.#n.textContent=i,this.#a.textContent=e?`\u2014 ${e}`:"",this.#h=t,this.#d=e,this.#m()}#p(t,e){this.#t.push({stage:t,message:e,timestamp:Date.now()})}#m(){if(this.#t.length===0){this.#o.hidden=!0;return}this.#o.hidden=!1,this.#l.textContent=`${this.#t.length} step${this.#t.length>1?"s":""} completed`,this.#c.innerHTML="";for(let t of this.#t){let e=document.createElement("li"),i=document.createElement("span");i.setAttribute("data-pipeline-dot","complete");let r=document.createElement("span"),n=W1[t.stage]||t.stage;r.textContent=t.message?`${n} \u2014 ${t.message}`:n,e.append(i,r),this.#c.appendChild(e)}this.status==="completed"&&this.#o.removeAttribute("open")}disconnected(){this.#i=null,this.#s=null,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null,this.#e=!1}};S("pipeline-status-ui",aa);var la=class extends M{static properties={...M.properties,value:{type:Number,default:0,reflect:!0},max:{type:Number,default:5,reflect:!0},icon:{type:String,default:"star",reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},allowHalf:{type:Boolean,default:!1,reflect:!0,attribute:"allow-half"},size:{type:String,default:"md",reflect:!0}};static template=()=>null;#t=null;connected(){super.connected(),this.setAttribute("role","slider"),this.setAttribute("aria-orientation","horizontal"),this.setAttribute("aria-valuemin","0"),this.hasAttribute("tabindex")||this.setAttribute("tabindex",this.readonly?"-1":"0"),this.addEventListener("pointermove",this.#i),this.addEventListener("pointerleave",this.#s),this.addEventListener("click",this.#r),this.addEventListener("keydown",this.#n)}render(){let t=Number(this.max)||5,e=this.#t??(Number(this.value)||0),i=Array.from({length:t},(r,n)=>{let o=n+1;return`
305
305
  <span data-rating-symbol data-fill="${e>=o?"full":e>=o-.5?"half":"empty"}" aria-hidden="true">
306
306
  <icon-ui name="${this.icon}" data-rating-symbol-bg></icon-ui>
307
307
  <icon-ui name="${this.icon}" weight="fill" data-rating-symbol-fg></icon-ui>
@@ -309,7 +309,7 @@ Correct shape for <chart-ui x="label" y="value">:
309
309
  `}).join("");this.innerHTML=i,this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(Number(this.value)||0)),this.setAttribute("aria-valuetext",`${Number(this.value)||0} out of ${t}`),this.readonly?this.setAttribute("aria-readonly","true"):this.removeAttribute("aria-readonly")}#e(t){let e=[...this.querySelectorAll("[data-rating-symbol]")],i=e.find(n=>n.contains(t.target));if(!i)return null;let r=e.indexOf(i);if(r===-1)return null;if(this.allowHalf){let n=i.getBoundingClientRect(),o=t.clientX-n.left<n.width/2;return r+(o?.5:1)}return r+1}#i=t=>{if(this.readonly||this.disabled)return;let e=this.#e(t);e!=null&&e!==this.#t&&(this.#t=e,this.render())};#s=()=>{this.#t!=null&&(this.#t=null,this.render())};#r=t=>{if(this.readonly||this.disabled)return;let e=this.#e(t);e!=null&&this.#a(e)};#n=t=>{if(this.readonly||this.disabled)return;let e=this.allowHalf?.5:1,i=Number(this.max)||5,r=Number(this.value)||0,n=r;if(t.key==="ArrowRight"||t.key==="ArrowUp")n=Math.min(i,r+e);else if(t.key==="ArrowLeft"||t.key==="ArrowDown")n=Math.max(0,r-e);else if(t.key==="Home")n=0;else if(t.key==="End")n=i;else return;t.preventDefault(),this.#a(n)};#a(t){this.value=t,this.#t=null,this.syncValue(String(t)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.render()}disconnected(){super.disconnected(),this.removeEventListener("pointermove",this.#i),this.removeEventListener("pointerleave",this.#s),this.removeEventListener("click",this.#r),this.removeEventListener("keydown",this.#n)}};S("rating-ui",la);$();var ha=class extends x{static properties={layout:{type:String,default:"stacked",reflect:!0},align:{type:String,default:"start",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","group")}render(){let t=this.#t();t.length&&(this.innerHTML=t.map(({term:e,description:i})=>`
310
310
  <dt data-dl-term>${this.#e(e)}</dt>
311
311
  <dd data-dl-desc>${this.#e(i)}</dd>
312
- `).join(""))}#t(){if(Array.isArray(this._items)&&this._items.length)return this._items;let t=this.getAttribute("items");if(t)try{let e=JSON.parse(t);if(Array.isArray(e))return e}catch{}return[]}set items(t){this._items=Array.isArray(t)?t:[],this.render()}get items(){return this._items||[]}#e(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}};S("description-list-ui",ha);$();var ND=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ca=class extends x{static properties={type:{type:String,default:"matrix",reflect:!0},rows:{type:Number,default:7,reflect:!0},cols:{type:Number,default:12,reflect:!0},scale:{type:String,default:"linear",reflect:!0},noLegend:{type:Boolean,default:!1,reflect:!0,attribute:"no-legend"},colorScheme:{type:String,default:"data-ramp",reflect:!0,attribute:"color-scheme"},startDate:{type:String,default:"",reflect:!0,attribute:"start-date"},aspect:{type:String,default:"wide",reflect:!0}};static template=()=>null;#t=[];#e=!1;set data(t){if(typeof t=="string")try{t=JSON.parse(t)}catch{t=[]}this.#t=Array.isArray(t)?t:[],this.#s()}get data(){return this.#t}connected(){this.setAttribute("role","img");let t=this.getAttribute("data");if(t&&!this.#t.length)try{this.#t=JSON.parse(t)}catch{}this.#e||(this.#e=!0,this.addEventListener("pointerover",this.#l),this.addEventListener("pointermove",this.#c),this.addEventListener("pointerleave",this.#h),this.addEventListener("click",this.#u))}disconnected(){this.removeEventListener("pointerover",this.#l),this.removeEventListener("pointermove",this.#c),this.removeEventListener("pointerleave",this.#h),this.removeEventListener("click",this.#u),this.#e=!1,this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null)}#i=null;#s(){!this.isConnected||this.#i||(this.#i=requestAnimationFrame(()=>{this.#i=null,this.render()}))}#r(){let t=this.#t.map(n=>Number(n.v)||0);if(!t.length)return n=>0;let e=Math.min(...t),i=Math.max(...t);if(e===i)return n=>4;let r=this.scale;if(r==="log"){let n=Math.log(Math.max(1,e)),o=Math.log(Math.max(1,i));return a=>{let h=(Math.log(Math.max(1,Number(a)||0))-n)/(o-n);return Math.min(4,Math.max(0,Math.round(h*4)))}}if(r==="quantile"){let n=[...t].sort((l,h)=>l-h),o=l=>n[Math.floor(l*(n.length-1))],a=[o(.2),o(.4),o(.6),o(.8)];return l=>{let h=Number(l)||0;return h<=a[0]?0:h<=a[1]?1:h<=a[2]?2:h<=a[3]?3:4}}return n=>{let a=((Number(n)||0)-e)/(i-e);return Math.min(4,Math.max(0,Math.round(a*4)))}}render(){let t=Math.max(1,this.rows||7),e=Math.max(1,this.cols||12),i=new Map;for(let h of this.#t)h&&h.r!=null&&h.c!=null&&i.set(`${h.r},${h.c}`,h);let r=this.#r(),n=this.querySelector(':scope > [slot="title"]');if(this.replaceChildren(),n&&this.appendChild(n),this.type==="day-grid"&&this.startDate){let h=document.createElement("div");h.setAttribute("data-months","");let c=new Date(this.startDate);if(!Number.isNaN(c.getTime())){let u=[];for(let d=0;d<e;d++){let f=new Date(c);f.setDate(f.getDate()+d*7),(d===0||f.getDate()<=7)&&u.push({col:d,label:ND[f.getMonth()]})}for(let d of u){let f=document.createElement("span");f.setAttribute("data-month-label",""),f.style.gridColumn=String(d.col+1),f.textContent=d.label,h.appendChild(f)}}h.style.gridTemplateColumns=`repeat(${e}, var(--heatmap-cell-min-size, 0.75rem))`,this.appendChild(h)}let o=this.type==="day-grid",a=o?"var(--heatmap-cell-min-size, 0.75rem)":"minmax(0, 1fr)",l=document.createElement("div");l.setAttribute("data-grid",""),l.style.gridTemplateColumns=`repeat(${e}, ${a})`,l.style.gridTemplateRows=`repeat(${t}, ${o?"var(--heatmap-cell-min-size, 0.75rem)":"1fr"})`;for(let h=0;h<t;h++)for(let c=0;c<e;c++){let u=i.get(`${h},${c}`),d=document.createElement("div");if(d.setAttribute("data-cell",""),d.setAttribute("role","gridcell"),d.dataset.r=String(h),d.dataset.c=String(c),u!=null){let f=Number(u.v)||0,p=r(f);d.dataset.bucket=String(p),d.dataset.v=String(f),u.label&&d.setAttribute("aria-label",u.label)}else d.dataset.empty="";l.appendChild(d)}if(this.appendChild(l),!this.noLegend){let h=document.createElement("div");h.setAttribute("data-legend","");let c=document.createElement("span");c.setAttribute("data-legend-label",""),c.textContent="Less",h.appendChild(c);for(let d=0;d<5;d++){let f=document.createElement("span");f.setAttribute("data-legend-swatch",""),f.dataset.bucket=String(d),h.appendChild(f)}let u=document.createElement("span");u.setAttribute("data-legend-label",""),u.textContent="More",h.appendChild(u),this.appendChild(h)}}#n(t){return t?.closest?.("[data-cell]")}#a(t,e){let i=Number(t.dataset.r),r=Number(t.dataset.c),n=Number(t.dataset.v),o=t.getAttribute("aria-label")||"";return{r:i,c:r,label:o,value:Number.isFinite(n)?n:null,pct:null,series:null,slot:0,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#o=null;#l=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v)return;this.#o=e;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))};#c=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v){this.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})));return}if(e!==this.#o){this.#o=e;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}else{let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}};#h=()=>{this.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})))};#u=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v)return;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-click",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-select",{detail:i,bubbles:!0}))}};S("heatmap-ui",ca);$();var U1=new Set(["idle","active","done","error"]);function uO(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ZD(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var ua=class extends x{static requiredIcons=["check-circle","circle","warning","warning-circle"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},noAutocollapse:{type:Boolean,default:!1,reflect:!0,attribute:"no-autocollapse"},heading:{type:String,default:"",reflect:!0},status:{type:String,default:"active",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=Date.now();#s=null;#r=null;#n=null;#a=null;#o=!1;#l=null;#c=0;get entries(){return this.#t}connected(){this.#o||(this.#o=!0,this.#i=Date.now(),this.#s=setInterval(()=>this.#E(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#w()}))}),this.#l.observe(this)))}#h=t=>{let e=t.target.closest("timeline-item-ui[data-step-id]");!e||!this.#a?.contains(e)||this.dispatchEvent(new CustomEvent("reasoning-step-toggle",{bubbles:!0,detail:{stepId:e.dataset.stepId}}))};disconnected(){this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.#r!=null&&(clearTimeout(this.#r),this.#r=null),this.#c&&(cancelAnimationFrame(this.#c),this.#c=0),this.#l?.disconnect(),this.#l=null,this.#n?.removeEventListener("click",this.#f),this.#n?.removeEventListener("keydown",this.#p),this.#a?.removeEventListener("timeline-toggle",this.#h),this.#n=null,this.#a=null,this.#o=!1}addStep(t){let e={kind:"step",status:"active",duration:null,outcomes:[],children:[],...t};return this.#u(e),this.#y(),e}updateStep(t,e){let i=this.#d(t);i&&(Object.assign(i,e),this.#y())}completeStep(t,e){let i=this.#d(t);i&&(i.status="done",e!=null&&(i.duration=e),this.#y())}failStep(t,e){let i=this.#d(t);i&&(i.status="error",e&&(i.outcomes=[...i.outcomes||[],String(e)]),this.#y())}addThought(t,e=`thought-${this.#t.length}`){this.#u({kind:"thought",id:e,text:t}),this.#y()}setPlan(t,e="plan"){let i=this.#t.find(r=>r.kind==="plan"&&r.id===e);i?i.items=t.slice():this.#t.push({kind:"plan",id:e,items:t.slice()}),this.#y()}startIteration(t,e=`Attempt ${t}`,i=`iter-${t}`){let r={kind:"iteration",id:i,n:t,label:e,status:"active",summary:"",steps:[]};return this.#t.push(r),this.#e.push(i),this.#y(),r}endIteration(t,{status:e="done",summary:i=""}={}){let r=`iter-${t}`,n=this.#t.find(a=>a.kind==="iteration"&&a.id===r);if(!n)return;n.status=e,n.summary=i;let o=this.#e.lastIndexOf(r);o>=0&&this.#e.splice(o,1),this.#y()}finish(t,{status:e="done"}={}){let i=U1.has(e)?e:"done",r=i==="error";for(let n of this.#t)if(n.kind==="step"&&n.status==="active"&&(n.status=r?"error":"done"),n.kind==="iteration"){n.status==="active"&&(n.status=r?"error":"done");for(let o of n.steps||[])o.status==="active"&&(o.status=r?"error":"done")}this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.status=i,t&&(this.dataset.summary=t),this.#y(),this.dispatchEvent(new CustomEvent("reasoning-finish",{bubbles:!0,detail:{summary:t||"",status:i}})),this.#r!=null&&clearTimeout(this.#r),!this.noAutocollapse&&!r&&(this.#r=setTimeout(()=>{this.#r=null,this.collapsed=!0,this.#y()},1200))}fail(t){this.finish(t,{status:"error"})}#u(t){if(this.#e.length>0){let e=this.#e[this.#e.length-1],i=this.#t.find(r=>r.kind==="iteration"&&r.id===e);if(i){t.kind==="step"?i.steps.push(t):this.#t.push(t);return}}this.#t.push(t)}#d(t){for(let e of this.#t){if(e.kind==="step"&&e.id===t)return e;if(e.kind==="iteration"){for(let i of e.steps||[])if(i.id===t)return i}}return null}#f=()=>{this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("reasoning-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.#y()};#p=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#f())};#m(){this.innerHTML="",this.#n=document.createElement("div"),this.#n.setAttribute("data-reasoning-summary",""),this.#n.setAttribute("role","button"),this.#n.setAttribute("tabindex","0"),this.#n.setAttribute("aria-expanded",String(!this.collapsed)),this.#n.addEventListener("click",this.#f),this.#n.addEventListener("keydown",this.#p),this.appendChild(this.#n),this.#a=document.createElement("div"),this.#a.setAttribute("data-reasoning-body",""),this.#a.addEventListener("timeline-toggle",this.#h),this.appendChild(this.#a),this.#y()}#g(){for(let e=this.#t.length-1;e>=0;e--){let i=this.#t[e];if(i.kind==="step"&&i.status==="active")return i.label;if(i.kind==="iteration")for(let r=(i.steps||[]).length-1;r>=0;r--){let n=i.steps[r];if(n.status==="active")return n.label}if(i.kind==="thought")return i.text}return this.#t.findLast?.(e=>e.kind==="step")?.label||this.heading||"Thinking\u2026"}#b(t){switch(t){case"done":return'<icon-ui name="check-circle" color="success" data-reasoning-check></icon-ui>';case"error":return'<icon-ui name="warning-circle" color="danger" data-reasoning-check data-error></icon-ui>';case"idle":return'<icon-ui name="circle" color="muted" data-reasoning-check data-idle></icon-ui>';default:return"<span data-reasoning-spinner></span>"}}#O(){let t=0,e=0,i=r=>{t++,r.status==="done"&&e++};for(let r of this.#t)if(r.kind==="step"&&i(r),r.kind==="iteration")for(let n of r.steps||[])i(n);return{total:t,done:e}}#y(){if(!this.#n)return;let t=U1.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:r}=this.#O(),n=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#g();if(this.#n.innerHTML=`
312
+ `).join(""))}#t(){if(Array.isArray(this._items)&&this._items.length)return this._items;let t=this.getAttribute("items");if(t)try{let e=JSON.parse(t);if(Array.isArray(e))return e}catch{}return[]}set items(t){this._items=Array.isArray(t)?t:[],this.render()}get items(){return this._items||[]}#e(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}};S("description-list-ui",ha);$();var ND=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ca=class extends x{static properties={type:{type:String,default:"matrix",reflect:!0},rows:{type:Number,default:7,reflect:!0},cols:{type:Number,default:12,reflect:!0},scale:{type:String,default:"linear",reflect:!0},noLegend:{type:Boolean,default:!1,reflect:!0,attribute:"no-legend"},colorScheme:{type:String,default:"data-ramp",reflect:!0,attribute:"color-scheme"},startDate:{type:String,default:"",reflect:!0,attribute:"start-date"},aspect:{type:String,default:"wide",reflect:!0}};static template=()=>null;#t=[];#e=!1;set data(t){if(typeof t=="string")try{t=JSON.parse(t)}catch{t=[]}this.#t=Array.isArray(t)?t:[],this.#s()}get data(){return this.#t}connected(){this.setAttribute("role","img");let t=this.getAttribute("data");if(t&&!this.#t.length)try{this.#t=JSON.parse(t)}catch{}this.#e||(this.#e=!0,this.addEventListener("pointerover",this.#l),this.addEventListener("pointermove",this.#c),this.addEventListener("pointerleave",this.#h),this.addEventListener("click",this.#d))}disconnected(){this.removeEventListener("pointerover",this.#l),this.removeEventListener("pointermove",this.#c),this.removeEventListener("pointerleave",this.#h),this.removeEventListener("click",this.#d),this.#e=!1,this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null)}#i=null;#s(){!this.isConnected||this.#i||(this.#i=requestAnimationFrame(()=>{this.#i=null,this.render()}))}#r(){let t=this.#t.map(n=>Number(n.v)||0);if(!t.length)return n=>0;let e=Math.min(...t),i=Math.max(...t);if(e===i)return n=>4;let r=this.scale;if(r==="log"){let n=Math.log(Math.max(1,e)),o=Math.log(Math.max(1,i));return a=>{let h=(Math.log(Math.max(1,Number(a)||0))-n)/(o-n);return Math.min(4,Math.max(0,Math.round(h*4)))}}if(r==="quantile"){let n=[...t].sort((l,h)=>l-h),o=l=>n[Math.floor(l*(n.length-1))],a=[o(.2),o(.4),o(.6),o(.8)];return l=>{let h=Number(l)||0;return h<=a[0]?0:h<=a[1]?1:h<=a[2]?2:h<=a[3]?3:4}}return n=>{let a=((Number(n)||0)-e)/(i-e);return Math.min(4,Math.max(0,Math.round(a*4)))}}render(){let t=Math.max(1,this.rows||7),e=Math.max(1,this.cols||12),i=new Map;for(let h of this.#t)h&&h.r!=null&&h.c!=null&&i.set(`${h.r},${h.c}`,h);let r=this.#r(),n=this.querySelector(':scope > [slot="title"]');if(this.replaceChildren(),n&&this.appendChild(n),this.type==="day-grid"&&this.startDate){let h=document.createElement("div");h.setAttribute("data-months","");let c=new Date(this.startDate);if(!Number.isNaN(c.getTime())){let u=[];for(let d=0;d<e;d++){let f=new Date(c);f.setDate(f.getDate()+d*7),(d===0||f.getDate()<=7)&&u.push({col:d,label:ND[f.getMonth()]})}for(let d of u){let f=document.createElement("span");f.setAttribute("data-month-label",""),f.style.gridColumn=String(d.col+1),f.textContent=d.label,h.appendChild(f)}}h.style.gridTemplateColumns=`repeat(${e}, var(--heatmap-cell-min-size, 0.75rem))`,this.appendChild(h)}let o=this.type==="day-grid",a=o?"var(--heatmap-cell-min-size, 0.75rem)":"minmax(0, 1fr)",l=document.createElement("div");l.setAttribute("data-grid",""),l.style.gridTemplateColumns=`repeat(${e}, ${a})`,l.style.gridTemplateRows=`repeat(${t}, ${o?"var(--heatmap-cell-min-size, 0.75rem)":"1fr"})`;for(let h=0;h<t;h++)for(let c=0;c<e;c++){let u=i.get(`${h},${c}`),d=document.createElement("div");if(d.setAttribute("data-cell",""),d.setAttribute("role","gridcell"),d.dataset.r=String(h),d.dataset.c=String(c),u!=null){let f=Number(u.v)||0,p=r(f);d.dataset.bucket=String(p),d.dataset.v=String(f),u.label&&d.setAttribute("aria-label",u.label)}else d.dataset.empty="";l.appendChild(d)}if(this.appendChild(l),!this.noLegend){let h=document.createElement("div");h.setAttribute("data-legend","");let c=document.createElement("span");c.setAttribute("data-legend-label",""),c.textContent="Less",h.appendChild(c);for(let d=0;d<5;d++){let f=document.createElement("span");f.setAttribute("data-legend-swatch",""),f.dataset.bucket=String(d),h.appendChild(f)}let u=document.createElement("span");u.setAttribute("data-legend-label",""),u.textContent="More",h.appendChild(u),this.appendChild(h)}}#n(t){return t?.closest?.("[data-cell]")}#a(t,e){let i=Number(t.dataset.r),r=Number(t.dataset.c),n=Number(t.dataset.v),o=t.getAttribute("aria-label")||"";return{r:i,c:r,label:o,value:Number.isFinite(n)?n:null,pct:null,series:null,slot:0,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#o=null;#l=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v)return;this.#o=e;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))};#c=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v){this.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})));return}if(e!==this.#o){this.#o=e;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}else{let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}};#h=()=>{this.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})))};#d=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v)return;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-click",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-select",{detail:i,bubbles:!0}))}};S("heatmap-ui",ca);$();var U1=new Set(["idle","active","done","error"]);function uO(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ZD(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var ua=class extends x{static requiredIcons=["check-circle","circle","warning","warning-circle"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},noAutocollapse:{type:Boolean,default:!1,reflect:!0,attribute:"no-autocollapse"},heading:{type:String,default:"",reflect:!0},status:{type:String,default:"active",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=Date.now();#s=null;#r=null;#n=null;#a=null;#o=!1;#l=null;#c=0;get entries(){return this.#t}connected(){this.#o||(this.#o=!0,this.#i=Date.now(),this.#s=setInterval(()=>this.#E(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#S()}))}),this.#l.observe(this)))}#h=t=>{let e=t.target.closest("timeline-item-ui[data-step-id]");!e||!this.#a?.contains(e)||this.dispatchEvent(new CustomEvent("reasoning-step-toggle",{bubbles:!0,detail:{stepId:e.dataset.stepId}}))};disconnected(){this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.#r!=null&&(clearTimeout(this.#r),this.#r=null),this.#c&&(cancelAnimationFrame(this.#c),this.#c=0),this.#l?.disconnect(),this.#l=null,this.#n?.removeEventListener("click",this.#f),this.#n?.removeEventListener("keydown",this.#p),this.#a?.removeEventListener("timeline-toggle",this.#h),this.#n=null,this.#a=null,this.#o=!1}addStep(t){let e={kind:"step",status:"active",duration:null,outcomes:[],children:[],...t};return this.#d(e),this.#O(),e}updateStep(t,e){let i=this.#u(t);i&&(Object.assign(i,e),this.#O())}completeStep(t,e){let i=this.#u(t);i&&(i.status="done",e!=null&&(i.duration=e),this.#O())}failStep(t,e){let i=this.#u(t);i&&(i.status="error",e&&(i.outcomes=[...i.outcomes||[],String(e)]),this.#O())}addThought(t,e=`thought-${this.#t.length}`){this.#d({kind:"thought",id:e,text:t}),this.#O()}setPlan(t,e="plan"){let i=this.#t.find(r=>r.kind==="plan"&&r.id===e);i?i.items=t.slice():this.#t.push({kind:"plan",id:e,items:t.slice()}),this.#O()}startIteration(t,e=`Attempt ${t}`,i=`iter-${t}`){let r={kind:"iteration",id:i,n:t,label:e,status:"active",summary:"",steps:[]};return this.#t.push(r),this.#e.push(i),this.#O(),r}endIteration(t,{status:e="done",summary:i=""}={}){let r=`iter-${t}`,n=this.#t.find(a=>a.kind==="iteration"&&a.id===r);if(!n)return;n.status=e,n.summary=i;let o=this.#e.lastIndexOf(r);o>=0&&this.#e.splice(o,1),this.#O()}finish(t,{status:e="done"}={}){let i=U1.has(e)?e:"done",r=i==="error";for(let n of this.#t)if(n.kind==="step"&&n.status==="active"&&(n.status=r?"error":"done"),n.kind==="iteration"){n.status==="active"&&(n.status=r?"error":"done");for(let o of n.steps||[])o.status==="active"&&(o.status=r?"error":"done")}this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.status=i,t&&(this.dataset.summary=t),this.#O(),this.dispatchEvent(new CustomEvent("reasoning-finish",{bubbles:!0,detail:{summary:t||"",status:i}})),this.#r!=null&&clearTimeout(this.#r),!this.noAutocollapse&&!r&&(this.#r=setTimeout(()=>{this.#r=null,this.collapsed=!0,this.#O()},1200))}fail(t){this.finish(t,{status:"error"})}#d(t){if(this.#e.length>0){let e=this.#e[this.#e.length-1],i=this.#t.find(r=>r.kind==="iteration"&&r.id===e);if(i){t.kind==="step"?i.steps.push(t):this.#t.push(t);return}}this.#t.push(t)}#u(t){for(let e of this.#t){if(e.kind==="step"&&e.id===t)return e;if(e.kind==="iteration"){for(let i of e.steps||[])if(i.id===t)return i}}return null}#f=()=>{this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("reasoning-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.#O()};#p=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#f())};#m(){this.innerHTML="",this.#n=document.createElement("div"),this.#n.setAttribute("data-reasoning-summary",""),this.#n.setAttribute("role","button"),this.#n.setAttribute("tabindex","0"),this.#n.setAttribute("aria-expanded",String(!this.collapsed)),this.#n.addEventListener("click",this.#f),this.#n.addEventListener("keydown",this.#p),this.appendChild(this.#n),this.#a=document.createElement("div"),this.#a.setAttribute("data-reasoning-body",""),this.#a.addEventListener("timeline-toggle",this.#h),this.appendChild(this.#a),this.#O()}#g(){for(let e=this.#t.length-1;e>=0;e--){let i=this.#t[e];if(i.kind==="step"&&i.status==="active")return i.label;if(i.kind==="iteration")for(let r=(i.steps||[]).length-1;r>=0;r--){let n=i.steps[r];if(n.status==="active")return n.label}if(i.kind==="thought")return i.text}return this.#t.findLast?.(e=>e.kind==="step")?.label||this.heading||"Thinking\u2026"}#b(t){switch(t){case"done":return'<icon-ui name="check-circle" color="success" data-reasoning-check></icon-ui>';case"error":return'<icon-ui name="warning-circle" color="danger" data-reasoning-check data-error></icon-ui>';case"idle":return'<icon-ui name="circle" color="muted" data-reasoning-check data-idle></icon-ui>';default:return"<span data-reasoning-spinner></span>"}}#y(){let t=0,e=0,i=r=>{t++,r.status==="done"&&e++};for(let r of this.#t)if(r.kind==="step"&&i(r),r.kind==="iteration")for(let n of r.steps||[])i(n);return{total:t,done:e}}#O(){if(!this.#n)return;let t=U1.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:r}=this.#y(),n=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#g();if(this.#n.innerHTML=`
313
313
  ${this.#b(t)}
314
314
  <span data-reasoning-label>${uO(o)}</span>
315
315
  <span data-reasoning-meta>
@@ -317,12 +317,12 @@ Correct shape for <chart-ui x="label" y="value">:
317
317
  <span data-reasoning-time>${n}s</span>
318
318
  <icon-ui name="${this.collapsed?"caret-right":"caret-up"}" color="muted" data-reasoning-caret></icon-ui>
319
319
  </span>
320
- `,this.#a.hidden=this.collapsed,this.#n.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#a.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#v(),this.#a.appendChild(a)),a.appendChild(this.#S(l))):(a=null,this.#a.appendChild(this.#x(l)));this.#w()}#w(){let t=this.#a;if(!t)return;if(this.collapsed){t.removeAttribute("data-spine");return}let e=t.querySelectorAll("timeline-item-ui");if(e.length<2){t.removeAttribute("data-spine");return}let i=t.getBoundingClientRect().top,r=a=>{let l=a.getBoundingClientRect(),h=parseFloat(getComputedStyle(a).fontSize)||14;return l.top-i+.7*h+1},n=r(e[0]),o=Math.max(0,r(e[e.length-1])-n);t.style.setProperty("--reasoning-spine-top",`${Math.round(n)}px`),t.style.setProperty("--reasoning-spine-h",`${Math.round(o)}px`),t.setAttribute("data-spine","")}#v(){let t=document.createElement("timeline-ui");return t.setAttribute("size","sm"),t}#S(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?ZD(t.duration):"");return i&&e.setAttribute("duration",i),t.outcomes?.length&&(e.outcomes=t.outcomes),e.dataset.stepId=t.id||"",e}#x(t){switch(t.kind){case"thought":return this.#k(t);case"plan":return this.#A(t);case"iteration":return this.#C(t);default:return document.createTextNode("")}}#k(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}#A(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 r=document.createElement("ol");r.setAttribute("data-reasoning-plan-list","");for(let n of t.items||[]){let o=document.createElement("li");o.textContent=n,r.appendChild(o)}return e.appendChild(r),e}#C(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 r=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=`
320
+ `,this.#a.hidden=this.collapsed,this.#n.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#a.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#v(),this.#a.appendChild(a)),a.appendChild(this.#w(l))):(a=null,this.#a.appendChild(this.#x(l)));this.#S()}#S(){let t=this.#a;if(!t)return;if(this.collapsed){t.removeAttribute("data-spine");return}let e=t.querySelectorAll("timeline-item-ui");if(e.length<2){t.removeAttribute("data-spine");return}let i=t.getBoundingClientRect().top,r=a=>{let l=a.getBoundingClientRect(),h=parseFloat(getComputedStyle(a).fontSize)||14;return l.top-i+.7*h+1},n=r(e[0]),o=Math.max(0,r(e[e.length-1])-n);t.style.setProperty("--reasoning-spine-top",`${Math.round(n)}px`),t.style.setProperty("--reasoning-spine-h",`${Math.round(o)}px`),t.setAttribute("data-spine","")}#v(){let t=document.createElement("timeline-ui");return t.setAttribute("size","sm"),t}#w(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?ZD(t.duration):"");return i&&e.setAttribute("duration",i),t.outcomes?.length&&(e.outcomes=t.outcomes),e.dataset.stepId=t.id||"",e}#x(t){switch(t.kind){case"thought":return this.#k(t);case"plan":return this.#A(t);case"iteration":return this.#C(t);default:return document.createTextNode("")}}#k(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}#A(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 r=document.createElement("ol");r.setAttribute("data-reasoning-plan-list","");for(let n of t.items||[]){let o=document.createElement("li");o.textContent=n,r.appendChild(o)}return e.appendChild(r),e}#C(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 r=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=`
321
321
  ${r}
322
322
  <span data-reasoning-iter-n>#${t.n}</span>
323
323
  <span data-reasoning-iter-label>${uO(t.label||"")}</span>
324
324
  ${t.summary?`<span data-reasoning-iter-summary>${uO(t.summary)}</span>`:""}
325
- `,e.appendChild(i),t.steps?.length){let n=this.#v();for(let o of t.steps)n.appendChild(this.#S(o));e.appendChild(n)}return e}#E(){if(this.status==="done"||this.status==="error")return;let t=Math.round((Date.now()-this.#i)/1e3),e=this.#n?.querySelector("[data-reasoning-time]");e&&(e.textContent=t+"s");let i=t+"s";for(let r of this.querySelectorAll("timeline-item-ui[active]:not([completed])"))r.dataset._frozenDuration||r.setAttribute("duration",i)}};S("agent-reasoning-ui",ua);$();var _l=class extends x{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.#a()}get metrics(){return this.#e}set metrics(t){this.#e=Array.isArray(t)?t.slice():[],this.#a()}get feedback(){return this.#i}set feedback(t){this.#i=Array.isArray(t)?t.slice():[],this.#a()}connected(){this.#n()}disconnected(){this.#s?.removeEventListener("toggle",this.#r),this.#s=null}#r=()=>{this.collapsed=!this.#s.hasAttribute("open"),this.dispatchEvent(new CustomEvent("trace-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}}))};#n(){this.innerHTML="",this.#s=document.createElement("details"),this.#s.setAttribute("data-trace-root",""),this.collapsed||this.#s.setAttribute("open",""),this.#s.addEventListener("toggle",this.#r),this.appendChild(this.#s),this.#a()}#a(){if(!this.#s)return;let t=this.#t.length?this.#t.map(a=>this.#h(a)).join("<span data-trace-sep>\xB7</span>"):`<span>${ss(this.label||"Trace")}</span>`,e=this.#e.some(a=>a.aux!=null&&String(a.aux).trim()!==""),i=this.#e.some(a=>this.#o(a)),r=this.#e.length?`
325
+ `,e.appendChild(i),t.steps?.length){let n=this.#v();for(let o of t.steps)n.appendChild(this.#w(o));e.appendChild(n)}return e}#E(){if(this.status==="done"||this.status==="error")return;let t=Math.round((Date.now()-this.#i)/1e3),e=this.#n?.querySelector("[data-reasoning-time]");e&&(e.textContent=t+"s");let i=t+"s";for(let r of this.querySelectorAll("timeline-item-ui[active]:not([completed])"))r.dataset._frozenDuration||r.setAttribute("duration",i)}};S("agent-reasoning-ui",ua);$();var _l=class extends x{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.#a()}get metrics(){return this.#e}set metrics(t){this.#e=Array.isArray(t)?t.slice():[],this.#a()}get feedback(){return this.#i}set feedback(t){this.#i=Array.isArray(t)?t.slice():[],this.#a()}connected(){this.#n()}disconnected(){this.#s?.removeEventListener("toggle",this.#r),this.#s=null}#r=()=>{this.collapsed=!this.#s.hasAttribute("open"),this.dispatchEvent(new CustomEvent("trace-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}}))};#n(){this.innerHTML="",this.#s=document.createElement("details"),this.#s.setAttribute("data-trace-root",""),this.collapsed||this.#s.setAttribute("open",""),this.#s.addEventListener("toggle",this.#r),this.appendChild(this.#s),this.#a()}#a(){if(!this.#s)return;let t=this.#t.length?this.#t.map(a=>this.#h(a)).join("<span data-trace-sep>\xB7</span>"):`<span>${ss(this.label||"Trace")}</span>`,e=this.#e.some(a=>a.aux!=null&&String(a.aux).trim()!==""),i=this.#e.some(a=>this.#o(a)),r=this.#e.length?`
326
326
  <div data-trace-headers>
327
327
  <span data-trace-header>Stage</span>
328
328
  <span data-trace-header>Score</span>
@@ -365,7 +365,7 @@ Correct shape for <chart-ui x="label" y="value">:
365
365
  <dd>${ss(e.value!=null?String(e.value):"")}</dd>
366
366
  `).join("")}
367
367
  </dl>
368
- `:typeof t=="string"?t:""}#h(t){let e=t.tone||"neutral",i={success:"var(--a-success-strong)",warning:"var(--a-warning-strong)",danger:"var(--a-danger-strong)",info:"var(--a-accent-strong)",neutral:"var(--a-fg-muted)"}[e]||"var(--a-fg-muted)",r=t.dot===!1?"":`<icon-ui name="circle-fill" data-trace-dot style="color:${i}"></icon-ui>`,n=t.label!=null?String(t.label):"",o=t.value!=null?String(t.value):"",a=o?`${o}${n?` ${n}`:""}`:n;return`<span data-trace-pill>${r}<span>${ss(a)}</span></span>`}};function ss(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function F1(s){return String(s).replace(/"/g,"&quot;")}customElements.define("agent-trace-ui",_l);$();function dO({icon:s,text:t="",title:e=""}){let i=document.createElement("button-ui");return i.setAttribute("icon",s),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),t&&i.setAttribute("text",t),!t&&e&&i.setAttribute("title",e),i}var da=class extends x{static properties={saveLabel:{type:String,default:"",reflect:!0,attribute:"save-label"},saveIcon:{type:String,default:"bookmark-simple",reflect:!0,attribute:"save-icon"},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=!1;#n=!1;connected(){this.#u()}disconnected(){this.#t?.removeEventListener("press",this.#a),this.#e?.removeEventListener("press",this.#o),this.#i?.removeEventListener("press",this.#l),this.#t=this.#e=this.#i=this.#s=null}setStatus(t,{lock:e=""}={}){this.#s&&(this.#s.textContent=t||"",(e==="rate"||e==="all")&&(this.#r=!0,this.#t&&(this.#t.disabled=!0),this.#e&&(this.#e.disabled=!0)),(e==="save"||e==="all")&&(this.#n=!0,this.#i&&(this.#i.disabled=!0)))}reset(){this.#r=!1,this.#n=!1,this.#s&&(this.#s.textContent=""),this.#t&&(this.#t.disabled=!1),this.#e&&(this.#e.disabled=!1),this.#i&&(this.#i.disabled=!1)}#a=()=>{!this.#r&&!this.disabled&&this.#c(5)};#o=()=>{!this.#r&&!this.disabled&&this.#c(2)};#l=()=>{!this.#n&&!this.disabled&&this.#h()};#c(t){this.dispatchEvent(new CustomEvent("feedback-rate",{bubbles:!0,detail:{rating:t}})),this.#s?.textContent||this.setStatus(t>=4?"Thanks!":"Noted",{lock:"rate"})}#h(){this.dispatchEvent(new CustomEvent("feedback-save",{bubbles:!0,detail:{}}))}render(){let t=this.saveLabel,e=this.saveIcon;this.#i&&(t?(this.#i.setAttribute("text",t),this.#i.hidden=!1):this.#i.hidden=!0,e&&this.#i.setAttribute("icon",e))}#u(){this.innerHTML="",this.#t=dO({icon:"thumbs-up",title:"Rate this response positively"}),this.#e=dO({icon:"thumbs-down",title:"Rate this response negatively"}),this.#i=dO({icon:this.saveIcon||"bookmark-simple",text:this.saveLabel||"",title:this.saveLabel?"":"Save this response"}),this.saveLabel||(this.#i.hidden=!0),this.#t.addEventListener("press",this.#a),this.#e.addEventListener("press",this.#o),this.#i.addEventListener("press",this.#l),this.#s=document.createElement("span"),this.#s.setAttribute("data-feedback-status",""),this.append(this.#t,this.#e,this.#i,this.#s)}};S("agent-feedback-bar-ui",da);$();function BD(s,t){return typeof s!="string"?"":s.length>t?s.slice(0,t-1)+"\u2026":s}var fa=class extends x{static properties={variant:{type:String,default:"outline",reflect:!0},size:{type:String,default:"sm",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];get suggestions(){return this.#t}set suggestions(t){this.#t=Array.isArray(t)?t.slice():[],this.#e()}connected(){this.#e()}disconnected(){this.innerHTML=""}#e(){this.innerHTML="";for(let t=0;t<this.#t.length;t++){let e=this.#t[t],i=typeof e=="string"?e:e.label||e.prompt||"",r=typeof e=="string"?e:e.prompt||e.label||"",n=typeof e=="object"?e.icon:null,o=document.createElement("button-ui");o.setAttribute("text",BD(i,42)),o.setAttribute("variant",this.variant),o.setAttribute("size",this.size),n&&o.setAttribute("icon",n),this.disabled&&o.setAttribute("disabled",""),o.addEventListener("press",()=>{this.disabled||this.dispatchEvent(new CustomEvent("suggestion-select",{bubbles:!0,detail:{label:i,prompt:r,index:t}}))}),this.appendChild(o)}}};S("agent-suggestions-ui",fa);$();function Y1(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function zD(s){return String(s).replace(/"/g,"&quot;")}var pa=class extends x{static requiredIcons=["check"];static properties={multi:{type:Boolean,default:!1,reflect:!0},question:{type:String,default:"",reflect:!0},helper:{type:String,default:"",reflect:!0},submitLabel:{type:String,default:"Continue",reflect:!0,attribute:"submit-label"}};static template=()=>null;#t=[];#e=new Set;#i=!1;#s=null;#r=null;#n=null;#a=null;get options(){return this.#t}set options(t){this.#t=Array.isArray(t)?t.slice():[],this.#e.clear(),this.#i=!1,this.#l()}connected(){this.#o()}disconnected(){this.#a?.removeEventListener("press",this.#h),this.#s=this.#r=this.#n=this.#a=null}render(){this.#s&&(this.#s.textContent=this.question||"",this.#s.hidden=!this.question),this.#r&&(this.#r.textContent=this.helper||"",this.#r.hidden=!this.helper),this.#a&&(this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.hidden=!this.multi)}#o(){this.innerHTML="",this.#s=document.createElement("div"),this.#s.setAttribute("data-questions-q",""),this.question?this.#s.textContent=this.question:this.#s.hidden=!0,this.#r=document.createElement("div"),this.#r.setAttribute("data-questions-helper",""),this.helper?this.#r.textContent=this.helper:this.#r.hidden=!0,this.#n=document.createElement("div"),this.#n.setAttribute("data-questions-options",""),this.#a=document.createElement("button-ui"),this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.setAttribute("variant","primary"),this.#a.setAttribute("size","sm"),this.#a.setAttribute("disabled",""),this.multi||(this.#a.hidden=!0),this.#a.addEventListener("press",this.#h),this.append(this.#s,this.#r,this.#n,this.#a),this.#l()}#l(){if(this.#n){this.#n.innerHTML="";for(let t of this.#t){let e=document.createElement("button");e.type="button",e.setAttribute("data-questions-option",""),e.setAttribute("role",this.multi?"checkbox":"radio"),e.setAttribute("aria-checked",this.#e.has(t.id)?"true":"false"),this.#e.has(t.id)&&e.setAttribute("data-selected",""),this.#i&&e.setAttribute("disabled","");let i=t.icon?`<icon-ui name="${zD(t.icon)}" color="muted" data-questions-option-icon></icon-ui>`:"",r=`
368
+ `:typeof t=="string"?t:""}#h(t){let e=t.tone||"neutral",i={success:"var(--a-success-strong)",warning:"var(--a-warning-strong)",danger:"var(--a-danger-strong)",info:"var(--a-accent-strong)",neutral:"var(--a-fg-muted)"}[e]||"var(--a-fg-muted)",r=t.dot===!1?"":`<icon-ui name="circle-fill" data-trace-dot style="color:${i}"></icon-ui>`,n=t.label!=null?String(t.label):"",o=t.value!=null?String(t.value):"",a=o?`${o}${n?` ${n}`:""}`:n;return`<span data-trace-pill>${r}<span>${ss(a)}</span></span>`}};function ss(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function F1(s){return String(s).replace(/"/g,"&quot;")}customElements.define("agent-trace-ui",_l);$();function dO({icon:s,text:t="",title:e=""}){let i=document.createElement("button-ui");return i.setAttribute("icon",s),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),t&&i.setAttribute("text",t),!t&&e&&i.setAttribute("title",e),i}var da=class extends x{static properties={saveLabel:{type:String,default:"",reflect:!0,attribute:"save-label"},saveIcon:{type:String,default:"bookmark-simple",reflect:!0,attribute:"save-icon"},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=!1;#n=!1;connected(){this.#d()}disconnected(){this.#t?.removeEventListener("press",this.#a),this.#e?.removeEventListener("press",this.#o),this.#i?.removeEventListener("press",this.#l),this.#t=this.#e=this.#i=this.#s=null}setStatus(t,{lock:e=""}={}){this.#s&&(this.#s.textContent=t||"",(e==="rate"||e==="all")&&(this.#r=!0,this.#t&&(this.#t.disabled=!0),this.#e&&(this.#e.disabled=!0)),(e==="save"||e==="all")&&(this.#n=!0,this.#i&&(this.#i.disabled=!0)))}reset(){this.#r=!1,this.#n=!1,this.#s&&(this.#s.textContent=""),this.#t&&(this.#t.disabled=!1),this.#e&&(this.#e.disabled=!1),this.#i&&(this.#i.disabled=!1)}#a=()=>{!this.#r&&!this.disabled&&this.#c(5)};#o=()=>{!this.#r&&!this.disabled&&this.#c(2)};#l=()=>{!this.#n&&!this.disabled&&this.#h()};#c(t){this.dispatchEvent(new CustomEvent("feedback-rate",{bubbles:!0,detail:{rating:t}})),this.#s?.textContent||this.setStatus(t>=4?"Thanks!":"Noted",{lock:"rate"})}#h(){this.dispatchEvent(new CustomEvent("feedback-save",{bubbles:!0,detail:{}}))}render(){let t=this.saveLabel,e=this.saveIcon;this.#i&&(t?(this.#i.setAttribute("text",t),this.#i.hidden=!1):this.#i.hidden=!0,e&&this.#i.setAttribute("icon",e))}#d(){this.innerHTML="",this.#t=dO({icon:"thumbs-up",title:"Rate this response positively"}),this.#e=dO({icon:"thumbs-down",title:"Rate this response negatively"}),this.#i=dO({icon:this.saveIcon||"bookmark-simple",text:this.saveLabel||"",title:this.saveLabel?"":"Save this response"}),this.saveLabel||(this.#i.hidden=!0),this.#t.addEventListener("press",this.#a),this.#e.addEventListener("press",this.#o),this.#i.addEventListener("press",this.#l),this.#s=document.createElement("span"),this.#s.setAttribute("data-feedback-status",""),this.append(this.#t,this.#e,this.#i,this.#s)}};S("agent-feedback-bar-ui",da);$();function BD(s,t){return typeof s!="string"?"":s.length>t?s.slice(0,t-1)+"\u2026":s}var fa=class extends x{static properties={variant:{type:String,default:"outline",reflect:!0},size:{type:String,default:"sm",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];get suggestions(){return this.#t}set suggestions(t){this.#t=Array.isArray(t)?t.slice():[],this.#e()}connected(){this.#e()}disconnected(){this.innerHTML=""}#e(){this.innerHTML="";for(let t=0;t<this.#t.length;t++){let e=this.#t[t],i=typeof e=="string"?e:e.label||e.prompt||"",r=typeof e=="string"?e:e.prompt||e.label||"",n=typeof e=="object"?e.icon:null,o=document.createElement("button-ui");o.setAttribute("text",BD(i,42)),o.setAttribute("variant",this.variant),o.setAttribute("size",this.size),n&&o.setAttribute("icon",n),this.disabled&&o.setAttribute("disabled",""),o.addEventListener("press",()=>{this.disabled||this.dispatchEvent(new CustomEvent("suggestion-select",{bubbles:!0,detail:{label:i,prompt:r,index:t}}))}),this.appendChild(o)}}};S("agent-suggestions-ui",fa);$();function Y1(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function zD(s){return String(s).replace(/"/g,"&quot;")}var pa=class extends x{static requiredIcons=["check"];static properties={multi:{type:Boolean,default:!1,reflect:!0},question:{type:String,default:"",reflect:!0},helper:{type:String,default:"",reflect:!0},submitLabel:{type:String,default:"Continue",reflect:!0,attribute:"submit-label"}};static template=()=>null;#t=[];#e=new Set;#i=!1;#s=null;#r=null;#n=null;#a=null;get options(){return this.#t}set options(t){this.#t=Array.isArray(t)?t.slice():[],this.#e.clear(),this.#i=!1,this.#l()}connected(){this.#o()}disconnected(){this.#a?.removeEventListener("press",this.#h),this.#s=this.#r=this.#n=this.#a=null}render(){this.#s&&(this.#s.textContent=this.question||"",this.#s.hidden=!this.question),this.#r&&(this.#r.textContent=this.helper||"",this.#r.hidden=!this.helper),this.#a&&(this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.hidden=!this.multi)}#o(){this.innerHTML="",this.#s=document.createElement("div"),this.#s.setAttribute("data-questions-q",""),this.question?this.#s.textContent=this.question:this.#s.hidden=!0,this.#r=document.createElement("div"),this.#r.setAttribute("data-questions-helper",""),this.helper?this.#r.textContent=this.helper:this.#r.hidden=!0,this.#n=document.createElement("div"),this.#n.setAttribute("data-questions-options",""),this.#a=document.createElement("button-ui"),this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.setAttribute("variant","primary"),this.#a.setAttribute("size","sm"),this.#a.setAttribute("disabled",""),this.multi||(this.#a.hidden=!0),this.#a.addEventListener("press",this.#h),this.append(this.#s,this.#r,this.#n,this.#a),this.#l()}#l(){if(this.#n){this.#n.innerHTML="";for(let t of this.#t){let e=document.createElement("button");e.type="button",e.setAttribute("data-questions-option",""),e.setAttribute("role",this.multi?"checkbox":"radio"),e.setAttribute("aria-checked",this.#e.has(t.id)?"true":"false"),this.#e.has(t.id)&&e.setAttribute("data-selected",""),this.#i&&e.setAttribute("disabled","");let i=t.icon?`<icon-ui name="${zD(t.icon)}" color="muted" data-questions-option-icon></icon-ui>`:"",r=`
369
369
  <span data-questions-option-check aria-hidden="true">
370
370
  <icon-ui name="check" size="sm" color="accent"></icon-ui>
371
371
  </span>`;e.innerHTML=`
@@ -378,7 +378,7 @@ Correct shape for <chart-ui x="label" y="value">:
378
378
  `,e.addEventListener("click",()=>this.#c(t)),this.#n.appendChild(e)}this.#a&&(this.#a.disabled=this.#i||this.#e.size===0)}}#c(t){this.#i||(this.multi?(this.#e.has(t.id)?this.#e.delete(t.id):this.#e.add(t.id),this.#l()):(this.#e.clear(),this.#e.add(t.id),this.#i=!0,this.#l(),this.dispatchEvent(new CustomEvent("questions-answer",{bubbles:!0,detail:{selected:[t.id],option:t}}))))}#h=()=>{if(this.#i||this.#e.size===0)return;this.#i=!0,this.#l();let t=[...this.#e],e=this.#t.find(i=>i.id===t[0])||null;this.dispatchEvent(new CustomEvent("questions-answer",{bubbles:!0,detail:{selected:t,option:e}}))}};S("agent-questions-ui",pa);$();var H1={neutral:"default",accent:"accent",warning:"warning",danger:"danger"},ma=class extends x{static properties={title:{type:String,default:"",reflect:!0},kind:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},tone:{type:String,default:"neutral",reflect:!0}};static requiredIcons=["caret-right","caret-down"];static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){this.#l()}disconnected(){this.#t?.removeEventListener("click",this.#a),this.#t?.removeEventListener("keydown",this.#o),this.#t=this.#e=this.#i=null,this.#s=this.#r=this.#n=null}#a=t=>{t.target.closest('[slot="primary"], [slot="secondary"]')||(this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("artifact-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.render())};#o=t=>{if(t.key===" "||t.key==="Enter"){if(t.target.closest('[slot="primary"], [slot="secondary"]'))return;t.preventDefault(),this.#a(t)}};render(){this.#t&&(this.#e&&(this.icon?(this.#e.setAttribute("name",this.icon),this.#e.hidden=!1):this.#e.hidden=!0),this.#i&&(this.#i.textContent=this.title||"",this.#i.hidden=!this.title),this.#s&&(this.#s.setAttribute("text",(this.kind||"").toUpperCase()),this.#s.setAttribute("variant",H1[this.tone]||"default"),this.#s.hidden=!this.kind),this.#r&&this.#r.setAttribute("name",this.collapsed?"caret-right":"caret-down"),this.#n&&(this.#n.hidden=this.collapsed),this.#t&&this.#t.setAttribute("aria-expanded",String(!this.collapsed)))}#l(){let t=Array.from(this.childNodes).filter(n=>{if(n.nodeType===1){let o=n.getAttribute?.("slot")||"";return o!=="primary"&&o!=="secondary"}return!0}),e=this.querySelectorAll(':scope > [slot="primary"]'),i=this.querySelectorAll(':scope > [slot="secondary"]');this.innerHTML="",this.#t=document.createElement("div"),this.#t.setAttribute("data-artifact-header",""),this.#t.setAttribute("role","button"),this.#t.setAttribute("tabindex","0"),this.#t.setAttribute("aria-expanded",String(!this.collapsed)),this.#t.addEventListener("click",this.#a),this.#t.addEventListener("keydown",this.#o),this.#e=document.createElement("icon-ui"),this.#e.setAttribute("data-artifact-icon",""),this.#e.setAttribute("color","muted"),this.icon?this.#e.setAttribute("name",this.icon):this.#e.hidden=!0,this.#i=document.createElement("span"),this.#i.setAttribute("data-artifact-title",""),this.title?this.#i.textContent=this.title:this.#i.hidden=!0,this.#s=document.createElement("badge-ui"),this.#s.setAttribute("data-artifact-kind",""),this.#s.setAttribute("size","sm"),this.#s.setAttribute("variant",H1[this.tone]||"default"),this.kind?this.#s.setAttribute("text",this.kind.toUpperCase()):this.#s.hidden=!0;let r=document.createElement("span");r.setAttribute("data-artifact-actions","");for(let n of i)r.appendChild(n);for(let n of e)r.appendChild(n);this.#r=document.createElement("icon-ui"),this.#r.setAttribute("color","muted"),this.#r.setAttribute("data-artifact-caret",""),this.#r.setAttribute("name",this.collapsed?"caret-right":"caret-down"),this.#t.append(this.#e,this.#i,this.#s,r,this.#r),this.#n=document.createElement("div"),this.#n.setAttribute("data-artifact-body","");for(let n of t)this.#n.appendChild(n);this.collapsed&&(this.#n.hidden=!0),this.append(this.#t,this.#n)}};S("agent-artifact-ui",ma);$();var _D="rounded borderless",jl=class s extends x{static properties={mode:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("mode")||(this.mode=_D),this.addEventListener("click",this.#e),this.#i()}#t(t){return this.querySelector(`admin-sidebar[slot="${t}"], admin-sidebar[name="${t}"]`)}#e=t=>{let e=t.target.closest("[data-sidebar-toggle]");if(e&&this.contains(e)){let r=e.getAttribute("data-sidebar-toggle"),n=this.#t(r);n&&typeof n.toggle!="function"&&this.#r("admin-sidebar",`slot="${r}"`,"Sidebar toggle"),n?.toggle?.();return}let i=t.target.closest("[data-command-trigger]");if(i&&this.contains(i)){t.stopPropagation();let r=this.querySelector("admin-command");if(!r)return;if(typeof r.show!="function"){this.#r("admin-command","","Command palette");return}r.show()}};#i(){let t=this.querySelector("admin-command"),e=this.querySelector("nav-ui");!t||!e||t.addEventListener("command-select",i=>{let r=e.querySelector(`nav-item-ui[value="${i.detail.value}"]`);r&&e.select(r)})}static#s=new WeakSet;#r(t,e,i){let r=e?this.querySelector(`${t}[${e}], ${t}[${e.replace("slot=","name=")}]`):this.querySelector(t);if(!r||s.#s.has(r))return;s.#s.add(r);let n=t==="admin-sidebar"?"shell/admin-sidebar":"shell/admin-command";console.warn(`[admin-shell] <${t}${e?" "+e:""}> is in the DOM but ${t==="admin-sidebar"?"AdminSidebar":"AdminCommand"} is NOT registered \u2014 ${i} will not work. Import the cluster barrel \`@adia-ai/web-modules/shell\` (which registers all shell elements), OR add \`@adia-ai/web-modules/${n}\` alongside \`@adia-ai/web-modules/shell/admin-shell\` on the per-component path. Closes FB-55 silent-failure trap.`)}};customElements.define("admin-shell",jl);$();var Vl=96,G1=160,Wl=class s extends x{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0},name:{type:String,default:"",reflect:!0},minWidth:{type:String,default:"",reflect:!0,attribute:"min-width"}};static template=()=>null;static#t=new WeakSet;#e="";#i=[];#s=null;connected(){this.#a(),this.resizable&&this.#l(),this.#c(),this.#o()}disconnected(){for(let t of this.#i)t();this.#i=[],this.#s?.disconnect(),this.#s=null}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){if(this.collapsed)return;let t=this.style.width||getComputedStyle(this).width;parseFloat(t)>Vl&&(this.#e=t);let e=this.minWidth||getComputedStyle(this).minWidth;this.style.width=e,this.#n(e),this.collapsed=!0,this.#h(!1)}expand(){if(!this.collapsed)return;let t=this.#e||"";this.style.width=t,this.#n(t),this.collapsed=!1,this.#h(!0)}#r(){return`adia-sidebar-${this.name||this.getAttribute("slot")||"default"}`}#n(t){try{localStorage.setItem(this.#r(),t)}catch{}}#a(){try{let t=localStorage.getItem(this.#r());if(!t)return;this.style.width=t;let e=parseFloat(t);!isNaN(e)&&e>Vl&&(this.#e=t)}catch{}}#o(){let t=this.getBoundingClientRect().width;this.collapsed=t<=Vl}#l(){let t=this.querySelector(":scope > [data-resize]");if(!t){s.#t.has(this)||(s.#t.add(this),console.warn("[admin-sidebar] `resizable` is set but no `[data-resize]` child was found. Add `<div data-resize></div>` as a direct child to enable drag-to-resize. (Unlike `collapsible`, `resizable` requires this author-supplied handle.)",this));return}let e=this.getAttribute("slot"),i=e==="leading",r=n=>{n.preventDefault(),t.setPointerCapture(n.pointerId);let o=n.clientX,a=this.getBoundingClientRect().width;this.resizing=!0,document.documentElement.style.cursor="col-resize";let l=c=>{let u=c.clientX-o,d=parseInt(getComputedStyle(this).getPropertyValue("max-width"))||480,f=Math.max(48,Math.min(d,a+(i?u:-u)));this.style.width=`${f}px`},h=()=>{this.resizing=!1,document.documentElement.style.cursor="",t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",h);let c=this.getBoundingClientRect().width;c<=Vl?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<G1&&(this.style.width=`${G1}px`),this.#n(this.style.width),this.#o(),this.dispatchEvent(new CustomEvent("sidebar-resize",{bubbles:!0,detail:{name:this.name||e,width:this.getBoundingClientRect().width}}))};t.addEventListener("pointermove",l),t.addEventListener("pointerup",h)};t.addEventListener("pointerdown",r),this.#i.push(()=>t.removeEventListener("pointerdown",r))}#c(){this.#s=new ResizeObserver(t=>{for(let e of t){let i=e.contentBoxSize[0].inlineSize<=Vl;for(let r of this.querySelectorAll("select-ui"))r.setAttribute("placement",i?"right":"bottom-start")}}),this.#s.observe(this)}#h(t){this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:this.name||this.getAttribute("slot")||"default",expanded:t}}))}};customElements.define("admin-sidebar",Wl);$();var Ul=class extends x{static properties={open:{type:Boolean,default:!1,reflect:!0},shortcut:{type:String,default:"both",reflect:!0},noShortcut:{type:Boolean,default:!1,reflect:!0,attribute:"no-shortcut"}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.#i=this.querySelector(":scope > dialog"),!this.#i){for(this.#i=document.createElement("dialog");this.firstChild;)this.#i.appendChild(this.firstChild);this.appendChild(this.#i)}this.#e=this.querySelector("command-ui"),this.#s(),this.#r(),this.noShortcut||this.#n()}disconnected(){this.#t&&(document.removeEventListener("keydown",this.#t),this.#t=null)}show(){this.#i&&(this.#i.open||(this.#i.showModal(),this.#e&&(this.#e.open=!0,this.#e.value="",this.#e.focus()),this.open=!0))}hide(){this.#i&&this.#i.open&&(this.#i.close(),this.#e&&(this.#e.open=!1),this.open=!1)}toggle(){return this.open?this.hide():this.show(),this.open}#s(){this.#i&&(this.#i.addEventListener("click",t=>{t.target===this.#i&&this.hide()}),this.#i.addEventListener("close",()=>{this.#e&&(this.#e.open=!1),this.open=!1}))}#r(){this.#e&&(this.#e.addEventListener("dismiss",()=>this.hide()),this.#e.addEventListener("select",t=>{this.dispatchEvent(new CustomEvent("command-select",{bubbles:!0,detail:t.detail})),this.hide()}))}#n(){let t=e=>{let i=e.metaKey,r=e.ctrlKey;return e.key!=="k"?!1:this.shortcut==="cmd+k"?i:this.shortcut==="ctrl+k"?r:i||r};this.#t=e=>{t(e)&&(e.preventDefault(),this.toggle())},document.addEventListener("keydown",this.#t)}};customElements.define("admin-command",Ul);lE();$();function bO(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var KD=0,Fl=class extends x{static properties={streaming:{type:Boolean,default:!1,reflect:!0},provider:{type:String,default:"",reflect:!0},model:{type:String,default:"",reflect:!0},system:{type:String,default:"",reflect:!0},proxyUrl:{type:String,default:"",attribute:"proxy-url",reflect:!0},thinking:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;#i=null;#s=null;#r=null;#n=null;#a="";get messages(){return[...this.#t]}get conversation(){return this.#t.filter(t=>t.role==="user"||t.role==="assistant").map(t=>({role:t.role,content:t.content}))}set conversation(t){this.clear();for(let e of t)this.appendMessage({role:e.role,content:e.content,render:!0})}set apiKey(t){this.#a=t}connected(){this.#i=this.querySelector("chat-thread"),this.#s=this.querySelector("chat-composer"),this.#r=this.querySelector("chat-empty"),this.#n=this.querySelector("chat-status"),this.#s?.addEventListener("composer-submit",this.#l)}disconnected(){this.#s?.removeEventListener("composer-submit",this.#l),this.abort()}#o(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}#l=t=>{if(this.streaming)return;let{text:e,model:i}=t.detail||{};e&&(this.#s.clear(),this.#o("submit",{text:e,model:i}),(this.proxyUrl||this.#a)&&this.send(e,i?{model:i}:{}))};appendMessage({role:t,content:e="",render:i=!1}){let r=`msg_${++KD}`;this.#t.push({id:r,role:t,content:e});let n=document.createElement("div");if(n.setAttribute("data-role",t),n.setAttribute("data-id",r),t==="user")n.innerHTML=`<div data-bubble>${bO(e)}</div>`;else if(t==="assistant"){let o=i&&e?ci(e):bO(e);n.innerHTML=`
379
379
  <span data-avatar>AI</span>
380
380
  <div data-bubble><div data-content>${o}</div>${i?"":"<span data-cursor></span>"}</div>
381
- `}else t==="error"&&(n.innerHTML=`<icon-ui name="warning"></icon-ui><span>${bO(e)}</span>`);return this.#i?.appendChild(n),this.#c(),this.#o("message",{id:r,role:t,content:e}),n}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role!=="assistant")return;e.content+=t;let i=this.#i?.querySelector("[data-role]:last-child [data-content]");i&&i.insertAdjacentText("beforeend",t),this.#c()}deleteMessage(t){let e=this.#t.findIndex(i=>i.id===t);e!==-1&&(this.#t.splice(e,1),this.#i?.querySelector(`[data-id="${t}"]`)?.remove())}clear(){if(this.#t.length=0,this.#i){let t=this.#r;this.#i.innerHTML="",t&&this.#i.appendChild(t)}this.#o("clear")}startStreaming(){this.streaming=!0,this.#s&&(this.#s.disabled=!0),this.#n&&(this.#n.textContent="Typing..."),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!0)}stopStreaming(){this.streaming=!1,this.#s&&(this.#s.disabled=!1),this.#n&&(this.#n.textContent=""),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!1),this.#i?.querySelector("[data-role]:last-child [data-cursor]")?.remove();let t=this.#t[this.#t.length-1];if(t?.role==="assistant"&&t.content){let e=this.#i?.querySelector("[data-role]:last-child [data-content]");e&&(e.innerHTML=ci(t.content),this.#h(e))}this.#s?.focus()}abort(){this.#e&&(this.#e.abort(),this.#e=null,this.#o("abort")),this.streaming&&this.stopStreaming()}async send(t,e={}){let i=e.model||this.model||this.#s?.model;if(!i)throw new Error("No model specified");this.appendMessage({role:"user",content:t}),this.appendMessage({role:"assistant",content:""}),this.startStreaming(),this.#e=new AbortController;try{let r={provider:this.provider||void 0,apiKey:this.#a||void 0,model:i,system:this.system||void 0,proxyUrl:this.proxyUrl||void 0,thinking:this.thinking||void 0,messages:this.conversation.slice(0,-1),signal:this.#e.signal,...e};for await(let n of md(r))n.type==="text"?(this.appendChunk(n.text),this.#o("chunk",{text:n.text,snapshot:n.snapshot})):n.type==="thinking"?this.#o("thinking",{text:n.text}):n.type==="done"?this.#o("done",{text:n.text,usage:n.usage,stopReason:n.stopReason}):n.type==="error"&&(this.appendMessage({role:"error",content:n.error.message}),this.#o("error",{error:n.error}))}catch(r){r.name!=="AbortError"&&(this.appendMessage({role:"error",content:r.message}),this.#o("error",{error:r}))}this.#e=null,this.stopStreaming()}export(){return{messages:this.#t.map(t=>({role:t.role,content:t.content})),model:this.model,system:this.system}}import(t){t.model&&(this.model=t.model),t.system&&(this.system=t.system),t.messages&&(this.conversation=t.messages)}#c(){let t=this.#i;t&&requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}#h(t){for(let e of t.querySelectorAll("pre")){let i=e.querySelector("code");if(!i)continue;let r=i.getAttribute("data-lang")||"",n=document.createElement("code-ui");r&&n.setAttribute("language",r),n.textContent=i.textContent,e.replaceWith(n)}}};customElements.define("chat-shell",Fl);$();var JD=40,Yl=class extends x{static properties={streaming:{type:Boolean,default:!1,reflect:!0},empty:{type:Boolean,default:!0,reflect:!0}};static template=()=>null;#t=null;#e=!0;#i=null;connected(){this.#s(),this.#r(),this.#n()}disconnected(){this.#t?.disconnect(),this.#t=null,this.#i&&(this.removeEventListener("scroll",this.#i),this.#i=null)}scrollToBottom(){this.scrollTo({top:this.scrollHeight,behavior:"smooth"})}scrollToBottomInstant(){this.scrollTop=this.scrollHeight}#s(){let t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()!=="chat-empty");this.empty=t.length===0}#r(){this.#t=new MutationObserver(()=>{this.#s(),this.#e&&this.scrollToBottomInstant()}),this.#t.observe(this,{childList:!0})}#n(){this.#i=()=>{let t=this.scrollHeight-(this.scrollTop+this.clientHeight);this.#e=t<=JD},this.addEventListener("scroll",this.#i,{passive:!0})}};customElements.define("chat-thread",Yl);$();var Hl=class extends x{static properties={disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.#t=this.querySelector("chat-input-ui")||this.querySelector("input-ui")||this.querySelector("textarea-ui"),this.#e=t=>{this.dispatchEvent(new CustomEvent("composer-submit",{bubbles:!0,detail:t.detail||{}}))},this.#t?.addEventListener("submit",this.#e),this.#i()}disconnected(){this.#t&&this.#e&&this.#t.removeEventListener("submit",this.#e),this.#t=null,this.#e=null}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),t==="disabled"&&this.#i()}focus(){this.#t?.focus?.()}clear(){this.#t?.clear?.()}get input(){return this.#t}#i(){this.#t&&(this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"))}};customElements.define("chat-composer",Hl);$();var Gl=96,hE=160,Kl=class extends x{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0},name:{type:String,default:"",reflect:!0},minWidth:{type:String,default:"",reflect:!0,attribute:"min-width"}};static template=()=>null;#t="";#e=[];#i=null;connected(){this.#n(),this.resizable&&this.#o(),this.#l(),this.#a()}disconnected(){for(let t of this.#e)t();this.#e=[],this.#i?.disconnect(),this.#i=null}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){if(this.collapsed)return;let t=this.style.width||getComputedStyle(this).width;parseFloat(t)>Gl&&(this.#t=t);let e=this.minWidth||getComputedStyle(this).minWidth;this.style.width=e,this.#r(e),this.collapsed=!0,this.#c(!1)}expand(){if(!this.collapsed)return;let t=this.#t||"";this.style.width=t,this.#r(t),this.collapsed=!1,this.#c(!0)}#s(){return`adia-chat-sidebar-${this.name||this.getAttribute("slot")||"default"}`}#r(t){try{localStorage.setItem(this.#s(),t)}catch{}}#n(){try{let t=localStorage.getItem(this.#s());if(!t)return;this.style.width=t;let e=parseFloat(t);!isNaN(e)&&e>Gl&&(this.#t=t)}catch{}}#a(){let t=this.getBoundingClientRect().width;this.collapsed=t<=Gl}#o(){let t=this.querySelector(":scope > [data-resize]");if(!t)return;let e=this.getAttribute("slot"),i=e==="leading",r=n=>{n.preventDefault(),t.setPointerCapture(n.pointerId);let o=n.clientX,a=this.getBoundingClientRect().width;this.resizing=!0,document.documentElement.style.cursor="col-resize";let l=c=>{let u=c.clientX-o,d=parseInt(getComputedStyle(this).getPropertyValue("max-width"))||480,f=Math.max(48,Math.min(d,a+(i?u:-u)));this.style.width=`${f}px`},h=()=>{this.resizing=!1,document.documentElement.style.cursor="",t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",h);let c=this.getBoundingClientRect().width;c<=Gl?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<hE&&(this.style.width=`${hE}px`),this.#r(this.style.width),this.#a(),this.dispatchEvent(new CustomEvent("sidebar-resize",{bubbles:!0,detail:{name:this.name||e,width:this.getBoundingClientRect().width}}))};t.addEventListener("pointermove",l),t.addEventListener("pointerup",h)};t.addEventListener("pointerdown",r),this.#e.push(()=>t.removeEventListener("pointerdown",r))}#l(){this.#i=new ResizeObserver(t=>{for(let e of t){let i=e.contentBoxSize[0].inlineSize<=Gl;for(let r of this.querySelectorAll("select-ui"))r.setAttribute("placement",i?"right":"bottom-start")}}),this.#i.observe(this)}#c(t){this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:this.name||this.getAttribute("slot")||"default",expanded:t}}))}};customElements.define("chat-sidebar",Kl);$();var Jl=class extends x{static properties={focusMode:{type:Boolean,default:!1,reflect:!0,attribute:"focus-mode"}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.#t=this.querySelector("editor-toolbar"),this.#e=this.querySelector("editor-canvas"),this.#s(),this.#i=t=>{let e=t?.detail?.name;e&&(e==="toggle-focus"||e==="full-screen")&&this.toggleFocusMode()},this.addEventListener("toolbar-action",this.#i)}disconnected(){this.#i&&this.removeEventListener("toolbar-action",this.#i),this.#i=null}toggleFocusMode(){this.focusMode=!this.focusMode,this.#t?.tagName?.toLowerCase()==="editor-toolbar"&&(this.#t.fullScreen=this.focusMode),this.#e?.tagName?.toLowerCase()==="editor-canvas"&&(this.focusMode?this.#e.focus?.():this.#e.blur?.()),this.dispatchEvent(new CustomEvent("editor-mode-change",{bubbles:!0,detail:{focusMode:this.focusMode}}))}#s(){for(let t of this.querySelectorAll("select-ui[data-options]"))try{let e=JSON.parse(t.getAttribute("data-options"));t.options=e}catch{}}};customElements.define("editor-shell",Jl);$();var th=class extends x{static properties={fullScreen:{type:Boolean,default:!1,reflect:!0,attribute:"full-screen"}};static template=()=>null;#t=null;connected(){this.#t=t=>{let e=t.target.closest("[data-toolbar-action]");if(!e||!this.contains(e))return;let i=e.getAttribute("data-toolbar-action");this.dispatchEvent(new CustomEvent("toolbar-action",{bubbles:!0,detail:{name:i}}))},this.addEventListener("click",this.#t)}disconnected(){this.#t&&this.removeEventListener("click",this.#t),this.#t=null}};customElements.define("editor-toolbar",th);$();var eh=class extends x{static properties={empty:{type:Boolean,default:!0,reflect:!0},focused:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=1;#e=null;connected(){this.#i(),this.#s()}disconnected(){this.#e?.disconnect(),this.#e=null}get zoom(){return this.#t}set zoom(t){let e=parseFloat(t);!isFinite(e)||e<=0||(this.#t=e,this.style.setProperty("--editor-canvas-zoom",String(e)))}resetView(){this.zoom=1}focus(){super.focus?.(),this.focused=!0}blur(){super.blur?.(),this.focused=!1}#i(){let t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()!=="editor-canvas-empty");this.empty=t.length===0}#s(){this.#e=new MutationObserver(()=>{this.#i()}),this.#e.observe(this,{childList:!0})}};customElements.define("editor-canvas",eh);$();var ih=96,tq="adia-editor-sidebar-",sh=class extends x{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){if(this.#t=this.querySelector("pane-ui"),!this.#t)return;let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.#i=`${tq}${e}`,this.#h(),this.#e=new ResizeObserver(i=>{if(getComputedStyle(this).display==="none")return;this.#a();let r=this.#t.offsetWidth;r>0&&(this.style.width=`${r}px`)}),this.#e.observe(this.#t),this.#s=i=>{i.target?.closest?.('[slot="resize"], [data-resize], [class*="handle"]')&&(this.resizing=!0)},this.#t.addEventListener("pointerdown",this.#s),this.#r=()=>{this.resizing&&(this.resizing=!1),this.#l()},document.addEventListener("pointerup",this.#r)}disconnected(){this.#n!==null&&(cancelAnimationFrame(this.#n),this.#n=null),this.#e?.disconnect(),this.#e=null,this.#s&&this.#t&&(this.#t.removeEventListener("pointerdown",this.#s),this.#s=null),this.#r&&(document.removeEventListener("pointerup",this.#r),this.#r=null)}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){this.#t&&(this.collapsed||this.#l(),this.#t.style.width=`${ih}px`,this.collapsed=!0,this.#o())}expand(){if(!this.#t)return;let t=this.#c(),e=t&&t>ih?t:240;this.#t.style.width=`${e}px`,this.collapsed=!1,this.#l(),this.#o()}#a(){if(!this.#t||getComputedStyle(this).display==="none")return;let t=this.#t.getBoundingClientRect();if(t.width!==0){if(t.width>ih){this.#n!==null&&(cancelAnimationFrame(this.#n),this.#n=null),this.collapsed=!1;return}this.#n===null&&(this.#n=requestAnimationFrame(()=>{if(this.#n=null,!this.#t||getComputedStyle(this).display==="none")return;let e=this.#t.getBoundingClientRect();e.width>0&&e.width<=ih&&(this.collapsed=!0)}))}}#o(){let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:e,expanded:!this.collapsed}}))}#l(){if(!(!this.#t||!this.#i))try{let t=this.#t.style.width||"";t&&localStorage.setItem(this.#i,t)}catch{}}#c(){if(!this.#i)return null;try{let t=localStorage.getItem(this.#i);if(!t)return null;let e=parseFloat(t);return isFinite(e)?e:null}catch{return null}}#h(){if(!this.#t)return;let t=this.#c();t&&t>0&&(this.#t.style.width=`${t}px`,this.collapsed=t<=ih)}};customElements.define("editor-sidebar",sh);function eq(){let s=document.activeElement;if(!s)return!1;let t=s.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||s.isContentEditable||t==="INPUT-UI"||t==="TEXTAREA-UI"||t==="OTP-INPUT-UI"||t==="SEARCH-UI")}$();var rh=class extends x{static properties={centered:{type:Boolean,default:!1,reflect:!0},"full-bleed":{type:Boolean,default:!1,reflect:!0}};static template=()=>null};customElements.get("simple-shell")||customElements.define("simple-shell",rh);$();var gd=class extends x{static properties={mode:{type:String,default:"chat",reflect:!0},inspector:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=null;connected(){}render(){this.#t||(this.#t=!0,this.#e=document.createElement("chat-thread-ui"),this.#i=document.createElement("canvas-ui"),this.appendChild(this.#e),this.appendChild(this.#i),this.inspector&&(this.#s=document.createElement("inspector-ui"),this.appendChild(this.#s)))}appendMessage(t){this.#e?.appendMessage(t)}appendCoT(t){this.#e?.appendCoT(t)}pushArtifact(t){this.mode==="chat"&&(this.mode="split"),this.#i?.processAll(t)}setSuggestions(t){this.#e?.setSuggestions(t)}appendResultMessage(t){this.#e?.appendResultMessage(t)}showSavePatternBar(t){this.#e?.showSavePatternBar(t)}showFeedbackWidget(t){this.#e?.showFeedbackWidget(t)}showTyping(){this.#e?.showTyping()}hideTyping(){this.#e?.hideTyping()}appendError(t){this.#e?.appendError(t)}startPipelineStatus(){return this.#e?.startPipelineStatus()}updatePipelineStatus(t){this.#e?.updatePipelineStatus(t)}completePipelineStatus(){this.#e?.completePipelineStatus()}reset(){this.#e?.clear(),this.#i?.reset(),this.mode="chat"}get thread(){return this.#e}get canvas(){return this.#i}get inspect(){return this.#s}};customElements.define("gen-root",gd);cO();$();var iq=["default","ocean","forest","sunset","lavender","rose","slate","midnight"],sq={compact:{density:.85,radius:.75},default:{density:1,radius:1,clearTheme:!0},spacious:{density:1.15,radius:1.25}},cE=s=>s.length?s[0].toUpperCase()+s.slice(1):s,nh=class extends x{static properties={themes:{type:String,default:iq.join(" "),reflect:!0},parametric:{type:Boolean,default:!1,reflect:!0},presets:{type:Boolean,default:!1,reflect:!0},schemeToggle:{type:Boolean,default:!1,reflect:!0,attribute:"scheme-toggle"},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},target:{type:String,default:":root",reflect:!0},scheme:{type:String,default:"auto",reflect:!0},activeTheme:{type:String,default:"",reflect:!0,attribute:"active-theme"},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"},activeDensity:{type:String,default:"",reflect:!0,attribute:"active-density"},activeRadius:{type:String,default:"",reflect:!0,attribute:"active-radius"}};static template=()=>null;#t=null;#e=null;#i=[];#s=null;#r=null;#n=null;#a=!1;connected(){this.#a||(this.#o(),this.#a=!0,this.#f(),this.#m())}disconnected(){for(let t of this.#i)t();this.#i=[],this.#b()}apply(t={}){this.#u(t,"programmatic")}reset(){let t=this.#O();if(t.removeAttribute("data-theme"),t.style.removeProperty("--a-density"),t.style.removeProperty("--a-radius-k"),t.style.removeProperty("color-scheme"),this.persist)for(let i of["theme","scheme","density","radius"])try{localStorage.removeItem(`${this.storagePrefix}${i}`)}catch{}this.activeTheme="",this.activeDensity="",this.activeRadius="";let e=this.#p();this.activeScheme=e,this.#n&&(this.#n.value=e),this.#s&&(this.#s.value=1),this.#r&&(this.#r.value=1),this.#d("reset")}#o(){let t=document.createDocumentFragment();if(this.schemeToggle){let n=document.createElement("div");n.setAttribute("part","scheme");let o=document.createElement("segmented-ui");o.id=`${this.#y}-scheme`;let a=document.createElement("segment-ui");a.setAttribute("value","light"),a.setAttribute("text","Light");let l=document.createElement("segment-ui");l.setAttribute("value","dark"),l.setAttribute("text","Dark"),o.append(a,l),n.appendChild(o),t.appendChild(n),this.#n=o}let e=document.createElement("text-ui");e.setAttribute("variant","label"),e.textContent="Theme",t.appendChild(e);let i=document.createElement("div");i.setAttribute("part","themes");let r=(this.themes||"").trim().split(/\s+/).filter(Boolean);for(let n of r){let o=document.createElement("button-ui");o.setAttribute("data-theme-slug",n),o.setAttribute("text",cE(n)),o.setAttribute("variant","outline"),o.setAttribute("size","sm"),i.appendChild(o)}if(t.appendChild(i),this.parametric){t.appendChild(document.createElement("divider-ui"));let n=document.createElement("text-ui");n.setAttribute("variant","label"),n.textContent="Parametric",t.appendChild(n);let o=document.createElement("field-ui");o.setAttribute("label","Density");let a=document.createElement("slider-ui");a.setAttribute("part","density"),a.setAttribute("value","1"),a.setAttribute("min","0.5"),a.setAttribute("max","1.5"),a.setAttribute("step","0.05"),a.setAttribute("suffix","\xD7"),o.appendChild(a),t.appendChild(o),this.#s=a;let l=document.createElement("field-ui");l.setAttribute("label","Radius");let h=document.createElement("slider-ui");h.setAttribute("part","radius"),h.setAttribute("value","1"),h.setAttribute("min","0"),h.setAttribute("max","2"),h.setAttribute("step","0.1"),h.setAttribute("suffix","\xD7"),l.appendChild(h),t.appendChild(l),this.#r=h}if(this.presets){t.appendChild(document.createElement("divider-ui"));let n=document.createElement("div");n.setAttribute("part","presets");for(let o of["compact","default","spacious"]){let a=document.createElement("button-ui");a.setAttribute("data-preset",o),a.setAttribute("text",o==="default"?"Reset":cE(o)),a.setAttribute("variant","outline"),a.setAttribute("size","sm"),n.appendChild(a)}t.appendChild(n)}this.appendChild(t),this.#l()}#l(){for(let t of this.querySelectorAll('[part="themes"] button-ui')){let e=t.getAttribute("data-theme-slug"),i=()=>this.#c(e);t.addEventListener("press",i),t.addEventListener("click",i),this.#i.push(()=>{t.removeEventListener("press",i),t.removeEventListener("click",i)})}if(this.#s){let t=()=>this.#u({density:parseFloat(this.#s.value)},"slider");this.#s.addEventListener("input",t),this.#i.push(()=>this.#s.removeEventListener("input",t))}if(this.#r){let t=()=>this.#u({radius:parseFloat(this.#r.value)},"slider");this.#r.addEventListener("input",t),this.#i.push(()=>this.#r.removeEventListener("input",t))}for(let t of this.querySelectorAll('[part="presets"] button-ui')){let e=t.getAttribute("data-preset"),i=()=>this.#h(e);t.addEventListener("press",i),t.addEventListener("click",i),this.#i.push(()=>{t.removeEventListener("press",i),t.removeEventListener("click",i)})}if(this.#n){let t=e=>{let i=e.detail?.value??this.#n.value;(i==="light"||i==="dark")&&this.#u({scheme:i},"scheme")};this.#n.addEventListener("change",t),this.#i.push(()=>this.#n.removeEventListener("change",t))}}#c(t){let e=this.#O();if(e.style.removeProperty("--a-density"),e.style.removeProperty("--a-radius-k"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}density`),localStorage.removeItem(`${this.storagePrefix}radius`)}catch{}this.#u({theme:t},"theme");let i=()=>{let r=getComputedStyle(e),n=parseFloat(r.getPropertyValue("--a-density"))||1,o=parseFloat(r.getPropertyValue("--a-radius-k"))||1;this.#s&&(this.#s.value=n),this.#r&&(this.#r.value=o),this.activeDensity=String(n),this.activeRadius=String(o)};typeof requestAnimationFrame=="function"?requestAnimationFrame(i):i()}#h(t){let e=sq[t];if(e){if(e.clearTheme&&(this.#O().removeAttribute("data-theme"),this.activeTheme="",this.persist))try{localStorage.removeItem(`${this.storagePrefix}theme`)}catch{}this.#u({density:e.density,radius:e.radius},"preset"),this.#s&&(this.#s.value=e.density),this.#r&&(this.#r.value=e.radius)}}#u(t,e){let i=this.#O();if(t.theme!==void 0&&(t.theme===""||t.theme==="default"?(i.removeAttribute("data-theme"),this.activeTheme=""):(i.setAttribute("data-theme",t.theme),this.activeTheme=t.theme),this.persist))try{this.activeTheme?localStorage.setItem(`${this.storagePrefix}theme`,this.activeTheme):localStorage.removeItem(`${this.storagePrefix}theme`)}catch{}if(t.density!==void 0&&(i.style.setProperty("--a-density",t.density),this.activeDensity=String(t.density),this.persist))try{localStorage.setItem(`${this.storagePrefix}density`,String(t.density))}catch{}if(t.radius!==void 0&&(i.style.setProperty("--a-radius-k",t.radius),this.activeRadius=String(t.radius),this.persist))try{localStorage.setItem(`${this.storagePrefix}radius`,String(t.radius))}catch{}if(t.scheme!==void 0){let r=t.scheme;if(r==="auto"){if(i.style.removeProperty("color-scheme"),this.activeScheme=this.#p(),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}this.#g()}else if(r==="light"||r==="dark"){if(i.style.setProperty("color-scheme",r),this.activeScheme=r,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,r)}catch{}this.#b()}this.#n&&(this.#n.value=this.activeScheme)}this.#d(e)}#d(t){this.dispatchEvent(new CustomEvent("theme-change",{bubbles:!0,detail:{theme:this.activeTheme,scheme:this.activeScheme,density:this.activeDensity?parseFloat(this.activeDensity):1,radius:this.activeRadius?parseFloat(this.activeRadius):1,source:t}}))}#f(){let t=this.#O(),e,i,r,n;if(this.persist)try{e=localStorage.getItem(`${this.storagePrefix}theme`)||"",i=localStorage.getItem(`${this.storagePrefix}scheme`)||"";let o=localStorage.getItem(`${this.storagePrefix}density`),a=localStorage.getItem(`${this.storagePrefix}radius`);r=o!=null?parseFloat(o):void 0,n=a!=null?parseFloat(a):void 0}catch{}if(e?(t.setAttribute("data-theme",e),this.activeTheme=e):this.activeTheme=t.getAttribute("data-theme")||"",i==="light"||i==="dark")t.style.setProperty("color-scheme",i),this.activeScheme=i,this.#n&&(this.#n.value=i);else{let o=this.scheme||"auto";o==="light"||o==="dark"?(t.style.setProperty("color-scheme",o),this.activeScheme=o):this.activeScheme=this.#p(),this.#n&&(this.#n.value=this.activeScheme)}if(r!=null&&!Number.isNaN(r))t.style.setProperty("--a-density",r),this.activeDensity=String(r),this.#s&&(this.#s.value=r);else if(this.#s){let o=getComputedStyle(t),a=parseFloat(o.getPropertyValue("--a-density"))||1;this.#s.value=a,this.activeDensity=String(a)}if(n!=null&&!Number.isNaN(n))t.style.setProperty("--a-radius-k",n),this.activeRadius=String(n),this.#r&&(this.#r.value=n);else if(this.#r){let o=getComputedStyle(t),a=parseFloat(o.getPropertyValue("--a-radius-k"))||1;this.#r.value=a,this.activeRadius=String(a)}}#p(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}#m(){if(this.scheme==="auto"){if(this.persist)try{let t=localStorage.getItem(`${this.storagePrefix}scheme`);if(t==="light"||t==="dark")return}catch{}this.#g()}}#g(){if(!(this.#t||typeof matchMedia!="function"))try{this.#t=matchMedia("(prefers-color-scheme: dark)"),this.#e=()=>{let t=this.#t.matches?"dark":"light";this.activeScheme=t,this.#n&&(this.#n.value=t),this.#d("scheme")},this.#t.addEventListener("change",this.#e)}catch{}}#b(){if(this.#t&&this.#e)try{this.#t.removeEventListener("change",this.#e)}catch{}this.#t=null,this.#e=null}#O(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}get#y(){return this.id||"theme-panel"}};customElements.define("theme-panel",nh);$();var oh=class extends x{static properties={items:{type:Array,default:[]},"storage-key":{type:String,default:"",reflect:!0},storage:{type:String,default:"local",reflect:!0},"dismiss-on-complete":{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},value:{type:Object,default:{}},title:{type:String,default:"Get started",reflect:!0}};static template=t=>t._renderTemplate();#t=`obc-h-${Math.random().toString(36).slice(2,8)}`;#e=`obc-l-${Math.random().toString(36).slice(2,8)}`;#i=!1;#s=!1;#r=null;#n=null;attributeChangedCallback(t,e,i){if(t==="items"||t==="value"){if(i==null)this[t]=t==="items"?[]:{};else try{let r=JSON.parse(i);this[t]=r}catch{this[t]=t==="items"?[]:{}}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#t),this.hasAttribute("items")&&!Array.isArray(this.items))try{this.items=JSON.parse(this.getAttribute("items"))}catch{this.items=[]}if(this.hasAttribute("value")&&(typeof this.value!="object"||Array.isArray(this.value)))try{this.value=JSON.parse(this.getAttribute("value"))}catch{this.value={}}if(this.#i=this.value&&Object.keys(this.value).length>0,!this.#i){let t=this.#w();t&&(this.value=t)}this.#r=this.#o.bind(this),this.#n=this.#l.bind(this),this.addEventListener("change",this.#r),this.addEventListener("click",this.#n),this.#s=this.#p(),this.#m()}disconnected(){this.#r&&this.removeEventListener("change",this.#r),this.#n&&this.removeEventListener("click",this.#n),this.#r=null,this.#n=null,this.#v()}render(){this.#m(),this.#O(),this.#g()}_renderTemplate(){let t=Array.isArray(this.items)?this.items:[],{done:e,total:i,percent:r}=this.#f(),n=this.collapsed?"Expand":"Collapse",o=this.collapsed?"chevron-down":"chevron-up",a=!!this.collapsible,l=this.title||"Get started",h=i>0&&e===i;return it`
381
+ `}else t==="error"&&(n.innerHTML=`<icon-ui name="warning"></icon-ui><span>${bO(e)}</span>`);return this.#i?.appendChild(n),this.#c(),this.#o("message",{id:r,role:t,content:e}),n}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role!=="assistant")return;e.content+=t;let i=this.#i?.querySelector("[data-role]:last-child [data-content]");i&&i.insertAdjacentText("beforeend",t),this.#c()}deleteMessage(t){let e=this.#t.findIndex(i=>i.id===t);e!==-1&&(this.#t.splice(e,1),this.#i?.querySelector(`[data-id="${t}"]`)?.remove())}clear(){if(this.#t.length=0,this.#i){let t=this.#r;this.#i.innerHTML="",t&&this.#i.appendChild(t)}this.#o("clear")}startStreaming(){this.streaming=!0,this.#s&&(this.#s.disabled=!0),this.#n&&(this.#n.textContent="Typing..."),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!0)}stopStreaming(){this.streaming=!1,this.#s&&(this.#s.disabled=!1),this.#n&&(this.#n.textContent=""),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!1),this.#i?.querySelector("[data-role]:last-child [data-cursor]")?.remove();let t=this.#t[this.#t.length-1];if(t?.role==="assistant"&&t.content){let e=this.#i?.querySelector("[data-role]:last-child [data-content]");e&&(e.innerHTML=ci(t.content),this.#h(e))}this.#s?.focus()}abort(){this.#e&&(this.#e.abort(),this.#e=null,this.#o("abort")),this.streaming&&this.stopStreaming()}async send(t,e={}){let i=e.model||this.model||this.#s?.model;if(!i)throw new Error("No model specified");this.appendMessage({role:"user",content:t}),this.appendMessage({role:"assistant",content:""}),this.startStreaming(),this.#e=new AbortController;try{let r={provider:this.provider||void 0,apiKey:this.#a||void 0,model:i,system:this.system||void 0,proxyUrl:this.proxyUrl||void 0,thinking:this.thinking||void 0,messages:this.conversation.slice(0,-1),signal:this.#e.signal,...e};for await(let n of md(r))n.type==="text"?(this.appendChunk(n.text),this.#o("chunk",{text:n.text,snapshot:n.snapshot})):n.type==="thinking"?this.#o("thinking",{text:n.text}):n.type==="done"?this.#o("done",{text:n.text,usage:n.usage,stopReason:n.stopReason}):n.type==="error"&&(this.appendMessage({role:"error",content:n.error.message}),this.#o("error",{error:n.error}))}catch(r){r.name!=="AbortError"&&(this.appendMessage({role:"error",content:r.message}),this.#o("error",{error:r}))}this.#e=null,this.stopStreaming()}export(){return{messages:this.#t.map(t=>({role:t.role,content:t.content})),model:this.model,system:this.system}}import(t){t.model&&(this.model=t.model),t.system&&(this.system=t.system),t.messages&&(this.conversation=t.messages)}#c(){let t=this.#i;t&&requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}#h(t){for(let e of t.querySelectorAll("pre")){let i=e.querySelector("code");if(!i)continue;let r=i.getAttribute("data-lang")||"",n=document.createElement("code-ui");r&&n.setAttribute("language",r),n.textContent=i.textContent,e.replaceWith(n)}}};customElements.define("chat-shell",Fl);$();var JD=40,Yl=class extends x{static properties={streaming:{type:Boolean,default:!1,reflect:!0},empty:{type:Boolean,default:!0,reflect:!0}};static template=()=>null;#t=null;#e=!0;#i=null;connected(){this.#s(),this.#r(),this.#n()}disconnected(){this.#t?.disconnect(),this.#t=null,this.#i&&(this.removeEventListener("scroll",this.#i),this.#i=null)}scrollToBottom(){this.scrollTo({top:this.scrollHeight,behavior:"smooth"})}scrollToBottomInstant(){this.scrollTop=this.scrollHeight}#s(){let t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()!=="chat-empty");this.empty=t.length===0}#r(){this.#t=new MutationObserver(()=>{this.#s(),this.#e&&this.scrollToBottomInstant()}),this.#t.observe(this,{childList:!0})}#n(){this.#i=()=>{let t=this.scrollHeight-(this.scrollTop+this.clientHeight);this.#e=t<=JD},this.addEventListener("scroll",this.#i,{passive:!0})}};customElements.define("chat-thread",Yl);$();var Hl=class extends x{static properties={disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.#t=this.querySelector("chat-input-ui")||this.querySelector("input-ui")||this.querySelector("textarea-ui"),this.#e=t=>{this.dispatchEvent(new CustomEvent("composer-submit",{bubbles:!0,detail:t.detail||{}}))},this.#t?.addEventListener("submit",this.#e),this.#i()}disconnected(){this.#t&&this.#e&&this.#t.removeEventListener("submit",this.#e),this.#t=null,this.#e=null}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),t==="disabled"&&this.#i()}focus(){this.#t?.focus?.()}clear(){this.#t?.clear?.()}get input(){return this.#t}#i(){this.#t&&(this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"))}};customElements.define("chat-composer",Hl);$();var Gl=96,hE=160,Kl=class extends x{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0},name:{type:String,default:"",reflect:!0},minWidth:{type:String,default:"",reflect:!0,attribute:"min-width"}};static template=()=>null;#t="";#e=[];#i=null;connected(){this.#n(),this.resizable&&this.#o(),this.#l(),this.#a()}disconnected(){for(let t of this.#e)t();this.#e=[],this.#i?.disconnect(),this.#i=null}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){if(this.collapsed)return;let t=this.style.width||getComputedStyle(this).width;parseFloat(t)>Gl&&(this.#t=t);let e=this.minWidth||getComputedStyle(this).minWidth;this.style.width=e,this.#r(e),this.collapsed=!0,this.#c(!1)}expand(){if(!this.collapsed)return;let t=this.#t||"";this.style.width=t,this.#r(t),this.collapsed=!1,this.#c(!0)}#s(){return`adia-chat-sidebar-${this.name||this.getAttribute("slot")||"default"}`}#r(t){try{localStorage.setItem(this.#s(),t)}catch{}}#n(){try{let t=localStorage.getItem(this.#s());if(!t)return;this.style.width=t;let e=parseFloat(t);!isNaN(e)&&e>Gl&&(this.#t=t)}catch{}}#a(){let t=this.getBoundingClientRect().width;this.collapsed=t<=Gl}#o(){let t=this.querySelector(":scope > [data-resize]");if(!t)return;let e=this.getAttribute("slot"),i=e==="leading",r=n=>{n.preventDefault(),t.setPointerCapture(n.pointerId);let o=n.clientX,a=this.getBoundingClientRect().width;this.resizing=!0,document.documentElement.style.cursor="col-resize";let l=c=>{let u=c.clientX-o,d=parseInt(getComputedStyle(this).getPropertyValue("max-width"))||480,f=Math.max(48,Math.min(d,a+(i?u:-u)));this.style.width=`${f}px`},h=()=>{this.resizing=!1,document.documentElement.style.cursor="",t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",h);let c=this.getBoundingClientRect().width;c<=Gl?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<hE&&(this.style.width=`${hE}px`),this.#r(this.style.width),this.#a(),this.dispatchEvent(new CustomEvent("sidebar-resize",{bubbles:!0,detail:{name:this.name||e,width:this.getBoundingClientRect().width}}))};t.addEventListener("pointermove",l),t.addEventListener("pointerup",h)};t.addEventListener("pointerdown",r),this.#e.push(()=>t.removeEventListener("pointerdown",r))}#l(){this.#i=new ResizeObserver(t=>{for(let e of t){let i=e.contentBoxSize[0].inlineSize<=Gl;for(let r of this.querySelectorAll("select-ui"))r.setAttribute("placement",i?"right":"bottom-start")}}),this.#i.observe(this)}#c(t){this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:this.name||this.getAttribute("slot")||"default",expanded:t}}))}};customElements.define("chat-sidebar",Kl);$();var Jl=class extends x{static properties={focusMode:{type:Boolean,default:!1,reflect:!0,attribute:"focus-mode"}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.#t=this.querySelector("editor-toolbar"),this.#e=this.querySelector("editor-canvas"),this.#s(),this.#i=t=>{let e=t?.detail?.name;e&&(e==="toggle-focus"||e==="full-screen")&&this.toggleFocusMode()},this.addEventListener("toolbar-action",this.#i)}disconnected(){this.#i&&this.removeEventListener("toolbar-action",this.#i),this.#i=null}toggleFocusMode(){this.focusMode=!this.focusMode,this.#t?.tagName?.toLowerCase()==="editor-toolbar"&&(this.#t.fullScreen=this.focusMode),this.#e?.tagName?.toLowerCase()==="editor-canvas"&&(this.focusMode?this.#e.focus?.():this.#e.blur?.()),this.dispatchEvent(new CustomEvent("editor-mode-change",{bubbles:!0,detail:{focusMode:this.focusMode}}))}#s(){for(let t of this.querySelectorAll("select-ui[data-options]"))try{let e=JSON.parse(t.getAttribute("data-options"));t.options=e}catch{}}};customElements.define("editor-shell",Jl);$();var th=class extends x{static properties={fullScreen:{type:Boolean,default:!1,reflect:!0,attribute:"full-screen"}};static template=()=>null;#t=null;connected(){this.#t=t=>{let e=t.target.closest("[data-toolbar-action]");if(!e||!this.contains(e))return;let i=e.getAttribute("data-toolbar-action");this.dispatchEvent(new CustomEvent("toolbar-action",{bubbles:!0,detail:{name:i}}))},this.addEventListener("click",this.#t)}disconnected(){this.#t&&this.removeEventListener("click",this.#t),this.#t=null}};customElements.define("editor-toolbar",th);$();var eh=class extends x{static properties={empty:{type:Boolean,default:!0,reflect:!0},focused:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=1;#e=null;connected(){this.#i(),this.#s()}disconnected(){this.#e?.disconnect(),this.#e=null}get zoom(){return this.#t}set zoom(t){let e=parseFloat(t);!isFinite(e)||e<=0||(this.#t=e,this.style.setProperty("--editor-canvas-zoom",String(e)))}resetView(){this.zoom=1}focus(){super.focus?.(),this.focused=!0}blur(){super.blur?.(),this.focused=!1}#i(){let t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()!=="editor-canvas-empty");this.empty=t.length===0}#s(){this.#e=new MutationObserver(()=>{this.#i()}),this.#e.observe(this,{childList:!0})}};customElements.define("editor-canvas",eh);$();var ih=96,tq="adia-editor-sidebar-",sh=class extends x{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){if(this.#t=this.querySelector("pane-ui"),!this.#t)return;let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.#i=`${tq}${e}`,this.#h(),this.#e=new ResizeObserver(i=>{if(getComputedStyle(this).display==="none")return;this.#a();let r=this.#t.offsetWidth;r>0&&(this.style.width=`${r}px`)}),this.#e.observe(this.#t),this.#s=i=>{i.target?.closest?.('[slot="resize"], [data-resize], [class*="handle"]')&&(this.resizing=!0)},this.#t.addEventListener("pointerdown",this.#s),this.#r=()=>{this.resizing&&(this.resizing=!1),this.#l()},document.addEventListener("pointerup",this.#r)}disconnected(){this.#n!==null&&(cancelAnimationFrame(this.#n),this.#n=null),this.#e?.disconnect(),this.#e=null,this.#s&&this.#t&&(this.#t.removeEventListener("pointerdown",this.#s),this.#s=null),this.#r&&(document.removeEventListener("pointerup",this.#r),this.#r=null)}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){this.#t&&(this.collapsed||this.#l(),this.#t.style.width=`${ih}px`,this.collapsed=!0,this.#o())}expand(){if(!this.#t)return;let t=this.#c(),e=t&&t>ih?t:240;this.#t.style.width=`${e}px`,this.collapsed=!1,this.#l(),this.#o()}#a(){if(!this.#t||getComputedStyle(this).display==="none")return;let t=this.#t.getBoundingClientRect();if(t.width!==0){if(t.width>ih){this.#n!==null&&(cancelAnimationFrame(this.#n),this.#n=null),this.collapsed=!1;return}this.#n===null&&(this.#n=requestAnimationFrame(()=>{if(this.#n=null,!this.#t||getComputedStyle(this).display==="none")return;let e=this.#t.getBoundingClientRect();e.width>0&&e.width<=ih&&(this.collapsed=!0)}))}}#o(){let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:e,expanded:!this.collapsed}}))}#l(){if(!(!this.#t||!this.#i))try{let t=this.#t.style.width||"";t&&localStorage.setItem(this.#i,t)}catch{}}#c(){if(!this.#i)return null;try{let t=localStorage.getItem(this.#i);if(!t)return null;let e=parseFloat(t);return isFinite(e)?e:null}catch{return null}}#h(){if(!this.#t)return;let t=this.#c();t&&t>0&&(this.#t.style.width=`${t}px`,this.collapsed=t<=ih)}};customElements.define("editor-sidebar",sh);function eq(){let s=document.activeElement;if(!s)return!1;let t=s.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||s.isContentEditable||t==="INPUT-UI"||t==="TEXTAREA-UI"||t==="OTP-INPUT-UI"||t==="SEARCH-UI")}$();var rh=class extends x{static properties={centered:{type:Boolean,default:!1,reflect:!0},"full-bleed":{type:Boolean,default:!1,reflect:!0}};static template=()=>null};customElements.get("simple-shell")||customElements.define("simple-shell",rh);$();var gd=class extends x{static properties={mode:{type:String,default:"chat",reflect:!0},inspector:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=null;connected(){}render(){this.#t||(this.#t=!0,this.#e=document.createElement("chat-thread-ui"),this.#i=document.createElement("canvas-ui"),this.appendChild(this.#e),this.appendChild(this.#i),this.inspector&&(this.#s=document.createElement("inspector-ui"),this.appendChild(this.#s)))}appendMessage(t){this.#e?.appendMessage(t)}appendCoT(t){this.#e?.appendCoT(t)}pushArtifact(t){this.mode==="chat"&&(this.mode="split"),this.#i?.processAll(t)}setSuggestions(t){this.#e?.setSuggestions(t)}appendResultMessage(t){this.#e?.appendResultMessage(t)}showSavePatternBar(t){this.#e?.showSavePatternBar(t)}showFeedbackWidget(t){this.#e?.showFeedbackWidget(t)}showTyping(){this.#e?.showTyping()}hideTyping(){this.#e?.hideTyping()}appendError(t){this.#e?.appendError(t)}startPipelineStatus(){return this.#e?.startPipelineStatus()}updatePipelineStatus(t){this.#e?.updatePipelineStatus(t)}completePipelineStatus(){this.#e?.completePipelineStatus()}reset(){this.#e?.clear(),this.#i?.reset(),this.mode="chat"}get thread(){return this.#e}get canvas(){return this.#i}get inspect(){return this.#s}};customElements.define("gen-root",gd);cO();$();var iq=["default","ocean","forest","sunset","lavender","rose","slate","midnight"],sq={compact:{density:.85,radius:.75},default:{density:1,radius:1,clearTheme:!0},spacious:{density:1.15,radius:1.25}},cE=s=>s.length?s[0].toUpperCase()+s.slice(1):s,nh=class extends x{static properties={themes:{type:String,default:iq.join(" "),reflect:!0},parametric:{type:Boolean,default:!1,reflect:!0},presets:{type:Boolean,default:!1,reflect:!0},schemeToggle:{type:Boolean,default:!1,reflect:!0,attribute:"scheme-toggle"},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},target:{type:String,default:":root",reflect:!0},scheme:{type:String,default:"auto",reflect:!0},activeTheme:{type:String,default:"",reflect:!0,attribute:"active-theme"},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"},activeDensity:{type:String,default:"",reflect:!0,attribute:"active-density"},activeRadius:{type:String,default:"",reflect:!0,attribute:"active-radius"},register:{type:Boolean,default:!1,reflect:!0},activeRegister:{type:String,default:"",reflect:!0,attribute:"active-register"}};static template=()=>null;#t=null;#e=null;#i=[];#s=null;#r=null;#n=null;#a=null;#o=!1;connected(){this.#o||(this.#l(),this.#o=!0,this.#p(),this.#g())}disconnected(){for(let t of this.#i)t();this.#i=[],this.#y()}apply(t={}){this.#u(t,"programmatic")}reset(){let t=this.#O();if(t.removeAttribute("data-theme"),t.style.removeProperty("--a-density"),t.style.removeProperty("--a-radius-k"),t.style.removeProperty("color-scheme"),t.removeAttribute("verse"),t.removeAttribute("prose"),this.persist)for(let i of["theme","scheme","density","radius","register"])try{localStorage.removeItem(`${this.storagePrefix}${i}`)}catch{}this.activeTheme="",this.activeDensity="",this.activeRadius="",this.activeRegister="";let e=this.#m();this.activeScheme=e,this.#n&&(this.#n.value=e),this.#s&&(this.#s.value=1),this.#r&&(this.#r.value=1),this.#a&&(this.#a.value="regular"),this.#f("reset")}#l(){let t=document.createDocumentFragment();if(this.schemeToggle){let n=document.createElement("div");n.setAttribute("part","scheme");let o=document.createElement("segmented-ui");o.id=`${this.#S}-scheme`;let a=document.createElement("segment-ui");a.setAttribute("value","light"),a.setAttribute("text","Light");let l=document.createElement("segment-ui");l.setAttribute("value","dark"),l.setAttribute("text","Dark"),o.append(a,l),n.appendChild(o),t.appendChild(n),this.#n=o}let e=document.createElement("text-ui");e.setAttribute("variant","label"),e.textContent="Theme",t.appendChild(e);let i=document.createElement("div");i.setAttribute("part","themes");let r=(this.themes||"").trim().split(/\s+/).filter(Boolean);for(let n of r){let o=document.createElement("button-ui");o.setAttribute("data-theme-slug",n),o.setAttribute("text",cE(n)),o.setAttribute("variant","outline"),o.setAttribute("size","sm"),i.appendChild(o)}if(t.appendChild(i),this.parametric){t.appendChild(document.createElement("divider-ui"));let n=document.createElement("text-ui");n.setAttribute("variant","label"),n.textContent="Parametric",t.appendChild(n);let o=document.createElement("field-ui");o.setAttribute("label","Density");let a=document.createElement("slider-ui");a.setAttribute("part","density"),a.setAttribute("value","1"),a.setAttribute("min","0.5"),a.setAttribute("max","1.5"),a.setAttribute("step","0.05"),a.setAttribute("suffix","\xD7"),o.appendChild(a),t.appendChild(o),this.#s=a;let l=document.createElement("field-ui");l.setAttribute("label","Radius");let h=document.createElement("slider-ui");h.setAttribute("part","radius"),h.setAttribute("value","1"),h.setAttribute("min","0"),h.setAttribute("max","2"),h.setAttribute("step","0.1"),h.setAttribute("suffix","\xD7"),l.appendChild(h),t.appendChild(l),this.#r=h}if(this.presets||this.register){if(t.appendChild(document.createElement("divider-ui")),this.presets){let n=document.createElement("div");n.setAttribute("part","preset-row");let o=document.createElement("text-ui");o.setAttribute("variant","label"),o.textContent="Density",n.appendChild(o);let a=document.createElement("div");a.setAttribute("part","presets");for(let l of["compact","default","spacious"]){let h=document.createElement("button-ui");h.setAttribute("data-preset",l),h.setAttribute("text",l==="default"?"Reset":cE(l)),h.setAttribute("variant","outline"),h.setAttribute("size","sm"),a.appendChild(h)}n.appendChild(a),t.appendChild(n)}if(this.register){let n=document.createElement("div");n.setAttribute("part","preset-row");let o=document.createElement("text-ui");o.setAttribute("variant","label"),o.textContent="Scale Context",n.appendChild(o);let a=document.createElement("segmented-ui");a.setAttribute("part","register"),a.setAttribute("size","sm"),a.id=`${this.#S}-register`;for(let l of["verse","regular","prose"]){let h=document.createElement("segment-ui");h.setAttribute("value",l),h.setAttribute("text",l),a.appendChild(h)}a.setAttribute("value","regular"),n.appendChild(a),t.appendChild(n),this.#a=a}}this.appendChild(t),this.#c()}#c(){for(let t of this.querySelectorAll('[part="themes"] button-ui')){let e=t.getAttribute("data-theme-slug"),i=()=>this.#h(e);t.addEventListener("press",i),t.addEventListener("click",i),this.#i.push(()=>{t.removeEventListener("press",i),t.removeEventListener("click",i)})}if(this.#s){let t=()=>this.#u({density:parseFloat(this.#s.value)},"slider");this.#s.addEventListener("input",t),this.#i.push(()=>this.#s.removeEventListener("input",t))}if(this.#r){let t=()=>this.#u({radius:parseFloat(this.#r.value)},"slider");this.#r.addEventListener("input",t),this.#i.push(()=>this.#r.removeEventListener("input",t))}for(let t of this.querySelectorAll('[part="presets"] button-ui')){let e=t.getAttribute("data-preset"),i=()=>this.#d(e);t.addEventListener("press",i),t.addEventListener("click",i),this.#i.push(()=>{t.removeEventListener("press",i),t.removeEventListener("click",i)})}if(this.#n){let t=e=>{let i=e.detail?.value??this.#n.value;(i==="light"||i==="dark")&&this.#u({scheme:i},"scheme")};this.#n.addEventListener("change",t),this.#i.push(()=>this.#n.removeEventListener("change",t))}if(this.#a){let t=e=>{let i=e.detail?.value??this.#a.value;this.#u({register:i},"register")};this.#a.addEventListener("change",t),this.#i.push(()=>this.#a.removeEventListener("change",t))}}#h(t){let e=this.#O();if(e.style.removeProperty("--a-density"),e.style.removeProperty("--a-radius-k"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}density`),localStorage.removeItem(`${this.storagePrefix}radius`)}catch{}this.#u({theme:t},"theme");let i=()=>{let r=getComputedStyle(e),n=parseFloat(r.getPropertyValue("--a-density"))||1,o=parseFloat(r.getPropertyValue("--a-radius-k"))||1;this.#s&&(this.#s.value=n),this.#r&&(this.#r.value=o),this.activeDensity=String(n),this.activeRadius=String(o)};typeof requestAnimationFrame=="function"?requestAnimationFrame(i):i()}#d(t){let e=sq[t];if(e){if(e.clearTheme&&(this.#O().removeAttribute("data-theme"),this.activeTheme="",this.persist))try{localStorage.removeItem(`${this.storagePrefix}theme`)}catch{}this.#u({density:e.density,radius:e.radius},"preset"),this.#s&&(this.#s.value=e.density),this.#r&&(this.#r.value=e.radius)}}#u(t,e){let i=this.#O();if(t.theme!==void 0&&(t.theme===""||t.theme==="default"?(i.removeAttribute("data-theme"),this.activeTheme=""):(i.setAttribute("data-theme",t.theme),this.activeTheme=t.theme),this.persist))try{this.activeTheme?localStorage.setItem(`${this.storagePrefix}theme`,this.activeTheme):localStorage.removeItem(`${this.storagePrefix}theme`)}catch{}if(t.density!==void 0&&(i.style.setProperty("--a-density",t.density),this.activeDensity=String(t.density),this.persist))try{localStorage.setItem(`${this.storagePrefix}density`,String(t.density))}catch{}if(t.radius!==void 0&&(i.style.setProperty("--a-radius-k",t.radius),this.activeRadius=String(t.radius),this.persist))try{localStorage.setItem(`${this.storagePrefix}radius`,String(t.radius))}catch{}if(t.scheme!==void 0){let r=t.scheme;if(r==="auto"){if(i.style.removeProperty("color-scheme"),this.activeScheme=this.#m(),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}this.#b()}else if(r==="light"||r==="dark"){if(i.style.setProperty("color-scheme",r),this.activeScheme=r,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,r)}catch{}this.#y()}this.#n&&(this.#n.value=this.activeScheme)}if(t.register!==void 0){let r=t.register;if(i.toggleAttribute("verse",r==="verse"),i.toggleAttribute("prose",r==="prose"),this.activeRegister=r==="verse"||r==="prose"?r:"",this.persist)try{this.activeRegister?localStorage.setItem(`${this.storagePrefix}register`,this.activeRegister):localStorage.removeItem(`${this.storagePrefix}register`)}catch{}this.#a&&(this.#a.value=r)}this.#f(e)}#f(t){this.dispatchEvent(new CustomEvent("theme-change",{bubbles:!0,detail:{theme:this.activeTheme,scheme:this.activeScheme,density:this.activeDensity?parseFloat(this.activeDensity):1,radius:this.activeRadius?parseFloat(this.activeRadius):1,source:t}}))}#p(){let t=this.#O(),e,i,r,n,o;if(this.persist)try{e=localStorage.getItem(`${this.storagePrefix}theme`)||"",i=localStorage.getItem(`${this.storagePrefix}scheme`)||"";let a=localStorage.getItem(`${this.storagePrefix}density`),l=localStorage.getItem(`${this.storagePrefix}radius`);r=a!=null?parseFloat(a):void 0,n=l!=null?parseFloat(l):void 0,o=localStorage.getItem(`${this.storagePrefix}register`)||""}catch{}if(e?(t.setAttribute("data-theme",e),this.activeTheme=e):this.activeTheme=t.getAttribute("data-theme")||"",i==="light"||i==="dark")t.style.setProperty("color-scheme",i),this.activeScheme=i,this.#n&&(this.#n.value=i);else{let a=this.scheme||"auto";a==="light"||a==="dark"?(t.style.setProperty("color-scheme",a),this.activeScheme=a):this.activeScheme=this.#m(),this.#n&&(this.#n.value=this.activeScheme)}if(r!=null&&!Number.isNaN(r))t.style.setProperty("--a-density",r),this.activeDensity=String(r),this.#s&&(this.#s.value=r);else if(this.#s){let a=getComputedStyle(t),l=parseFloat(a.getPropertyValue("--a-density"))||1;this.#s.value=l,this.activeDensity=String(l)}if(n!=null&&!Number.isNaN(n))t.style.setProperty("--a-radius-k",n),this.activeRadius=String(n),this.#r&&(this.#r.value=n);else if(this.#r){let a=getComputedStyle(t),l=parseFloat(a.getPropertyValue("--a-radius-k"))||1;this.#r.value=l,this.activeRadius=String(l)}if(this.#a){let a=o==="verse"||o==="prose"?o:"regular";t.toggleAttribute("verse",a==="verse"),t.toggleAttribute("prose",a==="prose"),this.#a.value=a,this.activeRegister=a==="regular"?"":a}}#m(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}#g(){if(this.scheme==="auto"){if(this.persist)try{let t=localStorage.getItem(`${this.storagePrefix}scheme`);if(t==="light"||t==="dark")return}catch{}this.#b()}}#b(){if(!(this.#t||typeof matchMedia!="function"))try{this.#t=matchMedia("(prefers-color-scheme: dark)"),this.#e=()=>{let t=this.#t.matches?"dark":"light";this.activeScheme=t,this.#n&&(this.#n.value=t),this.#f("scheme")},this.#t.addEventListener("change",this.#e)}catch{}}#y(){if(this.#t&&this.#e)try{this.#t.removeEventListener("change",this.#e)}catch{}this.#t=null,this.#e=null}#O(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}get#S(){return this.id||"theme-panel"}};customElements.define("theme-panel",nh);$();var oh=class extends x{static properties={items:{type:Array,default:[]},"storage-key":{type:String,default:"",reflect:!0},storage:{type:String,default:"local",reflect:!0},"dismiss-on-complete":{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},value:{type:Object,default:{}},title:{type:String,default:"Get started",reflect:!0}};static template=t=>t._renderTemplate();#t=`obc-h-${Math.random().toString(36).slice(2,8)}`;#e=`obc-l-${Math.random().toString(36).slice(2,8)}`;#i=!1;#s=!1;#r=null;#n=null;attributeChangedCallback(t,e,i){if(t==="items"||t==="value"){if(i==null)this[t]=t==="items"?[]:{};else try{let r=JSON.parse(i);this[t]=r}catch{this[t]=t==="items"?[]:{}}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#t),this.hasAttribute("items")&&!Array.isArray(this.items))try{this.items=JSON.parse(this.getAttribute("items"))}catch{this.items=[]}if(this.hasAttribute("value")&&(typeof this.value!="object"||Array.isArray(this.value)))try{this.value=JSON.parse(this.getAttribute("value"))}catch{this.value={}}if(this.#i=this.value&&Object.keys(this.value).length>0,!this.#i){let t=this.#S();t&&(this.value=t)}this.#r=this.#o.bind(this),this.#n=this.#l.bind(this),this.addEventListener("change",this.#r),this.addEventListener("click",this.#n),this.#s=this.#p(),this.#m()}disconnected(){this.#r&&this.removeEventListener("change",this.#r),this.#n&&this.removeEventListener("click",this.#n),this.#r=null,this.#n=null,this.#v()}render(){this.#m(),this.#y(),this.#g()}_renderTemplate(){let t=Array.isArray(this.items)?this.items:[],{done:e,total:i,percent:r}=this.#f(),n=this.collapsed?"Expand":"Collapse",o=this.collapsed?"chevron-down":"chevron-up",a=!!this.collapsible,l=this.title||"Get started",h=i>0&&e===i;return it`
382
382
  <div data-part="header">
383
383
  <div data-part="title" id=${this.#t}>${l}</div>
384
384
  ${a?it`<button-ui
@@ -438,10 +438,10 @@ Correct shape for <chart-ui x="label" y="value">:
438
438
  text="Open"
439
439
  ></button-ui>`:null}
440
440
  </list-item-ui>
441
- `}#o(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-check]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"";if(!r)return;let n=this.#u(r),o=!!i.checked;n!==o&&this.#d(r,o,{emit:o})}#l(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-action]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"",n=i.getAttribute("data-href")||"";r&&this.dispatchEvent(new CustomEvent("onboarding-step-action",{bubbles:!0,detail:{id:r,href:n}}))}#c(t){t?.stopPropagation?.();let e=!this.collapsed;this.collapsed=e,e&&this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:"collapsed"}}))}#h(t){if(!t)return!1;let e=t.id;return e!=null&&Object.prototype.hasOwnProperty.call(this.value||{},e)?!!this.value[e]:!!t.done}#u(t){let i=(Array.isArray(this.items)?this.items:[]).find(r=>r&&String(r.id)===String(t));return this.#h(i)}#d(t,e,{emit:i=!0}={}){let r={...this.value||{},[t]:!!e};this.value=r,this.#v(),i&&e&&this.dispatchEvent(new CustomEvent("onboarding-step-complete",{bubbles:!0,detail:{id:t,value:r}}))}#f(){let t=Array.isArray(this.items)?this.items:[],e=t.length,i=0;for(let n of t)this.#h(n)&&i++;let r=e===0?0:Math.round(i/e*100);return{done:i,total:e,percent:r}}#p(){let{done:t,total:e}=this.#f();return e>0&&t===e}#m(){this.#p()?this.setAttribute("data-complete",""):this.removeAttribute("data-complete")}#g(){let t=this.#p();t&&!this.#s?(this.#s=!0,this.dispatchEvent(new CustomEvent("onboarding-complete",{bubbles:!0,detail:{value:this.value}})),this["dismiss-on-complete"]&&this.#b("complete")):t||(this.#s=!1)}#b(t="user"){this.setAttribute("hidden",""),this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:t}}))}#O(){}#y(){if(this.#i||this.storage==="none"||!this["storage-key"]||typeof window>"u")return null;try{return this.storage==="session"?window.sessionStorage:window.localStorage}catch{return null}}#w(){let t=this.#y();if(!t)return null;try{let e=t.getItem(this["storage-key"]);if(!e)return null;let i=JSON.parse(e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}#v(){let t=this.#y();if(t)try{t.setItem(this["storage-key"],JSON.stringify(this.value||{}))}catch{}}complete(t){if(t==null)return;let e=String(t);this.#u(e)||this.#d(e,!0,{emit:!0})}reset(t){if(t==null){this.value={};let i=this.#y();try{i?.removeItem(this["storage-key"])}catch{}this.#s=!1,this.removeAttribute("hidden");return}let e=String(t);Object.prototype.hasOwnProperty.call(this.value||{},e)&&this.#d(e,!1,{emit:!1})}progress(){return this.#f()}};customElements.get("onboarding-checklist-ui")||customElements.define("onboarding-checklist-ui",oh);$();Ct();var OO=new Set(["","comfortable","compact","spacious"]),yO=new Set(["2","3","4","5","6"]),uE=new Set(["","2","2:1","3:2","3:1"]),vO=["toolbar","kpis","charts","table","aside"],bd=class extends x{static get properties(){return{density:{type:String,default:"",reflect:!0},"kpi-columns":{type:String,default:"4",reflect:!0,attribute:"kpi-columns"},"chart-split":{type:String,default:"",reflect:!0,attribute:"chart-split"},loading:{type:Boolean,default:!1,reflect:!0},gap:{type:String,default:"",reflect:!0}}}static template=()=>null;#t={toolbar:!1,kpis:!1,charts:!1,table:!1,aside:!1};#e=null;#i=!1;setDensity(t){let e=OO.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return vO.includes(t)?this.querySelector(`:scope > [slot="${t}"]`):null}connected(){this.hasAttribute("role")||this.setAttribute("role","region"),F(()=>this.#s()),this.#r(),this.#n(),this.#a(),this.#e=new MutationObserver(t=>this.#o(t)),this.#e.observe(this,{childList:!0})}disconnected(){this.#e&&(this.#e.disconnect(),this.#e=null)}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!this.#i){if(t==="density"&&e!==i){if(!OO.has(i)){this.#i=!0;try{this.density=""}finally{this.#i=!1}return}this.isConnected&&this.dispatchEvent(new CustomEvent("density-change",{bubbles:!0,detail:{density:i}}));return}if(t==="kpi-columns"&&e!==i){if(i!=null&&!yO.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...yO].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!uE.has(i)){console.warn(`[dashboard-layout-ui] chart-split="${i}" not in enum \u2014 falling back to "" (single column). Use one of: "" (full), 2, 2:1, 3:2, 3:1.`),this.#i=!0;try{this["chart-split"]=""}finally{this.#i=!1}}return}if(t==="loading"&&e!==i){this.#r();return}if(t==="gap"&&e!==i){this.#n();return}}}#s(){if(!OO.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!yO.has(this["kpi-columns"])){console.warn(`[dashboard-layout-ui] kpi-columns="${this["kpi-columns"]}" out of range \u2014 clamping to "4".`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}if(!uE.has(this["chart-split"])){console.warn(`[dashboard-layout-ui] chart-split="${this["chart-split"]}" not in enum \u2014 clamping to "".`),this.#i=!0;try{this["chart-split"]=""}finally{this.#i=!1}}}#r(){this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy")}#n(){let t=(this.gap||"").trim();if(t===""){this.style.removeProperty("--dashboard-layout-gap");return}/^[1-6]$/.test(t)?this.style.setProperty("--dashboard-layout-gap",`var(--a-space-${t})`):this.style.setProperty("--dashboard-layout-gap",t)}#a(){for(let t of vO)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of vO){let i=this.#t[e],r=!!this.querySelector(`:scope > [slot="${e}"]`);i&&!r&&this.dispatchEvent(new CustomEvent("region-empty",{bubbles:!0,detail:{region:e}})),this.#t[e]=r}}};customElements.get("dashboard-layout-ui")||customElements.define("dashboard-layout-ui",bd);Ct();var Gs=new Set,dE=!1;function fE(s){return String(s).padStart(2,"0")}function Od(s){return`${s.getFullYear()}-${fE(s.getMonth()+1)}-${fE(s.getDate())}`}function pE(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}var mE={today:"Today","7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",qtd:"Quarter to date",ytd:"Year to date",custom:"Custom"},Ks=new Set(Object.keys(mE));function ah(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=Od(e),r=n=>{let o=new Date(e);return o.setDate(o.getDate()-n),Od(o)};switch(s){case"today":return{from:i,to:i};case"7d":return{from:r(6),to:i};case"30d":return{from:r(29),to:i};case"90d":return{from:r(89),to:i};case"qtd":{let n=Math.floor(e.getMonth()/3)*3;return{from:Od(new Date(e.getFullYear(),n,1)),to:i}}case"ytd":return{from:Od(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function rq(s,t){let e=pE(s),i=pE(t);if(!e||!i)return"";let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=e.getFullYear()===i.getFullYear(),o=n&&e.getMonth()===i.getMonth();return n&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate()?`${r[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`:o?`${r[e.getMonth()]} ${e.getDate()} \u2013 ${i.getDate()}, ${i.getFullYear()}`:n?`${r[e.getMonth()]} ${e.getDate()} \u2013 ${r[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`:`${r[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()} \u2013 ${r[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`}var yd=class s extends M{static labelDeprecated=!0;static get properties(){return{...M.properties,value:{type:String,default:"7d",reflect:!0},from:{type:String,default:"",reflect:!0},to:{type:String,default:"",reflect:!0},presets:{type:String,default:"today,7d,30d,90d,qtd,ytd,custom"},broadcast:{type:String,default:"document",reflect:!0},ariaLabelAttr:{type:String,default:"Time period",attribute:"aria-label",reflect:!0},pickerOpen:{type:Boolean,default:!1,attribute:"picker-open",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n={prefix:null,chips:null,picker:null,readout:null,suffix:null};#a=!1;#o=!1;static#l=new WeakSet;setRange(t,e,i){if(t==="custom"){if(!e||!i){console.warn('[date-range-selector-ui] setRange("custom", \u2026) requires from + to ISO dates.');return}let n=this.#p(e,i);this.#d("custom",n.from,n.to);return}if(!Ks.has(t)){console.warn(`[date-range-selector-ui] unknown preset "${t}" \u2014 ignored. Use one of: ${[...Ks].join(", ")}.`);return}let r=ah(t);r&&this.#d(t,r.from,r.to)}getRange(){return{value:this.value,preset:this.value,from:this.from,to:this.to}}subscribe(t){let e=this.#g();return e?(e.addEventListener("range-change",t),()=>e.removeEventListener("range-change",t)):()=>{}}connected(){super.connected(),this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.ariaLabelAttr||"Time period"),this.#t||(this.#c(),this.#u(),this.#t=!0),this.broadcast==="document"&&this.#y(),F(()=>{let t=this.#m();t&&this.#d(this.value,t.from,t.to,{initial:!0})})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0,this.#w()}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#o)){if(t==="presets"){this.#h();return}if(t==="broadcast"){e==="document"&&i!=="document"&&this.#w(),i==="document"?(this.#y(),this.#O()):i==="self"&&this.#O();return}if(t==="value"&&e!==i&&i&&Ks.has(i)){if(i!=="custom"){let r=ah(i);r&&this.#d(i,r.from,r.to)}return}}}syncValue(t){let e=this.from&&this.to?`${this.from}:${this.to}`:"";this.internals.setFormValue(e)}render(){if(this.#t){if(this.#i&&this.#i.value!==this.value&&(this.#i.value=this.value),this.#s){this.hasAttribute("min")&&this.#s.setAttribute("min",this.getAttribute("min")),this.hasAttribute("max")&&this.#s.setAttribute("max",this.getAttribute("max"));let t=this.from&&this.to?JSON.stringify({from:this.from,to:this.to}):"";this.#s.value!==t&&(this.#s.value=t)}if(this.#r){let t=rq(this.from,this.to);this.#r.textContent=t,this.#r.hidden=!t}}}#c(){let t=document.createElement("segmented-ui");t.setAttribute("data-region","chips"),t.setAttribute("role","radiogroup"),t.setAttribute("aria-label","Preset ranges"),this.appendChild(t),this.#i=t,this.#n.chips=t;let e=document.createElement("date-range-picker-ui");e.setAttribute("data-region","picker"),e.setAttribute("format","short"),e.setAttribute("placeholder","Custom range"),this.appendChild(e),this.#s=e,this.#n.picker=e;let i=document.createElement("text-ui");i.setAttribute("data-region","readout"),i.setAttribute("part","readout"),i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.hidden=!0,this.appendChild(i),this.#r=i,this.#n.readout=i,this.#h()}#h(){if(!this.#i)return;let t=(this.presets||"").split(",").map(i=>i.trim()).filter(Boolean),e=this.#i.querySelector(":scope > [data-indicator]");this.#i.replaceChildren(),e&&this.#i.appendChild(e);for(let i of t){if(!Ks.has(i)){s.#l.has(this)||(s.#l.add(this),console.warn(`[date-range-selector-ui] unknown preset key "${i}" in [presets] \u2014 ignored. Use one of: ${[...Ks].join(", ")}.`));continue}let r=document.createElement("segment-ui");r.setAttribute("value",i),r.setAttribute("text",mE[i]),this.#i.appendChild(r)}this.#i.value=this.value}#u(){let t=n=>{let o=n.detail?.value;if(!o||!Ks.has(o))return;if(n.stopPropagation(),o==="custom"){this.#v(),this.#f("custom");return}let a=ah(o);a&&this.#d(o,a.from,a.to)};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=n=>{n.stopPropagation();let a=(n.detail||{}).value||null;if(!a||!a.from||!a.to)return;let l=this.#p(a.from,a.to);this.#d("custom",l.from,l.to)};this.#s.addEventListener("change",e),this.#e.push(()=>this.#s.removeEventListener("change",e));let i=()=>{this.pickerOpen=!0},r=()=>{this.pickerOpen=!1};this.#s.addEventListener("open",i),this.#s.addEventListener("close",r),this.#e.push(()=>this.#s.removeEventListener("open",i)),this.#e.push(()=>this.#s.removeEventListener("close",r))}#d(t,e,i,r={}){if(this.from===e&&this.to===i&&this.value===t&&!r.initial)return;this.#o=!0;try{this.from=e,this.to=i,this.value=t}finally{this.#o=!1}this.syncValue(),this.#O();let o={value:t,from:e,to:i,preset:t};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,from:e,to:i}}));let a=this.#g();a&&a.dispatchEvent(new CustomEvent("range-change",{bubbles:a===this,detail:o}))}#f(t){if(this.value!==t){this.#o=!0;try{this.value=t}finally{this.#o=!1}}}#p(t,e){return t<=e?{from:t,to:e}:{from:e,to:t}}#m(){if(this.value==="custom")return this.from&&this.to?this.#p(this.from,this.to):ah("7d");let t=Ks.has(this.value)?this.value:"7d";return ah(t)}#g(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#b(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#O(){let t=this.#b();t&&(this.broadcast==="document"&&!this.#a||(this.from?t.setAttribute("data-range-from",this.from):t.removeAttribute("data-range-from"),this.to?t.setAttribute("data-range-to",this.to):t.removeAttribute("data-range-to")))}#y(){if(Gs.size>0&&!Gs.has(this)){dE||(dE=!0,console.warn('[date-range-selector-ui] multiple instances with broadcast="document" on the same page; only the first writes data-range-from / data-range-to to <html>. Use broadcast="self" for secondary instances. See SPEC-019 \xA76 nesting rules.')),this.#a=!1,Gs.add(this);return}Gs.add(this),this.#a=!0}#w(){if(Gs.has(this)&&(Gs.delete(this),this.#a)){document.documentElement.removeAttribute("data-range-from"),document.documentElement.removeAttribute("data-range-to"),this.#a=!1;let t=Gs.values().next().value;t&&(t.#a=!0,t.#O())}}#v(){this.#s&&(typeof this.#s.openPopover=="function"?this.#s.openPopover():this.#s.open=!0)}};customElements.get("date-range-selector-ui")||customElements.define("date-range-selector-ui",yd);$();var vd=class extends x{static properties={open:{type:Boolean,default:!1,reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},confirmText:{type:String,default:"Confirm",reflect:!0,attribute:"confirm-text"},cancelText:{type:String,default:"Cancel",reflect:!0,attribute:"cancel-text"},confirmVariant:{type:String,default:"primary",reflect:!0,attribute:"confirm-variant"},size:{type:String,default:"sm",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=[];#u=!1;#d="";#f="";#p=!1;connected(){this.#u||(this.#d=`${this.#O}-title`,this.#f=`${this.#O}-desc`,this.#m(),this.#g(),this.#u=!0)}disconnected(){for(let t of this.#h)try{t()}catch{}this.#h.length=0}show(){this.open=!0}hide(){this.open=!1}render(){if(!this.#u)return;this.#t&&(this.#t.setAttribute("size",this.size||"sm"),this.#t.open=!!this.open),this.#s&&(this.#s.id=this.#d,this.#s.textContent=this.title||""),this.#n&&(this.#n.id=this.#f,this.#n.textContent=this.description||"",this.#n.hidden=!this.description),this.#i&&(this.querySelector(':scope > [slot="icon"]')?this.#i.hidden=!0:this.icon?(this.#i.hidden=!1,this.#i.setAttribute("name",this.icon)):this.#i.hidden=!0);let t=this.#t?.querySelector(':scope > [slot="dialog"]');t&&(t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),this.title?t.setAttribute("aria-labelledby",this.#d):t.removeAttribute("aria-labelledby"),this.description?t.setAttribute("aria-describedby",this.#f):t.removeAttribute("aria-describedby")),this.#l&&(this.#l.setAttribute("text",this.cancelText||"Cancel"),this.loading?this.#l.setAttribute("disabled",""):this.#l.removeAttribute("disabled")),this.#c&&(this.#c.setAttribute("text",this.confirmText||"Confirm"),this.#c.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),this.loading?(this.#c.setAttribute("disabled",""),this.#c.setAttribute("icon","spinner")):(this.#c.removeAttribute("disabled"),this.#c.removeAttribute("icon"))),this.open&&this.#l&&!this.loading&&this.#b()}#m(){let t=document.createElement("modal-ui");t.setAttribute("size",this.size||"sm");let e=document.createElement("header");e.setAttribute("slot","header");let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.hidden=!0,e.appendChild(i),this.#i=i;let r=document.createElement("text-ui");r.setAttribute("slot","heading"),r.id=this.#d,this.title&&(r.textContent=this.title),e.appendChild(r),this.#s=r,this.#e=e;let n=document.createElement("section");n.setAttribute("slot","body");let o=document.createElement("text-ui");o.setAttribute("slot","description"),o.id=this.#f,this.description?o.textContent=this.description:o.hidden=!0,n.appendChild(o),this.#n=o;let a=document.createElement("div");a.setAttribute("data-extra",""),n.appendChild(a),this.#a=a,this.#r=n;let l=document.createElement("footer");l.setAttribute("slot","footer");let h=document.createElement("button-ui");h.setAttribute("slot","action"),h.setAttribute("data-confirm-action","cancel"),h.setAttribute("variant","ghost"),h.setAttribute("text",this.cancelText||"Cancel"),l.appendChild(h),this.#l=h;let c=document.createElement("button-ui");c.setAttribute("slot","action"),c.setAttribute("data-confirm-action","confirm"),c.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),c.setAttribute("text",this.confirmText||"Confirm"),l.appendChild(c),this.#c=c,this.#o=l;let u=[...this.children];for(let d of u){let f=d.getAttribute("slot");f==="icon"?e.appendChild(d):f||a.appendChild(d)}t.appendChild(e),t.appendChild(n),t.appendChild(l),this.appendChild(t),this.#t=t}#g(){let t=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("confirm",{bubbles:!0,detail:{}})))};this.#c.addEventListener("press",t),this.#h.push(()=>this.#c.removeEventListener("press",t));let e=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.open=!1)};this.#l.addEventListener("press",e),this.#h.push(()=>this.#l.removeEventListener("press",e));let i=r=>{r.stopPropagation(),this.open=!1,this.#p||this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.#p=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{}}))};this.#t.addEventListener("close",i),this.#h.push(()=>this.#t.removeEventListener("close",i))}#b(){let t=()=>{if(!(!this.open||!this.#l||this.loading))try{this.#l.focus()}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):queueMicrotask(t)}get#O(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",vd);$();Ct();var nq=new Set(["active","trialing","past_due","canceled","paused"]),oq={active:"success",trialing:"info",past_due:"danger",canceled:"muted",paused:"warning"},aq={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},lq={update:"update-card",retry:"retry"};function gE(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function hq(s,t){if(!s)return"";try{let e=s instanceof Date?s:new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"2-digit"}).format(e)}catch{return String(s)}}var ba=class extends x{static get properties(){return{account:{type:Object,default:null},variant:{type:String,default:"full",reflect:!0},currency:{type:String,default:"USD",reflect:!0},locale:{type:String,default:""},loading:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=null;#g=null;#b=null;#O=null;#y=null;#w=null;#v=null;#S=null;#x="";#k=!1;#A=0;async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#A;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#A)return;this.loading=!1;let n=r&&typeof r=="object"&&r.account?r.account:r;this.account=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{account:n}}))}catch(i){if(e!==this.#A)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#C(),this.#T(),this.#q(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),this.#t&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;let t=this.account,e=!t&&!this.getAttribute("data-stream-src");e?this.setAttribute("empty",""):this.removeAttribute("empty"),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let i=t?.status||"";if(i==="past_due"?this.setAttribute("past-due",""):this.removeAttribute("past-due"),i==="trialing"?this.setAttribute("trial",""):this.removeAttribute("trial"),i&&!nq.has(i)&&!this.#k&&(this.#k=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#Q(null),this.#D(null);return}if(!t){this.#Q(null);return}this.#Q(t),this.#P(t),this.#I(t),this.#$(t),this.#M(t),this.#L(t),this.#D(t)}#C(){let t=this.querySelector(':scope > script[type="application/json"][data-account]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.account&&typeof e.account=="object"?e.account:e;this.account=i}}catch(e){console.warn("[billing-overview-ui] failed to parse <script data-account> JSON:",e?.message)}finally{t.remove()}}#E(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#T(){this.#x=`bo-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("card-ui");t.setAttribute("data-header","");let e=document.createElement("header"),i=document.createElement("span");i.setAttribute("slot","icon");let r=document.createElement("avatar-ui");r.setAttribute("icon","credit-card"),i.appendChild(r);let n=document.createElement("span");n.setAttribute("slot","heading");let o=document.createElement("h2");o.id=this.#x,o.setAttribute("data-billing-plan-name",""),n.appendChild(o);let a=document.createElement("tag-ui");a.setAttribute("data-billing-status",""),a.setAttribute("size","md"),n.appendChild(a);let l=document.createElement("span");l.setAttribute("slot","description");let h=document.createElement("div");h.setAttribute("data-billing-plan-meta",""),l.appendChild(h);let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("div");u.setAttribute("data-header-actions",""),c.appendChild(u),e.append(i,n,l,c),t.appendChild(e),this.appendChild(t),this.#i=t,this.#s=o,this.#r=h,this.#n=a,this.#a=u,this.#E("header-actions",u);let d=document.createElement("section");d.setAttribute("data-kpis","");let f=(bt,xt,Ot)=>{let Et=document.createElement("card-ui");Et.setAttribute("data-kpi-card",bt);let Tt=document.createElement("section"),Ft=document.createElement("stat-ui");return Ft.setAttribute("data-kpi",bt),Ft.setAttribute("label",xt),Ft.setAttribute("value","\u2014"),Ft.setAttribute("icon",Ot),Tt.appendChild(Ft),Et.appendChild(Tt),[Et,Ft]},[p,m]=f("spend","Current month","credit-card"),[b,g]=f("seats","Seats","users-three"),[y,v]=f("next-invoice","Next invoice","calendar");d.append(p,b,y),this.appendChild(d),this.#o=d,this.#l=m,this.#c=g,this.#h=v;let w=document.createElement("section");w.setAttribute("data-dunning",""),w.setAttribute("hidden","");let k=document.createElement("alert-ui");k.setAttribute("pattern","dunning"),k.setAttribute("variant","danger"),w.appendChild(k),this.appendChild(w),this.#u=w,this.#d=k;let E=document.createElement("section");E.setAttribute("data-plan-picker","");let A=document.createElement("h3");A.setAttribute("data-section-heading",""),A.textContent="Plan";let C=document.createElement("plan-picker-ui");C.setAttribute("data-billing-plan-picker",""),C.setAttribute("name","billing-overview-plan"),E.append(A,C),this.appendChild(E),this.#f=E,this.#p=A,this.#m=C;let T=document.createElement("div");T.setAttribute("data-before-plan-picker",""),E.insertBefore(T,A),this.#E("before-plan-picker",T);let Q=document.createElement("section");Q.setAttribute("data-payment-methods","");let D=document.createElement("h3");D.setAttribute("data-section-heading",""),D.textContent="Payment methods";let R=document.createElement("payment-method-list-ui");R.setAttribute("data-billing-payment-methods",""),R.setAttribute("name","billing-overview-payment-method"),Q.append(D,R),this.appendChild(Q),this.#g=Q,this.#b=D,this.#O=R;let _=document.createElement("section");_.setAttribute("data-invoice-history","");let V=document.createElement("h3");V.setAttribute("data-section-heading",""),V.textContent="Invoice history";let U=document.createElement("invoice-history-ui");U.setAttribute("data-billing-invoice-history",""),_.append(V,U),this.appendChild(_),this.#y=_,this.#w=V,this.#v=U;let J=document.createElement("div");J.setAttribute("data-after-invoice-history",""),_.appendChild(J),this.#E("after-invoice-history",J);let rt=document.createElement("div");rt.setAttribute("data-empty","");let ut=document.createElement("p");ut.setAttribute("data-empty-heading",""),ut.textContent="No billing account loaded";let ot=document.createElement("p");ot.setAttribute("data-empty-description",""),ot.textContent="Pass an `account` snapshot or `data-stream-src` to render the dashboard.",rt.append(ut,ot),this.appendChild(rt),this.#S=rt,this.#E("empty",this)}#Q(t){if(!this.#s||!this.#n||!this.#r)return;let e=t?.plan||null,i=e?.name?String(e.name):"Billing overview";this.#s.textContent!==i&&(this.#s.textContent=i);let r=this.#r;if(r.replaceChildren(),e&&Number.isFinite(e.price)){let o=e.currency||this.currency||"USD",a=this.#X(),l=e.cycle==="year"?"/yr":"/mo",h=document.createElement("span");h.setAttribute("data-plan-price",""),h.textContent=`${gE(e.price,o,a)} ${l}`,r.appendChild(h)}if(t?.billingCycle&&t.billingCycle!==e?.cycle){let o=document.createElement("span");o.setAttribute("data-plan-billing-cycle",""),o.textContent=`Billed ${t.billingCycle}ly`,r.appendChild(o)}let n=t?.status||"";if(!n)this.#n.setAttribute("hidden","");else{this.#n.removeAttribute("hidden");let o=oq[n]||"default",a=aq[n]||n;this.#n.getAttribute("variant")!==o&&this.#n.setAttribute("variant",o),this.#n.getAttribute("text")!==a&&this.#n.setAttribute("text",a),this.#n.setAttribute("aria-label",`Account status: ${a}`)}}#P(t){if(!this.#l||!this.#c||!this.#h)return;let e=t?.plan?.currency||this.currency||"USD",i=this.#X();if(Number.isFinite(t?.currentSpend)?this.#l.setAttribute("value",gE(t.currentSpend,e,i)):this.#l.setAttribute("value","\u2014"),t?.seats&&Number.isFinite(t.seats.used)){let r=t.seats.used,n=Number.isFinite(t.seats.total)?t.seats.total:null;this.#c.setAttribute("value",n!=null?`${r} / ${n}`:String(r))}else this.#c.setAttribute("value","\u2014");t?.nextInvoiceDate?this.#h.setAttribute("value",hq(t.nextInvoiceDate,i)):this.#h.setAttribute("value","\u2014");for(let r of[this.#l,this.#c,this.#h])this.loading?r.setAttribute("loading",""):r.removeAttribute("loading")}#I(t){if(!this.#u||!this.#d)return;let e=t?.dunning||null;if(!(t?.status==="past_due")||!e){this.#u.setAttribute("hidden","");return}this.#u.removeAttribute("hidden");let r=Number.isFinite(e.amount)?e.amount:null,n=e.currency||t?.plan?.currency||this.currency||"USD";if(r!=null?this.#d.setAttribute("amount",String(r)):this.#d.removeAttribute("amount"),this.#d.setAttribute("currency",n),e.dueAt&&this.#d.setAttribute("due-at",String(e.dueAt)),e.cardLast4&&this.#d.setAttribute("card-last4",String(e.cardLast4)),e.reason&&this.#d.setAttribute("reason",String(e.reason)),!this.#d.querySelector(':scope > [slot="actions"]')){let o=document.createElement("button-ui");o.setAttribute("slot","actions"),o.setAttribute("data-dunning-action","update"),o.setAttribute("variant","primary"),o.setAttribute("text","Update payment method"),this.#d.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("slot","actions"),a.setAttribute("data-dunning-action","retry"),a.setAttribute("variant","outline"),a.setAttribute("text","Retry charge"),this.#d.appendChild(a)}}#$(t){if(!this.#f||!this.#m)return;let e=this.variant==="full",i=Array.isArray(t?.plans)&&t.plans.length>0;if(!(e&&i)){this.#f.setAttribute("hidden","");return}this.#f.removeAttribute("hidden"),this.#m.plans=t.plans,t?.plan?.id&&this.#m.setAttribute("current",String(t.plan.id)),this.loading?this.#m.setAttribute("loading",""):this.#m.removeAttribute("loading")}#M(t){if(!this.#O)return;let e=Array.isArray(t?.paymentMethods)?t.paymentMethods:[];this.#O.methods=e,this.loading?this.#O.setAttribute("loading",""):this.#O.removeAttribute("loading")}#L(t){if(!this.#v)return;let e=Array.isArray(t?.invoices)?t.invoices:[];this.#v.invoices=e;let i=t?.plan?.currency||this.currency||"USD";this.#v.setAttribute("currency",i),this.loading?this.#v.setAttribute("loading",""):this.#v.removeAttribute("loading")}#D(t){this.#x&&this.setAttribute("aria-labelledby",this.#x),!t&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label","No billing account loaded"):t&&this.removeAttribute("aria-label")}#X(){return this.locale?this.locale:typeof document<"u"&&document.documentElement.lang||""}#q(){let t=u=>{let d=u.target?.closest?.("[data-account-action]");if(!d||!this.contains(d))return;let f=d.getAttribute("data-account-action")||"";f&&(u.stopPropagation(),this.#R(f,"header",{target:d}))};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=u=>{let d=u.detail?.action||"",f=lq[d]||d||"dunning";this.#R(f,"alert-dunning",u.detail)};this.addEventListener("dunning-action",e),this.#e.push(()=>this.removeEventListener("dunning-action",e));let i=u=>{let d=u.detail?.value??u.detail?.plan?.id??"";this.#R("select-plan","plan-picker",{planId:d,...u.detail})};this.addEventListener("plan-change",i),this.#e.push(()=>this.removeEventListener("plan-change",i));let r=u=>{!this.#m||!this.#m.contains(u.target)&&u.target!==this.#m||this.#R("select-plan","plan-picker",u.detail)};this.addEventListener("change",r),this.#e.push(()=>this.removeEventListener("change",r));let n=()=>{this.#R("add-payment-method","payment-method-list",null)};this.addEventListener("add",n),this.#e.push(()=>this.removeEventListener("add",n));let o=u=>{this.#R("remove-payment-method","payment-method-list",u.detail)};this.addEventListener("remove",o),this.#e.push(()=>this.removeEventListener("remove",o));let a=u=>{this.#R("set-default-payment-method","payment-method-list",u.detail)};this.addEventListener("select",a),this.#e.push(()=>this.removeEventListener("select",a));let l=u=>{this.#R("view-invoice","invoice-history",u.detail)};this.addEventListener("invoice-row-click",l),this.#e.push(()=>this.removeEventListener("invoice-row-click",l));let h=u=>{this.#R("download-invoice","invoice-history",u.detail)};this.addEventListener("invoice-export",h),this.#e.push(()=>this.removeEventListener("invoice-export",h));let c=u=>{let d=u.detail?.action||"invoice";this.#R(d,"invoice-history",u.detail)};this.addEventListener("invoice-action",c),this.#e.push(()=>this.removeEventListener("invoice-action",c))}#R(t,e,i){this.dispatchEvent(new CustomEvent("account-action",{bubbles:!0,detail:{action:t,source:e,payload:i||null}}))}};customElements.get("billing-overview-ui")||customElements.define("billing-overview-ui",ba);$();Ct();var cq=new Set(["draft","open","paid","past-due","void"]),uq={paid:"success",open:"info","past-due":"danger",void:"muted",draft:"neutral"},bE={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},dq=[{value:"",label:"All"},{value:"paid",label:"Paid"},{value:"open",label:"Open"},{value:"past-due",label:"Past due"},{value:"void",label:"Void"},{value:"draft",label:"Draft"}],OE=["Number","Issued","Due","Amount","Currency","Status"];function yE(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function vE(s,t){if(!s)return"";try{let e=s instanceof Date?s:new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"2-digit"}).format(e)}catch{return String(s)}}function xE(s,t){return(s||"/invoices/{number}").replace("{number}",encodeURIComponent(t?.number??"")).replace("{id}",encodeURIComponent(t?.id??""))}function Xe(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
442
- `)?'"'+t.replace(/"/g,'""')+'"':t}var Oa=class extends x{static properties={invoices:{type:Array,default:[]},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},hrefPattern:{type:String,default:"/invoices/{number}",reflect:!0,attribute:"href-pattern"},paginate:{type:Number,default:25,reflect:!0},exportable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""},filter:{type:String,default:"",reflect:!0}};static template=()=>null;static requiredIcons=["download-simple","receipt","magnifying-glass"];#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=!1;#h=0;#u=!1;setFilter(t){let e=t||"";return e&&!cq.has(e)?!1:F(()=>{if(this.filter===e)return!0;let i=this.filter;return this.filter=e,this.dispatchEvent(new CustomEvent("invoice-filter-change",{bubbles:!0,detail:{filter:e,previous:i}})),!0})}exportCsv(){let t=this.#m(),e=[OE.join(",")];for(let r of t){let n=[Xe(r.number??""),Xe(r.issuedAt??""),Xe(r.dueAt??""),Xe(Number.isFinite(r.amount)?r.amount:""),Xe(r.currency||this.currency||"USD"),Xe(r.status??"")];e.push(n.join(","))}let i=e.join(`\r
443
- `);return new Blob([i],{type:"text/csv;charset=utf-8;"})}getSelected(){if(!this.#o)return[];let t=this.#o.selected||[],e=this.#m();return t.map(i=>e[i]).filter(Boolean)}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#h;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#h)return;this.removeAttribute("loading");let n=Array.isArray(r)?r:Array.isArray(r?.invoices)?r.invoices:[];this.invoices=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:n.length}}))}catch(i){if(e!==this.#h)return;this.removeAttribute("loading"),this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){super.connected?.(),this.setAttribute("role","region"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Invoice history"),this.#t||(this.#d(),this.#f(),this.#b(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#c)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;(Array.isArray(this.invoices)?this.invoices:[]).length===0&&!this.loading?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#p(),this.#o&&(this.#o.columns=this.#g(),this.#o.data=this.#m(),this.#o.density!==this.density&&(this.#o.density=this.density),!!this.#o.loading!=!!this.loading&&(this.#o.loading=!!this.loading),Number(this.#o.paginate||0)!==Number(this.paginate||0)&&(this.#o.paginate=Number(this.paginate||0)),!!this.#o.selectable!=!!this.selectable&&(this.#o.selectable=!!this.selectable)),this.#s&&this.#s.setAttribute("count",String(this.#m().length)),this.#n&&(this.#n.hidden=!this.exportable)}#d(){let t=this.querySelector(':scope > script[type="application/json"][data-invoices]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.invoices=e)}catch(e){console.warn("[invoice-history-ui] failed to parse <script data-invoices> JSON:",e?.message)}finally{t.remove()}}#f(){let t=document.createElement("div");t.setAttribute("data-toolbar",""),this.appendChild(t),this.#i=t;let e=this.querySelector(':scope > [slot="toolbar"]');if(e)t.appendChild(e);else{let n=document.createElement("table-toolbar-ui");n.setAttribute("data-default-toolbar",""),n.setAttribute("text","Invoices");let o=document.createElement("div");o.setAttribute("data-invoice-filter",""),o.setAttribute("role","group"),o.setAttribute("aria-label","Filter invoices by status"),o.setAttribute("slot","actions"),n.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("data-export",""),a.setAttribute("slot","actions"),a.setAttribute("variant","outline"),a.setAttribute("size","sm"),a.setAttribute("text","Export CSV"),a.setAttribute("icon","download-simple"),n.appendChild(a),t.appendChild(n),this.#s=n,this.#r=o,this.#n=a}let i=document.createElement("div");i.setAttribute("data-table-host",""),this.appendChild(i),this.#a=i;let r=document.createElement("table-ui");if(r.id=this.id?`${this.id}__table`:`invoice-history-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("data-invoice-table",""),r.setAttribute("sortable",""),i.appendChild(r),this.#o=r,this.#s&&this.#s.setAttribute("for",r.id),!this.querySelector(':scope > [slot="empty"]')){let n=document.createElement("empty-state-ui");n.setAttribute("data-empty",""),n.setAttribute("icon","receipt"),n.setAttribute("heading","No invoices yet"),n.setAttribute("description","Invoices will appear here once issued."),this.appendChild(n),this.#l=n}}#p(){if(!this.#r)return;if(this.#r.children.length===0)for(let e of dq){let i=document.createElement("button-ui");i.setAttribute("data-filter-chip",""),i.setAttribute("data-filter-value",e.value),i.setAttribute("size","sm"),i.setAttribute("text",e.label),this.#r.appendChild(i)}let t=this.filter||"";for(let e of this.#r.querySelectorAll("[data-filter-chip]"))(e.getAttribute("data-filter-value")||"")===t?(e.setAttribute("variant","primary"),e.setAttribute("aria-pressed","true")):(e.setAttribute("variant","ghost"),e.setAttribute("aria-pressed","false"))}#m(){let t=Array.isArray(this.invoices)?this.invoices:[],e=this.filter||"";return e?t.filter(i=>(i?.status||"")===e):t}#g(){let t=this.locale||typeof document<"u"&&document.documentElement?.lang||"",e=this.currency||"USD";return[{key:"number",label:"Invoice",sortable:!0,wrap:!1},{key:"issuedAt",label:"Issued",sortable:!0,format:i=>vE(i,t)},{key:"dueAt",label:"Due",sortable:!0,format:i=>vE(i,t)},{key:"amount",label:"Amount",sortable:!0,align:"end",render:(i,r,n)=>{let o=r?.currency||e,a=document.createElement("span");return a.setAttribute("data-invoice-amount",""),a.textContent=yE(i,o,t),n.dataset.align="end",a},format:(i,r)=>yE(i,r?.currency||e,t)},{key:"status",label:"Status",sortable:!0,render:i=>{let r=String(i||"").toLowerCase(),n=uq[r]||"neutral",o=bE[r]||(i?String(i):"\u2014"),a=document.createElement("badge-ui");return a.setAttribute("data-invoice-status",""),a.setAttribute("variant",n),a.setAttribute("text",o),a.setAttribute("aria-label",o),a},format:i=>bE[String(i||"").toLowerCase()]||(i?String(i):"")},{key:"actions",label:"",sortable:!1,align:"end",accessor:i=>i,render:(i,r)=>{let n=document.createElement("span");n.setAttribute("data-invoice-actions","");let o=document.createElement("button-ui");o.setAttribute("data-invoice-action","view"),o.setAttribute("data-invoice-id",String(r?.id??r?.number??"")),o.setAttribute("size","sm"),o.setAttribute("variant","ghost"),o.setAttribute("text","View"),n.appendChild(o);let a=document.createElement("button-ui");return a.setAttribute("data-invoice-action","download"),a.setAttribute("data-invoice-id",String(r?.id??r?.number??"")),a.setAttribute("size","sm"),a.setAttribute("variant","ghost"),a.setAttribute("icon","download-simple"),a.setAttribute("aria-label",`Download invoice ${r?.number??""}`),n.appendChild(a),n}}]}#b(){let t=o=>{let a=o.target?.closest?.("[data-filter-chip]");if(!a||!this.#r?.contains(a))return;o.stopPropagation();let l=a.getAttribute("data-filter-value")||"";this.setFilter(l)};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=o=>{let a=o?.detail;if(!a||a.key==="actions")return;let l=a.row;if(!l)return;let h=xE(this.hrefPattern,l),c=new CustomEvent("invoice-row-click",{bubbles:!0,cancelable:!0,detail:{invoice:l,href:h}});if(this.dispatchEvent(c)&&typeof window<"u"&&window.location?.assign)try{window.location.assign(h)}catch{}};this.addEventListener("cell-click",e),this.#e.push(()=>this.removeEventListener("cell-click",e));let i=o=>{let a=o.target?.closest?.("button-ui[data-invoice-action]");if(!a||!this.#a?.contains(a))return;o.stopPropagation();let l=a.getAttribute("data-invoice-action"),h=a.getAttribute("data-invoice-id")||"",c=(this.invoices||[]).find(u=>String(u?.id??u?.number??"")===h);if(c){if(l==="view"){let u=xE(this.hrefPattern,c),d=new CustomEvent("invoice-row-click",{bubbles:!0,cancelable:!0,detail:{invoice:c,href:u}});if(this.dispatchEvent(d)&&typeof window<"u"&&window.location?.assign)try{window.location.assign(u)}catch{}}else if(l==="download"){let u=this.#O(c);this.dispatchEvent(new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:u,rowCount:1,invoice:c}}))}}};this.addEventListener("press",i),this.addEventListener("click",i),this.#e.push(()=>this.removeEventListener("press",i)),this.#e.push(()=>this.removeEventListener("click",i));let r=o=>{let a=o.target?.closest?.("button-ui[data-export]");if(!a||!this.#i?.contains(a))return;o.stopPropagation();let l=this.exportCsv(),h=new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:l,rowCount:this.#m().length}});if(this.dispatchEvent(h)&&typeof document<"u"&&typeof URL<"u")try{let u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download="invoices.csv",document.body.appendChild(d),d.click(),d.remove(),setTimeout(()=>URL.revokeObjectURL(u),0)}catch{}};this.addEventListener("press",r),this.addEventListener("click",r),this.#e.push(()=>this.removeEventListener("press",r)),this.#e.push(()=>this.removeEventListener("click",r));let n=o=>{if(o.target!==this.#o)return;let a=this.getSelected();this.dispatchEvent(new CustomEvent("invoice-selection-change",{bubbles:!0,detail:{selected:a}}))};this.addEventListener("select",n),this.#e.push(()=>this.removeEventListener("select",n))}#O(t){let e=[OE.join(","),[Xe(t.number??""),Xe(t.issuedAt??""),Xe(t.dueAt??""),Xe(Number.isFinite(t.amount)?t.amount:""),Xe(t.currency||this.currency||"USD"),Xe(t.status??"")].join(",")];return new Blob([e.join(`\r
444
- `)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",Oa);$();Ct();var fq=new Set(["draft","open","paid","past-due","void"]),pq={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},mq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function xd(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(i)}catch{return`${t||"$"}${i.toFixed(2)}`}}function SE(s,t){if(!s)return"";try{let e=new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric"}).format(e)}catch{return String(s)}}var ya=class extends x{static get properties(){return{invoice:{type:Object,default:null},status:{type:String,default:"draft",reflect:!0},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},printable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m="";#g=!1;#b=!1;#O=0;#y="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#O;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#O)return;this.loading=!1;let n=r&&typeof r=="object"&&r.invoice?r.invoice:r;if(this.invoice=n,n?.status){this.#g=!0;try{this.status=String(n.status)}finally{this.#g=!1}}let o=n?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:o}})),this.#y=o}catch(i){if(e!==this.#O)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#w(),this.#S(),this.#T(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#g)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;let t=this.invoice,e=!t&&!this.getAttribute("data-stream-src");e?this.setAttribute("empty",""):this.removeAttribute("empty"),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let r=(this.hasAttribute("status")?this.getAttribute("status"):"")||t?.status||this.status||"draft";if(fq.has(r)||this.#b||(this.#b=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#x(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#x(null,r);return}this.#x(t,r),this.#k(t),this.#A(t),this.#C(t),this.#E(t)}#w(){let t=this.querySelector(':scope > script[type="application/json"][data-invoice]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.invoice&&typeof e.invoice=="object"?e.invoice:e;if(this.invoice=i,i?.status){this.#g=!0;try{this.status=String(i.status)}finally{this.#g=!1}}}}catch(e){console.warn("[invoice-detail-ui] failed to parse <script data-invoice> JSON:",e?.message)}finally{t.remove()}}#v(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#S(){this.#m=`inv-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("header");t.setAttribute("data-header","");let e=document.createElement("div");e.setAttribute("data-header-title","");let i=document.createElement("h2");i.id=this.#m,i.setAttribute("data-invoice-number",""),e.appendChild(i);let r=document.createElement("tag-ui");r.setAttribute("data-invoice-status",""),r.setAttribute("size","md"),e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-header-meta","");let o=document.createElement("div");o.setAttribute("data-header-actions",""),o.setAttribute("data-invoice-actions",""),t.append(e,n,o),this.appendChild(t),this.#i=t,this.#s=i,this.#r=r,this.#n=n,this.#a=o,this.#v("header-actions",o);let a=document.createElement("section");a.setAttribute("data-parties","");let l=document.createElement("div");l.setAttribute("data-customer","");let h=document.createElement("div");h.setAttribute("data-customer-default",""),l.appendChild(h),this.#l=h;let c=document.createElement("div");c.setAttribute("data-remit-to","");let u=document.createElement("div");u.setAttribute("data-remit-to-default",""),c.appendChild(u),this.#c=u,a.append(l,c),this.appendChild(a),this.#o=a,this.#v("customer-block",l),this.#v("remit-to-block",c);let d=document.createElement("section");d.setAttribute("data-lines","");let f=document.createElement("card-ui");f.setAttribute("data-lines-card",""),f.setAttribute("padding","none");let p=document.createElement("section");p.setAttribute("bleed",""),f.appendChild(p);let m=document.createElement("table-ui");m.setAttribute("data-lines-table",""),m.setAttribute("density",this.density||"standard"),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#h=d,this.#u=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#d=b;let g=document.createElement("footer");g.setAttribute("data-footer","");let y=document.createElement("div");y.setAttribute("data-footer-notes",""),g.appendChild(y),this.appendChild(g),this.#f=g,this.#v("footer",g);let v=document.createElement("empty-state-ui");v.setAttribute("data-empty",""),v.setAttribute("icon","receipt"),v.setAttribute("heading","No invoice loaded"),v.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(v),this.#p=v}#x(t,e){if(!this.#s||!this.#r||!this.#n)return;let i=t?.number?String(t.number):"";this.#s.textContent!==i&&(this.#s.textContent=i);let r=pq[e]||"default",n=mq[e]||(e?String(e):"Draft");if(this.#r.getAttribute("variant")!==r&&this.#r.setAttribute("variant",r),this.#r.getAttribute("text")!==n&&this.#r.setAttribute("text",n),this.#r.setAttribute("aria-label",`Status: ${n}`),t?this.#r.removeAttribute("hidden"):this.#r.setAttribute("hidden",""),this.#n.replaceChildren(),!t)return;let o=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(t.issuedAt){let a=document.createElement("span");a.setAttribute("data-issued",""),a.textContent=`Issued ${SE(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${SE(t.dueAt,o)}`,this.#n.appendChild(a)}}#k(t){if(!(!this.#l||!this.#c)){if(this.#l.replaceChildren(),t?.customer){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Billed to",this.#l.appendChild(e),t.customer.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.customer.name),this.#l.appendChild(i)}if(t.customer.email){let i=document.createElement("div");i.setAttribute("data-party-email",""),i.textContent=String(t.customer.email),this.#l.appendChild(i)}if(t.customer.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.customer.address),this.#l.appendChild(i)}}if(this.#c.replaceChildren(),t?.remitTo){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Remit to",this.#c.appendChild(e),t.remitTo.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.remitTo.name),this.#c.appendChild(i)}if(t.remitTo.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.remitTo.address),this.#c.appendChild(i)}}}}#A(t){if(!this.#u)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");this.#u.columns=[{key:"description",label:"Description",flex:1},{key:"qty",label:"Qty",width:80,format:n=>String(n??"")},{key:"unitAmount",label:"Unit",width:120,format:n=>xd(n,e,i)},{key:"amount",label:"Amount",width:140,format:n=>xd(n,e,i)}];let r=Array.isArray(t?.lines)?t.lines:[];this.#u.data=r.map((n,o)=>({__row:o,description:n?.description??"",qty:n?.qty??"",unitAmount:n?.unitAmount??0,amount:n?.amount??0})),this.#u.getAttribute("density")!==this.density&&this.#u.setAttribute("density",this.density||"standard")}#C(t){if(!this.#d)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(this.#d.replaceChildren(),!t)return;let r=[{key:"subtotal",label:"Subtotal",value:t.subtotal},{key:"tax",label:"Tax",value:t.tax}];Number.isFinite(t.discount)&&t.discount>0&&r.push({key:"discount",label:"Discount",value:-Math.abs(t.discount)});for(let n of r){if(!Number.isFinite(n.value))continue;let o=document.createElement("div");o.setAttribute("data-totals-row",""),o.setAttribute("data-totals-key",n.key);let a=document.createElement("span");a.setAttribute("data-totals-label",""),a.textContent=n.label;let l=document.createElement("span");l.setAttribute("data-totals-value",""),l.textContent=xd(n.value,e,i),o.append(a,l),this.#d.appendChild(o)}if(Number.isFinite(t.total)){let n=document.createElement("div");n.setAttribute("data-totals-row",""),n.setAttribute("data-totals-key","total"),n.setAttribute("data-grand-total","");let o=document.createElement("span");o.setAttribute("data-totals-label",""),o.textContent="Total";let a=document.createElement("span");a.setAttribute("data-totals-value",""),a.textContent=xd(t.total,e,i),n.append(o,a),this.#d.appendChild(n)}}#E(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#T(){let t=i=>{let r=i.target?.closest?.("[data-invoice-action]");if(!r||!this.contains(r))return;let n=r.getAttribute("data-invoice-action")||"";if(!n)return;let o=this.invoice?.number||"";i.stopPropagation(),this.dispatchEvent(new CustomEvent("invoice-action",{bubbles:!0,detail:{action:n,invoiceNumber:o}}))};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=i=>{if(!this.#h)return;let n=(i.composedPath?i.composedPath():[]).find(l=>l?.getAttribute&&l.getAttribute("data-row")!=null);if(!n||!this.#h.contains(n))return;let o=Number(n.getAttribute("data-row")),a=Array.isArray(this.invoice?.lines)?this.invoice.lines[o]:null;!Number.isFinite(o)||a==null||this.dispatchEvent(new CustomEvent("line-item-click",{bubbles:!0,detail:{index:o,lineItem:a}}))};this.addEventListener("click",e),this.#e.push(()=>this.removeEventListener("click",e))}};customElements.get("invoice-detail-ui")||customElements.define("invoice-detail-ui",ya);Ct();var gq=[{brand:"amex",re:/^3[47]/},{brand:"visa",re:/^4/},{brand:"mastercard",re:/^(5[1-5]|2[2-7])/},{brand:"discover",re:/^6(011|5)/}];function Sd(s){if(!s)return"unknown";for(let{brand:t,re:e}of gq)if(e.test(s))return t;return"unknown"}function wd(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function bG(s,t){return s?t==="amex"?s.replace(/^(\d{0,4})(\d{0,6})(\d{0,5}).*$/,(e,i,r,n)=>[i,r,n].filter(Boolean).join(" ")):s.match(/.{1,4}/g)?.join(" ")??"":""}function wE(s){if(!s||s.length<12)return!1;let t=0,e=!1;for(let i=s.length-1;i>=0;i--){let r=s.charCodeAt(i)-48;if(r<0||r>9)return!1;e&&(r*=2,r>9&&(r-=9)),t+=r,e=!e}return t%10===0}function kE(s){if(!s)return null;let t=String(s).replace(/\s+/g,"").match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(!t)return null;let e=Number(t[1]),i=Number(t[2]);return i<100&&(i+=2e3),!Number.isFinite(e)||!Number.isFinite(i)?null:{month:e,year:i}}function AE(s){let t=kE(s);if(!t)return"expiry-format";let{month:e,year:i}=t;if(e<1||e>12)return"expiry-month";let r=new Date,n=r.getFullYear(),o=r.getMonth()+1;return i<n||i===n&&e<o?"expiry-past":i>n+50?"expiry-far":null}function EE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function bq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var Oq=["US","CA","GB","DE","FR","AU"],yq={US:"United States",CA:"Canada",GB:"United Kingdom",DE:"Germany",FR:"France",AU:"Australia",JP:"Japan",ES:"Spain",IT:"Italy",NL:"Netherlands",SE:"Sweden",IE:"Ireland",SG:"Singapore",IN:"India",BR:"Brazil",MX:"Mexico"};function vq(s){return yq[s]||s}var va=class extends M{static labelDeprecated=!1;static get properties(){return{...M.properties,name:{type:String,default:"paymentMethod",reflect:!0},value:{type:String,default:"",reflect:!0},prefill:{type:String,default:"",attribute:"prefill"},countries:{type:Array,default:[]},defaultCountry:{type:String,default:"US",reflect:!0,attribute:"default-country"},requireBillingAddress:{type:Boolean,default:!1,reflect:!0,attribute:"require-billing-address"},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},autofocus:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#o={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#l="unknown";#c=!1;#h=null;#u=null;#d=!1;async tokenize(){if(this.#d)return Promise.reject(new Error("tokenize-inflight"));this.#d=!0,this.setAttribute("tokenizing","");try{let t=this.#A();if(!t.ok){let r=new Error(t.message);throw r.code=t.code,r.field=t.field,this.dispatchEvent(new CustomEvent("payment-method-error",{bubbles:!0,detail:{message:t.message,code:t.code,field:t.field}})),this.setAttribute("aria-invalid","true"),r}let e=t.detail;this.#c=!0;try{this.value=bq(e.last4)}finally{this.#c=!1}this.syncValue(),this.removeAttribute("aria-invalid");let i={token:this.value,...e};return this.dispatchEvent(new CustomEvent("submit-payment-method",{bubbles:!0,detail:i})),i}finally{this.removeAttribute("tokenizing"),this.#d=!1}}reset(){F(()=>{for(let t of Object.keys(this.#o)){let e=this.#o[t];e&&(e.value="",e.removeAttribute("error"))}this.#o.country&&(this.#o.country.value=this.defaultCountry||"US"),this.#c=!0;try{this.value="",this.error=""}finally{this.#c=!1}this.syncValue(),this.#l="unknown",this.removeAttribute("aria-invalid"),this.removeAttribute("error"),this.#x()})}syncValue(t){this.internals.setFormValue(this.value||""),this.required&&!this.value?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Payment method required.",this):this.internals.setValidity({})}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment method form"),this.#t||(this.#f(),this.#g(),this.#t=!0),F(()=>this.render()),this.autofocus&&requestAnimationFrame(()=>{this.#o.name?.focus?.()})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#c)){if(t==="prefill"&&e!==i)this.render();else if(t==="disabled"&&e!==i)this.#w();else if(t==="error"&&e!==i)this.#v();else if(t==="require-billing-address"&&e!==i)this.#y();else if(t==="default-country"&&e!==i){let r=this.#o.country;r&&!r.value&&(r.value=i||"US")}}}render(){this.#t&&(this.#O(),this.#y(),this.#w(),this.#v(),this.#S(),this.#x())}#f(){let t=document.createElement("alert-ui");t.setAttribute("data-alert",""),t.setAttribute("variant","danger"),t.setAttribute("icon","warning-circle"),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-summary",""),e.hidden=!0;let i=document.createElement("icon-ui");i.setAttribute("name","credit-card"),i.setAttribute("aria-hidden","true"),i.setAttribute("data-summary-icon",""),e.appendChild(i);let r=document.createElement("div");r.setAttribute("data-summary-text",""),e.appendChild(r);let n=document.createElement("button-ui");n.setAttribute("data-summary-edit",""),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("text","Edit card"),e.appendChild(n),this.appendChild(e),this.#s=e,this.#r=n;let o=document.createElement("div");o.setAttribute("data-grid",""),this.appendChild(o),this.#n=o,this.#a.name=this.#p("name",{label:"Name on card",required:!0,area:"name",input:{autocomplete:"cc-name",placeholder:"Pat Doe"}}),this.#o.name=this.#a.name.querySelector("input-ui"),this.#a.cardNumber=this.#p("cardNumber",{label:"Card number",required:!0,area:"card",input:{type:"text",inputmode:"numeric",autocomplete:"cc-number",placeholder:"1234 1234 1234 1234",prefix:"credit-card",maxlength:23}}),this.#o.cardNumber=this.#a.cardNumber.querySelector("input-ui");let a=document.createElement("span");a.setAttribute("slot","trailing"),a.setAttribute("data-brand-badge",""),this.#o.cardNumber.appendChild(a),this.#a.expiry=this.#p("expiry",{label:"Expiry",required:!0,area:"expiry",input:{type:"text",inputmode:"numeric",autocomplete:"cc-exp",placeholder:"MM/YY",maxlength:7}}),this.#o.expiry=this.#a.expiry.querySelector("input-ui"),this.#a.cvc=this.#p("cvc",{label:"CVC",required:!0,area:"cvc",input:{type:"text",inputmode:"numeric",autocomplete:"cc-csc",placeholder:"123",maxlength:4}}),this.#o.cvc=this.#a.cvc.querySelector("input-ui"),this.#a.country=this.#p("country",{label:"Country",required:!0,area:"country",kind:"select",input:{autocomplete:"country"},seedOptions:this.#m(),seedValue:this.defaultCountry||"US"}),this.#o.country=this.#a.country.querySelector("select-ui"),this.#a.postalCode=this.#p("postalCode",{label:"Postal code",required:!0,area:"postal",input:{type:"text",inputmode:"text",autocomplete:"postal-code",placeholder:"94105",maxlength:12}}),this.#o.postalCode=this.#a.postalCode.querySelector("input-ui"),this.#a.addressLine1=this.#p("addressLine1",{label:"Address line 1",required:!1,area:"address1",input:{type:"text",autocomplete:"address-line1",placeholder:"123 Main St",maxlength:100}}),this.#o.addressLine1=this.#a.addressLine1.querySelector("input-ui"),this.#a.addressLine1.hidden=!0,this.#a.addressLine2=this.#p("addressLine2",{label:"Address line 2 (optional)",required:!1,area:"address2",input:{type:"text",autocomplete:"address-line2",placeholder:"Apt 4B",maxlength:100}}),this.#o.addressLine2=this.#a.addressLine2.querySelector("input-ui"),this.#a.addressLine2.hidden=!0;let l=document.createElement("div");l.setAttribute("data-legal",""),this.appendChild(l),this.#h=l;for(let h of[...this.children])h!==l&&h.getAttribute&&h.getAttribute("slot")==="legal"&&l.appendChild(h)}#p(t,e){let i=document.createElement("field-ui");i.setAttribute("label",e.label),e.required&&i.setAttribute("required",""),i.setAttribute("data-field",t),i.style.gridArea=e.area;let r;if(e.kind==="select"){if(r=document.createElement("select-ui"),Array.isArray(e.seedOptions))for(let n of e.seedOptions){let o=document.createElement("option");o.value=n.value,o.textContent=n.label,e.seedValue&&n.value===e.seedValue&&o.setAttribute("selected",""),r.appendChild(o)}}else r=document.createElement("input-ui");r.setAttribute("name",t),r.setAttribute("data-control",t),e.required&&r.setAttribute("required","");for(let[n,o]of Object.entries(e.input||{}))o==null||o===""||r.setAttribute(n,String(o));return i.appendChild(r),this.#n.appendChild(i),i}#m(){return(Array.isArray(this.countries)&&this.countries.length>0?this.countries:Oq).map(e=>({value:e,label:vq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=wd(n),a=Sd(o);a!==this.#l&&(this.#l=a,this.#x()),this.#b()};this.addEventListener("input",t),this.#e.push(()=>this.removeEventListener("input",t));let e=r=>{r.target!==this&&this.#b()};this.addEventListener("change",e),this.#e.push(()=>this.removeEventListener("change",e));let i=()=>{this.disabled||(this.removeAttribute("prefilled"),this.#s&&(this.#s.hidden=!0),this.#n&&(this.#n.hidden=!1))};this.#r.addEventListener("click",i),this.#r.addEventListener("press",i),this.#e.push(()=>{this.#r.removeEventListener("click",i),this.#r.removeEventListener("press",i)})}#b(){let t=wd(this.#o.cardNumber?.value),e=Sd(t),i=this.#k();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#O(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((r,n)=>r?.value===e[n].value&&r?.label===e[n].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#y(){let t=!!this.requireBillingAddress;this.#a.addressLine1&&(this.#a.addressLine1.hidden=!t),this.#a.addressLine2&&(this.#a.addressLine2.hidden=!t)}#w(){let t=!!this.disabled;for(let e of Object.values(this.#o))e&&(t?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}#v(){if(!this.#i)return;let t=this.error||"";t?(this.#i.setAttribute("text",t),this.#i.hidden=!1,this.setAttribute("aria-invalid","true")):(this.#i.removeAttribute("text"),this.#i.hidden=!0,this.removeAttribute("aria-invalid"))}#S(){if(!this.#s)return;let t=this.#C();if(!t||this.hasAttribute("prefilled-dismissed")){this.#s.hidden=!0,this.#n&&(this.#n.hidden=!1),this.removeAttribute("prefilled");return}let e=this.#s.querySelector(":scope > [data-summary-text]");if(e){let i=(t.brand||"Card").toUpperCase(),r=t.last4||"\u2022\u2022\u2022\u2022",n=t.expMonth&&t.expYear?` \xB7 expires ${String(t.expMonth).padStart(2,"0")}/${String(t.expYear).slice(-2)}`:"";e.textContent=`${i} ending in ${r}${n}`}this.#s.hidden=!1,this.#n&&(this.#n.hidden=!0),this.setAttribute("prefilled","")}#x(){let t=this.#o.cardNumber;if(!t)return;let e=t.querySelector(":scope > [data-brand-badge]");if(!e)return;if(this.#l==="unknown"||!this.#l){e.replaceChildren();return}let i=e.querySelector(":scope > [data-brand]");if(i&&i.getAttribute("data-brand")===this.#l)return;e.replaceChildren();let r=document.createElement("span");r.setAttribute("data-brand",this.#l),r.textContent=this.#l.toUpperCase(),e.appendChild(r)}#k(){let t=wd(this.#o.cardNumber?.value);return t?wE(t)?AE(this.#o.expiry?.value)?{ok:!1}:EE(this.#o.cvc?.value,Sd(t))?{ok:!1}:(this.#o.name?.value||"").trim()?(this.#o.postalCode?.value||"").trim()?{ok:!0}:{ok:!1}:{ok:!1}:{ok:!1}:{ok:!1}}#A(){for(let d of Object.values(this.#o))d?.removeAttribute?.("error");let t=String(this.#o.name?.value||"").trim();if(!t)return this.#o.name?.setAttribute("error","Name on card is required."),{ok:!1,message:"Name on card is required.",code:"validation-failed",field:"name"};let e=this.#o.cardNumber?.value||"",i=wd(e);if(!i)return this.#o.cardNumber?.setAttribute("error","Card number is required."),{ok:!1,message:"Card number is required.",code:"validation-failed",field:"cardNumber"};if(!wE(i))return this.#o.cardNumber?.setAttribute("error","Card number is invalid."),{ok:!1,message:"Card number is invalid.",code:"card-invalid",field:"cardNumber"};let r=AE(this.#o.expiry?.value||"");if(r){let d=r==="expiry-past"?"Card has expired.":r==="expiry-month"?"Expiry month must be 01-12.":r==="expiry-far"?"Expiry year is too far in the future.":"Expiry must be MM/YY.";return this.#o.expiry?.setAttribute("error",d),{ok:!1,message:d,code:r==="expiry-past"?"expired":"validation-failed",field:"expiry"}}let n=Sd(i);if(EE(this.#o.cvc?.value||"",n)){let f=`CVC must be ${n==="amex"?4:3} digits.`;return this.#o.cvc?.setAttribute("error",f),{ok:!1,message:f,code:"cvc-invalid",field:"cvc"}}let a=String(this.#o.country?.value||this.defaultCountry||"US");if(!String(this.#o.postalCode?.value||"").trim())return this.#o.postalCode?.setAttribute("error","Postal code is required."),{ok:!1,message:"Postal code is required.",code:"validation-failed",field:"postalCode"};if(this.requireBillingAddress&&!String(this.#o.addressLine1?.value||"").trim())return this.#o.addressLine1?.setAttribute("error","Address is required."),{ok:!1,message:"Address is required.",code:"validation-failed",field:"addressLine1"};let h=kE(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:n,expMonth:h.month,expYear:h.year,name:t,country:a}}}#C(){let t=this.prefill||this.getAttribute("prefill")||"";if(!t)return null;try{let e=JSON.parse(t);return!e||typeof e!="object"?null:e}catch{return null}}};customElements.get("payment-method-form-ui")||customElements.define("payment-method-form-ui",va);Ct();var xq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),CE=new Set(["card","bank","wallet"]),$E={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},Sq={card:"credit-card",bank:"bank",wallet:"credit-card"},PE={visa:"Visa",mastercard:"Mastercard",amex:"American Express",discover:"Discover",jcb:"JCB",unionpay:"UnionPay",diners:"Diners Club",paypal:"PayPal","apple-pay":"Apple Pay","google-pay":"Google Pay",ach:"Bank account",sepa:"SEPA"};function QE(s){let t=(s?.brand||"").toLowerCase();if($E[t])return $E[t];let e=(s?.type||"card").toLowerCase();return Sq[e]||"credit-card"}function TE(s){let t=(s?.brand||"").toLowerCase();if(PE[t])return PE[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function xO(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=TE(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function SO(s){let t=(s?.expiry||"").trim();if(!t)return"";let e="",i="",r=t.match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(r)e=r[1].padStart(2,"0"),i=r[2].length===4?r[2].slice(-2):r[2];else{let n=t.match(/^(\d{4})-(\d{2})-\d{2}$/);n&&(i=n[1].slice(-2),e=n[2])}return!e||!i?"":`Expires ${e}/${i}`}var xa=class extends M{static get properties(){return{...M.properties,methods:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},"add-label":{type:String,default:"Add payment method",attribute:"add-label"},"add-icon":{type:String,default:"plus",attribute:"add-icon"},"no-add":{type:Boolean,default:!1,reflect:!0,attribute:"no-add"},"no-remove":{type:Boolean,default:!1,reflect:!0,attribute:"no-remove"},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=new Map;#o=!1;setDefault(t){return t?F(()=>{let e=(this.methods||[]).find(r=>r.id===t);if(!e)return!1;if(this.value===t)return!0;let i=this.value||"";this.#o=!0;try{this.value=t}finally{this.#o=!1}return this.syncValue(),this.#m(t,i,e),!0}):!1}remove(t){return t?F(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(r=>r.id===t);if(i<0)return!1;if(e.splice(i,1),this.methods=e,this.value===t){let r=e[0]?.id||"";this.#o=!0;try{this.value=r}finally{this.#o=!1}this.syncValue()}return!0}):!1}add(t){!t||!t.id||F(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(r=>r.id===t.id);if(i>=0?e[i]=t:e.push(t),this.methods=e,t.default){let r=this.value||"";this.#o=!0;try{this.value=t.id}finally{this.#o=!1}this.syncValue(),r!==t.id&&this.#m(t.id,r,t)}})}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment methods"),this.#t||(this.#c(),this.#h(),this.#p(),this.#t=!0),F(()=>this.render())}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.methods)?this.methods:[],e=this.#l(t);if(e&&this.value!==e){this.#o=!0;try{this.value=e}finally{this.#o=!1}this.syncValue()}if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#r&&(this.#r.hidden=!!this["no-add"]),this.#n){this.#n.setAttribute("text",this["add-label"]||"Add payment method");let i=this["add-icon"]||"plus";i?this.#n.setAttribute("icon",i):this.#n.removeAttribute("icon"),this.disabled?this.#n.setAttribute("disabled",""):this.#n.removeAttribute("disabled")}this.#u(t)}#l(t){if(!t.length)return"";if(this.value&&t.some(i=>i.id===this.value))return this.value;let e=t.find(i=>i.default);return e?e.id:t[0].id||""}#c(){let t=this.querySelector(':scope > script[type="application/json"][data-methods]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.methods=e)}catch(e){console.warn("[payment-method-list-ui] failed to parse <script data-methods> JSON:",e?.message)}finally{t.remove()}}#h(){let t=document.createElement("div");if(t.setAttribute("data-rows",""),t.setAttribute("role","presentation"),this.appendChild(t),this.#i=t,!this.querySelector(':scope > [slot="empty"]')){let i=document.createElement("empty-state-ui");i.setAttribute("data-empty",""),i.setAttribute("icon","credit-card"),i.setAttribute("heading","No payment methods"),i.setAttribute("description","Add a method to get started."),this.appendChild(i),this.#s=i}let e=document.createElement("div");if(e.setAttribute("data-add",""),this.appendChild(e),this.#r=e,!this.querySelector(':scope > [slot="add"]')){let i=document.createElement("button-ui");i.setAttribute("data-add-cta",""),i.setAttribute("variant","outline"),i.setAttribute("icon",this["add-icon"]||"plus"),i.setAttribute("text",this["add-label"]||"Add payment method"),e.appendChild(i),this.#n=i}}#u(t){if(!this.#i)return;let e=new Map;for(let i of t){if(!i?.id)continue;let r=this.#a.get(i.id);r||(r=this.#d(i),this.#i.appendChild(r)),this.#f(r,i),e.set(i.id,r)}for(let[i,r]of this.#a)if(!e.has(i))try{r.remove()}catch{}for(let i of t){let r=e.get(i.id);r&&this.#i.appendChild(r)}this.#a=e}#d(t){let e=document.createElement("card-ui");e.setAttribute("data-row",""),e.setAttribute("role","radio"),e.setAttribute("tabindex","0");let i=document.createElement("header"),r=document.createElement("span");r.setAttribute("slot","icon");let n=document.createElement("icon-ui");n.setAttribute("aria-hidden","true"),r.appendChild(n);let o=document.createElement("span");o.setAttribute("slot","heading");let a=document.createElement("span");a.setAttribute("data-primary","");let l=document.createElement("tag-ui");l.setAttribute("data-default-tag",""),l.setAttribute("text","Default"),l.setAttribute("variant","success"),l.setAttribute("size","sm"),l.setAttribute("hidden",""),o.appendChild(a),o.appendChild(l);let h=document.createElement("p");h.setAttribute("slot","description"),h.setAttribute("data-secondary","");let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("button-ui");u.setAttribute("data-action","set-default"),u.setAttribute("variant","ghost"),u.setAttribute("size","sm"),u.setAttribute("text","Set default");let d=document.createElement("button-ui");d.setAttribute("data-action","edit"),d.setAttribute("variant","ghost"),d.setAttribute("size","sm"),d.setAttribute("icon","pencil"),d.setAttribute("aria-label","Edit payment method");let f=document.createElement("button-ui");return f.setAttribute("data-action","remove"),f.setAttribute("variant","ghost"),f.setAttribute("size","sm"),f.setAttribute("icon","trash"),f.setAttribute("aria-label","Remove payment method"),c.appendChild(u),c.appendChild(d),c.appendChild(f),i.appendChild(r),i.appendChild(o),i.appendChild(h),i.appendChild(c),e.appendChild(i),e}#f(t,e){t.setAttribute("data-id",e.id);let i=(e?.brand||"").toLowerCase();i?t.setAttribute("data-brand-key",i):t.removeAttribute("data-brand-key");let r=(e?.type||"card").toLowerCase();CE.has(r)&&t.setAttribute("data-type",r);let n=e.id===this.value;n?(t.setAttribute("data-default",""),t.setAttribute("aria-checked","true"),t.setAttribute("tabindex","0")):(t.removeAttribute("data-default"),t.setAttribute("aria-checked","false"),t.setAttribute("tabindex","-1")),this.disabled?t.setAttribute("aria-disabled","true"):t.removeAttribute("aria-disabled");let o=t.querySelector(':scope > header > [slot="icon"] > icon-ui');if(o){let m=QE(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=xO(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=SO(e);l.textContent=m,m?l.removeAttribute("hidden"):l.setAttribute("hidden","")}let h=t.querySelector(':scope > header > [slot="heading"] > [data-default-tag]');h&&(n?h.removeAttribute("hidden"):h.setAttribute("hidden",""));let c=SO(e),u=[xO(e)];c&&u.push(c),n&&u.push("default"),t.setAttribute("aria-label",u.join(", "));let d=t.querySelector(':scope > header > [slot="action"] > [data-action="set-default"]');d&&(n?d.setAttribute("hidden",""):d.removeAttribute("hidden"),this.disabled?d.setAttribute("disabled",""):d.removeAttribute("disabled"));let f=t.querySelector(':scope > header > [slot="action"] > [data-action="edit"]');f&&(this.disabled?f.setAttribute("disabled",""):f.removeAttribute("disabled"));let p=t.querySelector(':scope > header > [slot="action"] > [data-action="remove"]');p&&(this["no-remove"]?p.setAttribute("hidden",""):p.removeAttribute("hidden"),this.disabled?p.setAttribute("disabled",""):p.removeAttribute("disabled"))}#p(){let t=r=>{let n=r.target?.closest?.("button-ui[data-action]");if(n&&this.#i.contains(n)){let a=n.closest("[data-row]");if(!a)return;let l=a.getAttribute("data-id")||"";if(!l)return;if(this.disabled||n.hasAttribute("disabled")){r.stopPropagation();return}let h=(this.methods||[]).find(u=>u.id===l);if(!h)return;let c=n.getAttribute("data-action");r.stopPropagation(),c==="set-default"?this.setDefault(l):c==="remove"?this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{id:l,method:h}})):c==="edit"&&this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{id:l,method:h}}));return}let o=r.target?.closest?.("button-ui[data-add-cta]");if(o&&this.#r?.contains(o)){if(this.disabled||o.hasAttribute("disabled")){r.stopPropagation();return}r.stopPropagation(),this.dispatchEvent(new CustomEvent("add",{bubbles:!0,detail:{}}))}};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=r=>{if(r.target?.closest?.("button-ui[data-action]")||r.target?.closest?.("button-ui[data-add-cta]"))return;let n=r.target?.closest?.("[data-row]");if(!n||!this.#i.contains(n))return;let o=n.getAttribute("data-id")||"";o&&(this.disabled||this.setDefault(o))};this.#i.addEventListener("click",e),this.#e.push(()=>this.#i.removeEventListener("click",e));let i=r=>{let o=document.activeElement?.closest?.("[data-row]");if(!o||!this.#i.contains(o))return;let a=Array.from(this.#i.querySelectorAll(":scope > [data-row]")),l=a.indexOf(o);if(!(l<0)){if(r.key==="ArrowDown"||r.key==="ArrowRight")r.preventDefault(),a[(l+1)%a.length]?.focus?.();else if(r.key==="ArrowUp"||r.key==="ArrowLeft")r.preventDefault(),a[(l-1+a.length)%a.length]?.focus?.();else if(r.key==="Home")r.preventDefault(),a[0]?.focus?.();else if(r.key==="End")r.preventDefault(),a[a.length-1]?.focus?.();else if(r.key===" "||r.key==="Enter"){r.preventDefault();let h=o.getAttribute("data-id")||"";h&&!this.disabled&&this.setDefault(h)}}};this.#i.addEventListener("keydown",i),this.#e.push(()=>this.#i.removeEventListener("keydown",i))}#m(t,e,i){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,method:i}}))}};customElements.get("payment-method-list-ui")||customElements.define("payment-method-list-ui",xa);Ct();var kd=new Set(["monthly","annual"]),wq={monthly:"Monthly",annual:"Annual"},kq={monthly:"/month",annual:"/year"};function Aq(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function Eq(s,t,e){if(s.cta)return s.cta;if(!e)return`Choose ${s.name||""}`.trim();if(s.id===e)return"Manage";let i=t.find(r=>r.id===e);if(i&&Number.isFinite(i.rank)&&Number.isFinite(s.rank)){if(s.rank>i.rank)return"Upgrade";if(s.rank<i.rank)return"Downgrade"}return`Switch to ${s.name||""}`.trim()}var Sa=class extends M{static labelDeprecated=!0;static get properties(){return{...M.properties,plans:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},current:{type:String,default:"",reflect:!0},cycle:{type:String,default:"monthly",reflect:!0},cycleToggle:{type:Boolean,default:!1,reflect:!0,attribute:"cycle-toggle"},currency:{type:String,default:"USD"},locale:{type:String,default:""},layout:{type:String,default:"grid",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=new Map;#l=!1;#c=!1;#h=!1;#u=0;setValue(t){return t?F(()=>{let e=(this.plans||[]).find(r=>r.id===t);if(!e)return!1;if(e.disabled)return this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}})),!1;if(this.value===t)return!0;let i=this.value||"";return this.value=t,this.syncValue(),this.#y(t,i),!0}):!1}setCycle(t){return kd.has(t)?F(()=>{if(this.cycle===t)return!0;let e=this.cycle;return this.cycle=t,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:t,previous:e}})),!0}):!1}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#u;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#u)return;this.removeAttribute("loading");let n=Array.isArray(r)?r:Array.isArray(r?.plans)?r.plans:[];this.plans=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:n.length}}))}catch(i){if(e!==this.#u)return;this.removeAttribute("loading"),this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Choose a plan"),this.#t||(this.#d(),this.#f(),this.#O(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#l)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.plans)?this.plans:[];if(!kd.has(this.cycle)){this.#c||(this.#c=!0,console.warn(`[plan-picker-ui] unknown cycle "${this.cycle}" \u2014 coercing to "monthly".`)),this.#l=!0;try{this.cycle="monthly"}finally{this.#l=!1}}let e=t.filter(r=>r.recommended);e.length>1&&!this.#h&&(this.#h=!0,console.warn(`[plan-picker-ui] ${e.length} plans carry recommended:true \u2014 using the first ("${e[0].id}"); ignoring the rest.`));let i=e[0]?.id||"";if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#i){let r=this.cycleToggle&&t.length>0;this.#i.hidden=!r,r&&this.#p()}this.#m(t,i)}#d(){let t=this.querySelector(':scope > script[type="application/json"][data-plans]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.plans=e)}catch(e){console.warn("[plan-picker-ui] failed to parse <script data-plans> JSON:",e?.message)}finally{t.remove()}}#f(){let t=document.createElement("div");t.setAttribute("data-toggle",""),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-plans",""),e.setAttribute("role","presentation"),this.appendChild(e),this.#r=e;let i=document.createElement("div");if(i.setAttribute("data-skeleton",""),i.hidden=!0,this.appendChild(i),this.#n=i,!this.querySelector(':scope > [slot="empty"]')){let r=document.createElement("empty-state-ui");r.setAttribute("data-empty",""),r.setAttribute("icon","package"),r.setAttribute("heading","No plans available"),r.setAttribute("description","Plans will appear here once configured."),this.appendChild(r),this.#a=r}}#p(){if(!this.#i)return;let t=this.#s;if(!t){t=document.createElement("segmented-ui"),t.setAttribute("aria-label","Billing cycle"),this.#i.appendChild(t),this.#s=t;for(let e of["monthly","annual"]){let i=document.createElement("segment-ui");i.setAttribute("value",e),i.setAttribute("text",wq[e]),t.appendChild(i)}}t.value!==this.cycle&&(t.value=this.cycle)}#m(t,e){if(!this.#r)return;let i=new Map;for(let r of t){if(!r?.id)continue;let n=this.#o.get(r.id);n||(n=document.createElement("option-card-ui"),n.setAttribute("layout","tile"),this.#r.appendChild(n)),this.#g(n,r,e),i.set(r.id,n)}for(let[r,n]of this.#o)if(!i.has(r))try{n.remove()}catch{}for(let r of t){let n=i.get(r.id);n&&this.#r.appendChild(n)}this.#o=i}#g(t,e,i){t.setAttribute("name",`${this.name||"plan"}__${this.id||"pp"}`),t.setAttribute("value",e.id),t.setAttribute("heading",e.name||""),t.setAttribute("description",e.tagline||""),e.icon?t.setAttribute("icon",e.icon):t.removeAttribute("icon");let r=!!(this.current&&e.id===this.current),n=e.id===i;r?t.setAttribute("data-current",""):t.removeAttribute("data-current"),n?t.setAttribute("data-recommended",""):t.removeAttribute("data-recommended"),e.disabled||this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.value&&this.value===e.id||!this.value&&r?t.setAttribute("checked",""):t.removeAttribute("checked");let a=t.querySelector(":scope > [data-plan-body]");a||(a=document.createElement("div"),a.setAttribute("data-plan-body",""),t.appendChild(a)),this.#b(a,e);let l=t.querySelector(":scope > [data-plan-tags]");if(l||(l=document.createElement("div"),l.setAttribute("data-plan-tags",""),l.setAttribute("slot","heading-suffix"),t.appendChild(l)),l.replaceChildren(),r){let h=document.createElement("tag-ui");h.setAttribute("text","Current plan"),h.setAttribute("variant","muted"),l.appendChild(h)}else if(n){let h=document.createElement("tag-ui");h.setAttribute("text","Recommended"),h.setAttribute("variant","accent"),l.appendChild(h)}}#b(t,e){t.replaceChildren();let i=document.createElement("div");i.setAttribute("data-price-row","");let r=kd.has(this.cycle)?this.cycle:"monthly",n=e.prices||{},o=n[r]||n.monthly||null;if(o){let l=document.createElement("span");l.setAttribute("data-price","");let h=o.currency||this.currency||"USD";l.textContent=Aq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:kq[r];c.textContent=u,i.appendChild(c)}else{let l=document.createElement("span");l.setAttribute("data-price",""),l.textContent="Contact sales",i.appendChild(l)}if(t.appendChild(i),o?.note){let l=document.createElement("span");l.setAttribute("data-price-note",""),l.textContent=o.note,t.appendChild(l)}if(Array.isArray(e.features)&&e.features.length){let l=document.createElement("ul");l.setAttribute("data-features","");for(let h of e.features){let c=document.createElement("li"),u=document.createElement("icon-ui");u.setAttribute("name","check"),u.setAttribute("aria-hidden","true"),c.appendChild(u);let d=document.createElement("span");d.textContent=String(h),c.appendChild(d),l.appendChild(c)}t.appendChild(l)}if(!!!(this.current&&e.id===this.current)||e.cta){let l=document.createElement("button-ui");l.setAttribute("data-cta",""),l.setAttribute("variant",e.recommended?"primary":"outline"),l.setAttribute("text",Eq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#O(){let t=r=>{let n=r?.detail?.value;if(!kd.has(n)||this.cycle===n)return;r.stopPropagation();let o=this.cycle;this.cycle=n,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:n,previous:o}}))};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=r=>{let n=r.target?.closest?.("option-card-ui");if(!n||!this.#r.contains(n))return;let o=n.getAttribute("value")||"";if(!o)return;let a=(this.plans||[]).find(h=>h.id===o);if(!a)return;if(a.disabled||this.disabled){n.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}}));return}r.stopPropagation();let l=this.value||"";if(l!==o){this.#l=!0;try{this.value=o}finally{this.#l=!1}this.syncValue(),this.#y(o,l)}};this.#r.addEventListener("change",e),this.#e.push(()=>this.#r.removeEventListener("change",e));let i=r=>{let n=r.target?.closest?.("button-ui[data-cta]");if(!n||!this.#r.contains(n))return;let o=n.closest("option-card-ui");if(!o)return;let a=o.getAttribute("value")||"";if(!a)return;let l=(this.plans||[]).find(c=>c.id===a);if(!l||l.disabled||this.disabled)return;r.stopPropagation();let h=this.value||"";if(h!==a){this.#l=!0;try{this.value=a}finally{this.#l=!1}this.syncValue(),this.#y(a,h)}this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:a,cycle:this.cycle}}))};this.#r.addEventListener("press",i),this.#r.addEventListener("click",i),this.#e.push(()=>this.#r.removeEventListener("press",i)),this.#e.push(()=>this.#r.removeEventListener("click",i))}#y(t,e){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,cycle:this.cycle}}))}};customElements.get("plan-picker-ui")||customElements.define("plan-picker-ui",Sa);$();var Cq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),$q=6,lh=class extends x{static properties={integrations:{type:Array,default:[]},loading:{type:Boolean,default:!1,reflect:!0},"search-placeholder":{type:String,default:"Search integrations",reflect:!0},"group-by":{type:String,default:"category",reflect:!0},"status-filter":{type:String,default:"all",reflect:!0}};static template=t=>t._renderTemplate();#t="";#e=`intpage-h-${Math.random().toString(36).slice(2,8)}`;#i=null;attributeChangedCallback(t,e,i){if(t==="integrations"){if(i==null)this.integrations=[];else try{let r=JSON.parse(i);this.integrations=Array.isArray(r)?r:[]}catch{this.integrations=[]}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#e),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Integrations"),this.hasAttribute("integrations")&&!Array.isArray(this.integrations))try{this.integrations=JSON.parse(this.getAttribute("integrations"))}catch{this.integrations=[]}this.addEventListener("input",this.#u),this.addEventListener("change",this.#d)}disconnected(){this.removeEventListener("input",this.#u),this.removeEventListener("change",this.#d),this.#i&&(clearTimeout(this.#i),this.#i=null)}render(){this.#h(),this.querySelector('segmented-ui[data-part="filter"]')?.render?.()}_renderTemplate(){let t=this["search-placeholder"]||"Search integrations",e=this["status-filter"]||"all",i=!!this.loading,r=this.#l();return it`
441
+ `}#o(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-check]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"";if(!r)return;let n=this.#d(r),o=!!i.checked;n!==o&&this.#u(r,o,{emit:o})}#l(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-action]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"",n=i.getAttribute("data-href")||"";r&&this.dispatchEvent(new CustomEvent("onboarding-step-action",{bubbles:!0,detail:{id:r,href:n}}))}#c(t){t?.stopPropagation?.();let e=!this.collapsed;this.collapsed=e,e&&this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:"collapsed"}}))}#h(t){if(!t)return!1;let e=t.id;return e!=null&&Object.prototype.hasOwnProperty.call(this.value||{},e)?!!this.value[e]:!!t.done}#d(t){let i=(Array.isArray(this.items)?this.items:[]).find(r=>r&&String(r.id)===String(t));return this.#h(i)}#u(t,e,{emit:i=!0}={}){let r={...this.value||{},[t]:!!e};this.value=r,this.#v(),i&&e&&this.dispatchEvent(new CustomEvent("onboarding-step-complete",{bubbles:!0,detail:{id:t,value:r}}))}#f(){let t=Array.isArray(this.items)?this.items:[],e=t.length,i=0;for(let n of t)this.#h(n)&&i++;let r=e===0?0:Math.round(i/e*100);return{done:i,total:e,percent:r}}#p(){let{done:t,total:e}=this.#f();return e>0&&t===e}#m(){this.#p()?this.setAttribute("data-complete",""):this.removeAttribute("data-complete")}#g(){let t=this.#p();t&&!this.#s?(this.#s=!0,this.dispatchEvent(new CustomEvent("onboarding-complete",{bubbles:!0,detail:{value:this.value}})),this["dismiss-on-complete"]&&this.#b("complete")):t||(this.#s=!1)}#b(t="user"){this.setAttribute("hidden",""),this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:t}}))}#y(){}#O(){if(this.#i||this.storage==="none"||!this["storage-key"]||typeof window>"u")return null;try{return this.storage==="session"?window.sessionStorage:window.localStorage}catch{return null}}#S(){let t=this.#O();if(!t)return null;try{let e=t.getItem(this["storage-key"]);if(!e)return null;let i=JSON.parse(e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}#v(){let t=this.#O();if(t)try{t.setItem(this["storage-key"],JSON.stringify(this.value||{}))}catch{}}complete(t){if(t==null)return;let e=String(t);this.#d(e)||this.#u(e,!0,{emit:!0})}reset(t){if(t==null){this.value={};let i=this.#O();try{i?.removeItem(this["storage-key"])}catch{}this.#s=!1,this.removeAttribute("hidden");return}let e=String(t);Object.prototype.hasOwnProperty.call(this.value||{},e)&&this.#u(e,!1,{emit:!1})}progress(){return this.#f()}};customElements.get("onboarding-checklist-ui")||customElements.define("onboarding-checklist-ui",oh);$();Ct();var OO=new Set(["","comfortable","compact","spacious"]),yO=new Set(["2","3","4","5","6"]),uE=new Set(["","2","2:1","3:2","3:1"]),vO=["toolbar","kpis","charts","table","aside"],bd=class extends x{static get properties(){return{density:{type:String,default:"",reflect:!0},"kpi-columns":{type:String,default:"4",reflect:!0,attribute:"kpi-columns"},"chart-split":{type:String,default:"",reflect:!0,attribute:"chart-split"},loading:{type:Boolean,default:!1,reflect:!0},gap:{type:String,default:"",reflect:!0}}}static template=()=>null;#t={toolbar:!1,kpis:!1,charts:!1,table:!1,aside:!1};#e=null;#i=!1;setDensity(t){let e=OO.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return vO.includes(t)?this.querySelector(`:scope > [slot="${t}"]`):null}connected(){this.hasAttribute("role")||this.setAttribute("role","region"),F(()=>this.#s()),this.#r(),this.#n(),this.#a(),this.#e=new MutationObserver(t=>this.#o(t)),this.#e.observe(this,{childList:!0})}disconnected(){this.#e&&(this.#e.disconnect(),this.#e=null)}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!this.#i){if(t==="density"&&e!==i){if(!OO.has(i)){this.#i=!0;try{this.density=""}finally{this.#i=!1}return}this.isConnected&&this.dispatchEvent(new CustomEvent("density-change",{bubbles:!0,detail:{density:i}}));return}if(t==="kpi-columns"&&e!==i){if(i!=null&&!yO.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...yO].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!uE.has(i)){console.warn(`[dashboard-layout-ui] chart-split="${i}" not in enum \u2014 falling back to "" (single column). Use one of: "" (full), 2, 2:1, 3:2, 3:1.`),this.#i=!0;try{this["chart-split"]=""}finally{this.#i=!1}}return}if(t==="loading"&&e!==i){this.#r();return}if(t==="gap"&&e!==i){this.#n();return}}}#s(){if(!OO.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!yO.has(this["kpi-columns"])){console.warn(`[dashboard-layout-ui] kpi-columns="${this["kpi-columns"]}" out of range \u2014 clamping to "4".`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}if(!uE.has(this["chart-split"])){console.warn(`[dashboard-layout-ui] chart-split="${this["chart-split"]}" not in enum \u2014 clamping to "".`),this.#i=!0;try{this["chart-split"]=""}finally{this.#i=!1}}}#r(){this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy")}#n(){let t=(this.gap||"").trim();if(t===""){this.style.removeProperty("--dashboard-layout-gap");return}/^[1-6]$/.test(t)?this.style.setProperty("--dashboard-layout-gap",`var(--a-space-${t})`):this.style.setProperty("--dashboard-layout-gap",t)}#a(){for(let t of vO)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of vO){let i=this.#t[e],r=!!this.querySelector(`:scope > [slot="${e}"]`);i&&!r&&this.dispatchEvent(new CustomEvent("region-empty",{bubbles:!0,detail:{region:e}})),this.#t[e]=r}}};customElements.get("dashboard-layout-ui")||customElements.define("dashboard-layout-ui",bd);Ct();var Gs=new Set,dE=!1;function fE(s){return String(s).padStart(2,"0")}function Od(s){return`${s.getFullYear()}-${fE(s.getMonth()+1)}-${fE(s.getDate())}`}function pE(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}var mE={today:"Today","7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",qtd:"Quarter to date",ytd:"Year to date",custom:"Custom"},Ks=new Set(Object.keys(mE));function ah(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=Od(e),r=n=>{let o=new Date(e);return o.setDate(o.getDate()-n),Od(o)};switch(s){case"today":return{from:i,to:i};case"7d":return{from:r(6),to:i};case"30d":return{from:r(29),to:i};case"90d":return{from:r(89),to:i};case"qtd":{let n=Math.floor(e.getMonth()/3)*3;return{from:Od(new Date(e.getFullYear(),n,1)),to:i}}case"ytd":return{from:Od(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function rq(s,t){let e=pE(s),i=pE(t);if(!e||!i)return"";let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=e.getFullYear()===i.getFullYear(),o=n&&e.getMonth()===i.getMonth();return n&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate()?`${r[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`:o?`${r[e.getMonth()]} ${e.getDate()} \u2013 ${i.getDate()}, ${i.getFullYear()}`:n?`${r[e.getMonth()]} ${e.getDate()} \u2013 ${r[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`:`${r[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()} \u2013 ${r[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`}var yd=class s extends M{static labelDeprecated=!0;static get properties(){return{...M.properties,value:{type:String,default:"7d",reflect:!0},from:{type:String,default:"",reflect:!0},to:{type:String,default:"",reflect:!0},presets:{type:String,default:"today,7d,30d,90d,qtd,ytd,custom"},broadcast:{type:String,default:"document",reflect:!0},ariaLabelAttr:{type:String,default:"Time period",attribute:"aria-label",reflect:!0},pickerOpen:{type:Boolean,default:!1,attribute:"picker-open",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n={prefix:null,chips:null,picker:null,readout:null,suffix:null};#a=!1;#o=!1;static#l=new WeakSet;setRange(t,e,i){if(t==="custom"){if(!e||!i){console.warn('[date-range-selector-ui] setRange("custom", \u2026) requires from + to ISO dates.');return}let n=this.#p(e,i);this.#u("custom",n.from,n.to);return}if(!Ks.has(t)){console.warn(`[date-range-selector-ui] unknown preset "${t}" \u2014 ignored. Use one of: ${[...Ks].join(", ")}.`);return}let r=ah(t);r&&this.#u(t,r.from,r.to)}getRange(){return{value:this.value,preset:this.value,from:this.from,to:this.to}}subscribe(t){let e=this.#g();return e?(e.addEventListener("range-change",t),()=>e.removeEventListener("range-change",t)):()=>{}}connected(){super.connected(),this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.ariaLabelAttr||"Time period"),this.#t||(this.#c(),this.#d(),this.#t=!0),this.broadcast==="document"&&this.#O(),F(()=>{let t=this.#m();t&&this.#u(this.value,t.from,t.to,{initial:!0})})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0,this.#S()}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#o)){if(t==="presets"){this.#h();return}if(t==="broadcast"){e==="document"&&i!=="document"&&this.#S(),i==="document"?(this.#O(),this.#y()):i==="self"&&this.#y();return}if(t==="value"&&e!==i&&i&&Ks.has(i)){if(i!=="custom"){let r=ah(i);r&&this.#u(i,r.from,r.to)}return}}}syncValue(t){let e=this.from&&this.to?`${this.from}:${this.to}`:"";this.internals.setFormValue(e)}render(){if(this.#t){if(this.#i&&this.#i.value!==this.value&&(this.#i.value=this.value),this.#s){this.hasAttribute("min")&&this.#s.setAttribute("min",this.getAttribute("min")),this.hasAttribute("max")&&this.#s.setAttribute("max",this.getAttribute("max"));let t=this.from&&this.to?JSON.stringify({from:this.from,to:this.to}):"";this.#s.value!==t&&(this.#s.value=t)}if(this.#r){let t=rq(this.from,this.to);this.#r.textContent=t,this.#r.hidden=!t}}}#c(){let t=document.createElement("segmented-ui");t.setAttribute("data-region","chips"),t.setAttribute("role","radiogroup"),t.setAttribute("aria-label","Preset ranges"),this.appendChild(t),this.#i=t,this.#n.chips=t;let e=document.createElement("date-range-picker-ui");e.setAttribute("data-region","picker"),e.setAttribute("format","short"),e.setAttribute("placeholder","Custom range"),this.appendChild(e),this.#s=e,this.#n.picker=e;let i=document.createElement("text-ui");i.setAttribute("data-region","readout"),i.setAttribute("part","readout"),i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.hidden=!0,this.appendChild(i),this.#r=i,this.#n.readout=i,this.#h()}#h(){if(!this.#i)return;let t=(this.presets||"").split(",").map(i=>i.trim()).filter(Boolean),e=this.#i.querySelector(":scope > [data-indicator]");this.#i.replaceChildren(),e&&this.#i.appendChild(e);for(let i of t){if(!Ks.has(i)){s.#l.has(this)||(s.#l.add(this),console.warn(`[date-range-selector-ui] unknown preset key "${i}" in [presets] \u2014 ignored. Use one of: ${[...Ks].join(", ")}.`));continue}let r=document.createElement("segment-ui");r.setAttribute("value",i),r.setAttribute("text",mE[i]),this.#i.appendChild(r)}this.#i.value=this.value}#d(){let t=n=>{let o=n.detail?.value;if(!o||!Ks.has(o))return;if(n.stopPropagation(),o==="custom"){this.#v(),this.#f("custom");return}let a=ah(o);a&&this.#u(o,a.from,a.to)};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=n=>{n.stopPropagation();let a=(n.detail||{}).value||null;if(!a||!a.from||!a.to)return;let l=this.#p(a.from,a.to);this.#u("custom",l.from,l.to)};this.#s.addEventListener("change",e),this.#e.push(()=>this.#s.removeEventListener("change",e));let i=()=>{this.pickerOpen=!0},r=()=>{this.pickerOpen=!1};this.#s.addEventListener("open",i),this.#s.addEventListener("close",r),this.#e.push(()=>this.#s.removeEventListener("open",i)),this.#e.push(()=>this.#s.removeEventListener("close",r))}#u(t,e,i,r={}){if(this.from===e&&this.to===i&&this.value===t&&!r.initial)return;this.#o=!0;try{this.from=e,this.to=i,this.value=t}finally{this.#o=!1}this.syncValue(),this.#y();let o={value:t,from:e,to:i,preset:t};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,from:e,to:i}}));let a=this.#g();a&&a.dispatchEvent(new CustomEvent("range-change",{bubbles:a===this,detail:o}))}#f(t){if(this.value!==t){this.#o=!0;try{this.value=t}finally{this.#o=!1}}}#p(t,e){return t<=e?{from:t,to:e}:{from:e,to:t}}#m(){if(this.value==="custom")return this.from&&this.to?this.#p(this.from,this.to):ah("7d");let t=Ks.has(this.value)?this.value:"7d";return ah(t)}#g(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#b(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#y(){let t=this.#b();t&&(this.broadcast==="document"&&!this.#a||(this.from?t.setAttribute("data-range-from",this.from):t.removeAttribute("data-range-from"),this.to?t.setAttribute("data-range-to",this.to):t.removeAttribute("data-range-to")))}#O(){if(Gs.size>0&&!Gs.has(this)){dE||(dE=!0,console.warn('[date-range-selector-ui] multiple instances with broadcast="document" on the same page; only the first writes data-range-from / data-range-to to <html>. Use broadcast="self" for secondary instances. See SPEC-019 \xA76 nesting rules.')),this.#a=!1,Gs.add(this);return}Gs.add(this),this.#a=!0}#S(){if(Gs.has(this)&&(Gs.delete(this),this.#a)){document.documentElement.removeAttribute("data-range-from"),document.documentElement.removeAttribute("data-range-to"),this.#a=!1;let t=Gs.values().next().value;t&&(t.#a=!0,t.#y())}}#v(){this.#s&&(typeof this.#s.openPopover=="function"?this.#s.openPopover():this.#s.open=!0)}};customElements.get("date-range-selector-ui")||customElements.define("date-range-selector-ui",yd);$();var vd=class extends x{static properties={open:{type:Boolean,default:!1,reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},confirmText:{type:String,default:"Confirm",reflect:!0,attribute:"confirm-text"},cancelText:{type:String,default:"Cancel",reflect:!0,attribute:"cancel-text"},confirmVariant:{type:String,default:"primary",reflect:!0,attribute:"confirm-variant"},size:{type:String,default:"sm",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=[];#d=!1;#u="";#f="";#p=!1;connected(){this.#d||(this.#u=`${this.#y}-title`,this.#f=`${this.#y}-desc`,this.#m(),this.#g(),this.#d=!0)}disconnected(){for(let t of this.#h)try{t()}catch{}this.#h.length=0}show(){this.open=!0}hide(){this.open=!1}render(){if(!this.#d)return;this.#t&&(this.#t.setAttribute("size",this.size||"sm"),this.#t.open=!!this.open),this.#s&&(this.#s.id=this.#u,this.#s.textContent=this.title||""),this.#n&&(this.#n.id=this.#f,this.#n.textContent=this.description||"",this.#n.hidden=!this.description),this.#i&&(this.querySelector(':scope > [slot="icon"]')?this.#i.hidden=!0:this.icon?(this.#i.hidden=!1,this.#i.setAttribute("name",this.icon)):this.#i.hidden=!0);let t=this.#t?.querySelector(':scope > [slot="dialog"]');t&&(t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),this.title?t.setAttribute("aria-labelledby",this.#u):t.removeAttribute("aria-labelledby"),this.description?t.setAttribute("aria-describedby",this.#f):t.removeAttribute("aria-describedby")),this.#l&&(this.#l.setAttribute("text",this.cancelText||"Cancel"),this.loading?this.#l.setAttribute("disabled",""):this.#l.removeAttribute("disabled")),this.#c&&(this.#c.setAttribute("text",this.confirmText||"Confirm"),this.#c.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),this.loading?(this.#c.setAttribute("disabled",""),this.#c.setAttribute("icon","spinner")):(this.#c.removeAttribute("disabled"),this.#c.removeAttribute("icon"))),this.open&&this.#l&&!this.loading&&this.#b()}#m(){let t=document.createElement("modal-ui");t.setAttribute("size",this.size||"sm");let e=document.createElement("header");e.setAttribute("slot","header");let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.hidden=!0,e.appendChild(i),this.#i=i;let r=document.createElement("text-ui");r.setAttribute("slot","heading"),r.id=this.#u,this.title&&(r.textContent=this.title),e.appendChild(r),this.#s=r,this.#e=e;let n=document.createElement("section");n.setAttribute("slot","body");let o=document.createElement("text-ui");o.setAttribute("slot","description"),o.id=this.#f,this.description?o.textContent=this.description:o.hidden=!0,n.appendChild(o),this.#n=o;let a=document.createElement("div");a.setAttribute("data-extra",""),n.appendChild(a),this.#a=a,this.#r=n;let l=document.createElement("footer");l.setAttribute("slot","footer");let h=document.createElement("button-ui");h.setAttribute("slot","action"),h.setAttribute("data-confirm-action","cancel"),h.setAttribute("variant","ghost"),h.setAttribute("text",this.cancelText||"Cancel"),l.appendChild(h),this.#l=h;let c=document.createElement("button-ui");c.setAttribute("slot","action"),c.setAttribute("data-confirm-action","confirm"),c.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),c.setAttribute("text",this.confirmText||"Confirm"),l.appendChild(c),this.#c=c,this.#o=l;let u=[...this.children];for(let d of u){let f=d.getAttribute("slot");f==="icon"?e.appendChild(d):f||a.appendChild(d)}t.appendChild(e),t.appendChild(n),t.appendChild(l),this.appendChild(t),this.#t=t}#g(){let t=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("confirm",{bubbles:!0,detail:{}})))};this.#c.addEventListener("press",t),this.#h.push(()=>this.#c.removeEventListener("press",t));let e=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.open=!1)};this.#l.addEventListener("press",e),this.#h.push(()=>this.#l.removeEventListener("press",e));let i=r=>{r.stopPropagation(),this.open=!1,this.#p||this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.#p=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{}}))};this.#t.addEventListener("close",i),this.#h.push(()=>this.#t.removeEventListener("close",i))}#b(){let t=()=>{if(!(!this.open||!this.#l||this.loading))try{this.#l.focus()}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):queueMicrotask(t)}get#y(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",vd);$();Ct();var nq=new Set(["active","trialing","past_due","canceled","paused"]),oq={active:"success",trialing:"info",past_due:"danger",canceled:"muted",paused:"warning"},aq={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},lq={update:"update-card",retry:"retry"};function gE(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function hq(s,t){if(!s)return"";try{let e=s instanceof Date?s:new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"2-digit"}).format(e)}catch{return String(s)}}var ba=class extends x{static get properties(){return{account:{type:Object,default:null},variant:{type:String,default:"full",reflect:!0},currency:{type:String,default:"USD",reflect:!0},locale:{type:String,default:""},loading:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m=null;#g=null;#b=null;#y=null;#O=null;#S=null;#v=null;#w=null;#x="";#k=!1;#A=0;async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#A;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#A)return;this.loading=!1;let n=r&&typeof r=="object"&&r.account?r.account:r;this.account=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{account:n}}))}catch(i){if(e!==this.#A)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#C(),this.#T(),this.#q(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),this.#t&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;let t=this.account,e=!t&&!this.getAttribute("data-stream-src");e?this.setAttribute("empty",""):this.removeAttribute("empty"),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let i=t?.status||"";if(i==="past_due"?this.setAttribute("past-due",""):this.removeAttribute("past-due"),i==="trialing"?this.setAttribute("trial",""):this.removeAttribute("trial"),i&&!nq.has(i)&&!this.#k&&(this.#k=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#Q(null),this.#D(null);return}if(!t){this.#Q(null);return}this.#Q(t),this.#P(t),this.#I(t),this.#$(t),this.#M(t),this.#L(t),this.#D(t)}#C(){let t=this.querySelector(':scope > script[type="application/json"][data-account]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.account&&typeof e.account=="object"?e.account:e;this.account=i}}catch(e){console.warn("[billing-overview-ui] failed to parse <script data-account> JSON:",e?.message)}finally{t.remove()}}#E(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#T(){this.#x=`bo-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("card-ui");t.setAttribute("data-header","");let e=document.createElement("header"),i=document.createElement("span");i.setAttribute("slot","icon");let r=document.createElement("avatar-ui");r.setAttribute("icon","credit-card"),i.appendChild(r);let n=document.createElement("span");n.setAttribute("slot","heading");let o=document.createElement("h2");o.id=this.#x,o.setAttribute("data-billing-plan-name",""),n.appendChild(o);let a=document.createElement("tag-ui");a.setAttribute("data-billing-status",""),a.setAttribute("size","md"),n.appendChild(a);let l=document.createElement("span");l.setAttribute("slot","description");let h=document.createElement("div");h.setAttribute("data-billing-plan-meta",""),l.appendChild(h);let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("div");u.setAttribute("data-header-actions",""),c.appendChild(u),e.append(i,n,l,c),t.appendChild(e),this.appendChild(t),this.#i=t,this.#s=o,this.#r=h,this.#n=a,this.#a=u,this.#E("header-actions",u);let d=document.createElement("section");d.setAttribute("data-kpis","");let f=(bt,xt,Ot)=>{let Et=document.createElement("card-ui");Et.setAttribute("data-kpi-card",bt);let Tt=document.createElement("section"),Ft=document.createElement("stat-ui");return Ft.setAttribute("data-kpi",bt),Ft.setAttribute("label",xt),Ft.setAttribute("value","\u2014"),Ft.setAttribute("icon",Ot),Tt.appendChild(Ft),Et.appendChild(Tt),[Et,Ft]},[p,m]=f("spend","Current month","credit-card"),[b,g]=f("seats","Seats","users-three"),[y,v]=f("next-invoice","Next invoice","calendar");d.append(p,b,y),this.appendChild(d),this.#o=d,this.#l=m,this.#c=g,this.#h=v;let w=document.createElement("section");w.setAttribute("data-dunning",""),w.setAttribute("hidden","");let k=document.createElement("alert-ui");k.setAttribute("pattern","dunning"),k.setAttribute("variant","danger"),w.appendChild(k),this.appendChild(w),this.#d=w,this.#u=k;let E=document.createElement("section");E.setAttribute("data-plan-picker","");let A=document.createElement("h3");A.setAttribute("data-section-heading",""),A.textContent="Plan";let C=document.createElement("plan-picker-ui");C.setAttribute("data-billing-plan-picker",""),C.setAttribute("name","billing-overview-plan"),E.append(A,C),this.appendChild(E),this.#f=E,this.#p=A,this.#m=C;let T=document.createElement("div");T.setAttribute("data-before-plan-picker",""),E.insertBefore(T,A),this.#E("before-plan-picker",T);let Q=document.createElement("section");Q.setAttribute("data-payment-methods","");let D=document.createElement("h3");D.setAttribute("data-section-heading",""),D.textContent="Payment methods";let R=document.createElement("payment-method-list-ui");R.setAttribute("data-billing-payment-methods",""),R.setAttribute("name","billing-overview-payment-method"),Q.append(D,R),this.appendChild(Q),this.#g=Q,this.#b=D,this.#y=R;let _=document.createElement("section");_.setAttribute("data-invoice-history","");let V=document.createElement("h3");V.setAttribute("data-section-heading",""),V.textContent="Invoice history";let U=document.createElement("invoice-history-ui");U.setAttribute("data-billing-invoice-history",""),_.append(V,U),this.appendChild(_),this.#O=_,this.#S=V,this.#v=U;let J=document.createElement("div");J.setAttribute("data-after-invoice-history",""),_.appendChild(J),this.#E("after-invoice-history",J);let rt=document.createElement("div");rt.setAttribute("data-empty","");let ut=document.createElement("p");ut.setAttribute("data-empty-heading",""),ut.textContent="No billing account loaded";let ot=document.createElement("p");ot.setAttribute("data-empty-description",""),ot.textContent="Pass an `account` snapshot or `data-stream-src` to render the dashboard.",rt.append(ut,ot),this.appendChild(rt),this.#w=rt,this.#E("empty",this)}#Q(t){if(!this.#s||!this.#n||!this.#r)return;let e=t?.plan||null,i=e?.name?String(e.name):"Billing overview";this.#s.textContent!==i&&(this.#s.textContent=i);let r=this.#r;if(r.replaceChildren(),e&&Number.isFinite(e.price)){let o=e.currency||this.currency||"USD",a=this.#X(),l=e.cycle==="year"?"/yr":"/mo",h=document.createElement("span");h.setAttribute("data-plan-price",""),h.textContent=`${gE(e.price,o,a)} ${l}`,r.appendChild(h)}if(t?.billingCycle&&t.billingCycle!==e?.cycle){let o=document.createElement("span");o.setAttribute("data-plan-billing-cycle",""),o.textContent=`Billed ${t.billingCycle}ly`,r.appendChild(o)}let n=t?.status||"";if(!n)this.#n.setAttribute("hidden","");else{this.#n.removeAttribute("hidden");let o=oq[n]||"default",a=aq[n]||n;this.#n.getAttribute("variant")!==o&&this.#n.setAttribute("variant",o),this.#n.getAttribute("text")!==a&&this.#n.setAttribute("text",a),this.#n.setAttribute("aria-label",`Account status: ${a}`)}}#P(t){if(!this.#l||!this.#c||!this.#h)return;let e=t?.plan?.currency||this.currency||"USD",i=this.#X();if(Number.isFinite(t?.currentSpend)?this.#l.setAttribute("value",gE(t.currentSpend,e,i)):this.#l.setAttribute("value","\u2014"),t?.seats&&Number.isFinite(t.seats.used)){let r=t.seats.used,n=Number.isFinite(t.seats.total)?t.seats.total:null;this.#c.setAttribute("value",n!=null?`${r} / ${n}`:String(r))}else this.#c.setAttribute("value","\u2014");t?.nextInvoiceDate?this.#h.setAttribute("value",hq(t.nextInvoiceDate,i)):this.#h.setAttribute("value","\u2014");for(let r of[this.#l,this.#c,this.#h])this.loading?r.setAttribute("loading",""):r.removeAttribute("loading")}#I(t){if(!this.#d||!this.#u)return;let e=t?.dunning||null;if(!(t?.status==="past_due")||!e){this.#d.setAttribute("hidden","");return}this.#d.removeAttribute("hidden");let r=Number.isFinite(e.amount)?e.amount:null,n=e.currency||t?.plan?.currency||this.currency||"USD";if(r!=null?this.#u.setAttribute("amount",String(r)):this.#u.removeAttribute("amount"),this.#u.setAttribute("currency",n),e.dueAt&&this.#u.setAttribute("due-at",String(e.dueAt)),e.cardLast4&&this.#u.setAttribute("card-last4",String(e.cardLast4)),e.reason&&this.#u.setAttribute("reason",String(e.reason)),!this.#u.querySelector(':scope > [slot="actions"]')){let o=document.createElement("button-ui");o.setAttribute("slot","actions"),o.setAttribute("data-dunning-action","update"),o.setAttribute("variant","primary"),o.setAttribute("text","Update payment method"),this.#u.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("slot","actions"),a.setAttribute("data-dunning-action","retry"),a.setAttribute("variant","outline"),a.setAttribute("text","Retry charge"),this.#u.appendChild(a)}}#$(t){if(!this.#f||!this.#m)return;let e=this.variant==="full",i=Array.isArray(t?.plans)&&t.plans.length>0;if(!(e&&i)){this.#f.setAttribute("hidden","");return}this.#f.removeAttribute("hidden"),this.#m.plans=t.plans,t?.plan?.id&&this.#m.setAttribute("current",String(t.plan.id)),this.loading?this.#m.setAttribute("loading",""):this.#m.removeAttribute("loading")}#M(t){if(!this.#y)return;let e=Array.isArray(t?.paymentMethods)?t.paymentMethods:[];this.#y.methods=e,this.loading?this.#y.setAttribute("loading",""):this.#y.removeAttribute("loading")}#L(t){if(!this.#v)return;let e=Array.isArray(t?.invoices)?t.invoices:[];this.#v.invoices=e;let i=t?.plan?.currency||this.currency||"USD";this.#v.setAttribute("currency",i),this.loading?this.#v.setAttribute("loading",""):this.#v.removeAttribute("loading")}#D(t){this.#x&&this.setAttribute("aria-labelledby",this.#x),!t&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label","No billing account loaded"):t&&this.removeAttribute("aria-label")}#X(){return this.locale?this.locale:typeof document<"u"&&document.documentElement.lang||""}#q(){let t=u=>{let d=u.target?.closest?.("[data-account-action]");if(!d||!this.contains(d))return;let f=d.getAttribute("data-account-action")||"";f&&(u.stopPropagation(),this.#R(f,"header",{target:d}))};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=u=>{let d=u.detail?.action||"",f=lq[d]||d||"dunning";this.#R(f,"alert-dunning",u.detail)};this.addEventListener("dunning-action",e),this.#e.push(()=>this.removeEventListener("dunning-action",e));let i=u=>{let d=u.detail?.value??u.detail?.plan?.id??"";this.#R("select-plan","plan-picker",{planId:d,...u.detail})};this.addEventListener("plan-change",i),this.#e.push(()=>this.removeEventListener("plan-change",i));let r=u=>{!this.#m||!this.#m.contains(u.target)&&u.target!==this.#m||this.#R("select-plan","plan-picker",u.detail)};this.addEventListener("change",r),this.#e.push(()=>this.removeEventListener("change",r));let n=()=>{this.#R("add-payment-method","payment-method-list",null)};this.addEventListener("add",n),this.#e.push(()=>this.removeEventListener("add",n));let o=u=>{this.#R("remove-payment-method","payment-method-list",u.detail)};this.addEventListener("remove",o),this.#e.push(()=>this.removeEventListener("remove",o));let a=u=>{this.#R("set-default-payment-method","payment-method-list",u.detail)};this.addEventListener("select",a),this.#e.push(()=>this.removeEventListener("select",a));let l=u=>{this.#R("view-invoice","invoice-history",u.detail)};this.addEventListener("invoice-row-click",l),this.#e.push(()=>this.removeEventListener("invoice-row-click",l));let h=u=>{this.#R("download-invoice","invoice-history",u.detail)};this.addEventListener("invoice-export",h),this.#e.push(()=>this.removeEventListener("invoice-export",h));let c=u=>{let d=u.detail?.action||"invoice";this.#R(d,"invoice-history",u.detail)};this.addEventListener("invoice-action",c),this.#e.push(()=>this.removeEventListener("invoice-action",c))}#R(t,e,i){this.dispatchEvent(new CustomEvent("account-action",{bubbles:!0,detail:{action:t,source:e,payload:i||null}}))}};customElements.get("billing-overview-ui")||customElements.define("billing-overview-ui",ba);$();Ct();var cq=new Set(["draft","open","paid","past-due","void"]),uq={paid:"success",open:"info","past-due":"danger",void:"muted",draft:"neutral"},bE={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},dq=[{value:"",label:"All"},{value:"paid",label:"Paid"},{value:"open",label:"Open"},{value:"past-due",label:"Past due"},{value:"void",label:"Void"},{value:"draft",label:"Draft"}],OE=["Number","Issued","Due","Amount","Currency","Status"];function yE(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function vE(s,t){if(!s)return"";try{let e=s instanceof Date?s:new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"2-digit"}).format(e)}catch{return String(s)}}function xE(s,t){return(s||"/invoices/{number}").replace("{number}",encodeURIComponent(t?.number??"")).replace("{id}",encodeURIComponent(t?.id??""))}function Xe(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
442
+ `)?'"'+t.replace(/"/g,'""')+'"':t}var Oa=class extends x{static properties={invoices:{type:Array,default:[]},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},hrefPattern:{type:String,default:"/invoices/{number}",reflect:!0,attribute:"href-pattern"},paginate:{type:Number,default:25,reflect:!0},exportable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""},filter:{type:String,default:"",reflect:!0}};static template=()=>null;static requiredIcons=["download-simple","receipt","magnifying-glass"];#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=!1;#h=0;#d=!1;setFilter(t){let e=t||"";return e&&!cq.has(e)?!1:F(()=>{if(this.filter===e)return!0;let i=this.filter;return this.filter=e,this.dispatchEvent(new CustomEvent("invoice-filter-change",{bubbles:!0,detail:{filter:e,previous:i}})),!0})}exportCsv(){let t=this.#m(),e=[OE.join(",")];for(let r of t){let n=[Xe(r.number??""),Xe(r.issuedAt??""),Xe(r.dueAt??""),Xe(Number.isFinite(r.amount)?r.amount:""),Xe(r.currency||this.currency||"USD"),Xe(r.status??"")];e.push(n.join(","))}let i=e.join(`\r
443
+ `);return new Blob([i],{type:"text/csv;charset=utf-8;"})}getSelected(){if(!this.#o)return[];let t=this.#o.selected||[],e=this.#m();return t.map(i=>e[i]).filter(Boolean)}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#h;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#h)return;this.removeAttribute("loading");let n=Array.isArray(r)?r:Array.isArray(r?.invoices)?r.invoices:[];this.invoices=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:n.length}}))}catch(i){if(e!==this.#h)return;this.removeAttribute("loading"),this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){super.connected?.(),this.setAttribute("role","region"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Invoice history"),this.#t||(this.#u(),this.#f(),this.#b(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#c)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;(Array.isArray(this.invoices)?this.invoices:[]).length===0&&!this.loading?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#p(),this.#o&&(this.#o.columns=this.#g(),this.#o.data=this.#m(),this.#o.density!==this.density&&(this.#o.density=this.density),!!this.#o.loading!=!!this.loading&&(this.#o.loading=!!this.loading),Number(this.#o.paginate||0)!==Number(this.paginate||0)&&(this.#o.paginate=Number(this.paginate||0)),!!this.#o.selectable!=!!this.selectable&&(this.#o.selectable=!!this.selectable)),this.#s&&this.#s.setAttribute("count",String(this.#m().length)),this.#n&&(this.#n.hidden=!this.exportable)}#u(){let t=this.querySelector(':scope > script[type="application/json"][data-invoices]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.invoices=e)}catch(e){console.warn("[invoice-history-ui] failed to parse <script data-invoices> JSON:",e?.message)}finally{t.remove()}}#f(){let t=document.createElement("div");t.setAttribute("data-toolbar",""),this.appendChild(t),this.#i=t;let e=this.querySelector(':scope > [slot="toolbar"]');if(e)t.appendChild(e);else{let n=document.createElement("table-toolbar-ui");n.setAttribute("data-default-toolbar",""),n.setAttribute("text","Invoices");let o=document.createElement("div");o.setAttribute("data-invoice-filter",""),o.setAttribute("role","group"),o.setAttribute("aria-label","Filter invoices by status"),o.setAttribute("slot","actions"),n.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("data-export",""),a.setAttribute("slot","actions"),a.setAttribute("variant","outline"),a.setAttribute("size","sm"),a.setAttribute("text","Export CSV"),a.setAttribute("icon","download-simple"),n.appendChild(a),t.appendChild(n),this.#s=n,this.#r=o,this.#n=a}let i=document.createElement("div");i.setAttribute("data-table-host",""),this.appendChild(i),this.#a=i;let r=document.createElement("table-ui");if(r.id=this.id?`${this.id}__table`:`invoice-history-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("data-invoice-table",""),r.setAttribute("sortable",""),i.appendChild(r),this.#o=r,this.#s&&this.#s.setAttribute("for",r.id),!this.querySelector(':scope > [slot="empty"]')){let n=document.createElement("empty-state-ui");n.setAttribute("data-empty",""),n.setAttribute("icon","receipt"),n.setAttribute("heading","No invoices yet"),n.setAttribute("description","Invoices will appear here once issued."),this.appendChild(n),this.#l=n}}#p(){if(!this.#r)return;if(this.#r.children.length===0)for(let e of dq){let i=document.createElement("button-ui");i.setAttribute("data-filter-chip",""),i.setAttribute("data-filter-value",e.value),i.setAttribute("size","sm"),i.setAttribute("text",e.label),this.#r.appendChild(i)}let t=this.filter||"";for(let e of this.#r.querySelectorAll("[data-filter-chip]"))(e.getAttribute("data-filter-value")||"")===t?(e.setAttribute("variant","primary"),e.setAttribute("aria-pressed","true")):(e.setAttribute("variant","ghost"),e.setAttribute("aria-pressed","false"))}#m(){let t=Array.isArray(this.invoices)?this.invoices:[],e=this.filter||"";return e?t.filter(i=>(i?.status||"")===e):t}#g(){let t=this.locale||typeof document<"u"&&document.documentElement?.lang||"",e=this.currency||"USD";return[{key:"number",label:"Invoice",sortable:!0,wrap:!1},{key:"issuedAt",label:"Issued",sortable:!0,format:i=>vE(i,t)},{key:"dueAt",label:"Due",sortable:!0,format:i=>vE(i,t)},{key:"amount",label:"Amount",sortable:!0,align:"end",render:(i,r,n)=>{let o=r?.currency||e,a=document.createElement("span");return a.setAttribute("data-invoice-amount",""),a.textContent=yE(i,o,t),n.dataset.align="end",a},format:(i,r)=>yE(i,r?.currency||e,t)},{key:"status",label:"Status",sortable:!0,render:i=>{let r=String(i||"").toLowerCase(),n=uq[r]||"neutral",o=bE[r]||(i?String(i):"\u2014"),a=document.createElement("badge-ui");return a.setAttribute("data-invoice-status",""),a.setAttribute("variant",n),a.setAttribute("text",o),a.setAttribute("aria-label",o),a},format:i=>bE[String(i||"").toLowerCase()]||(i?String(i):"")},{key:"actions",label:"",sortable:!1,align:"end",accessor:i=>i,render:(i,r)=>{let n=document.createElement("span");n.setAttribute("data-invoice-actions","");let o=document.createElement("button-ui");o.setAttribute("data-invoice-action","view"),o.setAttribute("data-invoice-id",String(r?.id??r?.number??"")),o.setAttribute("size","sm"),o.setAttribute("variant","ghost"),o.setAttribute("text","View"),n.appendChild(o);let a=document.createElement("button-ui");return a.setAttribute("data-invoice-action","download"),a.setAttribute("data-invoice-id",String(r?.id??r?.number??"")),a.setAttribute("size","sm"),a.setAttribute("variant","ghost"),a.setAttribute("icon","download-simple"),a.setAttribute("aria-label",`Download invoice ${r?.number??""}`),n.appendChild(a),n}}]}#b(){let t=o=>{let a=o.target?.closest?.("[data-filter-chip]");if(!a||!this.#r?.contains(a))return;o.stopPropagation();let l=a.getAttribute("data-filter-value")||"";this.setFilter(l)};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=o=>{let a=o?.detail;if(!a||a.key==="actions")return;let l=a.row;if(!l)return;let h=xE(this.hrefPattern,l),c=new CustomEvent("invoice-row-click",{bubbles:!0,cancelable:!0,detail:{invoice:l,href:h}});if(this.dispatchEvent(c)&&typeof window<"u"&&window.location?.assign)try{window.location.assign(h)}catch{}};this.addEventListener("cell-click",e),this.#e.push(()=>this.removeEventListener("cell-click",e));let i=o=>{let a=o.target?.closest?.("button-ui[data-invoice-action]");if(!a||!this.#a?.contains(a))return;o.stopPropagation();let l=a.getAttribute("data-invoice-action"),h=a.getAttribute("data-invoice-id")||"",c=(this.invoices||[]).find(u=>String(u?.id??u?.number??"")===h);if(c){if(l==="view"){let u=xE(this.hrefPattern,c),d=new CustomEvent("invoice-row-click",{bubbles:!0,cancelable:!0,detail:{invoice:c,href:u}});if(this.dispatchEvent(d)&&typeof window<"u"&&window.location?.assign)try{window.location.assign(u)}catch{}}else if(l==="download"){let u=this.#y(c);this.dispatchEvent(new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:u,rowCount:1,invoice:c}}))}}};this.addEventListener("press",i),this.addEventListener("click",i),this.#e.push(()=>this.removeEventListener("press",i)),this.#e.push(()=>this.removeEventListener("click",i));let r=o=>{let a=o.target?.closest?.("button-ui[data-export]");if(!a||!this.#i?.contains(a))return;o.stopPropagation();let l=this.exportCsv(),h=new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:l,rowCount:this.#m().length}});if(this.dispatchEvent(h)&&typeof document<"u"&&typeof URL<"u")try{let u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download="invoices.csv",document.body.appendChild(d),d.click(),d.remove(),setTimeout(()=>URL.revokeObjectURL(u),0)}catch{}};this.addEventListener("press",r),this.addEventListener("click",r),this.#e.push(()=>this.removeEventListener("press",r)),this.#e.push(()=>this.removeEventListener("click",r));let n=o=>{if(o.target!==this.#o)return;let a=this.getSelected();this.dispatchEvent(new CustomEvent("invoice-selection-change",{bubbles:!0,detail:{selected:a}}))};this.addEventListener("select",n),this.#e.push(()=>this.removeEventListener("select",n))}#y(t){let e=[OE.join(","),[Xe(t.number??""),Xe(t.issuedAt??""),Xe(t.dueAt??""),Xe(Number.isFinite(t.amount)?t.amount:""),Xe(t.currency||this.currency||"USD"),Xe(t.status??"")].join(",")];return new Blob([e.join(`\r
444
+ `)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",Oa);$();Ct();var fq=new Set(["draft","open","paid","past-due","void"]),pq={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},mq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function xd(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(i)}catch{return`${t||"$"}${i.toFixed(2)}`}}function SE(s,t){if(!s)return"";try{let e=new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric"}).format(e)}catch{return String(s)}}var ya=class extends x{static get properties(){return{invoice:{type:Object,default:null},status:{type:String,default:"draft",reflect:!0},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},printable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m="";#g=!1;#b=!1;#y=0;#O="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#y;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#y)return;this.loading=!1;let n=r&&typeof r=="object"&&r.invoice?r.invoice:r;if(this.invoice=n,n?.status){this.#g=!0;try{this.status=String(n.status)}finally{this.#g=!1}}let o=n?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:o}})),this.#O=o}catch(i){if(e!==this.#y)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#S(),this.#w(),this.#T(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#g)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;let t=this.invoice,e=!t&&!this.getAttribute("data-stream-src");e?this.setAttribute("empty",""):this.removeAttribute("empty"),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let r=(this.hasAttribute("status")?this.getAttribute("status"):"")||t?.status||this.status||"draft";if(fq.has(r)||this.#b||(this.#b=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#x(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#x(null,r);return}this.#x(t,r),this.#k(t),this.#A(t),this.#C(t),this.#E(t)}#S(){let t=this.querySelector(':scope > script[type="application/json"][data-invoice]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.invoice&&typeof e.invoice=="object"?e.invoice:e;if(this.invoice=i,i?.status){this.#g=!0;try{this.status=String(i.status)}finally{this.#g=!1}}}}catch(e){console.warn("[invoice-detail-ui] failed to parse <script data-invoice> JSON:",e?.message)}finally{t.remove()}}#v(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#w(){this.#m=`inv-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("header");t.setAttribute("data-header","");let e=document.createElement("div");e.setAttribute("data-header-title","");let i=document.createElement("h2");i.id=this.#m,i.setAttribute("data-invoice-number",""),e.appendChild(i);let r=document.createElement("tag-ui");r.setAttribute("data-invoice-status",""),r.setAttribute("size","md"),e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-header-meta","");let o=document.createElement("div");o.setAttribute("data-header-actions",""),o.setAttribute("data-invoice-actions",""),t.append(e,n,o),this.appendChild(t),this.#i=t,this.#s=i,this.#r=r,this.#n=n,this.#a=o,this.#v("header-actions",o);let a=document.createElement("section");a.setAttribute("data-parties","");let l=document.createElement("div");l.setAttribute("data-customer","");let h=document.createElement("div");h.setAttribute("data-customer-default",""),l.appendChild(h),this.#l=h;let c=document.createElement("div");c.setAttribute("data-remit-to","");let u=document.createElement("div");u.setAttribute("data-remit-to-default",""),c.appendChild(u),this.#c=u,a.append(l,c),this.appendChild(a),this.#o=a,this.#v("customer-block",l),this.#v("remit-to-block",c);let d=document.createElement("section");d.setAttribute("data-lines","");let f=document.createElement("card-ui");f.setAttribute("data-lines-card",""),f.setAttribute("padding","none");let p=document.createElement("section");p.setAttribute("bleed",""),f.appendChild(p);let m=document.createElement("table-ui");m.setAttribute("data-lines-table",""),m.setAttribute("density",this.density||"standard"),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#h=d,this.#d=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#u=b;let g=document.createElement("footer");g.setAttribute("data-footer","");let y=document.createElement("div");y.setAttribute("data-footer-notes",""),g.appendChild(y),this.appendChild(g),this.#f=g,this.#v("footer",g);let v=document.createElement("empty-state-ui");v.setAttribute("data-empty",""),v.setAttribute("icon","receipt"),v.setAttribute("heading","No invoice loaded"),v.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(v),this.#p=v}#x(t,e){if(!this.#s||!this.#r||!this.#n)return;let i=t?.number?String(t.number):"";this.#s.textContent!==i&&(this.#s.textContent=i);let r=pq[e]||"default",n=mq[e]||(e?String(e):"Draft");if(this.#r.getAttribute("variant")!==r&&this.#r.setAttribute("variant",r),this.#r.getAttribute("text")!==n&&this.#r.setAttribute("text",n),this.#r.setAttribute("aria-label",`Status: ${n}`),t?this.#r.removeAttribute("hidden"):this.#r.setAttribute("hidden",""),this.#n.replaceChildren(),!t)return;let o=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(t.issuedAt){let a=document.createElement("span");a.setAttribute("data-issued",""),a.textContent=`Issued ${SE(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${SE(t.dueAt,o)}`,this.#n.appendChild(a)}}#k(t){if(!(!this.#l||!this.#c)){if(this.#l.replaceChildren(),t?.customer){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Billed to",this.#l.appendChild(e),t.customer.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.customer.name),this.#l.appendChild(i)}if(t.customer.email){let i=document.createElement("div");i.setAttribute("data-party-email",""),i.textContent=String(t.customer.email),this.#l.appendChild(i)}if(t.customer.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.customer.address),this.#l.appendChild(i)}}if(this.#c.replaceChildren(),t?.remitTo){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Remit to",this.#c.appendChild(e),t.remitTo.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.remitTo.name),this.#c.appendChild(i)}if(t.remitTo.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.remitTo.address),this.#c.appendChild(i)}}}}#A(t){if(!this.#d)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");this.#d.columns=[{key:"description",label:"Description",flex:1},{key:"qty",label:"Qty",width:80,format:n=>String(n??"")},{key:"unitAmount",label:"Unit",width:120,format:n=>xd(n,e,i)},{key:"amount",label:"Amount",width:140,format:n=>xd(n,e,i)}];let r=Array.isArray(t?.lines)?t.lines:[];this.#d.data=r.map((n,o)=>({__row:o,description:n?.description??"",qty:n?.qty??"",unitAmount:n?.unitAmount??0,amount:n?.amount??0})),this.#d.getAttribute("density")!==this.density&&this.#d.setAttribute("density",this.density||"standard")}#C(t){if(!this.#u)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(this.#u.replaceChildren(),!t)return;let r=[{key:"subtotal",label:"Subtotal",value:t.subtotal},{key:"tax",label:"Tax",value:t.tax}];Number.isFinite(t.discount)&&t.discount>0&&r.push({key:"discount",label:"Discount",value:-Math.abs(t.discount)});for(let n of r){if(!Number.isFinite(n.value))continue;let o=document.createElement("div");o.setAttribute("data-totals-row",""),o.setAttribute("data-totals-key",n.key);let a=document.createElement("span");a.setAttribute("data-totals-label",""),a.textContent=n.label;let l=document.createElement("span");l.setAttribute("data-totals-value",""),l.textContent=xd(n.value,e,i),o.append(a,l),this.#u.appendChild(o)}if(Number.isFinite(t.total)){let n=document.createElement("div");n.setAttribute("data-totals-row",""),n.setAttribute("data-totals-key","total"),n.setAttribute("data-grand-total","");let o=document.createElement("span");o.setAttribute("data-totals-label",""),o.textContent="Total";let a=document.createElement("span");a.setAttribute("data-totals-value",""),a.textContent=xd(t.total,e,i),n.append(o,a),this.#u.appendChild(n)}}#E(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#T(){let t=i=>{let r=i.target?.closest?.("[data-invoice-action]");if(!r||!this.contains(r))return;let n=r.getAttribute("data-invoice-action")||"";if(!n)return;let o=this.invoice?.number||"";i.stopPropagation(),this.dispatchEvent(new CustomEvent("invoice-action",{bubbles:!0,detail:{action:n,invoiceNumber:o}}))};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=i=>{if(!this.#h)return;let n=(i.composedPath?i.composedPath():[]).find(l=>l?.getAttribute&&l.getAttribute("data-row")!=null);if(!n||!this.#h.contains(n))return;let o=Number(n.getAttribute("data-row")),a=Array.isArray(this.invoice?.lines)?this.invoice.lines[o]:null;!Number.isFinite(o)||a==null||this.dispatchEvent(new CustomEvent("line-item-click",{bubbles:!0,detail:{index:o,lineItem:a}}))};this.addEventListener("click",e),this.#e.push(()=>this.removeEventListener("click",e))}};customElements.get("invoice-detail-ui")||customElements.define("invoice-detail-ui",ya);Ct();var gq=[{brand:"amex",re:/^3[47]/},{brand:"visa",re:/^4/},{brand:"mastercard",re:/^(5[1-5]|2[2-7])/},{brand:"discover",re:/^6(011|5)/}];function Sd(s){if(!s)return"unknown";for(let{brand:t,re:e}of gq)if(e.test(s))return t;return"unknown"}function wd(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function bG(s,t){return s?t==="amex"?s.replace(/^(\d{0,4})(\d{0,6})(\d{0,5}).*$/,(e,i,r,n)=>[i,r,n].filter(Boolean).join(" ")):s.match(/.{1,4}/g)?.join(" ")??"":""}function wE(s){if(!s||s.length<12)return!1;let t=0,e=!1;for(let i=s.length-1;i>=0;i--){let r=s.charCodeAt(i)-48;if(r<0||r>9)return!1;e&&(r*=2,r>9&&(r-=9)),t+=r,e=!e}return t%10===0}function kE(s){if(!s)return null;let t=String(s).replace(/\s+/g,"").match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(!t)return null;let e=Number(t[1]),i=Number(t[2]);return i<100&&(i+=2e3),!Number.isFinite(e)||!Number.isFinite(i)?null:{month:e,year:i}}function AE(s){let t=kE(s);if(!t)return"expiry-format";let{month:e,year:i}=t;if(e<1||e>12)return"expiry-month";let r=new Date,n=r.getFullYear(),o=r.getMonth()+1;return i<n||i===n&&e<o?"expiry-past":i>n+50?"expiry-far":null}function EE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function bq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var Oq=["US","CA","GB","DE","FR","AU"],yq={US:"United States",CA:"Canada",GB:"United Kingdom",DE:"Germany",FR:"France",AU:"Australia",JP:"Japan",ES:"Spain",IT:"Italy",NL:"Netherlands",SE:"Sweden",IE:"Ireland",SG:"Singapore",IN:"India",BR:"Brazil",MX:"Mexico"};function vq(s){return yq[s]||s}var va=class extends M{static labelDeprecated=!1;static get properties(){return{...M.properties,name:{type:String,default:"paymentMethod",reflect:!0},value:{type:String,default:"",reflect:!0},prefill:{type:String,default:"",attribute:"prefill"},countries:{type:Array,default:[]},defaultCountry:{type:String,default:"US",reflect:!0,attribute:"default-country"},requireBillingAddress:{type:Boolean,default:!1,reflect:!0,attribute:"require-billing-address"},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},autofocus:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#o={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#l="unknown";#c=!1;#h=null;#d=null;#u=!1;async tokenize(){if(this.#u)return Promise.reject(new Error("tokenize-inflight"));this.#u=!0,this.setAttribute("tokenizing","");try{let t=this.#A();if(!t.ok){let r=new Error(t.message);throw r.code=t.code,r.field=t.field,this.dispatchEvent(new CustomEvent("payment-method-error",{bubbles:!0,detail:{message:t.message,code:t.code,field:t.field}})),this.setAttribute("aria-invalid","true"),r}let e=t.detail;this.#c=!0;try{this.value=bq(e.last4)}finally{this.#c=!1}this.syncValue(),this.removeAttribute("aria-invalid");let i={token:this.value,...e};return this.dispatchEvent(new CustomEvent("submit-payment-method",{bubbles:!0,detail:i})),i}finally{this.removeAttribute("tokenizing"),this.#u=!1}}reset(){F(()=>{for(let t of Object.keys(this.#o)){let e=this.#o[t];e&&(e.value="",e.removeAttribute("error"))}this.#o.country&&(this.#o.country.value=this.defaultCountry||"US"),this.#c=!0;try{this.value="",this.error=""}finally{this.#c=!1}this.syncValue(),this.#l="unknown",this.removeAttribute("aria-invalid"),this.removeAttribute("error"),this.#x()})}syncValue(t){this.internals.setFormValue(this.value||""),this.required&&!this.value?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Payment method required.",this):this.internals.setValidity({})}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment method form"),this.#t||(this.#f(),this.#g(),this.#t=!0),F(()=>this.render()),this.autofocus&&requestAnimationFrame(()=>{this.#o.name?.focus?.()})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#c)){if(t==="prefill"&&e!==i)this.render();else if(t==="disabled"&&e!==i)this.#S();else if(t==="error"&&e!==i)this.#v();else if(t==="require-billing-address"&&e!==i)this.#O();else if(t==="default-country"&&e!==i){let r=this.#o.country;r&&!r.value&&(r.value=i||"US")}}}render(){this.#t&&(this.#y(),this.#O(),this.#S(),this.#v(),this.#w(),this.#x())}#f(){let t=document.createElement("alert-ui");t.setAttribute("data-alert",""),t.setAttribute("variant","danger"),t.setAttribute("icon","warning-circle"),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-summary",""),e.hidden=!0;let i=document.createElement("icon-ui");i.setAttribute("name","credit-card"),i.setAttribute("aria-hidden","true"),i.setAttribute("data-summary-icon",""),e.appendChild(i);let r=document.createElement("div");r.setAttribute("data-summary-text",""),e.appendChild(r);let n=document.createElement("button-ui");n.setAttribute("data-summary-edit",""),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("text","Edit card"),e.appendChild(n),this.appendChild(e),this.#s=e,this.#r=n;let o=document.createElement("div");o.setAttribute("data-grid",""),this.appendChild(o),this.#n=o,this.#a.name=this.#p("name",{label:"Name on card",required:!0,area:"name",input:{autocomplete:"cc-name",placeholder:"Pat Doe"}}),this.#o.name=this.#a.name.querySelector("input-ui"),this.#a.cardNumber=this.#p("cardNumber",{label:"Card number",required:!0,area:"card",input:{type:"text",inputmode:"numeric",autocomplete:"cc-number",placeholder:"1234 1234 1234 1234",prefix:"credit-card",maxlength:23}}),this.#o.cardNumber=this.#a.cardNumber.querySelector("input-ui");let a=document.createElement("span");a.setAttribute("slot","trailing"),a.setAttribute("data-brand-badge",""),this.#o.cardNumber.appendChild(a),this.#a.expiry=this.#p("expiry",{label:"Expiry",required:!0,area:"expiry",input:{type:"text",inputmode:"numeric",autocomplete:"cc-exp",placeholder:"MM/YY",maxlength:7}}),this.#o.expiry=this.#a.expiry.querySelector("input-ui"),this.#a.cvc=this.#p("cvc",{label:"CVC",required:!0,area:"cvc",input:{type:"text",inputmode:"numeric",autocomplete:"cc-csc",placeholder:"123",maxlength:4}}),this.#o.cvc=this.#a.cvc.querySelector("input-ui"),this.#a.country=this.#p("country",{label:"Country",required:!0,area:"country",kind:"select",input:{autocomplete:"country"},seedOptions:this.#m(),seedValue:this.defaultCountry||"US"}),this.#o.country=this.#a.country.querySelector("select-ui"),this.#a.postalCode=this.#p("postalCode",{label:"Postal code",required:!0,area:"postal",input:{type:"text",inputmode:"text",autocomplete:"postal-code",placeholder:"94105",maxlength:12}}),this.#o.postalCode=this.#a.postalCode.querySelector("input-ui"),this.#a.addressLine1=this.#p("addressLine1",{label:"Address line 1",required:!1,area:"address1",input:{type:"text",autocomplete:"address-line1",placeholder:"123 Main St",maxlength:100}}),this.#o.addressLine1=this.#a.addressLine1.querySelector("input-ui"),this.#a.addressLine1.hidden=!0,this.#a.addressLine2=this.#p("addressLine2",{label:"Address line 2 (optional)",required:!1,area:"address2",input:{type:"text",autocomplete:"address-line2",placeholder:"Apt 4B",maxlength:100}}),this.#o.addressLine2=this.#a.addressLine2.querySelector("input-ui"),this.#a.addressLine2.hidden=!0;let l=document.createElement("div");l.setAttribute("data-legal",""),this.appendChild(l),this.#h=l;for(let h of[...this.children])h!==l&&h.getAttribute&&h.getAttribute("slot")==="legal"&&l.appendChild(h)}#p(t,e){let i=document.createElement("field-ui");i.setAttribute("label",e.label),e.required&&i.setAttribute("required",""),i.setAttribute("data-field",t),i.style.gridArea=e.area;let r;if(e.kind==="select"){if(r=document.createElement("select-ui"),Array.isArray(e.seedOptions))for(let n of e.seedOptions){let o=document.createElement("option");o.value=n.value,o.textContent=n.label,e.seedValue&&n.value===e.seedValue&&o.setAttribute("selected",""),r.appendChild(o)}}else r=document.createElement("input-ui");r.setAttribute("name",t),r.setAttribute("data-control",t),e.required&&r.setAttribute("required","");for(let[n,o]of Object.entries(e.input||{}))o==null||o===""||r.setAttribute(n,String(o));return i.appendChild(r),this.#n.appendChild(i),i}#m(){return(Array.isArray(this.countries)&&this.countries.length>0?this.countries:Oq).map(e=>({value:e,label:vq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=wd(n),a=Sd(o);a!==this.#l&&(this.#l=a,this.#x()),this.#b()};this.addEventListener("input",t),this.#e.push(()=>this.removeEventListener("input",t));let e=r=>{r.target!==this&&this.#b()};this.addEventListener("change",e),this.#e.push(()=>this.removeEventListener("change",e));let i=()=>{this.disabled||(this.removeAttribute("prefilled"),this.#s&&(this.#s.hidden=!0),this.#n&&(this.#n.hidden=!1))};this.#r.addEventListener("click",i),this.#r.addEventListener("press",i),this.#e.push(()=>{this.#r.removeEventListener("click",i),this.#r.removeEventListener("press",i)})}#b(){let t=wd(this.#o.cardNumber?.value),e=Sd(t),i=this.#k();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#y(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((r,n)=>r?.value===e[n].value&&r?.label===e[n].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#O(){let t=!!this.requireBillingAddress;this.#a.addressLine1&&(this.#a.addressLine1.hidden=!t),this.#a.addressLine2&&(this.#a.addressLine2.hidden=!t)}#S(){let t=!!this.disabled;for(let e of Object.values(this.#o))e&&(t?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}#v(){if(!this.#i)return;let t=this.error||"";t?(this.#i.setAttribute("text",t),this.#i.hidden=!1,this.setAttribute("aria-invalid","true")):(this.#i.removeAttribute("text"),this.#i.hidden=!0,this.removeAttribute("aria-invalid"))}#w(){if(!this.#s)return;let t=this.#C();if(!t||this.hasAttribute("prefilled-dismissed")){this.#s.hidden=!0,this.#n&&(this.#n.hidden=!1),this.removeAttribute("prefilled");return}let e=this.#s.querySelector(":scope > [data-summary-text]");if(e){let i=(t.brand||"Card").toUpperCase(),r=t.last4||"\u2022\u2022\u2022\u2022",n=t.expMonth&&t.expYear?` \xB7 expires ${String(t.expMonth).padStart(2,"0")}/${String(t.expYear).slice(-2)}`:"";e.textContent=`${i} ending in ${r}${n}`}this.#s.hidden=!1,this.#n&&(this.#n.hidden=!0),this.setAttribute("prefilled","")}#x(){let t=this.#o.cardNumber;if(!t)return;let e=t.querySelector(":scope > [data-brand-badge]");if(!e)return;if(this.#l==="unknown"||!this.#l){e.replaceChildren();return}let i=e.querySelector(":scope > [data-brand]");if(i&&i.getAttribute("data-brand")===this.#l)return;e.replaceChildren();let r=document.createElement("span");r.setAttribute("data-brand",this.#l),r.textContent=this.#l.toUpperCase(),e.appendChild(r)}#k(){let t=wd(this.#o.cardNumber?.value);return t?wE(t)?AE(this.#o.expiry?.value)?{ok:!1}:EE(this.#o.cvc?.value,Sd(t))?{ok:!1}:(this.#o.name?.value||"").trim()?(this.#o.postalCode?.value||"").trim()?{ok:!0}:{ok:!1}:{ok:!1}:{ok:!1}:{ok:!1}}#A(){for(let d of Object.values(this.#o))d?.removeAttribute?.("error");let t=String(this.#o.name?.value||"").trim();if(!t)return this.#o.name?.setAttribute("error","Name on card is required."),{ok:!1,message:"Name on card is required.",code:"validation-failed",field:"name"};let e=this.#o.cardNumber?.value||"",i=wd(e);if(!i)return this.#o.cardNumber?.setAttribute("error","Card number is required."),{ok:!1,message:"Card number is required.",code:"validation-failed",field:"cardNumber"};if(!wE(i))return this.#o.cardNumber?.setAttribute("error","Card number is invalid."),{ok:!1,message:"Card number is invalid.",code:"card-invalid",field:"cardNumber"};let r=AE(this.#o.expiry?.value||"");if(r){let d=r==="expiry-past"?"Card has expired.":r==="expiry-month"?"Expiry month must be 01-12.":r==="expiry-far"?"Expiry year is too far in the future.":"Expiry must be MM/YY.";return this.#o.expiry?.setAttribute("error",d),{ok:!1,message:d,code:r==="expiry-past"?"expired":"validation-failed",field:"expiry"}}let n=Sd(i);if(EE(this.#o.cvc?.value||"",n)){let f=`CVC must be ${n==="amex"?4:3} digits.`;return this.#o.cvc?.setAttribute("error",f),{ok:!1,message:f,code:"cvc-invalid",field:"cvc"}}let a=String(this.#o.country?.value||this.defaultCountry||"US");if(!String(this.#o.postalCode?.value||"").trim())return this.#o.postalCode?.setAttribute("error","Postal code is required."),{ok:!1,message:"Postal code is required.",code:"validation-failed",field:"postalCode"};if(this.requireBillingAddress&&!String(this.#o.addressLine1?.value||"").trim())return this.#o.addressLine1?.setAttribute("error","Address is required."),{ok:!1,message:"Address is required.",code:"validation-failed",field:"addressLine1"};let h=kE(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:n,expMonth:h.month,expYear:h.year,name:t,country:a}}}#C(){let t=this.prefill||this.getAttribute("prefill")||"";if(!t)return null;try{let e=JSON.parse(t);return!e||typeof e!="object"?null:e}catch{return null}}};customElements.get("payment-method-form-ui")||customElements.define("payment-method-form-ui",va);Ct();var xq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),CE=new Set(["card","bank","wallet"]),$E={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},Sq={card:"credit-card",bank:"bank",wallet:"credit-card"},PE={visa:"Visa",mastercard:"Mastercard",amex:"American Express",discover:"Discover",jcb:"JCB",unionpay:"UnionPay",diners:"Diners Club",paypal:"PayPal","apple-pay":"Apple Pay","google-pay":"Google Pay",ach:"Bank account",sepa:"SEPA"};function QE(s){let t=(s?.brand||"").toLowerCase();if($E[t])return $E[t];let e=(s?.type||"card").toLowerCase();return Sq[e]||"credit-card"}function TE(s){let t=(s?.brand||"").toLowerCase();if(PE[t])return PE[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function xO(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=TE(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function SO(s){let t=(s?.expiry||"").trim();if(!t)return"";let e="",i="",r=t.match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(r)e=r[1].padStart(2,"0"),i=r[2].length===4?r[2].slice(-2):r[2];else{let n=t.match(/^(\d{4})-(\d{2})-\d{2}$/);n&&(i=n[1].slice(-2),e=n[2])}return!e||!i?"":`Expires ${e}/${i}`}var xa=class extends M{static get properties(){return{...M.properties,methods:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},"add-label":{type:String,default:"Add payment method",attribute:"add-label"},"add-icon":{type:String,default:"plus",attribute:"add-icon"},"no-add":{type:Boolean,default:!1,reflect:!0,attribute:"no-add"},"no-remove":{type:Boolean,default:!1,reflect:!0,attribute:"no-remove"},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=new Map;#o=!1;setDefault(t){return t?F(()=>{let e=(this.methods||[]).find(r=>r.id===t);if(!e)return!1;if(this.value===t)return!0;let i=this.value||"";this.#o=!0;try{this.value=t}finally{this.#o=!1}return this.syncValue(),this.#m(t,i,e),!0}):!1}remove(t){return t?F(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(r=>r.id===t);if(i<0)return!1;if(e.splice(i,1),this.methods=e,this.value===t){let r=e[0]?.id||"";this.#o=!0;try{this.value=r}finally{this.#o=!1}this.syncValue()}return!0}):!1}add(t){!t||!t.id||F(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(r=>r.id===t.id);if(i>=0?e[i]=t:e.push(t),this.methods=e,t.default){let r=this.value||"";this.#o=!0;try{this.value=t.id}finally{this.#o=!1}this.syncValue(),r!==t.id&&this.#m(t.id,r,t)}})}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment methods"),this.#t||(this.#c(),this.#h(),this.#p(),this.#t=!0),F(()=>this.render())}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.methods)?this.methods:[],e=this.#l(t);if(e&&this.value!==e){this.#o=!0;try{this.value=e}finally{this.#o=!1}this.syncValue()}if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#r&&(this.#r.hidden=!!this["no-add"]),this.#n){this.#n.setAttribute("text",this["add-label"]||"Add payment method");let i=this["add-icon"]||"plus";i?this.#n.setAttribute("icon",i):this.#n.removeAttribute("icon"),this.disabled?this.#n.setAttribute("disabled",""):this.#n.removeAttribute("disabled")}this.#d(t)}#l(t){if(!t.length)return"";if(this.value&&t.some(i=>i.id===this.value))return this.value;let e=t.find(i=>i.default);return e?e.id:t[0].id||""}#c(){let t=this.querySelector(':scope > script[type="application/json"][data-methods]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.methods=e)}catch(e){console.warn("[payment-method-list-ui] failed to parse <script data-methods> JSON:",e?.message)}finally{t.remove()}}#h(){let t=document.createElement("div");if(t.setAttribute("data-rows",""),t.setAttribute("role","presentation"),this.appendChild(t),this.#i=t,!this.querySelector(':scope > [slot="empty"]')){let i=document.createElement("empty-state-ui");i.setAttribute("data-empty",""),i.setAttribute("icon","credit-card"),i.setAttribute("heading","No payment methods"),i.setAttribute("description","Add a method to get started."),this.appendChild(i),this.#s=i}let e=document.createElement("div");if(e.setAttribute("data-add",""),this.appendChild(e),this.#r=e,!this.querySelector(':scope > [slot="add"]')){let i=document.createElement("button-ui");i.setAttribute("data-add-cta",""),i.setAttribute("variant","outline"),i.setAttribute("icon",this["add-icon"]||"plus"),i.setAttribute("text",this["add-label"]||"Add payment method"),e.appendChild(i),this.#n=i}}#d(t){if(!this.#i)return;let e=new Map;for(let i of t){if(!i?.id)continue;let r=this.#a.get(i.id);r||(r=this.#u(i),this.#i.appendChild(r)),this.#f(r,i),e.set(i.id,r)}for(let[i,r]of this.#a)if(!e.has(i))try{r.remove()}catch{}for(let i of t){let r=e.get(i.id);r&&this.#i.appendChild(r)}this.#a=e}#u(t){let e=document.createElement("card-ui");e.setAttribute("data-row",""),e.setAttribute("role","radio"),e.setAttribute("tabindex","0");let i=document.createElement("header"),r=document.createElement("span");r.setAttribute("slot","icon");let n=document.createElement("icon-ui");n.setAttribute("aria-hidden","true"),r.appendChild(n);let o=document.createElement("span");o.setAttribute("slot","heading");let a=document.createElement("span");a.setAttribute("data-primary","");let l=document.createElement("tag-ui");l.setAttribute("data-default-tag",""),l.setAttribute("text","Default"),l.setAttribute("variant","success"),l.setAttribute("size","sm"),l.setAttribute("hidden",""),o.appendChild(a),o.appendChild(l);let h=document.createElement("p");h.setAttribute("slot","description"),h.setAttribute("data-secondary","");let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("button-ui");u.setAttribute("data-action","set-default"),u.setAttribute("variant","ghost"),u.setAttribute("size","sm"),u.setAttribute("text","Set default");let d=document.createElement("button-ui");d.setAttribute("data-action","edit"),d.setAttribute("variant","ghost"),d.setAttribute("size","sm"),d.setAttribute("icon","pencil"),d.setAttribute("aria-label","Edit payment method");let f=document.createElement("button-ui");return f.setAttribute("data-action","remove"),f.setAttribute("variant","ghost"),f.setAttribute("size","sm"),f.setAttribute("icon","trash"),f.setAttribute("aria-label","Remove payment method"),c.appendChild(u),c.appendChild(d),c.appendChild(f),i.appendChild(r),i.appendChild(o),i.appendChild(h),i.appendChild(c),e.appendChild(i),e}#f(t,e){t.setAttribute("data-id",e.id);let i=(e?.brand||"").toLowerCase();i?t.setAttribute("data-brand-key",i):t.removeAttribute("data-brand-key");let r=(e?.type||"card").toLowerCase();CE.has(r)&&t.setAttribute("data-type",r);let n=e.id===this.value;n?(t.setAttribute("data-default",""),t.setAttribute("aria-checked","true"),t.setAttribute("tabindex","0")):(t.removeAttribute("data-default"),t.setAttribute("aria-checked","false"),t.setAttribute("tabindex","-1")),this.disabled?t.setAttribute("aria-disabled","true"):t.removeAttribute("aria-disabled");let o=t.querySelector(':scope > header > [slot="icon"] > icon-ui');if(o){let m=QE(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=xO(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=SO(e);l.textContent=m,m?l.removeAttribute("hidden"):l.setAttribute("hidden","")}let h=t.querySelector(':scope > header > [slot="heading"] > [data-default-tag]');h&&(n?h.removeAttribute("hidden"):h.setAttribute("hidden",""));let c=SO(e),u=[xO(e)];c&&u.push(c),n&&u.push("default"),t.setAttribute("aria-label",u.join(", "));let d=t.querySelector(':scope > header > [slot="action"] > [data-action="set-default"]');d&&(n?d.setAttribute("hidden",""):d.removeAttribute("hidden"),this.disabled?d.setAttribute("disabled",""):d.removeAttribute("disabled"));let f=t.querySelector(':scope > header > [slot="action"] > [data-action="edit"]');f&&(this.disabled?f.setAttribute("disabled",""):f.removeAttribute("disabled"));let p=t.querySelector(':scope > header > [slot="action"] > [data-action="remove"]');p&&(this["no-remove"]?p.setAttribute("hidden",""):p.removeAttribute("hidden"),this.disabled?p.setAttribute("disabled",""):p.removeAttribute("disabled"))}#p(){let t=r=>{let n=r.target?.closest?.("button-ui[data-action]");if(n&&this.#i.contains(n)){let a=n.closest("[data-row]");if(!a)return;let l=a.getAttribute("data-id")||"";if(!l)return;if(this.disabled||n.hasAttribute("disabled")){r.stopPropagation();return}let h=(this.methods||[]).find(u=>u.id===l);if(!h)return;let c=n.getAttribute("data-action");r.stopPropagation(),c==="set-default"?this.setDefault(l):c==="remove"?this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{id:l,method:h}})):c==="edit"&&this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{id:l,method:h}}));return}let o=r.target?.closest?.("button-ui[data-add-cta]");if(o&&this.#r?.contains(o)){if(this.disabled||o.hasAttribute("disabled")){r.stopPropagation();return}r.stopPropagation(),this.dispatchEvent(new CustomEvent("add",{bubbles:!0,detail:{}}))}};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=r=>{if(r.target?.closest?.("button-ui[data-action]")||r.target?.closest?.("button-ui[data-add-cta]"))return;let n=r.target?.closest?.("[data-row]");if(!n||!this.#i.contains(n))return;let o=n.getAttribute("data-id")||"";o&&(this.disabled||this.setDefault(o))};this.#i.addEventListener("click",e),this.#e.push(()=>this.#i.removeEventListener("click",e));let i=r=>{let o=document.activeElement?.closest?.("[data-row]");if(!o||!this.#i.contains(o))return;let a=Array.from(this.#i.querySelectorAll(":scope > [data-row]")),l=a.indexOf(o);if(!(l<0)){if(r.key==="ArrowDown"||r.key==="ArrowRight")r.preventDefault(),a[(l+1)%a.length]?.focus?.();else if(r.key==="ArrowUp"||r.key==="ArrowLeft")r.preventDefault(),a[(l-1+a.length)%a.length]?.focus?.();else if(r.key==="Home")r.preventDefault(),a[0]?.focus?.();else if(r.key==="End")r.preventDefault(),a[a.length-1]?.focus?.();else if(r.key===" "||r.key==="Enter"){r.preventDefault();let h=o.getAttribute("data-id")||"";h&&!this.disabled&&this.setDefault(h)}}};this.#i.addEventListener("keydown",i),this.#e.push(()=>this.#i.removeEventListener("keydown",i))}#m(t,e,i){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,method:i}}))}};customElements.get("payment-method-list-ui")||customElements.define("payment-method-list-ui",xa);Ct();var kd=new Set(["monthly","annual"]),wq={monthly:"Monthly",annual:"Annual"},kq={monthly:"/month",annual:"/year"};function Aq(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function Eq(s,t,e){if(s.cta)return s.cta;if(!e)return`Choose ${s.name||""}`.trim();if(s.id===e)return"Manage";let i=t.find(r=>r.id===e);if(i&&Number.isFinite(i.rank)&&Number.isFinite(s.rank)){if(s.rank>i.rank)return"Upgrade";if(s.rank<i.rank)return"Downgrade"}return`Switch to ${s.name||""}`.trim()}var Sa=class extends M{static labelDeprecated=!0;static get properties(){return{...M.properties,plans:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},current:{type:String,default:"",reflect:!0},cycle:{type:String,default:"monthly",reflect:!0},cycleToggle:{type:Boolean,default:!1,reflect:!0,attribute:"cycle-toggle"},currency:{type:String,default:"USD"},locale:{type:String,default:""},layout:{type:String,default:"grid",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=new Map;#l=!1;#c=!1;#h=!1;#d=0;setValue(t){return t?F(()=>{let e=(this.plans||[]).find(r=>r.id===t);if(!e)return!1;if(e.disabled)return this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}})),!1;if(this.value===t)return!0;let i=this.value||"";return this.value=t,this.syncValue(),this.#O(t,i),!0}):!1}setCycle(t){return kd.has(t)?F(()=>{if(this.cycle===t)return!0;let e=this.cycle;return this.cycle=t,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:t,previous:e}})),!0}):!1}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#d;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#d)return;this.removeAttribute("loading");let n=Array.isArray(r)?r:Array.isArray(r?.plans)?r.plans:[];this.plans=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:n.length}}))}catch(i){if(e!==this.#d)return;this.removeAttribute("loading"),this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Choose a plan"),this.#t||(this.#u(),this.#f(),this.#y(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#l)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.plans)?this.plans:[];if(!kd.has(this.cycle)){this.#c||(this.#c=!0,console.warn(`[plan-picker-ui] unknown cycle "${this.cycle}" \u2014 coercing to "monthly".`)),this.#l=!0;try{this.cycle="monthly"}finally{this.#l=!1}}let e=t.filter(r=>r.recommended);e.length>1&&!this.#h&&(this.#h=!0,console.warn(`[plan-picker-ui] ${e.length} plans carry recommended:true \u2014 using the first ("${e[0].id}"); ignoring the rest.`));let i=e[0]?.id||"";if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#i){let r=this.cycleToggle&&t.length>0;this.#i.hidden=!r,r&&this.#p()}this.#m(t,i)}#u(){let t=this.querySelector(':scope > script[type="application/json"][data-plans]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.plans=e)}catch(e){console.warn("[plan-picker-ui] failed to parse <script data-plans> JSON:",e?.message)}finally{t.remove()}}#f(){let t=document.createElement("div");t.setAttribute("data-toggle",""),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-plans",""),e.setAttribute("role","presentation"),this.appendChild(e),this.#r=e;let i=document.createElement("div");if(i.setAttribute("data-skeleton",""),i.hidden=!0,this.appendChild(i),this.#n=i,!this.querySelector(':scope > [slot="empty"]')){let r=document.createElement("empty-state-ui");r.setAttribute("data-empty",""),r.setAttribute("icon","package"),r.setAttribute("heading","No plans available"),r.setAttribute("description","Plans will appear here once configured."),this.appendChild(r),this.#a=r}}#p(){if(!this.#i)return;let t=this.#s;if(!t){t=document.createElement("segmented-ui"),t.setAttribute("aria-label","Billing cycle"),this.#i.appendChild(t),this.#s=t;for(let e of["monthly","annual"]){let i=document.createElement("segment-ui");i.setAttribute("value",e),i.setAttribute("text",wq[e]),t.appendChild(i)}}t.value!==this.cycle&&(t.value=this.cycle)}#m(t,e){if(!this.#r)return;let i=new Map;for(let r of t){if(!r?.id)continue;let n=this.#o.get(r.id);n||(n=document.createElement("option-card-ui"),n.setAttribute("layout","tile"),this.#r.appendChild(n)),this.#g(n,r,e),i.set(r.id,n)}for(let[r,n]of this.#o)if(!i.has(r))try{n.remove()}catch{}for(let r of t){let n=i.get(r.id);n&&this.#r.appendChild(n)}this.#o=i}#g(t,e,i){t.setAttribute("name",`${this.name||"plan"}__${this.id||"pp"}`),t.setAttribute("value",e.id),t.setAttribute("heading",e.name||""),t.setAttribute("description",e.tagline||""),e.icon?t.setAttribute("icon",e.icon):t.removeAttribute("icon");let r=!!(this.current&&e.id===this.current),n=e.id===i;r?t.setAttribute("data-current",""):t.removeAttribute("data-current"),n?t.setAttribute("data-recommended",""):t.removeAttribute("data-recommended"),e.disabled||this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.value&&this.value===e.id||!this.value&&r?t.setAttribute("checked",""):t.removeAttribute("checked");let a=t.querySelector(":scope > [data-plan-body]");a||(a=document.createElement("div"),a.setAttribute("data-plan-body",""),t.appendChild(a)),this.#b(a,e);let l=t.querySelector(":scope > [data-plan-tags]");if(l||(l=document.createElement("div"),l.setAttribute("data-plan-tags",""),l.setAttribute("slot","heading-suffix"),t.appendChild(l)),l.replaceChildren(),r){let h=document.createElement("tag-ui");h.setAttribute("text","Current plan"),h.setAttribute("variant","muted"),l.appendChild(h)}else if(n){let h=document.createElement("tag-ui");h.setAttribute("text","Recommended"),h.setAttribute("variant","accent"),l.appendChild(h)}}#b(t,e){t.replaceChildren();let i=document.createElement("div");i.setAttribute("data-price-row","");let r=kd.has(this.cycle)?this.cycle:"monthly",n=e.prices||{},o=n[r]||n.monthly||null;if(o){let l=document.createElement("span");l.setAttribute("data-price","");let h=o.currency||this.currency||"USD";l.textContent=Aq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:kq[r];c.textContent=u,i.appendChild(c)}else{let l=document.createElement("span");l.setAttribute("data-price",""),l.textContent="Contact sales",i.appendChild(l)}if(t.appendChild(i),o?.note){let l=document.createElement("span");l.setAttribute("data-price-note",""),l.textContent=o.note,t.appendChild(l)}if(Array.isArray(e.features)&&e.features.length){let l=document.createElement("ul");l.setAttribute("data-features","");for(let h of e.features){let c=document.createElement("li"),u=document.createElement("icon-ui");u.setAttribute("name","check"),u.setAttribute("aria-hidden","true"),c.appendChild(u);let d=document.createElement("span");d.textContent=String(h),c.appendChild(d),l.appendChild(c)}t.appendChild(l)}if(!!!(this.current&&e.id===this.current)||e.cta){let l=document.createElement("button-ui");l.setAttribute("data-cta",""),l.setAttribute("variant",e.recommended?"primary":"outline"),l.setAttribute("text",Eq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#y(){let t=r=>{let n=r?.detail?.value;if(!kd.has(n)||this.cycle===n)return;r.stopPropagation();let o=this.cycle;this.cycle=n,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:n,previous:o}}))};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=r=>{let n=r.target?.closest?.("option-card-ui");if(!n||!this.#r.contains(n))return;let o=n.getAttribute("value")||"";if(!o)return;let a=(this.plans||[]).find(h=>h.id===o);if(!a)return;if(a.disabled||this.disabled){n.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}}));return}r.stopPropagation();let l=this.value||"";if(l!==o){this.#l=!0;try{this.value=o}finally{this.#l=!1}this.syncValue(),this.#O(o,l)}};this.#r.addEventListener("change",e),this.#e.push(()=>this.#r.removeEventListener("change",e));let i=r=>{let n=r.target?.closest?.("button-ui[data-cta]");if(!n||!this.#r.contains(n))return;let o=n.closest("option-card-ui");if(!o)return;let a=o.getAttribute("value")||"";if(!a)return;let l=(this.plans||[]).find(c=>c.id===a);if(!l||l.disabled||this.disabled)return;r.stopPropagation();let h=this.value||"";if(h!==a){this.#l=!0;try{this.value=a}finally{this.#l=!1}this.syncValue(),this.#O(a,h)}this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:a,cycle:this.cycle}}))};this.#r.addEventListener("press",i),this.#r.addEventListener("click",i),this.#e.push(()=>this.#r.removeEventListener("press",i)),this.#e.push(()=>this.#r.removeEventListener("click",i))}#O(t,e){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,cycle:this.cycle}}))}};customElements.get("plan-picker-ui")||customElements.define("plan-picker-ui",Sa);$();var Cq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),$q=6,lh=class extends x{static properties={integrations:{type:Array,default:[]},loading:{type:Boolean,default:!1,reflect:!0},"search-placeholder":{type:String,default:"Search integrations",reflect:!0},"group-by":{type:String,default:"category",reflect:!0},"status-filter":{type:String,default:"all",reflect:!0}};static template=t=>t._renderTemplate();#t="";#e=`intpage-h-${Math.random().toString(36).slice(2,8)}`;#i=null;attributeChangedCallback(t,e,i){if(t==="integrations"){if(i==null)this.integrations=[];else try{let r=JSON.parse(i);this.integrations=Array.isArray(r)?r:[]}catch{this.integrations=[]}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#e),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Integrations"),this.hasAttribute("integrations")&&!Array.isArray(this.integrations))try{this.integrations=JSON.parse(this.getAttribute("integrations"))}catch{this.integrations=[]}this.addEventListener("input",this.#d),this.addEventListener("change",this.#u)}disconnected(){this.removeEventListener("input",this.#d),this.removeEventListener("change",this.#u),this.#i&&(clearTimeout(this.#i),this.#i=null)}render(){this.#h(),this.querySelector('segmented-ui[data-part="filter"]')?.render?.()}_renderTemplate(){let t=this["search-placeholder"]||"Search integrations",e=this["status-filter"]||"all",i=!!this.loading,r=this.#l();return it`
445
445
  <header data-part="header">
446
446
  <h2 data-part="title" id=${this.#e}>Integrations</h2>
447
447
  <slot name="header"></slot>
@@ -513,4 +513,4 @@ Correct shape for <chart-ui x="label" y="value">:
513
513
  <text-ui data-part="empty-description" variant="body" color="subtle">${e?"Try a different keyword or clear the search.":"Integrations will appear here once they are available."}</text-ui>
514
514
  </slot>
515
515
  </div>
516
- `}#l(){let t=Array.isArray(this.integrations)?this.integrations:[],e=(this.#t||"").trim().toLowerCase(),i=this["status-filter"]||"all",r=t.filter(l=>!(!l||typeof l!="object"||i!=="all"&&String(l.status??"available")!==i||e&&![l.name,l.description,l.provider,l.category].map(c=>String(c??"").toLowerCase()).join(" ").includes(e))),n=this["group-by"]||"category";if(n==="none")return[{key:"__none__",label:"",items:r}];let o=[],a=new Map;for(let l of r){let c=String(n==="status"?l.status??"available":l.category??"Other")||"Other";a.has(c)||(a.set(c,[]),o.push(c)),a.get(c).push(l)}return o.map(l=>({key:l,label:n==="status"?this.#c(l):l,items:a.get(l)}))}#c(t){switch(t){case"available":return"Available";case"connected":return"Connected";case"error":return"Issues";case"pending":return"Connecting";case"coming-soon":return"Coming soon";default:return t||"Other"}}#h(){let t=Array.isArray(this.integrations)?this.integrations:[],i=this.#l().reduce((r,n)=>r+n.items.length,0);if(this.loading){this.removeAttribute("data-empty-search"),this.removeAttribute("data-empty-data");return}i===0&&t.length>0?(this.setAttribute("data-empty-search",""),this.removeAttribute("data-empty-data")):t.length===0?(this.setAttribute("data-empty-data",""),this.removeAttribute("data-empty-search")):(this.removeAttribute("data-empty-search"),this.removeAttribute("data-empty-data"))}#u=t=>{let e=t.target;if(!e||!e.closest)return;let i=e.closest('search-ui[data-part="search"]');if(!i||!this.contains(i))return;let r=String(t.detail?.value??i.value??"");this.#t=r,this.integrations=Array.isArray(this.integrations)?[...this.integrations]:[],this.#i&&clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{query:r.toLowerCase().trim()}}))},250)};#d=t=>{let e=t.target;if(!e||!e.closest)return;let i=e.closest('segmented-ui[data-part="filter"]');if(!i||!this.contains(i))return;let r=String(t.detail?.value??i.value??"all");this["status-filter"]!==r&&(this["status-filter"]=r,this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{status:r}})))}};customElements.get("integrations-page-ui")||customElements.define("integrations-page-ui",lh);Ct();var hh=class extends M{static get properties(){return{...M.properties,preferences:{type:Array,default:[]},channels:{type:Array,default:[]},channelEnabled:{type:Object,default:{}},loading:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},"group-by":{type:String,default:"none",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=new Map;#c=new Map;#h=new Map;#u=new Map;#d=new Map;#f=!1;#p=`np-h-${Math.random().toString(36).slice(2,8)}`;attributeChangedCallback(t,e,i){if(t==="preferences"||t==="channels"||t==="channelenabled"){let r=t==="channelenabled"?"channelEnabled":t;if(i==null)this[r]=r==="channelEnabled"?{}:[];else try{let n=JSON.parse(i);r==="channelEnabled"?this[r]=n&&typeof n=="object"&&!Array.isArray(n)?n:{}:this[r]=Array.isArray(n)?n:[]}catch{this[r]=r==="channelEnabled"?{}:[]}return}super.attributeChangedCallback?.(t,e,i)}connected(){if(super.connected(),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Notification preferences"),this.setAttribute("role","region"),!this.#t){if(this.hasAttribute("preferences")&&!Array.isArray(this.preferences))try{this.preferences=JSON.parse(this.getAttribute("preferences"))}catch{this.preferences=[]}if(this.hasAttribute("channels")&&!Array.isArray(this.channels))try{this.channels=JSON.parse(this.getAttribute("channels"))}catch{this.channels=[]}if(this.hasAttribute("channelenabled")&&(typeof this.channelEnabled!="object"||Array.isArray(this.channelEnabled)))try{this.channelEnabled=JSON.parse(this.getAttribute("channelenabled"))}catch{this.channelEnabled={}}this.#m(),this.#S(),this.#t=!0}F(()=>this.render())}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(){let t={preferences:Array.isArray(this.preferences)?this.preferences:[],channelEnabled:this.channelEnabled&&typeof this.channelEnabled=="object"?this.channelEnabled:{}},e=JSON.stringify(t);this.value=e,this.internals.setFormValue(e)}render(){if(!this.#t)return;let t=Array.isArray(this.channels)?this.channels:[],e=Array.isArray(this.preferences)?this.preferences:[];e.length===0||t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.style.setProperty("--np-columns",`repeat(${Math.max(t.length,1)}, minmax(var(--notification-preferences-channel-width, var(--notification-preferences-channel-width-default)), auto))`),this.#g(t),(this["group-by"]||"none")==="group"?this.#y(e,t):this.#O(e,t),this.syncValue()}#m(){let t=document.createElement("div");t.setAttribute("data-part","header");let e=document.createElement("slot");e.setAttribute("name","header"),t.appendChild(e),this.appendChild(t),this.#i=t;let i=document.createElement("div");i.setAttribute("data-part","matrix"),i.setAttribute("role","table"),i.setAttribute("aria-labelledby",this.#p),this.appendChild(i),this.#s=i;let r=document.createElement("div");r.setAttribute("data-part","header-row"),r.setAttribute("role","row"),i.appendChild(r),this.#r=r;let n=document.createElement("div");n.setAttribute("data-part","body"),i.appendChild(n),this.#n=n;let o=document.createElement("div");o.setAttribute("data-part","empty");let a=document.createElement("slot");a.setAttribute("name","empty");let l=document.createElement("empty-state-ui");l.setAttribute("icon","bell"),l.setAttribute("heading","No notification types configured"),l.setAttribute("description","Add at least one notification type and one delivery channel to begin."),a.appendChild(l),o.appendChild(a),this.appendChild(o),this.#a=o;let h=document.createElement("div");h.setAttribute("data-part","footer");let c=document.createElement("slot");c.setAttribute("name","footer"),h.appendChild(c),this.appendChild(h),this.#o=h}#g(t){if(!this.#r)return;let e=this.#r.querySelector(":scope > [data-row-label]");e||(e=document.createElement("div"),e.setAttribute("role","columnheader"),e.setAttribute("data-row-label",""),e.id=this.#p,e.textContent="Notification",this.#r.appendChild(e));let i=new Set;for(let r of t){if(!r?.key)continue;i.add(r.key);let n=this.#h.get(r.key);n||(n=document.createElement("div"),n.setAttribute("role","columnheader"),n.setAttribute("data-channel-key",r.key),this.#r.appendChild(n),this.#h.set(r.key,n)),this.#b(n,r)}for(let[r,n]of this.#h)if(!i.has(r)){try{n.remove()}catch{}this.#h.delete(r),this.#u.delete(r)}for(let r of t){let n=this.#h.get(r.key);n&&this.#r.appendChild(n)}}#b(t,e){if(t.replaceChildren(),e.icon){let a=document.createElement("icon-ui");a.setAttribute("name",String(e.icon)),a.setAttribute("aria-hidden","true"),t.appendChild(a)}let i=document.createElement("span");i.setAttribute("data-channel-label",""),i.textContent=String(e.label||e.key),t.appendChild(i);let r=this.#u.get(e.key);r||(r=document.createElement("switch-ui"),r.setAttribute("size","sm"),r.setAttribute("data-channel-master",e.key),this.#u.set(e.key,r));let n=this.channelEnabled&&typeof this.channelEnabled=="object"?this.channelEnabled:{},o=Object.prototype.hasOwnProperty.call(n,e.key)?!!n[e.key]:!0;if(r.checked!==o){this.#f=!0;try{r.checked=o}finally{this.#f=!1}}r.setAttribute("aria-label",`Toggle ${e.label||e.key} for all rows`),this.disabled||this.loading?r.setAttribute("disabled",""):r.removeAttribute("disabled"),t.appendChild(r)}#O(t,e){if(!this.#n)return;for(let[,n]of this.#d)try{n.remove()}catch{}this.#d.clear();let i=new Set,r=new Set;for(let n of t){if(!n?.key)continue;i.add(n.key);let o=this.#w(n);this.#v(o,n,e,r)}for(let[n,o]of this.#l)if(!i.has(n)){try{o.remove()}catch{}this.#l.delete(n)}for(let[n,o]of this.#c)if(!r.has(n)){try{o.remove()}catch{}this.#c.delete(n)}for(let n of t){let o=this.#l.get(n.key);o&&this.#n.appendChild(o)}}#y(t,e){if(!this.#n)return;let i=[],r=new Map;for(let l of t){let h=String(l?.group??"Other")||"Other";r.has(h)||(r.set(h,[]),i.push(h)),r.get(h).push(l)}let n=new Set,o=new Set,a=new Set;for(let l of i){n.add(l);let h=this.#d.get(l);h||(h=document.createElement("div"),h.setAttribute("data-part","group-heading"),h.setAttribute("data-group",l),h.setAttribute("role","rowgroup"),this.#d.set(l,h)),h.textContent=l,this.#n.appendChild(h);for(let c of r.get(l)){if(!c?.key)continue;o.add(c.key);let u=this.#w(c);this.#v(u,c,e,a),this.#n.appendChild(u)}}for(let[l,h]of this.#l)if(!o.has(l)){try{h.remove()}catch{}this.#l.delete(l)}for(let[l,h]of this.#c)if(!a.has(l)){try{h.remove()}catch{}this.#c.delete(l)}for(let[l,h]of this.#d)if(!n.has(l)){try{h.remove()}catch{}this.#d.delete(l)}}#w(t){let e=this.#l.get(t.key);return e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-row-key",t.key),this.#n.appendChild(e),this.#l.set(t.key,e)),e}#v(t,e,i,r){let n=t.querySelector(':scope > [role="rowheader"]');n||(n=document.createElement("div"),n.setAttribute("role","rowheader"),t.appendChild(n)),n.replaceChildren();let o=document.createElement("span");if(o.setAttribute("data-row-label-text",""),o.textContent=String(e.label||e.key),n.appendChild(o),e.description){let l=document.createElement("span");l.setAttribute("data-row-description",""),l.textContent=String(e.description),n.appendChild(l)}let a=e.channels&&typeof e.channels=="object"?e.channels:{};for(let l of i){if(!l?.key)continue;let h=`${e.key}::${l.key}`;r.add(h);let c=t.querySelector(`:scope > [data-cell-key="${CSS.escape(h)}"]`);c||(c=document.createElement("div"),c.setAttribute("role","cell"),c.setAttribute("data-cell-key",h),t.appendChild(c));let u=this.#c.get(h);u||(u=document.createElement("check-ui"),u.setAttribute("data-row-key",e.key),u.setAttribute("data-channel-key",l.key),c.appendChild(u),this.#c.set(h,u));let d=!!a[l.key];if(u.checked!==d){this.#f=!0;try{u.checked=d}finally{this.#f=!1}}u.setAttribute("aria-label",`${e.label||e.key} via ${l.label||l.key}`),!!this.disabled||!!this.loading||!!e.disabled?u.setAttribute("disabled",""):u.removeAttribute("disabled")}for(let l of i){let h=`${e.key}::${l.key}`,c=t.querySelector(`:scope > [data-cell-key="${CSS.escape(h)}"]`);c&&t.appendChild(c)}}#S(){let t=e=>{if(this.#f)return;let i=e?.target;if(!i)return;let r=i.closest?.("switch-ui[data-channel-master]");if(r&&this.#s.contains(r)){let o=r.getAttribute("data-channel-master")||"";if(!o||this.disabled||this.loading)return;e.stopPropagation();let a=!!r.checked;this.dispatchEvent(new CustomEvent("bulk-toggle",{bubbles:!0,detail:{channel:o,enabled:a}}));return}let n=i.closest?.("check-ui[data-row-key][data-channel-key]");if(n&&this.#n.contains(n)){let o=n.getAttribute("data-row-key")||"",a=n.getAttribute("data-channel-key")||"";if(!o||!a||this.disabled||this.loading)return;e.stopPropagation();let l=!!n.checked;this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{row:o,channel:a,enabled:l}}));return}};this.#s.addEventListener("change",t),this.#e.push(()=>this.#s.removeEventListener("change",t))}};customElements.get("notification-preferences-ui")||customElements.define("notification-preferences-ui",hh);export{na as A2UIRoot,Ul as AdminCommand,jl as AdminShell,Wl as AdminSidebar,Hl as ChatComposer,Fl as ChatShell,Kl as ChatSidebar,Yl as ChatThread,vd as ConfirmDialog,eh as EditorCanvas,Jl as EditorShell,sh as EditorSidebar,th as EditorToolbar,gd as GenRoot,Oa as InvoiceHistory,xa as PaymentMethodList,Sa as PlanPicker,rh as SimpleShell,nh as ThemePanel,ba as UIBillingOverview,bd as UIDashboardLayout,yd as UIDateRangeSelector,lh as UIIntegrationsPage,ya as UIInvoiceDetail,hh as UINotificationPreferences,oh as UIOnboardingChecklist,va as UIPaymentMethodForm,eq as isFocusInInput};
516
+ `}#l(){let t=Array.isArray(this.integrations)?this.integrations:[],e=(this.#t||"").trim().toLowerCase(),i=this["status-filter"]||"all",r=t.filter(l=>!(!l||typeof l!="object"||i!=="all"&&String(l.status??"available")!==i||e&&![l.name,l.description,l.provider,l.category].map(c=>String(c??"").toLowerCase()).join(" ").includes(e))),n=this["group-by"]||"category";if(n==="none")return[{key:"__none__",label:"",items:r}];let o=[],a=new Map;for(let l of r){let c=String(n==="status"?l.status??"available":l.category??"Other")||"Other";a.has(c)||(a.set(c,[]),o.push(c)),a.get(c).push(l)}return o.map(l=>({key:l,label:n==="status"?this.#c(l):l,items:a.get(l)}))}#c(t){switch(t){case"available":return"Available";case"connected":return"Connected";case"error":return"Issues";case"pending":return"Connecting";case"coming-soon":return"Coming soon";default:return t||"Other"}}#h(){let t=Array.isArray(this.integrations)?this.integrations:[],i=this.#l().reduce((r,n)=>r+n.items.length,0);if(this.loading){this.removeAttribute("data-empty-search"),this.removeAttribute("data-empty-data");return}i===0&&t.length>0?(this.setAttribute("data-empty-search",""),this.removeAttribute("data-empty-data")):t.length===0?(this.setAttribute("data-empty-data",""),this.removeAttribute("data-empty-search")):(this.removeAttribute("data-empty-search"),this.removeAttribute("data-empty-data"))}#d=t=>{let e=t.target;if(!e||!e.closest)return;let i=e.closest('search-ui[data-part="search"]');if(!i||!this.contains(i))return;let r=String(t.detail?.value??i.value??"");this.#t=r,this.integrations=Array.isArray(this.integrations)?[...this.integrations]:[],this.#i&&clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{query:r.toLowerCase().trim()}}))},250)};#u=t=>{let e=t.target;if(!e||!e.closest)return;let i=e.closest('segmented-ui[data-part="filter"]');if(!i||!this.contains(i))return;let r=String(t.detail?.value??i.value??"all");this["status-filter"]!==r&&(this["status-filter"]=r,this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{status:r}})))}};customElements.get("integrations-page-ui")||customElements.define("integrations-page-ui",lh);Ct();var hh=class extends M{static get properties(){return{...M.properties,preferences:{type:Array,default:[]},channels:{type:Array,default:[]},channelEnabled:{type:Object,default:{}},loading:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},"group-by":{type:String,default:"none",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=new Map;#c=new Map;#h=new Map;#d=new Map;#u=new Map;#f=!1;#p=`np-h-${Math.random().toString(36).slice(2,8)}`;attributeChangedCallback(t,e,i){if(t==="preferences"||t==="channels"||t==="channelenabled"){let r=t==="channelenabled"?"channelEnabled":t;if(i==null)this[r]=r==="channelEnabled"?{}:[];else try{let n=JSON.parse(i);r==="channelEnabled"?this[r]=n&&typeof n=="object"&&!Array.isArray(n)?n:{}:this[r]=Array.isArray(n)?n:[]}catch{this[r]=r==="channelEnabled"?{}:[]}return}super.attributeChangedCallback?.(t,e,i)}connected(){if(super.connected(),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Notification preferences"),this.setAttribute("role","region"),!this.#t){if(this.hasAttribute("preferences")&&!Array.isArray(this.preferences))try{this.preferences=JSON.parse(this.getAttribute("preferences"))}catch{this.preferences=[]}if(this.hasAttribute("channels")&&!Array.isArray(this.channels))try{this.channels=JSON.parse(this.getAttribute("channels"))}catch{this.channels=[]}if(this.hasAttribute("channelenabled")&&(typeof this.channelEnabled!="object"||Array.isArray(this.channelEnabled)))try{this.channelEnabled=JSON.parse(this.getAttribute("channelenabled"))}catch{this.channelEnabled={}}this.#m(),this.#w(),this.#t=!0}F(()=>this.render())}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(){let t={preferences:Array.isArray(this.preferences)?this.preferences:[],channelEnabled:this.channelEnabled&&typeof this.channelEnabled=="object"?this.channelEnabled:{}},e=JSON.stringify(t);this.value=e,this.internals.setFormValue(e)}render(){if(!this.#t)return;let t=Array.isArray(this.channels)?this.channels:[],e=Array.isArray(this.preferences)?this.preferences:[];e.length===0||t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.style.setProperty("--np-columns",`repeat(${Math.max(t.length,1)}, minmax(var(--notification-preferences-channel-width, var(--notification-preferences-channel-width-default)), auto))`),this.#g(t),(this["group-by"]||"none")==="group"?this.#O(e,t):this.#y(e,t),this.syncValue()}#m(){let t=document.createElement("div");t.setAttribute("data-part","header");let e=document.createElement("slot");e.setAttribute("name","header"),t.appendChild(e),this.appendChild(t),this.#i=t;let i=document.createElement("div");i.setAttribute("data-part","matrix"),i.setAttribute("role","table"),i.setAttribute("aria-labelledby",this.#p),this.appendChild(i),this.#s=i;let r=document.createElement("div");r.setAttribute("data-part","header-row"),r.setAttribute("role","row"),i.appendChild(r),this.#r=r;let n=document.createElement("div");n.setAttribute("data-part","body"),i.appendChild(n),this.#n=n;let o=document.createElement("div");o.setAttribute("data-part","empty");let a=document.createElement("slot");a.setAttribute("name","empty");let l=document.createElement("empty-state-ui");l.setAttribute("icon","bell"),l.setAttribute("heading","No notification types configured"),l.setAttribute("description","Add at least one notification type and one delivery channel to begin."),a.appendChild(l),o.appendChild(a),this.appendChild(o),this.#a=o;let h=document.createElement("div");h.setAttribute("data-part","footer");let c=document.createElement("slot");c.setAttribute("name","footer"),h.appendChild(c),this.appendChild(h),this.#o=h}#g(t){if(!this.#r)return;let e=this.#r.querySelector(":scope > [data-row-label]");e||(e=document.createElement("div"),e.setAttribute("role","columnheader"),e.setAttribute("data-row-label",""),e.id=this.#p,e.textContent="Notification",this.#r.appendChild(e));let i=new Set;for(let r of t){if(!r?.key)continue;i.add(r.key);let n=this.#h.get(r.key);n||(n=document.createElement("div"),n.setAttribute("role","columnheader"),n.setAttribute("data-channel-key",r.key),this.#r.appendChild(n),this.#h.set(r.key,n)),this.#b(n,r)}for(let[r,n]of this.#h)if(!i.has(r)){try{n.remove()}catch{}this.#h.delete(r),this.#d.delete(r)}for(let r of t){let n=this.#h.get(r.key);n&&this.#r.appendChild(n)}}#b(t,e){if(t.replaceChildren(),e.icon){let a=document.createElement("icon-ui");a.setAttribute("name",String(e.icon)),a.setAttribute("aria-hidden","true"),t.appendChild(a)}let i=document.createElement("span");i.setAttribute("data-channel-label",""),i.textContent=String(e.label||e.key),t.appendChild(i);let r=this.#d.get(e.key);r||(r=document.createElement("switch-ui"),r.setAttribute("size","sm"),r.setAttribute("data-channel-master",e.key),this.#d.set(e.key,r));let n=this.channelEnabled&&typeof this.channelEnabled=="object"?this.channelEnabled:{},o=Object.prototype.hasOwnProperty.call(n,e.key)?!!n[e.key]:!0;if(r.checked!==o){this.#f=!0;try{r.checked=o}finally{this.#f=!1}}r.setAttribute("aria-label",`Toggle ${e.label||e.key} for all rows`),this.disabled||this.loading?r.setAttribute("disabled",""):r.removeAttribute("disabled"),t.appendChild(r)}#y(t,e){if(!this.#n)return;for(let[,n]of this.#u)try{n.remove()}catch{}this.#u.clear();let i=new Set,r=new Set;for(let n of t){if(!n?.key)continue;i.add(n.key);let o=this.#S(n);this.#v(o,n,e,r)}for(let[n,o]of this.#l)if(!i.has(n)){try{o.remove()}catch{}this.#l.delete(n)}for(let[n,o]of this.#c)if(!r.has(n)){try{o.remove()}catch{}this.#c.delete(n)}for(let n of t){let o=this.#l.get(n.key);o&&this.#n.appendChild(o)}}#O(t,e){if(!this.#n)return;let i=[],r=new Map;for(let l of t){let h=String(l?.group??"Other")||"Other";r.has(h)||(r.set(h,[]),i.push(h)),r.get(h).push(l)}let n=new Set,o=new Set,a=new Set;for(let l of i){n.add(l);let h=this.#u.get(l);h||(h=document.createElement("div"),h.setAttribute("data-part","group-heading"),h.setAttribute("data-group",l),h.setAttribute("role","rowgroup"),this.#u.set(l,h)),h.textContent=l,this.#n.appendChild(h);for(let c of r.get(l)){if(!c?.key)continue;o.add(c.key);let u=this.#S(c);this.#v(u,c,e,a),this.#n.appendChild(u)}}for(let[l,h]of this.#l)if(!o.has(l)){try{h.remove()}catch{}this.#l.delete(l)}for(let[l,h]of this.#c)if(!a.has(l)){try{h.remove()}catch{}this.#c.delete(l)}for(let[l,h]of this.#u)if(!n.has(l)){try{h.remove()}catch{}this.#u.delete(l)}}#S(t){let e=this.#l.get(t.key);return e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-row-key",t.key),this.#n.appendChild(e),this.#l.set(t.key,e)),e}#v(t,e,i,r){let n=t.querySelector(':scope > [role="rowheader"]');n||(n=document.createElement("div"),n.setAttribute("role","rowheader"),t.appendChild(n)),n.replaceChildren();let o=document.createElement("span");if(o.setAttribute("data-row-label-text",""),o.textContent=String(e.label||e.key),n.appendChild(o),e.description){let l=document.createElement("span");l.setAttribute("data-row-description",""),l.textContent=String(e.description),n.appendChild(l)}let a=e.channels&&typeof e.channels=="object"?e.channels:{};for(let l of i){if(!l?.key)continue;let h=`${e.key}::${l.key}`;r.add(h);let c=t.querySelector(`:scope > [data-cell-key="${CSS.escape(h)}"]`);c||(c=document.createElement("div"),c.setAttribute("role","cell"),c.setAttribute("data-cell-key",h),t.appendChild(c));let u=this.#c.get(h);u||(u=document.createElement("check-ui"),u.setAttribute("data-row-key",e.key),u.setAttribute("data-channel-key",l.key),c.appendChild(u),this.#c.set(h,u));let d=!!a[l.key];if(u.checked!==d){this.#f=!0;try{u.checked=d}finally{this.#f=!1}}u.setAttribute("aria-label",`${e.label||e.key} via ${l.label||l.key}`),!!this.disabled||!!this.loading||!!e.disabled?u.setAttribute("disabled",""):u.removeAttribute("disabled")}for(let l of i){let h=`${e.key}::${l.key}`,c=t.querySelector(`:scope > [data-cell-key="${CSS.escape(h)}"]`);c&&t.appendChild(c)}}#w(){let t=e=>{if(this.#f)return;let i=e?.target;if(!i)return;let r=i.closest?.("switch-ui[data-channel-master]");if(r&&this.#s.contains(r)){let o=r.getAttribute("data-channel-master")||"";if(!o||this.disabled||this.loading)return;e.stopPropagation();let a=!!r.checked;this.dispatchEvent(new CustomEvent("bulk-toggle",{bubbles:!0,detail:{channel:o,enabled:a}}));return}let n=i.closest?.("check-ui[data-row-key][data-channel-key]");if(n&&this.#n.contains(n)){let o=n.getAttribute("data-row-key")||"",a=n.getAttribute("data-channel-key")||"";if(!o||!a||this.disabled||this.loading)return;e.stopPropagation();let l=!!n.checked;this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{row:o,channel:a,enabled:l}}));return}};this.#s.addEventListener("change",t),this.#e.push(()=>this.#s.removeEventListener("change",t))}};customElements.get("notification-preferences-ui")||customElements.define("notification-preferences-ui",hh);export{na as A2UIRoot,Ul as AdminCommand,jl as AdminShell,Wl as AdminSidebar,Hl as ChatComposer,Fl as ChatShell,Kl as ChatSidebar,Yl as ChatThread,vd as ConfirmDialog,eh as EditorCanvas,Jl as EditorShell,sh as EditorSidebar,th as EditorToolbar,gd as GenRoot,Oa as InvoiceHistory,xa as PaymentMethodList,Sa as PlanPicker,rh as SimpleShell,nh as ThemePanel,ba as UIBillingOverview,bd as UIDashboardLayout,yd as UIDateRangeSelector,lh as UIIntegrationsPage,ya as UIInvoiceDetail,hh as UINotificationPreferences,oh as UIOnboardingChecklist,va as UIPaymentMethodForm,eq as isFocusInInput};