@adia-ai/web-modules 0.8.46 → 0.8.47
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.
package/dist/everything.min.js
CHANGED
|
@@ -38,10 +38,10 @@ var t$=Object.defineProperty;var F=(s,t,e)=>()=>{if(e)throw e[0];try{return s&&(
|
|
|
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=Uu.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 et(this.parser.nodeSet.types[t],ko,ko,(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(bb(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?UA(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=bb(this.parser.parseInline(t.content,t.start),t.marks);this.addNode(this.buffer.writeElements(e,-t.start).finish(q.Paragraph,t.content.length),t.start)}elt(t,e,i,r){return typeof t=="string"?at(this.parser.getNodeType(t),e,i,r):new ed(t,e)}get buffer(){return new td(this.parser.nodeSet)}};Co=class s extends oi{constructor(t,e,i,r,n,o,a,l,h){super(),this.nodeSet=t,this.blockParsers=e,this.leafBlockParsers=i,this.blockNames=r,this.endLeafBlock=n,this.skipContextMarkup=o,this.inlineParsers=a,this.inlineNames=l,this.wrappers=h,this.nodeTypes=Object.create(null);for(let c of t.types)this.nodeTypes[c.name]=c.id}createParse(t,e,i){let r=new Ku(this,t,e,i);for(let n of this.wrappers)r=n(r,t,e,i);return r}configure(t){let e=mb(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(Jl(e.defineNodes)){r=Object.assign({},r);let d=i.types.slice(),f;for(let p of e.defineNodes){let{name:m,block:g,composite:b,style:A}=typeof p=="string"?{name:p}:p;if(d.some(v=>v.name==m))continue;b&&(r[d.length]=(v,E,O)=>b(E,O,v.value));let x=d.length,S=b?["Block","BlockContext"]:g?x>=q.ATXHeading1&&x<=q.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;d.push(yt.define({id:x,name:m,props:S&&[[W.group,S]]})),A&&(f||(f={}),Array.isArray(A)||A instanceof be?f[m]=A:Object.assign(f,A))}i=new ni(d),f&&(i=i.extend(qt(f)))}if(Jl(e.props)&&(i=i.extend(...e.props)),Jl(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(Jl(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?Ju(a,d.before):d.after?Ju(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(Jl(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?Ju(h,d.before):d.after?Ju(h,d.after)+1:h.length-1;l.splice(p,0,d.parse),h.splice(p,0,d.name)}}return e.wrap&&(u=u.concat(e.wrap)),new s(i,n,o,a,c,r,l,h,u)}getNodeType(t){let e=this.nodeTypes[t];if(e==null)throw new RangeError(`Unknown node type '${t}'`);return e}parseInline(t,e){let i=new Eo(this,t,e);t:for(let r=e;r<i.end;){let n=i.char(r);for(let o of this.inlineParsers)if(o){let a=o(i,n,r);if(a>=0){r=a;continue t}}r++}return i.resolveMarkers(0)}};YA=[yt.none];for(let s=1,t;t=q[s];s++)YA[s]=yt.define({id:s,name:t,props:s>=q.Escape?[]:[[W.group,s in DA?["Block","BlockContext"]:["Block","LeafBlock"]]],top:t=="Document"});ko=[],td=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 et.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:t,length:e})}},ms=class{constructor(t,e,i,r=ko){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 td(t).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}},ed=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 ko}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}};HA={resolve:"Emphasis",mark:"EmphasisMark"},GA={resolve:"Emphasis",mark:"EmphasisMark"},ir={},id={},fe=class{constructor(t,e,i,r){this.type=t,this.from=e,this.to=i,this.side=r}},KA="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",th=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{th=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}gb={Escape(s,t,e){if(t!=92||e==s.end-1)return-1;let i=s.char(e+1);for(let r=0;r<KA.length;r++)if(KA.charCodeAt(r)==i)return s.append(at(q.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(at(q.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(at(q.InlineCode,e,i+1,[at(q.CodeMark,e,e+r),at(q.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(at(q.Autolink,e,e+1+r[0].length,[at(q.LinkMark,e,e+1),at(q.URL,e+1,e+r[0].length),at(q.LinkMark,e+r[0].length,e+1+r[0].length)]));let n=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(i);if(n)return s.append(at(q.Comment,e,e+1+n[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return s.append(at(q.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(at(q.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=th.test(r),a=th.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 fe(t==95?HA:GA,e,i,(d?1:0)|(f?2:0)))},HardBreak(s,t,e){if(t==92&&s.char(e+1)==10)return s.append(at(q.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(at(q.HardBreak,e,i+1))}return-1},Link(s,t,e){return t==91?s.append(new fe(ir,e,e+1,1)):-1},Image(s,t,e){return t==33&&s.char(e+1)==91?s.append(new fe(id,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 fe&&(r.type==ir||r.type==id)){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]=PI(s,n,r.type==ir?q.Link:q.Image,r.from,e+1);if(r.type==ir)for(let a=0;a<i;a++){let l=s.parts[a];l instanceof fe&&l.type==ir&&(l.side=0)}return o.to}}return-1}};Eo=class{constructor(t,e,i){this.parser=t,this.text=e,this.offset=i,this.parts=[]}char(t){return t>=this.end?-1:this.text.charCodeAt(t-this.offset)}get end(){return this.offset+this.text.length}slice(t,e){return this.text.slice(t-this.offset,e-this.offset)}append(t){return this.parts.push(t),t.to}addDelimiter(t,e,i,r,n){return this.append(new fe(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 fe&&(e.type==ir||e.type==id))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 fe&&r.type.resolve&&r.side&2))continue;let n=r.type==HA||r.type==GA,o=r.to-r.from,a,l=i-1;for(;l>=t;l--){let m=this.parts[l];if(m instanceof fe&&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 ms&&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 fe(a.type,a.from,u,a.side):null,(this.parts[i]=n&&r.to!=d?new fe(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 ms&&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 fe&&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 fe?e:null}skipSpace(t){return Kl(this.text,t-this.offset)+this.offset}elt(t,e,i,r){return typeof t=="string"?at(this.parser.getNodeType(t),e,i,r):new ed(t,e)}};Eo.linkStart=ir,Eo.imageStart=id;QI=[q.CodeBlock,q.ListItem,q.OrderedList,q.BulletList],Ob=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(W.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=ik(e.from-i,t.ranges);if(e.to-i<=t.ranges[t.rangeI].to)t.addNode(e.tree,c);else{let u=new et(t.parser.nodeSet.types[q.Paragraph],[],[],0,t.block.hashProp);t.reusePlaceholders.set(u,e.tree),t.addNode(u,c)}if(e.type.is("Block")&&(QI.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}};TI=qt({"Blockquote/...":y.quote,HorizontalRule:y.contentSeparator,"ATXHeading1/... SetextHeading1/...":y.heading1,"ATXHeading2/... SetextHeading2/...":y.heading2,"ATXHeading3/...":y.heading3,"ATXHeading4/...":y.heading4,"ATXHeading5/...":y.heading5,"ATXHeading6/...":y.heading6,"Comment CommentBlock":y.comment,Escape:y.escape,Entity:y.character,"Emphasis/...":y.emphasis,"StrongEmphasis/...":y.strong,"Link/... Image/...":y.link,"OrderedList/... BulletList/...":y.list,"BlockQuote/...":y.quote,"InlineCode CodeText":y.monospace,"URL Autolink":y.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":y.processingInstruction,"CodeInfo LinkLabel":y.labelName,LinkTitle:y.string,Paragraph:y.content}),vb=new Co(new ni(YA).extend(TI),Object.keys(Gu).map(s=>Gu[s]),Object.keys(Gu).map(s=>WA[s]),Object.keys(Gu),CI,DA,Object.keys(gb).map(s=>gb[s]),Object.keys(gb),[]);MI={resolve:"Strikethrough",mark:"StrikethroughMark"},sk={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":y.strikethrough}},{name:"StrikethroughMark",style:y.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=th.test(i),l=th.test(r);return s.addDelimiter(MI,e,e+2,!o&&(!l||n||a),!n&&(!a||o||l))},after:"Emphasis"}]};nk=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,sd=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)&&nk.test(r=e.text.slice(e.pos))){let n=[];eh(t,i.content,0,n,i.start)==eh(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=[];eh(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}},ok={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":y.heading}},"TableRow",{name:"TableCell",style:y.content},{name:"TableDelimiter",style:y.processingInstruction}],parseBlock:[{name:"Table",leaf(s,t){return rk(t.content,0)?new sd:null},endLeaf(s,t,e){if(e.parsers.some(r=>r instanceof sd)||!rk(t.text,t.basePos))return!1;let i=s.peekLine();return nk.test(i)&&eh(s,t.text,t.basePos)==eh(s,i,t.basePos)},before:"SetextHeading"}]},yb=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}},ak={defineNodes:[{name:"Task",block:!0,style:y.list},{name:"TaskMarker",style:y.atom}],parseBlock:[{name:"TaskList",leaf(s,t){return/^\[[ xX]\][ \t]/.test(t.content)&&s.parentType().name=="ListItem"?new yb:null},after:"SetextHeading"}]},lk=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,hk=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,RI=/[\w-]+\.[\w-]+($|\/)/,ck=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,uk=/\/[a-zA-Z\d@.]+/gy;pk={parseInline:[{name:"Autolink",parse(s,t,e){let i=e-s.offset;if(i&&/\w/.test(s.text[i-1]))return-1;lk.lastIndex=i;let r=lk.exec(s.text),n=-1;if(!r)return-1;if(r[1]||r[2]){if(n=II(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=fk(s.text,i):(n=fk(s.text,i+r[0].length),n>-1&&r[0]=="xmpp:"&&(uk.lastIndex=n,r=uk.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)}}]},Sb=[ok,ak,sk,pk];wb={defineNodes:[{name:"Superscript",style:y.special(y.content)},{name:"SuperscriptMark",style:y.processingInstruction}],parseInline:[{name:"Superscript",parse:mk(94,"Superscript","SuperscriptMark")}]},Ab={defineNodes:[{name:"Subscript",style:y.special(y.content)},{name:"SubscriptMark",style:y.processingInstruction}],parseInline:[{name:"Subscript",parse:mk(126,"Subscript","SubscriptMark")}]},kb={defineNodes:[{name:"Emoji",style:y.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 Ek={};se(Ek,{commonmarkLanguage:()=>Tb,deleteMarkupBackward:()=>Rb,insertNewlineContinueMarkup:()=>Mb,insertNewlineContinueMarkupCommand:()=>Lb,markdown:()=>kk,markdownKeymap:()=>Ib,markdownLanguage:()=>$o,pasteURLAsLink:()=>Db});function Eb(s){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(s.name);return t?+t[1]:void 0}function DI(s){return s.name=="OrderedList"||s.name=="BulletList"}function NI(s,t){let e=s;for(;;){let i=e.nextSibling,r;if(!i||(r=Eb(i.type))!=null&&r<=t)break;e=i}return e.to}function Cb(s){return new It(bk,s,[],"markdown")}function BI(s,t){return e=>{if(e&&s){let i=null;if(e=/\S*/.exec(e)[0],typeof s=="function"?i=s(e):i=yo.matchLanguageName(s,e,!0),i instanceof yo)return i.support?i.support.language.parser:ds.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}function vk(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 ih(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 ih(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 ih(n.parent,l,l+c,o[1],h,u,n))}}return i}function xk(s,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(s.from,s.from+10))}function $b(s,t,e,i=0){for(let r=-1,n=s;;){if(n.name=="ListItem"){let a=xk(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 Pb(s,t){let e=/^[ \t]*/.exec(s)[0].length;if(!e||t.facet(Xi)!=" ")return s;let i=Gt(s,4,e),r="";for(let n=i;n>0;)n>=4?(r+=" ",n-=4):(r+=" ",n--);return r+s.slice(e)}function Sk(s){return s.name=="QuoteMark"||s.name=="ListMark"}function zI(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 wk(s,t,e){let i="";for(let r=0,n=s.length-2;r<=n;r++)i+=s[r].blank(r<n?Gt(e.text,4,s[r+1].from)-i.length:null,r<n);return Pb(i,t)}function ZI(s,t){let e=s.resolveInner(t,-1),i=t;Sk(e)&&(i=e.from,e=e.parent);for(let r;r=e.childBefore(i);)if(Sk(r))i=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")e=r.lastChild,i=e.to;else break;return e}function kk(s={}){let{codeLanguages:t,defaultCodeLanguage:e,addKeymap:i=!0,base:{parser:r}=Tb,completeHTMLTags:n=!0,pasteURLAsLink:o=!0,htmlTagLanguage:a=Ak}=s;if(!(r instanceof Co))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=s.extensions?[s.extensions]:[],h=[a.support,qI],c;o&&h.push(Db),e instanceof Ct?(h.push(e.support),c=e.language):e&&(c=e);let u=t||c?BI(t,c):void 0;l.push(xb({codeParser:u,htmlParser:a.language.parser})),i&&h.push(Oe.high(mi.of(Ib)));let d=Cb(r.configure(l));return n&&h.push(d.data.of({autocomplete:_I})),new Ct(d,h)}function _I(s){let{state:t,pos:e}=s,i=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(e-25,e));if(!i)return null;let r=st(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:VI(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}function VI(){if(Qb)return Qb;let s=Fu(new Js(dt.create({extensions:Ak}),0,!0));return Qb=s?s.options:[]}var bk,Ok,yk,qI,Tb,XI,$o,ih,Lb,Mb,Rb,Ib,Ak,Qb,jI,Db,Ck=F(()=>{di();Mi();Oi();Fg();gk();ob();Ye();bk=Us({commentTokens:{block:{open:"<!--",close:"-->"}}}),Ok=new W,yk=vb.configure({props:[de.add(s=>!s.is("Block")||s.is("Document")||Eb(s)!=null||DI(s)?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),Ok.add(Eb),ue.add({Document:()=>null}),gi.add({Document:bk})]});qI=Cu.of((s,t,e)=>{for(let i=st(s).resolveInner(e,-1);i&&!(i.from<t);i=i.parent){let r=i.type.prop(Ok);if(r==null)continue;let n=NI(i,r);if(n>e)return{from:e,to:n}}return null});Tb=Cb(yk),XI=yk.configure([Sb,Ab,wb,kb,{props:[de.add({Table:(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}]),$o=Cb(XI);ih=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(+xk(this.item,t)[2]+e):"";return this.spaceBefore+i+this.type+this.spaceAfter}};Lb=(s={})=>({state:t,dispatch:e})=>{let i=st(t),{doc:r}=t,n=null,o=t.changeByRange(a=>{if(!a.empty||!$o.isActiveAt(t,a.from,-1)&&!$o.isActiveAt(t,a.from,1))return n={range:a};let l=a.from,h=r.lineAt(l),c=vk(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){if(u.item.from<h.from&&!/^[\s>]*$/.test(h.text.slice(0,u.to)))return n={range:a};let b=u.node.firstChild,A=u.node.getChild("ListItem","ListItem");if(b.to>=l||A&&A.to<l||h.from>0&&!/[^\s>]/.test(r.lineAt(h.from-1).text)||s.nonTightLists===!1){let x=c.length>1?c[c.length-2]:null,S,v="";x&&x.item?(S=h.from+x.from,v=x.marker(r,1)):S=h.from+(x?x.to:0);let E=[{from:S,to:l,insert:v}];return u.node.name=="OrderedList"&&$b(u.item,r,E,-2),x&&x.node.name=="OrderedList"&&$b(x.item,r,E),{range:I.cursor(S+v.length),changes:E}}else{let x=wk(c,t,h);return{range:I.cursor(l+x.length+1),changes:{from:h.from,insert:x+t.lineBreak}}}}if(u.node.name=="Blockquote"&&d&&h.from){let b=r.lineAt(h.from-1),A=/>\s*$/.exec(b.text);if(A&&A.index==u.from){let x=t.changes([{from:b.from+A.index,to:b.to},{from:h.from+u.from,to:h.to}]);return{range:a.map(x),changes:x}}}let f=[];u.node.name=="OrderedList"&&$b(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 b=0,A=c.length-1;b<=A;b++)m+=b==A&&!p?c[b].marker(r,1):c[b].blank(b<A?Gt(h.text,4,c[b+1].from)-m.length:null);let g=l;for(;g>h.from&&/\s/.test(h.text.charAt(g-h.from-1));)g--;return m=Pb(m,t),zI(u.node,t.doc)&&(m=wk(c,t,h)+t.lineBreak+m),f.push({from:g,to:l,insert:t.lineBreak+m}),{range:I.cursor(g+m.length+1),changes:f}});return n?!1:(e(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},Mb=Lb();Rb=({state:s,dispatch:t})=>{let e=st(s),i=null,r=s.changeByRange(n=>{let o=n.from,{doc:a}=s;if(n.empty&&$o.isActiveAt(s,n.from)){let l=a.lineAt(o),h=vk(ZI(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:I.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(Gt(l.text,4,c.to)-Gt(l.text,4,c.from));return d==l.from&&(f=Pb(f,s)),{range:I.cursor(d+f.length),changes:{from:d,to:l.from+c.to,insert:f}}}if(d<o)return{range:I.cursor(d),changes:{from:d,to:o}}}}}return i={range:n}});return i?!1:(t(s.update(r,{scrollIntoView:!0,userEvent:"delete"})),!0)},Ib=[{key:"Enter",run:Mb},{key:"Backspace",run:Rb}],Ak=Wu({matchClosingTags:!1});Qb=null;jI=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Db=z.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),!$o.isActiveAt(t.state,i.from,1)))return!1;let n=st(t.state),o=!1;return n.iterate({from:i.from,to:i.to,enter:a=>{(a.from>i.from||jI.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 rh(s,t){for(let e=0,i=t-s.pos-1;;i--,e++){let r=s.peek(i);if(Vi(r)||r==-1)return e}}function Bb(s){return s==32||s==9}function Vi(s){return s==10||s==13}function Mk(s){return Bb(s)||Vi(s)}function sr(s){return s<0||Mk(s)}function Qo(s,t,e=0){return s.peek(e)==t&&s.peek(e+1)==t&&s.peek(e+2)==t&&sr(s.peek(e+3))}function f5(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 Rk(s){return s>=48&&s<=57||s>=97&&s<=102||s>=65&&s<=70}function Ik(s,t){return s.next==37?(s.advance(),Rk(s.next)&&s.advance(),Rk(s.next)&&s.advance(),!0):f5(s.next)||t&&s.next==44?(s.advance(),!0):!1}function Dk(s){if(s.advance(),s.next==60){for(s.advance();;)if(!Ik(s,!0)){s.next==62&&s.advance();break}}else for(;Ik(s,!1););}function zb(s){for(s.advance();!sr(s.next)&&rd(s.next)!="f";)s.advance()}function Zb(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(Vi(n)){if(t)return!1;i=!0}else if(t&&s.pos>=r+1024)return!1}return!i}function p5(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(!Zb(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||Vi(s.next))return!1;s.advance()}}function rd(s){return s<33?"u":s>125?"s":m5[s-33]}function _b(s,t){let e=rd(s);return e!="u"&&!(t&&e=="f")}function Nk(s,t,e,i){if(rd(s.next)=="s"||(s.next==63||s.next==58||s.next==45)&&_b(s.peek(1),e))s.advance();else return!1;let r=s.pos;for(;;){let n=s.next,o=0,a=i+1;for(;Mk(n);){if(Vi(n)){if(t)return!1;a=0}else a++;n=s.peek(++o)}if(!(n>=0&&(n==58?_b(s.peek(o+1),e):n==35?s.peek(o-1)!=32:_b(n,e)))||!e&&a<=i||a==0&&!e&&(Qo(s,45,o)||Qo(s,46,o)))break;if(t&&rd(n)=="f")return!1;for(let h=o;h>=0;h--)s.advance();if(t&&s.pos>r+1024)return!1}return!0}var Po,$k,FI,WI,Pk,UI,Qk,YI,HI,Tk,GI,KI,JI,t5,e5,i5,Lk,s5,r5,n5,o5,a5,l5,h5,Nb,qb,sh,Xb,_i,c5,u5,d5,m5,g5,b5,O5,Vb,qk=F(()=>{Ls();ci();Po=63,$k=64,FI=1,WI=2,Pk=3,UI=4,Qk=5,YI=6,HI=7,Tk=65,GI=66,KI=8,JI=9,t5=10,e5=11,i5=12,Lk=13,s5=19,r5=20,n5=29,o5=33,a5=34,l5=47,h5=0,Nb=1,qb=2,sh=3,Xb=4,_i=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}};_i.top=new _i(null,-1,h5);c5=new $i({start:_i.top,reduce(s,t){return s.type==sh&&(t==r5||t==a5)?s.parent:s},shift(s,t,e,i){if(t==Pk)return new _i(s,rh(i,i.pos),Nb);if(t==Tk||t==Qk)return new _i(s,rh(i,i.pos),qb);if(t==Po)return s.parent;if(t==s5||t==o5)return new _i(s,0,sh);if(t==Lk&&s.type==Xb)return s.parent;if(t==l5){let r=/[1-9]/.exec(i.read(i.pos,e.pos));if(r)return new _i(s,s.depth+ +r[0],Xb)}return s},hash(s){return s.hash}});u5=new vt((s,t)=>{if(s.next==-1&&t.canShift($k))return s.acceptToken($k);let e=s.peek(-1);if((Vi(e)||e<0)&&t.context.type!=sh){if(Qo(s,45))if(t.canShift(Po))s.acceptToken(Po);else return s.acceptToken(FI,3);if(Qo(s,46))if(t.canShift(Po))s.acceptToken(Po);else return s.acceptToken(WI,3);let i=0;for(;s.next==32;)i++,s.advance();(i<t.context.depth||i==t.context.depth&&t.context.type==Nb&&(s.next!=45||!sr(s.peek(1))))&&s.next!=-1&&!Vi(s.next)&&s.next!=35&&s.acceptToken(Po,-i)}},{contextual:!0}),d5=new vt((s,t)=>{if(t.context.type==sh){s.next==63&&(s.advance(),sr(s.next)&&s.acceptToken(HI));return}if(s.next==45)s.advance(),sr(s.next)&&s.acceptToken(t.context.type==Nb&&t.context.depth==rh(s,s.pos-1)?UI:Pk);else if(s.next==63)s.advance(),sr(s.next)&&s.acceptToken(t.context.type==qb&&t.context.depth==rh(s,s.pos-1)?YI:Qk);else{let e=s.pos;for(;;)if(Bb(s.next)){if(s.pos==e)return;s.advance()}else if(s.next==33)Dk(s);else if(s.next==38)zb(s);else if(s.next==42){zb(s);break}else if(s.next==39||s.next==34){if(Zb(s,!0))break;return}else if(s.next==91||s.next==123){if(!p5(s))return;break}else{Nk(s,!0,!1,0);break}for(;Bb(s.next);)s.advance();if(s.next==58){if(s.pos==e&&t.canShift(n5))return;let i=s.peek(1);sr(i)&&s.acceptTokenTo(t.context.type==qb&&t.context.depth==rh(s,e)?GI:Tk,e)}}},{contextual:!0});m5="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";g5=new vt((s,t)=>{if(s.next==33)Dk(s),s.acceptToken(i5);else if(s.next==38||s.next==42){let e=s.next==38?t5:e5;zb(s),s.acceptToken(e)}else s.next==39||s.next==34?(Zb(s,!1),s.acceptToken(JI)):Nk(s,!1,t.context.type==sh,t.context.depth)&&s.acceptToken(KI)}),b5=new vt((s,t)=>{let e=t.context.type==Xb?t.context.depth:-1,i=s.pos;t:for(;;){let r=0,n=s.next;for(;n==32;)n=s.peek(++r);if(!r&&(Qo(s,45,r)||Qo(s,46,r))||!Vi(n)&&(e<0&&(e=Math.max(t.context.depth+1,r)),r<e))break;for(;;){if(s.next<0)break t;let o=Vi(s.next);if(s.advance(),o)continue t;i=s.pos}}s.acceptTokenTo(Lk,i)}),O5=qt({DirectiveName:y.keyword,DirectiveContent:y.attributeValue,"DirectiveEnd DocEnd":y.meta,QuotedLiteral:y.string,BlockLiteralHeader:y.special(y.string),BlockLiteralContent:y.content,Literal:y.content,"Key/Literal Key/QuotedLiteral":y.definition(y.propertyName),"Anchor Alias":y.labelName,Tag:y.typeName,Comment:y.lineComment,": , -":y.separator,"?":y.punctuation,"[ ]":y.squareBracket,"{ }":y.brace}),Vb=ne.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:c5,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[O5],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:[u5,d5,g5,b5,0,1],topRules:{Stream:[0,15]},tokenPrec:0})});var zk={};se(zk,{yaml:()=>Xk,yamlFrontmatter:()=>Bk,yamlLanguage:()=>nd});function Xk(){return new Ct(nd)}function Bk(s){let{language:t,support:e}=s.content instanceof Ct?s.content:{language:s.content,support:[]};return new Ct(v5.configure({wrap:Ts(i=>i.name=="FrontmatterContent"?{parser:nd.parser}:i.name=="Body"?{parser:t.parser}:null)}),e)}var y5,nd,v5,Zk=F(()=>{qk();Oi();Ye();ci();Ls();y5=ne.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}),nd=xe.define({name:"yaml",parser:Vb.configure({props:[ue.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:xo({closing:"}"}),FlowSequence:xo({closing:"]"})}),de.add({"FlowMapping FlowSequence":Bi,"Item Pair BlockLiteral":(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});v5=xe.define({name:"yaml-frontmatter",parser:y5.configure({props:[qt({DashLine:y.meta})]})})});function rr(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 jb(s,t){let e=s.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}function k5(s,{open:t,close:e},i,r){let n=s.sliceDoc(i-nh,i),o=s.sliceDoc(r,r+nh),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*nh?c=u=s.sliceDoc(i,r):(c=s.sliceDoc(i,i+nh),u=s.sliceDoc(r-nh,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 E5(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 od(s,t,e=t.selection.ranges){let i=e.map(n=>jb(t,n.from).block);if(!i.every(n=>n))return null;let r=e.map((n,o)=>k5(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 Fb(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=jb(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 xd(s={}){return[ad,Yk.of(s),z.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?Ub:t.inputType=="historyRedo"?hd:null;return i?(t.preventDefault(),i(e)):!1}})]}function ld(s,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let r=e.field(ad,!1);if(!r)return!1;let n=r.pop(s,e,t);return n?(i(n),!0):!1}}function Kk(s){return function(t){let e=t.field(ad,!1);if(!e)return 0;let i=s==0?e.done:e.undone;return i.length-(i.length&&!i[0].changes?1:0)}}function cd(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 Q5(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 T5(s,t){return s.ranges.length==t.ranges.length&&s.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function Jk(s,t){return s.length?t.length?s.concat(t):s:t}function t1(s,t){if(s.length){let e=s[s.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-L5));return i.length&&i[i.length-1].eq(t)?s:(i.push(t),cd(s,s.length-1,1e9,e.setSelAfter(i)))}else return[Ge.selection([t])]}function M5(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 Yb(s,t){if(!s.length)return s;let e=s.length,i=_e;for(;e;){let r=R5(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?[Ge.selection(i)]:_e}function R5(s,t,e){let i=Jk(s.selectionsAfter.length?s.selectionsAfter.map(a=>a.map(t)):_e,e);if(!s.changes)return Ge.selection(i);let r=s.changes.map(t),n=t.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(n):n;return new Ge(r,G.mapEffects(s.effects,t),o,s.startSelection.map(n),i)}function To(s,t){return I.create(s.ranges.map(t),s.mainIndex)}function Ke(s,t){return s.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function we({state:s,dispatch:t},e){let i=To(s.selection,e);return i.eq(s.selection,!0)?!1:(t(Ke(s,i)),!0)}function or(s,t){return I.cursor(t?s.to:s.from)}function ud(s,t){return we(s,e=>e.empty?s.moveByChar(e,t):or(e,t))}function Jt(s){return s.textDirectionAt(s.state.selection.main.head)==lt.LTR}function Kb(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+Pt(r.text,i-r.from,e),I.cursor(i,e?-1:1)}function e1(s,t){return we(s,e=>e.empty?Kb(s.state,e,t):or(e,t))}function dd(s,t){return we(s,e=>e.empty?s.moveByGroup(e,t):or(e,t))}function Jb(s,t,e){let i=s.state.charCategorizer(t),r=i(e),n=r!=xt.Space;return o=>{let a=i(o);return a!=xt.Space?n&&a==r:(n=!1,!0)}}function n1(s,t,e){let i=s.state.charCategorizer(t.from),r=xt.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==xt.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(f=-1),r==xt.Space&&(r=f),r!=f)return!1;if(r==xt.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))==xt.Word&&p.toLowerCase()==p)return!1;l=!0}return o++,!0},u=s.moveByChar(t,e,d=>(c(d),c));if(r1&&r==xt.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(r1.segment(p));if(m.length>1)return e?I.cursor(t.head+m[1].index,-1):I.cursor(u.head+m[m.length-1].index,1)}}return u}function o1(s,t){return we(s,e=>e.empty?n1(s,e,t):or(e,t))}function j5(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 fd(s,t,e){let i=st(s).resolveInner(t.head),r=e?W.closedBy:W.openedBy;for(let l=t.head;;){let h=e?i.childAfter(l):i.childBefore(l);if(!h)break;j5(s,h,r)?i=h:l=e?h.to:h.from}let n=i.type.prop(r),o,a;return n&&(o=e?ze(s,i.from,1):ze(s,i.to,-1))&&o.matched?a=e?o.end.to:o.end.from:a=e?i.to:i.from,I.cursor(a,e?-1:1)}function h1(s,t){return we(s,e=>{if(!e.empty)return or(e,t);let i=s.moveVertically(e,t);return i.head!=e.head?i:s.moveToLineBoundary(e,t)})}function c1(s){let t=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,e=0,i=0,r;if(t){for(let n of s.state.facet(z.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 u1(s,t){let e=c1(s),{state:i}=s,r=To(i.selection,o=>o.empty?s.moveVertically(o,t,e.height):or(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=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-l}))}return s.dispatch(Ke(i,r),{effects:n}),!0}function gs(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=I.cursor(i.from+n))}return r}function O1(s,t,e){let i=!1,r=To(s.selection,n=>{let o=ze(s,n.head,-1)||ze(s,n.head,1)||n.head>0&&ze(s,n.head-1,1)||n.head<s.doc.length&&ze(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?I.range(n.anchor,a):I.cursor(a)});return i?(t(Ke(s,r)),!0):!1}function te(s,t,e){let i=To(s.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=t&&(r=I.range(r.head,r.anchor));let n=e(r);return I.range(r.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return i.eq(s.state.selection)?!1:(s.dispatch(Ke(s.state,i)),!0)}function md(s,t){return te(s,t,e=>s.moveByChar(e,t))}function gd(s,t){return te(s,t,e=>s.moveByGroup(e,t))}function S1(s,t){return te(s,t,e=>n1(s,e,t))}function k1(s,t){return te(s,t,e=>s.moveVertically(e,t))}function E1(s,t){return te(s,t,e=>s.moveVertically(e,t,c1(s).height))}function D1(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(Ke(e,I.create(r,r.length-1))),!0)}function ar(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=bd(s,l,!1)):l>o&&(e="delete.forward",l=bd(s,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=bd(s,o,!1),a=bd(s,a,!0);return o==a?{range:n}:{changes:{from:o,to:a},range:I.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"?z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function bd(s,t,e){if(s instanceof z)for(let i of s.state.facet(z.atomicRanges).map(r=>r(s)))i.between(t,t,(r,n)=>{r<t&&n>t&&(t=e?n:r)});return t}function yd(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 W1(s,t,e){if(s.readOnly)return!1;let i=[],r=[];for(let n of yd(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(I.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(I.range(l.anchor-a,l.head-a))}}return i.length?(t(s.update({changes:i,scrollIntoView:!0,selection:I.create(r,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}function H1(s,t,e){if(s.readOnly)return!1;let i=[];for(let n of yd(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 lD(s,t){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=st(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(W.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 eE(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&&lD(t,n);s&&(n=o=(o<=a.to?a:t.doc.lineAt(o)).to);let h=new Di(t,{simulateBreak:n,simulateDoubleBreak:!!l}),c=vo(h,n);for(c==null&&(c=Gt(/^\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=["",fs(t,c)];return l&&u.push(fs(t,h.lineIndent(a.from,-1))),{changes:{from:n,to:o,insert:rt.of(u)},range:I.cursor(n+1+u[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function bO(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:I.range(n.mapPos(i.anchor,1),n.mapPos(i.head,1))}})}var _k,Vk,x5,S5,jk,w5,A5,Fk,nh,Wb,Wk,Uk,Yk,ad,C5,Ub,hd,Hk,Gk,$5,P5,Ge,_e,L5,I5,nr,Sd,Hb,Gb,D5,N5,q5,X5,i1,s1,B5,z5,Z5,r1,_5,V5,a1,l1,tO,eO,iO,pd,d1,f1,p1,m1,g1,b1,y1,F5,sO,rO,W5,U5,Y5,H5,v1,x1,G5,K5,J5,tD,eD,w1,A1,nO,oO,aO,lO,C1,$1,P1,Q1,T1,L1,hO,cO,uO,dO,M1,R1,I1,N1,q1,X1,fO,Od,iD,pO,B1,mO,z1,sD,Z1,rD,_1,V1,nD,j1,F1,U1,Y1,G1,K1,J1,oD,aD,gO,tE,iE,vd,OO,sE,hD,cD,rE,nE,wd,Ad,oE=F(()=>{di();Mi();Oi();Ye();_k=s=>{let{state:t}=s,e=t.doc.lineAt(t.selection.main.from),i=jb(s.state,e.from);return i.line?Vk(s):i.block?Fk(s):!1};Vk=rr(Fb,0),x5=rr(Fb,1),S5=rr(Fb,2),jk=rr(od,0),w5=rr(od,1),A5=rr(od,2),Fk=rr((s,t)=>od(s,t,E5(t)),0);nh=50;Wb=oe.define(),Wk=oe.define(),Uk=Z.define(),Yk=Z.define({combine(s){return ae(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)})}}),ad=St.define({create(){return nr.empty},update(s,t){let e=t.state.facet(Yk),i=t.annotation(Wb);if(i){let l=Ge.fromTransaction(t,i.selection),h=i.side,c=h==0?s.undone:s.done;return l?c=cd(c,c.length,e.minDepth,l):c=t1(c,t.startState.selection),new nr(h==0?i.rest:c,h==0?c:i.rest)}let r=t.annotation(Wk);if((r=="full"||r=="before")&&(s=s.isolate()),t.annotation(Et.addToHistory)===!1)return t.changes.empty?s:s.addMapping(t.changes.desc);let n=Ge.fromTransaction(t),o=t.annotation(Et.time),a=t.annotation(Et.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 nr(s.done.map(Ge.fromJSON),s.undone.map(Ge.fromJSON))}});C5=ad;Ub=ld(0,!1),hd=ld(1,!1),Hk=ld(0,!0),Gk=ld(1,!0);$5=Kk(0),P5=Kk(1),Ge=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&&Yt.fromJSON(t.changes),[],t.mapped&&ui.fromJSON(t.mapped),t.startSelection&&I.fromJSON(t.startSelection),t.selectionsAfter.map(I.fromJSON))}static fromTransaction(t,e){let i=_e;for(let r of t.startState.facet(Uk)){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,_e)}static selection(t){return new s(void 0,_e,void 0,void 0,t)}};_e=[],L5=200;I5=/^(input\.type|delete)($|\.)/,nr=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||I5.test(i))&&(!a.selectionsAfter.length&&e-this.prevTime<r.newGroupDelay&&r.joinToEvent(n,Q5(a.changes,t.changes))||i=="input.type.compose")?o=cd(o,o.length-1,r.minDepth,new Ge(t.changes.compose(a.changes),Jk(G.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,_e)):o=cd(o,o.length,r.minDepth,t),new s(o,_e,e,i)}addSelection(t,e,i,r){let n=this.done.length?this.done[this.done.length-1].selectionsAfter:_e;return n.length>0&&e-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&T5(n[n.length-1],t)?this:new s(t1(this.done,t),this.undone,e,i)}addMapping(t){return new s(Yb(this.done,t),Yb(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:Wb.of({side:t,rest:M5(r),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(n.changes){let a=r.length==1?_e:r.slice(0,r.length-1);return n.mapped&&(a=Yb(a,n.mapped)),e.update({changes:n.changes,selection:n.startSelection,effects:n.effects,annotations:Wb.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};nr.empty=new nr(_e,_e);Sd=[{key:"Mod-z",run:Ub,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:hd,preventDefault:!0},{linux:"Ctrl-Shift-z",run:hd,preventDefault:!0},{key:"Mod-u",run:Hk,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Gk,preventDefault:!0}];Hb=s=>ud(s,!Jt(s)),Gb=s=>ud(s,Jt(s)),D5=s=>ud(s,!0),N5=s=>ud(s,!1);q5=s=>e1(s,!0),X5=s=>e1(s,!1);i1=s=>dd(s,!Jt(s)),s1=s=>dd(s,Jt(s)),B5=s=>dd(s,!0),z5=s=>dd(s,!1);Z5=s=>we(s,t=>t.empty?s.moveByChar(t,!0,e=>Jb(s,t.head,e)):or(t,!0)),r1=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;_5=s=>o1(s,!0),V5=s=>o1(s,!1);a1=s=>we(s,t=>fd(s.state,t,!Jt(s))),l1=s=>we(s,t=>fd(s.state,t,Jt(s)));tO=s=>h1(s,!1),eO=s=>h1(s,!0);iO=s=>u1(s,!1),pd=s=>u1(s,!0);d1=s=>we(s,t=>gs(s,t,!0)),f1=s=>we(s,t=>gs(s,t,!1)),p1=s=>we(s,t=>gs(s,t,!Jt(s))),m1=s=>we(s,t=>gs(s,t,Jt(s))),g1=s=>we(s,t=>I.cursor(s.lineBlockAt(t.head).from,1)),b1=s=>we(s,t=>I.cursor(s.lineBlockAt(t.head).to,-1));y1=({state:s,dispatch:t})=>O1(s,t,!1),F5=({state:s,dispatch:t})=>O1(s,t,!0);sO=s=>md(s,!Jt(s)),rO=s=>md(s,Jt(s)),W5=s=>md(s,!0),U5=s=>md(s,!1),Y5=s=>te(s,!0,t=>Kb(s.state,t,!0)),H5=s=>te(s,!1,t=>Kb(s.state,t,!1));v1=s=>gd(s,!Jt(s)),x1=s=>gd(s,Jt(s)),G5=s=>gd(s,!0),K5=s=>gd(s,!1),J5=s=>te(s,!0,t=>s.moveByChar(t,!0,e=>Jb(s,t.head,e)));tD=s=>S1(s,!0),eD=s=>S1(s,!1),w1=s=>{let t=!Jt(s);return te(s,t,e=>fd(s.state,e,t))},A1=s=>{let t=Jt(s);return te(s,t,e=>fd(s.state,e,t))};nO=s=>k1(s,!1),oO=s=>k1(s,!0);aO=s=>E1(s,!1),lO=s=>E1(s,!0),C1=s=>te(s,!0,t=>gs(s,t,!0)),$1=s=>te(s,!1,t=>gs(s,t,!1)),P1=s=>{let t=!Jt(s);return te(s,t,e=>gs(s,e,t))},Q1=s=>{let t=Jt(s);return te(s,t,e=>gs(s,e,t))},T1=s=>te(s,!1,t=>I.cursor(s.lineBlockAt(t.head).from)),L1=s=>te(s,!0,t=>I.cursor(s.lineBlockAt(t.head).to)),hO=({state:s,dispatch:t})=>(t(Ke(s,{anchor:0})),!0),cO=({state:s,dispatch:t})=>(t(Ke(s,{anchor:s.doc.length})),!0),uO=({state:s,dispatch:t})=>(t(Ke(s,{anchor:s.selection.main.anchor,head:0})),!0),dO=({state:s,dispatch:t})=>(t(Ke(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),M1=({state:s,dispatch:t})=>(t(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),R1=({state:s,dispatch:t})=>{let e=yd(s).map(({from:i,to:r})=>I.range(i,Math.min(r+1,s.doc.length)));return t(s.update({selection:I.create(e),userEvent:"select"})),!0},I1=({state:s,dispatch:t})=>{let e=To(s.selection,i=>{let r=st(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 I.range(a.to,a.from)}return i});return e.eq(s.selection)?!1:(t(Ke(s,e)),!0)};N1=s=>D1(s,!1),q1=s=>D1(s,!0),X1=({state:s,dispatch:t})=>{let e=s.selection,i=null;return e.ranges.length>1?i=I.create([e.main]):e.main.empty||(i=I.create([I.cursor(e.main.head)])),i?(t(Ke(s,i)),!0):!1};fO=(s,t,e)=>ar(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=Gt(a,n.tabSize),c=h%Ni(n)||Ni(n);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)r--;l=r}else l=Pt(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=Pt(o.text,l-o.from,!1,!1)+o.from);return l}),Od=s=>fO(s,!1,!0),iD=s=>fO(s,!1,!1),pO=s=>fO(s,!0,!1),B1=(s,t)=>ar(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=Pt(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}),mO=s=>B1(s,!1),z1=s=>B1(s,!0),sD=s=>ar(s,t=>s.moveByChar(t,!0,e=>Jb(s,t.head,e)).head),Z1=s=>ar(s,t=>{let e=s.lineBlockAt(t.head).to;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),rD=s=>ar(s,t=>{let e=s.lineBlockAt(t.head).from;return t.head>e?e:Math.max(0,t.head-1)}),_1=s=>ar(s,t=>{let e=s.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),V1=s=>ar(s,t=>{let e=s.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),nD=({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},j1=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:rt.of(["",""])},range:I.cursor(i.from)}));return t(s.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},F1=({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:Pt(n.text,r-n.from,!1)+n.from,a=r==n.to?r+1:Pt(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:I.cursor(a)}});return e.changes.empty?!1:(t(s.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};U1=({state:s,dispatch:t})=>W1(s,t,!1),Y1=({state:s,dispatch:t})=>W1(s,t,!0);G1=({state:s,dispatch:t})=>H1(s,t,!1),K1=({state:s,dispatch:t})=>H1(s,t,!0),J1=s=>{if(s.state.readOnly)return!1;let{state:t}=s,e=t.changes(yd(t).map(({from:r,to:n})=>(r>0?r--:n<t.doc.length&&n++,{from:r,to:n}))),i=To(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},oD=({state:s,dispatch:t})=>(t(s.update(s.replaceSelection(s.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),aD=({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:I.cursor(e.from+i.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);gO=eE(!1),tE=eE(!0);iE=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=Object.create(null),i=new Di(s,{overrideIndentation:n=>{let o=e[n];return o??-1}}),r=bO(s,(n,o,a)=>{let l=vo(i,n.from);if(l==null)return;/\S/.test(n.text)||(l=0);let h=/^\s*/.exec(n.text)[0],c=fs(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},vd=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(bO(s,(e,i)=>{i.push({from:e.from,insert:s.facet(Xi)})}),{userEvent:"input.indent"})),!0),OO=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(bO(s,(e,i)=>{let r=/^\s*/.exec(e.text)[0];if(!r)return;let n=Gt(r,s.tabSize),o=0,a=fs(s,Math.max(0,n-Ni(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),sE=s=>(s.setTabFocusMode(),!0),hD=s=>(s.setTabFocusMode(2e3),!0),cD=({state:s,dispatch:t})=>s.selection.ranges.some(e=>!e.empty)?vd({state:s,dispatch:t}):(t(s.update(s.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),rE=[{key:"Ctrl-b",run:Hb,shift:sO,preventDefault:!0},{key:"Ctrl-f",run:Gb,shift:rO},{key:"Ctrl-p",run:tO,shift:nO},{key:"Ctrl-n",run:eO,shift:oO},{key:"Ctrl-a",run:g1,shift:T1},{key:"Ctrl-e",run:b1,shift:L1},{key:"Ctrl-d",run:pO},{key:"Ctrl-h",run:Od},{key:"Ctrl-k",run:Z1},{key:"Ctrl-Alt-h",run:mO},{key:"Ctrl-o",run:j1},{key:"Ctrl-t",run:F1},{key:"Ctrl-v",run:pd}],nE=[{key:"ArrowLeft",run:Hb,shift:sO,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:i1,shift:v1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:p1,shift:P1,preventDefault:!0},{key:"ArrowRight",run:Gb,shift:rO,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:s1,shift:x1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:m1,shift:Q1,preventDefault:!0},{key:"ArrowUp",run:tO,shift:nO,preventDefault:!0},{mac:"Cmd-ArrowUp",run:hO,shift:uO},{mac:"Ctrl-ArrowUp",run:iO,shift:aO},{key:"ArrowDown",run:eO,shift:oO,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cO,shift:dO},{mac:"Ctrl-ArrowDown",run:pd,shift:lO},{key:"PageUp",run:iO,shift:aO},{key:"PageDown",run:pd,shift:lO},{key:"Home",run:f1,shift:$1,preventDefault:!0},{key:"Mod-Home",run:hO,shift:uO},{key:"End",run:d1,shift:C1,preventDefault:!0},{key:"Mod-End",run:cO,shift:dO},{key:"Enter",run:gO,shift:gO},{key:"Mod-a",run:M1},{key:"Backspace",run:Od,shift:Od,preventDefault:!0},{key:"Delete",run:pO,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:mO,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:z1,preventDefault:!0},{mac:"Mod-Backspace",run:_1,preventDefault:!0},{mac:"Mod-Delete",run:V1,preventDefault:!0}].concat(rE.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),wd=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:a1,shift:w1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:l1,shift:A1},{key:"Alt-ArrowUp",run:U1},{key:"Shift-Alt-ArrowUp",run:G1},{key:"Alt-ArrowDown",run:Y1},{key:"Shift-Alt-ArrowDown",run:K1},{key:"Mod-Alt-ArrowUp",run:N1},{key:"Mod-Alt-ArrowDown",run:q1},{key:"Escape",run:X1},{key:"Mod-Enter",run:tE},{key:"Alt-l",mac:"Ctrl-l",run:R1},{key:"Mod-i",run:I1,preventDefault:!0},{key:"Mod-[",run:OO},{key:"Mod-]",run:vd},{key:"Mod-Alt-\\",run:iE},{key:"Shift-Mod-k",run:J1},{key:"Shift-Mod-\\",run:y1},{key:"Mod-/",run:_k},{key:"Alt-A",run:jk},{key:"Ctrl-m",mac:"Shift-Alt-m",run:sE}].concat(nE),Ad={key:"Tab",run:vd,shift:OO}});function bs(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 kd(r,n,t||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new kd(i.from,n,i.diagnostic)}}),i}function aE(s,t){let e=t.pos,i=t.end||e,r=s.state.facet(yi).hideOn(s,e,i);if(r!=null)return r;let n=s.startState.doc.lineAt(t.pos);return!!(s.effects.some(o=>o.is(oh))||s.changes.touchesRange(n.from,Math.max(n.to,i)))}function lE(s,t){return s.field(ee,!1)?t:t.concat(G.appendConfig.of(vE))}function hE(s,t){return{effects:lE(s,[oh.of(t)])}}function uD(s){let t=s.field(ee,!1);return t?t.diagnostics.size:0}function fD(s,t,e){let{diagnostics:i}=s.state.field(ee),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(yi).tooltipFilter;return r&&a&&(r=a(r,s.state)),r?{pos:n,end:o,above:!0,create(){return{dom:uE(s,r)}}}:null}function uE(s,t){return Mt("ul",{class:"cm-tooltip-lint"},t.map(e=>bE(s,e,!1)))}function gD(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 mE(s,t){return s?t?(e,i)=>t(s(e,i),i):s:t}function lh(s,t={}){return[yi.of({source:s,config:t}),pE,vE]}function bD(s){let t=s.plugin(pE);t&&t.force()}function gE(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 bE(s,t,e){var i;let r=e?gE(t.actions):[];return Mt("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Mt("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=bs(s.state.field(ee).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),Mt("u",h.slice(c,c+1)),h.slice(c+1)],d=n.markClass?" "+n.markClass:"";return Mt("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},u)}),t.source&&Mt("div",{class:"cm-diagnosticSource"},t.source))}function Cd(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 $d(s){return Cd(`<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 yD(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function OE(s){let t="hint",e=1;for(let i of s){let r=yD(i.severity);r>e&&(e=r,t=i.severity)}return t}function vD(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(yE)&&s.dispatch({effects:wO.of(null)})}};window.addEventListener("mousemove",e)}function xD(s,t,e){function i(){let o=s.elementAtHeight(t.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:wO.of({pos:o.from,above:!1,clip:!1,create(){return{dom:uE(s,e),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,vD(s,t)}let{hoverTime:r}=s.state.facet(Qd),n=setTimeout(i,r);t.onmouseout=()=>{clearTimeout(n),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(n),n=setTimeout(i,r)}}function SD(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 Pd(e[r]).range(+r));return it.of(i,!0)}function Td(s={}){return[Qd.of(s),SO,wD,AD,yE]}function kD(s,t){let e=s.field(ee,!1);if(e&&e.diagnostics.size){let i=[],r=[],n=-1;for(let o=it.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 kd,lr,oh,yO,cE,ee,dD,dE,vO,fE,pD,mD,pE,yi,xO,Ed,ah,OD,Pd,wD,SO,wO,yE,AD,AO,vE,Qd,xE=F(()=>{Mi();di();Qp();kd=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},lr=class s{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let r=i.facet(yi).markerFilter;r&&(t=r(t,i));let n=t.slice().sort((f,p)=>f.from-p.from||f.to-p.to),o=new Qe,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,g;if(a.length)m=l,g=a.reduce((x,S)=>Math.min(x,S.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>u)break;g=p.to,a.push(p),f++}for(;f<n.length;){let x=n[f];if(x.from==m&&(x.to>x.from||x.to==m))a.push(x),f++,g=Math.min(x.to,g);else{g=Math.min(x.from,g);break}}g=Math.min(g,u);let b=!1;if(a.some(x=>x.from==m&&(x.to==g||g==u))&&(b=m==g,!b&&g-m<10)){let x=m-(c+h.value.length);x>0&&(h.next(x),c=m);for(let S=m;;){if(S>=g){b=!0;break}if(!h.lineBreak&&c+h.value.length>S)break;S=c+h.value.length,c+=h.value.length,h.next()}}let A=OE(a);if(b)o.add(m,m,U.widget({widget:new xO(A),diagnostics:a.slice()}));else{let x=a.reduce((S,v)=>v.markClass?S+" "+v.markClass:S,"");o.add(m,g,U.mark({class:"cm-lintRange cm-lintRange-"+A+x,diagnostics:a.slice(),inclusiveEnd:a.some(S=>S.to>g)}))}if(l=g,l==u)break;for(let x=0;x<a.length;x++)a[x].to<=l&&a.splice(x--,1)}let d=o.finish();return new s(d,e,bs(d))}};oh=G.define(),yO=G.define(),cE=G.define(),ee=St.define({create(){return new lr(U.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=bs(e,s.selected.diagnostic,n)||bs(e,null,n)}!e.size&&r&&t.state.facet(yi).autoPanel&&(r=null),s=new lr(e,r,i)}for(let e of t.effects)if(e.is(oh)){let i=t.state.facet(yi).autoPanel?e.value.length?ah.open:null:s.panel;s=lr.init(e.value,i,t.state)}else e.is(yO)?s=new lr(s.diagnostics,e.value?ah.open:null,s.selected):e.is(cE)&&(s=new lr(s.diagnostics,s.panel,e.value));return s},provide:s=>[go.from(s,t=>t.panel),z.decorations.from(s,t=>t.diagnostics)]});dD=U.mark({class:"cm-lintRange cm-lintRange-active"});dE=s=>{let t=s.state.field(ee,!1);(!t||!t.panel)&&s.dispatch({effects:lE(s.state,[yO.of(!0)])});let e=pu(s,ah.open);return e&&e.dom.querySelector(".cm-panel-lint ul").focus(),!0},vO=s=>{let t=s.state.field(ee,!1);return!t||!t.panel?!1:(s.dispatch({effects:yO.of(!1)}),!0)},fE=s=>{let t=s.state.field(ee,!1);if(!t)return!1;let e=s.state.selection.main,i=bs(t.diagnostics,null,e.to+1);return!i&&(i=bs(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}),Ou(s,i.from,1,{tooltip:AO,until:r=>r.docChanged||r.newSelection.main.head<i.from||r.newSelection.main.head>i.to}),!0)},pD=s=>{var t;let{state:e}=s,i=e.field(ee,!1);if(!i)return!1;let r=e.selection.main,n,o,a,l;if(i.diagnostics.between(0,e.doc.length,(u,d)=>{d<r.to&&(n==null||n<u)&&(n=u,o=d),(a==null||u>a)&&(a=u,l=d)}),a==null||n==null&&a==r.from)return!1;let h=n??a,c=(t=o??l)!==null&&t!==void 0?t:h;return s.dispatch({selection:{anchor:h,head:c},scrollIntoView:!0}),Ou(s,h,1,{tooltip:AO,until:u=>u.docChanged||u.newSelection.main.head<h||u.newSelection.main.head>c}),!0},mD=[{key:"Mod-Shift-m",run:dE,preventDefault:!0},{key:"F8",run:fE}],pE=gt.fromClass(class{constructor(s){this.view=s,this.timeout=-1,this.set=!0;let{delay:t}=s.state.facet(yi);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(yi);e.length&&gD(e.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==t.doc&&this.view.dispatch(hE(this.view.state,i.reduce((r,n)=>r.concat(n))))},i=>{Rt(this.view.state,i)})}}update(s){let t=s.state.facet(yi);(s.docChanged||t!=s.startState.facet(yi)||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)}});yi=Z.define({combine(s){return{sources:s.map(t=>t.source).filter(t=>t!=null),...ae(s.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:mE,tooltipFilter:mE,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})}}});xO=class extends _t{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Mt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},Ed=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=bE(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},ah=class s{constructor(t){this.view=t,this.items=[];let e=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)vO(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=gE(n.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==r.keyCode){let l=bs(this.view.state.field(ee).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=Mt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:i}),this.dom=Mt("div",{class:"cm-panel-lint"},this.list,Mt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>vO(this.view)},"\xD7")),this.update()}get selectedIndex(){let t=this.view.state.field(ee).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(ee),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 Ed(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 Ed(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(ee),i=bs(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:cE.of(i)})}static open(t){return new s(t)}};OD=z.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:$d("#f11")},".cm-lintRange-warning":{backgroundImage:$d("orange")},".cm-lintRange-info":{backgroundImage:$d("#999")},".cm-lintRange-hint":{backgroundImage:$d("#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"}}});Pd=class extends ce{constructor(t){super(),this.diagnostics=t,this.severity=OE(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(Qd).tooltipFilter;return r&&(i=r(i,t.state)),i.length&&(e.onmouseover=()=>xD(t,e,i)),e}};wD=Rl({class:"cm-gutter-lint",markers:s=>s.state.field(SO),widgetMarker:(s,t,e)=>{let i=[];return s.state.field(SO).between(e.from,e.to,(r,n,o)=>{r>e.from&&r<e.to&&i.push(...o.diagnostics)}),i.length?new Pd(i):null}}),SO=St.define({create(){return it.empty},update(s,t){s=s.map(t.changes);let e=t.state.facet(Qd).markerFilter;for(let i of t.effects)if(i.is(oh)){let r=i.value;e&&(r=e(r||[],t.state)),s=SD(t.state.doc,r.slice(0))}return s}}),wO=G.define(),yE=St.define({create(){return null},update(s,t){return s&&t.docChanged&&(s=aE(t,s)?null:{...s,pos:t.changes.mapPos(s.pos)}),t.effects.reduce((e,i)=>i.is(wO)?i.value:e,s)},provide:s=>Fs.from(s)}),AD=z.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Cd('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Cd('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Cd('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),AO=Vm(fD,{hideOn:aE}),vE=[ee,z.decorations.compute([ee],s=>{let{selected:t,panel:e}=s.field(ee);return!t||!e||t.from==t.to?U.none:U.set([dD.range(t.from,t.to)])}),AO,OD],Qd=Z.define({combine(s){return ae(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}})});var EO={};se(EO,{Compartment:()=>os,EditorSelection:()=>I,EditorState:()=>dt,EditorView:()=>z,HighlightStyle:()=>qi,LOAD_TIMEOUT_MS:()=>kO,LanguageSupport:()=>Ct,StateEffect:()=>G,adiaBaseTheme:()=>ED,adiaHighlightStyle:()=>CD,defaultHighlightStyle:()=>Qu,defaultKeymap:()=>wd,drawSelection:()=>mu,highlightActiveLine:()=>gu,highlightActiveLineGutter:()=>xu,history:()=>xd,historyKeymap:()=>Sd,importWithTimeout:()=>PD,indentWithTab:()=>Ad,jsonLinter:()=>QD,keymap:()=>mi,languages:()=>$D,lineNumbers:()=>vu,lintGutter:()=>Td,linter:()=>lh,placeholder:()=>bu,syntaxHighlighting:()=>Pu});function PD(s,t){return Promise.race([s(),new Promise((e,i)=>setTimeout(()=>i(new Error(`code-editor: ${t} load timed out after ${kO}ms`)),kO))])}function TD(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 ED,CD,$D,kO,QD,CO=F(()=>{"use strict";di();Mi();oE();Oi();xE();ci();ED=z.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{caretColor:"inherit"},".cm-focused":{outline:"none"}}),CD=qi.define([{tag:[y.comment,y.lineComment,y.blockComment,y.docComment],class:"tok-comment"},{tag:[y.keyword,y.controlKeyword,y.modifier,y.operatorKeyword],class:"tok-keyword"},{tag:[y.string,y.character,y.regexp,y.escape,y.special(y.string)],class:"tok-string"},{tag:[y.number,y.integer,y.float],class:"tok-number"},{tag:[y.bool,y.null,y.atom],class:"tok-boolean"},{tag:[y.operator,y.logicOperator,y.arithmeticOperator,y.compareOperator,y.updateOperator,y.definitionOperator],class:"tok-operator"},{tag:[y.punctuation,y.bracket,y.paren,y.brace,y.squareBracket,y.angleBracket,y.separator],class:"tok-punctuation"},{tag:[y.function(y.variableName),y.function(y.propertyName),y.macroName],class:"tok-function"},{tag:[y.variableName,y.local(y.variableName),y.self],class:"tok-variable"},{tag:[y.typeName,y.className,y.namespace],class:"tok-type"},{tag:[y.propertyName,y.labelName,y.definition(y.variableName)],class:"tok-property"},{tag:[y.tagName,y.heading,y.contentSeparator],class:"tok-tag"},{tag:[y.attributeName,y.attributeValue],class:"tok-attribute"},{tag:[y.url,y.link],class:"tok-url"},{tag:[y.invalid,y.deleted],class:"tok-invalid"}]),$D={json:()=>Promise.resolve().then(()=>(iw(),ew)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(ob(),RA)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(Jg(),SA)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Ag(),Lw)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(Ck(),Ek)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Zk(),zk)).then(s=>({extension:s.yaml()}))},kO=1e4;QD=lh(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}=TD(i,t);return[{from:r,to:n,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function Id(s){return Vt.get(s)||null}function XE(s,t){Vt.set(s,t)}var Vt,qO=F(()=>{"use strict";Vt=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"],["DateRangePicker","date-range-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"],["RadioGroup","radio-group-ui"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorArea","color-area-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"],["AnchorBar","anchor-bar-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"],["Drilldown","drilldown-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"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-ui"],["ToolbarGroup","toolbar-group-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-area-ui","color-area-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"],["UIChatThread","chat-thread-ui"],["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"],["AdiaMark","adia-mark-ui"],["AdiaWordmark","adia-wordmark-ui"],["AgentArtifact","agent-artifact-ui"],["AgentFeedbackBar","agent-feedback-bar-ui"],["AgentQuestions","agent-questions-ui"],["AgentReasoning","agent-reasoning-ui"],["AgentSuggestions","agent-suggestions-ui"],["AgentTrace","agent-trace-ui"],["Aside","aside-ui"],["Blockquote","blockquote-ui"],["Canvas","canvas-ui"],["ChartLegend","chart-legend-ui"],["ColorInput","color-input-ui"],["ContextMenu","context-menu-ui"],["DemoToggle","demo-toggle-ui"],["DisplayField","display-field-ui"],["Feed","feed-ui"],["FeedItem","feed-item-ui"],["Fields","fields-ui"],["Frame","frame-ui"],["InlineEdit","inline-edit-ui"],["InlineMessage","inline-message-ui"],["ListWindow","list-window-ui"],["LoadingOverlay","loading-overlay-ui"],["Mark","mark-ui"],["MenuDivider","menu-divider-ui"],["MenuItem","menu-item-ui"],["MenuLabel","menu-label-ui"],["NumberFormat","number-format-ui"],["Page","page-ui"],["PasswordStrength","password-strength-ui"],["PipelineStatus","pipeline-status-ui"],["Preview","preview-ui"],["QRCode","qr-code-ui"],["RelativeTime","relative-time-ui"],["Search","search-ui"],["SkipNav","skip-nav-ui"],["Spinner","spinner-ui"],["StepProgress","step-progress-ui"],["Swatch","swatch-ui"],["TableFooter","table-footer-ui"],["TableOfContents","toc-ui"],["TableToolbar","table-toolbar-ui"],["TagsInput","tags-input-ui"],["ThemeProvider","theme-provider"],["TimePicker","time-picker-ui"],["ToggleScheme","toggle-scheme-ui"],["Tree","tree-ui"],["TreeItem","tree-item-ui"],["VisuallyHidden","visually-hidden-ui"],["AdminEntityItem","admin-entity-item"],["AdminRoster","admin-roster-ui"],["AdminSettings","admin-settings-ui"],["AgentAdmin","agent-admin-ui"],["AppShell","embed-shell"],["BillingOverview","billing-overview-ui"],["ConfirmDialog","confirm-dialog-ui"],["DashboardLayout","dashboard-layout-ui"],["DateRangeSelector","date-range-selector-ui"],["FormPopover","form-popover-ui"],["IntegrationsPage","integrations-page-ui"],["InvoiceDetail","invoice-detail-ui"],["InvoiceHistory","invoice-history-ui"],["NotificationPreferences","notification-preferences-ui"],["OnboardingChecklist","onboarding-checklist-ui"],["PaymentMethodForm","payment-method-form-ui"],["PaymentMethodList","payment-method-list-ui"],["PlanPicker","plan-picker-ui"],["chat-thread-ui","chat-thread-ui"],["section-ui","section-ui"],["DescriptionTerm","dt"],["DescriptionDetail","dd"]])});function Dd(s){return!s||s==="/"}function XO(s){return s.split("/").filter(Boolean)}function BE(s){return s.replace(/^\//,"").split("/")}function zE(s,t){return Dd(t)?s:XO(t).reduce((e,i)=>e?.[i],s)}function ZE(s,t,e){if(Dd(t))return;let i=XO(t),r=s;for(let n=0;n<i.length-1;n++)r[i[n]]==null&&(r[i[n]]={}),r=r[i[n]];r[i[i.length-1]]=e}function BO(s,t){if(Dd(t))return s;let e=BE(t),i=s;for(let r of e){if(i==null)return;i=i[r]}return i}function _E(s,t,e){if(Dd(t))return;let i=BE(t),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}function VE(s,t){if(!t||!s)return;let e=XO(t),i=s;for(let r of e){if(i==null||typeof i!="object")return;i=i[r]}return i}var Nd=F(()=>{"use strict"});var qd,ya,zO=F(()=>{"use strict";Nd();qd={provider:0,controller:1,source:2,action:3,lifecycle:4},ya=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?BO(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)=>(qd[i.kind]??9)-(qd[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)=>(qd[i[1].dockable.kind]??9)-(qd[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){_E(this.#e,t,e);for(let[i,r]of this.#s)if(t===i||t.startsWith(i+"/"))for(let n of r)n(BO(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 Ae,ur=F(()=>{"use strict";Ae=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 va,ZO=F(()=>{"use strict";ur();va=class extends Ae{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 xa,_O=F(()=>{"use strict";ur();xa=class extends Ae{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 Xd,Sa,VO=F(()=>{"use strict";ur();Xd={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"},Sa=class extends Ae{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=Xd[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 wa,jO=F(()=>{"use strict";ur();wa=class extends Ae{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,FO=F(()=>{"use strict";ur();Aa=class extends Ae{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 jE,ke,dr=F(()=>{"use strict";jE=new WeakSet,ke=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!jE.has(e)&&e!==s&&(jE.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 FE={};se(FE,{FormController:()=>WO});var WO,WE=F(()=>{"use strict";dr();WO=class extends ke{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 UE={};se(UE,{DataStreamController:()=>UO});var UO,YE=F(()=>{"use strict";dr();UO=class extends ke{static schema=Object.freeze({name:"data-stream",state:{data:"array",status:"string",error:"string"},commands:["push","pushMany","connect","poll","consume","stop","clear"],attributes:["data-stream-status"]});#t=[];#e;#i="idle";#s=null;#r=null;#n=0;#a=1;#o=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:r=[]}={}){super(),this.#e=t,this.#n=e,this.#a=Math.max(1,Math.round(i)),this.#t=r.slice(-t)}getState(){return{data:this.#t,status:this.#i,error:this.#s}}reflect(){this.host&&this.host.setAttribute("data-stream-status",this.#i)}onDisconnect(){this.commands.stop()}#c(t){this.#l++,!(this.#a>1&&this.#l%this.#a!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#d())}#h(t){if(this.#a>1){let e=[];for(let i of t)this.#l++,this.#l%this.#a===0&&e.push(i);this.#t.push(...e)}else this.#t.push(...t);this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#d()}#d(){if(this.#n<=0){this.notify();return}this.#o===null&&(this.#o=setTimeout(()=>{this.#o=null,this.notify()},this.#n))}#u(t,e=null){this.#i=t,this.#s=e,this.notify()}commands={push:t=>{this.#c(t)},pushMany:t=>{this.#h(t)},connect:(t,e)=>{this.commands.stop(),this.#r=new AbortController,t==="sse"?this.#f(e):t==="ws"?this.#p(e):this.#u("error",`Unknown stream type: ${t}`)},poll:(t,e=2e3)=>{this.commands.stop(),this.#r=new AbortController,this.#m(t,e)},consume:t=>{this.commands.stop(),this.#r=new AbortController,this.#g(t)},stop:()=>{this.#r&&(this.#r.abort(),this.#r=null),this.#o!==null&&(clearTimeout(this.#o),this.#o=null),(this.#i==="streaming"||this.#i==="connecting")&&this.#u("stopped")},clear:()=>{this.#t=[],this.notify()}};#f(t){this.#u("connecting");let e=new EventSource(t),i=this.#r.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#u("streaming"),e.onmessage=r=>{try{let n=JSON.parse(r.data);this.#c(n)}catch{}},e.onerror=()=>{i.aborted||(this.#u("error","SSE connection lost"),e.close())}}#p(t){this.#u("connecting");let e=new WebSocket(t),i=this.#r.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#u("streaming"),e.onmessage=r=>{try{let n=JSON.parse(r.data);Array.isArray(n)?this.#h(n):this.#c(n)}catch{}},e.onerror=()=>{i.aborted||this.#u("error","WebSocket error")},e.onclose=()=>{i.aborted||this.#u("stopped")}}async#m(t,e){this.#u("streaming");let i=this.#r.signal;for(;!i.aborted;){try{let n=await(await fetch(t,{signal:i})).json();Array.isArray(n)?this.#h(n):this.#c(n)}catch(r){if(i.aborted)break;this.#u("error",r.message);break}await new Promise(r=>setTimeout(r,e))}}async#g(t){this.#u("streaming");let e=this.#r.signal;try{for await(let i of t){if(e.aborted)break;Array.isArray(i)?this.#h(i):this.#c(i)}e.aborted||this.#u("idle")}catch(i){e.aborted||this.#u("error",i.message)}}}});var HE={};se(HE,{SelectionController:()=>YO});var YO,GE=F(()=>{"use strict";dr();YO=class extends ke{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 KE={};se(KE,{ToggleController:()=>HO});var HO,JE=F(()=>{"use strict";dr();HO=class extends ke{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 tC={};se(tC,{AccordionController:()=>GO});var GO,eC=F(()=>{"use strict";dr();GO=class extends ke{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 iC={};se(iC,{StateMachineController:()=>KO});var KO,sC=F(()=>{"use strict";dr();KO=class extends ke{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 rC(s,t){Ui.controllers.set(s,t)}function nC(s,t){Ui.handlers.set(s,t)}function oC(s,t){Ui.resolvers.set(s,t)}async function Bd(s){let t=Ui.controllers.get(s);return t?t():null}function zd(s){return Ui.handlers.get(s)||null}async function dh(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=Ui.resolvers.get(r);if(!n)throw new Error(`No resolver for scheme "${r}"`);return n(e,t)}async function nN(s){let{action:t,params:e}=s,i=JO(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=Ui.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 oN(s){let{action:t}=s,e=JO(t.value,s);s.updateModel(t.path,e)}async function aN(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 lN(){history.back()}async function hN(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 cN(s){let{action:t,source:e}=s,i=JO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function uN(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function dN(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 JO(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 VE(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}async function fN(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 pN(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 mN(s,t){return{_source:s,_mock:!0}}var Ui,ty=F(()=>{"use strict";Nd();Ui={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(WE(),FE))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(YE(),UE))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(GE(),HE))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(JE(),KE))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(eC(),tC))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(sC(),iC))).StateMachineController]]),handlers:new Map([["submit-resource",nN],["update-model",oN],["navigate",aN],["navigate-back",lN],["controller-command",hN],["emit-event",cN],["refresh-source",uN],["notify",dN]]),resolvers:new Map([["resource",fN],["api",pN],["mock",mN]])}});function gN(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:dh};return s(r)}}function bN(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=zd(t);if(!e)return null;let i=gN(e);return s.set(t,i),i}}function ON(){return async s=>Bd(s)}function yN(){return async(s,t)=>dh(s,{})}function Zd(s){let t=[],e=bN(),i=ON(),r=yN();if(s.data?.sources)for(let o of s.data.sources)t.push(new xa(o,r));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new va(o,i));if(s.actions)for(let o of s.actions)t.push(new Sa(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new wa(a))}s.lifecycle&&t.push(new Aa(s.lifecycle,e));let n=s.state?.model||null;return{dockables:t,initialModel:n}}var ey=F(()=>{"use strict";ZO();_O();VO();jO();FO();ty()});var aC={};se(aC,{WiringEngine:()=>fh});var fh,iy=F(()=>{"use strict";zO();ey();fh=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}=Zd(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))}undockIds(t,e){let i=this.#t.get(t);i&&i.undockMany(e)}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 ya(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}}});function Os(s){return SN.has(s.toLowerCase())?s.toLowerCase():s.replace(/([A-Z])/g,"-$1").toLowerCase()}function _d(s,t,e){if(t==="style"&&typeof e=="string"){s.style.cssText=e;return}if(vN.has(t)&&e!=null){if(t==="textContent"&&!xN.has(s.localName)){s.setAttribute("text",String(e));return}let i=e;if(typeof i=="string"&&(i.startsWith("[")||i.startsWith("{")))try{i=JSON.parse(i)}catch{}s[t]=i;return}if(typeof e=="boolean"){e?s.setAttribute(Os(t),""):s.removeAttribute(Os(t));return}e!=null?s.setAttribute(Os(t),String(e)):s.removeAttribute(Os(t))}var vN,xN,SN,sy=F(()=>{"use strict";vN=new Set(["data","columns","options","itemRenderer","textContent","pageSizeOptions"]),xN=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui","kbd-ui"]),SN=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"])});var ys,lC=F(()=>{"use strict";qO();sy();Nd();ys=class s{#t;#e;#i=new Map;#s=new Map;#r=new Map;#n=[];#a=null;#o=!1;constructor(t,e=Vt,{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.#h(t))}#l(){this.#a=null;let t=this.#n.splice(0);for(let e of t)try{this.#h(e)}catch(i){console.error("A2UI: message failed during batch flush",i),this.#_(null,"a2ui-message-error",{error:i,messageType:e?.type||e?.messageType})}}static#c=new Set(["updateComponents","updateDataModel","wireComponents","updateStyles","removeStyles"]);#h(t){let e=t.type||t.messageType,i=t.surfaceId;if(i&&s.#c.has(e)){let r=this.#i.get(i);if(r&&!r.synthetic&&this.#u(r)){r.lifecycle.buffer.push(t);return}}this.#d(t)}#d(t){switch(t.type||t.messageType){case"createSurface":this.#m(t);return;case"updateComponents":this.#g(t);return;case"updateDataModel":this.#k(t);return;case"wireComponents":return this.#p(t);case"deleteSurface":this.#w(t);return;case"updateStyles":this.#R(t);return;case"removeStyles":this.#q(t);return;case"meta":return;default:console.warn("A2UI: unknown message type",t.type);return}}#u(t){return t.lifecycle.state==="pending-first"||t.lifecycle.state==="pending-stale"}#f=null;async#p(t){if(!this.#f){let{WiringEngine:e}=await Promise.resolve().then(()=>(iy(),aC));this.#f=new e({updateDataModel:(i,r,n)=>{this.#k({surfaceId:i,path:r,value:n})},getElement:(i,r)=>this.#i.get(i)?.elements.get(r)||null})}await this.#f.process(t)}async processStream(t){for await(let e of t)this.process(e)}#m({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t)){let n=this.#i.get(t);this.#_(n.root,"a2ui-duplicate-surface-id",{surfaceId:t});let o=new Error(`A2UI: duplicate createSurface for surfaceId "${t}" \u2014 REQ-002 (spec-a2ui-v1-conformance.md) makes this a hard error. Regenerate an existing surface with renderer.beginSurfaceUpdate(surfaceId) \u2192 applyTo \u2192 commitSurfaceUpdate instead (spec-a2ui-surface-lifecycle.md).`);throw o.code="DUPLICATE_SURFACE_ID",o.surfaceId=t,o}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,synthetic:!1,lifecycle:{state:"empty",generationId:null,buffer:null,mode:"replace",reason:null,hadError:!1}})}#g({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,synthetic:!0,lifecycle:null},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.#A(l.variant,l):Id(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.#C(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#S(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#b=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#O=new Set(["Header","Section","Footer"]);static#v=new Set(["header","body","footer"]);#y=new Set;#S(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.#O:s.#b,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.#v.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#y.has(u)||(this.#y.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#x={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};#A(t,e){return!e?.slot&&s.#x[t]?s.#x[t]:"text-ui"}#C(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#x[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.#P(a,e._surfaceId);n[o]=h,!(r&&Object.is(r[o],h))&&(h==null&&!l||_d(t,o,h))}if(r)for(let o of Object.keys(r))!(o in n)&&!i.has(o)&&t.removeAttribute(Os(o));this.#r.set(e.id,n)}#P(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?zE(i.dataModel,t.path):t.path}return t}#k({surfaceId:t,path:e,value:i}){let r=this.#i.get(t);if(r){!e||e==="/"?r.dataModel=i??{}:ZE(r.dataModel,e,i);for(let[n,o]of r.bindings){let a=r.elements.get(n);a&&this.#C(a,o)}}}#w({surfaceId:t}){let e=this.#i.get(t);if(e){this.#f?.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)}}#E=0;#T(){return this.#E+=1,`g${this.#E}-${Date.now().toString(36)}`}#$(t,e){t.root?.setAttribute?.("data-a2ui-lifecycle",e)}#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{}}beginSurfaceUpdate(t,{generationId:e,reason:i=null,mode:r="replace"}={}){let n=this.#i.get(t);if(!n)return console.warn(`A2UI: beginSurfaceUpdate \u2014 no such surface "${t}"`),null;if(n.synthetic)return console.warn(`A2UI: beginSurfaceUpdate \u2014 surfaceId "${t}" is synthetic (no prior createSurface); lifecycle is a no-op here. Send createSurface first.`),null;let o=n.lifecycle,a=o.state==="error-empty"||o.state==="error-stale",h=o.state==="live"||o.state==="error-stale"?"pending-stale":"pending-first";return o.state=h,o.generationId=typeof e=="string"&&e?e:this.#T(),o.buffer=[],o.mode=r==="patch"?"patch":"replace",o.reason=i,o.hadError=a,this.#$(n,h),this.#L(n.root,"surface-pending",{surfaceId:t,generationId:o.generationId,reason:i,firstRender:h==="pending-first"}),o.generationId}applyTo(t,e){let i=Array.isArray(e)?e:[e];for(let r of i)this.#h({...r,surfaceId:t})}async commitSurfaceUpdate(t,e){let i=this.#i.get(t);if(!i||i.synthetic)return console.warn(`A2UI: commitSurfaceUpdate \u2014 no such lifecycle surface "${t}"`),!1;let r=i.lifecycle;if(!this.#u(i))return console.warn(`A2UI: commitSurfaceUpdate \u2014 surface "${t}" has no in-flight generation to commit`),!1;if(e!=null&&e!==r.generationId)return!1;let n=r.buffer||[],o=r.generationId,a=r.hadError,l=[],h=[];if(r.mode==="replace"){let c=new Set,u=!1,d=new Set,f=!1;for(let p of n){let m=p.type||p.messageType;if(m==="updateComponents"){u=!0;for(let g of p.components||[])g.id!=null&&c.add(g.id)}else m==="updateStyles"&&(f=!0,typeof p.styleId=="string"&&d.add(p.styleId))}for(let p of n)await this.#d(p);u&&(l=this.#M(t,c)),f&&(h=this.#Q(t,d))}else for(let c of n)await this.#d(c);return r.state="live",r.buffer=null,r.generationId=null,r.reason=null,r.hadError=!1,this.#$(i,"live"),this.#L(i.root,"surface-committed",{surfaceId:t,generationId:o,healed:a,swept:l,stylesSwept:h}),!0}#Q(t,e){let i=this.#i.get(t);if(!i||!i.adoptedSheets||i.adoptedSheets.size===0)return[];let r=[];for(let n of[...i.adoptedSheets.keys()]){if(e.has(n))continue;let o=i.adoptedSheets.get(n);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet),i.adoptedSheets.delete(n),this.#N(i.root,"styles-removed",{surfaceId:t,styleId:n}),r.push(n)}return r}#M(t,e){let i=this.#i.get(t);if(!i)return[];let r=[];for(let n of[...i.elements.keys()]){if(e.has(n))continue;i.elements.get(n)?.remove(),i.elements.delete(n),this.#s.delete(n),i.bindings.delete(n),this.#r.delete(n),r.push(n)}return r.length>0&&this.#f?.undockIds(t,r),r}abortSurfaceUpdate(t,e,i){let r=this.#i.get(t);if(!r||r.synthetic)return console.warn(`A2UI: abortSurfaceUpdate \u2014 no such lifecycle surface "${t}"`),!1;let n=r.lifecycle;if(!this.#u(r))return console.warn(`A2UI: abortSurfaceUpdate \u2014 surface "${t}" has no in-flight generation to abort`),!1;if(e!=null&&e!==n.generationId)return!1;let o=n.generationId,a=n.state==="pending-first"?"error-empty":"error-stale";return n.state=a,n.buffer=null,n.generationId=null,n.reason=null,n.hadError=!0,this.#$(r,a),this.#L(r.root,"surface-aborted",{surfaceId:t,generationId:o,error:i??null}),!0}getLifecycle(t){let e=this.#i.get(t);return e&&!e.synthetic?e.lifecycle:null}isPending(t){let e=this.getLifecycle(t);return e?.state==="pending-first"||e?.state==="pending-stale"}get pendingSurfaces(){let t=[];for(let[e,i]of this.#i)!i.synthetic&&this.#u(i)&&t.push(e);return t}static#I=new Set(["root","html","body"]);#R({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#N(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#N(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.#N(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let n=this.#z(i,t);if(n.rejected){this.#N(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.#N(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.#N(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#z(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.#X(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.#B(r,e),o=this.#D(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}}#X(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.#Z(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.#I.has(a))return`forbidden-${a}-selector`}}return null}#Z(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}#B(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}#D(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 ED,CD,$D,kO,QD,CO=F(()=>{"use strict";di();Mi();oE();Oi();xE();ci();ED=z.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{caretColor:"inherit"},".cm-focused":{outline:"none"}}),CD=qi.define([{tag:[y.comment,y.lineComment,y.blockComment,y.docComment],class:"tok-comment"},{tag:[y.keyword,y.controlKeyword,y.modifier,y.operatorKeyword],class:"tok-keyword"},{tag:[y.string,y.character,y.regexp,y.escape,y.special(y.string)],class:"tok-string"},{tag:[y.number,y.integer,y.float],class:"tok-number"},{tag:[y.bool,y.null,y.atom],class:"tok-boolean"},{tag:[y.operator,y.logicOperator,y.arithmeticOperator,y.compareOperator,y.updateOperator,y.definitionOperator],class:"tok-operator"},{tag:[y.punctuation,y.bracket,y.paren,y.brace,y.squareBracket,y.angleBracket,y.separator],class:"tok-punctuation"},{tag:[y.function(y.variableName),y.function(y.propertyName),y.macroName],class:"tok-function"},{tag:[y.variableName,y.local(y.variableName),y.self],class:"tok-variable"},{tag:[y.typeName,y.className,y.namespace],class:"tok-type"},{tag:[y.propertyName,y.labelName,y.definition(y.variableName)],class:"tok-property"},{tag:[y.tagName,y.heading,y.contentSeparator],class:"tok-tag"},{tag:[y.attributeName,y.attributeValue],class:"tok-attribute"},{tag:[y.url,y.link],class:"tok-url"},{tag:[y.invalid,y.deleted],class:"tok-invalid"}]),$D={json:()=>Promise.resolve().then(()=>(iw(),ew)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(ob(),RA)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(Jg(),SA)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Ag(),Lw)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(Ck(),Ek)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Zk(),zk)).then(s=>({extension:s.yaml()}))},kO=1e4;QD=lh(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}=TD(i,t);return[{from:r,to:n,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function Id(s){return Vt.get(s)||null}function XE(s,t){Vt.set(s,t)}var Vt,qO=F(()=>{"use strict";Vt=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"],["DateRangePicker","date-range-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"],["RadioGroup","radio-group-ui"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorArea","color-area-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"],["AnchorBar","anchor-bar-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"],["Drilldown","drilldown-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"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-ui"],["ToolbarGroup","toolbar-group-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-area-ui","color-area-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"],["UIChatThread","chat-thread-ui"],["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"],["AdiaMark","adia-mark-ui"],["AdiaWordmark","adia-wordmark-ui"],["AgentArtifact","agent-artifact-ui"],["AgentFeedbackBar","agent-feedback-bar-ui"],["AgentQuestions","agent-questions-ui"],["AgentReasoning","agent-reasoning-ui"],["AgentSuggestions","agent-suggestions-ui"],["AgentTrace","agent-trace-ui"],["Aside","aside-ui"],["Blockquote","blockquote-ui"],["Canvas","canvas-ui"],["ChartLegend","chart-legend-ui"],["ColorInput","color-input-ui"],["ContextMenu","context-menu-ui"],["DemoToggle","demo-toggle-ui"],["DisplayField","display-field-ui"],["Feed","feed-ui"],["FeedItem","feed-item-ui"],["Fields","fields-ui"],["Frame","frame-ui"],["InlineEdit","inline-edit-ui"],["InlineMessage","inline-message-ui"],["ListWindow","list-window-ui"],["LoadingOverlay","loading-overlay-ui"],["Mark","mark-ui"],["MenuDivider","menu-divider-ui"],["MenuItem","menu-item-ui"],["MenuLabel","menu-label-ui"],["NumberFormat","number-format-ui"],["Page","page-ui"],["PasswordStrength","password-strength-ui"],["PipelineStatus","pipeline-status-ui"],["Preview","preview-ui"],["QRCode","qr-code-ui"],["RelativeTime","relative-time-ui"],["Search","search-ui"],["SkipNav","skip-nav-ui"],["Spinner","spinner-ui"],["StepProgress","step-progress-ui"],["Swatch","swatch-ui"],["TableFooter","table-footer-ui"],["TableOfContents","toc-ui"],["TableToolbar","table-toolbar-ui"],["TagsInput","tags-input-ui"],["ThemeProvider","theme-provider"],["TimePicker","time-picker-ui"],["ToggleScheme","toggle-scheme-ui"],["Tree","tree-ui"],["TreeItem","tree-item-ui"],["VisuallyHidden","visually-hidden-ui"],["AdminEntityItem","admin-entity-item"],["AdminRoster","admin-roster-ui"],["AdminSettings","admin-settings-ui"],["AgentAdmin","agent-admin-ui"],["AppShell","embed-shell"],["BillingOverview","billing-overview-ui"],["ConfirmDialog","confirm-dialog-ui"],["DashboardLayout","dashboard-layout-ui"],["DateRangeSelector","date-range-selector-ui"],["FormPopover","form-popover-ui"],["IntegrationsPage","integrations-page-ui"],["InvoiceDetail","invoice-detail-ui"],["InvoiceHistory","invoice-history-ui"],["NotificationPreferences","notification-preferences-ui"],["OnboardingChecklist","onboarding-checklist-ui"],["PaymentMethodForm","payment-method-form-ui"],["PaymentMethodList","payment-method-list-ui"],["PlanPicker","plan-picker-ui"],["chat-thread-ui","chat-thread-ui"],["section-ui","section-ui"],["DescriptionTerm","dt"],["DescriptionDetail","dd"]])});function Dd(s){return!s||s==="/"}function XO(s){return s.split("/").filter(Boolean)}function BE(s){return s.replace(/^\//,"").split("/")}function zE(s,t){return Dd(t)?s:XO(t).reduce((e,i)=>e?.[i],s)}function ZE(s,t,e){if(Dd(t))return;let i=XO(t),r=s;for(let n=0;n<i.length-1;n++)r[i[n]]==null&&(r[i[n]]={}),r=r[i[n]];r[i[i.length-1]]=e}function BO(s,t){if(Dd(t))return s;let e=BE(t),i=s;for(let r of e){if(i==null)return;i=i[r]}return i}function _E(s,t,e){if(Dd(t))return;let i=BE(t),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}function VE(s,t){if(!t||!s)return;let e=XO(t),i=s;for(let r of e){if(i==null||typeof i!="object")return;i=i[r]}return i}var Nd=F(()=>{"use strict"});var qd,ya,zO=F(()=>{"use strict";Nd();qd={provider:0,controller:1,source:2,action:3,lifecycle:4},ya=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?BO(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)=>(qd[i.kind]??9)-(qd[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)=>(qd[i[1].dockable.kind]??9)-(qd[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){_E(this.#e,t,e);for(let[i,r]of this.#s)if(t===i||t.startsWith(i+"/"))for(let n of r)n(BO(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 Ae,ur=F(()=>{"use strict";Ae=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 va,ZO=F(()=>{"use strict";ur();va=class extends Ae{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 xa,_O=F(()=>{"use strict";ur();xa=class extends Ae{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 Xd,Sa,VO=F(()=>{"use strict";ur();Xd={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"},Sa=class extends Ae{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=Xd[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 wa,jO=F(()=>{"use strict";ur();wa=class extends Ae{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,FO=F(()=>{"use strict";ur();Aa=class extends Ae{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 jE,ke,dr=F(()=>{"use strict";jE=new WeakSet,ke=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!jE.has(e)&&e!==s&&(jE.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 FE={};se(FE,{FormController:()=>WO});var WO,WE=F(()=>{"use strict";dr();WO=class extends ke{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 UE={};se(UE,{DataStreamController:()=>UO});var UO,YE=F(()=>{"use strict";dr();UO=class extends ke{static schema=Object.freeze({name:"data-stream",state:{data:"array",status:"string",error:"string"},commands:["push","pushMany","connect","poll","consume","stop","clear"],attributes:["data-stream-status"]});#t=[];#e;#i="idle";#s=null;#r=null;#n=0;#a=1;#o=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:r=[]}={}){super(),this.#e=t,this.#n=e,this.#a=Math.max(1,Math.round(i)),this.#t=r.slice(-t)}getState(){return{data:this.#t,status:this.#i,error:this.#s}}reflect(){this.host&&this.host.setAttribute("data-stream-status",this.#i)}onDisconnect(){this.commands.stop()}#c(t){this.#l++,!(this.#a>1&&this.#l%this.#a!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#d())}#h(t){if(this.#a>1){let e=[];for(let i of t)this.#l++,this.#l%this.#a===0&&e.push(i);this.#t.push(...e)}else this.#t.push(...t);this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#d()}#d(){if(this.#n<=0){this.notify();return}this.#o===null&&(this.#o=setTimeout(()=>{this.#o=null,this.notify()},this.#n))}#u(t,e=null){this.#i=t,this.#s=e,this.notify()}commands={push:t=>{this.#c(t)},pushMany:t=>{this.#h(t)},connect:(t,e)=>{this.commands.stop(),this.#r=new AbortController,t==="sse"?this.#f(e):t==="ws"?this.#p(e):this.#u("error",`Unknown stream type: ${t}`)},poll:(t,e=2e3)=>{this.commands.stop(),this.#r=new AbortController,this.#m(t,e)},consume:t=>{this.commands.stop(),this.#r=new AbortController,this.#g(t)},stop:()=>{this.#r&&(this.#r.abort(),this.#r=null),this.#o!==null&&(clearTimeout(this.#o),this.#o=null),(this.#i==="streaming"||this.#i==="connecting")&&this.#u("stopped")},clear:()=>{this.#t=[],this.notify()}};#f(t){this.#u("connecting");let e=new EventSource(t),i=this.#r.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#u("streaming"),e.onmessage=r=>{try{let n=JSON.parse(r.data);this.#c(n)}catch{}},e.onerror=()=>{i.aborted||(this.#u("error","SSE connection lost"),e.close())}}#p(t){this.#u("connecting");let e=new WebSocket(t),i=this.#r.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#u("streaming"),e.onmessage=r=>{try{let n=JSON.parse(r.data);Array.isArray(n)?this.#h(n):this.#c(n)}catch{}},e.onerror=()=>{i.aborted||this.#u("error","WebSocket error")},e.onclose=()=>{i.aborted||this.#u("stopped")}}async#m(t,e){this.#u("streaming");let i=this.#r.signal;for(;!i.aborted;){try{let n=await(await fetch(t,{signal:i})).json();Array.isArray(n)?this.#h(n):this.#c(n)}catch(r){if(i.aborted)break;this.#u("error",r.message);break}await new Promise(r=>setTimeout(r,e))}}async#g(t){this.#u("streaming");let e=this.#r.signal;try{for await(let i of t){if(e.aborted)break;Array.isArray(i)?this.#h(i):this.#c(i)}e.aborted||this.#u("idle")}catch(i){e.aborted||this.#u("error",i.message)}}}});var HE={};se(HE,{SelectionController:()=>YO});var YO,GE=F(()=>{"use strict";dr();YO=class extends ke{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 KE={};se(KE,{ToggleController:()=>HO});var HO,JE=F(()=>{"use strict";dr();HO=class extends ke{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 tC={};se(tC,{AccordionController:()=>GO});var GO,eC=F(()=>{"use strict";dr();GO=class extends ke{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 iC={};se(iC,{StateMachineController:()=>KO});var KO,sC=F(()=>{"use strict";dr();KO=class extends ke{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 rC(s,t){Ui.controllers.set(s,t)}function nC(s,t){Ui.handlers.set(s,t)}function oC(s,t){Ui.resolvers.set(s,t)}async function Bd(s){let t=Ui.controllers.get(s);return t?t():null}function zd(s){return Ui.handlers.get(s)||null}async function dh(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=Ui.resolvers.get(r);if(!n)throw new Error(`No resolver for scheme "${r}"`);return n(e,t)}async function nN(s){let{action:t,params:e}=s,i=JO(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=Ui.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 oN(s){let{action:t}=s,e=JO(t.value,s);s.updateModel(t.path,e)}async function aN(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 lN(){history.back()}async function hN(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 cN(s){let{action:t,source:e}=s,i=JO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function uN(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function dN(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 JO(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 VE(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}async function fN(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 pN(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 mN(s,t){return{_source:s,_mock:!0}}var Ui,ty=F(()=>{"use strict";Nd();Ui={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(WE(),FE))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(YE(),UE))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(GE(),HE))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(JE(),KE))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(eC(),tC))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(sC(),iC))).StateMachineController]]),handlers:new Map([["submit-resource",nN],["update-model",oN],["navigate",aN],["navigate-back",lN],["controller-command",hN],["emit-event",cN],["refresh-source",uN],["notify",dN]]),resolvers:new Map([["resource",fN],["api",pN],["mock",mN]])}});function gN(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:dh};return s(r)}}function bN(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=zd(t);if(!e)return null;let i=gN(e);return s.set(t,i),i}}function ON(){return async s=>Bd(s)}function yN(){return async(s,t)=>dh(s,{})}function Zd(s){let t=[],e=bN(),i=ON(),r=yN();if(s.data?.sources)for(let o of s.data.sources)t.push(new xa(o,r));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new va(o,i));if(s.actions)for(let o of s.actions)t.push(new Sa(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new wa(a))}s.lifecycle&&t.push(new Aa(s.lifecycle,e));let n=s.state?.model||null;return{dockables:t,initialModel:n}}var ey=F(()=>{"use strict";ZO();_O();VO();jO();FO();ty()});var aC={};se(aC,{WiringEngine:()=>fh});var fh,iy=F(()=>{"use strict";zO();ey();fh=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}=Zd(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))}undockIds(t,e){let i=this.#t.get(t);i&&i.undockMany(e)}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 ya(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}}});function Os(s){return SN.has(s.toLowerCase())?s.toLowerCase():s.replace(/([A-Z])/g,"-$1").toLowerCase()}function _d(s,t,e){if(t==="style"&&typeof e=="string"){s.style.cssText=e;return}if(vN.has(t)&&e!=null){if(t==="textContent"&&!xN.has(s.localName)){s.setAttribute("text",String(e));return}let i=e;if(typeof i=="string"&&(i.startsWith("[")||i.startsWith("{")))try{i=JSON.parse(i)}catch{}s[t]=i;return}if(typeof e=="boolean"){e?s.setAttribute(Os(t),""):s.removeAttribute(Os(t));return}e!=null?s.setAttribute(Os(t),String(e)):s.removeAttribute(Os(t))}var vN,xN,SN,sy=F(()=>{"use strict";vN=new Set(["data","columns","options","itemRenderer","textContent","pageSizeOptions"]),xN=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui","kbd-ui"]),SN=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"])});var ys,lC=F(()=>{"use strict";qO();sy();Nd();ys=class s{#t;#e;#i=new Map;#s=new Map;#r=new Map;#n=[];#a=null;#o=!1;constructor(t,e=Vt,{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.#h(t))}#l(){this.#a=null;let t=this.#n.splice(0);for(let e of t)try{this.#h(e)}catch(i){console.error("A2UI: message failed during batch flush",i),this.#_(null,"a2ui-message-error",{error:i,messageType:e?.type||e?.messageType})}}static#c=new Set(["updateComponents","updateDataModel","wireComponents","updateStyles","removeStyles"]);#h(t){let e=t.type||t.messageType,i=t.surfaceId;if(i&&s.#c.has(e)){let r=this.#i.get(i);if(r&&!r.synthetic&&this.#u(r)){r.lifecycle.buffer.push(t);return}}this.#d(t)}#d(t){switch(t.type||t.messageType){case"createSurface":this.#m(t);return;case"updateComponents":this.#g(t);return;case"updateDataModel":this.#k(t);return;case"wireComponents":return this.#p(t);case"deleteSurface":this.#w(t);return;case"updateStyles":this.#L(t);return;case"removeStyles":this.#D(t);return;case"meta":return;default:console.warn("A2UI: unknown message type",t.type);return}}#u(t){return t.lifecycle.state==="pending-first"||t.lifecycle.state==="pending-stale"}#f=null;async#p(t){if(!this.#f){let{WiringEngine:e}=await Promise.resolve().then(()=>(iy(),aC));this.#f=new e({updateDataModel:(i,r,n)=>{this.#k({surfaceId:i,path:r,value:n})},getElement:(i,r)=>this.#i.get(i)?.elements.get(r)||null})}await this.#f.process(t)}async processStream(t){for await(let e of t)this.process(e)}#m({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t)){let n=this.#i.get(t);this.#_(n.root,"a2ui-duplicate-surface-id",{surfaceId:t});let o=new Error(`A2UI: duplicate createSurface for surfaceId "${t}" \u2014 REQ-002 (spec-a2ui-v1-conformance.md) makes this a hard error. Regenerate an existing surface with renderer.beginSurfaceUpdate(surfaceId) \u2192 applyTo \u2192 commitSurfaceUpdate instead (spec-a2ui-surface-lifecycle.md).`);throw o.code="DUPLICATE_SURFACE_ID",o.surfaceId=t,o}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,synthetic:!1,lifecycle:{state:"empty",generationId:null,buffer:null,mode:"replace",reason:null,hadError:!1}})}#g({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,synthetic:!0,lifecycle:null},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.#A(l.variant,l):Id(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.#E(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#S(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#b=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#O=new Set(["Header","Section","Footer"]);static#y=new Set(["header","body","footer"]);#v=new Set;#S(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.#O:s.#b,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.#y.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#v.has(u)||(this.#v.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#x={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};#A(t,e){return!e?.slot&&s.#x[t]?s.#x[t]:"text-ui"}#E(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#x[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.#$(a,e._surfaceId);n[o]=h,!(r&&Object.is(r[o],h))&&(h==null&&!l||_d(t,o,h))}if(r)for(let o of Object.keys(r))!(o in n)&&!i.has(o)&&t.removeAttribute(Os(o));this.#r.set(e.id,n)}#$(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?zE(i.dataModel,t.path):t.path}return t}#k({surfaceId:t,path:e,value:i}){let r=this.#i.get(t);if(r){!e||e==="/"?r.dataModel=i??{}:ZE(r.dataModel,e,i);for(let[n,o]of r.bindings){let a=r.elements.get(n);a&&this.#E(a,o)}}}#w({surfaceId:t}){let e=this.#i.get(t);if(e){this.#f?.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)}}#C=0;#Q(){return this.#C+=1,`g${this.#C}-${Date.now().toString(36)}`}#P(t,e){t.root?.setAttribute?.("data-a2ui-lifecycle",e)}#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{}}beginSurfaceUpdate(t,{generationId:e,reason:i=null,mode:r="replace"}={}){let n=this.#i.get(t);if(!n)return console.warn(`A2UI: beginSurfaceUpdate \u2014 no such surface "${t}"`),null;if(n.synthetic)return console.warn(`A2UI: beginSurfaceUpdate \u2014 surfaceId "${t}" is synthetic (no prior createSurface); lifecycle is a no-op here. Send createSurface first.`),null;let o=n.lifecycle,a=o.state==="error-empty"||o.state==="error-stale",h=o.state==="live"||o.state==="error-stale"?"pending-stale":"pending-first";return o.state=h,o.generationId=typeof e=="string"&&e?e:this.#Q(),o.buffer=[],o.mode=r==="patch"?"patch":"replace",o.reason=i,o.hadError=a,this.#P(n,h),this.#M(n.root,"surface-pending",{surfaceId:t,generationId:o.generationId,reason:i,firstRender:h==="pending-first"}),o.generationId}applyTo(t,e){let i=Array.isArray(e)?e:[e];for(let r of i)this.#h({...r,surfaceId:t})}async commitSurfaceUpdate(t,e){let i=this.#i.get(t);if(!i||i.synthetic)return console.warn(`A2UI: commitSurfaceUpdate \u2014 no such lifecycle surface "${t}"`),!1;let r=i.lifecycle;if(!this.#u(i))return console.warn(`A2UI: commitSurfaceUpdate \u2014 surface "${t}" has no in-flight generation to commit`),!1;if(e!=null&&e!==r.generationId)return!1;let n=r.buffer||[],o=r.generationId,a=r.hadError,l=[],h=[];if(r.mode==="replace"){let c=new Set,u=!1,d=new Set,f=!1;for(let p of n){let m=p.type||p.messageType;if(m==="updateComponents"){u=!0;for(let g of p.components||[])g.id!=null&&c.add(g.id)}else m==="updateStyles"&&(f=!0,typeof p.styleId=="string"&&d.add(p.styleId))}for(let p of n)await this.#d(p);u&&(l=this.#R(t,c)),f&&(h=this.#T(t,d))}else for(let c of n)await this.#d(c);return r.state="live",r.buffer=null,r.generationId=null,r.reason=null,r.hadError=!1,this.#P(i,"live"),this.#M(i.root,"surface-committed",{surfaceId:t,generationId:o,healed:a,swept:l,stylesSwept:h}),!0}#T(t,e){let i=this.#i.get(t);if(!i||!i.adoptedSheets||i.adoptedSheets.size===0)return[];let r=[];for(let n of[...i.adoptedSheets.keys()]){if(e.has(n))continue;let o=i.adoptedSheets.get(n);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet),i.adoptedSheets.delete(n),this.#q(i.root,"styles-removed",{surfaceId:t,styleId:n}),r.push(n)}return r}#R(t,e){let i=this.#i.get(t);if(!i)return[];let r=[];for(let n of[...i.elements.keys()]){if(e.has(n))continue;i.elements.get(n)?.remove(),i.elements.delete(n),this.#s.delete(n),i.bindings.delete(n),this.#r.delete(n),r.push(n)}return r.length>0&&this.#f?.undockIds(t,r),r}abortSurfaceUpdate(t,e,i){let r=this.#i.get(t);if(!r||r.synthetic)return console.warn(`A2UI: abortSurfaceUpdate \u2014 no such lifecycle surface "${t}"`),!1;let n=r.lifecycle;if(!this.#u(r))return console.warn(`A2UI: abortSurfaceUpdate \u2014 surface "${t}" has no in-flight generation to abort`),!1;if(e!=null&&e!==n.generationId)return!1;let o=n.generationId,a=n.state==="pending-first"?"error-empty":"error-stale";return n.state=a,n.buffer=null,n.generationId=null,n.reason=null,n.hadError=!0,this.#P(r,a),this.#M(r.root,"surface-aborted",{surfaceId:t,generationId:o,error:i??null}),!0}getLifecycle(t){let e=this.#i.get(t);return e&&!e.synthetic?e.lifecycle:null}isPending(t){let e=this.getLifecycle(t);return e?.state==="pending-first"||e?.state==="pending-stale"}get pendingSurfaces(){let t=[];for(let[e,i]of this.#i)!i.synthetic&&this.#u(i)&&t.push(e);return t}static#I=new Set(["root","html","body"]);#L({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#q(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#q(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.#q(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let n=this.#z(i,t);if(n.rejected){this.#q(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.#q(r.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:n.sheet.cssRules.length,validationWarnings:n.warnings})}#D({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.#q(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#z(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.#X(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.#B(r,e),o=this.#N(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}}#X(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.#Z(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.#I.has(a))return`forbidden-${a}-selector`}}return null}#Z(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}#B(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}#N(t,e){let i=[];for(let n of t.cssRules)i.push(n.cssText);return`@scope ([data-a2ui-surface="${String(e).replace(/"/g,'\\"')}"]) {
|
|
42
42
|
${i.join(`
|
|
43
43
|
`)}
|
|
44
|
-
}`}#
|
|
44
|
+
}`}#q(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{}}#_(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 Vd(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 jd(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 uC(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function Fd(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?wN(s,t):cC(s,t)}function hC(s,t){if(s.result?.content){for(let e of s.result.content)if(e.type==="resource"&&(e.resource?.mimeType==="application/a2ui+json"||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 wN(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);hC(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 cC(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:r}=t,n=[],o=null,a=!1,l=b=>{if(o){let A=o;o=null,A({value:b,done:!1})}else n.push(b)},h=()=>{if(a=!0,o){let b=o;o=null,b({value:void 0,done:!0})}},c={jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:"a2ui",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(b){console.warn("A2UI MCP HTTP: initialize failed",b);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 A=u.body.getReader(),x=new TextDecoder,S="";for(;;){let{done:v,value:E}=await A.read();if(v||(S+=x.decode(E,{stream:!0}),S.includes(`
|
|
45
45
|
|
|
46
46
|
`)))break}try{A.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(b=>b.text()).catch(()=>null)}catch{}if(i){let b=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:b}}),signal:e}).then(A=>A.text()).catch(()=>null)}catch{}}let f=b=>fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify(b),signal:e}).then(A=>A.text()).catch(()=>null),p=b=>{hC(b,l),b.method==="a2ui/action"&&r&&Promise.resolve().then(()=>r(b.params?.name,b.params?.arguments)).then(A=>f({jsonrpc:"2.0",id:b.id,result:A})).catch(A=>f({jsonrpc:"2.0",id:b.id,error:{code:-1,message:A.message}}))},m;try{m=await fetch(s,{method:"GET",headers:{Accept:"text/event-stream","mcp-session-id":d},signal:e})}catch(b){b?.name!=="AbortError"&&console.warn("A2UI MCP HTTP: GET stream failed",b);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 g=()=>{try{fetch(s,{method:"DELETE",headers:{"mcp-session-id":d}}).catch(()=>null)}catch{}};for((async()=>{let b=m.body.getReader(),A=new TextDecoder,x="";try{for(;!a;){let{done:S,value:v}=await b.read();if(S)break;x+=A.decode(v,{stream:!0});let E;for(;(E=x.indexOf(`
|
|
47
47
|
|
|
@@ -79,7 +79,7 @@ See the JSDoc header of icons-phosphor.js for the full recipe (gh#786).`)},0)}el
|
|
|
79
79
|
aria-label="Undo" \u2190 explicit accessible name
|
|
80
80
|
title="Undo" \u2190 auto-mirrored to aria-label + tooltip
|
|
81
81
|
aria-labelledby="..." \u2190 reference an existing label element
|
|
82
|
-
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)}};M();w("button-ui",vr);R();var xr=class extends k{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)}};M();w("link-ui",xr);R();var X=class s extends k{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 A$=s=>s.getAttribute?.("role")==="presentation"||s.style?.display==="contents";function k$(s){let t=[],e=i=>{for(let r of i)if(r.nodeType===1){if(A$(r)){e(r.children);continue}t.push(r)}};return s&&e(s.children),t}function ct(s,t){return k$(s).filter(e=>e.getAttribute("slot")===t)}function Zt(s,t,e){let i=s.getAttribute("aria-label");if(t!==void 0&&i!==t&&(t=void 0),i!==null&&t===void 0)return t;if(e)return i!==e&&s.setAttribute("aria-label",e),e;i!==null&&s.removeAttribute("aria-label")}var ov=s=>Vh(s)?`<icon-ui name="${s}"></icon-ui>`:s,Sr=class s extends X{static labelDeprecated=!1;static requiredIcons=["caret-up","caret-down"];static properties={...X.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;#d=void 0;static#u=400;static#f=60;get#p(){return this.type==="password"}get#m(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#w(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.#E(t)}connected(){super.connected(),this.setAttribute("role",this.#m?"spinbutton":"textbox");let t=ct(this,"leading"),e=ct(this,"trailing");this.querySelector('[slot="text"]')||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.#p&&this.value&&(this.#t.textContent=this.#m?this.#$(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#M),this.#t.addEventListener("keydown",this.#Z),this.#t.addEventListener("blur",this.#D),this.#t.addEventListener("focus",this.#B),this.#t.addEventListener("paste",this.#j),this.#m&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#F),this.#s?.addEventListener("pointerdown",this.#U),(this.prefix||this.suffix)&&Va.then(()=>this.#y())}#g(t,e){let i=this.label?`input-label-${++s.#h}`:"";this.innerHTML=this.#O(i),this.#v(t,e)}#b(){if(this.#p||!this.#t||!!this.querySelector(':scope > [slot="field"] [data-controls]')===this.#m)return;this.#t.removeEventListener("input",this.#M),this.#t.removeEventListener("keydown",this.#Z),this.#t.removeEventListener("blur",this.#D),this.#t.removeEventListener("focus",this.#B),this.#t.removeEventListener("paste",this.#j),this.#t.removeEventListener("beforeinput",this.#I);let e=this.querySelector(':scope > [slot="field"]'),i=e?[...e.querySelectorAll(':scope > [slot="leading"]')]:[],r=e?[...e.querySelectorAll(':scope > [slot="trailing"]')]:[];this.#g(i,r),this.setAttribute("role",this.#m?"spinbutton":"textbox"),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.#t&&(this.#t.addEventListener("input",this.#M),this.#t.addEventListener("keydown",this.#Z),this.#t.addEventListener("blur",this.#D),this.#t.addEventListener("focus",this.#B),this.#t.addEventListener("paste",this.#j),this.#m&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#F),this.#s?.addEventListener("pointerdown",this.#U),(this.prefix||this.suffix)&&Va.then(()=>this.#y())}#O(t){let e=this.prefix?`<span slot="prefix">${ov(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",r=this.suffix?`<span slot="suffix">${ov(this.suffix)}</span>`:"",n=t?`aria-labelledby="${t}"`:"";if(this.#p)return`
|
|
82
|
+
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)}};M();w("button-ui",vr);R();var xr=class extends k{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)}};M();w("link-ui",xr);R();var X=class s extends k{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 A$=s=>s.getAttribute?.("role")==="presentation"||s.style?.display==="contents";function k$(s){let t=[],e=i=>{for(let r of i)if(r.nodeType===1){if(A$(r)){e(r.children);continue}t.push(r)}};return s&&e(s.children),t}function ct(s,t){return k$(s).filter(e=>e.getAttribute("slot")===t)}function Zt(s,t,e){let i=s.getAttribute("aria-label");if(t!==void 0&&i!==t&&(t=void 0),i!==null&&t===void 0)return t;if(e)return i!==e&&s.setAttribute("aria-label",e),e;i!==null&&s.removeAttribute("aria-label")}var ov=s=>Vh(s)?`<icon-ui name="${s}"></icon-ui>`:s,Sr=class s extends X{static labelDeprecated=!1;static requiredIcons=["caret-up","caret-down"];static properties={...X.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;#d=void 0;static#u=400;static#f=60;get#p(){return this.type==="password"}get#m(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#w(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.#C(t)}connected(){super.connected(),this.setAttribute("role",this.#m?"spinbutton":"textbox");let t=ct(this,"leading"),e=ct(this,"trailing");this.querySelector('[slot="text"]')||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.#p&&this.value&&(this.#t.textContent=this.#m?this.#P(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#R),this.#t.addEventListener("keydown",this.#Z),this.#t.addEventListener("blur",this.#N),this.#t.addEventListener("focus",this.#B),this.#t.addEventListener("paste",this.#j),this.#m&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#F),this.#s?.addEventListener("pointerdown",this.#U),(this.prefix||this.suffix)&&Va.then(()=>this.#v())}#g(t,e){let i=this.label?`input-label-${++s.#h}`:"";this.innerHTML=this.#O(i),this.#y(t,e)}#b(){if(this.#p||!this.#t||!!this.querySelector(':scope > [slot="field"] [data-controls]')===this.#m)return;this.#t.removeEventListener("input",this.#R),this.#t.removeEventListener("keydown",this.#Z),this.#t.removeEventListener("blur",this.#N),this.#t.removeEventListener("focus",this.#B),this.#t.removeEventListener("paste",this.#j),this.#t.removeEventListener("beforeinput",this.#I);let e=this.querySelector(':scope > [slot="field"]'),i=e?[...e.querySelectorAll(':scope > [slot="leading"]')]:[],r=e?[...e.querySelectorAll(':scope > [slot="trailing"]')]:[];this.#g(i,r),this.setAttribute("role",this.#m?"spinbutton":"textbox"),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.#t&&(this.#t.addEventListener("input",this.#R),this.#t.addEventListener("keydown",this.#Z),this.#t.addEventListener("blur",this.#N),this.#t.addEventListener("focus",this.#B),this.#t.addEventListener("paste",this.#j),this.#m&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#F),this.#s?.addEventListener("pointerdown",this.#U),(this.prefix||this.suffix)&&Va.then(()=>this.#v())}#O(t){let e=this.prefix?`<span slot="prefix">${ov(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",r=this.suffix?`<span slot="suffix">${ov(this.suffix)}</span>`:"",n=t?`aria-labelledby="${t}"`:"";if(this.#p)return`
|
|
83
83
|
<div slot="field">
|
|
84
84
|
${e}${i}
|
|
85
85
|
<input slot="text" type="password" tabindex="0"
|
|
@@ -106,7 +106,7 @@ See the JSDoc header of icons-phosphor.js for the full recipe (gh#786).`)},0)}el
|
|
|
106
106
|
<div slot="field">
|
|
107
107
|
${e}${i}${o}${r}${a}
|
|
108
108
|
</div>
|
|
109
|
-
`}#v(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)}}}#y(){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")&&Vh(e)){i.replaceChildren();let r=document.createElement("icon-ui");r.setAttribute("name",e),i.appendChild(r)}}}#S(){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&&Vh(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;this.#b();let t=this.value??"";if(this.#p)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 i=this.#m&&document.activeElement!==this.#t?this.#$(t):String(t);this.#t.textContent!==i&&(this.#t.textContent=i,this.#t.toggleAttribute("data-empty",!i))}this.#e&&(this.#e.textContent=this.label||""),this.#S();let e=this.label?"":this.placeholder||"";if(this.#d=Zt(this,this.#d,e),this.#m){let i=this.valueAsNumber;Number.isFinite(i)?(this.setAttribute("aria-valuenow",String(i)),this.setAttribute("aria-valuetext",`${this.#E(i)}${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 r=this.disabled||this.readonly||this.max!=null&&Number.isFinite(i)&&i>=this.max,n=this.disabled||this.readonly||this.min!=null&&Number.isFinite(i)&&i<=this.min;this.#i?.toggleAttribute("disabled",!!r),this.#s?.toggleAttribute("disabled",!!n)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#m&&this.#x(String(t))}validate(){let t=super.validate();if(!this.#m)return t;if(!t)return!1;let e=this.#x(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#x(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#w(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)}#A(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#C(){return this.locale?this.#c===this.locale?this.#o:(this.#k(),this.#o):"."}#P(){return this.locale?this.#c===this.locale?this.#l:(this.#k(),this.#l):""}#k(){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}#w(t){let e=this.#C(),i=this.#P(),r=String(t);return i&&(r=r.split(i).join("")),e!=="."&&(r=r.replace(new RegExp(`\\${e}`,"g"),".")),r}#E(t){if(!Number.isFinite(t))return"";let e=this.#A();if(this.locale)try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!1}).format(t)}catch{}return e>0?t.toFixed(e):String(Math.round(t))}#T(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#E(t);let e=this.#A();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#E(t)}}#$(t){let e=String(t??"");if(!e)return"";let i=Number(this.#w(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#E(i):this.#T(i):e}#L(t){let e=this.step||1,i=this.min!=null?this.min:0,r=Math.round((t-i)/e)*e+i,n=Math.max(this.min!=null?this.min:-1/0,Math.min(this.max!=null?this.max:1/0,r));return parseFloat(n.toFixed(10))}#Q(t){if(this.disabled||this.readonly)return;let e=(this.step||1)*t,i=Number.isFinite(this.valueAsNumber)?this.valueAsNumber:this.min!=null?this.min:0,r=this.#L(i+e);r!==this.valueAsNumber&&(this.value=this.#E(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}})))}#M=()=>{let t;if(this.#p)t=this.#t.value||"";else if(this.#m){let e=this.#t.textContent||"";t=this.#q(e),t!==e&&(this.#t.textContent=t,this.#X())}else t=this.#t.textContent||"";this.value=t,this.#p||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.#z(h.startContainer,h.startOffset),a=this.#z(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.#w(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)}#q(t){let e=this.#C(),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}#z(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}#X(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#Z=t=>{if(this.#m){switch(t.key){case"ArrowUp":t.preventDefault(),this.#Q(1);return;case"ArrowDown":t.preventDefault(),this.#Q(-1);return;case"PageUp":t.preventDefault(),this.#Q(10);return;case"PageDown":t.preventDefault(),this.#Q(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#_(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#_(this.max));return;case"Escape":t.preventDefault(),this.value=this.#r,this.#t.textContent=this.#$(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#N(),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})))};#B=()=>{if(this.#r=this.value??"",this.#m&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#w(t));if(!Number.isFinite(e))return;let i=this.#E(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#D=()=>{this.#m&&this.#N(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#N(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#w(t));if(!Number.isFinite(e))return;let i=this.#L(e),r=this.#E(i),n=this.#T(i);this.value!==r&&(this.value=r,this.syncValue(r),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==n&&(this.#t.textContent=n,this.#t.toggleAttribute("data-empty",!n))}#_(t){let e=this.#L(t);e!==this.valueAsNumber&&(this.value=this.#E(e),this.syncValue(this.value),this.#t.textContent=this.value,this.#t.toggleAttribute("data-empty",!this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#j=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#m?this.#q(e):e;document.execCommand("insertText",!1,i)};#F=t=>this.#et(t,1);#U=t=>this.#et(t,-1);#et(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#Q(e),this.#Y(),document.addEventListener("pointerup",this.#G,{once:!0}),document.addEventListener("pointercancel",this.#G,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#n=window.setInterval(()=>{let i=this.valueAsNumber;this.#Q(e),this.valueAsNumber===i&&this.#Y()},s.#f)},s.#u))}#G=()=>this.#Y();#Y(){this.#a!=null&&(window.clearTimeout(this.#a),this.#a=null),this.#n!=null&&(window.clearInterval(this.#n),this.#n=null),document.removeEventListener("pointerup",this.#G),document.removeEventListener("pointercancel",this.#G)}focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#p?this.#t.value="":(this.#t.textContent="",this.#t.setAttribute("data-empty",""))),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#M),this.#t.removeEventListener("keydown",this.#Z),this.#t.removeEventListener("blur",this.#D),this.#t.removeEventListener("focus",this.#B),this.#t.removeEventListener("paste",this.#j),this.#t.removeEventListener("beforeinput",this.#I)),this.#i?.removeEventListener("pointerdown",this.#F),this.#s?.removeEventListener("pointerdown",this.#U),this.#Y(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};M();w("input-ui",Sr);var wr=class extends X{static labelDeprecated=!1;static properties={...X.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;#e=void 0;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
|
|
109
|
+
`}#y(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)}}}#v(){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")&&Vh(e)){i.replaceChildren();let r=document.createElement("icon-ui");r.setAttribute("name",e),i.appendChild(r)}}}#S(){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&&Vh(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;this.#b();let t=this.value??"";if(this.#p)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 i=this.#m&&document.activeElement!==this.#t?this.#P(t):String(t);this.#t.textContent!==i&&(this.#t.textContent=i,this.#t.toggleAttribute("data-empty",!i))}this.#e&&(this.#e.textContent=this.label||""),this.#S();let e=this.label?"":this.placeholder||"";if(this.#d=Zt(this,this.#d,e),this.#m){let i=this.valueAsNumber;Number.isFinite(i)?(this.setAttribute("aria-valuenow",String(i)),this.setAttribute("aria-valuetext",`${this.#C(i)}${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 r=this.disabled||this.readonly||this.max!=null&&Number.isFinite(i)&&i>=this.max,n=this.disabled||this.readonly||this.min!=null&&Number.isFinite(i)&&i<=this.min;this.#i?.toggleAttribute("disabled",!!r),this.#s?.toggleAttribute("disabled",!!n)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#m&&this.#x(String(t))}validate(){let t=super.validate();if(!this.#m)return t;if(!t)return!1;let e=this.#x(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#x(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#w(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)}#A(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#E(){return this.locale?this.#c===this.locale?this.#o:(this.#k(),this.#o):"."}#$(){return this.locale?this.#c===this.locale?this.#l:(this.#k(),this.#l):""}#k(){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}#w(t){let e=this.#E(),i=this.#$(),r=String(t);return i&&(r=r.split(i).join("")),e!=="."&&(r=r.replace(new RegExp(`\\${e}`,"g"),".")),r}#C(t){if(!Number.isFinite(t))return"";let e=this.#A();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))}#Q(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#C(t);let e=this.#A();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#C(t)}}#P(t){let e=String(t??"");if(!e)return"";let i=Number(this.#w(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#C(i):this.#Q(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(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.#C(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}})))}#R=()=>{let t;if(this.#p)t=this.#t.value||"";else if(this.#m){let e=this.#t.textContent||"";t=this.#D(e),t!==e&&(this.#t.textContent=t,this.#X())}else t=this.#t.textContent||"";this.value=t,this.#p||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.#z(h.startContainer,h.startOffset),a=this.#z(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=r.slice(0,o)+i+r.slice(a);this.#L(l)||t.preventDefault()};#L(t){let e=this.#w(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)}#D(t){let e=this.#E(),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}#z(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}#X(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#Z=t=>{if(this.#m){switch(t.key){case"ArrowUp":t.preventDefault(),this.#T(1);return;case"ArrowDown":t.preventDefault(),this.#T(-1);return;case"PageUp":t.preventDefault(),this.#T(10);return;case"PageDown":t.preventDefault(),this.#T(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#_(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#_(this.max));return;case"Escape":t.preventDefault(),this.value=this.#r,this.#t.textContent=this.#P(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#q(),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})))};#B=()=>{if(this.#r=this.value??"",this.#m&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#w(t));if(!Number.isFinite(e))return;let i=this.#C(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#N=()=>{this.#m&&this.#q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#q(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#w(t));if(!Number.isFinite(e))return;let i=this.#M(e),r=this.#C(i),n=this.#Q(i);this.value!==r&&(this.value=r,this.syncValue(r),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==n&&(this.#t.textContent=n,this.#t.toggleAttribute("data-empty",!n))}#_(t){let e=this.#M(t);e!==this.valueAsNumber&&(this.value=this.#C(e),this.syncValue(this.value),this.#t.textContent=this.value,this.#t.toggleAttribute("data-empty",!this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#j=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#m?this.#D(e):e;document.execCommand("insertText",!1,i)};#F=t=>this.#et(t,1);#U=t=>this.#et(t,-1);#et(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#T(e),this.#Y(),document.addEventListener("pointerup",this.#G,{once:!0}),document.addEventListener("pointercancel",this.#G,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#n=window.setInterval(()=>{let i=this.valueAsNumber;this.#T(e),this.valueAsNumber===i&&this.#Y()},s.#f)},s.#u))}#G=()=>this.#Y();#Y(){this.#a!=null&&(window.clearTimeout(this.#a),this.#a=null),this.#n!=null&&(window.clearInterval(this.#n),this.#n=null),document.removeEventListener("pointerup",this.#G),document.removeEventListener("pointercancel",this.#G)}focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#p?this.#t.value="":(this.#t.textContent="",this.#t.setAttribute("data-empty",""))),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#R),this.#t.removeEventListener("keydown",this.#Z),this.#t.removeEventListener("blur",this.#N),this.#t.removeEventListener("focus",this.#B),this.#t.removeEventListener("paste",this.#j),this.#t.removeEventListener("beforeinput",this.#I)),this.#i?.removeEventListener("pointerdown",this.#F),this.#s?.removeEventListener("pointerdown",this.#U),this.#Y(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};M();w("input-ui",Sr);var wr=class extends X{static labelDeprecated=!1;static properties={...X.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;#e=void 0;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
|
|
110
110
|
${this.label?`<label slot="label" label="${this.label}"></label>`:""}
|
|
111
111
|
<div slot="text" contenteditable="plaintext-only" tabindex="0"
|
|
112
112
|
${this.value?"":'data-empty=""'}
|
|
@@ -128,12 +128,12 @@ See the JSDoc header of icons-phosphor.js for the full recipe (gh#786).`)},0)}el
|
|
|
128
128
|
${o}
|
|
129
129
|
</div>
|
|
130
130
|
${this.hint?`<span slot="hint" id="${e}">${this.hint}</span>`:""}
|
|
131
|
-
`,this.hint&&this.setAttribute("aria-describedby",e)}this.#e=this.querySelector('[slot="track"]'),t?(this.#s=this.querySelector('[slot="thumb"][data-thumb="lower"]'),this.#r=this.querySelector('[slot="thumb"][data-thumb="upper"]'),this.#s?.addEventListener("pointerdown",this.#
|
|
131
|
+
`,this.hint&&this.setAttribute("aria-describedby",e)}this.#e=this.querySelector('[slot="track"]'),t?(this.#s=this.querySelector('[slot="thumb"][data-thumb="lower"]'),this.#r=this.querySelector('[slot="thumb"][data-thumb="upper"]'),this.#s?.addEventListener("pointerdown",this.#y),this.#r?.addEventListener("pointerdown",this.#y)):(this.#i=this.querySelector('[slot="thumb"]'),this.#i?.addEventListener("pointerdown",this.#y)),this.#e?.addEventListener("click",this.#A),this.addEventListener("keydown",this.#E)}render(){if(!this.#e)return;if(typeof this.value=="function"||typeof this.lowerValue=="function"||typeof this.upperValue=="function"){console.warn(`[slider-ui] .value / .lowerValue / .upperValue received a function. Did you mean:
|
|
132
132
|
.value=\${fn()} \u2190 call the function to get the current value
|
|
133
133
|
.value=\${signal.value} \u2190 read the signal's current value
|
|
134
134
|
Functions are not auto-invoked at render time; the slider reads
|
|
135
135
|
.value synchronously. See USAGE.md "Reactive binding" for the
|
|
136
|
-
parent-template-re-read pattern that works across frameworks.`);return}if(this.dual){if(this.lowerValue>this.upperValue){let a=!Number.isNaN(this.#l)&&this.lowerValue!==this.#l;!Number.isNaN(this.#c)&&this.upperValue!==this.#c&&!a?this.upperValue=this.lowerValue:this.lowerValue=this.upperValue}this.#l=this.lowerValue,this.#c=this.upperValue;let i=this.#h(this.lowerValue),r=this.#h(this.upperValue);this.style.setProperty("--slider-pct-lower",String(i)),this.style.setProperty("--slider-pct-upper",String(r));let n=this.querySelector('[slot="value-lower"]'),o=this.querySelector('[slot="value-upper"]');n&&(n.textContent=this.#d(this.lowerValue)),o&&(o.textContent=this.#d(this.upperValue)),this.#s&&(this.#s.setAttribute("aria-valuenow",this.lowerValue),this.#s.setAttribute("aria-valuetext",`${this.#d(this.lowerValue)}${this.suffix?" "+this.suffix:""}`)),this.#r&&(this.#r.setAttribute("aria-valuenow",this.upperValue),this.#r.setAttribute("aria-valuetext",`${this.#d(this.upperValue)}${this.suffix?" "+this.suffix:""}`)),this.syncValue(`${this.lowerValue},${this.upperValue}`)}else{let i=this.#h(this.value);this.style.setProperty("--slider-pct",String(i));let r=this.querySelector('[slot="value"]');r&&(r.textContent=this.#d(this.value)),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.#d(this.value)}${this.suffix?" "+this.suffix:""}`),this.syncValue(String(this.value))}let t=this.querySelector('[slot="label"]');if(t)t.textContent=this.label;else if(this.label){let i=this.querySelector('[slot="header"]');if(i){let r=document.createElement("span");r.slot="label",r.textContent=this.label,i.prepend(r)}}this.label&&this.setAttribute("aria-label",this.label);let e=this.querySelector('[slot="suffix"]');e&&(e.textContent=this.suffix)}#u(t,e=null){let i=this.#i||this.#s||this.#r;if(!this.#e||!i)return this.min;let r=this.#e.getBoundingClientRect(),n=i.getBoundingClientRect().width,o=r.width,a,l;if(this.dual?(a=o-2*n,l=e==="upper"?1.5*n:.5*n):(a=o-n,l=.5*n),a<=0)return this.min;let h=t-r.left,c=Math.max(0,Math.min(1,(h-l)/a)),u=this.min+c*(this.max-this.min);return this.#p(u)}#f(t){if(!this.#e)return 0;let e=this.#i||this.#s||this.#r;if(!e)return 0;let i=this.#e.getBoundingClientRect(),r=e.getBoundingClientRect().width,n=i.width;if(this.dual){let o=n-2*r,a=t==="upper"?this.#h(this.upperValue):this.#h(this.lowerValue),l=t==="upper"?1.5*r:.5*r;return i.left+l+a*o}else return i.left+.5*r+this.#h(this.value)*(n-r)}#p(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#m(t){t!==this.value&&(this.value=t,this.scheduleThrottledInput())}#g(t){let e=Math.min(Math.max(t,this.min),this.upperValue);e!==this.lowerValue&&(this.lowerValue=e,this.scheduleThrottledInput())}#b(t){let e=Math.max(Math.min(t,this.max),this.lowerValue);e!==this.upperValue&&(this.upperValue=e,this.scheduleThrottledInput())}#O(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#v=t=>{if(this.disabled)return;t.preventDefault(),this.#n=!0,this.setAttribute("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.#y),e.addEventListener("pointerup",this.#x),e.addEventListener("pointercancel",this.#S),e.addEventListener("lostpointercapture",this.#S)};#y=t=>{if(!this.#n)return;let e=t.clientX-this.#o;if(this.dual){let i=this.#u(e,this.#a);this.#a==="lower"?this.#g(i):this.#b(i)}else this.#m(this.#u(e))};#S=t=>{this.#n&&this.#x(t)};#x=t=>{this.#n=!1,this.#o=0,this.removeAttribute("dragging");let e=this.dual?this.#a==="lower"?this.#s:this.#r:this.#i;try{e?.releasePointerCapture(t.pointerId)}catch{}e?.removeEventListener("pointermove",this.#y),e?.removeEventListener("pointerup",this.#x),e?.removeEventListener("pointercancel",this.#S),e?.removeEventListener("lostpointercapture",this.#S),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#O(),this.#a=null};#A=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#r)return;let e=Math.abs(t.clientX-this.#f("lower")),i=Math.abs(t.clientX-this.#f("upper"));e<=i?this.#g(this.#u(t.clientX,"lower")):this.#b(this.#u(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#u(t.clientX))}this.flushPendingInput(),this.#O()}};#C=t=>{if(this.disabled)return;let e=0,i=null;switch(t.key){case"ArrowRight":case"ArrowUp":e=this.step;break;case"ArrowLeft":case"ArrowDown":e=-this.step;break;case"Home":i=this.min;break;case"End":i=this.max;break;case"PageUp":e=this.step*10;break;case"PageDown":e=-this.step*10;break;default:return}if(t.preventDefault(),this.dual){let n=this.ownerDocument?.activeElement===this.#r?"upper":"lower",o=n==="lower"?this.lowerValue:this.upperValue,a=i!==null?i:o+e;a=this.#p(a),n==="lower"?this.#g(a):this.#b(a)}else{let r=i!==null?i:this.value+e;this.#m(this.#p(r))}this.flushPendingInput(),this.#O()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#v),this.#s?.removeEventListener("pointerdown",this.#v),this.#r?.removeEventListener("pointerdown",this.#v),this.#e?.removeEventListener("click",this.#A),this.removeEventListener("keydown",this.#C),this.#e=null,this.#i=null,this.#s=null,this.#r=null}};M();w("slider-ui",Qr);var P$=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,Q$=0;function Ot(s,t,e={}){let{placement:i="bottom-start",gap:r=4,matchWidth:n=!1}=e;return P$?T$(s,t,{placement:i,gap:r,matchWidth:n}):R$(s,t,{placement:i,gap:r,matchWidth:n})}function T$(s,t,{placement:e,gap:i,matchWidth:r}){let n=`--a-anchor-${++Q$}`,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=Sf(getComputedStyle(t).getPropertyValue("--popover-max-height")),p=Number.isFinite(f)?f:t.scrollHeight||0,m=e.startsWith("bottom"),g=p<=u,b=p<=d,A=m;m&&!g?A=b?!1:u>=d:!m&&!b&&(A=g?!0:u>d),l=e.replace(/^(bottom|top)/,A?"bottom":"top");let x=Math.max(40,Math.floor(A?u:d));t.style.maxHeight=`${Number.isFinite(f)?Math.min(f,x):x}px`}return t.style.position="fixed",t.style.positionAnchor=n,t.style.positionArea=M$(l),t.style.margin=L$(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 Sf(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 L$(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 M$(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 R$(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 g=d-h.bottom-i*2,b=h.top-i*2,A=f.startsWith("bottom"),x=c.height<=g,S=c.height<=b,v=A;A&&!x?v=S?!1:g>=b:!A&&!S&&(v=x?!0:g>b),f=f.replace(/^(bottom|top)/,v?"bottom":"top");let E=Math.max(0,Math.floor(v?g:b));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=I$(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 I$(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}Lt();function Nt(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Tr=class s extends X{static labelDeprecated=!1;static requiredIcons=["caret-down","check","x"];static#t=new WeakSet;static properties={...X.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},labelHidden:{type:Boolean,default:!1,reflect:!0,attribute:"label-hidden"},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",reflect:!0},mark:{type:Boolean,default:!1,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},noRadio:{type:Boolean,default:!1,reflect:!0,attribute:"no-radio"},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},summaryLabel:{type:String,default:"",reflect:!0,attribute:"summary-label"},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)};#d=t=>{t.stopPropagation(),this.disabled||(this.open=!0)};#u=t=>{let e=t.currentTarget;t.stopPropagation();let i=e.__adiaOption;if(i&&!i.disabled){if(i.action){this.open=!1,this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{action:i.action}}));return}if(this.multiple){this.toggle(i.value);return}this.value=i.value,this.open=!1,this.#a="",this.syncValue(i.value),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}};syncValue(t){if(!this.multiple)return super.syncValue(t);let e=t??this.value??"";this.internals.setFormValue(e);let i=String(e).split(",").map(r=>r.trim()).filter(Boolean);if(this.min>0&&i.length<this.min){this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please select at least ${this.min}.`,this);return}if(this.max>0&&i.length>this.max){this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-max")||`Please select no more than ${this.max}.`,this);return}if(this.required&&i.length===0){this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this);return}this.internals.setValidity({})}#f(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#p(t){let e=new Set,i=[];for(let r of t){if(r==null||r==="")continue;let n=String(r);e.has(n)||(e.add(n),i.push(n))}return i.join(",")}toggle(t){if(!this.multiple){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}let e=this.#f(),i=e.indexOf(String(t)),r=e.slice(),n=[],o=[];if(i>=0)e.splice(i,1),o=[String(t)];else{if(this.max>0&&e.length>=this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:r,reason:"max"}}));return}e.push(String(t)),n=[String(t)]}let a=this.#p(e);this.value=a,this.syncValue(a),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e,added:n,removed:o}}))}selectAllOptions(){if(!this.multiple)return;let t=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null),e=this.#p(t.map(o=>o.value));if(e===this.value)return;let i=this.#f();this.value=e,this.syncValue(e),this.render();let r=this.#f(),n=r.filter(o=>!i.includes(o));this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:n,removed:[]}}))}clear(){if(!this.multiple){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:""}}));return}let t=this.#f();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#m(){let t=this.#f();if(t.length===0)return;let e=t.pop(),i=this.#p(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#g=t=>{if(!this.multiple)return;let e=t.target;if(!e||e.tagName!=="TAG-UI")return;let i=e.dataset.chipValue;if(!i)return;t.stopPropagation();let r=this.#f().filter(o=>o!==i),n=this.#p(r);this.value=n,this.syncValue(n),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:[],removed:[i]}}))};#b=t=>{t.stopPropagation(),!this.disabled&&(this.open=!0)};#O=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#v=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()};#y=void 0;#S(){let t="Select...";if(this.labelHidden&&this.label){this.#y=Zt(this,this.#y,this.label);return}let r=!(!!this.label||this.hasAttribute("aria-labelledby"))&&this.placeholder&&this.placeholder!==t?this.placeholder:"";this.#y=Zt(this,this.#y,r)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#I),this.addEventListener("remove",this.#g),this.#i.length===0&&this.#C(),!this.#c&&typeof MutationObserver<"u"&&(this.#c=new MutationObserver(()=>{this.#i.length||!this.#A().some(e=>e.tagName==="OPTION"||e.tagName==="OPTGROUP")||(this.#C(),this.#i.length&&(this.#w(),this.#x()))})),this.#c?.observe(this,{childList:!0,subtree:!0})}render(){if(this.#S(),this.querySelector('[slot="trigger"]'))this.#x();else{this.#s=!0;let e=this.#r;e?.parentNode===this&&this.removeChild(e);let i=this.mark?'<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':this.avatar?`<img slot="leading" data-select-leading src="${Nt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${Nt(this.icon)}"></icon-ui>`:"",r=this.#L()===this.placeholder?"":this.#L(),n=this.searchable?`<span slot="display" contenteditable="plaintext-only" role="combobox" aria-autocomplete="list" tabindex="0" data-placeholder="${Nt(this.placeholder||"")}"${r?"":" data-empty"}>${Nt(r)}</span>`:`<span slot="display">${Nt(this.#L())}</span>`,o=this.hint?`select-hint-${++s.#e}`:"",a=this.hint?`<span slot="hint" id="${o}">${Nt(this.hint)}</span>`:"";this.innerHTML=`
|
|
136
|
+
parent-template-re-read pattern that works across frameworks.`);return}if(this.dual){if(this.lowerValue>this.upperValue){let a=!Number.isNaN(this.#l)&&this.lowerValue!==this.#l;!Number.isNaN(this.#c)&&this.upperValue!==this.#c&&!a?this.upperValue=this.lowerValue:this.lowerValue=this.upperValue}this.#l=this.lowerValue,this.#c=this.upperValue;let i=this.#h(this.lowerValue),r=this.#h(this.upperValue);this.style.setProperty("--slider-pct-lower",String(i)),this.style.setProperty("--slider-pct-upper",String(r));let n=this.querySelector('[slot="value-lower"]'),o=this.querySelector('[slot="value-upper"]');n&&(n.textContent=this.#d(this.lowerValue)),o&&(o.textContent=this.#d(this.upperValue)),this.#s&&(this.#s.setAttribute("aria-valuenow",this.lowerValue),this.#s.setAttribute("aria-valuetext",`${this.#d(this.lowerValue)}${this.suffix?" "+this.suffix:""}`)),this.#r&&(this.#r.setAttribute("aria-valuenow",this.upperValue),this.#r.setAttribute("aria-valuetext",`${this.#d(this.upperValue)}${this.suffix?" "+this.suffix:""}`)),this.syncValue(`${this.lowerValue},${this.upperValue}`)}else{let i=this.#h(this.value);this.style.setProperty("--slider-pct",String(i));let r=this.querySelector('[slot="value"]');r&&(r.textContent=this.#d(this.value)),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.#d(this.value)}${this.suffix?" "+this.suffix:""}`),this.syncValue(String(this.value))}let t=this.querySelector('[slot="label"]');if(t)t.textContent=this.label;else if(this.label){let i=this.querySelector('[slot="header"]');if(i){let r=document.createElement("span");r.slot="label",r.textContent=this.label,i.prepend(r)}}this.label&&this.setAttribute("aria-label",this.label);let e=this.querySelector('[slot="suffix"]');e&&(e.textContent=this.suffix)}#u(t,e=null){let i=this.#i||this.#s||this.#r;if(!this.#e||!i)return this.min;let r=this.#e.getBoundingClientRect(),n=i.getBoundingClientRect().width,o=r.width,a,l;if(this.dual?(a=o-2*n,l=e==="upper"?1.5*n:.5*n):(a=o-n,l=.5*n),a<=0)return this.min;let h=t-r.left,c=Math.max(0,Math.min(1,(h-l)/a)),u=this.min+c*(this.max-this.min);return this.#p(u)}#f(t){if(!this.#e)return 0;let e=this.#i||this.#s||this.#r;if(!e)return 0;let i=this.#e.getBoundingClientRect(),r=e.getBoundingClientRect().width,n=i.width;if(this.dual){let o=n-2*r,a=t==="upper"?this.#h(this.upperValue):this.#h(this.lowerValue),l=t==="upper"?1.5*r:.5*r;return i.left+l+a*o}else return i.left+.5*r+this.#h(this.value)*(n-r)}#p(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#m(t){t!==this.value&&(this.value=t,this.scheduleThrottledInput())}#g(t){let e=Math.min(Math.max(t,this.min),this.upperValue);e!==this.lowerValue&&(this.lowerValue=e,this.scheduleThrottledInput())}#b(t){let e=Math.max(Math.min(t,this.max),this.lowerValue);e!==this.upperValue&&(this.upperValue=e,this.scheduleThrottledInput())}#O(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#y=t=>{if(this.disabled)return;t.preventDefault(),this.#n=!0,this.setAttribute("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.#v),e.addEventListener("pointerup",this.#x),e.addEventListener("pointercancel",this.#S),e.addEventListener("lostpointercapture",this.#S)};#v=t=>{if(!this.#n)return;let e=t.clientX-this.#o;if(this.dual){let i=this.#u(e,this.#a);this.#a==="lower"?this.#g(i):this.#b(i)}else this.#m(this.#u(e))};#S=t=>{this.#n&&this.#x(t)};#x=t=>{this.#n=!1,this.#o=0,this.removeAttribute("dragging");let e=this.dual?this.#a==="lower"?this.#s:this.#r:this.#i;try{e?.releasePointerCapture(t.pointerId)}catch{}e?.removeEventListener("pointermove",this.#v),e?.removeEventListener("pointerup",this.#x),e?.removeEventListener("pointercancel",this.#S),e?.removeEventListener("lostpointercapture",this.#S),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#O(),this.#a=null};#A=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#r)return;let e=Math.abs(t.clientX-this.#f("lower")),i=Math.abs(t.clientX-this.#f("upper"));e<=i?this.#g(this.#u(t.clientX,"lower")):this.#b(this.#u(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#u(t.clientX))}this.flushPendingInput(),this.#O()}};#E=t=>{if(this.disabled)return;let e=0,i=null;switch(t.key){case"ArrowRight":case"ArrowUp":e=this.step;break;case"ArrowLeft":case"ArrowDown":e=-this.step;break;case"Home":i=this.min;break;case"End":i=this.max;break;case"PageUp":e=this.step*10;break;case"PageDown":e=-this.step*10;break;default:return}if(t.preventDefault(),this.dual){let n=this.ownerDocument?.activeElement===this.#r?"upper":"lower",o=n==="lower"?this.lowerValue:this.upperValue,a=i!==null?i:o+e;a=this.#p(a),n==="lower"?this.#g(a):this.#b(a)}else{let r=i!==null?i:this.value+e;this.#m(this.#p(r))}this.flushPendingInput(),this.#O()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#y),this.#s?.removeEventListener("pointerdown",this.#y),this.#r?.removeEventListener("pointerdown",this.#y),this.#e?.removeEventListener("click",this.#A),this.removeEventListener("keydown",this.#E),this.#e=null,this.#i=null,this.#s=null,this.#r=null}};M();w("slider-ui",Qr);var P$=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,Q$=0;function Ot(s,t,e={}){let{placement:i="bottom-start",gap:r=4,matchWidth:n=!1}=e;return P$?T$(s,t,{placement:i,gap:r,matchWidth:n}):R$(s,t,{placement:i,gap:r,matchWidth:n})}function T$(s,t,{placement:e,gap:i,matchWidth:r}){let n=`--a-anchor-${++Q$}`,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=Sf(getComputedStyle(t).getPropertyValue("--popover-max-height")),p=Number.isFinite(f)?f:t.scrollHeight||0,m=e.startsWith("bottom"),g=p<=u,b=p<=d,A=m;m&&!g?A=b?!1:u>=d:!m&&!b&&(A=g?!0:u>d),l=e.replace(/^(bottom|top)/,A?"bottom":"top");let x=Math.max(40,Math.floor(A?u:d));t.style.maxHeight=`${Number.isFinite(f)?Math.min(f,x):x}px`}return t.style.position="fixed",t.style.positionAnchor=n,t.style.positionArea=M$(l),t.style.margin=L$(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===n&&(s.style.anchorName=o);for(let[h,c]of Object.entries(a))t.style[h]=c}}function Sf(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 L$(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 M$(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 R$(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 g=d-h.bottom-i*2,b=h.top-i*2,A=f.startsWith("bottom"),x=c.height<=g,S=c.height<=b,v=A;A&&!x?v=S?!1:g>=b:!A&&!S&&(v=x?!0:g>b),f=f.replace(/^(bottom|top)/,v?"bottom":"top");let E=Math.max(0,Math.floor(v?g:b));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=I$(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 I$(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}Lt();function Nt(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Tr=class s extends X{static labelDeprecated=!1;static requiredIcons=["caret-down","check","x"];static#t=new WeakSet;static properties={...X.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},labelHidden:{type:Boolean,default:!1,reflect:!0,attribute:"label-hidden"},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",reflect:!0},mark:{type:Boolean,default:!1,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},noRadio:{type:Boolean,default:!1,reflect:!0,attribute:"no-radio"},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},summaryLabel:{type:String,default:"",reflect:!0,attribute:"summary-label"},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)};#d=t=>{t.stopPropagation(),this.disabled||(this.open=!0)};#u=t=>{let e=t.currentTarget;t.stopPropagation();let i=e.__adiaOption;if(i&&!i.disabled){if(i.action){this.open=!1,this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{action:i.action}}));return}if(this.multiple){this.toggle(i.value);return}this.value=i.value,this.open=!1,this.#a="",this.syncValue(i.value),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}};syncValue(t){if(!this.multiple)return super.syncValue(t);let e=t??this.value??"";this.internals.setFormValue(e);let i=String(e).split(",").map(r=>r.trim()).filter(Boolean);if(this.min>0&&i.length<this.min){this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please select at least ${this.min}.`,this);return}if(this.max>0&&i.length>this.max){this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-max")||`Please select no more than ${this.max}.`,this);return}if(this.required&&i.length===0){this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this);return}this.internals.setValidity({})}#f(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#p(t){let e=new Set,i=[];for(let r of t){if(r==null||r==="")continue;let n=String(r);e.has(n)||(e.add(n),i.push(n))}return i.join(",")}toggle(t){if(!this.multiple){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}let e=this.#f(),i=e.indexOf(String(t)),r=e.slice(),n=[],o=[];if(i>=0)e.splice(i,1),o=[String(t)];else{if(this.max>0&&e.length>=this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:r,reason:"max"}}));return}e.push(String(t)),n=[String(t)]}let a=this.#p(e);this.value=a,this.syncValue(a),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e,added:n,removed:o}}))}selectAllOptions(){if(!this.multiple)return;let t=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null),e=this.#p(t.map(o=>o.value));if(e===this.value)return;let i=this.#f();this.value=e,this.syncValue(e),this.render();let r=this.#f(),n=r.filter(o=>!i.includes(o));this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:n,removed:[]}}))}clear(){if(!this.multiple){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:""}}));return}let t=this.#f();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#m(){let t=this.#f();if(t.length===0)return;let e=t.pop(),i=this.#p(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#g=t=>{if(!this.multiple)return;let e=t.target;if(!e||e.tagName!=="TAG-UI")return;let i=e.dataset.chipValue;if(!i)return;t.stopPropagation();let r=this.#f().filter(o=>o!==i),n=this.#p(r);this.value=n,this.syncValue(n),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,added:[],removed:[i]}}))};#b=t=>{t.stopPropagation(),!this.disabled&&(this.open=!0)};#O=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#y=t=>{if(t.stopPropagation(),this.disabled||this.readonly)return;let i=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null).map(o=>String(o.value)),r=new Set(this.#f());i.length>0&&i.every(o=>r.has(o))?this.clear():this.selectAllOptions()};#v=void 0;#S(){let t="Select...";if(this.labelHidden&&this.label){this.#v=Zt(this,this.#v,this.label);return}let r=!(!!this.label||this.hasAttribute("aria-labelledby"))&&this.placeholder&&this.placeholder!==t?this.placeholder:"";this.#v=Zt(this,this.#v,r)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#T),this.addEventListener("keydown",this.#I),this.addEventListener("remove",this.#g),this.#i.length===0&&this.#E(),!this.#c&&typeof MutationObserver<"u"&&(this.#c=new MutationObserver(()=>{this.#i.length||!this.#A().some(e=>e.tagName==="OPTION"||e.tagName==="OPTGROUP")||(this.#E(),this.#i.length&&(this.#w(),this.#x()))})),this.#c?.observe(this,{childList:!0,subtree:!0})}render(){if(this.#S(),this.querySelector('[slot="trigger"]'))this.#x();else{this.#s=!0;let e=this.#r;e?.parentNode===this&&this.removeChild(e);let i=this.mark?'<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':this.avatar?`<img slot="leading" data-select-leading src="${Nt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${Nt(this.icon)}"></icon-ui>`:"",r=this.#M()===this.placeholder?"":this.#M(),n=this.searchable?`<span slot="display" contenteditable="plaintext-only" role="combobox" aria-autocomplete="list" tabindex="0" data-placeholder="${Nt(this.placeholder||"")}"${r?"":" data-empty"}>${Nt(r)}</span>`:`<span slot="display">${Nt(this.#M())}</span>`,o=this.hint?`select-hint-${++s.#e}`:"",a=this.hint?`<span slot="hint" id="${o}">${Nt(this.hint)}</span>`:"";this.innerHTML=`
|
|
137
137
|
<span slot="trigger">
|
|
138
138
|
${i}
|
|
139
139
|
<span data-chips></span>
|
|
@@ -142,7 +142,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
142
142
|
<icon-ui name="caret-down" slot="caret"></icon-ui>
|
|
143
143
|
</span>
|
|
144
144
|
${a}
|
|
145
|
-
`,this.hint&&this.setAttribute("aria-describedby",o);let l=this.querySelector("[data-clear-all]");l&&(l.removeEventListener("click",this.#O),l.addEventListener("click",this.#O)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#R),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#d)),this.#o=this.querySelector('[slot="display"][contenteditable]'),this.#o&&(this.#o.addEventListener("input",this.#R),this.#o.addEventListener("focus",this.#h),this.#o.addEventListener("click",this.#d))),e&&this.appendChild(e)}this.#k(),this.multiple&&this.#T();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.#w()),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");r!==null&&(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=Ot(e,this.#r,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#M,{once:!0})})}else this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#M)}#x(){let t=this.querySelector('[slot="display"]');if(t)if(this.multiple){let e=this.#f().length>0;t.hasAttribute("contenteditable")?(t.setAttribute("data-placeholder",e?"":this.placeholder||""),this.#a||(t.textContent="",t.toggleAttribute("data-empty",!0))):t.textContent=e?"":this.placeholder||""}else if(t.hasAttribute("contenteditable")){if(!this.#a){let e=this.#L()===this.placeholder?"":this.#L();t.textContent=e,t.toggleAttribute("data-empty",!e)}}else t.textContent=this.#L()}#A(){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}#C(){this.#i=[];let t=new Set,e=[];for(let i of this.#A())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")||"",mark:n.hasAttribute("mark")}),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")||"",mark:i.hasAttribute("mark")}),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){tt(()=>{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.#w(),this.#x(),this.#k()})}get options(){return this.#i}static#P(t){return t?t.mark?'<adia-mark-ui data-select-mark size="sm"></adia-mark-ui>':t.avatar?`<img data-option-avatar src="${Nt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Nt(t.icon)}"></icon-ui>`:"":""}#k(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(u=>u.options||[u]).find(u=>!u.header&&!u.separator&&u.value===this.value),r=i&&i.mark||this.mark||!1,n=i&&i.avatar||this.avatar||"",o=i&&i.icon||this.icon||"",a=t.querySelector(":scope > [data-select-leading]"),l="";if(r?l='<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':n?l=`<img slot="leading" data-select-leading src="${Nt(n)}" alt="" />`:o&&(l=`<icon-ui slot="leading" data-select-leading name="${Nt(o)}"></icon-ui>`),!l){a?.remove();return}let h=document.createElement("template");h.innerHTML=l;let c=h.content.firstElementChild;a?a.tagName===c.tagName?c.tagName==="IMG"?a.getAttribute("src")!==c.getAttribute("src")&&a.setAttribute("src",c.getAttribute("src")):a.getAttribute("name")!==c.getAttribute("name")&&a.setAttribute("name",c.getAttribute("name")):a.replaceWith(c):t.insertBefore(c,t.firstChild)}#w(){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-ui");i.setAttribute("variant","ghost"),i.setAttribute("size","xs"),i.dataset.selectAllBtn="",i.setAttribute("text",this.#E()?"Clear":"Select all"),i.addEventListener("click",this.#v),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"),e.action||i.setAttribute("data-value",e.value||"");let r=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,n=!e.action&&(r?r.has(e.value):e.value===this.value),o=s.#P(e);if(e.action){i.setAttribute("data-action-option","");let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Nt(e.label)}`:a.textContent=e.label,i.appendChild(a)}else 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}${Nt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else{if(i.setAttribute("data-single-option",""),!(this.noRadio||this.mark)){let l=document.createElement("span");l.setAttribute("data-radio",""),l.setAttribute("aria-hidden","true"),i.appendChild(l)}let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Nt(e.label)}`:a.textContent=e.label,i.appendChild(a)}return n&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#u),i};for(let e of this.#i)if(e.separator)this.#r.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${Nt(e.label)}</strong><span>${Nt(e.description||"")}</span></div>`:`<div><strong>${Nt(e.label)}</strong><span>${Nt(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">${Nt(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.#q()}#E(){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)))}#T(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;if(this.summaryLabel){for(;t.firstChild;)t.removeChild(t.firstChild);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=a=>this.#$(a);for(;t.firstChild;)t.removeChild(t.firstChild);for(let a of r){let l=document.createElement("tag-ui");l.setAttribute("size","sm"),!this.disabled&&!this.readonly&&l.setAttribute("removable",""),l.dataset.chipValue=String(a),l.setAttribute("text",o(a)),t.appendChild(l)}if(n>0){let a=document.createElement("button-ui");a.setAttribute("variant","ghost"),a.setAttribute("size","xs"),a.dataset.more="",a.setAttribute("text",`+${n} more`),a.addEventListener("click",this.#b),t.appendChild(a)}}#$(t){let i=this.#i.flatMap(r=>r.options||[r]).filter(r=>!r.separator&&!r.header&&r.value!=null).find(r=>String(r.value)===String(t));return i?i.label:String(t)}#L(){if(this.multiple){if(this.summaryLabel){let i=this.#f();return i.length===0?this.placeholder:i.length===1?this.#$(i[0]):`${this.summaryLabel} (${i.length})`}return this.value?"":this.placeholder}return this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#Q=t=>{this.disabled||this.#r&&t.composedPath().includes(this.#r)||(this.open=!this.open)};#M=t=>{!this.contains(t.target)&&!(this.#r&&t.composedPath().includes(this.#r))&&(this.open=!1)};#I=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.hasAttribute?.("contenteditable")&&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('[slot="display"][contenteditable]');e&&(e.textContent="",e.toggleAttribute("data-empty",!0)),this.#q();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.#z(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#z(-1))};#R=t=>{let e=t.target.textContent||"";this.#a=e,t.target.toggleAttribute("data-empty",!e),this.open||(this.open=!0),this.#q()};#q(){if(!this.#r)return;let t=o=>o.toLowerCase().replace(/_/g," "),e=t(this.#a),i=this.#r.querySelectorAll('[role="option"]'),r=!1;for(let o of i){let a=t(o.textContent||"");!e||a.includes(e)?(o.removeAttribute("data-filtered-out"),o.style.display="",r=!0):(o.setAttribute("data-filtered-out",""),o.style.display="none")}for(let o of this.#r.querySelectorAll('[role="group"]')){let a=o.querySelectorAll('[role="option"]:not([data-filtered-out])').length;o.style.display=a?"":"none"}let n=this.#r.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#z(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.#I),this.removeEventListener("remove",this.#g),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#M),this.#o&&(this.#o.removeEventListener("input",this.#R),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#d),this.#o=null),this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#r=null}};M();w("select-ui",Tr);R();var Lr=class extends k{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()}};M();w("segment-ui",Lr);var Mr=class s extends X{static properties={...X.properties,multiple:{type:Boolean,default:!1,reflect:!0},value:{type:String,default:"",reflect:!0},allowEmpty:{type:Boolean,default:!1,reflect:!0,attribute:"allow-empty"}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#r=null;#n=null;connected(){if(super.connected(),this.setAttribute("role",this.multiple?"group":"radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#d),this.addEventListener("keydown",this.#f)),!this.multiple&&!this.value&&!this.allowEmpty){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#r=new ResizeObserver(()=>this.#c(this.#a)),this.#r.observe(this)),document.fonts?.ready&&(this.#n=document.fonts.ready.then(()=>{this.#n=null,this.#c(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.#d),this.removeEventListener("keydown",this.#f),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}get#l(){return new Set(this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[])}render(){if(this.setAttribute("role",this.multiple?"group":"radiogroup"),!s.#t.has(this)){let r=[...this.children].find(n=>n.tagName!=="SEGMENT-UI"&&!n.hasAttribute("data-indicator")&&!(n.tagName==="SPAN"&&n.style.display==="contents"));r&&(s.#t.add(this),console.warn(`[segmented-ui] child <${r.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)return;let e=this.multiple?this.#l:null,i=!1;for(let r of t){let n=r.value||r.getAttribute("value")||"",o=this.multiple?e.has(n):n===this.value;r.setAttribute("role",this.multiple?"checkbox":"radio"),o?(r.setAttribute("selected",""),i=!0):r.removeAttribute("selected"),r.setAttribute("tabindex",o?"0":"-1")}i||t.find(n=>!n.disabled)?.setAttribute("tabindex","0"),this.label&&this.setAttribute("aria-label",this.label),this.#c(t)}#c(t){if(this.multiple){for(let r of this.querySelectorAll(":scope > [data-indicator]"))r.remove();this.#e=null,this.removeAttribute("data-indicator-ready");return}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",""))}#h(t){if(t.disabled)return;let e=t.value||t.getAttribute("value")||"";if(this.multiple){if(!e)return;let i=this.#l;i.has(e)?i.delete(e):i.add(e),this.value=[...i].join(",")}else this.value=e;this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}#d=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#h(e)};#u(t,e){let i=this.#o,r=i.indexOf(t);if(r<0)return null;switch(e){case"ArrowRight":case"ArrowDown":return i[r<i.length-1?r+1:0];case"ArrowLeft":case"ArrowUp":return i[r>0?r-1:i.length-1];case"Home":return i[0];case"End":return i[i.length-1];default:return null}}#f=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;if(this.multiple){if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.#h(e);return}let r=this.#u(e,t.key);if(!r)return;t.preventDefault(),r.focus();return}let i=this.#u(e,t.key);i&&(t.preventDefault(),i.focus(),this.#h(i))}};M();w("segmented-ui",Mr);var Rr=class extends X{static labelDeprecated=!1;static properties={...X.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;#n=void 0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
|
|
145
|
+
`,this.hint&&this.setAttribute("aria-describedby",o);let l=this.querySelector("[data-clear-all]");l&&(l.removeEventListener("click",this.#O),l.addEventListener("click",this.#O)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#L),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#d)),this.#o=this.querySelector('[slot="display"][contenteditable]'),this.#o&&(this.#o.addEventListener("input",this.#L),this.#o.addEventListener("focus",this.#h),this.#o.addEventListener("click",this.#d))),e&&this.appendChild(e)}this.#k(),this.multiple&&this.#Q();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.#w()),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");r!==null&&(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=Ot(e,this.#r,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#R,{once:!0})})}else this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#R)}#x(){let t=this.querySelector('[slot="display"]');if(t)if(this.multiple){let e=this.#f().length>0;t.hasAttribute("contenteditable")?(t.setAttribute("data-placeholder",e?"":this.placeholder||""),this.#a||(t.textContent="",t.toggleAttribute("data-empty",!0))):t.textContent=e?"":this.placeholder||""}else if(t.hasAttribute("contenteditable")){if(!this.#a){let e=this.#M()===this.placeholder?"":this.#M();t.textContent=e,t.toggleAttribute("data-empty",!e)}}else t.textContent=this.#M()}#A(){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}#E(){this.#i=[];let t=new Set,e=[];for(let i of this.#A())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")||"",mark:n.hasAttribute("mark")}),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")||"",mark:i.hasAttribute("mark")}),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){tt(()=>{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.#w(),this.#x(),this.#k()})}get options(){return this.#i}static#$(t){return t?t.mark?'<adia-mark-ui data-select-mark size="sm"></adia-mark-ui>':t.avatar?`<img data-option-avatar src="${Nt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Nt(t.icon)}"></icon-ui>`:"":""}#k(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(u=>u.options||[u]).find(u=>!u.header&&!u.separator&&u.value===this.value),r=i&&i.mark||this.mark||!1,n=i&&i.avatar||this.avatar||"",o=i&&i.icon||this.icon||"",a=t.querySelector(":scope > [data-select-leading]"),l="";if(r?l='<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':n?l=`<img slot="leading" data-select-leading src="${Nt(n)}" alt="" />`:o&&(l=`<icon-ui slot="leading" data-select-leading name="${Nt(o)}"></icon-ui>`),!l){a?.remove();return}let h=document.createElement("template");h.innerHTML=l;let c=h.content.firstElementChild;a?a.tagName===c.tagName?c.tagName==="IMG"?a.getAttribute("src")!==c.getAttribute("src")&&a.setAttribute("src",c.getAttribute("src")):a.getAttribute("name")!==c.getAttribute("name")&&a.setAttribute("name",c.getAttribute("name")):a.replaceWith(c):t.insertBefore(c,t.firstChild)}#w(){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-ui");i.setAttribute("variant","ghost"),i.setAttribute("size","xs"),i.dataset.selectAllBtn="",i.setAttribute("text",this.#C()?"Clear":"Select all"),i.addEventListener("click",this.#y),e.appendChild(i),this.#r.appendChild(e)}let t=e=>{if(e.separator){let a=document.createElement("hr");return a.setAttribute("data-separator",""),a}let i=document.createElement("div");i.setAttribute("role","option"),e.action||i.setAttribute("data-value",e.value||"");let r=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,n=!e.action&&(r?r.has(e.value):e.value===this.value),o=s.#$(e);if(e.action){i.setAttribute("data-action-option","");let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Nt(e.label)}`:a.textContent=e.label,i.appendChild(a)}else 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}${Nt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else{if(i.setAttribute("data-single-option",""),!(this.noRadio||this.mark)){let l=document.createElement("span");l.setAttribute("data-radio",""),l.setAttribute("aria-hidden","true"),i.appendChild(l)}let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Nt(e.label)}`:a.textContent=e.label,i.appendChild(a)}return n&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#u),i};for(let e of this.#i)if(e.separator)this.#r.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${Nt(e.label)}</strong><span>${Nt(e.description||"")}</span></div>`:`<div><strong>${Nt(e.label)}</strong><span>${Nt(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">${Nt(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)))}#Q(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;if(this.summaryLabel){for(;t.firstChild;)t.removeChild(t.firstChild);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=a=>this.#P(a);for(;t.firstChild;)t.removeChild(t.firstChild);for(let a of r){let l=document.createElement("tag-ui");l.setAttribute("size","sm"),!this.disabled&&!this.readonly&&l.setAttribute("removable",""),l.dataset.chipValue=String(a),l.setAttribute("text",o(a)),t.appendChild(l)}if(n>0){let a=document.createElement("button-ui");a.setAttribute("variant","ghost"),a.setAttribute("size","xs"),a.dataset.more="",a.setAttribute("text",`+${n} more`),a.addEventListener("click",this.#b),t.appendChild(a)}}#P(t){let i=this.#i.flatMap(r=>r.options||[r]).filter(r=>!r.separator&&!r.header&&r.value!=null).find(r=>String(r.value)===String(t));return i?i.label:String(t)}#M(){if(this.multiple){if(this.summaryLabel){let i=this.#f();return i.length===0?this.placeholder:i.length===1?this.#P(i[0]):`${this.summaryLabel} (${i.length})`}return this.value?"":this.placeholder}return this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#T=t=>{this.disabled||this.#r&&t.composedPath().includes(this.#r)||(this.open=!this.open)};#R=t=>{!this.contains(t.target)&&!(this.#r&&t.composedPath().includes(this.#r))&&(this.open=!1)};#I=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.hasAttribute?.("contenteditable")&&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('[slot="display"][contenteditable]');e&&(e.textContent="",e.toggleAttribute("data-empty",!0)),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.#z(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#z(-1))};#L=t=>{let e=t.target.textContent||"";this.#a=e,t.target.toggleAttribute("data-empty",!e),this.open||(this.open=!0),this.#D()};#D(){if(!this.#r)return;let t=o=>o.toLowerCase().replace(/_/g," "),e=t(this.#a),i=this.#r.querySelectorAll('[role="option"]'),r=!1;for(let o of i){let a=t(o.textContent||"");!e||a.includes(e)?(o.removeAttribute("data-filtered-out"),o.style.display="",r=!0):(o.setAttribute("data-filtered-out",""),o.style.display="none")}for(let o of this.#r.querySelectorAll('[role="group"]')){let a=o.querySelectorAll('[role="option"]:not([data-filtered-out])').length;o.style.display=a?"":"none"}let n=this.#r.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#z(t){if(!this.#r)return;let e=[...this.#r.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#r.querySelector('[role="option"][data-focused]'),r=i?e.indexOf(i):-1,n=e[(r+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),n&&(n.setAttribute("data-focused",""),n.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#T),this.removeEventListener("keydown",this.#I),this.removeEventListener("remove",this.#g),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#R),this.#o&&(this.#o.removeEventListener("input",this.#L),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#d),this.#o=null),this.#n?.(),this.#n=null,this.#r?.hidePopover?.(),this.#r=null}};M();w("select-ui",Tr);R();var Lr=class extends k{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()}};M();w("segment-ui",Lr);var Mr=class s extends X{static properties={...X.properties,multiple:{type:Boolean,default:!1,reflect:!0},value:{type:String,default:"",reflect:!0},allowEmpty:{type:Boolean,default:!1,reflect:!0,attribute:"allow-empty"}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#r=null;#n=null;connected(){if(super.connected(),this.setAttribute("role",this.multiple?"group":"radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#d),this.addEventListener("keydown",this.#f)),!this.multiple&&!this.value&&!this.allowEmpty){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#r=new ResizeObserver(()=>this.#c(this.#a)),this.#r.observe(this)),document.fonts?.ready&&(this.#n=document.fonts.ready.then(()=>{this.#n=null,this.#c(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.#d),this.removeEventListener("keydown",this.#f),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}get#l(){return new Set(this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[])}render(){if(this.setAttribute("role",this.multiple?"group":"radiogroup"),!s.#t.has(this)){let r=[...this.children].find(n=>n.tagName!=="SEGMENT-UI"&&!n.hasAttribute("data-indicator")&&!(n.tagName==="SPAN"&&n.style.display==="contents"));r&&(s.#t.add(this),console.warn(`[segmented-ui] child <${r.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)return;let e=this.multiple?this.#l:null,i=!1;for(let r of t){let n=r.value||r.getAttribute("value")||"",o=this.multiple?e.has(n):n===this.value;r.setAttribute("role",this.multiple?"checkbox":"radio"),o?(r.setAttribute("selected",""),i=!0):r.removeAttribute("selected"),r.setAttribute("tabindex",o?"0":"-1")}i||t.find(n=>!n.disabled)?.setAttribute("tabindex","0"),this.label&&this.setAttribute("aria-label",this.label),this.#c(t)}#c(t){if(this.multiple){for(let r of this.querySelectorAll(":scope > [data-indicator]"))r.remove();this.#e=null,this.removeAttribute("data-indicator-ready");return}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",""))}#h(t){if(t.disabled)return;let e=t.value||t.getAttribute("value")||"";if(this.multiple){if(!e)return;let i=this.#l;i.has(e)?i.delete(e):i.add(e),this.value=[...i].join(",")}else this.value=e;this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}#d=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#h(e)};#u(t,e){let i=this.#o,r=i.indexOf(t);if(r<0)return null;switch(e){case"ArrowRight":case"ArrowDown":return i[r<i.length-1?r+1:0];case"ArrowLeft":case"ArrowUp":return i[r>0?r-1:i.length-1];case"Home":return i[0];case"End":return i[i.length-1];default:return null}}#f=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;if(this.multiple){if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.#h(e);return}let r=this.#u(e,t.key);if(!r)return;t.preventDefault(),r.focus();return}let i=this.#u(e,t.key);i&&(t.preventDefault(),i.focus(),this.#h(i))}};M();w("segmented-ui",Mr);var Rr=class extends X{static labelDeprecated=!1;static properties={...X.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;#n=void 0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
|
|
146
146
|
<span slot="label">${this.label}</span>
|
|
147
147
|
<span slot="value">${this.#a(this.value)}</span>
|
|
148
148
|
${this.suffix?`<span slot="suffix">${this.suffix}</span>`:""}
|
|
@@ -151,7 +151,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
151
151
|
<div slot="layer" data-layer="base">${t}</div>
|
|
152
152
|
<div slot="layer" data-layer="fill" aria-hidden="true">${t}</div>
|
|
153
153
|
</div>
|
|
154
|
-
`}this.#t=this.querySelector('[slot="field"]'),this.#e=this.querySelector('[data-layer="base"] [slot="value"]'),this.#t&&this.#t.addEventListener("pointerdown",this.#h),this.addEventListener("keydown",this.#f)}render(){if(!this.#t)return;let t=this.#a(this.value);this.#e&&(this.#e.textContent=t);let e=this.querySelector('[data-layer="fill"] [slot="value"]');e&&(e.textContent=t);let i=this.max-this.min,r=i>0?(this.value-this.min)/i*100:0;this.style.setProperty("--range-fill-pct",`${r}%`),this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.value}${this.suffix?" "+this.suffix:""}`),this.#n=Zt(this,this.#n,this.label||""),this.syncValue(String(this.value))}#a(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}#o(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))))}#l(t){let e=this.#o(t);e!==this.value&&(this.value=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})))}#c(t){let e=this.#t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-e.left)/e.width));return this.#o(this.min+i*(this.max-this.min))}#h=t=>{this.disabled||(t.preventDefault(),this.#l(this.#c(t.clientX)),this.#i=!0,this.#s=t.clientX,this.#r=this.value,this.setAttribute("dragging",""),this.#t.setPointerCapture(t.pointerId),this.#t.addEventListener("pointermove",this.#d),this.#t.addEventListener("pointerup",this.#u))};#d=t=>{if(!this.#i)return;let e=t.clientX-this.#s,i=this.#t.getBoundingClientRect().width,r=this.max-this.min,n=e/i*r;this.#l(this.#r+n)};#u=t=>{this.#i=!1,this.removeAttribute("dragging"),this.#t.releasePointerCapture(t.pointerId),this.#t.removeEventListener("pointermove",this.#d),this.#t.removeEventListener("pointerup",this.#u),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#f=t=>{if(this.disabled)return;let e=this.value;switch(t.key){case"ArrowRight":case"ArrowUp":e+=this.step;break;case"ArrowLeft":case"ArrowDown":e-=this.step;break;case"Home":e=this.min;break;case"End":e=this.max;break;case"PageUp":e+=this.step*10;break;case"PageDown":e-=this.step*10;break;default:return}t.preventDefault(),this.#l(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};disconnected(){super.disconnected(),this.#t?.removeEventListener("pointerdown",this.#h),this.#t?.removeEventListener("pointermove",this.#d),this.#t?.removeEventListener("pointerup",this.#u),this.removeEventListener("keydown",this.#f),this.#t=null,this.#e=null}};M();w("range-ui",Rr);R();ii();var Ir=class extends k{static requiredIcons=["caret-right"];static template=()=>null;connected(){this.setAttribute("role","tree"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}get selectedItem(){return this.querySelector("tree-item-ui[selected]")}select(t,e=null){let i=this.selectedItem;i&&i!==t&&i.removeAttribute("selected"),t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("tree-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value,ctrlKey:!!e?.ctrlKey,metaKey:!!e?.metaKey,shiftKey:!!e?.shiftKey}}))}#t(t){if(!t)return null;if(re(t))return t.matches?.("tree-item-ui")?t:null;if(typeof t=="string"){let e=t.replace(/"/g,'\\"');return this.querySelector(`tree-item-ui[value="${e}"]`)||this.querySelector(`tree-item-ui[text="${e}"]`)||null}return null}expand(t){let e=this.#t(t);e&&e.hasChildren&&!e.open&&(e.open=!0)}collapse(t){let e=this.#t(t);e&&e.open&&(e.open=!1)}expandAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.hasChildren&&!t.open&&(t.open=!0)}collapseAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.open&&(t.open=!1)}expandTo(t){let e=this.#t(t);if(!e)return;let i=e.parentElement?.closest("tree-item-ui");for(;i;)i.hasChildren&&!i.open&&(i.open=!0),i=i.parentElement?.closest("tree-item-ui");e.querySelector(':scope > [slot="row"]')?.scrollIntoView?.({block:"nearest",inline:"nearest"})}#e=t=>{let e=t.target.closest("tree-item-ui");if(!e||!this.contains(e)||t.target.closest('[slot="actions"] *'))return;let i=e.querySelector(':scope > [slot="row"]');!i||!(t.target===i||i.contains(t.target))||(this.select(e,t),e.hasChildren&&(e.open=!e.open))};#i=t=>{let e=t.target.closest("tree-item-ui");if(e)switch(t.key){case"ArrowRight":if(t.preventDefault(),e.hasChildren&&!e.open)e.open=!0;else{let i=e.querySelector(":scope > tree-item-ui");i&&i.querySelector('[slot="row"]')?.focus()}break;case"ArrowLeft":if(t.preventDefault(),e.hasChildren&&e.open)e.open=!1;else{let i=e.parentElement?.closest("tree-item-ui");i&&i.querySelector(':scope > [slot="row"]')?.focus()}break;case"ArrowDown":{t.preventDefault();let i=this.#s(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"ArrowUp":{t.preventDefault();let i=this.#r(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"Enter":case" ":t.preventDefault(),this.select(e,t);break}};#s(t){if(t.open&&t.hasChildren)return t.querySelector(":scope > tree-item-ui");let e=t;for(;e;){let i=e.nextElementSibling;if(i&&i.matches("tree-item-ui"))return i;e=e.parentElement?.closest("tree-item-ui")}return null}#r(t){let e=t.previousElementSibling;if(e&&e.matches("tree-item-ui")){let r=e;for(;r.open&&r.hasChildren;){let n=r.querySelectorAll(":scope > tree-item-ui");r=n[n.length-1]}return r}return t.parentElement?.closest("tree-item-ui")||null}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}},Dr=class extends k{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},badge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;get hasChildren(){return this.querySelector(":scope > tree-item-ui")!==null}get depth(){let t=0,e=this.parentElement;for(;e;)e.matches("tree-item-ui")&&t++,e=e.parentElement;return t}connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="row"]')||this.#i();let t=this.querySelector(':scope > [slot="row"]');t&&(t.setAttribute("role","treeitem"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","0")),this.#r(),typeof MutationObserver<"u"&&(this.#t=new MutationObserver(()=>this.#r()),this.#t.observe(this,{childList:!0,subtree:!0}))}#i(){let t=document.createElement("div");t.setAttribute("slot","row"),t.setAttribute("tabindex","0");let e=this.#s("caret")[0];if(e)t.appendChild(e);else{let o=document.createElement("icon-ui");o.setAttribute("slot","caret"),o.setAttribute("name","caret-right"),o.dataset.treeCaretDefault="1",t.appendChild(o)}if(this.icon){let o=document.createElement("icon-ui");o.setAttribute("name",this.icon),o.setAttribute("slot","icon"),t.appendChild(o)}let i=document.createElement("span");i.setAttribute("slot","text"),i.textContent=this.text,t.appendChild(i);let r=document.createElement("span");r.setAttribute("slot","badge"),this.badge&&(r.textContent=this.badge),t.appendChild(r);let n=document.createElement("span");n.setAttribute("slot","actions"),n.dataset.treeActionsPlaceholder="1",t.appendChild(n),this.prepend(t)}render(){let t=this.querySelector(':scope > [slot="row"]');if(!t)return;t.style.paddingInlineStart=`${this.depth*16+4}px`,this.hasChildren?t.setAttribute("aria-expanded",String(this.open)):t.removeAttribute("aria-expanded"),this.selected?t.setAttribute("aria-selected","true"):t.removeAttribute("aria-selected");let e=t.querySelector('[slot="text"]');e&&this.text&&(e.textContent=this.text);let i=t.querySelector('[slot="badge"]');i&&(i.textContent=this.badge||"")}#s(t){let e=[],i=r=>{for(let n of r.children)if(!n.matches("tree-item-ui")){if(n.getAttribute("slot")===t){e.push(n);continue}(n.matches('[role="presentation"]')||n.style?.display==="contents")&&i(n)}};return i(this),e}#r(){if(this.#e)return;let t=this.querySelector(':scope > [slot="row"]');if(t){this.#e=!0;try{let e=this.#s("actions").filter(r=>!r.dataset.treeActionsPlaceholder&&r.parentElement!==t);if(e.length){t.querySelector(':scope > [slot="actions"][data-tree-actions-placeholder]')?.remove();for(let r of e)t.appendChild(r)}let i=this.#s("caret").find(r=>!r.dataset.treeCaretDefault&&r.parentElement!==t);i&&(t.querySelector(':scope > [slot="caret"][data-tree-caret-default]')?.remove(),t.prepend(i))}finally{this.#t?.takeRecords(),this.#e=!1}}}disconnected(){this.#t?.disconnect(),this.#t=null}};M();w("tree-ui",Ir),w("tree-item-ui",Dr);R();ii();var Nr=class extends k{static requiredIcons=["caret-left","caret-right","magnifying-glass"];static properties={rootLabel:{type:String,default:"",reflect:!0,attribute:"root-label"},filterable:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Filter\u2026",reflect:!0},selectOnDrill:{type:Boolean,default:!1,reflect:!0,attribute:"select-on-drill"},static:{type:Boolean,default:!1,reflect:!0}};static get observedAttributes(){return[...super.observedAttributes,"path"]}static template=()=>null;#t=[];#e=new WeakMap;#i=new WeakMap;#s=[];#r="";#n=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m=new WeakMap;#g=null;#b=null;#O=[];#v=!1;get items(){return this.#t}set items(t){this.#t=Array.isArray(t)?t:[],this.#e=new WeakMap,this.#i=new WeakMap,this.#n&&this.#w(null)}get path(){return[...this.#O]}set path(t){this.#y(Array.isArray(t)?t.map(String):[],!1)}#y(t,e){let i=this.#O,r=i.length!==t.length||t.some((o,a)=>o!==i[a]),n=null;r&&(t.length>i.length&&i.every((o,a)=>o===t[a])?n="forward":i.length>t.length&&t.every((o,a)=>o===i[a])&&(n="backward")),this.#O=t,e||(this.#v=!0,t.length?this.setAttribute("path",JSON.stringify(t)):this.removeAttribute("path"),this.#v=!1),this.#n&&(this.#w(n),r&&this.dispatchEvent(new CustomEvent("navigate",{bubbles:!0,detail:{path:[...t]}})))}attributeChangedCallback(t,e,i){if(t==="path"){if(this.#v)return;let r=[];try{let n=JSON.parse(i??"[]");Array.isArray(n)&&(r=n.map(String))}catch{}this.#y(r,!0);return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","group"),this.addEventListener("keydown",this.#B),this.hasAttribute("path")){let t=[];try{let e=JSON.parse(this.getAttribute("path")??"[]");Array.isArray(e)&&(t=e.map(String))}catch{}this.#O=t}}render(){this.#n||this.#S(),this.#w(null)}disconnected(){this.removeEventListener("keydown",this.#B),this.#d?.removeEventListener("input",this.#X),this.#a?.removeEventListener("click",this.#z),this.#u?.removeEventListener("click",this.#Z),this.#u=null,this.#d=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null,this.#h=null,this.#f=null,this.#p=null}#S(){this.innerHTML=`
|
|
154
|
+
`}this.#t=this.querySelector('[slot="field"]'),this.#e=this.querySelector('[data-layer="base"] [slot="value"]'),this.#t&&this.#t.addEventListener("pointerdown",this.#h),this.addEventListener("keydown",this.#f)}render(){if(!this.#t)return;let t=this.#a(this.value);this.#e&&(this.#e.textContent=t);let e=this.querySelector('[data-layer="fill"] [slot="value"]');e&&(e.textContent=t);let i=this.max-this.min,r=i>0?(this.value-this.min)/i*100:0;this.style.setProperty("--range-fill-pct",`${r}%`),this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.value}${this.suffix?" "+this.suffix:""}`),this.#n=Zt(this,this.#n,this.label||""),this.syncValue(String(this.value))}#a(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}#o(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))))}#l(t){let e=this.#o(t);e!==this.value&&(this.value=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})))}#c(t){let e=this.#t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-e.left)/e.width));return this.#o(this.min+i*(this.max-this.min))}#h=t=>{this.disabled||(t.preventDefault(),this.#l(this.#c(t.clientX)),this.#i=!0,this.#s=t.clientX,this.#r=this.value,this.setAttribute("dragging",""),this.#t.setPointerCapture(t.pointerId),this.#t.addEventListener("pointermove",this.#d),this.#t.addEventListener("pointerup",this.#u))};#d=t=>{if(!this.#i)return;let e=t.clientX-this.#s,i=this.#t.getBoundingClientRect().width,r=this.max-this.min,n=e/i*r;this.#l(this.#r+n)};#u=t=>{this.#i=!1,this.removeAttribute("dragging"),this.#t.releasePointerCapture(t.pointerId),this.#t.removeEventListener("pointermove",this.#d),this.#t.removeEventListener("pointerup",this.#u),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#f=t=>{if(this.disabled)return;let e=this.value;switch(t.key){case"ArrowRight":case"ArrowUp":e+=this.step;break;case"ArrowLeft":case"ArrowDown":e-=this.step;break;case"Home":e=this.min;break;case"End":e=this.max;break;case"PageUp":e+=this.step*10;break;case"PageDown":e-=this.step*10;break;default:return}t.preventDefault(),this.#l(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};disconnected(){super.disconnected(),this.#t?.removeEventListener("pointerdown",this.#h),this.#t?.removeEventListener("pointermove",this.#d),this.#t?.removeEventListener("pointerup",this.#u),this.removeEventListener("keydown",this.#f),this.#t=null,this.#e=null}};M();w("range-ui",Rr);R();ii();var Ir=class extends k{static requiredIcons=["caret-right"];static template=()=>null;connected(){this.setAttribute("role","tree"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}get selectedItem(){return this.querySelector("tree-item-ui[selected]")}select(t,e=null){let i=this.selectedItem;i&&i!==t&&i.removeAttribute("selected"),t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("tree-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value,ctrlKey:!!e?.ctrlKey,metaKey:!!e?.metaKey,shiftKey:!!e?.shiftKey}}))}#t(t){if(!t)return null;if(re(t))return t.matches?.("tree-item-ui")?t:null;if(typeof t=="string"){let e=t.replace(/"/g,'\\"');return this.querySelector(`tree-item-ui[value="${e}"]`)||this.querySelector(`tree-item-ui[text="${e}"]`)||null}return null}expand(t){let e=this.#t(t);e&&e.hasChildren&&!e.open&&(e.open=!0)}collapse(t){let e=this.#t(t);e&&e.open&&(e.open=!1)}expandAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.hasChildren&&!t.open&&(t.open=!0)}collapseAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.open&&(t.open=!1)}expandTo(t){let e=this.#t(t);if(!e)return;let i=e.parentElement?.closest("tree-item-ui");for(;i;)i.hasChildren&&!i.open&&(i.open=!0),i=i.parentElement?.closest("tree-item-ui");e.querySelector(':scope > [slot="row"]')?.scrollIntoView?.({block:"nearest",inline:"nearest"})}#e=t=>{let e=t.target.closest("tree-item-ui");if(!e||!this.contains(e)||t.target.closest('[slot="actions"] *'))return;let i=e.querySelector(':scope > [slot="row"]');!i||!(t.target===i||i.contains(t.target))||(this.select(e,t),e.hasChildren&&(e.open=!e.open))};#i=t=>{let e=t.target.closest("tree-item-ui");if(e)switch(t.key){case"ArrowRight":if(t.preventDefault(),e.hasChildren&&!e.open)e.open=!0;else{let i=e.querySelector(":scope > tree-item-ui");i&&i.querySelector('[slot="row"]')?.focus()}break;case"ArrowLeft":if(t.preventDefault(),e.hasChildren&&e.open)e.open=!1;else{let i=e.parentElement?.closest("tree-item-ui");i&&i.querySelector(':scope > [slot="row"]')?.focus()}break;case"ArrowDown":{t.preventDefault();let i=this.#s(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"ArrowUp":{t.preventDefault();let i=this.#r(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"Enter":case" ":t.preventDefault(),this.select(e,t);break}};#s(t){if(t.open&&t.hasChildren)return t.querySelector(":scope > tree-item-ui");let e=t;for(;e;){let i=e.nextElementSibling;if(i&&i.matches("tree-item-ui"))return i;e=e.parentElement?.closest("tree-item-ui")}return null}#r(t){let e=t.previousElementSibling;if(e&&e.matches("tree-item-ui")){let r=e;for(;r.open&&r.hasChildren;){let n=r.querySelectorAll(":scope > tree-item-ui");r=n[n.length-1]}return r}return t.parentElement?.closest("tree-item-ui")||null}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}},Dr=class extends k{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},badge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;get hasChildren(){return this.querySelector(":scope > tree-item-ui")!==null}get depth(){let t=0,e=this.parentElement;for(;e;)e.matches("tree-item-ui")&&t++,e=e.parentElement;return t}connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="row"]')||this.#i();let t=this.querySelector(':scope > [slot="row"]');t&&(t.setAttribute("role","treeitem"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","0")),this.#r(),typeof MutationObserver<"u"&&(this.#t=new MutationObserver(()=>this.#r()),this.#t.observe(this,{childList:!0,subtree:!0}))}#i(){let t=document.createElement("div");t.setAttribute("slot","row"),t.setAttribute("tabindex","0");let e=this.#s("caret")[0];if(e)t.appendChild(e);else{let o=document.createElement("icon-ui");o.setAttribute("slot","caret"),o.setAttribute("name","caret-right"),o.dataset.treeCaretDefault="1",t.appendChild(o)}if(this.icon){let o=document.createElement("icon-ui");o.setAttribute("name",this.icon),o.setAttribute("slot","icon"),t.appendChild(o)}let i=document.createElement("span");i.setAttribute("slot","text"),i.textContent=this.text,t.appendChild(i);let r=document.createElement("span");r.setAttribute("slot","badge"),this.badge&&(r.textContent=this.badge),t.appendChild(r);let n=document.createElement("span");n.setAttribute("slot","actions"),n.dataset.treeActionsPlaceholder="1",t.appendChild(n),this.prepend(t)}render(){let t=this.querySelector(':scope > [slot="row"]');if(!t)return;t.style.paddingInlineStart=`${this.depth*16+4}px`,this.hasChildren?t.setAttribute("aria-expanded",String(this.open)):t.removeAttribute("aria-expanded"),this.selected?t.setAttribute("aria-selected","true"):t.removeAttribute("aria-selected");let e=t.querySelector('[slot="text"]');e&&this.text&&(e.textContent=this.text);let i=t.querySelector('[slot="badge"]');i&&(i.textContent=this.badge||"")}#s(t){let e=[],i=r=>{for(let n of r.children)if(!n.matches("tree-item-ui")){if(n.getAttribute("slot")===t){e.push(n);continue}(n.matches('[role="presentation"]')||n.style?.display==="contents")&&i(n)}};return i(this),e}#r(){if(this.#e)return;let t=this.querySelector(':scope > [slot="row"]');if(t){this.#e=!0;try{let e=this.#s("actions").filter(r=>!r.dataset.treeActionsPlaceholder&&r.parentElement!==t);if(e.length){t.querySelector(':scope > [slot="actions"][data-tree-actions-placeholder]')?.remove();for(let r of e)t.appendChild(r)}let i=this.#s("caret").find(r=>!r.dataset.treeCaretDefault&&r.parentElement!==t);i&&(t.querySelector(':scope > [slot="caret"][data-tree-caret-default]')?.remove(),t.prepend(i))}finally{this.#t?.takeRecords(),this.#e=!1}}}disconnected(){this.#t?.disconnect(),this.#t=null}};M();w("tree-ui",Ir),w("tree-item-ui",Dr);R();ii();var Nr=class extends k{static requiredIcons=["caret-left","caret-right","magnifying-glass"];static properties={rootLabel:{type:String,default:"",reflect:!0,attribute:"root-label"},filterable:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Filter\u2026",reflect:!0},selectOnDrill:{type:Boolean,default:!1,reflect:!0,attribute:"select-on-drill"},static:{type:Boolean,default:!1,reflect:!0}};static get observedAttributes(){return[...super.observedAttributes,"path"]}static template=()=>null;#t=[];#e=new WeakMap;#i=new WeakMap;#s=[];#r="";#n=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m=new WeakMap;#g=null;#b=null;#O=[];#y=!1;get items(){return this.#t}set items(t){this.#t=Array.isArray(t)?t:[],this.#e=new WeakMap,this.#i=new WeakMap,this.#n&&this.#w(null)}get path(){return[...this.#O]}set path(t){this.#v(Array.isArray(t)?t.map(String):[],!1)}#v(t,e){let i=this.#O,r=i.length!==t.length||t.some((o,a)=>o!==i[a]),n=null;r&&(t.length>i.length&&i.every((o,a)=>o===t[a])?n="forward":i.length>t.length&&t.every((o,a)=>o===i[a])&&(n="backward")),this.#O=t,e||(this.#y=!0,t.length?this.setAttribute("path",JSON.stringify(t)):this.removeAttribute("path"),this.#y=!1),this.#n&&(this.#w(n),r&&this.dispatchEvent(new CustomEvent("navigate",{bubbles:!0,detail:{path:[...t]}})))}attributeChangedCallback(t,e,i){if(t==="path"){if(this.#y)return;let r=[];try{let n=JSON.parse(i??"[]");Array.isArray(n)&&(r=n.map(String))}catch{}this.#v(r,!0);return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","group"),this.addEventListener("keydown",this.#B),this.hasAttribute("path")){let t=[];try{let e=JSON.parse(this.getAttribute("path")??"[]");Array.isArray(e)&&(t=e.map(String))}catch{}this.#O=t}}render(){this.#n||this.#S(),this.#w(null)}disconnected(){this.removeEventListener("keydown",this.#B),this.#d?.removeEventListener("input",this.#X),this.#a?.removeEventListener("click",this.#z),this.#u?.removeEventListener("click",this.#Z),this.#u=null,this.#d=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null,this.#h=null,this.#f=null,this.#p=null}#S(){this.innerHTML=`
|
|
155
155
|
<div slot="header">
|
|
156
156
|
<button-ui slot="back" icon="caret-left" variant="ghost" size="sm" hidden>
|
|
157
157
|
<span data-back-label></span>
|
|
@@ -170,7 +170,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
170
170
|
<div slot="panel" role="listbox"></div>
|
|
171
171
|
</div>
|
|
172
172
|
<div slot="live" aria-live="polite" data-visually-hidden></div>
|
|
173
|
-
`,this.#a=this.querySelector('[slot="back"]'),this.#o=this.querySelector("[data-back-label]"),this.#l=this.querySelector("[data-level-title]"),this.#c=this.querySelector("[data-level-count]"),this.#h=this.querySelector('[slot="filter"]'),this.#d=this.querySelector('[slot="filter"] input-ui'),this.#u=this.querySelector('[slot="panel"]'),this.#f=this.querySelector('[slot="live"]'),this.#p=this.querySelector('[slot="breadcrumb"]');let t=[...this.children].find(e=>e.getAttribute("slot")==="breadcrumb"&&e.parentElement===this);t&&t!==this.#p&&(this.#p.replaceWith(t),this.#p=t),this.#a.addEventListener("click",this.#z),this.#d.addEventListener("input",this.#X),this.#u.addEventListener("click",this.#Z),this.#n=!0}#x(){this.#h.hidden=!this.filterable,this.#d.setAttribute("placeholder",this.placeholder)}#A(t,e){return(t||[]).find(i=>String(i.value)===String(e))||null}#C(t){if(!t||t.leaf)return[];let e=t.children;if(e==null)return[];if(Array.isArray(e))return e;if(typeof e=="function"){if(this.#e.has(t))return this.#e.get(t);if(this.#i.has(t))return"loading";let i;try{i=e(t)}catch{i=[]}if(i&&typeof i.then=="function")return this.#i.set(t,i),i.then(n=>{this.#i.delete(t),this.#e.set(t,Array.isArray(n)?n:[]),this.#w(null)}).catch(()=>{this.#i.delete(t),this.#e.set(t,[]),this.#w(null)}),"loading";let r=Array.isArray(i)?i:[];return this.#e.set(t,r),r}return[]}#P(t){return!t||t.leaf?!1:Array.isArray(t.children)?t.children.length>0:typeof t.children=="function"}#k(t){let e=this.#t,i=null;for(let r of t){if(i=this.#A(e,r),!i)return{item:null,list:[]};let n=this.#C(i);if(e=n==="loading"?"loading":n,e==="loading")return{item:i,list:"loading"}}return{item:i,list:e}}#w(t){this.#n&&tt(()=>this.#E(t))}#E(t){this.#x();let e=this.path,{item:i,list:r}=this.#k(e),n=i?i.label??"":this.rootLabel||"";if(this.#l.textContent=n,this.#a.hidden=e.length===0,e.length>0){let{item:d}=this.#k(e.slice(0,-1));this.#o.textContent=d?d.label??"":this.rootLabel||""}let o=r==="loading",a=o?[]:r,l=this.#r.trim().toLowerCase(),h=l?a.filter(d=>(d.label||"").toLowerCase().includes(l)||(d.meta||"").toLowerCase().includes(l)):a;if(this.#c.textContent=o?"":String(a.length),this.#u.setAttribute("aria-busy",String(o)),this.#u.setAttribute("aria-label",n||"Items"),this.#u.innerHTML="",this.#u.removeAttribute("data-anim"),o)for(let d=0;d<4;d++){let f=document.createElement("skeleton-ui");f.setAttribute("height","2.25rem"),f.setAttribute("data-drilldown-skeleton",""),this.#u.appendChild(f)}else if(h.length)for(let d of h)this.#u.appendChild(this.#L(d));else{let d=document.createElement("empty-state-ui");d.setAttribute("minimal",""),d.setAttribute("heading",l?"No matches":"No items"),this.#u.appendChild(d)}this.static||(t==="forward"?this.#u.setAttribute("data-anim","forward"):t==="backward"&&this.#u.setAttribute("data-anim","backward"));let c=[...this.#u.querySelectorAll('[role="option"]')];if(this.#b==="first"&&c[0])this.#Q(c[0]),c[0].focus();else if(this.#b&&this.#b.restoreValue!=null){let d=c.find(f=>f.dataset.value===String(this.#b.restoreValue));d?(this.#Q(d),d.focus()):c[0]&&this.#Q(c[0])}else{let d=c.find(f=>f.dataset.value===this.#g);d?this.#Q(d):c[0]&&this.#Q(c[0])}this.#b=null;let u=o?"":` \u2014 ${a.length} item${a.length===1?"":"s"}`;this.#f.textContent=`${n||"Root"}${u}`}#T(t){return String(t??"").replace(/"/g,""")}#$(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}#L(t){let e=this.#P(t),i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("tabindex","-1"),i.setAttribute("aria-selected","false"),i.dataset.value=String(t.value),e||i.setAttribute("data-leaf","");let r="";t.dot&&(r+=`<span slot="dot" data-tone="${this.#T(t.dot)}"></span>`),r+=`<div slot="main"><span slot="label">${this.#$(t.label)}</span>`,t.meta&&(r+=`<span slot="meta">${this.#$(t.meta)}</span>`),r+="</div>";let n=Array.isArray(t.counts)?t.counts:[];return n.length&&(r+=`<span slot="counts">${n.map(o=>`<span data-drilldown-chip data-tone="${this.#T(o.variant||"neutral")}">${this.#$(o.value)}</span>`).join("")}</span>`),e&&(r+='<icon-ui name="caret-right" slot="chevron"></icon-ui>'),i.innerHTML=r,this.#m.set(i,t),i}#Q(t){let e=this.#u.querySelector('[role="option"][tabindex="0"]');e&&e!==t&&e.setAttribute("tabindex","-1"),t.setAttribute("tabindex","0"),this.#g=t.dataset.value}#M(t){let e=[...this.#u.querySelectorAll('[role="option"]')];if(!e.length)return;let i=this.#u.querySelector('[role="option"][tabindex="0"]'),r=i?e.indexOf(i):-1;r=(r+t+e.length)%e.length,this.#Q(e[r]),e[r].focus()}#I(t){let e=this.path;this.#s[e.length]=t.value,this.#b="first",this.path=[...e,t.value]}back(){let t=this.path;if(!t.length)return;let e=this.#s[t.length-1];this.#b={restoreValue:e},this.path=t.slice(0,-1)}#R(t){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{path:this.path,item:t}}))}#q(t){if(!this.#P(t)){this.#R(t);return}this.selectOnDrill&&this.#R(t),this.#I(t)}#z=()=>this.back();#X=()=>{this.#r=this.#d.value,this.#w(null)};#Z=t=>{let e=re(t.target)?t.target.closest('[role="option"]'):null;if(!e)return;let i=this.#m.get(e);i&&(this.#Q(e),this.#q(i))};#B=t=>{let e=re(t.target)?t.target.closest('[role="option"]'):null;switch(t.key){case"ArrowDown":t.preventDefault(),this.#M(1);break;case"ArrowUp":t.preventDefault(),this.#M(-1);break;case"ArrowRight":{if(!e)break;t.preventDefault();let i=this.#m.get(e);i&&this.#P(i)&&this.#q(i);break}case"ArrowLeft":case"Backspace":if(t.key==="Backspace"&&this.#d?.contains(t.target))break;t.preventDefault(),this.back();break;case"Enter":case" ":if(!e)break;t.preventDefault();{let i=this.#m.get(e);i&&this.#q(i)}break}}};M();w("drilldown-ui",Nr);R();var qr=class extends k{static requiredIcons=["caret-right"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},minWidth:{type:Number,default:200,attribute:"min-width",reflect:!0},maxWidth:{type:Number,default:9999,attribute:"max-width",reflect:!0},edge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=0;#s=0;#r=null;#n="";#a=!1;connected(){this.#a||(this.#a=!0,this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l)),this.resizable&&!this.querySelector('[slot="resize"]')&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","resize"),this.appendChild(this.#t)),(this.#t||this.resizable)&&(this.#t=this.#t||this.querySelector('[slot="resize"]'),this.#t?.addEventListener("pointerdown",this.#c))}render(){let t=this.querySelector(":scope > header");if(t&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-expanded",String(!this.collapsed)),!t.querySelector('[slot="caret"]'))){let e=document.createElement("icon-ui");e.setAttribute("slot","caret"),e.setAttribute("name","caret-right"),t.append(e)}}toggle(){this.collapsed=!this.collapsed,this.dispatchEvent(new Event("toggle",{bubbles:!0}))}#o=t=>{let e=this.querySelector(":scope > header");e&&(t.target===e||e.contains(t.target))&&this.toggle()};#l=t=>{t.target===this.querySelector(":scope > header")&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.toggle())};#c=t=>{if(t.isPrimary){t.preventDefault(),this.#e=!0,this.#i=t.clientX,this.#s=this.getBoundingClientRect().width,this.#r=t.pointerId,this.setAttribute("resizing","");try{this.#t.setPointerCapture(t.pointerId)}catch{}this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#d,{once:!0}),this.#t.addEventListener("pointercancel",this.#d,{once:!0}),this.#n=document.documentElement.style.cursor,document.documentElement.style.cursor="col-resize"}};#h=t=>{if(!this.#e)return;let e=this.edge==="trailing"?-1:1,i=(t.clientX-this.#i)*e,r=Math.max(this.minWidth,Math.min(this.maxWidth,this.#s+i));this.style.width=`${r}px`};#d=()=>{if(this.#e){this.#e=!1,this.removeAttribute("resizing");try{this.#t?.releasePointerCapture(this.#r)}catch{}this.#r=null,this.#t?.removeEventListener("pointermove",this.#h),document.documentElement.style.cursor=this.#n}};disconnected(){this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#l),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#e&&(document.documentElement.style.cursor=this.#n),this.#a=!1}};M();w("pane-ui",qr);R();var Xr=class extends k{static properties={scroll:{type:Boolean,default:!1,reflect:!0},maxWidth:{type:String,default:"",attribute:"max-width",reflect:!0},padding:{type:String,default:"",reflect:!0},stickyHeader:{type:Boolean,default:!1,attribute:"sticky-header",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.stickyHeader&&this.#i()}disconnected(){this.#s()}render(){this.stickyHeader&&!this.#t&&this.#i(),!this.stickyHeader&&this.#t&&this.#s()}#i(){let t=this.querySelector(":scope > :is(header, header-ui)");t&&(this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-page-sentinel",""),this.#t.style.cssText="height: 0; width: 0; pointer-events: none;",t.insertAdjacentElement("beforebegin",this.#t)),!this.#e&&typeof IntersectionObserver<"u"&&(this.#e=new IntersectionObserver(e=>{this.toggleAttribute("data-header-stuck",!e[0].isIntersecting)},{threshold:0})),this.#e?.observe(this.#t))}#s(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null,this.removeAttribute("data-header-stuck")}};M();w("page-ui",Xr);M();R();var Ya=class extends k{static properties={disabled:{type:Boolean,default:!1,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Type a message...",reflect:!0},model:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=[];#n=[];#a=null;#o=null;#l=null;#c=()=>this.#o?.click();#h=()=>{this.#o?.files?.length&&this.#m(this.#o.files),this.#o&&(this.#o.value="")};get value(){return this.#t?.value?.trim()??""}get attachments(){return[...this.#n]}set models(t){this.#r=t||[],this.#i&&(this.#i.options=this.#r,this.model&&(this.#i.value=this.model))}get models(){return this.#r}connected(){this.querySelector('[slot="toolbar"]')||(this.innerHTML=`
|
|
173
|
+
`,this.#a=this.querySelector('[slot="back"]'),this.#o=this.querySelector("[data-back-label]"),this.#l=this.querySelector("[data-level-title]"),this.#c=this.querySelector("[data-level-count]"),this.#h=this.querySelector('[slot="filter"]'),this.#d=this.querySelector('[slot="filter"] input-ui'),this.#u=this.querySelector('[slot="panel"]'),this.#f=this.querySelector('[slot="live"]'),this.#p=this.querySelector('[slot="breadcrumb"]');let t=[...this.children].find(e=>e.getAttribute("slot")==="breadcrumb"&&e.parentElement===this);t&&t!==this.#p&&(this.#p.replaceWith(t),this.#p=t),this.#a.addEventListener("click",this.#z),this.#d.addEventListener("input",this.#X),this.#u.addEventListener("click",this.#Z),this.#n=!0}#x(){this.#h.hidden=!this.filterable,this.#d.setAttribute("placeholder",this.placeholder)}#A(t,e){return(t||[]).find(i=>String(i.value)===String(e))||null}#E(t){if(!t||t.leaf)return[];let e=t.children;if(e==null)return[];if(Array.isArray(e))return e;if(typeof e=="function"){if(this.#e.has(t))return this.#e.get(t);if(this.#i.has(t))return"loading";let i;try{i=e(t)}catch{i=[]}if(i&&typeof i.then=="function")return this.#i.set(t,i),i.then(n=>{this.#i.delete(t),this.#e.set(t,Array.isArray(n)?n:[]),this.#w(null)}).catch(()=>{this.#i.delete(t),this.#e.set(t,[]),this.#w(null)}),"loading";let r=Array.isArray(i)?i:[];return this.#e.set(t,r),r}return[]}#$(t){return!t||t.leaf?!1:Array.isArray(t.children)?t.children.length>0:typeof t.children=="function"}#k(t){let e=this.#t,i=null;for(let r of t){if(i=this.#A(e,r),!i)return{item:null,list:[]};let n=this.#E(i);if(e=n==="loading"?"loading":n,e==="loading")return{item:i,list:"loading"}}return{item:i,list:e}}#w(t){this.#n&&tt(()=>this.#C(t))}#C(t){this.#x();let e=this.path,{item:i,list:r}=this.#k(e),n=i?i.label??"":this.rootLabel||"";if(this.#l.textContent=n,this.#a.hidden=e.length===0,e.length>0){let{item:d}=this.#k(e.slice(0,-1));this.#o.textContent=d?d.label??"":this.rootLabel||""}let o=r==="loading",a=o?[]:r,l=this.#r.trim().toLowerCase(),h=l?a.filter(d=>(d.label||"").toLowerCase().includes(l)||(d.meta||"").toLowerCase().includes(l)):a;if(this.#c.textContent=o?"":String(a.length),this.#u.setAttribute("aria-busy",String(o)),this.#u.setAttribute("aria-label",n||"Items"),this.#u.innerHTML="",this.#u.removeAttribute("data-anim"),o)for(let d=0;d<4;d++){let f=document.createElement("skeleton-ui");f.setAttribute("height","2.25rem"),f.setAttribute("data-drilldown-skeleton",""),this.#u.appendChild(f)}else if(h.length)for(let d of h)this.#u.appendChild(this.#M(d));else{let d=document.createElement("empty-state-ui");d.setAttribute("minimal",""),d.setAttribute("heading",l?"No matches":"No items"),this.#u.appendChild(d)}this.static||(t==="forward"?this.#u.setAttribute("data-anim","forward"):t==="backward"&&this.#u.setAttribute("data-anim","backward"));let c=[...this.#u.querySelectorAll('[role="option"]')];if(this.#b==="first"&&c[0])this.#T(c[0]),c[0].focus();else if(this.#b&&this.#b.restoreValue!=null){let d=c.find(f=>f.dataset.value===String(this.#b.restoreValue));d?(this.#T(d),d.focus()):c[0]&&this.#T(c[0])}else{let d=c.find(f=>f.dataset.value===this.#g);d?this.#T(d):c[0]&&this.#T(c[0])}this.#b=null;let u=o?"":` \u2014 ${a.length} item${a.length===1?"":"s"}`;this.#f.textContent=`${n||"Root"}${u}`}#Q(t){return String(t??"").replace(/"/g,""")}#P(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}#M(t){let e=this.#$(t),i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("tabindex","-1"),i.setAttribute("aria-selected","false"),i.dataset.value=String(t.value),e||i.setAttribute("data-leaf","");let r="";t.dot&&(r+=`<span slot="dot" data-tone="${this.#Q(t.dot)}"></span>`),r+=`<div slot="main"><span slot="label">${this.#P(t.label)}</span>`,t.meta&&(r+=`<span slot="meta">${this.#P(t.meta)}</span>`),r+="</div>";let n=Array.isArray(t.counts)?t.counts:[];return n.length&&(r+=`<span slot="counts">${n.map(o=>`<span data-drilldown-chip data-tone="${this.#Q(o.variant||"neutral")}">${this.#P(o.value)}</span>`).join("")}</span>`),e&&(r+='<icon-ui name="caret-right" slot="chevron"></icon-ui>'),i.innerHTML=r,this.#m.set(i,t),i}#T(t){let e=this.#u.querySelector('[role="option"][tabindex="0"]');e&&e!==t&&e.setAttribute("tabindex","-1"),t.setAttribute("tabindex","0"),this.#g=t.dataset.value}#R(t){let e=[...this.#u.querySelectorAll('[role="option"]')];if(!e.length)return;let i=this.#u.querySelector('[role="option"][tabindex="0"]'),r=i?e.indexOf(i):-1;r=(r+t+e.length)%e.length,this.#T(e[r]),e[r].focus()}#I(t){let e=this.path;this.#s[e.length]=t.value,this.#b="first",this.path=[...e,t.value]}back(){let t=this.path;if(!t.length)return;let e=this.#s[t.length-1];this.#b={restoreValue:e},this.path=t.slice(0,-1)}#L(t){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{path:this.path,item:t}}))}#D(t){if(!this.#$(t)){this.#L(t);return}this.selectOnDrill&&this.#L(t),this.#I(t)}#z=()=>this.back();#X=()=>{this.#r=this.#d.value,this.#w(null)};#Z=t=>{let e=re(t.target)?t.target.closest('[role="option"]'):null;if(!e)return;let i=this.#m.get(e);i&&(this.#T(e),this.#D(i))};#B=t=>{let e=re(t.target)?t.target.closest('[role="option"]'):null;switch(t.key){case"ArrowDown":t.preventDefault(),this.#R(1);break;case"ArrowUp":t.preventDefault(),this.#R(-1);break;case"ArrowRight":{if(!e)break;t.preventDefault();let i=this.#m.get(e);i&&this.#$(i)&&this.#D(i);break}case"ArrowLeft":case"Backspace":if(t.key==="Backspace"&&this.#d?.contains(t.target))break;t.preventDefault(),this.back();break;case"Enter":case" ":if(!e)break;t.preventDefault();{let i=this.#m.get(e);i&&this.#D(i)}break}}};M();w("drilldown-ui",Nr);R();var qr=class extends k{static requiredIcons=["caret-right"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},minWidth:{type:Number,default:200,attribute:"min-width",reflect:!0},maxWidth:{type:Number,default:9999,attribute:"max-width",reflect:!0},edge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=0;#s=0;#r=null;#n="";#a=!1;connected(){this.#a||(this.#a=!0,this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l)),this.resizable&&!this.querySelector('[slot="resize"]')&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","resize"),this.appendChild(this.#t)),(this.#t||this.resizable)&&(this.#t=this.#t||this.querySelector('[slot="resize"]'),this.#t?.addEventListener("pointerdown",this.#c))}render(){let t=this.querySelector(":scope > header");if(t&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-expanded",String(!this.collapsed)),!t.querySelector('[slot="caret"]'))){let e=document.createElement("icon-ui");e.setAttribute("slot","caret"),e.setAttribute("name","caret-right"),t.append(e)}}toggle(){this.collapsed=!this.collapsed,this.dispatchEvent(new Event("toggle",{bubbles:!0}))}#o=t=>{let e=this.querySelector(":scope > header");e&&(t.target===e||e.contains(t.target))&&this.toggle()};#l=t=>{t.target===this.querySelector(":scope > header")&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.toggle())};#c=t=>{if(t.isPrimary){t.preventDefault(),this.#e=!0,this.#i=t.clientX,this.#s=this.getBoundingClientRect().width,this.#r=t.pointerId,this.setAttribute("resizing","");try{this.#t.setPointerCapture(t.pointerId)}catch{}this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#d,{once:!0}),this.#t.addEventListener("pointercancel",this.#d,{once:!0}),this.#n=document.documentElement.style.cursor,document.documentElement.style.cursor="col-resize"}};#h=t=>{if(!this.#e)return;let e=this.edge==="trailing"?-1:1,i=(t.clientX-this.#i)*e,r=Math.max(this.minWidth,Math.min(this.maxWidth,this.#s+i));this.style.width=`${r}px`};#d=()=>{if(this.#e){this.#e=!1,this.removeAttribute("resizing");try{this.#t?.releasePointerCapture(this.#r)}catch{}this.#r=null,this.#t?.removeEventListener("pointermove",this.#h),document.documentElement.style.cursor=this.#n}};disconnected(){this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#l),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#e&&(document.documentElement.style.cursor=this.#n),this.#a=!1}};M();w("pane-ui",qr);R();var Xr=class extends k{static properties={scroll:{type:Boolean,default:!1,reflect:!0},maxWidth:{type:String,default:"",attribute:"max-width",reflect:!0},padding:{type:String,default:"",reflect:!0},stickyHeader:{type:Boolean,default:!1,attribute:"sticky-header",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.stickyHeader&&this.#i()}disconnected(){this.#s()}render(){this.stickyHeader&&!this.#t&&this.#i(),!this.stickyHeader&&this.#t&&this.#s()}#i(){let t=this.querySelector(":scope > :is(header, header-ui)");t&&(this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-page-sentinel",""),this.#t.style.cssText="height: 0; width: 0; pointer-events: none;",t.insertAdjacentElement("beforebegin",this.#t)),!this.#e&&typeof IntersectionObserver<"u"&&(this.#e=new IntersectionObserver(e=>{this.toggleAttribute("data-header-stuck",!e[0].isIntersecting)},{threshold:0})),this.#e?.observe(this.#t))}#s(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null,this.removeAttribute("data-header-stuck")}};M();w("page-ui",Xr);M();R();var Ya=class extends k{static properties={disabled:{type:Boolean,default:!1,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Type a message...",reflect:!0},model:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=[];#n=[];#a=null;#o=null;#l=null;#c=()=>this.#o?.click();#h=()=>{this.#o?.files?.length&&this.#m(this.#o.files),this.#o&&(this.#o.value="")};get value(){return this.#t?.value?.trim()??""}get attachments(){return[...this.#n]}set models(t){this.#r=t||[],this.#i&&(this.#i.options=this.#r,this.model&&(this.#i.value=this.model))}get models(){return this.#r}connected(){this.querySelector('[slot="toolbar"]')||(this.innerHTML=`
|
|
174
174
|
<textarea-ui placeholder="${this.placeholder}" rows="1"></textarea-ui>
|
|
175
175
|
<div slot="toolbar">
|
|
176
176
|
<select-ui slot="model" placeholder="Model" aria-label="Select model" divider></select-ui>
|
|
@@ -191,7 +191,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
191
191
|
`),this.#e=this.querySelector("section"),this.#i=this.querySelector("chat-input-ui"),this.#i?.addEventListener("submit",this.#r)}disconnected(){this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#i?.removeEventListener("submit",this.#r),this.#e=null,this.#i=null}#r=t=>{if(t?.type==="submit"&&t.stopPropagation(),this.streaming)return;let{text:e,model:i}=t.detail||{};e&&(this.#i.clear(),this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,detail:{text:e,model:i}})))};appendMessage({role:t,content:e="",render:i=!1}){this.#t.push({role:t,content:e});let r=document.createElement("div");r.setAttribute("data-role",t);let n=i?xi(e):X$(e);if(t==="user")r.innerHTML=`<div slot="bubble">${n}</div>`;else{let o=i?"":'<span slot="cursor"></span>';r.innerHTML=`
|
|
192
192
|
<span slot="avatar">${t==="assistant"?"AI":t[0].toUpperCase()}</span>
|
|
193
193
|
<div slot="bubble">${n}${o}</div>
|
|
194
|
-
`}return this.#e?.appendChild(r),this.#n(),r}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role==="user")return;e.content+=t;let i=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');if(i){let r=i.querySelector('[slot="cursor"]');r&&r.remove(),i.insertAdjacentText("beforeend",t),i.insertAdjacentHTML("beforeend",'<span slot="cursor"></span>')}this.#n()}startStreaming(){this.streaming=!0,this.#i&&(this.#i.disabled=!0)}stopStreaming(){this.streaming=!1,this.#i&&(this.#i.disabled=!1),this.#e?.querySelector('[data-role]:last-child [slot="cursor"]')?.remove();let t=this.#t[this.#t.length-1];if(t&&t.role==="assistant"&&t.content){let e=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');e&&(e.innerHTML=xi(t.content))}this.#i?.focus()}clear(){this.#t.length=0,this.#e&&(this.#e.innerHTML="")}#n(){let t=this.#e;t&&(this.#s!=null&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.isConnected&&(t.scrollTop=t.scrollHeight)}))}};M();w("chat-thread-ui",zr);R();var Zr=class extends k{#t=!1;#e=!1;#i=null;#s=null;#r=null;#n=null;#a="programmatic";static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},side:{type:String,default:"right",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"open");if(t?.set){let e=t.set;Object.defineProperty(this,"open",{get:t.get,set:i=>{e.call(this,i),this.#f()},configurable:!0})}}#o=t=>{t.target.closest('[slot="close"]')&&(this.#a="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#a="escape",this.permanent||(this.open=!1)};#c=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#a;this.#a="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#n&&!this.permanent&&(this.#a="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#o);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h))}disconnected(){this.removeEventListener("press",this.#o),this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#h)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#r!=null&&(clearTimeout(this.#r),this.#r=null),this.#t=!1,this.#n=null}#d(){let t=getComputedStyle(this).getPropertyValue("--drawer-duration").trim();return parseFloat(t)||200}#u(t,e,i="append"){let r={header:"header",body:"section",footer:"footer"}[t],n=h=>h.getAttribute("slot")===t||r&&!h.getAttribute("slot")&&h.localName===r,o=[...this.children].find(n),a=[...e.children].find(h=>h.getAttribute("slot")===t);o&&a&&o!==a&&a.remove();let l=o||a||(()=>{let h=this.constructor._pp?.[t];if(!h)return null;let c=h.cloneNode(!0);return c.setAttribute("data-stamped",""),c})();return l?(l.getAttribute("slot")!==t&&l.setAttribute("slot",t),l.parentElement!==e&&(i==="prepend"?e.prepend(l):e.appendChild(l)),l):null}render(){let t=this.ensure("dialog");t!==this.#n&&(this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#h)),this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h)),this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=this.#u("header",e,"prepend");if(i){let o=i.querySelector(':scope > [slot="heading"][data-stamped]'),a=[...i.children].some(l=>!l.hasAttribute("data-stamped")&&(l.getAttribute("slot")==="heading"||/^h[1-6]$/.test(l.localName)));this.text&&!a?(o||(o=document.createElement("span"),o.setAttribute("slot","heading"),o.setAttribute("data-stamped",""),i.prepend(o)),o.textContent!==this.text&&(o.textContent=this.text)):o&&o.remove()}if(this.permanent)this.drop("close");else{let o=this.ensure("close");i&&o.parentElement!==i&&i.appendChild(o)}let r=[...this.children].filter(o=>o.getAttribute("slot")==="body"||o.localName==="section"&&!o.getAttribute("slot"));if(r.length===0)this.#u("body",e,"append");else for(let o of r)o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o);let n=[...this.children].find(o=>o.getAttribute("slot")==="footer"||!o.getAttribute("slot")&&o.localName==="footer");n&&(n.getAttribute("slot")!=="footer"&&n.setAttribute("slot","footer"),n.parentElement!==e&&e.appendChild(n)),this.#f()}#f(){let t=this.#n;if(t&&t.isConnected)if(this.open&&!t.open){this.#e=!1,this.#i=document.activeElement;try{t.showModal()}catch(e){console.error("[drawer-ui] showModal() failed \u2014 dialog may be detached:",e)}t.offsetHeight,t.setAttribute("data-open",""),this.#r!=null&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.dispatchEvent(new CustomEvent("opened",{bubbles:!0}))},this.#d())}else!this.open&&t.open&&!this.#e&&this.#p(t)}#p(t){this.#e=!0,this.#r!=null&&(clearTimeout(this.#r),this.#r=null),t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close()},this.#d())}show(){this.open=!0}hide(){this.open=!1}};M();w("drawer-ui",Zr);R();var _r=class s extends k{#t=!1;#e=!1;#i=null;#s=null;#r=null;#n=!1;static#a=0;static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};#o=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#l=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#c=()=>{this.#h()};#h=()=>{this.#n||(this.#n=!0,this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0})))};#d=t=>{t.target===this.#r&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#o);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#d))}disconnected(){this.removeEventListener("press",this.#o),this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#c),this.#r.removeEventListener("click",this.#d)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),(this.open||this.#e||this.#r?.open)&&this.#h(),this.#e=!1,this.#t=!1,this.#r=null}#u(){let e=getComputedStyle(this).getPropertyValue("--modal-duration").trim(),i=/ms\s*$/.test(e)?parseFloat(e):/s\s*$/.test(e)?parseFloat(e)*1e3:parseFloat(e);return i>0?i:200}render(){let t=this.ensure("dialog");this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=[...this.children].find(c=>c.getAttribute("slot")==="header"||!c.getAttribute("slot")&&c.localName==="header"),r;i?(i.getAttribute("slot")!=="header"&&i.setAttribute("slot","header"),i.parentElement!==e&&e.prepend(i),e.querySelector(':scope > [slot="header"][data-stamped]')?.remove(),r=i):(r=this.ensure("header"),r.setAttribute("data-stamped",""),r.parentElement!==e&&e.prepend(r)),this.text?r.setAttribute("text",this.text):r.removeAttribute("text");let n=ct(r,"heading")[0];if(!this.text&&n?(n.id||(n.id=`modal-heading-${++s.#a}`),t.getAttribute("aria-labelledby")!==n.id&&t.setAttribute("aria-labelledby",n.id)):t.removeAttribute("aria-labelledby"),this.permanent)this.drop("close");else{let c=this.ensure("close");c.parentElement!==r&&r.appendChild(c)}let o=[...this.children].find(c=>c.getAttribute("slot")==="body"||!c.getAttribute("slot")&&c.localName==="section"),a=[...this.children].filter(c=>!c.getAttribute("slot")&&c.localName!=="section"&&c.localName!=="dialog"&&c.localName!=="footer"),l;o?(o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),l=o):(l=this.ensure("body"),l.setAttribute("data-stamped",""),l.parentElement!==e&&e.appendChild(l));for(let c of a)c!==l&&l.appendChild(c);let h=[...this.children].find(c=>c.getAttribute("slot")==="footer"||!c.getAttribute("slot")&&c.localName==="footer");if(h)h.getAttribute("slot")!=="footer"&&h.setAttribute("slot","footer"),h.parentElement!==e&&e.appendChild(h),e.querySelector(':scope > [slot="footer"][data-stamped]')?.remove();else{let c=this.ensure("footer");c.setAttribute("data-stamped",""),c.parentElement!==e&&e.appendChild(c)}this.open&&!t.open?(this.#e=!1,this.#n=!1,this.#i=document.activeElement,t.showModal(),t.offsetHeight,t.setAttribute("data-open","")):!this.open&&t.open&&!this.#e&&this.#f(t)}#f(t){this.#e=!0,t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close(),this.#h()},this.#u())}show(){this.open=!0}hide(){this.open=!1}};M();w("modal-ui",_r);R();var Vr=class extends k{static requiredIcons=["x"];static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>J``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},jr=class s extends k{#t=null;#e=!1;#i=null;#s=null;static properties={text:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},action:{type:String,default:"",reflect:!0}};static parts={body:'<div slot="body"></div>'};static template=()=>J``;#r=t=>{if(t.target.closest("[data-feed-close]")){this.dismiss();return}if(t.target.closest("[data-feed-action]")){try{this.#n?.()}catch(e){console.warn("[feed-item] action handler threw:",e)}this.dismiss()}};#n=null;#a=null;#o=null;connected(){this.addEventListener("press",this.#r)}#l(){let t=getComputedStyle(this).getPropertyValue("--feed-item-duration").trim();return parseFloat(t)||200}render(){let t=this.ensure("body");if(t.textContent="",this.heading){let h=document.createElement("strong");h.textContent=this.heading,h.style.display="block",t.appendChild(h)}if(this.text){let h=document.createElement("span");h.textContent=this.text,t.appendChild(h)}let e=!this.duration||this.duration<=0,i=this.variant==="danger"||this.variant==="warning",r=e&&!!this.action,n="status";r?n="alertdialog":e&&i&&(n="alert"),this.setAttribute("role",n),this.setAttribute("aria-live",n==="alert"||n==="alertdialog"?"assertive":"polite"),r&&this.setAttribute("aria-modal","false");let o=this.dismissible||e,a=this.querySelector(":scope > [data-feed-close]");o&&!a?(a=document.createElement("button-ui"),a.setAttribute("data-feed-close",""),a.setAttribute("icon","x"),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label","Dismiss"),this.appendChild(a)):!o&&a&&a.remove();let l=this.querySelector(":scope > [data-feed-action]");this.action?(l||(l=document.createElement("button-ui"),l.setAttribute("data-feed-action",""),l.setAttribute("variant","ghost"),l.setAttribute("size","sm"),a&&a.parentElement===this?this.insertBefore(l,a):this.appendChild(l)),l.setAttribute("text",this.action)):l&&l.remove(),r?this.#h():this.#d(),!this.hasAttribute("open")&&!this.#e&&(typeof requestAnimationFrame=="function"?this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("open","")}):this.setAttribute("open","")),this.#c()}#c(){this.#t&&clearTimeout(this.#t),this.duration&&this.duration>0&&(this.#t=setTimeout(()=>this.dismiss(),this.duration))}dismiss(){this.#e||(this.#e=!0,this.#t&&(clearTimeout(this.#t),this.#t=null),this.removeAttribute("open"),this.setAttribute("closing",""),this.#i=setTimeout(()=>{this.#i=null;let t=this.parentElement;this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove(),t?.matches?.("feed-ui")&&We.releaseContainerIfEmpty(t)},this.#l()))}update(t){if(!(!t||typeof t!="object")){for(let e of Object.keys(t))e in s.properties&&(this[e]=t[e]);typeof t.onAction=="function"&&(this.#n=t.onAction),this.#c()}}#h(){if(this.#o)return;this.#a=document.activeElement;let t=()=>[...this.querySelectorAll('button, button-ui, [tabindex]:not([tabindex="-1"]), input, [data-feed-action], [data-feed-close]')].filter(e=>!e.hasAttribute("disabled")&&e.offsetParent!==null);this.#o=e=>{if(e.key==="Escape"){e.stopPropagation(),this.dismiss();return}if(e.key!=="Tab")return;let i=t();if(!i.length)return;let r=i[0],n=i[i.length-1],o=document.activeElement;e.shiftKey&&o===r?(e.preventDefault(),n.focus()):!e.shiftKey&&o===n&&(e.preventDefault(),r.focus())},this.addEventListener("keydown",this.#o,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#d(){if(this.#o){this.removeEventListener("keydown",this.#o,!0),this.#o=null;try{this.#a?.focus?.()}catch{}this.#a=null}}disconnected(){this.removeEventListener("press",this.#r),this.#t&&(clearTimeout(this.#t),this.#t=null),this.#i&&(clearTimeout(this.#i),this.#i=null),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#d()}},We=class s{static#t=new Map;static get(t="bottom-right"){let e=s.#t.get(t);if(e&&e.isConnected)return e;e=document.createElement("feed-ui"),e.setAttribute("position",t),"popover"in HTMLElement.prototype&&e.setAttribute("popover","manual"),document.body.appendChild(e);try{e.showPopover?.()}catch{}return s.#t.set(t,e),e}static post(t={}){let{text:e="",heading:i="",icon:r="",variant:n="default",duration:o=4e3,position:a="bottom-right",dismissible:l,id:h,action:c="",onAction:u}=t,d=n==="error"?"danger":n,f=s.get(a),p=parseInt(f.getAttribute("max")||"5",10),m=[...f.children].filter(A=>A.tagName==="FEED-ITEM-UI"&&!A.hasAttribute("queued")).length,g=document.createElement("feed-item-ui");h&&g.setAttribute("data-id",h),g.text=e,g.heading=i,g.icon=r,g.variant=d;let b="duration"in t;return g.duration=c&&!b?0:o,l!=null&&(g.dismissible=!!l),c&&(g.action=c),m>=p&&g.setAttribute("queued",""),f.appendChild(g),typeof u=="function"&&g.update({onAction:u}),{id:h??null,dismiss:()=>g.dismiss(),update:A=>g.update(A)}}static clear(t="bottom-right"){let e=s.#t.get(t);if(e)for(let i of[...e.children])i.tagName==="FEED-ITEM-UI"&&i.dismiss?.()}static purge(){for(let t of s.#t.values()){try{t.hidePopover?.()}catch{}t.remove()}s.#t.clear()}static releaseContainerIfEmpty(t){if(!t)return;let e=t.querySelector("feed-item-ui[queued]");if(e&&e.removeAttribute("queued"),!(t.children.length>0)){try{t.hidePopover?.()}catch{}t.remove();for(let[i,r]of s.#t)r===t&&s.#t.delete(i)}}};M();w("feed-ui",Vr),w("feed-item-ui",jr),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&We.post(s.detail)}));R();var As=class extends k{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"info",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},position:{type:String,default:"bottom-right",reflect:!0}};static template=()=>J``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,We.post({text:this.text,variant:this.variant==="error"?"danger":this.variant,duration:this.duration,position:this.position}),queueMicrotask(()=>{try{this.remove()}catch{}}))}static show(t={}){let{text:e,variant:i="info",position:r="bottom-right",action:n,onAction:o}=t,a=We.get(r);a&&!a.hasAttribute("data-spawned-by")&&a.setAttribute("data-spawned-by","toast");let l={text:e,variant:i==="error"?"danger":i,position:r};return"duration"in t&&(l.duration=t.duration),"dismissible"in t&&(l.dismissible=!!t.dismissible),n&&(l.action=n),typeof o=="function"&&(l.onAction=o),We.post(l)}};M();w("toast-ui",As),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&As.show(s.detail)}));R();var Fr=class extends k{static properties={anchor:{type:String,default:"bottom",reflect:!0},align:{type:String,default:"center",reflect:!0},viewport:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.viewport&&this.#e()}updated(t){t.has("viewport")&&(this.viewport?this.#e():this.#i()),t.has("open")&&(this.#s(),this.dispatchEvent(new Event(this.open?"open":"close",{bubbles:!0})))}render(){this.viewport&&this.#s()}disconnected(){if(this.viewport&&this.matches(":popover-open"))try{this.hidePopover()}catch{}this.#t&&(this.#t=!1,this.removeEventListener("toggle",this.#r))}#e(){this.hasAttribute("popover")||this.setAttribute("popover","manual"),this.#t||(this.#t=!0,this.addEventListener("toggle",this.#r)),this.#s()}#i(){if(this.matches(":popover-open"))try{this.hidePopover()}catch{}this.#t&&(this.#t=!1,this.removeEventListener("toggle",this.#r)),this.removeAttribute("popover")}#s(){if(this.viewport){if(this.open&&!this.matches(":popover-open"))try{this.showPopover()}catch{}else if(!this.open&&this.matches(":popover-open"))try{this.hidePopover()}catch{}}}#r=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)}};M();w("anchor-bar-ui",Fr);M();R();var Ha=class extends k{static properties={text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","tabpanel")}render(){this.text&&this.setAttribute("aria-label",this.text),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}};w("tab-ui",Ha);R();var Wr=class extends k{static properties={value:{type:String,default:"",reflect:!0},orientation:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.setAttribute("role","tablist"),this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),!this.value){let t=this.querySelector("tab-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}}disconnected(){this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null),this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#l),this.#t=null,this.#e=null}get#s(){return[...this.querySelectorAll("tab-ui")]}get#r(){return this.#s.filter(t=>!t.disabled)}render(){let t=this.#s;if(t.length){this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("slot","strip"),this.#t.setAttribute("role","presentation")),this.#t.parentElement!==this&&this.prepend(this.#t),this.reconcile(this.#t,t,e=>e.value||e.getAttribute("value")||"",(e,i,r)=>{let n=e.value||e.getAttribute("value")||"",o=e.text||e.getAttribute("text")||"",a=e.icon||e.getAttribute("icon")||"",l=n===this.value,h=e.disabled||e.hasAttribute("disabled");if(r){if(r.textContent="",a){let u=document.createElement("icon-ui");u.setAttribute("name",a),r.appendChild(u)}return o&&r.appendChild(document.createTextNode(o)),r.setAttribute("aria-selected",String(l)),r.setAttribute("tabindex",l?"0":"-1"),h?r.setAttribute("disabled",""):r.removeAttribute("disabled"),l?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.dataset.value=n,r}let c=document.createElement("div");if(c.setAttribute("role","tab"),c.setAttribute("slot","tab-button"),c.dataset.value=n,c.setAttribute("aria-selected",String(l)),c.setAttribute("tabindex",l?"0":"-1"),h&&c.setAttribute("disabled",""),l&&c.setAttribute("data-active",""),a){let u=document.createElement("icon-ui");u.setAttribute("name",a),c.appendChild(u)}return o&&c.appendChild(document.createTextNode(o)),c}),this.#n();for(let e of t)(e.value||e.getAttribute("value")||"")===this.value?(e.setAttribute("selected",""),e.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):(e.removeAttribute("selected"),e.setAttribute("hidden",""))}}#n(){let t=this.#t?.querySelector('[slot="tab-button"][data-active]');if(!t){this.#e&&(this.#e.style.opacity="0");return}let e=!this.#e;e&&(this.#e=document.createElement("span"),this.#e.setAttribute("slot","indicator"),this.#t.appendChild(this.#e));let i=this.#t.getBoundingClientRect(),r=t.getBoundingClientRect(),n=this.orientation==="vertical",o=()=>{if(n){let a=r.top-i.top;this.#e.style.transform=`translateY(${a}px)`,this.#e.style.height=`${r.height}px`,this.#e.style.width=""}else{let a=r.left-i.left;this.#e.style.transform=`translateX(${a}px)`,this.#e.style.width=`${r.width}px`,this.#e.style.height=""}this.#e.style.opacity="1"};e?(this.#e.style.transition="none",o(),this.#i=requestAnimationFrame(()=>{this.#i=null,this.#e&&(this.#e.style.transition="")})):o()}#a(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#o=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#a(e.dataset.value)};#l=t=>{let e=t.target.closest('[slot="tab-button"]');if(!e||!this.contains(e))return;let i=[...this.#t.querySelectorAll('[slot="tab-button"]:not([disabled])')],r=i.indexOf(e);if(r<0)return;let n=this.orientation==="vertical",o=n?"ArrowDown":"ArrowRight",a=n?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=r<i.length-1?r+1:0;break;case a:l=r>0?r-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;default:return}t.preventDefault(),i[l].focus(),this.#a(i[l].dataset.value)}};M();w("tabs-ui",Wr);R();var Ur=class s extends k{static properties={text:{type:String,default:"",reflect:!0},placement:{type:String,default:"top",reflect:!0},delay:{type:Number,default:400,reflect:!0},follows:{type:String,default:"trigger",reflect:!0},for:{type:String,default:"",reflect:!0},indicator:{type:String,default:"none",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;connected(){this.follows==="pointer"?this.#c():(this.addEventListener("mouseenter",this.#n),this.addEventListener("focusin",this.#n),this.addEventListener("mouseleave",this.#a),this.addEventListener("focusout",this.#a))}disconnected(){this.removeEventListener("mouseenter",this.#n),this.removeEventListener("focusin",this.#n),this.removeEventListener("mouseleave",this.#a),this.removeEventListener("focusout",this.#a),this.#h(),this.#l()}render(){this.#t&&this.follows!=="pointer"&&(this.#t.textContent=this.text),this.#t&&this.follows==="pointer"&&this.#r&&this.#m(this.#r)}#n=()=>{this.text&&(this.#e&&clearTimeout(this.#e),this.#e=setTimeout(()=>this.#o(),this.delay))};#a=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#o(){if(this.#t)return;let t=document.createElement("div"),e=`tooltip-${Date.now()}`;t.id=e,t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.classList.add("tooltip-popup"),t.textContent=this.text,document.body.appendChild(t),this.setAttribute("aria-describedby",e);try{t.showPopover()}catch{}this.#t=t,this.#i=Ot(this,t,{placement:this.placement,gap:6})}#l(){if(this.#e&&(clearTimeout(this.#e),this.#e=null),!!this.#t){this.removeAttribute("aria-describedby"),this.#i?.(),this.#i=null;try{this.#t.hidePopover()}catch{}this.#t.remove(),this.#t=null,this.#r=null}}#c(){if(this.#h(),!this.for)return;let t=this.getRootNode();if(this.#s=t&&t.getElementById?t.getElementById(this.for):document.getElementById(this.for),!this.#s){s._warnedMissing||(s._warnedMissing=new WeakSet),s._warnedMissing.has(this)||(console.warn(`[tooltip-ui] follows="pointer" [for="${this.for}"] did not resolve to an element.`),s._warnedMissing.add(this));return}this.#s.addEventListener("chart-hover",this.#u),this.#s.addEventListener("chart-leave",this.#d)}#h(){this.#s&&(this.#s.removeEventListener("chart-hover",this.#u),this.#s.removeEventListener("chart-leave",this.#d)),this.#s=null}#d=()=>this.#l();#u=t=>{let e=t.detail;if(e){if(this.#r=e,!this.#t){this.#t=this.#f(),this.#p();try{this.#t.showPopover()}catch{}}this.#m(e),this.#g(e.pointerX,e.pointerY)}};#f(){let t=document.createElement("div");return t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.setAttribute("data-follows","pointer"),t.setAttribute("data-indicator",this.indicator||"none"),t.classList.add("tooltip-popup"),document.body.appendChild(t),t}#p(){if(!this.#s||!this.#t)return;let t=getComputedStyle(this.#s),e=Array.isArray(this.#s.legendData)?this.#s.legendData.map(i=>i.key).filter(Boolean):[];for(let i of e){let r=t.getPropertyValue(`--color-${i}`).trim();r&&this.#t.style.setProperty(`--color-${i}`,r)}for(let i=0;i<10;i++){let r=t.getPropertyValue(`--chart-${i}`).trim();r&&this.#t.style.setProperty(`--chart-${i}`,r)}}#m(t){if(!this.#t)return;let{label:e,value:i,pct:r,series:n,slot:o,payload:a}=t,l=this.indicator||"none",h=Array.isArray(a)&&a.length>0?a:[{series:n,label:e,value:i,pct:r,slot:o,hovered:!0}],c=[];e!=null&&c.push(`<span data-tip-role="label">${this.#b(String(e))}</span>`);for(let u of h){let d=u.series??null,f=u.value,p=u.pct,m=u.slot!=null?u.slot:0,g=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let b=f!=null?this.#b(String(f)):"",A=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",x=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${g}"></span>`:"",S=d?`<span data-tip-role="name">${this.#b(d)}</span>`:"",v=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${v}>${x}${S}<span data-tip-role="value">${b}${A}</span></span>`)}this.#t.setAttribute("data-indicator",l),this.#t.setAttribute("aria-live","polite"),this.#t.innerHTML=c.join("")}#g(t,e){if(!this.#t||t==null||e==null)return;let i=12,r=8,n=this.#t;n.style.position="fixed",n.style.left="0",n.style.top="0";let o=n.offsetWidth||0,a=n.offsetHeight||0,l=t-o/2,h=e-a-i;l<r&&(l=r),l+o>window.innerWidth-r&&(l=window.innerWidth-o-r),h<r&&(h=e+i),n.style.left=`${l}px`,n.style.top=`${h}px`}#b(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}};M();w("tooltip-ui",Ur);R();var B$={new:{variant:"success",text:"New"},updated:{variant:"info",text:"Updated"},deprecated:{variant:"warning",text:"Deprecated"},removed:{variant:"danger",text:"Removed"},beta:{variant:"primary",text:"Beta"}},Yr=class extends k{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","status")}render(){if(this.status){let t=B$[this.status];t&&(this.variant!==t.variant&&(this.variant=t.variant),this.text!==t.text&&(this.text=t.text))}if(this.text&&this.setAttribute("aria-label",this.text),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t&&t.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("size","sm"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};M();w("badge-ui",Yr);R();var Hr=class extends k{static properties={separator:{type:String,default:"/",reflect:!0},collapse:{type:Boolean,default:!1,reflect:!0},collapseKeepLeading:{type:Number,default:1,attribute:"collapse-keep-leading",reflect:!0},collapseKeepTrailing:{type:Number,default:2,attribute:"collapse-keep-trailing",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","navigation"),this.setAttribute("aria-label","Breadcrumb")}render(){this.querySelectorAll("[data-sep], [data-overflow]").forEach(l=>l.remove());let t=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-overflow")),e=t.length-1;t.forEach((l,h)=>{l.setAttribute("data-item",""),l.removeAttribute("data-collapsed"),h===e?l.setAttribute("aria-current","page"):l.removeAttribute("aria-current")});let i=Math.max(0,this.collapseKeepLeading|0),r=Math.max(0,this.collapseKeepTrailing|0),n=i+r+1;if(this.collapse&&t.length>=Math.max(n,4)){let l=t.slice(i,t.length-r);l.forEach(c=>c.setAttribute("data-collapsed",""));let h=this.#t(l);i>0?t[i-1].after(h):this.prepend(h)}let a=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-collapsed"));for(let l=0;l<a.length-1;l++){let h=document.createElement("span");h.setAttribute("data-sep",""),h.setAttribute("aria-hidden","true"),h.textContent=this.separator,a[l].after(h)}}#t(t){let e=document.createElement("menu-ui");e.setAttribute("data-overflow",""),e.setAttribute("data-item",""),e.setAttribute("placement","bottom-start");let i=document.createElement("button-ui");i.setAttribute("slot","trigger"),i.setAttribute("text","\u2026"),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("aria-label","Show collapsed crumbs"),e.appendChild(i);for(let r of t){let n=document.createElement("menu-item-ui");n.setAttribute("text",r.textContent.trim()),r.tagName==="A"&&r.hasAttribute("href")&&n.setAttribute("value",r.getAttribute("href")),e.appendChild(n)}return e.addEventListener("action",r=>{let n=r.detail?.value;n&&n!=="#"&&(window.location.href=n)}),e}};M();w("breadcrumb-ui",Hr);R();ii();function z$(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Z$=0,Gr=class s extends k{static requiredIcons=["magnifying-glass"];static properties={placeholder:{type:String,default:"Type a command...",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=[];#i=-1;#s=null;#r=null;#n=null;#a=null;#o=!1;#l=new WeakMap;#c=[];#h=`command-${++Z$}`;static#d=3;#u=t=>{let e=re(t.target)?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=this.#l.get(e);i&&this.#k(i)};#f=t=>{let e=re(t.target)?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=parseInt(e.dataset.idx);Number.isFinite(i)&&i!==this.#i&&this.#C(i)};connected(){this.#o||(this.#o=!0,this.addEventListener("keydown",this.#T))}render(){if(!this.#s){this.#t.length===0&&this.#b(),this.#c=ct(this,"empty");let t=`${this.#h}-list`;this.innerHTML=`
|
|
194
|
+
`}return this.#e?.appendChild(r),this.#n(),r}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role==="user")return;e.content+=t;let i=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');if(i){let r=i.querySelector('[slot="cursor"]');r&&r.remove(),i.insertAdjacentText("beforeend",t),i.insertAdjacentHTML("beforeend",'<span slot="cursor"></span>')}this.#n()}startStreaming(){this.streaming=!0,this.#i&&(this.#i.disabled=!0)}stopStreaming(){this.streaming=!1,this.#i&&(this.#i.disabled=!1),this.#e?.querySelector('[data-role]:last-child [slot="cursor"]')?.remove();let t=this.#t[this.#t.length-1];if(t&&t.role==="assistant"&&t.content){let e=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');e&&(e.innerHTML=xi(t.content))}this.#i?.focus()}clear(){this.#t.length=0,this.#e&&(this.#e.innerHTML="")}#n(){let t=this.#e;t&&(this.#s!=null&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.isConnected&&(t.scrollTop=t.scrollHeight)}))}};M();w("chat-thread-ui",zr);R();var Zr=class extends k{#t=!1;#e=!1;#i=null;#s=null;#r=null;#n=null;#a="programmatic";static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},side:{type:String,default:"right",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"open");if(t?.set){let e=t.set;Object.defineProperty(this,"open",{get:t.get,set:i=>{e.call(this,i),this.#f()},configurable:!0})}}#o=t=>{t.target.closest('[slot="close"]')&&(this.#a="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#a="escape",this.permanent||(this.open=!1)};#c=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#a;this.#a="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#n&&!this.permanent&&(this.#a="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#o);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h))}disconnected(){this.removeEventListener("press",this.#o),this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#h)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#r!=null&&(clearTimeout(this.#r),this.#r=null),this.#t=!1,this.#n=null}#d(){let t=getComputedStyle(this).getPropertyValue("--drawer-duration").trim();return parseFloat(t)||200}#u(t,e,i="append"){let r={header:"header",body:"section",footer:"footer"}[t],n=h=>h.getAttribute("slot")===t||r&&!h.getAttribute("slot")&&h.localName===r,o=[...this.children].find(n),a=[...e.children].find(h=>h.getAttribute("slot")===t);o&&a&&o!==a&&a.remove();let l=o||a||(()=>{let h=this.constructor._pp?.[t];if(!h)return null;let c=h.cloneNode(!0);return c.setAttribute("data-stamped",""),c})();return l?(l.getAttribute("slot")!==t&&l.setAttribute("slot",t),l.parentElement!==e&&(i==="prepend"?e.prepend(l):e.appendChild(l)),l):null}render(){let t=this.ensure("dialog");t!==this.#n&&(this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#h)),this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h)),this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=this.#u("header",e,"prepend");if(i){let o=i.querySelector(':scope > [slot="heading"][data-stamped]'),a=[...i.children].some(l=>!l.hasAttribute("data-stamped")&&(l.getAttribute("slot")==="heading"||/^h[1-6]$/.test(l.localName)));this.text&&!a?(o||(o=document.createElement("span"),o.setAttribute("slot","heading"),o.setAttribute("data-stamped",""),i.prepend(o)),o.textContent!==this.text&&(o.textContent=this.text)):o&&o.remove()}if(this.permanent)this.drop("close");else{let o=this.ensure("close");i&&o.parentElement!==i&&i.appendChild(o)}let r=[...this.children].filter(o=>o.getAttribute("slot")==="body"||o.localName==="section"&&!o.getAttribute("slot"));if(r.length===0)this.#u("body",e,"append");else for(let o of r)o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o);let n=[...this.children].find(o=>o.getAttribute("slot")==="footer"||!o.getAttribute("slot")&&o.localName==="footer");n&&(n.getAttribute("slot")!=="footer"&&n.setAttribute("slot","footer"),n.parentElement!==e&&e.appendChild(n)),this.#f()}#f(){let t=this.#n;if(t&&t.isConnected)if(this.open&&!t.open){this.#e=!1,this.#i=document.activeElement;try{t.showModal()}catch(e){console.error("[drawer-ui] showModal() failed \u2014 dialog may be detached:",e)}t.offsetHeight,t.setAttribute("data-open",""),this.#r!=null&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.dispatchEvent(new CustomEvent("opened",{bubbles:!0}))},this.#d())}else!this.open&&t.open&&!this.#e&&this.#p(t)}#p(t){this.#e=!0,this.#r!=null&&(clearTimeout(this.#r),this.#r=null),t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close()},this.#d())}show(){this.open=!0}hide(){this.open=!1}};M();w("drawer-ui",Zr);R();var _r=class s extends k{#t=!1;#e=!1;#i=null;#s=null;#r=null;#n=!1;static#a=0;static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};#o=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#l=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#c=()=>{this.#h()};#h=()=>{this.#n||(this.#n=!0,this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0})))};#d=t=>{t.target===this.#r&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#o);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#d))}disconnected(){this.removeEventListener("press",this.#o),this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#c),this.#r.removeEventListener("click",this.#d)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),(this.open||this.#e||this.#r?.open)&&this.#h(),this.#e=!1,this.#t=!1,this.#r=null}#u(){let e=getComputedStyle(this).getPropertyValue("--modal-duration").trim(),i=/ms\s*$/.test(e)?parseFloat(e):/s\s*$/.test(e)?parseFloat(e)*1e3:parseFloat(e);return i>0?i:200}render(){let t=this.ensure("dialog");this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=[...this.children].find(c=>c.getAttribute("slot")==="header"||!c.getAttribute("slot")&&c.localName==="header"),r;i?(i.getAttribute("slot")!=="header"&&i.setAttribute("slot","header"),i.parentElement!==e&&e.prepend(i),e.querySelector(':scope > [slot="header"][data-stamped]')?.remove(),r=i):(r=this.ensure("header"),r.setAttribute("data-stamped",""),r.parentElement!==e&&e.prepend(r)),this.text?r.setAttribute("text",this.text):r.removeAttribute("text");let n=ct(r,"heading")[0];if(!this.text&&n?(n.id||(n.id=`modal-heading-${++s.#a}`),t.getAttribute("aria-labelledby")!==n.id&&t.setAttribute("aria-labelledby",n.id)):t.removeAttribute("aria-labelledby"),this.permanent)this.drop("close");else{let c=this.ensure("close");c.parentElement!==r&&r.appendChild(c)}let o=[...this.children].find(c=>c.getAttribute("slot")==="body"||!c.getAttribute("slot")&&c.localName==="section"),a=[...this.children].filter(c=>!c.getAttribute("slot")&&c.localName!=="section"&&c.localName!=="dialog"&&c.localName!=="footer"),l;o?(o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),l=o):(l=this.ensure("body"),l.setAttribute("data-stamped",""),l.parentElement!==e&&e.appendChild(l));for(let c of a)c!==l&&l.appendChild(c);let h=[...this.children].find(c=>c.getAttribute("slot")==="footer"||!c.getAttribute("slot")&&c.localName==="footer");if(h)h.getAttribute("slot")!=="footer"&&h.setAttribute("slot","footer"),h.parentElement!==e&&e.appendChild(h),e.querySelector(':scope > [slot="footer"][data-stamped]')?.remove();else{let c=this.ensure("footer");c.setAttribute("data-stamped",""),c.parentElement!==e&&e.appendChild(c)}this.open&&!t.open?(this.#e=!1,this.#n=!1,this.#i=document.activeElement,t.showModal(),t.offsetHeight,t.setAttribute("data-open","")):!this.open&&t.open&&!this.#e&&this.#f(t)}#f(t){this.#e=!0,t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close(),this.#h()},this.#u())}show(){this.open=!0}hide(){this.open=!1}};M();w("modal-ui",_r);R();var Vr=class extends k{static requiredIcons=["x"];static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>J``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},jr=class s extends k{#t=null;#e=!1;#i=null;#s=null;static properties={text:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},action:{type:String,default:"",reflect:!0}};static parts={body:'<div slot="body"></div>'};static template=()=>J``;#r=t=>{if(t.target.closest("[data-feed-close]")){this.dismiss();return}if(t.target.closest("[data-feed-action]")){try{this.#n?.()}catch(e){console.warn("[feed-item] action handler threw:",e)}this.dismiss()}};#n=null;#a=null;#o=null;connected(){this.addEventListener("press",this.#r)}#l(){let t=getComputedStyle(this).getPropertyValue("--feed-item-duration").trim();return parseFloat(t)||200}render(){let t=this.ensure("body");if(t.textContent="",this.heading){let h=document.createElement("strong");h.textContent=this.heading,h.style.display="block",t.appendChild(h)}if(this.text){let h=document.createElement("span");h.textContent=this.text,t.appendChild(h)}let e=!this.duration||this.duration<=0,i=this.variant==="danger"||this.variant==="warning",r=e&&!!this.action,n="status";r?n="alertdialog":e&&i&&(n="alert"),this.setAttribute("role",n),this.setAttribute("aria-live",n==="alert"||n==="alertdialog"?"assertive":"polite"),r&&this.setAttribute("aria-modal","false");let o=this.dismissible||e,a=this.querySelector(":scope > [data-feed-close]");o&&!a?(a=document.createElement("button-ui"),a.setAttribute("data-feed-close",""),a.setAttribute("icon","x"),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label","Dismiss"),this.appendChild(a)):!o&&a&&a.remove();let l=this.querySelector(":scope > [data-feed-action]");this.action?(l||(l=document.createElement("button-ui"),l.setAttribute("data-feed-action",""),l.setAttribute("variant","ghost"),l.setAttribute("size","sm"),a&&a.parentElement===this?this.insertBefore(l,a):this.appendChild(l)),l.setAttribute("text",this.action)):l&&l.remove(),r?this.#h():this.#d(),!this.hasAttribute("open")&&!this.#e&&(typeof requestAnimationFrame=="function"?this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("open","")}):this.setAttribute("open","")),this.#c()}#c(){this.#t&&clearTimeout(this.#t),this.duration&&this.duration>0&&(this.#t=setTimeout(()=>this.dismiss(),this.duration))}dismiss(){this.#e||(this.#e=!0,this.#t&&(clearTimeout(this.#t),this.#t=null),this.removeAttribute("open"),this.setAttribute("closing",""),this.#i=setTimeout(()=>{this.#i=null;let t=this.parentElement;this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove(),t?.matches?.("feed-ui")&&We.releaseContainerIfEmpty(t)},this.#l()))}update(t){if(!(!t||typeof t!="object")){for(let e of Object.keys(t))e in s.properties&&(this[e]=t[e]);typeof t.onAction=="function"&&(this.#n=t.onAction),this.#c()}}#h(){if(this.#o)return;this.#a=document.activeElement;let t=()=>[...this.querySelectorAll('button, button-ui, [tabindex]:not([tabindex="-1"]), input, [data-feed-action], [data-feed-close]')].filter(e=>!e.hasAttribute("disabled")&&e.offsetParent!==null);this.#o=e=>{if(e.key==="Escape"){e.stopPropagation(),this.dismiss();return}if(e.key!=="Tab")return;let i=t();if(!i.length)return;let r=i[0],n=i[i.length-1],o=document.activeElement;e.shiftKey&&o===r?(e.preventDefault(),n.focus()):!e.shiftKey&&o===n&&(e.preventDefault(),r.focus())},this.addEventListener("keydown",this.#o,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#d(){if(this.#o){this.removeEventListener("keydown",this.#o,!0),this.#o=null;try{this.#a?.focus?.()}catch{}this.#a=null}}disconnected(){this.removeEventListener("press",this.#r),this.#t&&(clearTimeout(this.#t),this.#t=null),this.#i&&(clearTimeout(this.#i),this.#i=null),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#d()}},We=class s{static#t=new Map;static get(t="bottom-right"){let e=s.#t.get(t);if(e&&e.isConnected)return e;e=document.createElement("feed-ui"),e.setAttribute("position",t),"popover"in HTMLElement.prototype&&e.setAttribute("popover","manual"),document.body.appendChild(e);try{e.showPopover?.()}catch{}return s.#t.set(t,e),e}static post(t={}){let{text:e="",heading:i="",icon:r="",variant:n="default",duration:o=4e3,position:a="bottom-right",dismissible:l,id:h,action:c="",onAction:u}=t,d=n==="error"?"danger":n,f=s.get(a),p=parseInt(f.getAttribute("max")||"5",10),m=[...f.children].filter(A=>A.tagName==="FEED-ITEM-UI"&&!A.hasAttribute("queued")).length,g=document.createElement("feed-item-ui");h&&g.setAttribute("data-id",h),g.text=e,g.heading=i,g.icon=r,g.variant=d;let b="duration"in t;return g.duration=c&&!b?0:o,l!=null&&(g.dismissible=!!l),c&&(g.action=c),m>=p&&g.setAttribute("queued",""),f.appendChild(g),typeof u=="function"&&g.update({onAction:u}),{id:h??null,dismiss:()=>g.dismiss(),update:A=>g.update(A)}}static clear(t="bottom-right"){let e=s.#t.get(t);if(e)for(let i of[...e.children])i.tagName==="FEED-ITEM-UI"&&i.dismiss?.()}static purge(){for(let t of s.#t.values()){try{t.hidePopover?.()}catch{}t.remove()}s.#t.clear()}static releaseContainerIfEmpty(t){if(!t)return;let e=t.querySelector("feed-item-ui[queued]");if(e&&e.removeAttribute("queued"),!(t.children.length>0)){try{t.hidePopover?.()}catch{}t.remove();for(let[i,r]of s.#t)r===t&&s.#t.delete(i)}}};M();w("feed-ui",Vr),w("feed-item-ui",jr),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&We.post(s.detail)}));R();var As=class extends k{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"info",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},position:{type:String,default:"bottom-right",reflect:!0}};static template=()=>J``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,We.post({text:this.text,variant:this.variant==="error"?"danger":this.variant,duration:this.duration,position:this.position}),queueMicrotask(()=>{try{this.remove()}catch{}}))}static show(t={}){let{text:e,variant:i="info",position:r="bottom-right",action:n,onAction:o}=t,a=We.get(r);a&&!a.hasAttribute("data-spawned-by")&&a.setAttribute("data-spawned-by","toast");let l={text:e,variant:i==="error"?"danger":i,position:r};return"duration"in t&&(l.duration=t.duration),"dismissible"in t&&(l.dismissible=!!t.dismissible),n&&(l.action=n),typeof o=="function"&&(l.onAction=o),We.post(l)}};M();w("toast-ui",As),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&As.show(s.detail)}));R();var Fr=class extends k{static properties={anchor:{type:String,default:"bottom",reflect:!0},align:{type:String,default:"center",reflect:!0},viewport:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.viewport&&this.#e()}updated(t){t.has("viewport")&&(this.viewport?this.#e():this.#i()),t.has("open")&&(this.#s(),this.dispatchEvent(new Event(this.open?"open":"close",{bubbles:!0})))}render(){this.viewport&&this.#s()}disconnected(){if(this.viewport&&this.matches(":popover-open"))try{this.hidePopover()}catch{}this.#t&&(this.#t=!1,this.removeEventListener("toggle",this.#r))}#e(){this.hasAttribute("popover")||this.setAttribute("popover","manual"),this.#t||(this.#t=!0,this.addEventListener("toggle",this.#r)),this.#s()}#i(){if(this.matches(":popover-open"))try{this.hidePopover()}catch{}this.#t&&(this.#t=!1,this.removeEventListener("toggle",this.#r)),this.removeAttribute("popover")}#s(){if(this.viewport){if(this.open&&!this.matches(":popover-open"))try{this.showPopover()}catch{}else if(!this.open&&this.matches(":popover-open"))try{this.hidePopover()}catch{}}}#r=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)}};M();w("anchor-bar-ui",Fr);M();R();var Ha=class extends k{static properties={text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","tabpanel")}render(){this.text&&this.setAttribute("aria-label",this.text),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}};w("tab-ui",Ha);R();var Wr=class extends k{static properties={value:{type:String,default:"",reflect:!0},orientation:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.setAttribute("role","tablist"),this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),!this.value){let t=this.querySelector("tab-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}}disconnected(){this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null),this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#l),this.#t=null,this.#e=null}get#s(){return[...this.querySelectorAll("tab-ui")]}get#r(){return this.#s.filter(t=>!t.disabled)}render(){let t=this.#s;if(t.length){this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("slot","strip"),this.#t.setAttribute("role","presentation")),this.#t.parentElement!==this&&this.prepend(this.#t),this.reconcile(this.#t,t,e=>e.value||e.getAttribute("value")||"",(e,i,r)=>{let n=e.value||e.getAttribute("value")||"",o=e.text||e.getAttribute("text")||"",a=e.icon||e.getAttribute("icon")||"",l=n===this.value,h=e.disabled||e.hasAttribute("disabled");if(r){if(r.textContent="",a){let u=document.createElement("icon-ui");u.setAttribute("name",a),r.appendChild(u)}return o&&r.appendChild(document.createTextNode(o)),r.setAttribute("aria-selected",String(l)),r.setAttribute("tabindex",l?"0":"-1"),h?r.setAttribute("disabled",""):r.removeAttribute("disabled"),l?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.dataset.value=n,r}let c=document.createElement("div");if(c.setAttribute("role","tab"),c.setAttribute("slot","tab-button"),c.dataset.value=n,c.setAttribute("aria-selected",String(l)),c.setAttribute("tabindex",l?"0":"-1"),h&&c.setAttribute("disabled",""),l&&c.setAttribute("data-active",""),a){let u=document.createElement("icon-ui");u.setAttribute("name",a),c.appendChild(u)}return o&&c.appendChild(document.createTextNode(o)),c}),this.#n();for(let e of t)(e.value||e.getAttribute("value")||"")===this.value?(e.setAttribute("selected",""),e.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):(e.removeAttribute("selected"),e.setAttribute("hidden",""))}}#n(){let t=this.#t?.querySelector('[slot="tab-button"][data-active]');if(!t){this.#e&&(this.#e.style.opacity="0");return}let e=!this.#e;e&&(this.#e=document.createElement("span"),this.#e.setAttribute("slot","indicator"),this.#t.appendChild(this.#e));let i=this.#t.getBoundingClientRect(),r=t.getBoundingClientRect(),n=this.orientation==="vertical",o=()=>{if(n){let a=r.top-i.top;this.#e.style.transform=`translateY(${a}px)`,this.#e.style.height=`${r.height}px`,this.#e.style.width=""}else{let a=r.left-i.left;this.#e.style.transform=`translateX(${a}px)`,this.#e.style.width=`${r.width}px`,this.#e.style.height=""}this.#e.style.opacity="1"};e?(this.#e.style.transition="none",o(),this.#i=requestAnimationFrame(()=>{this.#i=null,this.#e&&(this.#e.style.transition="")})):o()}#a(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#o=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#a(e.dataset.value)};#l=t=>{let e=t.target.closest('[slot="tab-button"]');if(!e||!this.contains(e))return;let i=[...this.#t.querySelectorAll('[slot="tab-button"]:not([disabled])')],r=i.indexOf(e);if(r<0)return;let n=this.orientation==="vertical",o=n?"ArrowDown":"ArrowRight",a=n?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=r<i.length-1?r+1:0;break;case a:l=r>0?r-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;default:return}t.preventDefault(),i[l].focus(),this.#a(i[l].dataset.value)}};M();w("tabs-ui",Wr);R();var Ur=class s extends k{static properties={text:{type:String,default:"",reflect:!0},placement:{type:String,default:"top",reflect:!0},delay:{type:Number,default:400,reflect:!0},follows:{type:String,default:"trigger",reflect:!0},for:{type:String,default:"",reflect:!0},indicator:{type:String,default:"none",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;connected(){this.follows==="pointer"?this.#c():(this.addEventListener("mouseenter",this.#n),this.addEventListener("focusin",this.#n),this.addEventListener("mouseleave",this.#a),this.addEventListener("focusout",this.#a))}disconnected(){this.removeEventListener("mouseenter",this.#n),this.removeEventListener("focusin",this.#n),this.removeEventListener("mouseleave",this.#a),this.removeEventListener("focusout",this.#a),this.#h(),this.#l()}render(){this.#t&&this.follows!=="pointer"&&(this.#t.textContent=this.text),this.#t&&this.follows==="pointer"&&this.#r&&this.#m(this.#r)}#n=()=>{this.text&&(this.#e&&clearTimeout(this.#e),this.#e=setTimeout(()=>this.#o(),this.delay))};#a=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#o(){if(this.#t)return;let t=document.createElement("div"),e=`tooltip-${Date.now()}`;t.id=e,t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.classList.add("tooltip-popup"),t.textContent=this.text,document.body.appendChild(t),this.setAttribute("aria-describedby",e);try{t.showPopover()}catch{}this.#t=t,this.#i=Ot(this,t,{placement:this.placement,gap:6})}#l(){if(this.#e&&(clearTimeout(this.#e),this.#e=null),!!this.#t){this.removeAttribute("aria-describedby"),this.#i?.(),this.#i=null;try{this.#t.hidePopover()}catch{}this.#t.remove(),this.#t=null,this.#r=null}}#c(){if(this.#h(),!this.for)return;let t=this.getRootNode();if(this.#s=t&&t.getElementById?t.getElementById(this.for):document.getElementById(this.for),!this.#s){s._warnedMissing||(s._warnedMissing=new WeakSet),s._warnedMissing.has(this)||(console.warn(`[tooltip-ui] follows="pointer" [for="${this.for}"] did not resolve to an element.`),s._warnedMissing.add(this));return}this.#s.addEventListener("chart-hover",this.#u),this.#s.addEventListener("chart-leave",this.#d)}#h(){this.#s&&(this.#s.removeEventListener("chart-hover",this.#u),this.#s.removeEventListener("chart-leave",this.#d)),this.#s=null}#d=()=>this.#l();#u=t=>{let e=t.detail;if(e){if(this.#r=e,!this.#t){this.#t=this.#f(),this.#p();try{this.#t.showPopover()}catch{}}this.#m(e),this.#g(e.pointerX,e.pointerY)}};#f(){let t=document.createElement("div");return t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.setAttribute("data-follows","pointer"),t.setAttribute("data-indicator",this.indicator||"none"),t.classList.add("tooltip-popup"),document.body.appendChild(t),t}#p(){if(!this.#s||!this.#t)return;let t=getComputedStyle(this.#s),e=Array.isArray(this.#s.legendData)?this.#s.legendData.map(i=>i.key).filter(Boolean):[];for(let i of e){let r=t.getPropertyValue(`--color-${i}`).trim();r&&this.#t.style.setProperty(`--color-${i}`,r)}for(let i=0;i<10;i++){let r=t.getPropertyValue(`--chart-${i}`).trim();r&&this.#t.style.setProperty(`--chart-${i}`,r)}}#m(t){if(!this.#t)return;let{label:e,value:i,pct:r,series:n,slot:o,payload:a}=t,l=this.indicator||"none",h=Array.isArray(a)&&a.length>0?a:[{series:n,label:e,value:i,pct:r,slot:o,hovered:!0}],c=[];e!=null&&c.push(`<span data-tip-role="label">${this.#b(String(e))}</span>`);for(let u of h){let d=u.series??null,f=u.value,p=u.pct,m=u.slot!=null?u.slot:0,g=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let b=f!=null?this.#b(String(f)):"",A=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",x=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${g}"></span>`:"",S=d?`<span data-tip-role="name">${this.#b(d)}</span>`:"",v=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${v}>${x}${S}<span data-tip-role="value">${b}${A}</span></span>`)}this.#t.setAttribute("data-indicator",l),this.#t.setAttribute("aria-live","polite"),this.#t.innerHTML=c.join("")}#g(t,e){if(!this.#t||t==null||e==null)return;let i=12,r=8,n=this.#t;n.style.position="fixed",n.style.left="0",n.style.top="0";let o=n.offsetWidth||0,a=n.offsetHeight||0,l=t-o/2,h=e-a-i;l<r&&(l=r),l+o>window.innerWidth-r&&(l=window.innerWidth-o-r),h<r&&(h=e+i),n.style.left=`${l}px`,n.style.top=`${h}px`}#b(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}};M();w("tooltip-ui",Ur);R();var B$={new:{variant:"success",text:"New"},updated:{variant:"info",text:"Updated"},deprecated:{variant:"warning",text:"Deprecated"},removed:{variant:"danger",text:"Removed"},beta:{variant:"primary",text:"Beta"}},Yr=class extends k{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","status")}render(){if(this.status){let t=B$[this.status];t&&(this.variant!==t.variant&&(this.variant=t.variant),this.text!==t.text&&(this.text=t.text))}if(this.text&&this.setAttribute("aria-label",this.text),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t&&t.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("size","sm"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};M();w("badge-ui",Yr);R();var Hr=class extends k{static properties={separator:{type:String,default:"/",reflect:!0},collapse:{type:Boolean,default:!1,reflect:!0},collapseKeepLeading:{type:Number,default:1,attribute:"collapse-keep-leading",reflect:!0},collapseKeepTrailing:{type:Number,default:2,attribute:"collapse-keep-trailing",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","navigation"),this.setAttribute("aria-label","Breadcrumb")}render(){this.querySelectorAll("[data-sep], [data-overflow]").forEach(l=>l.remove());let t=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-overflow")),e=t.length-1;t.forEach((l,h)=>{l.setAttribute("data-item",""),l.removeAttribute("data-collapsed"),h===e?l.setAttribute("aria-current","page"):l.removeAttribute("aria-current")});let i=Math.max(0,this.collapseKeepLeading|0),r=Math.max(0,this.collapseKeepTrailing|0),n=i+r+1;if(this.collapse&&t.length>=Math.max(n,4)){let l=t.slice(i,t.length-r);l.forEach(c=>c.setAttribute("data-collapsed",""));let h=this.#t(l);i>0?t[i-1].after(h):this.prepend(h)}let a=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-collapsed"));for(let l=0;l<a.length-1;l++){let h=document.createElement("span");h.setAttribute("data-sep",""),h.setAttribute("aria-hidden","true"),h.textContent=this.separator,a[l].after(h)}}#t(t){let e=document.createElement("menu-ui");e.setAttribute("data-overflow",""),e.setAttribute("data-item",""),e.setAttribute("placement","bottom-start");let i=document.createElement("button-ui");i.setAttribute("slot","trigger"),i.setAttribute("text","\u2026"),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("aria-label","Show collapsed crumbs"),e.appendChild(i);for(let r of t){let n=document.createElement("menu-item-ui");n.setAttribute("text",r.textContent.trim()),r.tagName==="A"&&r.hasAttribute("href")&&n.setAttribute("value",r.getAttribute("href")),e.appendChild(n)}return e.addEventListener("action",r=>{let n=r.detail?.value;n&&n!=="#"&&(window.location.href=n)}),e}};M();w("breadcrumb-ui",Hr);R();ii();function z$(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Z$=0,Gr=class s extends k{static requiredIcons=["magnifying-glass"];static properties={placeholder:{type:String,default:"Type a command...",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=[];#i=-1;#s=null;#r=null;#n=null;#a=null;#o=!1;#l=new WeakMap;#c=[];#h=`command-${++Z$}`;static#d=3;#u=t=>{let e=re(t.target)?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=this.#l.get(e);i&&this.#k(i)};#f=t=>{let e=re(t.target)?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=parseInt(e.dataset.idx);Number.isFinite(i)&&i!==this.#i&&this.#E(i)};connected(){this.#o||(this.#o=!0,this.addEventListener("keydown",this.#Q))}render(){if(!this.#s){this.#t.length===0&&this.#b(),this.#c=ct(this,"empty");let t=`${this.#h}-list`;this.innerHTML=`
|
|
195
195
|
<header>
|
|
196
196
|
<icon-ui name="magnifying-glass" slot="icon"></icon-ui>
|
|
197
197
|
<span contenteditable="plaintext-only" role="combobox" tabindex="0"
|
|
@@ -205,13 +205,13 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
205
205
|
<span data-hint><kbd>\u21B5</kbd> Select</span>
|
|
206
206
|
<span data-hint><kbd>\u238B</kbd> Close</span>
|
|
207
207
|
</footer>
|
|
208
|
-
`,this.#s=this.querySelector('[slot="input"]'),this.#r=this.querySelector('[slot="list"]'),this.#a=this.querySelector("footer"),this.#s.addEventListener("input",this.#
|
|
208
|
+
`,this.#s=this.querySelector('[slot="input"]'),this.#r=this.querySelector('[slot="list"]'),this.#a=this.querySelector("footer"),this.#s.addEventListener("input",this.#C),this.#r.addEventListener("click",this.#u),this.#r.addEventListener("pointerover",this.#f),this.#y()}this.#s&&this.#s.setAttribute("aria-expanded",String(this.open)),this.open&&(this.#n=requestAnimationFrame(()=>{this.#n=null,this.#s?.focus()}))}get value(){return this.#s?.textContent||""}set value(t){if(!this.#s)return;let e=t??"";this.#s.textContent=e,this.#s.toggleAttribute("data-empty",!e),this.#y(e)}focus(){this.#s?.focus()}setItems(t){this.#t=t,this.#y()}set options(t){this.#t=this.#p(Array.isArray(t)?t:[]),this.#r&&this.#y(this.#s?.value||"")}get options(){return this.#t}#p(t){let e=[];for(let i of t)if(i&&Array.isArray(i.options)){let r=i.label||"";e.push({label:r,items:i.options.map(n=>this.#m(n,r))})}else i&&e.push(this.#m(i,""));return e}#m(t,e=""){return{value:t.value,label:t.label??t.value,icon:t.icon||"",shortcut:t.shortcut||"",keywords:t.keywords||"",disabled:!!t.disabled,category:e}}#g(){let t=[],e=i=>{for(let r of i.children)if(!r.hasAttribute("slot")){if(r.tagName==="OPTION"||r.tagName==="OPTGROUP"){t.push(r);continue}if(r.matches('[role="presentation"]')||r.style?.display==="contents"){e(r);continue}}};return e(this),t}#b(){let t=[];for(let e of this.#g())if(e.tagName==="OPTGROUP"){let i=e.label,r={label:i,items:[]};for(let n of e.querySelectorAll("option"))r.items.push(this.#O(n,i));t.push(r)}else e.tagName==="OPTION"&&t.push(this.#O(e,""));this.#t=t}#O(t,e=""){return{value:t.value,label:t.textContent.trim(),icon:t.dataset.icon||"",shortcut:t.dataset.shortcut||"",keywords:t.dataset.keywords||"",disabled:t.disabled,category:e}}#y(t=""){if(!this.#r)return;this.#r.innerHTML="",this.#i=-1;let e=t.toLowerCase(),i=this.#t,r=0;if(!e&&this.#e.length){let n=this.#e.map(o=>this.#v(o)).filter(o=>o&&!o.disabled);if(n.length){let o=document.createElement("div");o.setAttribute("data-group",""),o.setAttribute("data-recent",""),o.innerHTML="<div data-group-label>Recent</div>";for(let a of n)o.appendChild(this.#x(a,r)),r++;this.#r.appendChild(o)}}for(let n of i)if(n.items){let o=n.items.filter(l=>this.#A(l,e));if(!o.length)continue;let a=document.createElement("div");a.setAttribute("data-group",""),a.innerHTML=`<div data-group-label>${n.label}</div>`;for(let l of o)a.appendChild(this.#x(l,r)),r++;this.#r.appendChild(a)}else{if(!this.#A(n,e))continue;this.#r.appendChild(this.#x(n,r)),r++}if(!r){let n=document.createElement("div");n.setAttribute("data-empty",""),this.#c.length?n.append(...this.#c):n.textContent="No results found.",this.#r.appendChild(n)}r>0&&this.#E(0)}#v(t){for(let e of this.#t)if(e.items){let i=e.items.find(r=>r.value===t);if(i)return i}else if(e.value===t)return e;return null}#S(t){t&&(this.#e=[t,...this.#e.filter(e=>e!==t)].slice(0,s.#d))}#x(t,e){let i=document.createElement("div");return i.setAttribute("role","option"),i.setAttribute("data-value",t.value),i.setAttribute("data-idx",e),t.disabled&&i.setAttribute("aria-disabled","true"),i.innerHTML=`
|
|
209
209
|
${t.icon?`<icon-ui name="${t.icon}"></icon-ui>`:""}
|
|
210
210
|
<span data-text>${t.label}</span>
|
|
211
211
|
${t.shortcut?`<span data-shortcut>${t.shortcut}</span>`:""}
|
|
212
|
-
`,this.#l.set(i,t),i}#A(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#C(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)}#P(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.#C(parseInt(e[n].dataset.idx))}#k(t){this.#S(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#w(){let t=this.#r.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",n=(this.#l.get(t)||this.#y(e))?.category||"";this.#S(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:n}}))}#E=()=>{let t=this.#s.textContent||"";this.#s.toggleAttribute("data-empty",!t),this.#v(t)};#T=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#P(1);break;case"ArrowUp":t.preventDefault(),this.#P(-1);break;case"Enter":t.preventDefault(),this.#w();break;case"Tab":t.preventDefault(),this.#w();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),this.removeEventListener("keydown",this.#T),this.#s?.removeEventListener("input",this.#E),this.#r?.removeEventListener("click",this.#u),this.#r?.removeEventListener("pointerover",this.#f),this.#s=null,this.#r=null,this.#a=null,this.#o=!1}};M();w("command-ui",Gr);var Ga=.4;function wf(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function Af(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 Si(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function kf(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function hv(s,t,e){let{a:i,b:r}=wf(s,t,e),[n,o,a]=Af(s,i,r);return[Math.max(0,Math.min(1,Si(n))),Math.max(0,Math.min(1,Si(o))),Math.max(0,Math.min(1,Si(a)))]}function _$(s,t,e){let i=r=>Math.round(r*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Kr(s,t,e){let[i,r,n]=hv(s,t,e);return _$(i,r,n)}function V$(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=kf(parseInt(s.slice(0,2),16)/255),e=kf(parseInt(s.slice(2,4),16)/255),i=kf(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 cv(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Ka(s,t,e){let{a:i,b:r}=wf(s,t,e),[n,o,a]=Af(s,i,r);if(cv(Si(n),Si(o),Si(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=wf(s,u,e),[p,m,g]=Af(s,d,f);cv(Si(p),Si(m),Si(g))?l=u:h=u}return l}var Jr=class s extends X{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...X.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#r=NaN;#n=!1;#a=null;#o=!1;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m=null;#g=null;#b=null;#O=null;#v=null;#y=[];#S=null;static template=()=>null;#x=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")};#A=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#L(t))};#C=t=>{this.#a==="area"&&this.#L(t)};#P=()=>{this.#a==="area"&&(this.#a=null,this.#I("change"))};#k=t=>{this.disabled||(this.#a="hue",this.#u.setPointerCapture(t.pointerId),this.#Q(t))};#w=t=>{this.#a==="hue"&&this.#Q(t)};#E=()=>{this.#a==="hue"&&(this.#a=null,this.#I("change"))};#T=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(Ga,this.#i+i);break;case"ArrowLeft":t.preventDefault(),this.#i=Math.max(0,this.#i-i);break;case"ArrowUp":t.preventDefault(),this.#e=Math.min(1,this.#e+e);break;case"ArrowDown":t.preventDefault(),this.#e=Math.max(0,this.#e-e);break;default:return}this.#I("change")};#$=t=>{if(this.disabled)return;let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#s=(this.#s+e)%360;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#s=(this.#s-e+360)%360;break;default:return}this.#I("change")};connected(){if(super.connected(),this.#M(this.value),this.#n)return;this.#n=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#d=document.createElement("div"),this.#d.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#d),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(n,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",n),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#x),t.appendChild(c),c};this.#b=e("H","hue",0,360,1),this.#O=e("C","chroma",0,Ga,.001),this.#v=e("L","lightness",0,1,.001),this.appendChild(t),this.#u=document.createElement("div"),this.#u.setAttribute("data-hue-track",""),this.#u.setAttribute("tabindex","0"),this.#u.setAttribute("role","slider"),this.#u.setAttribute("aria-label","Hue"),this.#f=document.createElement("div"),this.#f.setAttribute("data-hue-thumb",""),this.#u.appendChild(this.#f),this.appendChild(this.#u);let i=document.createElement("div");i.setAttribute("data-output","");let r=n=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",n);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",n),l.setAttribute("aria-label",`Copy ${n}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#q(n,l);return l.addEventListener("click",h),this.#y.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.#A),this.#h.addEventListener("pointermove",this.#C),this.#h.addEventListener("pointerup",this.#P),this.#u.addEventListener("pointerdown",this.#k),this.#u.addEventListener("pointermove",this.#w),this.#u.addEventListener("pointerup",this.#E),this.#h.addEventListener("keydown",this.#T),this.#u.addEventListener("keydown",this.#$),typeof ResizeObserver<"u"&&(this.#g=new ResizeObserver(()=>this.#z()),this.#g.observe(this.#h))}disconnected(){super.disconnected(),this.#S!=null&&(clearTimeout(this.#S),this.#S=null),this.#g&&(this.#g.disconnect(),this.#g=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#A),this.#h.removeEventListener("pointermove",this.#C),this.#h.removeEventListener("pointerup",this.#P),this.#h.removeEventListener("keydown",this.#T)),this.#u&&(this.#u.removeEventListener("pointerdown",this.#k),this.#u.removeEventListener("pointermove",this.#w),this.#u.removeEventListener("pointerup",this.#E),this.#u.removeEventListener("keydown",this.#$)),this.#b?.removeEventListener("input",this.#x),this.#O?.removeEventListener("input",this.#x),this.#v?.removeEventListener("input",this.#x);for(let{el:t,handler:e}of this.#y)t.removeEventListener("click",e);this.#y=[],this.#n=!1}#L(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*Ga,this.#e=1-r,this.#I("input")}#Q(t){let e=this.#u.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#I("input")}#M(t){if(t){if(t.startsWith("#")){let e=V$(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-area-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=Ka(this.#e,this.#i,this.#s),r=Kr(this.#e,i,this.#s),n=this.#R();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}))}#R(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#q(t,e){let i=t==="oklch"?this.#R():Kr(this.#e,Ka(this.#e,this.#i,this.#s),this.#s),r=e.querySelector("icon-ui"),n=o=>{r&&(r.setAttribute("name",o?"check":"warning"),this.#S!=null&&clearTimeout(this.#S),this.#S=setTimeout(()=>{this.#S=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)*Ga,u=Ka(l,c,o),[d,f,p]=hv(l,u,o),m=(a*e+h)*4;n[m]=Math.round(d*255),n[m+1]=Math.round(f*255),n[m+2]=Math.round(p*255),n[m+3]=255}}this.#c.putImageData(r,0,0)}render(){if(this.#o?this.#o=!1:this.#M(this.value),this.#z(),this.#d){let n=this.#i/Ga*100,o=(1-this.#e)*100;this.#d.style.left=`${n}%`,this.#d.style.top=`${o}%`,this.#d.style.background=Kr(this.#e,Ka(this.#e,this.#i,this.#s),this.#s)}if(this.#u){let n=[];for(let o=0;o<=360;o+=30)n.push(Kr(.7,.15,o));this.#u.style.background=`linear-gradient(to right, ${n.join(", ")})`,this.#u.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#f&&(this.#f.style.left=`${this.#s/360*100}%`,this.#f.style.background=Kr(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#R());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=Kr(this.#e,Ka(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#R()),this.#m&&(this.#m.textContent=r)}onFormReset(){this.value="#3b82f6"}};M();w("color-area-ui",Jr);var tn=class extends X{static get properties(){return{...X.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0},maxL:{type:Number,default:1,reflect:!0},minL:{type:Number,default:0,reflect:!0},hueDriftMax:{type:Number,default:NaN,reflect:!0},baseHue:{type:Number,default:NaN,reflect:!0}}}#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=null;connected(){this.#o(),this.#l(),this.#u(),this.syncValue(this.value)}render(){this.#u(),this.#t&&this.#t.open!==this.open&&(this.#t.open=this.open),this.#i&&(this.#i.format!==this.format&&(this.#i.format=this.format),Object.is(this.#i.maxChroma,this.maxChroma)||(this.#i.maxChroma=this.maxChroma),Object.is(this.#i.maxL,this.maxL)||(this.#i.maxL=this.maxL),Object.is(this.#i.minL,this.minL)||(this.#i.minL=this.minL),Object.is(this.#i.hueDriftMax,this.hueDriftMax)||(this.#i.hueDriftMax=this.hueDriftMax),Object.is(this.#i.baseHue,this.baseHue)||(this.#i.baseHue=this.baseHue)),this.#e&&(this.disabled?this.#e.setAttribute("disabled",""):this.#e.removeAttribute("disabled"))}showPicker(){this.open=!0}hidePicker(){this.open=!1}#o(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-area-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-area-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),typeof MutationObserver<"u"&&(this.#a=new MutationObserver(t),this.#a.observe(this.#t,{attributes:!0,attributeFilter:["open"]}))}#c=t=>{this.#d(t.detail,"change")};#h=t=>{this.#d(t.detail,"input")};#d(t,e){if(!t)return;let i=this.format==="oklch"?t.oklch:t.hex;i&&i!==this.value&&(this.value=i,this.syncValue(i)),this.#u(),this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:{value:i??this.value,hex:t.hex,oklch:t.oklch,l:t.l,c:t.c,h:t.h}}))}#u(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#r&&(this.#r.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#c),this.#i?.removeEventListener("input",this.#h),this.#a?.disconnect(),this.#a=null,this.#n=!1}};M();w("color-input-ui",tn);R();ii();var Ef=0,en=class extends k{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-${++Ef}`,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-${++Ef}`,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),typeof ResizeObserver<"u"&&(this.#s=new ResizeObserver(()=>this.#h()),this.#s.observe(this)),typeof MutationObserver<"u"&&(this.#r=new MutationObserver(()=>{this.#x(),this.#h()})),this.#d();for(let t of this.#m())this.#s?.observe(t);this.#x(),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.#A(),this.#t?.remove(),this.#t=null,this.#a=!1}#h(){this.#n||typeof requestAnimationFrame=="function"&&(this.#n=requestAnimationFrame(()=>{this.#n=null,this.#f()}))}#d(){this.#r?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#u(){this.#r?.disconnect()}#f(){if(!this.#t)return;this.#u();let t=this.#m();for(let n of t)this.#s?.observe(n);this.#C();let e=this.#e.map(n=>{let o=this.#p(n.from),a=this.#p(n.to);if(!o||!a)return null;let l=this.#g(o,n.fromPort),h=this.#g(a,n.toPort);return!l||!h?null:{id:n.id,d:this.#b(l,h,n.fromPort,n.toPort)}}).filter(Boolean),i=new Map;for(let n of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(n.getAttribute("data-noodle-id"),n);let r=new Set(e.map(n=>n.id));for(let[n,o]of i)r.has(n)||o.remove();for(let{id:n,d:o}of e){let a=i.get(n);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",n),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#o&&this.#l){let n=this.#t.querySelector("path[data-noodle-preview]");n||(n=document.createElementNS("http://www.w3.org/2000/svg","path"),n.setAttribute("data-noodle-preview",""),n.style.opacity="0.5",n.style.strokeDasharray="6 3",this.#t.appendChild(n)),n.setAttribute("d",this.#l),n.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#d()}#p(t){return re(t)?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#g(t,e){let i=t.getBoundingClientRect(),r=this.getBoundingClientRect(),n=this.offsetWidth&&r.width?r.width/this.offsetWidth:1,o=(i.left-r.left)/n,a=(i.top-r.top)/n,l=i.width/n,h=i.height/n;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#b(t,e,i,r){switch(this.curve){case"step":return this.#y(t,e);case"straight":return this.#S(t,e);default:return this.#O(t,e,i,r)}}#O(t,e,i,r){let n=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(n*n+o*o),l=Math.max(50,a*this.tension),h=this.#v(t,i,l),c=this.#v(e,r,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#v(t,e,i){switch(e){case"left":return{x:t.x-i,y:t.y};case"right":return{x:t.x+i,y:t.y};case"top":return{x:t.x,y:t.y-i};case"bottom":return{x:t.x,y:t.y+i};default:return{x:t.x+i,y:t.y}}}#y(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}`}#S(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#x(){this.#u(),this.#A();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.#P(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.#k(a,e,r)),this.appendChild(o),this.#i.set(n,o)}}this.#C(),this.#d()}#A(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#C(){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.#P(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`}}}#P(t,e){return t._noodleId||(t._noodleId=`_n${++Ef}`),`${t._noodleId}:${e}`}#k=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let r=t.currentTarget;r.setPointerCapture(t.pointerId),r.setAttribute("data-noodle-dragging","");let n=this.#g(e,i),o=l=>{if(!this.#o)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#b(n,{x:c,y:u},i,this.#w(n,{x:c,y:u})),this.#h(),this.#E(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.#T(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#$(),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.#$(),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)};#w(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"}#E(t,e,i){this.#$();let r=this.#T(t,e,i);r?.dot&&r.dot.setAttribute("data-noodle-drop-ready","")}#T(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(g=>g._noodleId===f);!m||m===i||d<r&&d<o&&(o=d,n={el:m,side:p,dot:l})}return n}#$(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};M();w("noodles-ui",en);var Ji={};function pe(s,t){Ji[s]=t}function sn(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 Cf={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()};pe("text",{render(s,t,e){sn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),pe("number",{render(s,t,e){sn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),pe("currency",{render(s,t,e,i){sn(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"}),pe("percent",{render(s,t,e){sn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var uv={year:"numeric",month:"short",day:"numeric"};pe("date",{render(s,t,e){sn(e,s?new Intl.DateTimeFormat("en-US",uv).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",uv).format(new Date(s)):""},align:"left",sortFn:"datetime"});var dv={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};pe("datetime",{render(s,t,e){sn(e,s?new Intl.DateTimeFormat("en-US",dv).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",dv).format(new Date(s)):""},align:"left",sortFn:"datetime"}),pe("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"}),pe("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 o=(i?.variants||{})[s];o?(r.setAttribute("variant",o),r.removeAttribute("tone")):(r.removeAttribute("variant"),r.setAttribute("tone","muted"))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),pe("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"}),pe("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"}),pe("markdown",{render(s,t,e){let i=e.firstElementChild;(!i||i.tagName!=="SPAN")&&(e.replaceChildren(),i=e.appendChild(document.createElement("span"))),i.innerHTML=Br(String(s??"")),e.title=i.textContent},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),pe("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"),i.style.flex="1",i.style.minWidth="0";let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");a.style.flexShrink="0",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"}),pe("actions",{attachesListeners:!0,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});R();ii();function j$(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 wi(s,t){return typeof t.accessor=="function"?t.accessor(s):j$(s,t.key)}function Kh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
213
|
-
`)?'"'+t.replace(/"/g,'""')+'"':t}function Ja(s,t,e){s.getAttribute(t)!==e&&s.setAttribute(t,e)}function fv(s,t){s.hasAttribute(t)&&s.removeAttribute(t)}var Jh=new WeakSet;function $f(s,t){for(;s.children.length>t.length;)s.lastChild.remove();for(let e=0;e<t.length;e++){let i=s.children[e],r=t[e];i?(Jh.has(r)||!i.isEqualNode(r))&&s.replaceChild(r,i):s.appendChild(r)}}var rn=class extends k{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},valign:{type:String,default:"center",reflect:!0},frameless:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},paginate:{type:Number,default:0,reflect:!0},noPager:{type:Boolean,default:!1,reflect:!0,attribute:"no-pager"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0},clickableRows:{type:Boolean,default:!1,reflect:!0,attribute:"clickable-rows"}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#r=new Set;#n=null;#a=0;#o=new Set;#l=new Map;#c=null;#h=!1;#d=-1;#u=null;#f=null;get#p(){return this.hasAttribute("range-total")}#m(){let t=Number(this.rangeTotal);return Number.isFinite(t)&&t>0?Math.trunc(t):0}set columns(t){this.#t=Array.isArray(t)?t:[],this.#w()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#p||(this.#a=0),this.#w()}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.#w(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#w(),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.#p||(this.#a=0),this.#w(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#u=null,this.#p||(this.#a=0),this.#w(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}#g=t=>{t.target===this&&(this.search=t.detail?.value??"")};#b=t=>{if(t.target!==this)return;let{key:e,value:i,op:r}=t.detail||{};e&&this.setFilter(e,i,r)};#O=t=>{t.target===this&&this.clearFilters()};#v=t=>{if(t.target!==this)return;let e=t.detail?.columns;Array.isArray(e)&&(this.columns=e)};#y=t=>{t.target===this&&(this.paginate=Number(t.detail?.pageSize)||0)};#S=t=>{if(t.target!==this||!(this.paginate>0))return;let e=Number(t.detail?.page);if(!Number.isFinite(e))return;let i=Math.max(1,Math.min(Math.trunc(e),this.#Q));this.#a=i-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))};get filteredCount(){return this.#$().length}toggleExpand(t){!this.#x(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.#w())}get expanded(){return[...this.#r]}expandRenderer=null;rowExpandable=null;#x(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}}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),this.#w()}}#A(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#C(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){if(this.#P(),this.#e.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}Ja(this,"role","grid"),Ja(this,"tabindex","0"),this.#C(),this.#h||(this.#h=!0,this.addEventListener("click",this.#N),this.addEventListener("keydown",this.#G),this.addEventListener("pointerdown",this.#D),this.addEventListener("toolbar-search",this.#g),this.addEventListener("toolbar-filter-set",this.#b),this.addEventListener("toolbar-filter-clear",this.#O),this.addEventListener("toolbar-columns-set",this.#v),this.addEventListener("toolbar-paginate",this.#y),this.addEventListener("footer-page",this.#S))}disconnected(){this.removeEventListener("click",this.#N),this.removeEventListener("keydown",this.#G),this.removeEventListener("pointerdown",this.#D),this.removeEventListener("toolbar-search",this.#g),this.removeEventListener("toolbar-filter-set",this.#b),this.removeEventListener("toolbar-filter-clear",this.#O),this.removeEventListener("toolbar-columns-set",this.#v),this.removeEventListener("toolbar-paginate",this.#y),this.removeEventListener("footer-page",this.#S),this.#h=!1,this.#et(),this.#k&&(cancelAnimationFrame(this.#k),this.#k=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#w()}#P(){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,valign:i.getAttribute("valign")||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));let h=i.getAttribute("meta");if(h)try{r.meta=JSON.parse(h)}catch{}e.push(r),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#k=null;#w(){!this.isConnected||this.#k||(this.#k=requestAnimationFrame(()=>{this.#k=null,this.render(),this.#A()}))}get#E(){return this.#t.filter(t=>!t.hidden)}#T(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#E)if(this.#l.has(e.key))t.push(`${this.#l.get(e.key)}px`);else if(e.width)t.push(`${e.width}px`);else{let i=e.minWidth?`${e.minWidth}px`:"6rem",r=e.maxWidth?`${e.maxWidth}px`:`${e.flex||1}fr`;t.push(`minmax(${i}, ${r})`)}return t.join(" ")}#$(){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.#E.some(n=>{let o=wi(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=wi(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=wi(this.#e[e],o||{key:r}),l=wi(this.#e[i],o||{key:r}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Ji[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Cf[d]||Cf.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}#L(t){if(this.#p||!this.paginate||this.paginate<=0)return t;let e=this.#a*this.paginate;return t.slice(e,e+this.paginate)}get#Q(){if(!this.paginate||this.paginate<=0)return 1;if(this.#p)return Math.max(1,Math.ceil(this.#m()/this.paginate));let t=this.#$().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#E,e=this.#T();this.style.gridTemplateColumns!==e&&(this.style.gridTemplateColumns=e);let i=this.querySelector(":scope > [data-header]");i||(i=document.createElement("div"),i.setAttribute("role","row"),i.setAttribute("data-header",""),this.prepend(i)),this.#M(i,t),this.#B();let r=this.querySelector(":scope > [data-body]");r||(r=document.createElement("div"),r.setAttribute("role","rowgroup"),r.setAttribute("data-body",""),i.after(r));let n=this.#$(),o=this.#L(n),a=[];for(let u of o){let d=r.querySelector(`:scope > [role="row"][data-index="${u}"]`),f=d||this.#I(u,t);if(d&&this.#R(d,u,t),this.#x(u)&&this.#r.has(u)?Ja(f,"data-expanded",""):fv(f,"data-expanded"),a.push(f),this.#x(u)&&this.#r.has(u)){let p=r.querySelector(`:scope > [data-detail-row][data-for="${u}"]`);if(!p&&(p=document.createElement("div"),p.setAttribute("data-detail-row",""),p.dataset.for=u,this.expandRenderer)){let m=this.expandRenderer(this.#e[u],u);Gi(m)?p.appendChild(m):p.textContent=String(m)}a.push(p)}}let l=[...r.children];for(let u of l)a.includes(u)||u.remove();for(let u=0;u<a.length;u++)r.children[u]!==a[u]&&(r.children[u]?r.insertBefore(a[u],r.children[u]):r.appendChild(a[u]));this.#q(r),this.#z(r,n,t);let h=this.paginate>0&&!this.noPager&&(this.#p?this.#m()>0:this.#e.length>0),c=this.querySelector(":scope > [data-footer]");h?(c||(c=document.createElement("div"),c.setAttribute("data-footer",""),this.appendChild(c)),this.#X(c)):c&&c.remove()}#M(t,e){let i=this.#e.length>0&&this.#o.size===this.#e.length,r=[];if(this.expandable){let n=document.createElement("div");n.setAttribute("role","columnheader"),n.setAttribute("data-expand-col",""),n.setAttribute("aria-label","Expand"),r.push(n)}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-column-resize-handle",""),h.dataset.resizeKey=n.key,o.appendChild(h)}if(n.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=n.key,h.setAttribute("aria-label",`Filter ${n.label||n.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(n.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#u===n.key){let u=this.#Z(n);o.appendChild(u),o.setAttribute("data-filter-open","")}}r.push(o)}$f(t,r)}#I(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#R(i,t,e),i}#R(t,e,i){let r=this.#e[e],n=this.#o.has(e);Ja(t,"data-index",String(e)),n?Ja(t,"aria-selected","true"):fv(t,"aria-selected");let o=[];if(this.expandable){let a=document.createElement("div");if(a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col",""),this.#x(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=wi(r,a);if(typeof a.render=="function"){let u=a.render(h,r,l,e);Gi(u)?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u),Jh.add(l)}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=Ji[a.type||"text"];if(u?.render)u.render(h,r,l,a.meta),u.attachesListeners&&Jh.add(l);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Ji[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.valign&&(l.dataset.valign=a.valign),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}$f(t,o)}#q(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.#E,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("corner-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()}#z(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=wi(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=Ji[a.type||"text"];typeof c=="number"&&u?.render?(u.render(c,{},l,a.meta),u.attachesListeners&&Jh.add(l)):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}$f(n,o)}#X(t){let e=t.querySelector("pagination-ui");e||(t.innerHTML="",e=document.createElement("pagination-ui"),e.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(e));let i=this.#Q,r=Math.min(this.#a,i-1);e.setAttribute("page",String(r+1)),e.setAttribute("total",String(i))}#Z(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=wi(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),n=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of r){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=n.has(o.toLowerCase()),l.addEventListener("change",()=>{let h=[...e.querySelectorAll("input[type=checkbox]:checked")].map(c=>c.value);h.length?this.setFilter(t.key,h.join(","),"select"):this.setFilter(t.key,null)}),a.appendChild(l),a.appendChild(document.createTextNode(` ${o}`)),e.appendChild(a)}}else if(t.filter==="number"){let r=document.createElement("input");r.type="number",r.placeholder="Filter...",r.value=i?.value??"",r.setAttribute("data-filter-input","");let n=document.createElement("select");n.setAttribute("data-filter-op","");for(let[a,l]of[["gte","\u2265"],["lte","\u2264"],["gt",">"],["lt","<"],["equals","="]]){let h=document.createElement("option");h.value=a,h.textContent=l,i?.op===a&&(h.selected=!0),n.appendChild(h)}let o=()=>{r.value?this.setFilter(t.key,r.value,n.value):this.setFilter(t.key,null)};r.addEventListener("input",o),n.addEventListener("change",o),e.appendChild(n),e.appendChild(r)}else{let r=document.createElement("input");r.type="text",r.placeholder=`Filter ${t.label||t.key}...`,r.value=i?.value??"",r.setAttribute("data-filter-input",""),r.addEventListener("input",()=>{r.value?this.setFilter(t.key,r.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(r)}if(i){let r=document.createElement("button");r.textContent="Clear",r.setAttribute("data-filter-clear",""),r.addEventListener("click",()=>{this.setFilter(t.key,null),this.#u=null,this.#w()}),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}#B(){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)}#D=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-column-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#j(t,e))};#N=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#u=this.#u===c?null:c,this.#w();return}this.#u&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#u=null,this.#w());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-column-resize-handle]");if(n&&this.contains(n)){this.#j(t,n);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#o.add(u);else this.#o.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#d>=0){let f=Math.min(this.#d,u),p=Math.max(this.#d,u);for(let m=f;m<=p;m++)d?this.#o.add(m):this.#o.delete(m)}else d?this.#o.add(u):this.#o.delete(u);this.#d=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(g=>g.key===d),m=p?wi(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}}))}}};#_=null;#j(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;e.setAttribute("data-resizing",""),this.#_={key:i,col:r,startX:a,startWidth:o,handle:e},document.addEventListener("pointermove",this.#F),document.addEventListener("pointerup",this.#U)}#F=t=>{if(!this.#_)return;let{key:e,col:i,startX:r,startWidth:n}=this.#_,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.#T()};#U=t=>{if(!this.#_)return;let{key:e,handle:i}=this.#_;document.removeEventListener("pointermove",this.#F),document.removeEventListener("pointerup",this.#U),i.removeAttribute("data-resizing");let r=this.#l.get(e);this.#_=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:r}})),this.render()};#et(){document.removeEventListener("pointermove",this.#F),document.removeEventListener("pointerup",this.#U),this.#_=null}#G=t=>{let i=this.#E.length+(this.expandable?1:0)+(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.#Y())};#Y(){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.#E,i=this.#$(),r=e.map(c=>Kh(c.label||c.key)),n=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=wi(u,d);if(typeof d.format=="function")return Kh(d.format(f,u));let p=Ji[d.type||"text"];return p?.format?Kh(p.format(f,u,d.meta)):Kh(f)})}),o=[r.join(","),...n.map(c=>c.join(","))].join(`
|
|
214
|
-
`),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)}};M();w("table-ui",rn);R();var F$=200,W$=896,U$=640,Y$=416;function Pf(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 Qf(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}function Tf(s){let t=s.label;return typeof t=="string"&&t.trim()?t:s.key}var H$=50,pv=500;function mv(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 G$(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 K$(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(G$(s?.key))return"text";let e=[],i=Math.min(t?.length??0,pv),r=new Set;for(let n=0;n<i;n++){let o=mv(t[n],s);if(!(o==null||o==="")&&(e.push(o),r.add(String(o)),r.size>H$))return"text"}return e.length?"select":"text"}function J$(s,t){let e=new Set,i=Math.min(t?.length??0,pv);for(let r=0;r<i;r++){let n=mv(t[r],s);n==null||n===""||e.add(String(n))}return[...e].sort((r,n)=>r.localeCompare(n,void 0,{numeric:!0}))}var nn=class s extends k{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},rangeStart:{type:Number,default:0,reflect:!0,attribute:"range-start"},rangeEnd:{type:Number,default:0,reflect:!0,attribute:"range-end"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},pageSize:{type:Number,default:0,reflect:!0,attribute:"page-size"},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"},chromeOnly:{type:Boolean,default:!1,reflect:!0,attribute:"chrome-only"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0},stage:{type:String,default:"",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down","dots-three-vertical"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#r=null;#n=new Set;#a=[];#o=null;#l=null;#c=null;set pageSizeOptions(t){this.#a=Array.isArray(t)?t.map(Number).filter(e=>Number.isFinite(e)):[],this.#x()}get pageSizeOptions(){return this.#a}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(){if(this.setAttribute("role","toolbar"),this.#u(),this.#a.length===0&&this.hasAttribute("page-size-options"))try{let t=JSON.parse(this.getAttribute("page-size-options"));Array.isArray(t)&&(this.pageSizeOptions=t)}catch{}this.#g(),this.#f(),this.#k(),this.#l=this.clientWidth||null,this.#d(),typeof ResizeObserver<"u"&&(this.#o=new ResizeObserver(t=>{let{inlineSize:e}=t[0].contentBoxSize[0];this.#l=e,!this.#c&&(this.#c=requestAnimationFrame(()=>{this.#c=null,this.#d()}))}),this.#o.observe(this))}updated(t){(t.has("noFilter")||t.has("noSort")||t.has("noColumns")||t.has("noSearch")||t.has("chromeOnly"))&&this.#C(),t.has("placeholder")&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#S(),t==="stage"&&this.#d()}disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null);for(let t of this.#n)cancelAnimationFrame(t);this.#n.clear(),this.#E(),this.#m(),this.#c!=null&&(cancelAnimationFrame(this.#c),this.#c=null),this.#o?.disconnect(),this.#o=null}#h(t){let e=getComputedStyle(this),i=(a,l)=>{let h=Sf(a);return Number.isFinite(h)?h:l},r=i(e.getPropertyValue("--table-toolbar-bp-search-tight"),W$),n=i(e.getPropertyValue("--table-toolbar-bp-icon-only"),U$),o=i(e.getPropertyValue("--table-toolbar-bp-overflow"),Y$);return t<=o?"overflow":t<=n?"icon-only":t<=r?"search-tight":"full"}#d(){let t=this.stage||(this.#l==null?"full":this.#h(this.#l));this.getAttribute("data-stage-resolved")!==t&&this.setAttribute("data-stage-resolved",t)}render(){this.#f(),this.#k(),this.#y(),this.#S(),this.#x()}#u(){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.`)}#f(){let t=this.#p();if(t===this.#t||(this.#m(),!t))return;this.#t=t;let e=()=>this.#I(),i=()=>this.#Q();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#p(){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}#m(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#g(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-scope","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="scope"&&e.appendChild(m);let i=document.createElement("div");i.setAttribute("data-title","");let r=document.createElement("span");r.setAttribute("data-heading",""),i.appendChild(r);let n=document.createElement("badge-ui");n.setAttribute("data-toolbar-count-badge",""),n.setAttribute("size","sm"),n.setAttribute("tone","muted"),n.hidden=!0,i.appendChild(n);let o=document.createElement("div");o.setAttribute("data-summary",""),o.hidden=!0;let a=document.createElement("span");a.setAttribute("data-summary-text",""),o.appendChild(a);let l=document.createElement("span");l.setAttribute("data-summary-compact",""),l.hidden=!0,o.appendChild(l);let h=document.createElement("div");h.setAttribute("data-summary-empty",""),h.hidden=!0;for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="empty"&&h.appendChild(m);o.appendChild(h);let c=document.createElement("div");c.setAttribute("data-controls",""),c.appendChild(this.#O("filter","Filter","funnel-simple")),c.appendChild(this.#O("sort","Sort","arrows-down-up")),c.appendChild(this.#O("columns","Columns","columns")),c.appendChild(this.#v());let u=document.createElement("search-ui");u.setAttribute("data-search",""),u.setAttribute("size","sm"),u.setAttribute("placeholder",this.placeholder),u.setAttribute("debounce",String(F$)),u.addEventListener("search",this.#P);let d=document.createElement("select-ui");d.setAttribute("data-page-size",""),d.setAttribute("size","sm"),d.setAttribute("aria-label","Rows per page"),d.hidden=!0,d.addEventListener("change",this.#A);let f=document.createElement("div");f.setAttribute("data-actions-leading","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="actions-leading"&&f.appendChild(m);let p=document.createElement("div");p.setAttribute("data-actions","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="actions"&&p.appendChild(m);t.appendChild(e),t.appendChild(i),t.appendChild(o),t.appendChild(c),t.appendChild(u),t.appendChild(f),t.appendChild(d),t.appendChild(p),this.appendChild(t),this.#y(),this.#S(),this.#C(),this.#x()}#b(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}#O(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.setAttribute("title",e),r.addEventListener("click",n=>{n.stopPropagation(),this.#w(t,r)}),r}#v(){let t=document.createElement("menu-ui");t.setAttribute("data-toolbar-overflow","");let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("icon","dots-three-vertical"),e.setAttribute("variant","outline"),e.setAttribute("size","sm"),e.setAttribute("aria-label","More table actions"),e.setAttribute("aria-haspopup","menu"),t.appendChild(e);for(let[i,r,n]of[["filter","Filter","funnel-simple"],["sort","Sort","arrows-down-up"],["columns","Columns","columns"]]){let o=document.createElement("menu-item-ui");o.setAttribute("icon",n),o.setAttribute("text",r),o.setAttribute("value",i),t.appendChild(o)}return t.addEventListener("action",i=>{this.#w(i.detail.value,e)}),t}#y(){let t=this.querySelector(":scope [data-heading]");t&&(this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0);let e=this.querySelector(":scope [data-toolbar-count-badge]");if(e){let r=this.count?.toString().trim(),n=this.#t?.data?.length,o=r||(Number.isFinite(n)?String(n):"");o?(e.setAttribute("text",o),e.hidden=!1):e.hidden=!0}let i=this.querySelector(":scope > [data-toolbar] > [data-title]");i&&(i.hidden=Array.from(i.children).every(r=>r.hidden))}#S(){let t=this.querySelector(":scope > [data-toolbar] > [data-summary]");if(!t)return;let e=t.querySelector(":scope > [data-summary-text]"),i=t.querySelector(":scope > [data-summary-compact]"),r=t.querySelector(":scope > [data-summary-empty]"),n=Number(this.rangeStart)||0,o=Number(this.rangeEnd)||0,a=Number(this.rangeTotal)||0;if(n>0&&o>0&&a>0){e&&(e.textContent=`Showing ${n}\u2013${o} of ${a}`),e&&(e.hidden=!1),i&&(i.textContent=`${n}\u2013${o}/${a}`),i&&(i.hidden=!1),r&&(r.hidden=!0),t.hidden=!1;return}let l=this.hasAttribute("range-total")&&this.getAttribute("range-total")==="0",h=!!r&&r.childNodes.length>0;if(l&&h){e&&(e.hidden=!0),i&&(i.hidden=!0),r.hidden=!1,t.hidden=!1;return}e&&(e.hidden=!0),i&&(i.hidden=!0),r&&(r.hidden=!0),t.hidden=!0}#x(){let t=this.querySelector(":scope > [data-toolbar] > [data-page-size]");if(!t)return;let e=this.#a;if(!e.length){t.hidden=!0;return}t.hidden=!1;let i=e.map(o=>({value:String(o),label:`${o} / page`}));t.options=i;let r=Number(this.pageSize)||0,n=e.includes(r)?r:e[0];t.value=String(n)}#A=t=>{let e=Number(t.detail?.value??this.querySelector(":scope [data-page-size]")?.value)||0;this.pageSize=e,this.#t&&this.#t.dispatchEvent(new CustomEvent("toolbar-paginate",{bubbles:!0,detail:{pageSize:e}})),this.dispatchEvent(new CustomEvent("page-size-change",{bubbles:!0,detail:{pageSize:e}}))};#C(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=this.chromeOnly,i=(l,h)=>{let c=t.querySelector(l);c&&(c.hidden=h)},r=e||this.noFilter,n=e||this.noSort,o=e||this.noColumns;i('[data-toolbar-btn="filter"]',r),i('[data-toolbar-btn="sort"]',n),i('[data-toolbar-btn="columns"]',o),i("[data-search]",e||this.noSearch);let a=t.querySelector("[data-toolbar-overflow]");if(a){let l={filter:r,sort:n,columns:o};for(let h of a.querySelectorAll("menu-item-ui"))h.hidden=!!l[h.getAttribute("value")];a.hidden=r&&n&&o}}#P=t=>{let e=t.detail?.value??"";this.#t&&this.#t.dispatchEvent(new CustomEvent("toolbar-search",{bubbles:!0,detail:{value:e}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#k(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#y()}#w(t,e){if(this.#i?.kind===t){this.#E();return}this.#E();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#L(i),t==="sort"&&this.#M(i),t==="columns"&&this.#R(i),document.body.appendChild(i);try{i.showPopover()}catch{}let r=Ot(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.#T,!0),document.addEventListener("keydown",this.#$,!0))}))}#E(){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.#T,!0),document.removeEventListener("keydown",this.#$,!0))}}#T=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#E())};#$=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#E(),this.#i?.btn?.focus?.({preventScroll:!0}))};#L(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Pf("No filterable columns"));return}let i=e.filters||{};t.appendChild(Qf("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",Tf(o));let l=K$(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=J$(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||"";e.dispatchEvent(new CustomEvent("toolbar-filter-set",{bubbles:!0,detail:{key:o.key,value:d||null,op:"select"}})),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;e.dispatchEvent(new CustomEvent("toolbar-filter-set",{bubbles:!0,detail:{key:o.key,value:u||null,op:"contains"}})),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.#b("Clear all filters",()=>{e.dispatchEvent(new CustomEvent("toolbar-filter-clear",{bubbles:!0})),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#Q()});t.appendChild(o)}}#Q(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#L(t.panel))}#M(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Pf("No sortable columns"));return}t.appendChild(Qf("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",Tf(o)),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.#I()}),n.appendChild(l)}if(t.appendChild(n),i.length){let o=this.#b("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.#I()});t.appendChild(o)}}#I(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#M(t.panel))}#R(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Pf("No columns"));return}t.appendChild(Qf("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",Tf(r));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.dispatchEvent(new CustomEvent("toolbar-columns-set",{bubbles:!0,detail:{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)}};M();w("table-toolbar-ui",nn);R();var on=class extends k{static properties={for:{type:String,default:"",reflect:!0},page:{type:Number,default:1,reflect:!0},pageSize:{type:Number,default:0,reflect:!0,attribute:"page-size"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},siblings:{type:Number,default:1,reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;#t=null;connected(){this.#e()}render(){this.#s(),this.#l()}disconnected(){this.#n()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#l()}#e(){if(this.querySelector(":scope > [data-row]"))return;let t=document.createElement("div");t.setAttribute("data-row","");let e=document.createElement("div");e.setAttribute("data-range",""),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true");let i=document.createElement("span");i.setAttribute("data-range-text",""),e.appendChild(i);let r=document.createElement("div");r.setAttribute("data-range-empty",""),r.hidden=!0;for(let a of[...this.children])a!==t&&a.getAttribute?.("slot")==="empty"&&r.appendChild(a);e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-pager","");let o=document.createElement("pagination-ui");o.setAttribute("data-footer-pager",""),o.addEventListener("page-change",this.#i),n.appendChild(o),t.appendChild(e),t.appendChild(n),this.appendChild(t)}#i=t=>{t.stopPropagation();let e=Number(t.detail?.page);Number.isFinite(e)&&(this.hasAttribute("range-total")||(this.page=e),this.#t&&this.#t.dispatchEvent(new CustomEvent("footer-page",{bubbles:!0,composed:!0,detail:{page:e}})),this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,detail:{page:e}})))};#s(){let t=this.#r();t!==this.#t&&(this.#n(),t&&(this.#t=t,t.addEventListener("page",this.#a),t.addEventListener("filter-change",this.#o),t.addEventListener("sort",this.#o)))}#r(){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}#n(){this.#t&&(this.#t.removeEventListener("page",this.#a),this.#t.removeEventListener("filter-change",this.#o),this.#t.removeEventListener("sort",this.#o)),this.#t=null}#a=t=>{let e=Number(t.detail?.page);Number.isFinite(e)&&(this.page=e+1)};#o=()=>{this.#l()};#l(){let t=this.querySelector(":scope > [data-row]");if(!t)return;let e=t.querySelector(":scope > [data-range]"),i=e?.querySelector(":scope > [data-range-text]"),r=e?.querySelector(":scope > [data-range-empty]"),n=t.querySelector(":scope > [data-pager]"),o=n?.querySelector(":scope > pagination-ui"),a=this.#t,l=!!a&&a.hasAttribute("range-total"),h=!!a&&!l&&Number(a.paginate)>0,c=this.hasAttribute("range-total"),u=this.hasAttribute("page-size"),d=c||l||h,f=S=>{let v=Number(S);return Number.isFinite(v)&&v>0?Math.trunc(v):0},p=c?f(this.rangeTotal):l?f(a.rangeTotal):h&&Number(a.filteredCount)||0,m=u?Number(this.pageSize)||0:l||h?Number(a.paginate)||0:Number(this.pageSize)||0;if(!e)return;if(!d){e.hidden=!0,n&&(n.hidden=!0);return}if(e.hidden=!1,p===0){let S=!!r&&r.childNodes.length>0;i&&(i.hidden=!0),r&&(r.hidden=!S),n&&(n.hidden=!0);return}if(r&&(r.hidden=!0),m<=0){i&&(i.hidden=!1,i.textContent=`${p} items`),n&&(n.hidden=!0);return}let g=Math.max(1,Math.ceil(p/m)),b=Math.max(1,Math.min(Number(this.page)||1,g)),A=(b-1)*m+1,x=Math.min(b*m,p);i&&(i.hidden=!1,i.textContent=`Showing ${A}\u2013${x} of ${p}`),n&&(n.hidden=g<=1),o&&(o.setAttribute("page",String(b)),o.setAttribute("total",String(g)),o.setAttribute("siblings",String(Math.max(0,Number(this.siblings)||0))),o.setAttribute("size",this.size||"md"))}};M();w("table-footer-ui",on);R();var an=class extends k{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","")}},ln=class extends k{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()}#i(t){return t.dataset.timelineItemStamped="1",t}#s(t){return t?.dataset?.timelineItemStamped==="1"}connected(){for(let t of["label","description","time"]){if(ct(this,t).length)continue;let e=this.#i(document.createElement("span"));e.setAttribute("slot",t),this.appendChild(e)}}render(){let t=this.querySelector(':scope > [slot="label"]'),e=this.querySelector(':scope > [slot="description"]'),i=this.querySelector(':scope > [slot="time"]');this.#s(t)&&(t.textContent=this.text),this.#s(e)&&(e.textContent=this.description),this.#s(i)&&(i.textContent=this.duration||this.time);let r=this.querySelector(':scope > [slot="icon"]');if(this.icon)if(r)this.#s(r)&&r.setAttribute("name",this.icon);else{let o=this.#i(document.createElement("icon-ui"));o.setAttribute("slot","icon"),o.setAttribute("name",this.icon),this.prepend(o)}else this.#s(r)&&r.remove();let n=this.querySelector(':scope > [slot="outcomes"]');if(this.#t.length>0){n||(n=document.createElement("ul"),n.setAttribute("slot","outcomes"),this.appendChild(n)),n.innerHTML="";for(let a of this.#t){let l=document.createElement("li");l.textContent=a,n.appendChild(l)}n.hidden=!this.#e;let o=this.querySelector(":scope > [data-timeline-toggle]");o||(o=document.createElement("button-ui"),o.setAttribute("variant","ghost"),o.setAttribute("size","xs"),o.setAttribute("data-timeline-toggle",""),o.setAttribute("aria-label","Toggle details"),o.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(o)),o.setAttribute("icon",this.#e?"caret-down":"caret-right")}else this.querySelector(":scope > [data-timeline-toggle]")?.remove(),n?.remove()}};M();w("timeline-ui",an),w("timeline-item-ui",ln);R();function hn(s){return s.disabled||s.hasAttribute("disabled")}var cn=class extends k{static properties={step:{type:Number,default:0,reflect:!0},orientation:{type:String,default:"horizontal",reflect:!0},interactive:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=()=>this.render();#e=null;connected(){this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#a),!this.#e&&typeof MutationObserver<"u"&&(this.#e=new MutationObserver(this.#t),this.#e.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled"]}))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#a),this.#e?.disconnect(),this.#e=null}render(){let t=[...this.querySelectorAll("stepper-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];if(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"),this.interactive?(i.setAttribute("role","button"),r===this.step?i.setAttribute("aria-current","step"):i.removeAttribute("aria-current")):(i.removeAttribute("role"),i.removeAttribute("tabindex"),i.removeAttribute("aria-current"),i.removeAttribute("aria-disabled"))}),this.interactive){let i=t.filter(o=>!hn(o)),r=t[this.step],n=r&&!hn(r)?r:i[0];for(let o of t)hn(o)?(o.setAttribute("aria-disabled","true"),o.removeAttribute("tabindex")):(o.removeAttribute("aria-disabled"),o.setAttribute("tabindex",o===n?"0":"-1"))}}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))}get#i(){return[...this.querySelectorAll("stepper-item-ui")]}get#s(){return this.#i.filter(t=>!hn(t))}#r(t){let e=this.#i,i=e.length-1,r=Math.max(0,Math.min(t,i));if(r===this.step||e[r]&&hn(e[r]))return!1;let n=this.step;return this.dispatchEvent(new CustomEvent("step-request",{bubbles:!0,cancelable:!0,detail:{step:r,previous:n}}))?(this.step=r,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{step:this.step}})),!0):!1}#n=t=>{if(!this.interactive)return;let e=t.target.closest("stepper-item-ui");if(!e||!this.contains(e)||hn(e))return;let i=this.#i.indexOf(e);i<0||this.#r(i)};#a=t=>{if(!this.interactive)return;let e=t.target.closest("stepper-item-ui");if(!e||!this.contains(e))return;let i=this.#s,r=i.indexOf(e);if(r<0)return;let n=this.orientation==="vertical",o=n?"ArrowDown":"ArrowRight",a=n?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=r<i.length-1?r+1:0;break;case a:l=r>0?r-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;case"Enter":case" ":t.preventDefault(),this.#r(this.#i.indexOf(e));return;default:return}t.preventDefault();let h=i[l];this.#r(this.#i.indexOf(h))&&h.focus()}},un=class extends k{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},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t(t){return t.dataset.stepperItemStamped="1",t}#e(t){return t?.dataset?.stepperItemStamped==="1"}connected(){for(let t of["label","description"]){if(this.querySelector(`[slot="${t}"]`))continue;let e=this.#t(document.createElement("span"));e.setAttribute("slot",t),this.appendChild(e)}}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');this.#e(t)&&(t.textContent=this.text),this.#e(e)&&(e.textContent=this.description);let i=this.querySelector('[slot="icon"]');if(this.icon)if(i)this.#e(i)&&i.setAttribute("name",this.icon);else{let r=this.#t(document.createElement("icon-ui"));r.setAttribute("slot","icon"),r.setAttribute("name",this.icon),this.prepend(r)}else this.#e(i)&&i.remove()}};M();w("stepper-ui",cn),w("stepper-item-ui",un);R();var dn=class extends k{static requiredIcons=["caret-left","caret-right"];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.#x),this.addEventListener("pointerleave",this.#A),this.addEventListener("focusin",this.#C),this.addEventListener("focusout",this.#P)),this.addEventListener("keydown",this.#k),this.#t.addEventListener("pointerdown",this.#E),this.#t.addEventListener("pointermove",this.#T),this.#t.addEventListener("pointerup",this.#$),this.#t.addEventListener("pointercancel",this.#$),this.#t.addEventListener("click",this.#L,!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.#x),this.removeEventListener("pointerleave",this.#A),this.removeEventListener("focusin",this.#C),this.removeEventListener("focusout",this.#P),this.removeEventListener("keydown",this.#k),this.#t&&(this.#t.removeEventListener("pointerdown",this.#E),this.#t.removeEventListener("pointermove",this.#T),this.#t.removeEventListener("pointerup",this.#$),this.#t.removeEventListener("pointercancel",this.#$),this.#t.removeEventListener("click",this.#L,!0),this.#t.removeEventListener("dragstart",this.#Q)),this.#o=null,this.#t=null,this.#n=!1}next(){let t=this.#d()-1,e=this.#m(this.#r),i=Math.min(e+1,t);if(i!==e||this.loop){let r=this.loop&&i===e?0:i;this.goTo(this.#p(r))}}prev(){let t=this.#d()-1,e=this.#m(this.#r),i=Math.max(e-1,0);if(i!==e||this.loop){let r=this.loop&&i===e?t:i;this.goTo(this.#p(r))}}goTo(t){let e=this.slides[t];if(!e||!this.#t)return;let i=Math.max(0,this.#u(e));this.#t.scrollTo({left:i,behavior:"smooth"})}play(){this.pause(),!(typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: reduce)").matches)&&(this.#e=setInterval(()=>{let t=this.#d()-1,i=this.#m(this.#r)>=t;i&&this.loop?this.goTo(this.#p(0)):i?this.pause():this.next()},this.interval||5e3))}pause(){this.#e&&(clearInterval(this.#e),this.#e=null)}#l(){let t=this.slides;t.forEach((e,i)=>{e.setAttribute("role","group"),e.setAttribute("aria-roledescription","slide"),e.getAttribute("aria-label")||e.setAttribute("aria-label",`${i+1} of ${t.length}`)})}#c(){this.#s=()=>{let t=this.#f();t!==this.#r&&(this.#r=t,this.#S(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{index:t,slide:this.slides[t]}})))},this.#t.addEventListener("scroll",this.#s,{passive:!0}),this.#r=this.#f()}#h(){if(!this.#t)return 1;let e=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").trim(),i=parseInt(e,10);return Number.isFinite(i)&&i>0?i:1}#d(){let t=this.slides.length;return t===0?0:this.snap==="center"?t:Math.max(1,t-this.#h()+1)}#u(t){let e=this.#t.clientWidth,i=t.offsetLeft-this.#t.offsetLeft,r=t.offsetWidth;return this.snap==="center"?i+r/2-e/2:this.snap==="end"?i+r-e:i}#f(){if(!this.#t)return 0;let t=this.slides;if(t.length===0)return 0;let e=this.#t.scrollLeft,i=Math.max(0,this.#t.scrollWidth-this.#t.clientWidth),r=0,n=1/0;for(let o=0;o<t.length;o++){let a=Math.max(0,Math.min(i,this.#u(t[o]))),l=Math.abs(e-a);l<n&&(n=l,r=o)}return r}#p(t){if(this.snap!=="end")return t;let e=this.#h();return Math.min(this.slides.length-1,t+e-1)}#m(t){if(this.snap!=="end")return t;let e=this.#h();return Math.max(0,t-e+1)}#g(){this.#a||(this.#a=!0,this.chrome==="toolbar"?this.#O():this.#b(),this.#y(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#y()),this.#i.observe(this)))}#b(){let t=document.createElement("button-ui");t.setAttribute("data-swiper-btn",""),t.setAttribute("data-swiper-prev",""),t.setAttribute("icon","caret-left"),t.setAttribute("variant","ghost"),t.setAttribute("aria-label","Previous slide"),t.addEventListener("press",()=>this.prev());let e=document.createElement("button-ui");e.setAttribute("data-swiper-btn",""),e.setAttribute("data-swiper-next",""),e.setAttribute("icon","caret-right"),e.setAttribute("variant","ghost"),e.setAttribute("aria-label","Next slide"),e.addEventListener("press",()=>this.next()),this.appendChild(t),this.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-dots",""),i.setAttribute("role","tablist"),i.setAttribute("aria-label","Slide indicators"),this.appendChild(i)}#O(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let r=document.createElement("button-ui");r.setAttribute("icon","caret-left"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Previous slide"),r.addEventListener("press",()=>this.prev());let n=document.createElement("button-ui");n.setAttribute("icon","caret-right"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Next slide"),n.addEventListener("press",()=>this.next()),i.appendChild(r),i.appendChild(n),t.appendChild(i),this.insertBefore(t,this.#t);let o=document.createElement("div");o.setAttribute("data-swiper-foot","");let a=document.createElement("span");a.setAttribute("data-swiper-counter",""),o.appendChild(a);let l=document.createElement("div");l.setAttribute("data-swiper-dots",""),l.setAttribute("role","tablist"),l.setAttribute("aria-label","Slide indicators"),o.appendChild(l),this.appendChild(o),this.#v()}#v(){let t=this.querySelector("[data-swiper-counter]");if(!t)return;if(!this.counter){t.textContent="";return}let e=this.#m(this.#r)+1,i=this.#d();t.textContent=`${e} / ${i}`}#y(){let t=this.querySelector("[data-swiper-dots]");if(!t)return;let e=this.#d();if(t.children.length!==e){for(;t.firstChild;)t.removeChild(t.firstChild);for(let i=0;i<e;i++){let r=document.createElement("button-ui");r.setAttribute("variant","ghost"),r.setAttribute("role","tab"),r.setAttribute("aria-label",`Page ${i+1}`),r.addEventListener("click",()=>this.goTo(this.#p(i))),t.appendChild(r)}}this.#S()}#S(){if(!this.#a)return;let t=this.querySelector("[data-swiper-dots]");if(t){let e=this.#d()-1,i=Math.min(Math.max(this.#m(this.#r),0),e);[...t.children].forEach((r,n)=>{r.setAttribute("aria-current",n===i?"true":"false")})}this.#v()}#x=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#A=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#C=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#P=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#k=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#w=5;#E=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=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=t.clientX-this.#o.startX;if(Math.abs(e)>=this.#w){if(!this.#o.hasMoved){this.#o.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#o.startScrollLeft-e,t.preventDefault()}};#$=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")))};#L=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#Q=t=>{this.#o&&t.preventDefault()}};M();w("swiper-ui",dn);var fn=class extends X{static labelDeprecated=!1;static requiredIcons=["upload-simple"];static properties={...X.properties,label:{type:String,default:"",reflect:!0},accept:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},compact:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;connected(){super.connected(),this.querySelector("[data-dropzone]")||(this.innerHTML=`
|
|
212
|
+
`,this.#l.set(i,t),i}#A(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#E(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)}#$(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.#E(parseInt(e[n].dataset.idx))}#k(t){this.#S(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#w(){let t=this.#r.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",n=(this.#l.get(t)||this.#v(e))?.category||"";this.#S(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:n}}))}#C=()=>{let t=this.#s.textContent||"";this.#s.toggleAttribute("data-empty",!t),this.#y(t)};#Q=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#$(1);break;case"ArrowUp":t.preventDefault(),this.#$(-1);break;case"Enter":t.preventDefault(),this.#w();break;case"Tab":t.preventDefault(),this.#w();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),this.removeEventListener("keydown",this.#Q),this.#s?.removeEventListener("input",this.#C),this.#r?.removeEventListener("click",this.#u),this.#r?.removeEventListener("pointerover",this.#f),this.#s=null,this.#r=null,this.#a=null,this.#o=!1}};M();w("command-ui",Gr);var Ga=.4;function wf(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function Af(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 Si(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function kf(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function hv(s,t,e){let{a:i,b:r}=wf(s,t,e),[n,o,a]=Af(s,i,r);return[Math.max(0,Math.min(1,Si(n))),Math.max(0,Math.min(1,Si(o))),Math.max(0,Math.min(1,Si(a)))]}function _$(s,t,e){let i=r=>Math.round(r*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Kr(s,t,e){let[i,r,n]=hv(s,t,e);return _$(i,r,n)}function V$(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=kf(parseInt(s.slice(0,2),16)/255),e=kf(parseInt(s.slice(2,4),16)/255),i=kf(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 cv(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Ka(s,t,e){let{a:i,b:r}=wf(s,t,e),[n,o,a]=Af(s,i,r);if(cv(Si(n),Si(o),Si(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=wf(s,u,e),[p,m,g]=Af(s,d,f);cv(Si(p),Si(m),Si(g))?l=u:h=u}return l}var Jr=class s extends X{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...X.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#r=NaN;#n=!1;#a=null;#o=!1;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m=null;#g=null;#b=null;#O=null;#y=null;#v=[];#S=null;static template=()=>null;#x=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")};#A=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#M(t))};#E=t=>{this.#a==="area"&&this.#M(t)};#$=()=>{this.#a==="area"&&(this.#a=null,this.#I("change"))};#k=t=>{this.disabled||(this.#a="hue",this.#u.setPointerCapture(t.pointerId),this.#T(t))};#w=t=>{this.#a==="hue"&&this.#T(t)};#C=()=>{this.#a==="hue"&&(this.#a=null,this.#I("change"))};#Q=t=>{if(this.disabled)return;let e=t.shiftKey?.05:.01,i=t.shiftKey?.04:.004;switch(t.key){case"ArrowRight":t.preventDefault(),this.#i=Math.min(Ga,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.#R(this.value),this.#n)return;this.#n=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#d=document.createElement("div"),this.#d.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#d),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(n,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",n),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#x),t.appendChild(c),c};this.#b=e("H","hue",0,360,1),this.#O=e("C","chroma",0,Ga,.001),this.#y=e("L","lightness",0,1,.001),this.appendChild(t),this.#u=document.createElement("div"),this.#u.setAttribute("data-hue-track",""),this.#u.setAttribute("tabindex","0"),this.#u.setAttribute("role","slider"),this.#u.setAttribute("aria-label","Hue"),this.#f=document.createElement("div"),this.#f.setAttribute("data-hue-thumb",""),this.#u.appendChild(this.#f),this.appendChild(this.#u);let i=document.createElement("div");i.setAttribute("data-output","");let r=n=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",n);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",n),l.setAttribute("aria-label",`Copy ${n}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#D(n,l);return l.addEventListener("click",h),this.#v.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.#A),this.#h.addEventListener("pointermove",this.#E),this.#h.addEventListener("pointerup",this.#$),this.#u.addEventListener("pointerdown",this.#k),this.#u.addEventListener("pointermove",this.#w),this.#u.addEventListener("pointerup",this.#C),this.#h.addEventListener("keydown",this.#Q),this.#u.addEventListener("keydown",this.#P),typeof ResizeObserver<"u"&&(this.#g=new ResizeObserver(()=>this.#z()),this.#g.observe(this.#h))}disconnected(){super.disconnected(),this.#S!=null&&(clearTimeout(this.#S),this.#S=null),this.#g&&(this.#g.disconnect(),this.#g=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#A),this.#h.removeEventListener("pointermove",this.#E),this.#h.removeEventListener("pointerup",this.#$),this.#h.removeEventListener("keydown",this.#Q)),this.#u&&(this.#u.removeEventListener("pointerdown",this.#k),this.#u.removeEventListener("pointermove",this.#w),this.#u.removeEventListener("pointerup",this.#C),this.#u.removeEventListener("keydown",this.#P)),this.#b?.removeEventListener("input",this.#x),this.#O?.removeEventListener("input",this.#x),this.#y?.removeEventListener("input",this.#x);for(let{el:t,handler:e}of this.#v)t.removeEventListener("click",e);this.#v=[],this.#n=!1}#M(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*Ga,this.#e=1-r,this.#I("input")}#T(t){let e=this.#u.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#I("input")}#R(t){if(t){if(t.startsWith("#")){let e=V$(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-area-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=Ka(this.#e,this.#i,this.#s),r=Kr(this.#e,i,this.#s),n=this.#L();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}))}#L(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#D(t,e){let i=t==="oklch"?this.#L():Kr(this.#e,Ka(this.#e,this.#i,this.#s),this.#s),r=e.querySelector("icon-ui"),n=o=>{r&&(r.setAttribute("name",o?"check":"warning"),this.#S!=null&&clearTimeout(this.#S),this.#S=setTimeout(()=>{this.#S=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)*Ga,u=Ka(l,c,o),[d,f,p]=hv(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.#R(this.value),this.#z(),this.#d){let n=this.#i/Ga*100,o=(1-this.#e)*100;this.#d.style.left=`${n}%`,this.#d.style.top=`${o}%`,this.#d.style.background=Kr(this.#e,Ka(this.#e,this.#i,this.#s),this.#s)}if(this.#u){let n=[];for(let o=0;o<=360;o+=30)n.push(Kr(.7,.15,o));this.#u.style.background=`linear-gradient(to right, ${n.join(", ")})`,this.#u.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#f&&(this.#f.style.left=`${this.#s/360*100}%`,this.#f.style.background=Kr(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#L());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=Kr(this.#e,Ka(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#L()),this.#m&&(this.#m.textContent=r)}onFormReset(){this.value="#3b82f6"}};M();w("color-area-ui",Jr);var tn=class extends X{static get properties(){return{...X.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0},maxL:{type:Number,default:1,reflect:!0},minL:{type:Number,default:0,reflect:!0},hueDriftMax:{type:Number,default:NaN,reflect:!0},baseHue:{type:Number,default:NaN,reflect:!0}}}#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=null;connected(){this.#o(),this.#l(),this.#u(),this.syncValue(this.value)}render(){this.#u(),this.#t&&this.#t.open!==this.open&&(this.#t.open=this.open),this.#i&&(this.#i.format!==this.format&&(this.#i.format=this.format),Object.is(this.#i.maxChroma,this.maxChroma)||(this.#i.maxChroma=this.maxChroma),Object.is(this.#i.maxL,this.maxL)||(this.#i.maxL=this.maxL),Object.is(this.#i.minL,this.minL)||(this.#i.minL=this.minL),Object.is(this.#i.hueDriftMax,this.hueDriftMax)||(this.#i.hueDriftMax=this.hueDriftMax),Object.is(this.#i.baseHue,this.baseHue)||(this.#i.baseHue=this.baseHue)),this.#e&&(this.disabled?this.#e.setAttribute("disabled",""):this.#e.removeAttribute("disabled"))}showPicker(){this.open=!0}hidePicker(){this.open=!1}#o(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-area-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-area-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),typeof MutationObserver<"u"&&(this.#a=new MutationObserver(t),this.#a.observe(this.#t,{attributes:!0,attributeFilter:["open"]}))}#c=t=>{this.#d(t.detail,"change")};#h=t=>{this.#d(t.detail,"input")};#d(t,e){if(!t)return;let i=this.format==="oklch"?t.oklch:t.hex;i&&i!==this.value&&(this.value=i,this.syncValue(i)),this.#u(),this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:{value:i??this.value,hex:t.hex,oklch:t.oklch,l:t.l,c:t.c,h:t.h}}))}#u(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#r&&(this.#r.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#c),this.#i?.removeEventListener("input",this.#h),this.#a?.disconnect(),this.#a=null,this.#n=!1}};M();w("color-input-ui",tn);R();ii();var Ef=0,en=class extends k{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-${++Ef}`,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-${++Ef}`,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),typeof ResizeObserver<"u"&&(this.#s=new ResizeObserver(()=>this.#h()),this.#s.observe(this)),typeof MutationObserver<"u"&&(this.#r=new MutationObserver(()=>{this.#x(),this.#h()})),this.#d();for(let t of this.#m())this.#s?.observe(t);this.#x(),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.#A(),this.#t?.remove(),this.#t=null,this.#a=!1}#h(){this.#n||typeof requestAnimationFrame=="function"&&(this.#n=requestAnimationFrame(()=>{this.#n=null,this.#f()}))}#d(){this.#r?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#u(){this.#r?.disconnect()}#f(){if(!this.#t)return;this.#u();let t=this.#m();for(let n of t)this.#s?.observe(n);this.#E();let e=this.#e.map(n=>{let o=this.#p(n.from),a=this.#p(n.to);if(!o||!a)return null;let l=this.#g(o,n.fromPort),h=this.#g(a,n.toPort);return!l||!h?null:{id:n.id,d:this.#b(l,h,n.fromPort,n.toPort)}}).filter(Boolean),i=new Map;for(let n of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(n.getAttribute("data-noodle-id"),n);let r=new Set(e.map(n=>n.id));for(let[n,o]of i)r.has(n)||o.remove();for(let{id:n,d:o}of e){let a=i.get(n);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",n),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#o&&this.#l){let n=this.#t.querySelector("path[data-noodle-preview]");n||(n=document.createElementNS("http://www.w3.org/2000/svg","path"),n.setAttribute("data-noodle-preview",""),n.style.opacity="0.5",n.style.strokeDasharray="6 3",this.#t.appendChild(n)),n.setAttribute("d",this.#l),n.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#d()}#p(t){return re(t)?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#g(t,e){let i=t.getBoundingClientRect(),r=this.getBoundingClientRect(),n=this.offsetWidth&&r.width?r.width/this.offsetWidth:1,o=(i.left-r.left)/n,a=(i.top-r.top)/n,l=i.width/n,h=i.height/n;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#b(t,e,i,r){switch(this.curve){case"step":return this.#v(t,e);case"straight":return this.#S(t,e);default:return this.#O(t,e,i,r)}}#O(t,e,i,r){let n=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(n*n+o*o),l=Math.max(50,a*this.tension),h=this.#y(t,i,l),c=this.#y(e,r,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#y(t,e,i){switch(e){case"left":return{x:t.x-i,y:t.y};case"right":return{x:t.x+i,y:t.y};case"top":return{x:t.x,y:t.y-i};case"bottom":return{x:t.x,y:t.y+i};default:return{x:t.x+i,y:t.y}}}#v(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}`}#S(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#x(){this.#u(),this.#A();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.#$(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.#k(a,e,r)),this.appendChild(o),this.#i.set(n,o)}}this.#E(),this.#d()}#A(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#E(){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.#$(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`}}}#$(t,e){return t._noodleId||(t._noodleId=`_n${++Ef}`),`${t._noodleId}:${e}`}#k=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let r=t.currentTarget;r.setPointerCapture(t.pointerId),r.setAttribute("data-noodle-dragging","");let n=this.#g(e,i),o=l=>{if(!this.#o)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#b(n,{x:c,y:u},i,this.#w(n,{x:c,y:u})),this.#h(),this.#C(l.clientX,l.clientY,e),this.dispatchEvent(new CustomEvent("noodle-drag",{bubbles:!0,detail:{from:e,fromPort:i,x:c,y:u}}))},a=l=>{try{r.releasePointerCapture(l.pointerId)}catch{}if(r.removeAttribute("data-noodle-dragging"),r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#Q(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#P(),this.#o=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#o=null,r.removeAttribute("data-noodle-dragging"),r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",a),this.#P(),this.#l=null,this.#c=null},this.#o={fromEl:e,fromSide:i,startPos:n,pointerId:t.pointerId},this.#l=null,r.addEventListener("pointermove",o),r.addEventListener("pointerup",a)};#w(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"}#C(t,e,i){this.#P();let r=this.#Q(t,e,i);r?.dot&&r.dot.setAttribute("data-noodle-drop-ready","")}#Q(t,e,i){let r=this.portSize*2,n=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#m().find(g=>g._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")}};M();w("noodles-ui",en);var Ji={};function pe(s,t){Ji[s]=t}function sn(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 Cf={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()};pe("text",{render(s,t,e){sn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),pe("number",{render(s,t,e){sn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),pe("currency",{render(s,t,e,i){sn(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"}),pe("percent",{render(s,t,e){sn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var uv={year:"numeric",month:"short",day:"numeric"};pe("date",{render(s,t,e){sn(e,s?new Intl.DateTimeFormat("en-US",uv).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",uv).format(new Date(s)):""},align:"left",sortFn:"datetime"});var dv={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};pe("datetime",{render(s,t,e){sn(e,s?new Intl.DateTimeFormat("en-US",dv).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",dv).format(new Date(s)):""},align:"left",sortFn:"datetime"}),pe("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"}),pe("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 o=(i?.variants||{})[s];o?(r.setAttribute("variant",o),r.removeAttribute("tone")):(r.removeAttribute("variant"),r.setAttribute("tone","muted"))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),pe("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"}),pe("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"}),pe("markdown",{render(s,t,e){let i=e.firstElementChild;(!i||i.tagName!=="SPAN")&&(e.replaceChildren(),i=e.appendChild(document.createElement("span"))),i.innerHTML=Br(String(s??"")),e.title=i.textContent},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),pe("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"),i.style.flex="1",i.style.minWidth="0";let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");a.style.flexShrink="0",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"}),pe("actions",{attachesListeners:!0,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});R();ii();function j$(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 wi(s,t){return typeof t.accessor=="function"?t.accessor(s):j$(s,t.key)}function Kh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
213
|
+
`)?'"'+t.replace(/"/g,'""')+'"':t}function Ja(s,t,e){s.getAttribute(t)!==e&&s.setAttribute(t,e)}function fv(s,t){s.hasAttribute(t)&&s.removeAttribute(t)}var Jh=new WeakSet;function $f(s,t){for(;s.children.length>t.length;)s.lastChild.remove();for(let e=0;e<t.length;e++){let i=s.children[e],r=t[e];i?(Jh.has(r)||!i.isEqualNode(r))&&s.replaceChild(r,i):s.appendChild(r)}}var rn=class extends k{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},valign:{type:String,default:"center",reflect:!0},frameless:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},paginate:{type:Number,default:0,reflect:!0},noPager:{type:Boolean,default:!1,reflect:!0,attribute:"no-pager"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0},clickableRows:{type:Boolean,default:!1,reflect:!0,attribute:"clickable-rows"}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#r=new Set;#n=null;#a=0;#o=new Set;#l=new Map;#c=null;#h=!1;#d=-1;#u=null;#f=null;get#p(){return this.hasAttribute("range-total")}#m(){let t=Number(this.rangeTotal);return Number.isFinite(t)&&t>0?Math.trunc(t):0}set columns(t){this.#t=Array.isArray(t)?t:[],this.#w()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#p||(this.#a=0),this.#w()}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.#w(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#w(),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.#p||(this.#a=0),this.#w(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#u=null,this.#p||(this.#a=0),this.#w(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}#g=t=>{t.target===this&&(this.search=t.detail?.value??"")};#b=t=>{if(t.target!==this)return;let{key:e,value:i,op:r}=t.detail||{};e&&this.setFilter(e,i,r)};#O=t=>{t.target===this&&this.clearFilters()};#y=t=>{if(t.target!==this)return;let e=t.detail?.columns;Array.isArray(e)&&(this.columns=e)};#v=t=>{t.target===this&&(this.paginate=Number(t.detail?.pageSize)||0)};#S=t=>{if(t.target!==this||!(this.paginate>0))return;let e=Number(t.detail?.page);if(!Number.isFinite(e))return;let i=Math.max(1,Math.min(Math.trunc(e),this.#T));this.#a=i-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))};get filteredCount(){return this.#P().length}toggleExpand(t){!this.#x(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.#w())}get expanded(){return[...this.#r]}expandRenderer=null;rowExpandable=null;#x(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}}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),this.#w()}}#A(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#E(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){if(this.#$(),this.#e.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}Ja(this,"role","grid"),Ja(this,"tabindex","0"),this.#E(),this.#h||(this.#h=!0,this.addEventListener("click",this.#q),this.addEventListener("keydown",this.#G),this.addEventListener("pointerdown",this.#N),this.addEventListener("toolbar-search",this.#g),this.addEventListener("toolbar-filter-set",this.#b),this.addEventListener("toolbar-filter-clear",this.#O),this.addEventListener("toolbar-columns-set",this.#y),this.addEventListener("toolbar-paginate",this.#v),this.addEventListener("footer-page",this.#S))}disconnected(){this.removeEventListener("click",this.#q),this.removeEventListener("keydown",this.#G),this.removeEventListener("pointerdown",this.#N),this.removeEventListener("toolbar-search",this.#g),this.removeEventListener("toolbar-filter-set",this.#b),this.removeEventListener("toolbar-filter-clear",this.#O),this.removeEventListener("toolbar-columns-set",this.#y),this.removeEventListener("toolbar-paginate",this.#v),this.removeEventListener("footer-page",this.#S),this.#h=!1,this.#et(),this.#k&&(cancelAnimationFrame(this.#k),this.#k=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#w()}#$(){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,valign:i.getAttribute("valign")||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));let h=i.getAttribute("meta");if(h)try{r.meta=JSON.parse(h)}catch{}e.push(r),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#k=null;#w(){!this.isConnected||this.#k||(this.#k=requestAnimationFrame(()=>{this.#k=null,this.render(),this.#A()}))}get#C(){return this.#t.filter(t=>!t.hidden)}#Q(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#C)if(this.#l.has(e.key))t.push(`${this.#l.get(e.key)}px`);else if(e.width)t.push(`${e.width}px`);else{let i=e.minWidth?`${e.minWidth}px`:"6rem",r=e.maxWidth?`${e.maxWidth}px`:`${e.flex||1}fr`;t.push(`minmax(${i}, ${r})`)}return t.join(" ")}#P(){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.#C.some(n=>{let o=wi(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=wi(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=wi(this.#e[e],o||{key:r}),l=wi(this.#e[i],o||{key:r}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Ji[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Cf[d]||Cf.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}#M(t){if(this.#p||!this.paginate||this.paginate<=0)return t;let e=this.#a*this.paginate;return t.slice(e,e+this.paginate)}get#T(){if(!this.paginate||this.paginate<=0)return 1;if(this.#p)return Math.max(1,Math.ceil(this.#m()/this.paginate));let t=this.#P().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#C,e=this.#Q();this.style.gridTemplateColumns!==e&&(this.style.gridTemplateColumns=e);let i=this.querySelector(":scope > [data-header]");i||(i=document.createElement("div"),i.setAttribute("role","row"),i.setAttribute("data-header",""),this.prepend(i)),this.#R(i,t),this.#B();let r=this.querySelector(":scope > [data-body]");r||(r=document.createElement("div"),r.setAttribute("role","rowgroup"),r.setAttribute("data-body",""),i.after(r));let n=this.#P(),o=this.#M(n),a=[];for(let u of o){let d=r.querySelector(`:scope > [role="row"][data-index="${u}"]`),f=d||this.#I(u,t);if(d&&this.#L(d,u,t),this.#x(u)&&this.#r.has(u)?Ja(f,"data-expanded",""):fv(f,"data-expanded"),a.push(f),this.#x(u)&&this.#r.has(u)){let p=r.querySelector(`:scope > [data-detail-row][data-for="${u}"]`);if(!p&&(p=document.createElement("div"),p.setAttribute("data-detail-row",""),p.dataset.for=u,this.expandRenderer)){let m=this.expandRenderer(this.#e[u],u);Gi(m)?p.appendChild(m):p.textContent=String(m)}a.push(p)}}let l=[...r.children];for(let u of l)a.includes(u)||u.remove();for(let u=0;u<a.length;u++)r.children[u]!==a[u]&&(r.children[u]?r.insertBefore(a[u],r.children[u]):r.appendChild(a[u]));this.#D(r),this.#z(r,n,t);let h=this.paginate>0&&!this.noPager&&(this.#p?this.#m()>0:this.#e.length>0),c=this.querySelector(":scope > [data-footer]");h?(c||(c=document.createElement("div"),c.setAttribute("data-footer",""),this.appendChild(c)),this.#X(c)):c&&c.remove()}#R(t,e){let i=this.#e.length>0&&this.#o.size===this.#e.length,r=[];if(this.expandable){let n=document.createElement("div");n.setAttribute("role","columnheader"),n.setAttribute("data-expand-col",""),n.setAttribute("aria-label","Expand"),r.push(n)}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-column-resize-handle",""),h.dataset.resizeKey=n.key,o.appendChild(h)}if(n.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=n.key,h.setAttribute("aria-label",`Filter ${n.label||n.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(n.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#u===n.key){let u=this.#Z(n);o.appendChild(u),o.setAttribute("data-filter-open","")}}r.push(o)}$f(t,r)}#I(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#L(i,t,e),i}#L(t,e,i){let r=this.#e[e],n=this.#o.has(e);Ja(t,"data-index",String(e)),n?Ja(t,"aria-selected","true"):fv(t,"aria-selected");let o=[];if(this.expandable){let a=document.createElement("div");if(a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col",""),this.#x(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=wi(r,a);if(typeof a.render=="function"){let u=a.render(h,r,l,e);Gi(u)?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u),Jh.add(l)}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=Ji[a.type||"text"];if(u?.render)u.render(h,r,l,a.meta),u.attachesListeners&&Jh.add(l);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Ji[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.valign&&(l.dataset.valign=a.valign),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}$f(t,o)}#D(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.#C,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("corner-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()}#z(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=wi(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=Ji[a.type||"text"];typeof c=="number"&&u?.render?(u.render(c,{},l,a.meta),u.attachesListeners&&Jh.add(l)):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}$f(n,o)}#X(t){let e=t.querySelector("pagination-ui");e||(t.innerHTML="",e=document.createElement("pagination-ui"),e.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(e));let i=this.#T,r=Math.min(this.#a,i-1);e.setAttribute("page",String(r+1)),e.setAttribute("total",String(i))}#Z(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=wi(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),n=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of r){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=n.has(o.toLowerCase()),l.addEventListener("change",()=>{let h=[...e.querySelectorAll("input[type=checkbox]:checked")].map(c=>c.value);h.length?this.setFilter(t.key,h.join(","),"select"):this.setFilter(t.key,null)}),a.appendChild(l),a.appendChild(document.createTextNode(` ${o}`)),e.appendChild(a)}}else if(t.filter==="number"){let r=document.createElement("input");r.type="number",r.placeholder="Filter...",r.value=i?.value??"",r.setAttribute("data-filter-input","");let n=document.createElement("select");n.setAttribute("data-filter-op","");for(let[a,l]of[["gte","\u2265"],["lte","\u2264"],["gt",">"],["lt","<"],["equals","="]]){let h=document.createElement("option");h.value=a,h.textContent=l,i?.op===a&&(h.selected=!0),n.appendChild(h)}let o=()=>{r.value?this.setFilter(t.key,r.value,n.value):this.setFilter(t.key,null)};r.addEventListener("input",o),n.addEventListener("change",o),e.appendChild(n),e.appendChild(r)}else{let r=document.createElement("input");r.type="text",r.placeholder=`Filter ${t.label||t.key}...`,r.value=i?.value??"",r.setAttribute("data-filter-input",""),r.addEventListener("input",()=>{r.value?this.setFilter(t.key,r.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(r)}if(i){let r=document.createElement("button");r.textContent="Clear",r.setAttribute("data-filter-clear",""),r.addEventListener("click",()=>{this.setFilter(t.key,null),this.#u=null,this.#w()}),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}#B(){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)}#N=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-column-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#j(t,e))};#q=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#u=this.#u===c?null:c,this.#w();return}this.#u&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#u=null,this.#w());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-column-resize-handle]");if(n&&this.contains(n)){this.#j(t,n);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#o.add(u);else this.#o.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#d>=0){let f=Math.min(this.#d,u),p=Math.max(this.#d,u);for(let m=f;m<=p;m++)d?this.#o.add(m):this.#o.delete(m)}else d?this.#o.add(u):this.#o.delete(u);this.#d=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(g=>g.key===d),m=p?wi(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}}))}}};#_=null;#j(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;e.setAttribute("data-resizing",""),this.#_={key:i,col:r,startX:a,startWidth:o,handle:e},document.addEventListener("pointermove",this.#F),document.addEventListener("pointerup",this.#U)}#F=t=>{if(!this.#_)return;let{key:e,col:i,startX:r,startWidth:n}=this.#_,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.#Q()};#U=t=>{if(!this.#_)return;let{key:e,handle:i}=this.#_;document.removeEventListener("pointermove",this.#F),document.removeEventListener("pointerup",this.#U),i.removeAttribute("data-resizing");let r=this.#l.get(e);this.#_=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:r}})),this.render()};#et(){document.removeEventListener("pointermove",this.#F),document.removeEventListener("pointerup",this.#U),this.#_=null}#G=t=>{let i=this.#C.length+(this.expandable?1:0)+(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.#Y())};#Y(){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.#C,i=this.#P(),r=e.map(c=>Kh(c.label||c.key)),n=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=wi(u,d);if(typeof d.format=="function")return Kh(d.format(f,u));let p=Ji[d.type||"text"];return p?.format?Kh(p.format(f,u,d.meta)):Kh(f)})}),o=[r.join(","),...n.map(c=>c.join(","))].join(`
|
|
214
|
+
`),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)}};M();w("table-ui",rn);R();var F$=200,W$=896,U$=640,Y$=416;function Pf(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 Qf(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}function Tf(s){let t=s.label;return typeof t=="string"&&t.trim()?t:s.key}var H$=50,pv=500;function mv(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 G$(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 K$(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(G$(s?.key))return"text";let e=[],i=Math.min(t?.length??0,pv),r=new Set;for(let n=0;n<i;n++){let o=mv(t[n],s);if(!(o==null||o==="")&&(e.push(o),r.add(String(o)),r.size>H$))return"text"}return e.length?"select":"text"}function J$(s,t){let e=new Set,i=Math.min(t?.length??0,pv);for(let r=0;r<i;r++){let n=mv(t[r],s);n==null||n===""||e.add(String(n))}return[...e].sort((r,n)=>r.localeCompare(n,void 0,{numeric:!0}))}var nn=class s extends k{static properties={for:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},rangeStart:{type:Number,default:0,reflect:!0,attribute:"range-start"},rangeEnd:{type:Number,default:0,reflect:!0,attribute:"range-end"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},pageSize:{type:Number,default:0,reflect:!0,attribute:"page-size"},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"},chromeOnly:{type:Boolean,default:!1,reflect:!0,attribute:"chrome-only"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0},stage:{type:String,default:"",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down","dots-three-vertical"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#r=null;#n=new Set;#a=[];#o=null;#l=null;#c=null;set pageSizeOptions(t){this.#a=Array.isArray(t)?t.map(Number).filter(e=>Number.isFinite(e)):[],this.#A()}get pageSizeOptions(){return this.#a}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(){if(this.setAttribute("role","toolbar"),this.hasAttribute("size")||this.setAttribute("size",this.size||"sm"),this.#u(),this.#a.length===0&&this.hasAttribute("page-size-options"))try{let t=JSON.parse(this.getAttribute("page-size-options"));Array.isArray(t)&&(this.pageSizeOptions=t)}catch{}this.#b(),this.#f(),this.#w(),this.#l=this.clientWidth||null,this.#d(),typeof ResizeObserver<"u"&&(this.#o=new ResizeObserver(t=>{let{inlineSize:e}=t[0].contentBoxSize[0];this.#l=e,!this.#c&&(this.#c=requestAnimationFrame(()=>{this.#c=null,this.#d()}))}),this.#o.observe(this))}updated(t){(t.has("noFilter")||t.has("noSort")||t.has("noColumns")||t.has("noSearch")||t.has("chromeOnly"))&&this.#$(),t.has("placeholder")&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#x(),t==="stage"&&this.#d()}disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null);for(let t of this.#n)cancelAnimationFrame(t);this.#n.clear(),this.#Q(),this.#m(),this.#c!=null&&(cancelAnimationFrame(this.#c),this.#c=null),this.#o?.disconnect(),this.#o=null}#h(t){let e=getComputedStyle(this),i=(a,l)=>{let h=Sf(a);return Number.isFinite(h)?h:l},r=i(e.getPropertyValue("--table-toolbar-bp-search-tight"),W$),n=i(e.getPropertyValue("--table-toolbar-bp-icon-only"),U$),o=i(e.getPropertyValue("--table-toolbar-bp-overflow"),Y$);return t<=o?"overflow":t<=n?"icon-only":t<=r?"search-tight":"full"}#d(){let t=this.stage||(this.#l==null?"full":this.#h(this.#l));this.getAttribute("data-stage-resolved")!==t&&this.setAttribute("data-stage-resolved",t)}render(){this.#f(),this.#w(),this.#S(),this.#x(),this.#A()}#u(){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.`)}#f(){let t=this.#p();if(t===this.#t||(this.#m(),!t))return;this.#t=t;let e=()=>this.#L(),i=()=>this.#R();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#p(){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}#m(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#g(){return this.size||"sm"}#b(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-scope","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="scope"&&e.appendChild(m);let i=document.createElement("div");i.setAttribute("data-title","");let r=document.createElement("span");r.setAttribute("data-heading",""),i.appendChild(r);let n=document.createElement("badge-ui");n.setAttribute("data-toolbar-count-badge",""),n.setAttribute("tone","muted"),n.hidden=!0,i.appendChild(n);let o=document.createElement("div");o.setAttribute("data-summary",""),o.hidden=!0;let a=document.createElement("span");a.setAttribute("data-summary-text",""),o.appendChild(a);let l=document.createElement("span");l.setAttribute("data-summary-compact",""),l.hidden=!0,o.appendChild(l);let h=document.createElement("div");h.setAttribute("data-summary-empty",""),h.hidden=!0;for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="empty"&&h.appendChild(m);o.appendChild(h);let c=document.createElement("div");c.setAttribute("data-controls",""),c.appendChild(this.#y("filter","Filter","funnel-simple")),c.appendChild(this.#y("sort","Sort","arrows-down-up")),c.appendChild(this.#y("columns","Columns","columns")),c.appendChild(this.#v());let u=document.createElement("search-ui");u.setAttribute("data-search",""),u.setAttribute("placeholder",this.placeholder),u.setAttribute("debounce",String(F$)),u.addEventListener("search",this.#k);let d=document.createElement("select-ui");d.setAttribute("data-page-size",""),d.setAttribute("aria-label","Rows per page"),d.hidden=!0,d.addEventListener("change",this.#E);let f=document.createElement("div");f.setAttribute("data-actions-leading","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="actions-leading"&&f.appendChild(m);let p=document.createElement("div");p.setAttribute("data-actions","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="actions"&&p.appendChild(m);t.appendChild(e),t.appendChild(i),t.appendChild(o),t.appendChild(c),t.appendChild(u),t.appendChild(f),t.appendChild(d),t.appendChild(p),this.appendChild(t),this.#S(),this.#x(),this.#$(),this.#A()}#O(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",this.#g()),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#y(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("aria-haspopup","menu"),r.setAttribute("title",e),r.addEventListener("click",n=>{n.stopPropagation(),this.#C(t,r)}),r}#v(){let t=document.createElement("menu-ui");t.setAttribute("data-toolbar-overflow","");let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("icon","dots-three-vertical"),e.setAttribute("variant","outline"),e.setAttribute("aria-label","More table actions"),e.setAttribute("aria-haspopup","menu"),t.appendChild(e);for(let[i,r,n]of[["filter","Filter","funnel-simple"],["sort","Sort","arrows-down-up"],["columns","Columns","columns"]]){let o=document.createElement("menu-item-ui");o.setAttribute("icon",n),o.setAttribute("text",r),o.setAttribute("value",i),t.appendChild(o)}return t.addEventListener("action",i=>{this.#C(i.detail.value,e)}),t}#S(){let t=this.querySelector(":scope [data-heading]");t&&(this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0);let e=this.querySelector(":scope [data-toolbar-count-badge]");if(e){let r=this.count?.toString().trim(),n=this.#t?.data?.length,o=r||(Number.isFinite(n)?String(n):"");o?(e.setAttribute("text",o),e.hidden=!1):e.hidden=!0}let i=this.querySelector(":scope > [data-toolbar] > [data-title]");i&&(i.hidden=Array.from(i.children).every(r=>r.hidden))}#x(){let t=this.querySelector(":scope > [data-toolbar] > [data-summary]");if(!t)return;let e=t.querySelector(":scope > [data-summary-text]"),i=t.querySelector(":scope > [data-summary-compact]"),r=t.querySelector(":scope > [data-summary-empty]"),n=Number(this.rangeStart)||0,o=Number(this.rangeEnd)||0,a=Number(this.rangeTotal)||0;if(n>0&&o>0&&a>0){e&&(e.textContent=`Showing ${n}\u2013${o} of ${a}`),e&&(e.hidden=!1),i&&(i.textContent=`${n}\u2013${o}/${a}`),i&&(i.hidden=!1),r&&(r.hidden=!0),t.hidden=!1;return}let l=this.hasAttribute("range-total")&&this.getAttribute("range-total")==="0",h=!!r&&r.childNodes.length>0;if(l&&h){e&&(e.hidden=!0),i&&(i.hidden=!0),r.hidden=!1,t.hidden=!1;return}e&&(e.hidden=!0),i&&(i.hidden=!0),r&&(r.hidden=!0),t.hidden=!0}#A(){let t=this.querySelector(":scope > [data-toolbar] > [data-page-size]");if(!t)return;let e=this.#a;if(!e.length){t.hidden=!0;return}t.hidden=!1;let i=e.map(o=>({value:String(o),label:`${o} / page`}));t.options=i;let r=Number(this.pageSize)||0,n=e.includes(r)?r:e[0];t.value=String(n)}#E=t=>{let e=Number(t.detail?.value??this.querySelector(":scope [data-page-size]")?.value)||0;this.pageSize=e,this.#t&&this.#t.dispatchEvent(new CustomEvent("toolbar-paginate",{bubbles:!0,detail:{pageSize:e}})),this.dispatchEvent(new CustomEvent("page-size-change",{bubbles:!0,detail:{pageSize:e}}))};#$(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=this.chromeOnly,i=(l,h)=>{let c=t.querySelector(l);c&&(c.hidden=h)},r=e||this.noFilter,n=e||this.noSort,o=e||this.noColumns;i('[data-toolbar-btn="filter"]',r),i('[data-toolbar-btn="sort"]',n),i('[data-toolbar-btn="columns"]',o),i("[data-search]",e||this.noSearch);let a=t.querySelector("[data-toolbar-overflow]");if(a){let l={filter:r,sort:n,columns:o};for(let h of a.querySelectorAll("menu-item-ui"))h.hidden=!!l[h.getAttribute("value")];a.hidden=r&&n&&o}}#k=t=>{let e=t.detail?.value??"";this.#t&&this.#t.dispatchEvent(new CustomEvent("toolbar-search",{bubbles:!0,detail:{value:e}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#w(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#S()}#C(t,e){if(this.#i?.kind===t){this.#Q();return}this.#Q();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#T(i),t==="sort"&&this.#I(i),t==="columns"&&this.#D(i),document.body.appendChild(i);try{i.showPopover()}catch{}let r=Ot(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.#P,!0),document.addEventListener("keydown",this.#M,!0))}))}#Q(){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.#P,!0),document.removeEventListener("keydown",this.#M,!0))}}#P=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#Q())};#M=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#Q(),this.#i?.btn?.focus?.({preventScroll:!0}))};#T(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Pf("No filterable columns"));return}let i=e.filters||{};t.appendChild(Qf("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",Tf(o));let l=K$(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=J$(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||"";e.dispatchEvent(new CustomEvent("toolbar-filter-set",{bubbles:!0,detail:{key:o.key,value:d||null,op:"select"}})),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",this.#g()),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;e.dispatchEvent(new CustomEvent("toolbar-filter-set",{bubbles:!0,detail:{key:o.key,value:u||null,op:"contains"}})),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.#O("Clear all filters",()=>{e.dispatchEvent(new CustomEvent("toolbar-filter-clear",{bubbles:!0})),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#R()});t.appendChild(o)}}#R(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#T(t.panel))}#I(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Pf("No sortable columns"));return}t.appendChild(Qf("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",Tf(o)),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.#L()}),n.appendChild(l)}if(t.appendChild(n),i.length){let o=this.#O("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.#L()});t.appendChild(o)}}#L(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#I(t.panel))}#D(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Pf("No columns"));return}t.appendChild(Qf("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",Tf(r));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.dispatchEvent(new CustomEvent("toolbar-columns-set",{bubbles:!0,detail:{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)}};M();w("table-toolbar-ui",nn);R();var on=class extends k{static properties={for:{type:String,default:"",reflect:!0},page:{type:Number,default:1,reflect:!0},pageSize:{type:Number,default:0,reflect:!0,attribute:"page-size"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},siblings:{type:Number,default:1,reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;#t=null;connected(){this.#e()}render(){this.#s(),this.#l()}disconnected(){this.#n()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#l()}#e(){if(this.querySelector(":scope > [data-row]"))return;let t=document.createElement("div");t.setAttribute("data-row","");let e=document.createElement("div");e.setAttribute("data-range",""),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true");let i=document.createElement("span");i.setAttribute("data-range-text",""),e.appendChild(i);let r=document.createElement("div");r.setAttribute("data-range-empty",""),r.hidden=!0;for(let a of[...this.children])a!==t&&a.getAttribute?.("slot")==="empty"&&r.appendChild(a);e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-pager","");let o=document.createElement("pagination-ui");o.setAttribute("data-footer-pager",""),o.addEventListener("page-change",this.#i),n.appendChild(o),t.appendChild(e),t.appendChild(n),this.appendChild(t)}#i=t=>{t.stopPropagation();let e=Number(t.detail?.page);Number.isFinite(e)&&(this.hasAttribute("range-total")||(this.page=e),this.#t&&this.#t.dispatchEvent(new CustomEvent("footer-page",{bubbles:!0,composed:!0,detail:{page:e}})),this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,detail:{page:e}})))};#s(){let t=this.#r();t!==this.#t&&(this.#n(),t&&(this.#t=t,t.addEventListener("page",this.#a),t.addEventListener("filter-change",this.#o),t.addEventListener("sort",this.#o)))}#r(){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}#n(){this.#t&&(this.#t.removeEventListener("page",this.#a),this.#t.removeEventListener("filter-change",this.#o),this.#t.removeEventListener("sort",this.#o)),this.#t=null}#a=t=>{let e=Number(t.detail?.page);Number.isFinite(e)&&(this.page=e+1)};#o=()=>{this.#l()};#l(){let t=this.querySelector(":scope > [data-row]");if(!t)return;let e=t.querySelector(":scope > [data-range]"),i=e?.querySelector(":scope > [data-range-text]"),r=e?.querySelector(":scope > [data-range-empty]"),n=t.querySelector(":scope > [data-pager]"),o=n?.querySelector(":scope > pagination-ui"),a=this.#t,l=!!a&&a.hasAttribute("range-total"),h=!!a&&!l&&Number(a.paginate)>0,c=this.hasAttribute("range-total"),u=this.hasAttribute("page-size"),d=c||l||h,f=S=>{let v=Number(S);return Number.isFinite(v)&&v>0?Math.trunc(v):0},p=c?f(this.rangeTotal):l?f(a.rangeTotal):h&&Number(a.filteredCount)||0,m=u?Number(this.pageSize)||0:l||h?Number(a.paginate)||0:Number(this.pageSize)||0;if(!e)return;if(!d){e.hidden=!0,n&&(n.hidden=!0);return}if(e.hidden=!1,p===0){let S=!!r&&r.childNodes.length>0;i&&(i.hidden=!0),r&&(r.hidden=!S),n&&(n.hidden=!0);return}if(r&&(r.hidden=!0),m<=0){i&&(i.hidden=!1,i.textContent=`${p} items`),n&&(n.hidden=!0);return}let g=Math.max(1,Math.ceil(p/m)),b=Math.max(1,Math.min(Number(this.page)||1,g)),A=(b-1)*m+1,x=Math.min(b*m,p);i&&(i.hidden=!1,i.textContent=`Showing ${A}\u2013${x} of ${p}`),n&&(n.hidden=g<=1),o&&(o.setAttribute("page",String(b)),o.setAttribute("total",String(g)),o.setAttribute("siblings",String(Math.max(0,Number(this.siblings)||0))),o.setAttribute("size",this.size||"md"))}};M();w("table-footer-ui",on);R();var an=class extends k{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","")}},ln=class extends k{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()}#i(t){return t.dataset.timelineItemStamped="1",t}#s(t){return t?.dataset?.timelineItemStamped==="1"}connected(){for(let t of["label","description","time"]){if(ct(this,t).length)continue;let e=this.#i(document.createElement("span"));e.setAttribute("slot",t),this.appendChild(e)}}render(){let t=this.querySelector(':scope > [slot="label"]'),e=this.querySelector(':scope > [slot="description"]'),i=this.querySelector(':scope > [slot="time"]');this.#s(t)&&(t.textContent=this.text),this.#s(e)&&(e.textContent=this.description),this.#s(i)&&(i.textContent=this.duration||this.time);let r=this.querySelector(':scope > [slot="icon"]');if(this.icon)if(r)this.#s(r)&&r.setAttribute("name",this.icon);else{let o=this.#i(document.createElement("icon-ui"));o.setAttribute("slot","icon"),o.setAttribute("name",this.icon),this.prepend(o)}else this.#s(r)&&r.remove();let n=this.querySelector(':scope > [slot="outcomes"]');if(this.#t.length>0){n||(n=document.createElement("ul"),n.setAttribute("slot","outcomes"),this.appendChild(n)),n.innerHTML="";for(let a of this.#t){let l=document.createElement("li");l.textContent=a,n.appendChild(l)}n.hidden=!this.#e;let o=this.querySelector(":scope > [data-timeline-toggle]");o||(o=document.createElement("button-ui"),o.setAttribute("variant","ghost"),o.setAttribute("size","xs"),o.setAttribute("data-timeline-toggle",""),o.setAttribute("aria-label","Toggle details"),o.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(o)),o.setAttribute("icon",this.#e?"caret-down":"caret-right")}else this.querySelector(":scope > [data-timeline-toggle]")?.remove(),n?.remove()}};M();w("timeline-ui",an),w("timeline-item-ui",ln);R();function hn(s){return s.disabled||s.hasAttribute("disabled")}var cn=class extends k{static properties={step:{type:Number,default:0,reflect:!0},orientation:{type:String,default:"horizontal",reflect:!0},interactive:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=()=>this.render();#e=null;connected(){this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#a),!this.#e&&typeof MutationObserver<"u"&&(this.#e=new MutationObserver(this.#t),this.#e.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled"]}))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#a),this.#e?.disconnect(),this.#e=null}render(){let t=[...this.querySelectorAll("stepper-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];if(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"),this.interactive?(i.setAttribute("role","button"),r===this.step?i.setAttribute("aria-current","step"):i.removeAttribute("aria-current")):(i.removeAttribute("role"),i.removeAttribute("tabindex"),i.removeAttribute("aria-current"),i.removeAttribute("aria-disabled"))}),this.interactive){let i=t.filter(o=>!hn(o)),r=t[this.step],n=r&&!hn(r)?r:i[0];for(let o of t)hn(o)?(o.setAttribute("aria-disabled","true"),o.removeAttribute("tabindex")):(o.removeAttribute("aria-disabled"),o.setAttribute("tabindex",o===n?"0":"-1"))}}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))}get#i(){return[...this.querySelectorAll("stepper-item-ui")]}get#s(){return this.#i.filter(t=>!hn(t))}#r(t){let e=this.#i,i=e.length-1,r=Math.max(0,Math.min(t,i));if(r===this.step||e[r]&&hn(e[r]))return!1;let n=this.step;return this.dispatchEvent(new CustomEvent("step-request",{bubbles:!0,cancelable:!0,detail:{step:r,previous:n}}))?(this.step=r,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{step:this.step}})),!0):!1}#n=t=>{if(!this.interactive)return;let e=t.target.closest("stepper-item-ui");if(!e||!this.contains(e)||hn(e))return;let i=this.#i.indexOf(e);i<0||this.#r(i)};#a=t=>{if(!this.interactive)return;let e=t.target.closest("stepper-item-ui");if(!e||!this.contains(e))return;let i=this.#s,r=i.indexOf(e);if(r<0)return;let n=this.orientation==="vertical",o=n?"ArrowDown":"ArrowRight",a=n?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=r<i.length-1?r+1:0;break;case a:l=r>0?r-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;case"Enter":case" ":t.preventDefault(),this.#r(this.#i.indexOf(e));return;default:return}t.preventDefault();let h=i[l];this.#r(this.#i.indexOf(h))&&h.focus()}},un=class extends k{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},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t(t){return t.dataset.stepperItemStamped="1",t}#e(t){return t?.dataset?.stepperItemStamped==="1"}connected(){for(let t of["label","description"]){if(this.querySelector(`[slot="${t}"]`))continue;let e=this.#t(document.createElement("span"));e.setAttribute("slot",t),this.appendChild(e)}}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');this.#e(t)&&(t.textContent=this.text),this.#e(e)&&(e.textContent=this.description);let i=this.querySelector('[slot="icon"]');if(this.icon)if(i)this.#e(i)&&i.setAttribute("name",this.icon);else{let r=this.#t(document.createElement("icon-ui"));r.setAttribute("slot","icon"),r.setAttribute("name",this.icon),this.prepend(r)}else this.#e(i)&&i.remove()}};M();w("stepper-ui",cn),w("stepper-item-ui",un);R();var dn=class extends k{static requiredIcons=["caret-left","caret-right"];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.#x),this.addEventListener("pointerleave",this.#A),this.addEventListener("focusin",this.#E),this.addEventListener("focusout",this.#$)),this.addEventListener("keydown",this.#k),this.#t.addEventListener("pointerdown",this.#C),this.#t.addEventListener("pointermove",this.#Q),this.#t.addEventListener("pointerup",this.#P),this.#t.addEventListener("pointercancel",this.#P),this.#t.addEventListener("click",this.#M,!0),this.#t.addEventListener("dragstart",this.#T)),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.#x),this.removeEventListener("pointerleave",this.#A),this.removeEventListener("focusin",this.#E),this.removeEventListener("focusout",this.#$),this.removeEventListener("keydown",this.#k),this.#t&&(this.#t.removeEventListener("pointerdown",this.#C),this.#t.removeEventListener("pointermove",this.#Q),this.#t.removeEventListener("pointerup",this.#P),this.#t.removeEventListener("pointercancel",this.#P),this.#t.removeEventListener("click",this.#M,!0),this.#t.removeEventListener("dragstart",this.#T)),this.#o=null,this.#t=null,this.#n=!1}next(){let t=this.#d()-1,e=this.#m(this.#r),i=Math.min(e+1,t);if(i!==e||this.loop){let r=this.loop&&i===e?0:i;this.goTo(this.#p(r))}}prev(){let t=this.#d()-1,e=this.#m(this.#r),i=Math.max(e-1,0);if(i!==e||this.loop){let r=this.loop&&i===e?t:i;this.goTo(this.#p(r))}}goTo(t){let e=this.slides[t];if(!e||!this.#t)return;let i=Math.max(0,this.#u(e));this.#t.scrollTo({left:i,behavior:"smooth"})}play(){this.pause(),!(typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: reduce)").matches)&&(this.#e=setInterval(()=>{let t=this.#d()-1,i=this.#m(this.#r)>=t;i&&this.loop?this.goTo(this.#p(0)):i?this.pause():this.next()},this.interval||5e3))}pause(){this.#e&&(clearInterval(this.#e),this.#e=null)}#l(){let t=this.slides;t.forEach((e,i)=>{e.setAttribute("role","group"),e.setAttribute("aria-roledescription","slide"),e.getAttribute("aria-label")||e.setAttribute("aria-label",`${i+1} of ${t.length}`)})}#c(){this.#s=()=>{let t=this.#f();t!==this.#r&&(this.#r=t,this.#S(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{index:t,slide:this.slides[t]}})))},this.#t.addEventListener("scroll",this.#s,{passive:!0}),this.#r=this.#f()}#h(){if(!this.#t)return 1;let e=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").trim(),i=parseInt(e,10);return Number.isFinite(i)&&i>0?i:1}#d(){let t=this.slides.length;return t===0?0:this.snap==="center"?t:Math.max(1,t-this.#h()+1)}#u(t){let e=this.#t.clientWidth,i=t.offsetLeft-this.#t.offsetLeft,r=t.offsetWidth;return this.snap==="center"?i+r/2-e/2:this.snap==="end"?i+r-e:i}#f(){if(!this.#t)return 0;let t=this.slides;if(t.length===0)return 0;let e=this.#t.scrollLeft,i=Math.max(0,this.#t.scrollWidth-this.#t.clientWidth),r=0,n=1/0;for(let o=0;o<t.length;o++){let a=Math.max(0,Math.min(i,this.#u(t[o]))),l=Math.abs(e-a);l<n&&(n=l,r=o)}return r}#p(t){if(this.snap!=="end")return t;let e=this.#h();return Math.min(this.slides.length-1,t+e-1)}#m(t){if(this.snap!=="end")return t;let e=this.#h();return Math.max(0,t-e+1)}#g(){this.#a||(this.#a=!0,this.chrome==="toolbar"?this.#O():this.#b(),this.#v(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#v()),this.#i.observe(this)))}#b(){let t=document.createElement("button-ui");t.setAttribute("data-swiper-btn",""),t.setAttribute("data-swiper-prev",""),t.setAttribute("icon","caret-left"),t.setAttribute("variant","ghost"),t.setAttribute("aria-label","Previous slide"),t.addEventListener("press",()=>this.prev());let e=document.createElement("button-ui");e.setAttribute("data-swiper-btn",""),e.setAttribute("data-swiper-next",""),e.setAttribute("icon","caret-right"),e.setAttribute("variant","ghost"),e.setAttribute("aria-label","Next slide"),e.addEventListener("press",()=>this.next()),this.appendChild(t),this.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-dots",""),i.setAttribute("role","tablist"),i.setAttribute("aria-label","Slide indicators"),this.appendChild(i)}#O(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let r=document.createElement("button-ui");r.setAttribute("icon","caret-left"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Previous slide"),r.addEventListener("press",()=>this.prev());let n=document.createElement("button-ui");n.setAttribute("icon","caret-right"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Next slide"),n.addEventListener("press",()=>this.next()),i.appendChild(r),i.appendChild(n),t.appendChild(i),this.insertBefore(t,this.#t);let o=document.createElement("div");o.setAttribute("data-swiper-foot","");let a=document.createElement("span");a.setAttribute("data-swiper-counter",""),o.appendChild(a);let l=document.createElement("div");l.setAttribute("data-swiper-dots",""),l.setAttribute("role","tablist"),l.setAttribute("aria-label","Slide indicators"),o.appendChild(l),this.appendChild(o),this.#y()}#y(){let t=this.querySelector("[data-swiper-counter]");if(!t)return;if(!this.counter){t.textContent="";return}let e=this.#m(this.#r)+1,i=this.#d();t.textContent=`${e} / ${i}`}#v(){let t=this.querySelector("[data-swiper-dots]");if(!t)return;let e=this.#d();if(t.children.length!==e){for(;t.firstChild;)t.removeChild(t.firstChild);for(let i=0;i<e;i++){let r=document.createElement("button-ui");r.setAttribute("variant","ghost"),r.setAttribute("role","tab"),r.setAttribute("aria-label",`Page ${i+1}`),r.addEventListener("click",()=>this.goTo(this.#p(i))),t.appendChild(r)}}this.#S()}#S(){if(!this.#a)return;let t=this.querySelector("[data-swiper-dots]");if(t){let e=this.#d()-1,i=Math.min(Math.max(this.#m(this.#r),0),e);[...t.children].forEach((r,n)=>{r.setAttribute("aria-current",n===i?"true":"false")})}this.#y()}#x=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#A=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#E=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#$=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#k=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#w=5;#C=t=>{t.pointerType!=="touch"&&t.button===0&&(t.target.closest("button, button-ui, a, input, select, textarea")||(this.#o={pointerId:t.pointerId,startX:t.clientX,startScrollLeft:this.#t.scrollLeft,hasMoved:!1},this.#t.style.scrollBehavior="auto",this.#t.setAttribute("data-dragging","")))};#Q=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=t.clientX-this.#o.startX;if(Math.abs(e)>=this.#w){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")))};#M=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#T=t=>{this.#o&&t.preventDefault()}};M();w("swiper-ui",dn);var fn=class extends X{static labelDeprecated=!1;static requiredIcons=["upload-simple"];static properties={...X.properties,label:{type:String,default:"",reflect:!0},accept:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},compact:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;connected(){super.connected(),this.querySelector("[data-dropzone]")||(this.innerHTML=`
|
|
215
215
|
<div data-dropzone tabindex="0" role="button"><icon-ui data-upload-icon name="upload-simple"></icon-ui><span data-upload-text>Drop files here or click to browse</span></div>
|
|
216
216
|
<span hint="${this.hint||""}"></span>
|
|
217
217
|
<div data-filelist></div>
|
|
@@ -231,9 +231,9 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
231
231
|
<path data-wordmark-glyph fill-rule="evenodd" clip-rule="evenodd" d="M267.953 4.72882H299.978V178.524H267.953V163.876C258.519 175.959 245.113 182 227.735 182C211.019 182 196.703 175.71 184.786 163.131C173.035 150.386 167.16 134.827 167.16 116.454C167.16 98.0817 173.035 82.6057 184.786 70.0262C196.703 57.2812 211.019 50.9087 227.735 50.9087C245.113 50.9087 258.519 56.9502 267.953 69.0331V4.72882ZM208.867 141.779C215.488 148.234 223.763 151.462 233.693 151.462C243.623 151.462 251.816 148.234 258.271 141.779C264.725 135.158 267.953 126.717 267.953 116.454C267.953 106.192 264.725 97.8334 258.271 91.3782C251.816 84.7574 243.623 81.447 233.693 81.447C223.763 81.447 215.488 84.7574 208.867 91.3782C202.413 97.8334 199.185 106.192 199.185 116.454C199.185 126.717 202.413 135.158 208.867 141.779Z"></path>
|
|
232
232
|
<path data-wordmark-glyph fill-rule="evenodd" clip-rule="evenodd" d="M116.681 147.241L127.108 178.524H164.347L103.275 4.72882H60.8231L0 178.524H36.9904L47.4172 147.241H116.681ZM82.1733 44.2052L106.006 115.213H58.3406L82.1733 44.2052Z"></path>
|
|
233
233
|
</svg>
|
|
234
|
-
`;connected(){this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Adia")}};M();w("adia-wordmark-ui",yn);R();var vn=class extends k{static properties={value:{type:Number,default:null,reflect:!0},label:{type:String,default:"",reflect:!0},meta:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=void 0;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.#i=this.querySelector(':scope > [slot="label"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","label"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="meta"]'),this.#s||(this.#s=document.createElement("span"),this.#s.setAttribute("slot","meta"),this.appendChild(this.#s)),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}%`),this.#i&&(this.#i.textContent=this.label,this.#i.hidden=!this.label),this.#s&&(this.label?this.meta?(this.#s.textContent=this.meta,this.#s.hidden=!1):this.#s.hidden=!this.#s.hasChildNodes():this.#s.hidden=!0);let i=this.label?this.meta?`${this.label}, ${this.meta}`:this.label:"";this.#r=Zt(this,this.#r,i)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};M();w("progress-ui",vn);R();var xn=class extends k{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"),!ct(this,"caption").length&&!ct(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=ct(this,"caption")[0],this.#e=ct(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}};M();w("step-progress-ui",xn);R();var Sn=class extends k{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},cornerRadius:{type:String,default:"sm",reflect:!0,attribute:"corner-radius"},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}};M();w("skeleton-ui",Sn);R();var wn=class extends k{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())}};M();w("spinner-ui",wn);R();var An=class extends k{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)}};M();w("loading-overlay-ui",An);R();var gv=new Set;function bv(s,t){gv.has(s)||(gv.add(s),console.warn(`[alert-ui] ${t}`))}var kn=class s extends k{static requiredIcons=["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"&&(bv("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger]. 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")&&(bv("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()}};M();w("alert-ui",kn);R();var tP={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},En=class extends k{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||tP[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()}};M();w("inline-message-ui",En);R();var Cn=class extends k{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};M();w("kbd-ui",Cn);R();var $n=class extends k{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-ui slot="dismiss" variant="ghost" size="sm" aria-label="Remove"><icon-ui slot="icon" name="x" weight="bold" size="0.75rem"></icon-ui></button-ui>'};static template=()=>null;#t=void 0;#e(){this.#t=Zt(this,this.#t,this.text||"")}#i=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#s=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.#i),this.addEventListener("keydown",this.#s)}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}render(){if(this.#e(),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")}};M();w("tag-ui",$n);R();var eP=new Set(["block","dot","square","line","dashed"]),iP=new Set(["sm","md","lg"]),sP=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),rP={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},nP={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function oP(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&sP.has(t)):[]}var ks=null;function aP(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!ks){let u=document.createElement("canvas");u.width=1,u.height=1,ks=u.getContext("2d")}ks.fillStyle="#000",ks.clearRect(0,0,1,1),ks.fillStyle=s,ks.fillRect(0,0,1,1);let[t,e,i]=ks.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 Pn=class extends k{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,attribute:"auto-contrast"},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;connected(){this.#u(),this.#y(),typeof MutationObserver<"u"&&(this.#d=new MutationObserver(t=>{let e=!1;for(let i of t){for(let r of i.addedNodes)if(r.nodeType===1){if(r.getAttribute?.("slot")==="chrome"){e=!0;break}if(r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#d.takeRecords())}),this.#d.observe(this,{childList:!0}))}render(){this.#u(),this.#p(),this.#m(),this.#b(),this.#O(),this.#v(),this.#g()}#u(){if(this.#n)return;let t=Array.from(this.children).filter(n=>n.getAttribute&&n.getAttribute("slot")==="chrome");for(let n of t)n.remove();let e=Array.from(this.children).filter(n=>n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]'));for(let n of e)n.remove();let i=[];for(let n of Array.from(this.childNodes))(n.nodeType===3&&!n.data||n.nodeType===8)&&i.push(n);for(let n of i)n.remove();let r=Array.from(this.childNodes).filter(n=>!(n.nodeType===1&&n.dataset&&(n.dataset.tile!==void 0||n.dataset.label!==void 0||n.dataset.detail!==void 0||n.dataset.badge!==void 0||n.dataset.copy!==void 0))&&!(n.nodeType===3&&!n.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let n of t)this.appendChild(n);for(let n of e)this.appendChild(n);for(let n of i)this.appendChild(n);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),r.length)for(let n of r)this.#e.appendChild(n);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#r=document.createElement("button-ui"),this.#r.setAttribute("data-copy",""),this.#r.setAttribute("variant","ghost"),this.#r.setAttribute("size","xs"),this.#r.setAttribute("aria-label","Copy value"),this.#r.setAttribute("hidden",""),this.#r.setAttribute("text","\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=eP.has(this.shape)?this.shape:"square",e=iP.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=oP(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",nP[n]),o.textContent=rP[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=aP(t);if(e==null){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark");return}let i=e<.62;this.#e.toggleAttribute("data-on-dark",i),this.#e.toggleAttribute("data-on-light",!i)}#b(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#O(){if(!this.#r)return;if(!this.copyable){this.#r.setAttribute("hidden","");return}this.#r.removeAttribute("hidden");let t=this.#x();t?this.#r.setAttribute("aria-label",`Copy ${t}`):this.#r.setAttribute("aria-label","Copy value")}#v(){this.selectable?(this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.setAttribute("aria-pressed",this.selected?"true":"false")):(this.getAttribute("role")==="button"&&this.removeAttribute("role"),this.getAttribute("tabindex")==="0"&&this.removeAttribute("tabindex"),this.removeAttribute("aria-pressed"))}#y(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#r)||this.#S()},this.#l=t=>{!this.selectable||t.key!=="Enter"&&t.key!==" "||(t.composedPath?t.composedPath():[t.target]).includes(this.#r)||(t.preventDefault(),this.#S())},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#x();e&&this.#A(e)},this.#r.addEventListener("click",this.#c)}#S(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#x(){return this.copyValue?this.copyValue:this.color?this.color:""}async#A(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#C(e)}#C(t){this.#r&&(this.#h!=null&&clearTimeout(this.#h),this.#r.setAttribute("data-copy-state",t?"ok":"fail"),this.#r.setAttribute("text",t?"\u2713":"\u26A0"),this.#h=setTimeout(()=>{this.#r&&(this.#r.removeAttribute("data-copy-state"),this.#r.setAttribute("text","\u29C9"),this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#d&&(this.#d.disconnect(),this.#d=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#r&&this.#c&&this.#r.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=!1}};M();w("swatch-ui",Pn);Lt();var Ov={xs:0,sm:480,md:768,lg:1024,xl:1280},Es=Object.keys(Ov),Lf=Object.values(Ov);function yv(){let s=typeof window<"u"?window.innerWidth:void 0;if(typeof s!="number")return"lg";for(let t=Es.length-1;t>=0;t--)if(s>=Lf[t])return Es[t];return"xs"}var Re=ei(yv());if(typeof window<"u"&&typeof window.matchMedia=="function")for(let s=1;s<Lf.length;s++)window.matchMedia(`(min-width: ${Lf[s]}px)`).addEventListener("change",()=>{Re.value=yv()});function jt(s,t=Re.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=Es.indexOf(t),n=null,o=-1;for(let[a,l]of i){let h=Es.indexOf(a);h!==-1&&h<=r&&h>o&&(n=l,o=h)}return n??e}R();var Qn=class extends k{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("@")?Re.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",cP(jt(t,n))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=jt(e,n);this.style.setProperty("--col-align",uP(o)),this.style.textAlign=dP(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",fP(jt(i,n))):this.style.removeProperty("--col-justify")}},lP={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},hP={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function cP(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function uP(s){return lP[s]??s}function dP(s){return{start:"start",center:"center",end:"end"}[s]??""}function fP(s){return hP[s]??s}M();w("col-ui",Qn);R();var Tn=class s extends k{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.#O(e);i&&(t.preventDefault(),i.focus())};connected(){this.#d(),this.#u(),this.#f(),this.#p(),this.#c(),this.#t?.addEventListener("click",this.#n),typeof MutationObserver<"u"&&(this.#r=new MutationObserver(()=>{this.#p(),this.#c(),this.#m(),this.#a()}),this.#r.observe(this,{childList:!0})),this.#a()}disconnected(){this.#r?.disconnect(),this.#r=null,this.#h(),this.#t?.removeEventListener("click",this.#n),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#a(),this.#m()}#a(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#o=()=>{this.#a(),this.#m()};#l=null;#c(){let t=this.#g();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#d(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#u(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#x("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#f(){if(this.#s=this.querySelector(":scope > [data-field-error]"),this.#s)return;let t=document.createElement("div");t.setAttribute("slot","error"),t.setAttribute("data-field-error",""),t.setAttribute("id",s.#x("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#p(){if(!this.#t)return;let t=this.#g();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#y()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#g();if(!t)return;let e=new Set;this.#i&&!this.#i.hidden&&e.add(this.#i.id),this.#s&&!this.#s.hidden&&e.add(this.#s.id);let r=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(n=>n&&!n.startsWith("field-hint-")&&!n.startsWith("field-err-")),...e].join(" ").trim();r?t.setAttribute("aria-describedby",r):t.removeAttribute("aria-describedby")}#g(){let t=null,e=null;for(let i of this.children)if(!i.hasAttribute("slot")){if(t===null&&(t=i),s.#b.has(i.localName))return i;e===null&&this.#O(i)&&(e=i)}return e??t}static#b=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","date-range-picker-ui","calendar-picker-ui","color-area-ui","upload-ui","rating-ui","segmented-ui","input","textarea","select"]);#O(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#v=0;static#y(){return`field-ctl-${++s.#v}`}static#S=0;static#x(t){return`field-${t}-${++s.#S}`}};M();w("field-ui",Tn);R();var Ln=class extends k{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),typeof MutationObserver<"u"&&(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}};M();w("fields-ui",Ln);R();M();var vv=0,tl=class extends k{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-${++vv}`),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-${++vv}`,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}};w("display-field-ui",tl);R();var Mn=class extends k{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(pn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(pn),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?Re.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",gP(jt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",bP(jt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",OP(jt(i,o))):this.style.removeProperty("--row-justify"),r){let a=Es.indexOf(o),l=Es.indexOf(r);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},pP={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},mP={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function gP(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function bP(s){return pP[s]??s}function OP(s){return mP[s]??s}M();w("row-ui",Mn);R();var Rn=class extends k{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=Re.value,e=this.columns;if(e?.includes("@")){let r=jt(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=jt(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})`}};M();w("grid-ui",Rn);R();var In=class extends k{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};M();w("stack-ui",In);R();var Dn=class extends k{static properties={};static template=()=>null};M();w("frame-ui",Dn);R();function ts(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 xv(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 ft(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ue(s,t){let e=String(s);return e.length>t?e.slice(0,Math.max(1,t-1))+"\u2026":e}function ht({label:s,value:t,pct:e,series:i}){let r="";return s!=null&&(r+=` data-tip-label="${ft(String(s))}"`),t!=null&&(r+=` data-tip-value="${t}"`),e!=null&&(r+=` data-tip-pct="${e}"`),i!=null&&(r+=` data-tip-series="${ft(String(i))}"`),r}function Ft(s,t,e){return s+t*Math.cos(e)}function Wt(s,t,e){return s+t*Math.sin(e)}function yP(s,t,e,i,r){let n=Ft(s,e,i),o=Wt(t,e,i),a=Ft(s,e,r),l=Wt(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 Mf(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 H=Ft(s,e,r),K=Wt(t,e,r),nt=Ft(s,e,n),ut=Wt(t,e,n),bt=Ft(s,i,n),kt=Wt(t,i,n),Tt=Ft(s,i,r),Dt=Wt(t,i,r),ie=l>Math.PI?1:0;return`M ${H} ${K} A ${e} ${e} 0 ${ie} 1 ${nt} ${ut} L ${bt} ${kt} A ${i} ${i} 0 ${ie} 0 ${Tt} ${Dt} 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,g=n-d,b=p-f>Math.PI?1:0,A=Ft(s,e,f),x=Wt(t,e,f),S=Ft(s,e,p),v=Wt(t,e,p),E=Ft(s,i,g),O=Wt(t,i,g),$=Ft(s,i,m),C=Wt(t,i,m),Q=Ft(s,e-h,r),T=Wt(t,e-h,r),P=Ft(s,i+h,r),L=Wt(t,i+h,r),D=Ft(s,e-h,n),N=Wt(t,e-h,n),B=Ft(s,i+h,n),Y=Wt(t,i+h,n);return`M ${A} ${x} A ${e} ${e} 0 ${b} 1 ${S} ${v} A ${h} ${h} 0 0 1 ${D} ${N} L ${B} ${Y} A ${h} ${h} 0 0 1 ${E} ${O} A ${i} ${i} 0 ${b} 0 ${$} ${C} A ${h} ${h} 0 0 1 ${P} ${L} L ${Q} ${T} A ${h} ${h} 0 0 1 ${A} ${x} Z`}function Cs(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 Rf(s,t,e=.4){let i=Cs(s,e),r=s[s.length-1],n=s[0];return`${i} L${r.x},${t} L${n.x},${t} Z`}function tc(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`}function If(s,t,e,i,r=0){if(i<=0||e<=0)return"";let n=Math.max(0,Math.min(r,i/2,e));return n===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t} H${s+e-n} Q${s+e},${t} ${s+e},${t+n} V${t+i-n} Q${s+e},${t+i} ${s+e-n},${t+i} H${s} Z`}function Sv(s,t,e,i){if(t.length<=e)return{labels:s,vals:t};let r=Math.max(1,e-1),n=t.map((c,u)=>u),o=i?n.slice().sort((c,u)=>t[u]-t[c]).slice(0,r).sort((c,u)=>c-u):n.slice(0,r),a=new Set(o),l=n.filter(c=>!a.has(c)),h=l.reduce((c,u)=>c+t[u],0);return{labels:o.map(c=>s[c]).concat([`+${l.length} more`]),vals:o.map(c=>t[c]).concat([h])}}var wv=6,Av=5,vP={std:{ratio:4/3}},xP={"3:2":3/2,"1:1":1,"2:3":2/3},kv={wide:5/4,tall:4/5},Nn=class extends k{static properties={type:{type:String,default:"bar",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},noAverage:{type:Boolean,default:!1,reflect:!0,attribute:"no-average"},color:{type:String,default:"",reflect:!0},noGrid:{type:Boolean,default:!1,reflect:!0,attribute:"no-grid"},noValues:{type:Boolean,default:!1,reflect:!0,attribute:"no-values"},cornerRadius:{type:Number,default:null,reflect:!0,attribute:"corner-radius"},smooth:{type:Number,default:.4,reflect:!0},size:{type:String,default:"",reflect:!0},ratio:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},dots:{type:String,default:"all",reflect:!0},seriesEmphasis:{type:String,default:"",reflect:!0,attribute:"series-emphasis"},yMin:{type:Number,default:null,reflect:!0,attribute:"y-min"},yMax:{type:Number,default:null,reflect:!0,attribute:"y-max"},labels:{type:String,default:"",reflect:!0},today:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#r=0;#n=0;#a=new Set;#o=null;#l(){if(this.cornerRadius!=null)return this.cornerRadius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}#c(t){let e=this.yMin!=null&&Number.isFinite(this.yMin)?this.yMin:0,i=this.yMax!=null&&Number.isFinite(this.yMax)?this.yMax:Math.max(...t);return[e,i]}#h(t,e){return Math.min(Math.max(t,0),e)}#d(t,e,i){return Math.min(Math.max(t,e),i)}#u(t,e){let i=getComputedStyle(this).getPropertyValue(t).trim();if(!i)return e;if(/^-?\d*\.?\d+(px)?$/.test(i)){let o=parseFloat(i);return Number.isFinite(o)?o:e}let r=document.createElement("span");r.style.cssText="position:absolute; visibility:hidden; pointer-events:none; height:0; width:"+i,this.appendChild(r);let n=parseFloat(getComputedStyle(r).width);return r.remove(),Number.isFinite(n)?n:e}#f(){return this.labels==="chip"?"chip":"outside"}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.
|
|
234
|
+
`;connected(){this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Adia")}};M();w("adia-wordmark-ui",yn);R();var vn=class extends k{static properties={value:{type:Number,default:null,reflect:!0},label:{type:String,default:"",reflect:!0},meta:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=void 0;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.#i=this.querySelector(':scope > [slot="label"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","label"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="meta"]'),this.#s||(this.#s=document.createElement("span"),this.#s.setAttribute("slot","meta"),this.appendChild(this.#s)),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}%`),this.#i&&(this.#i.textContent=this.label,this.#i.hidden=!this.label),this.#s&&(this.label?this.meta?(this.#s.textContent=this.meta,this.#s.hidden=!1):this.#s.hidden=!this.#s.hasChildNodes():this.#s.hidden=!0);let i=this.label?this.meta?`${this.label}, ${this.meta}`:this.label:"";this.#r=Zt(this,this.#r,i)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};M();w("progress-ui",vn);R();var xn=class extends k{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"),!ct(this,"caption").length&&!ct(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=ct(this,"caption")[0],this.#e=ct(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}};M();w("step-progress-ui",xn);R();var Sn=class extends k{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},cornerRadius:{type:String,default:"sm",reflect:!0,attribute:"corner-radius"},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}};M();w("skeleton-ui",Sn);R();var wn=class extends k{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())}};M();w("spinner-ui",wn);R();var An=class extends k{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)}};M();w("loading-overlay-ui",An);R();var gv=new Set;function bv(s,t){gv.has(s)||(gv.add(s),console.warn(`[alert-ui] ${t}`))}var kn=class s extends k{static requiredIcons=["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"&&(bv("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger]. 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")&&(bv("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()}};M();w("alert-ui",kn);R();var tP={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},En=class extends k{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||tP[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()}};M();w("inline-message-ui",En);R();var Cn=class extends k{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};M();w("kbd-ui",Cn);R();var $n=class extends k{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-ui slot="dismiss" variant="ghost" size="sm" aria-label="Remove"><icon-ui slot="icon" name="x" weight="bold" size="0.75rem"></icon-ui></button-ui>'};static template=()=>null;#t=void 0;#e(){this.#t=Zt(this,this.#t,this.text||"")}#i=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#s=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.#i),this.addEventListener("keydown",this.#s)}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}render(){if(this.#e(),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")}};M();w("tag-ui",$n);R();var eP=new Set(["block","dot","square","line","dashed"]),iP=new Set(["sm","md","lg"]),sP=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),rP={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},nP={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function oP(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&sP.has(t)):[]}var ks=null;function aP(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!ks){let u=document.createElement("canvas");u.width=1,u.height=1,ks=u.getContext("2d")}ks.fillStyle="#000",ks.clearRect(0,0,1,1),ks.fillStyle=s,ks.fillRect(0,0,1,1);let[t,e,i]=ks.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 Pn=class extends k{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,attribute:"auto-contrast"},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;connected(){this.#u(),this.#v(),typeof MutationObserver<"u"&&(this.#d=new MutationObserver(t=>{let e=!1;for(let i of t){for(let r of i.addedNodes)if(r.nodeType===1){if(r.getAttribute?.("slot")==="chrome"){e=!0;break}if(r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#d.takeRecords())}),this.#d.observe(this,{childList:!0}))}render(){this.#u(),this.#p(),this.#m(),this.#b(),this.#O(),this.#y(),this.#g()}#u(){if(this.#n)return;let t=Array.from(this.children).filter(n=>n.getAttribute&&n.getAttribute("slot")==="chrome");for(let n of t)n.remove();let e=Array.from(this.children).filter(n=>n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]'));for(let n of e)n.remove();let i=[];for(let n of Array.from(this.childNodes))(n.nodeType===3&&!n.data||n.nodeType===8)&&i.push(n);for(let n of i)n.remove();let r=Array.from(this.childNodes).filter(n=>!(n.nodeType===1&&n.dataset&&(n.dataset.tile!==void 0||n.dataset.label!==void 0||n.dataset.detail!==void 0||n.dataset.badge!==void 0||n.dataset.copy!==void 0))&&!(n.nodeType===3&&!n.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let n of t)this.appendChild(n);for(let n of e)this.appendChild(n);for(let n of i)this.appendChild(n);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),r.length)for(let n of r)this.#e.appendChild(n);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#r=document.createElement("button-ui"),this.#r.setAttribute("data-copy",""),this.#r.setAttribute("variant","ghost"),this.#r.setAttribute("size","xs"),this.#r.setAttribute("aria-label","Copy value"),this.#r.setAttribute("hidden",""),this.#r.setAttribute("text","\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=eP.has(this.shape)?this.shape:"square",e=iP.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=oP(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",nP[n]),o.textContent=rP[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=aP(t);if(e==null){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark");return}let i=e<.62;this.#e.toggleAttribute("data-on-dark",i),this.#e.toggleAttribute("data-on-light",!i)}#b(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#O(){if(!this.#r)return;if(!this.copyable){this.#r.setAttribute("hidden","");return}this.#r.removeAttribute("hidden");let t=this.#x();t?this.#r.setAttribute("aria-label",`Copy ${t}`):this.#r.setAttribute("aria-label","Copy value")}#y(){this.selectable?(this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.setAttribute("aria-pressed",this.selected?"true":"false")):(this.getAttribute("role")==="button"&&this.removeAttribute("role"),this.getAttribute("tabindex")==="0"&&this.removeAttribute("tabindex"),this.removeAttribute("aria-pressed"))}#v(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#r)||this.#S()},this.#l=t=>{!this.selectable||t.key!=="Enter"&&t.key!==" "||(t.composedPath?t.composedPath():[t.target]).includes(this.#r)||(t.preventDefault(),this.#S())},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#x();e&&this.#A(e)},this.#r.addEventListener("click",this.#c)}#S(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#x(){return this.copyValue?this.copyValue:this.color?this.color:""}async#A(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#E(e)}#E(t){this.#r&&(this.#h!=null&&clearTimeout(this.#h),this.#r.setAttribute("data-copy-state",t?"ok":"fail"),this.#r.setAttribute("text",t?"\u2713":"\u26A0"),this.#h=setTimeout(()=>{this.#r&&(this.#r.removeAttribute("data-copy-state"),this.#r.setAttribute("text","\u29C9"),this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#d&&(this.#d.disconnect(),this.#d=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#r&&this.#c&&this.#r.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=!1}};M();w("swatch-ui",Pn);Lt();var Ov={xs:0,sm:480,md:768,lg:1024,xl:1280},Es=Object.keys(Ov),Lf=Object.values(Ov);function yv(){let s=typeof window<"u"?window.innerWidth:void 0;if(typeof s!="number")return"lg";for(let t=Es.length-1;t>=0;t--)if(s>=Lf[t])return Es[t];return"xs"}var Re=ei(yv());if(typeof window<"u"&&typeof window.matchMedia=="function")for(let s=1;s<Lf.length;s++)window.matchMedia(`(min-width: ${Lf[s]}px)`).addEventListener("change",()=>{Re.value=yv()});function jt(s,t=Re.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=Es.indexOf(t),n=null,o=-1;for(let[a,l]of i){let h=Es.indexOf(a);h!==-1&&h<=r&&h>o&&(n=l,o=h)}return n??e}R();var Qn=class extends k{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("@")?Re.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",cP(jt(t,n))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=jt(e,n);this.style.setProperty("--col-align",uP(o)),this.style.textAlign=dP(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",fP(jt(i,n))):this.style.removeProperty("--col-justify")}},lP={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},hP={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function cP(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function uP(s){return lP[s]??s}function dP(s){return{start:"start",center:"center",end:"end"}[s]??""}function fP(s){return hP[s]??s}M();w("col-ui",Qn);R();var Tn=class s extends k{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.#O(e);i&&(t.preventDefault(),i.focus())};connected(){this.#d(),this.#u(),this.#f(),this.#p(),this.#c(),this.#t?.addEventListener("click",this.#n),typeof MutationObserver<"u"&&(this.#r=new MutationObserver(()=>{this.#p(),this.#c(),this.#m(),this.#a()}),this.#r.observe(this,{childList:!0})),this.#a()}disconnected(){this.#r?.disconnect(),this.#r=null,this.#h(),this.#t?.removeEventListener("click",this.#n),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#a(),this.#m()}#a(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#o=()=>{this.#a(),this.#m()};#l=null;#c(){let t=this.#g();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#d(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#u(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#x("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#f(){if(this.#s=this.querySelector(":scope > [data-field-error]"),this.#s)return;let t=document.createElement("div");t.setAttribute("slot","error"),t.setAttribute("data-field-error",""),t.setAttribute("id",s.#x("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#p(){if(!this.#t)return;let t=this.#g();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#v()),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.#b.has(i.localName))return i;e===null&&this.#O(i)&&(e=i)}return e??t}static#b=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","date-range-picker-ui","calendar-picker-ui","color-area-ui","upload-ui","rating-ui","segmented-ui","input","textarea","select"]);#O(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#y=0;static#v(){return`field-ctl-${++s.#y}`}static#S=0;static#x(t){return`field-${t}-${++s.#S}`}};M();w("field-ui",Tn);R();var Ln=class extends k{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),typeof MutationObserver<"u"&&(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}};M();w("fields-ui",Ln);R();M();var vv=0,tl=class extends k{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-${++vv}`),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-${++vv}`,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}};w("display-field-ui",tl);R();var Mn=class extends k{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(pn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(pn),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?Re.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",gP(jt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",bP(jt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",OP(jt(i,o))):this.style.removeProperty("--row-justify"),r){let a=Es.indexOf(o),l=Es.indexOf(r);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},pP={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},mP={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function gP(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function bP(s){return pP[s]??s}function OP(s){return mP[s]??s}M();w("row-ui",Mn);R();var Rn=class extends k{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=Re.value,e=this.columns;if(e?.includes("@")){let r=jt(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=jt(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})`}};M();w("grid-ui",Rn);R();var In=class extends k{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};M();w("stack-ui",In);R();var Dn=class extends k{static properties={};static template=()=>null};M();w("frame-ui",Dn);R();function ts(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 xv(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 ft(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ue(s,t){let e=String(s);return e.length>t?e.slice(0,Math.max(1,t-1))+"\u2026":e}function ht({label:s,value:t,pct:e,series:i}){let r="";return s!=null&&(r+=` data-tip-label="${ft(String(s))}"`),t!=null&&(r+=` data-tip-value="${t}"`),e!=null&&(r+=` data-tip-pct="${e}"`),i!=null&&(r+=` data-tip-series="${ft(String(i))}"`),r}function Ft(s,t,e){return s+t*Math.cos(e)}function Wt(s,t,e){return s+t*Math.sin(e)}function yP(s,t,e,i,r){let n=Ft(s,e,i),o=Wt(t,e,i),a=Ft(s,e,r),l=Wt(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 Mf(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 H=Ft(s,e,r),K=Wt(t,e,r),nt=Ft(s,e,n),ut=Wt(t,e,n),bt=Ft(s,i,n),kt=Wt(t,i,n),Tt=Ft(s,i,r),Dt=Wt(t,i,r),ie=l>Math.PI?1:0;return`M ${H} ${K} A ${e} ${e} 0 ${ie} 1 ${nt} ${ut} L ${bt} ${kt} A ${i} ${i} 0 ${ie} 0 ${Tt} ${Dt} 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,g=n-d,b=p-f>Math.PI?1:0,A=Ft(s,e,f),x=Wt(t,e,f),S=Ft(s,e,p),v=Wt(t,e,p),E=Ft(s,i,g),O=Wt(t,i,g),$=Ft(s,i,m),C=Wt(t,i,m),Q=Ft(s,e-h,r),T=Wt(t,e-h,r),P=Ft(s,i+h,r),L=Wt(t,i+h,r),D=Ft(s,e-h,n),N=Wt(t,e-h,n),B=Ft(s,i+h,n),Y=Wt(t,i+h,n);return`M ${A} ${x} A ${e} ${e} 0 ${b} 1 ${S} ${v} A ${h} ${h} 0 0 1 ${D} ${N} L ${B} ${Y} A ${h} ${h} 0 0 1 ${E} ${O} A ${i} ${i} 0 ${b} 0 ${$} ${C} A ${h} ${h} 0 0 1 ${P} ${L} L ${Q} ${T} A ${h} ${h} 0 0 1 ${A} ${x} Z`}function Cs(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 Rf(s,t,e=.4){let i=Cs(s,e),r=s[s.length-1],n=s[0];return`${i} L${r.x},${t} L${n.x},${t} Z`}function tc(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`}function If(s,t,e,i,r=0){if(i<=0||e<=0)return"";let n=Math.max(0,Math.min(r,i/2,e));return n===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t} H${s+e-n} Q${s+e},${t} ${s+e},${t+n} V${t+i-n} Q${s+e},${t+i} ${s+e-n},${t+i} H${s} Z`}function Sv(s,t,e,i){if(t.length<=e)return{labels:s,vals:t};let r=Math.max(1,e-1),n=t.map((c,u)=>u),o=i?n.slice().sort((c,u)=>t[u]-t[c]).slice(0,r).sort((c,u)=>c-u):n.slice(0,r),a=new Set(o),l=n.filter(c=>!a.has(c)),h=l.reduce((c,u)=>c+t[u],0);return{labels:o.map(c=>s[c]).concat([`+${l.length} more`]),vals:o.map(c=>t[c]).concat([h])}}var wv=6,Av=5,vP={std:{ratio:4/3}},xP={"3:2":3/2,"1:1":1,"2:3":2/3},kv={wide:5/4,tall:4/5},Nn=class extends k{static properties={type:{type:String,default:"bar",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},noAverage:{type:Boolean,default:!1,reflect:!0,attribute:"no-average"},color:{type:String,default:"",reflect:!0},noGrid:{type:Boolean,default:!1,reflect:!0,attribute:"no-grid"},noValues:{type:Boolean,default:!1,reflect:!0,attribute:"no-values"},cornerRadius:{type:Number,default:null,reflect:!0,attribute:"corner-radius"},smooth:{type:Number,default:.4,reflect:!0},size:{type:String,default:"",reflect:!0},ratio:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},dots:{type:String,default:"all",reflect:!0},seriesEmphasis:{type:String,default:"",reflect:!0,attribute:"series-emphasis"},yMin:{type:Number,default:null,reflect:!0,attribute:"y-min"},yMax:{type:Number,default:null,reflect:!0,attribute:"y-max"},labels:{type:String,default:"",reflect:!0},today:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#r=0;#n=0;#a=new Set;#o=null;#l(){if(this.cornerRadius!=null)return this.cornerRadius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}#c(t){let e=this.yMin!=null&&Number.isFinite(this.yMin)?this.yMin:0,i=this.yMax!=null&&Number.isFinite(this.yMax)?this.yMax:Math.max(...t);return[e,i]}#h(t,e){return Math.min(Math.max(t,0),e)}#d(t,e,i){return Math.min(Math.max(t,e),i)}#u(t,e){let i=getComputedStyle(this).getPropertyValue(t).trim();if(!i)return e;if(/^-?\d*\.?\d+(px)?$/.test(i)){let o=parseFloat(i);return Number.isFinite(o)?o:e}let r=document.createElement("span");r.style.cssText="position:absolute; visibility:hidden; pointer-events:none; height:0; width:"+i,this.appendChild(r);let n=parseFloat(getComputedStyle(r).width);return r.remove(),Number.isFinite(n)?n:e}#f(){return this.labels==="chip"?"chip":"outside"}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.
|
|
235
235
|
Correct shape for <chart-ui x="label" y="value">:
|
|
236
|
-
[{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#m(),this.#v()}get data(){return this.#t}#p=!1;#m(){if(this.#p)return;let t=this.#g();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.#p=!0)}#g(){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.#P),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#z),this.addEventListener("focus",this.#R),this.addEventListener("blur",this.#q),this.addEventListener("pointerover",this.#Z),this.addEventListener("pointermove",this.#B),this.addEventListener("pointerleave",this.#D),this.addEventListener("pointerdown",this.#N),this.addEventListener("click",this.#j),typeof ResizeObserver<"u"&&(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.#v()})))}),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.#v()}#b(){let t=this.clientWidth||300,e=this.clientHeight||0,i=vP.std,r=this.#t.length||1,n=Math.max(t,120),o=this.hasAttribute("resize")||this.style.height,a=xP[this.ratio],l=a?Math.round(n/a):o&&e>40?e:Math.round(n/i.ratio),h=parseFloat(getComputedStyle(this).maxHeight);isFinite(h)&&h>0&&l>h&&(l=Math.round(h));let c=n/Math.max(l,1),u=a?this.ratio:c>=kv.wide?"3:2":c<=kv.tall?"2:3":"1:1";this.getAttribute("data-ratio-resolved")!==u&&this.setAttribute("data-ratio-resolved",u);let d=Math.min(n,l),f=this.size||(d<150?"sm":d<300?"md":"lg"),p=f==="sm"?9:f==="md"?10:11,m=p,g=f==="sm"?8:f==="md"?9:10,b=this.#f();this.getAttribute("data-labels-resolved")!==b&&this.setAttribute("data-labels-resolved",b);let A=b==="chip",x=this.#u("--chart-chrome-inset",8),S=this.#u("--chart-band-gap",4),v=Math.max(x,this.#u("--card-radius",x)),E=this.#u("--chart-chip-font-size",p),O=this.#u("--chart-chip-pad-x",6),$=this.#u("--chart-chip-pad-y",4),C=this.#u("--chart-min-plot-height-chips",180),Q=this.#u("--chart-min-plot-height-grid",120),T=A?l<Q?"bare":l<C?"no-x-chrome":"full":"full",P=this.noGrid,L=u==="3:2"?1:.8,D=P?0:p*3.2*L,N=!!this.x,B=A?{top:0,right:0,bottom:0,left:0}:{top:P?2:p*1.6,right:P?2:p*1.2,bottom:!N||P?2:p*2.2*L,left:D},Y=n-B.left-B.right,H=Math.max(4,Y/r*.6);return{width:n,height:l,pad:B,fontSize:p,labelSize:m,valueSize:g,barMinW:H,plotW:Y,n:r,sizeClass:f,ratioResolved:u,labelsResolved:b,chipMode:A,chromeInset:x,bandGap:S,cornerClearance:v,chipFontSize:E,chipPadX:O,chipPadY:$,minPlotHeightChips:C,minPlotHeightGrid:Q,degradeStage:T}}#O=null;#v(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#O&&(this.#O=t.cloneNode(!0)),this.innerHTML="",this.#O&&this.appendChild(this.#O.cloneNode(!0)),!this.#t.length){this.removeAttribute("has-data");return}this.setAttribute("has-data",""),this.#o=null;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.#ct());break;case"line":({svg:r,viewBox:n}=this.#ut());break;case"pie":({svg:r,viewBox:n}=this.#ft());break;case"donut":({svg:r,viewBox:n}=this.#pt());break;case"radar":({svg:r,viewBox:n}=this.#mt());break;case"sparkline":({svg:r,viewBox:n}=this.#gt());break;case"segments":({svg:r,viewBox:n}=this.#kt());break;case"area":({svg:r,viewBox:n}=this.#bt());break;case"scatter":({svg:r,viewBox:n}=this.#Ot());break;case"radial-bar":({svg:r,viewBox:n}=this.#yt());break;case"gauge":({svg:r,viewBox:n}=this.#vt());break;case"funnel":({svg:r,viewBox:n}=this.#xt());break;case"treemap":({svg:r,viewBox:n}=this.#St());break;case"sankey":({svg:r,viewBox:n}=this.#wt());break;case"composed":({svg:r,viewBox:n}=this.#At());break;case"stacked-bar":({svg:r,viewBox:n}=this.#Ct());break;case"grouped-bar":({svg:r,viewBox:n}=this.#Pt());break;case"multi-line":({svg:r,viewBox:n}=this.#Tt());break;default:({svg:r,viewBox:n}=this.#ct());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.#A()){let o=this.#Lt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#y(t,e){return e?` data-slice="${t}" data-series-key="${ft(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#S(t,e){return e?` data-slice="${t}" data-series-key="${ft(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#x=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#P),document.removeEventListener("pointerdown",this.#_),this.removeEventListener("keydown",this.#z),this.removeEventListener("focus",this.#R),this.removeEventListener("blur",this.#q),this.removeEventListener("pointerover",this.#Z),this.removeEventListener("pointermove",this.#B),this.removeEventListener("pointerleave",this.#D),this.removeEventListener("pointerdown",this.#N),this.removeEventListener("click",this.#j),this.#J()}#A(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#C(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#P=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.#v())};#k(t){return!!t&&this.#a.has(t)}#w(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let r=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),`${r||"$"}${xv(e)}`}default:return xv(e)}}#E=-1;#T(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#$(t){let e=this.#T();if(!e.length){this.#Q();return}this.#E=Math.max(0,Math.min(t,e.length-1)),this.#L(),this.#M()}#L(){let t=this.#T();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#E];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#Q(){this.#E=-1;for(let t of this.#T())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#M(){let t=this.#T()[this.#E];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#F(t,i)}#I(){let t=this.#T()[this.#E];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.#Y(t,i)}))}#R=()=>{this.#E===-1&&this.#$(0)};#q=()=>{this.#Q(),this.#X&&this.#U()};#z=t=>{let e=this.#T();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#$(this.#E+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#$(Math.max(0,this.#E-1));break;case"Home":t.preventDefault(),this.#$(0);break;case"End":t.preventDefault(),this.#$(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#I();break;case"Escape":t.preventDefault(),this.#Q(),this.#X&&this.#U();break}};#X=null;#Z=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#nt(e,t),this.#F(e,t))};#B=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#X&&this.#U(),this.#J();this.#nt(e,t),e!==this.#X&&this.#F(e,t)};#D=t=>{t&&t.pointerType==="touch"||(this.#J(),this.#X&&this.#U())};#N=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#X&&this.#U(),this.#J();this.#nt(e,t),e!==this.#X&&this.#F(e,t),document.addEventListener("pointerdown",this.#_)};#_=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#J(),this.#X&&this.#U(),document.removeEventListener("pointerdown",this.#_)))};#j=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#Y(e,t)}))};#F(t,e){this.#X=t,this.dots==="hover"&&this.#et(t),this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#Y(t,e)}))}#U(){this.#X=null,this.dots==="hover"&&this.#G(),this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#et(t){let e=t?.previousElementSibling;this.#o&&this.#o!==e&&this.#o.removeAttribute("data-dot-active"),e&&e.hasAttribute("data-dot")?(e.setAttribute("data-dot-active",""),this.#o=e):this.#o=null}#G(){this.#o&&this.#o.removeAttribute("data-dot-active"),this.#o=null}#Y(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.#rt(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}}#rt(t,e){if(t==null)return null;let i=this.x,r=this.#W();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.#k(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}})}#nt(t,e){if(this.#C())return;let{tipLabel:i,tipValue:r,tipPct:n,tipSeries:o}=t.dataset;if(!this.#x){let g=document.createElement("div");g.setAttribute("popover","manual"),g.setAttribute("role","tooltip"),g.classList.add("chart-tooltip-popup"),document.body.appendChild(g),this.#x=g}let a=[];if(o&&a.push(`<span data-tip-role="series">${ft(o)}</span>`),i&&a.push(`<span data-tip-role="label">${ft(i)}</span>`),r!==void 0){let g=n!==void 0?` <span data-tip-role="pct">(${n}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#w(r)}${g}</span>`)}this.#x.innerHTML=a.join("");try{this.#x.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#x.offsetWidth||0,f=this.#x.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.#x.style.left=`${p}px`,this.#x.style.top=`${m}px`}#J(){if(this.#x){try{this.#x.hidePopover()}catch{}this.#x.remove(),this.#x=null}}#W(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#ot(t,e){switch(this.dots){case"none":return!1;case"last":return t===e-1;default:return!0}}#tt(t,e,i,r,n,o,a={}){let l=n,h=o?.fontSize||10,c=o?.labelSize||h,u=!!o?.chipMode,d=o?.degradeStage||"full",f="",p="",m=i;if((o?.sizeClass==="sm"||a.thinGrid)&&i.length>4&&(m=i.filter((g,b)=>b%2===0||b===i.length-1)),!this.noGrid&&d!=="bare"){let b=i[i.length-1]-i[0]||1;if(a.vertical){if(r&&r.length){let A=t-l.left-l.right,x=r.length-1,S=a.pointAligned?A/Math.max(x,1):A/r.length,v=Math.max(1,Math.round(r.length/3));for(let E=0;E<r.length;E++){if(E%v!==0&&E!==x)continue;let O=a.pointAligned?l.left+S*E:l.left+S*E+S/2;f+=`<line data-chart-grid x1="${O}" y1="${l.top}" x2="${O}" y2="${e-l.bottom}"/>`}}}else for(let A of m){let x=l.top+(e-l.top-l.bottom)*(1-(A-i[0])/b);f+=`<line data-chart-grid x1="${l.left}" y1="${x}" x2="${t-l.right}" y2="${x}"/>`}if(u)p+=this.#at(m,i,b,t,e,l,o);else for(let A of m){let x=l.top+(e-l.top-l.bottom)*(1-(A-i[0])/b);f+=`<text data-y-label x="${l.left-4}" y="${x+h*.35}" text-anchor="end" font-size="${h}">${this.#w(A)}</text>`}if(r&&d!=="no-x-chrome")if(u)p+=this.#it(r,t,e,l,o,a);else{let A=t-l.left-l.right,x=A/r.length,S=r.length-1,v=new Set;if(a.xTickMode==="sparse"&&S>1)v.add(0),v.add(Math.round(S/2)),v.add(S);else if(a.xTickMode==="everyNth"&&S>1){let O=Math.max(2,Math.ceil(r.length/4));for(let $=0;$<=S;$+=O)v.add($);v.add(S)}else{let $=r.reduce((Q,T)=>Math.max(Q,String(T).length),1)*c*.6+c*.75,C=Math.max(1,Math.ceil($/x));for(let Q=0;Q<r.length;Q++)Q%C!==0&&Q!==S||Q!==S&&S-Q<C||v.add(Q)}let E=A/Math.max(S,1);for(let O of v){let $=a.pointAligned?l.left+E*O:l.left+x*O+x/2,C=ft(a.abbreviateLabels?Ue(r[O],4):r[O]);f+=`<text data-x-label x="${$}" y="${e-h*.5}" text-anchor="middle" font-size="${c}">${C}</text>`}}}return{svg:f,chipSvg:p}}#at(t,e,i,r,n,o,a){let{chromeInset:l,chipFontSize:h,chipPadX:c,chipPadY:u,cornerClearance:d}=a,f=h*.6+u,p=h*1.2+u*2,m=t.map(S=>{let v=o.top+(n-o.top-o.bottom)*(1-(S-e[0])/i),E=Math.min(Math.max(v,l+f),n-l-f),$=E-f<=d||E+f>=n-d?d:l,C=this.#w(S),Q=String(C).length*h*.6+c*2;return{cy:E,cx:$,rw:Q,text:C}});if(!m.length)return"";let g=m.length-1,b=[m[0]];for(let S=1;S<g;S++){let v=m[S],E=b[b.length-1];Math.abs(v.cy-E.cy)>=p&&b.push(v)}for(m.length>1&&b.push(m[g]);b.length>2;){let S=b[b.length-2],v=b[b.length-1];if(Math.abs(v.cy-S.cy)<p)b.splice(b.length-2,1);else break}if(b.length===2){let[S,v]=b;if(Math.abs(S.cy-v.cy)<p){let E=(S.cy+v.cy)/2,[O,$]=S.cy<=v.cy?[S,v]:[v,S];O.cy=Math.min(O.cy,E-p/2),$.cy=Math.max($.cy,E+p/2)}}let A=b,x="";for(let S of A)x+=`<rect data-chip data-chip-axis="y" x="${S.cx}" y="${S.cy-p/2}" width="${S.rw}" height="${p}"/>`,x+=`<text data-chip-label data-chip-axis="y" x="${S.cx+c}" y="${S.cy}" dominant-baseline="central" font-size="${h}">${S.text}</text>`;return x}#it(t,e,i,r,n,o){let{chromeInset:a,bandGap:l,chipFontSize:h,chipPadX:c,chipPadY:u,cornerClearance:d}=n,f=e-r.left-r.right,p=t.length-1,m=o.pointAligned?f/Math.max(p,1):f/t.length,g=h*1.2+u*2,b=i-Math.max(a,l)-g/2,A=t.map((v,E)=>{let O=o.pointAligned?r.left+m*E:r.left+m*E+m/2,$=o.abbreviateLabels?Ue(v,4):v,C=ft($),Q=String($).length*h*.6+c*2;return{cx0:O,rw:Q,text:C}});if(!A.length)return"";for(let v of A)v.cx=Math.min(Math.max(v.cx0,a+v.rw/2),e-a-v.rw/2);A[0].cx=Math.max(A[0].cx,d+A[0].rw/2),A[p].cx=Math.min(A[p].cx,e-d-A[p].rw/2);let x=[A[0]];for(let v=1;v<A.length-1;v++){let E=A[v],O=x[x.length-1];E.cx-E.rw/2>=O.cx+O.rw/2&&x.push(E)}for(A.length>1&&x.push(A[p]);x.length>2;){let v=x[x.length-2],E=x[x.length-1];if(E.cx-E.rw/2<v.cx+v.rw/2)x.splice(x.length-2,1);else break}if(x.length===2){let[v,E]=x;if(v.cx+v.rw/2>E.cx-E.rw/2){let O=(v.cx+E.cx)/2;v.cx=Math.min(v.cx,O-v.rw/2),E.cx=Math.max(E.cx,O+E.rw/2)}}let S="";for(let v of x)S+=`<rect data-chip data-chip-axis="x" x="${v.cx-v.rw/2}" y="${b-g/2}" width="${v.rw}" height="${g}"/>`,S+=`<text data-chip-label data-chip-axis="x" x="${v.cx}" y="${b}" text-anchor="middle" dominant-baseline="central" font-size="${h}">${v.text}</text>`;return S}#V(){let t=this.x,e=this.#t;if(this.today){for(let i=0;i<e.length;i++)if(String(e[i]?.[t]??"")===String(this.today))return i;return-1}return e.findIndex(i=>i&&i.today)}#st(t,e,i){let r=i.sizeClass==="sm"?2.5:3.5,n=Math.max(6,i.fontSize),o=i.chipMode?-1:1,a=i.chipMode?e-Math.max(i.chromeInset??0,r):e;return`<circle data-today-dot cx="${t}" cy="${a}" r="${r}"/><line data-today-tick x1="${t}" y1="${a}" x2="${t}" y2="${a+o*n}"/>`}#lt(t,e,i){let r=i.sizeClass==="sm"?2.5:3.5,n=Math.max(6,i.fontSize);return`<circle data-today-dot cx="${e}" cy="${t}" r="${r}"/><line data-today-tick x1="${e}" y1="${t}" x2="${e-n}" y2="${t}"/>`}#K(t){return t&&t.provisional?" data-provisional":""}#ht(t,e,i,r,n){let o="",a=-1,l=h=>{if(a<0)return;let c=Math.max(a-1,0),u=t.slice(c,h);if(u.length>=2){let d=u[0].x,f=u[u.length-1].x,p=Math.min(...u.map(m=>m.y));o+=`<rect data-area-provisional-fade x="${d}" y="${p}" width="${Math.max(f-d,0)}" height="${Math.max(i-p,0)}"/>`,o+=`<path data-line-provisional d="${Cs(u,n)}"/>`}a=-1};for(let h=0;h<t.length;h++){let c=!!(e[h]&&e[h].provisional);c&&a<0?a=h:!c&&a>=0&&l(h)}return l(t.length),o}#ct(){let t=this.#b(),e=this.#t,i=this.#W()[0]||this.y,r=e.map(O=>+(O[i]??0)),n=e.map(O=>O[this.x]??""),o=r,a=t.ratioResolved==="1:1"&&r.length>wv;a&&({labels:n,vals:r}=Sv(n,r,wv,!1));let l=ts(...this.#c(r),5),h=l[l.length-1],c=l[0];if(t.ratioResolved==="2:3")return this.#dt(t,n,r,l,h,a?[]:e);let{width:u,height:d,pad:f}=t,p=d-f.top-f.bottom,g=(u-f.left-f.right)/n.length,b=g*.6,A=(g-b)/2,{svg:x,chipSvg:S}=this.#tt(u,d,l,n,f,t,{abbreviateLabels:t.ratioResolved==="1:1"}),v=!this.noValues&&t.sizeClass!=="sm",E=!this.noAverage&&o.length>1&&t.sizeClass!=="sm"&&!this.noGrid;for(let O=0;O<n.length;O++){let $=r[O],C=h-c?($-c)/(h-c)*p:0,Q=this.#h(C,p),T=f.left+g*O+A,P=f.top+p-Q,L=a?"":this.#K(e[O]);x+=`<path data-bar${L}${ht({label:n[O],value:$})} d="${tc(T,P,b,Q,this.#l())}"/>`,v&&(x+=`<text data-value x="${T+b/2}" y="${P-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#w($)}</text>`)}if(E){let O=o.reduce((Q,T)=>Q+T,0)/o.length,$=h-c?(O-c)/(h-c)*p:0,C=f.top+p-this.#h($,p);x+=`<line data-avg x1="${f.left}" y1="${C}" x2="${u-f.right}" y2="${C}"/>`,x+=`<text data-avg-label x="${u-f.right+2}" y="${C+3}" text-anchor="start" font-size="${t.valueSize}">${this.#w(O)}</text>`,x+=`<line data-hit${ht({label:"Average",value:O})} x1="${f.left}" y1="${C}" x2="${u-f.right}" y2="${C}" stroke="transparent" stroke-width="12"/>`}if(!a){let O=this.#V();O>-1&&O<n.length&&(x+=this.#st(f.left+g*O+A+b/2,f.top+p,t))}return x+=S,{svg:x,viewBox:`0 0 ${u} ${d}`}}#dt(t,e,i,r,n,o=[]){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce((C,Q)=>Math.max(C,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,b=(l-p.top-p.bottom)/e.length,A=b*.6,x=(b-A)/2,S="";if(!u){let C=r[r.length-1]-r[0]||1;for(let Q of r){let T=p.left+m*((Q-r[0])/C);S+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,S+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#w(Q)}</text>`}}let v=!this.noValues,E=!this.noAverage&&i.length>1&&!u,O=r[0];for(let C=0;C<e.length;C++){let Q=i[C],T=n-O?(Q-O)/(n-O)*m:0,P=this.#h(T,m),L=p.top+b*C+x,D=p.left,N=this.#K(o[C]);S+=`<text data-x-label x="${p.left-6}" y="${L+A/2+h*.35}" text-anchor="end" font-size="${c}">${ft(e[C])}</text>`,S+=`<path data-bar${N}${ht({label:e[C],value:Q})} d="${If(D,L,P,A,this.#l())}"/>`,v&&(S+=`<text data-value x="${D+P+4}" y="${L+A/2+h*.35}" text-anchor="start" font-size="${t.valueSize}">${this.#w(Q)}</text>`)}if(E){let C=i.reduce((P,L)=>P+L,0)/i.length,Q=n-O?(C-O)/(n-O)*m:0,T=p.left+this.#h(Q,m);S+=`<line data-avg x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,S+=`<line data-hit${ht({label:"Average",value:C})} x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}" stroke="transparent" stroke-width="12"/>`}let $=this.#V();return $>-1&&$<e.length&&o.length&&(S+=this.#lt(p.top+b*$+x+A/2,p.left,t)),{svg:S,viewBox:`0 0 ${a} ${l}`}}#ut(){let t=this.#b(),e=this.#t,i=this.#W()[0]||this.y,r=e.map(P=>+(P[i]??0)),n=e.map(P=>P[this.x]??""),o=ts(...this.#c(r),5),a=o[o.length-1],l=o[0],{width:h,height:c,pad:u}=t,d=c-u.top-u.bottom,p=(h-u.left-u.right)/Math.max(e.length-1,1),m=this.type==="area",g=t.ratioResolved,{svg:b,chipSvg:A}=this.#tt(h,c,o,n,u,t,{thinGrid:g!=="3:2",vertical:m&&g==="2:3",xTickMode:g==="2:3"?"sparse":g==="1:1"?"everyNth":void 0,pointAligned:!0}),x=r.map((P,L)=>{let D=u.left+p*L,N=u.top+d-(a-l?(P-l)/(a-l)*d:0),B=this.#d(N,u.top,u.top+d);return{x:D,y:B,v:P,label:n[L]}}),S=u.top+d,v=Math.max(0,Math.min(1,this.smooth));b+=`<path data-area d="${Rf(x,S,v)}"/>`,b+=`<path data-line d="${Cs(x,v)}"/>`,b+=this.#ht(x,e,S,t,v);let E=t.sizeClass==="sm",O=E?1.5:3,$=Math.max(O,10),C=!this.noValues&&!E,Q=!this.noAverage&&r.length>1&&!E&&!this.noGrid;if(x.forEach((P,L)=>{let D=this.#K(e[L]);this.#ot(L,x.length)&&(b+=`<circle data-dot${D} cx="${P.x}" cy="${P.y}" r="${O}"/>`),b+=`<circle data-hit${ht({label:P.label,value:P.v})} cx="${P.x}" cy="${P.y}" r="${$}" fill="transparent"/>`,C&&(b+=`<text data-value x="${P.x}" y="${P.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#w(P.v)}</text>`)}),Q){let P=r.reduce((N,B)=>N+B,0)/r.length,L=u.top+d-(a-l?(P-l)/(a-l)*d:0),D=this.#d(L,u.top,u.top+d);b+=`<line data-avg x1="${u.left}" y1="${D}" x2="${h-u.right}" y2="${D}"/>`,b+=`<text data-avg-label x="${h-u.right+2}" y="${D+3}" text-anchor="start" font-size="${t.valueSize}">${this.#w(P)}</text>`,b+=`<line data-hit${ht({label:"Average",value:P})} x1="${u.left}" y1="${D}" x2="${h-u.right}" y2="${D}" stroke="transparent" stroke-width="12"/>`}let T=this.#V();return T>-1&&T<x.length&&(b+=this.#st(x[T].x,S,t)),b+=A,{svg:b,viewBox:`0 0 ${h} ${c}`}}#ft(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(P=>+(P[e]??0)),r=i.reduce((P,L)=>P+L,0)||1,n=t.map(P=>P[this.x]??""),o=this.#b(),{width:a,height:l,fontSize:h,valueSize:c}=o,u=o.ratioResolved,d=h,f=8,p=20,m=P=>(P+f)*c*.62+d+4,g=c*1.2+d+4,b=Math.max(0,a/2-p),A=Math.floor((b-d-4)/(c*.62))-f,x=n.reduce((P,L)=>Math.max(P,String(L).length),1),S=Math.max(4,Math.min(14,A,x)),v=m(S),E=u==="1:1"?Math.max(p,Math.min(a/2-v,l/2-g)):Math.max(30,Math.min(a,l)*.42),O=u==="3:2"?Math.max(E+8,a*.32):a/2,$=u==="2:3"?Math.min(l/2,E+h*1.5):l/2,C=u==="1:1",Q="",T=-Math.PI/2;for(let P=0;P<i.length;P++){let L=i[P]/r*Math.PI*2;if(L===0)continue;let D=T+L,N=(i[P]/r*100).toFixed(1),B=` data-slice="${P%10}"${ht({label:n[P],value:i[P],pct:N})}`;if(Math.abs(L-Math.PI*2)<.001?Q+=`<circle${B} cx="${O}" cy="${$}" r="${E}"/>`:Q+=`<path${B} d="${yP(O,$,E,T,D)}"/>`,C){let Y=T+L/2,H=Ft(O,E+d,Y),K=Wt($,E+d,Y),nt=Math.cos(Y),ut=Math.abs(nt)<.15?"middle":nt>0?"start":"end",bt=`${ft(Ue(n[P],S))} (${N}%)`;Q+=`<text data-ring-label x="${H}" y="${K}" text-anchor="${ut}" dominant-baseline="central" font-size="${c}">${bt}</text>`}T=D}return this.#H=t.map((P,L)=>({label:n[L],value:i[L],pct:(i[L]/r*100).toFixed(1),slot:L%10})),{svg:Q,viewBox:`0 0 ${a} ${l}`}}#pt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(x=>+(x[e]??0)),r=i.reduce((x,S)=>x+S,0)||1,n=t.map(x=>x[this.x]??""),o=this.#b(),{width:a,height:l,fontSize:h}=o,c=o.ratioResolved,u=Math.max(30,Math.min(a,l)*(c==="1:1"?.46:.42)),d=u*.72,f=c==="3:2"?Math.max(u+8,a*.32):a/2,p=c==="2:3"?Math.min(l/2,u+h*1.5):l/2,m="",g=-Math.PI/2;for(let x=0;x<i.length;x++){let S=i[x]/r*Math.PI*2;if(S===0)continue;let v=g+S,E=(i[x]/r*100).toFixed(1),O=` data-slice="${x%10}"${ht({label:n[x],value:i[x],pct:E})}`;Math.abs(S-Math.PI*2)<.001?(m+=`<circle${O} cx="${f}" cy="${p}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,m+=`<path${O} d="M ${f-u} ${p} A ${u} ${u} 0 1 1 ${f+u} ${p} A ${u} ${u} 0 1 1 ${f-u} ${p} Z M ${f-d} ${p} A ${d} ${d} 0 1 0 ${f+d} ${p} A ${d} ${d} 0 1 0 ${f-d} ${p} Z" fill-rule="evenodd"/>`):m+=`<path${O} d="${Mf(f,p,u,d,g,v,this.#l())}"/>`,g=v}let b=Math.max(14,Math.round(u*.32)),A=Math.max(9,Math.round(u*.16));return m+=`<text data-donut-total x="${f}" y="${p}" text-anchor="middle" dominant-baseline="central" font-size="${b}">${this.#w(r)}</text>`,m+=`<text data-donut-label x="${f}" y="${p+b}" text-anchor="middle" dominant-baseline="central" font-size="${A}">Total</text>`,this.#H=t.map((x,S)=>({label:n[S],value:i[S],pct:(i[S]/r*100).toFixed(1),slot:S%10})),{svg:m,viewBox:`0 0 ${a} ${l}`}}#mt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(C=>+(C[e]??0)),r=t.map(C=>C[this.x]??""),n=Math.max(...i)||1,o=t.length,a=this.#b(),{width:l,height:h,fontSize:c}=a,u=a.ratioResolved,d=u==="1:1",f=u==="2:3",p=d?c*1.8:c*3.5,m=f?h*.6:h,g=l/2,b=f?m/2:h/2,A=Math.max(40,Math.min(l,m)/2-p),x="",S=Math.PI*2/o;for(let C=1;C<=3;C++){let Q=A*C/3,T="";for(let P=0;P<o;P++){let L=-Math.PI/2+S*P,D=g+Q*Math.cos(L),N=b+Q*Math.sin(L);T+=(P===0?"M":"L")+` ${D} ${N}`}T+=" Z",x+=`<path data-chart-grid d="${T}"/>`}for(let C=0;C<o;C++){let Q=-Math.PI/2+S*C,T=g+A*Math.cos(Q),P=b+A*Math.sin(Q);x+=`<line data-chart-grid x1="${g}" y1="${b}" x2="${T}" y2="${P}"/>`}let v="",E=[];for(let C=0;C<o;C++){let Q=-Math.PI/2+S*C,T=i[C]/n*A,P=g+T*Math.cos(Q),L=b+T*Math.sin(Q);v+=(C===0?"M":"L")+` ${P} ${L}`,E.push({px:P,py:L})}v+=" Z",x+=`<path data-radar-fill d="${v}"/>`,x+=`<path data-radar-line d="${v}"/>`;let O=Math.max(c,10);for(let C=0;C<o;C++){let{px:Q,py:T}=E[C];x+=`<circle data-hit${ht({label:r[C],value:i[C]})} cx="${Q}" cy="${T}" r="${O}" fill="transparent"/>`}let $=d?c*.6:c*1.3;for(let C=0;C<o;C++){let Q=-Math.PI/2+S*C,T=g+(A+$)*Math.cos(Q),P=b+(A+$)*Math.sin(Q),L=Math.abs(Math.cos(Q))<.1?"middle":Math.cos(Q)>0?"start":"end",D=ft(f?Ue(r[C],5):r[C]);x+=`<text data-x-label x="${T}" y="${P}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${D}</text>`}return{svg:x,viewBox:`0 0 ${l} ${h}`}}#gt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(b=>+(b[e]??0)),r=ts(0,Math.max(...i),5),n=r[r.length-1],o=this.clientWidth||120,a=this.clientHeight||32,l=Math.max(40,o),h=Math.max(16,a),c=l/Math.max(i.length-1,1),u=Math.max(2,Math.min(6,h*.1)),d=t.map(b=>b[this.x]??""),f=i.map((b,A)=>({x:c*A,y:h-(n?b/n*(h-u*2):0)-u,v:b,label:d[A]})),p=Math.max(0,Math.min(1,this.smooth)),m="";m+=`<path data-area d="${Rf(f,h,p)}"/>`,m+=`<path data-line d="${Cs(f,p)}"/>`;let g=Math.max(c/2,6);for(let b of f)m+=`<circle data-hit${ht({label:b.label,value:b.v})} cx="${b.x}" cy="${b.y}" r="${g}" fill="transparent"/>`;return{svg:m,viewBox:`0 0 ${l} ${h}`}}#bt(){return this.#ut()}#Ot(){let t=this.#b(),e=this.#t,i=this.#W()[0]||this.y,r=e.map(O=>+(O[i]??0)),n=e.map(O=>O[this.x]??""),o=t.ratioResolved,a=o==="2:3"?8:5,l=ts(...this.#c(r),a),h=l[l.length-1],c=l[0],{width:u,height:d,pad:f}=t,p=d-f.top-f.bottom,g=(u-f.left-f.right)/Math.max(e.length-1,1),{svg:b,chipSvg:A}=this.#tt(u,d,l,n,f,t,{abbreviateLabels:o==="1:1"}),x=t.sizeClass==="sm"?2.5:4,S=o==="1:1"?x*.85:x,v=Math.max(S*2,10);for(let O=0;O<r.length;O++){let $=f.left+g*O,C=f.top+p-(h-c?(r[O]-c)/(h-c)*p:0),Q=this.#d(C,f.top,f.top+p),T=this.#K(e[O]);b+=`<circle data-dot data-scatter${T} cx="${$}" cy="${Q}" r="${S}"/>`,b+=`<circle data-hit${ht({label:n[O],value:r[O]})} cx="${$}" cy="${Q}" r="${v}" fill="transparent"/>`}let E=this.#V();return E>-1&&E<r.length&&(b+=this.#st(f.left+g*E,f.top+p,t)),b+=A,{svg:b,viewBox:`0 0 ${u} ${d}`}}#yt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(O=>+(O[e]??0)),r=t.map(O=>O[this.x]??""),n=Math.max(...i)||1,o=this.#b(),{width:a,height:l,fontSize:h,valueSize:c}=o,u=o.ratioResolved,d=a/2,f=l/2,p=Math.max(30,Math.min(a,l)*.45),m=p*.3,g=i.length||1,b=(p-m)/g,A=Math.min(2,b*.15),x=u==="1:1",S=u==="3:2"?0:-Math.PI/2,v=O=>x?-Math.PI/2+Math.PI*2*O/g:S,E="";for(let O=0;O<i.length;O++){let $=m+b*O+A/2,C=m+b*(O+1)-A/2,Q=($+C)/2,T=C-$,P=2*Math.PI*Q,L=Math.max(0,Math.min(1,i[O]/n))*P,N=v(O)*180/Math.PI;if(E+=`<circle data-radial-track cx="${d}" cy="${f}" r="${Q}" fill="none" stroke-width="${T}"/>`,L<=0)continue;let B=(i[O]/n*100).toFixed(1),Y=ht({label:r[O],value:i[O],pct:B}),H=Math.abs(L-P)<.5,K=H?"butt":"round",nt=H?`${P} 0`:`${L} ${P-L}`;E+=`<circle data-slice="${O%10}"${Y} data-radial-bar cx="${d}" cy="${f}" r="${Q}" fill="none" stroke-width="${T}" stroke-linecap="${K}" stroke-dasharray="${nt}" transform="rotate(${N} ${d} ${f})"/>`}if(x){let O=h;for(let $=0;$<i.length;$++){let C=v($),Q=Ft(d,p+O,C),T=Wt(f,p+O,C),P=Math.cos(C),L=Math.abs(P)<.15?"middle":P>0?"start":"end";E+=`<text data-ring-label x="${Q}" y="${T}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${ft(r[$])}</text>`}}return this.#H=t.map((O,$)=>({label:r[$],key:r[$],value:i[$],pct:(i[$]/n*100).toFixed(1),slot:$%10})),{svg:E,viewBox:`0 0 ${a} ${l}`}}#vt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(Q=>+(Q[e]??0)),r=i.reduce((Q,T)=>Q+T,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.#b(),{width:h,height:c,fontSize:u}=l,d=l.ratioResolved,f=d==="3:2",p=d==="2:3",m=Math.max(40,Math.min(h*(d==="1:1"?.48:.45),c*(p?.46:.6))),g=m*.72,b=(m-g)/2,A=f?Math.max(m+8,h*.34):h/2,x=p?Math.min(c*.5,m+u*1.3):c*.68,S="";if(S+=`<path data-radial-track d="${Mf(A,x,m,g,Math.PI,2*Math.PI,b)}"/>`,a>0){let Q=Math.PI+Math.PI*a,T=ht({label:t[0]?.[this.x]??"Value",value:n,pct:(a*100).toFixed(1)});S+=`<path data-slice="0"${T} data-gauge-fill d="${Mf(A,x,m,g,Math.PI,Q,b)}"/>`}let v=Math.max(18,Math.round(m*.42)),E=Math.max(10,Math.round(m*.2)),O,$,C;return f?(O=A+m+u*1.2,$=x-m*.15,C="start"):p?(O=A,$=x+v*.7,C="middle"):(O=A,$=x-m*.15,C="middle"),S+=`<text data-gauge-value x="${O}" y="${$}" text-anchor="${C}" dominant-baseline="central" font-size="${v}">${this.#w(n)}</text>`,o!==n&&(S+=`<text data-gauge-max x="${O}" y="${$+v*.8}" text-anchor="${C}" dominant-baseline="central" font-size="${E}">of ${this.#w(o)}</text>`),{svg:S,viewBox:`0 0 ${h} ${c}`}}#xt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(O=>+(O[e]??0)),r=t.map(O=>O[this.x]??""),n=i.length;if(n===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#b(),{width:l,height:h}=a,c=a.fontSize,u=a.ratioResolved;this.#H=t.map((O,$)=>({label:r[$],value:i[$],pct:(i[$]/o*100).toFixed(1),slot:$%10}));let d="";if(u==="3:2"){let O=Math.max(h*.16,c*2.2),$=c*.8,C=l-$*2,Q=h-O*2,T=C/n,P=Math.max(2,T*.08),L=O+Q/2;for(let D=0;D<n;D++){let N=i[D],B=D<n-1?i[D+1]:i[D],Y=N/o*(Q/2),H=B/o*(Q/2),K=$+T*D+P/2,nt=$+T*(D+1)-P/2,ut=(K+nt)/2,bt=(N/o*100).toFixed(1),kt=ht({label:r[D],value:N,pct:bt}),Tt=`M ${K} ${L-Y} L ${nt} ${L-H} L ${nt} ${L+H} L ${K} ${L+Y} Z`;if(d+=`<path data-slice="${D%10}" data-funnel-stage${kt} d="${Tt}"/>`,d+=`<text data-funnel-label x="${ut}" y="${O-c*.6}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${c}">${ft(r[D])}</text>`,d+=`<text data-funnel-value x="${ut}" y="${h-O+c*1.3}" text-anchor="middle" dominant-baseline="hanging" font-size="${c}">${this.#w(N)}</text>`,D>0){let Dt=(i[D]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${ut}" y="${h-O+c*2.5}" text-anchor="middle" dominant-baseline="hanging" font-size="${c*.85}">${Dt}%</text>`}}return{svg:d,viewBox:`0 0 ${l} ${h}`}}let f=u==="1:1",p=u==="2:3",m=f||p?c*.8:Math.max(l*.18,80),g=p?Math.max(l*.3,c*6):Math.max(l*.18,80),b=c*.8,A=l-m-g,S=(h-b*2)/n,v=Math.max(2,S*.08),E=m+A/2;for(let O=0;O<n;O++){let $=i[O],C=O<n-1?i[O+1]:i[O],Q=$/o*(A/2),T=C/o*(A/2),P=b+S*O+v/2,L=b+S*(O+1)-v/2,D=P+S/2-v/2,N=($/o*100).toFixed(1),B=ht({label:r[O],value:$,pct:N}),Y=`M ${E-Q} ${P} L ${E+Q} ${P} L ${E+T} ${L} L ${E-T} ${L} Z`;if(d+=`<path data-slice="${O%10}" data-funnel-stage${B} d="${Y}"/>`,f){let H=(Q+T)/2,K=Math.floor((H*2-c)/(c*.6));K>=2&&(d+=`<text data-funnel-label data-funnel-label-inline x="${E}" y="${D}" text-anchor="middle" dominant-baseline="central" font-size="${c}">${ft(Ue(r[O],K))}</text>`)}else d+=`<text data-funnel-label x="${m-8}" y="${D}" text-anchor="end" dominant-baseline="central" font-size="${c}">${ft(r[O])}</text>`;if(p){if(d+=`<text data-funnel-label data-funnel-label-right x="${l-g+8}" y="${D-c*.6}" text-anchor="start" dominant-baseline="central" font-size="${c}">${ft(r[O])}</text>`,d+=`<text data-funnel-value x="${l-g+8}" y="${D+c*.6}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#w($)}</text>`,O>0){let H=(i[O]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${l-g+8}" y="${D+c*1.7}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${H}%</text>`}}else if(d+=`<text data-funnel-value x="${l-g+8}" y="${D}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#w($)}</text>`,O>0){let H=(i[O]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${l-g+8}" y="${D+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${H}%</text>`}}return{svg:d,viewBox:`0 0 ${l} ${h}`}}#St(){let t=this.#t,e=this.#W()[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=this.#b(),{width:a,height:l,fontSize:h}=o,c=i.reduce((v,E)=>v+E,0)||1,u=o.ratioResolved,d=Array.from({length:n},(v,E)=>E).sort((v,E)=>i[E]-i[v]),f=u==="3:2"?Math.max(2,Math.ceil(Math.sqrt(n*2))):u==="2:3"?Math.max(1,Math.floor(Math.sqrt(n/2))):Math.max(1,Math.round(Math.sqrt(n))),p=[];for(let v=0;v<d.length;v+=f)p.push(d.slice(v,v+f));let m=p.map(v=>v.reduce((E,O)=>E+i[O],0)),g=m.reduce((v,E)=>v+E,0)||1,b=[],A=0;for(let v=0;v<p.length;v++){let E=m[v]/g*l,O=m[v]||1,$=0;for(let C of p[v]){let Q=i[C]/O*a;b.push({i:C,x:$,y:A,w:Q,h:E}),$+=Q}A+=E}let x="",S=2;for(let v of b){let E=(i[v.i]/c*100).toFixed(1),O=ht({label:r[v.i],value:i[v.i],pct:E});x+=`<rect data-slice="${v.i%10}" data-treemap-tile${O} x="${v.x+S}" y="${v.y+S}" width="${Math.max(0,v.w-S*2)}" height="${Math.max(0,v.h-S*2)}" rx="${this.#l()}"/>`;let $=v.x+8,C=v.w>h*4,Q=C&&v.h>h*2.5,T=C&&!Q&&v.h>h*1.2,P=u==="2:3"?8:20;if(Q)x+=`<text data-treemap-label x="${$}" y="${v.y+h+4}" font-size="${h}" dominant-baseline="hanging">${ft(Ue(r[v.i],P))}</text>`,x+=`<text data-treemap-value x="${$}" y="${v.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#w(i[v.i])}</text>`;else if(T){let L=v.y+v.h/2;x+=`<text data-treemap-label x="${$}" y="${L}" font-size="${h}" dominant-baseline="central">${ft(Ue(r[v.i],P))}</text>`}}return this.#H=t.map((v,E)=>({label:r[E],value:i[E],pct:(i[E]/c*100).toFixed(1),slot:E%10})),{svg:x,viewBox:`0 0 ${a} ${l}`}}#wt(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let O of t){let $=O.source??O.from??"",C=O.target??O.to??"",Q=+(O.value??O.v??0);e.has($)||e.set($,{name:$,flow:0}),i.has(C)||i.set(C,{name:C,flow:0}),e.get($).flow+=Q,i.get(C).flow+=Q}let r=this.#b(),{width:n,height:o,fontSize:a}=r,l=r.ratioResolved,h=[...e.values()],c=[...i.values()],u=h.reduce((O,$)=>O+$.flow,0)||1,d=c.reduce((O,$)=>O+$.flow,0)||1,f="";if(l==="2:3"){let O=Math.max(8,o*.05),$=O+a*1.8,C=n*.5,Q=Math.min(a*.8,C/Math.max(1,Math.max(h.length,c.length)-1)),T=Math.max(1,n-Q*Math.max(0,h.length-1)),P=Math.max(1,n-Q*Math.max(0,c.length-1)),L=0;for(let N of h){let B=N.flow/u*T;N.x0=L,N.x1=L+B,N.cursor=L,L+=B+Q}L=0;for(let N of c){let B=N.flow/d*P;N.x0=L,N.x1=L+B,N.cursor=L,L+=B+Q}let D=Math.min(this.#l(),O/2);h.forEach((N,B)=>{let Y=ht({label:N.name,value:N.flow});f+=`<rect data-sankey-node data-slice="${B%10}"${Y} x="${N.x0}" y="${$-O}" width="${N.x1-N.x0}" height="${O}" rx="${D}"/>`,f+=`<text data-sankey-label x="${(N.x0+N.x1)/2}" y="${$-O-6}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${a}">${ft(Ue(N.name,10))}</text>`}),c.forEach((N,B)=>{let Y=ht({label:N.name,value:N.flow});f+=`<rect data-sankey-node data-slice="${(h.length+B)%10}"${Y} x="${N.x0}" y="${o-$}" width="${N.x1-N.x0}" height="${O}" rx="${D}"/>`,f+=`<text data-sankey-label x="${(N.x0+N.x1)/2}" y="${o-$+O+a+2}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${a}">${ft(Ue(N.name,10))}</text>`});for(let N of t){let B=e.get(N.source??N.from??""),Y=i.get(N.target??N.to??"");if(!B||!Y)continue;let H=+(N.value??N.v??0);if(H<=0)continue;let K=H/u*T,nt=H/d*P,ut=B.cursor,bt=ut+K,kt=Y.cursor,Tt=kt+nt;B.cursor+=K,Y.cursor+=nt;let Dt=$,ie=o-$,ti=(Dt+ie)/2,lf=ht({label:`${B.name} \u2192 ${Y.name}`,value:H}),hf=`M ${ut} ${Dt} C ${ut} ${ti}, ${kt} ${ti}, ${kt} ${ie} L ${Tt} ${ie} C ${Tt} ${ti}, ${bt} ${ti}, ${bt} ${Dt} Z`;f+=`<path data-sankey-link${lf} d="${hf}"/>`}return{svg:f,viewBox:`0 0 ${n} ${o}`}}let p=l==="1:1",m=Math.max(8,n*.03),g=m+a*(p?2.2:5),b=p?6:24,A=a*.6,x=o-A*Math.max(0,h.length-1),S=o-A*Math.max(0,c.length-1),v=0;for(let O of h){let $=O.flow/u*x;O.y0=v,O.y1=v+$,O.cursor=v,v+=$+A}v=0;for(let O of c){let $=O.flow/d*S;O.y0=v,O.y1=v+$,O.cursor=v,v+=$+A}let E=Math.min(this.#l(),m/2);h.forEach((O,$)=>{let C=ht({label:O.name,value:O.flow});f+=`<rect data-sankey-node data-slice="${$%10}"${C} x="${g-m}" y="${O.y0}" width="${m}" height="${O.y1-O.y0}" rx="${E}"/>`,f+=`<text data-sankey-label x="${g-m-6}" y="${(O.y0+O.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${ft(Ue(O.name,b))}</text>`}),c.forEach((O,$)=>{let C=ht({label:O.name,value:O.flow});f+=`<rect data-sankey-node data-slice="${(h.length+$)%10}"${C} x="${n-g}" y="${O.y0}" width="${m}" height="${O.y1-O.y0}" rx="${E}"/>`,f+=`<text data-sankey-label x="${n-g+m+6}" y="${(O.y0+O.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${ft(Ue(O.name,b))}</text>`});for(let O of t){let $=e.get(O.source??O.from??""),C=i.get(O.target??O.to??"");if(!$||!C)continue;let Q=+(O.value??O.v??0);if(Q<=0)continue;let T=Q/u*x,P=Q/d*S,L=$.cursor,D=L+T,N=C.cursor,B=N+P;$.cursor+=T,C.cursor+=P;let Y=g,H=n-g,K=(Y+H)/2,nt=ht({label:`${$.name} \u2192 ${C.name}`,value:Q}),ut=`M ${Y} ${L} C ${K} ${L}, ${K} ${N}, ${H} ${N} L ${H} ${B} C ${K} ${B}, ${K} ${D}, ${Y} ${D} Z`;f+=`<path data-sankey-link${nt} d="${ut}"/>`}return{svg:f,viewBox:`0 0 ${n} ${o}`}}#At(){let t=this.#b(),e=this.#t,i=t.ratioResolved,r=this.#W(),n=r[0]||"bar",o=r[1]||"line",a=e.map(C=>C[this.x]??""),l=e.map(C=>+(C[n]??0)),h=e.map(C=>+(C[o]??0)),c=[...l,...h],u=ts(...this.#c(c),5),d=u[u.length-1],f=u[0],{width:p,height:m,pad:g}=t,b=m-g.top-g.bottom,A=p-g.left-g.right,x=A/e.length,S=x*.6,v=(x-S)/2,{svg:E,chipSvg:O}=this.#tt(p,m,u,a,g,t);if(!this.#k(n))for(let C=0;C<e.length;C++){let Q=l[C],T=d-f?(Q-f)/(d-f)*b:0,P=this.#h(T,b),L=g.left+x*C+v,D=g.top+b-P,N=this.#K(e[C]);E+=`<path${N}${this.#y(0,n)}${ht({label:a[C],value:Q,series:n})} d="${tc(L,D,S,P,this.#l())}"/>`}if(!this.#k(o))if(i==="2:3"){let C=A*.34,Q=Math.min(b*.26,C*.6),T=g.left+A-C-2,P=g.top+2,L=Math.min(...h),N=Math.max(...h)-L||1,B=h.map((H,K)=>({x:T+(h.length>1?K/(h.length-1)*C:C/2),y:P+Q-(H-L)/N*Q,v:H,label:a[K]})),Y=Math.max(0,Math.min(1,this.smooth));E+=`<rect data-composed-inset-bg x="${T-4}" y="${P-4}" width="${C+8}" height="${Q+8}" rx="${this.#l()}"/>`,E+=`<path data-composed-inset-line${this.#S(1,o)} d="${Cs(B,Y)}"/>`;for(let H of B)E+=`<circle data-hit${ht({label:H.label,value:H.v,series:o})} cx="${H.x}" cy="${H.y}" r="6" fill="transparent"/>`;E+=`<text data-composed-inset-label x="${T}" y="${P-6}" text-anchor="start" font-size="${t.valueSize}">${ft(o)}</text>`}else{let C=h.map((D,N)=>{let B=g.top+b-(d-f?(D-f)/(d-f)*b:0);return{x:g.left+x*N+x/2,y:this.#d(B,g.top,g.top+b),v:D,label:a[N]}}),Q=Math.max(0,Math.min(1,this.smooth)),T=i==="1:1",P=T?' data-slice="1" data-deemphasized-tint style="stroke: var(--md-sys-color-neutral-on-surface-variant)"':this.#S(1,o),L=T?' data-slice="1" data-deemphasized-tint style="fill: var(--md-sys-color-neutral-on-surface-variant)"':this.#y(1,o);E+=`<path data-line${P} d="${Cs(C,Q)}"/>`,E+=this.#ht(C,e,g.top+b,t,Q),C.forEach((D,N)=>{let B=this.#K(e[N]);E+=`<circle data-dot${L}${B} cx="${D.x}" cy="${D.y}" r="3"/>`,E+=`<circle data-hit${ht({label:D.label,value:D.v,series:o})} cx="${D.x}" cy="${D.y}" r="10" fill="transparent"/>`})}let $=this.#V();return $>-1&&$<e.length&&(E+=this.#st(g.left+x*$+x/2,g.top+b,t)),this.#H=[{label:n,key:n,slot:0},{label:o,key:o,slot:1,deemphasized:i==="1:1"}],E+=O,{svg:E,viewBox:`0 0 ${p} ${m}`}}#kt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(g=>+(g[e]??0)),r=t.map(g=>g[this.x]??""),n=i.reduce((g,b)=>g+b,0)||1,o=this.#b(),a=o.ratioResolved;if(a==="1:1"&&i.length>Av&&({labels:r,vals:i}=Sv(r,i,Av,!0)),this.#H=r.map((g,b)=>({label:g,value:i[b],pct:(i[b]/n*100).toFixed(1),slot:b%10})),a==="2:3")return this.#Et(o,r,i,n);let l=getComputedStyle(this),h=Math.max(40,this.clientWidth||200),c=24,u=Math.min(this.#l(),c/2),d=Math.max(0,parseFloat(l.getPropertyValue("--chart-segments-gap"))||2),f=[],p=0;for(let g=0;g<i.length;g++){let b=g===i.length-1?h:Math.round((p*n+i[g]*h)/n),A=g===i.length-1?h:i.slice(0,g+1).reduce((S,v)=>S+v,0)/n*h,x=g===0?0:i.slice(0,g).reduce((S,v)=>S+v,0)/n*h;f.push({x,w:Math.max(0,A-x)}),p=b}let m="";for(let g=0;g<f.length;g++){let{x:b,w:A}=f[g];if(A<=0)continue;let x=g===0,S=g===f.length-1,v=Math.max(0,A-(S?0:d)),E=(i[g]/n*100).toFixed(1),O=ht({label:r[g],value:i[g],pct:E}),$=`<title>${ft(r[g])}: ${i[g]} (${E}%)</title>`;if(x&&S||!x&&!S||u===0)m+=`<rect data-slice="${g%10}"${O} x="${b}" y="0" width="${v}" height="${c}"${(x||S)&&u?` rx="${u}"`:""}>${$}</rect>`;else{let C=u,Q=b+v,T;x?T=`M ${b+C} 0 H ${Q} V ${c} H ${b+C} A ${C} ${C} 0 0 1 ${b} ${c-C} V ${C} A ${C} ${C} 0 0 1 ${b+C} 0 Z`:T=`M ${b} 0 H ${Q-C} A ${C} ${C} 0 0 1 ${Q} ${C} V ${c-C} A ${C} ${C} 0 0 1 ${Q-C} ${c} H ${b} Z`,m+=`<path data-slice="${g%10}"${O} d="${T}">${$}</path>`}}return{svg:m,viewBox:`0 0 ${h} ${c}`}}#Et(t,e,i,r){let o=Math.max(60,t.height),a=Math.min(this.#l(),24/2),l=getComputedStyle(this),h=Math.max(0,parseFloat(l.getPropertyValue("--chart-segments-gap"))||2),c=[];for(let d=0;d<i.length;d++){let f=d===i.length-1?o:i.slice(0,d+1).reduce((m,g)=>m+g,0)/r*o,p=d===0?0:i.slice(0,d).reduce((m,g)=>m+g,0)/r*o;c.push({y:p,h:Math.max(0,f-p)})}let u="";for(let d=0;d<c.length;d++){let{y:f,h:p}=c[d];if(p<=0)continue;let m=d===0,g=d===c.length-1,b=Math.max(0,p-(g?0:h)),A=(i[d]/r*100).toFixed(1),x=ht({label:e[d],value:i[d],pct:A}),S=`<title>${ft(e[d])}: ${i[d]} (${A}%)</title>`;if(m&&g||!m&&!g||a===0)u+=`<rect data-slice="${d%10}"${x} x="0" y="${f}" width="24" height="${b}"${(m||g)&&a?` rx="${a}"`:""}>${S}</rect>`;else{let v=a,E=f+b,O;m?O=`M 0 ${f+v} A ${v} ${v} 0 0 1 ${v} ${f} H ${24-v} A ${v} ${v} 0 0 1 24 ${f+v} V ${E} H 0 Z`:O=`M 0 ${f} H 24 V ${E-v} A ${v} ${v} 0 0 1 ${24-v} ${E} H ${v} A ${v} ${v} 0 0 1 0 ${E-v} Z`,u+=`<path data-slice="${d%10}"${x} d="${O}">${S}</path>`}}return{svg:u,viewBox:`0 0 24 ${o}`}}#Ct(){let t=this.#t,e=this.#W(),i=t.map(O=>O[this.x]??""),r=t.map(O=>e.reduce(($,C)=>$+ +(O[C]??0),0)),n=ts(...this.#c(r),5),o=n[n.length-1],a=n[0],l=this.#b(),h=l.ratioResolved;if(this.#H=e.map((O,$)=>({label:O,key:O,slot:$%10})),h==="2:3")return this.#$t(l,i,e,t,o,n);let{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/t.length,g=m*.6,b=(m-g)/2,{svg:A,chipSvg:x}=this.#tt(c,u,n,i,d,l,{abbreviateLabels:h==="1:1"}),S=o-a?f/(o-a):0,v=this.#d(d.top+f+a*S,d.top,d.top+f);for(let O=0;O<t.length;O++){let $=v,C=e.length;for(let Q=0;Q<C;Q++){if(this.#k(e[Q]))continue;let T=+(t[O][e[Q]]??0),P=T*S;if(P<=0){$=this.#d($-P,d.top,d.top+f);continue}let L=Math.max($-P,d.top),D=$-L,N=d.left+m*O+b,B=L;$=L;let Y=Q===C-1,H=this.#l(),nt=`${this.#K(t[O])}${this.#y(Q%10,e[Q])}${ht({label:i[O],value:T,series:e[Q]})}`;Y?A+=`<path${nt} d="${tc(N,B,g,D,H)}"/>`:A+=`<rect${nt} x="${N}" y="${B}" width="${g}" height="${D}"/>`}}let E=this.#V();return E>-1&&E<t.length&&(A+=this.#st(d.left+m*E+m/2,d.top+f,l)),A+=x,{svg:A,viewBox:`0 0 ${c} ${u}`}}#$t(t,e,i,r,n,o){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce((C,Q)=>Math.max(C,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,b=(l-p.top-p.bottom)/e.length,A=b*.6,x=(b-A)/2,S=o[0],v=n-S?m/(n-S):0,E=this.#d(p.left-S*v,p.left,p.left+m),O="";if(!u){let C=o[o.length-1]-o[0]||1;for(let Q of o){let T=p.left+m*((Q-o[0])/C);O+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,O+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#w(Q)}</text>`}}for(let C=0;C<e.length;C++){let Q=p.top+b*C+x;O+=`<text data-x-label x="${p.left-6}" y="${Q+A/2+h*.35}" text-anchor="end" font-size="${c}">${ft(e[C])}</text>`;let T=E,P=i.length;for(let L=0;L<P;L++){if(this.#k(i[L]))continue;let D=+(r[C][i[L]]??0),N=D*v;if(N<=0)continue;let B=T,Y=Math.min(T+N,p.left+m),H=Y-B;T=Y;let K=L===P-1,ut=`${this.#K(r[C])}${this.#y(L%10,i[L])}${ht({label:e[C],value:D,series:i[L]})}`;K?O+=`<path${ut} d="${If(B,Q,H,A,this.#l())}"/>`:O+=`<rect${ut} x="${B}" y="${Q}" width="${H}" height="${A}"/>`}}let $=this.#V();return $>-1&&$<e.length&&(O+=this.#lt(p.top+b*$+b/2,p.left,t)),{svg:O,viewBox:`0 0 ${a} ${l}`}}#Pt(){let t=this.#t,e=this.#W(),i=t.map(O=>O[this.x]??""),r=t.flatMap(O=>e.map($=>+(O[$]??0))),n=ts(...this.#c(r),5),o=n[n.length-1],a=n[0],l=this.#b(),h=l.ratioResolved;if(this.#H=e.map((O,$)=>({label:O,key:O,slot:$%10})),h==="2:3")return this.#Qt(l,i,e,t,o,n);let{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/t.length,g=3,b=m*.7,A=(b-g*(e.length-1))/e.length,x=(m-b)/2,{svg:S,chipSvg:v}=this.#tt(c,u,n,i,d,l,{abbreviateLabels:h==="1:1"});for(let O=0;O<t.length;O++){let $=this.#K(t[O]);for(let C=0;C<e.length;C++){if(this.#k(e[C]))continue;let Q=+(t[O][e[C]]??0),T=o-a?(Q-a)/(o-a)*f:0,P=this.#h(T,f),L=d.left+m*O+x+(A+g)*C,D=d.top+f-P;S+=`<path${$}${this.#y(C%10,e[C])}${ht({label:i[O],value:Q,series:e[C]})} d="${tc(L,D,A,P,this.#l())}"/>`,this.noValues||(S+=`<text data-value x="${L+A/2}" y="${D-4}" text-anchor="middle" font-size="${l.valueSize}">${this.#w(Q)}</text>`)}}let E=this.#V();return E>-1&&E<t.length&&(S+=this.#st(d.left+m*E+m/2,d.top+f,l)),S+=v,{svg:S,viewBox:`0 0 ${c} ${u}`}}#Qt(t,e,i,r,n,o){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce((C,Q)=>Math.max(C,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,b=(l-p.top-p.bottom)/e.length,A=3,x=b*.7,S=(x-A*(i.length-1))/i.length,v=(b-x)/2,E=o[0],O="";if(!u){let C=o[o.length-1]-o[0]||1;for(let Q of o){let T=p.left+m*((Q-o[0])/C);O+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,O+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#w(Q)}</text>`}}for(let C=0;C<e.length;C++){let Q=p.top+b*C,T=this.#K(r[C]);O+=`<text data-x-label x="${p.left-6}" y="${Q+b/2+h*.35}" text-anchor="end" font-size="${c}">${ft(e[C])}</text>`;for(let P=0;P<i.length;P++){if(this.#k(i[P]))continue;let L=+(r[C][i[P]]??0),D=n-E?(L-E)/(n-E)*m:0,N=this.#h(D,m),B=Q+v+(S+A)*P;O+=`<path${T}${this.#y(P%10,i[P])}${ht({label:e[C],value:L,series:i[P]})} d="${If(p.left,B,N,S,this.#l())}"/>`,this.noValues||(O+=`<text data-value x="${p.left+N+4}" y="${B+S/2+h*.35}" text-anchor="start" font-size="${t.valueSize}">${this.#w(L)}</text>`)}}let $=this.#V();return $>-1&&$<e.length&&(O+=this.#lt(p.top+b*$+b/2,p.left,t)),{svg:O,viewBox:`0 0 ${a} ${l}`}}#Tt(){let t=this.#t,e=this.#W(),i=t.map(S=>S[this.x]??""),r=t.flatMap(S=>e.map(v=>+(S[v]??0))),n=ts(...this.#c(r),5),o=n[n.length-1],a=n[0],l=this.#b(),h=l.ratioResolved,{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/Math.max(t.length-1,1),{svg:g,chipSvg:b}=this.#tt(c,u,n,i,d,l,{pointAligned:!0}),A=h==="3:2";for(let S=0;S<e.length;S++){if(this.#k(e[S]))continue;let E=t.map(P=>+(P[e[S]]??0)).map((P,L)=>{let D=d.left+m*L,N=d.top+f-(o-a?(P-a)/(o-a)*f:0),B=this.#d(N,d.top,d.top+f);return{x:D,y:B,v:P,label:i[L]}}),O=d.top+f,$=Math.max(0,Math.min(1,this.smooth)),C=this.seriesEmphasis,Q=!C||e[S]===C,T=Q?"":" data-deemphasized";if(Q&&(g+=`<path data-area${this.#y(S%10,e[S])} d="${Rf(E,O,$)}"/>`),g+=`<path data-line${this.#S(S%10,e[S])}${T} d="${Cs(E,$)}"/>`,g+=this.#ht(E,t,O,l,$),E.forEach((P,L)=>{let D=this.#K(t[L]);this.#ot(L,E.length)&&(g+=`<circle data-dot${this.#y(S%10,e[S])}${T}${D} cx="${P.x}" cy="${P.y}" r="3"/>`),g+=`<circle data-hit${ht({label:P.label,value:P.v,series:e[S]})} cx="${P.x}" cy="${P.y}" r="10" fill="transparent"/>`}),A&&E.length){let P=E[E.length-1];g+=`<text data-series-end-label${this.#y(S%10,e[S])} x="${P.x+6}" y="${P.y}" text-anchor="start" dominant-baseline="central" font-size="${l.labelSize}">${ft(e[S])}</text>`}}let x=this.#V();return x>-1&&x<t.length&&(g+=this.#st(d.left+m*x,d.top+f,l)),this.#H=e.map((S,v)=>({label:S,key:S,slot:v%10})),g+=b,{svg:g,viewBox:`0 0 ${c} ${u}`}}#H=null;get legendData(){return this.#H?this.#H.map(t=>({...t})):null}#Lt(){if(!this.#H||!this.#H.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#H){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.deemphasized?(r.setAttribute("data-deemphasized-tint",""),r.style.background="var(--md-sys-color-neutral-on-surface-variant)"):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}};M();w("chart-ui",Nn);R();var Ev=new Set(["3:2","1:1","2:3"]),qn=class s extends k{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},ratio:{type:String,default:"",reflect:!0},interactive:{type:Boolean,default:!0,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#o()}disconnected(){this.#r()}render(){this.#s(),this.#o()}#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.#o(),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(Ev.has(this.ratio))return this.ratio;if(this.#t){let t=this.#t.getAttribute("data-ratio-resolved");if(Ev.has(t))return t}return""}#a(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#o(){let t=this.#n();t?this.getAttribute("data-ratio-resolved")!==t&&this.setAttribute("data-ratio-resolved",t):this.hasAttribute("data-ratio-resolved")&&this.removeAttribute("data-ratio-resolved");let e=this.#a();if(this.innerHTML="",!!e.length)for(let i of e){let r=i.key??i.label??"",n=i.label??r,o=i.slot!=null?i.slot:0,a=!this.#i.has(r),l=document.createElement("badge-ui");l.setAttribute("data-row",""),l.setAttribute("role",this.interactive?"button":"listitem"),l.setAttribute("text",n),r&&l.setAttribute("data-key",r),a&&l.setAttribute("data-active",""),i.deemphasized&&l.setAttribute("data-deemphasized",""),this.interactive&&(l.setAttribute("tabindex","0"),l.setAttribute("aria-pressed",a?"true":"false"));let h=this.shape||"dot",c=document.createElement("swatch-ui");c.setAttribute("shape",h),c.setAttribute("size","sm");let u=i.deemphasized?"var(--md-sys-color-neutral-on-surface-variant)":r?`var(--color-${r}, var(--a-data-${o}))`:`var(--a-data-${o})`;c.style.setProperty("--swatch-color",u),l.appendChild(c),this.interactive&&(l.addEventListener("click",d=>this.#l(d,r)),l.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),this.#l(d,r))})),this.appendChild(l)}}#l(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"}}))}};M();w("chart-legend-ui",qn);R();var SP=120,Xn=class extends k{static properties={placement:{type:String,default:"bottom",reflect:!0},offset:{type:Number,default:4,reflect:!0},open:{type:Boolean,default:!1,reflect:!0},trigger:{type:String,default:"click",reflect:!0},matchWidth:{type:Boolean,default:!1,reflect:!0,attribute:"match-width"}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#r=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#u),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#d),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#d))))}render(){this.open?this.#n():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#n(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=Ot(t,e,{placement:this.placement,gap:this.offset,matchWidth:this.matchWidth}),(this.trigger==="click"||this.trigger==="manual")&&(this.#r=requestAnimationFrame(()=>{this.#r=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#c)}))}}#a(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#o=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#d=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},SP)};#u=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#a(),this.trigger==="click"&&this.removeEventListener("click",this.#o),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#d),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#d))),this.#s?.removeEventListener("toggle",this.#u),this.#s=null,this.#e=!1}};M();w("popover-ui",Xn);R();var Bn=class extends k{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)}},zn=class extends k{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())}};M();w("accordion-ui",Bn),w("accordion-item-ui",zn);R();var Zn=class extends k{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()}}};M();w("divider-ui",Zn);R();var _n=class extends k{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()}};M();w("blockquote-ui",_n);R();var Df=[{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}],Vn=class extends k{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=Df.find(o=>i<=o.limit)||Df[Df.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()}};M();w("relative-time-ui",Vn);R();var jn=class extends k{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")}};M();w("number-format-ui",jn);R();var Nf=["Weak","Fair","Good","Strong"];function wP(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 Fn=class extends k{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=`
|
|
236
|
+
[{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#m(),this.#y()}get data(){return this.#t}#p=!1;#m(){if(this.#p)return;let t=this.#g();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.#p=!0)}#g(){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.#$),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#z),this.addEventListener("focus",this.#L),this.addEventListener("blur",this.#D),this.addEventListener("pointerover",this.#Z),this.addEventListener("pointermove",this.#B),this.addEventListener("pointerleave",this.#N),this.addEventListener("pointerdown",this.#q),this.addEventListener("click",this.#j),typeof ResizeObserver<"u"&&(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.#y()})))}),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.#y()}#b(){let t=this.clientWidth||300,e=this.clientHeight||0,i=vP.std,r=this.#t.length||1,n=Math.max(t,120),o=this.hasAttribute("resize")||this.style.height,a=xP[this.ratio],l=a?Math.round(n/a):o&&e>40?e:Math.round(n/i.ratio),h=parseFloat(getComputedStyle(this).maxHeight);isFinite(h)&&h>0&&l>h&&(l=Math.round(h));let c=n/Math.max(l,1),u=a?this.ratio:c>=kv.wide?"3:2":c<=kv.tall?"2:3":"1:1";this.getAttribute("data-ratio-resolved")!==u&&this.setAttribute("data-ratio-resolved",u);let d=Math.min(n,l),f=this.size||(d<150?"sm":d<300?"md":"lg"),p=f==="sm"?9:f==="md"?10:11,m=p,g=f==="sm"?8:f==="md"?9:10,b=this.#f();this.getAttribute("data-labels-resolved")!==b&&this.setAttribute("data-labels-resolved",b);let A=b==="chip",x=this.#u("--chart-chrome-inset",8),S=this.#u("--chart-band-gap",4),v=Math.max(x,this.#u("--card-radius",x)),E=this.#u("--chart-chip-font-size",p),O=this.#u("--chart-chip-pad-x",6),$=this.#u("--chart-chip-pad-y",4),C=this.#u("--chart-min-plot-height-chips",180),Q=this.#u("--chart-min-plot-height-grid",120),T=A?l<Q?"bare":l<C?"no-x-chrome":"full":"full",P=this.noGrid,L=u==="3:2"?1:.8,D=P?0:p*3.2*L,N=!!this.x,B=A?{top:0,right:0,bottom:0,left:0}:{top:P?2:p*1.6,right:P?2:p*1.2,bottom:!N||P?2:p*2.2*L,left:D},Y=n-B.left-B.right,H=Math.max(4,Y/r*.6);return{width:n,height:l,pad:B,fontSize:p,labelSize:m,valueSize:g,barMinW:H,plotW:Y,n:r,sizeClass:f,ratioResolved:u,labelsResolved:b,chipMode:A,chromeInset:x,bandGap:S,cornerClearance:v,chipFontSize:E,chipPadX:O,chipPadY:$,minPlotHeightChips:C,minPlotHeightGrid:Q,degradeStage:T}}#O=null;#y(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#O&&(this.#O=t.cloneNode(!0)),this.innerHTML="",this.#O&&this.appendChild(this.#O.cloneNode(!0)),!this.#t.length){this.removeAttribute("has-data");return}this.setAttribute("has-data",""),this.#o=null;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.#ct());break;case"line":({svg:r,viewBox:n}=this.#ut());break;case"pie":({svg:r,viewBox:n}=this.#ft());break;case"donut":({svg:r,viewBox:n}=this.#pt());break;case"radar":({svg:r,viewBox:n}=this.#mt());break;case"sparkline":({svg:r,viewBox:n}=this.#gt());break;case"segments":({svg:r,viewBox:n}=this.#kt());break;case"area":({svg:r,viewBox:n}=this.#bt());break;case"scatter":({svg:r,viewBox:n}=this.#Ot());break;case"radial-bar":({svg:r,viewBox:n}=this.#yt());break;case"gauge":({svg:r,viewBox:n}=this.#vt());break;case"funnel":({svg:r,viewBox:n}=this.#xt());break;case"treemap":({svg:r,viewBox:n}=this.#St());break;case"sankey":({svg:r,viewBox:n}=this.#wt());break;case"composed":({svg:r,viewBox:n}=this.#At());break;case"stacked-bar":({svg:r,viewBox:n}=this.#Ct());break;case"grouped-bar":({svg:r,viewBox:n}=this.#Pt());break;case"multi-line":({svg:r,viewBox:n}=this.#Tt());break;default:({svg:r,viewBox:n}=this.#ct());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.#A()){let o=this.#Lt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#v(t,e){return e?` data-slice="${t}" data-series-key="${ft(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#S(t,e){return e?` data-slice="${t}" data-series-key="${ft(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#x=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#$),document.removeEventListener("pointerdown",this.#_),this.removeEventListener("keydown",this.#z),this.removeEventListener("focus",this.#L),this.removeEventListener("blur",this.#D),this.removeEventListener("pointerover",this.#Z),this.removeEventListener("pointermove",this.#B),this.removeEventListener("pointerleave",this.#N),this.removeEventListener("pointerdown",this.#q),this.removeEventListener("click",this.#j),this.#J()}#A(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#E(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#$=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.#y())};#k(t){return!!t&&this.#a.has(t)}#w(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let r=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),`${r||"$"}${xv(e)}`}default:return xv(e)}}#C=-1;#Q(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#P(t){let e=this.#Q();if(!e.length){this.#T();return}this.#C=Math.max(0,Math.min(t,e.length-1)),this.#M(),this.#R()}#M(){let t=this.#Q();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#C];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#T(){this.#C=-1;for(let t of this.#Q())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#R(){let t=this.#Q()[this.#C];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#F(t,i)}#I(){let t=this.#Q()[this.#C];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.#Y(t,i)}))}#L=()=>{this.#C===-1&&this.#P(0)};#D=()=>{this.#T(),this.#X&&this.#U()};#z=t=>{let e=this.#Q();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#P(this.#C+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#P(Math.max(0,this.#C-1));break;case"Home":t.preventDefault(),this.#P(0);break;case"End":t.preventDefault(),this.#P(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#I();break;case"Escape":t.preventDefault(),this.#T(),this.#X&&this.#U();break}};#X=null;#Z=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#nt(e,t),this.#F(e,t))};#B=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#X&&this.#U(),this.#J();this.#nt(e,t),e!==this.#X&&this.#F(e,t)};#N=t=>{t&&t.pointerType==="touch"||(this.#J(),this.#X&&this.#U())};#q=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#X&&this.#U(),this.#J();this.#nt(e,t),e!==this.#X&&this.#F(e,t),document.addEventListener("pointerdown",this.#_)};#_=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#J(),this.#X&&this.#U(),document.removeEventListener("pointerdown",this.#_)))};#j=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#Y(e,t)}))};#F(t,e){this.#X=t,this.dots==="hover"&&this.#et(t),this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#Y(t,e)}))}#U(){this.#X=null,this.dots==="hover"&&this.#G(),this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#et(t){let e=t?.previousElementSibling;this.#o&&this.#o!==e&&this.#o.removeAttribute("data-dot-active"),e&&e.hasAttribute("data-dot")?(e.setAttribute("data-dot-active",""),this.#o=e):this.#o=null}#G(){this.#o&&this.#o.removeAttribute("data-dot-active"),this.#o=null}#Y(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.#rt(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}}#rt(t,e){if(t==null)return null;let i=this.x,r=this.#W();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.#k(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}})}#nt(t,e){if(this.#E())return;let{tipLabel:i,tipValue:r,tipPct:n,tipSeries:o}=t.dataset;if(!this.#x){let g=document.createElement("div");g.setAttribute("popover","manual"),g.setAttribute("role","tooltip"),g.classList.add("chart-tooltip-popup"),document.body.appendChild(g),this.#x=g}let a=[];if(o&&a.push(`<span data-tip-role="series">${ft(o)}</span>`),i&&a.push(`<span data-tip-role="label">${ft(i)}</span>`),r!==void 0){let g=n!==void 0?` <span data-tip-role="pct">(${n}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#w(r)}${g}</span>`)}this.#x.innerHTML=a.join("");try{this.#x.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#x.offsetWidth||0,f=this.#x.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.#x.style.left=`${p}px`,this.#x.style.top=`${m}px`}#J(){if(this.#x){try{this.#x.hidePopover()}catch{}this.#x.remove(),this.#x=null}}#W(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#ot(t,e){switch(this.dots){case"none":return!1;case"last":return t===e-1;default:return!0}}#tt(t,e,i,r,n,o,a={}){let l=n,h=o?.fontSize||10,c=o?.labelSize||h,u=!!o?.chipMode,d=o?.degradeStage||"full",f="",p="",m=i;if((o?.sizeClass==="sm"||a.thinGrid)&&i.length>4&&(m=i.filter((g,b)=>b%2===0||b===i.length-1)),!this.noGrid&&d!=="bare"){let b=i[i.length-1]-i[0]||1;if(a.vertical){if(r&&r.length){let A=t-l.left-l.right,x=r.length-1,S=a.pointAligned?A/Math.max(x,1):A/r.length,v=Math.max(1,Math.round(r.length/3));for(let E=0;E<r.length;E++){if(E%v!==0&&E!==x)continue;let O=a.pointAligned?l.left+S*E:l.left+S*E+S/2;f+=`<line data-chart-grid x1="${O}" y1="${l.top}" x2="${O}" y2="${e-l.bottom}"/>`}}}else for(let A of m){let x=l.top+(e-l.top-l.bottom)*(1-(A-i[0])/b);f+=`<line data-chart-grid x1="${l.left}" y1="${x}" x2="${t-l.right}" y2="${x}"/>`}if(u)p+=this.#at(m,i,b,t,e,l,o);else for(let A of m){let x=l.top+(e-l.top-l.bottom)*(1-(A-i[0])/b);f+=`<text data-y-label x="${l.left-4}" y="${x+h*.35}" text-anchor="end" font-size="${h}">${this.#w(A)}</text>`}if(r&&d!=="no-x-chrome")if(u)p+=this.#it(r,t,e,l,o,a);else{let A=t-l.left-l.right,x=A/r.length,S=r.length-1,v=new Set;if(a.xTickMode==="sparse"&&S>1)v.add(0),v.add(Math.round(S/2)),v.add(S);else if(a.xTickMode==="everyNth"&&S>1){let O=Math.max(2,Math.ceil(r.length/4));for(let $=0;$<=S;$+=O)v.add($);v.add(S)}else{let $=r.reduce((Q,T)=>Math.max(Q,String(T).length),1)*c*.6+c*.75,C=Math.max(1,Math.ceil($/x));for(let Q=0;Q<r.length;Q++)Q%C!==0&&Q!==S||Q!==S&&S-Q<C||v.add(Q)}let E=A/Math.max(S,1);for(let O of v){let $=a.pointAligned?l.left+E*O:l.left+x*O+x/2,C=ft(a.abbreviateLabels?Ue(r[O],4):r[O]);f+=`<text data-x-label x="${$}" y="${e-h*.5}" text-anchor="middle" font-size="${c}">${C}</text>`}}}return{svg:f,chipSvg:p}}#at(t,e,i,r,n,o,a){let{chromeInset:l,chipFontSize:h,chipPadX:c,chipPadY:u,cornerClearance:d}=a,f=h*.6+u,p=h*1.2+u*2,m=t.map(S=>{let v=o.top+(n-o.top-o.bottom)*(1-(S-e[0])/i),E=Math.min(Math.max(v,l+f),n-l-f),$=E-f<=d||E+f>=n-d?d:l,C=this.#w(S),Q=String(C).length*h*.6+c*2;return{cy:E,cx:$,rw:Q,text:C}});if(!m.length)return"";let g=m.length-1,b=[m[0]];for(let S=1;S<g;S++){let v=m[S],E=b[b.length-1];Math.abs(v.cy-E.cy)>=p&&b.push(v)}for(m.length>1&&b.push(m[g]);b.length>2;){let S=b[b.length-2],v=b[b.length-1];if(Math.abs(v.cy-S.cy)<p)b.splice(b.length-2,1);else break}if(b.length===2){let[S,v]=b;if(Math.abs(S.cy-v.cy)<p){let E=(S.cy+v.cy)/2,[O,$]=S.cy<=v.cy?[S,v]:[v,S];O.cy=Math.min(O.cy,E-p/2),$.cy=Math.max($.cy,E+p/2)}}let A=b,x="";for(let S of A)x+=`<rect data-chip data-chip-axis="y" x="${S.cx}" y="${S.cy-p/2}" width="${S.rw}" height="${p}"/>`,x+=`<text data-chip-label data-chip-axis="y" x="${S.cx+c}" y="${S.cy}" dominant-baseline="central" font-size="${h}">${S.text}</text>`;return x}#it(t,e,i,r,n,o){let{chromeInset:a,bandGap:l,chipFontSize:h,chipPadX:c,chipPadY:u,cornerClearance:d}=n,f=e-r.left-r.right,p=t.length-1,m=o.pointAligned?f/Math.max(p,1):f/t.length,g=h*1.2+u*2,b=i-Math.max(a,l)-g/2,A=t.map((v,E)=>{let O=o.pointAligned?r.left+m*E:r.left+m*E+m/2,$=o.abbreviateLabels?Ue(v,4):v,C=ft($),Q=String($).length*h*.6+c*2;return{cx0:O,rw:Q,text:C}});if(!A.length)return"";for(let v of A)v.cx=Math.min(Math.max(v.cx0,a+v.rw/2),e-a-v.rw/2);A[0].cx=Math.max(A[0].cx,d+A[0].rw/2),A[p].cx=Math.min(A[p].cx,e-d-A[p].rw/2);let x=[A[0]];for(let v=1;v<A.length-1;v++){let E=A[v],O=x[x.length-1];E.cx-E.rw/2>=O.cx+O.rw/2&&x.push(E)}for(A.length>1&&x.push(A[p]);x.length>2;){let v=x[x.length-2],E=x[x.length-1];if(E.cx-E.rw/2<v.cx+v.rw/2)x.splice(x.length-2,1);else break}if(x.length===2){let[v,E]=x;if(v.cx+v.rw/2>E.cx-E.rw/2){let O=(v.cx+E.cx)/2;v.cx=Math.min(v.cx,O-v.rw/2),E.cx=Math.max(E.cx,O+E.rw/2)}}let S="";for(let v of x)S+=`<rect data-chip data-chip-axis="x" x="${v.cx-v.rw/2}" y="${b-g/2}" width="${v.rw}" height="${g}"/>`,S+=`<text data-chip-label data-chip-axis="x" x="${v.cx}" y="${b}" text-anchor="middle" dominant-baseline="central" font-size="${h}">${v.text}</text>`;return S}#V(){let t=this.x,e=this.#t;if(this.today){for(let i=0;i<e.length;i++)if(String(e[i]?.[t]??"")===String(this.today))return i;return-1}return e.findIndex(i=>i&&i.today)}#st(t,e,i){let r=i.sizeClass==="sm"?2.5:3.5,n=Math.max(6,i.fontSize),o=i.chipMode?-1:1,a=i.chipMode?e-Math.max(i.chromeInset??0,r):e;return`<circle data-today-dot cx="${t}" cy="${a}" r="${r}"/><line data-today-tick x1="${t}" y1="${a}" x2="${t}" y2="${a+o*n}"/>`}#lt(t,e,i){let r=i.sizeClass==="sm"?2.5:3.5,n=Math.max(6,i.fontSize);return`<circle data-today-dot cx="${e}" cy="${t}" r="${r}"/><line data-today-tick x1="${e}" y1="${t}" x2="${e-n}" y2="${t}"/>`}#K(t){return t&&t.provisional?" data-provisional":""}#ht(t,e,i,r,n){let o="",a=-1,l=h=>{if(a<0)return;let c=Math.max(a-1,0),u=t.slice(c,h);if(u.length>=2){let d=u[0].x,f=u[u.length-1].x,p=Math.min(...u.map(m=>m.y));o+=`<rect data-area-provisional-fade x="${d}" y="${p}" width="${Math.max(f-d,0)}" height="${Math.max(i-p,0)}"/>`,o+=`<path data-line-provisional d="${Cs(u,n)}"/>`}a=-1};for(let h=0;h<t.length;h++){let c=!!(e[h]&&e[h].provisional);c&&a<0?a=h:!c&&a>=0&&l(h)}return l(t.length),o}#ct(){let t=this.#b(),e=this.#t,i=this.#W()[0]||this.y,r=e.map(O=>+(O[i]??0)),n=e.map(O=>O[this.x]??""),o=r,a=t.ratioResolved==="1:1"&&r.length>wv;a&&({labels:n,vals:r}=Sv(n,r,wv,!1));let l=ts(...this.#c(r),5),h=l[l.length-1],c=l[0];if(t.ratioResolved==="2:3")return this.#dt(t,n,r,l,h,a?[]:e);let{width:u,height:d,pad:f}=t,p=d-f.top-f.bottom,g=(u-f.left-f.right)/n.length,b=g*.6,A=(g-b)/2,{svg:x,chipSvg:S}=this.#tt(u,d,l,n,f,t,{abbreviateLabels:t.ratioResolved==="1:1"}),v=!this.noValues&&t.sizeClass!=="sm",E=!this.noAverage&&o.length>1&&t.sizeClass!=="sm"&&!this.noGrid;for(let O=0;O<n.length;O++){let $=r[O],C=h-c?($-c)/(h-c)*p:0,Q=this.#h(C,p),T=f.left+g*O+A,P=f.top+p-Q,L=a?"":this.#K(e[O]);x+=`<path data-bar${L}${ht({label:n[O],value:$})} d="${tc(T,P,b,Q,this.#l())}"/>`,v&&(x+=`<text data-value x="${T+b/2}" y="${P-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#w($)}</text>`)}if(E){let O=o.reduce((Q,T)=>Q+T,0)/o.length,$=h-c?(O-c)/(h-c)*p:0,C=f.top+p-this.#h($,p);x+=`<line data-avg x1="${f.left}" y1="${C}" x2="${u-f.right}" y2="${C}"/>`,x+=`<text data-avg-label x="${u-f.right+2}" y="${C+3}" text-anchor="start" font-size="${t.valueSize}">${this.#w(O)}</text>`,x+=`<line data-hit${ht({label:"Average",value:O})} x1="${f.left}" y1="${C}" x2="${u-f.right}" y2="${C}" stroke="transparent" stroke-width="12"/>`}if(!a){let O=this.#V();O>-1&&O<n.length&&(x+=this.#st(f.left+g*O+A+b/2,f.top+p,t))}return x+=S,{svg:x,viewBox:`0 0 ${u} ${d}`}}#dt(t,e,i,r,n,o=[]){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce((C,Q)=>Math.max(C,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,b=(l-p.top-p.bottom)/e.length,A=b*.6,x=(b-A)/2,S="";if(!u){let C=r[r.length-1]-r[0]||1;for(let Q of r){let T=p.left+m*((Q-r[0])/C);S+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,S+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#w(Q)}</text>`}}let v=!this.noValues,E=!this.noAverage&&i.length>1&&!u,O=r[0];for(let C=0;C<e.length;C++){let Q=i[C],T=n-O?(Q-O)/(n-O)*m:0,P=this.#h(T,m),L=p.top+b*C+x,D=p.left,N=this.#K(o[C]);S+=`<text data-x-label x="${p.left-6}" y="${L+A/2+h*.35}" text-anchor="end" font-size="${c}">${ft(e[C])}</text>`,S+=`<path data-bar${N}${ht({label:e[C],value:Q})} d="${If(D,L,P,A,this.#l())}"/>`,v&&(S+=`<text data-value x="${D+P+4}" y="${L+A/2+h*.35}" text-anchor="start" font-size="${t.valueSize}">${this.#w(Q)}</text>`)}if(E){let C=i.reduce((P,L)=>P+L,0)/i.length,Q=n-O?(C-O)/(n-O)*m:0,T=p.left+this.#h(Q,m);S+=`<line data-avg x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,S+=`<line data-hit${ht({label:"Average",value:C})} x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}" stroke="transparent" stroke-width="12"/>`}let $=this.#V();return $>-1&&$<e.length&&o.length&&(S+=this.#lt(p.top+b*$+x+A/2,p.left,t)),{svg:S,viewBox:`0 0 ${a} ${l}`}}#ut(){let t=this.#b(),e=this.#t,i=this.#W()[0]||this.y,r=e.map(P=>+(P[i]??0)),n=e.map(P=>P[this.x]??""),o=ts(...this.#c(r),5),a=o[o.length-1],l=o[0],{width:h,height:c,pad:u}=t,d=c-u.top-u.bottom,p=(h-u.left-u.right)/Math.max(e.length-1,1),m=this.type==="area",g=t.ratioResolved,{svg:b,chipSvg:A}=this.#tt(h,c,o,n,u,t,{thinGrid:g!=="3:2",vertical:m&&g==="2:3",xTickMode:g==="2:3"?"sparse":g==="1:1"?"everyNth":void 0,pointAligned:!0}),x=r.map((P,L)=>{let D=u.left+p*L,N=u.top+d-(a-l?(P-l)/(a-l)*d:0),B=this.#d(N,u.top,u.top+d);return{x:D,y:B,v:P,label:n[L]}}),S=u.top+d,v=Math.max(0,Math.min(1,this.smooth));b+=`<path data-area d="${Rf(x,S,v)}"/>`,b+=`<path data-line d="${Cs(x,v)}"/>`,b+=this.#ht(x,e,S,t,v);let E=t.sizeClass==="sm",O=E?1.5:3,$=Math.max(O,10),C=!this.noValues&&!E,Q=!this.noAverage&&r.length>1&&!E&&!this.noGrid;if(x.forEach((P,L)=>{let D=this.#K(e[L]);this.#ot(L,x.length)&&(b+=`<circle data-dot${D} cx="${P.x}" cy="${P.y}" r="${O}"/>`),b+=`<circle data-hit${ht({label:P.label,value:P.v})} cx="${P.x}" cy="${P.y}" r="${$}" fill="transparent"/>`,C&&(b+=`<text data-value x="${P.x}" y="${P.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#w(P.v)}</text>`)}),Q){let P=r.reduce((N,B)=>N+B,0)/r.length,L=u.top+d-(a-l?(P-l)/(a-l)*d:0),D=this.#d(L,u.top,u.top+d);b+=`<line data-avg x1="${u.left}" y1="${D}" x2="${h-u.right}" y2="${D}"/>`,b+=`<text data-avg-label x="${h-u.right+2}" y="${D+3}" text-anchor="start" font-size="${t.valueSize}">${this.#w(P)}</text>`,b+=`<line data-hit${ht({label:"Average",value:P})} x1="${u.left}" y1="${D}" x2="${h-u.right}" y2="${D}" stroke="transparent" stroke-width="12"/>`}let T=this.#V();return T>-1&&T<x.length&&(b+=this.#st(x[T].x,S,t)),b+=A,{svg:b,viewBox:`0 0 ${h} ${c}`}}#ft(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(P=>+(P[e]??0)),r=i.reduce((P,L)=>P+L,0)||1,n=t.map(P=>P[this.x]??""),o=this.#b(),{width:a,height:l,fontSize:h,valueSize:c}=o,u=o.ratioResolved,d=h,f=8,p=20,m=P=>(P+f)*c*.62+d+4,g=c*1.2+d+4,b=Math.max(0,a/2-p),A=Math.floor((b-d-4)/(c*.62))-f,x=n.reduce((P,L)=>Math.max(P,String(L).length),1),S=Math.max(4,Math.min(14,A,x)),v=m(S),E=u==="1:1"?Math.max(p,Math.min(a/2-v,l/2-g)):Math.max(30,Math.min(a,l)*.42),O=u==="3:2"?Math.max(E+8,a*.32):a/2,$=u==="2:3"?Math.min(l/2,E+h*1.5):l/2,C=u==="1:1",Q="",T=-Math.PI/2;for(let P=0;P<i.length;P++){let L=i[P]/r*Math.PI*2;if(L===0)continue;let D=T+L,N=(i[P]/r*100).toFixed(1),B=` data-slice="${P%10}"${ht({label:n[P],value:i[P],pct:N})}`;if(Math.abs(L-Math.PI*2)<.001?Q+=`<circle${B} cx="${O}" cy="${$}" r="${E}"/>`:Q+=`<path${B} d="${yP(O,$,E,T,D)}"/>`,C){let Y=T+L/2,H=Ft(O,E+d,Y),K=Wt($,E+d,Y),nt=Math.cos(Y),ut=Math.abs(nt)<.15?"middle":nt>0?"start":"end",bt=`${ft(Ue(n[P],S))} (${N}%)`;Q+=`<text data-ring-label x="${H}" y="${K}" text-anchor="${ut}" dominant-baseline="central" font-size="${c}">${bt}</text>`}T=D}return this.#H=t.map((P,L)=>({label:n[L],value:i[L],pct:(i[L]/r*100).toFixed(1),slot:L%10})),{svg:Q,viewBox:`0 0 ${a} ${l}`}}#pt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(x=>+(x[e]??0)),r=i.reduce((x,S)=>x+S,0)||1,n=t.map(x=>x[this.x]??""),o=this.#b(),{width:a,height:l,fontSize:h}=o,c=o.ratioResolved,u=Math.max(30,Math.min(a,l)*(c==="1:1"?.46:.42)),d=u*.72,f=c==="3:2"?Math.max(u+8,a*.32):a/2,p=c==="2:3"?Math.min(l/2,u+h*1.5):l/2,m="",g=-Math.PI/2;for(let x=0;x<i.length;x++){let S=i[x]/r*Math.PI*2;if(S===0)continue;let v=g+S,E=(i[x]/r*100).toFixed(1),O=` data-slice="${x%10}"${ht({label:n[x],value:i[x],pct:E})}`;Math.abs(S-Math.PI*2)<.001?(m+=`<circle${O} cx="${f}" cy="${p}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,m+=`<path${O} d="M ${f-u} ${p} A ${u} ${u} 0 1 1 ${f+u} ${p} A ${u} ${u} 0 1 1 ${f-u} ${p} Z M ${f-d} ${p} A ${d} ${d} 0 1 0 ${f+d} ${p} A ${d} ${d} 0 1 0 ${f-d} ${p} Z" fill-rule="evenodd"/>`):m+=`<path${O} d="${Mf(f,p,u,d,g,v,this.#l())}"/>`,g=v}let b=Math.max(14,Math.round(u*.32)),A=Math.max(9,Math.round(u*.16));return m+=`<text data-donut-total x="${f}" y="${p}" text-anchor="middle" dominant-baseline="central" font-size="${b}">${this.#w(r)}</text>`,m+=`<text data-donut-label x="${f}" y="${p+b}" text-anchor="middle" dominant-baseline="central" font-size="${A}">Total</text>`,this.#H=t.map((x,S)=>({label:n[S],value:i[S],pct:(i[S]/r*100).toFixed(1),slot:S%10})),{svg:m,viewBox:`0 0 ${a} ${l}`}}#mt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(C=>+(C[e]??0)),r=t.map(C=>C[this.x]??""),n=Math.max(...i)||1,o=t.length,a=this.#b(),{width:l,height:h,fontSize:c}=a,u=a.ratioResolved,d=u==="1:1",f=u==="2:3",p=d?c*1.8:c*3.5,m=f?h*.6:h,g=l/2,b=f?m/2:h/2,A=Math.max(40,Math.min(l,m)/2-p),x="",S=Math.PI*2/o;for(let C=1;C<=3;C++){let Q=A*C/3,T="";for(let P=0;P<o;P++){let L=-Math.PI/2+S*P,D=g+Q*Math.cos(L),N=b+Q*Math.sin(L);T+=(P===0?"M":"L")+` ${D} ${N}`}T+=" Z",x+=`<path data-chart-grid d="${T}"/>`}for(let C=0;C<o;C++){let Q=-Math.PI/2+S*C,T=g+A*Math.cos(Q),P=b+A*Math.sin(Q);x+=`<line data-chart-grid x1="${g}" y1="${b}" x2="${T}" y2="${P}"/>`}let v="",E=[];for(let C=0;C<o;C++){let Q=-Math.PI/2+S*C,T=i[C]/n*A,P=g+T*Math.cos(Q),L=b+T*Math.sin(Q);v+=(C===0?"M":"L")+` ${P} ${L}`,E.push({px:P,py:L})}v+=" Z",x+=`<path data-radar-fill d="${v}"/>`,x+=`<path data-radar-line d="${v}"/>`;let O=Math.max(c,10);for(let C=0;C<o;C++){let{px:Q,py:T}=E[C];x+=`<circle data-hit${ht({label:r[C],value:i[C]})} cx="${Q}" cy="${T}" r="${O}" fill="transparent"/>`}let $=d?c*.6:c*1.3;for(let C=0;C<o;C++){let Q=-Math.PI/2+S*C,T=g+(A+$)*Math.cos(Q),P=b+(A+$)*Math.sin(Q),L=Math.abs(Math.cos(Q))<.1?"middle":Math.cos(Q)>0?"start":"end",D=ft(f?Ue(r[C],5):r[C]);x+=`<text data-x-label x="${T}" y="${P}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${D}</text>`}return{svg:x,viewBox:`0 0 ${l} ${h}`}}#gt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(b=>+(b[e]??0)),r=ts(0,Math.max(...i),5),n=r[r.length-1],o=this.clientWidth||120,a=this.clientHeight||32,l=Math.max(40,o),h=Math.max(16,a),c=l/Math.max(i.length-1,1),u=Math.max(2,Math.min(6,h*.1)),d=t.map(b=>b[this.x]??""),f=i.map((b,A)=>({x:c*A,y:h-(n?b/n*(h-u*2):0)-u,v:b,label:d[A]})),p=Math.max(0,Math.min(1,this.smooth)),m="";m+=`<path data-area d="${Rf(f,h,p)}"/>`,m+=`<path data-line d="${Cs(f,p)}"/>`;let g=Math.max(c/2,6);for(let b of f)m+=`<circle data-hit${ht({label:b.label,value:b.v})} cx="${b.x}" cy="${b.y}" r="${g}" fill="transparent"/>`;return{svg:m,viewBox:`0 0 ${l} ${h}`}}#bt(){return this.#ut()}#Ot(){let t=this.#b(),e=this.#t,i=this.#W()[0]||this.y,r=e.map(O=>+(O[i]??0)),n=e.map(O=>O[this.x]??""),o=t.ratioResolved,a=o==="2:3"?8:5,l=ts(...this.#c(r),a),h=l[l.length-1],c=l[0],{width:u,height:d,pad:f}=t,p=d-f.top-f.bottom,g=(u-f.left-f.right)/Math.max(e.length-1,1),{svg:b,chipSvg:A}=this.#tt(u,d,l,n,f,t,{abbreviateLabels:o==="1:1"}),x=t.sizeClass==="sm"?2.5:4,S=o==="1:1"?x*.85:x,v=Math.max(S*2,10);for(let O=0;O<r.length;O++){let $=f.left+g*O,C=f.top+p-(h-c?(r[O]-c)/(h-c)*p:0),Q=this.#d(C,f.top,f.top+p),T=this.#K(e[O]);b+=`<circle data-dot data-scatter${T} cx="${$}" cy="${Q}" r="${S}"/>`,b+=`<circle data-hit${ht({label:n[O],value:r[O]})} cx="${$}" cy="${Q}" r="${v}" fill="transparent"/>`}let E=this.#V();return E>-1&&E<r.length&&(b+=this.#st(f.left+g*E,f.top+p,t)),b+=A,{svg:b,viewBox:`0 0 ${u} ${d}`}}#yt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(O=>+(O[e]??0)),r=t.map(O=>O[this.x]??""),n=Math.max(...i)||1,o=this.#b(),{width:a,height:l,fontSize:h,valueSize:c}=o,u=o.ratioResolved,d=a/2,f=l/2,p=Math.max(30,Math.min(a,l)*.45),m=p*.3,g=i.length||1,b=(p-m)/g,A=Math.min(2,b*.15),x=u==="1:1",S=u==="3:2"?0:-Math.PI/2,v=O=>x?-Math.PI/2+Math.PI*2*O/g:S,E="";for(let O=0;O<i.length;O++){let $=m+b*O+A/2,C=m+b*(O+1)-A/2,Q=($+C)/2,T=C-$,P=2*Math.PI*Q,L=Math.max(0,Math.min(1,i[O]/n))*P,N=v(O)*180/Math.PI;if(E+=`<circle data-radial-track cx="${d}" cy="${f}" r="${Q}" fill="none" stroke-width="${T}"/>`,L<=0)continue;let B=(i[O]/n*100).toFixed(1),Y=ht({label:r[O],value:i[O],pct:B}),H=Math.abs(L-P)<.5,K=H?"butt":"round",nt=H?`${P} 0`:`${L} ${P-L}`;E+=`<circle data-slice="${O%10}"${Y} data-radial-bar cx="${d}" cy="${f}" r="${Q}" fill="none" stroke-width="${T}" stroke-linecap="${K}" stroke-dasharray="${nt}" transform="rotate(${N} ${d} ${f})"/>`}if(x){let O=h;for(let $=0;$<i.length;$++){let C=v($),Q=Ft(d,p+O,C),T=Wt(f,p+O,C),P=Math.cos(C),L=Math.abs(P)<.15?"middle":P>0?"start":"end";E+=`<text data-ring-label x="${Q}" y="${T}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${ft(r[$])}</text>`}}return this.#H=t.map((O,$)=>({label:r[$],key:r[$],value:i[$],pct:(i[$]/n*100).toFixed(1),slot:$%10})),{svg:E,viewBox:`0 0 ${a} ${l}`}}#vt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(Q=>+(Q[e]??0)),r=i.reduce((Q,T)=>Q+T,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.#b(),{width:h,height:c,fontSize:u}=l,d=l.ratioResolved,f=d==="3:2",p=d==="2:3",m=Math.max(40,Math.min(h*(d==="1:1"?.48:.45),c*(p?.46:.6))),g=m*.72,b=(m-g)/2,A=f?Math.max(m+8,h*.34):h/2,x=p?Math.min(c*.5,m+u*1.3):c*.68,S="";if(S+=`<path data-radial-track d="${Mf(A,x,m,g,Math.PI,2*Math.PI,b)}"/>`,a>0){let Q=Math.PI+Math.PI*a,T=ht({label:t[0]?.[this.x]??"Value",value:n,pct:(a*100).toFixed(1)});S+=`<path data-slice="0"${T} data-gauge-fill d="${Mf(A,x,m,g,Math.PI,Q,b)}"/>`}let v=Math.max(18,Math.round(m*.42)),E=Math.max(10,Math.round(m*.2)),O,$,C;return f?(O=A+m+u*1.2,$=x-m*.15,C="start"):p?(O=A,$=x+v*.7,C="middle"):(O=A,$=x-m*.15,C="middle"),S+=`<text data-gauge-value x="${O}" y="${$}" text-anchor="${C}" dominant-baseline="central" font-size="${v}">${this.#w(n)}</text>`,o!==n&&(S+=`<text data-gauge-max x="${O}" y="${$+v*.8}" text-anchor="${C}" dominant-baseline="central" font-size="${E}">of ${this.#w(o)}</text>`),{svg:S,viewBox:`0 0 ${h} ${c}`}}#xt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(O=>+(O[e]??0)),r=t.map(O=>O[this.x]??""),n=i.length;if(n===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#b(),{width:l,height:h}=a,c=a.fontSize,u=a.ratioResolved;this.#H=t.map((O,$)=>({label:r[$],value:i[$],pct:(i[$]/o*100).toFixed(1),slot:$%10}));let d="";if(u==="3:2"){let O=Math.max(h*.16,c*2.2),$=c*.8,C=l-$*2,Q=h-O*2,T=C/n,P=Math.max(2,T*.08),L=O+Q/2;for(let D=0;D<n;D++){let N=i[D],B=D<n-1?i[D+1]:i[D],Y=N/o*(Q/2),H=B/o*(Q/2),K=$+T*D+P/2,nt=$+T*(D+1)-P/2,ut=(K+nt)/2,bt=(N/o*100).toFixed(1),kt=ht({label:r[D],value:N,pct:bt}),Tt=`M ${K} ${L-Y} L ${nt} ${L-H} L ${nt} ${L+H} L ${K} ${L+Y} Z`;if(d+=`<path data-slice="${D%10}" data-funnel-stage${kt} d="${Tt}"/>`,d+=`<text data-funnel-label x="${ut}" y="${O-c*.6}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${c}">${ft(r[D])}</text>`,d+=`<text data-funnel-value x="${ut}" y="${h-O+c*1.3}" text-anchor="middle" dominant-baseline="hanging" font-size="${c}">${this.#w(N)}</text>`,D>0){let Dt=(i[D]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${ut}" y="${h-O+c*2.5}" text-anchor="middle" dominant-baseline="hanging" font-size="${c*.85}">${Dt}%</text>`}}return{svg:d,viewBox:`0 0 ${l} ${h}`}}let f=u==="1:1",p=u==="2:3",m=f||p?c*.8:Math.max(l*.18,80),g=p?Math.max(l*.3,c*6):Math.max(l*.18,80),b=c*.8,A=l-m-g,S=(h-b*2)/n,v=Math.max(2,S*.08),E=m+A/2;for(let O=0;O<n;O++){let $=i[O],C=O<n-1?i[O+1]:i[O],Q=$/o*(A/2),T=C/o*(A/2),P=b+S*O+v/2,L=b+S*(O+1)-v/2,D=P+S/2-v/2,N=($/o*100).toFixed(1),B=ht({label:r[O],value:$,pct:N}),Y=`M ${E-Q} ${P} L ${E+Q} ${P} L ${E+T} ${L} L ${E-T} ${L} Z`;if(d+=`<path data-slice="${O%10}" data-funnel-stage${B} d="${Y}"/>`,f){let H=(Q+T)/2,K=Math.floor((H*2-c)/(c*.6));K>=2&&(d+=`<text data-funnel-label data-funnel-label-inline x="${E}" y="${D}" text-anchor="middle" dominant-baseline="central" font-size="${c}">${ft(Ue(r[O],K))}</text>`)}else d+=`<text data-funnel-label x="${m-8}" y="${D}" text-anchor="end" dominant-baseline="central" font-size="${c}">${ft(r[O])}</text>`;if(p){if(d+=`<text data-funnel-label data-funnel-label-right x="${l-g+8}" y="${D-c*.6}" text-anchor="start" dominant-baseline="central" font-size="${c}">${ft(r[O])}</text>`,d+=`<text data-funnel-value x="${l-g+8}" y="${D+c*.6}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#w($)}</text>`,O>0){let H=(i[O]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${l-g+8}" y="${D+c*1.7}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${H}%</text>`}}else if(d+=`<text data-funnel-value x="${l-g+8}" y="${D}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#w($)}</text>`,O>0){let H=(i[O]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${l-g+8}" y="${D+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${H}%</text>`}}return{svg:d,viewBox:`0 0 ${l} ${h}`}}#St(){let t=this.#t,e=this.#W()[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=this.#b(),{width:a,height:l,fontSize:h}=o,c=i.reduce((v,E)=>v+E,0)||1,u=o.ratioResolved,d=Array.from({length:n},(v,E)=>E).sort((v,E)=>i[E]-i[v]),f=u==="3:2"?Math.max(2,Math.ceil(Math.sqrt(n*2))):u==="2:3"?Math.max(1,Math.floor(Math.sqrt(n/2))):Math.max(1,Math.round(Math.sqrt(n))),p=[];for(let v=0;v<d.length;v+=f)p.push(d.slice(v,v+f));let m=p.map(v=>v.reduce((E,O)=>E+i[O],0)),g=m.reduce((v,E)=>v+E,0)||1,b=[],A=0;for(let v=0;v<p.length;v++){let E=m[v]/g*l,O=m[v]||1,$=0;for(let C of p[v]){let Q=i[C]/O*a;b.push({i:C,x:$,y:A,w:Q,h:E}),$+=Q}A+=E}let x="",S=2;for(let v of b){let E=(i[v.i]/c*100).toFixed(1),O=ht({label:r[v.i],value:i[v.i],pct:E});x+=`<rect data-slice="${v.i%10}" data-treemap-tile${O} x="${v.x+S}" y="${v.y+S}" width="${Math.max(0,v.w-S*2)}" height="${Math.max(0,v.h-S*2)}" rx="${this.#l()}"/>`;let $=v.x+8,C=v.w>h*4,Q=C&&v.h>h*2.5,T=C&&!Q&&v.h>h*1.2,P=u==="2:3"?8:20;if(Q)x+=`<text data-treemap-label x="${$}" y="${v.y+h+4}" font-size="${h}" dominant-baseline="hanging">${ft(Ue(r[v.i],P))}</text>`,x+=`<text data-treemap-value x="${$}" y="${v.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#w(i[v.i])}</text>`;else if(T){let L=v.y+v.h/2;x+=`<text data-treemap-label x="${$}" y="${L}" font-size="${h}" dominant-baseline="central">${ft(Ue(r[v.i],P))}</text>`}}return this.#H=t.map((v,E)=>({label:r[E],value:i[E],pct:(i[E]/c*100).toFixed(1),slot:E%10})),{svg:x,viewBox:`0 0 ${a} ${l}`}}#wt(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let O of t){let $=O.source??O.from??"",C=O.target??O.to??"",Q=+(O.value??O.v??0);e.has($)||e.set($,{name:$,flow:0}),i.has(C)||i.set(C,{name:C,flow:0}),e.get($).flow+=Q,i.get(C).flow+=Q}let r=this.#b(),{width:n,height:o,fontSize:a}=r,l=r.ratioResolved,h=[...e.values()],c=[...i.values()],u=h.reduce((O,$)=>O+$.flow,0)||1,d=c.reduce((O,$)=>O+$.flow,0)||1,f="";if(l==="2:3"){let O=Math.max(8,o*.05),$=O+a*1.8,C=n*.5,Q=Math.min(a*.8,C/Math.max(1,Math.max(h.length,c.length)-1)),T=Math.max(1,n-Q*Math.max(0,h.length-1)),P=Math.max(1,n-Q*Math.max(0,c.length-1)),L=0;for(let N of h){let B=N.flow/u*T;N.x0=L,N.x1=L+B,N.cursor=L,L+=B+Q}L=0;for(let N of c){let B=N.flow/d*P;N.x0=L,N.x1=L+B,N.cursor=L,L+=B+Q}let D=Math.min(this.#l(),O/2);h.forEach((N,B)=>{let Y=ht({label:N.name,value:N.flow});f+=`<rect data-sankey-node data-slice="${B%10}"${Y} x="${N.x0}" y="${$-O}" width="${N.x1-N.x0}" height="${O}" rx="${D}"/>`,f+=`<text data-sankey-label x="${(N.x0+N.x1)/2}" y="${$-O-6}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${a}">${ft(Ue(N.name,10))}</text>`}),c.forEach((N,B)=>{let Y=ht({label:N.name,value:N.flow});f+=`<rect data-sankey-node data-slice="${(h.length+B)%10}"${Y} x="${N.x0}" y="${o-$}" width="${N.x1-N.x0}" height="${O}" rx="${D}"/>`,f+=`<text data-sankey-label x="${(N.x0+N.x1)/2}" y="${o-$+O+a+2}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${a}">${ft(Ue(N.name,10))}</text>`});for(let N of t){let B=e.get(N.source??N.from??""),Y=i.get(N.target??N.to??"");if(!B||!Y)continue;let H=+(N.value??N.v??0);if(H<=0)continue;let K=H/u*T,nt=H/d*P,ut=B.cursor,bt=ut+K,kt=Y.cursor,Tt=kt+nt;B.cursor+=K,Y.cursor+=nt;let Dt=$,ie=o-$,ti=(Dt+ie)/2,lf=ht({label:`${B.name} \u2192 ${Y.name}`,value:H}),hf=`M ${ut} ${Dt} C ${ut} ${ti}, ${kt} ${ti}, ${kt} ${ie} L ${Tt} ${ie} C ${Tt} ${ti}, ${bt} ${ti}, ${bt} ${Dt} Z`;f+=`<path data-sankey-link${lf} d="${hf}"/>`}return{svg:f,viewBox:`0 0 ${n} ${o}`}}let p=l==="1:1",m=Math.max(8,n*.03),g=m+a*(p?2.2:5),b=p?6:24,A=a*.6,x=o-A*Math.max(0,h.length-1),S=o-A*Math.max(0,c.length-1),v=0;for(let O of h){let $=O.flow/u*x;O.y0=v,O.y1=v+$,O.cursor=v,v+=$+A}v=0;for(let O of c){let $=O.flow/d*S;O.y0=v,O.y1=v+$,O.cursor=v,v+=$+A}let E=Math.min(this.#l(),m/2);h.forEach((O,$)=>{let C=ht({label:O.name,value:O.flow});f+=`<rect data-sankey-node data-slice="${$%10}"${C} x="${g-m}" y="${O.y0}" width="${m}" height="${O.y1-O.y0}" rx="${E}"/>`,f+=`<text data-sankey-label x="${g-m-6}" y="${(O.y0+O.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${ft(Ue(O.name,b))}</text>`}),c.forEach((O,$)=>{let C=ht({label:O.name,value:O.flow});f+=`<rect data-sankey-node data-slice="${(h.length+$)%10}"${C} x="${n-g}" y="${O.y0}" width="${m}" height="${O.y1-O.y0}" rx="${E}"/>`,f+=`<text data-sankey-label x="${n-g+m+6}" y="${(O.y0+O.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${ft(Ue(O.name,b))}</text>`});for(let O of t){let $=e.get(O.source??O.from??""),C=i.get(O.target??O.to??"");if(!$||!C)continue;let Q=+(O.value??O.v??0);if(Q<=0)continue;let T=Q/u*x,P=Q/d*S,L=$.cursor,D=L+T,N=C.cursor,B=N+P;$.cursor+=T,C.cursor+=P;let Y=g,H=n-g,K=(Y+H)/2,nt=ht({label:`${$.name} \u2192 ${C.name}`,value:Q}),ut=`M ${Y} ${L} C ${K} ${L}, ${K} ${N}, ${H} ${N} L ${H} ${B} C ${K} ${B}, ${K} ${D}, ${Y} ${D} Z`;f+=`<path data-sankey-link${nt} d="${ut}"/>`}return{svg:f,viewBox:`0 0 ${n} ${o}`}}#At(){let t=this.#b(),e=this.#t,i=t.ratioResolved,r=this.#W(),n=r[0]||"bar",o=r[1]||"line",a=e.map(C=>C[this.x]??""),l=e.map(C=>+(C[n]??0)),h=e.map(C=>+(C[o]??0)),c=[...l,...h],u=ts(...this.#c(c),5),d=u[u.length-1],f=u[0],{width:p,height:m,pad:g}=t,b=m-g.top-g.bottom,A=p-g.left-g.right,x=A/e.length,S=x*.6,v=(x-S)/2,{svg:E,chipSvg:O}=this.#tt(p,m,u,a,g,t);if(!this.#k(n))for(let C=0;C<e.length;C++){let Q=l[C],T=d-f?(Q-f)/(d-f)*b:0,P=this.#h(T,b),L=g.left+x*C+v,D=g.top+b-P,N=this.#K(e[C]);E+=`<path${N}${this.#v(0,n)}${ht({label:a[C],value:Q,series:n})} d="${tc(L,D,S,P,this.#l())}"/>`}if(!this.#k(o))if(i==="2:3"){let C=A*.34,Q=Math.min(b*.26,C*.6),T=g.left+A-C-2,P=g.top+2,L=Math.min(...h),N=Math.max(...h)-L||1,B=h.map((H,K)=>({x:T+(h.length>1?K/(h.length-1)*C:C/2),y:P+Q-(H-L)/N*Q,v:H,label:a[K]})),Y=Math.max(0,Math.min(1,this.smooth));E+=`<rect data-composed-inset-bg x="${T-4}" y="${P-4}" width="${C+8}" height="${Q+8}" rx="${this.#l()}"/>`,E+=`<path data-composed-inset-line${this.#S(1,o)} d="${Cs(B,Y)}"/>`;for(let H of B)E+=`<circle data-hit${ht({label:H.label,value:H.v,series:o})} cx="${H.x}" cy="${H.y}" r="6" fill="transparent"/>`;E+=`<text data-composed-inset-label x="${T}" y="${P-6}" text-anchor="start" font-size="${t.valueSize}">${ft(o)}</text>`}else{let C=h.map((D,N)=>{let B=g.top+b-(d-f?(D-f)/(d-f)*b:0);return{x:g.left+x*N+x/2,y:this.#d(B,g.top,g.top+b),v:D,label:a[N]}}),Q=Math.max(0,Math.min(1,this.smooth)),T=i==="1:1",P=T?' data-slice="1" data-deemphasized-tint style="stroke: var(--md-sys-color-neutral-on-surface-variant)"':this.#S(1,o),L=T?' data-slice="1" data-deemphasized-tint style="fill: var(--md-sys-color-neutral-on-surface-variant)"':this.#v(1,o);E+=`<path data-line${P} d="${Cs(C,Q)}"/>`,E+=this.#ht(C,e,g.top+b,t,Q),C.forEach((D,N)=>{let B=this.#K(e[N]);E+=`<circle data-dot${L}${B} cx="${D.x}" cy="${D.y}" r="3"/>`,E+=`<circle data-hit${ht({label:D.label,value:D.v,series:o})} cx="${D.x}" cy="${D.y}" r="10" fill="transparent"/>`})}let $=this.#V();return $>-1&&$<e.length&&(E+=this.#st(g.left+x*$+x/2,g.top+b,t)),this.#H=[{label:n,key:n,slot:0},{label:o,key:o,slot:1,deemphasized:i==="1:1"}],E+=O,{svg:E,viewBox:`0 0 ${p} ${m}`}}#kt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(g=>+(g[e]??0)),r=t.map(g=>g[this.x]??""),n=i.reduce((g,b)=>g+b,0)||1,o=this.#b(),a=o.ratioResolved;if(a==="1:1"&&i.length>Av&&({labels:r,vals:i}=Sv(r,i,Av,!0)),this.#H=r.map((g,b)=>({label:g,value:i[b],pct:(i[b]/n*100).toFixed(1),slot:b%10})),a==="2:3")return this.#Et(o,r,i,n);let l=getComputedStyle(this),h=Math.max(40,this.clientWidth||200),c=24,u=Math.min(this.#l(),c/2),d=Math.max(0,parseFloat(l.getPropertyValue("--chart-segments-gap"))||2),f=[],p=0;for(let g=0;g<i.length;g++){let b=g===i.length-1?h:Math.round((p*n+i[g]*h)/n),A=g===i.length-1?h:i.slice(0,g+1).reduce((S,v)=>S+v,0)/n*h,x=g===0?0:i.slice(0,g).reduce((S,v)=>S+v,0)/n*h;f.push({x,w:Math.max(0,A-x)}),p=b}let m="";for(let g=0;g<f.length;g++){let{x:b,w:A}=f[g];if(A<=0)continue;let x=g===0,S=g===f.length-1,v=Math.max(0,A-(S?0:d)),E=(i[g]/n*100).toFixed(1),O=ht({label:r[g],value:i[g],pct:E}),$=`<title>${ft(r[g])}: ${i[g]} (${E}%)</title>`;if(x&&S||!x&&!S||u===0)m+=`<rect data-slice="${g%10}"${O} x="${b}" y="0" width="${v}" height="${c}"${(x||S)&&u?` rx="${u}"`:""}>${$}</rect>`;else{let C=u,Q=b+v,T;x?T=`M ${b+C} 0 H ${Q} V ${c} H ${b+C} A ${C} ${C} 0 0 1 ${b} ${c-C} V ${C} A ${C} ${C} 0 0 1 ${b+C} 0 Z`:T=`M ${b} 0 H ${Q-C} A ${C} ${C} 0 0 1 ${Q} ${C} V ${c-C} A ${C} ${C} 0 0 1 ${Q-C} ${c} H ${b} Z`,m+=`<path data-slice="${g%10}"${O} d="${T}">${$}</path>`}}return{svg:m,viewBox:`0 0 ${h} ${c}`}}#Et(t,e,i,r){let o=Math.max(60,t.height),a=Math.min(this.#l(),24/2),l=getComputedStyle(this),h=Math.max(0,parseFloat(l.getPropertyValue("--chart-segments-gap"))||2),c=[];for(let d=0;d<i.length;d++){let f=d===i.length-1?o:i.slice(0,d+1).reduce((m,g)=>m+g,0)/r*o,p=d===0?0:i.slice(0,d).reduce((m,g)=>m+g,0)/r*o;c.push({y:p,h:Math.max(0,f-p)})}let u="";for(let d=0;d<c.length;d++){let{y:f,h:p}=c[d];if(p<=0)continue;let m=d===0,g=d===c.length-1,b=Math.max(0,p-(g?0:h)),A=(i[d]/r*100).toFixed(1),x=ht({label:e[d],value:i[d],pct:A}),S=`<title>${ft(e[d])}: ${i[d]} (${A}%)</title>`;if(m&&g||!m&&!g||a===0)u+=`<rect data-slice="${d%10}"${x} x="0" y="${f}" width="24" height="${b}"${(m||g)&&a?` rx="${a}"`:""}>${S}</rect>`;else{let v=a,E=f+b,O;m?O=`M 0 ${f+v} A ${v} ${v} 0 0 1 ${v} ${f} H ${24-v} A ${v} ${v} 0 0 1 24 ${f+v} V ${E} H 0 Z`:O=`M 0 ${f} H 24 V ${E-v} A ${v} ${v} 0 0 1 ${24-v} ${E} H ${v} A ${v} ${v} 0 0 1 0 ${E-v} Z`,u+=`<path data-slice="${d%10}"${x} d="${O}">${S}</path>`}}return{svg:u,viewBox:`0 0 24 ${o}`}}#Ct(){let t=this.#t,e=this.#W(),i=t.map(O=>O[this.x]??""),r=t.map(O=>e.reduce(($,C)=>$+ +(O[C]??0),0)),n=ts(...this.#c(r),5),o=n[n.length-1],a=n[0],l=this.#b(),h=l.ratioResolved;if(this.#H=e.map((O,$)=>({label:O,key:O,slot:$%10})),h==="2:3")return this.#$t(l,i,e,t,o,n);let{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/t.length,g=m*.6,b=(m-g)/2,{svg:A,chipSvg:x}=this.#tt(c,u,n,i,d,l,{abbreviateLabels:h==="1:1"}),S=o-a?f/(o-a):0,v=this.#d(d.top+f+a*S,d.top,d.top+f);for(let O=0;O<t.length;O++){let $=v,C=e.length;for(let Q=0;Q<C;Q++){if(this.#k(e[Q]))continue;let T=+(t[O][e[Q]]??0),P=T*S;if(P<=0){$=this.#d($-P,d.top,d.top+f);continue}let L=Math.max($-P,d.top),D=$-L,N=d.left+m*O+b,B=L;$=L;let Y=Q===C-1,H=this.#l(),nt=`${this.#K(t[O])}${this.#v(Q%10,e[Q])}${ht({label:i[O],value:T,series:e[Q]})}`;Y?A+=`<path${nt} d="${tc(N,B,g,D,H)}"/>`:A+=`<rect${nt} x="${N}" y="${B}" width="${g}" height="${D}"/>`}}let E=this.#V();return E>-1&&E<t.length&&(A+=this.#st(d.left+m*E+m/2,d.top+f,l)),A+=x,{svg:A,viewBox:`0 0 ${c} ${u}`}}#$t(t,e,i,r,n,o){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce((C,Q)=>Math.max(C,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,b=(l-p.top-p.bottom)/e.length,A=b*.6,x=(b-A)/2,S=o[0],v=n-S?m/(n-S):0,E=this.#d(p.left-S*v,p.left,p.left+m),O="";if(!u){let C=o[o.length-1]-o[0]||1;for(let Q of o){let T=p.left+m*((Q-o[0])/C);O+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,O+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#w(Q)}</text>`}}for(let C=0;C<e.length;C++){let Q=p.top+b*C+x;O+=`<text data-x-label x="${p.left-6}" y="${Q+A/2+h*.35}" text-anchor="end" font-size="${c}">${ft(e[C])}</text>`;let T=E,P=i.length;for(let L=0;L<P;L++){if(this.#k(i[L]))continue;let D=+(r[C][i[L]]??0),N=D*v;if(N<=0)continue;let B=T,Y=Math.min(T+N,p.left+m),H=Y-B;T=Y;let K=L===P-1,ut=`${this.#K(r[C])}${this.#v(L%10,i[L])}${ht({label:e[C],value:D,series:i[L]})}`;K?O+=`<path${ut} d="${If(B,Q,H,A,this.#l())}"/>`:O+=`<rect${ut} x="${B}" y="${Q}" width="${H}" height="${A}"/>`}}let $=this.#V();return $>-1&&$<e.length&&(O+=this.#lt(p.top+b*$+b/2,p.left,t)),{svg:O,viewBox:`0 0 ${a} ${l}`}}#Pt(){let t=this.#t,e=this.#W(),i=t.map(O=>O[this.x]??""),r=t.flatMap(O=>e.map($=>+(O[$]??0))),n=ts(...this.#c(r),5),o=n[n.length-1],a=n[0],l=this.#b(),h=l.ratioResolved;if(this.#H=e.map((O,$)=>({label:O,key:O,slot:$%10})),h==="2:3")return this.#Qt(l,i,e,t,o,n);let{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/t.length,g=3,b=m*.7,A=(b-g*(e.length-1))/e.length,x=(m-b)/2,{svg:S,chipSvg:v}=this.#tt(c,u,n,i,d,l,{abbreviateLabels:h==="1:1"});for(let O=0;O<t.length;O++){let $=this.#K(t[O]);for(let C=0;C<e.length;C++){if(this.#k(e[C]))continue;let Q=+(t[O][e[C]]??0),T=o-a?(Q-a)/(o-a)*f:0,P=this.#h(T,f),L=d.left+m*O+x+(A+g)*C,D=d.top+f-P;S+=`<path${$}${this.#v(C%10,e[C])}${ht({label:i[O],value:Q,series:e[C]})} d="${tc(L,D,A,P,this.#l())}"/>`,this.noValues||(S+=`<text data-value x="${L+A/2}" y="${D-4}" text-anchor="middle" font-size="${l.valueSize}">${this.#w(Q)}</text>`)}}let E=this.#V();return E>-1&&E<t.length&&(S+=this.#st(d.left+m*E+m/2,d.top+f,l)),S+=v,{svg:S,viewBox:`0 0 ${c} ${u}`}}#Qt(t,e,i,r,n,o){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce((C,Q)=>Math.max(C,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,b=(l-p.top-p.bottom)/e.length,A=3,x=b*.7,S=(x-A*(i.length-1))/i.length,v=(b-x)/2,E=o[0],O="";if(!u){let C=o[o.length-1]-o[0]||1;for(let Q of o){let T=p.left+m*((Q-o[0])/C);O+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,O+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#w(Q)}</text>`}}for(let C=0;C<e.length;C++){let Q=p.top+b*C,T=this.#K(r[C]);O+=`<text data-x-label x="${p.left-6}" y="${Q+b/2+h*.35}" text-anchor="end" font-size="${c}">${ft(e[C])}</text>`;for(let P=0;P<i.length;P++){if(this.#k(i[P]))continue;let L=+(r[C][i[P]]??0),D=n-E?(L-E)/(n-E)*m:0,N=this.#h(D,m),B=Q+v+(S+A)*P;O+=`<path${T}${this.#v(P%10,i[P])}${ht({label:e[C],value:L,series:i[P]})} d="${If(p.left,B,N,S,this.#l())}"/>`,this.noValues||(O+=`<text data-value x="${p.left+N+4}" y="${B+S/2+h*.35}" text-anchor="start" font-size="${t.valueSize}">${this.#w(L)}</text>`)}}let $=this.#V();return $>-1&&$<e.length&&(O+=this.#lt(p.top+b*$+b/2,p.left,t)),{svg:O,viewBox:`0 0 ${a} ${l}`}}#Tt(){let t=this.#t,e=this.#W(),i=t.map(S=>S[this.x]??""),r=t.flatMap(S=>e.map(v=>+(S[v]??0))),n=ts(...this.#c(r),5),o=n[n.length-1],a=n[0],l=this.#b(),h=l.ratioResolved,{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/Math.max(t.length-1,1),{svg:g,chipSvg:b}=this.#tt(c,u,n,i,d,l,{pointAligned:!0}),A=h==="3:2";for(let S=0;S<e.length;S++){if(this.#k(e[S]))continue;let E=t.map(P=>+(P[e[S]]??0)).map((P,L)=>{let D=d.left+m*L,N=d.top+f-(o-a?(P-a)/(o-a)*f:0),B=this.#d(N,d.top,d.top+f);return{x:D,y:B,v:P,label:i[L]}}),O=d.top+f,$=Math.max(0,Math.min(1,this.smooth)),C=this.seriesEmphasis,Q=!C||e[S]===C,T=Q?"":" data-deemphasized";if(Q&&(g+=`<path data-area${this.#v(S%10,e[S])} d="${Rf(E,O,$)}"/>`),g+=`<path data-line${this.#S(S%10,e[S])}${T} d="${Cs(E,$)}"/>`,g+=this.#ht(E,t,O,l,$),E.forEach((P,L)=>{let D=this.#K(t[L]);this.#ot(L,E.length)&&(g+=`<circle data-dot${this.#v(S%10,e[S])}${T}${D} cx="${P.x}" cy="${P.y}" r="3"/>`),g+=`<circle data-hit${ht({label:P.label,value:P.v,series:e[S]})} cx="${P.x}" cy="${P.y}" r="10" fill="transparent"/>`}),A&&E.length){let P=E[E.length-1];g+=`<text data-series-end-label${this.#v(S%10,e[S])} x="${P.x+6}" y="${P.y}" text-anchor="start" dominant-baseline="central" font-size="${l.labelSize}">${ft(e[S])}</text>`}}let x=this.#V();return x>-1&&x<t.length&&(g+=this.#st(d.left+m*x,d.top+f,l)),this.#H=e.map((S,v)=>({label:S,key:S,slot:v%10})),g+=b,{svg:g,viewBox:`0 0 ${c} ${u}`}}#H=null;get legendData(){return this.#H?this.#H.map(t=>({...t})):null}#Lt(){if(!this.#H||!this.#H.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#H){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.deemphasized?(r.setAttribute("data-deemphasized-tint",""),r.style.background="var(--md-sys-color-neutral-on-surface-variant)"):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}};M();w("chart-ui",Nn);R();var Ev=new Set(["3:2","1:1","2:3"]),qn=class s extends k{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},ratio:{type:String,default:"",reflect:!0},interactive:{type:Boolean,default:!0,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#o()}disconnected(){this.#r()}render(){this.#s(),this.#o()}#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.#o(),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(Ev.has(this.ratio))return this.ratio;if(this.#t){let t=this.#t.getAttribute("data-ratio-resolved");if(Ev.has(t))return t}return""}#a(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#o(){let t=this.#n();t?this.getAttribute("data-ratio-resolved")!==t&&this.setAttribute("data-ratio-resolved",t):this.hasAttribute("data-ratio-resolved")&&this.removeAttribute("data-ratio-resolved");let e=this.#a();if(this.innerHTML="",!!e.length)for(let i of e){let r=i.key??i.label??"",n=i.label??r,o=i.slot!=null?i.slot:0,a=!this.#i.has(r),l=document.createElement("badge-ui");l.setAttribute("data-row",""),l.setAttribute("role",this.interactive?"button":"listitem"),l.setAttribute("text",n),r&&l.setAttribute("data-key",r),a&&l.setAttribute("data-active",""),i.deemphasized&&l.setAttribute("data-deemphasized",""),this.interactive&&(l.setAttribute("tabindex","0"),l.setAttribute("aria-pressed",a?"true":"false"));let h=this.shape||"dot",c=document.createElement("swatch-ui");c.setAttribute("shape",h),c.setAttribute("size","sm");let u=i.deemphasized?"var(--md-sys-color-neutral-on-surface-variant)":r?`var(--color-${r}, var(--a-data-${o}))`:`var(--a-data-${o})`;c.style.setProperty("--swatch-color",u),l.appendChild(c),this.interactive&&(l.addEventListener("click",d=>this.#l(d,r)),l.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),this.#l(d,r))})),this.appendChild(l)}}#l(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"}}))}};M();w("chart-legend-ui",qn);R();var SP=120,Xn=class extends k{static properties={placement:{type:String,default:"bottom",reflect:!0},offset:{type:Number,default:4,reflect:!0},open:{type:Boolean,default:!1,reflect:!0},trigger:{type:String,default:"click",reflect:!0},matchWidth:{type:Boolean,default:!1,reflect:!0,attribute:"match-width"}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#r=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#u),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#d),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#d))))}render(){this.open?this.#n():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#n(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=Ot(t,e,{placement:this.placement,gap:this.offset,matchWidth:this.matchWidth}),(this.trigger==="click"||this.trigger==="manual")&&(this.#r=requestAnimationFrame(()=>{this.#r=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#c)}))}}#a(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#o=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#d=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},SP)};#u=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#a(),this.trigger==="click"&&this.removeEventListener("click",this.#o),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#d),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#d))),this.#s?.removeEventListener("toggle",this.#u),this.#s=null,this.#e=!1}};M();w("popover-ui",Xn);R();var Bn=class extends k{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)}},zn=class extends k{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())}};M();w("accordion-ui",Bn),w("accordion-item-ui",zn);R();var Zn=class extends k{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()}}};M();w("divider-ui",Zn);R();var _n=class extends k{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()}};M();w("blockquote-ui",_n);R();var Df=[{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}],Vn=class extends k{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=Df.find(o=>i<=o.limit)||Df[Df.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()}};M();w("relative-time-ui",Vn);R();var jn=class extends k{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")}};M();w("number-format-ui",jn);R();var Nf=["Weak","Fair","Good","Strong"];function wP(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 Fn=class extends k{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=`
|
|
237
237
|
<div slot="bar" aria-hidden="true">
|
|
238
238
|
<div slot="segment" data-i="0"></div>
|
|
239
239
|
<div slot="segment" data-i="1"></div>
|
|
@@ -249,7 +249,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
249
249
|
`),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(`
|
|
250
250
|
`):e}async#d(){if(this.#r||this.#i)return;let t=this.#s,e=$O(this.language);this.#r=!0;try{let i=await Promise.resolve().then(()=>(CO(),EO)),r=null;try{r=(await i.importWithTimeout(i.languages[e],`lang-${e}`))?.extension??null}catch(n){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"language",language:e,error:n}}))}if(t!==this.#s||!this.isConnected)return;this.#u(i,r,e)}catch(i){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"core",error:i}})),console.warn("[code-ui] CodeMirror failed to load; staying on static fallback.",i)}finally{this.#r=!1}}#u(t,e,i){let{EditorState:r,EditorView:n,Compartment:o,lineNumbers:a,placeholder:l,syntaxHighlighting:h,history:c,historyKeymap:u,defaultKeymap:d,indentWithTab:f,keymap:p,adiaBaseTheme:m,adiaHighlightStyle:g,lintGutter:b,jsonLinter:A}=t,x=this.querySelector(":scope > pre"),S=x?x.querySelector("code")?.textContent??"":"",v=this.text||S||"";this.#a=v;let E=document.createElement("div");E.setAttribute("data-cm-mount",""),x?x.replaceWith(E):this.appendChild(E);let O=[m,h(g)];this.editable&&O.push(c(),p.of([{key:"Mod-s",run:$=>(this.#b($),!0)},...d,...u,f]),n.updateListener.of($=>{if(!$.docChanged)return;let C=$.state.doc.toString();this.#m(C),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:C}}))}),n.domEventHandlers({focus:($,C)=>(this.#n=C.state.doc.toString(),!1),blur:($,C)=>{let Q=C.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,O.push(this.#o.of(this.#f(n,r))),e&&O.push(e),this.lineNumbers&&O.push(a()),this.placeholder&&O.push(l(this.placeholder)),this.editable&&i==="json"&&O.push(A,b()),this.#i=new n({parent:E,state:r.create({doc:v,extensions:O})}),this.editable&&this.#m(v)}#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(()=>(CO(),EO));this.#i.dispatch({effects:this.#o.reconfigure(this.#f(t.EditorView,t.EditorState))})}get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}#m(t){this.editable&&(t=t??this.value??"",this.internals.setFormValue(t),this.#g(t))}#g(t){return t=t??"",this.required&&!t.trim()?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),this.setAttribute("aria-invalid","true"),!1):(this.internals.setValidity({}),this.removeAttribute("aria-invalid"),!0)}formResetCallback(){this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:this.#a}}):this.text=this.#a}formDisabledCallback(t){this.disabled=t}formStateRestoreCallback(t,e){typeof t=="string"&&(this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:t}}):this.text=t)}#b(t){this.dispatchEvent(new CustomEvent("save",{bubbles:!0,cancelable:!0,detail:{value:t.state.doc.toString()}}))}get value(){return this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??this.text??""}set value(t){this.text=String(t??"")}#O(){let t=this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??"";t&&navigator.clipboard.writeText(t).then(()=>{let e=this.querySelector(':scope > header [slot="copy"]');if(!e)return;let i=e.textContent;e.textContent="Copied!",this.#e!=null&&clearTimeout(this.#e),this.#e=setTimeout(()=>{this.#e=null,e.textContent=i},1500)})}render(){let t=this.querySelector(':scope > header [slot="label"]');if(t&&this.language&&(t.textContent=this.language),this.#p(),!this.inline&&this.text!=="")if(this.#i){if(this.editable&&this.#i.hasFocus)return;let e=this.#i.state.doc.toString();e!==this.text&&this.#i.dispatch({changes:{from:0,to:e.length,insert:this.text}})}else{let e=this.querySelector(":scope > pre > code");e&&e.textContent!==this.text&&(e.textContent=this.text)}}};M();w("code-ui",Lo);R();function SE(s){let t=s.replace(/=""(?=[\s/>])/g,"").replace(/="([^"]*"[^"]*)"/g,(o,a)=>{let l=a.replace(/"/g,'"').replace(/&/g,"&");return l.includes("'")?o:`='${l}'`}).replace(/\t/g," ").split(`
|
|
251
251
|
`);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(`
|
|
252
|
-
`)}var Mo=class extends k{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=SE(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=SE(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=()=>{typeof requestAnimationFrame=="function"&&requestAnimationFrame(this.#i)};#r(){this.#s(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(this.#s),this.#t.observe(this))}disconnected(){this.#t?.disconnect()}};M();w("preview-ui",Mo);R();var Ro=class extends k{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;#e=!1;connected(){this.hasAttribute("role")||this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#a))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#a),this.#t=!1}render(){if(!this.selectable){if(this.#e){for(let r of this.#i())r.removeAttribute("selected"),r.removeAttribute("aria-selected"),r.removeAttribute("tabindex");this.#e=!1}return}this.#e=!0;let t=this.selectedKey||"",e=this.#i(),i=null;for(let r of e){let n=this.#s(r),o=n&&n===t;o?r.setAttribute("selected",""):r.removeAttribute("selected"),r.setAttribute("aria-selected",o?"true":"false"),r.setAttribute("tabindex",o?"0":"-1"),o&&(i=r)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#i(){return[...this.children].filter(t=>t.tagName==="LIST-ITEM-UI"||t.getAttribute?.("role")==="listitem")}#s(t){return t.id||t.getAttribute("data-key")||""}#r(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.#i()].find(n=>this.#s(n)===t)?.focus?.())}#n=t=>{if(!this.selectable)return;let e=t.target.closest?.('list-item-ui, [role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#s(e);i&&this.#r(i)};#a=t=>{if(!this.selectable)return;let e=this.#i();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.#s(e[r]);o&&this.#r(o);return}default:return}n!==r&&(t.preventDefault(),e[n]?.focus?.())}},Io=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||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(){if(this.#t('[slot="content"]'))return;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()}};M();w("list-ui",Ro),w("list-item-ui",Io);R();ii();var Do=class extends k{static properties={items:{type:Array,default:[],reflect:!1},itemSize:{type:Number,default:0,reflect:!0,attribute:"item-size"},itemSizeRem:{type:Number,default:0,reflect:!0,attribute:"item-size-rem"},estimatedSize:{type:Number,default:48,reflect:!0,attribute:"estimated-size"},overscan:{type:Number,default:3,reflect:!0},direction:{type:String,default:"vertical",reflect:!0},pinBottom:{type:Boolean,default:!1,reflect:!0,attribute:"pin-bottom"},startIndex:{type:Number,default:0,reflect:!1,attribute:"start-index"},loading:{type:Boolean,default:!1,reflect:!0}};static parts={phantom:"<div data-phantom></div>",window:"<div data-window></div>",sentinelTop:'<div data-sentinel="top"></div>',sentinelBottom:'<div data-sentinel="bottom"></div>'};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=(t,e)=>t&&typeof t=="object"&&"id"in t?t.id:e;#a=new Map;#o=new Map;#l=1e5;#c=-1;#h=-1;#d=0;#u=!0;#f=null;#p=null;#m=()=>{this.#$();let t=this.#P();this.#d=t,this.#u=this.#w()};#g=t=>{let e=t.target.closest?.("[data-row]");if(!e||e.parentElement!==this.#e)return;let i=Number(e.dataset.index);if(!Number.isInteger(i)||i<0)return;let r=this.items?.[i];r!=null&&this.dispatchEvent(new CustomEvent("item-click",{detail:{item:r,index:i},bubbles:!0}))};#b=t=>{if(t.target!==this)return;let e=this.#y()||this.estimatedSize||48,i=this.#C(),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.#P();this.#k(n+r)};#O=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let r=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:r},bubbles:!0}))}else if(i==="bottom"){let r=this.items||[],n=this.#h>=0?this.#h:r.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:n},bubbles:!0}))}}};#v=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.#q(),this.#E(),this.#$())};connected(){this.setAttribute("role",this.getAttribute("role")||"list"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t=this.ensure("phantom"),this.#e=this.ensure("window"),this.#i=this.ensure("sentinelTop"),this.#s=this.ensure("sentinelBottom"),typeof IntersectionObserver<"u"&&(this.#p=new IntersectionObserver(this.#O,{root:this,rootMargin:"0px",threshold:0}),this.#p.observe(this.#i),this.#p.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#f=new ResizeObserver(this.#v)),this.addEventListener("scroll",this.#m,{passive:!0}),this.addEventListener("click",this.#g),this.addEventListener("keydown",this.#b),this.startIndex>0&&queueMicrotask(()=>this.scrollToIndex(this.startIndex))}disconnected(){this.removeEventListener("scroll",this.#m),this.removeEventListener("click",this.#g),this.removeEventListener("keydown",this.#b),this.#p?.disconnect(),this.#p=null,this.#f?.disconnect(),this.#f=null,this.#a.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#u||this.#w());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.#E(),this.#$(),e&&this.scrollToBottom(),this.#u=this.#w()}set renderRow(t){this.#r=typeof t=="function"?t:null,this.#a.clear(),this.#$()}get renderRow(){return this.#r}set keyFn(t){this.#n=typeof t=="function"?t:((e,i)=>i),this.#a.clear(),this.#$()}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.#x(n),a=this.#C(),l=this.#S(n),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#k(Math.max(0,h),e)}scrollToTop(){this.#k(0)}scrollToBottom(){let t=this.#A();this.#k(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.#E(),this.#$()}#y(){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}#S(t){let e=this.#y();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#x(t){let e=this.#y();if(e>0)return t*e;let i=0;for(let r=0;r<t;r++)i+=this.#S(r);return i}#A(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#y();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}#C(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#P(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#k(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#w(){let t=this.#P(),e=this.#C(),i=this.#A();return t+e>=i-1}#E(){if(!this.#t)return;let t=this.#A();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")}#T(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#C(),r=this.#P(),n=this.#y(),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}}#$(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=t.length,{start:i,end:r}=this.#T(),n=this.#x(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.#L(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})))}#L(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.#M(h,l,n),this.#a.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#n(h,l),u=this.#a.get(c);u&&o.push(u)}for(let[l,h]of this.#a)r.has(l)||(this.#f?.unobserve(h),h.parentElement===this.#e&&h.remove(),this.#a.delete(l));let a=this.#e.firstChild;for(let l of o)l!==a&&this.#e.insertBefore(l,a),a=l.nextSibling;for(;a;){let l=a.nextSibling;a.remove(),a=l}if(this.itemSize<=0&&this.itemSizeRem<=0&&this.#f)for(let l of o)this.#f.observe(l)}#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)}}#M(t,e,i){let r=document.createElement("div");r.setAttribute("data-row",""),r.setAttribute("role","listitem"),r.dataset.index=String(e),r.setAttribute("aria-rowindex",String(e+1));let n=null;if(typeof i=="function")try{n=i(t,e)}catch(o){console.warn("[list-window-ui] render() threw:",o)}if(Gi(n))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.#R==null&&(this.#R=t.innerHTML);let e=this.#R;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?"":RD(String(h))}),o=document.createElement("template");return o.innerHTML=n,o.content.cloneNode(!0)}}#R=null;#q(){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 RD(s){return s.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}M();w("list-window-ui",Do);R();var No=class extends k{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},offset:{type:Number,default:4,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=null;#r=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#u),this.addEventListener("keydown",this.#f))}render(){this.open?this.#a():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#n(){if(this.#e)return this.#e;let t=document.createElement("div");return t.setAttribute("data-menu-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.addEventListener("toggle",this.#O),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#a(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#n(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui, menu-label-ui");for(let r of i)e.contains(r)||e.appendChild(r);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=Ot(t,e,{placement:this.placement,gap:this.offset}),this.#d&&(this.#d=!1,this.#r=requestAnimationFrame(()=>{this.#r=null,this.#c(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#g),document.addEventListener("keydown",this.#b,!0)})}#o(){this.#t?.(),this.#t=null;let t=this.#e;if(t){t.matches(":popover-open")&&t.hidePopover?.();let e=t.querySelectorAll("menu-item-ui, menu-divider-ui, menu-label-ui");for(let i of e)this.insertBefore(i,t)}this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),document.removeEventListener("pointerdown",this.#g),document.removeEventListener("keydown",this.#b,!0)}#l(){return Array.from(this.#e?.querySelectorAll("menu-item-ui")??[]).filter(t=>!t.disabled)}#c(t){let e=this.#l();if(!e.length)return;let i=(t+e.length)%e.length,r=e[i];r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#d=!1;#u=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#d=!1,this.open=!this.open)};#f=t=>{let e=this.querySelector('[slot="trigger"]');!e||!(t.target===e||e.contains(t.target))||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#d=!0,this.open=!0)};#p=t=>{let e=t.target.closest("menu-item-ui");!e||e.disabled||(this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.value,text:e.text}})),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0}))};#m=t=>{let e=this.#l();if(!e.length)return;let i=this.#h();switch(t.key){case"ArrowDown":t.preventDefault(),this.#c(i+1);break;case"ArrowUp":t.preventDefault(),this.#c(i-1);break;case"Home":t.preventDefault(),this.#c(0);break;case"End":t.preventDefault(),this.#c(e.length-1);break;case"Enter":case" ":{t.preventDefault(),(e[i]??e[0])?.click();break}}};#g=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#b=t=>{t.key==="Escape"&&this.open?(t.stopPropagation(),t.preventDefault(),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0})):t.key==="Tab"&&this.open&&(this.open=!1)};#O=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#O),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},qo=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{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;#t=!1;connected(){this.hasAttribute("role")&&!this.#t||(this.closest('[role="menu"], [role="menubar"]')?(this.setAttribute("role","menuitem"),this.#t=!0,this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")):(this.removeAttribute("role"),this.removeAttribute("tabindex"),this.#t=!1)),this.#r(),this.#n()}#e(t){return t.dataset.menuItemStamped="1",t}#i(t){return t?.dataset?.menuItemStamped==="1"}#s(t){for(let e of this.children)if(e.matches(t))return e;return null}#r(){if(!this.#s('[slot="text"]')){if(this.icon&&!this.#s('[slot="icon"]')){let t=this.#e(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#e(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}if(this.description&&!this.#s('[slot="subtitle"]')){let t=this.#e(document.createElement("span"));t.setAttribute("slot","subtitle"),t.textContent=this.description,this.appendChild(t)}}}#n(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#s('[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.#s('[slot="text"]');this.#i(e)&&(e.textContent=this.text);let i=this.#s('[slot="subtitle"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let r=this.#e(document.createElement("span"));r.setAttribute("slot","subtitle"),r.textContent=this.description,this.appendChild(r)}else this.#i(i)&&i.remove();this.#n()}},Xo=class extends k{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}},hh=class extends k{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)}};M();w("menu-ui",No),w("menu-item-ui",qo),w("menu-divider-ui",Xo),w("menu-label-ui",hh);R();var wE=500,AE=new WeakSet,Bo=class extends k{static properties={targetSelector:{type:String,default:"",reflect:!0,attribute:"target-selector"},for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:wE,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#r=null;#n=null;#a=null;#o=null;connected(){super.connected(),this.#l()}disconnected(){super.disconnected(),this.#c(),this.#S(),this.#t?.remove(),this.#t=null}openAt(t,e,i=null){if(i??=this.#s[0]??null,!!i){if(this.#n=i,t==null||e==null){let r=i.getBoundingClientRect();t=r.left+r.width/2,e=r.top+r.height/2}this.#v(t,e)}}close(t="manual"){this.#y(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#u),t.addEventListener("touchstart",this.#f,{passive:!0}),t.addEventListener("touchend",this.#p),t.addEventListener("touchcancel",this.#p),t.addEventListener("keydown",this.#m)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#u),t.removeEventListener("touchstart",this.#f),t.removeEventListener("touchend",this.#p),t.removeEventListener("touchcancel",this.#p),t.removeEventListener("keydown",this.#m);this.#s=[]}#h(){let t=this.targetSelector||this.#d();if(t)try{return[...document.querySelectorAll(t)]}catch(e){return console.warn(`[context-menu-ui] invalid [target-selector] selector: ${t}`,e),[]}for(let e of this.children){let i=e.tagName.toLowerCase();if(i!=="menu-item-ui"&&i!=="menu-divider-ui")return[e]}return[]}#d(){return this.for?(AE.has(this)||(AE.add(this),console.warn(`[context-menu-ui] [for="${this.for}"] is deprecated \u2014 use [target-selector="${this.for}"] instead. [for] now means an id-ref everywhere else in AdiaUI; context-menu-ui's own prior [for] carried a CSS-selector meaning (ADR-0079).`)),this.for):""}#u=t=>{t.defaultPrevented||this.#g()&&(t.preventDefault(),this.#n=t.currentTarget,this.#v(t.clientX,t.clientY))};#f=t=>{if(!this.#g())return;let e=t.touches[0];e&&(this.#r=setTimeout(()=>{this.#n=t.currentTarget,this.#v(e.clientX,e.clientY)},this.longPressMs??wE))};#p=()=>{this.#r&&clearTimeout(this.#r),this.#r=null};#m=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#g())return;t.preventDefault(),this.#n=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#g(){return[...this.children].some(t=>t.tagName.toLowerCase()==="menu-item-ui")}#b(){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.#C),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}#v(t,e){let i=this.#b();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=Ot(r,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#x();let n=i.querySelector("menu-item-ui:not([disabled])");queueMicrotask(()=>n?.focus?.()),this.dispatchEvent(new CustomEvent("context-menu-open",{bubbles:!0,detail:{target:this.#n,x:t,y:e}}))}#y(t="manual"){if(this.open){this.open=!1,this.#S(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#n?.focus?.()}catch{}}}#S(){this.#A(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#x(){this.#a=t=>{this.#t?.contains(t.target)||this.#y("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#A(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#C=t=>{let e=t.target.closest("menu-item-ui");if(!e||e.hasAttribute("disabled"))return;let i=e.getAttribute("value")||"",r=e.getAttribute("text")||e.textContent.trim();this.dispatchEvent(new CustomEvent("context-menu-select",{bubbles:!0,detail:{value:i,text:r}})),this.#y("select")}};M();w("context-menu-ui",Bo);R();var zo=class extends k{static properties={};static template=()=>null};M();w("visually-hidden-ui",zo);R();var Zo=class extends k{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})=>J`<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})})}};M();w("skip-nav-ui",Zo);R();var _o=class extends k{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};M();w("mark-ui",_o);var Vo=class extends X{static properties={...X.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))}};M();w("inline-edit-ui",Vo);R();var jo=class extends k{static properties={active:{type:Boolean,default:!1,reflect:!0},step:{type:Number,default:0,reflect:!1},autoStart:{type:Boolean,default:!1,reflect:!0,attribute:"auto-start"},storageKey:{type:String,default:"",reflect:!0,attribute:"storage-key"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){super.connected(),this.autoStart&&!this.#o()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#a.length){console.warn("[tour-ui] start() called with no <tour-step> children \u2014 nothing to render.");return}this.step=0,this.active=!0,this.#c(),this.#d(),this.dispatchEvent(new CustomEvent("tour-start",{bubbles:!0,detail:{step:0}}))}}next(){if(!this.active)return;let t=this.#a.length;if(this.step>=t-1){this.finish();return}let e=this.step;this.step=e+1,this.#d(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:e,to:this.step,totalSteps:t}}))}previous(){if(!this.active||this.step<=0)return;let t=this.step;this.step=t-1,this.#d(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:t,to:this.step,totalSteps:this.#a.length}}))}skip(){if(!this.active)return;let t=this.#a.length,e=this.step;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-skip",{bubbles:!0,detail:{step:e,totalSteps:t}}))}finish(){if(!this.active)return;let t=this.#a.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#a(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#o(){if(!this.storageKey)return!1;try{return localStorage.getItem(this.storageKey)==="done"}catch{return!1}}#l(){if(this.storageKey)try{localStorage.setItem(this.storageKey,"done")}catch{}}#c(){if(!this.#t){let t=document.createElement("div");t.setAttribute("data-tour-spotlight",""),t.setAttribute("aria-hidden","true"),document.body.appendChild(t),this.#t=t}if(!this.#e){let t=document.createElement("div");t.setAttribute("data-tour-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#p),document.body.appendChild(t),this.#e=t}this.#s=()=>this.#f(),this.#r=()=>this.#f(),window.addEventListener("resize",this.#s),window.addEventListener("scroll",this.#r,!0),this.#n=t=>{this.active&&(t.key==="Escape"?(t.preventDefault(),this.skip()):t.key==="ArrowRight"?(t.preventDefault(),this.next()):t.key==="ArrowLeft"&&(t.preventDefault(),this.previous()))},document.addEventListener("keydown",this.#n)}#h(){this.#i?.(),this.#i=null,this.#s&&window.removeEventListener("resize",this.#s),this.#r&&window.removeEventListener("scroll",this.#r,!0),this.#n&&document.removeEventListener("keydown",this.#n),this.#s=this.#r=this.#n=null;try{this.#e?.hidePopover?.()}catch{}this.#e?.removeEventListener("click",this.#p),this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null}#d(){let t=this.#a[this.step];if(!t)return;let e=this.#a.length,i=this.step===e-1,r=this.step===0,n=t.getAttribute("title")||"",o=t.getAttribute("placement")||"bottom",a=t.getAttribute("target")||"",l=a?document.querySelector(a):null;this.#u=l,this.#f();let h=`${this.step+1} of ${e}`,c=t.innerHTML;this.#e.innerHTML=`
|
|
252
|
+
`)}var Mo=class extends k{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,"").replace(/\s+data-a2ui-id="[^"]*"/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=SE(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=SE(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=()=>{typeof requestAnimationFrame=="function"&&requestAnimationFrame(this.#i)};#r(){this.#s(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(this.#s),this.#t.observe(this))}disconnected(){this.#t?.disconnect()}};M();w("preview-ui",Mo);R();var Ro=class extends k{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;#e=!1;connected(){this.hasAttribute("role")||this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#a))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#a),this.#t=!1}render(){if(!this.selectable){if(this.#e){for(let r of this.#i())r.removeAttribute("selected"),r.removeAttribute("aria-selected"),r.removeAttribute("tabindex");this.#e=!1}return}this.#e=!0;let t=this.selectedKey||"",e=this.#i(),i=null;for(let r of e){let n=this.#s(r),o=n&&n===t;o?r.setAttribute("selected",""):r.removeAttribute("selected"),r.setAttribute("aria-selected",o?"true":"false"),r.setAttribute("tabindex",o?"0":"-1"),o&&(i=r)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#i(){return[...this.children].filter(t=>t.tagName==="LIST-ITEM-UI"||t.getAttribute?.("role")==="listitem")}#s(t){return t.id||t.getAttribute("data-key")||""}#r(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.#i()].find(n=>this.#s(n)===t)?.focus?.())}#n=t=>{if(!this.selectable)return;let e=t.target.closest?.('list-item-ui, [role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#s(e);i&&this.#r(i)};#a=t=>{if(!this.selectable)return;let e=this.#i();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.#s(e[r]);o&&this.#r(o);return}default:return}n!==r&&(t.preventDefault(),e[n]?.focus?.())}},Io=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||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(){if(this.#t('[slot="content"]'))return;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()}};M();w("list-ui",Ro),w("list-item-ui",Io);R();ii();var Do=class extends k{static properties={items:{type:Array,default:[],reflect:!1},itemSize:{type:Number,default:0,reflect:!0,attribute:"item-size"},itemSizeRem:{type:Number,default:0,reflect:!0,attribute:"item-size-rem"},estimatedSize:{type:Number,default:48,reflect:!0,attribute:"estimated-size"},overscan:{type:Number,default:3,reflect:!0},direction:{type:String,default:"vertical",reflect:!0},pinBottom:{type:Boolean,default:!1,reflect:!0,attribute:"pin-bottom"},startIndex:{type:Number,default:0,reflect:!1,attribute:"start-index"},loading:{type:Boolean,default:!1,reflect:!0}};static parts={phantom:"<div data-phantom></div>",window:"<div data-window></div>",sentinelTop:'<div data-sentinel="top"></div>',sentinelBottom:'<div data-sentinel="bottom"></div>'};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=(t,e)=>t&&typeof t=="object"&&"id"in t?t.id:e;#a=new Map;#o=new Map;#l=1e5;#c=-1;#h=-1;#d=0;#u=!0;#f=null;#p=null;#m=()=>{this.#P();let t=this.#$();this.#d=t,this.#u=this.#w()};#g=t=>{let e=t.target.closest?.("[data-row]");if(!e||e.parentElement!==this.#e)return;let i=Number(e.dataset.index);if(!Number.isInteger(i)||i<0)return;let r=this.items?.[i];r!=null&&this.dispatchEvent(new CustomEvent("item-click",{detail:{item:r,index:i},bubbles:!0}))};#b=t=>{if(t.target!==this)return;let e=this.#v()||this.estimatedSize||48,i=this.#E(),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.#$();this.#k(n+r)};#O=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let r=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:r},bubbles:!0}))}else if(i==="bottom"){let r=this.items||[],n=this.#h>=0?this.#h:r.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:n},bubbles:!0}))}}};#y=t=>{if(this.itemSize>0)return;let e=!1;for(let i of t){let r=i.target;if(!r||r.parentElement!==this.#e)continue;let n=Number(r.dataset.index);if(!Number.isInteger(n))continue;let o=this.direction==="horizontal"?i.contentRect.width:i.contentRect.height,a=Math.max(1,Math.round(o));this.#o.get(n)!==a&&(this.#o.set(n,a),this.dispatchEvent(new CustomEvent("measure",{detail:{index:n,height:a},bubbles:!0})),e=!0)}e&&(this.#D(),this.#C(),this.#P())};connected(){this.setAttribute("role",this.getAttribute("role")||"list"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t=this.ensure("phantom"),this.#e=this.ensure("window"),this.#i=this.ensure("sentinelTop"),this.#s=this.ensure("sentinelBottom"),typeof IntersectionObserver<"u"&&(this.#p=new IntersectionObserver(this.#O,{root:this,rootMargin:"0px",threshold:0}),this.#p.observe(this.#i),this.#p.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#f=new ResizeObserver(this.#y)),this.addEventListener("scroll",this.#m,{passive:!0}),this.addEventListener("click",this.#g),this.addEventListener("keydown",this.#b),this.startIndex>0&&queueMicrotask(()=>this.scrollToIndex(this.startIndex))}disconnected(){this.removeEventListener("scroll",this.#m),this.removeEventListener("click",this.#g),this.removeEventListener("keydown",this.#b),this.#p?.disconnect(),this.#p=null,this.#f?.disconnect(),this.#f=null,this.#a.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#u||this.#w());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.#C(),this.#P(),e&&this.scrollToBottom(),this.#u=this.#w()}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.#x(n),a=this.#E(),l=this.#S(n),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#k(Math.max(0,h),e)}scrollToTop(){this.#k(0)}scrollToBottom(){let t=this.#A();this.#k(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.#C(),this.#P()}#v(){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}#S(t){let e=this.#v();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#x(t){let e=this.#v();if(e>0)return t*e;let i=0;for(let r=0;r<t;r++)i+=this.#S(r);return i}#A(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#v();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}#E(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#$(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#k(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#w(){let t=this.#$(),e=this.#E(),i=this.#A();return t+e>=i-1}#C(){if(!this.#t)return;let t=this.#A();this.direction==="horizontal"?(this.#t.style.width=`${t}px`,this.#t.style.height="1px"):(this.#t.style.height=`${t}px`,this.#t.style.width="1px")}#Q(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#E(),r=this.#$(),n=this.#v(),o,a;if(n>0)o=Math.floor(r/n),a=Math.ceil((r+i)/n);else{let h=this.estimatedSize||48,c=0;o=0;for(let d=0;d<e;d++){let f=this.#o.get(d)??h;if(c+f>r){o=d;break}c+=f}a=o;let u=0;for(let d=o;d<e;d++){let f=this.#o.get(d)??h;if(u+=f,a=d+1,u>=i)break}}let l=Math.max(0,this.overscan|0);return o=Math.max(0,o-l),a=Math.min(e,a+l),{start:o,end:a}}#P(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=t.length,{start:i,end:r}=this.#Q(),n=this.#x(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${n}px)`:this.#e.style.transform=`translateY(${n}px)`,this.loading?this.#T(r-i):this.#M(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})))}#M(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.#R(h,l,n),this.#a.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#n(h,l),u=this.#a.get(c);u&&o.push(u)}for(let[l,h]of this.#a)r.has(l)||(this.#f?.unobserve(h),h.parentElement===this.#e&&h.remove(),this.#a.delete(l));let a=this.#e.firstChild;for(let l of o)l!==a&&this.#e.insertBefore(l,a),a=l.nextSibling;for(;a;){let l=a.nextSibling;a.remove(),a=l}if(this.itemSize<=0&&this.itemSizeRem<=0&&this.#f)for(let l of o)this.#f.observe(l)}#T(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)}}#R(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(Gi(n))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.#L==null&&(this.#L=t.innerHTML);let e=this.#L;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?"":RD(String(h))}),o=document.createElement("template");return o.innerHTML=n,o.content.cloneNode(!0)}}#L=null;#D(){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 RD(s){return s.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}M();w("list-window-ui",Do);R();var No=class extends k{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},offset:{type:Number,default:4,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=null;#r=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#u),this.addEventListener("keydown",this.#f))}render(){this.open?this.#a():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#n(){if(this.#e)return this.#e;let t=document.createElement("div");return t.setAttribute("data-menu-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.addEventListener("toggle",this.#O),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#a(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#n(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui, menu-label-ui");for(let r of i)e.contains(r)||e.appendChild(r);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=Ot(t,e,{placement:this.placement,gap:this.offset}),this.#d&&(this.#d=!1,this.#r=requestAnimationFrame(()=>{this.#r=null,this.#c(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#g),document.addEventListener("keydown",this.#b,!0)})}#o(){this.#t?.(),this.#t=null;let t=this.#e;if(t){t.matches(":popover-open")&&t.hidePopover?.();let e=t.querySelectorAll("menu-item-ui, menu-divider-ui, menu-label-ui");for(let i of e)this.insertBefore(i,t)}this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),document.removeEventListener("pointerdown",this.#g),document.removeEventListener("keydown",this.#b,!0)}#l(){return Array.from(this.#e?.querySelectorAll("menu-item-ui")??[]).filter(t=>!t.disabled)}#c(t){let e=this.#l();if(!e.length)return;let i=(t+e.length)%e.length,r=e[i];r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#d=!1;#u=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#d=!1,this.open=!this.open)};#f=t=>{let e=this.querySelector('[slot="trigger"]');!e||!(t.target===e||e.contains(t.target))||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#d=!0,this.open=!0)};#p=t=>{let e=t.target.closest("menu-item-ui");!e||e.disabled||(this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.value,text:e.text}})),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0}))};#m=t=>{let e=this.#l();if(!e.length)return;let i=this.#h();switch(t.key){case"ArrowDown":t.preventDefault(),this.#c(i+1);break;case"ArrowUp":t.preventDefault(),this.#c(i-1);break;case"Home":t.preventDefault(),this.#c(0);break;case"End":t.preventDefault(),this.#c(e.length-1);break;case"Enter":case" ":{t.preventDefault(),(e[i]??e[0])?.click();break}}};#g=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#b=t=>{t.key==="Escape"&&this.open?(t.stopPropagation(),t.preventDefault(),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0})):t.key==="Tab"&&this.open&&(this.open=!1)};#O=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#O),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},qo=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{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;#t=!1;connected(){this.hasAttribute("role")&&!this.#t||(this.closest('[role="menu"], [role="menubar"]')?(this.setAttribute("role","menuitem"),this.#t=!0,this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")):(this.removeAttribute("role"),this.removeAttribute("tabindex"),this.#t=!1)),this.#r(),this.#n()}#e(t){return t.dataset.menuItemStamped="1",t}#i(t){return t?.dataset?.menuItemStamped==="1"}#s(t){for(let e of this.children)if(e.matches(t))return e;return null}#r(){if(!this.#s('[slot="text"]')){if(this.icon&&!this.#s('[slot="icon"]')){let t=this.#e(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#e(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}if(this.description&&!this.#s('[slot="subtitle"]')){let t=this.#e(document.createElement("span"));t.setAttribute("slot","subtitle"),t.textContent=this.description,this.appendChild(t)}}}#n(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#s('[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.#s('[slot="text"]');this.#i(e)&&(e.textContent=this.text);let i=this.#s('[slot="subtitle"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let r=this.#e(document.createElement("span"));r.setAttribute("slot","subtitle"),r.textContent=this.description,this.appendChild(r)}else this.#i(i)&&i.remove();this.#n()}},Xo=class extends k{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}},hh=class extends k{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)}};M();w("menu-ui",No),w("menu-item-ui",qo),w("menu-divider-ui",Xo),w("menu-label-ui",hh);R();var wE=500,AE=new WeakSet,Bo=class extends k{static properties={targetSelector:{type:String,default:"",reflect:!0,attribute:"target-selector"},for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:wE,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#r=null;#n=null;#a=null;#o=null;connected(){super.connected(),this.#l()}disconnected(){super.disconnected(),this.#c(),this.#S(),this.#t?.remove(),this.#t=null}openAt(t,e,i=null){if(i??=this.#s[0]??null,!!i){if(this.#n=i,t==null||e==null){let r=i.getBoundingClientRect();t=r.left+r.width/2,e=r.top+r.height/2}this.#y(t,e)}}close(t="manual"){this.#v(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#u),t.addEventListener("touchstart",this.#f,{passive:!0}),t.addEventListener("touchend",this.#p),t.addEventListener("touchcancel",this.#p),t.addEventListener("keydown",this.#m)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#u),t.removeEventListener("touchstart",this.#f),t.removeEventListener("touchend",this.#p),t.removeEventListener("touchcancel",this.#p),t.removeEventListener("keydown",this.#m);this.#s=[]}#h(){let t=this.targetSelector||this.#d();if(t)try{return[...document.querySelectorAll(t)]}catch(e){return console.warn(`[context-menu-ui] invalid [target-selector] selector: ${t}`,e),[]}for(let e of this.children){let i=e.tagName.toLowerCase();if(i!=="menu-item-ui"&&i!=="menu-divider-ui")return[e]}return[]}#d(){return this.for?(AE.has(this)||(AE.add(this),console.warn(`[context-menu-ui] [for="${this.for}"] is deprecated \u2014 use [target-selector="${this.for}"] instead. [for] now means an id-ref everywhere else in AdiaUI; context-menu-ui's own prior [for] carried a CSS-selector meaning (ADR-0079).`)),this.for):""}#u=t=>{t.defaultPrevented||this.#g()&&(t.preventDefault(),this.#n=t.currentTarget,this.#y(t.clientX,t.clientY))};#f=t=>{if(!this.#g())return;let e=t.touches[0];e&&(this.#r=setTimeout(()=>{this.#n=t.currentTarget,this.#y(e.clientX,e.clientY)},this.longPressMs??wE))};#p=()=>{this.#r&&clearTimeout(this.#r),this.#r=null};#m=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#g())return;t.preventDefault(),this.#n=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#g(){return[...this.children].some(t=>t.tagName.toLowerCase()==="menu-item-ui")}#b(){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.#E),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.#b();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=Ot(r,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#x();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}}))}#v(t="manual"){if(this.open){this.open=!1,this.#S(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#n?.focus?.()}catch{}}}#S(){this.#A(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#x(){this.#a=t=>{this.#t?.contains(t.target)||this.#v("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#v("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#A(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#E=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.#v("select")}};M();w("context-menu-ui",Bo);R();var zo=class extends k{static properties={};static template=()=>null};M();w("visually-hidden-ui",zo);R();var Zo=class extends k{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})=>J`<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})})}};M();w("skip-nav-ui",Zo);R();var _o=class extends k{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};M();w("mark-ui",_o);var Vo=class extends X{static properties={...X.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))}};M();w("inline-edit-ui",Vo);R();var jo=class extends k{static properties={active:{type:Boolean,default:!1,reflect:!0},step:{type:Number,default:0,reflect:!1},autoStart:{type:Boolean,default:!1,reflect:!0,attribute:"auto-start"},storageKey:{type:String,default:"",reflect:!0,attribute:"storage-key"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){super.connected(),this.autoStart&&!this.#o()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#a.length){console.warn("[tour-ui] start() called with no <tour-step> children \u2014 nothing to render.");return}this.step=0,this.active=!0,this.#c(),this.#d(),this.dispatchEvent(new CustomEvent("tour-start",{bubbles:!0,detail:{step:0}}))}}next(){if(!this.active)return;let t=this.#a.length;if(this.step>=t-1){this.finish();return}let e=this.step;this.step=e+1,this.#d(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:e,to:this.step,totalSteps:t}}))}previous(){if(!this.active||this.step<=0)return;let t=this.step;this.step=t-1,this.#d(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:t,to:this.step,totalSteps:this.#a.length}}))}skip(){if(!this.active)return;let t=this.#a.length,e=this.step;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-skip",{bubbles:!0,detail:{step:e,totalSteps:t}}))}finish(){if(!this.active)return;let t=this.#a.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#a(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#o(){if(!this.storageKey)return!1;try{return localStorage.getItem(this.storageKey)==="done"}catch{return!1}}#l(){if(this.storageKey)try{localStorage.setItem(this.storageKey,"done")}catch{}}#c(){if(!this.#t){let t=document.createElement("div");t.setAttribute("data-tour-spotlight",""),t.setAttribute("aria-hidden","true"),document.body.appendChild(t),this.#t=t}if(!this.#e){let t=document.createElement("div");t.setAttribute("data-tour-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#p),document.body.appendChild(t),this.#e=t}this.#s=()=>this.#f(),this.#r=()=>this.#f(),window.addEventListener("resize",this.#s),window.addEventListener("scroll",this.#r,!0),this.#n=t=>{this.active&&(t.key==="Escape"?(t.preventDefault(),this.skip()):t.key==="ArrowRight"?(t.preventDefault(),this.next()):t.key==="ArrowLeft"&&(t.preventDefault(),this.previous()))},document.addEventListener("keydown",this.#n)}#h(){this.#i?.(),this.#i=null,this.#s&&window.removeEventListener("resize",this.#s),this.#r&&window.removeEventListener("scroll",this.#r,!0),this.#n&&document.removeEventListener("keydown",this.#n),this.#s=this.#r=this.#n=null;try{this.#e?.hidePopover?.()}catch{}this.#e?.removeEventListener("click",this.#p),this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null}#d(){let t=this.#a[this.step];if(!t)return;let e=this.#a.length,i=this.step===e-1,r=this.step===0,n=t.getAttribute("title")||"",o=t.getAttribute("placement")||"bottom",a=t.getAttribute("target")||"",l=a?document.querySelector(a):null;this.#u=l,this.#f();let h=`${this.step+1} of ${e}`,c=t.innerHTML;this.#e.innerHTML=`
|
|
253
253
|
<div data-tour-header>
|
|
254
254
|
<span data-tour-indicator>${h}</span>
|
|
255
255
|
<span></span>
|
|
@@ -263,7 +263,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
263
263
|
<button-ui data-tour-next variant="primary" size="sm" text="${i?"Done":"Next \u2192"}"></button-ui>
|
|
264
264
|
</div>
|
|
265
265
|
</div>
|
|
266
|
-
`;try{this.#e.showPopover()}catch{}this.#i?.(),l?this.#i=Ot(l,this.#e,{placement:o,gap:12}):(this.#e.style.position="fixed",this.#e.style.top="50%",this.#e.style.left="50%",this.#e.style.transform="translate(-50%, -50%)"),queueMicrotask(()=>this.#e?.focus?.())}#u=null;#f(){if(!this.#t)return;let t=this.#u;if(!t){this.#t.setAttribute("data-tour-no-target","");return}this.#t.removeAttribute("data-tour-no-target");let e=t.getBoundingClientRect(),i=getComputedStyle(this),r=parseFloat(i.getPropertyValue("--tour-spotlight-padding"))||8,n=Math.max(0,e.top-r),o=Math.max(0,e.left-r),a=e.width+r*2,l=e.height+r*2;this.#t.style.top=`${n}px`,this.#t.style.left=`${o}px`,this.#t.style.width=`${a}px`,this.#t.style.height=`${l}px`}#p=t=>{let e=t.target;if(!(!e||!e.closest)){if(e.closest("[data-tour-skip]")){this.skip();return}if(e.closest("[data-tour-previous]")){this.previous();return}if(e.closest("[data-tour-next]")){this.next();return}}}},Fo=class extends k{static properties={target:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null};function ID(s){return String(s??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}M();w("tour-ui",jo),w("tour-step-ui",Fo);R();var kE="data-toolbar-spillover",DD="data-toolbar-spillover-menu",EE=8,Ld="data-toolbar-spillover-label";function CE(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function ND(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function qD(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(Ld)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||ND(e.getAttribute("icon"));i&&(e.setAttribute(Ld,""),e.setAttribute("text",i))}}function XD(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(Ld)&&(e.removeAttribute(Ld),e.removeAttribute("text"))}function $E(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,r=parseFloat(e.marginRight)||0;return t.width+i+r}var Wo=class extends k{static requiredIcons=["dots-three"];static properties={gap:{type:String,default:"sm",reflect:!0},align:{type:String,default:"start",reflect:!0},overflow:{type:String,default:"menu",reflect:!0},bordered:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=!1;#o=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#c(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(()=>this.#b()),this.#t.observe(this)),typeof MutationObserver<"u"&&(this.#e=new MutationObserver(()=>{this.#n||this.#b()})),this.#O(),this.#b()}disconnected(){this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.#a=!1,this.#t?.disconnect(),this.#e?.disconnect(),this.#d(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}#c(){if(this.#i)return;let t=document.createElement("button-ui");t.setAttribute("icon","dots-three"),t.setAttribute("variant","ghost"),t.setAttribute("size","sm"),t.setAttribute(kE,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(DD,""),e.setAttribute("popover","manual"),e.setAttribute("role","menu"),t.addEventListener("click",this.#u),e.addEventListener("click",this.#f),e.addEventListener("toggle",this.#g),this.appendChild(t),this.appendChild(e),this.#i=t,this.#s=e}#h(){let t=this.#s;!t||t.matches(":popover-open")||(t.showPopover?.(),this.#r?.(),this.#r=Ot(this.#i,t,{placement:"bottom-end",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#p,!0),document.addEventListener("keydown",this.#m,!0)}))}#d(){this.#r?.(),this.#r=null,this.#s?.matches(":popover-open")&&this.#s.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0)}#u=t=>{t.stopPropagation(),this.#s?.matches(":popover-open")?this.#d():this.#h()};#f=t=>{let e=t.target.closest("button-ui");e&&(e.matches(`[${kE}]`)||queueMicrotask(()=>this.#d()))};#p=t=>{if(this.#i?.contains(t.target)||this.#s?.contains(t.target))return;let e=t.composedPath?.()||[];for(let i of e){if(i===document)break;if(i?.nodeType===1&&i.hasAttribute?.("popover"))return}this.#d()};#m=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#d(),this.#i?.focus?.({preventScroll:!0}))};#g=t=>{t.newState==="closed"&&(this.#r?.(),this.#r=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0))};#b(){this.#a||typeof requestAnimationFrame=="function"&&(this.#a=!0,this.#o=requestAnimationFrame(()=>{this.#o=null,this.#a=!1,this.isConnected&&this.#
|
|
266
|
+
`;try{this.#e.showPopover()}catch{}this.#i?.(),l?this.#i=Ot(l,this.#e,{placement:o,gap:12}):(this.#e.style.position="fixed",this.#e.style.top="50%",this.#e.style.left="50%",this.#e.style.transform="translate(-50%, -50%)"),queueMicrotask(()=>this.#e?.focus?.())}#u=null;#f(){if(!this.#t)return;let t=this.#u;if(!t){this.#t.setAttribute("data-tour-no-target","");return}this.#t.removeAttribute("data-tour-no-target");let e=t.getBoundingClientRect(),i=getComputedStyle(this),r=parseFloat(i.getPropertyValue("--tour-spotlight-padding"))||8,n=Math.max(0,e.top-r),o=Math.max(0,e.left-r),a=e.width+r*2,l=e.height+r*2;this.#t.style.top=`${n}px`,this.#t.style.left=`${o}px`,this.#t.style.width=`${a}px`,this.#t.style.height=`${l}px`}#p=t=>{let e=t.target;if(!(!e||!e.closest)){if(e.closest("[data-tour-skip]")){this.skip();return}if(e.closest("[data-tour-previous]")){this.previous();return}if(e.closest("[data-tour-next]")){this.next();return}}}},Fo=class extends k{static properties={target:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null};function ID(s){return String(s??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}M();w("tour-ui",jo),w("tour-step-ui",Fo);R();var kE="data-toolbar-spillover",DD="data-toolbar-spillover-menu",EE=8,Ld="data-toolbar-spillover-label";function CE(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function ND(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function qD(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(Ld)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||ND(e.getAttribute("icon"));i&&(e.setAttribute(Ld,""),e.setAttribute("text",i))}}function XD(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(Ld)&&(e.removeAttribute(Ld),e.removeAttribute("text"))}function $E(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,r=parseFloat(e.marginRight)||0;return t.width+i+r}var Wo=class extends k{static requiredIcons=["dots-three"];static properties={gap:{type:String,default:"sm",reflect:!0},align:{type:String,default:"start",reflect:!0},overflow:{type:String,default:"menu",reflect:!0},bordered:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=!1;#o=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#c(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(()=>this.#b()),this.#t.observe(this)),typeof MutationObserver<"u"&&(this.#e=new MutationObserver(()=>{this.#n||this.#b()})),this.#O(),this.#b()}disconnected(){this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.#a=!1,this.#t?.disconnect(),this.#e?.disconnect(),this.#d(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}#c(){if(this.#i)return;let t=document.createElement("button-ui");t.setAttribute("icon","dots-three"),t.setAttribute("variant","ghost"),t.setAttribute("size","sm"),t.setAttribute(kE,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(DD,""),e.setAttribute("popover","manual"),e.setAttribute("role","menu"),t.addEventListener("click",this.#u),e.addEventListener("click",this.#f),e.addEventListener("toggle",this.#g),this.appendChild(t),this.appendChild(e),this.#i=t,this.#s=e}#h(){let t=this.#s;!t||t.matches(":popover-open")||(t.showPopover?.(),this.#r?.(),this.#r=Ot(this.#i,t,{placement:"bottom-end",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#p,!0),document.addEventListener("keydown",this.#m,!0)}))}#d(){this.#r?.(),this.#r=null,this.#s?.matches(":popover-open")&&this.#s.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0)}#u=t=>{t.stopPropagation(),this.#s?.matches(":popover-open")?this.#d():this.#h()};#f=t=>{let e=t.target.closest("button-ui");e&&(e.matches(`[${kE}]`)||queueMicrotask(()=>this.#d()))};#p=t=>{if(this.#i?.contains(t.target)||this.#s?.contains(t.target))return;let e=t.composedPath?.()||[];for(let i of e){if(i===document)break;if(i?.nodeType===1&&i.hasAttribute?.("popover"))return}this.#d()};#m=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#d(),this.#i?.focus?.({preventScroll:!0}))};#g=t=>{t.newState==="closed"&&(this.#r?.(),this.#r=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0))};#b(){this.#a||typeof requestAnimationFrame=="function"&&(this.#a=!0,this.#o=requestAnimationFrame(()=>{this.#o=null,this.#a=!1,this.isConnected&&this.#v()}))}#O(){this.#e?.observe(this,{childList:!0})}#y(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#v(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#n=!0,this.#y();try{for(;e.firstChild;)XD(e.firstChild),this.insertBefore(e.firstChild,t);let i=0;for(let S of this.children)S===t||S===e||(S.dataset.toolbarOrder==null&&(S.dataset.toolbarOrder=String(i)),i+=1);let r=Array.from(this.children).filter(S=>S!==t&&S!==e).sort((S,v)=>Number(S.dataset.toolbarOrder)-Number(v.dataset.toolbarOrder));for(let S of r)this.insertBefore(S,t);let n=r;for(let S of n)S.hidden=!1;if(t.hidden=!0,this.clientWidth===0)return;let o=getComputedStyle(this),a=parseFloat(o.paddingLeft)||0,l=parseFloat(o.paddingRight)||0,h=parseFloat(o.columnGap||o.gap)||0,c=this.clientWidth-a-l,u=n.filter(S=>parseFloat(getComputedStyle(S).flexGrow)>0),d=u.map(S=>S.style.flexGrow);for(let S of u)S.style.flexGrow="0";let f=n.map(S=>$E(S));u.forEach((S,v)=>{S.style.flexGrow=d[v]});let p=f.reduce((S,v)=>S+v,0)+Math.max(0,n.length-1)*h,m=p<=c-EE;if(this.overflow==="none"||m)return;t.hidden=!1;let g=$E(t),b=n.length,A=p;for(;b>0&&!(A+h+g<=c-EE);)b-=1,A-=f[b],b>0&&(A-=h);for(;b>0&&CE(n[b-1]);)b-=1;let x=n.slice(b);for(let S of x){if(CE(S)){S.hidden=!0;continue}qD(S),e.appendChild(S)}e.firstElementChild||(t.hidden=!0)}finally{this.#n=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#O()})}}}},Uo=class extends k{static template=()=>null;connected(){this.setAttribute("role","group")}};M();w("toolbar-ui",Wo),w("toolbar-group-ui",Uo);R();var Yo=class extends k{static properties={variant:{type:String,default:"primary",reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},divider:{type:Boolean,default:!1,reflect:!0},heading:{type:String,default:"",reflect:!0},multiExpand:{type:Boolean,default:!1,reflect:!0,attribute:"multi-expand"}};static template=()=>null;#t=null;connected(){this.setAttribute("role","navigation"),this.heading&&this.setAttribute("aria-label",this.heading),this.addEventListener("click",this.#r),this.variant!=="section"&&typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(()=>this.#i()),this.#t.observe(this))}render(){this.heading?this.setAttribute("aria-label",this.heading):this.removeAttribute("aria-label"),this.variant!=="section"&&this.#i()}get#e(){return this.collapsed||typeof this.getBoundingClientRect=="function"&&this.getBoundingClientRect().width<=96}#i(){let t=this.#e;for(let e of this.querySelectorAll(":scope > nav-group-ui")){let i=e.querySelector(':scope > [slot="header"]');i&&(i.title=t?e.text:"")}for(let e of this.querySelectorAll(":scope > nav-item-ui"))e.title=t?e.text:""}get selectedItem(){return this.querySelector("nav-item-ui[selected]")}select(t){let e=this.selectedItem;e!==t&&(e&&e.removeAttribute("selected"),t&&(t.setAttribute("selected",""),this.#n(),this.#s(t),this.dispatchEvent(new CustomEvent("nav-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value}}))))}#s(t){if(this.multiExpand)return;let e=t.closest("nav-group-ui");for(let i of this.querySelectorAll(":scope > nav-group-ui"))i!==e&&(i.open=!1)}toggle(){this.variant!=="section"&&(this.collapsed=!this.collapsed)}#r=t=>{if(this.variant==="section")return;let e=t.target.closest("nav-group-ui");if(e&&this.contains(e))if(this.#e){if(t.target.closest("[popover]"))return;e.showPopover?.()}else{let i=e.querySelector(':scope > [slot="header"]');i&&(t.target===i||i.contains(t.target))&&(e.open=!e.open)}};#n(){this.style.pointerEvents="none",requestAnimationFrame(()=>{this.style.pointerEvents=""})}disconnected(){this.removeEventListener("click",this.#r),this.#t?.disconnect(),this.#t=null}};M();w("nav-ui",Yo);R();var Ho=class extends k{static requiredIcons=["caret-right"];static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},variant:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=()=>this.#a();#r=null;#n=t=>{this.collapsible&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!this.open,this.dispatchEvent(new CustomEvent("group-toggle",{bubbles:!0,detail:{text:this.text,open:this.open}})))};connected(){this.setAttribute("role","group"),ct(this,"header").length?this.#i=ct(this,"header")[0]:(this.#i=document.createElement("div"),this.#i.setAttribute("slot","header"),this.#i.setAttribute("tabindex","0"),this.#i.innerHTML=`
|
|
267
267
|
<span slot="icon">${this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:""}</span>
|
|
268
268
|
<span slot="text">${this.text}</span>
|
|
269
269
|
${this.badge?`<span slot="badge">${this.badge}</span>`:""}
|
|
@@ -278,7 +278,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
278
278
|
placeholder="${this.placeholder}"
|
|
279
279
|
${this.disabled?"disabled":""}
|
|
280
280
|
${t?`size="${t}"`:""}
|
|
281
|
-
></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&&(Md(this.#t,"placeholder",this.placeholder),this.disabled?Md(this.#t,"disabled",""):BD(this.#t,"disabled"),Md(this,"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}};M();w("search-ui",ta);Lt();function hr(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function zD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ZD=0,ea=class extends X{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle"];static properties={...X.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;#d=null;#u=null;#f=null;#p=null;#m=`combobox-${++ZD}`;#g=void 0;#b=()=>this.#X();#O=t=>this.#Z(t);#
|
|
281
|
+
></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&&(Md(this.#t,"placeholder",this.placeholder),this.disabled?Md(this.#t,"disabled",""):BD(this.#t,"disabled"),Md(this,"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}};M();w("search-ui",ta);Lt();function hr(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function zD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ZD=0,ea=class extends X{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle"];static properties={...X.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;#d=null;#u=null;#f=null;#p=null;#m=`combobox-${++ZD}`;#g=void 0;#b=()=>this.#X();#O=t=>this.#Z(t);#y=()=>this.#B();#v=t=>this.#N(t);#S=t=>this.#F(t);#x=t=>this.#U(t);#A=t=>this.#nt(t);#E=t=>this.#W(t);#$=t=>this.#ot(t);connected(){super.connected(),this.#t.length===0&&this.#P(),this.#e=this.value||"",this.#k(),this.#R(),this.#V()}disconnected(){super.disconnected(),this.#Q(),this.#f?.(),this.#f=null,this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#$),this.#o?.hidePopover?.(),this.#o=null,this.#n=null,this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#d=null,this.#u=null}render(){if(!this.#n)return;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");let t=this.label?"":this.placeholder||"";this.#g=Zt(this,this.#g,t),this.#d&&(this.#d.style.display=this.clearable&&this.value?"":"none"),this.#c&&(this.#c.style.display=this.loading?"":"none"),this.open?this.#at():this.#it()}#k(){if(this.querySelector(":scope > [data-field]")){this.#w(),this.#C();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,r=ct(this,"prefix"),n=ct(this,"suffix"),o=ct(this,"empty"),a=ct(this,"loading"),l=ct(this,"footer");this.innerHTML=`
|
|
282
282
|
<span data-label id="${t}"${this.label?"":' style="display:none"'}>${hr(this.label||"")}</span>
|
|
283
283
|
<div data-field>
|
|
284
284
|
<span data-prefix></span>
|
|
@@ -303,8 +303,8 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
303
303
|
<div data-empty>No matches</div>
|
|
304
304
|
<div data-footer></div>
|
|
305
305
|
</div>
|
|
306
|
-
`,this.#w(),r.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...r),n.length&&this.#u.replaceChildren(...n),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#E()}#w(){this.#n=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#d=this.querySelector(":scope > [data-field] > [data-clear]"),this.#u=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#E(){this.#n&&(this.#n.addEventListener("input",this.#b),this.#n.addEventListener("keydown",this.#O),this.#n.addEventListener("focus",this.#v),this.#n.addEventListener("blur",this.#y)),this.#d&&this.#d.addEventListener("click",this.#A),this.#u&&this.#u.addEventListener("click",this.#C)}#T(){this.#n&&(this.#n.removeEventListener("input",this.#b),this.#n.removeEventListener("keydown",this.#O),this.#n.removeEventListener("focus",this.#v),this.#n.removeEventListener("blur",this.#y)),this.#d&&this.#d.removeEventListener("click",this.#A),this.#u&&this.#u.removeEventListener("click",this.#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){tt(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#M(),this.#V()})}get options(){return this.#t}#L(){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}#Q(t){return this.#L().find(e=>e.value===t)||null}#M(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#L(),i=this.#z(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.setAttribute("data-single-option",""),l.innerHTML=`<span data-radio aria-hidden="true"></span><span data-option-label>${this.#R(a.label??a.value)}</span>`,l.addEventListener("click",this.#S),l.addEventListener("mouseenter",this.#x),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.#z(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.#q(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.#I(),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant")}#I(){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`)}#R(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return hr(e);let i=this.#i,r=new RegExp(zD(i),"i"),n=e.match(r);if(!n)return hr(e);let o=n.index??0,a=o+n[0].length;return hr(e.slice(0,o))+"<mark>"+hr(e.slice(o,a))+"</mark>"+hr(e.slice(a))}#q(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)}}#z(t){return this.#i?t.filter(e=>this.#q(e)):t.slice()}#X(){if(this.#r)return;let t=this.#n.textContent||"";this.#i=t.trim(),this.#n.toggleAttribute("data-empty",!t),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#M();let e=this.#N();this.#i&&e.length&&this.#j(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#Z(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.#j(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#N();this.#j(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#et();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#tt("escape"));return}if(e==="Tab"){this.#G();return}if(e==="Backspace"){let i=!(this.#n.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#B(){}#D(t){!this.freeText&&this.#i&&!this.value&&(this.#V(),this.#i="")}#N(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#_(t){let e=this.#N();if(!e.length)return;if(this.#s<0){this.#j(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#j(i)}#j(t){let e=this.#N();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)}#F(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#Y(i,"click")}#U(t){let e=t.currentTarget,r=this.#N().indexOf(e);r>=0&&this.#j(r)}#et(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#N(),e=this.#s>=0?t[this.#s]:null;if(e){this.#Y(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(!i){this.#it("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#rt(i,"keyboard");return}if(this.freeText){this.#rt(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#V(),this.#i="",this.#M()}#G(){if(!this.open)return;let t=this.#N(),e=this.#s>=0?t[this.#s]:null;if(e){this.#Y(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#Q(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#rt(i,"keyboard");return}this.#V(),this.#i="",this.#it("blur")}#Y(t,e){if(this.readonly){this.#it("select");return}let i=this.#Q(t);tt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#V(),this.#M(),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"}}))}#rt(t,e){if(this.readonly){this.#it("select");return}tt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#V(),this.#M(),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"}}))}#nt(t){t.preventDefault(),t.stopPropagation(),this.#J("click"),this.#n?.focus()}#J(t){tt(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#V(),this.#M(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#J("programmatic")}#W(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()))}#ot(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#V(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#tt(t){this.#V(),this.#i="",this.#M(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#at(){if(!this.#o)return;this.#o.showPopover?.(),this.#I();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=Ot(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.#P)});let e=this.#N();if(!e.length)return;let i=e.findIndex(r=>r.dataset.value===this.value);this.#j(i>=0?i:0)}#it(t){this.#o&&(this.#f?.(),this.#f=null,this.#o.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#P),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant"))}#V(){if(!this.#n)return;let t=this.#Q(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.#Q(t)?(this.#Y(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};M();w("combobox-ui",ea);Lt();var _D=0;function VD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ia=class extends X{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=X.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
|
|
307
|
-
`,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},normalize:{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.#F(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-${++_D}`;#d=()=>this.#
|
|
306
|
+
`,this.#w(),r.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...r),n.length&&this.#u.replaceChildren(...n),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#C()}#w(){this.#n=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#d=this.querySelector(":scope > [data-field] > [data-clear]"),this.#u=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#C(){this.#n&&(this.#n.addEventListener("input",this.#b),this.#n.addEventListener("keydown",this.#O),this.#n.addEventListener("focus",this.#y),this.#n.addEventListener("blur",this.#v)),this.#d&&this.#d.addEventListener("click",this.#A),this.#u&&this.#u.addEventListener("click",this.#E)}#Q(){this.#n&&(this.#n.removeEventListener("input",this.#b),this.#n.removeEventListener("keydown",this.#O),this.#n.removeEventListener("focus",this.#y),this.#n.removeEventListener("blur",this.#v)),this.#d&&this.#d.removeEventListener("click",this.#A),this.#u&&this.#u.removeEventListener("click",this.#E)}#P(){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){tt(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#R(),this.#V()})}get options(){return this.#t}#M(){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}#T(t){return this.#M().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.#M(),i=this.#z(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.setAttribute("data-single-option",""),l.innerHTML=`<span data-radio aria-hidden="true"></span><span data-option-label>${this.#L(a.label??a.value)}</span>`,l.addEventListener("click",this.#S),l.addEventListener("mouseenter",this.#x),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.#z(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.#D(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.#I(),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant")}#I(){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`)}#L(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return hr(e);let i=this.#i,r=new RegExp(zD(i),"i"),n=e.match(r);if(!n)return hr(e);let o=n.index??0,a=o+n[0].length;return hr(e.slice(0,o))+"<mark>"+hr(e.slice(o,a))+"</mark>"+hr(e.slice(a))}#D(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)}}#z(t){return this.#i?t.filter(e=>this.#D(e)):t.slice()}#X(){if(this.#r)return;let t=this.#n.textContent||"";this.#i=t.trim(),this.#n.toggleAttribute("data-empty",!t),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#R();let e=this.#q();this.#i&&e.length&&this.#j(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#Z(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.#j(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#q();this.#j(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#et();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#tt("escape"));return}if(e==="Tab"){this.#G();return}if(e==="Backspace"){let i=!(this.#n.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#B(){}#N(t){!this.freeText&&this.#i&&!this.value&&(this.#V(),this.#i="")}#q(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#_(t){let e=this.#q();if(!e.length)return;if(this.#s<0){this.#j(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#j(i)}#j(t){let e=this.#q();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)}#F(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#Y(i,"click")}#U(t){let e=t.currentTarget,r=this.#q().indexOf(e);r>=0&&this.#j(r)}#et(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#q(),e=this.#s>=0?t[this.#s]:null;if(e){this.#Y(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(!i){this.#it("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#rt(i,"keyboard");return}if(this.freeText){this.#rt(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#V(),this.#i="",this.#R()}#G(){if(!this.open)return;let t=this.#q(),e=this.#s>=0?t[this.#s]:null;if(e){this.#Y(e.dataset.value||"","keyboard");return}let i=(this.#n.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#T(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#rt(i,"keyboard");return}this.#V(),this.#i="",this.#it("blur")}#Y(t,e){if(this.readonly){this.#it("select");return}let i=this.#T(t);tt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#V(),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"}}))}#rt(t,e){if(this.readonly){this.#it("select");return}tt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#V(),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"}}))}#nt(t){t.preventDefault(),t.stopPropagation(),this.#J("click"),this.#n?.focus()}#J(t){tt(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#V(),this.#R(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#J("programmatic")}#W(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()))}#ot(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#V(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#tt(t){this.#V(),this.#i="",this.#R(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#at(){if(!this.#o)return;this.#o.showPopover?.(),this.#I();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=Ot(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.#$)});let e=this.#q();if(!e.length)return;let i=e.findIndex(r=>r.dataset.value===this.value);this.#j(i>=0?i:0)}#it(t){this.#o&&(this.#f?.(),this.#f=null,this.#o.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#$),this.#s=-1,this.#n?.removeAttribute("aria-activedescendant"))}#V(){if(!this.#n)return;let t=this.#T(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.#T(t)?(this.#Y(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};M();w("combobox-ui",ea);Lt();var _D=0;function VD(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ia=class extends X{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=X.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
|
|
307
|
+
`,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},normalize:{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.#F(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-${++_D}`;#d=()=>this.#C();#u=t=>this.#Q(t);#f=t=>this.#P(t);#p=t=>this.#M(t);#m=t=>this.#T(t);#g=t=>this.#R(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#F(this.getAttribute("value"));t&&(this.#t=t)}this.#b(),this.#S(),this.#k(),this.#w()}disconnected(){super.disconnected(),this.#v(),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){tt(()=>{let e=Array.isArray(t)?t.map(r=>String(r??"")):typeof t=="string"?this.#F(t)||[]:[],i=this.#t.slice();this.#t=e,this.#S(),this.#k(),this.#w(),this.#Z(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){tt(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#$(),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.#L(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#X(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#S(),this.#k(),this.#w(),this.#Z(t,[],"programmatic")}focus(){this.#o?.focus()}#b(){if(this.querySelector(":scope > [data-chip-list]")){this.#O(),this.#y();return}let t=this.querySelector(':scope > template[slot="chip"]'),e=`${this.#h}-suggestions`,i=`${this.#h}-input`;this.innerHTML=`
|
|
308
308
|
<div data-chip-list role="list" aria-label="Tags"></div>
|
|
309
309
|
<span data-inline-input
|
|
310
310
|
id="${i}"
|
|
@@ -319,20 +319,20 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
319
319
|
<icon-ui name="circle-notch"></icon-ui>
|
|
320
320
|
</span>
|
|
321
321
|
<div data-suggestions id="${e}" role="listbox" hidden></div>
|
|
322
|
-
`,t&&this.appendChild(t),this.#O(),this.#v()}#O(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#v(){this.#o&&(this.#o.addEventListener("input",this.#d),this.#o.addEventListener("keydown",this.#u),this.#o.addEventListener("paste",this.#f)),this.#a&&this.#a.addEventListener("remove",this.#p),this.#l&&this.#l.addEventListener("click",this.#g),this.addEventListener("mousedown",this.#m)}#y(){this.#o&&(this.#o.removeEventListener("input",this.#d),this.#o.removeEventListener("keydown",this.#u),this.#o.removeEventListener("paste",this.#f)),this.#a&&this.#a.removeEventListener("remove",this.#p),this.#l&&this.#l.removeEventListener("click",this.#g),this.removeEventListener("mousedown",this.#m)}#S(){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.#A(t,n,r):this.#x(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()}#x(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}#A(t,e,i){let r=t.content.cloneNode(!0);this.#C(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.#x(e,i)}#C(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))}#P(){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")}#k(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.toggleAttribute("editing",!t)}#w(){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({})}#E(){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.#R(n,"delimiter")&&(r=!0);this.#r=!0,this.#o.textContent=i||"",this.#r=!1,this.#N(),this.#k(),this.#P(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#k(),this.#P(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#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.#R(r.dataset.value||"","suggestion");return}}i&&this.#R(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#X(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.#j())}#$(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(`[${VD(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.#k(),this.#P();return}let n="";for(let o=0;o<r.length;o++){let a=r[o];!this.#R(a,"paste")&&o===r.length-1&&(n=a)}n&&(this.#r=!0,this.#o.textContent=n,this.#r=!1,this.#N(),this.#k(),this.#P())}#L(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.#X(i,"chip-click"))}#Q(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#o&&(t.preventDefault(),this.#o?.focus(),this.#N())}#M(t){let e=t.target.closest('[role="option"]');e&&this.#R(e.dataset.value||"","suggestion")}#I(t){let e=this.normalize;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#R(t,e){if(this.disabled||this.readonly)return!1;let i=this.#I(t.trim());if(!i)return this.#D(),!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.#D(),!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.#q(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}#q(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.#S(),this.#D(),this.#k(),this.#w(),this.#Z(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#X(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.#S(),this.#k(),this.#w(),this.#Z(i,r,e),e!=="programmatic"&&this.#o?.focus()}#Z(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}}))}#D(){this.#o&&(this.#r=!0,this.#o.textContent="",this.#r=!1,this.removeAttribute("editing"),this.#P())}#N(){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)}#j(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#F(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.#F(t);if(e){this.value=e;return}}super.syncValue(t)}};M();w("tags-input-ui",ia);M();R();var ch=class extends k{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},band:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;static requiredIcons=["arrow-up","arrow-down"];#t=null;#e=null;#i=null;#s=null;#r=null;#n=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.#i.querySelector(":scope > icon-ui[data-trend-icon]"),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("data-trend-icon",""),this.#s.hidden=!0,this.#i.appendChild(this.#s)),this.#r=this.#i.querySelector(":scope > [data-trend-text]"),this.#r||(this.#r=document.createElement("span"),this.#r.setAttribute("data-trend-text",""),this.#i.appendChild(this.#r)),this.#n=this.querySelector(':scope > [slot="icon"]'),this.#n||(this.#n=document.createElement("icon-ui"),this.#n.setAttribute("slot","icon"),this.appendChild(this.#n))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" corner-radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" corner-radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#n.setAttribute("name",this.icon),this.#n.hidden=!1):this.#n.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.childNodes.length===2&&this.#i.firstChild===this.#s&&this.#i.lastChild===this.#r||(this.#i.textContent="",this.#i.appendChild(this.#s),this.#i.appendChild(this.#r)),this.#r.textContent=this.change,this.trend==="up"?(this.#s.setAttribute("name","arrow-up"),this.#s.hidden=!1):this.trend==="down"?(this.#s.setAttribute("name","arrow-down"),this.#s.hidden=!1):this.#s.hidden=!0,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#n.setAttribute("name",this.icon),this.#n.hidden=!1):this.#n.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=null}};w("stat-ui",ch);R();var sa=class extends k{static properties={};static template=()=>null;#t=!1;connected(){this.hasAttribute("role")||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}}}},ra=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{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;#t(t){return t.dataset.actionItemStamped="1",t}#e(t){return t?.dataset?.actionItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}connected(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#s(),this.#r()}#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)}if(this.description&&!this.#i('[slot="subtitle"]')){let t=this.#t(document.createElement("span"));t.setAttribute("slot","subtitle"),t.textContent=this.description,this.appendChild(t)}}}#r(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let r=this.#t(document.createElement("icon-ui"));r.setAttribute("slot","icon"),r.setAttribute("name",this.icon),this.prepend(r)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text);let i=this.#i('[slot="subtitle"]');if(this.description)if(i)this.#e(i)&&(i.textContent=this.description);else{let r=this.#t(document.createElement("span"));r.setAttribute("slot","subtitle"),r.textContent=this.description,this.appendChild(r)}else this.#e(i)&&i.remove();this.#r()}};M();w("action-list-ui",sa),w("action-item-ui",ra);R();var na=class extends k{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}};M();w("empty-state-ui",na);R();ii();var jD=["S","M","T","W","T","F","S"],FD=["January","February","March","April","May","June","July","August","September","October","November","December"];function PE(s){return String(s).padStart(2,"0")}function PO(s,t,e){return`${s}-${PE(t+1)}-${PE(e)}`}function ji(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 Rd(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var oa=class extends k{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=ji(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=ji(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=ji(this.value),n=ji(this.min),o=ji(this.max),a=ji(this.rangeStart),l=ji(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
|
|
322
|
+
`,t&&this.appendChild(t),this.#O(),this.#y()}#O(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#y(){this.#o&&(this.#o.addEventListener("input",this.#d),this.#o.addEventListener("keydown",this.#u),this.#o.addEventListener("paste",this.#f)),this.#a&&this.#a.addEventListener("remove",this.#p),this.#l&&this.#l.addEventListener("click",this.#g),this.addEventListener("mousedown",this.#m)}#v(){this.#o&&(this.#o.removeEventListener("input",this.#d),this.#o.removeEventListener("keydown",this.#u),this.#o.removeEventListener("paste",this.#f)),this.#a&&this.#a.removeEventListener("remove",this.#p),this.#l&&this.#l.removeEventListener("click",this.#g),this.removeEventListener("mousedown",this.#m)}#S(){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.#A(t,n,r):this.#x(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()}#x(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}#A(t,e,i){let r=t.content.cloneNode(!0);this.#E(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.#x(e,i)}#E(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))}#$(){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")}#k(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.toggleAttribute("editing",!t)}#w(){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({})}#C(){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.#L(n,"delimiter")&&(r=!0);this.#r=!0,this.#o.textContent=i||"",this.#r=!1,this.#q(),this.#k(),this.#$(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#k(),this.#$(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#Q(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.#L(r.dataset.value||"","suggestion");return}}i&&this.#L(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#X(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.#j())}#P(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(`[${VD(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.#k(),this.#$();return}let n="";for(let o=0;o<r.length;o++){let a=r[o];!this.#L(a,"paste")&&o===r.length-1&&(n=a)}n&&(this.#r=!0,this.#o.textContent=n,this.#r=!1,this.#q(),this.#k(),this.#$())}#M(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.#X(i,"chip-click"))}#T(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.#q())}#R(t){let e=t.target.closest('[role="option"]');e&&this.#L(e.dataset.value||"","suggestion")}#I(t){let e=this.normalize;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#L(t,e){if(this.disabled||this.readonly)return!1;let i=this.#I(t.trim());if(!i)return this.#N(),!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.#N(),!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.#D(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}#D(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.#S(),this.#N(),this.#k(),this.#w(),this.#Z(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#X(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.#S(),this.#k(),this.#w(),this.#Z(i,r,e),e!=="programmatic"&&this.#o?.focus()}#Z(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}}))}#N(){this.#o&&(this.#r=!0,this.#o.textContent="",this.#r=!1,this.removeAttribute("editing"),this.#$())}#q(){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)}#j(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#F(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.#F(t);if(e){this.value=e;return}}super.syncValue(t)}};M();w("tags-input-ui",ia);M();R();var ch=class extends k{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},band:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;static requiredIcons=["arrow-up","arrow-down"];#t=null;#e=null;#i=null;#s=null;#r=null;#n=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.#i.querySelector(":scope > icon-ui[data-trend-icon]"),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("data-trend-icon",""),this.#s.hidden=!0,this.#i.appendChild(this.#s)),this.#r=this.#i.querySelector(":scope > [data-trend-text]"),this.#r||(this.#r=document.createElement("span"),this.#r.setAttribute("data-trend-text",""),this.#i.appendChild(this.#r)),this.#n=this.querySelector(':scope > [slot="icon"]'),this.#n||(this.#n=document.createElement("icon-ui"),this.#n.setAttribute("slot","icon"),this.appendChild(this.#n))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" corner-radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" corner-radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#n.setAttribute("name",this.icon),this.#n.hidden=!1):this.#n.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.childNodes.length===2&&this.#i.firstChild===this.#s&&this.#i.lastChild===this.#r||(this.#i.textContent="",this.#i.appendChild(this.#s),this.#i.appendChild(this.#r)),this.#r.textContent=this.change,this.trend==="up"?(this.#s.setAttribute("name","arrow-up"),this.#s.hidden=!1):this.trend==="down"?(this.#s.setAttribute("name","arrow-down"),this.#s.hidden=!1):this.#s.hidden=!0,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#n.setAttribute("name",this.icon),this.#n.hidden=!1):this.#n.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=null}};w("stat-ui",ch);R();var sa=class extends k{static properties={};static template=()=>null;#t=!1;connected(){this.hasAttribute("role")||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}}}},ra=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{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;#t(t){return t.dataset.actionItemStamped="1",t}#e(t){return t?.dataset?.actionItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}connected(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#s(),this.#r()}#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)}if(this.description&&!this.#i('[slot="subtitle"]')){let t=this.#t(document.createElement("span"));t.setAttribute("slot","subtitle"),t.textContent=this.description,this.appendChild(t)}}}#r(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let r=this.#t(document.createElement("icon-ui"));r.setAttribute("slot","icon"),r.setAttribute("name",this.icon),this.prepend(r)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text);let i=this.#i('[slot="subtitle"]');if(this.description)if(i)this.#e(i)&&(i.textContent=this.description);else{let r=this.#t(document.createElement("span"));r.setAttribute("slot","subtitle"),r.textContent=this.description,this.appendChild(r)}else this.#e(i)&&i.remove();this.#r()}};M();w("action-list-ui",sa),w("action-item-ui",ra);R();var na=class extends k{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}};M();w("empty-state-ui",na);R();ii();var jD=["S","M","T","W","T","F","S"],FD=["January","February","March","April","May","June","July","August","September","October","November","December"];function PE(s){return String(s).padStart(2,"0")}function PO(s,t,e){return`${s}-${PE(t+1)}-${PE(e)}`}function ji(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 Rd(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var oa=class extends k{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=ji(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=ji(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=ji(this.value),n=ji(this.min),o=ji(this.max),a=ji(this.rangeStart),l=ji(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
|
|
323
323
|
<button-ui variant="ghost" size="sm" icon="caret-left" data-cal-prev aria-label="Previous month" tabindex="-1"></button-ui>
|
|
324
324
|
<span data-cal-title>${FD[e]} ${t}</span>
|
|
325
325
|
<button-ui variant="ghost" size="sm" icon="caret-right" data-cal-next aria-label="Next month" tabindex="-1"></button-ui>
|
|
326
|
-
</div>`;u+=`<div data-cal-weekdays>${jD.map(E=>`<span>${E}</span>`).join("")}</div>`;let d=new Date(t,e,1).getDay(),f=new Date(t,e+1,0).getDate(),p=new Date(t,e,0).getDate(),m=(E,O,$)=>{let C=PO(E.getFullYear(),E.getMonth(),E.getDate()),Q=Rd(E,i),T=!!(r&&Rd(E,r)),P=!!(h&&c&&E>h&&E<c),L=!!(h&&Rd(E,h)),D=!!(c&&Rd(E,c)),N=$||n&&E<n||o&&E>o,B=!$&&this.#i===O;return`<button-ui variant="ghost" ${["data-cal-day",$?"data-outside":`data-date="${C}"`,Q?"data-today":"",T?"data-selected":"",P?"data-in-range":"",L?"data-range-start":"",D?"data-range-end":"",N?"disabled":"",B?"data-focused":"",`tabindex="${B?"0":"-1"}"`].filter(Boolean).join(" ")} text="${O}"></button-ui>`};u+="<div data-cal-grid>";let g=e===0?11:e-1,b=e===0?t-1:t;for(let E=d-1;E>=0;E--){let O=p-E;u+=m(new Date(b,g,O),O,!0)}for(let E=1;E<=f;E++)u+=m(new Date(t,e,E),E,!1);let x=(7-(d+f)%7)%7,S=e===11?0:e+1,v=e===11?t+1:t;for(let E=1;E<=x;E++)u+=m(new Date(v,S,E),E,!0);u+="</div>",this.innerHTML=u}#n(t){this.disabled||this.readonly||(this.value=t,this.#r(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t}})))}#a=t=>{if(this.disabled)return;let e=re(t.target)?t.target:null;if(!e)return;if(e.closest("[data-cal-prev]")){t.stopPropagation(),this.navigate(-1);return}if(e.closest("[data-cal-next]")){t.stopPropagation(),this.navigate(1);return}let n=e.closest("[data-cal-day][data-date]:not([disabled])");n&&(t.stopPropagation(),this.#n(n.dataset.date))};#o=t=>{if(this.disabled)return;if(t.key==="Enter"||t.key===" "){if(this.#i){t.preventDefault();let i=PO(this.#t,this.#e,this.#i),r=new Date(this.#t,this.#e,this.#i),n=ji(this.min),o=ji(this.max);(!n||r>=n)&&(!o||r<=o)&&this.#n(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#t,this.#e+1,0).getDate(),r=(this.#i||1)+e[t.key];if(r<1){this.navigate(-1);let o=new Date(this.#t,this.#e+1,0).getDate();this.#i=o+r}else r>i?(this.navigate(1),this.#i=r-i):this.#i=r;this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{focusDate:PO(this.#t,this.#e,this.#i)}}));return}if(t.key==="PageUp"){t.preventDefault(),this.navigate(-1);return}if(t.key==="PageDown"){t.preventDefault(),this.navigate(1);return}if(t.key==="Home"){t.preventDefault(),this.#i=1,this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}if(t.key==="End"){t.preventDefault(),this.#i=new Date(this.#t,this.#e+1,0).getDate(),this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}}};M();w("calendar-grid-ui",oa);var QE=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],TE=["January","February","March","April","May","June","July","August","September","October","November","December"];function QO(s){return String(s).padStart(2,"0")}function WD(s){if(!s)return null;let[t,e,i]=s.split("-").map(Number);return isNaN(t)||isNaN(e)||isNaN(i)?null:new Date(t,e-1,i)}function cr(s){if(!s)return null;let t=String(s).trim(),e=/^(\d{4}-\d{2}-\d{2})[T ](\d{1,2}:\d{2}(?::\d{2})?)$/.exec(t);return e?{date:e[1],time:e[2]}:null}function TO(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let r=QO(Number(i[1])),n=i[2],o=i[3]||"00";return e==="second"?`${s}T${r}:${n}:${o}`:`${s}T${r}:${n}`}function UD(s,t){let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s||"");if(!e)return"";let i=+e[1],r=+e[2]-1,n=+e[3];switch(t){case"long":return`${TE[r]} ${n}, ${i}`;case"iso":return s;default:return`${QE[r]} ${n}, ${i}`}}function YD(s,t,e){let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(s||"");if(!i)return"";let r=+i[1],n=i[2],o=i[3],a,l="";if(e==="h12"){let c=r>=12,u=r%12||12;a=QO(u),l=c?" PM":" AM"}else a=QO(r);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${n}${h}${l}`}var aa=class extends X{static labelDeprecated=!0;static requiredIcons=["calendar"];static properties={...X.properties,placeholder:{type:String,default:"Select date...",reflect:!0},format:{type:String,default:"short",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},precision:{type:String,default:"date",reflect:!0},step:{type:Number,default:60,reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},locale:{type:String,default:"",reflect:!1},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#r=null;#n=null;#a=!1;#o=null;#l=null;#c=!1;#h=null;#d="programmatic";#u="programmatic";get#f(){return this.precision==="minute"||this.precision==="second"}#p=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#i?.value||"";if(!e)return;if(!this.#f){this.value=e,this.syncValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}this.#h||(this.#h={date:"",time:""}),this.#h.date=e;let i=cr(this.value),r=this.#h.time||i?.time||"",n=r?TO(e,r,this.precision):`${e}T`;this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:n}})),r?this.#O({date:e,time:r}):queueMicrotask(()=>{if(!this.open)return;this.#n?.querySelector?.('[data-segment="hour"]')?.focus?.()})};#m=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#n?.value||"";if(!e)return;this.#h||(this.#h={date:"",time:""}),this.#h.time=e;let i=cr(this.value),r=this.#h.date||i?.date||"";r?this.#O({date:r,time:e}):this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:`T${e}`}}))};#g=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"",i=cr(this.value),r=this.#h?.date||i?.date||"",n=r&&e?TO(r,e,this.precision):e?`T${e}`:"";this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:n}}))};#b=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:t.detail?.reason||"pane"}}))};#O(t){if(!t||!t.date||!t.time)return;let e=TO(t.date,t.time,this.precision);if(!e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"parse"}}));return}if(this.min&&e<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"below-min"}}));return}if(this.max&&e>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"above-max"}}));return}this.value=e,this.#h=null,this.syncValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e}}))}syncValue(t){let e=t??this.value??"";this.internals.setFormValue(e),this.#
|
|
326
|
+
</div>`;u+=`<div data-cal-weekdays>${jD.map(E=>`<span>${E}</span>`).join("")}</div>`;let d=new Date(t,e,1).getDay(),f=new Date(t,e+1,0).getDate(),p=new Date(t,e,0).getDate(),m=(E,O,$)=>{let C=PO(E.getFullYear(),E.getMonth(),E.getDate()),Q=Rd(E,i),T=!!(r&&Rd(E,r)),P=!!(h&&c&&E>h&&E<c),L=!!(h&&Rd(E,h)),D=!!(c&&Rd(E,c)),N=$||n&&E<n||o&&E>o,B=!$&&this.#i===O;return`<button-ui variant="ghost" ${["data-cal-day",$?"data-outside":`data-date="${C}"`,Q?"data-today":"",T?"data-selected":"",P?"data-in-range":"",L?"data-range-start":"",D?"data-range-end":"",N?"disabled":"",B?"data-focused":"",`tabindex="${B?"0":"-1"}"`].filter(Boolean).join(" ")} text="${O}"></button-ui>`};u+="<div data-cal-grid>";let g=e===0?11:e-1,b=e===0?t-1:t;for(let E=d-1;E>=0;E--){let O=p-E;u+=m(new Date(b,g,O),O,!0)}for(let E=1;E<=f;E++)u+=m(new Date(t,e,E),E,!1);let x=(7-(d+f)%7)%7,S=e===11?0:e+1,v=e===11?t+1:t;for(let E=1;E<=x;E++)u+=m(new Date(v,S,E),E,!0);u+="</div>",this.innerHTML=u}#n(t){this.disabled||this.readonly||(this.value=t,this.#r(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t}})))}#a=t=>{if(this.disabled)return;let e=re(t.target)?t.target:null;if(!e)return;if(e.closest("[data-cal-prev]")){t.stopPropagation(),this.navigate(-1);return}if(e.closest("[data-cal-next]")){t.stopPropagation(),this.navigate(1);return}let n=e.closest("[data-cal-day][data-date]:not([disabled])");n&&(t.stopPropagation(),this.#n(n.dataset.date))};#o=t=>{if(this.disabled)return;if(t.key==="Enter"||t.key===" "){if(this.#i){t.preventDefault();let i=PO(this.#t,this.#e,this.#i),r=new Date(this.#t,this.#e,this.#i),n=ji(this.min),o=ji(this.max);(!n||r>=n)&&(!o||r<=o)&&this.#n(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#t,this.#e+1,0).getDate(),r=(this.#i||1)+e[t.key];if(r<1){this.navigate(-1);let o=new Date(this.#t,this.#e+1,0).getDate();this.#i=o+r}else r>i?(this.navigate(1),this.#i=r-i):this.#i=r;this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{focusDate:PO(this.#t,this.#e,this.#i)}}));return}if(t.key==="PageUp"){t.preventDefault(),this.navigate(-1);return}if(t.key==="PageDown"){t.preventDefault(),this.navigate(1);return}if(t.key==="Home"){t.preventDefault(),this.#i=1,this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}if(t.key==="End"){t.preventDefault(),this.#i=new Date(this.#t,this.#e+1,0).getDate(),this.#r(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}}};M();w("calendar-grid-ui",oa);var QE=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],TE=["January","February","March","April","May","June","July","August","September","October","November","December"];function QO(s){return String(s).padStart(2,"0")}function WD(s){if(!s)return null;let[t,e,i]=s.split("-").map(Number);return isNaN(t)||isNaN(e)||isNaN(i)?null:new Date(t,e-1,i)}function cr(s){if(!s)return null;let t=String(s).trim(),e=/^(\d{4}-\d{2}-\d{2})[T ](\d{1,2}:\d{2}(?::\d{2})?)$/.exec(t);return e?{date:e[1],time:e[2]}:null}function TO(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let r=QO(Number(i[1])),n=i[2],o=i[3]||"00";return e==="second"?`${s}T${r}:${n}:${o}`:`${s}T${r}:${n}`}function UD(s,t){let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s||"");if(!e)return"";let i=+e[1],r=+e[2]-1,n=+e[3];switch(t){case"long":return`${TE[r]} ${n}, ${i}`;case"iso":return s;default:return`${QE[r]} ${n}, ${i}`}}function YD(s,t,e){let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(s||"");if(!i)return"";let r=+i[1],n=i[2],o=i[3],a,l="";if(e==="h12"){let c=r>=12,u=r%12||12;a=QO(u),l=c?" PM":" AM"}else a=QO(r);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${n}${h}${l}`}var aa=class extends X{static labelDeprecated=!0;static requiredIcons=["calendar"];static properties={...X.properties,placeholder:{type:String,default:"Select date...",reflect:!0},format:{type:String,default:"short",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},precision:{type:String,default:"date",reflect:!0},step:{type:Number,default:60,reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},locale:{type:String,default:"",reflect:!1},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#r=null;#n=null;#a=!1;#o=null;#l=null;#c=!1;#h=null;#d="programmatic";#u="programmatic";get#f(){return this.precision==="minute"||this.precision==="second"}#p=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#i?.value||"";if(!e)return;if(!this.#f){this.value=e,this.syncValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}this.#h||(this.#h={date:"",time:""}),this.#h.date=e;let i=cr(this.value),r=this.#h.time||i?.time||"",n=r?TO(e,r,this.precision):`${e}T`;this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:n}})),r?this.#O({date:e,time:r}):queueMicrotask(()=>{if(!this.open)return;this.#n?.querySelector?.('[data-segment="hour"]')?.focus?.()})};#m=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#n?.value||"";if(!e)return;this.#h||(this.#h={date:"",time:""}),this.#h.time=e;let i=cr(this.value),r=this.#h.date||i?.date||"";r?this.#O({date:r,time:e}):this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:`T${e}`}}))};#g=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"",i=cr(this.value),r=this.#h?.date||i?.date||"",n=r&&e?TO(r,e,this.precision):e?`T${e}`:"";this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:n}}))};#b=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:t.detail?.reason||"pane"}}))};#O(t){if(!t||!t.date||!t.time)return;let e=TO(t.date,t.time,this.precision);if(!e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"parse"}}));return}if(this.min&&e<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"below-min"}}));return}if(this.max&&e>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"above-max"}}));return}this.value=e,this.#h=null,this.syncValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e}}))}syncValue(t){let e=t??this.value??"";this.internals.setFormValue(e),this.#y(e)}#y(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||(this.#f?"Please select a date and time.":"Please select a date."),this),!1):t?this.#f&&!cr(t)?(this.internals.setValidity({badInput:!0},"Invalid date or time format.",this),!1):this.min&&t<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable ${this.#f?"datetime":"date"} is ${this.min}.`,this),!1):this.max&&t>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable ${this.#f?"datetime":"date"} is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","group"),this.addEventListener("click",this.#S),this.addEventListener("keydown",this.#A)}render(){if(!this.querySelector('[slot="trigger"]'))this.innerHTML=`
|
|
327
327
|
<span slot="trigger">
|
|
328
|
-
<span slot="display">${this.#
|
|
328
|
+
<span slot="display">${this.#v()}</span>
|
|
329
329
|
<icon-ui name="calendar" slot="caret"></icon-ui>
|
|
330
330
|
</span>
|
|
331
|
-
`,this.#e=this.querySelector('[slot="trigger"]'),this.#t=document.createElement("div"),this.#t.setAttribute("slot","popover"),this.#t.setAttribute("popover","manual"),this.appendChild(this.#t);else{let r=this.querySelector('[slot="display"]');r&&(r.textContent=this.#y())}if(this.#t||(this.#t=this.querySelector('[slot="popover"]')),this.#e||(this.#e=this.querySelector('[slot="trigger"]')),this.#t&&!this.#i&&(this.#i=this.#t.querySelector("calendar-grid-ui"),this.#i||(this.#i=document.createElement("calendar-grid-ui"),this.#t.appendChild(this.#i))),this.#i&&!this.#s&&(this.#i.addEventListener("change",this.#p),this.#s=!0),this.#t&&(this.#f?(this.#r||(this.#r=this.#t.querySelector("[data-pane-divider]"),this.#r||(this.#r=document.createElement("divider-ui"),this.#r.setAttribute("data-pane-divider",""),this.#r.setAttribute("vertical",""),this.#t.appendChild(this.#r))),this.#n||(this.#n=this.#t.querySelector("[data-time-pane]"),this.#n||(this.#n=document.createElement("time-picker-ui"),this.#n.setAttribute("data-time-pane",""),this.#t.appendChild(this.#n))),this.#a||(this.#n.addEventListener("change",this.#m),this.#n.addEventListener("input",this.#g),this.#n.addEventListener("invalid",this.#b),this.#a=!0)):(this.#n||this.#r)&&(this.#a&&(this.#n.removeEventListener("change",this.#m),this.#n.removeEventListener("input",this.#g),this.#n.removeEventListener("invalid",this.#b),this.#a=!1),this.#n?.remove(),this.#r?.remove(),this.#n=null,this.#r=null,this.#h=null)),this.#i){let r=this.#f?cr(this.value):null,n=this.#f?this.#h?.date??r?.date??"":this.value||"";this.#i.value=n;let o=this.#f?this.min?this.min.slice(0,10):"":this.min,a=this.#f?this.max?this.max.slice(0,10):"":this.max;o?this.#i.setAttribute("min",o):this.#i.removeAttribute("min"),a?this.#i.setAttribute("max",a):this.#i.removeAttribute("max"),this.#i.toggleAttribute("disabled",!!this.disabled),this.#i.toggleAttribute("readonly",!!this.readonly)}if(this.#f&&this.#n){let r=cr(this.value),n=this.#h?.time??r?.time??"";this.#n.setAttribute("precision",this.precision),this.#n.setAttribute("step",String(this.step)),this.hourcycle?this.#n.setAttribute("hour-cycle",this.hourcycle):this.#n.removeAttribute("hour-cycle"),this.locale?this.#n.setAttribute("locale",this.locale):this.#n.removeAttribute("locale");let o=this.#h?.date??r?.date??"",a=this.min?this.min.slice(11):"",l=this.max?this.max.slice(11):"";a&&o===this.min.slice(0,10)?this.#n.setAttribute("min",a):this.#n.removeAttribute("min"),l&&o===this.max.slice(0,10)?this.#n.setAttribute("max",l):this.#n.removeAttribute("max"),this.#n.value!==n&&(this.#n.value=n),this.#n.toggleAttribute("disabled",!!this.disabled),this.#n.toggleAttribute("readonly",!!this.readonly)}let t=this.querySelector(':scope > [slot="footer"]');t&&this.#t&&t.parentElement!==this.#t&&this.#t.appendChild(t),this.open&&(this.disabled||this.readonly)&&(this.open=!1);let e=this.open&&!this.#c,i=!this.open&&this.#c;this.open?(this.#t?.showPopover?.(),this.#o=Ot(this.#e,this.#t,{placement:this.getAttribute("placement")||"bottom",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,!(!this.isConnected||!this.open)&&document.addEventListener("pointerdown",this.#x,{once:!0})}),e&&queueMicrotask(()=>{if(!this.open||!this.#i)return;let n=this.#i.querySelector("[data-cal-day][data-selected]:not([data-outside])")||this.#i.querySelector("[data-cal-day]:not([disabled]):not([data-outside])"),o=n&&Number(n.dataset.date?.split("-")[2]);o&&this.#i.focusDay(o)}),e&&this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:this.#d}}))):(this.#o?.(),this.#o=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.#t?.hidePopover?.(),document.removeEventListener("pointerdown",this.#x),i&&this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:this.#u}}))),this.#c=this.open}#y(){if(!this.value)return this.placeholder;if(this.#f){let e=cr(this.value);if(!e)return this.value;let i=UD(e.date,this.format),r=YD(e.time,this.precision,this.hourcycle);return!i||!r?this.placeholder:`${i} ${r}`}let t=WD(this.value);if(!t)return this.value;switch(this.format){case"long":return`${TE[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`;case"iso":return this.value;default:return`${QE[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`}}#S=t=>{if(!(this.disabled||this.readonly)){if(this.#t&&t.composedPath().includes(this.#t)){let e=t.target.closest?.("[data-action]");if(e&&this.contains(e)){let i=e.dataset.action;i==="apply"?(this.#O({date:this.#h?.date??this.#i?.value??"",time:this.#h?.time??this.#n?.value??""}),this.#u="apply",this.open=!1):i==="cancel"&&(this.#h=null,this.#u="cancel",this.open=!1)}return}this.open?(this.#u="outside",this.open=!1):(this.#d="click",this.open=!0)}};#x=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.#u="outside",this.open=!1)};#A=t=>{if(!(this.disabled||this.readonly)){if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#d="keyboard",this.open=!0);return}t.key==="Escape"&&(t.preventDefault(),this.#u="escape",this.open=!1)}};disconnected(){super.disconnected(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.removeEventListener("click",this.#S),this.removeEventListener("keydown",this.#A),document.removeEventListener("pointerdown",this.#x),this.#i&&this.#s&&this.#i.removeEventListener("change",this.#p),this.#n&&this.#a&&(this.#n.removeEventListener("change",this.#m),this.#n.removeEventListener("input",this.#g),this.#n.removeEventListener("invalid",this.#b)),this.#s=!1,this.#a=!1,this.#o?.(),this.#o=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null,this.#i=null,this.#r=null,this.#n=null,this.#h=null,this.#c=!1}};M();w("calendar-picker-ui",aa);Lt();var HD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],GD=["January","February","March","April","May","June","July","August","September","October","November","December"];function LO(s){return String(s).padStart(2,"0")}function Je(s){return s?`${s.getFullYear()}-${LO(s.getMonth()+1)}-${LO(s.getDate())}`:""}function MO(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}function Fi(s){if(s==null)return null;if(typeof s=="object")return!s.from||!s.to?null:{from:String(s.from),to:String(s.to)};if(typeof s!="string"||!s.trim())return null;try{let t=JSON.parse(s);if(t&&t.from&&t.to)return{from:String(t.from),to:String(t.to)}}catch{}return null}function LE(s){return s?s.from<=s.to:!1}function ME(s,t){let e=MO(s);if(!e)return"";switch(t){case"long":return`${GD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${HD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function KD(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=Je(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),Je(l)},r=Je(new Date(t.getFullYear(),t.getMonth(),1)),n=Je(new Date(t.getFullYear(),t.getMonth()+1,0)),o=Je(new Date(t.getFullYear(),0,1));return[{label:"Today",range:{from:e,to:e}},{label:"Last 7 days",range:{from:i(6),to:e}},{label:"Last 30 days",range:{from:i(29),to:e}},{label:"This month",range:{from:r,to:n}},{label:"Year to date",range:{from:o,to:e}}]}function JD(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var la=class extends X{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down"];static get properties(){return{...X.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" icon-trailing="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#r=!1;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;get rangeValue(){return Fi(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return Fi(this.compareValue)}set rangeCompareValue(t){t==null?this.compareValue="":this.compareValue=JSON.stringify({from:String(t.from),to:String(t.to)})}get presets(){return Array.isArray(this.#t)?this.#t:KD()}set presets(t){tt(()=>{this.#t=Array.isArray(t)?t.slice():null,this.isConnected&&this.#p()})}open$(){this.open=!0}close$(){this.open=!1}openPopover(){this.disabled||this.readonly||this.open||(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.comparison&&(this.compareValue=""),this.#e=null,this.syncValue("")}applyPreset(t){let e=this.presets.find(i=>i.label===t);return!e||!e.range?!1:(this.#A(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=Fi(e);if(this.comparison&&this.name){let r=new FormData;i&&r.append(this.name,e),Fi(this.compareValue)&&r.append(`${this.name}-compare`,this.compareValue),this.internals.setFormValue(r)}else this.internals.setFormValue(i?e:"");this.#d(i)}#d(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date range.",this),!1):t&&!LE(t)?(this.internals.setValidity({rangeUnderflow:!0},"End date must be on or after start date.",this),!1):t&&this.min&&t.from<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable date is ${this.min}.`,this),!1):t&&this.max&&t.to>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable date is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#s||(this.#s=!0,this.#u(),this.#n.addEventListener("click",this.#g),this.#n.addEventListener("keydown",this.#b,!0),this.#a.addEventListener("click",this.#O),this.#a.addEventListener("keydown",this.#v),this.#l.addEventListener("change",this.#S),this.#c.addEventListener("change",this.#S)),this.syncValue()}disconnected(){super.disconnected(),this.#n&&(this.#n.removeEventListener("click",this.#g),this.#n.removeEventListener("keydown",this.#b,!0)),this.#a&&(this.#a.removeEventListener("click",this.#O),this.#a.removeEventListener("keydown",this.#v),this.#a.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#S),this.#c&&this.#c.removeEventListener("change",this.#S),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#y),this.#h?.(),this.#h=null,this.#s=!1,this.#r=!1,this.#n=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null}#u(){if(this.#n=this.ensure("trigger"),this.#a=this.ensure("popover"),this.id&&this.#a.setAttribute("aria-labelledby",this.id),!this.#a.querySelector(":scope > [data-calendar-area]")){let r=this.constructor._pp.calArea.cloneNode(!0);this.#a.appendChild(r)}let t=ct(this,"presets")[0];if(t&&t.parentElement!==this.#a)this.#a.appendChild(t),this.#o=t;else if(!this.noPresets&&!t){if(!this.#a.querySelector(":scope > [data-preset-rail]")){let r=this.constructor._pp.presets.cloneNode(!0);this.#a.insertBefore(r,this.#a.querySelector(":scope > [data-calendar-area]"))}this.#o=this.#a.querySelector(":scope > [data-preset-rail]")}let e=this.#a.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let r=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(r)}if(!e.querySelector(":scope > [data-cal-to]")){let r=this.constructor._pp.calTo.cloneNode(!0),n=Fi(this.value)?.from,o,a;if(n){let[l,h]=n.split("-").map(Number);o=l,a=h-1}else{let l=new Date;o=l.getFullYear(),a=l.getMonth()}a+=1,a>11&&(a=0,o+=1),r.setAttribute("month",`${o}-${LO(a+1)}`),e.appendChild(r)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=ct(this,"footer")[0];i&&i.parentElement!==this.#a&&this.#a.appendChild(i)}render(){if(!this.#n)return;let t=this.#f();this.#n.setAttribute("text",t),this.#n.toggleAttribute("data-has-value",t!==this.placeholder),this.#n.toggleAttribute("disabled",this.disabled),this.#n.setAttribute("aria-haspopup","dialog"),this.#n.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let e=Fi(this.value),i=this.#e,r=i?i.from:e?.from||"",n=i?i.to:e?.to||"",o=a=>{r?a.setAttribute("range-start",r):a.removeAttribute("range-start"),n?a.setAttribute("range-end",n):a.removeAttribute("range-end")};this.#l&&(this.min&&this.#l.setAttribute("min",this.min),this.max&&this.#l.setAttribute("max",this.max),this.#l.value=r,o(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=n,o(this.#c)),ct(this,"presets").length||(this.noPresets?(this.#o?.remove(),this.#o=null):(this.#o||this.#u(),this.#p())),this.#a&&(this.open&&!this.#r?!this.disabled&&!this.readonly?(this.#r=!0,this.#a.showPopover?.(),this.#h?.(),this.#h=Ot(this.#n,this.#a,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#x),document.addEventListener("keydown",this.#y),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#r&&(this.#r=!1,this.#h?.(),this.#h=null,this.#a.hidePopover?.(),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#y),this.#n?.focus?.()))}#f(){let t=Fi(this.value);if(!t)return this.placeholder;let e=ME(t.from,this.format),i=ME(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#p(){if(this.#o){this.#o.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#o.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#o.appendChild(t);for(let e of JD()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#o.appendChild(i)}}}}#m=!1;#g=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#m;this.#m=!1,this.open?this.closePopover("outside"):(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#b=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#O=t=>{if(this.readonly){let r=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),n=t.target.closest("[data-cal-day]");if(r||n){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let r=Fi(this.value);if(!r)return;let n=this.#C(i.dataset.comparisonPresetLabel,r);n&&(this.rangeCompareValue=n);return}};#v=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#P();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#y=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#S=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"";if(!e)return;if(!this.#e?.from||this.#e.to||e<this.#e.from){this.#e={from:e,to:""},this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));return}this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from,to:e}}})),this.#A({from:this.#e.from,to:e})};#x=t=>{this.open&&(this.contains(t.target)||this.#a&&t.composedPath?.().includes(this.#a)||this.closePopover("outside"))};#A(t,e={}){if(!t||!t.from||!t.to)return;if(!LE(t)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"reversed"}}));return}if(this.min&&t.from<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"below-min"}}));return}if(this.max&&t.to>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"above-max"}}));return}let i=JSON.stringify({from:t.from,to:t.to});this.value=i,this.#e=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:{from:t.from,to:t.to},compareValue:Fi(this.compareValue),presetLabel:e.presetLabel||null}}))}#C(t,e){let i=MO(e.from),r=MO(e.to);if(!i||!r)return null;let n=Math.round((r-i)/864e5)+1;switch(t){case"Previous period":{let o=new Date(i);o.setDate(o.getDate()-1);let a=new Date(o);return a.setDate(a.getDate()-(n-1)),{from:Je(a),to:Je(o)}}case"Same period last year":{let o=new Date(i);o.setFullYear(o.getFullYear()-1);let a=new Date(r);return a.setFullYear(a.getFullYear()-1),{from:Je(o),to:Je(a)}}case"Same period last month":{let o=new Date(i);o.setMonth(o.getMonth()-1);let a=new Date(r);return a.setMonth(a.getMonth()-1),{from:Je(o),to:Je(a)}}default:return null}}#P(){if(!this.#a)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#a.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};M();w("date-range-picker-ui",la);ii();var RE=23,IE=12,h6=1,DE=59,NE=59,tN=["hour","minute"];function uh(s){if(!s)return null;let t=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(String(s).trim());if(!t)return null;let e=Number(t[1]),i=Number(t[2]),r=t[3]!=null?Number(t[3]):0;return!Number.isFinite(e)||e<0||e>23||!Number.isFinite(i)||i<0||i>59||!Number.isFinite(r)||r<0||r>59?null:{h:e,m:i,s:r}}function RO({h:s,m:t,s:e},i){let r=n=>String(n).padStart(2,"0");return i==="second"?`${r(s)}:${r(t)}:${r(e)}`:`${r(s)}:${r(t)}`}function ha({h:s,m:t,s:e}){return s*3600+t*60+e}function eN(s){try{let t=s||document?.documentElement?.lang||void 0,i=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions(),r=i.hourCycle||(i.hour12?"h12":"h23");return r==="h11"||r==="h12"?"h12":"h23"}catch{return"h23"}}var ua=class extends X{static labelDeprecated=!1;static properties={...X.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#r(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:eN(this.locale)}get#n(){return this.#r==="h12"}get#a(){return this.precision==="second"}get#o(){return`${this.#r}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#b),this.addEventListener("focusin",this.#O),this.addEventListener("focusout",this.#v)}render(){this.#i&&this.#i!==this.#o&&this.#l(),this.#d(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#b),this.removeEventListener("focusin",this.#O),this.removeEventListener("focusout",this.#v),this.#t=null,this.#e=[],this.#s=null}clear(){this.value="",this.syncValue(""),this.#d()}stepUp(t,e=1){this.#f(t,1*(e|0||1))}stepDown(t,e=1){this.#f(t,-1*(e|0||1))}#l(){let t=this.#r,e=this.#a,i=this.#n,r=[...tN];e&&r.push("second"),i&&r.push("meridiem"),this.#e=r;let n=this.querySelector(':scope > [slot="prefix"]'),o=this.querySelector(':scope > [slot="suffix"]'),a=(c,u,d)=>`<span data-segment="${c}" role="spinbutton" tabindex="0"
|
|
331
|
+
`,this.#e=this.querySelector('[slot="trigger"]'),this.#t=document.createElement("div"),this.#t.setAttribute("slot","popover"),this.#t.setAttribute("popover","manual"),this.appendChild(this.#t);else{let r=this.querySelector('[slot="display"]');r&&(r.textContent=this.#v())}if(this.#t||(this.#t=this.querySelector('[slot="popover"]')),this.#e||(this.#e=this.querySelector('[slot="trigger"]')),this.#t&&!this.#i&&(this.#i=this.#t.querySelector("calendar-grid-ui"),this.#i||(this.#i=document.createElement("calendar-grid-ui"),this.#t.appendChild(this.#i))),this.#i&&!this.#s&&(this.#i.addEventListener("change",this.#p),this.#s=!0),this.#t&&(this.#f?(this.#r||(this.#r=this.#t.querySelector("[data-pane-divider]"),this.#r||(this.#r=document.createElement("divider-ui"),this.#r.setAttribute("data-pane-divider",""),this.#r.setAttribute("vertical",""),this.#t.appendChild(this.#r))),this.#n||(this.#n=this.#t.querySelector("[data-time-pane]"),this.#n||(this.#n=document.createElement("time-picker-ui"),this.#n.setAttribute("data-time-pane",""),this.#t.appendChild(this.#n))),this.#a||(this.#n.addEventListener("change",this.#m),this.#n.addEventListener("input",this.#g),this.#n.addEventListener("invalid",this.#b),this.#a=!0)):(this.#n||this.#r)&&(this.#a&&(this.#n.removeEventListener("change",this.#m),this.#n.removeEventListener("input",this.#g),this.#n.removeEventListener("invalid",this.#b),this.#a=!1),this.#n?.remove(),this.#r?.remove(),this.#n=null,this.#r=null,this.#h=null)),this.#i){let r=this.#f?cr(this.value):null,n=this.#f?this.#h?.date??r?.date??"":this.value||"";this.#i.value=n;let o=this.#f?this.min?this.min.slice(0,10):"":this.min,a=this.#f?this.max?this.max.slice(0,10):"":this.max;o?this.#i.setAttribute("min",o):this.#i.removeAttribute("min"),a?this.#i.setAttribute("max",a):this.#i.removeAttribute("max"),this.#i.toggleAttribute("disabled",!!this.disabled),this.#i.toggleAttribute("readonly",!!this.readonly)}if(this.#f&&this.#n){let r=cr(this.value),n=this.#h?.time??r?.time??"";this.#n.setAttribute("precision",this.precision),this.#n.setAttribute("step",String(this.step)),this.hourcycle?this.#n.setAttribute("hour-cycle",this.hourcycle):this.#n.removeAttribute("hour-cycle"),this.locale?this.#n.setAttribute("locale",this.locale):this.#n.removeAttribute("locale");let o=this.#h?.date??r?.date??"",a=this.min?this.min.slice(11):"",l=this.max?this.max.slice(11):"";a&&o===this.min.slice(0,10)?this.#n.setAttribute("min",a):this.#n.removeAttribute("min"),l&&o===this.max.slice(0,10)?this.#n.setAttribute("max",l):this.#n.removeAttribute("max"),this.#n.value!==n&&(this.#n.value=n),this.#n.toggleAttribute("disabled",!!this.disabled),this.#n.toggleAttribute("readonly",!!this.readonly)}let t=this.querySelector(':scope > [slot="footer"]');t&&this.#t&&t.parentElement!==this.#t&&this.#t.appendChild(t),this.open&&(this.disabled||this.readonly)&&(this.open=!1);let e=this.open&&!this.#c,i=!this.open&&this.#c;this.open?(this.#t?.showPopover?.(),this.#o=Ot(this.#e,this.#t,{placement:this.getAttribute("placement")||"bottom",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,!(!this.isConnected||!this.open)&&document.addEventListener("pointerdown",this.#x,{once:!0})}),e&&queueMicrotask(()=>{if(!this.open||!this.#i)return;let n=this.#i.querySelector("[data-cal-day][data-selected]:not([data-outside])")||this.#i.querySelector("[data-cal-day]:not([disabled]):not([data-outside])"),o=n&&Number(n.dataset.date?.split("-")[2]);o&&this.#i.focusDay(o)}),e&&this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:this.#d}}))):(this.#o?.(),this.#o=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.#t?.hidePopover?.(),document.removeEventListener("pointerdown",this.#x),i&&this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:this.#u}}))),this.#c=this.open}#v(){if(!this.value)return this.placeholder;if(this.#f){let e=cr(this.value);if(!e)return this.value;let i=UD(e.date,this.format),r=YD(e.time,this.precision,this.hourcycle);return!i||!r?this.placeholder:`${i} ${r}`}let t=WD(this.value);if(!t)return this.value;switch(this.format){case"long":return`${TE[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`;case"iso":return this.value;default:return`${QE[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`}}#S=t=>{if(!(this.disabled||this.readonly)){if(this.#t&&t.composedPath().includes(this.#t)){let e=t.target.closest?.("[data-action]");if(e&&this.contains(e)){let i=e.dataset.action;i==="apply"?(this.#O({date:this.#h?.date??this.#i?.value??"",time:this.#h?.time??this.#n?.value??""}),this.#u="apply",this.open=!1):i==="cancel"&&(this.#h=null,this.#u="cancel",this.open=!1)}return}this.open?(this.#u="outside",this.open=!1):(this.#d="click",this.open=!0)}};#x=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.#u="outside",this.open=!1)};#A=t=>{if(!(this.disabled||this.readonly)){if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#d="keyboard",this.open=!0);return}t.key==="Escape"&&(t.preventDefault(),this.#u="escape",this.open=!1)}};disconnected(){super.disconnected(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.removeEventListener("click",this.#S),this.removeEventListener("keydown",this.#A),document.removeEventListener("pointerdown",this.#x),this.#i&&this.#s&&this.#i.removeEventListener("change",this.#p),this.#n&&this.#a&&(this.#n.removeEventListener("change",this.#m),this.#n.removeEventListener("input",this.#g),this.#n.removeEventListener("invalid",this.#b)),this.#s=!1,this.#a=!1,this.#o?.(),this.#o=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null,this.#i=null,this.#r=null,this.#n=null,this.#h=null,this.#c=!1}};M();w("calendar-picker-ui",aa);Lt();var HD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],GD=["January","February","March","April","May","June","July","August","September","October","November","December"];function LO(s){return String(s).padStart(2,"0")}function Je(s){return s?`${s.getFullYear()}-${LO(s.getMonth()+1)}-${LO(s.getDate())}`:""}function MO(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}function Fi(s){if(s==null)return null;if(typeof s=="object")return!s.from||!s.to?null:{from:String(s.from),to:String(s.to)};if(typeof s!="string"||!s.trim())return null;try{let t=JSON.parse(s);if(t&&t.from&&t.to)return{from:String(t.from),to:String(t.to)}}catch{}return null}function LE(s){return s?s.from<=s.to:!1}function ME(s,t){let e=MO(s);if(!e)return"";switch(t){case"long":return`${GD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${HD[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function KD(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=Je(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),Je(l)},r=Je(new Date(t.getFullYear(),t.getMonth(),1)),n=Je(new Date(t.getFullYear(),t.getMonth()+1,0)),o=Je(new Date(t.getFullYear(),0,1));return[{label:"Today",range:{from:e,to:e}},{label:"Last 7 days",range:{from:i(6),to:e}},{label:"Last 30 days",range:{from:i(29),to:e}},{label:"This month",range:{from:r,to:n}},{label:"Year to date",range:{from:o,to:e}}]}function JD(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var la=class extends X{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down"];static get properties(){return{...X.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" icon-trailing="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#r=!1;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;get rangeValue(){return Fi(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return Fi(this.compareValue)}set rangeCompareValue(t){t==null?this.compareValue="":this.compareValue=JSON.stringify({from:String(t.from),to:String(t.to)})}get presets(){return Array.isArray(this.#t)?this.#t:KD()}set presets(t){tt(()=>{this.#t=Array.isArray(t)?t.slice():null,this.isConnected&&this.#p()})}open$(){this.open=!0}close$(){this.open=!1}openPopover(){this.disabled||this.readonly||this.open||(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.comparison&&(this.compareValue=""),this.#e=null,this.syncValue("")}applyPreset(t){let e=this.presets.find(i=>i.label===t);return!e||!e.range?!1:(this.#A(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=Fi(e);if(this.comparison&&this.name){let r=new FormData;i&&r.append(this.name,e),Fi(this.compareValue)&&r.append(`${this.name}-compare`,this.compareValue),this.internals.setFormValue(r)}else this.internals.setFormValue(i?e:"");this.#d(i)}#d(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date range.",this),!1):t&&!LE(t)?(this.internals.setValidity({rangeUnderflow:!0},"End date must be on or after start date.",this),!1):t&&this.min&&t.from<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable date is ${this.min}.`,this),!1):t&&this.max&&t.to>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable date is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#s||(this.#s=!0,this.#u(),this.#n.addEventListener("click",this.#g),this.#n.addEventListener("keydown",this.#b,!0),this.#a.addEventListener("click",this.#O),this.#a.addEventListener("keydown",this.#y),this.#l.addEventListener("change",this.#S),this.#c.addEventListener("change",this.#S)),this.syncValue()}disconnected(){super.disconnected(),this.#n&&(this.#n.removeEventListener("click",this.#g),this.#n.removeEventListener("keydown",this.#b,!0)),this.#a&&(this.#a.removeEventListener("click",this.#O),this.#a.removeEventListener("keydown",this.#y),this.#a.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#S),this.#c&&this.#c.removeEventListener("change",this.#S),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#v),this.#h?.(),this.#h=null,this.#s=!1,this.#r=!1,this.#n=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null}#u(){if(this.#n=this.ensure("trigger"),this.#a=this.ensure("popover"),this.id&&this.#a.setAttribute("aria-labelledby",this.id),!this.#a.querySelector(":scope > [data-calendar-area]")){let r=this.constructor._pp.calArea.cloneNode(!0);this.#a.appendChild(r)}let t=ct(this,"presets")[0];if(t&&t.parentElement!==this.#a)this.#a.appendChild(t),this.#o=t;else if(!this.noPresets&&!t){if(!this.#a.querySelector(":scope > [data-preset-rail]")){let r=this.constructor._pp.presets.cloneNode(!0);this.#a.insertBefore(r,this.#a.querySelector(":scope > [data-calendar-area]"))}this.#o=this.#a.querySelector(":scope > [data-preset-rail]")}let e=this.#a.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let r=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(r)}if(!e.querySelector(":scope > [data-cal-to]")){let r=this.constructor._pp.calTo.cloneNode(!0),n=Fi(this.value)?.from,o,a;if(n){let[l,h]=n.split("-").map(Number);o=l,a=h-1}else{let l=new Date;o=l.getFullYear(),a=l.getMonth()}a+=1,a>11&&(a=0,o+=1),r.setAttribute("month",`${o}-${LO(a+1)}`),e.appendChild(r)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=ct(this,"footer")[0];i&&i.parentElement!==this.#a&&this.#a.appendChild(i)}render(){if(!this.#n)return;let t=this.#f();this.#n.setAttribute("text",t),this.#n.toggleAttribute("data-has-value",t!==this.placeholder),this.#n.toggleAttribute("disabled",this.disabled),this.#n.setAttribute("aria-haspopup","dialog"),this.#n.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let e=Fi(this.value),i=this.#e,r=i?i.from:e?.from||"",n=i?i.to:e?.to||"",o=a=>{r?a.setAttribute("range-start",r):a.removeAttribute("range-start"),n?a.setAttribute("range-end",n):a.removeAttribute("range-end")};this.#l&&(this.min&&this.#l.setAttribute("min",this.min),this.max&&this.#l.setAttribute("max",this.max),this.#l.value=r,o(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=n,o(this.#c)),ct(this,"presets").length||(this.noPresets?(this.#o?.remove(),this.#o=null):(this.#o||this.#u(),this.#p())),this.#a&&(this.open&&!this.#r?!this.disabled&&!this.readonly?(this.#r=!0,this.#a.showPopover?.(),this.#h?.(),this.#h=Ot(this.#n,this.#a,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#x),document.addEventListener("keydown",this.#v),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#r&&(this.#r=!1,this.#h?.(),this.#h=null,this.#a.hidePopover?.(),document.removeEventListener("pointerdown",this.#x),document.removeEventListener("keydown",this.#v),this.#n?.focus?.()))}#f(){let t=Fi(this.value);if(!t)return this.placeholder;let e=ME(t.from,this.format),i=ME(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#p(){if(this.#o){this.#o.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#o.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#o.appendChild(t);for(let e of JD()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#o.appendChild(i)}}}}#m=!1;#g=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#m;this.#m=!1,this.open?this.closePopover("outside"):(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#b=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#O=t=>{if(this.readonly){let r=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),n=t.target.closest("[data-cal-day]");if(r||n){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let r=Fi(this.value);if(!r)return;let n=this.#E(i.dataset.comparisonPresetLabel,r);n&&(this.rangeCompareValue=n);return}};#y=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#$();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#v=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#S=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"";if(!e)return;if(!this.#e?.from||this.#e.to||e<this.#e.from){this.#e={from:e,to:""},this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));return}this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from,to:e}}})),this.#A({from:this.#e.from,to:e})};#x=t=>{this.open&&(this.contains(t.target)||this.#a&&t.composedPath?.().includes(this.#a)||this.closePopover("outside"))};#A(t,e={}){if(!t||!t.from||!t.to)return;if(!LE(t)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"reversed"}}));return}if(this.min&&t.from<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"below-min"}}));return}if(this.max&&t.to>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"above-max"}}));return}let i=JSON.stringify({from:t.from,to:t.to});this.value=i,this.#e=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:{from:t.from,to:t.to},compareValue:Fi(this.compareValue),presetLabel:e.presetLabel||null}}))}#E(t,e){let i=MO(e.from),r=MO(e.to);if(!i||!r)return null;let n=Math.round((r-i)/864e5)+1;switch(t){case"Previous period":{let o=new Date(i);o.setDate(o.getDate()-1);let a=new Date(o);return a.setDate(a.getDate()-(n-1)),{from:Je(a),to:Je(o)}}case"Same period last year":{let o=new Date(i);o.setFullYear(o.getFullYear()-1);let a=new Date(r);return a.setFullYear(a.getFullYear()-1),{from:Je(o),to:Je(a)}}case"Same period last month":{let o=new Date(i);o.setMonth(o.getMonth()-1);let a=new Date(r);return a.setMonth(a.getMonth()-1),{from:Je(o),to:Je(a)}}default:return null}}#$(){if(!this.#a)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#a.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};M();w("date-range-picker-ui",la);ii();var RE=23,IE=12,h6=1,DE=59,NE=59,tN=["hour","minute"];function uh(s){if(!s)return null;let t=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(String(s).trim());if(!t)return null;let e=Number(t[1]),i=Number(t[2]),r=t[3]!=null?Number(t[3]):0;return!Number.isFinite(e)||e<0||e>23||!Number.isFinite(i)||i<0||i>59||!Number.isFinite(r)||r<0||r>59?null:{h:e,m:i,s:r}}function RO({h:s,m:t,s:e},i){let r=n=>String(n).padStart(2,"0");return i==="second"?`${r(s)}:${r(t)}:${r(e)}`:`${r(s)}:${r(t)}`}function ha({h:s,m:t,s:e}){return s*3600+t*60+e}function eN(s){try{let t=s||document?.documentElement?.lang||void 0,i=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions(),r=i.hourCycle||(i.hour12?"h12":"h23");return r==="h11"||r==="h12"?"h12":"h23"}catch{return"h23"}}var ua=class extends X{static labelDeprecated=!1;static properties={...X.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#r(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:eN(this.locale)}get#n(){return this.#r==="h12"}get#a(){return this.precision==="second"}get#o(){return`${this.#r}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#b),this.addEventListener("focusin",this.#O),this.addEventListener("focusout",this.#y)}render(){this.#i&&this.#i!==this.#o&&this.#l(),this.#d(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#b),this.removeEventListener("focusin",this.#O),this.removeEventListener("focusout",this.#y),this.#t=null,this.#e=[],this.#s=null}clear(){this.value="",this.syncValue(""),this.#d()}stepUp(t,e=1){this.#f(t,1*(e|0||1))}stepDown(t,e=1){this.#f(t,-1*(e|0||1))}#l(){let t=this.#r,e=this.#a,i=this.#n,r=[...tN];e&&r.push("second"),i&&r.push("meridiem"),this.#e=r;let n=this.querySelector(':scope > [slot="prefix"]'),o=this.querySelector(':scope > [slot="suffix"]'),a=(c,u,d)=>`<span data-segment="${c}" role="spinbutton" tabindex="0"
|
|
332
332
|
aria-label="${u}" aria-valuemin="0" aria-valuemax="${d}"
|
|
333
333
|
aria-valuenow=""></span>`,l='<span data-separator aria-hidden="true">:</span>',h="";h+=a("hour","Hours",i?IE:RE),h+=l,h+=a("minute","Minutes",DE),e&&(h+=l,h+=a("second","Seconds",NE)),i&&(h+=`<span data-segment="meridiem" role="spinbutton" tabindex="0"
|
|
334
334
|
aria-label="AM/PM" aria-valuemin="0" aria-valuemax="1"
|
|
335
|
-
aria-valuenow="" data-meridiem></span>`),this.innerHTML=h,n&&this.insertBefore(n,this.firstChild),o&&this.appendChild(o),this.#t={};for(let c of r){let u=this.querySelector(`[data-segment="${c}"]`);u&&(this.#t[c]=u)}for(let c of r){let u=this.#t[c];u&&(u.contentEditable="plaintext-only",u.addEventListener("beforeinput",this.#y),u.addEventListener("input",this.#S),u.addEventListener("blur",this.#x),u.addEventListener("focus",this.#A))}this.#i=this.#o}#c(){if(!this.#t)return;let t=!(this.disabled||this.readonly);for(let e of this.#e){let i=this.#t[e];i&&(i.contentEditable=t?"plaintext-only":"false")}}#h(){let t=uh(this.value);return t||null}#d(){if(!this.#t)return;let t=this.#h(),e=this.#r;if(!t){for(let a of this.#e){let l=this.#t[a];l&&(document.activeElement===l&&l.textContent!==""||(l.textContent="",l.setAttribute("aria-valuenow",""),l.setAttribute("aria-valuetext",this.placeholder)))}return}let i=this.#n?t.h%12||12:t.h,r={hour:IO(i),minute:IO(t.m),second:IO(t.s),meridiem:e==="h12"?t.h>=12?"PM":"AM":""},n={hour:String(i),minute:String(t.m),second:String(t.s),meridiem:e==="h12"?t.h>=12?"1":"0":""},o={hour:`${i} hour${i===1?"":"s"}`,minute:`${t.m} minute${t.m===1?"":"s"}`,second:`${t.s} second${t.s===1?"":"s"}`,meridiem:e==="h12"?t.h>=12?"PM":"AM":""};for(let a of this.#e){let l=this.#t[a];l&&document.activeElement!==l&&(l.textContent=r[a],l.setAttribute("aria-valuenow",n[a]),l.setAttribute("aria-valuetext",o[a]))}}#u(t){if(!this.#t)return;let e=this.#r,i={};for(let d of this.#e)i[d]=(this.#t[d]?.textContent||"").trim();if(!i.hour&&!i.minute){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",segment:t||null}}));return}let r=DO(i.hour,0,e==="h12"?IE:RE),n=DO(i.minute,0,DE),o=this.#a?DO(i.second,0,NE):0;if(r==null||n==null||o==null){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"parse"}}));return}if(e==="h12"){let f=String(i.meridiem||"").trim().toUpperCase()==="PM";r===12?r=f?12:0:f&&(r+=12)}let a={h:r,m:n,s:o},l=ha(a),h=uh(this.min),c=uh(this.max);if(h&&l<ha(h)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(c&&l>ha(c)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let u=RO(a,this.precision);if(u===this.value){this.#d();return}this.value=u,this.syncValue(u),this.#d(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:u,segment:t||null}}))}#f(t,e){if(this.disabled||this.readonly||!this.#t?.[t])return;let i=this.#r,r=Math.max(1,this.step|0),n=this.#h();if(n||(n={h:0,m:0,s:0}),t==="hour")n.h=ca(n.h+e,0,24);else if(t==="minute"){let c=Math.max(1,Math.floor(r/60))*e;for(n.m=n.m+c;n.m<0;)n.m+=60,n.h=ca(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=ca(n.h+1,0,24)}else if(t==="second"){let c=Math.max(1,r)*e;for(n.s=n.s+c;n.s<0;)n.s+=60,n.m-=1;for(;n.s>59;)n.s-=60,n.m+=1;for(;n.m<0;)n.m+=60,n.h=ca(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=ca(n.h+1,0,24)}else t==="meridiem"&&(n.h=ca(n.h+12,0,24));let o=ha(n),a=uh(this.min),l=uh(this.max);if(a&&o<ha(a)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(l&&o>ha(l)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let h=RO(n,this.precision);this.value=h,this.syncValue(h),this.#d(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:h}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:h,segment:t}}))}#p(t,e){if(this.disabled||this.readonly)return;let i=this.#r,r=this.#h()||{h:0,m:0,s:0};t==="hour"?r.h=e==="min"?0:23:t==="minute"?r.m=e==="min"?0:59:t==="second"?r.s=e==="min"?0:59:t==="meridiem"&&(r.h=e==="min"?r.h%12:r.h%12+12);let n=RO(r,this.precision);this.value=n,this.syncValue(n),this.#d(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,segment:t}}))}#m(t,e){let i=this.#e.indexOf(t);if(i<0)return;let r=i+e;if(r<0||r>=this.#e.length)return;this.#t?.[this.#e[r]]?.focus()}#g(t){if(!re(t))return null;let e=t.closest("[data-segment]");return!e||!this.contains(e)?null:e.getAttribute("data-segment")}#b=t=>{if(this.disabled)return;let e=this.#g(t.target);if(e)switch(t.key){case"ArrowUp":t.preventDefault(),this.#f(e,1);return;case"ArrowDown":t.preventDefault(),this.#f(e,-1);return;case"PageUp":t.preventDefault(),this.#f(e,10);return;case"PageDown":t.preventDefault(),this.#f(e,-10);return;case"Home":t.preventDefault(),this.#p(e,"min");return;case"End":t.preventDefault(),this.#p(e,"max");return;case"ArrowLeft":t.preventDefault(),this.#m(e,-1);return;case"ArrowRight":t.preventDefault(),this.#m(e,1);return;case"Enter":t.preventDefault(),this.#u(e);return}};#O=t=>{let e=this.#g(t.target);e&&(this.#s=e,this.setAttribute("editing",""),this.setAttribute("segment",e))};#v=t=>{queueMicrotask(()=>{let e=document.activeElement;(!e||!this.contains(e))&&(this.removeAttribute("editing"),this.removeAttribute("segment"),this.#s=null)})};#y=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;if(this.#g(t.target)==="meridiem"){if(!/^[apmAPM]$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault();return}if(!/^\d$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault()};#S=t=>{let e=this.#g(t.target);if(!e)return;let i=(t.target.textContent||"").trim();if(this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),e==="meridiem"){let r=i.toUpperCase();(r==="AM"||r==="PM")&&(t.target.textContent=r,this.#u(e));return}if(i.length<2){let r=parseInt(t.target.getAttribute("aria-valuemax")||"0",10),n=parseInt(i,10);Number.isNaN(n)||n*10>r&&(this.#u(e),this.#m(e,1))}else this.#u(e),this.#m(e,1)};#x=t=>{let e=this.#g(t.target);e&&this.#u(e)};#A=t=>{let e=t.target;re(e)&&typeof requestAnimationFrame=="function"&&requestAnimationFrame(()=>{if(document.activeElement!==e)return;let i=window.getSelection?.();if(!i)return;let r=document.createRange();r.selectNodeContents(e),i.removeAllRanges(),i.addRange(r)})};onFormReset(){this.value="",this.#d()}};function IO(s){return String(s).padStart(2,"0")}function DO(s,t,e){if(s===""||s==null)return null;let i=Number(s);return!Number.isFinite(i)||!Number.isInteger(i)||i<t||i>e?null:i}function ca(s,t,e){let i=s-t,r=e-t;return i=(i%r+r)%r,i+t}M();w("time-picker-ui",ua);R();var da=class extends k{static properties={src:{type:String,default:"",reflect:!0},height:{type:String,default:"400",reflect:!0},width:{type:String,default:"100%",reflect:!0},aspect:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;connected(){this.#t||(this.#t=document.createElement("iframe"),this.#t.setAttribute("sandbox","allow-scripts allow-same-origin"),this.#t.setAttribute("loading","lazy"),this.#t.setAttribute("allowfullscreen",""),this.appendChild(this.#t))}render(){this.#t&&(this.src&&(this.#t.src=this.src),this.aspect?(this.style.aspectRatio=this.aspect,this.#t.style.width="100%",this.#t.style.height="100%",this.style.width=this.width,this.style.height=""):(this.style.aspectRatio="",this.#t.style.width="100%",this.#t.style.height=this.height.match(/^\d+$/)?`${this.height}px`:this.height,this.style.width=this.width,this.style.height=""))}disconnected(){this.#t=null}};M();w("embed-ui",da);R();var iN=new Set(["xs","sm","md","lg","xl"]);function qE(s,t){return s==null||s===""?"":s==="none"?"0":iN.has(s)?`var(--a-${t}-${s})`:/^\d+$/.test(s)?`var(--a-space-${s})`:s}var fa=class extends k{static properties={padding:{type:String,default:"md",reflect:!0},margin:{type:String,default:"none",reflect:!0}};static template=()=>null;render(){let t=this.padding,e=this.margin,r=t?.includes("@")||e?.includes("@")?Re.value:"";t?.includes("@")?this.style.setProperty("--block-padding",qE(jt(t,r),"padding")):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",qE(jt(e,r),"margin")):this.style.removeProperty("--block-margin")}};M();w("block-ui",fa);R();var sN={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function rN(s){return sN[s]??s}var pa=class extends k{static properties={variant:{type:String,default:"body",reflect:!0},strong:{type:Boolean,default:!1,reflect:!0},truncate:{type:Boolean,default:!1,reflect:!0},lines:{type:Number,default:0,reflect:!0},size:{type:String,default:"",reflect:!0},color:{type:String,default:"",reflect:!0},weight:{type:String,default:"",reflect:!0},"text-align":{type:String,default:"",reflect:!0}};static template=()=>null;render(){this.lines>0?this.style.setProperty("--_text-lines",String(this.lines)):this.style.removeProperty("--_text-lines");let t=this.size;if(t?.includes("@")){let e=Re.value;this.style.setProperty("--text-size",rN(jt(t,e)))}else this.style.removeProperty("--text-size")}};M();w("text-ui",pa);R();var Wi="light",Ve="dark",NO="auto",ma=class extends k{static properties={scheme:{type:String,default:NO,reflect:!0},target:{type:String,default:":root",reflect:!0},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},iconLight:{type:String,default:"sun",reflect:!0,attribute:"icon-light"},iconDark:{type:String,default:"moon",reflect:!0,attribute:"icon-dark"},labelLight:{type:String,default:"Switch to dark mode",reflect:!0,attribute:"label-light"},labelDark:{type:String,default:"Switch to light mode",reflect:!0,attribute:"label-dark"},size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"ghost",reflect:!0},color:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=!1;#n=!1;connected(){this.#r||(this.#a(),this.#r=!0),this.#o()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="scheme"&&this.isConnected&&this.#r&&!this.#n&&e!==i&&this.#o()}disconnected(){this.#t&&this.#s&&this.#t.removeEventListener("press",this.#s),this.#g()}toggle(){this.#n=!0;let t=this.activeScheme===Ve?Wi:Ve;this.#l(t,"programmatic")}setScheme(t){if(this.#n=!0,t===NO){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Wi||t===Ve)&&this.#l(t,"programmatic")}#a(){let t=document.createElement("button-ui");t.setAttribute("part","button"),t.setAttribute("variant",this.variant||"ghost"),t.setAttribute("size",this.size||"md"),this.color&&t.setAttribute("color",this.color),this.disabled&&t.setAttribute("disabled",""),this.appendChild(t),this.#t=t,this.#s=e=>{if(e.stopPropagation(),this.disabled)return;this.#n=!0;let i=this.activeScheme===Ve?Wi:Ve;this.#l(i,"press")},t.addEventListener("press",this.#s)}#o(){let t=null;if(this.persist)try{let e=localStorage.getItem(`${this.storagePrefix}scheme`);(e===Wi||e===Ve)&&(t=e)}catch{}if(t===null){let e=this.scheme||NO;(e===Wi||e===Ve)&&(t=e)}t===Wi||t===Ve?(this.#u(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Wi&&t!==Ve)){if(this.#u(t),this.activeScheme=t,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,t)}catch{}this.#g(),this.#c(),this.#h(e)}}#c(){if(!this.#t)return;let t=this.activeScheme===Ve,e=t?this.iconDark:this.iconLight,i=t?this.labelDark:this.labelLight;this.#t.getAttribute("icon")!==e&&this.#t.setAttribute("icon",e),this.#t.setAttribute("aria-label",i),this.#t.setAttribute("title",i),this.#t.getAttribute("variant")!==this.variant&&this.#t.setAttribute("variant",this.variant||"ghost"),this.#t.getAttribute("size")!==this.size&&this.#t.setAttribute("size",this.size||"md"),this.color?this.#t.setAttribute("color",this.color):this.#t.removeAttribute("color"),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled")}render(){this.#c()}#h(t){this.dispatchEvent(new CustomEvent("scheme-change",{bubbles:!0,detail:{scheme:this.activeScheme,source:t}}))}#d(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}#u(t){let e=this.#d();e.style.setProperty("color-scheme",t),e.setAttribute("data-scheme",t)}#f(){let t=this.#d();if(t.style.removeProperty("color-scheme"),t.removeAttribute("data-scheme"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}}#p(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return Ve}catch{}return Wi}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?Ve:Wi;t!==this.activeScheme&&(this.activeScheme=t,this.#c(),this.#h("media"))},this.#e.addEventListener("change",this.#i)}catch{}}#g(){if(this.#e&&this.#i)try{this.#e.removeEventListener("change",this.#i)}catch{}this.#e=null,this.#i=null}};M();w("toggle-scheme-ui",ma);R();var ga=class extends k{static properties={labelOn:{type:String,default:"On",attribute:"label-on",reflect:!0},labelOff:{type:String,default:"Off",attribute:"label-off",reflect:!0},initial:{type:String,default:"off",reflect:!0},state:{type:String,default:"",reflect:!0}};static parts={bar:`
|
|
335
|
+
aria-valuenow="" data-meridiem></span>`),this.innerHTML=h,n&&this.insertBefore(n,this.firstChild),o&&this.appendChild(o),this.#t={};for(let c of r){let u=this.querySelector(`[data-segment="${c}"]`);u&&(this.#t[c]=u)}for(let c of r){let u=this.#t[c];u&&(u.contentEditable="plaintext-only",u.addEventListener("beforeinput",this.#v),u.addEventListener("input",this.#S),u.addEventListener("blur",this.#x),u.addEventListener("focus",this.#A))}this.#i=this.#o}#c(){if(!this.#t)return;let t=!(this.disabled||this.readonly);for(let e of this.#e){let i=this.#t[e];i&&(i.contentEditable=t?"plaintext-only":"false")}}#h(){let t=uh(this.value);return t||null}#d(){if(!this.#t)return;let t=this.#h(),e=this.#r;if(!t){for(let a of this.#e){let l=this.#t[a];l&&(document.activeElement===l&&l.textContent!==""||(l.textContent="",l.setAttribute("aria-valuenow",""),l.setAttribute("aria-valuetext",this.placeholder)))}return}let i=this.#n?t.h%12||12:t.h,r={hour:IO(i),minute:IO(t.m),second:IO(t.s),meridiem:e==="h12"?t.h>=12?"PM":"AM":""},n={hour:String(i),minute:String(t.m),second:String(t.s),meridiem:e==="h12"?t.h>=12?"1":"0":""},o={hour:`${i} hour${i===1?"":"s"}`,minute:`${t.m} minute${t.m===1?"":"s"}`,second:`${t.s} second${t.s===1?"":"s"}`,meridiem:e==="h12"?t.h>=12?"PM":"AM":""};for(let a of this.#e){let l=this.#t[a];l&&document.activeElement!==l&&(l.textContent=r[a],l.setAttribute("aria-valuenow",n[a]),l.setAttribute("aria-valuetext",o[a]))}}#u(t){if(!this.#t)return;let e=this.#r,i={};for(let d of this.#e)i[d]=(this.#t[d]?.textContent||"").trim();if(!i.hour&&!i.minute){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",segment:t||null}}));return}let r=DO(i.hour,0,e==="h12"?IE:RE),n=DO(i.minute,0,DE),o=this.#a?DO(i.second,0,NE):0;if(r==null||n==null||o==null){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"parse"}}));return}if(e==="h12"){let f=String(i.meridiem||"").trim().toUpperCase()==="PM";r===12?r=f?12:0:f&&(r+=12)}let a={h:r,m:n,s:o},l=ha(a),h=uh(this.min),c=uh(this.max);if(h&&l<ha(h)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(c&&l>ha(c)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let u=RO(a,this.precision);if(u===this.value){this.#d();return}this.value=u,this.syncValue(u),this.#d(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:u,segment:t||null}}))}#f(t,e){if(this.disabled||this.readonly||!this.#t?.[t])return;let i=this.#r,r=Math.max(1,this.step|0),n=this.#h();if(n||(n={h:0,m:0,s:0}),t==="hour")n.h=ca(n.h+e,0,24);else if(t==="minute"){let c=Math.max(1,Math.floor(r/60))*e;for(n.m=n.m+c;n.m<0;)n.m+=60,n.h=ca(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=ca(n.h+1,0,24)}else if(t==="second"){let c=Math.max(1,r)*e;for(n.s=n.s+c;n.s<0;)n.s+=60,n.m-=1;for(;n.s>59;)n.s-=60,n.m+=1;for(;n.m<0;)n.m+=60,n.h=ca(n.h-1,0,24);for(;n.m>59;)n.m-=60,n.h=ca(n.h+1,0,24)}else t==="meridiem"&&(n.h=ca(n.h+12,0,24));let o=ha(n),a=uh(this.min),l=uh(this.max);if(a&&o<ha(a)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(l&&o>ha(l)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let h=RO(n,this.precision);this.value=h,this.syncValue(h),this.#d(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:h}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:h,segment:t}}))}#p(t,e){if(this.disabled||this.readonly)return;let i=this.#r,r=this.#h()||{h:0,m:0,s:0};t==="hour"?r.h=e==="min"?0:23:t==="minute"?r.m=e==="min"?0:59:t==="second"?r.s=e==="min"?0:59:t==="meridiem"&&(r.h=e==="min"?r.h%12:r.h%12+12);let n=RO(r,this.precision);this.value=n,this.syncValue(n),this.#d(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,segment:t}}))}#m(t,e){let i=this.#e.indexOf(t);if(i<0)return;let r=i+e;if(r<0||r>=this.#e.length)return;this.#t?.[this.#e[r]]?.focus()}#g(t){if(!re(t))return null;let e=t.closest("[data-segment]");return!e||!this.contains(e)?null:e.getAttribute("data-segment")}#b=t=>{if(this.disabled)return;let e=this.#g(t.target);if(e)switch(t.key){case"ArrowUp":t.preventDefault(),this.#f(e,1);return;case"ArrowDown":t.preventDefault(),this.#f(e,-1);return;case"PageUp":t.preventDefault(),this.#f(e,10);return;case"PageDown":t.preventDefault(),this.#f(e,-10);return;case"Home":t.preventDefault(),this.#p(e,"min");return;case"End":t.preventDefault(),this.#p(e,"max");return;case"ArrowLeft":t.preventDefault(),this.#m(e,-1);return;case"ArrowRight":t.preventDefault(),this.#m(e,1);return;case"Enter":t.preventDefault(),this.#u(e);return}};#O=t=>{let e=this.#g(t.target);e&&(this.#s=e,this.setAttribute("editing",""),this.setAttribute("segment",e))};#y=t=>{queueMicrotask(()=>{let e=document.activeElement;(!e||!this.contains(e))&&(this.removeAttribute("editing"),this.removeAttribute("segment"),this.#s=null)})};#v=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;if(this.#g(t.target)==="meridiem"){if(!/^[apmAPM]$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault();return}if(!/^\d$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault()};#S=t=>{let e=this.#g(t.target);if(!e)return;let i=(t.target.textContent||"").trim();if(this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),e==="meridiem"){let r=i.toUpperCase();(r==="AM"||r==="PM")&&(t.target.textContent=r,this.#u(e));return}if(i.length<2){let r=parseInt(t.target.getAttribute("aria-valuemax")||"0",10),n=parseInt(i,10);Number.isNaN(n)||n*10>r&&(this.#u(e),this.#m(e,1))}else this.#u(e),this.#m(e,1)};#x=t=>{let e=this.#g(t.target);e&&this.#u(e)};#A=t=>{let e=t.target;re(e)&&typeof requestAnimationFrame=="function"&&requestAnimationFrame(()=>{if(document.activeElement!==e)return;let i=window.getSelection?.();if(!i)return;let r=document.createRange();r.selectNodeContents(e),i.removeAllRanges(),i.addRange(r)})};onFormReset(){this.value="",this.#d()}};function IO(s){return String(s).padStart(2,"0")}function DO(s,t,e){if(s===""||s==null)return null;let i=Number(s);return!Number.isFinite(i)||!Number.isInteger(i)||i<t||i>e?null:i}function ca(s,t,e){let i=s-t,r=e-t;return i=(i%r+r)%r,i+t}M();w("time-picker-ui",ua);R();var da=class extends k{static properties={src:{type:String,default:"",reflect:!0},height:{type:String,default:"400",reflect:!0},width:{type:String,default:"100%",reflect:!0},aspect:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;connected(){this.#t||(this.#t=document.createElement("iframe"),this.#t.setAttribute("sandbox","allow-scripts allow-same-origin"),this.#t.setAttribute("loading","lazy"),this.#t.setAttribute("allowfullscreen",""),this.appendChild(this.#t))}render(){this.#t&&(this.src&&(this.#t.src=this.src),this.aspect?(this.style.aspectRatio=this.aspect,this.#t.style.width="100%",this.#t.style.height="100%",this.style.width=this.width,this.style.height=""):(this.style.aspectRatio="",this.#t.style.width="100%",this.#t.style.height=this.height.match(/^\d+$/)?`${this.height}px`:this.height,this.style.width=this.width,this.style.height=""))}disconnected(){this.#t=null}};M();w("embed-ui",da);R();var iN=new Set(["xs","sm","md","lg","xl"]);function qE(s,t){return s==null||s===""?"":s==="none"?"0":iN.has(s)?`var(--a-${t}-${s})`:/^\d+$/.test(s)?`var(--a-space-${s})`:s}var fa=class extends k{static properties={padding:{type:String,default:"md",reflect:!0},margin:{type:String,default:"none",reflect:!0}};static template=()=>null;render(){let t=this.padding,e=this.margin,r=t?.includes("@")||e?.includes("@")?Re.value:"";t?.includes("@")?this.style.setProperty("--block-padding",qE(jt(t,r),"padding")):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",qE(jt(e,r),"margin")):this.style.removeProperty("--block-margin")}};M();w("block-ui",fa);R();var sN={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function rN(s){return sN[s]??s}var pa=class extends k{static properties={variant:{type:String,default:"body",reflect:!0},strong:{type:Boolean,default:!1,reflect:!0},truncate:{type:Boolean,default:!1,reflect:!0},lines:{type:Number,default:0,reflect:!0},size:{type:String,default:"",reflect:!0},color:{type:String,default:"",reflect:!0},weight:{type:String,default:"",reflect:!0},"text-align":{type:String,default:"",reflect:!0}};static template=()=>null;render(){this.lines>0?this.style.setProperty("--_text-lines",String(this.lines)):this.style.removeProperty("--_text-lines");let t=this.size;if(t?.includes("@")){let e=Re.value;this.style.setProperty("--text-size",rN(jt(t,e)))}else this.style.removeProperty("--text-size")}};M();w("text-ui",pa);R();var Wi="light",Ve="dark",NO="auto",ma=class extends k{static properties={scheme:{type:String,default:NO,reflect:!0},target:{type:String,default:":root",reflect:!0},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},iconLight:{type:String,default:"sun",reflect:!0,attribute:"icon-light"},iconDark:{type:String,default:"moon",reflect:!0,attribute:"icon-dark"},labelLight:{type:String,default:"Switch to dark mode",reflect:!0,attribute:"label-light"},labelDark:{type:String,default:"Switch to light mode",reflect:!0,attribute:"label-dark"},size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"ghost",reflect:!0},color:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=!1;#n=!1;connected(){this.#r||(this.#a(),this.#r=!0),this.#o()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="scheme"&&this.isConnected&&this.#r&&!this.#n&&e!==i&&this.#o()}disconnected(){this.#t&&this.#s&&this.#t.removeEventListener("press",this.#s),this.#g()}toggle(){this.#n=!0;let t=this.activeScheme===Ve?Wi:Ve;this.#l(t,"programmatic")}setScheme(t){if(this.#n=!0,t===NO){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Wi||t===Ve)&&this.#l(t,"programmatic")}#a(){let t=document.createElement("button-ui");t.setAttribute("part","button"),t.setAttribute("variant",this.variant||"ghost"),t.setAttribute("size",this.size||"md"),this.color&&t.setAttribute("color",this.color),this.disabled&&t.setAttribute("disabled",""),this.appendChild(t),this.#t=t,this.#s=e=>{if(e.stopPropagation(),this.disabled)return;this.#n=!0;let i=this.activeScheme===Ve?Wi:Ve;this.#l(i,"press")},t.addEventListener("press",this.#s)}#o(){let t=null;if(this.persist)try{let e=localStorage.getItem(`${this.storagePrefix}scheme`);(e===Wi||e===Ve)&&(t=e)}catch{}if(t===null){let e=this.scheme||NO;(e===Wi||e===Ve)&&(t=e)}t===Wi||t===Ve?(this.#u(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Wi&&t!==Ve)){if(this.#u(t),this.activeScheme=t,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,t)}catch{}this.#g(),this.#c(),this.#h(e)}}#c(){if(!this.#t)return;let t=this.activeScheme===Ve,e=t?this.iconDark:this.iconLight,i=t?this.labelDark:this.labelLight;this.#t.getAttribute("icon")!==e&&this.#t.setAttribute("icon",e),this.#t.setAttribute("aria-label",i),this.#t.setAttribute("title",i),this.#t.getAttribute("variant")!==this.variant&&this.#t.setAttribute("variant",this.variant||"ghost"),this.#t.getAttribute("size")!==this.size&&this.#t.setAttribute("size",this.size||"md"),this.color?this.#t.setAttribute("color",this.color):this.#t.removeAttribute("color"),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled")}render(){this.#c()}#h(t){this.dispatchEvent(new CustomEvent("scheme-change",{bubbles:!0,detail:{scheme:this.activeScheme,source:t}}))}#d(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}#u(t){let e=this.#d();e.style.setProperty("color-scheme",t),e.setAttribute("data-scheme",t)}#f(){let t=this.#d();if(t.style.removeProperty("color-scheme"),t.removeAttribute("data-scheme"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}}#p(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return Ve}catch{}return Wi}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?Ve:Wi;t!==this.activeScheme&&(this.activeScheme=t,this.#c(),this.#h("media"))},this.#e.addEventListener("change",this.#i)}catch{}}#g(){if(this.#e&&this.#i)try{this.#e.removeEventListener("change",this.#i)}catch{}this.#e=null,this.#i=null}};M();w("toggle-scheme-ui",ma);R();var ga=class extends k{static properties={labelOn:{type:String,default:"On",attribute:"label-on",reflect:!0},labelOff:{type:String,default:"Off",attribute:"label-off",reflect:!0},initial:{type:String,default:"off",reflect:!0},state:{type:String,default:"",reflect:!0}};static parts={bar:`
|
|
336
336
|
<row-ui slot="bar" gap="3" align="center" data-demo-toggle-bar>
|
|
337
337
|
<text-ui slot="label" data-demo-toggle-label></text-ui>
|
|
338
338
|
<switch-ui slot="switch" data-demo-toggle-switch></switch-ui>
|
|
@@ -347,7 +347,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
347
347
|
`}).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)}};M();w("rating-ui",$a);R();var Pa=class extends k{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})=>`
|
|
348
348
|
<dt data-dl-term>${this.#e(e)}</dt>
|
|
349
349
|
<dd data-dl-desc>${this.#e(i)}</dd>
|
|
350
|
-
`).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,"&").replace(/</g,"<").replace(/>/g,">")}};M();w("description-list-ui",Pa);R();var AN=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Qa=class extends k{static properties={type:{type:String,default:"matrix",reflect:!0},rows:{type:Number,default:7,reflect:!0},cols:{type:Number,default:12,reflect:!0},scale:{type:String,default:"linear",reflect:!0},noLegend:{type:Boolean,default:!1,reflect:!0,attribute:"no-legend"},colorScheme:{type:String,default:"data-ramp",reflect:!0,attribute:"color-scheme"},startDate:{type:String,default:"",reflect:!0,attribute:"start-date"},aspect:{type:String,default:"wide",reflect:!0}};static template=()=>null;#t=[];#e=!1;set data(t){if(typeof t=="string")try{t=JSON.parse(t)}catch{t=[]}this.#t=Array.isArray(t)?t:[],this.#s()}get data(){return this.#t}connected(){this.setAttribute("role","img");let t=this.getAttribute("data");if(t&&!this.#t.length)try{this.#t=JSON.parse(t)}catch{}this.#e||(this.#e=!0,this.addEventListener("pointerover",this.#l),this.addEventListener("pointermove",this.#c),this.addEventListener("pointerleave",this.#h),this.addEventListener("click",this.#d))}disconnected(){this.removeEventListener("pointerover",this.#l),this.removeEventListener("pointermove",this.#c),this.removeEventListener("pointerleave",this.#h),this.removeEventListener("click",this.#d),this.#e=!1,this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null)}#i=null;#s(){!this.isConnected||this.#i||(this.#i=requestAnimationFrame(()=>{this.#i=null,this.render()}))}#r(){let t=this.#t.map(n=>Number(n.v)||0);if(!t.length)return n=>0;let e=Math.min(...t),i=Math.max(...t);if(e===i)return n=>4;let r=this.scale;if(r==="log"){let n=Math.log(Math.max(1,e)),o=Math.log(Math.max(1,i));return a=>{let h=(Math.log(Math.max(1,Number(a)||0))-n)/(o-n);return Math.min(4,Math.max(0,Math.round(h*4)))}}if(r==="quantile"){let n=[...t].sort((l,h)=>l-h),o=l=>n[Math.floor(l*(n.length-1))],a=[o(.2),o(.4),o(.6),o(.8)];return l=>{let h=Number(l)||0;return h<=a[0]?0:h<=a[1]?1:h<=a[2]?2:h<=a[3]?3:4}}return n=>{let a=((Number(n)||0)-e)/(i-e);return Math.min(4,Math.max(0,Math.round(a*4)))}}render(){let t=Math.max(1,this.rows||7),e=Math.max(1,this.cols||12),i=new Map;for(let h of this.#t)h&&h.r!=null&&h.c!=null&&i.set(`${h.r},${h.c}`,h);let r=this.#r(),n=this.querySelector(':scope > [slot="title"]');if(this.replaceChildren(),n&&this.appendChild(n),this.type==="day-grid"&&this.startDate){let h=document.createElement("div");h.setAttribute("data-months","");let c=new Date(this.startDate);if(!Number.isNaN(c.getTime())){let u=[];for(let d=0;d<e;d++){let f=new Date(c);f.setDate(f.getDate()+d*7),(d===0||f.getDate()<=7)&&u.push({col:d,label:AN[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-heatmap-grid",""),l.style.gridTemplateColumns=`repeat(${e}, ${a})`,l.style.gridTemplateRows=`repeat(${t}, ${o?"var(--heatmap-cell-min-size, 0.75rem)":"1fr"})`;for(let h=0;h<t;h++)for(let c=0;c<e;c++){let u=i.get(`${h},${c}`),d=document.createElement("div");if(d.setAttribute("data-cell",""),d.setAttribute("role","gridcell"),d.dataset.r=String(h),d.dataset.c=String(c),u!=null){let f=Number(u.v)||0,p=r(f);d.dataset.bucket=String(p),d.dataset.v=String(f),u.label&&d.setAttribute("aria-label",u.label)}else d.dataset.empty="";l.appendChild(d)}if(this.appendChild(l),!this.noLegend){let h=document.createElement("div");h.setAttribute("data-legend","");let c=document.createElement("span");c.setAttribute("data-legend-label",""),c.textContent="Less",h.appendChild(c);for(let d=0;d<5;d++){let f=document.createElement("span");f.setAttribute("data-legend-swatch",""),f.dataset.bucket=String(d),h.appendChild(f)}let u=document.createElement("span");u.setAttribute("data-legend-label",""),u.textContent="More",h.appendChild(u),this.appendChild(h)}}#n(t){return t?.closest?.("[data-cell]")}#a(t,e){let i=Number(t.dataset.r),r=Number(t.dataset.c),n=Number(t.dataset.v),o=t.getAttribute("aria-label")||"";return{r:i,c:r,label:o,value:Number.isFinite(n)?n:null,pct:null,series:null,slot:0,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#o=null;#l=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v)return;this.#o=e;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))};#c=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v){this.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})));return}if(e!==this.#o){this.#o=e;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}else{let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}};#h=()=>{this.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})))};#d=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v)return;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-click",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-select",{detail:i,bubbles:!0}))}};M();w("heatmap-ui",Qa);R();var gC=new Set(["idle","active","done","error"]);function oy(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function kN(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var Ta=class extends k{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.#w(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#y()}))}),this.#l.observe(this)))}#h=t=>{let e=t.target.closest("timeline-item-ui[data-step-id]");!e||!this.#a?.contains(e)||this.dispatchEvent(new CustomEvent("reasoning-step-toggle",{bubbles:!0,detail:{stepId:e.dataset.stepId}}))};disconnected(){this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.#r!=null&&(clearTimeout(this.#r),this.#r=null),this.#c&&(cancelAnimationFrame(this.#c),this.#c=0),this.#l?.disconnect(),this.#l=null,this.#n?.removeEventListener("click",this.#f),this.#n?.removeEventListener("keydown",this.#p),this.#a?.removeEventListener("timeline-toggle",this.#h),this.#n=null,this.#a=null,this.#o=!1}addStep(t){let e={kind:"step",status:"active",duration:null,outcomes:[],children:[],...t};return this.#d(e),this.#v(),e}updateStep(t,e){let i=this.#u(t);i&&(Object.assign(i,e),this.#v())}completeStep(t,e){let i=this.#u(t);i&&(i.status="done",e!=null&&(i.duration=e),this.#v())}failStep(t,e){let i=this.#u(t);i&&(i.status="error",e&&(i.outcomes=[...i.outcomes||[],String(e)]),this.#v())}addThought(t,e=`thought-${this.#t.length}`){this.#d({kind:"thought",id:e,text:t}),this.#v()}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.#v()}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.#v(),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.#v()}finish(t,{status:e="done"}={}){let i=gC.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.#v(),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.#v()},1200))}fail(t){this.finish(t,{status:"error"})}#d(t){if(this.#e.length>0){let e=this.#e[this.#e.length-1],i=this.#t.find(r=>r.kind==="iteration"&&r.id===e);if(i){t.kind==="step"?i.steps.push(t):this.#t.push(t);return}}this.#t.push(t)}#u(t){for(let e of this.#t){if(e.kind==="step"&&e.id===t)return e;if(e.kind==="iteration"){for(let i of e.steps||[])if(i.id===t)return i}}return null}#f=()=>{this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("reasoning-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.#v()};#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.#v()}#g(){for(let e=this.#t.length-1;e>=0;e--){let i=this.#t[e];if(i.kind==="step"&&i.status==="active")return i.label;if(i.kind==="iteration")for(let r=(i.steps||[]).length-1;r>=0;r--){let n=i.steps[r];if(n.status==="active")return n.label}if(i.kind==="thought")return i.text}return this.#t.findLast?.(e=>e.kind==="step")?.label||this.heading||"Thinking\u2026"}#b(t){switch(t){case"done":return'<icon-ui name="check-circle" color="success" data-reasoning-check></icon-ui>';case"error":return'<icon-ui name="warning-circle" color="danger" data-reasoning-check data-error></icon-ui>';case"idle":return'<icon-ui name="circle" color="muted" data-reasoning-check data-idle></icon-ui>';default:return"<span data-reasoning-spinner></span>"}}#O(){let t=0,e=0,i=r=>{t++,r.status==="done"&&e++};for(let r of this.#t)if(r.kind==="step"&&i(r),r.kind==="iteration")for(let n of r.steps||[])i(n);return{total:t,done:e}}#v(){if(!this.#n)return;let t=gC.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:r}=this.#O(),n=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#g();if(this.#n.innerHTML=`
|
|
350
|
+
`).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,"&").replace(/</g,"<").replace(/>/g,">")}};M();w("description-list-ui",Pa);R();var AN=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Qa=class extends k{static properties={type:{type:String,default:"matrix",reflect:!0},rows:{type:Number,default:7,reflect:!0},cols:{type:Number,default:12,reflect:!0},scale:{type:String,default:"linear",reflect:!0},noLegend:{type:Boolean,default:!1,reflect:!0,attribute:"no-legend"},colorScheme:{type:String,default:"data-ramp",reflect:!0,attribute:"color-scheme"},startDate:{type:String,default:"",reflect:!0,attribute:"start-date"},aspect:{type:String,default:"wide",reflect:!0}};static template=()=>null;#t=[];#e=!1;set data(t){if(typeof t=="string")try{t=JSON.parse(t)}catch{t=[]}this.#t=Array.isArray(t)?t:[],this.#s()}get data(){return this.#t}connected(){this.setAttribute("role","img");let t=this.getAttribute("data");if(t&&!this.#t.length)try{this.#t=JSON.parse(t)}catch{}this.#e||(this.#e=!0,this.addEventListener("pointerover",this.#l),this.addEventListener("pointermove",this.#c),this.addEventListener("pointerleave",this.#h),this.addEventListener("click",this.#d))}disconnected(){this.removeEventListener("pointerover",this.#l),this.removeEventListener("pointermove",this.#c),this.removeEventListener("pointerleave",this.#h),this.removeEventListener("click",this.#d),this.#e=!1,this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null)}#i=null;#s(){!this.isConnected||this.#i||(this.#i=requestAnimationFrame(()=>{this.#i=null,this.render()}))}#r(){let t=this.#t.map(n=>Number(n.v)||0);if(!t.length)return n=>0;let e=Math.min(...t),i=Math.max(...t);if(e===i)return n=>4;let r=this.scale;if(r==="log"){let n=Math.log(Math.max(1,e)),o=Math.log(Math.max(1,i));return a=>{let h=(Math.log(Math.max(1,Number(a)||0))-n)/(o-n);return Math.min(4,Math.max(0,Math.round(h*4)))}}if(r==="quantile"){let n=[...t].sort((l,h)=>l-h),o=l=>n[Math.floor(l*(n.length-1))],a=[o(.2),o(.4),o(.6),o(.8)];return l=>{let h=Number(l)||0;return h<=a[0]?0:h<=a[1]?1:h<=a[2]?2:h<=a[3]?3:4}}return n=>{let a=((Number(n)||0)-e)/(i-e);return Math.min(4,Math.max(0,Math.round(a*4)))}}render(){let t=Math.max(1,this.rows||7),e=Math.max(1,this.cols||12),i=new Map;for(let h of this.#t)h&&h.r!=null&&h.c!=null&&i.set(`${h.r},${h.c}`,h);let r=this.#r(),n=this.querySelector(':scope > [slot="title"]');if(this.replaceChildren(),n&&this.appendChild(n),this.type==="day-grid"&&this.startDate){let h=document.createElement("div");h.setAttribute("data-months","");let c=new Date(this.startDate);if(!Number.isNaN(c.getTime())){let u=[];for(let d=0;d<e;d++){let f=new Date(c);f.setDate(f.getDate()+d*7),(d===0||f.getDate()<=7)&&u.push({col:d,label:AN[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-heatmap-grid",""),l.style.gridTemplateColumns=`repeat(${e}, ${a})`,l.style.gridTemplateRows=`repeat(${t}, ${o?"var(--heatmap-cell-min-size, 0.75rem)":"1fr"})`;for(let h=0;h<t;h++)for(let c=0;c<e;c++){let u=i.get(`${h},${c}`),d=document.createElement("div");if(d.setAttribute("data-cell",""),d.setAttribute("role","gridcell"),d.dataset.r=String(h),d.dataset.c=String(c),u!=null){let f=Number(u.v)||0,p=r(f);d.dataset.bucket=String(p),d.dataset.v=String(f),u.label&&d.setAttribute("aria-label",u.label)}else d.dataset.empty="";l.appendChild(d)}if(this.appendChild(l),!this.noLegend){let h=document.createElement("div");h.setAttribute("data-legend","");let c=document.createElement("span");c.setAttribute("data-legend-label",""),c.textContent="Less",h.appendChild(c);for(let d=0;d<5;d++){let f=document.createElement("span");f.setAttribute("data-legend-swatch",""),f.dataset.bucket=String(d),h.appendChild(f)}let u=document.createElement("span");u.setAttribute("data-legend-label",""),u.textContent="More",h.appendChild(u),this.appendChild(h)}}#n(t){return t?.closest?.("[data-cell]")}#a(t,e){let i=Number(t.dataset.r),r=Number(t.dataset.c),n=Number(t.dataset.v),o=t.getAttribute("aria-label")||"";return{r:i,c:r,label:o,value:Number.isFinite(n)?n:null,pct:null,series:null,slot:0,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#o=null;#l=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v)return;this.#o=e;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))};#c=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v){this.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})));return}if(e!==this.#o){this.#o=e;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}else{let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}};#h=()=>{this.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})))};#d=t=>{let e=this.#n(t.target);if(!e||!e.dataset.v)return;let i=this.#a(e,t);this.dispatchEvent(new CustomEvent("cell-click",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-select",{detail:i,bubbles:!0}))}};M();w("heatmap-ui",Qa);R();var gC=new Set(["idle","active","done","error"]);function oy(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function kN(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var Ta=class extends k{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.#w(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#v()}))}),this.#l.observe(this)))}#h=t=>{let e=t.target.closest("timeline-item-ui[data-step-id]");!e||!this.#a?.contains(e)||this.dispatchEvent(new CustomEvent("reasoning-step-toggle",{bubbles:!0,detail:{stepId:e.dataset.stepId}}))};disconnected(){this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.#r!=null&&(clearTimeout(this.#r),this.#r=null),this.#c&&(cancelAnimationFrame(this.#c),this.#c=0),this.#l?.disconnect(),this.#l=null,this.#n?.removeEventListener("click",this.#f),this.#n?.removeEventListener("keydown",this.#p),this.#a?.removeEventListener("timeline-toggle",this.#h),this.#n=null,this.#a=null,this.#o=!1}addStep(t){let e={kind:"step",status:"active",duration:null,outcomes:[],children:[],...t};return this.#d(e),this.#y(),e}updateStep(t,e){let i=this.#u(t);i&&(Object.assign(i,e),this.#y())}completeStep(t,e){let i=this.#u(t);i&&(i.status="done",e!=null&&(i.duration=e),this.#y())}failStep(t,e){let i=this.#u(t);i&&(i.status="error",e&&(i.outcomes=[...i.outcomes||[],String(e)]),this.#y())}addThought(t,e=`thought-${this.#t.length}`){this.#d({kind:"thought",id:e,text:t}),this.#y()}setPlan(t,e="plan"){let i=this.#t.find(r=>r.kind==="plan"&&r.id===e);i?i.items=t.slice():this.#t.push({kind:"plan",id:e,items:t.slice()}),this.#y()}startIteration(t,e=`Attempt ${t}`,i=`iter-${t}`){let r={kind:"iteration",id:i,n:t,label:e,status:"active",summary:"",steps:[]};return this.#t.push(r),this.#e.push(i),this.#y(),r}endIteration(t,{status:e="done",summary:i=""}={}){let r=`iter-${t}`,n=this.#t.find(a=>a.kind==="iteration"&&a.id===r);if(!n)return;n.status=e,n.summary=i;let o=this.#e.lastIndexOf(r);o>=0&&this.#e.splice(o,1),this.#y()}finish(t,{status:e="done"}={}){let i=gC.has(e)?e:"done",r=i==="error";for(let n of this.#t)if(n.kind==="step"&&n.status==="active"&&(n.status=r?"error":"done"),n.kind==="iteration"){n.status==="active"&&(n.status=r?"error":"done");for(let o of n.steps||[])o.status==="active"&&(o.status=r?"error":"done")}this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.status=i,t&&(this.dataset.summary=t),this.#y(),this.dispatchEvent(new CustomEvent("reasoning-finish",{bubbles:!0,detail:{summary:t||"",status:i}})),this.#r!=null&&clearTimeout(this.#r),!this.noAutocollapse&&!r&&(this.#r=setTimeout(()=>{this.#r=null,this.collapsed=!0,this.#y()},1200))}fail(t){this.finish(t,{status:"error"})}#d(t){if(this.#e.length>0){let e=this.#e[this.#e.length-1],i=this.#t.find(r=>r.kind==="iteration"&&r.id===e);if(i){t.kind==="step"?i.steps.push(t):this.#t.push(t);return}}this.#t.push(t)}#u(t){for(let e of this.#t){if(e.kind==="step"&&e.id===t)return e;if(e.kind==="iteration"){for(let i of e.steps||[])if(i.id===t)return i}}return null}#f=()=>{this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("reasoning-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.#y()};#p=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#f())};#m(){this.innerHTML="",this.#n=document.createElement("div"),this.#n.setAttribute("data-reasoning-summary",""),this.#n.setAttribute("role","button"),this.#n.setAttribute("tabindex","0"),this.#n.setAttribute("aria-expanded",String(!this.collapsed)),this.#n.addEventListener("click",this.#f),this.#n.addEventListener("keydown",this.#p),this.appendChild(this.#n),this.#a=document.createElement("div"),this.#a.setAttribute("data-reasoning-body",""),this.#a.addEventListener("timeline-toggle",this.#h),this.appendChild(this.#a),this.#y()}#g(){for(let e=this.#t.length-1;e>=0;e--){let i=this.#t[e];if(i.kind==="step"&&i.status==="active")return i.label;if(i.kind==="iteration")for(let r=(i.steps||[]).length-1;r>=0;r--){let n=i.steps[r];if(n.status==="active")return n.label}if(i.kind==="thought")return i.text}return this.#t.findLast?.(e=>e.kind==="step")?.label||this.heading||"Thinking\u2026"}#b(t){switch(t){case"done":return'<icon-ui name="check-circle" color="success" data-reasoning-check></icon-ui>';case"error":return'<icon-ui name="warning-circle" color="danger" data-reasoning-check data-error></icon-ui>';case"idle":return'<icon-ui name="circle" color="muted" data-reasoning-check data-idle></icon-ui>';default:return"<span data-reasoning-spinner></span>"}}#O(){let t=0,e=0,i=r=>{t++,r.status==="done"&&e++};for(let r of this.#t)if(r.kind==="step"&&i(r),r.kind==="iteration")for(let n of r.steps||[])i(n);return{total:t,done:e}}#y(){if(!this.#n)return;let t=gC.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:r}=this.#O(),n=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#g();if(this.#n.innerHTML=`
|
|
351
351
|
${this.#b(t)}
|
|
352
352
|
<span data-reasoning-label>${oy(o)}</span>
|
|
353
353
|
<span data-reasoning-meta>
|
|
@@ -355,7 +355,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
355
355
|
<span data-reasoning-time>${n}s</span>
|
|
356
356
|
<icon-ui name="${this.collapsed?"caret-right":"caret-up"}" color="muted" data-reasoning-caret></icon-ui>
|
|
357
357
|
</span>
|
|
358
|
-
`,this.#a.hidden=this.collapsed,this.#n.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#a.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#S(),this.#a.appendChild(a)),a.appendChild(this.#x(l))):(a=null,this.#a.appendChild(this.#A(l)));this.#
|
|
358
|
+
`,this.#a.hidden=this.collapsed,this.#n.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#a.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#S(),this.#a.appendChild(a)),a.appendChild(this.#x(l))):(a=null,this.#a.appendChild(this.#A(l)));this.#v()}#v(){let t=this.#a;if(!t)return;if(this.collapsed){t.removeAttribute("data-spine");return}let e=t.querySelectorAll("timeline-item-ui");if(e.length<2){t.removeAttribute("data-spine");return}let i=t.getBoundingClientRect().top,r=a=>{let l=a.getBoundingClientRect(),h=parseFloat(getComputedStyle(a).fontSize)||14;return l.top-i+.7*h+1},n=r(e[0]),o=Math.max(0,r(e[e.length-1])-n);t.style.setProperty("--reasoning-spine-top",`${Math.round(n)}px`),t.style.setProperty("--reasoning-spine-h",`${Math.round(o)}px`),t.setAttribute("data-spine","")}#S(){let t=document.createElement("timeline-ui");return t.setAttribute("size","sm"),t}#x(t){let e=document.createElement("timeline-item-ui");e.setAttribute("text",t.label||""),t.status==="done"&&e.setAttribute("status","completed"),t.status==="error"&&e.setAttribute("status","error"),t.status==="active"&&(e.setAttribute("status","active"),e.setAttribute("spinner",""));let i=t.durationLabel||(t.duration!=null?kN(t.duration):"");return i&&e.setAttribute("duration",i),t.outcomes?.length&&(e.outcomes=t.outcomes),e.dataset.stepId=t.id||"",e}#A(t){switch(t.kind){case"thought":return this.#E(t);case"plan":return this.#$(t);case"iteration":return this.#k(t);default:return document.createTextNode("")}}#E(t){let e=document.createElement("div");e.setAttribute("data-reasoning-thought","");let i=document.createElement("span");return i.setAttribute("data-reasoning-thought-text",""),i.textContent=t.text||"",e.appendChild(i),e}#$(t){let e=document.createElement("div");e.setAttribute("data-reasoning-plan","");let i=document.createElement("div");i.setAttribute("data-reasoning-plan-label",""),i.textContent="Plan",e.appendChild(i);let r=document.createElement("ol");r.setAttribute("data-reasoning-plan-list","");for(let n of t.items||[]){let o=document.createElement("li");o.textContent=n,r.appendChild(o)}return e.appendChild(r),e}#k(t){let e=document.createElement("div");e.setAttribute("data-reasoning-iteration",""),t.status==="active"&&e.setAttribute("data-active",""),t.status==="done"&&e.setAttribute("data-done",""),t.status==="error"&&e.setAttribute("data-error","");let i=document.createElement("div");i.setAttribute("data-reasoning-iter-header","");let r=t.status==="done"?'<icon-ui name="check-circle" color="success" size="sm"></icon-ui>':t.status==="error"?'<icon-ui name="warning" color="danger" size="sm"></icon-ui>':"<span data-reasoning-spinner data-small></span>";if(i.innerHTML=`
|
|
359
359
|
${r}
|
|
360
360
|
<span data-reasoning-iter-n>#${t.n}</span>
|
|
361
361
|
<span data-reasoning-iter-label>${oy(t.label||"")}</span>
|
|
@@ -406,7 +406,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
406
406
|
`:typeof t=="string"?t:""}#h(t){let e=t.tone||"neutral",i={success:"var(--a-success-strong)",warning:"var(--a-warning-strong)",danger:"var(--a-danger-strong)",info:"var(--a-primary-strong)",neutral:"var(--a-fg-muted)"}[e]||"var(--a-fg-muted)",r=t.dot===!1?"":`<icon-ui name="circle-fill" data-trace-dot style="color:${i}"></icon-ui>`,n=t.label!=null?String(t.label):"",o=t.value!=null?String(t.value):"",a=o?`${o}${n?` ${n}`:""}`:n;return`<span data-trace-pill>${r}<span>${vs(a)}</span></span>`}};function vs(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function bC(s){return String(s).replace(/"/g,""")}w("agent-trace-ui",ph);R();function ay({icon:s,text:t="",title:e=""}){let i=document.createElement("button-ui");return i.setAttribute("icon",s),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),t&&i.setAttribute("text",t),!t&&e&&i.setAttribute("title",e),i}var La=class extends k{static properties={saveLabel:{type:String,default:"",reflect:!0,attribute:"save-label"},saveIcon:{type:String,default:"bookmark-simple",reflect:!0,attribute:"save-icon"},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=!1;#n=!1;connected(){this.#d()}disconnected(){this.#t?.removeEventListener("press",this.#a),this.#e?.removeEventListener("press",this.#o),this.#i?.removeEventListener("press",this.#l),this.#t=this.#e=this.#i=this.#s=null}setStatus(t,{lock:e=""}={}){this.#s&&(this.#s.textContent=t||"",(e==="rate"||e==="all")&&(this.#r=!0,this.#t&&(this.#t.disabled=!0),this.#e&&(this.#e.disabled=!0)),(e==="save"||e==="all")&&(this.#n=!0,this.#i&&(this.#i.disabled=!0)))}reset(){this.#r=!1,this.#n=!1,this.#s&&(this.#s.textContent=""),this.#t&&(this.#t.disabled=!1),this.#e&&(this.#e.disabled=!1),this.#i&&(this.#i.disabled=!1)}#a=()=>{!this.#r&&!this.disabled&&this.#c(5)};#o=()=>{!this.#r&&!this.disabled&&this.#c(2)};#l=()=>{!this.#n&&!this.disabled&&this.#h()};#c(t){this.dispatchEvent(new CustomEvent("feedback-rate",{bubbles:!0,detail:{rating:t}})),this.#s?.textContent||this.setStatus(t>=4?"Thanks!":"Noted",{lock:"rate"})}#h(){this.dispatchEvent(new CustomEvent("feedback-save",{bubbles:!0,detail:{}}))}render(){let t=this.saveLabel,e=this.saveIcon;this.#i&&(t?(this.#i.setAttribute("text",t),this.#i.hidden=!1):this.#i.hidden=!0,e&&this.#i.setAttribute("icon",e))}#d(){this.innerHTML="",this.#t=ay({icon:"thumbs-up",title:"Rate this response positively"}),this.#e=ay({icon:"thumbs-down",title:"Rate this response negatively"}),this.#i=ay({icon:this.saveIcon||"bookmark-simple",text:this.saveLabel||"",title:this.saveLabel?"":"Save this response"}),this.saveLabel||(this.#i.hidden=!0),this.#t.addEventListener("press",this.#a),this.#e.addEventListener("press",this.#o),this.#i.addEventListener("press",this.#l),this.#s=document.createElement("span"),this.#s.setAttribute("data-feedback-status",""),this.append(this.#t,this.#e,this.#i,this.#s)}};M();w("agent-feedback-bar-ui",La);R();function EN(s,t){return typeof s!="string"?"":s.length>t?s.slice(0,t-1)+"\u2026":s}var Ma=class extends k{static properties={variant:{type:String,default:"outline",reflect:!0},size:{type:String,default:"sm",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];get suggestions(){return this.#t}set suggestions(t){this.#t=Array.isArray(t)?t.slice():[],this.#e()}connected(){this.#e()}disconnected(){this.innerHTML=""}#e(){this.innerHTML="";for(let t=0;t<this.#t.length;t++){let e=this.#t[t],i=typeof e=="string"?e:e.label||e.prompt||"",r=typeof e=="string"?e:e.prompt||e.label||"",n=typeof e=="object"?e.icon:null,o=document.createElement("button-ui");o.setAttribute("text",EN(i,42)),o.setAttribute("variant",this.variant),o.setAttribute("size",this.size),n&&o.setAttribute("icon",n),this.disabled&&o.setAttribute("disabled",""),o.addEventListener("press",()=>{this.disabled||this.dispatchEvent(new CustomEvent("suggestion-select",{bubbles:!0,detail:{label:i,prompt:r,index:t}}))}),this.appendChild(o)}}};M();w("agent-suggestions-ui",Ma);R();var Ra=class extends k{static properties={multi:{type:Boolean,default:!1,reflect:!0},question:{type:String,default:"",reflect:!0},helper:{type:String,default:"",reflect:!0},submitLabel:{type:String,default:"Continue",reflect:!0,attribute:"submit-label"}};static template=()=>null;#t=[];#e=new Set;#i=!1;#s=null;#r=null;#n=null;#a=null;get options(){return this.#t}set options(t){this.#t=Array.isArray(t)?t.slice():[],this.#e.clear(),this.#i=!1,this.#l()}connected(){this.#o()}disconnected(){this.#a?.removeEventListener("press",this.#f),this.#n?.removeEventListener("change",this.#c),this.#n?.removeEventListener("click",this.#h,!0),this.#n?.removeEventListener("keydown",this.#d,!0),this.#s=this.#r=this.#n=this.#a=null}render(){this.#s&&(this.#s.textContent=this.question||"",this.#s.hidden=!this.question),this.#r&&(this.#r.textContent=this.helper||"",this.#r.hidden=!this.helper),this.#a&&(this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.hidden=!this.multi)}#o(){this.innerHTML="",this.#s=document.createElement("div"),this.#s.setAttribute("data-questions-q",""),this.question?this.#s.textContent=this.question:this.#s.hidden=!0,this.#r=document.createElement("div"),this.#r.setAttribute("data-questions-helper",""),this.helper?this.#r.textContent=this.helper:this.#r.hidden=!0,this.#n=document.createElement("div"),this.#n.setAttribute("data-questions-options",""),this.#n.addEventListener("change",this.#c),this.#n.addEventListener("click",this.#h,!0),this.#n.addEventListener("keydown",this.#d,!0),this.#a=document.createElement("button-ui"),this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.setAttribute("variant","primary"),this.#a.setAttribute("disabled",""),this.multi||(this.#a.hidden=!0),this.#a.addEventListener("press",this.#f),this.append(this.#s,this.#r,this.#n,this.#a),this.#l()}#l(){if(this.#n){this.#n.innerHTML="";for(let t of this.#t){let e=document.createElement("option-card-ui");e.setAttribute("data-questions-option",""),e.setAttribute("data-questions-option-id",t.id),e.name="questions-option",e.value=t.id,e.heading=t.label||"",e.description=t.description||"",e.icon=t.icon||"",this.#n.appendChild(e),this.multi&&e.setAttribute("role","checkbox"),e.checked=this.#e.has(t.id),e.disabled=this.#i}this.#a&&(this.#a.disabled=this.#i||this.#e.size===0)}}#c=t=>{if(this.multi||this.#i)return;let e=t.detail?.value,i=this.#t.find(r=>r.id===e);i&&(this.#e.clear(),this.#e.add(i.id),this.#i=!0,this.#l(),this.dispatchEvent(new CustomEvent("questions-answer",{bubbles:!0,detail:{selected:[i.id],option:i}})))};#h=t=>{if(!this.multi)return;let e=t.target.closest?.("option-card-ui[data-questions-option]");!e||!this.#n.contains(e)||(t.stopPropagation(),this.#u(e))};#d=t=>{if(!this.multi)return;let e=t.target.closest?.("option-card-ui[data-questions-option]");if(!(!e||!this.#n.contains(e))){if(t.key===" "||t.key==="Enter"){t.preventDefault(),t.stopPropagation(),this.#u(e);return}(t.key==="ArrowDown"||t.key==="ArrowUp"||t.key==="ArrowLeft"||t.key==="ArrowRight")&&t.stopPropagation()}};#u(t){if(this.#i)return;let e=t.dataset.questionsOptionId,i=this.#t.find(r=>r.id===e);i&&(this.#e.has(i.id)?this.#e.delete(i.id):this.#e.add(i.id),this.#l())}#f=()=>{if(this.#i||this.#e.size===0)return;this.#i=!0,this.#l();let t=[...this.#e],e=this.#t.find(i=>i.id===t[0])||null;this.dispatchEvent(new CustomEvent("questions-answer",{bubbles:!0,detail:{selected:t,option:e}}))}};M();w("agent-questions-ui",Ra);R();var OC={neutral:"default",accent:"accent",warning:"warning",danger:"danger"},Ia=class extends k{static properties={title:{type:String,default:"",reflect:!0},kind:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},tone:{type:String,default:"neutral",reflect:!0}};static requiredIcons=["caret-right","caret-down"];static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){this.#l()}disconnected(){this.#t?.removeEventListener("click",this.#a),this.#t?.removeEventListener("keydown",this.#o),this.#t=this.#e=this.#i=null,this.#s=this.#r=this.#n=null}#a=t=>{t.target.closest('[slot="primary"], [slot="secondary"]')||(this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("artifact-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.render())};#o=t=>{if(t.key===" "||t.key==="Enter"){if(t.target.closest('[slot="primary"], [slot="secondary"]'))return;t.preventDefault(),this.#a(t)}};render(){this.#t&&(this.#e&&(this.icon?(this.#e.setAttribute("name",this.icon),this.#e.hidden=!1):this.#e.hidden=!0),this.#i&&(this.#i.textContent=this.title||"",this.#i.hidden=!this.title),this.#s&&(this.#s.setAttribute("text",(this.kind||"").toUpperCase()),this.#s.setAttribute("variant",OC[this.tone]||"default"),this.#s.hidden=!this.kind),this.#r&&this.#r.setAttribute("name",this.collapsed?"caret-right":"caret-down"),this.#n&&(this.#n.hidden=this.collapsed),this.#t&&this.#t.setAttribute("aria-expanded",String(!this.collapsed)))}#l(){let t=[],e=[],i=[],r=a=>a.getAttribute("role")==="presentation"||a.style?.display==="contents",n=a=>{for(let l of a){if(l.nodeType===1){let h=l;if(r(h)){n(h.childNodes);continue}let c=h.getAttribute("slot")||"";if(c==="primary"){t.push(h);continue}if(c==="secondary"){e.push(h);continue}}i.push(l)}};n(Array.from(this.childNodes)),this.innerHTML="",this.#t=document.createElement("div"),this.#t.setAttribute("data-artifact-header",""),this.#t.setAttribute("role","button"),this.#t.setAttribute("tabindex","0"),this.#t.setAttribute("aria-expanded",String(!this.collapsed)),this.#t.addEventListener("click",this.#a),this.#t.addEventListener("keydown",this.#o),this.#e=document.createElement("icon-ui"),this.#e.setAttribute("data-artifact-icon",""),this.#e.setAttribute("color","muted"),this.icon?this.#e.setAttribute("name",this.icon):this.#e.hidden=!0,this.#i=document.createElement("span"),this.#i.setAttribute("data-artifact-title",""),this.title?this.#i.textContent=this.title:this.#i.hidden=!0,this.#s=document.createElement("badge-ui"),this.#s.setAttribute("data-artifact-kind",""),this.#s.setAttribute("size","sm"),this.#s.setAttribute("variant",OC[this.tone]||"default"),this.kind?this.#s.setAttribute("text",this.kind.toUpperCase()):this.#s.hidden=!0;let o=document.createElement("span");o.setAttribute("data-artifact-actions","");for(let a of e)o.appendChild(a);for(let a of t)o.appendChild(a);this.#r=document.createElement("icon-ui"),this.#r.setAttribute("color","muted"),this.#r.setAttribute("data-artifact-caret",""),this.#r.setAttribute("name",this.collapsed?"caret-right":"caret-down"),this.#t.append(this.#e,this.#i,this.#s,o,this.#r),this.#n=document.createElement("div"),this.#n.setAttribute("data-artifact-body","");for(let a of i)this.#n.appendChild(a);this.collapsed&&(this.#n.hidden=!0),this.append(this.#t,this.#n)}};M();w("agent-artifact-ui",Ia);M();R();var CN="rounded borderless",mh=class s extends k{static properties={mode:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("mode")||(this.mode=CN),this.addEventListener("click",this.#e),this.#i()}#t(t){return this.querySelector(`admin-sidebar[slot="${t}"], admin-sidebar[name="${t}"]`)}#e=t=>{let e=t.target.closest("[data-sidebar-toggle]");if(e&&this.contains(e)){let r=e.getAttribute("data-sidebar-toggle"),n=this.#t(r);n&&typeof n.toggle!="function"&&this.#r("admin-sidebar",`slot="${r}"`,"Sidebar toggle"),n?.toggle?.();return}let i=t.target.closest("[data-command-trigger]");if(i&&this.contains(i)){t.stopPropagation();let r=this.querySelector("admin-command");if(!r)return;if(typeof r.show!="function"){this.#r("admin-command","","Command palette");return}r.show()}};#i(){let t=this.querySelector("admin-command"),e=this.querySelector("nav-ui");!t||!e||t.addEventListener("command-select",i=>{let r=e.querySelector(`nav-item-ui[value="${i.detail.value}"]`);r&&e.select(r)})}static#s=new WeakSet;#r(t,e,i){let r=e?this.querySelector(`${t}[${e}], ${t}[${e.replace("slot=","name=")}]`):this.querySelector(t);if(!r||s.#s.has(r))return;s.#s.add(r);let n=t==="admin-sidebar"?"shell/admin-sidebar":"shell/admin-command";console.warn(`[admin-shell] <${t}${e?" "+e:""}> is in the DOM but ${t==="admin-sidebar"?"AdminSidebar":"AdminCommand"} is NOT registered \u2014 ${i} will not work. Import the cluster barrel \`@adia-ai/web-modules/shell\` (which registers all shell elements), OR add \`@adia-ai/web-modules/${n}\` alongside \`@adia-ai/web-modules/shell/admin-shell\` on the per-component path. Closes FB-55 silent-failure trap.`)}};w("admin-shell",mh);var Me=96,Da=160;function ly(s){try{return localStorage.getItem(s)}catch{return null}}function hy(s,t){try{localStorage.setItem(s,t)}catch{}}function Hd(s,{prefix:t,guardZeroWidth:e=!1}){let i="";function r(){let d=s.name||s.getAttribute("slot")||"default";return`${t}-${d}`}function n(d){hy(r(),d)}function o(){let d=ly(r());if(!d)return;s.style.width=d;let f=parseFloat(d);!isNaN(f)&&f>96&&(i=d)}function a(d){s.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:s.name||s.getAttribute("slot")||"default",expanded:d}}))}function l(){if(s.collapsed)return;let d=s.style.width||getComputedStyle(s).width;parseFloat(d)>96&&(i=d);let f=s.minWidth||getComputedStyle(s).minWidth;s.style.width=f,n(f),s.collapsed=!0,a(!1)}function h(){if(!s.collapsed)return;let d=i||"";s.style.width=d,n(d),s.collapsed=!1,a(!0)}function c(){return s.collapsed?h():l(),s.collapsed}function u(){let d=s.getBoundingClientRect().width;d===0&&e||(s.collapsed=d<=96)}return{storageKey:r,persist:n,restoreFromStorage:o,syncCollapsedFromWidth:u,collapse:l,expand:h,toggle:c}}M();R();var gh=class s extends k{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0},name:{type:String,default:"",reflect:!0},minWidth:{type:String,default:"",reflect:!0,attribute:"min-width"}};static template=()=>null;static#t=new WeakSet;#e=[];#i=null;#s=Hd(this,{prefix:"adia-sidebar",guardZeroWidth:!0});connected(){this.#s.restoreFromStorage(),this.resizable&&this.#r(),this.#n(),this.#s.syncCollapsedFromWidth()}disconnected(){for(let t of this.#e)t();this.#e=[],this.#i?.disconnect(),this.#i=null}toggle(){return this.#s.toggle()}collapse(){this.#s.collapse()}expand(){this.#s.expand()}#r(){let t=this.querySelector(":scope > [data-sidebar-resize]");if(!t){s.#t.has(this)||(s.#t.add(this),console.warn("[admin-sidebar] `resizable` is set but no `[data-sidebar-resize]` child was found. Add `<div data-sidebar-resize></div>` as a direct child to enable drag-to-resize. (Unlike `collapsible`, `resizable` requires this author-supplied handle.)",this));return}let e=this.getAttribute("slot"),i=e==="leading",r=n=>{n.preventDefault(),t.setPointerCapture(n.pointerId);let o=n.clientX,a=this.getBoundingClientRect().width;this.resizing=!0,document.documentElement.style.cursor="col-resize";let l=c=>{let u=c.clientX-o,d=parseInt(getComputedStyle(this).getPropertyValue("max-width"))||480,f=Math.max(48,Math.min(d,a+(i?u:-u)));this.style.width=`${f}px`},h=()=>{this.resizing=!1,document.documentElement.style.cursor="",t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",h);let c=this.getBoundingClientRect().width;c<=96?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<160&&(this.style.width=`${160}px`),this.#s.persist(this.style.width),this.#s.syncCollapsedFromWidth(),this.dispatchEvent(new CustomEvent("sidebar-resize",{bubbles:!0,detail:{name:this.name||e,width:this.getBoundingClientRect().width}}))};t.addEventListener("pointermove",l),t.addEventListener("pointerup",h)};t.addEventListener("pointerdown",r),this.#e.push(()=>t.removeEventListener("pointerdown",r))}#n(){typeof ResizeObserver>"u"||(this.#i=new ResizeObserver(t=>{for(let e of t){let i=e.contentBoxSize[0].inlineSize;i>0&&(this.collapsed=i<=96);for(let r of this.querySelectorAll("select-ui"))r.setAttribute("placement",i<=96?"right":"bottom-start")}}),this.#i.observe(this))}};w("admin-sidebar",gh);M();R();var bh=class extends k{static properties={open:{type:Boolean,default:!1,reflect:!0},shortcut:{type:String,default:"both",reflect:!0},noShortcut:{type:Boolean,default:!1,reflect:!0,attribute:"no-shortcut"}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.#i=this.querySelector(":scope > dialog"),!this.#i){for(this.#i=document.createElement("dialog");this.firstChild;)this.#i.appendChild(this.firstChild);this.appendChild(this.#i)}this.#e=this.querySelector("command-ui"),this.#s(),this.#r(),this.noShortcut||this.#n()}disconnected(){this.#t&&(document.removeEventListener("keydown",this.#t),this.#t=null)}show(){this.#i&&(this.#i.open||(this.#i.showModal(),this.#e&&(this.#e.open=!0,this.#e.value="",this.#e.focus()),this.open=!0))}hide(){this.#i&&this.#i.open&&(this.#i.close(),this.#e&&(this.#e.open=!1),this.open=!1)}toggle(){return this.open?this.hide():this.show(),this.open}#s(){this.#i&&(this.#i.addEventListener("click",t=>{t.target===this.#i&&this.hide()}),this.#i.addEventListener("close",()=>{this.#e&&(this.#e.open=!1),this.open=!1}))}#r(){this.#e&&(this.#e.addEventListener("dismiss",()=>this.hide()),this.#e.addEventListener("select",t=>{this.dispatchEvent(new CustomEvent("command-select",{bubbles:!0,detail:t.detail})),this.hide()}))}#n(){let t=e=>{let i=e.metaKey,r=e.ctrlKey;return e.key!=="k"?!1:this.shortcut==="cmd+k"?i:this.shortcut==="ctrl+k"?r:i||r};this.#t=e=>{t(e)&&(e.preventDefault(),this.toggle())},document.addEventListener("keydown",this.#t)}};w("admin-command",bh);M();R();var Oh=class extends k{static template=()=>null;connected(){this.addEventListener("click",this.#t),this.addEventListener("embed:open",this.#e),this.addEventListener("keydown",this.#i)}#t=t=>{let e=t.target.closest?.("[opens]");if(e&&this.contains(e)){this.toggle(e.getAttribute("opens"));return}let i=t.target.closest?.("[close]");i&&this.contains(i)&&this.close()};#e=t=>this.toggle(t.detail?.panel);#i=t=>{t.key==="Escape"&&this.panel&&(t.stopPropagation(),this.close())};get panel(){return this.getAttribute("panel")||""}toggle(t){return this.panel===t?this.close():this.open(t)}open(t){if(!t)return;let e=this.querySelector(`:scope > [panel="${CSS.escape(t)}"]`);if(e){for(let i of this.querySelectorAll(":scope > [panel][active]"))i!==e&&i.removeAttribute("active");e.setAttribute("active",""),this.setAttribute("panel",t),requestAnimationFrame(()=>e.querySelector("[autofocus], [close], button-ui, [tabindex]")?.focus?.({preventScroll:!0})),this.#s(t)}}close(){this.panel&&(this.querySelector(":scope > [panel][active]")?.removeAttribute("active"),this.removeAttribute("panel"),this.#s(""))}#s(t){this.dispatchEvent(new CustomEvent("embed:change",{detail:{panel:t},bubbles:!0}))}};w("embed-shell",Oh);M();R();function cy(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var $N=0,yh=class extends k{static properties={streaming:{type:Boolean,default:!1,reflect:!0},provider:{type:String,default:"",reflect:!0},model:{type:String,default:"",reflect:!0},system:{type:String,default:"",reflect:!0},proxyUrl:{type:String,default:"",attribute:"proxy-url",reflect:!0},thinking:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;#i=null;#s=null;#r=null;#n=null;#a="";get messages(){return[...this.#t]}get conversation(){return this.#t.filter(t=>t.role==="user"||t.role==="assistant").map(t=>t.html?{role:t.role,content:t.content,html:!0}:{role:t.role,content:t.content})}set conversation(t){this.clear();for(let e of t)this.appendMessage({role:e.role,content:e.content,render:!e.html,html:!!e.html})}set apiKey(t){this.#a=t}connected(){this.#i=this.querySelector("chat-thread"),this.#s=this.querySelector("chat-composer"),this.#r=this.querySelector("chat-empty"),this.#n=this.querySelector("chat-status"),this.#s?.addEventListener("composer-submit",this.#l)}disconnected(){this.#s?.removeEventListener("composer-submit",this.#l),this.abort()}#o(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}#l=t=>{if(this.streaming)return;let{text:e,model:i}=t.detail||{};e&&(this.#s.clear(),this.#o("submit",{text:e,model:i}),(this.proxyUrl||this.#a)&&this.send(e,i?{model:i}:{}))};appendMessage({role:t,content:e="",render:i=!1,html:r=!1}){let n=`msg_${++$N}`;this.#t.push({id:n,role:t,content:e,html:r});let o=document.createElement("div");if(o.setAttribute("data-role",t),o.setAttribute("data-id",n),t==="user")o.innerHTML=`<div data-bubble>${cy(e)}</div>`;else if(t==="assistant"){let a=i||r,l=r?e:i&&e?xi(e):cy(e);o.innerHTML=`
|
|
407
407
|
<span data-avatar>AI</span>
|
|
408
408
|
<div data-bubble><div data-content>${l}</div>${a?"":"<span data-cursor></span>"}</div>
|
|
409
|
-
`}else t==="error"&&(o.innerHTML=`<icon-ui name="warning"></icon-ui><span>${cy(e)}</span>`);return this.#i?.appendChild(o),this.#c(),this.#o("message",{id:n,role:t,content:e}),o}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role!=="assistant")return;e.content+=t;let i=this.#i?.querySelector("[data-role]:last-child [data-content]");i&&i.insertAdjacentText("beforeend",t),this.#c()}setStreamedText(t){let e=this.#t[this.#t.length-1];if(!e||e.role!=="assistant")return;e.content=t;let i=this.#i?.querySelector("[data-role]:last-child [data-content]");i&&(i.textContent=t),this.#c()}deleteMessage(t){let e=this.#t.findIndex(i=>i.id===t);e!==-1&&(this.#t.splice(e,1),this.#i?.querySelector(`[data-id="${t}"]`)?.remove())}clear(){if(this.#t.length=0,this.#i){let t=this.#r;this.#i.innerHTML="",t&&this.#i.appendChild(t)}this.#o("clear")}startStreaming(){this.streaming=!0,this.#s&&(this.#s.disabled=!0),this.#n&&(this.#n.textContent="Typing..."),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!0)}stopStreaming(){this.streaming=!1,this.#s&&(this.#s.disabled=!1),this.#n&&(this.#n.textContent=""),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!1),this.#i?.querySelector("[data-role]:last-child [data-cursor]")?.remove();let t=this.#t[this.#t.length-1];if(t?.role==="assistant"&&t.content&&!t.html){let e=this.#i?.querySelector("[data-role]:last-child [data-content]");e&&(e.innerHTML=xi(t.content),this.#h(e))}this.#s?.focus()}abort(){this.#e&&(this.#e.abort(),this.#e=null,this.#o("abort")),this.streaming&&this.stopStreaming()}async send(t,e={}){let i=e.model||this.model||this.#s?.model;if(!i)throw new Error("No model specified");this.appendMessage({role:"user",content:t}),this.appendMessage({role:"assistant",content:""}),this.startStreaming(),this.#e=new AbortController;try{let r={provider:this.provider||void 0,apiKey:this.#a||void 0,model:i,system:this.system||void 0,proxyUrl:this.proxyUrl||void 0,thinking:this.thinking||void 0,messages:this.conversation.slice(0,-1),signal:this.#e.signal,...e},n;for(let o of["../../../llm/index.js","../../llm/index.js"])try{({streamChat:n}=await import(new URL(o,import.meta.url).href));break}catch{}if(!n){this.appendMessage({role:"error",content:"@adia-ai/llm is not available \u2014 in a fresh checkout run the packages/llm/core build (see gh#527/gh#541)."}),this.#o("error",{error:new Error("llm build artifact missing")});return}for await(let o of n(r))o.type==="text"?(this.appendChunk(o.text),this.#o("chunk",{text:o.text,snapshot:o.snapshot})):o.type==="thinking"?this.#o("thinking",{text:o.text}):o.type==="done"?this.#o("done",{text:o.text,usage:o.usage,stopReason:o.stopReason}):o.type==="error"&&(this.appendMessage({role:"error",content:o.error.message}),this.#o("error",{error:o.error}))}catch(r){r.name!=="AbortError"&&(this.appendMessage({role:"error",content:r.message}),this.#o("error",{error:r}))}this.#e=null,this.stopStreaming()}export(){return{messages:this.#t.map(t=>({role:t.role,content:t.content})),model:this.model,system:this.system}}import(t){t.model&&(this.model=t.model),t.system&&(this.system=t.system),t.messages&&(this.conversation=t.messages)}#c(){let t=this.#i;t&&requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}#h(t){for(let e of t.querySelectorAll("pre")){let i=e.querySelector("code");if(!i)continue;let r=i.getAttribute("data-lang")||"",n=document.createElement("code-ui");r&&n.setAttribute("language",r),n.textContent=i.textContent,e.replaceWith(n)}}};w("chat-shell",yh);M();R();var PN=40,vh=class extends k{static properties={streaming:{type:Boolean,default:!1,reflect:!0},empty:{type:Boolean,default:!0,reflect:!0}};static template=()=>null;#t=null;#e=!0;#i=null;connected(){this.#s(),this.#r(),this.#n()}disconnected(){this.#t?.disconnect(),this.#t=null,this.#i&&(this.removeEventListener("scroll",this.#i),this.#i=null)}scrollToBottom(){this.scrollTo({top:this.scrollHeight,behavior:"smooth"})}scrollToBottomInstant(){this.scrollTop=this.scrollHeight}#s(){let e=Array.from(this.children).filter(i=>i.tagName.toLowerCase()!=="chat-empty").length===0;this.empty=e,this.toggleAttribute("empty",e)}#r(){typeof MutationObserver>"u"||(this.#t=new MutationObserver(()=>{this.#s(),this.#e&&this.scrollToBottomInstant()}),this.#t.observe(this,{childList:!0}))}#n(){this.#i=()=>{let t=this.scrollHeight-(this.scrollTop+this.clientHeight);this.#e=t<=PN},this.addEventListener("scroll",this.#i,{passive:!0})}};w("chat-thread",vh);M();R();var xh=class extends k{static properties={disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.#t=this.querySelector("chat-input-ui")||this.querySelector("input-ui")||this.querySelector("textarea-ui"),this.#e=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("composer-submit",{bubbles:!0,detail:t.detail||{}}))},this.#t?.addEventListener("submit",this.#e),this.#i()}disconnected(){this.#t&&this.#e&&this.#t.removeEventListener("submit",this.#e),this.#t=null,this.#e=null}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),t==="disabled"&&this.#i()}focus(){this.#t?.focus?.()}clear(){this.#t?.clear?.()}get input(){return this.#t}#i(){this.#t&&(this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"))}};w("chat-composer",xh);M();R();var Sh=class extends k{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0},name:{type:String,default:"",reflect:!0},minWidth:{type:String,default:"",reflect:!0,attribute:"min-width"}};static template=()=>null;#t=[];#e=null;#i=Hd(this,{prefix:"adia-chat-sidebar"});connected(){this.#i.restoreFromStorage(),this.resizable&&this.#s(),this.#r(),this.#i.syncCollapsedFromWidth()}disconnected(){for(let t of this.#t)t();this.#t=[],this.#e?.disconnect(),this.#e=null}toggle(){return this.#i.toggle()}collapse(){this.#i.collapse()}expand(){this.#i.expand()}#s(){let t=this.querySelector(":scope > [data-sidebar-resize]");if(!t)return;let e=this.getAttribute("slot"),i=e==="leading",r=n=>{n.preventDefault(),t.setPointerCapture(n.pointerId);let o=n.clientX,a=this.getBoundingClientRect().width;this.resizing=!0,document.documentElement.style.cursor="col-resize";let l=c=>{let u=c.clientX-o,d=parseInt(getComputedStyle(this).getPropertyValue("max-width"))||480,f=Math.max(48,Math.min(d,a+(i?u:-u)));this.style.width=`${f}px`},h=()=>{this.resizing=!1,document.documentElement.style.cursor="",t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",h);let c=this.getBoundingClientRect().width;c<=96?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<160&&(this.style.width=`${160}px`),this.#i.persist(this.style.width),this.#i.syncCollapsedFromWidth(),this.dispatchEvent(new CustomEvent("sidebar-resize",{bubbles:!0,detail:{name:this.name||e,width:this.getBoundingClientRect().width}}))};t.addEventListener("pointermove",l),t.addEventListener("pointerup",h)};t.addEventListener("pointerdown",r),this.#t.push(()=>t.removeEventListener("pointerdown",r))}#r(){typeof ResizeObserver>"u"||(this.#e=new ResizeObserver(t=>{for(let e of t){let i=e.contentBoxSize[0].inlineSize<=96;for(let r of this.querySelectorAll("select-ui"))r.setAttribute("placement",i?"right":"bottom-start")}}),this.#e.observe(this))}};w("chat-sidebar",Sh);M();R();var wh=class extends k{static properties={};static template=()=>null};w("chat-empty",wh);var QN="Closed.",TN="v1.0";function dy({renderer:s,doc:t=document}){if(!s)throw new Error("createSurfaceRegistry: opts.renderer is required");let e=new Map;function i(h,c){let u=e.get(h);if(u)return u;if(!c)throw new Error(`createSurfaceRegistry.route: no bubble element for fresh surfaceId "${h}"`);let d=t.createElement("div");d.setAttribute("data-surface-root",h),c.appendChild(d);let f=s.attachSurface(h,d),p={surfaceId:h,root:d,handle:f,bubbleEl:c,status:"open"};return e.set(h,p),p}function r(h){let c=t.createElement("div");c.setAttribute("data-surface-closed",h.surfaceId),c.textContent=QN,h.bubbleEl.appendChild(c)}function n(h){let c=e.get(h);if(c)return c.status==="closed"||(s.handleFrame(JSON.stringify({version:TN,deleteSurface:{surfaceId:h}})),c.status="closed",r(c)),c}function o(h,c,u){let d=null;try{d=JSON.parse(c)}catch{}if(d&&Object.hasOwn(d,"deleteSurface")){s.handleFrame(c);let f=e.get(h);return f&&f.status!=="closed"&&(f.status="closed",r(f)),f}return s.handleFrame(c),s.surfaces.has(h)?i(h,u):e.get(h)}function a(h){return e.get(h)}function l(){for(let h of e.values())h.handle.detach();e.clear()}return{route:i,close:n,feed:o,get:a,disposeAll:l,hosts:e}}var uy={sent:"Sending\u2026",started:"Thinking\u2026",reasoning:"Reasoning\u2026",content:"Writing\u2026",validating:"Validating\u2026",retry:"Retrying\u2026",tool:"Using a tool\u2026",done:"Done"};function LN(s){let t=s.surfaces.length,e=s.surfaces.map(i=>`${i.surfaceId} \u2014 ${i.rationale}`).join("; ");return`Planning ${t} surface${t===1?"":"s"}: ${e}`}var MN={new:"New",updated:"Updated",closed:"Closed"};function RN(s){let t=["new","updated","closed"].filter(e=>s[e].length>0).map(e=>`${MN[e]}: ${s[e].join(", ")}`);return t.length?`What changed \u2014 ${t.join(" \xB7 ")}`:"What changed \u2014 nothing this turn"}async function fy(s,t,e){let{events:i,statusEl:r=null,isProgressStage:n=c=>Object.hasOwn(uy,c)}=e??{};if(!i)throw new Error("wireAgentEvents: opts.events (AsyncIterable<AgentEvent>) is required");let o=()=>s.querySelector?.("chat-thread")?.querySelector('[data-role="assistant"]:last-child [data-bubble]')??null,a=null,l=()=>{if(a)return a;let c=o();return c?(a=document.createElement("agent-reasoning-ui"),a.collapsed=!0,c.insertBefore(a,c.firstChild),a):null},h=c=>a?.entries?.find(u=>u.kind==="step"&&u.id===c);for await(let c of i)switch(c.type){case"text":c.text===""?s.setStreamedText?.(c.snapshot??""):s.appendChunk?.(c.text);break;case"progress":{if(!n(c.stage))break;r&&(r.textContent=uy[c.stage]??"");break}case"surface":{let u=o();t.feed(c.surfaceId,c.line,u);break}case"step":{if(c.workflow==="plan"&&c.step==="manifest")s.appendMessage?.({role:"assistant",content:LN(c.data),render:!0}),s.appendMessage?.({role:"assistant",content:""});else if(c.workflow==="plan"&&c.step==="synthesis")s.appendMessage?.({role:"assistant",content:RN(c.data),render:!0}),s.appendMessage?.({role:"assistant",content:""});else{let u=l();if(u){let d=`${c.workflow}:${c.step}:${c.data?.round??1}`,f=`${c.workflow}: ${c.step}`;u.addStep({id:d,label:f}),c.data?.accepted?u.completeStep(d):u.failStep(d,c.data?.reason??"fell through")}}break}case"tool_use":{let u=l();if(u){let d=`${c.name}(${JSON.stringify(c.input)})`;h(c.id)?u.updateStep(c.id,{label:d}):u.addStep({id:c.id,label:d})}break}case"tool_input_delta":{let u=l();if(u){let d=`${c.name}(${c.partial})`;h(c.id)?u.updateStep(c.id,{label:d}):u.addStep({id:c.id,label:d})}break}case"tool_result":{let u=l();if(u){let d=String(c.output).slice(0,300);c.isError?u.failStep(c.id,d):(u.updateStep(c.id,{outcomes:[d]}),u.completeStep(c.id))}break}case"guardrail":{let u=l(),d=c.action==="deny"?"blocked":"rewrote",f=c.toolName?`tool call "${c.toolName}"`:"the response";u?.addThought?.(`Guardrail "${c.name}" ${d} ${f}${c.reason?` \u2014 ${c.reason}`:""}`);break}case"thinking":{l()?.addThought?.(c.text);break}case"error":a?.fail?.(c.error?.message??String(c.error)),s.appendMessage?.({role:"error",content:c.error?.message??String(c.error)}),s.stopStreaming?.();break;case"done":a&&(c.stopReason==="guardrail_denied"?a.fail("Blocked by guardrail"):a.finish()),s.stopStreaming?.();break;default:break}s.streaming&&s.stopStreaming?.()}M();R();var Ah=class extends k{static properties={focusMode:{type:Boolean,default:!1,reflect:!0,attribute:"focus-mode"}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.#t=this.querySelector("editor-toolbar"),this.#e=this.querySelector("editor-canvas"),this.#s(),this.#i=t=>{let e=t?.detail?.name;e&&(e==="toggle-focus"||e==="full-screen")&&this.toggleFocusMode()},this.addEventListener("toolbar-action",this.#i)}disconnected(){this.#i&&this.removeEventListener("toolbar-action",this.#i),this.#i=null}toggleFocusMode(){this.focusMode=!this.focusMode,this.#t?.tagName?.toLowerCase()==="editor-toolbar"&&(this.#t.fullScreen=this.focusMode),this.#e?.tagName?.toLowerCase()==="editor-canvas"&&(this.focusMode?this.#e.focus?.():this.#e.blur?.()),this.dispatchEvent(new CustomEvent("editor-mode-change",{bubbles:!0,detail:{focusMode:this.focusMode}}))}#s(){for(let t of this.querySelectorAll("select-ui[data-options]"))try{let e=JSON.parse(t.getAttribute("data-options"));t.options=e}catch{}}};w("editor-shell",Ah);M();R();var kh=class extends k{static properties={fullScreen:{type:Boolean,default:!1,reflect:!0,attribute:"full-screen"}};static template=()=>null;#t=null;connected(){this.#t=t=>{let e=t.target.closest("[data-toolbar-action]");if(!e||!this.contains(e))return;let i=e.getAttribute("data-toolbar-action");this.dispatchEvent(new CustomEvent("toolbar-action",{bubbles:!0,detail:{name:i}}))},this.addEventListener("click",this.#t)}disconnected(){this.#t&&this.removeEventListener("click",this.#t),this.#t=null}};w("editor-toolbar",kh);M();R();var Eh=class extends k{static properties={empty:{type:Boolean,default:!0,reflect:!0},focused:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=1;#e=null;connected(){this.#i(),this.#s()}disconnected(){this.#e?.disconnect(),this.#e=null}get zoom(){return this.#t}set zoom(t){let e=parseFloat(t);!isFinite(e)||e<=0||(this.#t=e,this.style.setProperty("--editor-canvas-zoom",String(e)))}resetView(){this.zoom=1}focus(){super.focus?.(),this.focused=!0}blur(){super.blur?.(),this.focused=!1}#i(){let t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()!=="editor-canvas-empty");this.empty=t.length===0}#s(){typeof MutationObserver>"u"||(this.#e=new MutationObserver(()=>{this.#i()}),this.#e.observe(this,{childList:!0}))}};w("editor-canvas",Eh);M();R();var IN="adia-editor-sidebar-",Ch=class extends k{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=!1;#l=null;connected(){if(this.#t=this.querySelector("pane-ui"),!this.#t)return;let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.#i=`${IN}${e}`,this.#m(),typeof ResizeObserver<"u"&&(this.#e=new ResizeObserver(i=>{if(getComputedStyle(this).display==="none")return;this.#d();let r=this.#t.offsetWidth;r>0&&(this.style.width=`${r}px`)}),this.#e.observe(this.#t)),this.#s=i=>{i.target?.closest?.('[slot="resize"], [data-sidebar-resize], [class*="handle"]')&&(this.resizing=!0)},this.#t.addEventListener("pointerdown",this.#s),this.#r=()=>{this.resizing&&(this.resizing=!1),this.#f()},document.addEventListener("pointerup",this.#r),this.#n=i=>{i.target!==this.#t||i.propertyName!=="width"||(this.#h(),this.#d())},this.#t.addEventListener("transitionend",this.#n)}disconnected(){this.#a!==null&&(cancelAnimationFrame(this.#a),this.#a=null),this.#l!==null&&(clearTimeout(this.#l),this.#l=null),this.#e?.disconnect(),this.#e=null,this.#s&&this.#t&&(this.#t.removeEventListener("pointerdown",this.#s),this.#s=null),this.#r&&(document.removeEventListener("pointerup",this.#r),this.#r=null),this.#n&&this.#t&&(this.#t.removeEventListener("transitionend",this.#n),this.#n=null)}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){this.#t&&(this.collapsed||this.#f(),this.#t.style.width=`${96}px`,this.collapsed=!0,this.#u())}expand(){if(!this.#t)return;let t=this.#p(),e=t&&t>96?t:240;this.#t.style.width=`${e}px`,this.collapsed=!1,this.#f(),this.#u(),this.#c()}#c(){this.#l!==null&&(clearTimeout(this.#l),this.#l=null);let t=getComputedStyle(this.#t).transitionDuration.split(",")[0].trim(),e=(parseFloat(t)||0)*(t.endsWith("ms")?1:1e3);e<=0||(this.#o=!0,this.#l=setTimeout(()=>{this.#l=null,this.#h(),this.#d()},e+50))}#h(){this.#o=!1,this.#l!==null&&(clearTimeout(this.#l),this.#l=null)}#d(){if(!this.#t||getComputedStyle(this).display==="none")return;let t=this.#t.getBoundingClientRect();if(t.width!==0){if(t.width>96){this.#a!==null&&(cancelAnimationFrame(this.#a),this.#a=null),this.collapsed=!1;return}this.#o||this.#a===null&&(this.#a=requestAnimationFrame(()=>{if(this.#a=null,!this.#t||getComputedStyle(this).display==="none"||this.#o)return;let e=this.#t.getBoundingClientRect();e.width>0&&e.width<=96&&(this.collapsed=!0)}))}}#u(){let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:e,expanded:!this.collapsed}}))}#f(){if(!this.#t||!this.#i)return;let t=this.#t.style.width||"";t&&hy(this.#i,t)}#p(){if(!this.#i)return null;let t=ly(this.#i);if(!t)return null;let e=parseFloat(t);return isFinite(e)?e:null}#m(){if(!this.#t)return;let t=this.#p();t&&t>0&&(this.#t.style.width=`${t}px`,this.collapsed=t<=96)}};w("editor-sidebar",Ch);function DN(){let s=document.activeElement;if(!s)return!1;let t=s.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||s.isContentEditable||t==="INPUT-UI"||t==="TEXTAREA-UI"||t==="OTP-INPUT-UI"||t==="SEARCH-UI")}R();var $h=class extends k{static properties={centered:{type:Boolean,default:!1,reflect:!0},"full-bleed":{type:Boolean,default:!1,reflect:!0}};static template=()=>null};customElements.get("simple-shell")||customElements.define("simple-shell",$h);M();R();var Gd=class extends k{static properties={mode:{type:String,default:"chat",reflect:!0},inspector:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=null;connected(){}render(){this.#t||(this.#t=!0,this.#e=document.createElement("chat-thread-ui"),this.#i=document.createElement("canvas-ui"),this.appendChild(this.#e),this.appendChild(this.#i),this.inspector&&(this.#s=document.createElement("inspector-ui"),this.appendChild(this.#s)))}appendMessage(t){this.#e?.appendMessage(t)}appendCoT(t){this.#e?.appendCoT(t)}pushArtifact(t){this.mode==="chat"&&(this.mode="split"),this.#i?.processAll(t)}setSuggestions(t){this.#e?.setSuggestions(t)}appendResultMessage(t){this.#e?.appendResultMessage(t)}showSavePatternBar(t){this.#e?.showSavePatternBar(t)}showFeedbackWidget(t){this.#e?.showFeedbackWidget(t)}showTyping(){this.#e?.showTyping()}hideTyping(){this.#e?.hideTyping()}appendError(t){this.#e?.appendError(t)}startPipelineStatus(){return this.#e?.startPipelineStatus()}updatePipelineStatus(t){this.#e?.updatePipelineStatus(t)}completePipelineStatus(){this.#e?.completePipelineStatus()}reset(){this.#e?.clear(),this.#i?.reset(),this.mode="chat"}get thread(){return this.#e}get canvas(){return this.#i}get inspect(){return this.#s}};w("gen-root",Gd);ny();M();R();var NN=["atlas","signal","terrarium","ledger","arcade","meridian","solstice","glacier","ember","botanica","vector","velour"],qN={compact:{density:.85,radius:.75},default:{density:1,radius:1},spacious:{density:1.15,radius:1.25}},py=["","ui-sm","ui-md","ui-lg","content-sm","content-md","content-lg"],yC=s=>s.length?s[0].toUpperCase()+s.slice(1):s,Ph=class extends k{static properties={themes:{type:String,default:NN.join(" "),reflect:!0},parametric:{type:Boolean,default:!1,reflect:!0},presets:{type:Boolean,default:!1,reflect:!0},schemeToggle:{type:Boolean,default:!1,reflect:!0,attribute:"scheme-toggle"},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},target:{type:String,default:":root",reflect:!0},scheme:{type:String,default:"auto",reflect:!0},activeTheme:{type:String,default:"",reflect:!0,attribute:"active-theme"},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"},activeDensity:{type:String,default:"",reflect:!0,attribute:"active-density"},activeRadius:{type:String,default:"",reflect:!0,attribute:"active-radius"},register:{type:Boolean,default:!1,reflect:!0},activeScale:{type:String,default:"",reflect:!0,attribute:"active-scale"}};static template=()=>null;#t=null;#e=null;#i=[];#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=!1;connected(){this.#c||(this.#h(),this.#c=!0,this.#A(),this.#g(),this.#v())}disconnected(){for(let t of this.#i)t();this.#i=[],this.#S(),this.parametric&&this.#x().removeAttribute("data-parametric-scope")}apply(t={}){this.#p(t,"programmatic")}reset(){let t=this.#x();if(t.removeAttribute("theme"),t.style.removeProperty("--a-density"),t.style.removeProperty("--a-radius-k"),t.style.removeProperty("color-scheme"),t.removeAttribute("scale"),this.persist)for(let e of["theme","scheme","density","radius","scale"])try{localStorage.removeItem(`${this.storagePrefix}${e}`)}catch{}this.activeTheme="",this.activeDensity="",this.activeRadius="",this.activeScale="",this.scheme="auto",this.activeScheme=this.#O(),this.#n&&(this.#n.value="auto"),this.#s&&(this.#s.value=1),this.#r&&(this.#r.value=1),this.#a&&(this.#a.value=""),this.#o&&(this.#o.value=""),this.#m("reset")}#h(){let t=document.createDocumentFragment();if(this.schemeToggle){let o=document.createElement("div");o.setAttribute("part","scheme");let a=document.createElement("segmented-ui");a.id=`${this.#C}-scheme`;let l=document.createElement("segment-ui");l.setAttribute("value","auto"),l.setAttribute("text","System");let h=document.createElement("segment-ui");h.setAttribute("value","light"),h.setAttribute("text","Light");let c=document.createElement("segment-ui");c.setAttribute("value","dark"),c.setAttribute("text","Dark"),a.append(l,h,c),o.appendChild(a),t.appendChild(o),this.#n=a}let e=(this.themes||"").trim().split(/\s+/).filter(Boolean);if(e.length){let o=document.createElement("div");o.setAttribute("part","theme-row");let a=document.createElement("text-ui");a.setAttribute("variant","label"),a.textContent="Theme",o.appendChild(a);let l=document.createElement("select-ui");l.setAttribute("part","themes"),l.setAttribute("size","sm"),l.id=`${this.#C}-theme`;let h=(c,u)=>{let d=document.createElement("option");return d.value=c,d.textContent=u,d};l.append(h("","Default"),...e.map(c=>h(c,yC(c)))),l.setAttribute("value",""),o.appendChild(l),t.appendChild(o),this.#o=l}if(this.parametric){t.appendChild(document.createElement("divider-ui"));let o=document.createElement("text-ui");o.setAttribute("variant","label"),o.textContent="Parametric",t.appendChild(o);let a=document.createElement("slider-ui");a.setAttribute("part","density"),a.setAttribute("label","Density"),a.setAttribute("value","1"),a.setAttribute("min","0.5"),a.setAttribute("max","1.5"),a.setAttribute("step","0.05"),a.setAttribute("suffix","\xD7"),t.appendChild(a),this.#s=a;let l=document.createElement("slider-ui");l.setAttribute("part","radius"),l.setAttribute("label","Radius"),l.setAttribute("value","1"),l.setAttribute("min","0"),l.setAttribute("max","2"),l.setAttribute("step","0.1"),l.setAttribute("suffix","\xD7"),t.appendChild(l),this.#r=l}if(this.presets||this.register){if(t.appendChild(document.createElement("divider-ui")),this.presets){let o=document.createElement("div");o.setAttribute("part","preset-row");let a=document.createElement("text-ui");a.setAttribute("variant","label"),a.textContent="Preset",o.appendChild(a);let l=document.createElement("div");l.setAttribute("part","presets");for(let h of["compact","default","spacious"]){let c=document.createElement("button-ui");c.setAttribute("data-preset",h),c.setAttribute("text",yC(h)),c.setAttribute("variant","outline"),c.setAttribute("size","sm"),l.appendChild(c)}o.appendChild(l),t.appendChild(o)}if(this.register){let o=document.createElement("div");o.setAttribute("part","preset-row");let a=document.createElement("text-ui");a.setAttribute("variant","label"),a.textContent="Scale",o.appendChild(a);let l=document.createElement("select-ui");l.setAttribute("part","scale"),l.setAttribute("size","sm"),l.id=`${this.#C}-scale`,l.innerHTML=py.map(h=>`<option value="${h}">${h||"Default"}</option>`).join(""),l.setAttribute("value",""),o.appendChild(l),t.appendChild(o),this.#a=l}}t.appendChild(document.createElement("divider-ui"));let i=document.createElement("div");i.setAttribute("part","reset-row");let r=document.createElement("button-ui");r.setAttribute("part","reset"),r.setAttribute("text","Reset"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),i.appendChild(r),t.appendChild(i),this.#l=r;let n=document.createElement("theme-provider");n.setAttribute("scale","ui-md"),n.appendChild(t),this.appendChild(n),this.#d()}#d(){if(this.#o){let t=e=>{let i=e.detail?.value??this.#o.value;this.#u(i)};this.#o.addEventListener("change",t),this.#i.push(()=>this.#o.removeEventListener("change",t))}if(this.#l){let t=()=>this.reset();this.#l.addEventListener("press",t),this.#l.addEventListener("click",t),this.#i.push(()=>{this.#l.removeEventListener("press",t),this.#l.removeEventListener("click",t)})}if(this.#s){let t=()=>this.#p({density:parseFloat(this.#s.value)},"slider");this.#s.addEventListener("input",t),this.#i.push(()=>this.#s.removeEventListener("input",t))}if(this.#r){let t=()=>this.#p({radius:parseFloat(this.#r.value)},"slider");this.#r.addEventListener("input",t),this.#i.push(()=>this.#r.removeEventListener("input",t))}for(let t of this.querySelectorAll('[part="presets"] button-ui')){let e=t.getAttribute("data-preset"),i=()=>this.#f(e);t.addEventListener("press",i),t.addEventListener("click",i),this.#i.push(()=>{t.removeEventListener("press",i),t.removeEventListener("click",i)})}if(this.#n){let t=e=>{let i=e.detail?.value??this.#n.value;(i==="light"||i==="dark"||i==="auto")&&this.#p({scheme:i},"scheme")};this.#n.addEventListener("change",t),this.#i.push(()=>this.#n.removeEventListener("change",t))}if(this.#a){let t=e=>{let i=e.detail?.value??this.#a.value;this.#p({scale:i},"scale")};this.#a.addEventListener("change",t),this.#i.push(()=>this.#a.removeEventListener("change",t))}}#u(t){let e=this.#x();if(e.style.removeProperty("--a-density"),e.style.removeProperty("--a-radius-k"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}density`),localStorage.removeItem(`${this.storagePrefix}radius`)}catch{}this.#p({theme:t},"theme"),this.#s&&(this.#s.value=1),this.#r&&(this.#r.value=1),this.activeDensity="",this.activeRadius=""}#f(t){let e=qN[t];e&&(this.#p({density:e.density,radius:e.radius},"preset"),this.#s&&(this.#s.value=e.density),this.#r&&(this.#r.value=e.radius))}#p(t,e){let i=this.#x();if(t.theme!==void 0){if(t.theme===""||t.theme==="default"?(i.removeAttribute("theme"),this.activeTheme=""):(i.setAttribute("theme",t.theme),this.activeTheme=t.theme),this.persist)try{this.activeTheme?localStorage.setItem(`${this.storagePrefix}theme`,this.activeTheme):localStorage.removeItem(`${this.storagePrefix}theme`)}catch{}this.#o&&(this.#o.value=this.activeTheme)}if(t.density!==void 0&&(i.style.setProperty("--a-density",t.density),this.activeDensity=String(t.density),this.persist))try{localStorage.setItem(`${this.storagePrefix}density`,String(t.density))}catch{}if(t.radius!==void 0&&(i.style.setProperty("--a-radius-k",t.radius),this.activeRadius=String(t.radius),this.persist))try{localStorage.setItem(`${this.storagePrefix}radius`,String(t.radius))}catch{}if(t.scheme!==void 0){let r=t.scheme;if(r==="auto"){if(i.style.removeProperty("color-scheme"),this.scheme="auto",this.activeScheme=this.#O(),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}this.#y()}else if(r==="light"||r==="dark"){if(i.style.setProperty("color-scheme",r),this.scheme=r,this.activeScheme=r,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,r)}catch{}this.#S()}this.#n&&(this.#n.value=this.scheme)}if(t.scale!==void 0){let r=t.scale;if(r&&py.includes(r)?(i.setAttribute("scale",r),this.activeScale=r):(i.removeAttribute("scale"),this.activeScale=""),this.persist)try{this.activeScale?localStorage.setItem(`${this.storagePrefix}scale`,this.activeScale):localStorage.removeItem(`${this.storagePrefix}scale`)}catch{}this.#a&&(this.#a.value=this.activeScale)}this.#m(e)}#m(t){this.dispatchEvent(new CustomEvent("theme-change",{bubbles:!0,detail:{theme:this.activeTheme,scheme:this.activeScheme,density:this.activeDensity?parseFloat(this.activeDensity):1,radius:this.activeRadius?parseFloat(this.activeRadius):1,scale:this.activeScale,source:t}}))}#g(){let t=this.#x(),e,i,r,n,o;if(this.persist)try{e=localStorage.getItem(`${this.storagePrefix}theme`)||"",i=localStorage.getItem(`${this.storagePrefix}scheme`)||"";let a=localStorage.getItem(`${this.storagePrefix}density`),l=localStorage.getItem(`${this.storagePrefix}radius`);r=a!=null?parseFloat(a):void 0,n=l!=null?parseFloat(l):void 0,o=localStorage.getItem(`${this.storagePrefix}scale`)||""}catch{}if(e?(t.setAttribute("theme",e),this.activeTheme=e):this.activeTheme=t.getAttribute("theme")||"",this.#o&&(this.#o.value=this.activeTheme),i==="light"||i==="dark")t.style.setProperty("color-scheme",i),this.scheme=i,this.activeScheme=i,this.#n&&(this.#n.value=i);else{let a=this.scheme||"auto";a==="light"||a==="dark"?(t.style.setProperty("color-scheme",a),this.activeScheme=a):(this.scheme="auto",this.activeScheme=this.#O()),this.#n&&(this.#n.value=this.scheme)}if(r!=null&&!Number.isNaN(r))t.style.setProperty("--a-density",r),this.activeDensity=String(r),this.#s&&(this.#s.value=r);else if(this.#s){let a=this.#b(t,"--a-density");this.#s.value=a,this.activeDensity=String(a)}if(n!=null&&!Number.isNaN(n))t.style.setProperty("--a-radius-k",n),this.activeRadius=String(n),this.#r&&(this.#r.value=n);else if(this.#r){let a=this.#b(t,"--a-radius-k");this.#r.value=a,this.activeRadius=String(a)}if(this.#a){let a=py.includes(o)?o:t.getAttribute("scale")||"";a&&t.setAttribute("scale",a),this.#a.value=a,this.activeScale=a}}#b(t,e){let i=getComputedStyle(t);return parseFloat(i.getPropertyValue(e))||1}#O(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}#v(){if(this.scheme==="auto"){if(this.persist)try{let t=localStorage.getItem(`${this.storagePrefix}scheme`);if(t==="light"||t==="dark")return}catch{}this.#y()}}#y(){if(!(this.#t||typeof matchMedia!="function"))try{this.#t=matchMedia("(prefers-color-scheme: dark)"),this.#e=()=>{let t=this.#t.matches?"dark":"light";this.activeScheme=t,this.#n&&(this.#n.value="auto"),this.#m("scheme")},this.#t.addEventListener("change",this.#e)}catch{}}#S(){if(this.#t&&this.#e)try{this.#t.removeEventListener("change",this.#e)}catch{}this.#t=null,this.#e=null}#x(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}#A(){let t=this.#x();t!==document.documentElement&&(this.parametric?t.setAttribute("data-parametric-scope",""):t.removeAttribute("data-parametric-scope"))}get#C(){return this.id||"theme-panel"}};w("theme-panel",Ph);R();var vC=["change","input"],Qh=class extends k{static properties={label:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=null;#r=()=>this.#d();#n=()=>{!this.#e||!this.#s||this.#e.setAttribute("aria-expanded",String(this.#s.hasAttribute("open")))};#a=null;#o=null;connected(){this.#t||(this.#l(),this.#t=!0);for(let t of vC)this.addEventListener(t,this.#r);this.#i&&!this.#o&&(this.#o=new MutationObserver(this.#r),this.#o.observe(this.#i,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["checked"]})),this.#s&&!this.#a&&(this.#a=new MutationObserver(this.#n),this.#a.observe(this.#s,{attributes:!0,attributeFilter:["open"]})),this.#d()}disconnected(){for(let t of vC)this.removeEventListener(t,this.#r);this.#o?.disconnect(),this.#o=null,this.#a?.disconnect(),this.#a=null}updated(t){this.#t&&(t.has("label")&&this.#d(),t.has("heading")&&this.#c(),t.has("placement")&&this.querySelector(":scope > popover-ui")?.setAttribute("placement",this.placement))}get summary(){let t=this.#i?this.#i.querySelectorAll("check-ui"):[],e=[];for(let i of t)(i.hasAttribute("checked")||i.checked)&&e.push(i);return{selected:e.length,total:t.length,checked:e}}#l(){let t=document.createDocumentFragment();for(;this.firstChild;)t.appendChild(this.firstChild);let e=document.createElement("popover-ui");e.setAttribute("placement",this.placement),e.setAttribute("match-width",""),this.#s=e;let i=document.createElement("button-ui");i.setAttribute("slot","trigger"),i.setAttribute("data-form-popover-trigger",""),i.setAttribute("icon-trailing","caret-down"),i.setAttribute("aria-haspopup","dialog"),i.setAttribute("aria-expanded","false"),this.#e=i,e.appendChild(i);let r=document.createElement("div");r.setAttribute("slot","content"),r.setAttribute("data-form-popover-body",""),r.appendChild(t),this.#i=r,e.appendChild(r),this.appendChild(e),this.#c()}#c(){if(!this.#i)return;let t=this.#i.querySelector(":scope > [data-form-popover-heading]");if(!this.heading){t?.remove();return}t||(t=document.createElement("div"),t.setAttribute("data-form-popover-heading",""),this.#i.prepend(t)),t.textContent=this.heading}#h(t){return(t.getAttribute("label")||t.label||t.textContent||"").trim()}#d(){if(!this.#e)return;let{selected:t,total:e,checked:i}=this.summary,r=this.label;t===1&&i[0]?r=this.#h(i[0])||r:t>1&&(r=r?`${r} (${t})`:`${t}`),r||(r="Options"),this.#e.setAttribute("text",r),this.dispatchEvent(new CustomEvent("summary-change",{bubbles:!0,detail:{selected:t,total:e}}))}};customElements.get("form-popover-ui")||customElements.define("form-popover-ui",Qh);R();var Th=class extends k{static properties={items:{type:Array,default:[]},"storage-key":{type:String,default:"",reflect:!0},storage:{type:String,default:"local",reflect:!0},"dismiss-on-complete":{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},value:{type:Object,default:{}},title:{type:String,default:"Get started",reflect:!0}};static template=t=>t._renderTemplate();#t=`obc-h-${Math.random().toString(36).slice(2,8)}`;#e=`obc-l-${Math.random().toString(36).slice(2,8)}`;#i=!1;#s=!1;#r=null;#n=null;attributeChangedCallback(t,e,i){if(t==="items"||t==="value"){if(i==null)this[t]=t==="items"?[]:{};else try{let r=JSON.parse(i);this[t]=r}catch{this[t]=t==="items"?[]:{}}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#t),this.hasAttribute("items")&&!Array.isArray(this.items))try{this.items=JSON.parse(this.getAttribute("items"))}catch{this.items=[]}if(this.hasAttribute("value")&&(typeof this.value!="object"||Array.isArray(this.value)))try{this.value=JSON.parse(this.getAttribute("value"))}catch{this.value={}}if(this.#i=this.value&&Object.keys(this.value).length>0,!this.#i){let t=this.#y();t&&(this.value=t)}this.#r=this.#o.bind(this),this.#n=this.#l.bind(this),this.addEventListener("change",this.#r),this.addEventListener("click",this.#n),this.#s=this.#p(),this.#m()}disconnected(){this.#r&&this.removeEventListener("change",this.#r),this.#n&&this.removeEventListener("click",this.#n),this.#r=null,this.#n=null,this.#S()}render(){this.#m(),this.#O(),this.#g()}_renderTemplate(){let t=Array.isArray(this.items)?this.items:[],{done:e,total:i,percent:r}=this.#f(),n=this.collapsed?"Expand":"Collapse",o=this.collapsed?"chevron-down":"chevron-up",a=!!this.collapsible,l=this.title||"Get started",h=i>0&&e===i;return J`
|
|
409
|
+
`}else t==="error"&&(o.innerHTML=`<icon-ui name="warning"></icon-ui><span>${cy(e)}</span>`);return this.#i?.appendChild(o),this.#c(),this.#o("message",{id:n,role:t,content:e}),o}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role!=="assistant")return;e.content+=t;let i=this.#i?.querySelector("[data-role]:last-child [data-content]");i&&i.insertAdjacentText("beforeend",t),this.#c()}setStreamedText(t){let e=this.#t[this.#t.length-1];if(!e||e.role!=="assistant")return;e.content=t;let i=this.#i?.querySelector("[data-role]:last-child [data-content]");i&&(i.textContent=t),this.#c()}deleteMessage(t){let e=this.#t.findIndex(i=>i.id===t);e!==-1&&(this.#t.splice(e,1),this.#i?.querySelector(`[data-id="${t}"]`)?.remove())}clear(){if(this.#t.length=0,this.#i){let t=this.#r;this.#i.innerHTML="",t&&this.#i.appendChild(t)}this.#o("clear")}startStreaming(){this.streaming=!0,this.#s&&(this.#s.disabled=!0),this.#n&&(this.#n.textContent="Typing..."),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!0)}stopStreaming(){this.streaming=!1,this.#s&&(this.#s.disabled=!1),this.#n&&(this.#n.textContent=""),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!1),this.#i?.querySelector("[data-role]:last-child [data-cursor]")?.remove();let t=this.#t[this.#t.length-1];if(t?.role==="assistant"&&t.content&&!t.html){let e=this.#i?.querySelector("[data-role]:last-child [data-content]");e&&(e.innerHTML=xi(t.content),this.#h(e))}this.#s?.focus()}abort(){this.#e&&(this.#e.abort(),this.#e=null,this.#o("abort")),this.streaming&&this.stopStreaming()}async send(t,e={}){let i=e.model||this.model||this.#s?.model;if(!i)throw new Error("No model specified");this.appendMessage({role:"user",content:t}),this.appendMessage({role:"assistant",content:""}),this.startStreaming(),this.#e=new AbortController;try{let r={provider:this.provider||void 0,apiKey:this.#a||void 0,model:i,system:this.system||void 0,proxyUrl:this.proxyUrl||void 0,thinking:this.thinking||void 0,messages:this.conversation.slice(0,-1),signal:this.#e.signal,...e},n;for(let o of["../../../llm/index.js","../../llm/index.js"])try{({streamChat:n}=await import(new URL(o,import.meta.url).href));break}catch{}if(!n){this.appendMessage({role:"error",content:"@adia-ai/llm is not available \u2014 in a fresh checkout run the packages/llm/core build (see gh#527/gh#541)."}),this.#o("error",{error:new Error("llm build artifact missing")});return}for await(let o of n(r))o.type==="text"?(this.appendChunk(o.text),this.#o("chunk",{text:o.text,snapshot:o.snapshot})):o.type==="thinking"?this.#o("thinking",{text:o.text}):o.type==="done"?this.#o("done",{text:o.text,usage:o.usage,stopReason:o.stopReason}):o.type==="error"&&(this.appendMessage({role:"error",content:o.error.message}),this.#o("error",{error:o.error}))}catch(r){r.name!=="AbortError"&&(this.appendMessage({role:"error",content:r.message}),this.#o("error",{error:r}))}this.#e=null,this.stopStreaming()}export(){return{messages:this.#t.map(t=>({role:t.role,content:t.content})),model:this.model,system:this.system}}import(t){t.model&&(this.model=t.model),t.system&&(this.system=t.system),t.messages&&(this.conversation=t.messages)}#c(){let t=this.#i;t&&requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}#h(t){for(let e of t.querySelectorAll("pre")){let i=e.querySelector("code");if(!i)continue;let r=i.getAttribute("data-lang")||"",n=document.createElement("code-ui");r&&n.setAttribute("language",r),n.textContent=i.textContent,e.replaceWith(n)}}};w("chat-shell",yh);M();R();var PN=40,vh=class extends k{static properties={streaming:{type:Boolean,default:!1,reflect:!0},empty:{type:Boolean,default:!0,reflect:!0}};static template=()=>null;#t=null;#e=!0;#i=null;connected(){this.#s(),this.#r(),this.#n()}disconnected(){this.#t?.disconnect(),this.#t=null,this.#i&&(this.removeEventListener("scroll",this.#i),this.#i=null)}scrollToBottom(){this.scrollTo({top:this.scrollHeight,behavior:"smooth"})}scrollToBottomInstant(){this.scrollTop=this.scrollHeight}#s(){let e=Array.from(this.children).filter(i=>i.tagName.toLowerCase()!=="chat-empty").length===0;this.empty=e,this.toggleAttribute("empty",e)}#r(){typeof MutationObserver>"u"||(this.#t=new MutationObserver(()=>{this.#s(),this.#e&&this.scrollToBottomInstant()}),this.#t.observe(this,{childList:!0}))}#n(){this.#i=()=>{let t=this.scrollHeight-(this.scrollTop+this.clientHeight);this.#e=t<=PN},this.addEventListener("scroll",this.#i,{passive:!0})}};w("chat-thread",vh);M();R();var xh=class extends k{static properties={disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.#t=this.querySelector("chat-input-ui")||this.querySelector("input-ui")||this.querySelector("textarea-ui"),this.#e=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("composer-submit",{bubbles:!0,detail:t.detail||{}}))},this.#t?.addEventListener("submit",this.#e),this.#i()}disconnected(){this.#t&&this.#e&&this.#t.removeEventListener("submit",this.#e),this.#t=null,this.#e=null}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),t==="disabled"&&this.#i()}focus(){this.#t?.focus?.()}clear(){this.#t?.clear?.()}get input(){return this.#t}#i(){this.#t&&(this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"))}};w("chat-composer",xh);M();R();var Sh=class extends k{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0},name:{type:String,default:"",reflect:!0},minWidth:{type:String,default:"",reflect:!0,attribute:"min-width"}};static template=()=>null;#t=[];#e=null;#i=Hd(this,{prefix:"adia-chat-sidebar"});connected(){this.#i.restoreFromStorage(),this.resizable&&this.#s(),this.#r(),this.#i.syncCollapsedFromWidth()}disconnected(){for(let t of this.#t)t();this.#t=[],this.#e?.disconnect(),this.#e=null}toggle(){return this.#i.toggle()}collapse(){this.#i.collapse()}expand(){this.#i.expand()}#s(){let t=this.querySelector(":scope > [data-sidebar-resize]");if(!t)return;let e=this.getAttribute("slot"),i=e==="leading",r=n=>{n.preventDefault(),t.setPointerCapture(n.pointerId);let o=n.clientX,a=this.getBoundingClientRect().width;this.resizing=!0,document.documentElement.style.cursor="col-resize";let l=c=>{let u=c.clientX-o,d=parseInt(getComputedStyle(this).getPropertyValue("max-width"))||480,f=Math.max(48,Math.min(d,a+(i?u:-u)));this.style.width=`${f}px`},h=()=>{this.resizing=!1,document.documentElement.style.cursor="",t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",h);let c=this.getBoundingClientRect().width;c<=96?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<160&&(this.style.width=`${160}px`),this.#i.persist(this.style.width),this.#i.syncCollapsedFromWidth(),this.dispatchEvent(new CustomEvent("sidebar-resize",{bubbles:!0,detail:{name:this.name||e,width:this.getBoundingClientRect().width}}))};t.addEventListener("pointermove",l),t.addEventListener("pointerup",h)};t.addEventListener("pointerdown",r),this.#t.push(()=>t.removeEventListener("pointerdown",r))}#r(){typeof ResizeObserver>"u"||(this.#e=new ResizeObserver(t=>{for(let e of t){let i=e.contentBoxSize[0].inlineSize<=96;for(let r of this.querySelectorAll("select-ui"))r.setAttribute("placement",i?"right":"bottom-start")}}),this.#e.observe(this))}};w("chat-sidebar",Sh);M();R();var wh=class extends k{static properties={};static template=()=>null};w("chat-empty",wh);var QN="Closed.",TN="v1.0";function dy({renderer:s,doc:t=document}){if(!s)throw new Error("createSurfaceRegistry: opts.renderer is required");let e=new Map;function i(h,c){let u=e.get(h);if(u)return u;if(!c)throw new Error(`createSurfaceRegistry.route: no bubble element for fresh surfaceId "${h}"`);let d=t.createElement("div");d.setAttribute("data-surface-root",h),c.appendChild(d);let f=s.attachSurface(h,d),p={surfaceId:h,root:d,handle:f,bubbleEl:c,status:"open"};return e.set(h,p),p}function r(h){let c=t.createElement("div");c.setAttribute("data-surface-closed",h.surfaceId),c.textContent=QN,h.bubbleEl.appendChild(c)}function n(h){let c=e.get(h);if(c)return c.status==="closed"||(s.handleFrame(JSON.stringify({version:TN,deleteSurface:{surfaceId:h}})),c.status="closed",r(c)),c}function o(h,c,u){let d=null;try{d=JSON.parse(c)}catch{}if(d&&Object.hasOwn(d,"deleteSurface")){s.handleFrame(c);let f=e.get(h);return f&&f.status!=="closed"&&(f.status="closed",r(f)),f}return s.handleFrame(c),s.surfaces.has(h)?i(h,u):e.get(h)}function a(h){return e.get(h)}function l(){for(let h of e.values())h.handle.detach();e.clear()}return{route:i,close:n,feed:o,get:a,disposeAll:l,hosts:e}}var uy={sent:"Sending\u2026",started:"Thinking\u2026",reasoning:"Reasoning\u2026",content:"Writing\u2026",validating:"Validating\u2026",retry:"Retrying\u2026",tool:"Using a tool\u2026",done:"Done"};function LN(s){let t=s.surfaces.length,e=s.surfaces.map(i=>`${i.surfaceId} \u2014 ${i.rationale}`).join("; ");return`Planning ${t} surface${t===1?"":"s"}: ${e}`}var MN={new:"New",updated:"Updated",closed:"Closed"};function RN(s){let t=["new","updated","closed"].filter(e=>s[e].length>0).map(e=>`${MN[e]}: ${s[e].join(", ")}`);return t.length?`What changed \u2014 ${t.join(" \xB7 ")}`:"What changed \u2014 nothing this turn"}async function fy(s,t,e){let{events:i,statusEl:r=null,isProgressStage:n=c=>Object.hasOwn(uy,c)}=e??{};if(!i)throw new Error("wireAgentEvents: opts.events (AsyncIterable<AgentEvent>) is required");let o=()=>s.querySelector?.("chat-thread")?.querySelector('[data-role="assistant"]:last-child [data-bubble]')??null,a=null,l=()=>{if(a)return a;let c=o();return c?(a=document.createElement("agent-reasoning-ui"),a.collapsed=!0,c.insertBefore(a,c.firstChild),a):null},h=c=>a?.entries?.find(u=>u.kind==="step"&&u.id===c);for await(let c of i)switch(c.type){case"text":c.text===""?s.setStreamedText?.(c.snapshot??""):s.appendChunk?.(c.text);break;case"progress":{if(!n(c.stage))break;r&&(r.textContent=uy[c.stage]??"");break}case"surface":{let u=o();t.feed(c.surfaceId,c.line,u);break}case"step":{if(c.workflow==="plan"&&c.step==="manifest")s.appendMessage?.({role:"assistant",content:LN(c.data),render:!0}),s.appendMessage?.({role:"assistant",content:""});else if(c.workflow==="plan"&&c.step==="synthesis")s.appendMessage?.({role:"assistant",content:RN(c.data),render:!0}),s.appendMessage?.({role:"assistant",content:""});else{let u=l();if(u){let d=`${c.workflow}:${c.step}:${c.data?.round??1}`,f=`${c.workflow}: ${c.step}`;u.addStep({id:d,label:f}),c.data?.accepted?u.completeStep(d):u.failStep(d,c.data?.reason??"fell through")}}break}case"tool_use":{let u=l();if(u){let d=`${c.name}(${JSON.stringify(c.input)})`;h(c.id)?u.updateStep(c.id,{label:d}):u.addStep({id:c.id,label:d})}break}case"tool_input_delta":{let u=l();if(u){let d=`${c.name}(${c.partial})`;h(c.id)?u.updateStep(c.id,{label:d}):u.addStep({id:c.id,label:d})}break}case"tool_result":{let u=l();if(u){let d=String(c.output).slice(0,300);c.isError?u.failStep(c.id,d):(u.updateStep(c.id,{outcomes:[d]}),u.completeStep(c.id))}break}case"guardrail":{let u=l(),d=c.action==="deny"?"blocked":"rewrote",f=c.toolName?`tool call "${c.toolName}"`:"the response";u?.addThought?.(`Guardrail "${c.name}" ${d} ${f}${c.reason?` \u2014 ${c.reason}`:""}`);break}case"thinking":{l()?.addThought?.(c.text);break}case"error":a?.fail?.(c.error?.message??String(c.error)),s.appendMessage?.({role:"error",content:c.error?.message??String(c.error)}),s.stopStreaming?.();break;case"done":a&&(c.stopReason==="guardrail_denied"?a.fail("Blocked by guardrail"):a.finish()),s.stopStreaming?.();break;default:break}s.streaming&&s.stopStreaming?.()}M();R();var Ah=class extends k{static properties={focusMode:{type:Boolean,default:!1,reflect:!0,attribute:"focus-mode"}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.#t=this.querySelector("editor-toolbar"),this.#e=this.querySelector("editor-canvas"),this.#s(),this.#i=t=>{let e=t?.detail?.name;e&&(e==="toggle-focus"||e==="full-screen")&&this.toggleFocusMode()},this.addEventListener("toolbar-action",this.#i)}disconnected(){this.#i&&this.removeEventListener("toolbar-action",this.#i),this.#i=null}toggleFocusMode(){this.focusMode=!this.focusMode,this.#t?.tagName?.toLowerCase()==="editor-toolbar"&&(this.#t.fullScreen=this.focusMode),this.#e?.tagName?.toLowerCase()==="editor-canvas"&&(this.focusMode?this.#e.focus?.():this.#e.blur?.()),this.dispatchEvent(new CustomEvent("editor-mode-change",{bubbles:!0,detail:{focusMode:this.focusMode}}))}#s(){for(let t of this.querySelectorAll("select-ui[data-options]"))try{let e=JSON.parse(t.getAttribute("data-options"));t.options=e}catch{}}};w("editor-shell",Ah);M();R();var kh=class extends k{static properties={fullScreen:{type:Boolean,default:!1,reflect:!0,attribute:"full-screen"}};static template=()=>null;#t=null;connected(){this.#t=t=>{let e=t.target.closest("[data-toolbar-action]");if(!e||!this.contains(e))return;let i=e.getAttribute("data-toolbar-action");this.dispatchEvent(new CustomEvent("toolbar-action",{bubbles:!0,detail:{name:i}}))},this.addEventListener("click",this.#t)}disconnected(){this.#t&&this.removeEventListener("click",this.#t),this.#t=null}};w("editor-toolbar",kh);M();R();var Eh=class extends k{static properties={empty:{type:Boolean,default:!0,reflect:!0},focused:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=1;#e=null;connected(){this.#i(),this.#s()}disconnected(){this.#e?.disconnect(),this.#e=null}get zoom(){return this.#t}set zoom(t){let e=parseFloat(t);!isFinite(e)||e<=0||(this.#t=e,this.style.setProperty("--editor-canvas-zoom",String(e)))}resetView(){this.zoom=1}focus(){super.focus?.(),this.focused=!0}blur(){super.blur?.(),this.focused=!1}#i(){let t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()!=="editor-canvas-empty");this.empty=t.length===0}#s(){typeof MutationObserver>"u"||(this.#e=new MutationObserver(()=>{this.#i()}),this.#e.observe(this,{childList:!0}))}};w("editor-canvas",Eh);M();R();var IN="adia-editor-sidebar-",Ch=class extends k{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=!1;#l=null;connected(){if(this.#t=this.querySelector("pane-ui"),!this.#t)return;let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.#i=`${IN}${e}`,this.#m(),typeof ResizeObserver<"u"&&(this.#e=new ResizeObserver(i=>{if(getComputedStyle(this).display==="none")return;this.#d();let r=this.#t.offsetWidth;r>0&&(this.style.width=`${r}px`)}),this.#e.observe(this.#t)),this.#s=i=>{i.target?.closest?.('[slot="resize"], [data-sidebar-resize], [class*="handle"]')&&(this.resizing=!0)},this.#t.addEventListener("pointerdown",this.#s),this.#r=()=>{this.resizing&&(this.resizing=!1),this.#f()},document.addEventListener("pointerup",this.#r),this.#n=i=>{i.target!==this.#t||i.propertyName!=="width"||(this.#h(),this.#d())},this.#t.addEventListener("transitionend",this.#n)}disconnected(){this.#a!==null&&(cancelAnimationFrame(this.#a),this.#a=null),this.#l!==null&&(clearTimeout(this.#l),this.#l=null),this.#e?.disconnect(),this.#e=null,this.#s&&this.#t&&(this.#t.removeEventListener("pointerdown",this.#s),this.#s=null),this.#r&&(document.removeEventListener("pointerup",this.#r),this.#r=null),this.#n&&this.#t&&(this.#t.removeEventListener("transitionend",this.#n),this.#n=null)}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){this.#t&&(this.collapsed||this.#f(),this.#t.style.width=`${96}px`,this.collapsed=!0,this.#u())}expand(){if(!this.#t)return;let t=this.#p(),e=t&&t>96?t:240;this.#t.style.width=`${e}px`,this.collapsed=!1,this.#f(),this.#u(),this.#c()}#c(){this.#l!==null&&(clearTimeout(this.#l),this.#l=null);let t=getComputedStyle(this.#t).transitionDuration.split(",")[0].trim(),e=(parseFloat(t)||0)*(t.endsWith("ms")?1:1e3);e<=0||(this.#o=!0,this.#l=setTimeout(()=>{this.#l=null,this.#h(),this.#d()},e+50))}#h(){this.#o=!1,this.#l!==null&&(clearTimeout(this.#l),this.#l=null)}#d(){if(!this.#t||getComputedStyle(this).display==="none")return;let t=this.#t.getBoundingClientRect();if(t.width!==0){if(t.width>96){this.#a!==null&&(cancelAnimationFrame(this.#a),this.#a=null),this.collapsed=!1;return}this.#o||this.#a===null&&(this.#a=requestAnimationFrame(()=>{if(this.#a=null,!this.#t||getComputedStyle(this).display==="none"||this.#o)return;let e=this.#t.getBoundingClientRect();e.width>0&&e.width<=96&&(this.collapsed=!0)}))}}#u(){let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:e,expanded:!this.collapsed}}))}#f(){if(!this.#t||!this.#i)return;let t=this.#t.style.width||"";t&&hy(this.#i,t)}#p(){if(!this.#i)return null;let t=ly(this.#i);if(!t)return null;let e=parseFloat(t);return isFinite(e)?e:null}#m(){if(!this.#t)return;let t=this.#p();t&&t>0&&(this.#t.style.width=`${t}px`,this.collapsed=t<=96)}};w("editor-sidebar",Ch);function DN(){let s=document.activeElement;if(!s)return!1;let t=s.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||s.isContentEditable||t==="INPUT-UI"||t==="TEXTAREA-UI"||t==="OTP-INPUT-UI"||t==="SEARCH-UI")}R();var $h=class extends k{static properties={centered:{type:Boolean,default:!1,reflect:!0},"full-bleed":{type:Boolean,default:!1,reflect:!0}};static template=()=>null};customElements.get("simple-shell")||customElements.define("simple-shell",$h);M();R();var Gd=class extends k{static properties={mode:{type:String,default:"chat",reflect:!0},inspector:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=null;connected(){}render(){this.#t||(this.#t=!0,this.#e=document.createElement("chat-thread-ui"),this.#i=document.createElement("canvas-ui"),this.appendChild(this.#e),this.appendChild(this.#i),this.inspector&&(this.#s=document.createElement("inspector-ui"),this.appendChild(this.#s)))}appendMessage(t){this.#e?.appendMessage(t)}appendCoT(t){this.#e?.appendCoT(t)}pushArtifact(t){this.mode==="chat"&&(this.mode="split"),this.#i?.processAll(t)}setSuggestions(t){this.#e?.setSuggestions(t)}appendResultMessage(t){this.#e?.appendResultMessage(t)}showSavePatternBar(t){this.#e?.showSavePatternBar(t)}showFeedbackWidget(t){this.#e?.showFeedbackWidget(t)}showTyping(){this.#e?.showTyping()}hideTyping(){this.#e?.hideTyping()}appendError(t){this.#e?.appendError(t)}startPipelineStatus(){return this.#e?.startPipelineStatus()}updatePipelineStatus(t){this.#e?.updatePipelineStatus(t)}completePipelineStatus(){this.#e?.completePipelineStatus()}reset(){this.#e?.clear(),this.#i?.reset(),this.mode="chat"}get thread(){return this.#e}get canvas(){return this.#i}get inspect(){return this.#s}};w("gen-root",Gd);ny();M();R();var NN=["atlas","signal","terrarium","ledger","arcade","meridian","solstice","glacier","ember","botanica","vector","velour"],qN={compact:{density:.85,radius:.75},default:{density:1,radius:1},spacious:{density:1.15,radius:1.25}},py=["","ui-sm","ui-md","ui-lg","content-sm","content-md","content-lg"],yC=s=>s.length?s[0].toUpperCase()+s.slice(1):s,Ph=class extends k{static properties={themes:{type:String,default:NN.join(" "),reflect:!0},parametric:{type:Boolean,default:!1,reflect:!0},presets:{type:Boolean,default:!1,reflect:!0},schemeToggle:{type:Boolean,default:!1,reflect:!0,attribute:"scheme-toggle"},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},target:{type:String,default:":root",reflect:!0},scheme:{type:String,default:"auto",reflect:!0},activeTheme:{type:String,default:"",reflect:!0,attribute:"active-theme"},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"},activeDensity:{type:String,default:"",reflect:!0,attribute:"active-density"},activeRadius:{type:String,default:"",reflect:!0,attribute:"active-radius"},register:{type:Boolean,default:!1,reflect:!0},activeScale:{type:String,default:"",reflect:!0,attribute:"active-scale"}};static template=()=>null;#t=null;#e=null;#i=[];#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=!1;connected(){this.#c||(this.#h(),this.#c=!0,this.#A(),this.#g(),this.#y())}disconnected(){for(let t of this.#i)t();this.#i=[],this.#S(),this.parametric&&this.#x().removeAttribute("data-parametric-scope")}apply(t={}){this.#p(t,"programmatic")}reset(){let t=this.#x();if(t.removeAttribute("theme"),t.style.removeProperty("--a-density"),t.style.removeProperty("--a-radius-k"),t.style.removeProperty("color-scheme"),t.removeAttribute("scale"),this.persist)for(let e of["theme","scheme","density","radius","scale"])try{localStorage.removeItem(`${this.storagePrefix}${e}`)}catch{}this.activeTheme="",this.activeDensity="",this.activeRadius="",this.activeScale="",this.scheme="auto",this.activeScheme=this.#O(),this.#n&&(this.#n.value="auto"),this.#s&&(this.#s.value=1),this.#r&&(this.#r.value=1),this.#a&&(this.#a.value=""),this.#o&&(this.#o.value=""),this.#m("reset")}#h(){let t=document.createDocumentFragment();if(this.schemeToggle){let o=document.createElement("div");o.setAttribute("part","scheme");let a=document.createElement("segmented-ui");a.id=`${this.#E}-scheme`;let l=document.createElement("segment-ui");l.setAttribute("value","auto"),l.setAttribute("text","System");let h=document.createElement("segment-ui");h.setAttribute("value","light"),h.setAttribute("text","Light");let c=document.createElement("segment-ui");c.setAttribute("value","dark"),c.setAttribute("text","Dark"),a.append(l,h,c),o.appendChild(a),t.appendChild(o),this.#n=a}let e=(this.themes||"").trim().split(/\s+/).filter(Boolean);if(e.length){let o=document.createElement("div");o.setAttribute("part","theme-row");let a=document.createElement("text-ui");a.setAttribute("variant","label"),a.textContent="Theme",o.appendChild(a);let l=document.createElement("select-ui");l.setAttribute("part","themes"),l.setAttribute("size","sm"),l.id=`${this.#E}-theme`;let h=(c,u)=>{let d=document.createElement("option");return d.value=c,d.textContent=u,d};l.append(h("","Default"),...e.map(c=>h(c,yC(c)))),l.setAttribute("value",""),o.appendChild(l),t.appendChild(o),this.#o=l}if(this.parametric){t.appendChild(document.createElement("divider-ui"));let o=document.createElement("text-ui");o.setAttribute("variant","label"),o.textContent="Parametric",t.appendChild(o);let a=document.createElement("slider-ui");a.setAttribute("part","density"),a.setAttribute("label","Density"),a.setAttribute("value","1"),a.setAttribute("min","0.5"),a.setAttribute("max","1.5"),a.setAttribute("step","0.05"),a.setAttribute("suffix","\xD7"),t.appendChild(a),this.#s=a;let l=document.createElement("slider-ui");l.setAttribute("part","radius"),l.setAttribute("label","Radius"),l.setAttribute("value","1"),l.setAttribute("min","0"),l.setAttribute("max","2"),l.setAttribute("step","0.1"),l.setAttribute("suffix","\xD7"),t.appendChild(l),this.#r=l}if(this.presets||this.register){if(t.appendChild(document.createElement("divider-ui")),this.presets){let o=document.createElement("div");o.setAttribute("part","preset-row");let a=document.createElement("text-ui");a.setAttribute("variant","label"),a.textContent="Preset",o.appendChild(a);let l=document.createElement("div");l.setAttribute("part","presets");for(let h of["compact","default","spacious"]){let c=document.createElement("button-ui");c.setAttribute("data-preset",h),c.setAttribute("text",yC(h)),c.setAttribute("variant","outline"),c.setAttribute("size","sm"),l.appendChild(c)}o.appendChild(l),t.appendChild(o)}if(this.register){let o=document.createElement("div");o.setAttribute("part","preset-row");let a=document.createElement("text-ui");a.setAttribute("variant","label"),a.textContent="Scale",o.appendChild(a);let l=document.createElement("select-ui");l.setAttribute("part","scale"),l.setAttribute("size","sm"),l.id=`${this.#E}-scale`,l.innerHTML=py.map(h=>`<option value="${h}">${h||"Default"}</option>`).join(""),l.setAttribute("value",""),o.appendChild(l),t.appendChild(o),this.#a=l}}t.appendChild(document.createElement("divider-ui"));let i=document.createElement("div");i.setAttribute("part","reset-row");let r=document.createElement("button-ui");r.setAttribute("part","reset"),r.setAttribute("text","Reset"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),i.appendChild(r),t.appendChild(i),this.#l=r;let n=document.createElement("theme-provider");n.setAttribute("scale","ui-md"),n.appendChild(t),this.appendChild(n),this.#d()}#d(){if(this.#o){let t=e=>{let i=e.detail?.value??this.#o.value;this.#u(i)};this.#o.addEventListener("change",t),this.#i.push(()=>this.#o.removeEventListener("change",t))}if(this.#l){let t=()=>this.reset();this.#l.addEventListener("press",t),this.#l.addEventListener("click",t),this.#i.push(()=>{this.#l.removeEventListener("press",t),this.#l.removeEventListener("click",t)})}if(this.#s){let t=()=>this.#p({density:parseFloat(this.#s.value)},"slider");this.#s.addEventListener("input",t),this.#i.push(()=>this.#s.removeEventListener("input",t))}if(this.#r){let t=()=>this.#p({radius:parseFloat(this.#r.value)},"slider");this.#r.addEventListener("input",t),this.#i.push(()=>this.#r.removeEventListener("input",t))}for(let t of this.querySelectorAll('[part="presets"] button-ui')){let e=t.getAttribute("data-preset"),i=()=>this.#f(e);t.addEventListener("press",i),t.addEventListener("click",i),this.#i.push(()=>{t.removeEventListener("press",i),t.removeEventListener("click",i)})}if(this.#n){let t=e=>{let i=e.detail?.value??this.#n.value;(i==="light"||i==="dark"||i==="auto")&&this.#p({scheme:i},"scheme")};this.#n.addEventListener("change",t),this.#i.push(()=>this.#n.removeEventListener("change",t))}if(this.#a){let t=e=>{let i=e.detail?.value??this.#a.value;this.#p({scale:i},"scale")};this.#a.addEventListener("change",t),this.#i.push(()=>this.#a.removeEventListener("change",t))}}#u(t){let e=this.#x();if(e.style.removeProperty("--a-density"),e.style.removeProperty("--a-radius-k"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}density`),localStorage.removeItem(`${this.storagePrefix}radius`)}catch{}this.#p({theme:t},"theme"),this.#s&&(this.#s.value=1),this.#r&&(this.#r.value=1),this.activeDensity="",this.activeRadius=""}#f(t){let e=qN[t];e&&(this.#p({density:e.density,radius:e.radius},"preset"),this.#s&&(this.#s.value=e.density),this.#r&&(this.#r.value=e.radius))}#p(t,e){let i=this.#x();if(t.theme!==void 0){if(t.theme===""||t.theme==="default"?(i.removeAttribute("theme"),this.activeTheme=""):(i.setAttribute("theme",t.theme),this.activeTheme=t.theme),this.persist)try{this.activeTheme?localStorage.setItem(`${this.storagePrefix}theme`,this.activeTheme):localStorage.removeItem(`${this.storagePrefix}theme`)}catch{}this.#o&&(this.#o.value=this.activeTheme)}if(t.density!==void 0&&(i.style.setProperty("--a-density",t.density),this.activeDensity=String(t.density),this.persist))try{localStorage.setItem(`${this.storagePrefix}density`,String(t.density))}catch{}if(t.radius!==void 0&&(i.style.setProperty("--a-radius-k",t.radius),this.activeRadius=String(t.radius),this.persist))try{localStorage.setItem(`${this.storagePrefix}radius`,String(t.radius))}catch{}if(t.scheme!==void 0){let r=t.scheme;if(r==="auto"){if(i.style.removeProperty("color-scheme"),this.scheme="auto",this.activeScheme=this.#O(),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}this.#v()}else if(r==="light"||r==="dark"){if(i.style.setProperty("color-scheme",r),this.scheme=r,this.activeScheme=r,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,r)}catch{}this.#S()}this.#n&&(this.#n.value=this.scheme)}if(t.scale!==void 0){let r=t.scale;if(r&&py.includes(r)?(i.setAttribute("scale",r),this.activeScale=r):(i.removeAttribute("scale"),this.activeScale=""),this.persist)try{this.activeScale?localStorage.setItem(`${this.storagePrefix}scale`,this.activeScale):localStorage.removeItem(`${this.storagePrefix}scale`)}catch{}this.#a&&(this.#a.value=this.activeScale)}this.#m(e)}#m(t){this.dispatchEvent(new CustomEvent("theme-change",{bubbles:!0,detail:{theme:this.activeTheme,scheme:this.activeScheme,density:this.activeDensity?parseFloat(this.activeDensity):1,radius:this.activeRadius?parseFloat(this.activeRadius):1,scale:this.activeScale,source:t}}))}#g(){let t=this.#x(),e,i,r,n,o;if(this.persist)try{e=localStorage.getItem(`${this.storagePrefix}theme`)||"",i=localStorage.getItem(`${this.storagePrefix}scheme`)||"";let a=localStorage.getItem(`${this.storagePrefix}density`),l=localStorage.getItem(`${this.storagePrefix}radius`);r=a!=null?parseFloat(a):void 0,n=l!=null?parseFloat(l):void 0,o=localStorage.getItem(`${this.storagePrefix}scale`)||""}catch{}if(e?(t.setAttribute("theme",e),this.activeTheme=e):this.activeTheme=t.getAttribute("theme")||"",this.#o&&(this.#o.value=this.activeTheme),i==="light"||i==="dark")t.style.setProperty("color-scheme",i),this.scheme=i,this.activeScheme=i,this.#n&&(this.#n.value=i);else{let a=this.scheme||"auto";a==="light"||a==="dark"?(t.style.setProperty("color-scheme",a),this.activeScheme=a):(this.scheme="auto",this.activeScheme=this.#O()),this.#n&&(this.#n.value=this.scheme)}if(r!=null&&!Number.isNaN(r))t.style.setProperty("--a-density",r),this.activeDensity=String(r),this.#s&&(this.#s.value=r);else if(this.#s){let a=this.#b(t,"--a-density");this.#s.value=a,this.activeDensity=String(a)}if(n!=null&&!Number.isNaN(n))t.style.setProperty("--a-radius-k",n),this.activeRadius=String(n),this.#r&&(this.#r.value=n);else if(this.#r){let a=this.#b(t,"--a-radius-k");this.#r.value=a,this.activeRadius=String(a)}if(this.#a){let a=py.includes(o)?o:t.getAttribute("scale")||"";a&&t.setAttribute("scale",a),this.#a.value=a,this.activeScale=a}}#b(t,e){let i=getComputedStyle(t);return parseFloat(i.getPropertyValue(e))||1}#O(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}#y(){if(this.scheme==="auto"){if(this.persist)try{let t=localStorage.getItem(`${this.storagePrefix}scheme`);if(t==="light"||t==="dark")return}catch{}this.#v()}}#v(){if(!(this.#t||typeof matchMedia!="function"))try{this.#t=matchMedia("(prefers-color-scheme: dark)"),this.#e=()=>{let t=this.#t.matches?"dark":"light";this.activeScheme=t,this.#n&&(this.#n.value="auto"),this.#m("scheme")},this.#t.addEventListener("change",this.#e)}catch{}}#S(){if(this.#t&&this.#e)try{this.#t.removeEventListener("change",this.#e)}catch{}this.#t=null,this.#e=null}#x(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}#A(){let t=this.#x();t!==document.documentElement&&(this.parametric?t.setAttribute("data-parametric-scope",""):t.removeAttribute("data-parametric-scope"))}get#E(){return this.id||"theme-panel"}};w("theme-panel",Ph);R();var vC=["change","input"],Qh=class extends k{static properties={label:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=null;#r=()=>this.#d();#n=()=>{!this.#e||!this.#s||this.#e.setAttribute("aria-expanded",String(this.#s.hasAttribute("open")))};#a=null;#o=null;connected(){this.#t||(this.#l(),this.#t=!0);for(let t of vC)this.addEventListener(t,this.#r);this.#i&&!this.#o&&(this.#o=new MutationObserver(this.#r),this.#o.observe(this.#i,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["checked"]})),this.#s&&!this.#a&&(this.#a=new MutationObserver(this.#n),this.#a.observe(this.#s,{attributes:!0,attributeFilter:["open"]})),this.#d()}disconnected(){for(let t of vC)this.removeEventListener(t,this.#r);this.#o?.disconnect(),this.#o=null,this.#a?.disconnect(),this.#a=null}updated(t){this.#t&&(t.has("label")&&this.#d(),t.has("heading")&&this.#c(),t.has("placement")&&this.querySelector(":scope > popover-ui")?.setAttribute("placement",this.placement))}get summary(){let t=this.#i?this.#i.querySelectorAll("check-ui"):[],e=[];for(let i of t)(i.hasAttribute("checked")||i.checked)&&e.push(i);return{selected:e.length,total:t.length,checked:e}}#l(){let t=document.createDocumentFragment();for(;this.firstChild;)t.appendChild(this.firstChild);let e=document.createElement("popover-ui");e.setAttribute("placement",this.placement),e.setAttribute("match-width",""),this.#s=e;let i=document.createElement("button-ui");i.setAttribute("slot","trigger"),i.setAttribute("data-form-popover-trigger",""),i.setAttribute("icon-trailing","caret-down"),i.setAttribute("aria-haspopup","dialog"),i.setAttribute("aria-expanded","false"),this.#e=i,e.appendChild(i);let r=document.createElement("div");r.setAttribute("slot","content"),r.setAttribute("data-form-popover-body",""),r.appendChild(t),this.#i=r,e.appendChild(r),this.appendChild(e),this.#c()}#c(){if(!this.#i)return;let t=this.#i.querySelector(":scope > [data-form-popover-heading]");if(!this.heading){t?.remove();return}t||(t=document.createElement("div"),t.setAttribute("data-form-popover-heading",""),this.#i.prepend(t)),t.textContent=this.heading}#h(t){return(t.getAttribute("label")||t.label||t.textContent||"").trim()}#d(){if(!this.#e)return;let{selected:t,total:e,checked:i}=this.summary,r=this.label;t===1&&i[0]?r=this.#h(i[0])||r:t>1&&(r=r?`${r} (${t})`:`${t}`),r||(r="Options"),this.#e.setAttribute("text",r),this.dispatchEvent(new CustomEvent("summary-change",{bubbles:!0,detail:{selected:t,total:e}}))}};customElements.get("form-popover-ui")||customElements.define("form-popover-ui",Qh);R();var Th=class extends k{static properties={items:{type:Array,default:[]},"storage-key":{type:String,default:"",reflect:!0},storage:{type:String,default:"local",reflect:!0},"dismiss-on-complete":{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},value:{type:Object,default:{}},title:{type:String,default:"Get started",reflect:!0}};static template=t=>t._renderTemplate();#t=`obc-h-${Math.random().toString(36).slice(2,8)}`;#e=`obc-l-${Math.random().toString(36).slice(2,8)}`;#i=!1;#s=!1;#r=null;#n=null;attributeChangedCallback(t,e,i){if(t==="items"||t==="value"){if(i==null)this[t]=t==="items"?[]:{};else try{let r=JSON.parse(i);this[t]=r}catch{this[t]=t==="items"?[]:{}}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#t),this.hasAttribute("items")&&!Array.isArray(this.items))try{this.items=JSON.parse(this.getAttribute("items"))}catch{this.items=[]}if(this.hasAttribute("value")&&(typeof this.value!="object"||Array.isArray(this.value)))try{this.value=JSON.parse(this.getAttribute("value"))}catch{this.value={}}if(this.#i=this.value&&Object.keys(this.value).length>0,!this.#i){let t=this.#v();t&&(this.value=t)}this.#r=this.#o.bind(this),this.#n=this.#l.bind(this),this.addEventListener("change",this.#r),this.addEventListener("click",this.#n),this.#s=this.#p(),this.#m()}disconnected(){this.#r&&this.removeEventListener("change",this.#r),this.#n&&this.removeEventListener("click",this.#n),this.#r=null,this.#n=null,this.#S()}render(){this.#m(),this.#O(),this.#g()}_renderTemplate(){let t=Array.isArray(this.items)?this.items:[],{done:e,total:i,percent:r}=this.#f(),n=this.collapsed?"Expand":"Collapse",o=this.collapsed?"chevron-down":"chevron-up",a=!!this.collapsible,l=this.title||"Get started",h=i>0&&e===i;return J`
|
|
410
410
|
<div data-part="header">
|
|
411
411
|
<div data-part="title" id=${this.#t}>${l}</div>
|
|
412
412
|
${a?J`<button-ui
|
|
@@ -466,10 +466,10 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
466
466
|
text="Open"
|
|
467
467
|
></button-ui>`:null}
|
|
468
468
|
</list-item-ui>
|
|
469
|
-
`}#o(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-check]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"";if(!r)return;let n=this.#d(r),o=!!i.checked;n!==o&&this.#u(r,o,{emit:o})}#l(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-action]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"",n=i.getAttribute("data-href")||"";r&&this.dispatchEvent(new CustomEvent("onboarding-step-action",{bubbles:!0,detail:{id:r,href:n}}))}#c(t){t?.stopPropagation?.();let e=!this.collapsed;this.collapsed=e,e&&this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:"collapsed"}}))}#h(t){if(!t)return!1;let e=t.id;return e!=null&&Object.prototype.hasOwnProperty.call(this.value||{},e)?!!this.value[e]:!!t.done}#d(t){let i=(Array.isArray(this.items)?this.items:[]).find(r=>r&&String(r.id)===String(t));return this.#h(i)}#u(t,e,{emit:i=!0}={}){let r={...this.value||{},[t]:!!e};this.value=r,this.#S(),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("complete",""):this.removeAttribute("complete")}#g(){let t=this.#p();t&&!this.#s?(this.#s=!0,this.dispatchEvent(new CustomEvent("onboarding-complete",{bubbles:!0,detail:{value:this.value}})),this["dismiss-on-complete"]&&this.#b("complete")):t||(this.#s=!1)}#b(t="user"){this.setAttribute("hidden",""),this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:t}}))}#O(){}#v(){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}}#y(){let t=this.#v();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}}#S(){let t=this.#v();if(t)try{t.setItem(this["storage-key"],JSON.stringify(this.value||{}))}catch{}}complete(t){if(t==null)return;let e=String(t);this.#d(e)||this.#u(e,!0,{emit:!0})}reset(t){if(t==null){this.value={};let i=this.#v();try{i?.removeItem(this["storage-key"])}catch{}this.#s=!1,this.removeAttribute("hidden");return}let e=String(t);Object.prototype.hasOwnProperty.call(this.value||{},e)&&this.#u(e,!1,{emit:!1})}progress(){return this.#f()}};customElements.get("onboarding-checklist-ui")||customElements.define("onboarding-checklist-ui",Th);R();Lt();var my=new Set(["","compact","spacious"]),gy=new Set(["2","3","4","5","6"]),xC=new Set(["","2","2:1","3:2","3:1"]),by=["toolbar","kpis","charts","table","aside"],Kd=class extends k{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},bandGap:{type:String,default:"",reflect:!0,attribute:"band-gap"}}}static template=()=>null;#t={toolbar:!1,kpis:!1,charts:!1,table:!1,aside:!1};#e=null;#i=!1;setDensity(t){let e=my.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return by.includes(t)?this.querySelector(`:scope > [slot="${t}"]`):null}connected(){this.hasAttribute("role")||this.setAttribute("role","region"),tt(()=>this.#s()),this.#r(),this.#n(),this.#a(),typeof MutationObserver<"u"&&(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(!my.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&&!gy.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...gy].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!xC.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==="band-gap"&&e!==i){this.#n();return}}}#s(){if(!my.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!gy.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(!xC.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.bandGap||"").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 by)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of by){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",Kd);Lt();var fr=new Set,SC=!1;function wC(s){return String(s).padStart(2,"0")}function Jd(s){return`${s.getFullYear()}-${wC(s.getMonth()+1)}-${wC(s.getDate())}`}function AC(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 kC={today:"Today","7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",qtd:"Quarter to date",ytd:"Year to date",custom:"Custom"},pr=new Set(Object.keys(kC));function Lh(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=Jd(e),r=n=>{let o=new Date(e);return o.setDate(o.getDate()-n),Jd(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:Jd(new Date(e.getFullYear(),n,1)),to:i}}case"ytd":return{from:Jd(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function XN(s,t){let e=AC(s),i=AC(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 tf=class s extends X{static labelDeprecated=!0;static get properties(){return{...X.properties,value:{type:String,default:"7d",reflect:!0},from:{type:String,default:"",reflect:!0},to:{type:String,default:"",reflect:!0},presets:{type:String,default:"today,7d,30d,90d,qtd,ytd,custom"},broadcast:{type:String,default:"document",reflect:!0},ariaLabelAttr:{type:String,default:"Time period",attribute:"aria-label",reflect:!0},pickerOpen:{type:Boolean,default:!1,attribute:"picker-open",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n={prefix:null,chips:null,picker:null,readout:null,suffix:null};#a=!1;#o=!1;static#l=new WeakSet;setRange(t,e,i){if(t==="custom"){if(!e||!i){console.warn('[date-range-selector-ui] setRange("custom", \u2026) requires from + to ISO dates.');return}let n=this.#p(e,i);this.#u("custom",n.from,n.to);return}if(!pr.has(t)){console.warn(`[date-range-selector-ui] unknown preset "${t}" \u2014 ignored. Use one of: ${[...pr].join(", ")}.`);return}let r=Lh(t);r&&this.#u(t,r.from,r.to)}getRange(){return{value:this.value,preset:this.value,from:this.from,to:this.to}}subscribe(t){let e=this.#g();return e?(e.addEventListener("range-change",t),()=>e.removeEventListener("range-change",t)):()=>{}}connected(){super.connected(),this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.ariaLabelAttr||"Time period"),this.#t||(this.#c(),this.#d(),this.#t=!0),this.broadcast==="document"&&this.#v(),tt(()=>{let t=this.#m();t&&this.#u(this.value,t.from,t.to,{initial:!0})})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0,this.#y()}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.#y(),i==="document"?(this.#v(),this.#O()):i==="self"&&this.#O();return}if(t==="value"&&e!==i&&i&&pr.has(i)){if(i!=="custom"){let r=Lh(i);r&&this.#u(i,r.from,r.to)}return}}}syncValue(t){let e=this.from&&this.to?`${this.from}:${this.to}`:"";this.internals.setFormValue(e)}render(){if(this.#t){if(this.#i&&this.#i.value!==this.value&&(this.#i.value=this.value),this.#s){this.hasAttribute("min")&&this.#s.setAttribute("min",this.getAttribute("min")),this.hasAttribute("max")&&this.#s.setAttribute("max",this.getAttribute("max"));let t=this.from&&this.to?JSON.stringify({from:this.from,to:this.to}):"";this.#s.value!==t&&(this.#s.value=t)}if(this.#r){let t=XN(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(!pr.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: ${[...pr].join(", ")}.`));continue}let r=document.createElement("segment-ui");r.setAttribute("value",i),r.setAttribute("text",kC[i]),this.#i.appendChild(r)}this.#i.value=this.value}#d(){let t=n=>{let o=n.detail?.value;if(!o||!pr.has(o))return;if(n.stopPropagation(),o==="custom"){this.#S(),this.#f("custom");return}let a=Lh(o);a&&this.#u(o,a.from,a.to)};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=n=>{n.stopPropagation();let a=(n.detail||{}).value||null;if(!a||!a.from||!a.to)return;let l=this.#p(a.from,a.to);this.#u("custom",l.from,l.to)};this.#s.addEventListener("change",e),this.#e.push(()=>this.#s.removeEventListener("change",e));let i=()=>{this.pickerOpen=!0},r=()=>{this.pickerOpen=!1};this.#s.addEventListener("open",i),this.#s.addEventListener("close",r),this.#e.push(()=>this.#s.removeEventListener("open",i)),this.#e.push(()=>this.#s.removeEventListener("close",r))}#u(t,e,i,r={}){if(this.from===e&&this.to===i&&this.value===t&&!r.initial)return;this.#o=!0;try{this.from=e,this.to=i,this.value=t}finally{this.#o=!1}this.syncValue(),this.#O();let o={value:t,from:e,to:i,preset:t};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,from:e,to:i}}));let a=this.#g();a&&a.dispatchEvent(new CustomEvent("range-change",{bubbles:a===this,detail:o}))}#f(t){if(this.value!==t){this.#o=!0;try{this.value=t}finally{this.#o=!1}}}#p(t,e){return t<=e?{from:t,to:e}:{from:e,to:t}}#m(){if(this.value==="custom")return this.from&&this.to?this.#p(this.from,this.to):Lh("7d");let t=pr.has(this.value)?this.value:"7d";return Lh(t)}#g(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#b(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#O(){let t=this.#b();t&&(this.broadcast==="document"&&!this.#a||(this.from?t.setAttribute("data-range-from",this.from):t.removeAttribute("data-range-from"),this.to?t.setAttribute("data-range-to",this.to):t.removeAttribute("data-range-to")))}#v(){if(fr.size>0&&!fr.has(this)){SC||(SC=!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,fr.add(this);return}fr.add(this),this.#a=!0}#y(){if(fr.has(this)&&(fr.delete(this),this.#a)){document.documentElement.removeAttribute("data-range-from"),document.documentElement.removeAttribute("data-range-to"),this.#a=!1;let t=fr.values().next().value;t&&(t.#a=!0,t.#O())}}#S(){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",tf);R();var ef=class extends k{static properties={open:{type:Boolean,default:!1,reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},confirmText:{type:String,default:"Confirm",reflect:!0,attribute:"confirm-text"},cancelText:{type:String,default:"Cancel",reflect:!0,attribute:"cancel-text"},confirmVariant:{type:String,default:"primary",reflect:!0,attribute:"confirm-variant"},size:{type:String,default:"sm",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=[];#d=!1;#u="";#f="";#p=!1;connected(){this.#d||(this.#u=`${this.#O}-title`,this.#f=`${this.#O}-desc`,this.#m(),this.#g(),this.#d=!0)}disconnected(){for(let t of this.#h)try{t()}catch{}this.#h.length=0}show(){this.open=!0}hide(){this.open=!1}render(){if(!this.#d)return;this.#t&&(this.#t.setAttribute("size",this.size||"sm"),this.#t.open=!!this.open),this.#s&&(this.#s.id=this.#u,this.#s.textContent=this.title||""),this.#n&&(this.#n.id=this.#f,this.#n.textContent=this.description||"",this.#n.hidden=!this.description),this.#i&&(this.querySelector(':scope > [slot="icon"]')?this.#i.hidden=!0:this.icon?(this.#i.hidden=!1,this.#i.setAttribute("name",this.icon)):this.#i.hidden=!0);let t=this.#t?.querySelector(':scope > [slot="dialog"]');t&&(t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),this.title?t.setAttribute("aria-labelledby",this.#u):t.removeAttribute("aria-labelledby"),this.description?t.setAttribute("aria-describedby",this.#f):t.removeAttribute("aria-describedby")),this.#l&&(this.#l.setAttribute("text",this.cancelText||"Cancel"),this.loading?this.#l.setAttribute("disabled",""):this.#l.removeAttribute("disabled")),this.#c&&(this.#c.setAttribute("text",this.confirmText||"Confirm"),this.#c.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),this.loading?(this.#c.setAttribute("disabled",""),this.#c.setAttribute("icon","spinner")):(this.#c.removeAttribute("disabled"),this.#c.removeAttribute("icon"))),this.open&&this.#l&&!this.loading&&this.#b()}#m(){let t=document.createElement("modal-ui");t.setAttribute("size",this.size||"sm");let e=document.createElement("header");e.setAttribute("slot","header");let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.hidden=!0,e.appendChild(i),this.#i=i;let r=document.createElement("text-ui");r.setAttribute("slot","heading"),r.id=this.#u,this.title&&(r.textContent=this.title),e.appendChild(r),this.#s=r,this.#e=e;let n=document.createElement("section");n.setAttribute("slot","body");let o=document.createElement("text-ui");o.setAttribute("slot","description"),o.id=this.#f,this.description?o.textContent=this.description:o.hidden=!0,n.appendChild(o),this.#n=o;let a=document.createElement("div");a.setAttribute("data-extra",""),n.appendChild(a),this.#a=a,this.#r=n;let l=document.createElement("footer");l.setAttribute("slot","footer");let h=document.createElement("button-ui");h.setAttribute("slot","action"),h.setAttribute("data-confirm-action","cancel"),h.setAttribute("variant","ghost"),h.setAttribute("text",this.cancelText||"Cancel"),l.appendChild(h),this.#l=h;let c=document.createElement("button-ui");c.setAttribute("slot","action"),c.setAttribute("data-confirm-action","confirm"),c.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),c.setAttribute("text",this.confirmText||"Confirm"),l.appendChild(c),this.#c=c,this.#o=l;let u=[...this.children];for(let d of u){let f=d.getAttribute("slot");f==="icon"?e.appendChild(d):f||a.appendChild(d)}t.appendChild(e),t.appendChild(n),t.appendChild(l),this.appendChild(t),this.#t=t}#g(){let t=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("confirm",{bubbles:!0,detail:{}})))};this.#c.addEventListener("press",t),this.#h.push(()=>this.#c.removeEventListener("press",t));let e=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.open=!1)};this.#l.addEventListener("press",e),this.#h.push(()=>this.#l.removeEventListener("press",e));let i=r=>{r.stopPropagation(),this.open=!1,this.#p||this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.#p=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{}}))};this.#t.addEventListener("close",i),this.#h.push(()=>this.#t.removeEventListener("close",i))}#b(){let t=()=>{if(!(!this.open||!this.#l||this.loading))try{this.#l.focus()}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):queueMicrotask(t)}get#O(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",ef);async function BN(s,t={}){let{init:e={},timeout:i=3e4,retries:r=0,retryDelay:n=1e3,signal:o}=t;for(let a=0;a<=r;a++){let l=new AbortController,h=setTimeout(()=>l.abort(),i);if(o){if(o.aborted)throw clearTimeout(h),new Na("Request aborted",{kind:"abort"});o.addEventListener("abort",()=>l.abort(),{once:!0})}try{let c=await fetch(s,{...e,signal:l.signal});if(clearTimeout(h),!c.ok&&a<r&&c.status>=500){await EC(n*Math.pow(2,a));continue}return c}catch(c){if(clearTimeout(h),c.name==="AbortError")throw new Na(o?.aborted?"Request aborted":"Request timed out",{kind:o?.aborted?"abort":"timeout",cause:c});if(a<r){await EC(n*Math.pow(2,a));continue}throw new Na(`Network error: ${c.message}`,{kind:"network",cause:c})}}}async function xs(s,t={}){let e=await BN(s,t);if(!e.ok){let i;try{i=await e.json()}catch{i=await e.text().catch(()=>"")}throw new Na(`HTTP ${e.status}: ${e.statusText}`,{kind:"http",status:e.status,body:i})}return e.json()}var Na=class extends Error{constructor(t,{kind:e,status:i,body:r,cause:n}={}){super(t,{cause:n}),this.name="TransportError",this.kind=e,this.status=i,this.body=r}};function EC(s){return new Promise(t=>setTimeout(t,s))}R();Lt();var zN=new Set(["active","trialing","past_due","canceled","paused"]),ZN={active:"success",trialing:"info",past_due:"danger",paused:"warning"},_N={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},VN={update:"update-card",retry:"retry"};function CC(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 jN(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 qa=class extends k{static get properties(){return{account:{type:Object,default:null},variant:{type:String,default:"full",reflect:!0},currency:{type:String,default:"USD",reflect:!0},locale:{type:String,default:""},loading:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m=null;#g=null;#b="";#O=null;#v=null;#y=null;#S=null;#x=null;#A=null;#C=null;#P="";#k=!1;#w=0;async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#w;this.loading=!0,this.removeAttribute("error");try{let i=await xs(t);if(e!==this.#w)return;this.loading=!1;let r=i&&typeof i=="object"&&i.account?i.account:i;this.account=r,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{account:r}}))}catch(i){if(e!==this.#w)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("data-stream-managed","false"),this.setAttribute("role","region"),this.#t||(this.#E(),this.#L(),this.#B(),this.#t=!0),tt(()=>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&&!zN.has(i)&&!this.#k&&(this.#k=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#Q(null),this.#X(null);return}if(!t){this.#Q(null);return}this.#Q(t),this.#M(t),this.#I(t),this.#R(t),this.#q(t),this.#z(t),this.#X(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(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#$(t,e,i){let r=document.createElement("section");r.setAttribute(t,"");let n=document.createElement("aside"),o=document.createElement("h3");o.setAttribute("data-section-heading",""),o.textContent=e;let a=document.createElement("p");a.setAttribute("data-section-description",""),a.textContent=i,n.append(o,a);let l=document.createElement("col-ui");return l.setAttribute("data-region-content",""),l.setAttribute("gap","3"),r.append(n,l),this.appendChild(r),[r,l]}#L(){this.#P=`bo-h-${Math.random().toString(36).slice(2,8)}`;let[t,e]=this.#$("data-header","Current plan","Your active subscription and billing interval."),i=document.createElement("card-ui");i.setAttribute("data-plan-card","");let r=document.createElement("header"),n=document.createElement("span");n.setAttribute("slot","icon");let o=document.createElement("avatar-ui");o.setAttribute("icon","credit-card"),n.appendChild(o);let a=document.createElement("span");a.setAttribute("slot","heading");let l=document.createElement("h2");l.id=this.#P,l.setAttribute("data-billing-plan-name",""),a.appendChild(l);let h=document.createElement("tag-ui");h.setAttribute("data-billing-status",""),h.setAttribute("size","md"),a.appendChild(h);let c=document.createElement("span");c.setAttribute("slot","description");let u=document.createElement("row-ui");u.setAttribute("data-billing-plan-meta",""),u.setAttribute("gap","3"),u.setAttribute("wrap",""),c.appendChild(u);let d=document.createElement("span");d.setAttribute("slot","action");let f=document.createElement("div");f.setAttribute("data-header-actions",""),d.appendChild(f),r.append(n,a,c,d),i.appendChild(r),e.appendChild(i),this.#i=t,this.#s=l,this.#r=u,this.#n=h,this.#a=f,this.#T("header-actions",f);let[p,m]=this.#$("data-kpis","Usage this cycle","Spend, seats, and your next invoice."),g=document.createElement("grid-ui");g.setAttribute("data-kpi-grid",""),g.setAttribute("columns","3"),g.setAttribute("gap","3"),m.appendChild(g);let b=(ti,lf,hf)=>{let cf=document.createElement("card-ui");cf.setAttribute("data-kpi-card",ti);let uf=document.createElement("section"),mr=document.createElement("stat-ui");return mr.setAttribute("data-kpi",ti),mr.setAttribute("label",lf),mr.setAttribute("value","\u2014"),mr.setAttribute("icon",hf),uf.appendChild(mr),cf.appendChild(uf),[cf,mr,uf]},[A,x]=b("spend","Current month","credit-card"),[S,v,E]=b("seats","Seats","users-three"),[O,$]=b("next-invoice","Next invoice","calendar"),C=document.createElement("progress-ui");C.setAttribute("data-seats-quota",""),C.setAttribute("label","Seats used"),C.setAttribute("hidden",""),E.appendChild(C),g.append(A,S,O),this.#o=p,this.#l=x,this.#c=v,this.#h=C,this.#d=$;let[Q,T]=this.#$("data-dunning","Payment issue","Action needed to keep your subscription active.");Q.setAttribute("hidden","");let P=document.createElement("alert-ui");P.setAttribute("pattern","dunning"),P.setAttribute("variant","danger"),T.appendChild(P),this.#u=Q,this.#f=P;let[L,D]=this.#$("data-plan-picker","Plan","Compare plans and switch anytime."),N=document.createElement("div");N.setAttribute("data-before-plan-picker",""),D.appendChild(N),this.#T("before-plan-picker",N);let B=document.createElement("plan-picker-ui");B.setAttribute("data-billing-plan-picker",""),B.setAttribute("name","billing-overview-plan"),B.setAttribute("cycle-toggle",""),D.appendChild(B),this.#p=L,this.#m=L.querySelector("[data-section-heading]"),this.#g=B;let[Y,H]=this.#$("data-payment-methods","Payment methods","Cards and wallets on file for recurring charges."),K=document.createElement("payment-method-list-ui");K.setAttribute("data-billing-payment-methods",""),K.setAttribute("name","billing-overview-payment-method"),H.appendChild(K),this.#O=Y,this.#v=Y.querySelector("[data-section-heading]"),this.#y=K;let[nt,ut]=this.#$("data-invoice-history","Invoice history","Download past invoices for accounting."),bt=document.createElement("invoice-history-ui");bt.setAttribute("data-billing-invoice-history",""),ut.appendChild(bt),this.#S=nt,this.#x=nt.querySelector("[data-section-heading]"),this.#A=bt;let kt=document.createElement("div");kt.setAttribute("data-after-invoice-history",""),ut.appendChild(kt),this.#T("after-invoice-history",kt);let Tt=document.createElement("div");Tt.setAttribute("data-empty","");let Dt=document.createElement("p");Dt.setAttribute("data-empty-heading",""),Dt.textContent="No billing account loaded";let ie=document.createElement("p");ie.setAttribute("data-empty-description",""),ie.textContent="Pass an `account` snapshot or `data-stream-src` to render the dashboard.",Tt.append(Dt,ie),this.appendChild(Tt),this.#C=Tt,this.#T("empty",this)}#Q(t){if(!this.#s||!this.#n||!this.#r)return;let e=t?.plan||null,i=e?.name?String(e.name):"Billing overview";this.#s.textContent!==i&&(this.#s.textContent=i);let r=this.#r;if(r.replaceChildren(),e&&Number.isFinite(e.price)){let o=e.currency||this.currency||"USD",a=this.#Z(),l=e.cycle==="year"?"/yr":"/mo",h=document.createElement("span");h.setAttribute("data-plan-price",""),h.textContent=`${CC(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=ZN[n],a=_N[n]||n;o?(this.#n.getAttribute("variant")!==o&&this.#n.setAttribute("variant",o),this.#n.removeAttribute("tone")):(this.#n.removeAttribute("variant"),this.#n.getAttribute("tone")!=="muted"&&this.#n.setAttribute("tone","muted")),this.#n.getAttribute("text")!==a&&this.#n.setAttribute("text",a),this.#n.setAttribute("aria-label",`Account status: ${a}`)}}#M(t){if(!this.#l||!this.#c||!this.#d)return;let e=t?.plan?.currency||this.currency||"USD",i=this.#Z();if(Number.isFinite(t?.currentSpend)?this.#l.setAttribute("value",CC(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;if(this.#c.setAttribute("value",n!=null?`${r} / ${n}`:String(r)),this.#h)if(n!=null&&n>0){let o=Math.max(0,Math.min(100,Math.round(r/n*100)));this.#h.setAttribute("value",String(o)),this.#h.setAttribute("meta",`${r} / ${n}`),this.#h.removeAttribute("hidden")}else this.#h.setAttribute("hidden","")}else this.#c.setAttribute("value","\u2014"),this.#h&&this.#h.setAttribute("hidden","");t?.nextInvoiceDate?this.#d.setAttribute("value",jN(t.nextInvoiceDate,i)):this.#d.setAttribute("value","\u2014");for(let r of[this.#l,this.#c,this.#d])this.loading?r.setAttribute("loading",""):r.removeAttribute("loading")}#I(t){if(!this.#u||!this.#f)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.#f.setAttribute("amount",String(r)):this.#f.removeAttribute("amount"),this.#f.setAttribute("currency",n),e.dueAt&&this.#f.setAttribute("due-at",String(e.dueAt)),e.cardLast4&&this.#f.setAttribute("card-last4",String(e.cardLast4)),e.reason&&this.#f.setAttribute("reason",String(e.reason)),!this.#f.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.#f.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.#f.appendChild(a)}}#R(t){if(!this.#p||!this.#g)return;let e=this.variant==="full",i=Array.isArray(t?.plans)&&t.plans.length>0;if(!(e&&i)){this.#p.setAttribute("hidden","");return}this.#p.removeAttribute("hidden"),this.#g.plans=t.plans,t?.plan?.id&&this.#g.setAttribute("current",String(t.plan.id));let n=t?.billingCycle==="year"?"annual":"monthly";this.#b!==n&&(this.#b=n,this.#g.setAttribute("cycle",n)),this.loading?this.#g.setAttribute("loading",""):this.#g.removeAttribute("loading")}#q(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")}#z(t){if(!this.#A)return;let e=Array.isArray(t?.invoices)?t.invoices:[];this.#A.invoices=e;let i=t?.plan?.currency||this.currency||"USD";this.#A.setAttribute("currency",i),this.loading?this.#A.setAttribute("loading",""):this.#A.removeAttribute("loading")}#X(t){this.#P&&this.setAttribute("aria-labelledby",this.#P),!t&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label","No billing account loaded"):t&&this.removeAttribute("aria-label")}#Z(){return this.locale?this.locale:typeof document<"u"&&document.documentElement.lang||""}#B(){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.#D(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=VN[d]||d||"dunning";this.#D(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.#D("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.#g||!this.#g.contains(u.target)&&u.target!==this.#g||this.#D("select-plan","plan-picker",u.detail)};this.addEventListener("change",r),this.#e.push(()=>this.removeEventListener("change",r));let n=()=>{this.#D("add-payment-method","payment-method-list",null)};this.addEventListener("add",n),this.#e.push(()=>this.removeEventListener("add",n));let o=u=>{this.#D("remove-payment-method","payment-method-list",u.detail)};this.addEventListener("remove",o),this.#e.push(()=>this.removeEventListener("remove",o));let a=u=>{this.#D("set-default-payment-method","payment-method-list",u.detail)};this.addEventListener("select",a),this.#e.push(()=>this.removeEventListener("select",a));let l=u=>{this.#D("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.#D("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.#D(d,"invoice-history",u.detail)};this.addEventListener("invoice-action",c),this.#e.push(()=>this.removeEventListener("invoice-action",c))}#D(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",qa);R();Lt();var FN=new Set(["draft","open","paid","past-due","void"]),WN={paid:"success",open:"info","past-due":"danger"},$C={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},UN=[{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"}],PC=["Number","Issued","Due","Amount","Currency","Status"];function QC(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 TC(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 LC(s,t){return(s||"/invoices/{number}").replace("{number}",encodeURIComponent(t?.number??"")).replace("{id}",encodeURIComponent(t?.id??""))}function je(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
469
|
+
`}#o(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-check]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"";if(!r)return;let n=this.#d(r),o=!!i.checked;n!==o&&this.#u(r,o,{emit:o})}#l(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-action]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"",n=i.getAttribute("data-href")||"";r&&this.dispatchEvent(new CustomEvent("onboarding-step-action",{bubbles:!0,detail:{id:r,href:n}}))}#c(t){t?.stopPropagation?.();let e=!this.collapsed;this.collapsed=e,e&&this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:"collapsed"}}))}#h(t){if(!t)return!1;let e=t.id;return e!=null&&Object.prototype.hasOwnProperty.call(this.value||{},e)?!!this.value[e]:!!t.done}#d(t){let i=(Array.isArray(this.items)?this.items:[]).find(r=>r&&String(r.id)===String(t));return this.#h(i)}#u(t,e,{emit:i=!0}={}){let r={...this.value||{},[t]:!!e};this.value=r,this.#S(),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("complete",""):this.removeAttribute("complete")}#g(){let t=this.#p();t&&!this.#s?(this.#s=!0,this.dispatchEvent(new CustomEvent("onboarding-complete",{bubbles:!0,detail:{value:this.value}})),this["dismiss-on-complete"]&&this.#b("complete")):t||(this.#s=!1)}#b(t="user"){this.setAttribute("hidden",""),this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:t}}))}#O(){}#y(){if(this.#i||this.storage==="none"||!this["storage-key"]||typeof window>"u")return null;try{return this.storage==="session"?window.sessionStorage:window.localStorage}catch{return null}}#v(){let t=this.#y();if(!t)return null;try{let e=t.getItem(this["storage-key"]);if(!e)return null;let i=JSON.parse(e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}#S(){let t=this.#y();if(t)try{t.setItem(this["storage-key"],JSON.stringify(this.value||{}))}catch{}}complete(t){if(t==null)return;let e=String(t);this.#d(e)||this.#u(e,!0,{emit:!0})}reset(t){if(t==null){this.value={};let i=this.#y();try{i?.removeItem(this["storage-key"])}catch{}this.#s=!1,this.removeAttribute("hidden");return}let e=String(t);Object.prototype.hasOwnProperty.call(this.value||{},e)&&this.#u(e,!1,{emit:!1})}progress(){return this.#f()}};customElements.get("onboarding-checklist-ui")||customElements.define("onboarding-checklist-ui",Th);R();Lt();var my=new Set(["","compact","spacious"]),gy=new Set(["2","3","4","5","6"]),xC=new Set(["","2","2:1","3:2","3:1"]),by=["toolbar","kpis","charts","table","aside"],Kd=class extends k{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},bandGap:{type:String,default:"",reflect:!0,attribute:"band-gap"}}}static template=()=>null;#t={toolbar:!1,kpis:!1,charts:!1,table:!1,aside:!1};#e=null;#i=!1;setDensity(t){let e=my.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return by.includes(t)?this.querySelector(`:scope > [slot="${t}"]`):null}connected(){this.hasAttribute("role")||this.setAttribute("role","region"),tt(()=>this.#s()),this.#r(),this.#n(),this.#a(),typeof MutationObserver<"u"&&(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(!my.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&&!gy.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...gy].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!xC.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==="band-gap"&&e!==i){this.#n();return}}}#s(){if(!my.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!gy.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(!xC.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.bandGap||"").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 by)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of by){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",Kd);Lt();var fr=new Set,SC=!1;function wC(s){return String(s).padStart(2,"0")}function Jd(s){return`${s.getFullYear()}-${wC(s.getMonth()+1)}-${wC(s.getDate())}`}function AC(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 kC={today:"Today","7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",qtd:"Quarter to date",ytd:"Year to date",custom:"Custom"},pr=new Set(Object.keys(kC));function Lh(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=Jd(e),r=n=>{let o=new Date(e);return o.setDate(o.getDate()-n),Jd(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:Jd(new Date(e.getFullYear(),n,1)),to:i}}case"ytd":return{from:Jd(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function XN(s,t){let e=AC(s),i=AC(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 tf=class s extends X{static labelDeprecated=!0;static get properties(){return{...X.properties,value:{type:String,default:"7d",reflect:!0},from:{type:String,default:"",reflect:!0},to:{type:String,default:"",reflect:!0},presets:{type:String,default:"today,7d,30d,90d,qtd,ytd,custom"},broadcast:{type:String,default:"document",reflect:!0},ariaLabelAttr:{type:String,default:"Time period",attribute:"aria-label",reflect:!0},pickerOpen:{type:Boolean,default:!1,attribute:"picker-open",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n={prefix:null,chips:null,picker:null,readout:null,suffix:null};#a=!1;#o=!1;static#l=new WeakSet;setRange(t,e,i){if(t==="custom"){if(!e||!i){console.warn('[date-range-selector-ui] setRange("custom", \u2026) requires from + to ISO dates.');return}let n=this.#p(e,i);this.#u("custom",n.from,n.to);return}if(!pr.has(t)){console.warn(`[date-range-selector-ui] unknown preset "${t}" \u2014 ignored. Use one of: ${[...pr].join(", ")}.`);return}let r=Lh(t);r&&this.#u(t,r.from,r.to)}getRange(){return{value:this.value,preset:this.value,from:this.from,to:this.to}}subscribe(t){let e=this.#g();return e?(e.addEventListener("range-change",t),()=>e.removeEventListener("range-change",t)):()=>{}}connected(){super.connected(),this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.ariaLabelAttr||"Time period"),this.#t||(this.#c(),this.#d(),this.#t=!0),this.broadcast==="document"&&this.#y(),tt(()=>{let t=this.#m();t&&this.#u(this.value,t.from,t.to,{initial:!0})})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0,this.#v()}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.#v(),i==="document"?(this.#y(),this.#O()):i==="self"&&this.#O();return}if(t==="value"&&e!==i&&i&&pr.has(i)){if(i!=="custom"){let r=Lh(i);r&&this.#u(i,r.from,r.to)}return}}}syncValue(t){let e=this.from&&this.to?`${this.from}:${this.to}`:"";this.internals.setFormValue(e)}render(){if(this.#t){if(this.#i&&this.#i.value!==this.value&&(this.#i.value=this.value),this.#s){this.hasAttribute("min")&&this.#s.setAttribute("min",this.getAttribute("min")),this.hasAttribute("max")&&this.#s.setAttribute("max",this.getAttribute("max"));let t=this.from&&this.to?JSON.stringify({from:this.from,to:this.to}):"";this.#s.value!==t&&(this.#s.value=t)}if(this.#r){let t=XN(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(!pr.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: ${[...pr].join(", ")}.`));continue}let r=document.createElement("segment-ui");r.setAttribute("value",i),r.setAttribute("text",kC[i]),this.#i.appendChild(r)}this.#i.value=this.value}#d(){let t=n=>{let o=n.detail?.value;if(!o||!pr.has(o))return;if(n.stopPropagation(),o==="custom"){this.#S(),this.#f("custom");return}let a=Lh(o);a&&this.#u(o,a.from,a.to)};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=n=>{n.stopPropagation();let a=(n.detail||{}).value||null;if(!a||!a.from||!a.to)return;let l=this.#p(a.from,a.to);this.#u("custom",l.from,l.to)};this.#s.addEventListener("change",e),this.#e.push(()=>this.#s.removeEventListener("change",e));let i=()=>{this.pickerOpen=!0},r=()=>{this.pickerOpen=!1};this.#s.addEventListener("open",i),this.#s.addEventListener("close",r),this.#e.push(()=>this.#s.removeEventListener("open",i)),this.#e.push(()=>this.#s.removeEventListener("close",r))}#u(t,e,i,r={}){if(this.from===e&&this.to===i&&this.value===t&&!r.initial)return;this.#o=!0;try{this.from=e,this.to=i,this.value=t}finally{this.#o=!1}this.syncValue(),this.#O();let o={value:t,from:e,to:i,preset:t};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,from:e,to:i}}));let a=this.#g();a&&a.dispatchEvent(new CustomEvent("range-change",{bubbles:a===this,detail:o}))}#f(t){if(this.value!==t){this.#o=!0;try{this.value=t}finally{this.#o=!1}}}#p(t,e){return t<=e?{from:t,to:e}:{from:e,to:t}}#m(){if(this.value==="custom")return this.from&&this.to?this.#p(this.from,this.to):Lh("7d");let t=pr.has(this.value)?this.value:"7d";return Lh(t)}#g(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#b(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#O(){let t=this.#b();t&&(this.broadcast==="document"&&!this.#a||(this.from?t.setAttribute("data-range-from",this.from):t.removeAttribute("data-range-from"),this.to?t.setAttribute("data-range-to",this.to):t.removeAttribute("data-range-to")))}#y(){if(fr.size>0&&!fr.has(this)){SC||(SC=!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,fr.add(this);return}fr.add(this),this.#a=!0}#v(){if(fr.has(this)&&(fr.delete(this),this.#a)){document.documentElement.removeAttribute("data-range-from"),document.documentElement.removeAttribute("data-range-to"),this.#a=!1;let t=fr.values().next().value;t&&(t.#a=!0,t.#O())}}#S(){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",tf);R();var ef=class extends k{static properties={open:{type:Boolean,default:!1,reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},confirmText:{type:String,default:"Confirm",reflect:!0,attribute:"confirm-text"},cancelText:{type:String,default:"Cancel",reflect:!0,attribute:"cancel-text"},confirmVariant:{type:String,default:"primary",reflect:!0,attribute:"confirm-variant"},size:{type:String,default:"sm",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=[];#d=!1;#u="";#f="";#p=!1;connected(){this.#d||(this.#u=`${this.#O}-title`,this.#f=`${this.#O}-desc`,this.#m(),this.#g(),this.#d=!0)}disconnected(){for(let t of this.#h)try{t()}catch{}this.#h.length=0}show(){this.open=!0}hide(){this.open=!1}render(){if(!this.#d)return;this.#t&&(this.#t.setAttribute("size",this.size||"sm"),this.#t.open=!!this.open),this.#s&&(this.#s.id=this.#u,this.#s.textContent=this.title||""),this.#n&&(this.#n.id=this.#f,this.#n.textContent=this.description||"",this.#n.hidden=!this.description),this.#i&&(this.querySelector(':scope > [slot="icon"]')?this.#i.hidden=!0:this.icon?(this.#i.hidden=!1,this.#i.setAttribute("name",this.icon)):this.#i.hidden=!0);let t=this.#t?.querySelector(':scope > [slot="dialog"]');t&&(t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),this.title?t.setAttribute("aria-labelledby",this.#u):t.removeAttribute("aria-labelledby"),this.description?t.setAttribute("aria-describedby",this.#f):t.removeAttribute("aria-describedby")),this.#l&&(this.#l.setAttribute("text",this.cancelText||"Cancel"),this.loading?this.#l.setAttribute("disabled",""):this.#l.removeAttribute("disabled")),this.#c&&(this.#c.setAttribute("text",this.confirmText||"Confirm"),this.#c.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),this.loading?(this.#c.setAttribute("disabled",""),this.#c.setAttribute("icon","spinner")):(this.#c.removeAttribute("disabled"),this.#c.removeAttribute("icon"))),this.open&&this.#l&&!this.loading&&this.#b()}#m(){let t=document.createElement("modal-ui");t.setAttribute("size",this.size||"sm");let e=document.createElement("header");e.setAttribute("slot","header");let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.hidden=!0,e.appendChild(i),this.#i=i;let r=document.createElement("text-ui");r.setAttribute("slot","heading"),r.id=this.#u,this.title&&(r.textContent=this.title),e.appendChild(r),this.#s=r,this.#e=e;let n=document.createElement("section");n.setAttribute("slot","body");let o=document.createElement("text-ui");o.setAttribute("slot","description"),o.id=this.#f,this.description?o.textContent=this.description:o.hidden=!0,n.appendChild(o),this.#n=o;let a=document.createElement("div");a.setAttribute("data-extra",""),n.appendChild(a),this.#a=a,this.#r=n;let l=document.createElement("footer");l.setAttribute("slot","footer");let h=document.createElement("button-ui");h.setAttribute("slot","action"),h.setAttribute("data-confirm-action","cancel"),h.setAttribute("variant","ghost"),h.setAttribute("text",this.cancelText||"Cancel"),l.appendChild(h),this.#l=h;let c=document.createElement("button-ui");c.setAttribute("slot","action"),c.setAttribute("data-confirm-action","confirm"),c.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),c.setAttribute("text",this.confirmText||"Confirm"),l.appendChild(c),this.#c=c,this.#o=l;let u=[...this.children];for(let d of u){let f=d.getAttribute("slot");f==="icon"?e.appendChild(d):f||a.appendChild(d)}t.appendChild(e),t.appendChild(n),t.appendChild(l),this.appendChild(t),this.#t=t}#g(){let t=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("confirm",{bubbles:!0,detail:{}})))};this.#c.addEventListener("press",t),this.#h.push(()=>this.#c.removeEventListener("press",t));let e=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.open=!1)};this.#l.addEventListener("press",e),this.#h.push(()=>this.#l.removeEventListener("press",e));let i=r=>{r.stopPropagation(),this.open=!1,this.#p||this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.#p=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{}}))};this.#t.addEventListener("close",i),this.#h.push(()=>this.#t.removeEventListener("close",i))}#b(){let t=()=>{if(!(!this.open||!this.#l||this.loading))try{this.#l.focus()}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):queueMicrotask(t)}get#O(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",ef);async function BN(s,t={}){let{init:e={},timeout:i=3e4,retries:r=0,retryDelay:n=1e3,signal:o}=t;for(let a=0;a<=r;a++){let l=new AbortController,h=setTimeout(()=>l.abort(),i);if(o){if(o.aborted)throw clearTimeout(h),new Na("Request aborted",{kind:"abort"});o.addEventListener("abort",()=>l.abort(),{once:!0})}try{let c=await fetch(s,{...e,signal:l.signal});if(clearTimeout(h),!c.ok&&a<r&&c.status>=500){await EC(n*Math.pow(2,a));continue}return c}catch(c){if(clearTimeout(h),c.name==="AbortError")throw new Na(o?.aborted?"Request aborted":"Request timed out",{kind:o?.aborted?"abort":"timeout",cause:c});if(a<r){await EC(n*Math.pow(2,a));continue}throw new Na(`Network error: ${c.message}`,{kind:"network",cause:c})}}}async function xs(s,t={}){let e=await BN(s,t);if(!e.ok){let i;try{i=await e.json()}catch{i=await e.text().catch(()=>"")}throw new Na(`HTTP ${e.status}: ${e.statusText}`,{kind:"http",status:e.status,body:i})}return e.json()}var Na=class extends Error{constructor(t,{kind:e,status:i,body:r,cause:n}={}){super(t,{cause:n}),this.name="TransportError",this.kind=e,this.status=i,this.body=r}};function EC(s){return new Promise(t=>setTimeout(t,s))}R();Lt();var zN=new Set(["active","trialing","past_due","canceled","paused"]),ZN={active:"success",trialing:"info",past_due:"danger",paused:"warning"},_N={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},VN={update:"update-card",retry:"retry"};function CC(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 jN(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 qa=class extends k{static get properties(){return{account:{type:Object,default:null},variant:{type:String,default:"full",reflect:!0},currency:{type:String,default:"USD",reflect:!0},locale:{type:String,default:""},loading:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m=null;#g=null;#b="";#O=null;#y=null;#v=null;#S=null;#x=null;#A=null;#E=null;#$="";#k=!1;#w=0;async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#w;this.loading=!0,this.removeAttribute("error");try{let i=await xs(t);if(e!==this.#w)return;this.loading=!1;let r=i&&typeof i=="object"&&i.account?i.account:i;this.account=r,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{account:r}}))}catch(i){if(e!==this.#w)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("data-stream-managed","false"),this.setAttribute("role","region"),this.#t||(this.#C(),this.#M(),this.#B(),this.#t=!0),tt(()=>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&&!zN.has(i)&&!this.#k&&(this.#k=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#T(null),this.#X(null);return}if(!t){this.#T(null);return}this.#T(t),this.#R(t),this.#I(t),this.#L(t),this.#D(t),this.#z(t),this.#X(t)}#C(){let t=this.querySelector(':scope > script[type="application/json"][data-account]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.account&&typeof e.account=="object"?e.account:e;this.account=i}}catch(e){console.warn("[billing-overview-ui] failed to parse <script data-account> JSON:",e?.message)}finally{t.remove()}}#Q(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#P(t,e,i){let r=document.createElement("section");r.setAttribute(t,"");let n=document.createElement("aside"),o=document.createElement("h3");o.setAttribute("data-section-heading",""),o.textContent=e;let a=document.createElement("p");a.setAttribute("data-section-description",""),a.textContent=i,n.append(o,a);let l=document.createElement("col-ui");return l.setAttribute("data-region-content",""),l.setAttribute("gap","3"),r.append(n,l),this.appendChild(r),[r,l]}#M(){this.#$=`bo-h-${Math.random().toString(36).slice(2,8)}`;let[t,e]=this.#P("data-header","Current plan","Your active subscription and billing interval."),i=document.createElement("card-ui");i.setAttribute("data-plan-card","");let r=document.createElement("header"),n=document.createElement("span");n.setAttribute("slot","icon");let o=document.createElement("avatar-ui");o.setAttribute("icon","credit-card"),n.appendChild(o);let a=document.createElement("span");a.setAttribute("slot","heading");let l=document.createElement("h2");l.id=this.#$,l.setAttribute("data-billing-plan-name",""),a.appendChild(l);let h=document.createElement("tag-ui");h.setAttribute("data-billing-status",""),h.setAttribute("size","md"),a.appendChild(h);let c=document.createElement("span");c.setAttribute("slot","description");let u=document.createElement("row-ui");u.setAttribute("data-billing-plan-meta",""),u.setAttribute("gap","3"),u.setAttribute("wrap",""),c.appendChild(u);let d=document.createElement("span");d.setAttribute("slot","action");let f=document.createElement("div");f.setAttribute("data-header-actions",""),d.appendChild(f),r.append(n,a,c,d),i.appendChild(r),e.appendChild(i),this.#i=t,this.#s=l,this.#r=u,this.#n=h,this.#a=f,this.#Q("header-actions",f);let[p,m]=this.#P("data-kpis","Usage this cycle","Spend, seats, and your next invoice."),g=document.createElement("grid-ui");g.setAttribute("data-kpi-grid",""),g.setAttribute("columns","3"),g.setAttribute("gap","3"),m.appendChild(g);let b=(ti,lf,hf)=>{let cf=document.createElement("card-ui");cf.setAttribute("data-kpi-card",ti);let uf=document.createElement("section"),mr=document.createElement("stat-ui");return mr.setAttribute("data-kpi",ti),mr.setAttribute("label",lf),mr.setAttribute("value","\u2014"),mr.setAttribute("icon",hf),uf.appendChild(mr),cf.appendChild(uf),[cf,mr,uf]},[A,x]=b("spend","Current month","credit-card"),[S,v,E]=b("seats","Seats","users-three"),[O,$]=b("next-invoice","Next invoice","calendar"),C=document.createElement("progress-ui");C.setAttribute("data-seats-quota",""),C.setAttribute("label","Seats used"),C.setAttribute("hidden",""),E.appendChild(C),g.append(A,S,O),this.#o=p,this.#l=x,this.#c=v,this.#h=C,this.#d=$;let[Q,T]=this.#P("data-dunning","Payment issue","Action needed to keep your subscription active.");Q.setAttribute("hidden","");let P=document.createElement("alert-ui");P.setAttribute("pattern","dunning"),P.setAttribute("variant","danger"),T.appendChild(P),this.#u=Q,this.#f=P;let[L,D]=this.#P("data-plan-picker","Plan","Compare plans and switch anytime."),N=document.createElement("div");N.setAttribute("data-before-plan-picker",""),D.appendChild(N),this.#Q("before-plan-picker",N);let B=document.createElement("plan-picker-ui");B.setAttribute("data-billing-plan-picker",""),B.setAttribute("name","billing-overview-plan"),B.setAttribute("cycle-toggle",""),D.appendChild(B),this.#p=L,this.#m=L.querySelector("[data-section-heading]"),this.#g=B;let[Y,H]=this.#P("data-payment-methods","Payment methods","Cards and wallets on file for recurring charges."),K=document.createElement("payment-method-list-ui");K.setAttribute("data-billing-payment-methods",""),K.setAttribute("name","billing-overview-payment-method"),H.appendChild(K),this.#O=Y,this.#y=Y.querySelector("[data-section-heading]"),this.#v=K;let[nt,ut]=this.#P("data-invoice-history","Invoice history","Download past invoices for accounting."),bt=document.createElement("invoice-history-ui");bt.setAttribute("data-billing-invoice-history",""),ut.appendChild(bt),this.#S=nt,this.#x=nt.querySelector("[data-section-heading]"),this.#A=bt;let kt=document.createElement("div");kt.setAttribute("data-after-invoice-history",""),ut.appendChild(kt),this.#Q("after-invoice-history",kt);let Tt=document.createElement("div");Tt.setAttribute("data-empty","");let Dt=document.createElement("p");Dt.setAttribute("data-empty-heading",""),Dt.textContent="No billing account loaded";let ie=document.createElement("p");ie.setAttribute("data-empty-description",""),ie.textContent="Pass an `account` snapshot or `data-stream-src` to render the dashboard.",Tt.append(Dt,ie),this.appendChild(Tt),this.#E=Tt,this.#Q("empty",this)}#T(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.#Z(),l=e.cycle==="year"?"/yr":"/mo",h=document.createElement("span");h.setAttribute("data-plan-price",""),h.textContent=`${CC(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=ZN[n],a=_N[n]||n;o?(this.#n.getAttribute("variant")!==o&&this.#n.setAttribute("variant",o),this.#n.removeAttribute("tone")):(this.#n.removeAttribute("variant"),this.#n.getAttribute("tone")!=="muted"&&this.#n.setAttribute("tone","muted")),this.#n.getAttribute("text")!==a&&this.#n.setAttribute("text",a),this.#n.setAttribute("aria-label",`Account status: ${a}`)}}#R(t){if(!this.#l||!this.#c||!this.#d)return;let e=t?.plan?.currency||this.currency||"USD",i=this.#Z();if(Number.isFinite(t?.currentSpend)?this.#l.setAttribute("value",CC(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;if(this.#c.setAttribute("value",n!=null?`${r} / ${n}`:String(r)),this.#h)if(n!=null&&n>0){let o=Math.max(0,Math.min(100,Math.round(r/n*100)));this.#h.setAttribute("value",String(o)),this.#h.setAttribute("meta",`${r} / ${n}`),this.#h.removeAttribute("hidden")}else this.#h.setAttribute("hidden","")}else this.#c.setAttribute("value","\u2014"),this.#h&&this.#h.setAttribute("hidden","");t?.nextInvoiceDate?this.#d.setAttribute("value",jN(t.nextInvoiceDate,i)):this.#d.setAttribute("value","\u2014");for(let r of[this.#l,this.#c,this.#d])this.loading?r.setAttribute("loading",""):r.removeAttribute("loading")}#I(t){if(!this.#u||!this.#f)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.#f.setAttribute("amount",String(r)):this.#f.removeAttribute("amount"),this.#f.setAttribute("currency",n),e.dueAt&&this.#f.setAttribute("due-at",String(e.dueAt)),e.cardLast4&&this.#f.setAttribute("card-last4",String(e.cardLast4)),e.reason&&this.#f.setAttribute("reason",String(e.reason)),!this.#f.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.#f.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.#f.appendChild(a)}}#L(t){if(!this.#p||!this.#g)return;let e=this.variant==="full",i=Array.isArray(t?.plans)&&t.plans.length>0;if(!(e&&i)){this.#p.setAttribute("hidden","");return}this.#p.removeAttribute("hidden"),this.#g.plans=t.plans,t?.plan?.id&&this.#g.setAttribute("current",String(t.plan.id));let n=t?.billingCycle==="year"?"annual":"monthly";this.#b!==n&&(this.#b=n,this.#g.setAttribute("cycle",n)),this.loading?this.#g.setAttribute("loading",""):this.#g.removeAttribute("loading")}#D(t){if(!this.#v)return;let e=Array.isArray(t?.paymentMethods)?t.paymentMethods:[];this.#v.methods=e,this.loading?this.#v.setAttribute("loading",""):this.#v.removeAttribute("loading")}#z(t){if(!this.#A)return;let e=Array.isArray(t?.invoices)?t.invoices:[];this.#A.invoices=e;let i=t?.plan?.currency||this.currency||"USD";this.#A.setAttribute("currency",i),this.loading?this.#A.setAttribute("loading",""):this.#A.removeAttribute("loading")}#X(t){this.#$&&this.setAttribute("aria-labelledby",this.#$),!t&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label","No billing account loaded"):t&&this.removeAttribute("aria-label")}#Z(){return this.locale?this.locale:typeof document<"u"&&document.documentElement.lang||""}#B(){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.#N(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=VN[d]||d||"dunning";this.#N(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.#N("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.#g||!this.#g.contains(u.target)&&u.target!==this.#g||this.#N("select-plan","plan-picker",u.detail)};this.addEventListener("change",r),this.#e.push(()=>this.removeEventListener("change",r));let n=()=>{this.#N("add-payment-method","payment-method-list",null)};this.addEventListener("add",n),this.#e.push(()=>this.removeEventListener("add",n));let o=u=>{this.#N("remove-payment-method","payment-method-list",u.detail)};this.addEventListener("remove",o),this.#e.push(()=>this.removeEventListener("remove",o));let a=u=>{this.#N("set-default-payment-method","payment-method-list",u.detail)};this.addEventListener("select",a),this.#e.push(()=>this.removeEventListener("select",a));let l=u=>{this.#N("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.#N("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.#N(d,"invoice-history",u.detail)};this.addEventListener("invoice-action",c),this.#e.push(()=>this.removeEventListener("invoice-action",c))}#N(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",qa);R();Lt();var FN=new Set(["draft","open","paid","past-due","void"]),WN={paid:"success",open:"info","past-due":"danger"},$C={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},UN=[{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"}],PC=["Number","Issued","Due","Amount","Currency","Status"];function QC(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 TC(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 LC(s,t){return(s||"/invoices/{number}").replace("{number}",encodeURIComponent(t?.number??"")).replace("{id}",encodeURIComponent(t?.id??""))}function je(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
470
470
|
`)?'"'+t.replace(/"/g,'""')+'"':t}function MC(s){return s==="compact"||s==="spacious"?s:null}function YN(s,t){let e=MC(t);e?s.setAttribute("density",e):s.removeAttribute("density")}var Xa=class extends k{static properties={invoices:{type:Array,default:[]},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},hrefPattern:{type:String,default:"/invoices/{number}",reflect:!0,attribute:"href-pattern"},paginate:{type:Number,default:25,reflect:!0},exportable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""},filter:{type:String,default:"",reflect:!0}};static template=()=>null;static requiredIcons=["download-simple","receipt","magnifying-glass"];#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=!1;#h=0;#d=!1;setFilter(t){let e=t||"";return e&&!FN.has(e)?!1:tt(()=>{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=[PC.join(",")];for(let r of t){let n=[je(r.number??""),je(r.issuedAt??""),je(r.dueAt??""),je(Number.isFinite(r.amount)?r.amount:""),je(r.currency||this.currency||"USD"),je(r.status??"")];e.push(n.join(","))}let i=e.join(`\r
|
|
471
471
|
`);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 xs(t);if(e!==this.#h)return;this.removeAttribute("loading");let r=Array.isArray(i)?i:Array.isArray(i?.invoices)?i.invoices:[];this.invoices=r,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:r.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("data-stream-managed","false"),this.setAttribute("role","region"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Invoice history"),this.#t||(this.#u(),this.#f(),this.#b(),this.#t=!0),tt(()=>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(),tt(()=>{this.#o.getAttribute("density")!==MC(this.density)&&YN(this.#o,this.density),!!this.#o.loading!=!!this.loading&&(this.#o.loading=!!this.loading),Number(this.#o.paginate||0)!==Number(this.paginate||0)&&(this.#o.paginate=Number(this.paginate||0)),!!this.#o.selectable!=!!this.selectable&&(this.#o.selectable=!!this.selectable)})),this.#s&&this.#s.setAttribute("count",String(this.#m().length)),this.#n&&(this.#n.hidden=!this.exportable)}#u(){let t=this.querySelector(':scope > script[type="application/json"][data-invoices]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.invoices=e)}catch(e){console.warn("[invoice-history-ui] failed to parse <script data-invoices> JSON:",e?.message)}finally{t.remove()}}#f(){let t=document.createElement("div");t.setAttribute("data-toolbar",""),this.appendChild(t),this.#i=t;let e=this.querySelector(':scope > [slot="toolbar"]');if(e)t.appendChild(e);else{let o=document.createElement("table-toolbar-ui");o.setAttribute("data-default-toolbar",""),o.setAttribute("text","Invoices");let a=document.createElement("row-ui");a.setAttribute("data-invoice-filter",""),a.setAttribute("gap","2"),a.setAttribute("wrap",""),a.setAttribute("role","group"),a.setAttribute("aria-label","Filter invoices by status"),a.setAttribute("slot","actions"),o.appendChild(a);let l=document.createElement("button-ui");l.setAttribute("data-export",""),l.setAttribute("slot","actions"),l.setAttribute("variant","outline"),l.setAttribute("size","sm"),l.setAttribute("text","Export CSV"),l.setAttribute("icon","download-simple"),o.appendChild(l),t.appendChild(o),this.#s=o,this.#r=a,this.#n=l}let i=document.createElement("card-ui");i.setAttribute("data-table-host",""),this.appendChild(i),this.#a=i;let r=document.createElement("section");r.setAttribute("bleed",""),i.appendChild(r);let n=document.createElement("table-ui");if(n.id=this.id?`${this.id}__table`:`invoice-history-${Math.random().toString(36).slice(2,8)}`,n.setAttribute("data-invoice-table",""),n.setAttribute("sortable",""),r.appendChild(n),this.#o=n,this.#s&&this.#s.setAttribute("for",n.id),!this.querySelector(':scope > [slot="empty"]')){let o=document.createElement("empty-state-ui");o.setAttribute("data-empty",""),o.setAttribute("icon","receipt"),o.setAttribute("heading","No invoices yet"),o.setAttribute("description","Invoices will appear here once issued."),this.appendChild(o),this.#l=o}}#p(){if(!this.#r)return;if(this.#r.children.length===0)for(let e of UN){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=>TC(i,t)},{key:"dueAt",label:"Due",sortable:!0,format:i=>TC(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=QC(i,o,t),n.dataset.align="end",a},format:(i,r)=>QC(i,r?.currency||e,t)},{key:"status",label:"Status",sortable:!0,render:i=>{let r=String(i||"").toLowerCase(),n=WN[r],o=$C[r]||(i?String(i):"\u2014"),a=document.createElement("badge-ui");return a.setAttribute("data-invoice-status",""),n?a.setAttribute("variant",n):a.setAttribute("tone","muted"),a.setAttribute("text",o),a.setAttribute("aria-label",o),a},format:i=>$C[String(i||"").toLowerCase()]||(i?String(i):"")},{key:"actions",label:"",sortable:!1,align:"end",accessor:i=>i,render:(i,r)=>{let n=document.createElement("span");n.setAttribute("data-invoice-actions","");let o=document.createElement("button-ui");o.setAttribute("data-invoice-action","view"),o.setAttribute("data-invoice-id",String(r?.id??r?.number??"")),o.setAttribute("size","sm"),o.setAttribute("variant","ghost"),o.setAttribute("text","View"),n.appendChild(o);let a=document.createElement("button-ui");return a.setAttribute("data-invoice-action","download"),a.setAttribute("data-invoice-id",String(r?.id??r?.number??"")),a.setAttribute("size","sm"),a.setAttribute("variant","ghost"),a.setAttribute("icon","download-simple"),a.setAttribute("aria-label",`Download invoice ${r?.number??""}`),n.appendChild(a),n}}]}#b(){let t=o=>{let a=o.target?.closest?.("[data-filter-chip]");if(!a||!this.#r?.contains(a))return;o.stopPropagation();let l=a.getAttribute("data-filter-value")||"";this.setFilter(l)};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=o=>{let a=o?.detail;if(!a||a.key==="actions")return;let l=a.row;if(!l)return;let h=LC(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=LC(this.hrefPattern,c),d=new CustomEvent("invoice-row-click",{bubbles:!0,cancelable:!0,detail:{invoice:c,href:u}});if(this.dispatchEvent(d)&&typeof window<"u"&&window.location?.assign)try{window.location.assign(u)}catch{}}else if(l==="download"){let u=this.#O(c);this.dispatchEvent(new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:u,rowCount:1,invoice:c}}))}}};this.addEventListener("press",i),this.addEventListener("click",i),this.#e.push(()=>this.removeEventListener("press",i)),this.#e.push(()=>this.removeEventListener("click",i));let r=o=>{let a=o.target?.closest?.("button-ui[data-export]");if(!a||!this.#i?.contains(a))return;o.stopPropagation();let l=this.exportCsv(),h=new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:l,rowCount:this.#m().length}});if(this.dispatchEvent(h)&&typeof document<"u"&&typeof URL<"u")try{let u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download="invoices.csv",document.body.appendChild(d),d.click(),d.remove(),setTimeout(()=>URL.revokeObjectURL(u),0)}catch{}};this.addEventListener("press",r),this.addEventListener("click",r),this.#e.push(()=>this.removeEventListener("press",r)),this.#e.push(()=>this.removeEventListener("click",r));let n=o=>{if(o.target!==this.#o)return;let a=this.getSelected();this.dispatchEvent(new CustomEvent("invoice-selection-change",{bubbles:!0,detail:{selected:a}}))};this.addEventListener("select",n),this.#e.push(()=>this.removeEventListener("select",n))}#O(t){let e=[PC.join(","),[je(t.number??""),je(t.issuedAt??""),je(t.dueAt??""),je(Number.isFinite(t.amount)?t.amount:""),je(t.currency||this.currency||"USD"),je(t.status??"")].join(",")];return new Blob([e.join(`\r
|
|
472
|
-
`)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",Xa);R();Lt();var HN=new Set(["draft","open","paid","past-due","void"]),GN={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},KN={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function sf(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 RC(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)}}function IC(s){return s==="compact"||s==="spacious"?s:null}var Ba=class extends k{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:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},printable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m="";#g=!1;#b=!1;#O=0;#v="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#O;this.loading=!0,this.removeAttribute("error");try{let i=await xs(t);if(e!==this.#O)return;this.loading=!1;let r=i&&typeof i=="object"&&i.invoice?i.invoice:i;if(this.invoice=r,r?.status){this.#g=!0;try{this.status=String(r.status)}finally{this.#g=!1}}let n=r?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:n}})),this.#v=n}catch(i){if(e!==this.#O)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("data-stream-managed","false"),this.setAttribute("role","region"),this.#t||(this.#y(),this.#x(),this.#E(),this.#t=!0),tt(()=>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(HN.has(r)||this.#b||(this.#b=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#A(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#A(null,r);return}this.#A(t,r),this.#C(t),this.#P(t),this.#k(t),this.#w(t)}#y(){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()}}#S(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#x(){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.#S("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.#S("customer-block",l),this.#S("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","");let g=IC(this.density);g&&m.setAttribute("density",g),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#h=d,this.#d=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#u=b;let A=document.createElement("footer");A.setAttribute("data-footer","");let x=document.createElement("div");x.setAttribute("data-footer-notes",""),A.appendChild(x),this.appendChild(A),this.#f=A,this.#S("footer",A);let S=document.createElement("empty-state-ui");S.setAttribute("data-empty",""),S.setAttribute("icon","receipt"),S.setAttribute("heading","No invoice loaded"),S.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(S),this.#p=S}#A(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=GN[e]||"default",n=KN[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 ${RC(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${RC(t.dueAt,o)}`,this.#n.appendChild(a)}}#C(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)}}}}#P(t){if(!this.#d)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");this.#d.columns=[{key:"description",label:"Description",flex:1},{key:"qty",label:"Qty",width:80,format:o=>String(o??"")},{key:"unitAmount",label:"Unit",width:120,format:o=>sf(o,e,i)},{key:"amount",label:"Amount",width:140,format:o=>sf(o,e,i)}];let r=Array.isArray(t?.lines)?t.lines:[];this.#d.data=r.map((o,a)=>({__row:a,description:o?.description??"",qty:o?.qty??"",unitAmount:o?.unitAmount??0,amount:o?.amount??0}));let n=IC(this.density);this.#d.getAttribute("density")!==n&&(n?this.#d.setAttribute("density",n):this.#d.removeAttribute("density"))}#k(t){if(!this.#u)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(this.#u.replaceChildren(),!t)return;let r=[{key:"subtotal",label:"Subtotal",value:t.subtotal},{key:"tax",label:"Tax",value:t.tax}];Number.isFinite(t.discount)&&t.discount>0&&r.push({key:"discount",label:"Discount",value:-Math.abs(t.discount)});for(let n of r){if(!Number.isFinite(n.value))continue;let o=document.createElement("div");o.setAttribute("data-totals-row",""),o.setAttribute("data-totals-key",n.key);let a=document.createElement("span");a.setAttribute("data-totals-label",""),a.textContent=n.label;let l=document.createElement("span");l.setAttribute("data-totals-value",""),l.textContent=sf(n.value,e,i),o.append(a,l),this.#u.appendChild(o)}if(Number.isFinite(t.total)){let n=document.createElement("div");n.setAttribute("data-totals-row",""),n.setAttribute("data-totals-key","total"),n.setAttribute("data-grand-total","");let o=document.createElement("span");o.setAttribute("data-totals-label",""),o.textContent="Total";let a=document.createElement("span");a.setAttribute("data-totals-value",""),a.textContent=sf(t.total,e,i),n.append(o,a),this.#u.appendChild(n)}}#w(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#E(){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",Ba);Lt();var JN=[{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 rf(s){if(!s)return"unknown";for(let{brand:t,re:e}of JN)if(e.test(s))return t;return"unknown"}function nf(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function ttt(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 DC(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 NC(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 qC(s){let t=NC(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 XC(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 eq=["US","CA","GB","DE","FR","AU"],iq={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 sq(s){return iq[s]||s}var za=class extends X{static labelDeprecated=!1;static get properties(){return{...X.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},tokenizing:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#o={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#l="unknown";#c=!1;#h=null;#d=null;#u=!1;async tokenize(){if(this.#u)return Promise.reject(new Error("tokenize-inflight"));this.#u=!0,this.setAttribute("tokenizing","");try{let t=this.#P();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.#u=!1}}reset(){tt(()=>{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.#A()})}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),tt(()=>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.#y();else if(t==="error"&&e!==i)this.#S();else if(t==="require-billing-address"&&e!==i)this.#v();else if(t==="default-country"&&e!==i){let r=this.#o.country;r&&!r.value&&(r.value=i||"US")}}}render(){this.#t&&(this.#O(),this.#v(),this.#y(),this.#S(),this.#x(),this.#A())}#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-field-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:eq).map(e=>({value:e,label:sq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=nf(n),a=rf(o);a!==this.#l&&(this.#l=a,this.#A()),this.#b()};this.addEventListener("input",t),this.#e.push(()=>this.removeEventListener("input",t));let e=r=>{r.target!==this&&this.#b()};this.addEventListener("change",e),this.#e.push(()=>this.removeEventListener("change",e));let i=()=>{this.disabled||(this.removeAttribute("prefilled"),this.#s&&(this.#s.hidden=!0),this.#n&&(this.#n.hidden=!1))};this.#r.addEventListener("click",i),this.#r.addEventListener("press",i),this.#e.push(()=>{this.#r.removeEventListener("click",i),this.#r.removeEventListener("press",i)})}#b(){let t=nf(this.#o.cardNumber?.value),e=rf(t),i=this.#C();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#O(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((r,n)=>r?.value===e[n].value&&r?.label===e[n].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#v(){let t=!!this.requireBillingAddress;this.#a.addressLine1&&(this.#a.addressLine1.hidden=!t),this.#a.addressLine2&&(this.#a.addressLine2.hidden=!t)}#y(){let t=!!this.disabled;for(let e of Object.values(this.#o))e&&(t?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}#S(){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"))}#x(){if(!this.#s)return;let t=this.#k();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","")}#A(){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)}#C(){let t=nf(this.#o.cardNumber?.value);return t?DC(t)?qC(this.#o.expiry?.value)?{ok:!1}:XC(this.#o.cvc?.value,rf(t))?{ok:!1}:(this.#o.name?.value||"").trim()?(this.#o.postalCode?.value||"").trim()?{ok:!0}:{ok:!1}:{ok:!1}:{ok:!1}:{ok:!1}}#P(){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=nf(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(!DC(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=qC(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=rf(i);if(XC(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=NC(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:n,expMonth:h.month,expYear:h.year,name:t,country:a}}}#k(){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",za);Lt();var rq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),BC=new Set(["card","bank","wallet"]),zC={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},nq={card:"credit-card",bank:"bank",wallet:"credit-card"},ZC={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 _C(s){let t=(s?.brand||"").toLowerCase();if(zC[t])return zC[t];let e=(s?.type||"card").toLowerCase();return nq[e]||"credit-card"}function VC(s){let t=(s?.brand||"").toLowerCase();if(ZC[t])return ZC[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function Oy(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=VC(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function yy(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 Za=class extends X{static get properties(){return{...X.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=null;#o=new Map;#l=!1;setDefault(t){return t?tt(()=>{let e=(this.methods||[]).find(r=>r.id===t);if(!e)return!1;if(this.value===t)return!0;let i=this.value||"";this.#l=!0;try{this.value=t}finally{this.#l=!1}return this.syncValue(),this.#g(t,i,e),!0}):!1}remove(t){return t?tt(()=>{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.#l=!0;try{this.value=r}finally{this.#l=!1}this.syncValue()}return!0}):!1}add(t){!t||!t.id||tt(()=>{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.#l=!0;try{this.value=t.id}finally{this.#l=!1}this.syncValue(),r!==t.id&&this.#g(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.#h(),this.#d(),this.#m(),this.#t=!0),tt(()=>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.#c(t);if(e&&this.value!==e){this.#l=!0;try{this.value=e}finally{this.#l=!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.hidden=!!this["no-add"]||t.length===0),this.#a){this.#a.setAttribute("text",this["add-label"]||"Add payment method");let i=this["add-icon"]||"plus";i?this.#a.setAttribute("icon",i):this.#a.removeAttribute("icon"),this.disabled?this.#a.setAttribute("disabled",""):this.#a.removeAttribute("disabled")}this.#u(t)}#c(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||""}#h(){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()}}#d(){let t=document.createElement("col-ui");if(t.setAttribute("data-rows",""),t.setAttribute("gap","2"),t.setAttribute("role","presentation"),this.appendChild(t),this.#i=t,!this.querySelector(':scope > [slot="empty"]')){let r=document.createElement("empty-state-ui");r.setAttribute("data-empty",""),r.setAttribute("icon","credit-card"),r.setAttribute("heading","No payment methods"),r.setAttribute("description","Add a method to get started."),this.appendChild(r),this.#s=r}let e=document.createElement("divider-ui");e.setAttribute("data-add-divider",""),this.appendChild(e),this.#n=e;let i=document.createElement("row-ui");if(i.setAttribute("data-add",""),i.setAttribute("gap","2"),this.appendChild(i),this.#r=i,!this.querySelector(':scope > [slot="add"]')){let r=document.createElement("button-ui");r.setAttribute("data-add-cta",""),r.setAttribute("variant","outline"),r.setAttribute("icon",this["add-icon"]||"plus"),r.setAttribute("text",this["add-label"]||"Add payment method"),i.appendChild(r),this.#a=r}}#u(t){if(!this.#i)return;let e=new Map;for(let i of t){if(!i?.id)continue;let r=this.#o.get(i.id);r||(r=this.#f(i),this.#i.appendChild(r)),this.#p(r,i),e.set(i.id,r)}for(let[i,r]of this.#o)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.#o=e}#f(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"),r.setAttribute("data-pml-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"),c.setAttribute("data-pml-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}#p(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();BC.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=_C(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=Oy(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=yy(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=yy(e),u=[Oy(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"))}#m(){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))}#g(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",Za);Lt();var of=new Set(["monthly","annual"]),oq={monthly:"Monthly",annual:"Annual"},aq={monthly:"/month",annual:"/year"};function lq(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function hq(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 _a=class extends X{static labelDeprecated=!0;static get properties(){return{...X.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=null;#l=null;#c=new Map;#h=!1;#d=!1;#u=!1;#f=0;setValue(t){return t?tt(()=>{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.#S(t,i),!0}):!1}setCycle(t){return of.has(t)?tt(()=>{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.#f;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await xs(t);if(e!==this.#f)return;this.removeAttribute("loading");let r=Array.isArray(i)?i:Array.isArray(i?.plans)?i.plans:[];this.plans=r,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:r.length}}))}catch(i){if(e!==this.#f)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("data-stream-managed","false"),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Choose a plan"),this.#t||(this.#p(),this.#m(),this.#y(),this.#t=!0),tt(()=>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.#h)&&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(!of.has(this.cycle)){this.#d||(this.#d=!0,console.warn(`[plan-picker-ui] unknown cycle "${this.cycle}" \u2014 coercing to "monthly".`)),this.#h=!0;try{this.cycle="monthly"}finally{this.#h=!1}}let e=t.filter(r=>r.recommended);e.length>1&&!this.#u&&(this.#u=!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,this.#n&&(this.#n.hidden=!r),r&&this.#g()}this.#b(t,i)}#p(){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()}}#m(){let t=document.createElement("div");t.setAttribute("data-toggle",""),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("divider-ui");e.setAttribute("data-toggle-divider",""),e.hidden=!0,this.appendChild(e),this.#n=e;let i=document.createElement("grid-ui");i.setAttribute("data-plans",""),i.setAttribute("columns","auto-fit"),i.setAttribute("role","presentation"),this.appendChild(i),this.#a=i;let r=document.createElement("div");if(r.setAttribute("data-skeleton",""),r.hidden=!0,this.appendChild(r),this.#o=r,!this.querySelector(':scope > [slot="empty"]')){let n=document.createElement("empty-state-ui");n.setAttribute("data-empty",""),n.setAttribute("icon","package"),n.setAttribute("heading","No plans available"),n.setAttribute("description","Plans will appear here once configured."),this.appendChild(n),this.#l=n}}#g(){if(!this.#i)return;let t=this.#r;if(!t){let e=document.createElement("field-ui");e.setAttribute("label","Billing interval"),t=document.createElement("segmented-ui"),t.setAttribute("aria-label","Billing cycle"),e.appendChild(t),this.#i.appendChild(e),this.#s=e,this.#r=t;for(let i of["monthly","annual"]){let r=document.createElement("segment-ui");r.setAttribute("value",i),r.setAttribute("text",oq[i]),t.appendChild(r)}}t.value!==this.cycle&&(t.value=this.cycle)}#b(t,e){if(!this.#a)return;let i=new Map;for(let r of t){if(!r?.id)continue;let n=this.#c.get(r.id);n||(n=document.createElement("option-card-ui"),n.setAttribute("layout","tile"),this.#a.appendChild(n)),this.#O(n,r,e),i.set(r.id,n)}for(let[r,n]of this.#c)if(!i.has(r))try{n.remove()}catch{}for(let r of t){let n=i.get(r.id);n&&this.#a.appendChild(n)}this.#c=i}#O(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("col-ui"),a.setAttribute("data-plan-body",""),a.setAttribute("gap","3"),t.appendChild(a)),this.#v(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"),l.appendChild(h)}else if(n){let h=document.createElement("tag-ui");h.setAttribute("text","Recommended"),h.setAttribute("variant","primary"),l.appendChild(h)}}#v(t,e){t.replaceChildren();let i=document.createElement("row-ui");i.setAttribute("data-price-row",""),i.setAttribute("gap","1"),i.setAttribute("align","baseline");let r=of.has(this.cycle)?this.cycle:"monthly",n=e.prices||{},o=n[r]||n.monthly||null;if(o){let l=document.createElement("span");l.setAttribute("data-price","");let h=o.currency||this.currency||"USD";l.textContent=lq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:aq[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("divider-ui");l.setAttribute("data-body-divider",""),t.appendChild(l);let h=document.createElement("col-ui");h.setAttribute("data-features",""),h.setAttribute("gap","1"),h.setAttribute("role","list");for(let c of e.features){let u=document.createElement("row-ui");u.setAttribute("data-feature",""),u.setAttribute("gap","2"),u.setAttribute("align","start"),u.setAttribute("role","listitem");let d=document.createElement("icon-ui");d.setAttribute("name","check"),d.setAttribute("aria-hidden","true"),u.appendChild(d);let f=document.createElement("span");f.textContent=String(c),u.appendChild(f),h.appendChild(u)}t.appendChild(h)}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",hq(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(!of.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.#a.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.#h=!0;try{this.value=o}finally{this.#h=!1}this.syncValue(),this.#S(o,l)}};this.#a.addEventListener("change",e),this.#e.push(()=>this.#a.removeEventListener("change",e));let i=r=>{let n=r.target?.closest?.("button-ui[data-cta]");if(!n||!this.#a.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.#h=!0;try{this.value=a}finally{this.#h=!1}this.syncValue(),this.#S(a,h)}this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:a,cycle:this.cycle}}))};this.#a.addEventListener("press",i),this.#a.addEventListener("click",i),this.#e.push(()=>this.#a.removeEventListener("press",i)),this.#e.push(()=>this.#a.removeEventListener("click",i))}#S(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",_a);R();var cq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),uq=6,Mh=class extends k{static properties={integrations:{type:Array,default:[]},loading:{type:Boolean,default:!1,reflect:!0},"search-placeholder":{type:String,default:"Search integrations",reflect:!0},"group-by":{type:String,default:"category",reflect:!0},"status-filter":{type:String,default:"all",reflect:!0}};static template=t=>t._renderTemplate();#t="";#e=`intpage-h-${Math.random().toString(36).slice(2,8)}`;#i=null;attributeChangedCallback(t,e,i){if(t==="integrations"){if(i==null)this.integrations=[];else try{let r=JSON.parse(i);this.integrations=Array.isArray(r)?r:[]}catch{this.integrations=[]}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#e),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Integrations"),this.hasAttribute("integrations")&&!Array.isArray(this.integrations))try{this.integrations=JSON.parse(this.getAttribute("integrations"))}catch{this.integrations=[]}this.addEventListener("input",this.#d),this.addEventListener("change",this.#u)}disconnected(){this.removeEventListener("input",this.#d),this.removeEventListener("change",this.#u),this.#i&&(clearTimeout(this.#i),this.#i=null)}render(){this.#h(),this.querySelector('segmented-ui[data-part="filter"]')?.render?.()}_renderTemplate(){let t=this["search-placeholder"]||"Search integrations",e=this["status-filter"]||"all",i=!!this.loading,r=this.#l();return J`
|
|
472
|
+
`)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",Xa);R();Lt();var HN=new Set(["draft","open","paid","past-due","void"]),GN={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},KN={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function sf(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 RC(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)}}function IC(s){return s==="compact"||s==="spacious"?s:null}var Ba=class extends k{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:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},printable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#c=null;#h=null;#d=null;#u=null;#f=null;#p=null;#m="";#g=!1;#b=!1;#O=0;#y="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#O;this.loading=!0,this.removeAttribute("error");try{let i=await xs(t);if(e!==this.#O)return;this.loading=!1;let r=i&&typeof i=="object"&&i.invoice?i.invoice:i;if(this.invoice=r,r?.status){this.#g=!0;try{this.status=String(r.status)}finally{this.#g=!1}}let n=r?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:n}})),this.#y=n}catch(i){if(e!==this.#O)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("data-stream-managed","false"),this.setAttribute("role","region"),this.#t||(this.#v(),this.#x(),this.#C(),this.#t=!0),tt(()=>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(HN.has(r)||this.#b||(this.#b=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#A(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#A(null,r);return}this.#A(t,r),this.#E(t),this.#$(t),this.#k(t),this.#w(t)}#v(){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()}}#S(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#x(){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.#S("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.#S("customer-block",l),this.#S("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","");let g=IC(this.density);g&&m.setAttribute("density",g),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#h=d,this.#d=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#u=b;let A=document.createElement("footer");A.setAttribute("data-footer","");let x=document.createElement("div");x.setAttribute("data-footer-notes",""),A.appendChild(x),this.appendChild(A),this.#f=A,this.#S("footer",A);let S=document.createElement("empty-state-ui");S.setAttribute("data-empty",""),S.setAttribute("icon","receipt"),S.setAttribute("heading","No invoice loaded"),S.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(S),this.#p=S}#A(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=GN[e]||"default",n=KN[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 ${RC(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${RC(t.dueAt,o)}`,this.#n.appendChild(a)}}#E(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)}}}}#$(t){if(!this.#d)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");this.#d.columns=[{key:"description",label:"Description",flex:1},{key:"qty",label:"Qty",width:80,format:o=>String(o??"")},{key:"unitAmount",label:"Unit",width:120,format:o=>sf(o,e,i)},{key:"amount",label:"Amount",width:140,format:o=>sf(o,e,i)}];let r=Array.isArray(t?.lines)?t.lines:[];this.#d.data=r.map((o,a)=>({__row:a,description:o?.description??"",qty:o?.qty??"",unitAmount:o?.unitAmount??0,amount:o?.amount??0}));let n=IC(this.density);this.#d.getAttribute("density")!==n&&(n?this.#d.setAttribute("density",n):this.#d.removeAttribute("density"))}#k(t){if(!this.#u)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(this.#u.replaceChildren(),!t)return;let r=[{key:"subtotal",label:"Subtotal",value:t.subtotal},{key:"tax",label:"Tax",value:t.tax}];Number.isFinite(t.discount)&&t.discount>0&&r.push({key:"discount",label:"Discount",value:-Math.abs(t.discount)});for(let n of r){if(!Number.isFinite(n.value))continue;let o=document.createElement("div");o.setAttribute("data-totals-row",""),o.setAttribute("data-totals-key",n.key);let a=document.createElement("span");a.setAttribute("data-totals-label",""),a.textContent=n.label;let l=document.createElement("span");l.setAttribute("data-totals-value",""),l.textContent=sf(n.value,e,i),o.append(a,l),this.#u.appendChild(o)}if(Number.isFinite(t.total)){let n=document.createElement("div");n.setAttribute("data-totals-row",""),n.setAttribute("data-totals-key","total"),n.setAttribute("data-grand-total","");let o=document.createElement("span");o.setAttribute("data-totals-label",""),o.textContent="Total";let a=document.createElement("span");a.setAttribute("data-totals-value",""),a.textContent=sf(t.total,e,i),n.append(o,a),this.#u.appendChild(n)}}#w(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#C(){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",Ba);Lt();var JN=[{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 rf(s){if(!s)return"unknown";for(let{brand:t,re:e}of JN)if(e.test(s))return t;return"unknown"}function nf(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function ttt(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 DC(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 NC(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 qC(s){let t=NC(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 XC(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 eq=["US","CA","GB","DE","FR","AU"],iq={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 sq(s){return iq[s]||s}var za=class extends X{static labelDeprecated=!1;static get properties(){return{...X.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},tokenizing:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#o={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#l="unknown";#c=!1;#h=null;#d=null;#u=!1;async tokenize(){if(this.#u)return Promise.reject(new Error("tokenize-inflight"));this.#u=!0,this.setAttribute("tokenizing","");try{let t=this.#$();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.#u=!1}}reset(){tt(()=>{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.#A()})}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),tt(()=>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.#v();else if(t==="error"&&e!==i)this.#S();else if(t==="require-billing-address"&&e!==i)this.#y();else if(t==="default-country"&&e!==i){let r=this.#o.country;r&&!r.value&&(r.value=i||"US")}}}render(){this.#t&&(this.#O(),this.#y(),this.#v(),this.#S(),this.#x(),this.#A())}#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-field-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:eq).map(e=>({value:e,label:sq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=nf(n),a=rf(o);a!==this.#l&&(this.#l=a,this.#A()),this.#b()};this.addEventListener("input",t),this.#e.push(()=>this.removeEventListener("input",t));let e=r=>{r.target!==this&&this.#b()};this.addEventListener("change",e),this.#e.push(()=>this.removeEventListener("change",e));let i=()=>{this.disabled||(this.removeAttribute("prefilled"),this.#s&&(this.#s.hidden=!0),this.#n&&(this.#n.hidden=!1))};this.#r.addEventListener("click",i),this.#r.addEventListener("press",i),this.#e.push(()=>{this.#r.removeEventListener("click",i),this.#r.removeEventListener("press",i)})}#b(){let t=nf(this.#o.cardNumber?.value),e=rf(t),i=this.#E();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#O(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((r,n)=>r?.value===e[n].value&&r?.label===e[n].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#y(){let t=!!this.requireBillingAddress;this.#a.addressLine1&&(this.#a.addressLine1.hidden=!t),this.#a.addressLine2&&(this.#a.addressLine2.hidden=!t)}#v(){let t=!!this.disabled;for(let e of Object.values(this.#o))e&&(t?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}#S(){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"))}#x(){if(!this.#s)return;let t=this.#k();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","")}#A(){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)}#E(){let t=nf(this.#o.cardNumber?.value);return t?DC(t)?qC(this.#o.expiry?.value)?{ok:!1}:XC(this.#o.cvc?.value,rf(t))?{ok:!1}:(this.#o.name?.value||"").trim()?(this.#o.postalCode?.value||"").trim()?{ok:!0}:{ok:!1}:{ok:!1}:{ok:!1}:{ok:!1}}#$(){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=nf(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(!DC(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=qC(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=rf(i);if(XC(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=NC(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:n,expMonth:h.month,expYear:h.year,name:t,country:a}}}#k(){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",za);Lt();var rq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),BC=new Set(["card","bank","wallet"]),zC={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},nq={card:"credit-card",bank:"bank",wallet:"credit-card"},ZC={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 _C(s){let t=(s?.brand||"").toLowerCase();if(zC[t])return zC[t];let e=(s?.type||"card").toLowerCase();return nq[e]||"credit-card"}function VC(s){let t=(s?.brand||"").toLowerCase();if(ZC[t])return ZC[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function Oy(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=VC(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function yy(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 Za=class extends X{static get properties(){return{...X.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=null;#o=new Map;#l=!1;setDefault(t){return t?tt(()=>{let e=(this.methods||[]).find(r=>r.id===t);if(!e)return!1;if(this.value===t)return!0;let i=this.value||"";this.#l=!0;try{this.value=t}finally{this.#l=!1}return this.syncValue(),this.#g(t,i,e),!0}):!1}remove(t){return t?tt(()=>{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.#l=!0;try{this.value=r}finally{this.#l=!1}this.syncValue()}return!0}):!1}add(t){!t||!t.id||tt(()=>{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.#l=!0;try{this.value=t.id}finally{this.#l=!1}this.syncValue(),r!==t.id&&this.#g(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.#h(),this.#d(),this.#m(),this.#t=!0),tt(()=>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.#c(t);if(e&&this.value!==e){this.#l=!0;try{this.value=e}finally{this.#l=!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.hidden=!!this["no-add"]||t.length===0),this.#a){this.#a.setAttribute("text",this["add-label"]||"Add payment method");let i=this["add-icon"]||"plus";i?this.#a.setAttribute("icon",i):this.#a.removeAttribute("icon"),this.disabled?this.#a.setAttribute("disabled",""):this.#a.removeAttribute("disabled")}this.#u(t)}#c(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||""}#h(){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()}}#d(){let t=document.createElement("col-ui");if(t.setAttribute("data-rows",""),t.setAttribute("gap","2"),t.setAttribute("role","presentation"),this.appendChild(t),this.#i=t,!this.querySelector(':scope > [slot="empty"]')){let r=document.createElement("empty-state-ui");r.setAttribute("data-empty",""),r.setAttribute("icon","credit-card"),r.setAttribute("heading","No payment methods"),r.setAttribute("description","Add a method to get started."),this.appendChild(r),this.#s=r}let e=document.createElement("divider-ui");e.setAttribute("data-add-divider",""),this.appendChild(e),this.#n=e;let i=document.createElement("row-ui");if(i.setAttribute("data-add",""),i.setAttribute("gap","2"),this.appendChild(i),this.#r=i,!this.querySelector(':scope > [slot="add"]')){let r=document.createElement("button-ui");r.setAttribute("data-add-cta",""),r.setAttribute("variant","outline"),r.setAttribute("icon",this["add-icon"]||"plus"),r.setAttribute("text",this["add-label"]||"Add payment method"),i.appendChild(r),this.#a=r}}#u(t){if(!this.#i)return;let e=new Map;for(let i of t){if(!i?.id)continue;let r=this.#o.get(i.id);r||(r=this.#f(i),this.#i.appendChild(r)),this.#p(r,i),e.set(i.id,r)}for(let[i,r]of this.#o)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.#o=e}#f(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"),r.setAttribute("data-pml-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"),c.setAttribute("data-pml-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}#p(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();BC.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=_C(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=Oy(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=yy(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=yy(e),u=[Oy(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"))}#m(){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))}#g(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",Za);Lt();var of=new Set(["monthly","annual"]),oq={monthly:"Monthly",annual:"Annual"},aq={monthly:"/month",annual:"/year"};function lq(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function hq(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 _a=class extends X{static labelDeprecated=!0;static get properties(){return{...X.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=null;#l=null;#c=new Map;#h=!1;#d=!1;#u=!1;#f=0;setValue(t){return t?tt(()=>{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.#S(t,i),!0}):!1}setCycle(t){return of.has(t)?tt(()=>{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.#f;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await xs(t);if(e!==this.#f)return;this.removeAttribute("loading");let r=Array.isArray(i)?i:Array.isArray(i?.plans)?i.plans:[];this.plans=r,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:r.length}}))}catch(i){if(e!==this.#f)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("data-stream-managed","false"),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Choose a plan"),this.#t||(this.#p(),this.#m(),this.#v(),this.#t=!0),tt(()=>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.#h)&&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(!of.has(this.cycle)){this.#d||(this.#d=!0,console.warn(`[plan-picker-ui] unknown cycle "${this.cycle}" \u2014 coercing to "monthly".`)),this.#h=!0;try{this.cycle="monthly"}finally{this.#h=!1}}let e=t.filter(r=>r.recommended);e.length>1&&!this.#u&&(this.#u=!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,this.#n&&(this.#n.hidden=!r),r&&this.#g()}this.#b(t,i)}#p(){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()}}#m(){let t=document.createElement("div");t.setAttribute("data-toggle",""),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("divider-ui");e.setAttribute("data-toggle-divider",""),e.hidden=!0,this.appendChild(e),this.#n=e;let i=document.createElement("grid-ui");i.setAttribute("data-plans",""),i.setAttribute("columns","auto-fit"),i.setAttribute("role","presentation"),this.appendChild(i),this.#a=i;let r=document.createElement("div");if(r.setAttribute("data-skeleton",""),r.hidden=!0,this.appendChild(r),this.#o=r,!this.querySelector(':scope > [slot="empty"]')){let n=document.createElement("empty-state-ui");n.setAttribute("data-empty",""),n.setAttribute("icon","package"),n.setAttribute("heading","No plans available"),n.setAttribute("description","Plans will appear here once configured."),this.appendChild(n),this.#l=n}}#g(){if(!this.#i)return;let t=this.#r;if(!t){let e=document.createElement("field-ui");e.setAttribute("label","Billing interval"),t=document.createElement("segmented-ui"),t.setAttribute("aria-label","Billing cycle"),e.appendChild(t),this.#i.appendChild(e),this.#s=e,this.#r=t;for(let i of["monthly","annual"]){let r=document.createElement("segment-ui");r.setAttribute("value",i),r.setAttribute("text",oq[i]),t.appendChild(r)}}t.value!==this.cycle&&(t.value=this.cycle)}#b(t,e){if(!this.#a)return;let i=new Map;for(let r of t){if(!r?.id)continue;let n=this.#c.get(r.id);n||(n=document.createElement("option-card-ui"),n.setAttribute("layout","tile"),this.#a.appendChild(n)),this.#O(n,r,e),i.set(r.id,n)}for(let[r,n]of this.#c)if(!i.has(r))try{n.remove()}catch{}for(let r of t){let n=i.get(r.id);n&&this.#a.appendChild(n)}this.#c=i}#O(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("col-ui"),a.setAttribute("data-plan-body",""),a.setAttribute("gap","3"),t.appendChild(a)),this.#y(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"),l.appendChild(h)}else if(n){let h=document.createElement("tag-ui");h.setAttribute("text","Recommended"),h.setAttribute("variant","primary"),l.appendChild(h)}}#y(t,e){t.replaceChildren();let i=document.createElement("row-ui");i.setAttribute("data-price-row",""),i.setAttribute("gap","1"),i.setAttribute("align","baseline");let r=of.has(this.cycle)?this.cycle:"monthly",n=e.prices||{},o=n[r]||n.monthly||null;if(o){let l=document.createElement("span");l.setAttribute("data-price","");let h=o.currency||this.currency||"USD";l.textContent=lq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:aq[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("divider-ui");l.setAttribute("data-body-divider",""),t.appendChild(l);let h=document.createElement("col-ui");h.setAttribute("data-features",""),h.setAttribute("gap","1"),h.setAttribute("role","list");for(let c of e.features){let u=document.createElement("row-ui");u.setAttribute("data-feature",""),u.setAttribute("gap","2"),u.setAttribute("align","start"),u.setAttribute("role","listitem");let d=document.createElement("icon-ui");d.setAttribute("name","check"),d.setAttribute("aria-hidden","true"),u.appendChild(d);let f=document.createElement("span");f.textContent=String(c),u.appendChild(f),h.appendChild(u)}t.appendChild(h)}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",hq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#v(){let t=r=>{let n=r?.detail?.value;if(!of.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.#a.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.#h=!0;try{this.value=o}finally{this.#h=!1}this.syncValue(),this.#S(o,l)}};this.#a.addEventListener("change",e),this.#e.push(()=>this.#a.removeEventListener("change",e));let i=r=>{let n=r.target?.closest?.("button-ui[data-cta]");if(!n||!this.#a.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.#h=!0;try{this.value=a}finally{this.#h=!1}this.syncValue(),this.#S(a,h)}this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:a,cycle:this.cycle}}))};this.#a.addEventListener("press",i),this.#a.addEventListener("click",i),this.#e.push(()=>this.#a.removeEventListener("press",i)),this.#e.push(()=>this.#a.removeEventListener("click",i))}#S(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",_a);R();var cq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),uq=6,Mh=class extends k{static properties={integrations:{type:Array,default:[]},loading:{type:Boolean,default:!1,reflect:!0},"search-placeholder":{type:String,default:"Search integrations",reflect:!0},"group-by":{type:String,default:"category",reflect:!0},"status-filter":{type:String,default:"all",reflect:!0}};static template=t=>t._renderTemplate();#t="";#e=`intpage-h-${Math.random().toString(36).slice(2,8)}`;#i=null;attributeChangedCallback(t,e,i){if(t==="integrations"){if(i==null)this.integrations=[];else try{let r=JSON.parse(i);this.integrations=Array.isArray(r)?r:[]}catch{this.integrations=[]}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#e),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Integrations"),this.hasAttribute("integrations")&&!Array.isArray(this.integrations))try{this.integrations=JSON.parse(this.getAttribute("integrations"))}catch{this.integrations=[]}this.addEventListener("input",this.#d),this.addEventListener("change",this.#u)}disconnected(){this.removeEventListener("input",this.#d),this.removeEventListener("change",this.#u),this.#i&&(clearTimeout(this.#i),this.#i=null)}render(){this.#h(),this.querySelector('segmented-ui[data-part="filter"]')?.render?.()}_renderTemplate(){let t=this["search-placeholder"]||"Search integrations",e=this["status-filter"]||"all",i=!!this.loading,r=this.#l();return J`
|
|
473
473
|
<header data-part="header">
|
|
474
474
|
<h2 data-part="title" id=${this.#e}>Integrations</h2>
|
|
475
475
|
<slot name="header"></slot>
|
|
@@ -541,7 +541,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
541
541
|
<text-ui data-part="empty-description" variant="body" color="subtle">${e?"Try a different keyword or clear the search.":"Integrations will appear here once they are available."}</text-ui>
|
|
542
542
|
</slot>
|
|
543
543
|
</div>
|
|
544
|
-
`}#l(){let t=Array.isArray(this.integrations)?this.integrations:[],e=(this.#t||"").trim().toLowerCase(),i=this["status-filter"]||"all",r=t.filter(l=>!(!l||typeof l!="object"||i!=="all"&&String(l.status??"available")!==i||e&&![l.name,l.description,l.provider,l.category].map(c=>String(c??"").toLowerCase()).join(" ").includes(e))),n=this["group-by"]||"category";if(n==="none")return[{key:"__none__",label:"",items:r}];let o=[],a=new Map;for(let l of r){let c=String(n==="status"?l.status??"available":l.category??"Other")||"Other";a.has(c)||(a.set(c,[]),o.push(c)),a.get(c).push(l)}return o.map(l=>({key:l,label:n==="status"?this.#c(l):l,items:a.get(l)}))}#c(t){switch(t){case"available":return"Available";case"connected":return"Connected";case"error":return"Issues";case"pending":return"Connecting";case"coming-soon":return"Coming soon";default:return t||"Other"}}#h(){let t=Array.isArray(this.integrations)?this.integrations:[],i=this.#l().reduce((r,n)=>r+n.items.length,0);if(this.loading){this.removeAttribute("empty-search"),this.removeAttribute("empty-data");return}i===0&&t.length>0?(this.setAttribute("empty-search",""),this.removeAttribute("empty-data")):t.length===0?(this.setAttribute("empty-data",""),this.removeAttribute("empty-search")):(this.removeAttribute("empty-search"),this.removeAttribute("empty-data"))}#d=t=>{let e=t.target;if(!e||!e.closest)return;let i=e.closest('search-ui[data-part="search"]');if(!i||!this.contains(i))return;let r=String(t.detail?.value??i.value??"");this.#t=r,this.integrations=Array.isArray(this.integrations)?[...this.integrations]:[],this.#i&&clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{query:r.toLowerCase().trim()}}))},250)};#u=t=>{let e=t.target;if(!e||!e.closest)return;let i=e.closest('segmented-ui[data-part="filter"]');if(!i||!this.contains(i))return;let r=String(t.detail?.value??i.value??"all");this["status-filter"]!==r&&(this["status-filter"]=r,this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{status:r}})))}};customElements.get("integrations-page-ui")||customElements.define("integrations-page-ui",Mh);Lt();var Rh=class extends X{static get properties(){return{...X.properties,preferences:{type:Array,default:[]},channels:{type:Array,default:[]},channelEnabled:{type:Object,default:{}},loading:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},"group-by":{type:String,default:"none",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=new Map;#c=new Map;#h=new Map;#d=new Map;#u=new Map;#f=!1;#p=`np-h-${Math.random().toString(36).slice(2,8)}`;attributeChangedCallback(t,e,i){if(t==="preferences"||t==="channels"||t==="channelenabled"){let r=t==="channelenabled"?"channelEnabled":t;if(i==null)this[r]=r==="channelEnabled"?{}:[];else try{let n=JSON.parse(i);r==="channelEnabled"?this[r]=n&&typeof n=="object"&&!Array.isArray(n)?n:{}:this[r]=Array.isArray(n)?n:[]}catch{this[r]=r==="channelEnabled"?{}:[]}return}super.attributeChangedCallback?.(t,e,i)}connected(){if(super.connected(),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Notification preferences"),this.setAttribute("role","region"),!this.#t){if(this.hasAttribute("preferences")&&!Array.isArray(this.preferences))try{this.preferences=JSON.parse(this.getAttribute("preferences"))}catch{this.preferences=[]}if(this.hasAttribute("channels")&&!Array.isArray(this.channels))try{this.channels=JSON.parse(this.getAttribute("channels"))}catch{this.channels=[]}if(this.hasAttribute("channelenabled")&&(typeof this.channelEnabled!="object"||Array.isArray(this.channelEnabled)))try{this.channelEnabled=JSON.parse(this.getAttribute("channelenabled"))}catch{this.channelEnabled={}}this.#m(),this.#x(),this.#t=!0}tt(()=>this.render())}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(){let t={preferences:Array.isArray(this.preferences)?this.preferences:[],channelEnabled:this.channelEnabled&&typeof this.channelEnabled=="object"?this.channelEnabled:{}},e=JSON.stringify(t);this.value=e,this.internals.setFormValue(e)}render(){if(!this.#t)return;let t=Array.isArray(this.channels)?this.channels:[],e=Array.isArray(this.preferences)?this.preferences:[];e.length===0||t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.style.setProperty("--np-columns",`repeat(${Math.max(t.length,1)}, minmax(var(--notification-preferences-channel-width, var(--notification-preferences-channel-width-default)), auto))`),this.#g(t),(this["group-by"]||"none")==="group"?this.#v(e,t):this.#O(e,t),this.syncValue()}#m(){let t=document.createElement("div");t.setAttribute("data-part","header");let e=document.createElement("slot");e.setAttribute("name","header"),t.appendChild(e),this.appendChild(t),this.#i=t;let i=document.createElement("div");i.setAttribute("data-part","matrix"),i.setAttribute("role","table"),i.setAttribute("aria-labelledby",this.#p),this.appendChild(i),this.#s=i;let r=document.createElement("div");r.setAttribute("data-part","header-row"),r.setAttribute("role","row"),i.appendChild(r),this.#r=r;let n=document.createElement("div");n.setAttribute("data-part","body"),i.appendChild(n),this.#n=n;let o=document.createElement("div");o.setAttribute("data-part","empty");let a=document.createElement("slot");a.setAttribute("name","empty");let l=document.createElement("empty-state-ui");l.setAttribute("icon","bell"),l.setAttribute("heading","No notification types configured"),l.setAttribute("description","Add at least one notification type and one delivery channel to begin."),a.appendChild(l),o.appendChild(a),this.appendChild(o),this.#a=o;let h=document.createElement("div");h.setAttribute("data-part","footer");let c=document.createElement("slot");c.setAttribute("name","footer"),h.appendChild(c),this.appendChild(h),this.#o=h}#g(t){if(!this.#r)return;let e=this.#r.querySelector(":scope > [data-row-label]");e||(e=document.createElement("div"),e.setAttribute("role","columnheader"),e.setAttribute("data-row-label",""),e.id=this.#p,e.textContent="Notification",this.#r.appendChild(e));let i=new Set;for(let r of t){if(!r?.key)continue;i.add(r.key);let n=this.#h.get(r.key);n||(n=document.createElement("div"),n.setAttribute("role","columnheader"),n.setAttribute("data-channel-key",r.key),this.#r.appendChild(n),this.#h.set(r.key,n)),this.#b(n,r)}for(let[r,n]of this.#h)if(!i.has(r)){try{n.remove()}catch{}this.#h.delete(r),this.#d.delete(r)}for(let r of t){let n=this.#h.get(r.key);n&&this.#r.appendChild(n)}}#b(t,e){if(t.replaceChildren(),e.icon){let a=document.createElement("icon-ui");a.setAttribute("name",String(e.icon)),a.setAttribute("aria-hidden","true"),t.appendChild(a)}let i=document.createElement("span");i.setAttribute("data-channel-label",""),i.textContent=String(e.label||e.key),t.appendChild(i);let r=this.#d.get(e.key);r||(r=document.createElement("switch-ui"),r.setAttribute("size","sm"),r.setAttribute("data-channel-master",e.key),this.#d.set(e.key,r));let n=this.channelEnabled&&typeof this.channelEnabled=="object"?this.channelEnabled:{},o=Object.prototype.hasOwnProperty.call(n,e.key)?!!n[e.key]:!0;if(r.checked!==o){this.#f=!0;try{r.checked=o}finally{this.#f=!1}}r.setAttribute("aria-label",`Toggle ${e.label||e.key} for all rows`),this.disabled||this.loading?r.setAttribute("disabled",""):r.removeAttribute("disabled"),t.appendChild(r)}#O(t,e){if(!this.#n)return;for(let[,n]of this.#u)try{n.remove()}catch{}this.#u.clear();let i=new Set,r=new Set;for(let n of t){if(!n?.key)continue;i.add(n.key);let o=this.#y(n);this.#S(o,n,e,r)}for(let[n,o]of this.#l)if(!i.has(n)){try{o.remove()}catch{}this.#l.delete(n)}for(let[n,o]of this.#c)if(!r.has(n)){try{o.remove()}catch{}this.#c.delete(n)}for(let n of t){let o=this.#l.get(n.key);o&&this.#n.appendChild(o)}}#v(t,e){if(!this.#n)return;let i=[],r=new Map;for(let l of t){let h=String(l?.group??"Other")||"Other";r.has(h)||(r.set(h,[]),i.push(h)),r.get(h).push(l)}let n=new Set,o=new Set,a=new Set;for(let l of i){n.add(l);let h=this.#u.get(l);h||(h=document.createElement("div"),h.setAttribute("data-part","group-heading"),h.setAttribute("data-group",l),h.setAttribute("role","rowgroup"),this.#u.set(l,h)),h.textContent=l,this.#n.appendChild(h);for(let c of r.get(l)){if(!c?.key)continue;o.add(c.key);let u=this.#y(c);this.#S(u,c,e,a),this.#n.appendChild(u)}}for(let[l,h]of this.#l)if(!o.has(l)){try{h.remove()}catch{}this.#l.delete(l)}for(let[l,h]of this.#c)if(!a.has(l)){try{h.remove()}catch{}this.#c.delete(l)}for(let[l,h]of this.#u)if(!n.has(l)){try{h.remove()}catch{}this.#u.delete(l)}}#y(t){let e=this.#l.get(t.key);return e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-row-key",t.key),this.#n.appendChild(e),this.#l.set(t.key,e)),e}#S(t,e,i,r){let n=t.querySelector(':scope > [role="rowheader"]');n||(n=document.createElement("div"),n.setAttribute("role","rowheader"),t.appendChild(n)),n.replaceChildren();let o=document.createElement("span");if(o.setAttribute("data-row-label-text",""),o.textContent=String(e.label||e.key),n.appendChild(o),e.description){let l=document.createElement("span");l.setAttribute("data-row-description",""),l.textContent=String(e.description),n.appendChild(l)}let a=e.channels&&typeof e.channels=="object"?e.channels:{};for(let l of i){if(!l?.key)continue;let h=`${e.key}::${l.key}`;r.add(h);let c=t.querySelector(`:scope > [data-cell-key="${CSS.escape(h)}"]`);c||(c=document.createElement("div"),c.setAttribute("role","cell"),c.setAttribute("data-cell-key",h),t.appendChild(c));let u=this.#c.get(h);u||(u=document.createElement("check-ui"),u.setAttribute("data-row-key",e.key),u.setAttribute("data-channel-key",l.key),c.appendChild(u),this.#c.set(h,u));let d=!!a[l.key];if(u.checked!==d){this.#f=!0;try{u.checked=d}finally{this.#f=!1}}u.setAttribute("aria-label",`${e.label||e.key} via ${l.label||l.key}`),!!this.disabled||!!this.loading||!!e.disabled?u.setAttribute("disabled",""):u.removeAttribute("disabled")}for(let l of i){let h=`${e.key}::${l.key}`,c=t.querySelector(`:scope > [data-cell-key="${CSS.escape(h)}"]`);c&&t.appendChild(c)}}#x(){let t=e=>{if(this.#f)return;let i=e?.target;if(!i)return;let r=i.closest?.("switch-ui[data-channel-master]");if(r&&this.#s.contains(r)){let o=r.getAttribute("data-channel-master")||"";if(!o||this.disabled||this.loading)return;e.stopPropagation();let a=!!r.checked;this.dispatchEvent(new CustomEvent("bulk-toggle",{bubbles:!0,detail:{channel:o,enabled:a}}));return}let n=i.closest?.("check-ui[data-row-key][data-channel-key]");if(n&&this.#n.contains(n)){let o=n.getAttribute("data-row-key")||"",a=n.getAttribute("data-channel-key")||"";if(!o||!a||this.disabled||this.loading)return;e.stopPropagation();let l=!!n.checked;this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{row:o,channel:a,enabled:l}}));return}};this.#s.addEventListener("change",t),this.#e.push(()=>this.#s.removeEventListener("change",t))}};customElements.get("notification-preferences-ui")||customElements.define("notification-preferences-ui",Rh);var vy=["prompt-section","skill","workflow","resource","tool","pattern-source"];function xy(s){return s.filter(t=>t.enabled).sort((t,e)=>t.order-e.order)}function jC(s){return{order:0,enabled:!0,builtin:!0,...s}}function dq(s){return s.map((t,e)=>jC({order:e,...t}))}function Sy(s){if(!s.id)throw new Error('definePersona: "id" is required');if(!Number.isInteger(s.seedVersion)||s.seedVersion<1)throw new Error(`definePersona "${s.id}": seedVersion must be an integer >= 1, got ${s.seedVersion}`);let t=new Set;for(let e of s.entries){if(t.has(e.id))throw new Error(`definePersona "${s.id}": duplicate entry id "${e.id}"`);t.add(e.id)}return s}Lt();function FC(s){let t=ei(s),e=new Set;return{get value(){return t.value},set value(i){let r=!Object.is(t.peek(),i);if(t.value=i,r)for(let n of e)n(i)},peek(){return t.peek()},subscribe(i){return e.add(i),()=>e.delete(i)}}}function fq(){try{return typeof localStorage<"u"}catch{return!1}}function YC(s={}){let t=s.persistKey,e=!!t&&fq(),i={...s.initial??{}};if(e)try{let o=localStorage.getItem(t);o&&(i={...i,...JSON.parse(o)})}catch{}let r=FC([]);function n(){if(e)try{localStorage.setItem(t,JSON.stringify(i))}catch{}}return{get(o){return i[o]},set(o,a){if(!(o in i&&Object.is(i[o],a))){i={...i,[o]:a},n();for(let l of r.peek())l()}},subscribe(o){return r.peek().includes(o)||(r.value=[...r.peek(),o]),()=>{r.value=r.peek().filter(a=>a!==o)}}}}var WC="__seedVersion";function UC(s,t){return`entry.${s}.${t}`}function pq(s){let t={};for(let e of s.entries)t[UC(e.id,"enabled")]=e.enabled,t[UC(e.id,"order")]=e.order;return t}function wy(s,t={}){let i=(t.createStore??YC)({persistKey:`persona.${s.id}`}),r=pq(s);if(i.get(WC)!==s.seedVersion){for(let[o,a]of Object.entries(r))i.set(o,a);i.set(WC,s.seedVersion)}else for(let[o,a]of Object.entries(r))i.get(o)===void 0&&i.set(o,a);return i}function Ih(s,t,e={}){if(typeof t=="function"&&e.cache)throw new Error(`promptLayer "${s}": a function layer resolves per turn and cannot be cached`);return{name:s,text:t,...e.cache?{cache:!0}:{}}}function Ay(s){let t=s.filter(l=>typeof l.text=="string"),e=s.filter(l=>typeof l.text=="function"),i=l=>typeof l.text=="function"?l.text():l.text,r=[...t,...e],n=r.map(i).filter(Boolean),o=[...t].reverse().find(l=>l.cache),a=r.map((l,h)=>({layer:l,text:n[h]??""})).filter(l=>l.text).map(l=>({type:"text",text:l.text,...l.layer===o?{cache_control:{type:"ephemeral"}}:{}}));return{text:n.join(`
|
|
544
|
+
`}#l(){let t=Array.isArray(this.integrations)?this.integrations:[],e=(this.#t||"").trim().toLowerCase(),i=this["status-filter"]||"all",r=t.filter(l=>!(!l||typeof l!="object"||i!=="all"&&String(l.status??"available")!==i||e&&![l.name,l.description,l.provider,l.category].map(c=>String(c??"").toLowerCase()).join(" ").includes(e))),n=this["group-by"]||"category";if(n==="none")return[{key:"__none__",label:"",items:r}];let o=[],a=new Map;for(let l of r){let c=String(n==="status"?l.status??"available":l.category??"Other")||"Other";a.has(c)||(a.set(c,[]),o.push(c)),a.get(c).push(l)}return o.map(l=>({key:l,label:n==="status"?this.#c(l):l,items:a.get(l)}))}#c(t){switch(t){case"available":return"Available";case"connected":return"Connected";case"error":return"Issues";case"pending":return"Connecting";case"coming-soon":return"Coming soon";default:return t||"Other"}}#h(){let t=Array.isArray(this.integrations)?this.integrations:[],i=this.#l().reduce((r,n)=>r+n.items.length,0);if(this.loading){this.removeAttribute("empty-search"),this.removeAttribute("empty-data");return}i===0&&t.length>0?(this.setAttribute("empty-search",""),this.removeAttribute("empty-data")):t.length===0?(this.setAttribute("empty-data",""),this.removeAttribute("empty-search")):(this.removeAttribute("empty-search"),this.removeAttribute("empty-data"))}#d=t=>{let e=t.target;if(!e||!e.closest)return;let i=e.closest('search-ui[data-part="search"]');if(!i||!this.contains(i))return;let r=String(t.detail?.value??i.value??"");this.#t=r,this.integrations=Array.isArray(this.integrations)?[...this.integrations]:[],this.#i&&clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{query:r.toLowerCase().trim()}}))},250)};#u=t=>{let e=t.target;if(!e||!e.closest)return;let i=e.closest('segmented-ui[data-part="filter"]');if(!i||!this.contains(i))return;let r=String(t.detail?.value??i.value??"all");this["status-filter"]!==r&&(this["status-filter"]=r,this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{status:r}})))}};customElements.get("integrations-page-ui")||customElements.define("integrations-page-ui",Mh);Lt();var Rh=class extends X{static get properties(){return{...X.properties,preferences:{type:Array,default:[]},channels:{type:Array,default:[]},channelEnabled:{type:Object,default:{}},loading:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},"group-by":{type:String,default:"none",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=new Map;#c=new Map;#h=new Map;#d=new Map;#u=new Map;#f=!1;#p=`np-h-${Math.random().toString(36).slice(2,8)}`;attributeChangedCallback(t,e,i){if(t==="preferences"||t==="channels"||t==="channelenabled"){let r=t==="channelenabled"?"channelEnabled":t;if(i==null)this[r]=r==="channelEnabled"?{}:[];else try{let n=JSON.parse(i);r==="channelEnabled"?this[r]=n&&typeof n=="object"&&!Array.isArray(n)?n:{}:this[r]=Array.isArray(n)?n:[]}catch{this[r]=r==="channelEnabled"?{}:[]}return}super.attributeChangedCallback?.(t,e,i)}connected(){if(super.connected(),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Notification preferences"),this.setAttribute("role","region"),!this.#t){if(this.hasAttribute("preferences")&&!Array.isArray(this.preferences))try{this.preferences=JSON.parse(this.getAttribute("preferences"))}catch{this.preferences=[]}if(this.hasAttribute("channels")&&!Array.isArray(this.channels))try{this.channels=JSON.parse(this.getAttribute("channels"))}catch{this.channels=[]}if(this.hasAttribute("channelenabled")&&(typeof this.channelEnabled!="object"||Array.isArray(this.channelEnabled)))try{this.channelEnabled=JSON.parse(this.getAttribute("channelenabled"))}catch{this.channelEnabled={}}this.#m(),this.#x(),this.#t=!0}tt(()=>this.render())}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(){let t={preferences:Array.isArray(this.preferences)?this.preferences:[],channelEnabled:this.channelEnabled&&typeof this.channelEnabled=="object"?this.channelEnabled:{}},e=JSON.stringify(t);this.value=e,this.internals.setFormValue(e)}render(){if(!this.#t)return;let t=Array.isArray(this.channels)?this.channels:[],e=Array.isArray(this.preferences)?this.preferences:[];e.length===0||t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.style.setProperty("--np-columns",`repeat(${Math.max(t.length,1)}, minmax(var(--notification-preferences-channel-width, var(--notification-preferences-channel-width-default)), auto))`),this.#g(t),(this["group-by"]||"none")==="group"?this.#y(e,t):this.#O(e,t),this.syncValue()}#m(){let t=document.createElement("div");t.setAttribute("data-part","header");let e=document.createElement("slot");e.setAttribute("name","header"),t.appendChild(e),this.appendChild(t),this.#i=t;let i=document.createElement("div");i.setAttribute("data-part","matrix"),i.setAttribute("role","table"),i.setAttribute("aria-labelledby",this.#p),this.appendChild(i),this.#s=i;let r=document.createElement("div");r.setAttribute("data-part","header-row"),r.setAttribute("role","row"),i.appendChild(r),this.#r=r;let n=document.createElement("div");n.setAttribute("data-part","body"),i.appendChild(n),this.#n=n;let o=document.createElement("div");o.setAttribute("data-part","empty");let a=document.createElement("slot");a.setAttribute("name","empty");let l=document.createElement("empty-state-ui");l.setAttribute("icon","bell"),l.setAttribute("heading","No notification types configured"),l.setAttribute("description","Add at least one notification type and one delivery channel to begin."),a.appendChild(l),o.appendChild(a),this.appendChild(o),this.#a=o;let h=document.createElement("div");h.setAttribute("data-part","footer");let c=document.createElement("slot");c.setAttribute("name","footer"),h.appendChild(c),this.appendChild(h),this.#o=h}#g(t){if(!this.#r)return;let e=this.#r.querySelector(":scope > [data-row-label]");e||(e=document.createElement("div"),e.setAttribute("role","columnheader"),e.setAttribute("data-row-label",""),e.id=this.#p,e.textContent="Notification",this.#r.appendChild(e));let i=new Set;for(let r of t){if(!r?.key)continue;i.add(r.key);let n=this.#h.get(r.key);n||(n=document.createElement("div"),n.setAttribute("role","columnheader"),n.setAttribute("data-channel-key",r.key),this.#r.appendChild(n),this.#h.set(r.key,n)),this.#b(n,r)}for(let[r,n]of this.#h)if(!i.has(r)){try{n.remove()}catch{}this.#h.delete(r),this.#d.delete(r)}for(let r of t){let n=this.#h.get(r.key);n&&this.#r.appendChild(n)}}#b(t,e){if(t.replaceChildren(),e.icon){let a=document.createElement("icon-ui");a.setAttribute("name",String(e.icon)),a.setAttribute("aria-hidden","true"),t.appendChild(a)}let i=document.createElement("span");i.setAttribute("data-channel-label",""),i.textContent=String(e.label||e.key),t.appendChild(i);let r=this.#d.get(e.key);r||(r=document.createElement("switch-ui"),r.setAttribute("size","sm"),r.setAttribute("data-channel-master",e.key),this.#d.set(e.key,r));let n=this.channelEnabled&&typeof this.channelEnabled=="object"?this.channelEnabled:{},o=Object.prototype.hasOwnProperty.call(n,e.key)?!!n[e.key]:!0;if(r.checked!==o){this.#f=!0;try{r.checked=o}finally{this.#f=!1}}r.setAttribute("aria-label",`Toggle ${e.label||e.key} for all rows`),this.disabled||this.loading?r.setAttribute("disabled",""):r.removeAttribute("disabled"),t.appendChild(r)}#O(t,e){if(!this.#n)return;for(let[,n]of this.#u)try{n.remove()}catch{}this.#u.clear();let i=new Set,r=new Set;for(let n of t){if(!n?.key)continue;i.add(n.key);let o=this.#v(n);this.#S(o,n,e,r)}for(let[n,o]of this.#l)if(!i.has(n)){try{o.remove()}catch{}this.#l.delete(n)}for(let[n,o]of this.#c)if(!r.has(n)){try{o.remove()}catch{}this.#c.delete(n)}for(let n of t){let o=this.#l.get(n.key);o&&this.#n.appendChild(o)}}#y(t,e){if(!this.#n)return;let i=[],r=new Map;for(let l of t){let h=String(l?.group??"Other")||"Other";r.has(h)||(r.set(h,[]),i.push(h)),r.get(h).push(l)}let n=new Set,o=new Set,a=new Set;for(let l of i){n.add(l);let h=this.#u.get(l);h||(h=document.createElement("div"),h.setAttribute("data-part","group-heading"),h.setAttribute("data-group",l),h.setAttribute("role","rowgroup"),this.#u.set(l,h)),h.textContent=l,this.#n.appendChild(h);for(let c of r.get(l)){if(!c?.key)continue;o.add(c.key);let u=this.#v(c);this.#S(u,c,e,a),this.#n.appendChild(u)}}for(let[l,h]of this.#l)if(!o.has(l)){try{h.remove()}catch{}this.#l.delete(l)}for(let[l,h]of this.#c)if(!a.has(l)){try{h.remove()}catch{}this.#c.delete(l)}for(let[l,h]of this.#u)if(!n.has(l)){try{h.remove()}catch{}this.#u.delete(l)}}#v(t){let e=this.#l.get(t.key);return e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-row-key",t.key),this.#n.appendChild(e),this.#l.set(t.key,e)),e}#S(t,e,i,r){let n=t.querySelector(':scope > [role="rowheader"]');n||(n=document.createElement("div"),n.setAttribute("role","rowheader"),t.appendChild(n)),n.replaceChildren();let o=document.createElement("span");if(o.setAttribute("data-row-label-text",""),o.textContent=String(e.label||e.key),n.appendChild(o),e.description){let l=document.createElement("span");l.setAttribute("data-row-description",""),l.textContent=String(e.description),n.appendChild(l)}let a=e.channels&&typeof e.channels=="object"?e.channels:{};for(let l of i){if(!l?.key)continue;let h=`${e.key}::${l.key}`;r.add(h);let c=t.querySelector(`:scope > [data-cell-key="${CSS.escape(h)}"]`);c||(c=document.createElement("div"),c.setAttribute("role","cell"),c.setAttribute("data-cell-key",h),t.appendChild(c));let u=this.#c.get(h);u||(u=document.createElement("check-ui"),u.setAttribute("data-row-key",e.key),u.setAttribute("data-channel-key",l.key),c.appendChild(u),this.#c.set(h,u));let d=!!a[l.key];if(u.checked!==d){this.#f=!0;try{u.checked=d}finally{this.#f=!1}}u.setAttribute("aria-label",`${e.label||e.key} via ${l.label||l.key}`),!!this.disabled||!!this.loading||!!e.disabled?u.setAttribute("disabled",""):u.removeAttribute("disabled")}for(let l of i){let h=`${e.key}::${l.key}`,c=t.querySelector(`:scope > [data-cell-key="${CSS.escape(h)}"]`);c&&t.appendChild(c)}}#x(){let t=e=>{if(this.#f)return;let i=e?.target;if(!i)return;let r=i.closest?.("switch-ui[data-channel-master]");if(r&&this.#s.contains(r)){let o=r.getAttribute("data-channel-master")||"";if(!o||this.disabled||this.loading)return;e.stopPropagation();let a=!!r.checked;this.dispatchEvent(new CustomEvent("bulk-toggle",{bubbles:!0,detail:{channel:o,enabled:a}}));return}let n=i.closest?.("check-ui[data-row-key][data-channel-key]");if(n&&this.#n.contains(n)){let o=n.getAttribute("data-row-key")||"",a=n.getAttribute("data-channel-key")||"";if(!o||!a||this.disabled||this.loading)return;e.stopPropagation();let l=!!n.checked;this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{row:o,channel:a,enabled:l}}));return}};this.#s.addEventListener("change",t),this.#e.push(()=>this.#s.removeEventListener("change",t))}};customElements.get("notification-preferences-ui")||customElements.define("notification-preferences-ui",Rh);var vy=["prompt-section","skill","workflow","resource","tool","pattern-source"];function xy(s){return s.filter(t=>t.enabled).sort((t,e)=>t.order-e.order)}function jC(s){return{order:0,enabled:!0,builtin:!0,...s}}function dq(s){return s.map((t,e)=>jC({order:e,...t}))}function Sy(s){if(!s.id)throw new Error('definePersona: "id" is required');if(!Number.isInteger(s.seedVersion)||s.seedVersion<1)throw new Error(`definePersona "${s.id}": seedVersion must be an integer >= 1, got ${s.seedVersion}`);let t=new Set;for(let e of s.entries){if(t.has(e.id))throw new Error(`definePersona "${s.id}": duplicate entry id "${e.id}"`);t.add(e.id)}return s}Lt();function FC(s){let t=ei(s),e=new Set;return{get value(){return t.value},set value(i){let r=!Object.is(t.peek(),i);if(t.value=i,r)for(let n of e)n(i)},peek(){return t.peek()},subscribe(i){return e.add(i),()=>e.delete(i)}}}function fq(){try{return typeof localStorage<"u"}catch{return!1}}function YC(s={}){let t=s.persistKey,e=!!t&&fq(),i={...s.initial??{}};if(e)try{let o=localStorage.getItem(t);o&&(i={...i,...JSON.parse(o)})}catch{}let r=FC([]);function n(){if(e)try{localStorage.setItem(t,JSON.stringify(i))}catch{}}return{get(o){return i[o]},set(o,a){if(!(o in i&&Object.is(i[o],a))){i={...i,[o]:a},n();for(let l of r.peek())l()}},subscribe(o){return r.peek().includes(o)||(r.value=[...r.peek(),o]),()=>{r.value=r.peek().filter(a=>a!==o)}}}}var WC="__seedVersion";function UC(s,t){return`entry.${s}.${t}`}function pq(s){let t={};for(let e of s.entries)t[UC(e.id,"enabled")]=e.enabled,t[UC(e.id,"order")]=e.order;return t}function wy(s,t={}){let i=(t.createStore??YC)({persistKey:`persona.${s.id}`}),r=pq(s);if(i.get(WC)!==s.seedVersion){for(let[o,a]of Object.entries(r))i.set(o,a);i.set(WC,s.seedVersion)}else for(let[o,a]of Object.entries(r))i.get(o)===void 0&&i.set(o,a);return i}function Ih(s,t,e={}){if(typeof t=="function"&&e.cache)throw new Error(`promptLayer "${s}": a function layer resolves per turn and cannot be cached`);return{name:s,text:t,...e.cache?{cache:!0}:{}}}function Ay(s){let t=s.filter(l=>typeof l.text=="string"),e=s.filter(l=>typeof l.text=="function"),i=l=>typeof l.text=="function"?l.text():l.text,r=[...t,...e],n=r.map(i).filter(Boolean),o=[...t].reverse().find(l=>l.cache),a=r.map((l,h)=>({layer:l,text:n[h]??""})).filter(l=>l.text).map(l=>({type:"text",text:l.text,...l.layer===o?{cache_control:{type:"ephemeral"}}:{}}));return{text:n.join(`
|
|
545
545
|
|
|
546
546
|
`),blocks:a}}function ky(s,t="memory"){if(s!==null)switch(typeof s){case"string":case"number":case"boolean":if(typeof s=="number"&&!Number.isFinite(s))throw new Error(`${t}: ${s} is not JSON-safe`);return;case"object":{if(Array.isArray(s)){s.forEach((i,r)=>ky(i,`${t}[${r}]`));return}let e=Object.getPrototypeOf(s);if(e!==Object.prototype&&e!==null)throw new Error(`${t}: ${s.constructor?.name??"object"} is not JSON-safe (plain objects only)`);for(let[i,r]of Object.entries(s))ky(r,`${t}.${i}`);return}default:throw new Error(`${t}: ${typeof s} is not JSON-safe`)}}var mq=0;function Ey(s){return{id:s??`s_${Date.now().toString(36)}_${++mq}`,messages:[]}}function gq(s){return JSON.stringify(s)}function bq(s){let t=JSON.parse(s);if(!t||typeof t.id!="string"||!Array.isArray(t.messages))throw new Error("Not a serialized Session: expected { id, messages[] }");return t}var HC="This persona configures the agent; it never overrides the harness grammar that precedes it.",Oq={skill:"Skills",workflow:"Workflows",resource:"Resources","pattern-source":"Pattern sources",tool:"Tools"};function yq(s){return Oq[s]??s}function vq(s,t){let e=t.map(i=>`### ${i.label}
|
|
547
547
|
${i.content}`).join(`
|