@adia-ai/web-modules 0.7.19 → 0.7.20

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.
@@ -38,7 +38,7 @@ var DE=Object.defineProperty;var Z=(s,t)=>()=>(s&&(t=s(s=0)),t);var Ht=(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=vu.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],io,io,(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(Lg(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?Mw(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=Lg(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 Cu(t,e)}get buffer(){return new Eu(this.parser.nodeSet)}};ro=class s extends Ge{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 ku(this,t,e,i);for(let n of this.wrappers)r=n(r,t,e,i);return r}configure(t){let e=Qg(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(Tl(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(ft.define({id:v,name:m,props:w&&[[z.group,w]]})),y&&(f||(f={}),Array.isArray(y)||y instanceof ce?f[m]=y:Object.assign(f,y))}i=new He(d),f&&(i=i.extend(Mt(f)))}if(Tl(e.props)&&(i=i.extend(...e.props)),Tl(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(Tl(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?Au(a,d.before):d.after?Au(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(Tl(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?Au(h,d.before):d.after?Au(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 so(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)}};Rw=[ft.none];for(let s=1,t;t=L[s];s++)Rw[s]=ft.define({id:s,name:t,props:s>=L.Escape?[]:[[z.group,s in xw?["Block","BlockContext"]:["Block","LeafBlock"]]],top:t=="Document"});io=[],Eu=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})}},Ji=class{constructor(t,e,i,r=io){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 Eu(t).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}},Cu=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 io}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}};Iw={resolve:"Emphasis",mark:"EmphasisMark"},Dw={resolve:"Emphasis",mark:"EmphasisMark"},Zs={},$u={},re=class{constructor(t,e,i,r){this.type=t,this.from=e,this.to=i,this.side=r}},qw="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",Ll=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{Ll=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}Tg={Escape(s,t,e){if(t!=92||e==s.end-1)return-1;let i=s.char(e+1);for(let r=0;r<qw.length;r++)if(qw.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=Ll.test(r),a=Ll.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 re(t==95?Iw:Dw,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 re(Zs,e,e+1,1)):-1},Image(s,t,e){return t==33&&s.char(e+1)==91?s.append(new re($u,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 re&&(r.type==Zs||r.type==$u)){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]=H2(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 re&&l.type==Zs&&(l.side=0)}return o.to}}return-1}};so=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 re(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 re&&(e.type==Zs||e.type==$u))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 re&&r.type.resolve&&r.side&2))continue;let n=r.type==Iw||r.type==Dw,o=r.to-r.from,a,l=i-1;for(;l>=t;l--){let m=this.parts[l];if(m instanceof re&&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 Ji&&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 re(a.type,a.from,u,a.side):null,(this.parts[i]=n&&r.to!=d?new re(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 Ji&&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 re&&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 re?e:null}skipSpace(t){return Ql(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 Cu(t,e)}};so.linkStart=Zs,so.imageStart=$u;G2=[L.CodeBlock,L.ListItem,L.OrderedList,L.BulletList],Mg=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=Zw(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")&&(G2.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}};K2=Mt({"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}),Ig=new ro(new He(Rw).extend(K2),Object.keys(wu).map(s=>wu[s]),Object.keys(wu).map(s=>Lw[s]),Object.keys(wu),F2,xw,Object.keys(Tg).map(s=>Tg[s]),Object.keys(Tg),[]);tR={resolve:"Strikethrough",mark:"StrikethroughMark"},zw={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=Ll.test(i),l=Ll.test(r);return s.addDelimiter(tR,e,e+2,!o&&(!l||n||a),!n&&(!a||o||l))},after:"Emphasis"}]};jw=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,Pu=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)&&jw.test(r=e.text.slice(e.pos))){let n=[];Ml(t,i.content,0,n,i.start)==Ml(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=[];Ml(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}},Vw={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 _w(t.content,0)?new Pu:null},endLeaf(s,t,e){if(e.parsers.some(r=>r instanceof Pu)||!_w(t.text,t.basePos))return!1;let i=s.peekLine();return jw.test(i)&&Ml(s,t.text,t.basePos)==Ml(s,i,t.basePos)},before:"SetextHeading"}]},Rg=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}},Ww={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 Rg:null},after:"SetextHeading"}]},Uw=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,Fw=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,eR=/[\w-]+\.[\w-]+($|\/)/,Yw=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,Hw=/\/[a-zA-Z\d@.]+/gy;Jw={parseInline:[{name:"Autolink",parse(s,t,e){let i=e-s.offset;if(i&&/\w/.test(s.text[i-1]))return-1;Uw.lastIndex=i;let r=Uw.exec(s.text),n=-1;if(!r)return-1;if(r[1]||r[2]){if(n=iR(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=Kw(s.text,i):(n=Kw(s.text,i+r[0].length),n>-1&&r[0]=="xmpp:"&&(Hw.lastIndex=n,r=Hw.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)}}]},qg=[Vw,Ww,zw,Jw];Xg={defineNodes:[{name:"Superscript",style:O.special(O.content)},{name:"SuperscriptMark",style:O.processingInstruction}],parseInline:[{name:"Superscript",parse:tk(94,"Superscript","SuperscriptMark")}]},Ng={defineNodes:[{name:"Subscript",style:O.special(O.content)},{name:"SubscriptMark",style:O.processingInstruction}],parseInline:[{name:"Subscript",parse:tk(126,"Subscript","SubscriptMark")}]},Bg={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 uk={};Ht(uk,{commonmarkLanguage:()=>Wg,deleteMarkupBackward:()=>Yg,insertNewlineContinueMarkup:()=>Fg,insertNewlineContinueMarkupCommand:()=>Ug,markdown:()=>ck,markdownKeymap:()=>Hg,markdownLanguage:()=>no,pasteURLAsLink:()=>Gg});function Zg(s){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(s.name);return t?+t[1]:void 0}function sR(s){return s.name=="OrderedList"||s.name=="BulletList"}function rR(s,t){let e=s;for(;;){let i=e.nextSibling,r;if(!i||(r=Zg(i.type))!=null&&r<=t)break;e=i}return e.to}function zg(s){return new Tt(ik,s,[],"markdown")}function aR(s,t){return e=>{if(e&&s){let i=null;if(e=/\S*/.exec(e)[0],typeof s=="function"?i=s(e):i=Yn.matchLanguageName(s,e,!0),i instanceof Yn)return i.support?i.support.language.parser:Hi.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}function nk(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 Rl(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 Rl(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 Rl(n.parent,l,l+c,o[1],h,u,n))}}return i}function ok(s,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(s.from,s.from+10))}function _g(s,t,e,i=0){for(let r=-1,n=s;;){if(n.name=="ListItem"){let a=ok(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 jg(s,t){let e=/^[ \t]*/.exec(s)[0].length;if(!e||t.facet(Pi)!=" ")return s;let i=jt(s,4,e),r="";for(let n=i;n>0;)n>=4?(r+=" ",n-=4):(r+=" ",n--);return r+s.slice(e)}function ak(s){return s.name=="QuoteMark"||s.name=="ListMark"}function lR(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 lk(s,t,e){let i="";for(let r=0,n=s.length-2;r<=n;r++)i+=s[r].blank(r<n?jt(e.text,4,s[r+1].from)-i.length:null,r<n);return jg(i,t)}function hR(s,t){let e=s.resolveInner(t,-1),i=t;ak(e)&&(i=e.from,e=e.parent);for(let r;r=e.childBefore(i);)if(ak(r))i=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")e=r.lastChild,i=e.to;else break;return e}function ck(s={}){let{codeLanguages:t,defaultCodeLanguage:e,addKeymap:i=!0,base:{parser:r}=Wg,completeHTMLTags:n=!0,pasteURLAsLink:o=!0,htmlTagLanguage:a=hk}=s;if(!(r instanceof ro))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=s.extensions?[s.extensions]:[],h=[a.support,nR],c;o&&h.push(Gg),e instanceof xt?(h.push(e.support),c=e.language):e&&(c=e);let u=t||c?aR(t,c):void 0;l.push(Dg({codeParser:u,htmlParser:a.language.parser})),i&&h.push(ue.high(oi.of(Hg)));let d=zg(r.configure(l));return n&&h.push(d.data.of({autocomplete:cR})),new xt(d,h)}function cR(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:uR(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}function uR(){if(Vg)return Vg;let s=Ou(new Ns(nt.create({extensions:hk}),0,!0));return Vg=s?s.options:[]}var ik,sk,rk,nR,Wg,oR,no,Rl,Ug,Fg,Yg,Hg,hk,Vg,dR,Gg,dk=Z(()=>{si();wi();hi();ag();ek();xg();ze();ik=Rs({commentTokens:{block:{open:"<!--",close:"-->"}}}),sk=new z,rk=Ig.configure({props:[se.add(s=>!s.is("Block")||s.is("Document")||Zg(s)!=null||sR(s)?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),sk.add(Zg),ie.add({Document:()=>null}),ai.add({Document:ik})]});nR=Jc.of((s,t,e)=>{for(let i=G(s).resolveInner(e,-1);i&&!(i.from<t);i=i.parent){let r=i.type.prop(sk);if(r==null)continue;let n=rR(i,r);if(n>e)return{from:e,to:n}}return null});Wg=zg(rk),oR=rk.configure([qg,Ng,Xg,Bg,{props:[se.add({Table:(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}]),no=zg(oR);Rl=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(+ok(this.item,t)[2]+e):"";return this.spaceBefore+i+this.type+this.spaceAfter}};Ug=(s={})=>({state:t,dispatch:e})=>{let i=G(t),{doc:r}=t,n=null,o=t.changeByRange(a=>{if(!a.empty||!no.isActiveAt(t,a.from,-1)&&!no.isActiveAt(t,a.from,1))return n={range:a};let l=a.from,h=r.lineAt(l),c=nk(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"&&_g(u.item,r,E,-2),v&&v.node.name=="OrderedList"&&_g(v.item,r,E),{range:P.cursor(w+k.length),changes:E}}else{let v=lk(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"&&_g(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?jt(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=jg(m,t),lR(u.node,t.doc)&&(m=lk(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)},Fg=Ug();Yg=({state:s,dispatch:t})=>{let e=G(s),i=null,r=s.changeByRange(n=>{let o=n.from,{doc:a}=s;if(n.empty&&no.isActiveAt(s,n.from)){let l=a.lineAt(o),h=nk(hR(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(jt(l.text,4,c.to)-jt(l.text,4,c.from));return d==l.from&&(f=jg(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)},Hg=[{key:"Enter",run:Fg},{key:"Backspace",run:Yg}],hk=yu({matchClosingTags:!1});Vg=null;dR=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Gg=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),!no.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||dR.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 Dl(s,t){for(let e=0,i=t-s.pos-1;;i--,e++){let r=s.peek(i);if(Ri(r)||r==-1)return e}}function eb(s){return s==32||s==9}function Ri(s){return s==10||s==13}function Ok(s){return eb(s)||Ri(s)}function zs(s){return s<0||Ok(s)}function ao(s,t,e=0){return s.peek(e)==t&&s.peek(e+1)==t&&s.peek(e+2)==t&&zs(s.peek(e+3))}function RR(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 yk(s){return s>=48&&s<=57||s>=97&&s<=102||s>=65&&s<=70}function vk(s,t){return s.next==37?(s.advance(),yk(s.next)&&s.advance(),yk(s.next)&&s.advance(),!0):RR(s.next)||t&&s.next==44?(s.advance(),!0):!1}function xk(s){if(s.advance(),s.next==60){for(s.advance();;)if(!vk(s,!0)){s.next==62&&s.advance();break}}else for(;vk(s,!1););}function ib(s){for(s.advance();!zs(s.next)&&Qu(s.next)!="f";)s.advance()}function sb(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(Ri(n)){if(t)return!1;i=!0}else if(t&&s.pos>=r+1024)return!1}return!i}function IR(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(!sb(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||Ri(s.next))return!1;s.advance()}}function Qu(s){return s<33?"u":s>125?"s":DR[s-33]}function rb(s,t){let e=Qu(s);return e!="u"&&!(t&&e=="f")}function Sk(s,t,e,i){if(Qu(s.next)=="s"||(s.next==63||s.next==58||s.next==45)&&rb(s.peek(1),e))s.advance();else return!1;let r=s.pos;for(;;){let n=s.next,o=0,a=i+1;for(;Ok(n);){if(Ri(n)){if(t)return!1;a=0}else a++;n=s.peek(++o)}if(!(n>=0&&(n==58?rb(s.peek(o+1),e):n==35?s.peek(o-1)!=32:rb(n,e)))||!e&&a<=i||a==0&&!e&&(ao(s,45,o)||ao(s,46,o)))break;if(t&&Qu(n)=="f")return!1;for(let h=o;h>=0;h--)s.advance();if(t&&s.pos>r+1024)return!1}return!0}var oo,fk,fR,pR,pk,mR,mk,gR,bR,gk,OR,yR,vR,xR,SR,wR,bk,kR,AR,ER,CR,$R,PR,QR,Kg,Jg,Il,tb,Mi,TR,LR,MR,DR,qR,XR,NR,nb,wk=Z(()=>{bs();ei();oo=63,fk=64,fR=1,pR=2,pk=3,mR=4,mk=5,gR=6,bR=7,gk=65,OR=66,yR=8,vR=9,xR=10,SR=11,wR=12,bk=13,kR=19,AR=20,ER=29,CR=33,$R=34,PR=47,QR=0,Kg=1,Jg=2,Il=3,tb=4,Mi=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}};Mi.top=new Mi(null,-1,QR);TR=new Oi({start:Mi.top,reduce(s,t){return s.type==Il&&(t==AR||t==$R)?s.parent:s},shift(s,t,e,i){if(t==pk)return new Mi(s,Dl(i,i.pos),Kg);if(t==gk||t==mk)return new Mi(s,Dl(i,i.pos),Jg);if(t==oo)return s.parent;if(t==kR||t==CR)return new Mi(s,0,Il);if(t==bk&&s.type==tb)return s.parent;if(t==PR){let r=/[1-9]/.exec(i.read(i.pos,e.pos));if(r)return new Mi(s,s.depth+ +r[0],tb)}return s},hash(s){return s.hash}});LR=new pt((s,t)=>{if(s.next==-1&&t.canShift(fk))return s.acceptToken(fk);let e=s.peek(-1);if((Ri(e)||e<0)&&t.context.type!=Il){if(ao(s,45))if(t.canShift(oo))s.acceptToken(oo);else return s.acceptToken(fR,3);if(ao(s,46))if(t.canShift(oo))s.acceptToken(oo);else return s.acceptToken(pR,3);let i=0;for(;s.next==32;)i++,s.advance();(i<t.context.depth||i==t.context.depth&&t.context.type==Kg&&(s.next!=45||!zs(s.peek(1))))&&s.next!=-1&&!Ri(s.next)&&s.next!=35&&s.acceptToken(oo,-i)}},{contextual:!0}),MR=new pt((s,t)=>{if(t.context.type==Il){s.next==63&&(s.advance(),zs(s.next)&&s.acceptToken(bR));return}if(s.next==45)s.advance(),zs(s.next)&&s.acceptToken(t.context.type==Kg&&t.context.depth==Dl(s,s.pos-1)?mR:pk);else if(s.next==63)s.advance(),zs(s.next)&&s.acceptToken(t.context.type==Jg&&t.context.depth==Dl(s,s.pos-1)?gR:mk);else{let e=s.pos;for(;;)if(eb(s.next)){if(s.pos==e)return;s.advance()}else if(s.next==33)xk(s);else if(s.next==38)ib(s);else if(s.next==42){ib(s);break}else if(s.next==39||s.next==34){if(sb(s,!0))break;return}else if(s.next==91||s.next==123){if(!IR(s))return;break}else{Sk(s,!0,!1,0);break}for(;eb(s.next);)s.advance();if(s.next==58){if(s.pos==e&&t.canShift(ER))return;let i=s.peek(1);zs(i)&&s.acceptTokenTo(t.context.type==Jg&&t.context.depth==Dl(s,e)?OR:gk,e)}}},{contextual:!0});DR="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";qR=new pt((s,t)=>{if(s.next==33)xk(s),s.acceptToken(wR);else if(s.next==38||s.next==42){let e=s.next==38?xR:SR;ib(s),s.acceptToken(e)}else s.next==39||s.next==34?(sb(s,!1),s.acceptToken(vR)):Sk(s,!1,t.context.type==Il,t.context.depth)&&s.acceptToken(yR)}),XR=new pt((s,t)=>{let e=t.context.type==tb?t.context.depth:-1,i=s.pos;t:for(;;){let r=0,n=s.next;for(;n==32;)n=s.peek(++r);if(!r&&(ao(s,45,r)||ao(s,46,r))||!Ri(n)&&(e<0&&(e=Math.max(t.context.depth+1,r)),r<e))break;for(;;){if(s.next<0)break t;let o=Ri(s.next);if(s.advance(),o)continue t;i=s.pos}}s.acceptTokenTo(bk,i)}),NR=Mt({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}),nb=Gt.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:TR,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[NR],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:[LR,MR,qR,XR,0,1],topRules:{Stream:[0,15]},tokenPrec:0})});var Ek={};Ht(Ek,{yaml:()=>kk,yamlFrontmatter:()=>Ak,yamlLanguage:()=>Tu});function kk(){return new xt(Tu)}function Ak(s){let{language:t,support:e}=s.content instanceof xt?s.content:{language:s.content,support:[]};return new xt(ZR.configure({wrap:gs(i=>i.name=="FrontmatterContent"?{parser:Tu.parser}:i.name=="Body"?{parser:t.parser}:null)}),e)}var BR,Tu,ZR,Ck=Z(()=>{wk();hi();ze();ei();bs();BR=Gt.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}),Tu=me.define({name:"yaml",parser:nb.configure({props:[ie.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:Gn({closing:"}"}),FlowSequence:Gn({closing:"]"})}),se.add({"FlowMapping FlowSequence":Qi,"Item Pair BlockLiteral":(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});ZR=me.define({name:"yaml-frontmatter",parser:BR.configure({props:[Mt({DashLine:O.meta})]})})});function _s(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 ob(s,t){let e=s.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}function WR(s,{open:t,close:e},i,r){let n=s.sliceDoc(i-ql,i),o=s.sliceDoc(r,r+ql),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*ql?c=u=s.sliceDoc(i,r):(c=s.sliceDoc(i,i+ql),u=s.sliceDoc(r-ql,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 UR(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 Lu(s,t,e=t.selection.ranges){let i=e.map(n=>ob(t,n.from).block);if(!i.every(n=>n))return null;let r=e.map((n,o)=>WR(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 ab(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=ob(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 Uu(s={}){return[Mu,Rk.of(s),I.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?hb:t.inputType=="historyRedo"?Iu:null;return i?(t.preventDefault(),i(e)):!1}})]}function Ru(s,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let r=e.field(Mu,!1);if(!r)return!1;let n=r.pop(s,e,t);return n?(i(n),!0):!1}}function qk(s){return function(t){let e=t.field(Mu,!1);if(!e)return 0;let i=s==0?e.done:e.undone;return i.length-(i.length&&!i[0].changes?1:0)}}function Du(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 GR(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 KR(s,t){return s.ranges.length==t.ranges.length&&s.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function Xk(s,t){return s.length?t.length?s.concat(t):s:t}function Nk(s,t){if(s.length){let e=s[s.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-JR));return i.length&&i[i.length-1].eq(t)?s:(i.push(t),Du(s,s.length-1,1e9,e.setSelAfter(i)))}else return[je.selection([t])]}function tI(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 cb(s,t){if(!s.length)return s;let e=s.length,i=qe;for(;e;){let r=eI(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?[je.selection(i)]:qe}function eI(s,t,e){let i=Xk(s.selectionsAfter.length?s.selectionsAfter.map(a=>a.map(t)):qe,e);if(!s.changes)return je.selection(i);let r=s.changes.map(t),n=t.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(n):n;return new je(r,W.mapEffects(s.effects,t),o,s.startSelection.map(n),i)}function lo(s,t){return P.create(s.ranges.map(t),s.mainIndex)}function Ve(s,t){return s.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function be({state:s,dispatch:t},e){let i=lo(s.selection,e);return i.eq(s.selection,!0)?!1:(t(Ve(s,i)),!0)}function Vs(s,t){return P.cursor(t?s.to:s.from)}function qu(s,t){return be(s,e=>e.empty?s.moveByChar(e,t):Vs(e,t))}function Wt(s){return s.textDirectionAt(s.state.selection.main.head)==st.LTR}function fb(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+At(r.text,i-r.from,e),P.cursor(i,e?-1:1)}function Bk(s,t){return be(s,e=>e.empty?fb(s.state,e,t):Vs(e,t))}function Xu(s,t){return be(s,e=>e.empty?s.moveByGroup(e,t):Vs(e,t))}function pb(s,t,e){let i=s.state.charCategorizer(t),r=i(e),n=r!=mt.Space;return o=>{let a=i(o);return a!=mt.Space?n&&a==r:(n=!1,!0)}}function jk(s,t,e){let i=s.state.charCategorizer(t.from),r=mt.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==mt.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(f=-1),r==mt.Space&&(r=f),r!=f)return!1;if(r==mt.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))==mt.Word&&p.toLowerCase()==p)return!1;l=!0}return o++,!0},u=s.moveByChar(t,e,d=>(c(d),c));if(_k&&r==mt.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(_k.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 Vk(s,t){return be(s,e=>e.empty?jk(s,e,t):Vs(e,t))}function dI(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 Nu(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;dI(s,h,r)?i=h:l=e?h.to:h.from}let n=i.type.prop(r),o,a;return n&&(o=e?Ie(s,i.from,1):Ie(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 Fk(s,t){return be(s,e=>{if(!e.empty)return Vs(e,t);let i=s.moveVertically(e,t);return i.head!=e.head?i:s.moveToLineBoundary(e,t)})}function Yk(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 Hk(s,t){let e=Yk(s),{state:i}=s,r=lo(i.selection,o=>o.empty?s.moveVertically(o,t,e.height):Vs(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(Ve(i,r),{effects:n}),!0}function ts(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 sA(s,t,e){let i=!1,r=lo(s.selection,n=>{let o=Ie(s,n.head,-1)||Ie(s,n.head,1)||n.head>0&&Ie(s,n.head-1,1)||n.head<s.doc.length&&Ie(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(Ve(s,r)),!0):!1}function Ut(s,t){let e=lo(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(Ve(s.state,e)),!0)}function Zu(s,t){return Ut(s,e=>s.moveByChar(e,t))}function zu(s,t){return Ut(s,e=>s.moveByGroup(e,t))}function aA(s,t){return Ut(s,e=>jk(s,e,t))}function cA(s,t){return Ut(s,e=>s.moveVertically(e,t))}function uA(s,t){return Ut(s,e=>s.moveVertically(e,t,Yk(s).height))}function xA(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(Ve(e,P.create(r,r.length-1))),!0)}function Ws(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=_u(s,l,!1)):l>o&&(e="delete.forward",l=_u(s,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=_u(s,o,!1),a=_u(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 _u(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 Vu(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 LA(s,t,e){if(s.readOnly)return!1;let i=[],r=[];for(let n of Vu(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 IA(s,t,e){if(s.readOnly)return!1;let i=[];for(let n of Vu(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 PI(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 BA(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&&PI(t,n);s&&(n=o=(o<=a.to?a:t.doc.lineAt(o)).to);let h=new Ei(t,{simulateBreak:n,simulateDoubleBreak:!!l}),c=Hn(h,n);for(c==null&&(c=jt(/^\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=["",Gi(t,c)];return l&&u.push(Gi(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 Lb(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 $k,Pk,zR,_R,Qk,jR,VR,Tk,ql,lb,Lk,Mk,Rk,Mu,FR,hb,Iu,Ik,Dk,YR,HR,je,qe,JR,iI,js,Fu,ub,db,sI,rI,nI,oI,Zk,zk,aI,lI,hI,_k,cI,uI,Wk,Uk,mb,gb,bb,Bu,Gk,Kk,Jk,tA,eA,iA,rA,fI,Ob,yb,pI,mI,gI,bI,nA,oA,OI,yI,vI,xI,SI,lA,hA,vb,xb,Sb,wb,dA,fA,pA,mA,gA,bA,kb,Ab,Eb,Cb,OA,yA,vA,SA,wA,kA,$b,ju,wI,Pb,AA,Qb,EA,kI,CA,AI,$A,PA,EI,QA,TA,MA,RA,DA,qA,XA,CI,$I,Tb,NA,ZA,Wu,Mb,zA,QI,TI,_A,jA,Yu,Hu,VA=Z(()=>{si();wi();hi();ze();$k=s=>{let{state:t}=s,e=t.doc.lineAt(t.selection.main.from),i=ob(s.state,e.from);return i.line?Pk(s):i.block?Tk(s):!1};Pk=_s(ab,0),zR=_s(ab,1),_R=_s(ab,2),Qk=_s(Lu,0),jR=_s(Lu,1),VR=_s(Lu,2),Tk=_s((s,t)=>Lu(s,t,UR(t)),0);ql=50;lb=Kt.define(),Lk=Kt.define(),Mk=X.define(),Rk=X.define({combine(s){return Jt(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)})}}),Mu=gt.define({create(){return js.empty},update(s,t){let e=t.state.facet(Rk),i=t.annotation(lb);if(i){let l=je.fromTransaction(t,i.selection),h=i.side,c=h==0?s.undone:s.done;return l?c=Du(c,c.length,e.minDepth,l):c=Nk(c,t.startState.selection),new js(h==0?i.rest:c,h==0?c:i.rest)}let r=t.annotation(Lk);if((r=="full"||r=="before")&&(s=s.isolate()),t.annotation(vt.addToHistory)===!1)return t.changes.empty?s:s.addMapping(t.changes.desc);let n=je.fromTransaction(t),o=t.annotation(vt.time),a=t.annotation(vt.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 js(s.done.map(je.fromJSON),s.undone.map(je.fromJSON))}});FR=Mu;hb=Ru(0,!1),Iu=Ru(1,!1),Ik=Ru(0,!0),Dk=Ru(1,!0);YR=qk(0),HR=qk(1),je=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&&zt.fromJSON(t.changes),[],t.mapped&&ii.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,e){let i=qe;for(let r of t.startState.facet(Mk)){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,qe)}static selection(t){return new s(void 0,qe,void 0,void 0,t)}};qe=[],JR=200;iI=/^(input\.type|delete)($|\.)/,js=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||iI.test(i))&&(!a.selectionsAfter.length&&e-this.prevTime<r.newGroupDelay&&r.joinToEvent(n,GR(a.changes,t.changes))||i=="input.type.compose")?o=Du(o,o.length-1,r.minDepth,new je(t.changes.compose(a.changes),Xk(W.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,qe)):o=Du(o,o.length,r.minDepth,t),new s(o,qe,e,i)}addSelection(t,e,i,r){let n=this.done.length?this.done[this.done.length-1].selectionsAfter:qe;return n.length>0&&e-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&KR(n[n.length-1],t)?this:new s(Nk(this.done,t),this.undone,e,i)}addMapping(t){return new s(cb(this.done,t),cb(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:lb.of({side:t,rest:tI(r),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(n.changes){let a=r.length==1?qe:r.slice(0,r.length-1);return n.mapped&&(a=cb(a,n.mapped)),e.update({changes:n.changes,selection:n.startSelection,effects:n.effects,annotations:lb.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};js.empty=new js(qe,qe);Fu=[{key:"Mod-z",run:hb,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Iu,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Iu,preventDefault:!0},{key:"Mod-u",run:Ik,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Dk,preventDefault:!0}];ub=s=>qu(s,!Wt(s)),db=s=>qu(s,Wt(s)),sI=s=>qu(s,!0),rI=s=>qu(s,!1);nI=s=>Bk(s,!0),oI=s=>Bk(s,!1);Zk=s=>Xu(s,!Wt(s)),zk=s=>Xu(s,Wt(s)),aI=s=>Xu(s,!0),lI=s=>Xu(s,!1);hI=s=>be(s,t=>t.empty?s.moveByChar(t,!0,e=>pb(s,t.head,e)):Vs(t,!0)),_k=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;cI=s=>Vk(s,!0),uI=s=>Vk(s,!1);Wk=s=>be(s,t=>Nu(s.state,t,!Wt(s))),Uk=s=>be(s,t=>Nu(s.state,t,Wt(s)));mb=s=>Fk(s,!1),gb=s=>Fk(s,!0);bb=s=>Hk(s,!1),Bu=s=>Hk(s,!0);Gk=s=>be(s,t=>ts(s,t,!0)),Kk=s=>be(s,t=>ts(s,t,!1)),Jk=s=>be(s,t=>ts(s,t,!Wt(s))),tA=s=>be(s,t=>ts(s,t,Wt(s))),eA=s=>be(s,t=>P.cursor(s.lineBlockAt(t.head).from,1)),iA=s=>be(s,t=>P.cursor(s.lineBlockAt(t.head).to,-1));rA=({state:s,dispatch:t})=>sA(s,t,!1),fI=({state:s,dispatch:t})=>sA(s,t,!0);Ob=s=>Zu(s,!Wt(s)),yb=s=>Zu(s,Wt(s)),pI=s=>Zu(s,!0),mI=s=>Zu(s,!1),gI=s=>Ut(s,t=>fb(s.state,t,!0)),bI=s=>Ut(s,t=>fb(s.state,t,!1));nA=s=>zu(s,!Wt(s)),oA=s=>zu(s,Wt(s)),OI=s=>zu(s,!0),yI=s=>zu(s,!1),vI=s=>Ut(s,t=>s.moveByChar(t,!0,e=>pb(s,t.head,e)));xI=s=>aA(s,!0),SI=s=>aA(s,!1),lA=s=>Ut(s,t=>Nu(s.state,t,!Wt(s))),hA=s=>Ut(s,t=>Nu(s.state,t,Wt(s)));vb=s=>cA(s,!1),xb=s=>cA(s,!0);Sb=s=>uA(s,!1),wb=s=>uA(s,!0),dA=s=>Ut(s,t=>ts(s,t,!0)),fA=s=>Ut(s,t=>ts(s,t,!1)),pA=s=>Ut(s,t=>ts(s,t,!Wt(s))),mA=s=>Ut(s,t=>ts(s,t,Wt(s))),gA=s=>Ut(s,t=>P.cursor(s.lineBlockAt(t.head).from)),bA=s=>Ut(s,t=>P.cursor(s.lineBlockAt(t.head).to)),kb=({state:s,dispatch:t})=>(t(Ve(s,{anchor:0})),!0),Ab=({state:s,dispatch:t})=>(t(Ve(s,{anchor:s.doc.length})),!0),Eb=({state:s,dispatch:t})=>(t(Ve(s,{anchor:s.selection.main.anchor,head:0})),!0),Cb=({state:s,dispatch:t})=>(t(Ve(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),OA=({state:s,dispatch:t})=>(t(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),yA=({state:s,dispatch:t})=>{let e=Vu(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},vA=({state:s,dispatch:t})=>{let e=lo(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(Ve(s,e)),!0)};SA=s=>xA(s,!1),wA=s=>xA(s,!0),kA=({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(Ve(s,i)),!0):!1};$b=(s,t,e)=>Ws(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=jt(a,n.tabSize),c=h%Ci(n)||Ci(n);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)r--;l=r}else l=At(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=At(o.text,l-o.from,!1,!1)+o.from);return l}),ju=s=>$b(s,!1,!0),wI=s=>$b(s,!1,!1),Pb=s=>$b(s,!0,!1),AA=(s,t)=>Ws(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=At(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}),Qb=s=>AA(s,!1),EA=s=>AA(s,!0),kI=s=>Ws(s,t=>s.moveByChar(t,!0,e=>pb(s,t.head,e)).head),CA=s=>Ws(s,t=>{let e=s.lineBlockAt(t.head).to;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),AI=s=>Ws(s,t=>{let e=s.lineBlockAt(t.head).from;return t.head>e?e:Math.max(0,t.head-1)}),$A=s=>Ws(s,t=>{let e=s.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),PA=s=>Ws(s,t=>{let e=s.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),EI=({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},QA=({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},TA=({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:At(n.text,r-n.from,!1)+n.from,a=r==n.to?r+1:At(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)};MA=({state:s,dispatch:t})=>LA(s,t,!1),RA=({state:s,dispatch:t})=>LA(s,t,!0);DA=({state:s,dispatch:t})=>IA(s,t,!1),qA=({state:s,dispatch:t})=>IA(s,t,!0),XA=s=>{if(s.state.readOnly)return!1;let{state:t}=s,e=t.changes(Vu(t).map(({from:r,to:n})=>(r>0?r--:n<t.doc.length&&n++,{from:r,to:n}))),i=lo(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},CI=({state:s,dispatch:t})=>(t(s.update(s.replaceSelection(s.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),$I=({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);Tb=BA(!1),NA=BA(!0);ZA=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=Object.create(null),i=new Ei(s,{overrideIndentation:n=>{let o=e[n];return o??-1}}),r=Lb(s,(n,o,a)=>{let l=Hn(i,n.from);if(l==null)return;/\S/.test(n.text)||(l=0);let h=/^\s*/.exec(n.text)[0],c=Gi(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},Wu=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Lb(s,(e,i)=>{i.push({from:e.from,insert:s.facet(Pi)})}),{userEvent:"input.indent"})),!0),Mb=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Lb(s,(e,i)=>{let r=/^\s*/.exec(e.text)[0];if(!r)return;let n=jt(r,s.tabSize),o=0,a=Gi(s,Math.max(0,n-Ci(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),zA=s=>(s.setTabFocusMode(),!0),QI=s=>(s.setTabFocusMode(2e3),!0),TI=({state:s,dispatch:t})=>s.selection.ranges.some(e=>!e.empty)?Wu({state:s,dispatch:t}):(t(s.update(s.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),_A=[{key:"Ctrl-b",run:ub,shift:Ob,preventDefault:!0},{key:"Ctrl-f",run:db,shift:yb},{key:"Ctrl-p",run:mb,shift:vb},{key:"Ctrl-n",run:gb,shift:xb},{key:"Ctrl-a",run:eA,shift:gA},{key:"Ctrl-e",run:iA,shift:bA},{key:"Ctrl-d",run:Pb},{key:"Ctrl-h",run:ju},{key:"Ctrl-k",run:CA},{key:"Ctrl-Alt-h",run:Qb},{key:"Ctrl-o",run:QA},{key:"Ctrl-t",run:TA},{key:"Ctrl-v",run:Bu}],jA=[{key:"ArrowLeft",run:ub,shift:Ob,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Zk,shift:nA,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Jk,shift:pA,preventDefault:!0},{key:"ArrowRight",run:db,shift:yb,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:zk,shift:oA,preventDefault:!0},{mac:"Cmd-ArrowRight",run:tA,shift:mA,preventDefault:!0},{key:"ArrowUp",run:mb,shift:vb,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kb,shift:Eb},{mac:"Ctrl-ArrowUp",run:bb,shift:Sb},{key:"ArrowDown",run:gb,shift:xb,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ab,shift:Cb},{mac:"Ctrl-ArrowDown",run:Bu,shift:wb},{key:"PageUp",run:bb,shift:Sb},{key:"PageDown",run:Bu,shift:wb},{key:"Home",run:Kk,shift:fA,preventDefault:!0},{key:"Mod-Home",run:kb,shift:Eb},{key:"End",run:Gk,shift:dA,preventDefault:!0},{key:"Mod-End",run:Ab,shift:Cb},{key:"Enter",run:Tb,shift:Tb},{key:"Mod-a",run:OA},{key:"Backspace",run:ju,shift:ju,preventDefault:!0},{key:"Delete",run:Pb,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Qb,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:EA,preventDefault:!0},{mac:"Mod-Backspace",run:$A,preventDefault:!0},{mac:"Mod-Delete",run:PA,preventDefault:!0}].concat(_A.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),Yu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Wk,shift:lA},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Uk,shift:hA},{key:"Alt-ArrowUp",run:MA},{key:"Shift-Alt-ArrowUp",run:DA},{key:"Alt-ArrowDown",run:RA},{key:"Shift-Alt-ArrowDown",run:qA},{key:"Mod-Alt-ArrowUp",run:SA},{key:"Mod-Alt-ArrowDown",run:wA},{key:"Escape",run:kA},{key:"Mod-Enter",run:NA},{key:"Alt-l",mac:"Ctrl-l",run:yA},{key:"Mod-i",run:vA,preventDefault:!0},{key:"Mod-[",run:Mb},{key:"Mod-]",run:Wu},{key:"Mod-Alt-\\",run:ZA},{key:"Shift-Mod-k",run:XA},{key:"Shift-Mod-\\",run:rA},{key:"Mod-/",run:$k},{key:"Alt-A",run:Qk},{key:"Ctrl-m",mac:"Shift-Alt-m",run:zA}].concat(jA),Hu={key:"Tab",run:Wu,shift:Mb}});function es(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 Gu(r,n,t||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Gu(i.from,n,i.diagnostic)}}),i}function WA(s,t){let e=t.pos,i=t.end||e,r=s.state.facet(ci).hideOn(s,e,i);if(r!=null)return r;let n=s.startState.doc.lineAt(t.pos);return!!(s.effects.some(o=>o.is(Xl))||s.changes.touchesRange(n.from,Math.max(n.to,i)))}function UA(s,t){return s.field(Ft,!1)?t:t.concat(W.appendConfig.of(n1))}function FA(s,t){return{effects:UA(s,[Xl.of(t)])}}function LI(s){let t=s.field(Ft,!1);return t?t.diagnostics.size:0}function RI(s,t,e){let{diagnostics:i}=s.state.field(Ft),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(ci).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:HA(s,r)}}}:null}function HA(s,t){return Pt("ul",{class:"cm-tooltip-lint"},t.map(e=>i1(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 t1(s,t){return s?t?(e,i)=>t(s(e,i),i):s:t}function Bl(s,t={}){return[ci.of({source:s,config:t}),JA,n1]}function XI(s){let t=s.plugin(JA);t&&t.force()}function e1(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 i1(s,t,e){var i;let r=e?e1(t.actions):[];return Pt("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Pt("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=es(s.state.field(Ft).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),Pt("u",h.slice(c,c+1)),h.slice(c+1)],d=n.markClass?" "+n.markClass:"";return Pt("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},u)}),t.source&&Pt("div",{class:"cm-diagnosticSource"},t.source))}function Ju(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 td(s){return Ju(`<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 BI(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function s1(s){let t="hint",e=1;for(let i of s){let r=BI(i.severity);r>e&&(e=r,t=i.severity)}return t}function ZI(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(r1)&&s.dispatch({effects:Xb.of(null)})}};window.addEventListener("mousemove",e)}function zI(s,t,e){function i(){let o=s.elementAtHeight(t.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:Xb.of({pos:o.from,above:!1,clip:!1,create(){return{dom:HA(s,e),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,ZI(s,t)}let{hoverTime:r}=s.state.facet(id),n=setTimeout(i,r);t.onmouseout=()=>{clearTimeout(n),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(n),n=setTimeout(i,r)}}function _I(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 ed(e[r]).range(+r));return H.of(i,!0)}function sd(s={}){return[id.of(s),qb,jI,VI,r1]}function WI(s,t){let e=s.field(Ft,!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 Gu,Us,Xl,Rb,YA,Ft,MI,GA,Ib,KA,II,DI,JA,ci,Db,Ku,Nl,NI,ed,jI,qb,Xb,r1,VI,n1,id,o1=Z(()=>{wi();si();Wf();Gu=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},Us=class s{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let r=i.facet(ci).markerFilter;r&&(t=r(t,i));let n=t.slice().sort((f,p)=>f.from-p.from||f.to-p.to),o=new Ae,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=s1(a);if(g)o.add(m,m,j.widget({widget:new Db(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,es(d))}};Xl=W.define(),Rb=W.define(),YA=W.define(),Ft=gt.define({create(){return new Us(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=es(e,s.selected.diagnostic,n)||es(e,null,n)}!e.size&&r&&t.state.facet(ci).autoPanel&&(r=null),s=new Us(e,r,i)}for(let e of t.effects)if(e.is(Xl)){let i=t.state.facet(ci).autoPanel?e.value.length?Nl.open:null:s.panel;s=Us.init(e.value,i,t.state)}else e.is(Rb)?s=new Us(s.diagnostics,e.value?Nl.open:null,s.selected):e.is(YA)&&(s=new Us(s.diagnostics,s.panel,e.value));return s},provide:s=>[Wn.from(s,t=>t.panel),I.decorations.from(s,t=>t.diagnostics)]});MI=j.mark({class:"cm-lintRange cm-lintRange-active"});GA=s=>{let t=s.state.field(Ft,!1);(!t||!t.panel)&&s.dispatch({effects:UA(s.state,[Rb.of(!0)])});let e=Zc(s,Nl.open);return e&&e.dom.querySelector(".cm-panel-lint ul").focus(),!0},Ib=s=>{let t=s.state.field(Ft,!1);return!t||!t.panel?!1:(s.dispatch({effects:Rb.of(!1)}),!0)},KA=s=>{let t=s.state.field(Ft,!1);if(!t)return!1;let e=s.state.selection.main,i=es(t.diagnostics,null,e.to+1);return!i&&(i=es(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)},II=s=>{let{state:t}=s,e=t.field(Ft,!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)},DI=[{key:"Mod-Shift-m",run:GA,preventDefault:!0},{key:"F8",run:KA}],JA=ct.fromClass(class{constructor(s){this.view=s,this.timeout=-1,this.set=!0;let{delay:t}=s.state.facet(ci);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(ci);e.length&&qI(e.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==t.doc&&this.view.dispatch(FA(this.view.state,i.reduce((r,n)=>r.concat(n))))},i=>{Qt(this.view.state,i)})}}update(s){let t=s.state.facet(ci);(s.docChanged||t!=s.startState.facet(ci)||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)}});ci=X.define({combine(s){return{sources:s.map(t=>t.source).filter(t=>t!=null),...Jt(s.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:t1,tooltipFilter:t1,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})}}});Db=class extends Xt{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Pt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},Ku=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=i1(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Nl=class s{constructor(t){this.view=t,this.items=[];let e=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)Ib(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=e1(n.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==r.keyCode){let l=es(this.view.state.field(Ft).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=Pt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:i}),this.dom=Pt("div",{class:"cm-panel-lint"},this.list,Pt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Ib(this.view)},"\xD7")),this.update()}get selectedIndex(){let t=this.view.state.field(Ft).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(Ft),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 Ku(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 Ku(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(Ft),i=es(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:YA.of(i)})}static open(t){return new s(t)}};NI=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:td("#d11")},".cm-lintRange-warning":{backgroundImage:td("orange")},".cm-lintRange-info":{backgroundImage:td("#999")},".cm-lintRange-hint":{backgroundImage:td("#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"}}});ed=class extends ee{constructor(t){super(),this.diagnostics=t,this.severity=s1(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(id).tooltipFilter;return r&&(i=r(i,t.state)),i.length&&(e.onmouseover=()=>zI(t,e,i)),e}};jI=dl({class:"cm-gutter-lint",markers:s=>s.state.field(qb),widgetMarker:(s,t,e)=>{let i=[];return s.state.field(qb).between(e.from,e.to,(r,n,o)=>{r>e.from&&r<e.to&&i.push(...o.diagnostics)}),i.length?new ed(i):null}}),qb=gt.define({create(){return H.empty},update(s,t){s=s.map(t.changes);let e=t.state.facet(id).markerFilter;for(let i of t.effects)if(i.is(Xl)){let r=i.value;e&&(r=e(r||[],t.state)),s=_I(t.state.doc,r.slice(0))}return s}}),Xb=W.define(),r1=gt.define({create(){return null},update(s,t){return s&&t.docChanged&&(s=WA(t,s)?null:{...s,pos:t.changes.mapPos(s.pos)}),t.effects.reduce((e,i)=>i.is(Xb)?i.value:e,s)},provide:s=>Ls.from(s)}),VI=I.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Ju('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Ju('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Ju('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),n1=[Ft,I.decorations.compute([Ft],s=>{let{selected:t,panel:e}=s.field(Ft);return!t||!e||t.from==t.to?j.none:j.set([MI.range(t.from,t.to)])}),nm(RI,{hideOn:WA}),NI],id=X.define({combine(s){return Jt(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}})});var Bb={};Ht(Bb,{Compartment:()=>ji,EditorSelection:()=>P,EditorState:()=>nt,EditorView:()=>I,HighlightStyle:()=>$i,LOAD_TIMEOUT_MS:()=>Nb,LanguageSupport:()=>xt,StateEffect:()=>W,adiaBaseTheme:()=>UI,adiaHighlightStyle:()=>FI,defaultHighlightStyle:()=>iu,defaultKeymap:()=>Yu,drawSelection:()=>zc,highlightActiveLine:()=>_c,highlightActiveLineGutter:()=>Uc,history:()=>Uu,historyKeymap:()=>Fu,importWithTimeout:()=>HI,indentWithTab:()=>Hu,jsonLinter:()=>GI,keymap:()=>oi,languages:()=>YI,lineNumbers:()=>Wc,lintGutter:()=>sd,linter:()=>Bl,placeholder:()=>jc,syntaxHighlighting:()=>eu});function HI(s,t){return Promise.race([s(),new Promise((e,i)=>setTimeout(()=>i(new Error(`code-editor: ${t} load timed out after ${Nb}ms`)),Nb))])}function KI(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 UI,FI,YI,Nb,GI,Zb=Z(()=>{"use strict";si();wi();VA();hi();o1();ei();UI=I.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{padding:"0",caretColor:"inherit"},".cm-focused":{outline:"none"}}),FI=$i.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"}]),YI={json:()=>Promise.resolve().then(()=>(Zx(),Bx)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(xg(),yw)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(pg(),aw)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Nm(),bS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(dk(),uk)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Ck(),Ek)).then(s=>({extension:s.yaml()}))},Nb=1e4;GI=Bl(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}=KI(i,t);return[{from:r,to:n,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function ad(s){return Nt.get(s)||null}function k1(s,t){Nt.set(s,t)}var Nt,Gb=Z(()=>{"use strict";Nt=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 A1(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 $D(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 ld,ea,Kb=Z(()=>{"use strict";ld={provider:0,controller:1,source:2,action:3,lifecycle:4},ea=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?A1(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)=>(ld[i.kind]??9)-(ld[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)=>(ld[i[1].dockable.kind]??9)-(ld[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){$D(this.#e,t,e);for(let[i,r]of this.#s)if(t===i||t.startsWith(i+"/"))for(let n of r)n(A1(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 Oe,Hs=Z(()=>{"use strict";Oe=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 ia,Jb=Z(()=>{"use strict";Hs();ia=class extends Oe{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 sa,tO=Z(()=>{"use strict";Hs();sa=class extends Oe{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 hd,ra,eO=Z(()=>{"use strict";Hs();hd={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"},ra=class extends Oe{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=hd[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 na,iO=Z(()=>{"use strict";Hs();na=class extends Oe{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 oa,sO=Z(()=>{"use strict";Hs();oa=class extends Oe{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 E1,ye,Gs=Z(()=>{"use strict";E1=new WeakSet,ye=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!E1.has(e)&&e!==s&&(E1.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 C1={};Ht(C1,{FormController:()=>rO});var rO,$1=Z(()=>{"use strict";Gs();rO=class extends ye{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 P1={};Ht(P1,{DataStreamController:()=>nO});var nO,Q1=Z(()=>{"use strict";Gs();nO=class extends ye{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 T1={};Ht(T1,{SelectionController:()=>oO});var oO,L1=Z(()=>{"use strict";Gs();oO=class extends ye{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 M1={};Ht(M1,{ToggleController:()=>aO});var aO,R1=Z(()=>{"use strict";Gs();aO=class extends ye{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 I1={};Ht(I1,{AccordionController:()=>lO});var lO,D1=Z(()=>{"use strict";Gs();lO=class extends ye{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 q1={};Ht(q1,{StateMachineController:()=>hO});var hO,X1=Z(()=>{"use strict";Gs();hO=class extends ye{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 N1(s,t){qi.controllers.set(s,t)}function B1(s,t){qi.handlers.set(s,t)}function Z1(s,t){qi.resolvers.set(s,t)}async function cd(s){let t=qi.controllers.get(s);return t?t():null}function ud(s){return qi.handlers.get(s)||null}async function jl(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=qi.resolvers.get(r);if(!n)throw new Error(`No resolver for scheme "${r}"`);return n(e,t)}async function PD(s){let{action:t,params:e}=s,i=cO(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=qi.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 QD(s){let{action:t}=s,e=cO(t.value,s);s.updateModel(t.path,e)}async function TD(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 LD(){history.back()}async function MD(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 RD(s){let{action:t,source:e}=s,i=cO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function ID(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function DD(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 cO(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 XD(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 ND(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 BD(s,t){return{_source:s,_mock:!0}}var qi,uO=Z(()=>{"use strict";qi={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>($1(),C1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(Q1(),P1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(L1(),T1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(R1(),M1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(D1(),I1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(X1(),q1))).StateMachineController]]),handlers:new Map([["submit-resource",PD],["update-model",QD],["navigate",TD],["navigate-back",LD],["controller-command",MD],["emit-event",RD],["refresh-source",ID],["notify",DD]]),resolvers:new Map([["resource",XD],["api",ND],["mock",BD]])}});function ZD(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:jl};return s(r)}}function zD(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=ud(t);if(!e)return null;let i=ZD(e);return s.set(t,i),i}}function _D(){return async s=>cd(s)}function jD(){return async(s,t)=>jl(s,{})}function dd(s){let t=[],e=zD(),i=_D(),r=jD();if(s.data?.sources)for(let o of s.data.sources)t.push(new sa(o,r));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new ia(o,i));if(s.actions)for(let o of s.actions)t.push(new ra(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new na(a))}s.lifecycle&&t.push(new oa(s.lifecycle,e));let n=s.state?.model||null;return{dockables:t,initialModel:n}}var dO=Z(()=>{"use strict";Jb();tO();eO();iO();sO();uO()});var z1={};Ht(z1,{WiringEngine:()=>Vl});var Vl,fO=Z(()=>{"use strict";Kb();dO();Vl=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}=dd(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 ea(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 ss,_1=Z(()=>{"use strict";Gb();ss=class s{#t;#e;#i=new Map;#s=new Map;#r=new Map;#n=[];#a=null;#o=!1;constructor(t,e=Nt,{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.#M(t);break;case"wireComponents":this.#u(t);break;case"deleteSurface":this.#C(t);break;case"updateStyles":this.#D(t);break;case"removeStyles":this.#Q(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(()=>(fO(),z1));this.#h=new e({updateDataModel:(i,r,n)=>{this.#M({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.#S(l.variant,l):ad(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#x=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"]);#S(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.#E(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.#x.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()}#E(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.#$(i.dataModel,t.path):t.path}return t}#$(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,r)=>i?.[r],t)}#M({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)}}}#C({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"]);#D({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.#L(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})}#Q({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}))}#L(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.#T(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}}#T(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.#I(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}#I(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 UI,FI,YI,Nb,GI,Zb=Z(()=>{"use strict";si();wi();VA();hi();o1();ei();UI=I.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{padding:"0",caretColor:"inherit"},".cm-focused":{outline:"none"}}),FI=$i.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"}]),YI={json:()=>Promise.resolve().then(()=>(Zx(),Bx)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(xg(),yw)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(pg(),aw)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Nm(),bS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(dk(),uk)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Ck(),Ek)).then(s=>({extension:s.yaml()}))},Nb=1e4;GI=Bl(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}=KI(i,t);return[{from:r,to:n,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function ad(s){return Nt.get(s)||null}function k1(s,t){Nt.set(s,t)}var Nt,Gb=Z(()=>{"use strict";Nt=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 A1(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 $D(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 ld,ea,Kb=Z(()=>{"use strict";ld={provider:0,controller:1,source:2,action:3,lifecycle:4},ea=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?A1(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)=>(ld[i.kind]??9)-(ld[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)=>(ld[i[1].dockable.kind]??9)-(ld[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){$D(this.#e,t,e);for(let[i,r]of this.#s)if(t===i||t.startsWith(i+"/"))for(let n of r)n(A1(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 Oe,Hs=Z(()=>{"use strict";Oe=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 ia,Jb=Z(()=>{"use strict";Hs();ia=class extends Oe{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 sa,tO=Z(()=>{"use strict";Hs();sa=class extends Oe{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 hd,ra,eO=Z(()=>{"use strict";Hs();hd={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"},ra=class extends Oe{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=hd[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 na,iO=Z(()=>{"use strict";Hs();na=class extends Oe{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 oa,sO=Z(()=>{"use strict";Hs();oa=class extends Oe{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 E1,ye,Gs=Z(()=>{"use strict";E1=new WeakSet,ye=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!E1.has(e)&&e!==s&&(E1.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 C1={};Ht(C1,{FormController:()=>rO});var rO,$1=Z(()=>{"use strict";Gs();rO=class extends ye{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 P1={};Ht(P1,{DataStreamController:()=>nO});var nO,Q1=Z(()=>{"use strict";Gs();nO=class extends ye{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 T1={};Ht(T1,{SelectionController:()=>oO});var oO,L1=Z(()=>{"use strict";Gs();oO=class extends ye{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 M1={};Ht(M1,{ToggleController:()=>aO});var aO,R1=Z(()=>{"use strict";Gs();aO=class extends ye{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 I1={};Ht(I1,{AccordionController:()=>lO});var lO,D1=Z(()=>{"use strict";Gs();lO=class extends ye{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 q1={};Ht(q1,{StateMachineController:()=>hO});var hO,X1=Z(()=>{"use strict";Gs();hO=class extends ye{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 N1(s,t){qi.controllers.set(s,t)}function B1(s,t){qi.handlers.set(s,t)}function Z1(s,t){qi.resolvers.set(s,t)}async function cd(s){let t=qi.controllers.get(s);return t?t():null}function ud(s){return qi.handlers.get(s)||null}async function jl(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=qi.resolvers.get(r);if(!n)throw new Error(`No resolver for scheme "${r}"`);return n(e,t)}async function PD(s){let{action:t,params:e}=s,i=cO(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=qi.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 QD(s){let{action:t}=s,e=cO(t.value,s);s.updateModel(t.path,e)}async function TD(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 LD(){history.back()}async function MD(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 RD(s){let{action:t,source:e}=s,i=cO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function ID(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function DD(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 cO(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 XD(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 ND(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 BD(s,t){return{_source:s,_mock:!0}}var qi,uO=Z(()=>{"use strict";qi={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>($1(),C1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(Q1(),P1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(L1(),T1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(R1(),M1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(D1(),I1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(X1(),q1))).StateMachineController]]),handlers:new Map([["submit-resource",PD],["update-model",QD],["navigate",TD],["navigate-back",LD],["controller-command",MD],["emit-event",RD],["refresh-source",ID],["notify",DD]]),resolvers:new Map([["resource",XD],["api",ND],["mock",BD]])}});function ZD(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:jl};return s(r)}}function zD(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=ud(t);if(!e)return null;let i=ZD(e);return s.set(t,i),i}}function _D(){return async s=>cd(s)}function jD(){return async(s,t)=>jl(s,{})}function dd(s){let t=[],e=zD(),i=_D(),r=jD();if(s.data?.sources)for(let o of s.data.sources)t.push(new sa(o,r));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new ia(o,i));if(s.actions)for(let o of s.actions)t.push(new ra(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new na(a))}s.lifecycle&&t.push(new oa(s.lifecycle,e));let n=s.state?.model||null;return{dockables:t,initialModel:n}}var dO=Z(()=>{"use strict";Jb();tO();eO();iO();sO();uO()});var z1={};Ht(z1,{WiringEngine:()=>Vl});var Vl,fO=Z(()=>{"use strict";Kb();dO();Vl=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}=dd(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 ea(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 ss,_1=Z(()=>{"use strict";Gb();ss=class s{#t;#e;#i=new Map;#s=new Map;#r=new Map;#n=[];#a=null;#o=!1;constructor(t,e=Nt,{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.#M(t);break;case"wireComponents":this.#u(t);break;case"deleteSurface":this.#C(t);break;case"updateStyles":this.#D(t);break;case"removeStyles":this.#Q(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(()=>(fO(),z1));this.#h=new e({updateDataModel:(i,r,n)=>{this.#M({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.#S(l.variant,l):ad(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.#b(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"]);#O=new Set;#b(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let 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.#O.has(u)||(this.#O.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#x=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"]);#S(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.#E(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.#x.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()}#E(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.#$(i.dataModel,t.path):t.path}return t}#$(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,r)=>i?.[r],t)}#M({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)}}}#C({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"]);#D({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.#L(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})}#Q({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}))}#L(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.#T(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}}#T(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.#I(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}#I(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 fd(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 pd(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 W1(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function md(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?VD(s,t):V1(s,t)}function j1(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 VD(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);j1(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 V1(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",nr);C();var or=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",or);C();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 iC=s=>s.getAttribute?.("role")==="presentation"||s.style?.display==="contents";function sC(s){let t=[],e=i=>{for(let r of i)if(r.nodeType===1){if(iC(r)){e(r.children);continue}t.push(r)}};return s&&e(s.children),t}function at(s,t){return sC(s).filter(e=>e.getAttribute("slot")===t)}var ty=s=>yh(s)?`<icon-ui name="${s}"></icon-ui>`:s,ar=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=at(this,"leading"),e=at(this,"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.#$(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.#B),this.#p&&this.#t.addEventListener("beforeinput",this.#D)),this.#i?.addEventListener("pointerdown",this.#j),this.#s?.addEventListener("pointerdown",this.#V),(this.prefix||this.suffix)&&bh.then(()=>this.#b())}#m(t){let e=this.prefix?`<span slot="prefix">${ty(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",r=this.suffix?`<span slot="suffix">${ty(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",nr);C();var or=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",or);C();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 iC=s=>s.getAttribute?.("role")==="presentation"||s.style?.display==="contents";function sC(s){let t=[],e=i=>{for(let r of i)if(r.nodeType===1){if(iC(r)){e(r.children);continue}t.push(r)}};return s&&e(s.children),t}function at(s,t){return sC(s).filter(e=>e.getAttribute("slot")===t)}var ty=s=>yh(s)?`<icon-ui name="${s}"></icon-ui>`:s,ar=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=at(this,"leading"),e=at(this,"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.#$(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.#B),this.#p&&this.#t.addEventListener("beforeinput",this.#D)),this.#i?.addEventListener("pointerdown",this.#j),this.#s?.addEventListener("pointerdown",this.#V),(this.prefix||this.suffix)&&bh.then(()=>this.#O())}#m(t){let e=this.prefix?`<span slot="prefix">${ty(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",r=this.suffix?`<span slot="suffix">${ty(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,7 +89,7 @@ ${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")&&yh(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&&yh(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.#$(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)}#x(){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.#S(),this.#o):"."}#w(){return this.locale?this.#c===this.locale?this.#l:(this.#S(),this.#l):""}#S(){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.#x();if(this.locale)try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!1}).format(t)}catch{}return e>0?t.toFixed(e):String(Math.round(t))}#E(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#A(t);let e=this.#x();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#A(t)}}#$(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.#E(i):e}#M(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))}#C(t){if(this.disabled||this.readonly)return;let e=(this.step||1)*t,i=Number.isFinite(this.valueAsNumber)?this.valueAsNumber:this.min!=null?this.min:0,r=this.#M(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.#L(e),t!==e&&(this.#t.textContent=t,this.#I())}else t=this.#t.textContent||"";this.value=t,this.#f||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#D=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.#T(h.startContainer,h.startOffset),a=this.#T(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=r.slice(0,o)+i+r.slice(a);this.#Q(l)||t.preventDefault()};#Q(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)}#L(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}#T(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}#I(){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.#C(1);return;case"ArrowDown":t.preventDefault(),this.#C(-1);return;case"PageUp":t.preventDefault(),this.#C(10);return;case"PageDown":t.preventDefault(),this.#C(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#_(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#_(this.max));return;case"Escape":t.preventDefault(),this.value=this.#r,this.#t.textContent=this.#$(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#z(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0}));return}return}t.key==="Enter"&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#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.#z(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#z(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#M(e),r=this.#A(i),n=this.#E(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))}#_(t){let e=this.#M(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}})))}#B=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#p?this.#L(e):e;document.execCommand("insertText",!1,i)};#j=t=>this.#Y(t,1);#V=t=>this.#Y(t,-1);#Y(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#C(e),this.#N(),document.addEventListener("pointerup",this.#W,{once:!0}),document.addEventListener("pointercancel",this.#W,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#n=window.setInterval(()=>{let i=this.valueAsNumber;this.#C(e),this.valueAsNumber===i&&this.#N()},s.#d)},s.#u))}#W=()=>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.#W),document.removeEventListener("pointercancel",this.#W)}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.#B),this.#t.removeEventListener("beforeinput",this.#D)),this.#i?.removeEventListener("pointerdown",this.#j),this.#s?.removeEventListener("pointerdown",this.#V),this.#N(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};S("input-ui",ar);var lr=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)}}}#O(){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")&&yh(e)){i.replaceChildren();let r=document.createElement("icon-ui");r.setAttribute("name",e),i.appendChild(r)}}}#b(){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&&yh(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.#$(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.#b(),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)}#x(){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.#S(),this.#o):"."}#w(){return this.locale?this.#c===this.locale?this.#l:(this.#S(),this.#l):""}#S(){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.#x();if(this.locale)try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!1}).format(t)}catch{}return e>0?t.toFixed(e):String(Math.round(t))}#E(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#A(t);let e=this.#x();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#A(t)}}#$(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.#E(i):e}#M(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))}#C(t){if(this.disabled||this.readonly)return;let e=(this.step||1)*t,i=Number.isFinite(this.valueAsNumber)?this.valueAsNumber:this.min!=null?this.min:0,r=this.#M(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.#L(e),t!==e&&(this.#t.textContent=t,this.#I())}else t=this.#t.textContent||"";this.value=t,this.#f||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#D=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.#T(h.startContainer,h.startOffset),a=this.#T(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=r.slice(0,o)+i+r.slice(a);this.#Q(l)||t.preventDefault()};#Q(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)}#L(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}#T(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}#I(){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.#C(1);return;case"ArrowDown":t.preventDefault(),this.#C(-1);return;case"PageUp":t.preventDefault(),this.#C(10);return;case"PageDown":t.preventDefault(),this.#C(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#_(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#_(this.max));return;case"Escape":t.preventDefault(),this.value=this.#r,this.#t.textContent=this.#$(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#z(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0}));return}return}t.key==="Enter"&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#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.#z(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#z(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#M(e),r=this.#A(i),n=this.#E(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))}#_(t){let e=this.#M(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}})))}#B=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#p?this.#L(e):e;document.execCommand("insertText",!1,i)};#j=t=>this.#Y(t,1);#V=t=>this.#Y(t,-1);#Y(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#C(e),this.#N(),document.addEventListener("pointerup",this.#W,{once:!0}),document.addEventListener("pointercancel",this.#W,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#n=window.setInterval(()=>{let i=this.valueAsNumber;this.#C(e),this.valueAsNumber===i&&this.#N()},s.#d)},s.#u))}#W=()=>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.#W),document.removeEventListener("pointercancel",this.#W)}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.#B),this.#t.removeEventListener("beforeinput",this.#D)),this.#i?.removeEventListener("pointerdown",this.#j),this.#s?.removeEventListener("pointerdown",this.#V),this.#N(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};S("input-ui",ar);var lr=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=""'}
@@ -116,7 +116,7 @@ ${i.join(`
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.#x),e.addEventListener("pointerup",this.#v)};#x=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.#x),e?.removeEventListener("pointerup",this.#v),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#O(),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.#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()}};#S=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.#w),this.removeEventListener("keydown",this.#S),this.#e=null,this.#i=null,this.#s=null,this.#r=null}};S("slider-ui",pr);var aC=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,lC=0;function ut(s,t,e={}){let{placement:i="bottom-start",gap:r=4,matchWidth:n=!1}=e;return aC?hC(s,t,{placement:i,gap:r,matchWidth:n}):fC(s,t,{placement:i,gap:r,matchWidth:n})}function hC(s,t,{placement:e,gap:i,matchWidth:r}){let n=`--a-anchor-${++lC}`,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};s.style.anchorName=n;let l=e;if(e.startsWith("bottom")||e.startsWith("top")){let h=s.getBoundingClientRect(),u=window.innerHeight-h.bottom-i*2,d=h.top-i*2,f=cC(getComputedStyle(t).getPropertyValue("--popover-max-height")),p=Number.isFinite(f)?f:t.scrollHeight||0,m=e.startsWith("bottom"),b=p<=u,g=p<=d,y=m;m&&!b?y=g?!1:u>=d:!m&&!g&&(y=b?!0:u>d),l=e.replace(/^(bottom|top)/,y?"bottom":"top");let v=Math.max(40,Math.floor(y?u:d));t.style.maxHeight=`${Number.isFinite(f)?Math.min(f,v):v}px`}return t.style.position="fixed",t.style.positionAnchor=n,t.style.positionArea=dC(l),t.style.margin=uC(l,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))",!l.startsWith("bottom")&&!l.startsWith("top")&&(t.style.maxHeight="calc(100vh - 3rem)"),t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName=o;for(let[h,c]of Object.entries(a))t.style[h]=c}}function cC(s){let t=String(s||"").trim();if(!t)return NaN;let e=/^(-?\d+(?:\.\d+)?)(px|rem)$/.exec(t);if(!e)return NaN;let i=parseFloat(e[1]);if(e[2]==="px")return i;let r=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return i*r}function uC(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 dC(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 fC(s,t,{placement:e,gap:i,matchWidth:r}){let n=t.style.maxHeight,o=t.style.overflowY;function a(){if(!s||!t)return;t.style.maxHeight=n,t.style.overflowY=o;let h=s.getBoundingClientRect(),c=t.getBoundingClientRect(),u=window.innerWidth,d=window.innerHeight,f=e;if(f.startsWith("bottom")||f.startsWith("top")){let b=d-h.bottom-i*2,g=h.top-i*2,y=f.startsWith("bottom"),v=c.height<=b,w=c.height<=g,k=y;y&&!v?k=w?!1:b>=g:!y&&!w&&(k=v?!0:b>g),f=f.replace(/^(bottom|top)/,k?"bottom":"top");let E=Math.max(0,Math.floor(k?b:g));c.height>E&&(t.style.maxHeight=`${E}px`,t.style.overflowY="auto",c=t.getBoundingClientRect())}let p,m;f.startsWith("top")?p=h.top-c.height-i:f.startsWith("bottom")?p=h.bottom+i:f.startsWith("left")?(m=h.left-c.width-i,f==="left-start"?p=h.top:f==="left-end"?p=h.bottom-c.height:p=h.top+(h.height-c.height)/2):f.startsWith("right")&&(m=h.right+i,f==="right-start"?p=h.top:f==="right-end"?p=h.bottom-c.height:p=h.top+(h.height-c.height)/2),m===void 0&&(f.endsWith("-start")?m=h.left:f.endsWith("-end")?m=h.right-c.width:m=h.left+(h.width-c.width)/2),m+c.width>u-i&&(m=h.right-c.width),m<i&&(m=h.left),(f.startsWith("left")||f.startsWith("right"))&&(p=Math.max(i,Math.min(p,d-c.height-i))),m=Math.max(i,Math.min(m,u-c.width-i)),t.style.position="fixed",t.style.top=`${p}px`,t.style.left=`${m}px`,r&&(t.style.width=`${h.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{a(),t.style.opacity=""});let l=pC(s);for(let h of l)h.addEventListener("scroll",a,{passive:!0});return window.addEventListener("resize",a,{passive:!0}),()=>{for(let h of l)h.removeEventListener("scroll",a);window.removeEventListener("resize",a),t.style.maxHeight=n,t.style.overflowY=o}}function pC(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}$t();function qt(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var mr=class s extends M{static labelDeprecated=!1;static requiredIcons=["caret-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=null;#h=()=>{this.disabled||(this.open=!0)};#u=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({})}#f(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#p(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.#f(),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.#p(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.#p(t.map(o=>o.value));if(e===this.value)return;let i=this.#f();this.value=e,this.syncValue(e),this.render();let r=this.#f(),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.#f();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#m(){let t=this.#f();if(t.length===0)return;let e=t.pop(),i=this.#p(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#g=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.#f().filter(o=>o!==i),n=this.#p(r);this.value=n,this.syncValue(n),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:[],removed:[i]}}))};#b=t=>{t.stopPropagation(),!this.disabled&&(this.open=!0)};#O=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.#f());i.length>0&&i.every(o=>r.has(o))?this.clear():this.selectAllOptions()};#x=!1;#v(){let t="Select...",e=this.hasAttribute("aria-label")&&!this.#x,i=!!this.label||this.hasAttribute("aria-labelledby");!e&&!i&&this.placeholder&&this.placeholder!==t?(this.setAttribute("aria-label",this.placeholder),this.#x=!0):this.#x&&(this.removeAttribute("aria-label"),this.#x=!1)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#P),this.addEventListener("keydown",this.#Q),this.addEventListener("remove",this.#g),this.#i.length===0&&this.#S(),this.#c||(this.#c=new MutationObserver(()=>{if(!(this.#i.length||!this.#w().some(e=>e.tagName==="OPTION"||e.tagName==="OPTGROUP"))&&(this.#S(),this.#i.length)){this.#E();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#C())}})),this.#c.observe(this,{childList:!0,subtree:!0})}render(){if(this.multiple?this.setAttribute("data-multi-chips",""):this.removeAttribute("data-multi-chips"),this.#v(),this.querySelector('[slot="trigger"]')){let e=this.querySelector('[slot="display"]');if(e&&!this.multiple)e.tagName==="INPUT"?this.#a||(e.value=this.#C()===this.placeholder?"":this.#C()):e.textContent=this.#C();else if(e&&this.multiple){let i=this.#f().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="${qt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${qt(this.icon)}"></icon-ui>`:"",r=this.searchable?`<input slot="display" type="text" role="combobox" aria-autocomplete="list" autocomplete="off" placeholder="${qt(this.placeholder||"")}" value="${qt(this.#C()===this.placeholder?"":this.#C())}" />`:`<span slot="display">${qt(this.#C())}</span>`,n=this.hint?`select-hint-${++s.#e}`:"",o=this.hint?`<span slot="hint" id="${n}">${qt(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.#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())}#O(t){let e=Math.max(Math.min(t,this.max),this.lowerValue);e!==this.upperValue&&(this.upperValue=e,this.scheduleThrottledInput())}#b(){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.#x),e.addEventListener("pointerup",this.#v)};#x=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.#O(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.#x),e?.removeEventListener("pointerup",this.#v),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#b(),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.#d(t.clientX,"lower")):this.#O(this.#d(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#d(t.clientX))}this.flushPendingInput(),this.#b()}};#S=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.#O(a)}else{let r=i!==null?i:this.value+e;this.#m(this.#p(r))}this.flushPendingInput(),this.#b()};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.#w),this.removeEventListener("keydown",this.#S),this.#e=null,this.#i=null,this.#s=null,this.#r=null}};S("slider-ui",pr);var aC=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,lC=0;function ut(s,t,e={}){let{placement:i="bottom-start",gap:r=4,matchWidth:n=!1}=e;return aC?hC(s,t,{placement:i,gap:r,matchWidth:n}):fC(s,t,{placement:i,gap:r,matchWidth:n})}function hC(s,t,{placement:e,gap:i,matchWidth:r}){let n=`--a-anchor-${++lC}`,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};s.style.anchorName=n;let l=e;if(e.startsWith("bottom")||e.startsWith("top")){let h=s.getBoundingClientRect(),u=window.innerHeight-h.bottom-i*2,d=h.top-i*2,f=cC(getComputedStyle(t).getPropertyValue("--popover-max-height")),p=Number.isFinite(f)?f:t.scrollHeight||0,m=e.startsWith("bottom"),b=p<=u,g=p<=d,y=m;m&&!b?y=g?!1:u>=d:!m&&!g&&(y=b?!0:u>d),l=e.replace(/^(bottom|top)/,y?"bottom":"top");let v=Math.max(40,Math.floor(y?u:d));t.style.maxHeight=`${Number.isFinite(f)?Math.min(f,v):v}px`}return t.style.position="fixed",t.style.positionAnchor=n,t.style.positionArea=dC(l),t.style.margin=uC(l,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))",!l.startsWith("bottom")&&!l.startsWith("top")&&(t.style.maxHeight="calc(100vh - 3rem)"),t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName=o;for(let[h,c]of Object.entries(a))t.style[h]=c}}function cC(s){let t=String(s||"").trim();if(!t)return NaN;let e=/^(-?\d+(?:\.\d+)?)(px|rem)$/.exec(t);if(!e)return NaN;let i=parseFloat(e[1]);if(e[2]==="px")return i;let r=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return i*r}function uC(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 dC(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 fC(s,t,{placement:e,gap:i,matchWidth:r}){let n=t.style.maxHeight,o=t.style.overflowY;function a(){if(!s||!t)return;t.style.maxHeight=n,t.style.overflowY=o;let h=s.getBoundingClientRect(),c=t.getBoundingClientRect(),u=window.innerWidth,d=window.innerHeight,f=e;if(f.startsWith("bottom")||f.startsWith("top")){let b=d-h.bottom-i*2,g=h.top-i*2,y=f.startsWith("bottom"),v=c.height<=b,w=c.height<=g,k=y;y&&!v?k=w?!1:b>=g:!y&&!w&&(k=v?!0:b>g),f=f.replace(/^(bottom|top)/,k?"bottom":"top");let E=Math.max(0,Math.floor(k?b:g));c.height>E&&(t.style.maxHeight=`${E}px`,t.style.overflowY="auto",c=t.getBoundingClientRect())}let p,m;f.startsWith("top")?p=h.top-c.height-i:f.startsWith("bottom")?p=h.bottom+i:f.startsWith("left")?(m=h.left-c.width-i,f==="left-start"?p=h.top:f==="left-end"?p=h.bottom-c.height:p=h.top+(h.height-c.height)/2):f.startsWith("right")&&(m=h.right+i,f==="right-start"?p=h.top:f==="right-end"?p=h.bottom-c.height:p=h.top+(h.height-c.height)/2),m===void 0&&(f.endsWith("-start")?m=h.left:f.endsWith("-end")?m=h.right-c.width:m=h.left+(h.width-c.width)/2),m+c.width>u-i&&(m=h.right-c.width),m<i&&(m=h.left),(f.startsWith("left")||f.startsWith("right"))&&(p=Math.max(i,Math.min(p,d-c.height-i))),m=Math.max(i,Math.min(m,u-c.width-i)),t.style.position="fixed",t.style.top=`${p}px`,t.style.left=`${m}px`,r&&(t.style.width=`${h.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{a(),t.style.opacity=""});let l=pC(s);for(let h of l)h.addEventListener("scroll",a,{passive:!0});return window.addEventListener("resize",a,{passive:!0}),()=>{for(let h of l)h.removeEventListener("scroll",a);window.removeEventListener("resize",a),t.style.maxHeight=n,t.style.overflowY=o}}function pC(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}$t();function qt(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var mr=class s extends M{static labelDeprecated=!1;static requiredIcons=["caret-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=null;#h=()=>{this.disabled||(this.open=!0)};#u=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({})}#f(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#p(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.#f(),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.#p(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.#p(t.map(o=>o.value));if(e===this.value)return;let i=this.#f();this.value=e,this.syncValue(e),this.render();let r=this.#f(),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.#f();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#m(){let t=this.#f();if(t.length===0)return;let e=t.pop(),i=this.#p(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#g=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.#f().filter(o=>o!==i),n=this.#p(r);this.value=n,this.syncValue(n),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:[],removed:[i]}}))};#O=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.#f());i.length>0&&i.every(o=>r.has(o))?this.clear():this.selectAllOptions()};#x=!1;#v(){let t="Select...",e=this.hasAttribute("aria-label")&&!this.#x,i=!!this.label||this.hasAttribute("aria-labelledby");!e&&!i&&this.placeholder&&this.placeholder!==t?(this.setAttribute("aria-label",this.placeholder),this.#x=!0):this.#x&&(this.removeAttribute("aria-label"),this.#x=!1)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#P),this.addEventListener("keydown",this.#Q),this.addEventListener("remove",this.#g),this.#i.length===0&&this.#S(),this.#c||(this.#c=new MutationObserver(()=>{if(!(this.#i.length||!this.#w().some(e=>e.tagName==="OPTION"||e.tagName==="OPTGROUP"))&&(this.#S(),this.#i.length)){this.#E();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#C())}})),this.#c.observe(this,{childList:!0,subtree:!0})}render(){if(this.multiple?this.setAttribute("data-multi-chips",""):this.removeAttribute("data-multi-chips"),this.#v(),this.querySelector('[slot="trigger"]')){let e=this.querySelector('[slot="display"]');if(e&&!this.multiple)e.tagName==="INPUT"?this.#a||(e.value=this.#C()===this.placeholder?"":this.#C()):e.textContent=this.#C();else if(e&&this.multiple){let i=this.#f().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="${qt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${qt(this.icon)}"></icon-ui>`:"",r=this.searchable?`<input slot="display" type="text" role="combobox" aria-autocomplete="list" autocomplete="off" placeholder="${qt(this.placeholder||"")}" value="${qt(this.#C()===this.placeholder?"":this.#C())}" />`:`<span slot="display">${qt(this.#C())}</span>`,n=this.hint?`select-hint-${++s.#e}`:"",o=this.hint?`<span slot="hint" id="${n}">${qt(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-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.#O),a.addEventListener("click",this.#O)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#L),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#L),this.#o.addEventListener("focus",this.#h),this.#o.addEventListener("click",this.#u))),e&&this.appendChild(e)}this.#A(),this.multiple&&this.#M();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#f().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.#E()),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=ut(e,this.#r,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#D,{once:!0})})}else this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#D)}#w(){let t=[],e=i=>{for(let r of i.children)if(!r.hasAttribute("slot")){if(r.tagName==="OPTION"||r.tagName==="OPTGROUP"){t.push(r);continue}if(r.matches('[role="presentation"]')||r.style?.display==="contents"){e(r);continue}t.push(r)}};return e(this),t}#S(){this.#i=[];let t=new Set,e=[];for(let i of this.#w())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.#E();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#C())})}get options(){return this.#i}static#k(t){return t?t.avatar?`<img data-option-avatar src="${qt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${qt(t.icon)}"></icon-ui>`:"":""}#A(){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="${qt(r)}" alt="" />`:n&&(a=`<icon-ui slot="leading" data-select-leading name="${qt(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)}#E(){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.#$()?"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.#k(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}${qt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else o?i.innerHTML=`${o}${qt(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>${qt(e.label)}</strong><span>${qt(e.description||"")}</span></div>`:`<div><strong>${qt(e.label)}</strong><span>${qt(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">${qt(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.#T()}#$(){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.#f());return t.every(i=>e.has(String(i.value)))}#M(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;let e=this.#f(),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.#b),t.appendChild(l)}}#C(){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}#P=t=>{this.disabled||this.#r&&t.composedPath().includes(this.#r)||(this.open=!this.open)};#D=t=>{!this.contains(t.target)&&!(this.#r&&t.composedPath().includes(this.#r))&&(this.open=!1)};#Q=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.#f().length>0){t.preventDefault(),this.#m();return}}if(t.key==="Escape"){if(this.searchable&&this.#a){this.#a="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#T();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.#I(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#I(-1))};#L=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#T()};#T(){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")}#I(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.#P),this.removeEventListener("keydown",this.#Q),this.removeEventListener("remove",this.#g),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#D),this.#o&&(this.#o.removeEventListener("input",this.#L),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u),this.#o=null),this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#r=null}};S("select-ui",mr);C();var gr=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",gr);var br=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",br);var Or=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.#L),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#L),this.#o.addEventListener("focus",this.#h),this.#o.addEventListener("click",this.#u))),e&&this.appendChild(e)}this.#A(),this.multiple&&this.#M();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#f().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.#E()),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=ut(e,this.#r,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#D,{once:!0})})}else this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#D)}#w(){let t=[],e=i=>{for(let r of i.children)if(!r.hasAttribute("slot")){if(r.tagName==="OPTION"||r.tagName==="OPTGROUP"){t.push(r);continue}if(r.matches('[role="presentation"]')||r.style?.display==="contents"){e(r);continue}t.push(r)}};return e(this),t}#S(){this.#i=[];let t=new Set,e=[];for(let i of this.#w())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.#E();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#C())})}get options(){return this.#i}static#k(t){return t?t.avatar?`<img data-option-avatar src="${qt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${qt(t.icon)}"></icon-ui>`:"":""}#A(){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="${qt(r)}" alt="" />`:n&&(a=`<icon-ui slot="leading" data-select-leading name="${qt(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)}#E(){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.#$()?"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.#k(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}${qt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else o?i.innerHTML=`${o}${qt(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>${qt(e.label)}</strong><span>${qt(e.description||"")}</span></div>`:`<div><strong>${qt(e.label)}</strong><span>${qt(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">${qt(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.#T()}#$(){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.#f());return t.every(i=>e.has(String(i.value)))}#M(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;let e=this.#f(),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.#O),t.appendChild(l)}}#C(){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}#P=t=>{this.disabled||this.#r&&t.composedPath().includes(this.#r)||(this.open=!this.open)};#D=t=>{!this.contains(t.target)&&!(this.#r&&t.composedPath().includes(this.#r))&&(this.open=!1)};#Q=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.#f().length>0){t.preventDefault(),this.#m();return}}if(t.key==="Escape"){if(this.searchable&&this.#a){this.#a="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#T();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.#I(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#I(-1))};#L=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#T()};#T(){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")}#I(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.#P),this.removeEventListener("keydown",this.#Q),this.removeEventListener("remove",this.#g),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#D),this.#o&&(this.#o.removeEventListener("input",this.#L),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u),this.#o=null),this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#r=null}};S("select-ui",mr);C();var gr=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",gr);var br=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",br);var Or=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>`:""}
@@ -142,7 +142,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
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",$a);var mC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},iy=s=>s.replace(/[&<>"]/g,t=>mC[t]);function ui(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.#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.#O()},i.readAsDataURL(e)}}#g(t){this.#n.splice(t,1),this.#O()}#O(){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",$a);var mC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},iy=s=>s.replace(/[&<>"]/g,t=>mC[t]);function ui(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(iy(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}>${Ah(o[2])}</h${l}>`),i++;continue}if(/^[-*]\s/.test(r)){let l=[];for(;i<t.length&&/^[-*]\s/.test(t[i]);)l.push(`<li>${Ah(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>${Ah(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>${Ah(a.join(" "))}</p>`)}return e.join(`
148
148
  `)}function Ah(s){return iy(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>')}C();function gC(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var wr=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?ui(e):gC(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=ui(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",wr);C();var kr=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",kr);C();var Ar=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",Ar);C();var Er=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")}},Cr=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",Er),S("feed-item-ui",Cr),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&Ze.post(s.detail)}));C();var hs=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",hs),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&hs.show(s.detail)}));C();var Pa=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",Pa);C();var $r=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",$r);C();var Pr=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=ut(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",Pr);C();var bC={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"}},Qr=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=bC[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",Qr);C();var Tr=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",Tr);C();var Lr=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.#w(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.#x(i)};connected(){this.#o||(this.#o=!0,this.addEventListener("keydown",this.#A))}render(){this.#s||(this.#f(),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=ui(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",wr);C();var kr=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",kr);C();var Ar=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",Ar);C();var Er=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")}},Cr=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",Er),S("feed-item-ui",Cr),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&Ze.post(s.detail)}));C();var hs=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",hs),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&hs.show(s.detail)}));C();var Pa=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",Pa);C();var $r=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",$r);C();var Pr=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=ut(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.#O(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.#O(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.#O(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`}#O(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}};S("tooltip-ui",Pr);C();var bC={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"}},Qr=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=bC[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",Qr);C();var Tr=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",Tr);C();var Lr=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.#w(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.#x(i)};connected(){this.#o||(this.#o=!0,this.addEventListener("keydown",this.#A))}render(){this.#s||(this.#f(),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.#k),this.#r.addEventListener("click",this.#h),this.#r.addEventListener("pointerover",this.#u),this.#m()),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.#m(e)}focus(){this.#s?.focus()}setItems(t){this.#t=t,this.#m()}#d(){let t=[],e=i=>{for(let r of i.children)if(!r.hasAttribute("slot")){if(r.tagName==="OPTION"||r.tagName==="OPTGROUP"){t.push(r);continue}if(r.matches('[role="presentation"]')||r.style?.display==="contents"){e(r);continue}}};return e(this),t}#f(){let t=[];for(let e of this.#d())if(e.tagName==="OPTGROUP"){let i=e.label,r={label:i,items:[]};for(let n of e.querySelectorAll("option"))r.items.push(this.#p(n,i));t.push(r)}else e.tagName==="OPTION"&&t.push(this.#p(e,""));this.#t=t}#p(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}}#m(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.#g(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.#O(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.#O(l,r)),r++;this.#r.appendChild(a)}else{if(!this.#y(n,e))continue;this.#r.appendChild(this.#O(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.#x(0)}#g(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}#b(t){t&&(this.#e=[t,...this.#e.filter(e=>e!==t)].slice(0,s.#c))}#O(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.#k),this.#r.addEventListener("click",this.#h),this.#r.addEventListener("pointerover",this.#u),this.#m()),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.#m(e)}focus(){this.#s?.focus()}setItems(t){this.#t=t,this.#m()}#d(){let t=[],e=i=>{for(let r of i.children)if(!r.hasAttribute("slot")){if(r.tagName==="OPTION"||r.tagName==="OPTGROUP"){t.push(r);continue}if(r.matches('[role="presentation"]')||r.style?.display==="contents"){e(r);continue}}};return e(this),t}#f(){let t=[];for(let e of this.#d())if(e.tagName==="OPTGROUP"){let i=e.label,r={label:i,items:[]};for(let n of e.querySelectorAll("option"))r.items.push(this.#p(n,i));t.push(r)}else e.tagName==="OPTION"&&t.push(this.#p(e,""));this.#t=t}#p(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}}#m(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.#g(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.#x(0)}#g(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}#O(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}#y(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#x(t){let e=this.#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)}#v(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.#x(parseInt(e[n].dataset.idx))}#w(t){this.#b(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.#g(e))?.category||"";this.#b(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:n}}))}#k=()=>{this.#m(this.#s.value)};#A=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#v(1);break;case"ArrowUp":t.preventDefault(),this.#v(-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.#A),this.#s?.removeEventListener("input",this.#k),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",Lr);var Qa=.4;function zd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function _d(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 di(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function jd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function sy(s,t,e){let{a:i,b:r}=zd(s,t,e),[n,o,a]=_d(s,i,r);return[Math.max(0,Math.min(1,di(n))),Math.max(0,Math.min(1,di(o))),Math.max(0,Math.min(1,di(a)))]}function OC(s,t,e){let i=r=>Math.round(r*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Mr(s,t,e){let[i,r,n]=sy(s,t,e);return OC(i,r,n)}function yC(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=jd(parseInt(s.slice(0,2),16)/255),e=jd(parseInt(s.slice(2,4),16)/255),i=jd(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 ry(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Ta(s,t,e){let{a:i,b:r}=zd(s,t,e),[n,o,a]=_d(s,i,r);if(ry(di(n),di(o),di(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=zd(s,u,e),[p,m,b]=_d(s,d,f);ry(di(p),di(m),di(b))?l=u:h=u}return l}var Rr=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;#x=[];#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.#T("input")};#S=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#D(t))};#k=t=>{this.#a==="area"&&this.#D(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#T("change"))};#E=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#Q(t))};#$=t=>{this.#a==="hue"&&this.#Q(t)};#M=()=>{this.#a==="hue"&&(this.#a=null,this.#T("change"))};#C=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(Qa,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.#T("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.#T("change")};connected(){if(super.connected(),this.#L(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.#w),t.appendChild(c),c};this.#b=e("H","hue",0,360,1),this.#O=e("C","chroma",0,Qa,.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.#x.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.#S),this.#h.addEventListener("pointermove",this.#k),this.#h.addEventListener("pointerup",this.#A),this.#d.addEventListener("pointerdown",this.#E),this.#d.addEventListener("pointermove",this.#$),this.#d.addEventListener("pointerup",this.#M),this.#h.addEventListener("keydown",this.#C),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.#S),this.#h.removeEventListener("pointermove",this.#k),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#C)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#E),this.#d.removeEventListener("pointermove",this.#$),this.#d.removeEventListener("pointerup",this.#M),this.#d.removeEventListener("keydown",this.#P)),this.#b?.removeEventListener("input",this.#w),this.#O?.removeEventListener("input",this.#w),this.#y?.removeEventListener("input",this.#w);for(let{el:t,handler:e}of this.#x)t.removeEventListener("click",e);this.#x=[],this.#n=!1}#D(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*Qa,this.#e=1-r,this.#T("input")}#Q(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#T("input")}#L(t){if(t){if(t.startsWith("#")){let e=yC(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.`))}}}#T(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=Ta(this.#e,this.#i,this.#s),r=Mr(this.#e,i,this.#s),n=this.#I();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}))}#I(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#X(t,e){let i=t==="oklch"?this.#I():Mr(this.#e,Ta(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)*Qa,u=Ta(l,c,o),[d,f,p]=sy(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.#L(this.value),this.#q(),this.#u){let n=this.#i/Qa*100,o=(1-this.#e)*100;this.#u.style.left=`${n}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Mr(this.#e,Ta(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let n=[];for(let o=0;o<=360;o+=30)n.push(Mr(.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=Mr(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#I());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=Mr(this.#e,Ta(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#I()),this.#m&&(this.#m.textContent=r)}onFormReset(){this.value="#3b82f6"}};S("color-picker-ui",Rr);var Ir=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",Ir);C();var Vd=0,Dr=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-${++Vd}`,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-${++Vd}`,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.#u();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.#S(),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.#x(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}}}#x(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#v(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#w(){this.#d(),this.#S();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.#E(a,e,r)),this.appendChild(o),this.#i.set(n,o)}}this.#k(),this.#u()}#S(){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${++Vd}`),`${t._noodleId}:${e}`}#E=(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.#$(n,{x:c,y:u})),this.#h(),this.#M(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.#C(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)};#$(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"}#M(t,e,i){this.#P();let r=this.#C(t,e,i);r?.dot&&r.dot.setAttribute("data-noodle-drop-ready","")}#C(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",Dr);var Ni={};function xe(s,t){Ni[s]=t}function qr(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 Wd={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()};xe("text",{render(s,t,e){qr(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),xe("number",{render(s,t,e){qr(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),xe("currency",{render(s,t,e,i){qr(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"}),xe("percent",{render(s,t,e){qr(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var ny={year:"numeric",month:"short",day:"numeric"};xe("date",{render(s,t,e){qr(e,s?new Intl.DateTimeFormat("en-US",ny).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",ny).format(new Date(s)):""},align:"left",sortFn:"datetime"});var oy={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};xe("datetime",{render(s,t,e){qr(e,s?new Intl.DateTimeFormat("en-US",oy).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",oy).format(new Date(s)):""},align:"left",sortFn:"datetime"}),xe("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"}),xe("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"}),xe("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"}),xe("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"}),xe("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"}),xe("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});C();function vC(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 fi(s,t){return typeof t.accessor=="function"?t.accessor(s):vC(s,t.key)}function Eh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
176
- `)?'"'+t.replace(/"/g,'""')+'"':t}var Xr=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.#L),this.addEventListener("keydown",this.#z),this.addEventListener("pointerdown",this.#Q))}disconnected(){this.removeEventListener("click",this.#L),this.removeEventListener("keydown",this.#z),this.removeEventListener("pointerdown",this.#Q),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)}#x(){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=fi(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=fi(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=fi(this.#e[e],o||{key:r}),l=fi(this.#e[i],o||{key:r}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Ni[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Wd[d]||Wd.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#S(){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.#x();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.#D();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.#E(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.#$(i),this.#M(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.#C(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.#E(i,t,e),i}#E(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=fi(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=Ni[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=Ni[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])}#$(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()}#M(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=fi(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=Ni[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])}#C(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=fi(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}#D(){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)}#Q=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.#I(t,e))};#L=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.#I(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?fi(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}}))}}};#T=null;#I(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.#T={key:i,col:r,startX:a,startWidth:o},document.addEventListener("pointermove",this.#X),document.addEventListener("pointerup",this.#q)}#X=t=>{if(!this.#T)return;let{key:e,col:i,startX:r,startWidth:n}=this.#T,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.#x()};#q=t=>{if(!this.#T)return;let{key:e}=this.#T;document.removeEventListener("pointermove",this.#X),document.removeEventListener("pointerup",this.#q),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#T=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.#T=null}#z=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.#_())};#_(){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=>Eh(c.label||c.key)),n=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=fi(u,d);if(typeof d.format=="function")return Eh(d.format(f,u));let p=Ni[d.type||"text"];return p?.format?Eh(p.format(f,u,d.meta)):Eh(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",Xr);C();var xC=200;function Ud(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 Fd(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 SC=50,ay=500;function ly(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 wC(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 kC(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(wC(s?.key))return"text";let e=[],i=Math.min(t?.length??0,ay),r=new Set;for(let n=0;n<i;n++){let o=ly(t[n],s);if(!(o==null||o==="")&&(e.push(o),r.add(String(o)),r.size>SC))return"text"}return e.length?"select":"text"}function AC(s,t){let e=new Set,i=Math.min(t?.length??0,ay);for(let r=0;r<i;r++){let n=ly(t[r],s);n==null||n===""||e.add(String(n))}return[...e].sort((r,n)=>r.localeCompare(n,void 0,{numeric:!0}))}var Nr=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.#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.#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(xC)),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.#S(i),t==="columns"&&this.#A(i),document.body.appendChild(i);try{i.showPopover()}catch{}let r=ut(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.#x,!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.#x,!0))}}#y=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#O())};#x=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(Ud("No filterable columns"));return}let i=e.filters||{};t.appendChild(Fd("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=kC(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=AC(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.#w()});t.appendChild(o)}}#w(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#S(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ud("No sortable columns"));return}t.appendChild(Fd("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.#S(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ud("No columns"));return}t.appendChild(Fd("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",Nr);C();var Br=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(){at(this,"label").length||(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}#x(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)}#v(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.#x(parseInt(e[n].dataset.idx))}#w(t){this.#O(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.#g(e))?.category||"";this.#O(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:n}}))}#k=()=>{this.#m(this.#s.value)};#A=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#v(1);break;case"ArrowUp":t.preventDefault(),this.#v(-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.#A),this.#s?.removeEventListener("input",this.#k),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",Lr);var Qa=.4;function zd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function _d(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 di(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function jd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function sy(s,t,e){let{a:i,b:r}=zd(s,t,e),[n,o,a]=_d(s,i,r);return[Math.max(0,Math.min(1,di(n))),Math.max(0,Math.min(1,di(o))),Math.max(0,Math.min(1,di(a)))]}function OC(s,t,e){let i=r=>Math.round(r*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Mr(s,t,e){let[i,r,n]=sy(s,t,e);return OC(i,r,n)}function yC(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=jd(parseInt(s.slice(0,2),16)/255),e=jd(parseInt(s.slice(2,4),16)/255),i=jd(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 ry(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Ta(s,t,e){let{a:i,b:r}=zd(s,t,e),[n,o,a]=_d(s,i,r);if(ry(di(n),di(o),di(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=zd(s,u,e),[p,m,b]=_d(s,d,f);ry(di(p),di(m),di(b))?l=u:h=u}return l}var Rr=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;#O=null;#b=null;#y=null;#x=[];#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.#T("input")};#S=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#D(t))};#k=t=>{this.#a==="area"&&this.#D(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#T("change"))};#E=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#Q(t))};#$=t=>{this.#a==="hue"&&this.#Q(t)};#M=()=>{this.#a==="hue"&&(this.#a=null,this.#T("change"))};#C=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(Qa,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.#T("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.#T("change")};connected(){if(super.connected(),this.#L(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.#w),t.appendChild(c),c};this.#O=e("H","hue",0,360,1),this.#b=e("C","chroma",0,Qa,.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.#x.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.#S),this.#h.addEventListener("pointermove",this.#k),this.#h.addEventListener("pointerup",this.#A),this.#d.addEventListener("pointerdown",this.#E),this.#d.addEventListener("pointermove",this.#$),this.#d.addEventListener("pointerup",this.#M),this.#h.addEventListener("keydown",this.#C),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.#S),this.#h.removeEventListener("pointermove",this.#k),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#C)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#E),this.#d.removeEventListener("pointermove",this.#$),this.#d.removeEventListener("pointerup",this.#M),this.#d.removeEventListener("keydown",this.#P)),this.#O?.removeEventListener("input",this.#w),this.#b?.removeEventListener("input",this.#w),this.#y?.removeEventListener("input",this.#w);for(let{el:t,handler:e}of this.#x)t.removeEventListener("click",e);this.#x=[],this.#n=!1}#D(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*Qa,this.#e=1-r,this.#T("input")}#Q(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#T("input")}#L(t){if(t){if(t.startsWith("#")){let e=yC(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.`))}}}#T(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=Ta(this.#e,this.#i,this.#s),r=Mr(this.#e,i,this.#s),n=this.#I();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}))}#I(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#X(t,e){let i=t==="oklch"?this.#I():Mr(this.#e,Ta(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)*Qa,u=Ta(l,c,o),[d,f,p]=sy(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.#L(this.value),this.#q(),this.#u){let n=this.#i/Qa*100,o=(1-this.#e)*100;this.#u.style.left=`${n}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Mr(this.#e,Ta(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let n=[];for(let o=0;o<=360;o+=30)n.push(Mr(.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=Mr(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#I());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=Mr(this.#e,Ta(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#I()),this.#m&&(this.#m.textContent=r)}onFormReset(){this.value="#3b82f6"}};S("color-picker-ui",Rr);var Ir=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",Ir);C();var Vd=0,Dr=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-${++Vd}`,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-${++Vd}`,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.#u();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.#S(),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.#O(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}}}#O(t,e,i,r){switch(this.curve){case"step":return this.#x(t,e);case"straight":return this.#v(t,e);default:return this.#b(t,e,i,r)}}#b(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}}}#x(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#v(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#w(){this.#d(),this.#S();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.#E(a,e,r)),this.appendChild(o),this.#i.set(n,o)}}this.#k(),this.#u()}#S(){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${++Vd}`),`${t._noodleId}:${e}`}#E=(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.#O(n,{x:c,y:u},i,this.#$(n,{x:c,y:u})),this.#h(),this.#M(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.#C(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)};#$(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"}#M(t,e,i){this.#P();let r=this.#C(t,e,i);r?.dot&&r.dot.setAttribute("data-noodle-drop-ready","")}#C(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",Dr);var Ni={};function xe(s,t){Ni[s]=t}function qr(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 Wd={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()};xe("text",{render(s,t,e){qr(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),xe("number",{render(s,t,e){qr(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),xe("currency",{render(s,t,e,i){qr(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"}),xe("percent",{render(s,t,e){qr(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var ny={year:"numeric",month:"short",day:"numeric"};xe("date",{render(s,t,e){qr(e,s?new Intl.DateTimeFormat("en-US",ny).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",ny).format(new Date(s)):""},align:"left",sortFn:"datetime"});var oy={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};xe("datetime",{render(s,t,e){qr(e,s?new Intl.DateTimeFormat("en-US",oy).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",oy).format(new Date(s)):""},align:"left",sortFn:"datetime"}),xe("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"}),xe("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"}),xe("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"}),xe("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"}),xe("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"}),xe("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});C();function vC(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 fi(s,t){return typeof t.accessor=="function"?t.accessor(s):vC(s,t.key)}function Eh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
176
+ `)?'"'+t.replace(/"/g,'""')+'"':t}var Xr=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.#b()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#a=0,this.#b()}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.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#a=0,this.#b(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#a=0,this.#b(),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.#b()}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.#b()}}#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.#L),this.addEventListener("keydown",this.#z),this.addEventListener("pointerdown",this.#Q))}disconnected(){this.removeEventListener("click",this.#L),this.removeEventListener("keydown",this.#z),this.removeEventListener("pointerdown",this.#Q),this.#h=!1,this.#R(),this.#O&&(cancelAnimationFrame(this.#O),this.#O=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)}#O=null;#b(){!this.isConnected||this.#O||(this.#O=requestAnimationFrame(()=>{this.#O=null,this.render(),this.#p()}))}get#y(){return this.#t.filter(t=>!t.hidden)}#x(){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=fi(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=fi(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=fi(this.#e[e],o||{key:r}),l=fi(this.#e[i],o||{key:r}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Ni[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Wd[d]||Wd.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#S(){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.#x();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.#D();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.#E(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.#$(i),this.#M(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.#C(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.#E(i,t,e),i}#E(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=fi(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=Ni[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=Ni[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])}#$(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()}#M(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=fi(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=Ni[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])}#C(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=fi(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.#b()}),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}#D(){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)}#Q=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.#I(t,e))};#L=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#d=this.#d===c?null:c,this.#b();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#b());let 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.#I(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?fi(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}}))}}};#T=null;#I(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.#T={key:i,col:r,startX:a,startWidth:o},document.addEventListener("pointermove",this.#X),document.addEventListener("pointerup",this.#q)}#X=t=>{if(!this.#T)return;let{key:e,col:i,startX:r,startWidth:n}=this.#T,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.#x()};#q=t=>{if(!this.#T)return;let{key:e}=this.#T;document.removeEventListener("pointermove",this.#X),document.removeEventListener("pointerup",this.#q),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#T=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.#T=null}#z=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.#_())};#_(){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=>Eh(c.label||c.key)),n=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=fi(u,d);if(typeof d.format=="function")return Eh(d.format(f,u));let p=Ni[d.type||"text"];return p?.format?Eh(p.format(f,u,d.meta)):Eh(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",Xr);C();var xC=200;function Ud(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 Fd(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 SC=50,ay=500;function ly(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 wC(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 kC(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(wC(s?.key))return"text";let e=[],i=Math.min(t?.length??0,ay),r=new Set;for(let n=0;n<i;n++){let o=ly(t[n],s);if(!(o==null||o==="")&&(e.push(o),r.add(String(o)),r.size>SC))return"text"}return e.length?"select":"text"}function AC(s,t){let e=new Set,i=Math.min(t?.length??0,ay);for(let r=0;r<i;r++){let n=ly(t[r],s);n==null||n===""||e.add(String(n))}return[...e].sort((r,n)=>r.localeCompare(n,void 0,{numeric:!0}))}var Nr=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.#b(),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.#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(xC)),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.#O(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()}#O(t,e){if(this.#i?.kind===t){this.#b();return}this.#b();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#v(i),t==="sort"&&this.#S(i),t==="columns"&&this.#A(i),document.body.appendChild(i);try{i.showPopover()}catch{}let r=ut(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.#x,!0))}))}#b(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#y,!0),document.removeEventListener("keydown",this.#x,!0))}}#y=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#b())};#x=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#b(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ud("No filterable columns"));return}let i=e.filters||{};t.appendChild(Fd("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=kC(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=AC(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.#w()});t.appendChild(o)}}#w(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#S(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ud("No sortable columns"));return}t.appendChild(Fd("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.#S(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ud("No columns"));return}t.appendChild(Fd("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",Nr);C();var Br=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(){at(this,"label").length||(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",Br),S("timeline-item-ui",Zr);C();var zr=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))}},_r=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",zr),S("stepper-item-ui",_r);C();var jr=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.#S),this.addEventListener("focusin",this.#k),this.addEventListener("focusout",this.#A)),this.addEventListener("keydown",this.#E),this.#t.addEventListener("pointerdown",this.#M),this.#t.addEventListener("pointermove",this.#C),this.#t.addEventListener("pointerup",this.#P),this.#t.addEventListener("pointercancel",this.#P),this.#t.addEventListener("click",this.#D,!0),this.#t.addEventListener("dragstart",this.#Q)),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.#S),this.removeEventListener("focusin",this.#k),this.removeEventListener("focusout",this.#A),this.removeEventListener("keydown",this.#E),this.#t&&(this.#t.removeEventListener("pointerdown",this.#M),this.#t.removeEventListener("pointermove",this.#C),this.#t.removeEventListener("pointerup",this.#P),this.#t.removeEventListener("pointercancel",this.#P),this.#t.removeEventListener("click",this.#D,!0),this.#t.removeEventListener("dragstart",this.#Q)),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 e=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").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.#x(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#x()),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}`}#x(){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()}#w=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#S=()=>{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})))};#E=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#$=5;#M=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","")))};#C=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=t.clientX-this.#o.startX;if(Math.abs(e)>=this.#$){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")))};#D=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#Q=t=>{this.#o&&t.preventDefault()}};S("swiper-ui",jr);var Vr=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",zr),S("stepper-item-ui",_r);C();var jr=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.#S),this.addEventListener("focusin",this.#k),this.addEventListener("focusout",this.#A)),this.addEventListener("keydown",this.#E),this.#t.addEventListener("pointerdown",this.#M),this.#t.addEventListener("pointermove",this.#C),this.#t.addEventListener("pointerup",this.#P),this.#t.addEventListener("pointercancel",this.#P),this.#t.addEventListener("click",this.#D,!0),this.#t.addEventListener("dragstart",this.#Q)),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.#S),this.removeEventListener("focusin",this.#k),this.removeEventListener("focusout",this.#A),this.removeEventListener("keydown",this.#E),this.#t&&(this.#t.removeEventListener("pointerdown",this.#M),this.#t.removeEventListener("pointermove",this.#C),this.#t.removeEventListener("pointerup",this.#P),this.#t.removeEventListener("pointercancel",this.#P),this.#t.removeEventListener("click",this.#D,!0),this.#t.removeEventListener("dragstart",this.#Q)),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 e=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").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.#b():this.#O(),this.#x(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#x()),this.#i.observe(this)))}#O(){let t=document.createElement("button-ui");t.setAttribute("data-swiper-btn",""),t.setAttribute("data-swiper-prev",""),t.setAttribute("icon","caret-left"),t.setAttribute("variant","ghost"),t.setAttribute("aria-label","Previous slide"),t.addEventListener("press",()=>this.prev());let e=document.createElement("button-ui");e.setAttribute("data-swiper-btn",""),e.setAttribute("data-swiper-next",""),e.setAttribute("icon","caret-right"),e.setAttribute("variant","ghost"),e.setAttribute("aria-label","Next slide"),e.addEventListener("press",()=>this.next()),this.appendChild(t),this.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-dots",""),i.setAttribute("role","tablist"),i.setAttribute("aria-label","Slide indicators"),this.appendChild(i)}#b(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let 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}`}#x(){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()}#w=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#S=()=>{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})))};#E=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#$=5;#M=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","")))};#C=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=t.clientX-this.#o.startX;if(Math.abs(e)>=this.#$){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")))};#D=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#Q=t=>{this.#o&&t.preventDefault()}};S("swiper-ui",jr);var Vr=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",Vr);qd();var Wr=YO({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=""}}});C();var Ur=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(Wr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Wr),this.#t=!0)}};S("card-ui",Ur);C();var Fr=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}},Yr=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",Fr),S("avatar-group-ui",Yr);C();var Hr=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",Hr);C();var Gr=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"),!at(this,"caption").length&&!at(this,"track").length?(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=at(this,"caption")[0],this.#e=at(this,"track")[0])}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",Gr);C();var Kr=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",Kr);C();var Jr=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",Jr);C();var tn=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",tn);C();var hy=new Set;function cy(s,t){hy.has(s)||(hy.add(s),console.warn(`[alert-ui] ${t}`))}var en=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"&&(cy("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")&&(cy("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",en);C();var EC={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},sn=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||EC[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",sn);C();var rn=class extends x{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};S("kbd-ui",rn);C();var nn=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",nn);C();var CC=new Set(["block","dot","square","line","dashed"]),$C=new Set(["sm","md","lg"]),PC=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),QC={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},TC={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function LC(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&PC.has(t)):[]}var cs=null;function MC(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!cs){let u=document.createElement("canvas");u.width=1,u.height=1,cs=u.getContext("2d")}cs.fillStyle="#000",cs.clearRect(0,0,1,1),cs.fillStyle=s,cs.fillRect(0,0,1,1);let[t,e,i]=cs.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 on=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.#x(),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=CC.has(this.shape)?this.shape:"square",e=$C.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=LC(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",TC[n]),o.textContent=QC[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=MC(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.#w();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"))}#x(){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.#S(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#S(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",on);$t();var uy={xs:0,sm:480,md:768,lg:1024,xl:1280},us=Object.keys(uy),Yd=Object.values(uy);function dy(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=us.length-1;t>=0;t--)if(s>=Yd[t])return us[t];return"xs"}var $e=Xi(dy());if(typeof window<"u")for(let s=1;s<Yd.length;s++)window.matchMedia(`(min-width: ${Yd[s]}px)`).addEventListener("change",()=>{$e.value=dy()});function Bt(s,t=$e.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=us.indexOf(t),n=null,o=-1;for(let[a,l]of i){let h=us.indexOf(a);h!==-1&&h<=r&&h>o&&(n=l,o=h)}return n??e}C();var an=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("@")?$e.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",DC(Bt(t,n))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Bt(e,n);this.style.setProperty("--col-align",qC(o)),this.style.textAlign=XC(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",NC(Bt(i,n))):this.style.removeProperty("--col-justify")}},RC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},IC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function DC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function qC(s){return RC[s]??s}function XC(s){return{start:"start",center:"center",end:"end"}[s]??""}function NC(s){return IC[s]??s}S("col-ui",an);C();var ln=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#x=0;static#v(t){return`field-${t}-${++s.#x}`}};S("field-ui",ln);C();var hn=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",hn);C();var cn=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(Wr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Wr),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?$e.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",zC(Bt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",_C(Bt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",jC(Bt(i,o))):this.style.removeProperty("--row-justify"),r){let a=us.indexOf(o),l=us.indexOf(r);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},BC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},ZC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function zC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function _C(s){return BC[s]??s}function jC(s){return ZC[s]??s}S("row-ui",cn);C();var un=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=$e.value,e=this.columns;if(e?.includes("@")){let r=Bt(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=Bt(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",un);C();var dn=class extends x{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};S("stack-ui",dn);C();var fn=class extends x{static properties={};static template=()=>null};S("frame-ui",fn);C();function ds(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 fy(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 ne(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function wt({label:s,value:t,pct:e,series:i}){let r="";return s!=null&&(r+=` data-tip-label="${ne(String(s))}"`),t!=null&&(r+=` data-tip-value="${t}"`),e!=null&&(r+=` data-tip-pct="${e}"`),i!=null&&(r+=` data-tip-series="${ne(String(i))}"`),r}function oe(s,t,e){return s+t*Math.cos(e)}function ae(s,t,e){return s+t*Math.sin(e)}function VC(s,t,e,i,r){let n=oe(s,e,i),o=ae(t,e,i),a=oe(s,e,r),l=ae(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 Hd(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 dt=oe(s,e,r),ot=ae(t,e,r),Ot=oe(s,e,n),St=ae(t,e,n),yt=oe(s,i,n),Ct=ae(t,i,n),Lt=oe(s,i,r),Yt=ae(t,i,r),ns=l>Math.PI?1:0;return`M ${dt} ${ot} A ${e} ${e} 0 ${ns} 1 ${Ot} ${St} L ${yt} ${Ct} A ${i} ${i} 0 ${ns} 0 ${Lt} ${Yt} 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=oe(s,e,f),v=ae(t,e,f),w=oe(s,e,p),k=ae(t,e,p),E=oe(s,i,b),A=ae(t,i,b),$=oe(s,i,m),T=ae(t,i,m),Q=oe(s,e-h,r),D=ae(t,e-h,r),R=oe(s,i+h,r),_=ae(t,i+h,r),V=oe(s,e-h,n),U=ae(t,e-h,n),J=oe(s,i+h,n),rt=ae(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 ${$} ${T} A ${h} ${h} 0 0 1 ${R} ${_} L ${Q} ${D} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function La(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 Gd(s,t,e=.4){let i=La(s,e),r=s[s.length-1],n=s[0];return`${i} L${r.x},${t} L${n.x},${t} Z`}function Ch(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 WC={std:{ratio:4/3}},pn=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",Vr);qd();var Wr=YO({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=""}}});C();var Ur=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(Wr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Wr),this.#t=!0)}};S("card-ui",Ur);C();var Fr=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}},Yr=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",Fr),S("avatar-group-ui",Yr);C();var Hr=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",Hr);C();var Gr=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"),!at(this,"caption").length&&!at(this,"track").length?(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=at(this,"caption")[0],this.#e=at(this,"track")[0])}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",Gr);C();var Kr=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",Kr);C();var Jr=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",Jr);C();var tn=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",tn);C();var hy=new Set;function cy(s,t){hy.has(s)||(hy.add(s),console.warn(`[alert-ui] ${t}`))}var en=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"&&(cy("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")&&(cy("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",en);C();var EC={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},sn=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||EC[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",sn);C();var rn=class extends x{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};S("kbd-ui",rn);C();var nn=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",nn);C();var CC=new Set(["block","dot","square","line","dashed"]),$C=new Set(["sm","md","lg"]),PC=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),QC={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},TC={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function LC(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&PC.has(t)):[]}var cs=null;function MC(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!cs){let u=document.createElement("canvas");u.width=1,u.height=1,cs=u.getContext("2d")}cs.fillStyle="#000",cs.clearRect(0,0,1,1),cs.fillStyle=s,cs.fillRect(0,0,1,1);let[t,e,i]=cs.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 on=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.#x(),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.#O(),this.#b(),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=CC.has(this.shape)?this.shape:"square",e=$C.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=LC(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",TC[n]),o.textContent=QC[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=MC(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)}#O(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#b(){if(!this.#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")}#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"))}#x(){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.#S(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#S(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",on);$t();var uy={xs:0,sm:480,md:768,lg:1024,xl:1280},us=Object.keys(uy),Yd=Object.values(uy);function dy(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=us.length-1;t>=0;t--)if(s>=Yd[t])return us[t];return"xs"}var $e=Xi(dy());if(typeof window<"u")for(let s=1;s<Yd.length;s++)window.matchMedia(`(min-width: ${Yd[s]}px)`).addEventListener("change",()=>{$e.value=dy()});function Bt(s,t=$e.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=us.indexOf(t),n=null,o=-1;for(let[a,l]of i){let h=us.indexOf(a);h!==-1&&h<=r&&h>o&&(n=l,o=h)}return n??e}C();var an=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("@")?$e.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",DC(Bt(t,n))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Bt(e,n);this.style.setProperty("--col-align",qC(o)),this.style.textAlign=XC(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",NC(Bt(i,n))):this.style.removeProperty("--col-justify")}},RC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},IC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function DC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function qC(s){return RC[s]??s}function XC(s){return{start:"start",center:"center",end:"end"}[s]??""}function NC(s){return IC[s]??s}S("col-ui",an);C();var ln=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.#w("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.#w("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.#x()),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(){let t=null,e=null;for(let i of this.children)if(!i.hasAttribute("slot")){if(t===null&&(t=i),s.#O.has(i.localName))return i;e===null&&this.#b(i)&&(e=i)}return e??t}static#O=new Set(["input-ui","textarea-ui","select-ui","combobox-ui","search-ui","check-ui","radio-ui","switch-ui","slider-ui","range-ui","otp-input-ui","tags-input-ui","chat-input-ui","autocomplete-input-ui","datetime-picker-ui","date-range-picker-ui","calendar-picker-ui","color-picker-ui","upload-ui","rating-ui","segmented-ui","input","textarea","select"]);#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#x(){return`field-ctl-${++s.#y}`}static#v=0;static#w(t){return`field-${t}-${++s.#v}`}};S("field-ui",ln);C();var hn=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",hn);C();var cn=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(Wr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Wr),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?$e.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",zC(Bt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",_C(Bt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",jC(Bt(i,o))):this.style.removeProperty("--row-justify"),r){let a=us.indexOf(o),l=us.indexOf(r);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},BC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},ZC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function zC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function _C(s){return BC[s]??s}function jC(s){return ZC[s]??s}S("row-ui",cn);C();var un=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=$e.value,e=this.columns;if(e?.includes("@")){let r=Bt(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=Bt(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",un);C();var dn=class extends x{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};S("stack-ui",dn);C();var fn=class extends x{static properties={};static template=()=>null};S("frame-ui",fn);C();function ds(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 fy(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 ne(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function wt({label:s,value:t,pct:e,series:i}){let r="";return s!=null&&(r+=` data-tip-label="${ne(String(s))}"`),t!=null&&(r+=` data-tip-value="${t}"`),e!=null&&(r+=` data-tip-pct="${e}"`),i!=null&&(r+=` data-tip-series="${ne(String(i))}"`),r}function oe(s,t,e){return s+t*Math.cos(e)}function ae(s,t,e){return s+t*Math.sin(e)}function VC(s,t,e,i,r){let n=oe(s,e,i),o=ae(t,e,i),a=oe(s,e,r),l=ae(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 Hd(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 dt=oe(s,e,r),ot=ae(t,e,r),Ot=oe(s,e,n),St=ae(t,e,n),yt=oe(s,i,n),Ct=ae(t,i,n),Lt=oe(s,i,r),Yt=ae(t,i,r),ns=l>Math.PI?1:0;return`M ${dt} ${ot} A ${e} ${e} 0 ${ns} 1 ${Ot} ${St} L ${yt} ${Ct} A ${i} ${i} 0 ${ns} 0 ${Lt} ${Yt} 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=oe(s,e,f),v=ae(t,e,f),w=oe(s,e,p),k=ae(t,e,p),E=oe(s,i,b),A=ae(t,i,b),$=oe(s,i,m),T=ae(t,i,m),Q=oe(s,e-h,r),D=ae(t,e-h,r),R=oe(s,i+h,r),_=ae(t,i+h,r),V=oe(s,e-h,n),U=ae(t,e-h,n),J=oe(s,i+h,n),rt=ae(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 ${$} ${T} A ${h} ${h} 0 0 1 ${R} ${_} L ${Q} ${D} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function La(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 Gd(s,t,e=.4){let i=La(s,e),r=s[s.length-1],n=s[0];return`${i} L${r.x},${t} L${n.x},${t} Z`}function Ch(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 WC={std:{ratio:4/3}},pn=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.#x),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#Q),this.addEventListener("focus",this.#P),this.addEventListener("blur",this.#D),this.addEventListener("pointerover",this.#T),this.addEventListener("pointermove",this.#I),this.addEventListener("pointerleave",this.#X),this.addEventListener("pointerdown",this.#q),this.addEventListener("click",this.#z),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=WC.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.#H());break;case"line":({svg:r,viewBox:n}=this.#K());break;case"pie":({svg:r,viewBox:n}=this.#tt());break;case"donut":({svg:r,viewBox:n}=this.#J());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.#rt());break;case"radial-bar":({svg:r,viewBox:n}=this.#G());break;case"gauge":({svg:r,viewBox:n}=this.#U());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.#H());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="${ne(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g(t,e){return e?` data-slice="${t}" data-series-key="${ne(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.#x),document.removeEventListener("pointerdown",this.#R),this.removeEventListener("keydown",this.#Q),this.removeEventListener("focus",this.#P),this.removeEventListener("blur",this.#D),this.removeEventListener("pointerover",this.#T),this.removeEventListener("pointermove",this.#I),this.removeEventListener("pointerleave",this.#X),this.removeEventListener("pointerdown",this.#q),this.removeEventListener("click",this.#z),this.#W()}#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}#x=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||"$"}${fy(e)}`}default:return fy(e)}}#S=-1;#k(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#A(t){let e=this.#k();if(!e.length){this.#$();return}this.#S=Math.max(0,Math.min(t,e.length-1)),this.#E(),this.#M()}#E(){let t=this.#k();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#S];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#$(){this.#S=-1;for(let t of this.#k())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#M(){let t=this.#k()[this.#S];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#_(t,i)}#C(){let t=this.#k()[this.#S];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#j(t,i)}))}#P=()=>{this.#S===-1&&this.#A(0)};#D=()=>{this.#$(),this.#L&&this.#B()};#Q=t=>{let e=this.#k();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#A(this.#S+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#A(Math.max(0,this.#S-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.#C();break;case"Escape":t.preventDefault(),this.#$(),this.#L&&this.#B();break}};#L=null;#T=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#Y(e,t),this.#_(e,t))};#I=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#L&&this.#B(),this.#W();this.#Y(e,t),e!==this.#L&&this.#_(e,t)};#X=t=>{t&&t.pointerType==="touch"||(this.#W(),this.#L&&this.#B())};#q=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#L&&this.#B(),this.#W();this.#Y(e,t),e!==this.#L&&this.#_(e,t),document.addEventListener("pointerdown",this.#R)};#R=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#W(),this.#L&&this.#B(),document.removeEventListener("pointerdown",this.#R)))};#z=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#j(e,t)}))};#_(t,e){this.#L=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#j(t,e)}))}#B(){this.#L=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#j(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.#V(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}}#V(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}})}#Y(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">${ne(o)}</span>`),i&&a.push(`<span data-tip-role="label">${ne(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`}#W(){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):[]}#F(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}">${ne(r[w])}</text>`}}}return c}#H(){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=ds(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.#F(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${wt({label:n[v],value:w})} d="${Ch(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${wt({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}`}}#K(){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=ds(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.#F(l,h,o,n,c,t),m=r.map((A,$)=>{let T=c.left+f*$,Q=c.top+u-(a?A/a*u:0);return{x:T,y:Q,v:A,label:n[$]}}),b=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${Gd(m,b,g)}"/>`,p+=`<path data-line d="${La(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${wt({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.top+u-(a?A/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${$}" x2="${l-c.right}" y2="${$}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${$+3}" text-anchor="start" font-size="${t.valueSize}">${this.#w(A)}</text>`,p+=`<line data-hit${wt({label:"Average",value:A})} x1="${c.left}" y1="${$}" x2="${l-c.right}" y2="${$}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#tt(){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}"${wt({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="${VC(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}`}}#J(){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}"${wt({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="${Hd(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.#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 $=0;$<o;$++){let T=-Math.PI/2+b*$,Q=u+E*Math.cos(T),D=d+E*Math.sin(T);A+=($===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),$=d+p*Math.sin(E);m+=`<line data-grid x1="${u}" y1="${d}" x2="${A}" y2="${$}"/>`}let g="",y=[];for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=i[k]/n*p,$=u+A*Math.cos(E),T=d+A*Math.sin(E);g+=(k===0?"M":"L")+` ${$} ${T}`,y.push({px:$,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${wt({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),$=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="${$}" text-anchor="${T}" dominant-baseline="central" font-size="${c}">${ne(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="${Gd(p,c,m)}"/>`,b+=`<path data-line d="${La(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)b+=`<circle data-hit${wt({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.#K()}#rt(){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=ds(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.#F(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${wt({label:n[g],value:r[g]})} cx="${y}" cy="${v}" r="${b}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#G(){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 $=(i[g]/n*100).toFixed(1),T=wt({label:r[g],value:i[g],pct:$}),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}`}}#U(){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="${Hd(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let w=Math.PI+Math.PI*a,k=wt({label:t[0]?.[this.x]??"Value",value:n,pct:(a*100).toFixed(1)});b+=`<path data-slice="0"${k} data-gauge-fill d="${Hd(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.#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),$=d+m*v+b/2,T=d+m*(v+1)-b/2,Q=(w/o*100).toFixed(1),D=wt({label:r[v],value:w,pct:Q}),R=`M ${g-E} ${$} L ${g+E} ${$} 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="${$+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${ne(r[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${$+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="${$+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,dt)=>rt+dt,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((St,yt)=>St+yt,0),rt=V>=U,dt=rt?J/V:U,ot=rt?V:J/U,Ot=0;for(let St=0;St<Q.length;St++){let yt=Q[St]/J,Ct=u[D+St];if(rt){let Lt=yt*V;d.push({i:Ct,x:R+Ot,y:_,w:Lt,h:dt}),Ot+=Lt}else{let Lt=yt*U;d.push({i:Ct,x:R,y:_+Ot,w:ot,h:Lt}),Ot+=Lt}}return rt?{x:R,y:_+dt,w:V,h:U-dt}:{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 $="",T=2;for(let Q of d){let D=(i[Q.i]/c*100).toFixed(1),R=wt({label:r[Q.i],value:i[Q.i],pct:D});$+=`<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)$+=`<text data-treemap-label x="${_}" y="${Q.y+h+4}" font-size="${h}" dominant-baseline="hanging">${ne(r[Q.i])}</text>`,$+=`<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;$+=`<text data-treemap-label x="${_}" y="${rt}" font-size="${h}" dominant-baseline="central">${ne(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:$,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}">${ne(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}">${ne(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 $=A/c*m,T=A/u*b,Q=k.cursor,D=Q+$,R=E.cursor,_=R+T;k.cursor+=$,E.cursor+=T;let V=h,U=n-h,J=(V+U)/2,rt=wt({label:`${k.name} \u2192 ${E.name}`,value:A}),dt=`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="${dt}"/>`}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=ds(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.#F(d,f,c,o,p,t);if(!this.#v(r))for(let E=0;E<e.length;E++){let A=a[E],$=u?A/u*m:0,T=p.left+g*E+v,Q=p.top+m-$;k+=`<path${this.#m(0,r)}${wt({label:o[E],value:A,series:r})} d="${Ch(T,Q,y,$,this.#o())}"/>`}if(!this.#v(n)){let E=l.map(($,T)=>({x:p.left+g*T+g/2,y:p.top+m-(u?$/u*m:0),v:$,label:o[T]})),A=Math.max(0,Math.min(1,this.smooth));k+=`<path data-line${this.#g(1,n)} d="${La(E,A)}"/>`;for(let $ of E)k+=`<circle data-dot${this.#m(1,n)} cx="${$.x}" cy="${$.y}" r="3"/>`,k+=`<circle data-hit${wt({label:$.label,value:$.v,series:n})} cx="${$.x}" cy="${$.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=wt({label:n[p],value:i[p],pct:w}),E=`<title>${ne(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,$=m+v,T;g?T=`M ${m+A} 0 H ${$} 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 ${$-A} A ${A} ${A} 0 0 1 ${$} ${A} V ${l-A} A ${A} ${A} 0 0 1 ${$-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=ds(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.#F(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,$=y,T=E,Q=w===v-1,D=this.#o(),R=`${this.#m(w%10,e[w])}${wt({label:i[g],value:k,series:e[w]})}`;Q?b+=`<path${R} d="${Ch(A,$,p,T,D)}"/>`:b+=`<rect${R} x="${A}" y="${$}" 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=ds(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.#F(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.top+u-E;y+=`<path${this.#m(w%10,e[w])}${wt({label:i[v],value:k,series:e[w]})} d="${Ch(A,$,b,E,this.#o())}"/>`,this.hideValues||(y+=`<text data-value x="${A+b/2}" y="${$-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=ds(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.#F(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="${Gd(g,y,v)}"/>`,p+=`<path data-line${this.#g(m%10,e[m])} d="${La(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${wt({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",pn);C();var mn=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",mn);C();var UC=120,gn=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=ut(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},UC)};#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",gn);C();var bn=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)}},On=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",bn),S("accordion-item-ui",On);C();var yn=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",yn);C();var vn=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",vn);C();var Kd=[{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}],xn=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=Kd.find(o=>i<=o.limit)||Kd[Kd.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",xn);C();var Sn=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",Sn);C();var Jd=["Weak","Fair","Good","Strong"];function FC(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 wn=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.#x),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#Q),this.addEventListener("focus",this.#P),this.addEventListener("blur",this.#D),this.addEventListener("pointerover",this.#T),this.addEventListener("pointermove",this.#I),this.addEventListener("pointerleave",this.#X),this.addEventListener("pointerdown",this.#q),this.addEventListener("click",this.#z),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=WC.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.#H());break;case"line":({svg:r,viewBox:n}=this.#K());break;case"pie":({svg:r,viewBox:n}=this.#tt());break;case"donut":({svg:r,viewBox:n}=this.#J());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.#rt());break;case"radial-bar":({svg:r,viewBox:n}=this.#G());break;case"gauge":({svg:r,viewBox:n}=this.#U());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.#H());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.#b()){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="${ne(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g(t,e){return e?` data-slice="${t}" data-series-key="${ne(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#O=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#x),document.removeEventListener("pointerdown",this.#R),this.removeEventListener("keydown",this.#Q),this.removeEventListener("focus",this.#P),this.removeEventListener("blur",this.#D),this.removeEventListener("pointerover",this.#T),this.removeEventListener("pointermove",this.#I),this.removeEventListener("pointerleave",this.#X),this.removeEventListener("pointerdown",this.#q),this.removeEventListener("click",this.#z),this.#W()}#b(){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}#x=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||"$"}${fy(e)}`}default:return fy(e)}}#S=-1;#k(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#A(t){let e=this.#k();if(!e.length){this.#$();return}this.#S=Math.max(0,Math.min(t,e.length-1)),this.#E(),this.#M()}#E(){let t=this.#k();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#S];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#$(){this.#S=-1;for(let t of this.#k())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#M(){let t=this.#k()[this.#S];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#_(t,i)}#C(){let t=this.#k()[this.#S];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#j(t,i)}))}#P=()=>{this.#S===-1&&this.#A(0)};#D=()=>{this.#$(),this.#L&&this.#B()};#Q=t=>{let e=this.#k();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#A(this.#S+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#A(Math.max(0,this.#S-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.#C();break;case"Escape":t.preventDefault(),this.#$(),this.#L&&this.#B();break}};#L=null;#T=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#Y(e,t),this.#_(e,t))};#I=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#L&&this.#B(),this.#W();this.#Y(e,t),e!==this.#L&&this.#_(e,t)};#X=t=>{t&&t.pointerType==="touch"||(this.#W(),this.#L&&this.#B())};#q=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#L&&this.#B(),this.#W();this.#Y(e,t),e!==this.#L&&this.#_(e,t),document.addEventListener("pointerdown",this.#R)};#R=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#W(),this.#L&&this.#B(),document.removeEventListener("pointerdown",this.#R)))};#z=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#j(e,t)}))};#_(t,e){this.#L=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#j(t,e)}))}#B(){this.#L=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#j(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.#V(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}}#V(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}})}#Y(t,e){if(this.#y())return;let{tipLabel:i,tipValue:r,tipPct:n,tipSeries:o}=t.dataset;if(!this.#O){let b=document.createElement("div");b.setAttribute("popover","manual"),b.setAttribute("role","tooltip"),b.classList.add("chart-tooltip-popup"),document.body.appendChild(b),this.#O=b}let a=[];if(o&&a.push(`<span data-tip-role="series">${ne(o)}</span>`),i&&a.push(`<span data-tip-role="label">${ne(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.#O.innerHTML=a.join("");try{this.#O.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#O.offsetWidth||0,f=this.#O.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.#O.style.left=`${p}px`,this.#O.style.top=`${m}px`}#W(){if(this.#O){try{this.#O.hidePopover()}catch{}this.#O.remove(),this.#O=null}}#N(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#F(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}">${ne(r[w])}</text>`}}}return c}#H(){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=ds(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.#F(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${wt({label:n[v],value:w})} d="${Ch(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${wt({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}`}}#K(){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=ds(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.#F(l,h,o,n,c,t),m=r.map((A,$)=>{let T=c.left+f*$,Q=c.top+u-(a?A/a*u:0);return{x:T,y:Q,v:A,label:n[$]}}),b=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${Gd(m,b,g)}"/>`,p+=`<path data-line d="${La(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${wt({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.top+u-(a?A/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${$}" x2="${l-c.right}" y2="${$}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${$+3}" text-anchor="start" font-size="${t.valueSize}">${this.#w(A)}</text>`,p+=`<line data-hit${wt({label:"Average",value:A})} x1="${c.left}" y1="${$}" x2="${l-c.right}" y2="${$}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#tt(){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}"${wt({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="${VC(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}`}}#J(){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}"${wt({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="${Hd(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.#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 $=0;$<o;$++){let T=-Math.PI/2+b*$,Q=u+E*Math.cos(T),D=d+E*Math.sin(T);A+=($===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),$=d+p*Math.sin(E);m+=`<line data-grid x1="${u}" y1="${d}" x2="${A}" y2="${$}"/>`}let g="",y=[];for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=i[k]/n*p,$=u+A*Math.cos(E),T=d+A*Math.sin(E);g+=(k===0?"M":"L")+` ${$} ${T}`,y.push({px:$,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${wt({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),$=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="${$}" text-anchor="${T}" dominant-baseline="central" font-size="${c}">${ne(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="${Gd(p,c,m)}"/>`,b+=`<path data-line d="${La(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)b+=`<circle data-hit${wt({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.#K()}#rt(){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=ds(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.#F(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${wt({label:n[g],value:r[g]})} cx="${y}" cy="${v}" r="${b}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#G(){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 $=(i[g]/n*100).toFixed(1),T=wt({label:r[g],value:i[g],pct:$}),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}`}}#U(){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="${Hd(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let w=Math.PI+Math.PI*a,k=wt({label:t[0]?.[this.x]??"Value",value:n,pct:(a*100).toFixed(1)});b+=`<path data-slice="0"${k} data-gauge-fill d="${Hd(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.#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),$=d+m*v+b/2,T=d+m*(v+1)-b/2,Q=(w/o*100).toFixed(1),D=wt({label:r[v],value:w,pct:Q}),R=`M ${g-E} ${$} L ${g+E} ${$} 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="${$+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${ne(r[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${$+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="${$+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,dt)=>rt+dt,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((St,yt)=>St+yt,0),rt=V>=U,dt=rt?J/V:U,ot=rt?V:J/U,Ot=0;for(let St=0;St<Q.length;St++){let yt=Q[St]/J,Ct=u[D+St];if(rt){let Lt=yt*V;d.push({i:Ct,x:R+Ot,y:_,w:Lt,h:dt}),Ot+=Lt}else{let Lt=yt*U;d.push({i:Ct,x:R,y:_+Ot,w:ot,h:Lt}),Ot+=Lt}}return rt?{x:R,y:_+dt,w:V,h:U-dt}:{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 $="",T=2;for(let Q of d){let D=(i[Q.i]/c*100).toFixed(1),R=wt({label:r[Q.i],value:i[Q.i],pct:D});$+=`<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)$+=`<text data-treemap-label x="${_}" y="${Q.y+h+4}" font-size="${h}" dominant-baseline="hanging">${ne(r[Q.i])}</text>`,$+=`<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;$+=`<text data-treemap-label x="${_}" y="${rt}" font-size="${h}" dominant-baseline="central">${ne(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:$,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}">${ne(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}">${ne(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 $=A/c*m,T=A/u*b,Q=k.cursor,D=Q+$,R=E.cursor,_=R+T;k.cursor+=$,E.cursor+=T;let V=h,U=n-h,J=(V+U)/2,rt=wt({label:`${k.name} \u2192 ${E.name}`,value:A}),dt=`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="${dt}"/>`}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=ds(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.#F(d,f,c,o,p,t);if(!this.#v(r))for(let E=0;E<e.length;E++){let A=a[E],$=u?A/u*m:0,T=p.left+g*E+v,Q=p.top+m-$;k+=`<path${this.#m(0,r)}${wt({label:o[E],value:A,series:r})} d="${Ch(T,Q,y,$,this.#o())}"/>`}if(!this.#v(n)){let E=l.map(($,T)=>({x:p.left+g*T+g/2,y:p.top+m-(u?$/u*m:0),v:$,label:o[T]})),A=Math.max(0,Math.min(1,this.smooth));k+=`<path data-line${this.#g(1,n)} d="${La(E,A)}"/>`;for(let $ of E)k+=`<circle data-dot${this.#m(1,n)} cx="${$.x}" cy="${$.y}" r="3"/>`,k+=`<circle data-hit${wt({label:$.label,value:$.v,series:n})} cx="${$.x}" cy="${$.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=wt({label:n[p],value:i[p],pct:w}),E=`<title>${ne(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,$=m+v,T;g?T=`M ${m+A} 0 H ${$} 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 ${$-A} A ${A} ${A} 0 0 1 ${$} ${A} V ${l-A} A ${A} ${A} 0 0 1 ${$-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=ds(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.#F(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,$=y,T=E,Q=w===v-1,D=this.#o(),R=`${this.#m(w%10,e[w])}${wt({label:i[g],value:k,series:e[w]})}`;Q?b+=`<path${R} d="${Ch(A,$,p,T,D)}"/>`:b+=`<rect${R} x="${A}" y="${$}" 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=ds(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.#F(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.top+u-E;y+=`<path${this.#m(w%10,e[w])}${wt({label:i[v],value:k,series:e[w]})} d="${Ch(A,$,b,E,this.#o())}"/>`,this.hideValues||(y+=`<text data-value x="${A+b/2}" y="${$-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=ds(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.#F(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="${Gd(g,y,v)}"/>`,p+=`<path data-line${this.#g(m%10,e[m])} d="${La(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${wt({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",pn);C();var mn=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",mn);C();var UC=120,gn=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=ut(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},UC)};#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",gn);C();var bn=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)}},On=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",bn),S("accordion-item-ui",On);C();var yn=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",yn);C();var vn=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",vn);C();var Kd=[{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}],xn=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=Kd.find(o=>i<=o.limit)||Kd[Kd.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",xn);C();var Sn=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",Sn);C();var Jd=["Weak","Fair","Good","Strong"];function FC(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 wn=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>
@@ -198,12 +198,12 @@ Correct shape for <chart-ui x="label" y="value">:
198
198
  `),this.setAttribute("role","meter"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","3")}render(){let t=FC(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",Jd[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?Jd[t]:""),t!==this.#t&&(this.#t=t,this.dispatchEvent(new CustomEvent("score-change",{bubbles:!0,detail:{score:t,label:t>=0?Jd[t]:"",satisfied:t>=this.minScore}})))}};S("password-strength-ui",wn);C();function YC(s){return(s||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section"}var kn=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=YC(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",kn);var Ma=new Uint8Array(512),$h=new Uint8Array(256);(function(){let t=1;for(let e=0;e<255;e++)Ma[e]=t,$h[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)Ma[e]=Ma[e-255]})();function Ph(s,t){return s===0||t===0?0:Ma[($h[s]+$h[t])%255]}function py(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]=Ph(t[r],e),r+1<t.length&&(t[r]^=t[r+1]);e=Ph(e,2)}return t}function my(s,t){let e=py(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]^=Ph(e[o],n)}return i}var tf={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 gy(s,t){let[,e,i,r,n]=tf[t][s-1];return e*i+r*n}function by(s,t){for(let e=1;e<=10;e++){let i=gy(e,t),r=4+(e<10?8:16),n=Math.floor((i*8-r)/8);if(s<=n)return e}return-1}var HC=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]];function Oy(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 yy(s,t,e){let r=gy(t,e)*8,n=[];Qh(n,4,4);let o=t<10?8:16;Qh(n,s.length,o);for(let u of s)Qh(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;)Qh(n,h[c%2],8),c++;return GC(n)}function Qh(s,t,e){for(let i=e-1;i>=0;i--)s.push(t>>i&1)}function GC(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 vy(s,t,e){let[i,r,n,o,a]=tf[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=>my(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 KC(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 ef(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 JC(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 t$(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 e$(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 i$(s,t,e){let i=s.length;ef(s,t,0,0),ef(s,t,0,i-7),ef(s,t,i-7,0);let r=HC[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||JC(s,t,n,o);t$(s,t),s[i-8][8]=1,t[i-8][8]=1,e$(t)}function s$(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 r$(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 n$(s,t,e){let i=s.length;for(let r=0;r<i;r++)for(let n=0;n<i;n++)!t[r][n]&&r$(e,r,n)&&(s[r][n]^=1)}function o$(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 a$(s,t,e){let i=o$(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 l$(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 h$(s,t,e){if(t<7)return;let i=l$(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 c$(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 nj={rsGenerator:py,rsEncode:my,gfMul:Ph,EXP:Ma,LOG:$h,buildDataBits:yy,interleaveCodewords:vy,utf8Encode:Oy,selectVersion:by};function xy(s,t={}){let e=t.errorCorrection||"M";if(!tf[e])throw new Error(`Unknown error-correction level: ${e}. Expected L/M/Q/H.`);let i=Oy(s),r=t.version||by(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=yy(i,r,e),o=vy(n,r,e),a=null,l=1/0;for(let h=0;h<8;h++){let{matrix:c,reserved:u,size:d}=KC(r);i$(c,u,r),h$(c,r,u),s$(c,u,o),n$(c,u,h),a$(c,e,h);let f=c$(c);f<l&&(l=f,a={matrix:c,size:d,version:r,mask:h,ecc:e})}return a}function Sy(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>`}C();var An=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=xy(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=Sy(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",An);C();var En=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",En);C();var JI=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),tD={js:"javascript",md:"markdown",yml:"yaml"};function zb(s){if(!s)return"";let t=String(s).toLowerCase();return tD[t]??t}var ho=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=zb(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(JI.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=zb(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>`}C();var An=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=xy(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=Sy(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",An);C();var En=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",En);C();var JI=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),tD={js:"javascript",md:"markdown",yml:"yaml"};function zb(s){if(!s)return"";let t=String(s).toLowerCase();return tD[t]??t}var ho=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.#b();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=zb(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(JI.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=zb(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=zb(this.language);this.#r=!0;try{let i=await Promise.resolve().then(()=>(Zb(),Bb)),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:$=>(this.#b($),!0)},...d,...u,f]),n.updateListener.of($=>{if(!$.docChanged)return;let T=$.state.doc.toString();this.#m(T),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:T}}))}),n.domEventHandlers({focus:($,T)=>(this.#n=T.state.doc.toString(),!1),blur:($,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(()=>(Zb(),Bb));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",ho);C();function a1(s){let t=s.replace(/=""(?=[\s/>])/g,"").replace(/="([^"]*&quot;[^"]*)"/g,(o,a)=>{let l=a.replace(/&quot;/g,'"').replace(/&amp;/g,"&");return l.includes("'")?o:`='${l}'`}).replace(/\t/g," ").split(`
204
+ `):e}async#u(){if(this.#r||this.#i)return;let t=this.#s,e=zb(this.language);this.#r=!0;try{let i=await Promise.resolve().then(()=>(Zb(),Bb)),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:$=>(this.#O($),!0)},...d,...u,f]),n.updateListener.of($=>{if(!$.docChanged)return;let T=$.state.doc.toString();this.#m(T),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:T}}))}),n.domEventHandlers({focus:($,T)=>(this.#n=T.state.doc.toString(),!1),blur:($,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(()=>(Zb(),Bb));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)}#O(t){this.dispatchEvent(new CustomEvent("save",{bubbles:!0,cancelable:!0,detail:{value:t.state.doc.toString()}}))}get value(){return this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??this.text??""}set value(t){this.text=String(t??"")}#b(){let t=this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??"";t&&navigator.clipboard.writeText(t).then(()=>{let e=this.querySelector(':scope > header [slot="copy"]');if(!e)return;let i=e.textContent;e.textContent="Copied!",this.#e!=null&&clearTimeout(this.#e),this.#e=setTimeout(()=>{this.#e=null,e.textContent=i},1500)})}render(){let t=this.querySelector(':scope > header [slot="label"]');if(t&&this.language&&(t.textContent=this.language),this.#p(),!this.inline&&this.text!=="")if(this.#i){if(this.editable&&this.#i.hasFocus)return;let e=this.#i.state.doc.toString();e!==this.text&&this.#i.dispatch({changes:{from:0,to:e.length,insert:this.text}})}else{let e=this.querySelector(":scope > pre > code");e&&e.textContent!==this.text&&(e.textContent=this.text)}}};S("code-ui",ho);C();function a1(s){let t=s.replace(/=""(?=[\s/>])/g,"").replace(/="([^"]*&quot;[^"]*)"/g,(o,a)=>{let l=a.replace(/&quot;/g,'"').replace(/&amp;/g,"&");return l.includes("'")?o:`='${l}'`}).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 co=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=a1(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=a1(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",co);C();var uo=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?.())}},fo=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",uo),S("list-item-ui",fo);C();var po=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.#$()};#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.#x()||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.#E(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.#M(),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.#$());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.#M(),this.#P(),e&&this.scrollToBottom(),this.#d=this.#$()}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.#E(Math.max(0,h),e)}scrollToTop(){this.#E(0)}scrollToBottom(){let t=this.#S();this.#E(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.#M(),this.#P()}#x(){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.#x();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#w(t){let e=this.#x();if(e>0)return t*e;let i=0;for(let r=0;r<t;r++)i+=this.#v(r);return i}#S(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#x();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}#E(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#$(){let t=this.#A(),e=this.#k(),i=this.#S();return t+e>=i-1}#M(){if(!this.#t)return;let t=this.#S();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")}#C(){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.#x(),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.#C(),n=this.#w(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${n}px)`:this.#e.style.transform=`translateY(${n}px)`,this.loading?this.#Q(r-i):this.#D(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})))}#D(t,e,i){if(!this.#e)return;let r=new Set,n=this.#r??this.#T();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.#L(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)}#Q(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)}}#L(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}#T(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#I==null&&(this.#I=t.innerHTML);let e=this.#I;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?"":eD(String(h))}),o=document.createElement("template");return o.innerHTML=n,o.content.cloneNode(!0)}}#I=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 eD(s){return s.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}S("list-window-ui",po);C();var mo=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, menu-label-ui");for(let r of i)e.contains(r)||e.appendChild(r);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=ut(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, menu-label-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}},go=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()}},bo=class extends x{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}},Zl=class extends x{static properties={text:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation"),this.#t()}#t(){if(!this.querySelector(':scope > [slot="text"]')&&this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.dataset.menuLabelStamped="1",t.textContent=this.text,this.appendChild(t)}}render(){let t=this.querySelector(':scope > [slot="text"]');t?.dataset.menuLabelStamped==="1"&&(t.textContent=this.text)}};S("menu-ui",mo),S("menu-item-ui",go),S("menu-divider-ui",bo),S("menu-label-ui",Zl);C();var l1=500,Oo=class extends x{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:l1,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.#x(),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??l1))};#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.#S),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=ut(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.#x(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#n?.focus?.()}catch{}}}#x(){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.#y("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y("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}#S=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",Oo);C();var yo=class extends x{static properties={};static template=()=>null};S("visually-hidden-ui",yo);C();var vo=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",vo);C();var xo=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",xo);var So=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",So);C();var wo=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 co=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=a1(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=a1(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",co);C();var uo=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?.())}},fo=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",uo),S("list-item-ui",fo);C();var po=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.#$()};#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}))};#O=t=>{if(t.target!==this)return;let e=this.#x()||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.#E(n+r)};#b=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.#M(),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.#b,{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.#O),this.startIndex>0&&queueMicrotask(()=>this.scrollToIndex(this.startIndex))}disconnected(){this.removeEventListener("scroll",this.#m),this.removeEventListener("click",this.#g),this.removeEventListener("keydown",this.#O),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.#$());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.#M(),this.#P(),e&&this.scrollToBottom(),this.#d=this.#$()}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.#E(Math.max(0,h),e)}scrollToTop(){this.#E(0)}scrollToBottom(){let t=this.#S();this.#E(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.#M(),this.#P()}#x(){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.#x();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#w(t){let e=this.#x();if(e>0)return t*e;let i=0;for(let r=0;r<t;r++)i+=this.#v(r);return i}#S(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#x();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}#E(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#$(){let t=this.#A(),e=this.#k(),i=this.#S();return t+e>=i-1}#M(){if(!this.#t)return;let t=this.#S();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")}#C(){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.#x(),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.#C(),n=this.#w(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${n}px)`:this.#e.style.transform=`translateY(${n}px)`,this.loading?this.#Q(r-i):this.#D(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})))}#D(t,e,i){if(!this.#e)return;let r=new Set,n=this.#r??this.#T();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.#L(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)}#Q(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)}}#L(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}#T(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#I==null&&(this.#I=t.innerHTML);let e=this.#I;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?"":eD(String(h))}),o=document.createElement("template");return o.innerHTML=n,o.content.cloneNode(!0)}}#I=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 eD(s){return s.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}S("list-window-ui",po);C();var mo=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.#b),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, menu-label-ui");for(let r of i)e.contains(r)||e.appendChild(r);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=ut(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.#O,!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, menu-label-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.#O,!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))};#O=t=>{t.key==="Escape"&&this.open?(t.stopPropagation(),t.preventDefault(),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0})):t.key==="Tab"&&this.open&&(this.open=!1)};#b=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#b),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},go=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()}},bo=class extends x{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}},Zl=class extends x{static properties={text:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation"),this.#t()}#t(){if(!this.querySelector(':scope > [slot="text"]')&&this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.dataset.menuLabelStamped="1",t.textContent=this.text,this.appendChild(t)}}render(){let t=this.querySelector(':scope > [slot="text"]');t?.dataset.menuLabelStamped==="1"&&(t.textContent=this.text)}};S("menu-ui",mo),S("menu-item-ui",go),S("menu-divider-ui",bo),S("menu-label-ui",Zl);C();var l1=500,Oo=class extends x{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:l1,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.#x(),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.#b(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.#b(t.clientX,t.clientY))};#d=t=>{if(!this.#m())return;let e=t.touches[0];e&&(this.#r=setTimeout(()=>{this.#n=t.currentTarget,this.#b(e.clientX,e.clientY)},this.longPressMs??l1))};#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.#S),document.body.appendChild(t),this.#t=t,t}#O(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}#b(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.#O(t,e);this.#i?.(),this.#i=ut(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.#x(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#n?.focus?.()}catch{}}}#x(){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.#y("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y("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}#S=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",Oo);C();var yo=class extends x{static properties={};static template=()=>null};S("visually-hidden-ui",yo);C();var vo=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",vo);C();var xo=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",xo);var So=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",So);C();var wo=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=`
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=ut(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}}}},ko=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 iD(s){return String(s??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}S("tour-ui",wo),S("tour-step-ui",ko);C();var h1="data-toolbar-spillover",sD="data-toolbar-spillover-menu",c1=8,rd="data-toolbar-spillover-label";function u1(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function rD(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function nD(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(rd)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||rD(e.getAttribute("icon"));i&&(e.setAttribute(rd,""),e.setAttribute("text",i))}}function oD(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(rd)&&(e.removeAttribute(rd),e.removeAttribute("text"))}function d1(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,r=parseFloat(e.marginRight)||0;return t.width+i+r}var Ao=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(h1,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(sD,""),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=ut(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(`[${h1}]`)||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.#x()}))}#O(){this.#e?.observe(this,{childList:!0})}#y(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#x(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#n=!0,this.#y();try{for(;e.firstChild;)oD(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=>d1(y)),d=u.reduce((y,v)=>y+v,0)+Math.max(0,n.length-1)*h,f=d<=c-c1;if(this.overflow==="none"||f)return;t.hidden=!1;let p=d1(t),m=n.length,b=d;for(;m>0&&!(b+h+p<=c-c1);)m-=1,b-=u[m],m>0&&(b-=h);for(;m>0&&u1(n[m-1]);)m-=1;let g=n.slice(m);for(let y of g){if(u1(y)){y.hidden=!0;continue}nD(y),e.appendChild(y)}e.firstElementChild||(t.hidden=!0)}finally{this.#n=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#O()})}}}},Eo=class extends x{static template=()=>null;connected(){this.setAttribute("role","group")}};S("toolbar-ui",Ao),S("toolbar-group-ui",Eo);C();var Co=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",Co);C();var $o=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"),at(this,"header").length?this.#i=at(this,"header")[0]:(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=ut(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}}}},ko=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 iD(s){return String(s??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}S("tour-ui",wo),S("tour-step-ui",ko);C();var h1="data-toolbar-spillover",sD="data-toolbar-spillover-menu",c1=8,rd="data-toolbar-spillover-label";function u1(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function rD(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function nD(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(rd)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||rD(e.getAttribute("icon"));i&&(e.setAttribute(rd,""),e.setAttribute("text",i))}}function oD(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(rd)&&(e.removeAttribute(rd),e.removeAttribute("text"))}function d1(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,r=parseFloat(e.marginRight)||0;return t.width+i+r}var Ao=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.#O()),this.#t.observe(this),this.#e=new MutationObserver(()=>{this.#n||this.#O()}),this.#b(),this.#O()}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(h1,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(sD,""),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=ut(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(`[${h1}]`)||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))};#O(){this.#a||(this.#a=!0,this.#o=requestAnimationFrame(()=>{this.#o=null,this.#a=!1,this.isConnected&&this.#x()}))}#b(){this.#e?.observe(this,{childList:!0})}#y(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#x(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#n=!0,this.#y();try{for(;e.firstChild;)oD(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=>d1(y)),d=u.reduce((y,v)=>y+v,0)+Math.max(0,n.length-1)*h,f=d<=c-c1;if(this.overflow==="none"||f)return;t.hidden=!1;let p=d1(t),m=n.length,b=d;for(;m>0&&!(b+h+p<=c-c1);)m-=1,b-=u[m],m>0&&(b-=h);for(;m>0&&u1(n[m-1]);)m-=1;let g=n.slice(m);for(let y of g){if(u1(y)){y.hidden=!0;continue}nD(y),e.appendChild(y)}e.firstElementChild||(t.hidden=!0)}finally{this.#n=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#b()})}}}},Eo=class extends x{static template=()=>null;connected(){this.setAttribute("role","group")}};S("toolbar-ui",Ao),S("toolbar-group-ui",Eo);C();var Co=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",Co);C();var $o=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"),at(this,"header").length?this.#i=at(this,"header")[0]:(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>`:""}
@@ -233,7 +233,7 @@ Correct shape for <chart-ui x="label" y="value">:
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",Lo);$t();function Fs(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function aD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var lD=0,Mo=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"},maxVisibleItems:{type:Number,default:10,reflect:!0,attribute:"max-visible-items"},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-${++lD}`;#g=()=>this.#q();#b=t=>this.#R(t);#O=()=>this.#z();#y=t=>this.#_(t);#x=t=>this.#Y(t);#v=t=>this.#W(t);#w=t=>this.#tt(t);#S=t=>this.#et(t);#k=t=>this.#it(t);connected(){super.connected(),this.#t.length===0&&this.#C(),this.#e=this.value||"",this.#A(),this.#Q(),this.#U()}disconnected(){super.disconnected(),this.#M(),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.#rt():this.#G())}#A(){if(this.querySelector(":scope > [data-field]")){this.#E(),this.#$();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,r=at(this,"prefix"),n=at(this,"suffix"),o=at(this,"empty"),a=at(this,"loading"),l=at(this,"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",Lo);$t();function Fs(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function aD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var lD=0,Mo=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"},maxVisibleItems:{type:Number,default:10,reflect:!0,attribute:"max-visible-items"},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-${++lD}`;#g=()=>this.#q();#O=t=>this.#R(t);#b=()=>this.#z();#y=t=>this.#_(t);#x=t=>this.#Y(t);#v=t=>this.#W(t);#w=t=>this.#tt(t);#S=t=>this.#et(t);#k=t=>this.#it(t);connected(){super.connected(),this.#t.length===0&&this.#C(),this.#e=this.value||"",this.#A(),this.#Q(),this.#U()}disconnected(){super.disconnected(),this.#M(),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.#rt():this.#G())}#A(){if(this.querySelector(":scope > [data-field]")){this.#E(),this.#$();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,r=at(this,"prefix"),n=at(this,"suffix"),o=at(this,"empty"),a=at(this,"loading"),l=at(this,"footer");this.innerHTML=`
237
237
  <span data-label id="${t}"${this.label?"":' style="display:none"'}>${Fs(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.#E(),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(){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]")}#$(){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.#w),this.#d&&this.#d.addEventListener("click",this.#S)}#M(){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.#w),this.#d&&this.#d.removeEventListener("click",this.#S)}#C(){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.#Q(),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}#D(t){return this.#P().find(e=>e.value===t)||null}#Q(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#P(),i=this.#X(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=`<span data-option-label>${this.#T(a.label??a.value)}</span>`,l.addEventListener("click",this.#x),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.#X(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.#I(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.open&&this.#L(),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant")}#L(){if(!this.#o)return;let t=Number(this.maxVisibleItems),e=this.#o.querySelectorAll('[role="option"]');if(!Number.isFinite(t)||t<=0||e.length<=t){this.#o.style.removeProperty("--combobox-list-max-block");return}let i=e[0].getBoundingClientRect().height;if(!i)return;let r=getComputedStyle(this.#o),n=(parseFloat(r.paddingBlockStart)||0)+(parseFloat(r.paddingBlockEnd)||0)+(parseFloat(r.borderBlockStartWidth)||0)+(parseFloat(r.borderBlockEndWidth)||0);this.#o.style.setProperty("--combobox-list-max-block",`${Math.ceil(i*t+n)}px`)}#T(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Fs(e);let i=this.#i,r=new RegExp(aD(i),"i"),n=e.match(r);if(!n)return Fs(e);let o=n.index??0,a=o+n[0].length;return Fs(e.slice(0,o))+"<mark>"+Fs(e.slice(o,a))+"</mark>"+Fs(e.slice(a))}#I(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)}}#X(t){return this.#i?t.filter(e=>this.#I(e)):t.slice()}#q(){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.#Q();let e=this.#B();this.#i&&e.length&&this.#V(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#R(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.#V(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#B();this.#V(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#N();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#st("escape"));return}if(e==="Tab"){this.#F();return}if(e==="Backspace"){let i=!(this.#n.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#z(){}#_(t){!this.freeText&&this.#i&&!this.value&&(this.#U(),this.#i="")}#B(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#j(t){let e=this.#B();if(!e.length)return;if(this.#s<0){this.#V(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#V(i)}#V(t){let e=this.#B();if(!e.length){this.#s=-1,this.#n?.removeAttribute("aria-activedescendant");return}for(let o of e)o.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),r=e[i];if(!r)return;r.setAttribute("data-active","");let n=this.#o;if(n){let o=r.offsetTop,a=o+r.offsetHeight;o<n.scrollTop?n.scrollTop=o:a>n.scrollTop+n.clientHeight&&(n.scrollTop=a-n.clientHeight)}this.#s=i,this.#n?.setAttribute("aria-activedescendant",r.id)}#Y(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#H(i,"click")}#W(t){let e=t.currentTarget,r=this.#B().indexOf(e);r>=0&&this.#V(r)}#N(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#B(),e=this.#s>=0?t[this.#s]:null;if(e){this.#H(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(!i){this.#G("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#K(i,"keyboard");return}if(this.freeText){this.#K(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#U(),this.#i="",this.#Q()}#F(){if(!this.open)return;let t=this.#B(),e=this.#s>=0?t[this.#s]:null;if(e){this.#H(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#D(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#K(i,"keyboard");return}this.#U(),this.#i="",this.#G("blur")}#H(t,e){if(this.readonly){this.#G("select");return}let i=this.#D(t);F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#U(),this.#Q(),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"}}))}#K(t,e){if(this.readonly){this.#G("select");return}F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#U(),this.#Q(),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"}}))}#tt(t){t.preventDefault(),t.stopPropagation(),this.#J("click"),this.#n?.focus()}#J(t){F(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#U(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#J("programmatic")}#et(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()))}#it(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"}})))}#st(t){this.#U(),this.#i="",this.#Q(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#rt(){if(!this.#o)return;this.#o.showPopover?.(),this.#L();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=ut(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.#B();if(!e.length)return;let i=e.findIndex(r=>r.dataset.value===this.value);this.#V(i>=0?i:0)}#G(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.#D(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.#D(t)?(this.#H(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};S("combobox-ui",Mo);$t();var hD=0;function cD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ro=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.#j(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-${++hD}`;#u=()=>this.#A();#d=t=>this.#E(t);#f=t=>this.#$(t);#p=t=>this.#M(t);#m=t=>this.#C(t);#g=t=>this.#P(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#j(this.getAttribute("value"));t&&(this.#t=t)}this.#b(),this.#v(),this.#S(),this.#k()}disconnected(){super.disconnected(),this.#x(),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.#j(t)||[]:[],i=this.#t.slice();this.#t=e,this.#v(),this.#S(),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.#Q(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#I(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#v(),this.#S(),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.#E(),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(){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]")}#$(){this.#n&&(this.#n.addEventListener("input",this.#g),this.#n.addEventListener("keydown",this.#O),this.#n.addEventListener("focus",this.#b),this.#n.addEventListener("blur",this.#y)),this.#u&&this.#u.addEventListener("click",this.#w),this.#d&&this.#d.addEventListener("click",this.#S)}#M(){this.#n&&(this.#n.removeEventListener("input",this.#g),this.#n.removeEventListener("keydown",this.#O),this.#n.removeEventListener("focus",this.#b),this.#n.removeEventListener("blur",this.#y)),this.#u&&this.#u.removeEventListener("click",this.#w),this.#d&&this.#d.removeEventListener("click",this.#S)}#C(){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.#Q(),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}#D(t){return this.#P().find(e=>e.value===t)||null}#Q(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#P(),i=this.#X(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=`<span data-option-label>${this.#T(a.label??a.value)}</span>`,l.addEventListener("click",this.#x),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.#X(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.#I(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.open&&this.#L(),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant")}#L(){if(!this.#o)return;let t=Number(this.maxVisibleItems),e=this.#o.querySelectorAll('[role="option"]');if(!Number.isFinite(t)||t<=0||e.length<=t){this.#o.style.removeProperty("--combobox-list-max-block");return}let i=e[0].getBoundingClientRect().height;if(!i)return;let r=getComputedStyle(this.#o),n=(parseFloat(r.paddingBlockStart)||0)+(parseFloat(r.paddingBlockEnd)||0)+(parseFloat(r.borderBlockStartWidth)||0)+(parseFloat(r.borderBlockEndWidth)||0);this.#o.style.setProperty("--combobox-list-max-block",`${Math.ceil(i*t+n)}px`)}#T(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Fs(e);let i=this.#i,r=new RegExp(aD(i),"i"),n=e.match(r);if(!n)return Fs(e);let o=n.index??0,a=o+n[0].length;return Fs(e.slice(0,o))+"<mark>"+Fs(e.slice(o,a))+"</mark>"+Fs(e.slice(a))}#I(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)}}#X(t){return this.#i?t.filter(e=>this.#I(e)):t.slice()}#q(){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.#Q();let e=this.#B();this.#i&&e.length&&this.#V(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#R(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.#V(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#B();this.#V(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#N();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#st("escape"));return}if(e==="Tab"){this.#F();return}if(e==="Backspace"){let i=!(this.#n.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#z(){}#_(t){!this.freeText&&this.#i&&!this.value&&(this.#U(),this.#i="")}#B(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#j(t){let e=this.#B();if(!e.length)return;if(this.#s<0){this.#V(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#V(i)}#V(t){let e=this.#B();if(!e.length){this.#s=-1,this.#n?.removeAttribute("aria-activedescendant");return}for(let o of e)o.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),r=e[i];if(!r)return;r.setAttribute("data-active","");let n=this.#o;if(n){let o=r.offsetTop,a=o+r.offsetHeight;o<n.scrollTop?n.scrollTop=o:a>n.scrollTop+n.clientHeight&&(n.scrollTop=a-n.clientHeight)}this.#s=i,this.#n?.setAttribute("aria-activedescendant",r.id)}#Y(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#H(i,"click")}#W(t){let e=t.currentTarget,r=this.#B().indexOf(e);r>=0&&this.#V(r)}#N(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#B(),e=this.#s>=0?t[this.#s]:null;if(e){this.#H(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(!i){this.#G("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#K(i,"keyboard");return}if(this.freeText){this.#K(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#U(),this.#i="",this.#Q()}#F(){if(!this.open)return;let t=this.#B(),e=this.#s>=0?t[this.#s]:null;if(e){this.#H(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#D(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#K(i,"keyboard");return}this.#U(),this.#i="",this.#G("blur")}#H(t,e){if(this.readonly){this.#G("select");return}let i=this.#D(t);F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#U(),this.#Q(),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"}}))}#K(t,e){if(this.readonly){this.#G("select");return}F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#U(),this.#Q(),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"}}))}#tt(t){t.preventDefault(),t.stopPropagation(),this.#J("click"),this.#n?.focus()}#J(t){F(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#U(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#J("programmatic")}#et(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()))}#it(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"}})))}#st(t){this.#U(),this.#i="",this.#Q(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#rt(){if(!this.#o)return;this.#o.showPopover?.(),this.#L();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=ut(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.#B();if(!e.length)return;let i=e.findIndex(r=>r.dataset.value===this.value);this.#V(i>=0?i:0)}#G(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.#D(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.#D(t)?(this.#H(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};S("combobox-ui",Mo);$t();var hD=0;function cD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ro=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.#j(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-${++hD}`;#u=()=>this.#A();#d=t=>this.#E(t);#f=t=>this.#$(t);#p=t=>this.#M(t);#m=t=>this.#C(t);#g=t=>this.#P(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#j(this.getAttribute("value"));t&&(this.#t=t)}this.#O(),this.#v(),this.#S(),this.#k()}disconnected(){super.disconnected(),this.#x(),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.#j(t)||[]:[],i=this.#t.slice();this.#t=e,this.#v(),this.#S(),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.#Q(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#I(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#v(),this.#S(),this.#k(),this.#X(t,[],"programmatic")}focus(){this.#o?.focus()}#O(){if(this.querySelector(":scope > [data-chip-list]")){this.#b(),this.#y();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,7 +277,7 @@ 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)}#x(){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()}#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")}#S(){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.#Q(n,"delimiter")&&(r=!0);this.#r=!0,this.#o.textContent=i||"",this.#r=!1,this.#z(),this.#S(),this.#w(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#S(),this.#w(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#E(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.#Q(r.dataset.value||"","suggestion");return}}i&&this.#Q(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#I(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#_(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#_(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#B())}#$(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(`[${cD(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.#S(),this.#w();return}let n="";for(let o=0;o<r.length;o++){let a=r[o];!this.#Q(a,"paste")&&o===r.length-1&&(n=a)}n&&(this.#r=!0,this.#o.textContent=n,this.#r=!1,this.#z(),this.#S(),this.#w())}#M(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.#I(i,"chip-click"))}#C(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.#z())}#P(t){let e=t.target.closest('[role="option"]');e&&this.#Q(e.dataset.value||"","suggestion")}#D(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#Q(t,e){if(this.disabled||this.readonly)return!1;let i=this.#D(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.#L(i,o,e),!1;if(o===!1)return this.#q(i,"validator"),!1}catch{return this.#q(i,"validator"),!1}return this.#T(i,e),!0}#L(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.#T(t,i)}},()=>{r!==this.#n||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#q(t,"validator"))})}#T(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#R(),this.#S(),this.#k(),this.#X(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#I(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.#S(),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())}#z(){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{}}#_(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)}#B(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#j(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.#j(t);if(e){this.value=e;return}}super.syncValue(t)}};S("tags-input-ui",Ro);C();var zl=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",zl);C();var Io=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",Io);C();var Do=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}}}},qo=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",Do),S("action-item-ui",qo);C();var Xo=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",Xo);C();var uD=["S","M","T","W","T","F","S"],dD=["January","February","March","April","May","June","July","August","September","October","November","December"];function f1(s){return String(s).padStart(2,"0")}function _b(s,t,e){return`${s}-${f1(t+1)}-${f1(e)}`}function Ii(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 nd(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var No=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=Ii(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=Ii(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=Ii(this.value),n=Ii(this.min),o=Ii(this.max),a=Ii(this.rangeStart),l=Ii(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
280
+ `,this.#b(),this.#y()}#b(){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)}#x(){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()}#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")}#S(){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.#Q(n,"delimiter")&&(r=!0);this.#r=!0,this.#o.textContent=i||"",this.#r=!1,this.#z(),this.#S(),this.#w(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#S(),this.#w(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#E(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.#Q(r.dataset.value||"","suggestion");return}}i&&this.#Q(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#I(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#_(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#_(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#B())}#$(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(`[${cD(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.#S(),this.#w();return}let n="";for(let o=0;o<r.length;o++){let a=r[o];!this.#Q(a,"paste")&&o===r.length-1&&(n=a)}n&&(this.#r=!0,this.#o.textContent=n,this.#r=!1,this.#z(),this.#S(),this.#w())}#M(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.#I(i,"chip-click"))}#C(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.#z())}#P(t){let e=t.target.closest('[role="option"]');e&&this.#Q(e.dataset.value||"","suggestion")}#D(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#Q(t,e){if(this.disabled||this.readonly)return!1;let i=this.#D(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.#L(i,o,e),!1;if(o===!1)return this.#q(i,"validator"),!1}catch{return this.#q(i,"validator"),!1}return this.#T(i,e),!0}#L(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.#T(t,i)}},()=>{r!==this.#n||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#q(t,"validator"))})}#T(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#R(),this.#S(),this.#k(),this.#X(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#I(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.#S(),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())}#z(){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{}}#_(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)}#B(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#j(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.#j(t);if(e){this.value=e;return}}super.syncValue(t)}};S("tags-input-ui",Ro);C();var zl=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",zl);C();var Io=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",Io);C();var Do=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}}}},qo=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",Do),S("action-item-ui",qo);C();var Xo=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",Xo);C();var uD=["S","M","T","W","T","F","S"],dD=["January","February","March","April","May","June","July","August","September","October","November","December"];function f1(s){return String(s).padStart(2,"0")}function _b(s,t,e){return`${s}-${f1(t+1)}-${f1(e)}`}function Ii(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 nd(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var No=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=Ii(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=Ii(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=Ii(this.value),n=Ii(this.min),o=Ii(this.max),a=Ii(this.rangeStart),l=Ii(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>${dD[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>
@@ -290,11 +290,11 @@ 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>${p1[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>${fD.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=m1(t,e,f),b=g1(p,i),g=r&&g1(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=is(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=m1(this.#s,this.#r,this.#n),r=new Date(this.#s,this.#r,this.#n),n=is(this.min),o=is(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",Bo);$t();var mD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],gD=["January","February","March","April","May","June","July","August","September","October","November","December"];function jb(s){return String(s).padStart(2,"0")}function We(s){return s?`${s.getFullYear()}-${jb(s.getMonth()+1)}-${jb(s.getDate())}`:""}function Vb(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 Ue(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 b1(s){return s?s.from<=s.to:!1}function O1(s,t){let e=Vb(s);if(!e)return"";switch(t){case"long":return`${gD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${mD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function bD(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=We(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),We(l)},r=We(new Date(t.getFullYear(),t.getMonth(),1)),n=We(new Date(t.getFullYear(),t.getMonth()+1,0)),o=We(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 OD(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var Zo=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" icon-trailing="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 Ue(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return Ue(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:bD()}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=Ue(e);if(this.comparison&&this.name){let r=new FormData;i&&r.append(this.name,e),Ue(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&&!b1(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.#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.#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.#w),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#x),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=at(this,"presets")[0];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=Ue(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}-${jb(a+1)}`),e.appendChild(r)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=at(this,"footer")[0];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=Ue(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)),at(this,"presets").length||(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=ut(this.#n,this.#a,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#S),document.addEventListener("keydown",this.#x),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.#S),document.removeEventListener("keydown",this.#x),this.#n?.focus?.()))}#f(){let t=Ue(this.value);if(!t)return this.placeholder;let e=O1(t.from,this.format),i=O1(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 OD()){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=Ue(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.#E();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())}};#x=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=Ue(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=Ue(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})};#S=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(!b1(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:Ue(this.compareValue),presetLabel:e.presetLabel||null}}))}#A(t,e){let i=Vb(e.from),r=Vb(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:We(a),to:We(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:We(o),to:We(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:We(o),to:We(a)}}default:return null}}#E(){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",Zo);var y1=23,v1=12,c3=1,x1=59,S1=59,yD=["hour","minute"];function _l(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 Wb({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 vD(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 jo=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:vD(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=[...yD];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>${fD.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=m1(t,e,f),b=g1(p,i),g=r&&g1(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=is(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=m1(this.#s,this.#r,this.#n),r=new Date(this.#s,this.#r,this.#n),n=is(this.min),o=is(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",Bo);$t();var mD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],gD=["January","February","March","April","May","June","July","August","September","October","November","December"];function jb(s){return String(s).padStart(2,"0")}function We(s){return s?`${s.getFullYear()}-${jb(s.getMonth()+1)}-${jb(s.getDate())}`:""}function Vb(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 Ue(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 b1(s){return s?s.from<=s.to:!1}function O1(s,t){let e=Vb(s);if(!e)return"";switch(t){case"long":return`${gD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${mD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function bD(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=We(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),We(l)},r=We(new Date(t.getFullYear(),t.getMonth(),1)),n=We(new Date(t.getFullYear(),t.getMonth()+1,0)),o=We(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 OD(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var Zo=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" icon-trailing="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 Ue(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return Ue(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:bD()}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=Ue(e);if(this.comparison&&this.name){let r=new FormData;i&&r.append(this.name,e),Ue(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&&!b1(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.#O,!0),this.#a.addEventListener("click",this.#b),this.#a.addEventListener("keydown",this.#y),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.#O,!0)),this.#a&&(this.#a.removeEventListener("click",this.#b),this.#a.removeEventListener("keydown",this.#y),this.#a.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#v),this.#c&&this.#c.removeEventListener("change",this.#w),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#x),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=at(this,"presets")[0];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=Ue(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}-${jb(a+1)}`),e.appendChild(r)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=at(this,"footer")[0];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=Ue(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)),at(this,"presets").length||(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=ut(this.#n,this.#a,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#S),document.addEventListener("keydown",this.#x),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.#S),document.removeEventListener("keydown",this.#x),this.#n?.focus?.()))}#f(){let t=Ue(this.value);if(!t)return this.placeholder;let e=O1(t.from,this.format),i=O1(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 OD()){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"}})))};#O=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#b=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=Ue(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.#E();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())}};#x=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=Ue(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=Ue(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})};#S=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(!b1(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:Ue(this.compareValue),presetLabel:e.presetLabel||null}}))}#A(t,e){let i=Vb(e.from),r=Vb(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:We(a),to:We(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:We(o),to:We(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:We(o),to:We(a)}}default:return null}}#E(){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",Zo);var y1=23,v1=12,c3=1,x1=59,S1=59,yD=["hour","minute"];function _l(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 Wb({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 vD(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 jo=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:vD(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.#O),this.addEventListener("focusin",this.#b),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.#O),this.removeEventListener("focusin",this.#b),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=[...yD];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?v1:y1),h+=l,h+=a("minute","Minutes",x1),e&&(h+=l,h+=a("second","Seconds",S1)),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.#x),u.addEventListener("input",this.#v),u.addEventListener("blur",this.#w),u.addEventListener("focus",this.#S))}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=_l(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:Ub(i),minute:Ub(t.m),second:Ub(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=Fb(i.hour,0,e==="h12"?v1:y1),n=Fb(i.minute,0,x1),o=this.#a?Fb(i.second,0,S1):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=_l(this.min),c=_l(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=Wb(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=_o(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=_o(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=_o(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=_o(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=_o(n.h+1,0,24)}else t==="meridiem"&&(n.h=_o(n.h+12,0,24));let o=zo(n),a=_l(this.min),l=_l(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=Wb(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=Wb(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)})};#x=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)};#w=t=>{let e=this.#g(t.target);e&&this.#d(e)};#S=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 Ub(s){return String(s).padStart(2,"0")}function Fb(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 _o(s,t,e){let i=s-t,r=e-t;return i=(i%r+r)%r,i+t}S("time-picker-ui",jo);$t();var xD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],SD=["January","February","March","April","May","June","July","August","September","October","November","December"];function Yb(s){return String(s).padStart(2,"0")}function Ys(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 od(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let r=Yb(Number(i[1])),n=i[2],o=i[3]||"00";return e==="second"?`${s}T${r}:${n}:${o}`:`${s}T${r}:${n}`}function wD(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`${SD[r]} ${n}, ${i}`;case"iso":return s;default:return`${xD[r]} ${n}, ${i}`}}function kD(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=Yb(u),l=c?" PM":" AM"}else a=Yb(r);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${n}${h}${l}`}var Vo=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" icon-trailing="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 Ys(this.value)}set datetimeValue(t){F(()=>{t==null?this.value="":typeof t=="string"?this.value=t:t.date&&t.time?this.value=od(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?Ys(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.#x),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.#y),this.#o&&(this.#o.removeEventListener("change",this.#x),this.#o.removeEventListener("input",this.#v),this.#o.removeEventListener("invalid",this.#w)),document.removeEventListener("pointerdown",this.#S),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=Ys(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=ut(this.#r,this.#n,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#S),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.#S),document.removeEventListener("keydown",this.#O),this.#r?.focus?.()))}#f(){let t=Ys(this.value);if(!t)return this.placeholder;let e=wD(t.date,this.format),i=kD(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.#E();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=Ys(this.value),r=this.#t.time||i?.time||"",n=r?od(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?.()})};#x=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=Ys(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=Ys(this.value),r=this.#t?.date||i?.date||"",n=r&&e?od(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"}}))};#S=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=od(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)}#E(){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",Vo);C();var Wo=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",Wo);C();var AD=new Set(["xs","sm","md","lg","xl"]);function w1(s,t){return s==null||s===""?"":s==="none"?"0":AD.has(s)?`var(--a-${t}-${s})`:/^\d+$/.test(s)?`var(--a-space-${s})`:s}var Uo=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("@")?$e.value:"";t?.includes("@")?this.style.setProperty("--block-padding",w1(Bt(t,r),"padding")):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",w1(Bt(e,r),"margin")):this.style.removeProperty("--block-margin")}};S("block-ui",Uo);C();var ED={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function CD(s){return ED[s]??s}var Fo=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=$e.value;this.style.setProperty("--text-size",CD(Bt(t,e)))}else this.style.removeProperty("--text-size")}};S("text-ui",Fo);C();var Yo=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}},Ho=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",Yo),S("toggle-group-ui",Ho);C();var Di="light",Xe="dark",Hb="auto",Go=class extends x{static properties={scheme:{type:String,default:Hb,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===Xe?Di:Xe;this.#l(t,"programmatic")}setScheme(t){if(this.#n=!0,t===Hb){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Di||t===Xe)&&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===Xe?Di:Xe;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===Di||e===Xe)&&(t=e)}catch{}if(t===null){let e=this.scheme||Hb;(e===Di||e===Xe)&&(t=e)}t===Di||t===Xe?(this.#d(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Di&&t!==Xe)){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===Xe,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 Xe}catch{}return Di}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?Xe:Di;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",Go);C();var Ko=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.#x),u.addEventListener("input",this.#v),u.addEventListener("blur",this.#w),u.addEventListener("focus",this.#S))}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=_l(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:Ub(i),minute:Ub(t.m),second:Ub(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=Fb(i.hour,0,e==="h12"?v1:y1),n=Fb(i.minute,0,x1),o=this.#a?Fb(i.second,0,S1):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=_l(this.min),c=_l(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=Wb(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=_o(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=_o(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=_o(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=_o(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=_o(n.h+1,0,24)}else t==="meridiem"&&(n.h=_o(n.h+12,0,24));let o=zo(n),a=_l(this.min),l=_l(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=Wb(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=Wb(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")}#O=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}};#b=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)})};#x=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)};#w=t=>{let e=this.#g(t.target);e&&this.#d(e)};#S=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 Ub(s){return String(s).padStart(2,"0")}function Fb(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 _o(s,t,e){let i=s-t,r=e-t;return i=(i%r+r)%r,i+t}S("time-picker-ui",jo);$t();var xD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],SD=["January","February","March","April","May","June","July","August","September","October","November","December"];function Yb(s){return String(s).padStart(2,"0")}function Ys(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 od(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let r=Yb(Number(i[1])),n=i[2],o=i[3]||"00";return e==="second"?`${s}T${r}:${n}:${o}`:`${s}T${r}:${n}`}function wD(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`${SD[r]} ${n}, ${i}`;case"iso":return s;default:return`${xD[r]} ${n}, ${i}`}}function kD(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=Yb(u),l=c?" PM":" AM"}else a=Yb(r);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${n}${h}${l}`}var Vo=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" icon-trailing="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 Ys(this.value)}set datetimeValue(t){F(()=>{t==null?this.value="":typeof t=="string"?this.value=t:t.date&&t.time?this.value=od(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?Ys(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.#O),this.#a.addEventListener("change",this.#y),this.#o.addEventListener("change",this.#x),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.#O),this.#n.hidePopover?.()),this.#a&&this.#a.removeEventListener("change",this.#y),this.#o&&(this.#o.removeEventListener("change",this.#x),this.#o.removeEventListener("input",this.#v),this.#o.removeEventListener("invalid",this.#w)),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#b),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=Ys(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=ut(this.#r,this.#n,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#S),document.addEventListener("keydown",this.#b),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.#S),document.removeEventListener("keydown",this.#b),this.#r?.focus?.()))}#f(){let t=Ys(this.value);if(!t)return this.placeholder;let e=wD(t.date,this.format),i=kD(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"))}};#O=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#E();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())}};#b=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=Ys(this.value),r=this.#t.time||i?.time||"",n=r?od(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?.()})};#x=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=Ys(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=Ys(this.value),r=this.#t?.date||i?.date||"",n=r&&e?od(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"}}))};#S=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=od(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)}#E(){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",Vo);C();var Wo=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",Wo);C();var AD=new Set(["xs","sm","md","lg","xl"]);function w1(s,t){return s==null||s===""?"":s==="none"?"0":AD.has(s)?`var(--a-${t}-${s})`:/^\d+$/.test(s)?`var(--a-space-${s})`:s}var Uo=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("@")?$e.value:"";t?.includes("@")?this.style.setProperty("--block-padding",w1(Bt(t,r),"padding")):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",w1(Bt(e,r),"margin")):this.style.removeProperty("--block-margin")}};S("block-ui",Uo);C();var ED={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function CD(s){return ED[s]??s}var Fo=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=$e.value;this.style.setProperty("--text-size",CD(Bt(t,e)))}else this.style.removeProperty("--text-size")}};S("text-ui",Fo);C();var Yo=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}},Ho=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",Yo),S("toggle-group-ui",Ho);C();var Di="light",Xe="dark",Hb="auto",Go=class extends x{static properties={scheme:{type:String,default:Hb,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===Xe?Di:Xe;this.#l(t,"programmatic")}setScheme(t){if(this.#n=!0,t===Hb){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Di||t===Xe)&&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===Xe?Di:Xe;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===Di||e===Xe)&&(t=e)}catch{}if(t===null){let e=this.scheme||Hb;(e===Di||e===Xe)&&(t=e)}t===Di||t===Xe?(this.#d(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Di&&t!==Xe)){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===Xe,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 Xe}catch{}return Di}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?Xe:Di;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",Go);C();var Ko=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>
@@ -309,8 +309,8 @@ 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",ca);C();var ua=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",ua);C();var WD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],da=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:WD[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",da);C();var G1=new Set(["idle","active","done","error"]);function gO(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function UD(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var fa=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.#$(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#x()}))}),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=G1.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=G1.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=`
313
- ${this.#b(t)}
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",ua);C();var WD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],da=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:WD[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",da);C();var G1=new Set(["idle","active","done","error"]);function gO(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function UD(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var fa=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.#$(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#x()}))}),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=G1.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"}#O(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>"}}#b(){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=G1.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:r}=this.#b(),n=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#g();if(this.#n.innerHTML=`
313
+ ${this.#O(t)}
314
314
  <span data-reasoning-label>${gO(o)}</span>
315
315
  <span data-reasoning-meta>
316
316
  ${i?`<span data-reasoning-counter>${r}/${i}</span>`:""}
@@ -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",ga);C();var tE={neutral:"default",accent:"accent",warning:"warning",danger:"danger"},ba=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",tE[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=[],e=[],i=[],r=a=>a.getAttribute("role")==="presentation"||a.style?.display==="contents",n=a=>{for(let l of a){if(l.nodeType===1){let h=l;if(r(h)){n(h.childNodes);continue}let c=h.getAttribute("slot")||"";if(c==="primary"){t.push(h);continue}if(c==="secondary"){e.push(h);continue}}i.push(l)}};n(Array.from(this.childNodes)),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",tE[this.tone]||"default"),this.kind?this.#s.setAttribute("text",this.kind.toUpperCase()):this.#s.hidden=!0;let o=document.createElement("span");o.setAttribute("data-artifact-actions","");for(let a of e)o.appendChild(a);for(let a of t)o.appendChild(a);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,o,this.#r),this.#n=document.createElement("div"),this.#n.setAttribute("data-artifact-body","");for(let a of i)this.#n.appendChild(a);this.collapsed&&(this.#n.hidden=!0),this.append(this.#t,this.#n)}};S("agent-artifact-ui",ba);C();var HD="rounded borderless",Ul=class s extends x{static properties={mode:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("mode")||(this.mode=HD),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",Ul);C();var Fl=96,eE=160,Yl=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)>Fl&&(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>Fl&&(this.#e=t)}catch{}}#o(){let t=this.getBoundingClientRect().width;this.collapsed=t<=Fl}#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<=Fl?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<eE&&(this.style.width=`${eE}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<=Fl;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",Yl);C();var Hl=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",Hl);C();var Gl=class extends x{static template=()=>null;connected(){this.addEventListener("click",this.#t),this.addEventListener("embed:open",this.#e),this.addEventListener("keydown",this.#i)}#t=t=>{let e=t.target.closest?.("[opens]");if(e&&this.contains(e)){this.toggle(e.getAttribute("opens"));return}let i=t.target.closest?.("[close]");i&&this.contains(i)&&this.close()};#e=t=>this.toggle(t.detail?.panel);#i=t=>{t.key==="Escape"&&this.panel&&(t.stopPropagation(),this.close())};get panel(){return this.getAttribute("panel")||""}toggle(t){return this.panel===t?this.close():this.open(t)}open(t){if(!t)return;let e=this.querySelector(`:scope > [panel="${CSS.escape(t)}"]`);if(e){for(let i of this.querySelectorAll(":scope > [panel][active]"))i!==e&&i.removeAttribute("active");e.setAttribute("active",""),this.setAttribute("panel",t),requestAnimationFrame(()=>e.querySelector("[autofocus], [close], button-ui, [tabindex]")?.focus?.({preventScroll:!0})),this.#s(t)}}close(){this.panel&&(this.querySelector(":scope > [panel][active]")?.removeAttribute("active"),this.removeAttribute("panel"),this.#s(""))}#s(t){this.dispatchEvent(new CustomEvent("embed:change",{detail:{panel:t},bubbles:!0}))}};customElements.define("embed-shell",Gl);dE();C();function SO(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var nq=0,Kl=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_${++nq}`;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>${SO(e)}</div>`;else if(t==="assistant"){let o=i&&e?ui(e):SO(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>${SO(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=ui(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 vd(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",Kl);C();var oq=40,Jl=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<=oq},this.addEventListener("scroll",this.#i,{passive:!0})}};customElements.define("chat-thread",Jl);C();var th=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",th);C();var eh=96,fE=160,ih=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)>eh&&(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>eh&&(this.#t=t)}catch{}}#a(){let t=this.getBoundingClientRect().width;this.collapsed=t<=eh}#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<=eh?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<fE&&(this.style.width=`${fE}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<=eh;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",ih);C();var sh=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",sh);C();var rh=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",rh);C();var nh=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",nh);C();var oh=96,aq="adia-editor-sidebar-",ah=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=`${aq}${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=`${oh}px`,this.collapsed=!0,this.#o())}expand(){if(!this.#t)return;let t=this.#c(),e=t&&t>oh?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>oh){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<=oh&&(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<=oh)}};customElements.define("editor-sidebar",ah);function lq(){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")}C();var lh=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",lh);C();var xd=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",xd);mO();C();var hq=["default","ocean","forest","sunset","lavender","rose","slate","midnight"],cq={compact:{density:.85,radius:.75},default:{density:1,radius:1,clearTheme:!0},spacious:{density:1.15,radius:1.25}},pE=s=>s.length?s[0].toUpperCase()+s.slice(1):s,hh=class extends x{static properties={themes:{type:String,default:hq.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.#O()}apply(t={}){this.#d(t,"programmatic")}reset(){let t=this.#y();if(t.removeAttribute("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.#x}-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",pE(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":pE(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.#x}-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.#d({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.#d({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.#u(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.#d({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.#d({register:i},"register")};this.#a.addEventListener("change",t),this.#i.push(()=>this.#a.removeEventListener("change",t))}}#h(t){let e=this.#y();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.#d({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()}#u(t){let e=cq[t];if(e){if(e.clearTheme&&(this.#y().removeAttribute("theme"),this.activeTheme="",this.persist))try{localStorage.removeItem(`${this.storagePrefix}theme`)}catch{}this.#d({density:e.density,radius:e.radius},"preset"),this.#s&&(this.#s.value=e.density),this.#r&&(this.#r.value=e.radius)}}#d(t,e){let i=this.#y();if(t.theme!==void 0&&(t.theme===""||t.theme==="default"?(i.removeAttribute("theme"),this.activeTheme=""):(i.setAttribute("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.#O()}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.#y(),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("theme",e),this.activeTheme=e):this.activeTheme=t.getAttribute("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{}}#O(){if(this.#t&&this.#e)try{this.#t.removeEventListener("change",this.#e)}catch{}this.#t=null,this.#e=null}#y(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}get#x(){return this.id||"theme-panel"}};customElements.define("theme-panel",hh);C();var ch=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.#x();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>${SO(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=ui(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 vd(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",Kl);C();var oq=40,Jl=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<=oq},this.addEventListener("scroll",this.#i,{passive:!0})}};customElements.define("chat-thread",Jl);C();var th=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",th);C();var eh=96,fE=160,ih=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)>eh&&(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>eh&&(this.#t=t)}catch{}}#a(){let t=this.getBoundingClientRect().width;this.collapsed=t<=eh}#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<=eh?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<fE&&(this.style.width=`${fE}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<=eh;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",ih);C();var sh=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",sh);C();var rh=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",rh);C();var nh=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",nh);C();var oh=96,aq="adia-editor-sidebar-",ah=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=`${aq}${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=`${oh}px`,this.collapsed=!0,this.#o())}expand(){if(!this.#t)return;let t=this.#c(),e=t&&t>oh?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>oh){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<=oh&&(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<=oh)}};customElements.define("editor-sidebar",ah);function lq(){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")}C();var lh=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",lh);C();var xd=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",xd);mO();C();var hq=["default","ocean","forest","sunset","lavender","rose","slate","midnight"],cq={compact:{density:.85,radius:.75},default:{density:1,radius:1,clearTheme:!0},spacious:{density:1.15,radius:1.25}},pE=s=>s.length?s[0].toUpperCase()+s.slice(1):s,hh=class extends x{static properties={themes:{type:String,default:hq.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.#b()}apply(t={}){this.#d(t,"programmatic")}reset(){let t=this.#y();if(t.removeAttribute("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.#x}-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",pE(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":pE(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.#x}-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.#d({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.#d({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.#u(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.#d({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.#d({register:i},"register")};this.#a.addEventListener("change",t),this.#i.push(()=>this.#a.removeEventListener("change",t))}}#h(t){let e=this.#y();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.#d({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()}#u(t){let e=cq[t];if(e){if(e.clearTheme&&(this.#y().removeAttribute("theme"),this.activeTheme="",this.persist))try{localStorage.removeItem(`${this.storagePrefix}theme`)}catch{}this.#d({density:e.density,radius:e.radius},"preset"),this.#s&&(this.#s.value=e.density),this.#r&&(this.#r.value=e.radius)}}#d(t,e){let i=this.#y();if(t.theme!==void 0&&(t.theme===""||t.theme==="default"?(i.removeAttribute("theme"),this.activeTheme=""):(i.setAttribute("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.#O()}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)}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.#y(),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("theme",e),this.activeTheme=e):this.activeTheme=t.getAttribute("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.#O()}}#O(){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{}}#b(){if(this.#t&&this.#e)try{this.#t.removeEventListener("change",this.#e)}catch{}this.#t=null,this.#e=null}#y(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}get#x(){return this.id||"theme-panel"}};customElements.define("theme-panel",hh);C();var ch=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.#x();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.#b(),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
@@ -413,7 +413,7 @@ Correct shape for <chart-ui x="label" y="value">:
413
413
  variant="primary"
414
414
  size="sm"
415
415
  text="Done"
416
- @click=${()=>this.#b("user")}
416
+ @click=${()=>this.#O("user")}
417
417
  ></button-ui>
418
418
  </div>`:null}
419
419
  <div data-part="footer"><slot name="footer"></slot></div>
@@ -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}}#x(){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",ch);C();$t();var wO=new Set(["","comfortable","compact","spacious"]),kO=new Set(["2","3","4","5","6"]),mE=new Set(["","2","2:1","3:2","3:1"]),AO=["toolbar","kpis","charts","table","aside"],Sd=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=wO.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return AO.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(!wO.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&&!kO.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...kO].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!mE.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(!wO.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!kO.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(!mE.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 AO)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of AO){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",Sd);$t();var Ks=new Set,gE=!1;function bE(s){return String(s).padStart(2,"0")}function wd(s){return`${s.getFullYear()}-${bE(s.getMonth()+1)}-${bE(s.getDate())}`}function OE(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 yE={today:"Today","7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",qtd:"Quarter to date",ytd:"Year to date",custom:"Custom"},Js=new Set(Object.keys(yE));function uh(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=wd(e),r=n=>{let o=new Date(e);return o.setDate(o.getDate()-n),wd(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:wd(new Date(e.getFullYear(),n,1)),to:i}}case"ytd":return{from:wd(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function uq(s,t){let e=OE(s),i=OE(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 kd=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(!Js.has(t)){console.warn(`[date-range-selector-ui] unknown preset "${t}" \u2014 ignored. Use one of: ${[...Js].join(", ")}.`);return}let r=uh(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.#x()}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.#x(),i==="document"?(this.#y(),this.#O()):i==="self"&&this.#O();return}if(t==="value"&&e!==i&&i&&Js.has(i)){if(i!=="custom"){let r=uh(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=uq(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(!Js.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: ${[...Js].join(", ")}.`));continue}let r=document.createElement("segment-ui");r.setAttribute("value",i),r.setAttribute("text",yE[i]),this.#i.appendChild(r)}this.#i.value=this.value}#u(){let t=n=>{let o=n.detail?.value;if(!o||!Js.has(o))return;if(n.stopPropagation(),o==="custom"){this.#v(),this.#f("custom");return}let a=uh(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):uh("7d");let t=Js.has(this.value)?this.value:"7d";return uh(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(Ks.size>0&&!Ks.has(this)){gE||(gE=!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,Ks.add(this);return}Ks.add(this),this.#a=!0}#x(){if(Ks.has(this)&&(Ks.delete(this),this.#a)){document.documentElement.removeAttribute("data-range-from"),document.documentElement.removeAttribute("data-range-to"),this.#a=!1;let t=Ks.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",kd);C();var Ad=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",Ad);C();$t();var dq=new Set(["active","trialing","past_due","canceled","paused"]),fq={active:"success",trialing:"info",past_due:"danger",canceled:"muted",paused:"warning"},pq={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},mq={update:"update-card",retry:"retry"};function vE(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 gq(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 ya=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;#x=null;#v=null;#w=null;#S="";#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.#E(),this.#M(),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&&!dq.has(i)&&!this.#k&&(this.#k=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#C(null),this.#I(null);return}if(!t){this.#C(null);return}this.#C(t),this.#P(t),this.#D(t),this.#Q(t),this.#L(t),this.#T(t),this.#I(t)}#E(){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()}}#$(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#M(){this.#S=`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.#S,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.#$("header-actions",u);let d=document.createElement("section");d.setAttribute("data-kpis","");let f=(Ot,St,yt)=>{let Ct=document.createElement("card-ui");Ct.setAttribute("data-kpi-card",Ot);let Lt=document.createElement("section"),Yt=document.createElement("stat-ui");return Yt.setAttribute("data-kpi",Ot),Yt.setAttribute("label",St),Yt.setAttribute("value","\u2014"),Yt.setAttribute("icon",yt),Lt.appendChild(Yt),Ct.appendChild(Lt),[Ct,Yt]},[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 $=document.createElement("plan-picker-ui");$.setAttribute("data-billing-plan-picker",""),$.setAttribute("name","billing-overview-plan"),E.append(A,$),this.appendChild(E),this.#f=E,this.#p=A,this.#m=$;let T=document.createElement("div");T.setAttribute("data-before-plan-picker",""),E.insertBefore(T,A),this.#$("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.#x=V,this.#v=U;let J=document.createElement("div");J.setAttribute("data-after-invoice-history",""),_.appendChild(J),this.#$("after-invoice-history",J);let rt=document.createElement("div");rt.setAttribute("data-empty","");let dt=document.createElement("p");dt.setAttribute("data-empty-heading",""),dt.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(dt,ot),this.appendChild(rt),this.#w=rt,this.#$("empty",this)}#C(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=`${vE(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=fq[n]||"default",a=pq[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",vE(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",gq(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")}#D(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)}}#Q(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")}#L(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")}#T(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")}#I(t){this.#S&&this.setAttribute("aria-labelledby",this.#S),!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=mq[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",ya);C();$t();var bq=new Set(["draft","open","paid","past-due","void"]),Oq={paid:"success",open:"info","past-due":"danger",void:"muted",draft:"neutral"},xE={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},yq=[{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"}],SE=["Number","Issued","Due","Amount","Currency","Status"];function wE(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 kE(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 AE(s,t){return(s||"/invoices/{number}").replace("{number}",encodeURIComponent(t?.number??"")).replace("{id}",encodeURIComponent(t?.id??""))}function Ne(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
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.#O("complete")):t||(this.#s=!1)}#O(t="user"){this.setAttribute("hidden",""),this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:t}}))}#b(){}#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}}#x(){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",ch);C();$t();var wO=new Set(["","comfortable","compact","spacious"]),kO=new Set(["2","3","4","5","6"]),mE=new Set(["","2","2:1","3:2","3:1"]),AO=["toolbar","kpis","charts","table","aside"],Sd=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=wO.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return AO.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(!wO.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&&!kO.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...kO].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!mE.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(!wO.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!kO.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(!mE.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 AO)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of AO){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",Sd);$t();var Ks=new Set,gE=!1;function bE(s){return String(s).padStart(2,"0")}function wd(s){return`${s.getFullYear()}-${bE(s.getMonth()+1)}-${bE(s.getDate())}`}function OE(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 yE={today:"Today","7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",qtd:"Quarter to date",ytd:"Year to date",custom:"Custom"},Js=new Set(Object.keys(yE));function uh(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=wd(e),r=n=>{let o=new Date(e);return o.setDate(o.getDate()-n),wd(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:wd(new Date(e.getFullYear(),n,1)),to:i}}case"ytd":return{from:wd(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function uq(s,t){let e=OE(s),i=OE(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 kd=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(!Js.has(t)){console.warn(`[date-range-selector-ui] unknown preset "${t}" \u2014 ignored. Use one of: ${[...Js].join(", ")}.`);return}let r=uh(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.#x()}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.#x(),i==="document"?(this.#y(),this.#b()):i==="self"&&this.#b();return}if(t==="value"&&e!==i&&i&&Js.has(i)){if(i!=="custom"){let r=uh(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=uq(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(!Js.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: ${[...Js].join(", ")}.`));continue}let r=document.createElement("segment-ui");r.setAttribute("value",i),r.setAttribute("text",yE[i]),this.#i.appendChild(r)}this.#i.value=this.value}#u(){let t=n=>{let o=n.detail?.value;if(!o||!Js.has(o))return;if(n.stopPropagation(),o==="custom"){this.#v(),this.#f("custom");return}let a=uh(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.#b();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):uh("7d");let t=Js.has(this.value)?this.value:"7d";return uh(t)}#g(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#O(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#b(){let t=this.#O();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(Ks.size>0&&!Ks.has(this)){gE||(gE=!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,Ks.add(this);return}Ks.add(this),this.#a=!0}#x(){if(Ks.has(this)&&(Ks.delete(this),this.#a)){document.documentElement.removeAttribute("data-range-from"),document.documentElement.removeAttribute("data-range-to"),this.#a=!1;let t=Ks.values().next().value;t&&(t.#a=!0,t.#b())}}#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",kd);C();var Ad=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.#b}-title`,this.#f=`${this.#b}-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.#O()}#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))}#O(){let t=()=>{if(!(!this.open||!this.#l||this.loading))try{this.#l.focus()}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):queueMicrotask(t)}get#b(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",Ad);C();$t();var dq=new Set(["active","trialing","past_due","canceled","paused"]),fq={active:"success",trialing:"info",past_due:"danger",canceled:"muted",paused:"warning"},pq={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},mq={update:"update-card",retry:"retry"};function vE(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 gq(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 ya=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;#O=null;#b=null;#y=null;#x=null;#v=null;#w=null;#S="";#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.#E(),this.#M(),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&&!dq.has(i)&&!this.#k&&(this.#k=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#C(null),this.#I(null);return}if(!t){this.#C(null);return}this.#C(t),this.#P(t),this.#D(t),this.#Q(t),this.#L(t),this.#T(t),this.#I(t)}#E(){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()}}#$(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#M(){this.#S=`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.#S,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.#$("header-actions",u);let d=document.createElement("section");d.setAttribute("data-kpis","");let f=(Ot,St,yt)=>{let Ct=document.createElement("card-ui");Ct.setAttribute("data-kpi-card",Ot);let Lt=document.createElement("section"),Yt=document.createElement("stat-ui");return Yt.setAttribute("data-kpi",Ot),Yt.setAttribute("label",St),Yt.setAttribute("value","\u2014"),Yt.setAttribute("icon",yt),Lt.appendChild(Yt),Ct.appendChild(Lt),[Ct,Yt]},[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 $=document.createElement("plan-picker-ui");$.setAttribute("data-billing-plan-picker",""),$.setAttribute("name","billing-overview-plan"),E.append(A,$),this.appendChild(E),this.#f=E,this.#p=A,this.#m=$;let T=document.createElement("div");T.setAttribute("data-before-plan-picker",""),E.insertBefore(T,A),this.#$("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.#O=D,this.#b=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.#x=V,this.#v=U;let J=document.createElement("div");J.setAttribute("data-after-invoice-history",""),_.appendChild(J),this.#$("after-invoice-history",J);let rt=document.createElement("div");rt.setAttribute("data-empty","");let dt=document.createElement("p");dt.setAttribute("data-empty-heading",""),dt.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(dt,ot),this.appendChild(rt),this.#w=rt,this.#$("empty",this)}#C(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=`${vE(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=fq[n]||"default",a=pq[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",vE(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",gq(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")}#D(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)}}#Q(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")}#L(t){if(!this.#b)return;let e=Array.isArray(t?.paymentMethods)?t.paymentMethods:[];this.#b.methods=e,this.loading?this.#b.setAttribute("loading",""):this.#b.removeAttribute("loading")}#T(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")}#I(t){this.#S&&this.setAttribute("aria-labelledby",this.#S),!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=mq[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",ya);C();$t();var bq=new Set(["draft","open","paid","past-due","void"]),Oq={paid:"success",open:"info","past-due":"danger",void:"muted",draft:"neutral"},xE={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},yq=[{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"}],SE=["Number","Issued","Due","Amount","Currency","Status"];function wE(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 kE(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 AE(s,t){return(s||"/invoices/{number}").replace("{number}",encodeURIComponent(t?.number??"")).replace("{id}",encodeURIComponent(t?.id??""))}function Ne(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
442
442
  `)?'"'+t.replace(/"/g,'""')+'"':t}var va=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&&!bq.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=[SE.join(",")];for(let r of t){let n=[Ne(r.number??""),Ne(r.issuedAt??""),Ne(r.dueAt??""),Ne(Number.isFinite(r.amount)?r.amount:""),Ne(r.currency||this.currency||"USD"),Ne(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 yq){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=>kE(i,t)},{key:"dueAt",label:"Due",sortable:!0,format:i=>kE(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=wE(i,o,t),n.dataset.align="end",a},format:(i,r)=>wE(i,r?.currency||e,t)},{key:"status",label:"Status",sortable:!0,render:i=>{let r=String(i||"").toLowerCase(),n=Oq[r]||"neutral",o=xE[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=>xE[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=AE(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=AE(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=[SE.join(","),[Ne(t.number??""),Ne(t.issuedAt??""),Ne(t.dueAt??""),Ne(Number.isFinite(t.amount)?t.amount:""),Ne(t.currency||this.currency||"USD"),Ne(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",va);C();$t();var vq=new Set(["draft","open","paid","past-due","void"]),xq={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},Sq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function Ed(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 EE(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 xa=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.#x(),this.#w(),this.#M(),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(vq.has(r)||this.#b||(this.#b=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#S(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#S(null,r);return}this.#S(t,r),this.#k(t),this.#A(t),this.#E(t),this.#$(t)}#x(){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.#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}#S(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=xq[e]||"default",n=Sq[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 ${EE(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${EE(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=>Ed(n,e,i)},{key:"amount",label:"Amount",width:140,format:n=>Ed(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")}#E(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=Ed(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=Ed(t.total,e,i),n.append(o,a),this.#d.appendChild(n)}}#$(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#M(){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",xa);$t();var wq=[{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 Cd(s){if(!s)return"unknown";for(let{brand:t,re:e}of wq)if(e.test(s))return t;return"unknown"}function $d(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function ZG(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 CE(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 $E(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 PE(s){let t=$E(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 QE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function kq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var Aq=["US","CA","GB","DE","FR","AU"],Eq={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 Cq(s){return Eq[s]||s}var Sa=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=kq(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.#S()})}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.#x();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.#x(),this.#v(),this.#w(),this.#S())}#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:Aq).map(e=>({value:e,label:Cq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=$d(n),a=Cd(o);a!==this.#l&&(this.#l=a,this.#S()),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=$d(this.#o.cardNumber?.value),e=Cd(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)}#x(){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.#E();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","")}#S(){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=$d(this.#o.cardNumber?.value);return t?CE(t)?PE(this.#o.expiry?.value)?{ok:!1}:QE(this.#o.cvc?.value,Cd(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=$d(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(!CE(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=PE(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=Cd(i);if(QE(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=$E(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:n,expMonth:h.month,expYear:h.year,name:t,country:a}}}#E(){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",Sa);$t();var $q=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),TE=new Set(["card","bank","wallet"]),LE={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},Pq={card:"credit-card",bank:"bank",wallet:"credit-card"},ME={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 RE(s){let t=(s?.brand||"").toLowerCase();if(LE[t])return LE[t];let e=(s?.type||"card").toLowerCase();return Pq[e]||"credit-card"}function IE(s){let t=(s?.brand||"").toLowerCase();if(ME[t])return ME[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function EO(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=IE(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function CO(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 wa=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();TE.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=RE(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=EO(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=CO(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=CO(e),u=[EO(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",wa);$t();var Pd=new Set(["monthly","annual"]),Qq={monthly:"Monthly",annual:"Annual"},Tq={monthly:"/month",annual:"/year"};function Lq(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 Mq(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 ka=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 Pd.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(!Pd.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",Qq[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=Pd.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=Lq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:Tq[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",Mq(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(!Pd.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",ka);C();var Rq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),Iq=6,dh=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`
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.#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.#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 yq){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=>kE(i,t)},{key:"dueAt",label:"Due",sortable:!0,format:i=>kE(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=wE(i,o,t),n.dataset.align="end",a},format:(i,r)=>wE(i,r?.currency||e,t)},{key:"status",label:"Status",sortable:!0,render:i=>{let r=String(i||"").toLowerCase(),n=Oq[r]||"neutral",o=xE[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=>xE[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}}]}#O(){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=AE(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=AE(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.#b(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))}#b(t){let e=[SE.join(","),[Ne(t.number??""),Ne(t.issuedAt??""),Ne(t.dueAt??""),Ne(Number.isFinite(t.amount)?t.amount:""),Ne(t.currency||this.currency||"USD"),Ne(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",va);C();$t();var vq=new Set(["draft","open","paid","past-due","void"]),xq={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},Sq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function Ed(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 EE(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 xa=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;#O=!1;#b=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.#b;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.#b)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.#b)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.#x(),this.#w(),this.#M(),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(vq.has(r)||this.#O||(this.#O=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#S(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#S(null,r);return}this.#S(t,r),this.#k(t),this.#A(t),this.#E(t),this.#$(t)}#x(){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.#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}#S(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=xq[e]||"default",n=Sq[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 ${EE(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${EE(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=>Ed(n,e,i)},{key:"amount",label:"Amount",width:140,format:n=>Ed(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")}#E(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=Ed(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=Ed(t.total,e,i),n.append(o,a),this.#d.appendChild(n)}}#$(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#M(){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",xa);$t();var wq=[{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 Cd(s){if(!s)return"unknown";for(let{brand:t,re:e}of wq)if(e.test(s))return t;return"unknown"}function $d(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function ZG(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 CE(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 $E(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 PE(s){let t=$E(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 QE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function kq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var Aq=["US","CA","GB","DE","FR","AU"],Eq={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 Cq(s){return Eq[s]||s}var Sa=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=kq(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.#S()})}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.#x();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.#b(),this.#y(),this.#x(),this.#v(),this.#w(),this.#S())}#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:Aq).map(e=>({value:e,label:Cq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=$d(n),a=Cd(o);a!==this.#l&&(this.#l=a,this.#S()),this.#O()};this.addEventListener("input",t),this.#e.push(()=>this.removeEventListener("input",t));let e=r=>{r.target!==this&&this.#O()};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)})}#O(){let t=$d(this.#o.cardNumber?.value),e=Cd(t),i=this.#k();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#b(){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)}#x(){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.#E();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","")}#S(){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=$d(this.#o.cardNumber?.value);return t?CE(t)?PE(this.#o.expiry?.value)?{ok:!1}:QE(this.#o.cvc?.value,Cd(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=$d(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(!CE(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=PE(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=Cd(i);if(QE(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=$E(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:n,expMonth:h.month,expYear:h.year,name:t,country:a}}}#E(){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",Sa);$t();var $q=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),TE=new Set(["card","bank","wallet"]),LE={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},Pq={card:"credit-card",bank:"bank",wallet:"credit-card"},ME={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 RE(s){let t=(s?.brand||"").toLowerCase();if(LE[t])return LE[t];let e=(s?.type||"card").toLowerCase();return Pq[e]||"credit-card"}function IE(s){let t=(s?.brand||"").toLowerCase();if(ME[t])return ME[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function EO(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=IE(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function CO(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 wa=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();TE.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=RE(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=EO(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=CO(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=CO(e),u=[EO(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",wa);$t();var Pd=new Set(["monthly","annual"]),Qq={monthly:"Monthly",annual:"Annual"},Tq={monthly:"/month",annual:"/year"};function Lq(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 Mq(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 ka=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 Pd.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.#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.#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(!Pd.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",Qq[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.#O(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)}}#O(t,e){t.replaceChildren();let i=document.createElement("div");i.setAttribute("data-price-row","");let r=Pd.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=Lq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:Tq[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",Mq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#b(){let t=r=>{let n=r?.detail?.value;if(!Pd.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",ka);C();var Rq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),Iq=6,dh=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`
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",dh);$t();var fh=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.#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.#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.#x(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.#x(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)}}#x(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",fh);export{aa as A2UIRoot,Hl as AdminCommand,Ul as AdminShell,Yl as AdminSidebar,th as ChatComposer,Kl as ChatShell,ih as ChatSidebar,Jl as ChatThread,Ad as ConfirmDialog,nh as EditorCanvas,sh as EditorShell,ah as EditorSidebar,rh as EditorToolbar,Gl as EmbedShell,xd as GenRoot,va as InvoiceHistory,wa as PaymentMethodList,ka as PlanPicker,lh as SimpleShell,hh as ThemePanel,ya as UIBillingOverview,Sd as UIDashboardLayout,kd as UIDateRangeSelector,dh as UIIntegrationsPage,xa as UIInvoiceDetail,fh as UINotificationPreferences,ch as UIOnboardingChecklist,Sa as UIPaymentMethodForm,lq 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"))}#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",dh);$t();var fh=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.#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.#y(e,t):this.#b(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.#O(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)}}#O(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)}#b(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.#x(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.#x(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)}}#x(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",fh);export{aa as A2UIRoot,Hl as AdminCommand,Ul as AdminShell,Yl as AdminSidebar,th as ChatComposer,Kl as ChatShell,ih as ChatSidebar,Jl as ChatThread,Ad as ConfirmDialog,nh as EditorCanvas,sh as EditorShell,ah as EditorSidebar,rh as EditorToolbar,Gl as EmbedShell,xd as GenRoot,va as InvoiceHistory,wa as PaymentMethodList,ka as PlanPicker,lh as SimpleShell,hh as ThemePanel,ya as UIBillingOverview,Sd as UIDashboardLayout,kd as UIDateRangeSelector,dh as UIIntegrationsPage,xa as UIInvoiceDetail,fh as UINotificationPreferences,ch as UIOnboardingChecklist,Sa as UIPaymentMethodForm,lq as isFocusInInput};