@adia-ai/web-modules 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,10 +38,10 @@ var BE=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=xu.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],so,so,(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(Rg(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?qw(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=Rg(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 $u(t,e)}get buffer(){return new Cu(this.parser.nodeSet)}};no=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 Au(this,t,e,i);for(let n of this.wrappers)r=n(r,t,e,i);return r}configure(t){let e=Lg(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(Ml(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 ue?f[m]=y:Object.assign(f,y))}i=new He(d),f&&(i=i.extend(Mt(f)))}if(Ml(e.props)&&(i=i.extend(...e.props)),Ml(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(Ml(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?Eu(a,d.before):d.after?Eu(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(Ml(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?Eu(h,d.before):d.after?Eu(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 ro(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)}};Xw=[ft.none];for(let s=1,t;t=L[s];s++)Xw[s]=ft.define({id:s,name:t,props:s>=L.Escape?[]:[[z.group,s in Aw?["Block","BlockContext"]:["Block","LeafBlock"]]],top:t=="Document"});so=[],Cu=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})}},ts=class{constructor(t,e,i,r=so){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 Cu(t).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}},$u=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 so}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}};Nw={resolve:"Emphasis",mark:"EmphasisMark"},Bw={resolve:"Emphasis",mark:"EmphasisMark"},Zs={},Pu={},re=class{constructor(t,e,i,r){this.type=t,this.from=e,this.to=i,this.side=r}},Zw="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",Rl=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{Rl=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}Mg={Escape(s,t,e){if(t!=92||e==s.end-1)return-1;let i=s.char(e+1);for(let r=0;r<Zw.length;r++)if(Zw.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=Rl.test(r),a=Rl.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?Nw:Bw,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(Pu,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==Pu)){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]=sR(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}};ro=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==Pu))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==Nw||r.type==Bw,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 ts&&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 ts&&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 Ll(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 $u(t,e)}};ro.linkStart=Zs,ro.imageStart=Pu;rR=[L.CodeBlock,L.ListItem,L.OrderedList,L.BulletList],Ig=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=Vw(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")&&(rR.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}};nR=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}),qg=new no(new He(Xw).extend(nR),Object.keys(ku).map(s=>ku[s]),Object.keys(ku).map(s=>Dw[s]),Object.keys(ku),eR,Aw,Object.keys(Mg).map(s=>Mg[s]),Object.keys(Mg),[]);aR={resolve:"Strikethrough",mark:"StrikethroughMark"},Ww={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=Rl.test(i),l=Rl.test(r);return s.addDelimiter(aR,e,e+2,!o&&(!l||n||a),!n&&(!a||o||l))},after:"Emphasis"}]};Uw=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,Qu=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)&&Uw.test(r=e.text.slice(e.pos))){let n=[];Il(t,i.content,0,n,i.start)==Il(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=[];Il(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}},Yw={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 Fw(t.content,0)?new Qu:null},endLeaf(s,t,e){if(e.parsers.some(r=>r instanceof Qu)||!Fw(t.text,t.basePos))return!1;let i=s.peekLine();return Uw.test(i)&&Il(s,t.text,t.basePos)==Il(s,i,t.basePos)},before:"SetextHeading"}]},Dg=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}},Hw={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 Dg:null},after:"SetextHeading"}]},Gw=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,Kw=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,lR=/[\w-]+\.[\w-]+($|\/)/,Jw=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,tk=/\/[a-zA-Z\d@.]+/gy;sk={parseInline:[{name:"Autolink",parse(s,t,e){let i=e-s.offset;if(i&&/\w/.test(s.text[i-1]))return-1;Gw.lastIndex=i;let r=Gw.exec(s.text),n=-1;if(!r)return-1;if(r[1]||r[2]){if(n=hR(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=ik(s.text,i):(n=ik(s.text,i+r[0].length),n>-1&&r[0]=="xmpp:"&&(tk.lastIndex=n,r=tk.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)}}]},Ng=[Yw,Hw,Ww,sk];Bg={defineNodes:[{name:"Superscript",style:O.special(O.content)},{name:"SuperscriptMark",style:O.processingInstruction}],parseInline:[{name:"Superscript",parse:rk(94,"Superscript","SuperscriptMark")}]},Zg={defineNodes:[{name:"Subscript",style:O.special(O.content)},{name:"SubscriptMark",style:O.processingInstruction}],parseInline:[{name:"Subscript",parse:rk(126,"Subscript","SubscriptMark")}]},zg={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 mk={};Ht(mk,{commonmarkLanguage:()=>Ug,deleteMarkupBackward:()=>Gg,insertNewlineContinueMarkup:()=>Hg,insertNewlineContinueMarkupCommand:()=>Yg,markdown:()=>pk,markdownKeymap:()=>Kg,markdownLanguage:()=>oo,pasteURLAsLink:()=>Jg});function _g(s){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(s.name);return t?+t[1]:void 0}function cR(s){return s.name=="OrderedList"||s.name=="BulletList"}function uR(s,t){let e=s;for(;;){let i=e.nextSibling,r;if(!i||(r=_g(i.type))!=null&&r<=t)break;e=i}return e.to}function jg(s){return new Tt(ok,s,[],"markdown")}function pR(s,t){return e=>{if(e&&s){let i=null;if(e=/\S*/.exec(e)[0],typeof s=="function"?i=s(e):i=Hn.matchLanguageName(s,e,!0),i instanceof Hn)return i.support?i.support.language.parser:Gi.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}function hk(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 Dl(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 Dl(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 Dl(n.parent,l,l+c,o[1],h,u,n))}}return i}function ck(s,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(s.from,s.from+10))}function Vg(s,t,e,i=0){for(let r=-1,n=s;;){if(n.name=="ListItem"){let a=ck(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 Wg(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 uk(s){return s.name=="QuoteMark"||s.name=="ListMark"}function mR(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 dk(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 Wg(i,t)}function gR(s,t){let e=s.resolveInner(t,-1),i=t;uk(e)&&(i=e.from,e=e.parent);for(let r;r=e.childBefore(i);)if(uk(r))i=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")e=r.lastChild,i=e.to;else break;return e}function pk(s={}){let{codeLanguages:t,defaultCodeLanguage:e,addKeymap:i=!0,base:{parser:r}=Ug,completeHTMLTags:n=!0,pasteURLAsLink:o=!0,htmlTagLanguage:a=fk}=s;if(!(r instanceof no))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=s.extensions?[s.extensions]:[],h=[a.support,dR],c;o&&h.push(Jg),e instanceof xt?(h.push(e.support),c=e.language):e&&(c=e);let u=t||c?pR(t,c):void 0;l.push(Xg({codeParser:u,htmlParser:a.language.parser})),i&&h.push(de.high(oi.of(Kg)));let d=jg(r.configure(l));return n&&h.push(d.data.of({autocomplete:bR})),new xt(d,h)}function bR(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:OR(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}function OR(){if(Fg)return Fg;let s=yu(new Ns(ot.create({extensions:fk}),0,!0));return Fg=s?s.options:[]}var ok,ak,lk,dR,Ug,fR,oo,Dl,Yg,Hg,Gg,Kg,fk,Fg,yR,Jg,gk=Z(()=>{si();wi();hi();hg();nk();wg();ze();ok=Rs({commentTokens:{block:{open:"<!--",close:"-->"}}}),ak=new z,lk=qg.configure({props:[se.add(s=>!s.is("Block")||s.is("Document")||_g(s)!=null||cR(s)?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),ak.add(_g),ie.add({Document:()=>null}),ai.add({Document:ok})]});dR=tu.of((s,t,e)=>{for(let i=G(s).resolveInner(e,-1);i&&!(i.from<t);i=i.parent){let r=i.type.prop(ak);if(r==null)continue;let n=uR(i,r);if(n>e)return{from:e,to:n}}return null});Ug=jg(lk),fR=lk.configure([Ng,Zg,Bg,zg,{props:[se.add({Table:(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}]),oo=jg(fR);Dl=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(+ck(this.item,t)[2]+e):"";return this.spaceBefore+i+this.type+this.spaceAfter}};Yg=(s={})=>({state:t,dispatch:e})=>{let i=G(t),{doc:r}=t,n=null,o=t.changeByRange(a=>{if(!a.empty||!oo.isActiveAt(t,a.from,-1)&&!oo.isActiveAt(t,a.from,1))return n={range:a};let l=a.from,h=r.lineAt(l),c=hk(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"&&Vg(u.item,r,E,-2),v&&v.node.name=="OrderedList"&&Vg(v.item,r,E),{range:P.cursor(w+k.length),changes:E}}else{let v=dk(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"&&Vg(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=Wg(m,t),mR(u.node,t.doc)&&(m=dk(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)},Hg=Yg();Gg=({state:s,dispatch:t})=>{let e=G(s),i=null,r=s.changeByRange(n=>{let o=n.from,{doc:a}=s;if(n.empty&&oo.isActiveAt(s,n.from)){let l=a.lineAt(o),h=hk(gR(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=Wg(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)},Kg=[{key:"Enter",run:Hg},{key:"Backspace",run:Gg}],fk=vu({matchClosingTags:!1});Fg=null;yR=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Jg=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),!oo.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||yR.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 Xl(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 sb(s){return s==32||s==9}function Ri(s){return s==10||s==13}function Sk(s){return sb(s)||Ri(s)}function zs(s){return s<0||Sk(s)}function lo(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 ZR(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 wk(s){return s>=48&&s<=57||s>=97&&s<=102||s>=65&&s<=70}function kk(s,t){return s.next==37?(s.advance(),wk(s.next)&&s.advance(),wk(s.next)&&s.advance(),!0):ZR(s.next)||t&&s.next==44?(s.advance(),!0):!1}function Ak(s){if(s.advance(),s.next==60){for(s.advance();;)if(!kk(s,!0)){s.next==62&&s.advance();break}}else for(;kk(s,!1););}function rb(s){for(s.advance();!zs(s.next)&&Tu(s.next)!="f";)s.advance()}function nb(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 zR(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(!nb(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 Tu(s){return s<33?"u":s>125?"s":_R[s-33]}function ob(s,t){let e=Tu(s);return e!="u"&&!(t&&e=="f")}function Ek(s,t,e,i){if(Tu(s.next)=="s"||(s.next==63||s.next==58||s.next==45)&&ob(s.peek(1),e))s.advance();else return!1;let r=s.pos;for(;;){let n=s.next,o=0,a=i+1;for(;Sk(n);){if(Ri(n)){if(t)return!1;a=0}else a++;n=s.peek(++o)}if(!(n>=0&&(n==58?ob(s.peek(o+1),e):n==35?s.peek(o-1)!=32:ob(n,e)))||!e&&a<=i||a==0&&!e&&(lo(s,45,o)||lo(s,46,o)))break;if(t&&Tu(n)=="f")return!1;for(let h=o;h>=0;h--)s.advance();if(t&&s.pos>r+1024)return!1}return!0}var ao,bk,vR,xR,Ok,SR,yk,wR,kR,vk,AR,ER,CR,$R,PR,QR,xk,TR,LR,MR,RR,IR,DR,qR,tb,eb,ql,ib,Mi,XR,NR,BR,_R,jR,VR,WR,ab,Ck=Z(()=>{bs();ei();ao=63,bk=64,vR=1,xR=2,Ok=3,SR=4,yk=5,wR=6,kR=7,vk=65,AR=66,ER=8,CR=9,$R=10,PR=11,QR=12,xk=13,TR=19,LR=20,MR=29,RR=33,IR=34,DR=47,qR=0,tb=1,eb=2,ql=3,ib=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);XR=new Oi({start:Mi.top,reduce(s,t){return s.type==ql&&(t==LR||t==IR)?s.parent:s},shift(s,t,e,i){if(t==Ok)return new Mi(s,Xl(i,i.pos),tb);if(t==vk||t==yk)return new Mi(s,Xl(i,i.pos),eb);if(t==ao)return s.parent;if(t==TR||t==RR)return new Mi(s,0,ql);if(t==xk&&s.type==ib)return s.parent;if(t==DR){let r=/[1-9]/.exec(i.read(i.pos,e.pos));if(r)return new Mi(s,s.depth+ +r[0],ib)}return s},hash(s){return s.hash}});NR=new pt((s,t)=>{if(s.next==-1&&t.canShift(bk))return s.acceptToken(bk);let e=s.peek(-1);if((Ri(e)||e<0)&&t.context.type!=ql){if(lo(s,45))if(t.canShift(ao))s.acceptToken(ao);else return s.acceptToken(vR,3);if(lo(s,46))if(t.canShift(ao))s.acceptToken(ao);else return s.acceptToken(xR,3);let i=0;for(;s.next==32;)i++,s.advance();(i<t.context.depth||i==t.context.depth&&t.context.type==tb&&(s.next!=45||!zs(s.peek(1))))&&s.next!=-1&&!Ri(s.next)&&s.next!=35&&s.acceptToken(ao,-i)}},{contextual:!0}),BR=new pt((s,t)=>{if(t.context.type==ql){s.next==63&&(s.advance(),zs(s.next)&&s.acceptToken(kR));return}if(s.next==45)s.advance(),zs(s.next)&&s.acceptToken(t.context.type==tb&&t.context.depth==Xl(s,s.pos-1)?SR:Ok);else if(s.next==63)s.advance(),zs(s.next)&&s.acceptToken(t.context.type==eb&&t.context.depth==Xl(s,s.pos-1)?wR:yk);else{let e=s.pos;for(;;)if(sb(s.next)){if(s.pos==e)return;s.advance()}else if(s.next==33)Ak(s);else if(s.next==38)rb(s);else if(s.next==42){rb(s);break}else if(s.next==39||s.next==34){if(nb(s,!0))break;return}else if(s.next==91||s.next==123){if(!zR(s))return;break}else{Ek(s,!0,!1,0);break}for(;sb(s.next);)s.advance();if(s.next==58){if(s.pos==e&&t.canShift(MR))return;let i=s.peek(1);zs(i)&&s.acceptTokenTo(t.context.type==eb&&t.context.depth==Xl(s,e)?AR:vk,e)}}},{contextual:!0});_R="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";jR=new pt((s,t)=>{if(s.next==33)Ak(s),s.acceptToken(QR);else if(s.next==38||s.next==42){let e=s.next==38?$R:PR;rb(s),s.acceptToken(e)}else s.next==39||s.next==34?(nb(s,!1),s.acceptToken(CR)):Ek(s,!1,t.context.type==ql,t.context.depth)&&s.acceptToken(ER)}),VR=new pt((s,t)=>{let e=t.context.type==ib?t.context.depth:-1,i=s.pos;t:for(;;){let r=0,n=s.next;for(;n==32;)n=s.peek(++r);if(!r&&(lo(s,45,r)||lo(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(xk,i)}),WR=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}),ab=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:XR,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[WR],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:[NR,BR,jR,VR,0,1],topRules:{Stream:[0,15]},tokenPrec:0})});var Qk={};Ht(Qk,{yaml:()=>$k,yamlFrontmatter:()=>Pk,yamlLanguage:()=>Lu});function $k(){return new xt(Lu)}function Pk(s){let{language:t,support:e}=s.content instanceof xt?s.content:{language:s.content,support:[]};return new xt(UR.configure({wrap:gs(i=>i.name=="FrontmatterContent"?{parser:Lu.parser}:i.name=="Body"?{parser:t.parser}:null)}),e)}var FR,Lu,UR,Tk=Z(()=>{Ck();hi();ze();ei();bs();FR=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}),Lu=ge.define({name:"yaml",parser:ab.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:Kn({closing:"}"}),FlowSequence:Kn({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*[\]\}]$/}});UR=ge.define({name:"yaml-frontmatter",parser:FR.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 lb(s,t){let e=s.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}function JR(s,{open:t,close:e},i,r){let n=s.sliceDoc(i-Nl,i),o=s.sliceDoc(r,r+Nl),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*Nl?c=u=s.sliceDoc(i,r):(c=s.sliceDoc(i,i+Nl),u=s.sliceDoc(r-Nl,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 tI(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 Mu(s,t,e=t.selection.ranges){let i=e.map(n=>lb(t,n.from).block);if(!i.every(n=>n))return null;let r=e.map((n,o)=>JR(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 hb(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=lb(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[Ru,Xk.of(s),I.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?ub:t.inputType=="historyRedo"?Du:null;return i?(t.preventDefault(),i(e)):!1}})]}function Iu(s,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let r=e.field(Ru,!1);if(!r)return!1;let n=r.pop(s,e,t);return n?(i(n),!0):!1}}function Zk(s){return function(t){let e=t.field(Ru,!1);if(!e)return 0;let i=s==0?e.done:e.undone;return i.length-(i.length&&!i[0].changes?1:0)}}function qu(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 rI(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 nI(s,t){return s.ranges.length==t.ranges.length&&s.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function zk(s,t){return s.length?t.length?s.concat(t):s:t}function _k(s,t){if(s.length){let e=s[s.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-oI));return i.length&&i[i.length-1].eq(t)?s:(i.push(t),qu(s,s.length-1,1e9,e.setSelAfter(i)))}else return[je.selection([t])]}function aI(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 db(s,t){if(!s.length)return s;let e=s.length,i=qe;for(;e;){let r=lI(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 lI(s,t,e){let i=zk(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 ho(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 Oe({state:s,dispatch:t},e){let i=ho(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 Xu(s,t){return Oe(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 mb(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 jk(s,t){return Oe(s,e=>e.empty?mb(s.state,e,t):Vs(e,t))}function Nu(s,t){return Oe(s,e=>e.empty?s.moveByGroup(e,t):Vs(e,t))}function gb(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 Uk(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(Fk&&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(Fk.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 Yk(s,t){return Oe(s,e=>e.empty?Uk(s,e,t):Vs(e,t))}function yI(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 Bu(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;yI(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 Kk(s,t){return Oe(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 Jk(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 tA(s,t){let e=Jk(s),{state:i}=s,r=ho(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 es(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 aA(s,t,e){let i=!1,r=ho(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 Ft(s,t){let e=ho(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 Ft(s,e=>s.moveByChar(e,t))}function _u(s,t){return Ft(s,e=>s.moveByGroup(e,t))}function uA(s,t){return Ft(s,e=>Uk(s,e,t))}function pA(s,t){return Ft(s,e=>s.moveVertically(e,t))}function mA(s,t){return Ft(s,e=>s.moveVertically(e,t,Jk(s).height))}function AA(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=ju(s,l,!1)):l>o&&(e="delete.forward",l=ju(s,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=ju(s,o,!1),a=ju(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 ju(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 Wu(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 DA(s,t,e){if(s.readOnly)return!1;let i=[],r=[];for(let n of Wu(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 NA(s,t,e){if(s.readOnly)return!1;let i=[];for(let n of Wu(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 DI(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 jA(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&&DI(t,n);s&&(n=o=(o<=a.to?a:t.doc.lineAt(o)).to);let h=new Ei(t,{simulateBreak:n,simulateDoubleBreak:!!l}),c=Gn(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=["",Ki(t,c)];return l&&u.push(Ki(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 Rb(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 Lk,Mk,YR,HR,Rk,GR,KR,Ik,Nl,cb,Dk,qk,Xk,Ru,eI,ub,Du,Nk,Bk,iI,sI,je,qe,oI,hI,js,Yu,fb,pb,cI,uI,dI,fI,Vk,Wk,pI,mI,gI,Fk,bI,OI,Hk,Gk,bb,Ob,yb,Zu,eA,iA,sA,rA,nA,oA,lA,vI,vb,xb,xI,SI,wI,kI,hA,cA,AI,EI,CI,$I,PI,dA,fA,Sb,wb,kb,Ab,gA,bA,OA,yA,vA,xA,Eb,Cb,$b,Pb,SA,wA,kA,EA,CA,$A,Qb,Vu,QI,Tb,PA,Lb,QA,TI,TA,LI,LA,MA,MI,RA,IA,qA,XA,BA,ZA,zA,RI,II,Mb,_A,VA,Fu,Ib,WA,qI,XI,FA,UA,Hu,Gu,YA=Z(()=>{si();wi();hi();ze();Lk=s=>{let{state:t}=s,e=t.doc.lineAt(t.selection.main.from),i=lb(s.state,e.from);return i.line?Mk(s):i.block?Ik(s):!1};Mk=_s(hb,0),YR=_s(hb,1),HR=_s(hb,2),Rk=_s(Mu,0),GR=_s(Mu,1),KR=_s(Mu,2),Ik=_s((s,t)=>Mu(s,t,tI(t)),0);Nl=50;cb=Kt.define(),Dk=Kt.define(),qk=X.define(),Xk=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)})}}),Ru=gt.define({create(){return js.empty},update(s,t){let e=t.state.facet(Xk),i=t.annotation(cb);if(i){let l=je.fromTransaction(t,i.selection),h=i.side,c=h==0?s.undone:s.done;return l?c=qu(c,c.length,e.minDepth,l):c=_k(c,t.startState.selection),new js(h==0?i.rest:c,h==0?c:i.rest)}let r=t.annotation(Dk);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))}});eI=Ru;ub=Iu(0,!1),Du=Iu(1,!1),Nk=Iu(0,!0),Bk=Iu(1,!0);iI=Zk(0),sI=Zk(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(qk)){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=[],oI=200;hI=/^(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||hI.test(i))&&(!a.selectionsAfter.length&&e-this.prevTime<r.newGroupDelay&&r.joinToEvent(n,rI(a.changes,t.changes))||i=="input.type.compose")?o=qu(o,o.length-1,r.minDepth,new je(t.changes.compose(a.changes),zk(W.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,qe)):o=qu(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)&&nI(n[n.length-1],t)?this:new s(_k(this.done,t),this.undone,e,i)}addMapping(t){return new s(db(this.done,t),db(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:cb.of({side:t,rest:aI(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=db(a,n.mapped)),e.update({changes:n.changes,selection:n.startSelection,effects:n.effects,annotations:cb.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);Yu=[{key:"Mod-z",run:ub,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Du,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Du,preventDefault:!0},{key:"Mod-u",run:Nk,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Bk,preventDefault:!0}];fb=s=>Xu(s,!Wt(s)),pb=s=>Xu(s,Wt(s)),cI=s=>Xu(s,!0),uI=s=>Xu(s,!1);dI=s=>jk(s,!0),fI=s=>jk(s,!1);Vk=s=>Nu(s,!Wt(s)),Wk=s=>Nu(s,Wt(s)),pI=s=>Nu(s,!0),mI=s=>Nu(s,!1);gI=s=>Oe(s,t=>t.empty?s.moveByChar(t,!0,e=>gb(s,t.head,e)):Vs(t,!0)),Fk=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;bI=s=>Yk(s,!0),OI=s=>Yk(s,!1);Hk=s=>Oe(s,t=>Bu(s.state,t,!Wt(s))),Gk=s=>Oe(s,t=>Bu(s.state,t,Wt(s)));bb=s=>Kk(s,!1),Ob=s=>Kk(s,!0);yb=s=>tA(s,!1),Zu=s=>tA(s,!0);eA=s=>Oe(s,t=>es(s,t,!0)),iA=s=>Oe(s,t=>es(s,t,!1)),sA=s=>Oe(s,t=>es(s,t,!Wt(s))),rA=s=>Oe(s,t=>es(s,t,Wt(s))),nA=s=>Oe(s,t=>P.cursor(s.lineBlockAt(t.head).from,1)),oA=s=>Oe(s,t=>P.cursor(s.lineBlockAt(t.head).to,-1));lA=({state:s,dispatch:t})=>aA(s,t,!1),vI=({state:s,dispatch:t})=>aA(s,t,!0);vb=s=>zu(s,!Wt(s)),xb=s=>zu(s,Wt(s)),xI=s=>zu(s,!0),SI=s=>zu(s,!1),wI=s=>Ft(s,t=>mb(s.state,t,!0)),kI=s=>Ft(s,t=>mb(s.state,t,!1));hA=s=>_u(s,!Wt(s)),cA=s=>_u(s,Wt(s)),AI=s=>_u(s,!0),EI=s=>_u(s,!1),CI=s=>Ft(s,t=>s.moveByChar(t,!0,e=>gb(s,t.head,e)));$I=s=>uA(s,!0),PI=s=>uA(s,!1),dA=s=>Ft(s,t=>Bu(s.state,t,!Wt(s))),fA=s=>Ft(s,t=>Bu(s.state,t,Wt(s)));Sb=s=>pA(s,!1),wb=s=>pA(s,!0);kb=s=>mA(s,!1),Ab=s=>mA(s,!0),gA=s=>Ft(s,t=>es(s,t,!0)),bA=s=>Ft(s,t=>es(s,t,!1)),OA=s=>Ft(s,t=>es(s,t,!Wt(s))),yA=s=>Ft(s,t=>es(s,t,Wt(s))),vA=s=>Ft(s,t=>P.cursor(s.lineBlockAt(t.head).from)),xA=s=>Ft(s,t=>P.cursor(s.lineBlockAt(t.head).to)),Eb=({state:s,dispatch:t})=>(t(Ve(s,{anchor:0})),!0),Cb=({state:s,dispatch:t})=>(t(Ve(s,{anchor:s.doc.length})),!0),$b=({state:s,dispatch:t})=>(t(Ve(s,{anchor:s.selection.main.anchor,head:0})),!0),Pb=({state:s,dispatch:t})=>(t(Ve(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),SA=({state:s,dispatch:t})=>(t(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),wA=({state:s,dispatch:t})=>{let e=Wu(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},kA=({state:s,dispatch:t})=>{let e=ho(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)};EA=s=>AA(s,!1),CA=s=>AA(s,!0),$A=({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};Qb=(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}),Vu=s=>Qb(s,!1,!0),QI=s=>Qb(s,!1,!1),Tb=s=>Qb(s,!0,!1),PA=(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}),Lb=s=>PA(s,!1),QA=s=>PA(s,!0),TI=s=>Ws(s,t=>s.moveByChar(t,!0,e=>gb(s,t.head,e)).head),TA=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)}),LI=s=>Ws(s,t=>{let e=s.lineBlockAt(t.head).from;return t.head>e?e:Math.max(0,t.head-1)}),LA=s=>Ws(s,t=>{let e=s.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),MA=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)}),MI=({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},RA=({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},IA=({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)};qA=({state:s,dispatch:t})=>DA(s,t,!1),XA=({state:s,dispatch:t})=>DA(s,t,!0);BA=({state:s,dispatch:t})=>NA(s,t,!1),ZA=({state:s,dispatch:t})=>NA(s,t,!0),zA=s=>{if(s.state.readOnly)return!1;let{state:t}=s,e=t.changes(Wu(t).map(({from:r,to:n})=>(r>0?r--:n<t.doc.length&&n++,{from:r,to:n}))),i=ho(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},RI=({state:s,dispatch:t})=>(t(s.update(s.replaceSelection(s.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),II=({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);Mb=jA(!1),_A=jA(!0);VA=({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=Rb(s,(n,o,a)=>{let l=Gn(i,n.from);if(l==null)return;/\S/.test(n.text)||(l=0);let h=/^\s*/.exec(n.text)[0],c=Ki(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},Fu=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Rb(s,(e,i)=>{i.push({from:e.from,insert:s.facet(Pi)})}),{userEvent:"input.indent"})),!0),Ib=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Rb(s,(e,i)=>{let r=/^\s*/.exec(e.text)[0];if(!r)return;let n=jt(r,s.tabSize),o=0,a=Ki(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),WA=s=>(s.setTabFocusMode(),!0),qI=s=>(s.setTabFocusMode(2e3),!0),XI=({state:s,dispatch:t})=>s.selection.ranges.some(e=>!e.empty)?Fu({state:s,dispatch:t}):(t(s.update(s.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),FA=[{key:"Ctrl-b",run:fb,shift:vb,preventDefault:!0},{key:"Ctrl-f",run:pb,shift:xb},{key:"Ctrl-p",run:bb,shift:Sb},{key:"Ctrl-n",run:Ob,shift:wb},{key:"Ctrl-a",run:nA,shift:vA},{key:"Ctrl-e",run:oA,shift:xA},{key:"Ctrl-d",run:Tb},{key:"Ctrl-h",run:Vu},{key:"Ctrl-k",run:TA},{key:"Ctrl-Alt-h",run:Lb},{key:"Ctrl-o",run:RA},{key:"Ctrl-t",run:IA},{key:"Ctrl-v",run:Zu}],UA=[{key:"ArrowLeft",run:fb,shift:vb,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Vk,shift:hA,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:sA,shift:OA,preventDefault:!0},{key:"ArrowRight",run:pb,shift:xb,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Wk,shift:cA,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rA,shift:yA,preventDefault:!0},{key:"ArrowUp",run:bb,shift:Sb,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Eb,shift:$b},{mac:"Ctrl-ArrowUp",run:yb,shift:kb},{key:"ArrowDown",run:Ob,shift:wb,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cb,shift:Pb},{mac:"Ctrl-ArrowDown",run:Zu,shift:Ab},{key:"PageUp",run:yb,shift:kb},{key:"PageDown",run:Zu,shift:Ab},{key:"Home",run:iA,shift:bA,preventDefault:!0},{key:"Mod-Home",run:Eb,shift:$b},{key:"End",run:eA,shift:gA,preventDefault:!0},{key:"Mod-End",run:Cb,shift:Pb},{key:"Enter",run:Mb,shift:Mb},{key:"Mod-a",run:SA},{key:"Backspace",run:Vu,shift:Vu,preventDefault:!0},{key:"Delete",run:Tb,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Lb,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:QA,preventDefault:!0},{mac:"Mod-Backspace",run:LA,preventDefault:!0},{mac:"Mod-Delete",run:MA,preventDefault:!0}].concat(FA.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),Hu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Hk,shift:dA},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Gk,shift:fA},{key:"Alt-ArrowUp",run:qA},{key:"Shift-Alt-ArrowUp",run:BA},{key:"Alt-ArrowDown",run:XA},{key:"Shift-Alt-ArrowDown",run:ZA},{key:"Mod-Alt-ArrowUp",run:EA},{key:"Mod-Alt-ArrowDown",run:CA},{key:"Escape",run:$A},{key:"Mod-Enter",run:_A},{key:"Alt-l",mac:"Ctrl-l",run:wA},{key:"Mod-i",run:kA,preventDefault:!0},{key:"Mod-[",run:Ib},{key:"Mod-]",run:Fu},{key:"Mod-Alt-\\",run:VA},{key:"Shift-Mod-k",run:zA},{key:"Shift-Mod-\\",run:lA},{key:"Mod-/",run:Lk},{key:"Alt-A",run:Rk},{key:"Ctrl-m",mac:"Shift-Alt-m",run:WA}].concat(UA),Gu={key:"Tab",run:Fu,shift:Ib}});function is(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 Ku(r,n,t||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Ku(i.from,n,i.diagnostic)}}),i}function HA(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(Bl))||s.changes.touchesRange(n.from,Math.max(n.to,i)))}function GA(s,t){return s.field(Ut,!1)?t:t.concat(W.appendConfig.of(h1))}function KA(s,t){return{effects:GA(s,[Bl.of(t)])}}function NI(s){let t=s.field(Ut,!1);return t?t.diagnostics.size:0}function ZI(s,t,e){let{diagnostics:i}=s.state.field(Ut),r,n=-1,o=-1;i.between(t-(e<0?1:0),t+(e>0?1:0),(l,h,{spec:c})=>{if(t>=l&&t<=h&&(l==h||(t>l||e>0)&&(t<h||e<0)))return r=c.diagnostics,n=l,o=h,!1});let a=s.state.facet(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:t1(s,r)}}}:null}function t1(s,t){return Pt("ul",{class:"cm-tooltip-lint"},t.map(e=>o1(s,e,!1)))}function jI(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 r1(s,t){return s?t?(e,i)=>t(s(e,i),i):s:t}function zl(s,t={}){return[ci.of({source:s,config:t}),s1,h1]}function VI(s){let t=s.plugin(s1);t&&t.force()}function n1(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 o1(s,t,e){var i;let r=e?n1(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=is(s.state.field(Ut).diagnostics,t);p&&n.apply(s,p.from,p.to)},{name:h}=n,c=r[o]?h.indexOf(r[o]):-1,u=c<0?h:[h.slice(0,c),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 td(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 ed(s){return td(`<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 FI(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function a1(s){let t="hint",e=1;for(let i of s){let r=FI(i.severity);r>e&&(e=r,t=i.severity)}return t}function UI(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(l1)&&s.dispatch({effects:Bb.of(null)})}};window.addEventListener("mousemove",e)}function YI(s,t,e){function i(){let o=s.elementAtHeight(t.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:Bb.of({pos:o.from,above:!1,clip:!1,create(){return{dom:t1(s,e),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,UI(s,t)}let{hoverTime:r}=s.state.facet(sd),n=setTimeout(i,r);t.onmouseout=()=>{clearTimeout(n),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(n),n=setTimeout(i,r)}}function HI(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 id(e[r]).range(+r));return H.of(i,!0)}function rd(s={}){return[sd.of(s),Nb,GI,KI,l1]}function JI(s,t){let e=s.field(Ut,!1);if(e&&e.diagnostics.size){let i=[],r=[],n=-1;for(let o=H.iter([e.diagnostics]);;o.next()){for(let a=0;a<i.length;a++)(!o.value||o.value.spec.diagnostics.indexOf(i[a])<0)&&(t(i[a],r[a],n),i.splice(a,1),r.splice(a--,1));if(!o.value)break;for(let a of o.value.spec.diagnostics)i.indexOf(a)<0&&(i.push(a),r.push(o.from));n=o.to}}}var Ku,Fs,Bl,Db,JA,Ut,BI,e1,qb,i1,zI,_I,s1,ci,Xb,Ju,Zl,WI,id,GI,Nb,Bb,l1,KI,h1,sd,c1=Z(()=>{wi();si();Uf();Ku=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},Fs=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=a1(a);if(g)o.add(m,m,j.widget({widget:new Xb(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,is(d))}};Bl=W.define(),Db=W.define(),JA=W.define(),Ut=gt.define({create(){return new Fs(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=is(e,s.selected.diagnostic,n)||is(e,null,n)}!e.size&&r&&t.state.facet(ci).autoPanel&&(r=null),s=new Fs(e,r,i)}for(let e of t.effects)if(e.is(Bl)){let i=t.state.facet(ci).autoPanel?e.value.length?Zl.open:null:s.panel;s=Fs.init(e.value,i,t.state)}else e.is(Db)?s=new Fs(s.diagnostics,e.value?Zl.open:null,s.selected):e.is(JA)&&(s=new Fs(s.diagnostics,s.panel,e.value));return s},provide:s=>[Fn.from(s,t=>t.panel),I.decorations.from(s,t=>t.diagnostics)]});BI=j.mark({class:"cm-lintRange cm-lintRange-active"});e1=s=>{let t=s.state.field(Ut,!1);(!t||!t.panel)&&s.dispatch({effects:GA(s.state,[Db.of(!0)])});let e=zc(s,Zl.open);return e&&e.dom.querySelector(".cm-panel-lint ul").focus(),!0},qb=s=>{let t=s.state.field(Ut,!1);return!t||!t.panel?!1:(s.dispatch({effects:Db.of(!1)}),!0)},i1=s=>{let t=s.state.field(Ut,!1);if(!t)return!1;let e=s.state.selection.main,i=is(t.diagnostics,null,e.to+1);return!i&&(i=is(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)},zI=s=>{let{state:t}=s,e=t.field(Ut,!1);if(!e)return!1;let i=t.selection.main,r,n,o,a;return e.diagnostics.between(0,t.doc.length,(l,h)=>{h<i.to&&(r==null||r<l)&&(r=l,n=h),(o==null||l>o)&&(o=l,a=h)}),o==null||r==null&&o==i.from?!1:(s.dispatch({selection:{anchor:r??o,head:n??a},scrollIntoView:!0}),!0)},_I=[{key:"Mod-Shift-m",run:e1,preventDefault:!0},{key:"F8",run:i1}],s1=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&&jI(e.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==t.doc&&this.view.dispatch(KA(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:r1,tooltipFilter:r1,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})}}});Xb=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})}},Ju=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=o1(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Zl=class s{constructor(t){this.view=t,this.items=[];let e=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)qb(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],o=n1(n.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==r.keyCode){let l=is(this.view.state.field(Ut).diagnostics,n);l&&n.actions[a].apply(t,l.from,l.to)}}else return;r.preventDefault()}},i=r=>{for(let n=0;n<this.items.length;n++)this.items[n].dom.contains(r.target)&&this.moveSelection(n)};this.list=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:()=>qb(this.view)},"\xD7")),this.update()}get selectedIndex(){let t=this.view.state.field(Ut).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(Ut),i=0,r=!1,n=null,o=new Set;for(t.between(0,this.view.state.doc.length,(a,l,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let u=-1,d;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==c){u=f;break}u<0?(d=new Ju(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 Ju(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),n?(this.list.setAttribute("aria-activedescendant",n.id),this.view.requestMeasure({key:this,read:()=>({sel:n.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let h=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/h:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let t=this.list.firstChild;function e(){let i=t;t=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=this.view.state.field(Ut),i=is(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:JA.of(i)})}static open(t){return new s(t)}};WI=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:ed("#d11")},".cm-lintRange-warning":{backgroundImage:ed("orange")},".cm-lintRange-info":{backgroundImage:ed("#999")},".cm-lintRange-hint":{backgroundImage:ed("#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"}}});id=class extends ee{constructor(t){super(),this.diagnostics=t,this.severity=a1(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(sd).tooltipFilter;return r&&(i=r(i,t.state)),i.length&&(e.onmouseover=()=>YI(t,e,i)),e}};GI=pl({class:"cm-gutter-lint",markers:s=>s.state.field(Nb),widgetMarker:(s,t,e)=>{let i=[];return s.state.field(Nb).between(e.from,e.to,(r,n,o)=>{r>e.from&&r<e.to&&i.push(...o.diagnostics)}),i.length?new id(i):null}}),Nb=gt.define({create(){return H.empty},update(s,t){s=s.map(t.changes);let e=t.state.facet(sd).markerFilter;for(let i of t.effects)if(i.is(Bl)){let r=i.value;e&&(r=e(r||[],t.state)),s=HI(t.state.doc,r.slice(0))}return s}}),Bb=W.define(),l1=gt.define({create(){return null},update(s,t){return s&&t.docChanged&&(s=HA(t,s)?null:{...s,pos:t.changes.mapPos(s.pos)}),t.effects.reduce((e,i)=>i.is(Bb)?i.value:e,s)},provide:s=>Ls.from(s)}),KI=I.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:td('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:td('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:td('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),h1=[Ut,I.decorations.compute([Ut],s=>{let{selected:t,panel:e}=s.field(Ut);return!t||!e||t.from==t.to?j.none:j.set([BI.range(t.from,t.to)])}),am(ZI,{hideOn:HA}),WI],sd=X.define({combine(s){return Jt(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}})});var zb={};Ht(zb,{Compartment:()=>Vi,EditorSelection:()=>P,EditorState:()=>ot,EditorView:()=>I,HighlightStyle:()=>$i,LOAD_TIMEOUT_MS:()=>Zb,LanguageSupport:()=>xt,StateEffect:()=>W,adiaBaseTheme:()=>tD,adiaHighlightStyle:()=>eD,defaultHighlightStyle:()=>su,defaultKeymap:()=>Hu,drawSelection:()=>_c,highlightActiveLine:()=>jc,highlightActiveLineGutter:()=>Uc,history:()=>Uu,historyKeymap:()=>Yu,importWithTimeout:()=>sD,indentWithTab:()=>Gu,jsonLinter:()=>rD,keymap:()=>oi,languages:()=>iD,lineNumbers:()=>Fc,lintGutter:()=>rd,linter:()=>zl,placeholder:()=>Vc,syntaxHighlighting:()=>iu});function sD(s,t){return Promise.race([s(),new Promise((e,i)=>setTimeout(()=>i(new Error(`code-editor: ${t} load timed out after ${Zb}ms`)),Zb))])}function nD(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 tD,eD,iD,Zb,rD,_b=Z(()=>{"use strict";si();wi();YA();hi();c1();ei();tD=I.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{caretColor:"inherit"},".cm-focused":{outline:"none"}}),eD=$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"}]),iD={json:()=>Promise.resolve().then(()=>(Vx(),jx)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(wg(),ww)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(gg(),uw)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Zm(),xS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(gk(),mk)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Tk(),Qk)).then(s=>({extension:s.yaml()}))},Zb=1e4;rD=zl(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}=nD(i,t);return[{from:r,to:n,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function ld(s){return Nt.get(s)||null}function $1(s,t){Nt.set(s,t)}var Nt,Jb=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 P1(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 ID(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 hd,ia,tO=Z(()=>{"use strict";hd={provider:0,controller:1,source:2,action:3,lifecycle:4},ia=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?P1(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)=>(hd[i.kind]??9)-(hd[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)=>(hd[i[1].dockable.kind]??9)-(hd[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){ID(this.#e,t,e);for(let[i,r]of this.#s)if(t===i||t.startsWith(i+"/"))for(let n of r)n(P1(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 ye,Hs=Z(()=>{"use strict";ye=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 sa,eO=Z(()=>{"use strict";Hs();sa=class extends ye{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 ra,iO=Z(()=>{"use strict";Hs();ra=class extends ye{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 cd,na,sO=Z(()=>{"use strict";Hs();cd={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"},na=class extends ye{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=cd[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 oa,rO=Z(()=>{"use strict";Hs();oa=class extends ye{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 aa,nO=Z(()=>{"use strict";Hs();aa=class extends ye{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 Q1,ve,Gs=Z(()=>{"use strict";Q1=new WeakSet,ve=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!Q1.has(e)&&e!==s&&(Q1.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 T1={};Ht(T1,{FormController:()=>oO});var oO,L1=Z(()=>{"use strict";Gs();oO=class extends ve{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 M1={};Ht(M1,{DataStreamController:()=>aO});var aO,R1=Z(()=>{"use strict";Gs();aO=class extends ve{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 I1={};Ht(I1,{SelectionController:()=>lO});var lO,D1=Z(()=>{"use strict";Gs();lO=class extends ve{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 q1={};Ht(q1,{ToggleController:()=>hO});var hO,X1=Z(()=>{"use strict";Gs();hO=class extends ve{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 N1={};Ht(N1,{AccordionController:()=>cO});var cO,B1=Z(()=>{"use strict";Gs();cO=class extends ve{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 Z1={};Ht(Z1,{StateMachineController:()=>uO});var uO,z1=Z(()=>{"use strict";Gs();uO=class extends ve{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 _1(s,t){qi.controllers.set(s,t)}function j1(s,t){qi.handlers.set(s,t)}function V1(s,t){qi.resolvers.set(s,t)}async function ud(s){let t=qi.controllers.get(s);return t?t():null}function dd(s){return qi.handlers.get(s)||null}async function Wl(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 DD(s){let{action:t,params:e}=s,i=dO(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=dO(t.value,s);s.updateModel(t.path,e)}async function XD(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 ND(){history.back()}async function BD(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 ZD(s){let{action:t,source:e}=s,i=dO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function zD(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function _D(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 dO(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 jD(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}function jD(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 VD(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 WD(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 FD(s,t){return{_source:s,_mock:!0}}var qi,fO=Z(()=>{"use strict";qi={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(L1(),T1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(R1(),M1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(D1(),I1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(X1(),q1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(B1(),N1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(z1(),Z1))).StateMachineController]]),handlers:new Map([["submit-resource",DD],["update-model",qD],["navigate",XD],["navigate-back",ND],["controller-command",BD],["emit-event",ZD],["refresh-source",zD],["notify",_D]]),resolvers:new Map([["resource",VD],["api",WD],["mock",FD]])}});function UD(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:Wl};return s(r)}}function YD(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=dd(t);if(!e)return null;let i=UD(e);return s.set(t,i),i}}function HD(){return async s=>ud(s)}function GD(){return async(s,t)=>Wl(s,{})}function fd(s){let t=[],e=YD(),i=HD(),r=GD();if(s.data?.sources)for(let o of s.data.sources)t.push(new ra(o,r));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new sa(o,i));if(s.actions)for(let o of s.actions)t.push(new na(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new oa(a))}s.lifecycle&&t.push(new aa(s.lifecycle,e));let n=s.state?.model||null;return{dockables:t,initialModel:n}}var pO=Z(()=>{"use strict";eO();iO();sO();rO();nO();fO()});var W1={};Ht(W1,{WiringEngine:()=>Fl});var Fl,mO=Z(()=>{"use strict";tO();pO();Fl=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}=fd(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 ia(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 rs,F1=Z(()=>{"use strict";Jb();rs=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.#R(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(()=>(mO(),W1));this.#h=new e({updateDataModel:(i,r,n)=>{this.#R({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.#w(l.variant,l):ld(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-id",l.id),h.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),h.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),d.id=l.id,h.replaceWith(d),h=d,i.elements.set(l.id,h),this.#s.set(l.id,h)}l._surfaceId=t,Object.values(l).some(d=>d&&typeof d=="object"&&d.path)&&i.bindings.set(l.id,l),this.#k(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#y(e);let r=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])r.set(h,l.id);l.child&&r.set(l.child,l.id)}let n=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=r.get(u)}return!1};for(let l of e){let h=i.elements.get(l.id);if(h)try{let c=Array.isArray(l.children)?l.children:[];for(let u of c){if(u===l.id||n(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!n(l.id,l.child)){let u=i.elements.get(l.child);u&&u.parentElement!==h&&h.appendChild(u)}}catch(c){console.warn(`A2UI: tree build failed for "${l.id}":`,c.message)}}let o=i.rootId??"root";if(e.find(l=>l.id===o)){let l=i.elements.get(o);l&&l.parentElement!==i.root&&i.root.appendChild(l)}}static#p=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#m=new Set(["Header","Section","Footer"]);static#g=new Set(["header","body","footer"]);#O=new Set;#y(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let r=i.component==="Card"||i.component==="ErrorContainer",n=i.component==="Drawer";if(!r&&!n)continue;let o=n?s.#m:s.#p,a=n?"<drawer-ui>":"<card-ui>",l=Array.isArray(i.children)?i.children:[];for(let h of l){let c=e.get(h);if(!c||typeof c.slot=="string"&&s.#g.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#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#b=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#S=new Set(["autocomplete","autofocus","autocapitalize","autocorrect","inputmode","enterkeyhint","spellcheck","maxlength","minlength","readonly","novalidate","formnovalidate","formaction","formenctype","formmethod","formtarget","multiple","pattern","placeholder","required","tabindex","accesskey","autoplay","autopictureinpicture","controls","crossorigin","disablepictureinpicture","disableremoteplayback","loop","muted","playsinline","preload","srcset","srcdoc","srclang","sizes","loading","decoding","fetchpriority","ismap","usemap","hreflang","referrerpolicy","download","contenteditable","contextmenu","draggable","dirname","colspan","rowspan","headers","allowfullscreen","allowpaymentrequest","itemid","itemprop","itemref","itemscope","itemtype","nomodule","nonce"]);#w(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.#b.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.#S.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)}#R({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.#M(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#M(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.#M(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let n=this.#L(i,t);if(n.rejected){this.#M(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.#M(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.#M(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.#I(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}}#I(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.#T(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}#T(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 tD,eD,iD,Zb,rD,_b=Z(()=>{"use strict";si();wi();YA();hi();c1();ei();tD=I.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{caretColor:"inherit"},".cm-focused":{outline:"none"}}),eD=$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"}]),iD={json:()=>Promise.resolve().then(()=>(Vx(),jx)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(wg(),ww)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(gg(),uw)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Zm(),xS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(gk(),mk)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Tk(),Qk)).then(s=>({extension:s.yaml()}))},Zb=1e4;rD=zl(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}=nD(i,t);return[{from:r,to:n,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function ld(s){return Nt.get(s)||null}function $1(s,t){Nt.set(s,t)}var Nt,Jb=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 P1(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 ID(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 hd,ia,tO=Z(()=>{"use strict";hd={provider:0,controller:1,source:2,action:3,lifecycle:4},ia=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?P1(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)=>(hd[i.kind]??9)-(hd[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)=>(hd[i[1].dockable.kind]??9)-(hd[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){ID(this.#e,t,e);for(let[i,r]of this.#s)if(t===i||t.startsWith(i+"/"))for(let n of r)n(P1(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 ye,Hs=Z(()=>{"use strict";ye=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 sa,eO=Z(()=>{"use strict";Hs();sa=class extends ye{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 ra,iO=Z(()=>{"use strict";Hs();ra=class extends ye{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 cd,na,sO=Z(()=>{"use strict";Hs();cd={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"},na=class extends ye{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=cd[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 oa,rO=Z(()=>{"use strict";Hs();oa=class extends ye{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 aa,nO=Z(()=>{"use strict";Hs();aa=class extends ye{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 Q1,ve,Gs=Z(()=>{"use strict";Q1=new WeakSet,ve=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!Q1.has(e)&&e!==s&&(Q1.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 T1={};Ht(T1,{FormController:()=>oO});var oO,L1=Z(()=>{"use strict";Gs();oO=class extends ve{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 M1={};Ht(M1,{DataStreamController:()=>aO});var aO,R1=Z(()=>{"use strict";Gs();aO=class extends ve{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 I1={};Ht(I1,{SelectionController:()=>lO});var lO,D1=Z(()=>{"use strict";Gs();lO=class extends ve{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 q1={};Ht(q1,{ToggleController:()=>hO});var hO,X1=Z(()=>{"use strict";Gs();hO=class extends ve{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 N1={};Ht(N1,{AccordionController:()=>cO});var cO,B1=Z(()=>{"use strict";Gs();cO=class extends ve{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 Z1={};Ht(Z1,{StateMachineController:()=>uO});var uO,z1=Z(()=>{"use strict";Gs();uO=class extends ve{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 _1(s,t){qi.controllers.set(s,t)}function j1(s,t){qi.handlers.set(s,t)}function V1(s,t){qi.resolvers.set(s,t)}async function ud(s){let t=qi.controllers.get(s);return t?t():null}function dd(s){return qi.handlers.get(s)||null}async function Wl(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 DD(s){let{action:t,params:e}=s,i=dO(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=dO(t.value,s);s.updateModel(t.path,e)}async function XD(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 ND(){history.back()}async function BD(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 ZD(s){let{action:t,source:e}=s,i=dO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function zD(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function _D(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 dO(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 jD(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}function jD(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 VD(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 WD(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 FD(s,t){return{_source:s,_mock:!0}}var qi,fO=Z(()=>{"use strict";qi={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(L1(),T1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(R1(),M1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(D1(),I1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(X1(),q1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(B1(),N1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(z1(),Z1))).StateMachineController]]),handlers:new Map([["submit-resource",DD],["update-model",qD],["navigate",XD],["navigate-back",ND],["controller-command",BD],["emit-event",ZD],["refresh-source",zD],["notify",_D]]),resolvers:new Map([["resource",VD],["api",WD],["mock",FD]])}});function UD(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:Wl};return s(r)}}function YD(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=dd(t);if(!e)return null;let i=UD(e);return s.set(t,i),i}}function HD(){return async s=>ud(s)}function GD(){return async(s,t)=>Wl(s,{})}function fd(s){let t=[],e=YD(),i=HD(),r=GD();if(s.data?.sources)for(let o of s.data.sources)t.push(new ra(o,r));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new sa(o,i));if(s.actions)for(let o of s.actions)t.push(new na(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new oa(a))}s.lifecycle&&t.push(new aa(s.lifecycle,e));let n=s.state?.model||null;return{dockables:t,initialModel:n}}var pO=Z(()=>{"use strict";eO();iO();sO();rO();nO();fO()});var W1={};Ht(W1,{WiringEngine:()=>Fl});var Fl,mO=Z(()=>{"use strict";tO();pO();Fl=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}=fd(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 ia(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 rs,F1=Z(()=>{"use strict";Jb();rs=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.#$(t);break;case"updateStyles":this.#I(t);break;case"removeStyles":this.#R(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(()=>(mO(),W1));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.#w(l.variant,l):ld(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-id",l.id),h.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),h.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),d.id=l.id,h.replaceWith(d),h=d,i.elements.set(l.id,h),this.#s.set(l.id,h)}l._surfaceId=t,Object.values(l).some(d=>d&&typeof d=="object"&&d.path)&&i.bindings.set(l.id,l),this.#k(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#y(e);let r=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])r.set(h,l.id);l.child&&r.set(l.child,l.id)}let n=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=r.get(u)}return!1};for(let l of e){let h=i.elements.get(l.id);if(h)try{let c=Array.isArray(l.children)?l.children:[];for(let u of c){if(u===l.id||n(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!n(l.id,l.child)){let u=i.elements.get(l.child);u&&u.parentElement!==h&&h.appendChild(u)}}catch(c){console.warn(`A2UI: tree build failed for "${l.id}":`,c.message)}}let o=i.rootId??"root";if(e.find(l=>l.id===o)){let l=i.elements.get(o);l&&l.parentElement!==i.root&&i.root.appendChild(l)}}static#p=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#m=new Set(["Header","Section","Footer"]);static#g=new Set(["header","body","footer"]);#O=new Set;#y(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let r=i.component==="Card"||i.component==="ErrorContainer",n=i.component==="Drawer";if(!r&&!n)continue;let o=n?s.#m:s.#p,a=n?"<drawer-ui>":"<card-ui>",l=Array.isArray(i.children)?i.children:[];for(let h of l){let c=e.get(h);if(!c||typeof c.slot=="string"&&s.#g.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#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#b=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#S=new Set(["autocomplete","autofocus","autocapitalize","autocorrect","inputmode","enterkeyhint","spellcheck","maxlength","minlength","readonly","novalidate","formnovalidate","formaction","formenctype","formmethod","formtarget","multiple","pattern","placeholder","required","tabindex","accesskey","autoplay","autopictureinpicture","controls","crossorigin","disablepictureinpicture","disableremoteplayback","loop","muted","playsinline","preload","srcset","srcdoc","srclang","sizes","loading","decoding","fetchpriority","ismap","usemap","hreflang","referrerpolicy","download","contenteditable","contextmenu","draggable","dirname","colspan","rowspan","headers","allowfullscreen","allowpaymentrequest","itemid","itemprop","itemref","itemscope","itemtype","nomodule","nonce"]);#w(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.#b.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.#S.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.#C(i.dataModel,t.path):t.path}return t}#C(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)}}}#$({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#Q=new Set(["root","html","body"]);#I({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#L(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#L(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.#L(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let n=this.#T(i,t);if(n.rejected){this.#L(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.#L(r.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:n.sheet.cssRules.length,validationWarnings:n.warnings})}#R({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.#L(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#T(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.#D(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.#N(r,e),o=this.#Z(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}}#D(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.#P(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.#Q.has(a))return`forbidden-${a}-selector`}}return null}#P(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}#N(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}#Z(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
- }`}#M(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 pd(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 md(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 H1(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function gd(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?KD(s,t):Y1(s,t)}function U1(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 KD(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);U1(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 Y1(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(`
44
+ }`}#L(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 pd(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 md(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 H1(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function gd(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?KD(s,t):Y1(s,t)}function U1(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 KD(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);U1(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 Y1(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(`
45
45
 
46
46
  `)))break}try{y.cancel()}catch{}}else await u.json().catch(()=>null)}catch{}try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify({jsonrpc:"2.0",method:"notifications/initialized"}),signal:e}).then(g=>g.text()).catch(()=>null)}catch{}if(i){let g=i instanceof Map?[...i.keys()]:Object.keys(i);try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify({jsonrpc:"2.0",method:"a2ui/catalog",params:{supportedTypes:g}}),signal:e}).then(y=>y.text()).catch(()=>null)}catch{}}let f=g=>fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify(g),signal:e}).then(y=>y.text()).catch(()=>null),p=g=>{U1(g,l),g.method==="a2ui/action"&&r&&Promise.resolve().then(()=>r(g.params?.name,g.params?.arguments)).then(y=>f({jsonrpc:"2.0",id:g.id,result:y})).catch(y=>f({jsonrpc:"2.0",id:g.id,error:{code:-1,message:y.message}}))},m;try{m=await fetch(s,{method:"GET",headers:{Accept:"text/event-stream","mcp-session-id":d},signal:e})}catch(g){g?.name!=="AbortError"&&console.warn("A2UI MCP HTTP: GET stream failed",g);return}if(!m.ok||!m.body){console.warn(`A2UI MCP HTTP: GET stream returned ${m.status}`);return}e&&e.addEventListener("abort",h,{once:!0});let b=()=>{try{fetch(s,{method:"DELETE",headers:{"mcp-session-id":d}}).catch(()=>null)}catch{}};for((async()=>{let g=m.body.getReader(),y=new TextDecoder,v="";try{for(;!a;){let{done:w,value:k}=await g.read();if(w)break;v+=y.decode(k,{stream:!0});let E;for(;(E=v.indexOf(`
47
47
 
@@ -73,7 +73,7 @@ ${i.join(`
73
73
  aria-label="Undo" \u2190 explicit accessible name
74
74
  title="Undo" \u2190 auto-mirrored to aria-label + tooltip
75
75
  aria-labelledby="..." \u2190 reference an existing label element
76
- 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 aC=s=>s.getAttribute?.("role")==="presentation"||s.style?.display==="contents";function lC(s){let t=[],e=i=>{for(let r of i)if(r.nodeType===1){if(aC(r)){e(r.children);continue}t.push(r)}};return s&&e(s.children),t}function nt(s,t){return lC(s).filter(e=>e.getAttribute("slot")===t)}var sy=s=>xh(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=nt(this,"leading"),e=nt(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.#M),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.#_),this.#s?.addEventListener("pointerdown",this.#V),(this.prefix||this.suffix)&&yh.then(()=>this.#O())}#m(t){let e=this.prefix?`<span slot="prefix">${sy(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",r=this.suffix?`<span slot="suffix">${sy(this.suffix)}</span>`:"",n=t?`aria-labelledby="${t}"`:"";if(this.#f)return`
76
+ 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 aC=s=>s.getAttribute?.("role")==="presentation"||s.style?.display==="contents";function lC(s){let t=[],e=i=>{for(let r of i)if(r.nodeType===1){if(aC(r)){e(r.children);continue}t.push(r)}};return s&&e(s.children),t}function nt(s,t){return lC(s).filter(e=>e.getAttribute("slot")===t)}var sy=s=>xh(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=nt(this,"leading"),e=nt(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.#C(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#Q),this.#t.addEventListener("keydown",this.#N),this.#t.addEventListener("blur",this.#L),this.#t.addEventListener("focus",this.#Z),this.#t.addEventListener("paste",this.#X),this.#p&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#W),this.#s?.addEventListener("pointerdown",this.#_),(this.prefix||this.suffix)&&yh.then(()=>this.#O())}#m(t){let e=this.prefix?`<span slot="prefix">${sy(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",r=this.suffix?`<span slot="suffix">${sy(this.suffix)}</span>`:"",n=t?`aria-labelledby="${t}"`:"";if(this.#f)return`
77
77
  <div slot="field">
78
78
  ${e}${i}
79
79
  <input slot="text" type="password" tabindex="0"
@@ -97,7 +97,7 @@ ${i.join(`
97
97
  <div slot="field"${this.#p?" data-number":""}>
98
98
  ${e}${i}${o}${r}${a}
99
99
  </div>
100
- `}#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")&&xh(e)){i.replaceChildren();let r=document.createElement("icon-ui");r.setAttribute("name",e),i.appendChild(r)}}}#y(){for(let t of["prefix","suffix"]){let e=this.querySelector(`:scope > [slot="field"] > [slot="${t}"]`);if(!e)continue;let i=this[t]||"",r=e.querySelector(":scope > icon-ui");if(i&&xh(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.#y(),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#p){let e=this.valueAsNumber;Number.isFinite(e)?(this.setAttribute("aria-valuenow",String(e)),this.setAttribute("aria-valuetext",`${this.#A(e)}${this.suffix?" "+this.suffix:""}`)):(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuetext")),this.min!=null?this.setAttribute("aria-valuemin",String(this.min)):this.removeAttribute("aria-valuemin"),this.max!=null?this.setAttribute("aria-valuemax",String(this.max)):this.removeAttribute("aria-valuemax");let i=this.disabled||this.readonly||this.max!=null&&Number.isFinite(e)&&e>=this.max,r=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!r)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#p&&this.#b(String(t))}validate(){let t=super.validate();if(!this.#p)return t;if(!t)return!1;let e=this.#b(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#b(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#k(e),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.#w(),this.#o):"."}#S(){return this.locale?this.#c===this.locale?this.#l:(this.#w(),this.#l):""}#w(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#o=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#o=".",this.#l=""}this.#c=this.locale}#k(t){let e=this.#v(),i=this.#S(),r=String(t);return i&&(r=r.split(i).join("")),e!=="."&&(r=r.replace(new RegExp(`\\${e}`,"g"),".")),r}#A(t){if(!Number.isFinite(t))return"";let e=this.#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}#R(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.#R(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.#T())}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.#I(h.startContainer,h.startOffset),a=this.#I(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}#I(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}#T(){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.#Z(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#Z(this.max));return;case"Escape":t.preventDefault(),this.value=this.#r,this.#t.textContent=this.#$(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#j(),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)}};#M=()=>{this.#p&&this.#j(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#j(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#R(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))}#Z(t){let e=this.#R(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)};#_=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.#M),this.#t.removeEventListener("focus",this.#q),this.#t.removeEventListener("paste",this.#B),this.#t.removeEventListener("beforeinput",this.#D)),this.#i?.removeEventListener("pointerdown",this.#_),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=`
100
+ `}#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")&&xh(e)){i.replaceChildren();let r=document.createElement("icon-ui");r.setAttribute("name",e),i.appendChild(r)}}}#y(){for(let t of["prefix","suffix"]){let e=this.querySelector(`:scope > [slot="field"] > [slot="${t}"]`);if(!e)continue;let i=this[t]||"",r=e.querySelector(":scope > icon-ui");if(i&&xh(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.#C(t):String(t);this.#t.textContent!==e&&(this.#t.textContent=e,this.#t.toggleAttribute("data-empty",!e))}if(this.#e&&(this.#e.textContent=this.label||""),this.#y(),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#p){let e=this.valueAsNumber;Number.isFinite(e)?(this.setAttribute("aria-valuenow",String(e)),this.setAttribute("aria-valuetext",`${this.#A(e)}${this.suffix?" "+this.suffix:""}`)):(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuetext")),this.min!=null?this.setAttribute("aria-valuemin",String(this.min)):this.removeAttribute("aria-valuemin"),this.max!=null?this.setAttribute("aria-valuemax",String(this.max)):this.removeAttribute("aria-valuemax");let i=this.disabled||this.readonly||this.max!=null&&Number.isFinite(e)&&e>=this.max,r=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!r)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#p&&this.#b(String(t))}validate(){let t=super.validate();if(!this.#p)return t;if(!t)return!1;let e=this.#b(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#b(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#k(e),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.#w(),this.#o):"."}#S(){return this.locale?this.#c===this.locale?this.#l:(this.#w(),this.#l):""}#w(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#o=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#o=".",this.#l=""}this.#c=this.locale}#k(t){let e=this.#v(),i=this.#S(),r=String(t);return i&&(r=r.split(i).join("")),e!=="."&&(r=r.replace(new RegExp(`\\${e}`,"g"),".")),r}#A(t){if(!Number.isFinite(t))return"";let e=this.#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)}}#C(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))}#$(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}})))}#Q=()=>{let t;if(this.#f)t=this.#t.value||"";else if(this.#p){let e=this.#t.textContent||"";t=this.#T(e),t!==e&&(this.#t.textContent=t,this.#P())}else t=this.#t.textContent||"";this.value=t,this.#f||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#I=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;let r=this.#t.textContent||"",n=window.getSelection(),o=r.length,a=r.length;if(n&&n.rangeCount&&this.#t.contains(n.anchorNode)){let h=n.getRangeAt(0);o=this.#D(h.startContainer,h.startOffset),a=this.#D(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=r.slice(0,o)+i+r.slice(a);this.#R(l)||t.preventDefault()};#R(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)}#T(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}#D(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}#P(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#N=t=>{if(this.#p){switch(t.key){case"ArrowUp":t.preventDefault(),this.#$(1);return;case"ArrowDown":t.preventDefault(),this.#$(-1);return;case"PageUp":t.preventDefault(),this.#$(10);return;case"PageDown":t.preventDefault(),this.#$(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#B(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#B(this.max));return;case"Escape":t.preventDefault(),this.value=this.#r,this.#t.textContent=this.#C(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#V(),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})))};#Z=()=>{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)}};#L=()=>{this.#p&&this.#V(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#V(){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))}#B(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}})))}#X=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#p?this.#T(e):e;document.execCommand("insertText",!1,i)};#W=t=>this.#U(t,1);#_=t=>this.#U(t,-1);#U(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#$(e),this.#q(),document.addEventListener("pointerup",this.#z,{once:!0}),document.addEventListener("pointercancel",this.#z,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#n=window.setInterval(()=>{let i=this.valueAsNumber;this.#$(e),this.valueAsNumber===i&&this.#q()},s.#d)},s.#u))}#z=()=>this.#q();#q(){this.#a!=null&&(window.clearTimeout(this.#a),this.#a=null),this.#n!=null&&(window.clearInterval(this.#n),this.#n=null),document.removeEventListener("pointerup",this.#z),document.removeEventListener("pointercancel",this.#z)}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.#Q),this.#t.removeEventListener("keydown",this.#N),this.#t.removeEventListener("blur",this.#L),this.#t.removeEventListener("focus",this.#Z),this.#t.removeEventListener("paste",this.#X),this.#t.removeEventListener("beforeinput",this.#I)),this.#i?.removeEventListener("pointerdown",this.#W),this.#s?.removeEventListener("pointerdown",this.#_),this.#q(),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=`
101
101
  ${this.label?`<label slot="label" label="${this.label}"></label>`:""}
102
102
  <div slot="text" contenteditable="plaintext-only" tabindex="0"
103
103
  ${this.value?"":'data-empty=""'}
@@ -124,7 +124,7 @@ ${i.join(`
124
124
  .value=\${signal.value} \u2190 read the signal's current value
125
125
  Functions are not auto-invoked at render time; the slider reads
126
126
  .value synchronously. See USAGE.md "Reactive binding" for the
127
- 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())}#y(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#b=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.#y(),this.#a=null};#S=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#r)return;let e=Math.abs(t.clientX-this.#f("lower")),i=Math.abs(t.clientX-this.#f("upper"));e<=i?this.#g(this.#d(t.clientX,"lower")):this.#O(this.#d(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#d(t.clientX))}this.flushPendingInput(),this.#y()}};#w=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.#y()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#b),this.#s?.removeEventListener("pointerdown",this.#b),this.#r?.removeEventListener("pointerdown",this.#b),this.#e?.removeEventListener("click",this.#S),this.removeEventListener("keydown",this.#w),this.#e=null,this.#i=null,this.#s=null,this.#r=null}};S("slider-ui",pr);var dC=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,fC=0;function ut(s,t,e={}){let{placement:i="bottom-start",gap:r=4,matchWidth:n=!1}=e;return dC?pC(s,t,{placement:i,gap:r,matchWidth:n}):OC(s,t,{placement:i,gap:r,matchWidth:n})}function pC(s,t,{placement:e,gap:i,matchWidth:r}){let n=`--a-anchor-${++fC}`,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=mC(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=bC(l),t.style.margin=gC(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 mC(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 gC(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 bC(s){switch(s){case"bottom":return"bottom span-all";case"bottom-start":return"bottom span-right";case"bottom-end":return"bottom span-left";case"top":return"top span-all";case"top-start":return"top span-right";case"top-end":return"top span-left";case"left":return"left span-all";case"left-start":return"left span-bottom";case"left-end":return"left span-top";case"right":return"right span-all";case"right-start":return"right span-bottom";case"right-end":return"right span-top";default:return"bottom span-right"}}function OC(s,t,{placement:e,gap:i,matchWidth:r}){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=yC(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 yC(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)};#y=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#b=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.#w(),this.#c||(this.#c=new MutationObserver(()=>{if(!(this.#i.length||!this.#S().some(e=>e.tagName==="OPTION"||e.tagName==="OPTGROUP"))&&(this.#w(),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=`
127
+ 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())}#y(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#b=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.#y(),this.#a=null};#S=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#r)return;let e=Math.abs(t.clientX-this.#f("lower")),i=Math.abs(t.clientX-this.#f("upper"));e<=i?this.#g(this.#d(t.clientX,"lower")):this.#O(this.#d(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#d(t.clientX))}this.flushPendingInput(),this.#y()}};#w=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.#y()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#b),this.#s?.removeEventListener("pointerdown",this.#b),this.#r?.removeEventListener("pointerdown",this.#b),this.#e?.removeEventListener("click",this.#S),this.removeEventListener("keydown",this.#w),this.#e=null,this.#i=null,this.#s=null,this.#r=null}};S("slider-ui",pr);var dC=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,fC=0;function ut(s,t,e={}){let{placement:i="bottom-start",gap:r=4,matchWidth:n=!1}=e;return dC?pC(s,t,{placement:i,gap:r,matchWidth:n}):OC(s,t,{placement:i,gap:r,matchWidth:n})}function pC(s,t,{placement:e,gap:i,matchWidth:r}){let n=`--a-anchor-${++fC}`,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=mC(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=bC(l),t.style.margin=gC(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 mC(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 gC(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 bC(s){switch(s){case"bottom":return"bottom span-all";case"bottom-start":return"bottom span-right";case"bottom-end":return"bottom span-left";case"top":return"top span-all";case"top-start":return"top span-right";case"top-end":return"top span-left";case"left":return"left span-all";case"left-start":return"left span-bottom";case"left-end":return"left span-top";case"right":return"right span-all";case"right-start":return"right span-bottom";case"right-end":return"right span-top";default:return"bottom span-right"}}function OC(s,t,{placement:e,gap:i,matchWidth:r}){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=yC(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 yC(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)};#y=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#b=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.#Q),this.addEventListener("keydown",this.#R),this.addEventListener("remove",this.#g),this.#i.length===0&&this.#w(),this.#c||(this.#c=new MutationObserver(()=>{if(!(this.#i.length||!this.#S().some(e=>e.tagName==="OPTION"||e.tagName==="OPTGROUP"))&&(this.#w(),this.#i.length)){this.#E();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#$())}})),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.#$()===this.placeholder?"":this.#$()):e.textContent=this.#$();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.#$()===this.placeholder?"":this.#$())}" />`:`<span slot="display">${qt(this.#$())}</span>`,n=this.hint?`select-hint-${++s.#e}`:"",o=this.hint?`<span slot="hint" id="${n}">${qt(this.hint)}</span>`:"";this.innerHTML=`
128
128
  <span slot="trigger">
129
129
  ${i}
130
130
  <span data-chips></span>
@@ -135,7 +135,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
135
135
  <icon-ui name="caret-down" slot="caret"></icon-ui>
136
136
  </span>
137
137
  ${o}
138
- `,this.hint&&this.setAttribute("aria-describedby",n);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#y),a.addEventListener("click",this.#y)),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.#R();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)}#S(){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}#w(){this.#i=[];let t=new Set,e=[];for(let i of this.#S())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){U(()=>{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.#b),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.#I()}#$(){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)))}#R(){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.#I();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.#T(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#T(-1))};#L=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#I()};#I(){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")}#T(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=`
138
+ `,this.hint&&this.setAttribute("aria-describedby",n);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#y),a.addEventListener("click",this.#y)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#T),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.#T),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.#I,{once:!0})})}else this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#I)}#S(){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}#w(){this.#i=[];let t=new Set,e=[];for(let i of this.#S())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){U(()=>{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.#$())})}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.#C()?"Clear":"Select all",i.addEventListener("click",this.#b),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.#D()}#C(){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)}}#$(){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}#Q=t=>{this.disabled||this.#r&&t.composedPath().includes(this.#r)||(this.open=!this.open)};#I=t=>{!this.contains(t.target)&&!(this.#r&&t.composedPath().includes(this.#r))&&(this.open=!1)};#R=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.#D();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.#P(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#P(-1))};#T=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#D()};#D(){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")}#P(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.#Q),this.removeEventListener("keydown",this.#R),this.removeEventListener("remove",this.#g),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#I),this.#o&&(this.#o.removeEventListener("input",this.#T),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=`
139
139
  <span slot="label">${this.label}</span>
140
140
  <span slot="value">${this.#n(this.value)}</span>
141
141
  ${this.suffix?`<span slot="suffix">${this.suffix}</span>`:""}
@@ -180,8 +180,8 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
180
180
  ${t.icon?`<icon-ui name="${t.icon}"></icon-ui>`:""}
181
181
  <span data-text>${t.label}</span>
182
182
  ${t.shortcut?`<span data-shortcut>${t.shortcut}</span>`:""}
183
- `,this.#l.set(i,t),i}#x(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#v(t){let e=this.#r.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#r.querySelector("[data-active]");i&&i.removeAttribute("data-active");let r=[...e].find(n=>parseInt(n.dataset.idx)===t);r&&(r.setAttribute("data-active",""),r.scrollIntoView({block:"nearest"}),this.#i=t)}#S(t){let e=[...this.#r.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#r.querySelector("[data-active]"),n=(i?e.indexOf(i):-1)+t;n<0&&(n=e.length-1),n>=e.length&&(n=0),this.#v(parseInt(e[n].dataset.idx))}#w(t){this.#y(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#k(){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.#O(e))?.category||"";this.#y(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:n}}))}#A=()=>{this.#g(this.#s.value)};#E=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#S(1);break;case"ArrowUp":t.preventDefault(),this.#S(-1);break;case"Enter":t.preventDefault(),this.#k();break;case"Tab":t.preventDefault(),this.#k();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.#E),this.#s?.removeEventListener("input",this.#A),this.#r?.removeEventListener("click",this.#u),this.#r?.removeEventListener("pointerover",this.#d),this.#s=null,this.#r=null,this.#a=null,this.#o=!1}};S("command-ui",Mr);var Ta=.4;function jd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function Vd(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 Wd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function oy(s,t,e){let{a:i,b:r}=jd(s,t,e),[n,o,a]=Vd(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 AC(s,t,e){let i=r=>Math.round(r*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Rr(s,t,e){let[i,r,n]=oy(s,t,e);return AC(i,r,n)}function EC(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=Wd(parseInt(s.slice(0,2),16)/255),e=Wd(parseInt(s.slice(2,4),16)/255),i=Wd(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 ay(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function La(s,t,e){let{a:i,b:r}=jd(s,t,e),[n,o,a]=Vd(s,i,r);if(ay(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}=jd(s,u,e),[p,m,b]=Vd(s,d,f);ay(di(p),di(m),di(b))?l=u:h=u}return l}var Ir=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;#y=null;#b=null;#x=[];#v=null;static template=()=>null;#S=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#I("input")};#w=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.#I("change"))};#E=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#Q(t))};#$=t=>{this.#a==="hue"&&this.#Q(t)};#R=()=>{this.#a==="hue"&&(this.#a=null,this.#I("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(Ta,this.#i+i);break;case"ArrowLeft":t.preventDefault(),this.#i=Math.max(0,this.#i-i);break;case"ArrowUp":t.preventDefault(),this.#e=Math.min(1,this.#e+e);break;case"ArrowDown":t.preventDefault(),this.#e=Math.max(0,this.#e-e);break;default:return}this.#I("change")};#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.#I("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.#S),t.appendChild(c),c};this.#O=e("H","hue",0,360,1),this.#y=e("C","chroma",0,Ta,.001),this.#b=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.#w),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.#R),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.#w),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.#R),this.#d.removeEventListener("keydown",this.#P)),this.#O?.removeEventListener("input",this.#S),this.#y?.removeEventListener("input",this.#S),this.#b?.removeEventListener("input",this.#S);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*Ta,this.#e=1-r,this.#I("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.#I("input")}#L(t){if(t){if(t.startsWith("#")){let e=EC(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.`))}}}#I(t){let e=[];if(this.#e>this.maxL&&(e.push({axis:"l",requested:this.#e,clamped:this.maxL,reason:"max-l"}),this.#e=this.maxL),this.#e<this.minL&&(e.push({axis:"l",requested:this.#e,clamped:this.minL,reason:"min-l"}),this.#e=this.minL),this.#i>this.maxChroma&&(e.push({axis:"c",requested:this.#i,clamped:this.maxChroma,reason:"max-chroma"}),this.#i=this.maxChroma),Number.isFinite(this.hueDriftMax)){let a=Number.isFinite(this.baseHue)?this.baseHue:Number.isFinite(this.#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=La(this.#e,this.#i,this.#s),r=Rr(this.#e,i,this.#s),n=this.#T();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}))}#T(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#X(t,e){let i=t==="oklch"?this.#T():Rr(this.#e,La(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)*Ta,u=La(l,c,o),[d,f,p]=oy(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/Ta*100,o=(1-this.#e)*100;this.#u.style.left=`${n}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Rr(this.#e,La(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let n=[];for(let o=0;o<=360;o+=30)n.push(Rr(.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=Rr(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#T());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=Rr(this.#e,La(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#T()),this.#m&&(this.#m.textContent=r)}onFormReset(){this.value="#3b82f6"}};S("color-picker-ui",Ir);var Dr=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",Dr);C();var Fd=0,qr=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-${++Fd}`,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-${++Fd}`,from:e.from,to:e.to,fromPort:e.fromPort||"right",toPort:e.toPort||"left"})),this.#h()}clear(){this.#e=[],this.#h()}update(){this.#f()}connected(){this.#t=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#t.setAttribute("data-noodle-svg",""),this.prepend(this.#t),this.#s=new ResizeObserver(()=>this.#h()),this.#r=new MutationObserver(()=>{this.#S(),this.#h()}),this.#s.observe(this),this.#u();for(let t of this.#m())this.#s.observe(t);this.#S(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#c?.(),this.#s?.disconnect(),this.#r?.disconnect(),this.#n&&cancelAnimationFrame(this.#n),this.#n=null,this.#w(),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.#y(t,e,i,r)}}#y(t,e,i,r){let n=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(n*n+o*o),l=Math.max(50,a*this.tension),h=this.#b(t,i,l),c=this.#b(e,r,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#b(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}`}#S(){this.#d(),this.#w();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()}#w(){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${++Fd}`),`${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.#R(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"}#R(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",qr);var Bi={};function ne(s,t){Bi[s]=t}function Xr(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 Ud={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()};ne("text",{render(s,t,e){Xr(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ne("number",{render(s,t,e){Xr(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),ne("currency",{render(s,t,e,i){Xr(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"}),ne("percent",{render(s,t,e){Xr(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var ly={year:"numeric",month:"short",day:"numeric"};ne("date",{render(s,t,e){Xr(e,s?new Intl.DateTimeFormat("en-US",ly).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",ly).format(new Date(s)):""},align:"left",sortFn:"datetime"});var hy={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};ne("datetime",{render(s,t,e){Xr(e,s?new Intl.DateTimeFormat("en-US",hy).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",hy).format(new Date(s)):""},align:"left",sortFn:"datetime"}),ne("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"}),ne("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"}),ne("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"}),ne("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(--md-sys-color-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"}),ne("markdown",{render(s,t,e){let i=e.firstElementChild;(!i||i.tagName!=="SPAN")&&(e.replaceChildren(),i=e.appendChild(document.createElement("span"))),i.innerHTML=wr(String(s??"")),e.title=i.textContent},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ne("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"}),ne("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 CC(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):CC(s,t.key)}function Ch(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
184
- `)?'"'+t.replace(/"/g,'""')+'"':t}var Nr=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.#p(t)&&!this.#r.has(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;rowExpandable=null;#p(t){return this.expandable?typeof this.rowExpandable=="function"?!!this.rowExpandable(this.#e[t],t):!0:!1}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()}}#m(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#g(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){this.#O(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#g(),this.#h||(this.#h=!0,this.addEventListener("click",this.#I),this.addEventListener("keydown",this.#Z),this.addEventListener("pointerdown",this.#L))}disconnected(){this.removeEventListener("click",this.#I),this.removeEventListener("keydown",this.#Z),this.removeEventListener("pointerdown",this.#L),this.#h=!1,this.#j(),this.#y&&(cancelAnimationFrame(this.#y),this.#y=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}#O(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let 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)}#y=null;#b(){!this.isConnected||this.#y||(this.#y=requestAnimationFrame(()=>{this.#y=null,this.render(),this.#m()}))}get#x(){return this.#t.filter(t=>!t.hidden)}#v(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#x)this.#l.has(e.key)?t.push(`${this.#l.get(e.key)}px`):e.width?t.push(`${e.width}px`):e.flex?t.push(`minmax(6rem, ${e.flex}fr)`):t.push("minmax(6rem, 1fr)");return t.join(" ")}#S(){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.#x.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=Bi[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Ud[d]||Ud.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#k(){if(!this.paginate||this.paginate<=0)return 1;let t=this.#S().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#x;this.style.gridTemplateColumns=this.#v();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#A(e,t),this.#Q();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.#S(),n=this.#w(r),o=[];for(let c of n){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#E(c,t);if(u&&this.#$(u,c,t),this.#p(c)&&this.#r.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded"),o.push(d),this.#p(c)&&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.#R(i),this.#C(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.#P(h,r.length)):h&&h.remove()}#A(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.#D(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])}#E(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#$(i,t,e),i}#$(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");if(a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col",""),this.#p(e)){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=Bi[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=Bi[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])}#R(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.#x,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()}#C(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=Bi[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])}#P(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))}#D(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}#Q(){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)}#L=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.#X(t,e))};#I=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.#X(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;#X(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.#q),document.addEventListener("pointerup",this.#M)}#q=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.#v()};#M=t=>{if(!this.#T)return;let{key:e}=this.#T;document.removeEventListener("pointermove",this.#q),document.removeEventListener("pointerup",this.#M),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()};#j(){document.removeEventListener("pointermove",this.#q),document.removeEventListener("pointerup",this.#M),this.#T=null}#Z=t=>{let i=this.#x.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.#B())};#B(){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.#x,i=this.#S(),r=e.map(c=>Ch(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 Ch(d.format(f,u));let p=Bi[d.type||"text"];return p?.format?Ch(p.format(f,u,d.meta)):Ch(f)})}),o=[r.join(","),...n.map(c=>c.join(","))].join(`
183
+ `,this.#l.set(i,t),i}#x(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#v(t){let e=this.#r.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#r.querySelector("[data-active]");i&&i.removeAttribute("data-active");let r=[...e].find(n=>parseInt(n.dataset.idx)===t);r&&(r.setAttribute("data-active",""),r.scrollIntoView({block:"nearest"}),this.#i=t)}#S(t){let e=[...this.#r.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#r.querySelector("[data-active]"),n=(i?e.indexOf(i):-1)+t;n<0&&(n=e.length-1),n>=e.length&&(n=0),this.#v(parseInt(e[n].dataset.idx))}#w(t){this.#y(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#k(){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.#O(e))?.category||"";this.#y(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:n}}))}#A=()=>{this.#g(this.#s.value)};#E=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#S(1);break;case"ArrowUp":t.preventDefault(),this.#S(-1);break;case"Enter":t.preventDefault(),this.#k();break;case"Tab":t.preventDefault(),this.#k();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.#E),this.#s?.removeEventListener("input",this.#A),this.#r?.removeEventListener("click",this.#u),this.#r?.removeEventListener("pointerover",this.#d),this.#s=null,this.#r=null,this.#a=null,this.#o=!1}};S("command-ui",Mr);var Ta=.4;function jd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function Vd(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 Wd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function oy(s,t,e){let{a:i,b:r}=jd(s,t,e),[n,o,a]=Vd(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 AC(s,t,e){let i=r=>Math.round(r*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Rr(s,t,e){let[i,r,n]=oy(s,t,e);return AC(i,r,n)}function EC(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=Wd(parseInt(s.slice(0,2),16)/255),e=Wd(parseInt(s.slice(2,4),16)/255),i=Wd(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 ay(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function La(s,t,e){let{a:i,b:r}=jd(s,t,e),[n,o,a]=Vd(s,i,r);if(ay(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}=jd(s,u,e),[p,m,b]=Vd(s,d,f);ay(di(p),di(m),di(b))?l=u:h=u}return l}var Ir=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;#y=null;#b=null;#x=[];#v=null;static template=()=>null;#S=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#D("input")};#w=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#I(t))};#k=t=>{this.#a==="area"&&this.#I(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#D("change"))};#E=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#R(t))};#C=t=>{this.#a==="hue"&&this.#R(t)};#M=()=>{this.#a==="hue"&&(this.#a=null,this.#D("change"))};#$=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(Ta,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.#D("change")};#Q=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.#D("change")};connected(){if(super.connected(),this.#T(this.value),this.#n)return;this.#n=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#u=document.createElement("div"),this.#u.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#u),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(n,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",n),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#S),t.appendChild(c),c};this.#O=e("H","hue",0,360,1),this.#y=e("C","chroma",0,Ta,.001),this.#b=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.#N(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.#w),this.#h.addEventListener("pointermove",this.#k),this.#h.addEventListener("pointerup",this.#A),this.#d.addEventListener("pointerdown",this.#E),this.#d.addEventListener("pointermove",this.#C),this.#d.addEventListener("pointerup",this.#M),this.#h.addEventListener("keydown",this.#$),this.#d.addEventListener("keydown",this.#Q),this.#g=new ResizeObserver(()=>this.#Z()),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.#w),this.#h.removeEventListener("pointermove",this.#k),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#$)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#E),this.#d.removeEventListener("pointermove",this.#C),this.#d.removeEventListener("pointerup",this.#M),this.#d.removeEventListener("keydown",this.#Q)),this.#O?.removeEventListener("input",this.#S),this.#y?.removeEventListener("input",this.#S),this.#b?.removeEventListener("input",this.#S);for(let{el:t,handler:e}of this.#x)t.removeEventListener("click",e);this.#x=[],this.#n=!1}#I(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),r=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*Ta,this.#e=1-r,this.#D("input")}#R(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#D("input")}#T(t){if(t){if(t.startsWith("#")){let e=EC(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.`))}}}#D(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=La(this.#e,this.#i,this.#s),r=Rr(this.#e,i,this.#s),n=this.#P();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}))}#P(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#N(t,e){let i=t==="oklch"?this.#P():Rr(this.#e,La(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()}}#Z(){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)*Ta,u=La(l,c,o),[d,f,p]=oy(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.#T(this.value),this.#Z(),this.#u){let n=this.#i/Ta*100,o=(1-this.#e)*100;this.#u.style.left=`${n}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Rr(this.#e,La(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let n=[];for(let o=0;o<=360;o+=30)n.push(Rr(.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=Rr(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#P());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=Rr(this.#e,La(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#P()),this.#m&&(this.#m.textContent=r)}onFormReset(){this.value="#3b82f6"}};S("color-picker-ui",Ir);var Dr=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",Dr);C();var Fd=0,qr=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-${++Fd}`,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-${++Fd}`,from:e.from,to:e.to,fromPort:e.fromPort||"right",toPort:e.toPort||"left"})),this.#h()}clear(){this.#e=[],this.#h()}update(){this.#f()}connected(){this.#t=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#t.setAttribute("data-noodle-svg",""),this.prepend(this.#t),this.#s=new ResizeObserver(()=>this.#h()),this.#r=new MutationObserver(()=>{this.#S(),this.#h()}),this.#s.observe(this),this.#u();for(let t of this.#m())this.#s.observe(t);this.#S(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#c?.(),this.#s?.disconnect(),this.#r?.disconnect(),this.#n&&cancelAnimationFrame(this.#n),this.#n=null,this.#w(),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.#y(t,e,i,r)}}#y(t,e,i,r){let n=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(n*n+o*o),l=Math.max(50,a*this.tension),h=this.#b(t,i,l),c=this.#b(e,r,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#b(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}`}#S(){this.#d(),this.#w();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()}#w(){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${++Fd}`),`${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.#C(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.#$(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#Q(),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.#Q(),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)};#C(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.#Q();let r=this.#$(t,e,i);r?.dot&&r.dot.setAttribute("data-noodle-drop-ready","")}#$(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}#Q(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};S("noodles-ui",qr);var Bi={};function ne(s,t){Bi[s]=t}function Xr(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 Ud={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()};ne("text",{render(s,t,e){Xr(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ne("number",{render(s,t,e){Xr(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),ne("currency",{render(s,t,e,i){Xr(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"}),ne("percent",{render(s,t,e){Xr(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var ly={year:"numeric",month:"short",day:"numeric"};ne("date",{render(s,t,e){Xr(e,s?new Intl.DateTimeFormat("en-US",ly).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",ly).format(new Date(s)):""},align:"left",sortFn:"datetime"});var hy={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};ne("datetime",{render(s,t,e){Xr(e,s?new Intl.DateTimeFormat("en-US",hy).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",hy).format(new Date(s)):""},align:"left",sortFn:"datetime"}),ne("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"}),ne("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"}),ne("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"}),ne("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(--md-sys-color-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"}),ne("markdown",{render(s,t,e){let i=e.firstElementChild;(!i||i.tagName!=="SPAN")&&(e.replaceChildren(),i=e.appendChild(document.createElement("span"))),i.innerHTML=wr(String(s??"")),e.title=i.textContent},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ne("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"}),ne("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 CC(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):CC(s,t.key)}function Ch(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
184
+ `)?'"'+t.replace(/"/g,'""')+'"':t}var Nr=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.#p(t)&&!this.#r.has(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;rowExpandable=null;#p(t){return this.expandable?typeof this.rowExpandable=="function"?!!this.rowExpandable(this.#e[t],t):!0:!1}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()}}#m(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#g(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){this.#O(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#g(),this.#h||(this.#h=!0,this.addEventListener("click",this.#D),this.addEventListener("keydown",this.#B),this.addEventListener("pointerdown",this.#T))}disconnected(){this.removeEventListener("click",this.#D),this.removeEventListener("keydown",this.#B),this.removeEventListener("pointerdown",this.#T),this.#h=!1,this.#V(),this.#y&&(cancelAnimationFrame(this.#y),this.#y=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}#O(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let 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)}#y=null;#b(){!this.isConnected||this.#y||(this.#y=requestAnimationFrame(()=>{this.#y=null,this.render(),this.#m()}))}get#x(){return this.#t.filter(t=>!t.hidden)}#v(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#x)this.#l.has(e.key)?t.push(`${this.#l.get(e.key)}px`):e.width?t.push(`${e.width}px`):e.flex?t.push(`minmax(6rem, ${e.flex}fr)`):t.push("minmax(6rem, 1fr)");return t.join(" ")}#S(){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.#x.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=Bi[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Ud[d]||Ud.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#k(){if(!this.paginate||this.paginate<=0)return 1;let t=this.#S().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#x;this.style.gridTemplateColumns=this.#v();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#A(e,t),this.#R();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.#S(),n=this.#w(r),o=[];for(let c of n){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#E(c,t);if(u&&this.#C(u,c,t),this.#p(c)&&this.#r.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded"),o.push(d),this.#p(c)&&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.#M(i),this.#$(i,r,t);let l=this.paginate>0&&this.#e.length>0,h=this.querySelector(":scope > [data-footer]");l?(h||(h=document.createElement("div"),h.setAttribute("data-footer",""),this.appendChild(h)),this.#Q(h,r.length)):h&&h.remove()}#A(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.#I(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])}#E(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#C(i,t,e),i}#C(t,e,i){let r=this.#e[e],n=this.#o.has(e);t.dataset.index=e,n?(t.setAttribute("data-selected",""),t.setAttribute("aria-selected","true")):(t.removeAttribute("data-selected"),t.removeAttribute("aria-selected"));let o=[];if(this.expandable){let a=document.createElement("div");if(a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col",""),this.#p(e)){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=Bi[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=Bi[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])}#M(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.#x,n=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+r.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<n;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let r=document.createElement("icon-ui");r.setAttribute("name","table");let n=document.createElement("span");n.textContent="No data",e.appendChild(r),e.appendChild(n),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#$(t,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=Bi[a.type||"text"];typeof c=="number"&&u?.render?u.render(c,{},l,a.meta):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}for(;n.children.length>o.length;)n.lastChild.remove();for(let a=0;a<o.length;a++)n.children[a]?n.replaceChild(o[a],n.children[a]):n.appendChild(o[a])}#Q(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",n=>{this.#a=n.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))}),t.appendChild(i));let r=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#a+1)),i.setAttribute("total",String(r))}#I(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}#R(){let t=this.querySelector(":scope > [data-filter-bar]");if(this.#s.size===0){t&&t.remove();return}if(!t){t=document.createElement("div"),t.setAttribute("data-filter-bar",""),t.setAttribute("role","status");let i=this.querySelector(":scope > [data-header]");i?i.after(t):this.prepend(t)}t.innerHTML="";for(let[i,{op:r,value:n}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=r==="select"?`${n.split(",").length} selected`:n;l.setAttribute("text",`${a}: ${h}`),l.setAttribute("size","xs"),l.setAttribute("data-filter-chip",i);let c=document.createElement("button");c.textContent="\xD7",c.setAttribute("data-chip-dismiss",""),c.addEventListener("click",u=>{u.stopPropagation(),this.setFilter(i,null)}),l.appendChild(c),t.appendChild(l)}let e=document.createElement("button");e.textContent="Clear all",e.setAttribute("data-filter-clear-all",""),e.addEventListener("click",()=>this.clearFilters()),t.appendChild(e)}#T=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.#N(t,e))};#D=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.#N(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}}))}}};#P=null;#N(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.#P={key:i,col:r,startX:a,startWidth:o},document.addEventListener("pointermove",this.#Z),document.addEventListener("pointerup",this.#L)}#Z=t=>{if(!this.#P)return;let{key:e,col:i,startX:r,startWidth:n}=this.#P,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.#v()};#L=t=>{if(!this.#P)return;let{key:e}=this.#P;document.removeEventListener("pointermove",this.#Z),document.removeEventListener("pointerup",this.#L),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#P=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#V(){document.removeEventListener("pointermove",this.#Z),document.removeEventListener("pointerup",this.#L),this.#P=null}#B=t=>{let i=this.#x.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.#X())};#X(){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.#x,i=this.#S(),r=e.map(c=>Ch(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 Ch(d.format(f,u));let p=Bi[d.type||"text"];return p?.format?Ch(p.format(f,u,d.meta)):Ch(f)})}),o=[r.join(","),...n.map(c=>c.join(","))].join(`
185
185
  `),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",Nr);C();var $C=200;function Yd(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 Hd(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 PC=50,cy=500;function uy(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 QC(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 TC(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(QC(s?.key))return"text";let e=[],i=Math.min(t?.length??0,cy),r=new Set;for(let n=0;n<i;n++){let o=uy(t[n],s);if(!(o==null||o==="")&&(e.push(o),r.add(String(o)),r.size>PC))return"text"}return e.length?"select":"text"}function LC(s,t){let e=new Set,i=Math.min(t?.length??0,cy);for(let r=0;r<i;r++){let n=uy(t[r],s);n==null||n===""||e.add(String(n))}return[...e].sort((r,n)=>r.localeCompare(n,void 0,{numeric:!0}))}var Br=class s extends x{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#r=null;#n=new Set;static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){this.setAttribute("role","toolbar"),this.#a(),this.#h(),this.#o(),this.#g()}disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null);for(let t of this.#n)cancelAnimationFrame(t);this.#n.clear(),this.#y(),this.#c()}render(){this.#o(),this.#g(),this.#f()}#a(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let r=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(r)||s._OPT_OUT_PREFIX_RE.test(r)&&t.push(r)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#o(){let t=this.#l();if(t===this.#t||(this.#c(),!t))return;this.#t=t;let e=()=>this.#k(),i=()=>this.#S();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#l(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#c(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#h(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-title","");let i=document.createElement("span");i.setAttribute("data-heading",""),e.appendChild(i);let r=document.createElement("badge-ui");r.setAttribute("data-count-badge",""),r.setAttribute("size","sm"),r.setAttribute("variant","muted"),r.hidden=!0,e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-controls",""),n.appendChild(this.#d("filter","Filter","funnel-simple")),n.appendChild(this.#d("sort","Sort","arrows-down-up")),n.appendChild(this.#d("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("size","sm"),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String($C)),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.#y();return}this.#y();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#v(i),t==="sort"&&this.#w(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.#b,!0),document.addEventListener("keydown",this.#x,!0))}))}#y(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#b,!0),document.removeEventListener("keydown",this.#x,!0))}}#b=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#y())};#x=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Yd("No filterable columns"));return}let i=e.filters||{};t.appendChild(Hd("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=TC(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=LC(o,n);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";d?e.setFilter(o.key,d,"select"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size","sm"),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;u?e.setFilter(o.key,u,"contains"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}r.appendChild(a)}if(t.appendChild(r),Object.keys(i).length){let o=this.#u("Clear all filters",()=>{e.clearFilters(),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#S()});t.appendChild(o)}}#S(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#w(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Yd("No sortable columns"));return}t.appendChild(Hd("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.#w(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Yd("No columns"));return}t.appendChild(Hd("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",Br);C();var Zr=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(){nt(this,"label").length||(this.innerHTML=`
186
186
  <span slot="label"></span>
187
187
  <span slot="description"></span>
@@ -189,13 +189,13 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
189
189
  `)}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",Zr),S("timeline-item-ui",zr);C();var _r=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))}},jr=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=`
190
190
  <span slot="label"></span>
191
191
  <span slot="description"></span>
192
- `)}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",_r),S("stepper-item-ui",jr);C();var Vr=class extends x{static properties={autoplay:{type:Boolean,default:!1,reflect:!0},interval:{type:Number,default:5e3,reflect:!0},noPauseOnHover:{type:Boolean,default:!1,reflect:!0,attribute:"no-pause-on-hover"},loop:{type:Boolean,default:!1,reflect:!0},peek:{type:Boolean,default:!1,reflect:!0},snap:{type:String,default:"start",reflect:!0},gap:{type:String,default:"",reflect:!0},slidesPerView:{type:String,default:"",reflect:!0,attribute:"slides-per-view"},chrome:{type:String,default:"default",reflect:!0},label:{type:String,default:""},counter:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=0;#n=!1;#a=!1;#o=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#r}connected(){if(!this.#t){for(this.#t=document.createElement("div"),this.#t.setAttribute("data-swiper-track","");this.firstChild;)this.#t.appendChild(this.firstChild);this.appendChild(this.#t)}this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.getAttribute("aria-label")||this.setAttribute("aria-label","Carousel"),this.#l(),this.#c(),this.#g(),this.#n||(this.#n=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#S),this.addEventListener("pointerleave",this.#w),this.addEventListener("focusin",this.#k),this.addEventListener("focusout",this.#A)),this.addEventListener("keydown",this.#E),this.#t.addEventListener("pointerdown",this.#R),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.#S),this.removeEventListener("pointerleave",this.#w),this.removeEventListener("focusin",this.#k),this.removeEventListener("focusout",this.#A),this.removeEventListener("keydown",this.#E),this.#t&&(this.#t.removeEventListener("pointerdown",this.#R),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.#y():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)}#y(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let r=document.createElement("button-ui");r.setAttribute("icon","caret-left"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Previous slide"),r.addEventListener("press",()=>this.prev());let n=document.createElement("button-ui");n.setAttribute("icon","caret-right"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Next slide"),n.addEventListener("press",()=>this.next()),i.appendChild(r),i.appendChild(n),t.appendChild(i),this.insertBefore(t,this.#t);let o=document.createElement("div");o.setAttribute("data-swiper-foot","");let a=document.createElement("span");a.setAttribute("data-swiper-counter",""),o.appendChild(a);let l=document.createElement("div");l.setAttribute("data-swiper-dots",""),l.setAttribute("role","tablist"),l.setAttribute("aria-label","Slide indicators"),o.appendChild(l),this.appendChild(o),this.#b()}#b(){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.#b()}#S=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#w=()=>{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;#R=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",Vr);var Wr=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=`
192
+ `)}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",_r),S("stepper-item-ui",jr);C();var Vr=class extends x{static properties={autoplay:{type:Boolean,default:!1,reflect:!0},interval:{type:Number,default:5e3,reflect:!0},noPauseOnHover:{type:Boolean,default:!1,reflect:!0,attribute:"no-pause-on-hover"},loop:{type:Boolean,default:!1,reflect:!0},peek:{type:Boolean,default:!1,reflect:!0},snap:{type:String,default:"start",reflect:!0},gap:{type:String,default:"",reflect:!0},slidesPerView:{type:String,default:"",reflect:!0,attribute:"slides-per-view"},chrome:{type:String,default:"default",reflect:!0},label:{type:String,default:""},counter:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=0;#n=!1;#a=!1;#o=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#r}connected(){if(!this.#t){for(this.#t=document.createElement("div"),this.#t.setAttribute("data-swiper-track","");this.firstChild;)this.#t.appendChild(this.firstChild);this.appendChild(this.#t)}this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.getAttribute("aria-label")||this.setAttribute("aria-label","Carousel"),this.#l(),this.#c(),this.#g(),this.#n||(this.#n=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#S),this.addEventListener("pointerleave",this.#w),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.#$),this.#t.addEventListener("pointerup",this.#Q),this.#t.addEventListener("pointercancel",this.#Q),this.#t.addEventListener("click",this.#I,!0),this.#t.addEventListener("dragstart",this.#R)),this.autoplay&&this.play()}render(){if(this.gap&&this.#t){let e=/^[0-9]+$/.test(this.gap)?`var(--a-space-${this.gap})`:this.gap;this.style.setProperty("--swiper-gap",e)}}disconnected(){this.pause(),this.#i?.disconnect(),this.#i=null,this.#t&&this.#s&&this.#t.removeEventListener("scroll",this.#s),this.#s=null,this.removeEventListener("pointerenter",this.#S),this.removeEventListener("pointerleave",this.#w),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.#$),this.#t.removeEventListener("pointerup",this.#Q),this.#t.removeEventListener("pointercancel",this.#Q),this.#t.removeEventListener("click",this.#I,!0),this.#t.removeEventListener("dragstart",this.#R)),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.#y():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)}#y(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let r=document.createElement("button-ui");r.setAttribute("icon","caret-left"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Previous slide"),r.addEventListener("press",()=>this.prev());let n=document.createElement("button-ui");n.setAttribute("icon","caret-right"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Next slide"),n.addEventListener("press",()=>this.next()),i.appendChild(r),i.appendChild(n),t.appendChild(i),this.insertBefore(t,this.#t);let o=document.createElement("div");o.setAttribute("data-swiper-foot","");let a=document.createElement("span");a.setAttribute("data-swiper-counter",""),o.appendChild(a);let l=document.createElement("div");l.setAttribute("data-swiper-dots",""),l.setAttribute("role","tablist"),l.setAttribute("aria-label","Slide indicators"),o.appendChild(l),this.appendChild(o),this.#b()}#b(){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.#b()}#S=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#w=()=>{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())};#C=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","")))};#$=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=t.clientX-this.#o.startX;if(Math.abs(e)>=this.#C){if(!this.#o.hasMoved){this.#o.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#o.startScrollLeft-e,t.preventDefault()}};#Q=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=this.#o.hasMoved;if(e)try{this.#t.releasePointerCapture(t.pointerId)}catch{}this.#o=null,this.#t.style.scrollBehavior="",this.#t.removeAttribute("data-dragging"),e&&(this.#t.setAttribute("data-just-dragged",""),requestAnimationFrame(()=>this.#t?.removeAttribute("data-just-dragged")))};#I=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#R=t=>{this.#o&&t.preventDefault()}};S("swiper-ui",Vr);var Wr=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=`
193
193
  <div data-dropzone tabindex="0" role="button">Drop files here or click to browse</div>
194
194
  <span hint="${this.hint||""}"></span>
195
195
  <div data-filelist></div>
196
196
  `),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",Wr);Nd();var Fr=GO({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(Fr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Fr),this.#t=!0)}};S("card-ui",Ur);C();var Yr=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}},Hr=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",Yr),S("avatar-group-ui",Hr);C();var Gr=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",Gr);C();var Kr=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"),!nt(this,"caption").length&&!nt(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=nt(this,"caption")[0],this.#e=nt(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",Kr);C();var Jr=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",Jr);C();var tn=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",tn);C();var en=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",en);C();var dy=new Set;function fy(s,t){dy.has(s)||(dy.add(s),console.warn(`[alert-ui] ${t}`))}var sn=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"&&(fy("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")&&(fy("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",sn);C();var MC={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},rn=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||MC[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",rn);C();var nn=class extends x{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};S("kbd-ui",nn);C();var on=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",on);C();var RC=new Set(["block","dot","square","line","dashed"]),IC=new Set(["sm","md","lg"]),DC=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"},XC={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function NC(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&DC.has(t)):[]}var cs=null;function BC(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 an=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.#y(),this.#b(),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=RC.has(this.shape)?this.shape:"square",e=IC.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=NC(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",XC[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=BC(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)}#y(){if(!this.#r)return;if(!this.copyable){this.#r.setAttribute("hidden","");return}this.#r.removeAttribute("hidden");let t=this.#S();t?this.#r.setAttribute("aria-label",`Copy ${t}`):this.#r.setAttribute("aria-label","Copy value")}#b(){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.#S();e&&this.#w(e)},this.#r.addEventListener("click",this.#c)}#v(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#S(){return this.copyValue?this.copyValue:this.color?this.color:""}async#w(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",an);$t();var py={xs:0,sm:480,md:768,lg:1024,xl:1280},us=Object.keys(py),Gd=Object.values(py);function my(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=us.length-1;t>=0;t--)if(s>=Gd[t])return us[t];return"xs"}var $e=Ni(my());if(typeof window<"u")for(let s=1;s<Gd.length;s++)window.matchMedia(`(min-width: ${Gd[s]}px)`).addEventListener("change",()=>{$e.value=my()});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 ln=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",_C(Bt(t,n))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Bt(e,n);this.style.setProperty("--col-align",jC(o)),this.style.textAlign=VC(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",WC(Bt(i,n))):this.style.removeProperty("--col-justify")}},ZC={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 _C(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function jC(s){return ZC[s]??s}function VC(s){return{start:"start",center:"center",end:"end"}[s]??""}function WC(s){return zC[s]??s}S("col-ui",ln);C();var hn=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.#y(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.#S("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.#S("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.#y(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"]);#y(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#b=0;static#x(){return`field-ctl-${++s.#b}`}static#v=0;static#S(t){return`field-${t}-${++s.#v}`}};S("field-ui",hn);C();var cn=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",cn);C();var gy=0,Ma=class extends x{static properties={label:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},hint:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=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.insertBefore(this.#t,this.firstChild)),this.#t.id||(this.#t.id=`display-field-label-${++gy}`),this.#e=this.querySelector(':scope > [slot="value"]'),this.#i=this.querySelector(':scope > [slot="hint"]'),this.#s=this.querySelector(':scope > icon-ui[slot="icon"]')}render(){if(!this.#t)return;this.label?(this.#t.textContent=this.label,this.#t.hidden=!1,this.setAttribute("aria-labelledby",this.#t.id)):(this.#t.hidden=!0,this.removeAttribute("aria-labelledby")),this.querySelector(":scope > :not([slot])")?this.#e&&(this.#e.remove(),this.#e=null):(this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","value"),this.appendChild(this.#e)),this.#e.textContent=this.value),this.hint?(this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","hint"),this.#i.id=`display-field-hint-${++gy}`,this.appendChild(this.#i)),this.#i.textContent=this.hint,this.setAttribute("aria-describedby",this.#i.id)):this.#i&&(this.#i.remove(),this.#i=null,this.removeAttribute("aria-describedby")),this.icon?(this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.#s.setAttribute("aria-hidden","true"),this.appendChild(this.#s)),this.#s.setAttribute("name",this.icon)):this.#s&&(this.#s.remove(),this.#s=null)}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};S("display-field-ui",Ma);C();var un=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(Fr),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Fr),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",YC(Bt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",HC(Bt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",GC(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=""}},FC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},UC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function YC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function HC(s){return FC[s]??s}function GC(s){return UC[s]??s}S("row-ui",un);C();var dn=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",dn);C();var fn=class extends x{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};S("stack-ui",fn);C();var pn=class extends x{static properties={};static template=()=>null};S("frame-ui",pn);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 by(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 oe(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="${oe(String(s))}"`),t!=null&&(r+=` data-tip-value="${t}"`),e!=null&&(r+=` data-tip-pct="${e}"`),i!=null&&(r+=` data-tip-series="${oe(String(i))}"`),r}function ae(s,t,e){return s+t*Math.cos(e)}function le(s,t,e){return s+t*Math.sin(e)}function KC(s,t,e,i,r){let n=ae(s,e,i),o=le(t,e,i),a=ae(s,e,r),l=le(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 Kd(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=ae(s,e,r),at=le(t,e,r),Ot=ae(s,e,n),St=le(t,e,n),yt=ae(s,i,n),Ct=le(t,i,n),Lt=ae(s,i,r),Yt=le(t,i,r),os=l>Math.PI?1:0;return`M ${dt} ${at} A ${e} ${e} 0 ${os} 1 ${Ot} ${St} L ${yt} ${Ct} A ${i} ${i} 0 ${os} 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=ae(s,e,f),v=le(t,e,f),w=ae(s,e,p),k=le(t,e,p),E=ae(s,i,b),A=le(t,i,b),$=ae(s,i,m),T=le(t,i,m),Q=ae(s,e-h,r),D=le(t,e-h,r),R=ae(s,i+h,r),_=le(t,i+h,r),V=ae(s,e-h,n),F=le(t,e-h,n),J=ae(s,i+h,n),rt=le(t,i+h,n);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${w} ${k} A ${h} ${h} 0 0 1 ${V} ${F} 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 Ra(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 Jd(s,t,e=.4){let i=Ra(s,e),r=s[s.length-1],n=s[0];return`${i} L${r.x},${t} L${n.x},${t} Z`}function $h(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 JC={std:{ratio:4/3}},mn=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.
197
197
  Correct shape for <chart-ui x="label" y="value">:
198
- [{ 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.#I),this.addEventListener("pointermove",this.#T),this.addEventListener("pointerleave",this.#X),this.addEventListener("pointerdown",this.#q),this.addEventListener("click",this.#j),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=JC.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.#F());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.#y()){let o=this.#ft();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#p(){let t=this.#N();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#m(t,e){return e?` data-slice="${t}" data-series-key="${oe(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g(t,e){return e?` data-slice="${t}" data-series-key="${oe(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.#M),this.removeEventListener("keydown",this.#Q),this.removeEventListener("focus",this.#P),this.removeEventListener("blur",this.#D),this.removeEventListener("pointerover",this.#I),this.removeEventListener("pointermove",this.#T),this.removeEventListener("pointerleave",this.#X),this.removeEventListener("pointerdown",this.#q),this.removeEventListener("click",this.#j),this.#W()}#y(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#b(){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)}#S(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let r=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),`${r||"$"}${by(e)}`}default:return by(e)}}#w=-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.#w=Math.max(0,Math.min(t,e.length-1)),this.#E(),this.#R()}#E(){let t=this.#k();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#w];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#$(){this.#w=-1;for(let t of this.#k())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#R(){let t=this.#k()[this.#w];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#Z(t,i)}#C(){let t=this.#k()[this.#w];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.#_(t,i)}))}#P=()=>{this.#w===-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.#w+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#A(Math.max(0,this.#w-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;#I=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#Y(e,t),this.#Z(e,t))};#T=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.#Z(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.#Z(e,t),document.addEventListener("pointerdown",this.#M)};#M=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#W(),this.#L&&this.#B(),document.removeEventListener("pointerdown",this.#M)))};#j=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#_(e,t)}))};#Z(t,e){this.#L=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#_(t,e)}))}#B(){this.#L=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#_(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.#b())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">${oe(o)}</span>`),i&&a.push(`<span data-tip-role="label">${oe(i)}</span>`),r!==void 0){let b=n!==void 0?` <span data-tip-role="pct">(${n}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#S(r)}${b}</span>`)}this.#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):[]}#U(t,e,i,r,n,o){let a=n,l=o?.fontSize||10,h=o?.labelSize||l,c="",u=i;if(o?.sizeClass==="sm"&&i.length>4&&(u=i.filter((d,f)=>f%2===0||f===i.length-1)),!this.hideGrid){let f=i[i.length-1]-i[0]||1;for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<line data-grid x1="${a.left}" y1="${m}" x2="${t-a.right}" y2="${m}"/>`}for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<text data-y-label x="${a.left-4}" y="${m+l*.35}" text-anchor="end" font-size="${l}">${this.#S(p)}</text>`}if(r){let m=(t-a.left-a.right)/r.length,g=r.reduce((w,k)=>Math.max(w,String(k).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=r.length-1;for(let w=0;w<r.length;w++){if(w%y!==0&&w!==v||w!==v&&v-w<y)continue;let k=a.left+m*w+m/2;c+=`<text data-x-label x="${k}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${oe(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.#U(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="${$h(E,A,p,k,this.#o())}"/>`,g&&(b+=`<text data-value x="${E+p/2}" y="${A-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#S(w)}</text>`)}if(y){let v=r.reduce((k,E)=>k+E,0)/r.length,w=c.top+u-(a?v/a*u:0);b+=`<line data-avg x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}"/>`,b+=`<text data-avg-label x="${l-c.right+2}" y="${w+3}" text-anchor="start" font-size="${t.valueSize}">${this.#S(v)}</text>`,b+=`<line data-hit${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.#U(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="${Jd(m,b,g)}"/>`,p+=`<path data-line d="${Ra(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.#S(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.#S(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="${KC(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="${Kd(h,c,u,d,p,v,this.#o())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),b=Math.max(9,Math.round(u*.16));return f+=`<text data-donut-total x="${h}" y="${c}" text-anchor="middle" dominant-baseline="central" font-size="${m}">${this.#S(r)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${b}">Total</text>`,this.#z=t.map((g,y)=>({label:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#et(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(k=>+(k[e]??0)),r=t.map(k=>k[this.x]??""),n=Math.max(...i)||1,o=t.length,a=this.#u(),{width:l,height:h,fontSize:c}=a,u=l/2,d=h/2,f=c*3.5,p=Math.max(40,Math.min(l,h)/2-f),m="",b=Math.PI*2/o;for(let k=1;k<=3;k++){let E=p*k/3,A="";for(let $=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}">${oe(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="${Jd(p,c,m)}"/>`,b+=`<path data-line d="${Ra(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.#U(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}`}}#F(){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="${Kd(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="${Kd(u,d,f,p,Math.PI,w,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return b+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#S(n)}</text>`,o!==n&&(b+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#S(o)}</text>`),{svg:b,viewBox:`0 0 ${h} ${c}`}}#nt(){let t=this.#t,e=this.#N()[0]||this.y,i=t.map(v=>+(v[e]??0)),r=t.map(v=>v[this.x]??""),n=i.length;if(n===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#u(),{width:l,height:h}=a,c=a.fontSize,u=Math.max(l*.18,80),d=c*.8,f=l-u*2,m=(h-d*2)/n,b=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<n;v++){let w=i[v],k=v<n-1?i[v+1]:i[v],E=w/o*(f/2),A=k/o*(f/2),$=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}">${oe(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.#S(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),F=D*D,J=R*R;return Math.max(F*_/J,J/(F*V))},E=(Q,D,R,_,V,F)=>{let J=Q.reduce((St,yt)=>St+yt,0),rt=V>=F,dt=rt?J/V:F,at=rt?V:J/F,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*F;d.push({i:Ct,x:R,y:_+Ot,w:at,h:Lt}),Ot+=Lt}}return rt?{x:R,y:_+dt,w:V,h:F-dt}:{x:R+at,y:_,w:V-at,h:F}},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,F=V&&Q.h>h*2.5,J=V&&!F&&Q.h>h*1.2;if(F)$+=`<text data-treemap-label x="${_}" y="${Q.y+h+4}" font-size="${h}" dominant-baseline="hanging">${oe(r[Q.i])}</text>`,$+=`<text data-treemap-value x="${_}" y="${Q.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#S(i[Q.i])}</text>`;else if(J){let rt=Q.y+Q.h/2;$+=`<text data-treemap-label x="${_}" y="${rt}" font-size="${h}" dominant-baseline="central">${oe(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}">${oe(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}">${oe(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,F=n-h,J=(V+F)/2,rt=wt({label:`${k.name} \u2192 ${E.name}`,value:A}),dt=`M ${V} ${Q} C ${J} ${Q}, ${J} ${R}, ${F} ${R} L ${F} ${_} 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.#U(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="${$h(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="${Ra(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>${oe(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.#U(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="${$h(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.#U(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="${$h(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.#S(k)}</text>`)}return this.#z=e.map((v,w)=>({label:v,key:v,slot:w%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#dt(){let t=this.#t,e=this.#N(),i=t.map(m=>m[this.x]??""),r=t.flatMap(m=>e.map(b=>+(m[b]??0))),n=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.#U(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="${Jd(g,y,v)}"/>`,p+=`<path data-line${this.#g(m%10,e[m])} d="${Ra(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",mn);C();var gn=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",gn);C();var t$=120,bn=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},t$)};#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",bn);C();var On=class extends x{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0},variant:{type:String,default:"flat",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)}},yn=class extends x{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},variant:{type:String,default:"flat",reflect:!0}};static template=()=>null;#t=!1;connected(){let t=this.querySelector('[slot="header"]');if(t){if(!t.querySelector('[slot="caret"]')){let e=document.createElement("icon-ui");e.setAttribute("name","caret-down"),e.setAttribute("slot","caret"),t.appendChild(e)}}else{let e=document.createElement("div");e.setAttribute("slot","header"),e.setAttribute("tabindex","0"),e.setAttribute("role","button"),e.setAttribute("aria-expanded","false"),e.dataset.autofocusable="";let i=document.createElement("span");i.setAttribute("slot","header-text"),i.dataset.autolabel="",e.appendChild(i);let r=document.createElement("icon-ui");r.setAttribute("name","caret-down"),r.setAttribute("slot","caret"),e.appendChild(r),this.prepend(e)}if(!this.querySelector('[slot="body"]')){let e=document.createElement("div");e.setAttribute("slot","body");let i=[...this.childNodes].filter(r=>r.nodeType===1?!r.hasAttribute("slot"):r.nodeType===3&&r.textContent.trim());for(let r of i)e.appendChild(r);this.appendChild(e)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i))}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"][data-autolabel]');t&&(t.textContent=this.text);let e=this.querySelector('[slot="header"][data-autofocusable]');e&&e.setAttribute("aria-expanded",String(this.open))}#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}})))};#i=t=>{let e=this.querySelector('[slot="header"][data-autofocusable]');!e||t.target!==e||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),e.click())}};S("accordion-ui",On),S("accordion-item-ui",yn);C();var vn=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",vn);C();var xn=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",xn);C();var tf=[{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}],Sn=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=tf.find(o=>i<=o.limit)||tf[tf.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",Sn);C();var wn=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",wn);C();var ef=["Weak","Fair","Good","Strong"];function e$(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 kn=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=`
198
+ [{ 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.#R),this.addEventListener("focus",this.#Q),this.addEventListener("blur",this.#I),this.addEventListener("pointerover",this.#D),this.addEventListener("pointermove",this.#P),this.addEventListener("pointerleave",this.#N),this.addEventListener("pointerdown",this.#Z),this.addEventListener("click",this.#V),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=JC.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.#F());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.#y()){let o=this.#ft();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#p(){let t=this.#q();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="${oe(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g(t,e){return e?` data-slice="${t}" data-series-key="${oe(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.#L),this.removeEventListener("keydown",this.#R),this.removeEventListener("focus",this.#Q),this.removeEventListener("blur",this.#I),this.removeEventListener("pointerover",this.#D),this.removeEventListener("pointermove",this.#P),this.removeEventListener("pointerleave",this.#N),this.removeEventListener("pointerdown",this.#Z),this.removeEventListener("click",this.#V),this.#z()}#y(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#b(){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)}#S(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let r=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),`${r||"$"}${by(e)}`}default:return by(e)}}#w=-1;#k(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#A(t){let e=this.#k();if(!e.length){this.#C();return}this.#w=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.#w];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#C(){this.#w=-1;for(let t of this.#k())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#M(){let t=this.#k()[this.#w];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#B(t,i)}#$(){let t=this.#k()[this.#w];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.#W(t,i)}))}#Q=()=>{this.#w===-1&&this.#A(0)};#I=()=>{this.#C(),this.#T&&this.#X()};#R=t=>{let e=this.#k();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#A(this.#w+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#A(Math.max(0,this.#w-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.#$();break;case"Escape":t.preventDefault(),this.#C(),this.#T&&this.#X();break}};#T=null;#D=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#U(e,t),this.#B(e,t))};#P=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#T&&this.#X(),this.#z();this.#U(e,t),e!==this.#T&&this.#B(e,t)};#N=t=>{t&&t.pointerType==="touch"||(this.#z(),this.#T&&this.#X())};#Z=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#T&&this.#X(),this.#z();this.#U(e,t),e!==this.#T&&this.#B(e,t),document.addEventListener("pointerdown",this.#L)};#L=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#z(),this.#T&&this.#X(),document.removeEventListener("pointerdown",this.#L)))};#V=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#W(e,t)}))};#B(t,e){this.#T=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#W(t,e)}))}#X(){this.#T=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#W(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.#_(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}}#_(t,e){if(t==null)return null;let i=this.x,r=this.#q();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}})}#U(t,e){if(this.#b())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">${oe(o)}</span>`),i&&a.push(`<span data-tip-role="label">${oe(i)}</span>`),r!==void 0){let b=n!==void 0?` <span data-tip-role="pct">(${n}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#S(r)}${b}</span>`)}this.#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`}#z(){if(this.#O){try{this.#O.hidePopover()}catch{}this.#O.remove(),this.#O=null}}#q(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#Y(t,e,i,r,n,o){let a=n,l=o?.fontSize||10,h=o?.labelSize||l,c="",u=i;if(o?.sizeClass==="sm"&&i.length>4&&(u=i.filter((d,f)=>f%2===0||f===i.length-1)),!this.hideGrid){let f=i[i.length-1]-i[0]||1;for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<line data-grid x1="${a.left}" y1="${m}" x2="${t-a.right}" y2="${m}"/>`}for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<text data-y-label x="${a.left-4}" y="${m+l*.35}" text-anchor="end" font-size="${l}">${this.#S(p)}</text>`}if(r){let m=(t-a.left-a.right)/r.length,g=r.reduce((w,k)=>Math.max(w,String(k).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=r.length-1;for(let w=0;w<r.length;w++){if(w%y!==0&&w!==v||w!==v&&v-w<y)continue;let k=a.left+m*w+m/2;c+=`<text data-x-label x="${k}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${oe(r[w])}</text>`}}}return c}#H(){let t=this.#u(),e=this.#t,i=this.#q()[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.#Y(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="${$h(E,A,p,k,this.#o())}"/>`,g&&(b+=`<text data-value x="${E+p/2}" y="${A-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#S(w)}</text>`)}if(y){let v=r.reduce((k,E)=>k+E,0)/r.length,w=c.top+u-(a?v/a*u:0);b+=`<line data-avg x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}"/>`,b+=`<text data-avg-label x="${l-c.right+2}" y="${w+3}" text-anchor="start" font-size="${t.valueSize}">${this.#S(v)}</text>`,b+=`<line data-hit${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.#q()[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.#Y(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="${Jd(m,b,g)}"/>`,p+=`<path data-line d="${Ra(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.#S(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.#S(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.#q()[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="${KC(h,c,u,f,b)}"/>`,f=b}return this.#j=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.#q()[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="${Kd(h,c,u,d,p,v,this.#o())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),b=Math.max(9,Math.round(u*.16));return f+=`<text data-donut-total x="${h}" y="${c}" text-anchor="middle" dominant-baseline="central" font-size="${m}">${this.#S(r)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${b}">Total</text>`,this.#j=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.#q()[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}">${oe(r[k])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#it(){let t=this.#t,e=this.#q()[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="${Jd(p,c,m)}"/>`,b+=`<path data-line d="${Ra(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.#q()[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.#Y(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.#q()[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.#j=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}`}}#F(){let t=this.#t,e=this.#q()[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="${Kd(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="${Kd(u,d,f,p,Math.PI,w,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return b+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#S(n)}</text>`,o!==n&&(b+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#S(o)}</text>`),{svg:b,viewBox:`0 0 ${h} ${c}`}}#nt(){let t=this.#t,e=this.#q()[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}">${oe(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.#S(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.#j=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.#q()[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),F=D*D,J=R*R;return Math.max(F*_/J,J/(F*V))},E=(Q,D,R,_,V,F)=>{let J=Q.reduce((St,yt)=>St+yt,0),rt=V>=F,dt=rt?J/V:F,at=rt?V:J/F,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*F;d.push({i:Ct,x:R,y:_+Ot,w:at,h:Lt}),Ot+=Lt}}return rt?{x:R,y:_+dt,w:V,h:F-dt}:{x:R+at,y:_,w:V-at,h:F}},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,F=V&&Q.h>h*2.5,J=V&&!F&&Q.h>h*1.2;if(F)$+=`<text data-treemap-label x="${_}" y="${Q.y+h+4}" font-size="${h}" dominant-baseline="hanging">${oe(r[Q.i])}</text>`,$+=`<text data-treemap-value x="${_}" y="${Q.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#S(i[Q.i])}</text>`;else if(J){let rt=Q.y+Q.h/2;$+=`<text data-treemap-label x="${_}" y="${rt}" font-size="${h}" dominant-baseline="central">${oe(r[Q.i])}</text>`}}return this.#j=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}">${oe(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}">${oe(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,F=n-h,J=(V+F)/2,rt=wt({label:`${k.name} \u2192 ${E.name}`,value:A}),dt=`M ${V} ${Q} C ${J} ${Q}, ${J} ${R}, ${F} ${R} L ${F} ${_} 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.#q(),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.#Y(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="${$h(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="${Ra(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.#j=[{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.#q()[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>${oe(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.#j=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.#q(),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.#Y(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="${$h(A,$,p,T,D)}"/>`:b+=`<rect${R} x="${A}" y="${$}" width="${p}" height="${T}"/>`}}return this.#j=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.#q(),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.#Y(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="${$h(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.#S(k)}</text>`)}return this.#j=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.#q(),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.#Y(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="${Jd(g,y,v)}"/>`,p+=`<path data-line${this.#g(m%10,e[m])} d="${Ra(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.#j=e.map((m,b)=>({label:m,key:m,slot:b%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#j=null;get legendData(){return this.#j?this.#j.map(t=>({...t})):null}#ft(){if(!this.#j||!this.#j.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#j){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",mn);C();var gn=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",gn);C();var t$=120,bn=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},t$)};#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",bn);C();var On=class extends x{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0},variant:{type:String,default:"flat",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)}},yn=class extends x{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},variant:{type:String,default:"flat",reflect:!0}};static template=()=>null;#t=!1;connected(){let t=this.querySelector('[slot="header"]');if(t){if(!t.querySelector('[slot="caret"]')){let e=document.createElement("icon-ui");e.setAttribute("name","caret-down"),e.setAttribute("slot","caret"),t.appendChild(e)}}else{let e=document.createElement("div");e.setAttribute("slot","header"),e.setAttribute("tabindex","0"),e.setAttribute("role","button"),e.setAttribute("aria-expanded","false"),e.dataset.autofocusable="";let i=document.createElement("span");i.setAttribute("slot","header-text"),i.dataset.autolabel="",e.appendChild(i);let r=document.createElement("icon-ui");r.setAttribute("name","caret-down"),r.setAttribute("slot","caret"),e.appendChild(r),this.prepend(e)}if(!this.querySelector('[slot="body"]')){let e=document.createElement("div");e.setAttribute("slot","body");let i=[...this.childNodes].filter(r=>r.nodeType===1?!r.hasAttribute("slot"):r.nodeType===3&&r.textContent.trim());for(let r of i)e.appendChild(r);this.appendChild(e)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i))}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"][data-autolabel]');t&&(t.textContent=this.text);let e=this.querySelector('[slot="header"][data-autofocusable]');e&&e.setAttribute("aria-expanded",String(this.open))}#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}})))};#i=t=>{let e=this.querySelector('[slot="header"][data-autofocusable]');!e||t.target!==e||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),e.click())}};S("accordion-ui",On),S("accordion-item-ui",yn);C();var vn=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",vn);C();var xn=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",xn);C();var tf=[{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}],Sn=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=tf.find(o=>i<=o.limit)||tf[tf.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",Sn);C();var wn=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",wn);C();var ef=["Weak","Fair","Good","Strong"];function e$(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 kn=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=`
199
199
  <div slot="bar" aria-hidden="true">
200
200
  <div slot="segment" data-i="0"></div>
201
201
  <div slot="segment" data-i="1"></div>
@@ -211,7 +211,7 @@ Correct shape for <chart-ui x="label" y="value">:
211
211
  `),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(`
212
212
  `):e}async#u(){if(this.#r||this.#i)return;let t=this.#s,e=jb(this.language);this.#r=!0;try{let i=await Promise.resolve().then(()=>(_b(),zb)),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(()=>(_b(),zb));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??"")}#y(){let t=this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??"";t&&navigator.clipboard.writeText(t).then(()=>{let e=this.querySelector(':scope > header [slot="copy"]');if(!e)return;let i=e.textContent;e.textContent="Copied!",this.#e!=null&&clearTimeout(this.#e),this.#e=setTimeout(()=>{this.#e=null,e.textContent=i},1500)})}render(){let t=this.querySelector(':scope > header [slot="label"]');if(t&&this.language&&(t.textContent=this.language),this.#p(),!this.inline&&this.text!=="")if(this.#i){if(this.editable&&this.#i.hasFocus)return;let e=this.#i.state.doc.toString();e!==this.text&&this.#i.dispatch({changes:{from:0,to:e.length,insert:this.text}})}else{let e=this.querySelector(":scope > pre > code");e&&e.textContent!==this.text&&(e.textContent=this.text)}}};S("code-ui",co);C();function u1(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(`
213
213
  `);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(`
214
- `)}var uo=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=u1(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=u1(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",uo);C();var fo=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?.())}},po=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",fo),S("list-item-ui",po);C();var mo=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)};#y=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let r=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:r},bubbles:!0}))}else if(i==="bottom"){let r=this.items||[],n=this.#h>=0?this.#h:r.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:n},bubbles:!0}))}}};#b=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.#R(),this.#P())};connected(){this.setAttribute("role",this.getAttribute("role")||"list"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t=this.ensure("phantom"),this.#e=this.ensure("window"),this.#i=this.ensure("sentinelTop"),this.#s=this.ensure("sentinelBottom"),typeof IntersectionObserver<"u"&&(this.#p=new IntersectionObserver(this.#y,{root:this,rootMargin:"0px",threshold:0}),this.#p.observe(this.#i),this.#p.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#f=new ResizeObserver(this.#b)),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.#R(),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.#S(n),a=this.#k(),l=this.#v(n),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#E(Math.max(0,h),e)}scrollToTop(){this.#E(0)}scrollToBottom(){let t=this.#w();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.#R(),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)}#S(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}#w(){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.#w();return t+e>=i-1}#R(){if(!this.#t)return;let t=this.#w();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.#S(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.#I();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}#I(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#T==null&&(this.#T=t.innerHTML);let e=this.#T;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?"":lD(String(h))}),o=document.createElement("template");return o.innerHTML=n,o.content.cloneNode(!0)}}#T=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 lD(s){return s.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}S("list-window-ui",mo);C();var go=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.#y),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#a(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#n(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui, 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)};#y=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#y),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},bo=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()}},Oo=class extends x{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}},_l=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",go),S("menu-item-ui",bo),S("menu-divider-ui",Oo),S("menu-label-ui",_l);C();var d1=500,yo=class extends x{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:d1,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.#y(t,e)}}close(t="manual"){this.#b(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.#y(t.clientX,t.clientY))};#d=t=>{if(!this.#m())return;let e=t.touches[0];e&&(this.#r=setTimeout(()=>{this.#n=t.currentTarget,this.#y(e.clientX,e.clientY)},this.longPressMs??d1))};#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.#w),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}#y(t,e){let i=this.#g();i.replaceChildren();for(let o of[...this.children]){let a=o.tagName.toLowerCase();(a==="menu-item-ui"||a==="menu-divider-ui")&&i.appendChild(o.cloneNode(!0))}try{i.showPopover()}catch{}let r=this.#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}}))}#b(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.#S(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#v(){this.#a=t=>{this.#t?.contains(t.target)||this.#b("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#b("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#S(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#w=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.#b("select")}};S("context-menu-ui",yo);C();var vo=class extends x{static properties={};static template=()=>null};S("visually-hidden-ui",vo);C();var xo=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",xo);C();var So=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",So);var wo=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",wo);C();var ko=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=`
214
+ `)}var uo=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=u1(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=u1(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",uo);C();var fo=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?.())}},po=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",fo),S("list-item-ui",po);C();var mo=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.#Q();let t=this.#A();this.#u=t,this.#d=this.#C()};#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)};#y=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let r=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:r},bubbles:!0}))}else if(i==="bottom"){let r=this.items||[],n=this.#h>=0?this.#h:r.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:n},bubbles:!0}))}}};#b=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.#N(),this.#M(),this.#Q())};connected(){this.setAttribute("role",this.getAttribute("role")||"list"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t=this.ensure("phantom"),this.#e=this.ensure("window"),this.#i=this.ensure("sentinelTop"),this.#s=this.ensure("sentinelBottom"),typeof IntersectionObserver<"u"&&(this.#p=new IntersectionObserver(this.#y,{root:this,rootMargin:"0px",threshold:0}),this.#p.observe(this.#i),this.#p.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#f=new ResizeObserver(this.#b)),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.#C());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.#Q(),e&&this.scrollToBottom(),this.#d=this.#C()}set renderRow(t){this.#r=typeof t=="function"?t:null,this.#a.clear(),this.#Q()}get renderRow(){return this.#r}set keyFn(t){this.#n=typeof t=="function"?t:((e,i)=>i),this.#a.clear(),this.#Q()}get keyFn(){return this.#n}scrollToIndex(t,{behavior:e="auto",align:i="start"}={}){let r=this.items||[];if(!r.length)return;let n=Math.max(0,Math.min(r.length-1,t|0)),o=this.#S(n),a=this.#k(),l=this.#v(n),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#E(Math.max(0,h),e)}scrollToTop(){this.#E(0)}scrollToBottom(){let t=this.#w();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.#Q()}#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)}#S(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}#w(){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})}#C(){let t=this.#A(),e=this.#k(),i=this.#w();return t+e>=i-1}#M(){if(!this.#t)return;let t=this.#w();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")}#$(){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}}#Q(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=t.length,{start:i,end:r}=this.#$(),n=this.#S(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${n}px)`:this.#e.style.transform=`translateY(${n}px)`,this.loading?this.#R(r-i):this.#I(t,i,r),(i!==this.#c||r!==this.#h)&&(this.#c=i,this.#h=r,this.dispatchEvent(new CustomEvent("range-change",{detail:{startIndex:i,endIndex:r,items:t.slice(i,r)},bubbles:!0})))}#I(t,e,i){if(!this.#e)return;let r=new Set,n=this.#r??this.#D();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.#T(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)}#R(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)}}#T(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}#D(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#P==null&&(this.#P=t.innerHTML);let e=this.#P;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?"":lD(String(h))}),o=document.createElement("template");return o.innerHTML=n,o.content.cloneNode(!0)}}#P=null;#N(){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 lD(s){return s.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}S("list-window-ui",mo);C();var go=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.#y),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#a(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#n(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui, 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)};#y=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#y),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},bo=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()}},Oo=class extends x{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}},_l=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",go),S("menu-item-ui",bo),S("menu-divider-ui",Oo),S("menu-label-ui",_l);C();var d1=500,yo=class extends x{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:d1,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.#y(t,e)}}close(t="manual"){this.#b(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.#y(t.clientX,t.clientY))};#d=t=>{if(!this.#m())return;let e=t.touches[0];e&&(this.#r=setTimeout(()=>{this.#n=t.currentTarget,this.#y(e.clientX,e.clientY)},this.longPressMs??d1))};#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.#w),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}#y(t,e){let i=this.#g();i.replaceChildren();for(let o of[...this.children]){let a=o.tagName.toLowerCase();(a==="menu-item-ui"||a==="menu-divider-ui")&&i.appendChild(o.cloneNode(!0))}try{i.showPopover()}catch{}let r=this.#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}}))}#b(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.#S(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#v(){this.#a=t=>{this.#t?.contains(t.target)||this.#b("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#b("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#S(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#w=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.#b("select")}};S("context-menu-ui",yo);C();var vo=class extends x{static properties={};static template=()=>null};S("visually-hidden-ui",vo);C();var xo=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",xo);C();var So=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",So);var wo=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",wo);C();var ko=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=`
215
215
  <div data-tour-header>
216
216
  <span data-tour-indicator>${h}</span>
217
217
  <span></span>
@@ -241,7 +241,7 @@ Correct shape for <chart-ui x="label" y="value">:
241
241
  placeholder="${this.placeholder}"
242
242
  ${this.disabled?"disabled":""}
243
243
  ${t?`size="${t}"`:""}
244
- ></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",Mo);$t();function Us(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function pD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var mD=0,Ro=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-${++mD}`;#g=()=>this.#q();#O=t=>this.#M(t);#y=()=>this.#j();#b=t=>this.#Z(t);#x=t=>this.#Y(t);#v=t=>this.#W(t);#S=t=>this.#tt(t);#w=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.#F()}disconnected(){super.disconnected(),this.#R(),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=nt(this,"prefix"),n=nt(this,"suffix"),o=nt(this,"empty"),a=nt(this,"loading"),l=nt(this,"footer");this.innerHTML=`
244
+ ></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",Mo);$t();function Us(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function pD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var mD=0,Ro=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-${++mD}`;#g=()=>this.#Z();#O=t=>this.#L(t);#y=()=>this.#V();#b=t=>this.#B(t);#x=t=>this.#U(t);#v=t=>this.#z(t);#S=t=>this.#tt(t);#w=t=>this.#et(t);#k=t=>this.#it(t);connected(){super.connected(),this.#t.length===0&&this.#$(),this.#e=this.value||"",this.#A(),this.#R(),this.#F()}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.#C();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,r=nt(this,"prefix"),n=nt(this,"suffix"),o=nt(this,"empty"),a=nt(this,"loading"),l=nt(this,"footer");this.innerHTML=`
245
245
  <span data-label id="${t}"${this.label?"":' style="display:none"'}>${Us(this.label||"")}</span>
246
246
  <div data-field>
247
247
  <span data-prefix></span>
@@ -268,24 +268,24 @@ Correct shape for <chart-ui x="label" y="value">:
268
268
  <div data-empty>No matches</div>
269
269
  <div data-footer></div>
270
270
  </div>
271
- `,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.#y),this.#n.addEventListener("blur",this.#b)),this.#u&&this.#u.addEventListener("click",this.#S),this.#d&&this.#d.addEventListener("click",this.#w)}#R(){this.#n&&(this.#n.removeEventListener("input",this.#g),this.#n.removeEventListener("keydown",this.#O),this.#n.removeEventListener("focus",this.#y),this.#n.removeEventListener("blur",this.#b)),this.#u&&this.#u.removeEventListener("click",this.#S),this.#d&&this.#d.removeEventListener("click",this.#w)}#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){U(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#Q(),this.#F()})}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.#I(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.#T(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`)}#I(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Us(e);let i=this.#i,r=new RegExp(pD(i),"i"),n=e.match(r);if(!n)return Us(e);let o=n.index??0,a=o+n[0].length;return Us(e.slice(0,o))+"<mark>"+Us(e.slice(o,a))+"</mark>"+Us(e.slice(a))}#T(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.#T(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()}}))}#M(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.#_(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#_(-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.#U();return}if(e==="Backspace"){let i=!(this.#n.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#j(){}#Z(t){!this.freeText&&this.#i&&!this.value&&(this.#F(),this.#i="")}#B(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#_(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.#F(),this.#i="",this.#Q()}#U(){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.#F(),this.#i="",this.#G("blur")}#H(t,e){if(this.readonly){this.#G("select");return}let i=this.#D(t);U(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#F(),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}U(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#F(),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){U(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#F(),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.#F(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#st(t){this.#F(),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"))}#F(){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",Ro);$t();var gD=0;function bD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Io=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:`,
272
- `,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.#_(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-${++gD}`;#u=()=>this.#A();#d=t=>this.#E(t);#f=t=>this.#$(t);#p=t=>this.#R(t);#m=t=>this.#C(t);#g=t=>this.#P(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#_(this.getAttribute("value"));t&&(this.#t=t)}this.#O(),this.#v(),this.#w(),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){U(()=>{let e=Array.isArray(t)?t.map(r=>String(r??"")):typeof t=="string"?this.#_(t)||[]:[],i=this.#t.slice();this.#t=e,this.#v(),this.#w(),this.#k(),this.#X(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){U(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#S(),this.render()})}get suggestions(){return this.#e.slice()}set validateFn(t){this.#i=typeof t=="function"?t:null}get validateFn(){return this.#i}addToken(t){return this.#Q(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#T(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#v(),this.#w(),this.#k(),this.#X(t,[],"programmatic")}focus(){this.#o?.focus()}#O(){if(this.querySelector(":scope > [data-chip-list]")){this.#y(),this.#b();return}let t=`${this.#h}-suggestions`,e=`${this.#h}-input`;this.innerHTML=`
271
+ `,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.#C()}#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]")}#C(){this.#n&&(this.#n.addEventListener("input",this.#g),this.#n.addEventListener("keydown",this.#O),this.#n.addEventListener("focus",this.#y),this.#n.addEventListener("blur",this.#b)),this.#u&&this.#u.addEventListener("click",this.#S),this.#d&&this.#d.addEventListener("click",this.#w)}#M(){this.#n&&(this.#n.removeEventListener("input",this.#g),this.#n.removeEventListener("keydown",this.#O),this.#n.removeEventListener("focus",this.#y),this.#n.removeEventListener("blur",this.#b)),this.#u&&this.#u.removeEventListener("click",this.#S),this.#d&&this.#d.removeEventListener("click",this.#w)}#$(){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){U(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#R(),this.#F()})}get options(){return this.#t}#Q(){let t=[];for(let e of this.#t)if(e&&Array.isArray(e.options))for(let i of e.options)t.push(i);else e&&t.push(e);return t}#I(t){return this.#Q().find(e=>e.value===t)||null}#R(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#Q(),i=this.#N(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.#D(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.#N(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.#P(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.#T(),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant")}#T(){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`)}#D(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Us(e);let i=this.#i,r=new RegExp(pD(i),"i"),n=e.match(r);if(!n)return Us(e);let o=n.index??0,a=o+n[0].length;return Us(e.slice(0,o))+"<mark>"+Us(e.slice(o,a))+"</mark>"+Us(e.slice(a))}#P(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)}}#N(t){return this.#i?t.filter(e=>this.#P(e)):t.slice()}#Z(){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.#R();let e=this.#X();this.#i&&e.length&&this.#_(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#L(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.#W(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#W(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#_(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#X();this.#_(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#q();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#st("escape"));return}if(e==="Tab"){this.#Y();return}if(e==="Backspace"){let i=!(this.#n.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#V(){}#B(t){!this.freeText&&this.#i&&!this.value&&(this.#F(),this.#i="")}#X(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#W(t){let e=this.#X();if(!e.length)return;if(this.#s<0){this.#_(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#_(i)}#_(t){let e=this.#X();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)}#U(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#H(i,"click")}#z(t){let e=t.currentTarget,r=this.#X().indexOf(e);r>=0&&this.#_(r)}#q(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#X(),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.#F(),this.#i="",this.#R()}#Y(){if(!this.open)return;let t=this.#X(),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.#I(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#K(i,"keyboard");return}this.#F(),this.#i="",this.#G("blur")}#H(t,e){if(this.readonly){this.#G("select");return}let i=this.#I(t);U(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#F(),this.#R(),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}U(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#F(),this.#R(),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){U(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#F(),this.#R(),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.#F(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#st(t){this.#F(),this.#i="",this.#R(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#rt(){if(!this.#o)return;this.#o.showPopover?.(),this.#T();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.#X();if(!e.length)return;let i=e.findIndex(r=>r.dataset.value===this.value);this.#_(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"))}#F(){if(!this.#n)return;let t=this.#I(this.value),e=t?t.label??t.value??"":this.value||"";(this.#n.textContent||"")!==e&&(this.#r=!0,this.#n.textContent=e,this.#r=!1),this.#n.toggleAttribute("data-empty",!e)}open$(){this.open=!0}close$(){this.open=!1}focus(){this.#n?.focus()}selectOption(t){return this.#I(t)?(this.#H(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};S("combobox-ui",Ro);$t();var gD=0;function bD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Io=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:`,
272
+ `,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.#z(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-${++gD}`;#u=()=>this.#M();#d=t=>this.#$(t);#f=t=>this.#Q(t);#p=t=>this.#I(t);#m=t=>this.#R(t);#g=t=>this.#T(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#z(this.getAttribute("value"));t&&(this.#t=t)}this.#O(),this.#v(),this.#E(),this.#C()}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){U(()=>{let e=Array.isArray(t)?t.map(r=>String(r??"")):typeof t=="string"?this.#z(t)||[]:[],i=this.#t.slice();this.#t=e,this.#v(),this.#E(),this.#C(),this.#V(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){U(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#A(),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.#P(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#L(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#v(),this.#E(),this.#C(),this.#V(t,[],"programmatic")}focus(){this.#o?.focus()}#O(){if(this.querySelector(":scope > [data-chip-list]")){this.#y(),this.#b();return}let t=this.querySelector(':scope > template[slot="chip"]'),e=`${this.#h}-suggestions`,i=`${this.#h}-input`;this.innerHTML=`
273
273
  <div data-chip-list role="list" aria-label="Tags"></div>
274
274
  <span data-inline-input
275
- id="${e}"
275
+ id="${i}"
276
276
  contenteditable="plaintext-only"
277
277
  role="searchbox"
278
278
  tabindex="0"
279
279
  spellcheck="false"
280
280
  aria-autocomplete="list"
281
- aria-controls="${t}"
281
+ aria-controls="${e}"
282
282
  data-placeholder="${this.placeholder||""}"
283
283
  data-empty></span>
284
284
  <span data-spinner hidden aria-hidden="true">
285
285
  <icon-ui name="circle-notch"></icon-ui>
286
286
  </span>
287
- <div data-suggestions id="${t}" role="listbox" hidden></div>
288
- `,this.#y(),this.#b()}#y(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#b(){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()}#S(){if(!this.#l)return;let t=this.#o?(this.#o.textContent||"").trim().toLowerCase():"",e=this.#e.filter(r=>!this.#t.includes(r)).filter(r=>!t||r.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((r,n)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${n}`),o.dataset.value=r,o.textContent=r,this.#l.appendChild(o)});let i=this.#e.length>0&&e.length>0&&this.hasAttribute("editing");this.#l.hidden=!i,this.toggleAttribute("suggesting",i),i?this.setAttribute("aria-expanded","true"):this.removeAttribute("aria-expanded"),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant");for(let r of this.#l.children)r.removeAttribute("data-active")}#w(){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.#j(),this.#w(),this.#S(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#w(),this.#S(),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.#T(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#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(`[${bD(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.#w(),this.#S();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.#j(),this.#w(),this.#S())}#R(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.#T(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.#j())}#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.#M(),!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.#M(),!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.#I(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.#I(t,i)}},()=>{r!==this.#n||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#q(t,"validator"))})}#I(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#M(),this.#w(),this.#k(),this.#X(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#T(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.#w(),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}}))}#M(){this.#o&&(this.#r=!0,this.#o.textContent="",this.#r=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#S())}#j(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#Z(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let r of e)r.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#o?.setAttribute("aria-activedescendant",i.id)}#B(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#_(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.#_(t);if(e){this.value=e;return}}super.syncValue(t)}};S("tags-input-ui",Io);C();var jl=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",jl);C();var Do=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",Do);C();var qo=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}}}},Xo=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",qo),S("action-item-ui",Xo);C();var No=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",No);C();var OD=["S","M","T","W","T","F","S"],yD=["January","February","March","April","May","June","July","August","September","October","November","December"];function b1(s){return String(s).padStart(2,"0")}function Vb(s,t,e){return`${s}-${b1(t+1)}-${b1(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 od(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Bo=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>
287
+ <div data-suggestions id="${e}" role="listbox" hidden></div>
288
+ `,t&&this.appendChild(t),this.#y(),this.#b()}#y(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#b(){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=this.querySelector(':scope > template[slot="chip"]'),e=t?"custom":"default",i=Array.from(this.#a.children);for(let r=0;r<this.#t.length;r++){let n=this.#t[r],o=i[r];if(o&&o.dataset.chipMode===e&&o.dataset.chipValue===n){o.setAttribute("data-index",String(r)),t||(this.readonly||this.disabled?o.removeAttribute("removable"):o.setAttribute("removable",""));continue}let l=t?this.#w(t,n,r):this.#S(n,r);o?this.#a.replaceChild(l,o):this.#a.appendChild(l),i[r]=l}for(let r=this.#t.length;r<i.length;r++)i[r].remove()}#S(t,e){let i=document.createElement("tag-ui");return i.setAttribute("role","listitem"),i.setAttribute("text",t),this.readonly||this.disabled||i.setAttribute("removable",""),i.setAttribute("data-index",String(e)),i.dataset.chipMode="default",i.dataset.chipValue=t,i}#w(t,e,i){let r=t.content.cloneNode(!0);this.#k(r,e,i);let n=r.firstElementChild;return n?(n.setAttribute("role","listitem"),n.setAttribute("data-index",String(i)),n.dataset.chipMode="custom",n.dataset.chipValue=e,n):this.#S(e,i)}#k(t,e,i){let r=String(i),n=l=>l.replace(/\{\{value\}\}|\{\{index\}\}/g,h=>h==="{{value}}"?e:r),o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),a;for(;a=o.nextNode();)if(a.nodeType===Node.TEXT_NODE)a.data.includes("{{")&&(a.data=n(a.data));else for(let l of a.attributes)l.value.includes("{{")&&(l.value=n(l.value))}#A(){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")}#E(){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)}#C(){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({})}#M(){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.#P(n,"delimiter")&&(r=!0);this.#r=!0,this.#o.textContent=i||"",this.#r=!1,this.#W(),this.#E(),this.#A(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#E(),this.#A(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#$(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.#P(r.dataset.value||"","suggestion");return}}i&&this.#P(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#L(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.#U())}#Q(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(`[${bD(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.#E(),this.#A();return}let n="";for(let o=0;o<r.length;o++){let a=r[o];!this.#P(a,"paste")&&o===r.length-1&&(n=a)}n&&(this.#r=!0,this.#o.textContent=n,this.#r=!1,this.#W(),this.#E(),this.#A())}#I(t){let e=t.target.closest("[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#L(i,"chip-click"))}#R(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.#W())}#T(t){let e=t.target.closest('[role="option"]');e&&this.#P(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}#P(t,e){if(this.disabled||this.readonly)return!1;let i=this.#D(t.trim());if(!i)return this.#X(),!1;if(i.length<this.minLength)return this.#B(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#B(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#X(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#B(i,"max"),!1;let r=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(r))return this.#B(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#N(i,o,e),!1;if(o===!1)return this.#B(i,"validator"),!1}catch{return this.#B(i,"validator"),!1}return this.#Z(i,e),!0}#N(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.#B(t,"validator");return}this.#Z(t,i)}},()=>{r!==this.#n||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#B(t,"validator"))})}#Z(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#X(),this.#E(),this.#C(),this.#V(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#L(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.#E(),this.#C(),this.#V(i,r,e),e!=="programmatic"&&this.#o?.focus()}#V(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}}))}#B(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#X(){this.#o&&(this.#r=!0,this.#o.textContent="",this.#r=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#A())}#W(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#_(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)}#U(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#z(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.#B(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#z(t);if(e){this.value=e;return}}super.syncValue(t)}};S("tags-input-ui",Io);C();var jl=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",jl);C();var Do=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",Do);C();var qo=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}}}},Xo=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",qo),S("action-item-ui",Xo);C();var No=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",No);C();var OD=["S","M","T","W","T","F","S"],yD=["January","February","March","April","May","June","July","August","September","October","November","December"];function b1(s){return String(s).padStart(2,"0")}function Vb(s,t,e){return`${s}-${b1(t+1)}-${b1(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 od(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Bo=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>
289
289
  <button data-cal-prev type="button" aria-label="Previous month" tabindex="-1"><icon-ui name="caret-left"></icon-ui></button>
290
290
  <span data-cal-title>${yD[e]} ${t}</span>
291
291
  <button data-cal-next type="button" aria-label="Next month" tabindex="-1"><icon-ui name="caret-right"></icon-ui></button>
@@ -317,7 +317,7 @@ Correct shape for <chart-ui x="label" y="value">:
317
317
  `}).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",ua);C();var da=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})=>`
318
318
  <dt data-dl-term>${this.#e(e)}</dt>
319
319
  <dd data-dl-desc>${this.#e(i)}</dd>
320
- `).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",da);C();var JD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],fa=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:JD[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",fa);C();var eE=new Set(["idle","active","done","error"]);function OO(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function tq(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var pa=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.#b(),e}updateStep(t,e){let i=this.#d(t);i&&(Object.assign(i,e),this.#b())}completeStep(t,e){let i=this.#d(t);i&&(i.status="done",e!=null&&(i.duration=e),this.#b())}failStep(t,e){let i=this.#d(t);i&&(i.status="error",e&&(i.outcomes=[...i.outcomes||[],String(e)]),this.#b())}addThought(t,e=`thought-${this.#t.length}`){this.#u({kind:"thought",id:e,text:t}),this.#b()}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.#b()}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.#b(),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.#b()}finish(t,{status:e="done"}={}){let i=eE.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.#b(),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.#b()},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.#b()};#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.#b()}#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>"}}#y(){let t=0,e=0,i=r=>{t++,r.status==="done"&&e++};for(let r of this.#t)if(r.kind==="step"&&i(r),r.kind==="iteration")for(let n of r.steps||[])i(n);return{total:t,done:e}}#b(){if(!this.#n)return;let t=eE.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:r}=this.#y(),n=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#g();if(this.#n.innerHTML=`
320
+ `).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",da);C();var JD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],fa=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:JD[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",fa);C();var eE=new Set(["idle","active","done","error"]);function OO(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function tq(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var pa=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.#C(),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.#b(),e}updateStep(t,e){let i=this.#d(t);i&&(Object.assign(i,e),this.#b())}completeStep(t,e){let i=this.#d(t);i&&(i.status="done",e!=null&&(i.duration=e),this.#b())}failStep(t,e){let i=this.#d(t);i&&(i.status="error",e&&(i.outcomes=[...i.outcomes||[],String(e)]),this.#b())}addThought(t,e=`thought-${this.#t.length}`){this.#u({kind:"thought",id:e,text:t}),this.#b()}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.#b()}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.#b(),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.#b()}finish(t,{status:e="done"}={}){let i=eE.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.#b(),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.#b()},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.#b()};#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.#b()}#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>"}}#y(){let t=0,e=0,i=r=>{t++,r.status==="done"&&e++};for(let r of this.#t)if(r.kind==="step"&&i(r),r.kind==="iteration")for(let n of r.steps||[])i(n);return{total:t,done:e}}#b(){if(!this.#n)return;let t=eE.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:r}=this.#y(),n=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#g();if(this.#n.innerHTML=`
321
321
  ${this.#O(t)}
322
322
  <span data-reasoning-label>${OO(o)}</span>
323
323
  <span data-reasoning-meta>
@@ -330,7 +330,7 @@ Correct shape for <chart-ui x="label" y="value">:
330
330
  <span data-reasoning-iter-n>#${t.n}</span>
331
331
  <span data-reasoning-iter-label>${OO(t.label||"")}</span>
332
332
  ${t.summary?`<span data-reasoning-iter-summary>${OO(t.summary)}</span>`:""}
333
- `,e.appendChild(i),t.steps?.length){let n=this.#v();for(let o of t.steps)n.appendChild(this.#S(o));e.appendChild(n)}return e}#$(){if(this.status==="done"||this.status==="error")return;let t=Math.round((Date.now()-this.#i)/1e3),e=this.#n?.querySelector("[data-reasoning-time]");e&&(e.textContent=t+"s");let i=t+"s";for(let r of this.querySelectorAll("timeline-item-ui[active]:not([completed])"))r.dataset._frozenDuration||r.setAttribute("duration",i)}};S("agent-reasoning-ui",pa);C();var Ul=class extends x{static requiredIcons=["caret-right","circle-fill"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=null;get pills(){return this.#t}set pills(t){this.#t=Array.isArray(t)?t.slice():[],this.#a()}get metrics(){return this.#e}set metrics(t){this.#e=Array.isArray(t)?t.slice():[],this.#a()}get feedback(){return this.#i}set feedback(t){this.#i=Array.isArray(t)?t.slice():[],this.#a()}connected(){this.#n()}disconnected(){this.#s?.removeEventListener("toggle",this.#r),this.#s=null}#r=()=>{this.collapsed=!this.#s.hasAttribute("open"),this.dispatchEvent(new CustomEvent("trace-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}}))};#n(){this.innerHTML="",this.#s=document.createElement("details"),this.#s.setAttribute("data-trace-root",""),this.collapsed||this.#s.setAttribute("open",""),this.#s.addEventListener("toggle",this.#r),this.appendChild(this.#s),this.#a()}#a(){if(!this.#s)return;let t=this.#t.length?this.#t.map(a=>this.#h(a)).join("<span data-trace-sep>\xB7</span>"):`<span>${ns(this.label||"Trace")}</span>`,e=this.#e.some(a=>a.aux!=null&&String(a.aux).trim()!==""),i=this.#e.some(a=>this.#o(a)),r=this.#e.length?`
333
+ `,e.appendChild(i),t.steps?.length){let n=this.#v();for(let o of t.steps)n.appendChild(this.#S(o));e.appendChild(n)}return e}#C(){if(this.status==="done"||this.status==="error")return;let t=Math.round((Date.now()-this.#i)/1e3),e=this.#n?.querySelector("[data-reasoning-time]");e&&(e.textContent=t+"s");let i=t+"s";for(let r of this.querySelectorAll("timeline-item-ui[active]:not([completed])"))r.dataset._frozenDuration||r.setAttribute("duration",i)}};S("agent-reasoning-ui",pa);C();var Ul=class extends x{static requiredIcons=["caret-right","circle-fill"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=null;get pills(){return this.#t}set pills(t){this.#t=Array.isArray(t)?t.slice():[],this.#a()}get metrics(){return this.#e}set metrics(t){this.#e=Array.isArray(t)?t.slice():[],this.#a()}get feedback(){return this.#i}set feedback(t){this.#i=Array.isArray(t)?t.slice():[],this.#a()}connected(){this.#n()}disconnected(){this.#s?.removeEventListener("toggle",this.#r),this.#s=null}#r=()=>{this.collapsed=!this.#s.hasAttribute("open"),this.dispatchEvent(new CustomEvent("trace-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}}))};#n(){this.innerHTML="",this.#s=document.createElement("details"),this.#s.setAttribute("data-trace-root",""),this.collapsed||this.#s.setAttribute("open",""),this.#s.addEventListener("toggle",this.#r),this.appendChild(this.#s),this.#a()}#a(){if(!this.#s)return;let t=this.#t.length?this.#t.map(a=>this.#h(a)).join("<span data-trace-sep>\xB7</span>"):`<span>${ns(this.label||"Trace")}</span>`,e=this.#e.some(a=>a.aux!=null&&String(a.aux).trim()!==""),i=this.#e.some(a=>this.#o(a)),r=this.#e.length?`
334
334
  <div data-trace-headers>
335
335
  <span data-trace-header>Stage</span>
336
336
  <span data-trace-header>Score</span>
@@ -446,10 +446,10 @@ Correct shape for <chart-ui x="label" y="value">:
446
446
  text="Open"
447
447
  ></button-ui>`:null}
448
448
  </list-item-ui>
449
- `}#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}}))}#y(){}#b(){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.#b();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.#b();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.#b();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",dh);C();$t();var AO=new Set(["","comfortable","compact","spacious"]),EO=new Set(["2","3","4","5","6"]),yE=new Set(["","2","2:1","3:2","3:1"]),CO=["toolbar","kpis","charts","table","aside"],wd=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=AO.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return CO.includes(t)?this.querySelector(`:scope > [slot="${t}"]`):null}connected(){this.hasAttribute("role")||this.setAttribute("role","region"),U(()=>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(!AO.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&&!EO.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...EO].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!yE.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(!AO.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!EO.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(!yE.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 CO)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of CO){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",wd);$t();var Ks=new Set,vE=!1;function xE(s){return String(s).padStart(2,"0")}function kd(s){return`${s.getFullYear()}-${xE(s.getMonth()+1)}-${xE(s.getDate())}`}function SE(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 wE={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(wE));function fh(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=kd(e),r=n=>{let o=new Date(e);return o.setDate(o.getDate()-n),kd(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:kd(new Date(e.getFullYear(),n,1)),to:i}}case"ytd":return{from:kd(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function Oq(s,t){let e=SE(s),i=SE(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 Ad=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=fh(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.#b(),U(()=>{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.#b(),this.#y()):i==="self"&&this.#y();return}if(t==="value"&&e!==i&&i&&Js.has(i)){if(i!=="custom"){let r=fh(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=Oq(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",wE[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=fh(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.#y();let o={value:t,from:e,to:i,preset:t};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,from:e,to:i}}));let a=this.#g();a&&a.dispatchEvent(new CustomEvent("range-change",{bubbles:a===this,detail:o}))}#f(t){if(this.value!==t){this.#o=!0;try{this.value=t}finally{this.#o=!1}}}#p(t,e){return t<=e?{from:t,to:e}:{from:e,to:t}}#m(){if(this.value==="custom")return this.from&&this.to?this.#p(this.from,this.to):fh("7d");let t=Js.has(this.value)?this.value:"7d";return fh(t)}#g(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#O(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#y(){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")))}#b(){if(Ks.size>0&&!Ks.has(this)){vE||(vE=!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.#y())}}#v(){this.#s&&(typeof this.#s.openPopover=="function"?this.#s.openPopover():this.#s.open=!0)}};customElements.get("date-range-selector-ui")||customElements.define("date-range-selector-ui",Ad);C();var Ed=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.#y}-title`,this.#f=`${this.#y}-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#y(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",Ed);C();$t();var yq=new Set(["active","trialing","past_due","canceled","paused"]),vq={active:"success",trialing:"info",past_due:"danger",canceled:"muted",paused:"warning"},xq={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},Sq={update:"update-card",retry:"retry"};function kE(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 wq(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 va=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;#y=null;#b=null;#x=null;#v=null;#S=null;#w="";#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.#R(),this.#q(),this.#t=!0),U(()=>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&&!yq.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.#T(null);return}if(!t){this.#C(null);return}this.#C(t),this.#P(t),this.#D(t),this.#Q(t),this.#L(t),this.#I(t),this.#T(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)}#R(){this.#w=`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.#w,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.#y=R;let _=document.createElement("section");_.setAttribute("data-invoice-history","");let V=document.createElement("h3");V.setAttribute("data-section-heading",""),V.textContent="Invoice history";let F=document.createElement("invoice-history-ui");F.setAttribute("data-billing-invoice-history",""),_.append(V,F),this.appendChild(_),this.#b=_,this.#x=V,this.#v=F;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 at=document.createElement("p");at.setAttribute("data-empty-description",""),at.textContent="Pass an `account` snapshot or `data-stream-src` to render the dashboard.",rt.append(dt,at),this.appendChild(rt),this.#S=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=`${kE(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=vq[n]||"default",a=xq[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",kE(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",wq(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.#y)return;let e=Array.isArray(t?.paymentMethods)?t.paymentMethods:[];this.#y.methods=e,this.loading?this.#y.setAttribute("loading",""):this.#y.removeAttribute("loading")}#I(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")}#T(t){this.#w&&this.setAttribute("aria-labelledby",this.#w),!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.#M(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=Sq[d]||d||"dunning";this.#M(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.#M("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.#M("select-plan","plan-picker",u.detail)};this.addEventListener("change",r),this.#e.push(()=>this.removeEventListener("change",r));let n=()=>{this.#M("add-payment-method","payment-method-list",null)};this.addEventListener("add",n),this.#e.push(()=>this.removeEventListener("add",n));let o=u=>{this.#M("remove-payment-method","payment-method-list",u.detail)};this.addEventListener("remove",o),this.#e.push(()=>this.removeEventListener("remove",o));let a=u=>{this.#M("set-default-payment-method","payment-method-list",u.detail)};this.addEventListener("select",a),this.#e.push(()=>this.removeEventListener("select",a));let l=u=>{this.#M("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.#M("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.#M(d,"invoice-history",u.detail)};this.addEventListener("invoice-action",c),this.#e.push(()=>this.removeEventListener("invoice-action",c))}#M(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",va);C();$t();var kq=new Set(["draft","open","paid","past-due","void"]),Aq={paid:"success",open:"info","past-due":"danger",void:"muted",draft:"neutral"},AE={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},Eq=[{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"}],EE=["Number","Issued","Due","Amount","Currency","Status"];function CE(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 $E(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 PE(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(`
449
+ `}#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}}))}#y(){}#b(){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.#b();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.#b();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.#b();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",dh);C();$t();var AO=new Set(["","comfortable","compact","spacious"]),EO=new Set(["2","3","4","5","6"]),yE=new Set(["","2","2:1","3:2","3:1"]),CO=["toolbar","kpis","charts","table","aside"],wd=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=AO.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return CO.includes(t)?this.querySelector(`:scope > [slot="${t}"]`):null}connected(){this.hasAttribute("role")||this.setAttribute("role","region"),U(()=>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(!AO.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&&!EO.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...EO].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!yE.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(!AO.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!EO.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(!yE.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 CO)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of CO){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",wd);$t();var Ks=new Set,vE=!1;function xE(s){return String(s).padStart(2,"0")}function kd(s){return`${s.getFullYear()}-${xE(s.getMonth()+1)}-${xE(s.getDate())}`}function SE(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 wE={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(wE));function fh(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=kd(e),r=n=>{let o=new Date(e);return o.setDate(o.getDate()-n),kd(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:kd(new Date(e.getFullYear(),n,1)),to:i}}case"ytd":return{from:kd(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function Oq(s,t){let e=SE(s),i=SE(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 Ad=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=fh(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.#b(),U(()=>{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.#b(),this.#y()):i==="self"&&this.#y();return}if(t==="value"&&e!==i&&i&&Js.has(i)){if(i!=="custom"){let r=fh(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=Oq(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",wE[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=fh(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.#y();let o={value:t,from:e,to:i,preset:t};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,from:e,to:i}}));let a=this.#g();a&&a.dispatchEvent(new CustomEvent("range-change",{bubbles:a===this,detail:o}))}#f(t){if(this.value!==t){this.#o=!0;try{this.value=t}finally{this.#o=!1}}}#p(t,e){return t<=e?{from:t,to:e}:{from:e,to:t}}#m(){if(this.value==="custom")return this.from&&this.to?this.#p(this.from,this.to):fh("7d");let t=Js.has(this.value)?this.value:"7d";return fh(t)}#g(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#O(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#y(){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")))}#b(){if(Ks.size>0&&!Ks.has(this)){vE||(vE=!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.#y())}}#v(){this.#s&&(typeof this.#s.openPopover=="function"?this.#s.openPopover():this.#s.open=!0)}};customElements.get("date-range-selector-ui")||customElements.define("date-range-selector-ui",Ad);C();var Ed=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.#y}-title`,this.#f=`${this.#y}-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#y(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",Ed);C();$t();var yq=new Set(["active","trialing","past_due","canceled","paused"]),vq={active:"success",trialing:"info",past_due:"danger",canceled:"muted",paused:"warning"},xq={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},Sq={update:"update-card",retry:"retry"};function kE(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 wq(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 va=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;#y=null;#b=null;#x=null;#v=null;#S=null;#w="";#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.#Z(),this.#t=!0),U(()=>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&&!yq.has(i)&&!this.#k&&(this.#k=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#$(null),this.#P(null);return}if(!t){this.#$(null);return}this.#$(t),this.#Q(t),this.#I(t),this.#R(t),this.#T(t),this.#D(t),this.#P(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()}}#C(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#M(){this.#w=`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.#w,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.#C("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.#C("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.#y=R;let _=document.createElement("section");_.setAttribute("data-invoice-history","");let V=document.createElement("h3");V.setAttribute("data-section-heading",""),V.textContent="Invoice history";let F=document.createElement("invoice-history-ui");F.setAttribute("data-billing-invoice-history",""),_.append(V,F),this.appendChild(_),this.#b=_,this.#x=V,this.#v=F;let J=document.createElement("div");J.setAttribute("data-after-invoice-history",""),_.appendChild(J),this.#C("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 at=document.createElement("p");at.setAttribute("data-empty-description",""),at.textContent="Pass an `account` snapshot or `data-stream-src` to render the dashboard.",rt.append(dt,at),this.appendChild(rt),this.#S=rt,this.#C("empty",this)}#$(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.#N(),l=e.cycle==="year"?"/yr":"/mo",h=document.createElement("span");h.setAttribute("data-plan-price",""),h.textContent=`${kE(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=vq[n]||"default",a=xq[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}`)}}#Q(t){if(!this.#l||!this.#c||!this.#h)return;let e=t?.plan?.currency||this.currency||"USD",i=this.#N();if(Number.isFinite(t?.currentSpend)?this.#l.setAttribute("value",kE(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",wq(t.nextInvoiceDate,i)):this.#h.setAttribute("value","\u2014");for(let r of[this.#l,this.#c,this.#h])this.loading?r.setAttribute("loading",""):r.removeAttribute("loading")}#I(t){if(!this.#u||!this.#d)return;let e=t?.dunning||null;if(!(t?.status==="past_due")||!e){this.#u.setAttribute("hidden","");return}this.#u.removeAttribute("hidden");let r=Number.isFinite(e.amount)?e.amount:null,n=e.currency||t?.plan?.currency||this.currency||"USD";if(r!=null?this.#d.setAttribute("amount",String(r)):this.#d.removeAttribute("amount"),this.#d.setAttribute("currency",n),e.dueAt&&this.#d.setAttribute("due-at",String(e.dueAt)),e.cardLast4&&this.#d.setAttribute("card-last4",String(e.cardLast4)),e.reason&&this.#d.setAttribute("reason",String(e.reason)),!this.#d.querySelector(':scope > [slot="actions"]')){let o=document.createElement("button-ui");o.setAttribute("slot","actions"),o.setAttribute("data-dunning-action","update"),o.setAttribute("variant","primary"),o.setAttribute("text","Update payment method"),this.#d.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("slot","actions"),a.setAttribute("data-dunning-action","retry"),a.setAttribute("variant","outline"),a.setAttribute("text","Retry charge"),this.#d.appendChild(a)}}#R(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")}#T(t){if(!this.#y)return;let e=Array.isArray(t?.paymentMethods)?t.paymentMethods:[];this.#y.methods=e,this.loading?this.#y.setAttribute("loading",""):this.#y.removeAttribute("loading")}#D(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")}#P(t){this.#w&&this.setAttribute("aria-labelledby",this.#w),!t&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label","No billing account loaded"):t&&this.removeAttribute("aria-label")}#N(){return this.locale?this.locale:typeof document<"u"&&document.documentElement.lang||""}#Z(){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.#L(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=Sq[d]||d||"dunning";this.#L(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.#L("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.#L("select-plan","plan-picker",u.detail)};this.addEventListener("change",r),this.#e.push(()=>this.removeEventListener("change",r));let n=()=>{this.#L("add-payment-method","payment-method-list",null)};this.addEventListener("add",n),this.#e.push(()=>this.removeEventListener("add",n));let o=u=>{this.#L("remove-payment-method","payment-method-list",u.detail)};this.addEventListener("remove",o),this.#e.push(()=>this.removeEventListener("remove",o));let a=u=>{this.#L("set-default-payment-method","payment-method-list",u.detail)};this.addEventListener("select",a),this.#e.push(()=>this.removeEventListener("select",a));let l=u=>{this.#L("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.#L("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.#L(d,"invoice-history",u.detail)};this.addEventListener("invoice-action",c),this.#e.push(()=>this.removeEventListener("invoice-action",c))}#L(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",va);C();$t();var kq=new Set(["draft","open","paid","past-due","void"]),Aq={paid:"success",open:"info","past-due":"danger",void:"muted",draft:"neutral"},AE={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},Eq=[{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"}],EE=["Number","Issued","Due","Amount","Currency","Status"];function CE(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 $E(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 PE(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(`
450
450
  `)?'"'+t.replace(/"/g,'""')+'"':t}var xa=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&&!kq.has(e)?!1:U(()=>{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=[EE.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
451
451
  `);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),U(()=>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 Eq){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=>$E(i,t)},{key:"dueAt",label:"Due",sortable:!0,format:i=>$E(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=CE(i,o,t),n.dataset.align="end",a},format:(i,r)=>CE(i,r?.currency||e,t)},{key:"status",label:"Status",sortable:!0,render:i=>{let r=String(i||"").toLowerCase(),n=Aq[r]||"neutral",o=AE[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=>AE[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=PE(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=PE(this.hrefPattern,c),d=new CustomEvent("invoice-row-click",{bubbles:!0,cancelable:!0,detail:{invoice:c,href:u}});if(this.dispatchEvent(d)&&typeof window<"u"&&window.location?.assign)try{window.location.assign(u)}catch{}}else if(l==="download"){let u=this.#y(c);this.dispatchEvent(new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:u,rowCount:1,invoice:c}}))}}};this.addEventListener("press",i),this.addEventListener("click",i),this.#e.push(()=>this.removeEventListener("press",i)),this.#e.push(()=>this.removeEventListener("click",i));let r=o=>{let a=o.target?.closest?.("button-ui[data-export]");if(!a||!this.#i?.contains(a))return;o.stopPropagation();let l=this.exportCsv(),h=new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:l,rowCount:this.#m().length}});if(this.dispatchEvent(h)&&typeof document<"u"&&typeof URL<"u")try{let u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download="invoices.csv",document.body.appendChild(d),d.click(),d.remove(),setTimeout(()=>URL.revokeObjectURL(u),0)}catch{}};this.addEventListener("press",r),this.addEventListener("click",r),this.#e.push(()=>this.removeEventListener("press",r)),this.#e.push(()=>this.removeEventListener("click",r));let n=o=>{if(o.target!==this.#o)return;let a=this.getSelected();this.dispatchEvent(new CustomEvent("invoice-selection-change",{bubbles:!0,detail:{selected:a}}))};this.addEventListener("select",n),this.#e.push(()=>this.removeEventListener("select",n))}#y(t){let e=[EE.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
452
- `)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",xa);C();$t();var Cq=new Set(["draft","open","paid","past-due","void"]),$q={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},Pq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function Cd(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 QE(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 Sa=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;#y=0;#b="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#y;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#y)return;this.loading=!1;let n=r&&typeof r=="object"&&r.invoice?r.invoice:r;if(this.invoice=n,n?.status){this.#g=!0;try{this.status=String(n.status)}finally{this.#g=!1}}let o=n?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:o}})),this.#b=o}catch(i){if(e!==this.#y)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#x(),this.#S(),this.#R(),this.#t=!0),U(()=>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(Cq.has(r)||this.#O||(this.#O=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#w(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#w(null,r);return}this.#w(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)}#S(){this.#m=`inv-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("header");t.setAttribute("data-header","");let e=document.createElement("div");e.setAttribute("data-header-title","");let i=document.createElement("h2");i.id=this.#m,i.setAttribute("data-invoice-number",""),e.appendChild(i);let r=document.createElement("tag-ui");r.setAttribute("data-invoice-status",""),r.setAttribute("size","md"),e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-header-meta","");let o=document.createElement("div");o.setAttribute("data-header-actions",""),o.setAttribute("data-invoice-actions",""),t.append(e,n,o),this.appendChild(t),this.#i=t,this.#s=i,this.#r=r,this.#n=n,this.#a=o,this.#v("header-actions",o);let a=document.createElement("section");a.setAttribute("data-parties","");let l=document.createElement("div");l.setAttribute("data-customer","");let h=document.createElement("div");h.setAttribute("data-customer-default",""),l.appendChild(h),this.#l=h;let c=document.createElement("div");c.setAttribute("data-remit-to","");let u=document.createElement("div");u.setAttribute("data-remit-to-default",""),c.appendChild(u),this.#c=u,a.append(l,c),this.appendChild(a),this.#o=a,this.#v("customer-block",l),this.#v("remit-to-block",c);let d=document.createElement("section");d.setAttribute("data-lines","");let f=document.createElement("card-ui");f.setAttribute("data-lines-card",""),f.setAttribute("padding","none");let p=document.createElement("section");p.setAttribute("bleed",""),f.appendChild(p);let m=document.createElement("table-ui");m.setAttribute("data-lines-table",""),m.setAttribute("density",this.density||"standard"),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#h=d,this.#u=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#d=b;let g=document.createElement("footer");g.setAttribute("data-footer","");let y=document.createElement("div");y.setAttribute("data-footer-notes",""),g.appendChild(y),this.appendChild(g),this.#f=g,this.#v("footer",g);let v=document.createElement("empty-state-ui");v.setAttribute("data-empty",""),v.setAttribute("icon","receipt"),v.setAttribute("heading","No invoice loaded"),v.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(v),this.#p=v}#w(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=$q[e]||"default",n=Pq[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 ${QE(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${QE(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=>Cd(n,e,i)},{key:"amount",label:"Amount",width:140,format:n=>Cd(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=Cd(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=Cd(t.total,e,i),n.append(o,a),this.#d.appendChild(n)}}#$(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#R(){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",Sa);$t();var Qq=[{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 $d(s){if(!s)return"unknown";for(let{brand:t,re:e}of Qq)if(e.test(s))return t;return"unknown"}function Pd(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function t8(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 TE(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 LE(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 ME(s){let t=LE(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 RE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function Tq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var Lq=["US","CA","GB","DE","FR","AU"],Mq={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 Rq(s){return Mq[s]||s}var wa=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=Tq(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(){U(()=>{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.#w()})}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),U(()=>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.#b();else if(t==="default-country"&&e!==i){let r=this.#o.country;r&&!r.value&&(r.value=i||"US")}}}render(){this.#t&&(this.#y(),this.#b(),this.#x(),this.#v(),this.#S(),this.#w())}#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:Lq).map(e=>({value:e,label:Rq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=Pd(n),a=$d(o);a!==this.#l&&(this.#l=a,this.#w()),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=Pd(this.#o.cardNumber?.value),e=$d(t),i=this.#k();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#y(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((r,n)=>r?.value===e[n].value&&r?.label===e[n].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#b(){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"))}#S(){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","")}#w(){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=Pd(this.#o.cardNumber?.value);return t?TE(t)?ME(this.#o.expiry?.value)?{ok:!1}:RE(this.#o.cvc?.value,$d(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=Pd(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(!TE(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=ME(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=$d(i);if(RE(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=LE(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",wa);$t();var Iq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),IE=new Set(["card","bank","wallet"]),DE={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},Dq={card:"credit-card",bank:"bank",wallet:"credit-card"},qE={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 XE(s){let t=(s?.brand||"").toLowerCase();if(DE[t])return DE[t];let e=(s?.type||"card").toLowerCase();return Dq[e]||"credit-card"}function NE(s){let t=(s?.brand||"").toLowerCase();if(qE[t])return qE[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function $O(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=NE(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function PO(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 ka=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?U(()=>{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?U(()=>{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||U(()=>{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),U(()=>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();IE.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=XE(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=$O(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=PO(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=PO(e),u=[$O(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",ka);$t();var Qd=new Set(["monthly","annual"]),qq={monthly:"Monthly",annual:"Annual"},Xq={monthly:"/month",annual:"/year"};function Nq(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 Bq(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 Aa=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?U(()=>{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.#b(t,i),!0}):!1}setCycle(t){return Qd.has(t)?U(()=>{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.#y(),this.#t=!0),U(()=>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(!Qd.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=Qd.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=Nq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:Xq[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",Bq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#y(){let t=r=>{let n=r?.detail?.value;if(!Qd.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.#b(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.#b(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))}#b(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",Aa);C();var Zq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),zq=6,ph=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`
452
+ `)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",xa);C();$t();var Cq=new Set(["draft","open","paid","past-due","void"]),$q={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},Pq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function Cd(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 QE(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 Sa=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;#y=0;#b="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#y;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#y)return;this.loading=!1;let n=r&&typeof r=="object"&&r.invoice?r.invoice:r;if(this.invoice=n,n?.status){this.#g=!0;try{this.status=String(n.status)}finally{this.#g=!1}}let o=n?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:o}})),this.#b=o}catch(i){if(e!==this.#y)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#x(),this.#S(),this.#M(),this.#t=!0),U(()=>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(Cq.has(r)||this.#O||(this.#O=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#w(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#w(null,r);return}this.#w(t,r),this.#k(t),this.#A(t),this.#E(t),this.#C(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)}#S(){this.#m=`inv-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("header");t.setAttribute("data-header","");let e=document.createElement("div");e.setAttribute("data-header-title","");let i=document.createElement("h2");i.id=this.#m,i.setAttribute("data-invoice-number",""),e.appendChild(i);let r=document.createElement("tag-ui");r.setAttribute("data-invoice-status",""),r.setAttribute("size","md"),e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-header-meta","");let o=document.createElement("div");o.setAttribute("data-header-actions",""),o.setAttribute("data-invoice-actions",""),t.append(e,n,o),this.appendChild(t),this.#i=t,this.#s=i,this.#r=r,this.#n=n,this.#a=o,this.#v("header-actions",o);let a=document.createElement("section");a.setAttribute("data-parties","");let l=document.createElement("div");l.setAttribute("data-customer","");let h=document.createElement("div");h.setAttribute("data-customer-default",""),l.appendChild(h),this.#l=h;let c=document.createElement("div");c.setAttribute("data-remit-to","");let u=document.createElement("div");u.setAttribute("data-remit-to-default",""),c.appendChild(u),this.#c=u,a.append(l,c),this.appendChild(a),this.#o=a,this.#v("customer-block",l),this.#v("remit-to-block",c);let d=document.createElement("section");d.setAttribute("data-lines","");let f=document.createElement("card-ui");f.setAttribute("data-lines-card",""),f.setAttribute("padding","none");let p=document.createElement("section");p.setAttribute("bleed",""),f.appendChild(p);let m=document.createElement("table-ui");m.setAttribute("data-lines-table",""),m.setAttribute("density",this.density||"standard"),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#h=d,this.#u=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#d=b;let g=document.createElement("footer");g.setAttribute("data-footer","");let y=document.createElement("div");y.setAttribute("data-footer-notes",""),g.appendChild(y),this.appendChild(g),this.#f=g,this.#v("footer",g);let v=document.createElement("empty-state-ui");v.setAttribute("data-empty",""),v.setAttribute("icon","receipt"),v.setAttribute("heading","No invoice loaded"),v.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(v),this.#p=v}#w(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=$q[e]||"default",n=Pq[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 ${QE(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${QE(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=>Cd(n,e,i)},{key:"amount",label:"Amount",width:140,format:n=>Cd(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=Cd(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=Cd(t.total,e,i),n.append(o,a),this.#d.appendChild(n)}}#C(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",Sa);$t();var Qq=[{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 $d(s){if(!s)return"unknown";for(let{brand:t,re:e}of Qq)if(e.test(s))return t;return"unknown"}function Pd(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function t8(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 TE(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 LE(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 ME(s){let t=LE(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 RE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function Tq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var Lq=["US","CA","GB","DE","FR","AU"],Mq={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 Rq(s){return Mq[s]||s}var wa=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=Tq(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(){U(()=>{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.#w()})}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),U(()=>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.#b();else if(t==="default-country"&&e!==i){let r=this.#o.country;r&&!r.value&&(r.value=i||"US")}}}render(){this.#t&&(this.#y(),this.#b(),this.#x(),this.#v(),this.#S(),this.#w())}#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:Lq).map(e=>({value:e,label:Rq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=Pd(n),a=$d(o);a!==this.#l&&(this.#l=a,this.#w()),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=Pd(this.#o.cardNumber?.value),e=$d(t),i=this.#k();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#y(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((r,n)=>r?.value===e[n].value&&r?.label===e[n].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#b(){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"))}#S(){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","")}#w(){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=Pd(this.#o.cardNumber?.value);return t?TE(t)?ME(this.#o.expiry?.value)?{ok:!1}:RE(this.#o.cvc?.value,$d(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=Pd(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(!TE(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=ME(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=$d(i);if(RE(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=LE(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",wa);$t();var Iq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),IE=new Set(["card","bank","wallet"]),DE={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},Dq={card:"credit-card",bank:"bank",wallet:"credit-card"},qE={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 XE(s){let t=(s?.brand||"").toLowerCase();if(DE[t])return DE[t];let e=(s?.type||"card").toLowerCase();return Dq[e]||"credit-card"}function NE(s){let t=(s?.brand||"").toLowerCase();if(qE[t])return qE[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function $O(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=NE(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function PO(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 ka=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?U(()=>{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?U(()=>{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||U(()=>{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),U(()=>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();IE.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=XE(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=$O(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=PO(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=PO(e),u=[$O(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",ka);$t();var Qd=new Set(["monthly","annual"]),qq={monthly:"Monthly",annual:"Annual"},Xq={monthly:"/month",annual:"/year"};function Nq(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 Bq(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 Aa=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?U(()=>{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.#b(t,i),!0}):!1}setCycle(t){return Qd.has(t)?U(()=>{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.#y(),this.#t=!0),U(()=>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(!Qd.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=Qd.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=Nq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:Xq[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",Bq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#y(){let t=r=>{let n=r?.detail?.value;if(!Qd.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.#b(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.#b(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))}#b(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",Aa);C();var Zq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),zq=6,ph=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`
453
453
  <header data-part="header">
454
454
  <h2 data-part="title" id=${this.#e}>Integrations</h2>
455
455
  <slot name="header"></slot>